Guest User

Untitled

a guest
Jun 20th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 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. $today = date("Y_m_d");
  18. $logfile = $today."_log.txt";
  19. $dir = 'logs';
  20. $saveLocation=$dir . '/' . $logfile;
  21. if (!$handle = @fopen($saveLocation, "a")) {
  22. exit;
  23. }
  24. else {
  25. if (@fwrite($handle,"$msg\r\n") === FALSE) {
  26. exit;
  27. }
  28.  
  29. @fclose($handle);
  30. }
  31. }
  32.  
  33. ?>
Add Comment
Please, Sign In to add comment