Change font size
It is currently Mon Nov 19, 2018 10:17 am

Forum rules


{L_IMAGE}



Post a new topicPost a reply Page 1 of 1   [ 4 posts ]
Author Message
 Post subject: Visitor List with Emailing Capabilities
PostPosted: Wed Dec 10, 2008 6:36 pm 
Site Admin
User avatar

Joined: Sat Feb 02, 2008 5:27 pm
Posts: 843
I have just begun testing the smtp module for opensim, you can find details here on how to enable smtp for your simulator and get "llEmail" working for you:

SMTP Section (Experimental) This section is used if you want your region can use llEmail (experimental) function. To enable the function you must enabled the module in [Startup] section of your OpenSim.ini:

[Startup]
emailmodule = DefaultEmailModule

and then:

[SMTP]
enabled = true
host_domain_header_from = <domain name of grid or server, e.g. opensimulator.org, osgrid.org>
SMTP_SERVER_HOSTNAME = <smtp server>
SMTP_SERVER_PORT = <port number>
SMTP_SERVER_LOGIN = <login for smtp server>
SMTP_SERVER_PASSWORD = <password for smtp server>

once you get SMTP setup the following Visitor list will send you an email to your email address with visitor list totals everytime you type "say list". This is very rough use of email, mostly just an example of what can be done.

{L_CODE}:
// Global variables
list visitor_list;
float range = 10.0; // in meters
float rate = 1.0; // in seconds
string email_address = "user@email.com";
string date;
string region_name;

// Functions
integer isNameOnList( string name )
{
    integer len = llGetListLength( visitor_list );
    integer i;
    for( i = 0; i < len; i++ )
    {
        if( llList2String(visitor_list, i) == name )
        {
            return TRUE;
        }
    }
    return FALSE;
}

// States
default
{
    state_entry()
    {
        llSay(0, "Visitor List Maker started...");
        llSay(0, "The owner can say 'help' for instructions.");
        llSensorRepeat( "", "", AGENT, range, TWO_PI, rate );
        llListen(0, "", llGetOwner(), "");
    }
     
               
    sensor( integer number_detected )
    {
        integer i;
        for( i = 0; i < number_detected; i++ )
        {
            if( llDetectedKey( i ) != llGetOwner() )
            {
                string detected_name = llDetectedName( i );
                if( isNameOnList( detected_name ) == FALSE )
                {
                    visitor_list += detected_name;
                }
            }
        }   
    }
   
    listen( integer channel, string name, key id, string message )
    {
        if( id != llGetOwner() )
        {
            return;
        }
       
        if( message == "help" )
        {
            llSay( 0, "This object records the names of everyone who" );
            llSay( 0, "comes within "+ (string)range + " meters." );
            llSay( 0, "Commands the owner can say:" );
            llSay( 0, "'help'  - Shows these instructions." );
            llSay( 0, "'say list'   - Says the names of all visitors on the list.");
            llSay( 0, "'reset list' - Removes all the names from the list." );
        }
        else
        if( message == "say list" )
        {
            date = llGetDate();
            region_name = llGetRegionName();
            llSay( 0, "Visitor List:" );
            integer len = llGetListLength( visitor_list );
            integer i;
            for( i = 0; i < len; i++ )
            {
                llSay( 0, llList2String(visitor_list, i) );
                //llEmail(email_address, "visitor list", llList2String(visitor_list, i));
            }
            llSay( 0, "Total = " + (string)len );
            llEmail(email_address, "Visitor list totals for " + region_name + " on " + date , "Total = " + (string)len);
        }
        else
        if( message == "reset list" )
        {
            visitor_list = llDeleteSubList(visitor_list, 0, llGetListLength(visitor_list));
            llSay( 0, "Done resetting.");
        }
    }       
}


Top
 Profile  
 
 Post subject: Re: Visitor List with Emailing Capabilities
PostPosted: Wed Dec 10, 2008 6:39 pm 
Site Admin
User avatar

Joined: Sun Feb 03, 2008 9:10 am
Posts: 48
Location: Suburbia Americana in the Houston Texas area
W00T!!!

Excellent work Nebadon :D


Cheers
daTwitch

_________________
http://opensimulator.org http://osgrid.org http://simhost.com
---------------------------------------------------------------------------------------------------------------------------
The wind
scours the earth for prayers
The night obscures them


Top
 Profile  
 
 Post subject: Re: Visitor List with Emailing Capabilities
PostPosted: Thu Dec 18, 2008 1:30 pm 
Furious Typer
User avatar

Joined: Sun Aug 31, 2008 4:34 pm
Posts: 107
Thought I'd add this mess to the mix after doing a dev mail.
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 indentation on forum copy and the needed modifications in comments)

LSL
{L_CODE}:
//Bri logger V-OS-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://ol.ippy.us/baya-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)
}



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

<HTML>
<HEAD>
   <TITLE>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("visits.txt", "a");
fputs($fp, $data_line);
fclose($fp);
?>
</BODY>
</HTML>

The resultant log file example, (start with a blank file). set perms to r-w or 777
-------------------------------------start visits.txt
Sun, 18 Dec 2008 01:00:27 +0000 - IP: 71.6.163.177 | name: Bri Hasp | key: 0a83a315-a4d2-498b-aeb4c9172754a6f0 | object: Greeter Mat
-------------------------------------end visits.txt

If your flavor of PHP gets pissed off by fputs then use. also plopped a path.
{L_CODE}:
$fp = fopen("/path/to/logfile/visits.txt", "a");
fwrite($fp, $data_line);
------------------------------------END


Top
 Profile  
 
 Post subject: Re: Visitor List with Emailing Capabilities
PostPosted: Thu Dec 18, 2008 3:13 pm 
Site Admin
User avatar

Joined: Sat Feb 02, 2008 5:27 pm
Posts: 843
very nice, hope you dont mind i reformatted your posting a bit to make it easier to select the code from the message itself.

Neb :ugeek:


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 1   [ 4 posts ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
610nm Style by Daniel St. Jules of Gamexe.net