Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Scott Reynen http://randomchaos.com/source/

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

Apache log anonymizer

   1  
   2  /**
   3  * Takes Apache log file at $log_path, hashes the client address, and 
   4  * writes the file to $output_path. Useful for sharing log files without 
   5  * compromising user privacy. Reads input line-by-line to handle very 
   6  * large logs.
   7  *
   8  * @version 1.0
   9  * @author Scott Reynen
  10  * @copyright Scott Reynen 2006
  11  * @link http://httpd.apache.org/docs/1.3/logs.html#accesslog
  12  */
  13  
  14  $log_path = '';
  15  $output_path = '';
  16  
  17  $file = fopen( $log_path , 'r' );
  18  $output = fopen( $output_path , 'a' );
  19  
  20  while ( ! feof( $file ) ) 
  21  {
  22  
  23  	$line = fgets( $file , 8192 );
  24  	$space = strpos( $line , ' ' );
  25  	$out_line = md5( substr( $line , 0 , $space ) );
  26  	$out_line.= substr( $line , $space );
  27  	fwrite( $output , $out_line );
  28  
  29  } // while
  30  
  31  fclose( $file );
  32  fclose( $output );
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS