websaint
Sep 28 2004, 08:58 PM
Hi!! I'm going to show you how to make your own counter useing php!!  It's really easy and you woun't have to keep seaching the net for free and bannerless counters. So here comes the script: CODE <?php
//Simple class for counting visits //Written by WebSaint
class Teller { function count() { $countfile = file("alle.txt"); $count = $countfile[0]; $count= $count + 1; $fp = fopen("alle.txt","w"); $fw = fwrite($fp,$count); fclose($fp); echo $count; } }
$obj =& new Teller; $obj->count();
?> Then add this to display the number of visitors: CODE <p>Number of guests visiting my site: <? include('alle.txt'); ?>.</p> That's it. I hope you'll find the script useful! 
Reply
qwijibow
Sep 29 2004, 03:23 PM
Good... but you might find others steal your counter if they find it... they will link to your counter script, and store their page cound on your server. its always good to add some kind of proetection againsed this. a good, but not perfect way is to make sure the referer comes from your own site, and nobody elses.
Reply
Hercco
Sep 29 2004, 05:26 PM
QUOTE(qwijibow @ Sep 29 2004, 05:23 PM) Good... but you might find others steal your counter if they find it... they will link to your counter script, and store their page cound on your server. its always good to add some kind of proetection againsed this. a good, but not perfect way is to make sure the referer comes from your own site, and nobody elses. Well it's impossible to "steal" this. If you include that file from Websaints server the code will be treated as it was run on your server and thus will try to look file alle.txt from your server. If you simply request that file it will only add hits to Websaints counter. The referer checking would be pointless in this but I'd like comment it a bit in general. People do not seem to know or just forget that nowadays quite many users disable or block referer sending. In certain browsers it is an option and I believe most of the current commercial software firewalls include an option to block them. Not taking this into account can mean that users that do not want to send referers can't use the service at all. For instance one development version of the WordPress blog software required referer sending to make changing it's options possible. The referer checking was simply just for sending the user back to the page where he came from. Other example is a certain torrent site that refuses to work if not getting referer information. They reason is understandable though: there is apparently countless "mirror" sites that are not actual mirrors but simply index their files and points the user to download the .torrents from the original site.
Reply
qwijibow
Sep 30 2004, 02:56 PM
QUOTE(Hercco @ Sep 29 2004, 06:26 PM) Well it's impossible to "steal" this. If you include that file from Websaints server the code will be treated as it was run on your server and thus will try to look file alle.txt from your server. If you simply request that file it will only add hits to Websaints counter. The referer checking would be pointless in this but I'd like comment it a bit in general. People do not seem to know or just forget that nowadays quite many users disable or block referer sending. In certain browsers it is an option and I believe most of the current commercial software firewalls include an option to block them. Not taking this into account can mean that users that do not want to send referers can't use the service at all. For instance one development version of the WordPress blog software required referer sending to make changing it's options possible. The referer checking was simply just for sending the user back to the page where he came from. Other example is a certain torrent site that refuses to work if not getting referer information. They reason is understandable though: there is apparently countless "mirror" sites that are not actual mirrors but simply index their files and points the user to download the .torrents from the original site. you misunder stand my meaning....... i mean someone could replace CODE <p>Number of guests visiting my site: <? include('alle.txt'); ?>.</p> the include file with a coomplete URL to anouther server. and replace "alle.txt" with a different filename.
Reply
k22
Sep 30 2004, 04:03 PM
But if you substitute the .txt file with a php file is't better?like this CODE <?php <?php
$now=fopen("count.php","r+"); while(!feof($now)){ $cont=fgets($now,2); if ($cont=="N") { $check=fgets($now,3); if($check=="V=") { $nvisit=fgets($now,4); echo $nvisit; settype($nvisit,"integer"); $posi=ftell($now); fseek($now,($posi-2)); fwrite($now,($nvisit+1)); exit; } } } fclose($now);
?>
and a count.php like this
<?php
NV=34
?>
Reply
there are many scripting languages and you can find counter in each. first check which scripting is available on your server and then try to find its script for counter. i reccomond altavista.com rather than google.com for finding free scripts.
Reply
Hercco
Oct 4 2004, 02:15 PM
QUOTE(qwijibow @ Sep 30 2004, 04:56 PM) CODE <p>Number of guests visiting my site: <? include('alle.txt'); ?>.</p> the include file with a coomplete URL to anouther server. and replace "alle.txt" with a different filename. And that would accomplish what? QUOTE(sha @ Oct 4 2004, 04:02 PM) there are many scripting languages and you can find counter in each. first check which scripting is available on your server and then try to find its script for counter. i reccomond altavista.com rather than google.com for finding free scripts. We're DYI guys, we want to write our own scripts
Reply
deivid
Oct 4 2004, 05:17 PM
Why search or write you own counter ? if you want an easy way and a ads-less counter, just go to your astahost control panel, under Preinstalled Scripts / CGI Center / Counter, you can choose between 35 diferent types of counters and configure almost anything. After you choose your desired counter, press preview to see it how it's going to be and if you like, press make html and it will write a code to insert in your page. Greets Deivid
Reply
antitoxic
Oct 4 2004, 05:43 PM
Why don't you use a beautiful flash counter connected with a php code. An example can be downloaded from flashkit.com tutorials.
Reply
sohahm
Oct 6 2004, 05:13 PM
I know a very good free script named EliteStats. You just have to put its folder in your main directory and include a one line of code in your webpage. It will display How many visitors are online and complete statistics with IP address. Sohail Ahmed sohail4@msn.com
Reply
Latest Entries
rockarolla
Feb 17 2008, 05:00 PM
file based counter may jam - sometimes it wont be able to overwirte the data - when many visitors navigate to your web. The other problem is if you ain't got permissions to open a file on your server...hence host dependent.
Reply
comkidwizzer3
Feb 16 2008, 02:37 AM
QUOTE(qwijibow @ Sep 30 2004, 02:23 AM)  Good... but you might find others steal your counter if they find it... they will link to your counter script, and store their page cound on your server.
its always good to add some kind of proetection againsed this. a good, but not perfect way is to make sure the referer comes from your own site, and nobody elses. QUOTE(qwijibow @ Oct 1 2004, 01:56 AM)  you misunder stand my meaning....... i mean someone could replace CODE <p>Number of guests visiting my site: <? include('alle.txt'); ?>.</p> the include file with a coomplete URL to anouther server. and replace "alle.txt" with a different filename. A solution to your problem just encode your webpage.
Reply
optiplex
May 4 2007, 09:38 PM
verry good & no mysql !
Reply
livingston
Mar 21 2007, 07:27 PM
wow a great simple and effective counter.
Reply
warallthetm
Jul 9 2006, 05:33 PM
Dose this script count page loads or unique ips? I have been searching fo a php script that count's unique visitors and not just page loads. Is there a way to mod this?
Reply
Recent Queries:--
how to build a php counter - 0.05 hr back. (1)
-
a counter in php - 30.87 hr back. (1)
-
create hit count flash using php - 38.04 hr back. (2)
-
create website counters using php - 49.96 hr back. (1)
-
how to make a hit counter for flash videos php - 66.92 hr back. (1)
-
how to make flash counter - 71.09 hr back. (1)
-
how to make a counter using php - 73.66 hr back. (1)
-
how to build a counter in a html page php - 76.47 hr back. (1)
-
how to make counter flash script - 78.88 hr back. (1)
-
php counter - 80.43 hr back. (1)
-
how to make a website counter im php - 89.49 hr back. (1)
-
website counter php how to make - 89.51 hr back. (1)
-
make my own hit counter - 100.60 hr back. (1)
-
php counter fopen disabled - 113.53 hr back. (1)
Similar Topics
Keywords : make, simple, counter, php
- How To Create A PHP Based Hit Counter
With MySQL (2)
Looking for make, simple, counter, php
|
|
Searching Video's for make, simple, counter, php
|
advertisement
|
|