Advertisement
Atheuz

Untitled

Apr 14th, 2012
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.75 KB | None | 0 0
  1. ?php
  2.  
  3. //ASSIGN VARIABLES TO USER INFO
  4. $time = date("M j G:i:s Y");
  5. $ip = getenv('REMOTE_ADDR');
  6. $userAgent = getenv('HTTP_USER_AGENT');
  7. $referrer = getenv('HTTP_REFERER');
  8. $query = getenv('QUERY_STRING');
  9.  
  10. //COMBINE VARS INTO OUR LOG ENTRY
  11. $msg = "IP: " . $ip . " TIME: " . $time . " REFERRER: " . $referrer . " SEARCHSTRING: " . $query . " USERAGENT: " . $userAgent;
  12.  
  13. //CALL OUR LOG FUNCTION
  14. writeToLogFile($msg);
  15.  
  16. function writeToLogFile($msg)
  17. {
  18.      $logfile = "log.txt";
  19.      $saveLocation=$logfile;
  20.      if (!$handle = @fopen($saveLocation, "a"))
  21.      {
  22.           exit;
  23.      }
  24.      else
  25.      {
  26.           if(@fwrite($handle,"$msg\r\n")===FALSE)
  27.           {
  28.                exit;
  29.           }
  30.  
  31.           @fclose($handle);
  32.      }
  33. }
  34.  
  35. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement