![Quote](images/metro/blue/misc/quote_icon.png)
Originally Posted by
xiao-xiao
I think dili mn kaayo issue karon kung naka-enable ba ang javascript. rare ra mn kaayo ang mga ga-disabled ug javascript.
anyway, for me, I suggest server-side scripting.
Yup, there are only a few browsers now that does not support javascript. But not all clients of your webserver are browsers, you can never guess what's out there, for example if you serve binaries through http, such as the case of pdf files - they are not served through normal html, and hence google-analytics will not catch them (unless you do link forwarding). Or in the case for example of wget (command line tool to download files/pages through http). Or better yet - web services, they masquerade using http, through TLS or HTTPS. Google analytics will not be able to capture these kinds of traffic to your webserver. IMHO Google analytics is only good in tracking web pages.
For the TS, I only got an apache log analyzer in PHP, I got this script sometime ago, I couldn't trace where I got it or its original owner, I just have it in my script library. Its easy enough to understand, all you have to do is change the line which parses apache logs:
Code:
preg_match("/^(\S+) (\S+) (\S+) \[([^:]+):(\d+:\d+:\d+) ([^\]]+)\] \"(\S+) (.*?) (\S+)\" (\S+) (\S+) (\".*?\") (\".*?\")$/", $line, $matches); // pattern to format the line
to match IIS log format ... and the log file location (to where IIS log is located).
Here's the rest of the code:
Code:
<?php
class apache_log_parser
{
var $bad_rows; // Number of bad rows
var $fp; // File pointer
function format_log_line($line)
{
preg_match("/^(\S+) (\S+) (\S+) \[([^:]+):(\d+:\d+:\d+) ([^\]]+)\] \"(\S+) (.*?) (\S+)\" (\S+) (\S+) (\".*?\") (\".*?\")$/", $line, $matches); // pattern to format the line
return $matches;
}
function format_line($line)
{
$logs = $this->format_log_line($line); // format the line
if (isset($logs[0])) // check that it formated OK
{
$formated_log = array(); // make an array to store the lin info in
$formated_log['ip'] = $logs[1];
$formated_log['identity'] = $logs[2];
$formated_log['user'] = $logs[2];
$formated_log['date'] = $logs[4];
$formated_log['time'] = $logs[5];
$formated_log['timezone'] = $logs[6];
$formated_log['method'] = $logs[7];
$formated_log['path'] = $logs[8];
$formated_log['protocal'] = $logs[9];
$formated_log['status'] = $logs[10];
$formated_log['bytes'] = $logs[11];
$formated_log['referer'] = $logs[12];
$formated_log['agent'] = $logs[13];
return $formated_log; // return the array of info
}
else
{
$this->badRows++; // if the row is not in the right format add it to the bad rows
return false;
}
}
function open_log_file($file_name)
{
$this->fp = fopen($file_name, 'r'); // open the file
if (!$this->fp)
{
return false; // return false on fail
}
return true; // return true on sucsess
}
function close_log_file()
{
return fclose($this->fp); // close the file
}
function get_line($line_length=300)
{
return fgets($this->fp, $line_length); // true and get a line and return the result
}
}
$apache_log_parser = new apache_log_parser(); // Create an apache log parser
if ($apache_log_parser->open_log_file('example.log')) // Make sure it opens the log file
{
while ($line = $apache_log_parser->get_line()) { // while it can get a line
$parsed_line = $apache_log_parser->format_line($line); // format the line
print_r($parsed_line); // print out the array
}
$apache_log_parser->close_log_file(); // close the log file
}
else
{
echo 'Sorry cannot open log file.';
}
?>