View Single Post
Old 08-19-2007, 02:27 AM   #6
Osgeld Barmy
Registered User

Join Date: Mar 2005
Posts: 2,587
heres a simple "flat file" (stuff written in a text file on my server) guest book

in the lsl side of things its pretty simple
Quote:
string url = "http://cheesefactory.us/searchdata.php?search=";
string current_av = "";

end() // end routine - user defined function
{
current_av = "";
llSetTimerEvent(0);
}

default
{
touch_start(integer total_number)
{
if (current_av == "")
{
current_av = llDetectedName(0);
llSetTimerEvent(10);
// send data to the webpage
llHTTPRequest(url + current_av,[HTTP_METHOD,"GET"],"");
}
}
// get data back and process it
http_response(key request_id, integer status, list metadata, string body)
{
if (body == "Error: Cannot open file.")
{
llOwnerSay(body + " please check your webserver and logfile");
}

else if (body == "on list")
{
llSay(0,"You are already in the guestbook " + current_av);
}

else if (body == "new user added")
{
llSay(0,"Thank you signing my guestbook " + current_av);
}

end();
}

timer()
{
llSay(0,"server timeout, please try again in a moment");
end();
}
}


on the webserver ive got ... (in php)

Quote:
<?php
$filename = "userlog.dta";
$search = $_GET["search"];
$user_data = file($filename);

// trim whitespace from the strings
for($x = 0; $x < count($user_data); $x++)
{
$user_data[$x] = trim($user_data[$x]);
}
// see if its in the file
$on_list = array_search($search,$user_data);

if ($on_list != "")
{
echo "on list";
}
// if its not write the name in the file
else
{
$fp = fopen($filename,"a");

// if your server cannot access the file error
// almomst any php server can make a file if one does not exist
// even if your server will not create a file for you
// you can place an empty file for the script to use
// you really have to screw up to get this error
if(!$fp)
{
echo "Error: Cannot open file.";
exit;
}

fwrite($fp,$search."\n");
fclose($fp);
echo "new user added";
}
?>


now the only security is the fact noone knows exactly where to look (till now) and if this still existed on my website there would be nothing to stop anyone from putting

cheesefactory.us/searchdata.php?search=Osgeld Barmy
or
cheesefactory.us/searchdata.php?search=JACK ASS

into their browser and adding something to my text file so this is very simplistic and totally unadvised for anything but a learning experiance
Osgeld Barmy is offline Report Bad Post   Reply With Quote