Login   Register  
PHP Classes
elePHPant
Icontem

File: example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Paul Scott  >  Apache 2 log file parser  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: example script
Class: Apache 2 log file parser
Parse common log format files generated by Apache
Author: By
Last change:
Date: 7 years ago
Size: 763 bytes
 

Contents

Class file image Download
<?php

/**
 * Test script for the apache log parser class
 */

//include the class
require_once('apachelogparser_class_inc.php');

//The access log file
//you will want to change the path here :) and make sure that the logfile is readable by the www user (apache)
$file '/path/to/access.log';

//Instantiate the object
$log = new apachelogparser();

//get some stats about the file
$fstats $log->logfileStats($file);
var_dump($fstats);

$farr $log->log2arr($file);
//iterate through the array above and get the info we need from each line
foreach ($farr as $line)
{
    
//you would probably want to insert to a db or something here to do
    //datamining on the logfile, but here we will just print the output to browser
    
print_r($log->parselogEntry($line));
}
?>