|
Simple visits counter!
|
|
03-10-2007, 09:55 AM
Post: #1
|
|||
|
|||
|
Simple visits counter!
1. Create a new folder named "counter"
2. Create a file named "counter.php" 3. Create a file named "counter.txt" - it will be used as a database. 4. Paste the following code into the "counter.php" file: [code:1]<? $fp = fopen("counter.txt", "r"); $visits = fread($fp, 1024) + 1; $fp = fopen("counter.txt", "w"); fwrite($fp, $visits); print "document.write('$visits');"; ?>[/code:1] 5. Place this on your HTML pages where you want counter to be displayed: [code:1]<script language="JavaScript" src="http://.../counter/counter.php"></script>[/code:1] You should change "..." to the URL which is pointing to the "counter" folder. Enjoy your simple visits counter. [SIZE="3"]Get a free domain name![/SIZE] |
|||
|
03-11-2007, 01:38 PM
Post: #2
|
|||
|
|||
|
Well thats a nice share and wonderful script. Just some queries. I used before some counters which counts every refresh of home page. Is that also like that... I need a counter which don't counts page views.... I mean it counts single IP visits as one in 24 hours. If you have or can code... Can u help me in that??
![]() █ U2U.CC - Search Web | Rapidshare | Megaupload | Blogs █ PW | IT Discussion Board █ Virtual Pakistan | Its all about Pakistan |
|||
|
03-11-2007, 05:48 PM
Post: #3
|
|||
|
|||
|
[code:1]<?
$fp = fopen("counter.txt", "r"); $visits = fread($fp, 1024) + 1; [B]if($_COOKIE["visits_counter"]!=1){ [/B] $fp = fopen("counter.txt", "w"); [B]}[/B] fwrite($fp, $visits); [B]setcookie("visits_counter", "1", time()+86400);[/B] print "document.write('$visits');"; ?>[/code:1] This way only one visit per 24h will be counted. [SIZE="3"]Get a free domain name![/SIZE] |
|||
|
03-11-2007, 06:18 PM
Post: #4
|
|||
|
|||
|
[code:1]<?
$fp = fopen("counter.txt", "r"); $visits = fread($fp, 1024) + 1; [B]if($_COOKIE["visits_counter"]!=1){ setcookie("visits_counter", "1", time()+86400); [/B] $fp = fopen("counter.txt", "w"); [B]} [/B] fwrite($fp, $visits); print "document.write('$visits');"; ?>[/code:1] Sorry, this is the right code. [SIZE="3"]Get a free domain name![/SIZE] |
|||
|
03-13-2007, 07:11 AM
Post: #5
|
|||
|
|||
|
OK I will upload that today and check its working.... thanks NIKOLA.. You are really working hard
![]() █ U2U.CC - Search Web | Rapidshare | Megaupload | Blogs █ PW | IT Discussion Board █ Virtual Pakistan | Its all about Pakistan |
|||
|
03-13-2007, 04:30 PM
Post: #6
|
|||
|
|||
|
thank i'll try to my page if you don't mind can i take it to my friends
|
|||
|
03-13-2007, 06:57 PM
Post: #7
|
|||
|
|||
|
Sure Tphilakone,
you can use it anywhere you want. It would be nice if you could put a link to this community on your website if you choose to use this script
[SIZE="3"]Get a free domain name![/SIZE] |
|||
|
04-26-2007, 04:17 PM
Post: #8
|
|||
|
|||
|
Tip
Nice tutorial..Just want to add that couter.txt must be 777 for linux based servers.or It won't work.
|
|||
|
« Next Oldest | Next Newest »
|






![[Image: 2irvgpw.gif]](http://i20.tinypic.com/2irvgpw.gif)
