Tuesday, December 02, 2008
USERLOGIN PASSWORD Remember?
You are here » Learning Center ยป Forums

Openlife Forums

 Openlife Grid Forums
Minimize
 
  Openlife Forums  Scripting  Openlife LSL Ex...  A 'No-Load' visitor logger
Previous Previous
 
Next Next
New Post 8/24/2008 3:08 AM
User is offline Bri
7 posts
Openlife Newbie


A 'No-Load' visitor logger 
Modified By Bri  on 8/24/2008 3:31:23 AM)

This Visitor log may seem complex but it is very basic.  It uses a http web server to avoid loading resources on your region.
The LSL collision method is chosen to avoid timer based Av scanner loads.
The web based visitor list can easily be emailed or applied to another dynamic web application.

Just take this LSL script and drop it into a "welcome mat" prim.
(note the needed modifications in comments)

-----------------------------------start LSL
//Borne logger V-OL-01
string last_visitor = "";

default
{
 
    state_entry()
    {
        llSetAlpha(0,ALL_SIDES); //comment out when using a textured prim
    }
 
    collision_start(integer num)
    {
        integer i;
 
 
        for (i = 0; i < num; i++)
        {
            string name = llDetectedName(i);
            if (name != last_visitor)
            {
                string url = "http://sl.ippy.us/borne-visitor.php?";//CHANGE URL
                url += "name=" + llEscapeURL(name);
                url += "&key=" + llEscapeURL((string)llDetectedKey(i));
                url += "&object=" + llEscapeURL(llGetObjectName());
 
                llHTTPRequest(url ,[HTTP_METHOD,"GET"],"");
                last_visitor = name;
            }
        }
    }
 
    http_response(key id,integer status, list data, string body)
}

-----------------------------------end LSL

PHP example file. set perms to 755
------------------------------------start PHP
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

<HTML>
<HEAD>
   <TITLE>Borne Visitor Logger</TITLE>
</HEAD>
<BODY LINK="#FFFFFF" VLINK="#000000">
<?php
$name = htmlspecialchars($_GET['name']);
$object = htmlspecialchars($_GET['object']);
$key = htmlspecialchars($_GET['key']);
$ip = $_SERVER['REMOTE_ADDR'];
$ref = $_SERVER['HTTP_REFERER'];
$dtime = date('r');
}
if($name == ""){
   $name = "nameless";
}
if($ref == ""){
   $ref = "None";
}

?>
Hello <?php echo  $name ?>.
thank you for visiting.
<?php
$data_line = "$dtime - IP: $ip | name: $name | key: $key | object: $object\n";
$fp = fopen("borne-visits.txt", "a");
fputs($fp, $data_line);
fclose($fp);
?>
</BODY>
</HTML>
-------------------------------------end PHP

The resultant log file example, (start with a blank file). set perms to r-w or 777

-------------------------------------start borne-visits.txt
Sun, 24 Aug 2008 01:00:27 +0000 - IP: 71.6.163.177 | name: Bri Hasp | key: 0a83a315-a4d2-498b-aeb4-c9172754a6f0 | object: Greeter Mat
-------------------------------------end

 


RL..now with 100% less lag!
 
New Post 10/14/2008 1:44 AM
Online now... Digital Dreambuilder
104 posts
Openlife Handyman




Re: A 'No-Load' visitor logger 

Thanks for this Bri. Oddly, 'fputs' wouldn't work for my installation. Changing to fwrite( ) did.

 

I also moved the log file to a directory outside webpace to avoid having the directory in which the script resides writable by anyone.

...
$fp = fopen("/path/to/logfile/oro-visitors-log.txt", "a");
fwrite($fp, $data_line);
...

 


The Danaus Foundation .. coming soon
 
Previous Previous
 
Next Next
  Openlife Forums  Scripting  Openlife LSL Ex...  A 'No-Load' visitor logger
Privacy Statement | Terms Of UseAll Rights Reserved 2007,2008 3DX - Openlifegrid.com