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! 
Comment/Reply (w/o sign-up)
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.
Comment/Reply (w/o sign-up)
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.
Comment/Reply (w/o sign-up)
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.
Comment/Reply (w/o sign-up)
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
?>
Comment/Reply (w/o sign-up)
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.
Comment/Reply (w/o sign-up)
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
Comment/Reply (w/o sign-up)
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
Comment/Reply (w/o sign-up)
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.
Comment/Reply (w/o sign-up)
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
Comment/Reply (w/o sign-up)
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.
Comment/Reply (w/o sign-up)
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.
Comment/Reply (w/o sign-up)
optiplex
May 4 2007, 09:38 PM
livingston
Mar 21 2007, 07:27 PM
wow a great simple and effective counter.
Comment/Reply (w/o sign-up)
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?
Comment/Reply (w/o sign-up)
Similar Topics
Keywords : make, simple, counter, php
- Php Counter
(4)
How To Create A PHP Based Hit Counter
With MySQL (2) websaint recently posted a PHP hit counter using a flat-file to store information. This is a guide
a wrote a little while ago - it was for another web site, but I'll post it here as well.
----------------------------------------------------------------------------------- First and
foremost, you need to create a new table. You can use a whole new database if you want (and assuming
you have one free), but it's a bit of a waste. For this guide, our table will be called
'hits', and will contain two fields - 'unique' and 'total'. The first ....
Looking for make, simple, counter, php
|
See Also,
*SIMILAR VIDEOS*
Searching Video's for make, simple, counter, php
|
advertisement
|
|