PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Fri Sep 21, 2018 12:35 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Tue May 23, 2006 11:54 am 
Offline
Forum Newbie

Joined: Tue May 23, 2006 11:34 am
Posts: 4
Syntax: [ Download ] [ Hide ]
<?
$filename = "logs/access." . date("Y.m",time()) . ".log";

$fp = fopen($filename,"a");

$str = gethostbyaddr ( $_SERVER['REMOTE_ADDR'] );
$str .= " - -";
$str .= " [" . date("d/M/Y:G:i:s",time()) . " -0700]";
$str .= " \"" . $_SERVER['REQUEST_METHOD'] . " " . $_SERVER['REQUEST_URI'] . " HTTP/1.1\"";
$str .= " 200 1000";
if(isset($_SERVER['HTTP_REFERER']))
        $str .= " \"" . $_SERVER['HTTP_REFERER'] . "\"";
else
        $str .= " \"none\"";
$str .= " \"" . $_SERVER['HTTP_USER_AGENT'] . "\"";
$str .= "\r\n";
fwrite($fp,$str);
fclose($fp);
?>


I use GoDaddy for one of my sites which has 50GB of storage and 500,000MB of transfer but doesn't give raw access to logs and their web-stats tool is far less than spectacular. I use this code in log.php and include it in every page on the site. The only things it can't log accurately are the amount of data transfer and the status code of the request. It just uses code 200 and 1000 bytes transfered. GoDaddy does well enough telling me how much transfer there was and I only care about successful requests.

It works best for sites which are entirely PHP driven.

The logs are automatically rotated every month and they are in the standard Apache format so you can then download them and parse them with any log analyzer program you want that supports Apache logs.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 23, 2006 1:15 pm 
Offline
Forum Commoner
User avatar

Joined: Mon May 08, 2006 4:49 pm
Posts: 35
Have you tried the google analytics system?

I've been using it on my own server for some time now and am very impressed with the stats it offers.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 23, 2006 2:05 pm 
Offline
Breakbeat Nuttzer
User avatar

Joined: Wed Mar 24, 2004 8:57 am
Posts: 13098
Location: Melbourne, Australia
Hades wrote:
Have you tried the google analytics system?

I've been using it on my own server for some time now and am very impressed with the stats it offers.


The stats are impressive, in fact we use it here. The only issue really is that it relies upon the client to provide you with the statistic through javascript (and you can't just "get" an account).


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 02, 2006 3:59 pm 
Offline
Forum Newbie

Joined: Sat Sep 02, 2006 11:17 am
Posts: 16
Location: Belgium
Google analytics is now open for the general public for free (before only few could get an account!)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group