<?php // Copyright (C) 2006 Craig Spurrier // Released under the terms of the MIT/expat license. $serverip = "127.0.0.1"; //Set to your IP address or default hostname, so requests without hostnames can be sorted $log = file_get_contents("/var/log/lighttpd/access.log"); //Log location $fh = fopen("/var/log/lighttpd/access.log", 'w'); //Clear the log file fclose($fh); $lines = explode ("\n", $log); foreach ($lines as $line){ $parts = explode (" ", $line); $hostname = strtolower($parts[1]); if (substr($hostname, 0, 4) == 'www.'){$hostname = substr($hostname, 4);} //Treat www. as the same as the www-less version if ($hostname == '-'){$hostname = $serverip;} //Set a hostname for request without hostnames $fh = fopen("/var/log/lighttpd/users/$hostname.access.log", 'a'); //Add the entry to the log for that hostname. Make sure this script can write to this location. fwrite($fh, "$line\n"); fclose($fh); } ?>
You need to create an account or log in to post comments to this site.