Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Discussion: Online Status Indicator w/ PHP script

Aster Lardner
Registered User
Join date: 14 Nov 2005
Posts: 72
07-08-2006 21:16
I was gunna try and sell this, but I can't think of a good way to sell it without hosting scripts.

So if you end up using this, please be nice and tip me at least a quarter's worth of lindens ~75L.

It is basically your standard green/red online indicator prim. However, this updates a php script to copy an image in the same folder as your PHP script (online.gif or offline.gif) into a folder caled 'status' (might need to make this folder and chmod it 777) as well as writes a small status.txt file to the same folder with the word offline or online that can be included into your site/blog/forum posts using the information at this url:

All you have to do is...
  1. Save the php file to your server
  2. Create and save an online and offline image (.gif, .jpg, or . png)
  3. Upload it to the same folder as the php script
  4. make a subfolder in the same folder as the php script and name it 'status'
  5. Chmod it 777 is necesary
  6. save the lsl script onto a prim in-world you want to use as a status indicator
  7. copy the php file's URL to that prim's description
  8. reset the script
  9. Incporporate the status.txt into and status/status.gif into your site

Status.php file:

////// Simple PHP/LSL Status Updater///////////
// To Install:
// 0. Edit the following $Timer variable to match how oen in seconds you want your indicator to be updated.
// 1. Copy this script (status.php), a gif/jpg/png image named "online" and "offline" to your server.
// 2. In the same folder as the script create a folder named "status" and if applicable chmod it 777.
// 3. Copy and paste the URLof this script into the description of the online status indicator in-world.

$Timer = 300; //Five Minutes.

if($_POST) {
$Input = $_POST;
} else {
$Input = $_GET;
if ($Input['status'] == "Online") {
$status = "Online";
} else {
$status = "Offline"; //We don't want to pass funky status.

if (is_dir("status") == FALSE) {
if (@mkdir("status", 0777) == FALSE) {
echo "Error-- could not create 'status' folder. Please create it in the same folder as status.php and chmod it 777.";

$fp = @fopen("status/status.txt", "w"); //Open file, write
$fw = @fwrite( $fp, $status ); // Write the content on the file
@fclose( $fp ); // Close the file after writing
@chmod("status/status.txt", 0777);
if (!$fw)
echo "Failed to write status.txt...\n";
if ($status == "Online") {
if (is_file('online.gif')) {
$file = "online.gif";
$ext = ".gif";
if (is_file('online.jpg')) {
$file = "online.jpg";
$ext = ".jpg";
if (is_file('online.png')) {
$file = "online.png";
$ext = ".png";
else echo "Online image no found in same folder as status.php.";
} else {
if (is_file('offline.gif')){
$file = "offline.gif";
$ext = ".gif";
if (is_file('offline.jpg')){
$file = "offline.jpg";
$ext = ".jpg";
if (is_file('offline.png')){
$file = "offline.png";
$ext = ".png";
else echo "Offline image no found in same folder as status.php.";
$copy = copy($file, 'status/status'.$ext);
if (!$copy) {
echo "Failed to copy $file...\n";

if($fw && $copy) echo $Timer;
else echo "Error-- could not set status.";




integer gIsOnline = FALSE;
integer gLandOwner = FALSE;
key gKey = NULL_KEY;
string gName = "";
key requestid;
string owner;

updateStatus(string s){
key k = llGetLandOwnerAt(llGetPos());
gIsOnline = TRUE;
gIsOnline = FALSE;


key getWhom(){
if(gKey == NULL_KEY){
return llGetLandOwnerAt(llGetPos());
return llGetOwner();
return gKey;


on_rez(integer n){
owner = llKey2Name( llGetOwner());
dataserver(key req, string data){
if(data == "1" || data == "0"){
gName = data;
llSetText("Getting online status for " + gName,<1,1,1>,1);
llSetText(owner + "\nis Online",<1,1,1>,.25);
llSetPrimitiveParams([PRIM_POINT_LIGHT, TRUE, <0, 1, 0>, 1.0, 3.0, 0.75]);
if (llGetObjectDesc() != "Paste URL of Status.php here!")
requestid = llHTTPRequest(llGetObjectDesc() + "?status=Online",[HTTP_METHOD,"GET"],"");
llSetText(owner + "\nis Offline",<1,1,1>,.25);
llSetPrimitiveParams([PRIM_POINT_LIGHT, TRUE, <1, 0, 0>, 0.25, 3.0, 0.75]); if (llGetObjectDesc() != "Paste URL of Status.php here!")
requestid = llHTTPRequest(llGetObjectDesc() + "?status=Offline",[HTTP_METHOD,"GET"],"");

http_response(key request_id, integer status, list metadata, string body)
if (status == 404) {
llOwnerSay("The URL you entered into the description box appears to be incorrect. The server was found, but the script wasn't.");
UPDATE_INTERVAL = (float)body;

It wouldn't be that hard to expand this a bit and use the indicator as a in-world server for a HUD that gets your info (location, status, ect) if you're creative.

Its set up so the web server defines how often the status gets checked.
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Original Thread
07-12-2006 20:39
i've got nothing. ;)