|
Krull Aeon
Registered User
Join date: 13 May 2008
Posts: 4
|
10-23-2008 05:12
Hi there, I am trying to develop a simple stats tracker which sends GET or POST data to a PHP script where the PHP script grabs the data from the incoming URL encoded Data through the $_REQUEST(''); call.
Here is the LSL script I have come up with to date, any further help would be greatly appreciated, thank you.
*************LSL SCRIPT********************************
string send; string presend; key AVKey; string AVName; string Date;
default {
state_entry() { llSensorRepeat("", NULL_KEY, AGENT, 65, PI, 5); } sensor(integer total_number) {
AVKey = llDetectedKey(0); //Detects to get a raw key. AVName = llKey2Name(llDetectedKey(0)); //Detects to get a name. Date = llGetTimestamp(); float fps = llGetRegionFPS(); string region = llGetRegionName();
presend = ("?Date=" + (string)Date + "&AVName=" + (string)AVName + "&AVKey=" + (string)AVKey + "&Region=" + (string)region + "&FPS=" + (string)fps);
send = llEscapeURL(presend);
// Sends data to server. llHTTPRequest("http://www.atsi.ca/synergy/SLC/Counter.php", [HTTP_METHOD, "POST", HTTP_MIMETYPE, "application/x-www-form-urlencoded"], send);
} }
|
|
Haruki Watanabe
llSLCrash(void);
Join date: 28 Mar 2007
Posts: 434
|
10-23-2008 08:20
... seems right to me... what's the actual question? 
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
10-23-2008 11:38
You are going to need to escape EACH CGI peramaeter rather than the whole query string. llEscapeURL() escapes characters like '&' so that they can be used in the CGI parameter values, which is going to keep your parameter string from being parsed into individual parameters by the PHP engine on the server side. (Oh. I believe you also don't need the leading '?' if you are using POST) So I believe you're going to need something that looks more like: send = "Date="+llEscapeURL((string)Date)+ "&AVName="+llEscapeURL((string)AVName)+ "&AVKey="+llEscapeURL((string)AVKey)+ "&Region="+llEscapeURL(string)region)+ "&FPS="+llEscapeURL((string)fps);
If 'region' is ALWAYS going to be the region in which your script is running like you show in this example, you also shouldn't need to include it in the paramters, since llHTTPRequest() automatically includes that information in a HTTP "X-SecondLife-Region " header in the request (though you might have to do a little parsing in your PHP to strip off the positional data). See http://www.lslwiki.net/lslwiki/wakka.php?wakka=llHTTPRequest and http://www.php.net/manual/en/function.http-get-request-headers.php
|
|
Krull Aeon
Registered User
Join date: 13 May 2008
Posts: 4
|
10-23-2008 16:42
Thanks Hewee, thats great information to have on hand.
I didn't realize each set had to be escaped.
|