Posted By

lfatr on 02/16/10


Tagged

log


Versions (?)

SAVE USER ACTIVITY TO TEXT FILE, READING LOG FILE


 / Published in: PHP
 

URL: http://www.dreamincode.net/code/snippet3449.htm

  1. Function LogUserActivity($LogFile, $Activity){
  2.  
  3. $UserIp = $_SERVER['REMOTE_ADDR'];
  4. $TimeRef = date('d-m-Y H:i T');
  5.  
  6. $Handle = fopen($LogFile, 'a');
  7. $Data = $UserIp.'|'.$TimeRef.'|'.$Activity.'~';
  8. fwrite($Handle, $Data);
  9. fclose($Handle);
  10.  
  11. }
  12.  
  13. Function ReadUserActivity($LogFile){
  14.  
  15. GLOBAL $log;
  16.  
  17. $LogFile = file_get_contents($LogFile);
  18.  
  19. $ExplodedLogFile = explode("~", $LogFile);
  20.  
  21. $ArrayNum = count($ExplodedLogFile);
  22.  
  23. $i = 0;
  24.  
  25. while ( $i <= $ArrayNum ){
  26.  
  27. $log[$i] = explode("|", $ExplodedLogFile[$i]);
  28. $i++;
  29. }
  30.  
  31. }

Report this snippet  

You need to login to post a comment.