REQ: Raw log file generator script

This is a discussion on REQ: Raw log file generator script within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Anybody can tell me the full extend of Mattias Nilsson script? I mean that I want to create log files ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-27-2007
news
 
Posts: n/a
Default REQ: Raw log file generator script

Anybody can tell me the full extend of Mattias Nilsson script?
I mean that I want to create log files that will contain ALL POSSIBLE
information for every hit on a page (ex. user's ip, pages visited, time
spend, entry and exit page, browser type and version, operating system,
files accessed, type of files, if possible geographical and demographical
data etc etc).
Is there something out there? Or is somebody experienced enough to show the
code (sorry but I'm just an ignorant newbie).

Unless somebody can send me a better script to create log files. I need a
script to create my own raw log file because I rent hosting from a server
that does not give me the raw log data.

Regards

Gun Jah Man
gun@freemail.gr


p.s. Mattia's Script:

<?php

/*
* Common Logfile Format script.
*
* Author: Mattias Nilsson <mattias_at_coolt.nu>
*
*/

/* User definable variables */
$logfile = "clf.log"; /* Filename of log to write to */
$timezone = "+0100"; /* Timezone correction */
$lookup_size = true; /* Set to true to enable filesize lookup */
$document_root = "/usr/local/apache/share/htdocs";

/* A note about the lookup_size directive:
* This will make this script lookup the size of the original file on disk,
* which may or may not be the same amount of data sent to the client.
* It does give you a hint though..
* Oh, you have to set $document_root aswell if this should work..
*/

function write_to_log($str) {
if($fd = @fopen($GLOBALS[ "logfile"], "a")) {
fputs($fd, $str);
fclose($fd);
}
}

function get_var($name,$default) {
if($var = getenv($name)) {
return $var;
} else {
return $default;
}
}

if($remote_host = get_var( "REMOTE_HOST", true)) {
$remote_host = get_var( "REMOTE_ADDR", "-");
}
$remote_user = get_var( "REMOTE_USER", "-");
$remote_ident = get_var( "REMOTE_IDENT", "-");
$server_port = get_var( "SERVER_PORT", 80);
if($server_port!=80) {
$server_port = ":" . $server_port;
} else {
$server_port = "";
}
$server_name = get_var( "SERVER_NAME", "-");
$request_method = get_var( "REQUEST_METHOD", "GET");
$request_uri = get_var( "REQUEST_URI", "");
$user_agent = get_var( "HTTP_USER_AGENT", "");
if($lookup_size == true && $document_root) {
$filename = ereg_replace( "\?.*", "", $request_uri);
$filename = "$document_root$filename";
if(!$size = filesize($filename)) {
$size = 0;
}
} else {
$size = 0;
}

$date = gmdate( "d/M/Y:H:i:s");
$log = "$remote_host $remote_ident $remote_user [$date $timezone] \"".
"$request_method http://$server_name$server_port$request_uri\" 200
$size\n";

write_to_log($log);

?>



Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 03:27 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0