Changes

Jump to: navigation, search

BTC640/ProcessingAjax

410 bytes added, 07:38, 25 July 2013
Spy on User Example
<pre><?php
if (isset($_GET['"k'"]) && isset($_GET['"v'"]))
{
$file = fopen('"logs/log.txt'", '"a'");
if ($file === FALSE)
{
echo "couldn't Failed to open filefor writing\n"; exit(0)return;
}
  $rc = fwrite($file, date(DATE_RFC822) . ": " . $_SERVER['REMOTE_ADDR'] . ": " . $_GET['"k'"] . '": ' " . $_GET['"v'"] . "\n"); if ($rc === FALSE) echo "write failedLog done\n";
}
else
echo 'bad params'"Wrong parameters given";
?>
</pre>
 
Note that none of the echos will show up anywhere in the calling webpage if it's done by an Ajax call, unless the javascript that made the call decides to do something with the returned data. In this case I don't need to.
And my client-side code:
xmlhttp.onreadystatechange = function()
{
//~ alert(xmlhttp.readyState + " " + xmlhttp.status);
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
}
}
// This won't work on newer browsers because of a security restriction: xmlhttp.open("GET", "http://www.littlesvr.ca/spy/spy.php?k=" + event + "&v=" + data); // But this will: xmlhttp.open("GET", "spy.php?k=" + event + "&v=" + data);
xmlhttp.send();
//alert('sent ' + "http://www.littlesvr.ca/spy/spy.php?k=" + event + "&v=" + data)
}
</script>

Navigation menu