'Name to write into log', $users = array( // array of user agents and names to search for. 'googlebot'=>'Google Bot', // add new ones between here // and here - keep the comma on the end 'yahoo'=>'Yahoo Bot' ); $logfile = "log.txt"; // the log file // end config function sactivity (){ // the user-agent checking function global $users; // array is outside the function, so declair it as global foreach($users as $search=>$name) { // start the loop through the array if(strstr(strtolower($_SERVER['HTTP_USER_AGENT']),$search)) { // is the search string in the user agent? logit("$name activity found"); // yep, lets log it! } } // next... } function logit($text) { // simple function to log the time and some text. global $logfile; $h = fopen("$logfile","a"); fputs($h,date("r")." -> $text"); fclose($h); } ?>