Re: Web site counter
| From: | Werner Stuerenburg | Date: | Wed, 01 Aug 2001 12:25:35 +0000 |
| Subject: | Re: Web site counter | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-60636@lists.php.net to get a copy of this message | ||
It is easy, but you need to have write privileges on that file
(or rather httpd needs that) - so you may include a test that
this file only holds a number as a minimal protection.
$filename = "$GLOBALS[DOCUMENT_ROOT]/your_counter.txt";
$fp = fopen($filename,"a+");
$cnt = fread( $fp, filesize($filename));
fclose($fp);
if ($cnt == "") {
$cnt = "0";
}
$cnt++;
$fp = fopen($filename,"w");
$res = fwrite($fp, (string)$cnt);
fclose($fp);
Kyle Smith schrieb am Mittwoch, 1. August 2001, 22:12:35:
> Is it possible to make a website counter with a PHP script and a text document? If so can
> somebody email me a script (unlikely) or send me to a page with a script (yay)
> -lk6-
> http://www.StupeedStudios.f2s.com
> Home of the burning lego man!
> ICQ: 115852509
> MSN: dbzno1fan@hotmail.com
> AIM: legokiller666
--
Herzlich
Werner Stuerenburg
_________________________________________________
ISIS Verlag, Teut 3, D-32683 Barntrup-Alverdissen
Tel 0(049) 5224-997 407 · Fax 0(049) 5224-997 409
http://pferdezeitung.de