How to Log PHPRoxy Users

Posted by Vectro 18 July 2010

If you are comfortable modifying code, here is a quick cut-and-paste code tweak for PHProxy which logs the sites your users visit. This can come in handy to track misuse and block users which is important for keeping your script under control. It is usually a good idea to backup your index.php file before making any changes to it.

Step 1: Open up index.php in the editor of your choice:

Step 2: Find this line 2-line block of code:

function url_parse($url, & $container)
{

and put this underneath it:

/* Begin Logging
*/

$proxytime = date(‘h:i:s A’);
$proxydate = date(‘d-m-Y’);
$stuff = $_SERVER[‘REMOTE_ADDR’].”,”.$url.” , “.$proxydate.” , “.$proxytime.”\n”;
$fp = fopen(‘log.txt’,”a”);
fwrite($fp,$stuff);
fclose($fp);

/* End Logging
*/

Step 3: Put a blank file named ‘log.txt’ into your public_html directory so the script can write to it. Later on, you can download this file or view it on the web by going to http://www.yourdomain.com/log.txt and replace yourdomain.com with your actual domain name.

This will log all of the sites your users visit in CSV format. Like this:

<IP ADDRESS>,<URL> , <DATE> , <TIME>

It is a good idea to clear your log files every so often as they can increase in size and use up your disk space fast.

Get shared proxy hosting on a specially configured server and have this tweak done for you! Click here to find out more.

Sorry, comments are closed.

Previous Post
«
Next Post
»