Difference between revisions of "Visitor Logger (Web/Basic)"
m (<lsl> tag to <source>) |
|||
(4 intermediate revisions by 2 users not shown) | |||
Line 27: | Line 27: | ||
'''Serverside script:''' | '''Serverside script:''' | ||
< | <source lang="php"> | ||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> | ||
<HTML> | <HTML> | ||
Line 52: | Line 52: | ||
thank you for visiting. | thank you for visiting. | ||
<?php | <?php | ||
$entry_line = "$dtime - IP: $ip | name: $name | object: $object\n"; | $entry_line = "$dtime - IP: $ip | name: $name | key: $key | object: $object\n"; | ||
$fp = fopen("visitors.txt", "a"); | $fp = fopen("visitors.txt", "a"); | ||
fputs($fp, $entry_line); | fputs($fp, $entry_line); | ||
Line 62: | Line 62: | ||
</HTML> | </HTML> | ||
</ | </source> | ||
The text file, "visitors.txt" must have write permissions. | |||
'''LSL script:''' | '''LSL script:''' | ||
< | <source lang="lsl2"> | ||
// Copyright (c) Daniel Livingstone 2008 | // Copyright (c) Daniel Livingstone 2008 | ||
// Released under GNU Public License GPL 3.0 | // Released under GNU Public License GPL 3.0 | ||
string | string lastVisitor; | ||
default | default | ||
{ | { | ||
state_entry() | state_entry() | ||
{ | { | ||
llSetAlpha( | llSetAlpha((float)FALSE, ALL_SIDES); | ||
llVolumeDetect(TRUE); | llVolumeDetect(TRUE); | ||
} | } | ||
collision_start(integer | collision_start(integer num_detected) | ||
{ | { | ||
integer i; | integer i; | ||
do | |||
{ | { | ||
key id = llDetectedKey(i); | |||
string name = llDetectedName(i); | string name = llDetectedName(i); | ||
if (name != | |||
if (name != lastVisitor) | |||
{ | { | ||
string url = "http://www.YOURSITE.URL/get_data.php?" | string url = "http://www.YOURSITE.URL/get_data.php?" | ||
+ "name=" + llEscapeURL(name) | |||
+ "&key=" + llEscapeURL((string)id) | |||
+ "&object=" + llEscapeURL(llGetObjectName()); | |||
llHTTPRequest(url ,[ | llHTTPRequest(url, [], ""); | ||
lastVisitor = name; | |||
} | } | ||
} | } | ||
while (++i < num_detected); | |||
} | } | ||
http_response(key request_id, integer status, list data, string body) | |||
http_response(key | |||
{ | { | ||
//llOwnerSay(body); | //llOwnerSay(body); | ||
Line 108: | Line 107: | ||
} | } | ||
} | } | ||
</ | </source> | ||
[[Category:LSL Library|Visitor Logger (Web/Basic)]] | [[Category:LSL Library|Visitor Logger (Web/Basic)]] |
Latest revision as of 10:18, 25 January 2015
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
Notes
I was asked to log visitors for a two-day event a while ago, and then asked if the scripts I used could be given to original users. Being very simple scripts, I didn't want to charge for these, and so I've decided to make them public.
Licence info
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You can obtain a copy of the GNU General Public License from here: [1].
The software is copyright (c) Daniel Livingstone 2008
Use:
Upload the server side script to your web server, and place the LSL script a phantom prim in SL - the script will turn the prim invisible if it is not already. Ideal placement may be a small prim at waist height at a telehub, or at floor level covering a large area where users might walk through. You will need to edit the LSL script with the appropriate URL for your server.
Serverside script:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Simple Visitor Logger</TITLE>
</HEAD>
<BODY LINK="#0000FF" VLINK="#800080">
<?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($ref == ""){
$ref = "None";
}
if($name == ""){
$name = "anon";
}
?>
Hello <?php echo $name ?>.
thank you for visiting.
<?php
$entry_line = "$dtime - IP: $ip | name: $name | key: $key | object: $object\n";
$fp = fopen("visitors.txt", "a");
fputs($fp, $entry_line);
fclose($fp);
?>
</BODY>
</HTML>
The text file, "visitors.txt" must have write permissions.
LSL script:
// Copyright (c) Daniel Livingstone 2008
// Released under GNU Public License GPL 3.0
string lastVisitor;
default
{
state_entry()
{
llSetAlpha((float)FALSE, ALL_SIDES);
llVolumeDetect(TRUE);
}
collision_start(integer num_detected)
{
integer i;
do
{
key id = llDetectedKey(i);
string name = llDetectedName(i);
if (name != lastVisitor)
{
string url = "http://www.YOURSITE.URL/get_data.php?"
+ "name=" + llEscapeURL(name)
+ "&key=" + llEscapeURL((string)id)
+ "&object=" + llEscapeURL(llGetObjectName());
llHTTPRequest(url, [], "");
lastVisitor = name;
}
}
while (++i < num_detected);
}
http_response(key request_id, integer status, list data, string body)
{
//llOwnerSay(body);
//llOwnerSay("here!");
}
}