From owner-freebsd-questions@FreeBSD.ORG Mon Feb 2 18:54:17 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 05A3D16A4CE for ; Mon, 2 Feb 2004 18:54:17 -0800 (PST) Received: from rdsnet.ro (smtp.rdsnet.ro [62.231.74.130]) by mx1.FreeBSD.org (Postfix) with ESMTP id E18A043D48 for ; Mon, 2 Feb 2004 18:54:14 -0800 (PST) (envelope-from itetcu@apropo.ro) Received: (qmail 29029 invoked from network); 3 Feb 2004 02:54:13 -0000 Received: from unknown (HELO it.buh.cameradicommercio.ro) (81.196.25.19) by mail.rdsnet.ro with SMTP; 3 Feb 2004 02:54:12 -0000 Date: Tue, 3 Feb 2004 04:56:05 +0200 From: Ion-Mihai Tetcu To: Gary Kline Message-Id: <20040203045605.36812f9a@it.buh.cameradicommercio.ro> In-Reply-To: <20040203012859.GA78736@tao.thought.org> References: <20040203012859.GA78736@tao.thought.org> X-Mailer: Sylpheed version 0.9.8claws (GTK+ 1.2.10; i386-portbld-freebsd5.2) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit cc: FreeBSD Mailing List Subject: Re: OT: php question. X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Feb 2004 02:54:17 -0000 On Mon, 2 Feb 2004 17:28:59 -0800 Gary Kline wrote: > Is there a way of having 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