Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 29 Feb 2004 17:36:59 +0000
From:      Peter Risdon <peter@circlesquared.com>
To:        fbsd_user@a1poweruser.com
Cc:        "freebsd-questions@FreeBSD. ORG" <freebsd-questions@FreeBSD.ORG>
Subject:   Re: Counter in php script
Message-ID:  <4042233B.9070107@circlesquared.com>
In-Reply-To: <MIEPLLIBMLEEABPDBIEGKEEMFNAA.fbsd_user@a1poweruser.com>
References:  <MIEPLLIBMLEEABPDBIEGKEEMFNAA.fbsd_user@a1poweruser.com>

next in thread | previous in thread | raw e-mail | index | archive | help
fbsd_user wrote:

>Thanks, a really great reply.
>Have some questions about the fine details.
>  
>
I haven't used this script, just happened to notice it the other day 
while looking something up, but ...

>The counter file is an single line with any size numeric
>field starting in position 1?
>Like this, right?
>2004000000
>  
>
Looks like it. If the file isn't there already, the script creates it.

>Does the file have to be an  .txt  file?
>  
>
It can have any name you like, if that's what you mean. The contents are 
always going to be the same.

>What happens if the counter file is in use and locked?
>Does the second request pause until file is free?
>  
>
File locking is OS dependent. More particularly, php file locking works 
fine with other attempts to access the file from thingies that are also 
using the same type of file locking as php. So, I believe the 
conservative answer here is: yes, on FreeBSD, at least so far as other 
attempts from php scripts to access the file are concerned.

>If the counter file has no path prefix, then it's looked for
>in the same location as the script, right?
>$counter_file = 'counter.php'
>  
>
Yes, though personally I prefer to be anal and state the full path. If 
you might use the file in a number of locations in an expanded script 
and need to refer to this path more than once, set it once as:

$filepath = '/usr/home/someuser/counters/';

and edit just that line when you need to, then use:

$counter_file = $filepath."counter.php";

or similar throughout the script. Bear in mind that the file will be 
written as the default apache user, probably www, so the directory needs 
appropriate permissions.

PWR.



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