1,234
edits
Changes
→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;
}
}
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>