Script URL: www.oxcartdays.com/counter/graphcount.php
Version of script: 1.1
Hosting company: IXwebhosting
Write your message below:
I have the PHP graphical hit counter (PHPGcount) installed and a hit counter on multiple pages each with its own .txt log file. I have the unique visitors setting at "1" but when I navigate my site using the navigation menu, the counter advances every time I re-visit a page once I leave it. For example, if I jump back & forth between two pages, the counter on each page will keep advancing each time I land on the page..it doesn't advance if I refresh the page I am on however. It should only count me the first time i hit the page as a unique visitor. I have the unique hours set at 24 hours. Is this a bug in the script or do I have something set-up wrong?
Count unique visitors only - BUG
Try opening your graphcount.php file in Notepad and change everything from "/* Get current count */" to "/* Is zero-padding enabled? */" into this:
Upload the modified file to the browser, close all browser windows then try again.
Does it help?
Code: Select all
/* Get current count */
$count = trim(file_get_contents($logfile)) or $count = 0;
$cname = 'gcount_unique_'.$page;
if ($count_unique==0 || !isset($_COOKIE[$cname])) {
/* Increase the count by 1 */
$count = $count + 1;
$fp = @fopen($logfile,'w+') or die('ERROR: Can\'t write to the log file ('.$logfile.'), please make sure this file exists and is CHMOD to 666 (rw-rw-rw-)!');
flock($fp, LOCK_EX);
fputs($fp, $count);
flock($fp, LOCK_UN);
fclose($fp);
/* Print the Cookie and P3P compact privacy policy */
header('P3P: CP="NOI NID"');
setcookie($cname, 1, time()+60*60*$unique_hours);
}
/* Is zero-padding enabled? */
Does it help?
Last edited by Klemen on Mon Aug 10, 2009 6:51 pm, edited 1 time in total.
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here 
You should follow me on Twitter here
Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools


Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools
This stopped the counter from advancing when I swithch back & forth between pages BUT it set the counter at 1. I went in and changed the log file to different number for those pages and opened browser to try it again and it keeps resetting the count to 1. I opened the log file to check and it was 1. Don't know why my other number was replaced by the "1".
So I then set unique to 0 to try and let the counter advance on a refresh but the number stayed at 1.
Anything else you can think of to make it work?
So I then set unique to 0 to try and let the counter advance on a refresh but the number stayed at 1.
Anything else you can think of to make it work?
Sorry, my bad, when I was copying the code I missed two lines. I updated the code in my previous post, please try that one again (just add the top two line that are missing in your script now).
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here 
You should follow me on Twitter here
Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools


Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools
It works like a charm when I am on the site, but when I close my browser and re-open my browser & go back to the site, the counter advances one count on all the pages I visit, but only the first time I visit a page during my session. Is that correct? I am unique to my site each time I open my browser and visit it?
That makes sense to me as I see its setting a cookie so unless Klem says otherwise I would say its working as it should now.
Some have there browsers set to delete all cookies on close as well.
So going back would then count as 1 new count.
DC
Some have there browsers set to delete all cookies on close as well.
So going back would then count as 1 new count.
DC
To Code Or Not To Code That Is The Question?
Was my post of any help to you? if so please do [url=http://www.clickcraft.net/slice_donations.php][b]Buy Me A Slice[/b][/url] ...
Was my post of any help to you? if so please do [url=http://www.clickcraft.net/slice_donations.php][b]Buy Me A Slice[/b][/url] ...