I need to know, where from is my script used (it's for sale, and i don't want any thiefs). I want to write on my server in file, IP of user, domain where from script has been runned, date, etc. I've tried fopen, fwrite, but is_file_writable returned that it isn't. File CHmods are 777, it parent catalog has too 777 chmods.
Now i'm trying something like that:
<?php
$file = 'http://www.misiur.com/security/seal.txt';
$data = date("Y-m-d H:i:s");
$ip = $_SERVER['REMOTE_ADDR'];
$svr = $_SERVER['SERVER_NAME'];
$str = "[$data] Loaded by $ip at $svr
";
$current = file_get_contents($file);
$current .= $str;
file_put_contents($file, $current);
?>
However - nothing happens. What i've got to do?
The HTTP URL wrapper doesn't allow writing.
The best way to do this would be having a script on the remote server's end (in your example, misiur.com
:
http://www.misiur.com/security/write_seal.php
Send the contents of the new text file to that script using POST. The script would then file_put_contents()
the received information locally.
Here's a code snippet that allows you to send POST contents to remote scripts easily. You will need POST because GET is usually limited in size to 1-2 kilobytes.
Of course, you would need to secure that script somehow to prevent malicious use, e.g. through a .htaccess
based password protection or a passkey.