Date: Thu, 24 Mar 2011 18:25:39 -0500 From: Ryan Coleman <editor@d3photography.com> To: Gary Kline <kline@thought.org> Cc: Fr?d?ric Perrin <fred@resel.fr>, freebsd-questions@freebsd.org Subject: Re: why does this simple counter fail? Message-ID: <89898D0E-B4A9-41E9-B829-DF7CA8D3FF06@d3photography.com> In-Reply-To: <20110324230049.GB31958@thought.org> References: <20110323164504.GA25317@thought.org> <kggr59xpv0c.fsf@pc-df-302.priv.enst-bretagne.fr> <20110324230049.GB31958@thought.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Gary, you missed the put... fput($fp, $file); means you're dropping the = filename INTO the storage file. On Mar 24, 2011, at 6:00 PM, Gary Kline wrote: > On Wed, Mar 23, 2011 at 07:11:15PM +0100, Fr?d?ric Perrin wrote: >> Gary Kline <kline@thought.org> writes: >>> Can any of you php hackers tell me why this simple self-hacked >>> counter bomb? >>=20 >> As others said, what does 'this simple counter bomb' means? >>=20 >>> $fp =3D fopen($directory.$file, "r+"); >>> flock($fp, 1); >>=20 >> You want an exclusive lock (LOCK_EX, which is 2 is you use some = ancient >> PHP), not a shared lock. >>=20 >> When updating the file: >> > fputs($fp, $count); >> > fputs($fp, "\n"); >>> fputs($fp, $file); >>=20 >> Why do you feel the need to store the filename inside the file = itself? >> You don't seem to need it after. >=20 >=20 > $file is passed from the calling php file. index.php is by-hand > set to >=20 > $file=3D'index';=20 >=20 > and so on. =20 >=20 > 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 "<?"=20= > and "?>" tags. A simply recursive grepping found out that it = some=20 > places I had "<?" <cr> instead of "<?php"> <cr>. Adding the = "php"=20 > fixed everything. =20 >=20 > 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. >=20 > thanks to everybody , >=20 >=20 >>=20 >> --=20 >> Fr=E9d=E9ric Perrin -- http://tar-jx.bz >>=20 >> _______________________________________________ >> freebsd-questions@freebsd.org mailing list >> http://lists.freebsd.org/mailman/listinfo/freebsd-questions >> To unsubscribe, send any mail to = "freebsd-questions-unsubscribe@freebsd.org" >=20 > --=20 > Gary Kline kline@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 >=20 > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to = "freebsd-questions-unsubscribe@freebsd.org"
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?89898D0E-B4A9-41E9-B829-DF7CA8D3FF06>