Php photo gallery TWG | JFUploader | TWG Flash upload | WFU | Forum https://www.tinywebgallery.com/forum/ |
|
possible bug in counter.inc.php https://www.tinywebgallery.com/forum/viewtopic.php?f=5&t=3631 |
Page 1 of 1 |
Author: | KayM [ 9. Jan 2014, 19:46 ] |
Post subject: | possible bug in counter.inc.php |
Hi Michael, since a few weeks baidu hits my gallerie even its forbidden by robots.txt so I start looking at your code to get an idea how to disable counting robots. while doing this I adjust counter.txt by hand (I now: don't do this :-) and the total counter stops counting. I traced this down to an additional \n inserted from vi after editing the value in counter.txt. The problem was the implicit string to integer cast from "$zaehler++;" in counter.inc.php. If the string contains only regular characters the implict cast is working and the counter is increased. But if the string contains i.e. a \n the implicit cast was not woking, the string stays unchanged and is written back as is to the file. I solved the problem with an explict cast to integer while reading the value from counter.txt. afterwards the counter counts again, even if there is a \n. Code: from counter.inc.php
[...] $dateir = fopen($dateiname, "r"); $zaehler = (integer) fgets($dateir, 20); // <- explicit cast string to integer $closed = fclose($dateir); } $zaehler++; $dateiw = fopen($dateiname, "w+"); fwrite($dateiw, $zaehler); fclose($dateiw); [...] |
Author: | TinyWebGallery [ 9. Jan 2014, 23:24 ] |
Post subject: | Re: possible bug in counter.inc.php |
I'll add this improvement to the next version. Thanks, Michael |
Page 1 of 1 | All times are UTC + 1 hour [ DST ] |
Powered by phpBB® Forum Software © phpBB Group http://www.phpbb.com/ |