Re: Newbie question: Page Counter
| From: | yanto | Date: | Fri, 20 Apr 2001 05:51:58 +0000 |
| Subject: | Re: Newbie question: Page Counter | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-49495@lists.php.net to get a copy of this message | ||
this counter'll increment the counter, no matter where are you go the page
from. If you only want that the counter increment for the first time
visitor visit the website, put the code at mainpage file, and check also
the page referrer weather it's a local url or not.
-toto-
Adam writes:
> make a file called counter.php and include this text:
>
> //-------------------------------------counter.php--------------------------
> ---------------//
>
> <?php
> //Simple PHP counter, v0.1. Send comments to junkmail@nooper.homeip.net
> if (file_exists('count.inc'))
> {
> $fil = fopen('count.inc', r);
> $dat = fread($fil, filesize('count.inc'));
> echo $dat+1;
> fclose($fil);
> $fil = fopen('count.inc', w);
> fwrite($fil, $dat+1);
> }
> else
> {
> $fil = fopen('count.inc', w);
> fwrite($fil, 1);
> echo '1';
> fclose($fil);
> }
> php?>
>
> //--------------------------------------------------------------------------
> --//
>
>
> then make a file called count.inc and chmod it to 777 so anyone can write to
> it. insert a number into the file.
>
>
> //------------------------------count.inc-----------------------------------
> --//
> some value