Re: log analysis

From: Date: Fri, 10 May 2002 23:33:56 +0000
Subject: Re: log analysis
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-97037@lists.php.net to get a copy of this message
Thanks for replying Miguel I'm new to php and wonder how I would check if the first field is an IP address. Do I open the file fget it and then use a regular expression to check. Also if I want to break up the first line of my array what delimiter do I look at as the fields in the log are seperated by spaces. J "Miguel Cruz" <mnc@stoic.net> wrote in message news:Pine.LNX.4.44.0205101321370.2680-100000@stoic.net... > On Fri, 10 May 2002, Josh Edwards wrote: > > I'm working on using php to analyse an access log on an apache server. > > > > If a user inputs a file path I want to be able to use PHP to determine if > > it's a log file. Is there a function that will reject if it's not a binary > > file. If it's a binary file how would I then > > compare it to whats expected in a log file. > > 1. Apache logs are text files. > > 2. The difference between a binary file and a text file is not something > that can be observed, only declared. Well, it can be observed by humans, > but not by machines. Who knows how picky a given application is going to > be about line endings? Who knows what text encodings are valid in the > context? > > 3. The format for Apache log files depends on the configuration of the > server (directives like LogFormat). > > 4. If you know the configuration of the server, then it's trivial to > determine whether you have a valid log file. If the first column is > supposd to be an IP address, check for an IP address. If the fourth column > is supposed to be a date, check for a date. > > miguel >

« previous php.general (#97037) next »