|
|
|
|
![]() ![]() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members
Posts: 208 Joined: 27-January 05 From: LI, New York Member No.: 3,448 |
Post
#1
Mar 7 2005, 11:12 PM
Hello all, Here is a neat and helpful PHP script that can count unique page views on your website. First you need to open up a new page in your text editor and paste in this code. CODE <?php $filename = "hits.txt"; $file = file($filename); $file = array_unique($file); $hits = count($file); echo $hits; $fd = fopen ($filename , "r"); $fstring = fread ($fd , filesize ($filename)); fclose($fd); $fd = fopen ($filename , "w"); $fcounted = $fstring."\n".getenv("REMOTE_ADDR"); $fout= fwrite ($fd , $fcounted ); fclose($fd); ?> then save the page as counter.php Next open up another new page in your text editor and just save it as hits.txt Then upload all of the files onto your server and CHMOD hits.txt to 0777 or just 777. After that open up your main page or the page you will be placing the counter on and pste in the following code. CODE <?php include ('counter.php'); ?> then save and close that page. If needed, re-upload the file(s) to your server. Very simple and easy to use. Comments are allways appreciated. |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members
Posts: 168 Joined: 8-February 05 Member No.: 3,672 |
|
![]() ![]() ![]() ![]() Group: Members
Posts: 55 Joined: 26-February 05 Member No.: 3,996 |
Post
#3
Mar 8 2005, 03:17 AM
Yeh is really nice, im gonna test it out, i alrady have one that just counts page hits, one that counts unique page hits, EVEN BETTER!
|
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members
Posts: 710 Joined: 30-October 04 From: Texas Member No.: 2,058 |
Post
#4
Mar 8 2005, 03:30 AM
Very nice! All of the other ones I've seen are very complex and I have no idea what they mean, but I understand this one. Do you mind if I use it on my site?
|
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members
Posts: 623 Joined: 30-October 04 From: Philippines Member No.: 2,049 |
Post
#5
Mar 8 2005, 04:48 AM
Do you think that we must use Cookies to make a UNIQUE COUNTER SCRIPT? What do you think?
|
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members
Posts: 710 Joined: 30-October 04 From: Texas Member No.: 2,058 |
|
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members
Posts: 208 Joined: 27-January 05 From: LI, New York Member No.: 3,448 |
Post
#7
Mar 9 2005, 10:55 PM
It counts unique. The first couple hits are counted as page views till it kicks in. try it on my site at the bottum of the page. http://gamerspub.trap17.com |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members
Posts: 623 Joined: 30-October 04 From: Philippines Member No.: 2,049 |
Post
#8
Mar 10 2005, 04:51 AM
QUOTE(maddog39 @ Mar 10 2005, 06:55 AM) It counts unique. The first couple hits are counted as page views till it kicks in. try it on my site at the bottum of the page. http://gamerspub.trap17.com [right][snapback]58225[/snapback][/right] Well, here's what happened. I visited your website. After that, I saw the counter. Then I reloaded the page. It stays the same. Then I reloaded it again, then the counter increased by +1. After that, I reloaded and reloaded the page again. It stays the same. Then I went to http://gamerspub.trap17.com/hits.txt and I saw many logs of my ip address. You must use cookies() in order for it to work well. Or sessions. |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members
Posts: 208 Joined: 27-January 05 From: LI, New York Member No.: 3,448 |
Post
#9
Mar 10 2005, 09:21 PM
In my book thats not needed and it makes things complicated. It can mis count thats true. However its sensitive in different ways. So what you said depends. |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members
Posts: 623 Joined: 30-October 04 From: Philippines Member No.: 2,049 |
Post
#10
Mar 11 2005, 09:58 AM
QUOTE(maddog39 @ Mar 11 2005, 05:21 AM) In my book thats not needed and it makes things complicated. It can mis count thats true. However its sensitive in different ways. So what you said depends. [right][snapback]58596[/snapback][/right] Ok, maybe i'll try to modify your code and improve it. Don't worry, i'll put your copyright. Can you please add some comments and explaination to your code and add it again here, in your thread? |
![]() ![]() |
Similar Topics
| Topic Title | Replies | Topic Starter | Views | Last Action | |||
|---|---|---|---|---|---|---|---|
![]() |
13 | KooL | 1,743 | 31st August 2004 - 10:08 AM Last post by: Too_Hot |
|||
![]() |
19 | dask | 1,305 | 4th August 2004 - 05:01 AM Last post by: zyklon |
|||
![]() |
2 | gpinvest | 865 | 19th July 2006 - 12:10 PM Last post by: Florisjuh |
|||
![]() |
6 | KooL | 387 | 21st September 2004 - 11:13 PM Last post by: odomike |
|||
![]() |
1 | tomecki | 1,128 | 31st August 2004 - 08:52 PM Last post by: neeki4444 |
|||
![]() |
15 | -prodigy- | 1,697 | 27th February 2005 - 10:22 PM Last post by: alexia |
|||
![]() |
5 | blackhawk | 553 | 31st August 2004 - 01:13 PM Last post by: Spectre |
|||
![]() |
3 | Saint_Michael | 430 | 3rd June 2006 - 07:33 AM Last post by: Avalon |
|||
![]() |
2 | ZorBiX | 491 | 28th October 2004 - 09:14 AM Last post by: ZorBiX |
|||
![]() |
34 | MercifulFate | 4,758 | 16th March 2005 - 07:26 PM Last post by: AboveZero |
|||
|
Lo-Fi Version | Time is now: 4th December 2008 - 01:45 AM |