Jump to content
xisto Community
maddog39

Php Unique Hit Counter Count page hits with php.

Recommended Posts

For dynamic DNS which uses the IP address in your cPanel the only ones I know of are http://forums.xisto.com/no_longer_exists/ and http://forums.xisto.com/no_longer_exists/ they are both really short DNS, FREE dns domains. :angry:

60516[/snapback]

Hello. I think yi.org and cjb.net dosen't support name servers. I only know uni.cc and 1dni.com do you know any other?

Share this post


Link to post
Share on other sites

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.

<?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.

<?phpinclude ('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. :)  :)

57363[/snapback]


I just analysed this tutorial and it works, u could have added more choices for the php to read because it might get confused on what to do, remember it needs the right thing to do or it will not work, lol, and the way u designed it is for babies, you used very old php, and the syntax is a bit corrupted and rusty but it can be fixed with a little bit of elbow greese

Share this post


Link to post
Share on other sites

de nada

umm.. karlo it doesnt really matter. Just login to your cPanel and where it says account stats or something, there should be an IP address other than yours. Put that IP in there and point your URL on the dynamic DNS in addon domains in cPanel also. An example is my site. http://forums.xisto.com/no_longer_exists/

That should help you out some. :)

Share this post


Link to post
Share on other sites

It won

Php Unique Hit Counter

 

I put it in and do what it says, but there's no counter or anything like that. Even when I load up hits.Txt it's still blank.

 

-question by G-Money

Share this post


Link to post
Share on other sites

Did you make sure you did the following:

-Save and upload all files to the same directory
-make sure the page that has the counter is ending with the .php extension because that is hte only way to get it running.

If your looking for more ways to set up a counter check out pixel2life.com or check out this unique hit counter script. As it is very customizable to fit with your site and works the same way this script does with flat files and no DB's.

Share this post


Link to post
Share on other sites

this scipt dosent work for more tahn 4 times

Php Unique Hit Counter

 

This script is not working for more than 4 times after that echo remains

 

Same check it

 

 

 

-reply by kar32

Share this post


Link to post
Share on other sites

Thanks for this, i was going mad with my last host, login scripts, counter scripts, until i realised they had safe mode on, so they didn't allow the inclution of files ^_^ I spent hours trying to figure out what was wrong.*whoop*whoop* for Xisto :P

Share this post


Link to post
Share on other sites

thats good but if 50,000 odd pageviews a day were to see your site then 'hits.txt' would be around 150mb by the end of the month - the best way is to use cookies or a database. Or what you can do is check to see if the ip is already logged in the text file - if it is in there, dont write it ^_^

Share this post


Link to post
Share on other sites

size of hits.txt

Php Unique Hit Counter

 

Hi.. Easy installation and very straightforward.. However, is there any mod that can be done so that the hits.Txt file does not get too big. Thanks in advance... John

 

-reply by john

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.