Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 3 Feb 2004 04:56:05 +0200
From:      Ion-Mihai Tetcu <itetcu@apropo.ro>
To:        Gary Kline <kline@thought.org>
Cc:        FreeBSD Mailing List <freebsd-questions@FreeBSD.ORG>
Subject:   Re: OT: php question.
Message-ID:  <20040203045605.36812f9a@it.buh.cameradicommercio.ro>
In-Reply-To: <20040203012859.GA78736@tao.thought.org>
References:  <20040203012859.GA78736@tao.thought.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 2 Feb 2004 17:28:59 -0800
Gary Kline <kline@thought.org> wrote:

> 	Is there a way of having <? php code ?> print the name of 
> 	its file (along with the number of hits for tht file) and
> 	keep track of all the files in a $WWW_ROOT/filecount page?
> 
> 	Right now I have a cgi script tracking over 100 individual
> 	file with
> 
> 	filename1	hitcount1
> 	filename2	hitcount2
> 	...
> 	filenameN	hitcountN
> 
> 	This question came about when I realized that I've got
> 	more than 30K hits on *all* my pages in the past 22 months.
> 
> 	Of course, I could hand-code each individual filename  and
> 	call the counter code. Isn' there a more automagic way?

$_SERVER["SCRIPT_FILENAME"] /usr/local/psa/home/vhosts/some_host.ro/httpdocs/phpinfo.php
$_SERVER["REQUEST_URI"]	/phpinfo.php 	
$_SERVER["SCRIPT_NAME"]	/phpinfo.php 	
$_SERVER["PATH_TRANSLATED"]/usr/local/psa/home/vhosts/some_host.ro/httpdocs/phpinfo.php 	
$_SERVER["PHP_SELF"]	/phpinfo.php 

I would suggest only echo-ing a line per file per hit and do a wc -l
when needed; or echo the SCRIPT_FILENAME in a single file and do a grep
$SCRIPT_FILENAME | wc -l when needed. Of course, you can optimise this
(e.g. monthly doing accounting and deleteing the content of the log).
This way is much faster that reading current count for the page,
incrementing and writing it back.

This is far for being the best way, esp. under load, but will do the
trick.



-- 
IOnut
Unregistered ;) FreeBSD user



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040203045605.36812f9a>