why does this simple counter fail?
Gary Kline
kline at thought.org
Thu Mar 24 23:00:51 UTC 2011
On Wed, Mar 23, 2011 at 07:11:15PM +0100, Fr?d?ric Perrin wrote:
> Gary Kline <kline at thought.org> writes:
> > Can any of you php hackers tell me why this simple self-hacked
> > counter bomb?
>
> As others said, what does 'this simple counter bomb' means?
>
> > $fp = fopen($directory.$file, "r+");
> > flock($fp, 1);
>
> You want an exclusive lock (LOCK_EX, which is 2 is you use some ancient
> PHP), not a shared lock.
>
> When updating the file:
> > fputs($fp, $count);
> > fputs($fp, "\n");
> > fputs($fp, $file);
>
> Why do you feel the need to store the filename inside the file itself?
> You don't seem to need it after.
$file is passed from the calling php file. index.php is by-hand
set to
$file='index';
and so on.
Because of my shoulder/typing woes, it was great that I got clued in
above by Brad's thought that perhaos there were mis-matched "<?"
and "?>" tags. A simply recursive grepping found out that it some
places I had "<?" <cr> instead of "<?php"> <cr>. Adding the "php"
fixed everything.
Finally, you're right; this really, really is ancient php.
Somthing i found pre-2004 and hacked until it worked. The
counter is missings lots of features, but I'll fix that pretty
soon.
thanks to everybody ,
>
> --
> Frédéric Perrin -- http://tar-jx.bz
>
> _______________________________________________
> freebsd-questions at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions-unsubscribe at freebsd.org"
--
Gary Kline kline at thought.org http://www.thought.org Public Service Unix
Journey Toward the Dawn, E-Book: http://www.thought.org
The 7.98a release of Jottings: http://jottings.thought.org
More information about the freebsd-questions
mailing list