Page 1 of 1
Statistics plugin says noboby likes me
Posted: Sun Dec 04, 2005 12:45 am
by ghoti
I recently installed the statistics plugin, but whenever I look at the statistics page, it shows zero visitors.
Code: Select all
The extended visitor�s statistic feature has collected data since .
Nr of vistors
Nr of vistors today: 0
Total nr of vistors: 0
Latest Visitors
Top Referrers
No referrers has yet been registered.
Is there some cron job I have to run or something like that? I haven't found any documentation in the plugins directory or elsewhere. And I know from my server logs that there haven't been zero visitors ... at least a guy named googlebot seems to really enjoy my blog

Re: Statistics plugin says noboby likes me
Posted: Sun Dec 04, 2005 12:47 pm
by garvinhicking
What is your serendipity version?
Regards,
Garvin
Posted: Sun Dec 04, 2005 2:46 pm
by ghoti
The version is 0.9.1. Does it matter what position the plugin is in? It's now at the very end of the list, after Spartacus. Moving it up doesn't seem to do anything - would I see an effect right away, after reloading the blog page?
Posted: Sun Dec 04, 2005 3:01 pm
by garvinhicking
Did you configure the statistics plugin and enable the extended visitor tracking? Which other event plugins do you use? Depending on the other plugins, it might make a difference where the plugin is positioned.
And which database type are you using? Check if the serendipity_visitors table exists and if it gets populated?
Regards,
Garvin
Posted: Sun Dec 04, 2005 8:57 pm
by Guest
Yes, I configured the plugin to show the visitor statistics. It's now the first plugin in the list, and I even posted a new entry and reloaded it a few times - no change. The other plugins are Markup: Wiki, Markup: Serendipity, Browser compatibility, Spam protection, Fix common XHTML errors, Spartacus.
The data base is MySQL, and the visitors table exists, but is empty. So how do I get data into it?

Posted: Mon Dec 05, 2005 10:34 am
by garvinhicking
I'm afraid you'll have to do some manual work now.
Edit the plugins/serendpipity_event_statistics/serendpipity_event_statistics.php file. Go to line 95. There you should find this:
Code: Select all
$sessionChecker = serendipity_db_query("SELECT count(sessID) FROM {$serendipity['dbPrefix']}visitors WHERE '".serendipity_db_escape_string(session_id())."' = sessID GROUP BY sessID", true);
Please add a line directly after that:
Code: Select all
die("The result of the query:<br />SELECT count(sessID) FROM {$serendipity['dbPrefix']}visitors WHERE '".serendipity_db_escape_string(session_id())."' = sessID GROUP BY sessID<br/>is:<br /><pre>" . print_r($sessionChecker, true) . "</pre><br />");
The two problems I see that can apply for you are, either your PHP version is too old (below 4.1) or your PHP's session support is not enabled/does not work.
After you'Ve made the change above, save the file and to go your blog. You'll now see just an error, which you can please copy and paste here. After that you can remove the line again, and I'll tell you which error happens
Regards,
Garvin
Posted: Tue Dec 06, 2005 1:46 am
by ghoti
Garvin, I did that, but the I had to insert the line after line 160, since that is where the query appears in my version of the file. The result is this:
Code: Select all
The result of the query:
SELECT count(sessID) FROM serendipity_visitors WHERE '4ae182f31c3fbb32ef187e5a9cd66f1f' = sessID GROUP BY sessID
is:
I.e., no result. Hm. The PHP version is 4.3.1. Is there anything else to be done/checked? It's not vitally important, it would just be nice to have.
Thanks for your efforts!
Robert
Posted: Tue Dec 06, 2005 1:46 pm
by garvinhicking
Ghoti, can it be that you're using a browser that sends no HTTP User Agent string?
An empty result of the query is the right thing to have. Because then in the code the rest continues to track a vote:
Code: Select all
// avoiding banned browsers
$banned_bots = $this->get_config('banned_bots');
$tmp_array = explode('|', $banned_bots);
$found = 'no';
for ($i=0; $i<count($tmp_array); $i++) {
if (trim($tmp_array[$i]) == trim($_SERVER['HTTP_USER_AGENT'])){
$found = 'yes';
}
}
if ($found == 'no'){
$this->countVisitor();
}
please modify that part into this:
Code: Select all
// avoiding banned browsers
$banned_bots = $this->get_config('banned_bots');
$die_string = "Got banned bots: [$banned_bots]\n";
$tmp_array = explode('|', $banned_bots);
$found = 'no';
for ($i=0; $i<count($tmp_array); $i++) {
$die_string .= "Checking #$i, {$tmp_array[$i]} against HTTP User Agent [{$_SERVER['HTTP_USER_AGENT']}]\n";
if (trim($tmp_array[$i]) == trim($_SERVER['HTTP_USER_AGENT'])){
$die_string .= "Matched a bot. Not tracking visitor!\n";
$found = 'yes';
}
}
if ($found == 'no'){
$die_string .= "Not matched a bot. Tracking visitor!\n";
$this->countVisitor();
}
die($die_string);
Then we can get additional info
Regards,
Garvin
Posted: Tue Dec 06, 2005 9:03 pm
by ghoti
I registered a user, so I won't forget to put in my name when I reply ...
I can see the problem now. At least I see what's happening, but I don't know what the cause is: If I put the code where you told me to, it doesn't get executed. There's an if statement around this block, that apparently always fails:
Code: Select all
if ((is_array($sessionChecker)) && ($sessionChecker[0] == 0)) {
So I did some 1337 hax0ring to print out the $sessionChecker array, and this is it:
I have no idea what that means, but it's an array and the first entry is not 0, so of course the code inside that if block never gets executed.
My browser does send a proper UserAgent, as you can see here (this is the output from your code when put before the if):
Code: Select all
Got banned bots: [] Checking #0, against HTTP User Agent [Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8) Gecko/20051201 Firefox/1.5] Not matched a bot. Tracking visitor!
Robert
Posted: Tue Dec 06, 2005 10:02 pm
by garvinhicking
That is strange, because in the former die() statement I added a print_r($sessionChecker) command, but in your case it returned an empty variable (== false).
So the if-check you refer to should get executed.
Can you use phpMyAdmin or so to browse your serendipity_visitors table? If you get a result that is "array(1)" this means, your visitor with your session ID got tracked!
You might want to add a simple
after the serendipity_db_query, so that you can see what exactly is returned?
Regards,
Garvin
Posted: Wed Dec 14, 2005 4:22 pm
by ghoti
Hi, problem solved. I was playing around with the data base, when it suddenly occured to me that I had not upgrade to 0.9.1. And sure enough, one of the bugs fixed is one about visitors not being tracked correctly. So I upgraded, and it works now. Sorry about the confusion, and thanks for the help!
Robert