Jump to content
xisto Community
Sign in to follow this  
iGuest

Does any one have a php counter script? Free counter script?

Recommended Posts

Does anyone know of a good counter script i could use to display the number of clicks/hits on a download link on one of my sites?

Share this post


Link to post
Share on other sites

First upload a file anmed 'counter.txt' and chmod it to 666 with your ftp.
Then put this on your file:

<?php[br]$count = file_get_contents('counter.txt')+1;[/br]fwrite(fopen('counter.txt', 'w+'), $count);[br]echo $count;[/br]?>

Share this post


Link to post
Share on other sites

First upload a file anmed 'counter.txt' and chmod it to 666 with your ftp.Then put this on your file:

<?php[br]$count = file_get_contents('counter.txt')+1;[/br]fwrite(fopen('counter.txt', 'w+'), $count);[br]echo $count;[/br]?>
uhh... shouldn you chmod it to 777 not 666?

Share this post


Link to post
Share on other sites

I want to have a counter in my site but i would like to have it only increased everytime the user enters my homepage at the first time. I mean if i user goes to a subsection of my site and clicks the back button coming back to the home page i do not want the counter to be increased again (with Roly's counter the counter will be increased). I think the solution will be to create a counter which interacts with sessions or something like that. Does anyone has a counter which works as i explained?Thanks in advance.Sergio

Share this post


Link to post
Share on other sites

hii tested over 500 counter and statistic scripts (big numer load of time)look goyzi have selected 10-20 of the best(be adviced that i dont use txt scripts only the ones based on Db's)if any want a name or a script just pm metake care

Share this post


Link to post
Share on other sites

The php counter script I use for all my sites is phphits v1.1 found at https://www.google.de/?gfe_rd=cr&ei=43UjVN3tPMmH8QeiwYCYCA&gws_rd=ssl. It's very handy because you can set the time duration of what counts as a "new" hit, and you can display the number of users online in a duration of time, and also the number of hits in the last 24 hours. It also has a log page with statistics of what users came at what time, their IP and what page they hit. Very handy.

 

Also it's very easy to use if you know the basics of php. It uses a MySQL database.

Share this post


Link to post
Share on other sites

This will not work in a busy web site. Because there are many concurrent access, we need some mechanism to synchronize the access.

 

The error is

1 The count may not be correct. Suppose one request get count=1. At the mean time, another request get the same count=1. after both write finish, count=2 instead of count=3

2 The write to the file may cause the file corrupt, because fopen is not locked even you open it for write.

 

the process should be:

 

<?

fopen()

flock(LOCK_EX)

fread()

count++

fwrite()

flock(LOCK_UN)

fclose()

 

?>

 

First upload a file anmed 'counter.txt' and chmod it to 666 with your ftp.

Then put this on your file:

<?php$count = file_get_contents('counter.txt')+1;fwrite(fopen('counter.txt', 'w+'), $count);echo $count;?>

8061[/snapback]

Share this post


Link to post
Share on other sites

omg.. the last post in this thread was over 4 months ago.. And the original poster isn't even a member of the board anymore! Why bring back a thread that has been dead for so long? Arrrrrggh..

Share this post


Link to post
Share on other sites

The others can find what they want when search in the forum. Do you want others to get the wrong answer? :D

 

omg.. the last post in this thread was over 4 months ago.. And the original poster isn't even a member of the board anymore!  Why bring back a thread that has been dead for so long?  Arrrrrggh..

45556[/snapback]

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
Sign in to follow this  

×
×
  • 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.