antonvrg

PHP Logger

Aug 23rd, 2011
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.72 KB | None | 0 0
  1. <?php
  2. /* PHP logging script by antonvrg Feel free to modify this or use it however you want.
  3.  * to use this put the file (yes this one) in a directory where it is accessible (eg. www or public_html).
  4.  * put <?php include('stats.php'); ?> in all pages to log visitors. (change stats.php to the file name).
  5.  * you should only need to edit $logfile.
  6.  * enjoy!
  7. */
  8.  
  9. //get info
  10. $logfile = '../main.log';
  11. $ip = $_SERVER['REMOTE_ADDR'];
  12. $url = $_SERVER['REQUEST_URI'];
  13. $server = $_SERVER['SERVER_NAME'];
  14. $port = $_SERVER['SERVER_PORT'];
  15. $time = date('l jS \of F Y h:i:s A');
  16. $data = "$ip $server$url :$port       $time \n";
  17. $handle = fopen($logfile, 'a');
  18.  
  19. //writes to the file
  20. fwrite($handle, $data);
  21. fclose($handle);
  22.  
  23. ?>
Advertisement
Add Comment
Please, Sign In to add comment