#!/usr/local/bin/php // Change this to the fil you want to write to $HOME = "/home/projects/cortex/"; $logdir = "$HOME/public_html/logs/"; $username = "cortex"; // Creat logfile based on date (e.g. 2001-08.wwwlog ) $logfile = $logdir . date("Y-m") . ".wwwlog"; //Get remote variables $date = date("F j, Y, g:i a"); $user=""; if(isset($REMOTE_ADDR)) { $user=exec("/home/member/p/p/bin/w -n | grep " . escapeshellcmd($REMOTE_ADDR) . " | awk '{print \"\",$1}' |head -1"); } // Don't log if it's the person's own script if ($user != $username) { // Log stuff into a file $fp = fopen( $logfile,"a+"); fwrite ( $fp, $REMOTE_ADDR, 50); fwrite ( $fp, " -", 5); fwrite ( $fp, $user, 20); fwrite ( $fp, " - ", 5); fwrite ( $fp, $date, 50); fwrite ( $fp, " - ", 5); fwrite ( $fp, $DOCUMENT_URI, 5000); fwrite ( $fp, " - ", 5); fwrite ( $fp, $HTTP_REFERER, 5000); fwrite ( $fp, " - ", 5); fwrite ( $fp, $HTTP_USER_AGENT, 5000); fwrite ( $fp, "\n", 5); fclose( $fp ); } ?>