Page 1 of 2

[announcing] Statistics plugin

Posted: Sun Mar 05, 2006 4:50 pm
by SHRIKEE
I found a neat plugin while installing s9y. The statistics plugin...

Im missing one thing tho which is some uservisit graphs. Currently im trying to make that now with the existing 'statistics' data. All what i need is saved but not used 8)

These graphs will not be shown public.

Also im not interrested in the top15 posts and whatever more is shown on the page as im the only user of the site so i build in a switch to hide that part and show only the visitor count and graphs.

Ive setup a small page here:
http://www.sothq.net/projects/statistics.html

Re: [announcing] Statistics plugin

Posted: Sun Mar 05, 2006 9:03 pm
by garvinhicking
I can't yet see a picture or download link for that? If you can submit a patch or so, I can of course submit it to the core plugin in serendipity :)

Regards,
Garvin

Posted: Sun Mar 05, 2006 9:25 pm
by SHRIKEE
thats the plan!

i havent really started yet... just the idea is there and i made the option to hide data... 8)

the end product will be an updated (or 'patched' as you call it) statistics plugin which will be submitted to your database some additional info then can be found on my site aswell as a separate download.

Posted: Sun Mar 05, 2006 9:35 pm
by garvinhicking
That sounds great! Looking forward to that!

Do you know about some PHP based graphic plotters? JPgraph AFAIK does a lot of that stuff. But we need to pay a close look on licensing; only BSD-licensed code can be put into the statistics plugin. if that does not work, we would need to create a second, unrealted plugin that includes GPL code or whatever to display things... :-/

Have fun,
Garvin

Posted: Sun Mar 05, 2006 10:09 pm
by SHRIKEE
im not using image plotters. Those are resource consuming and require often a silly license.

Im using a 1x5px image which will the stretched for each graph bar. A simple sum calculates the height of the image and color. Red/yellow/green.

Its not to advanced and thats where the power lies.

Posted: Mon Mar 06, 2006 9:50 am
by SHRIKEE
Im curious.

When i compare my stats with a program called webalizer s9y has much higer stats.

How does it count visits exactly?
Ive seen it works with sessions instead of time of entry. Is it that when i enter the page a session is created. THen when i close my browser the session is killed (browserbehaviour). And when i go to the page again it counts another visit because theres no active session?

I hope not 8) This would mean i (or anyone) could easily fake my stats :(

Posted: Mon Mar 06, 2006 11:26 am
by garvinhicking
Hi!

Visitor counting is done based on Session cookies. Serendipity as a web application has no other means of inspecting identical visits.

In fact, using a session data is the only real way how unique visitors can be determined; Tools like webalizer only can use a IP address which is even worse because Proxy users can totally screw statistics.

Either way your statistics can be faked. There is no way apart from using a login-forced webpage to count unique visitors.

When IP addresses would count, anyone could fake your stats by using a proxy to access your site, so faking/altering statistics is always possible.

Regards,
Garvin

Posted: Mon Mar 06, 2006 1:50 pm
by SHRIKEE
i know that.

but how is a visitor being counted on s9y? per session or per day or how? When does the session cookie expire?

Posted: Mon Mar 06, 2006 2:06 pm
by garvinhicking
According to the code, it currently tracks the simple PHP session_start cookie, which is deleted on browser close and is valid until the PHP configured session time limit.

Every hit of a visitor is counted and incremented once a day for that session id.

Best regards,
Garvin

Posted: Tue Mar 07, 2006 3:54 pm
by SHRIKEE
i see.

I've started the monthly graph today
i get this as output:
Fatal error: Call to undefined method serendipity_event_statistics::statistics_getmonthlystats() in /var/www/html/plugins/serendipity_event_statistics/serendipity_event_statistics.php on line 643
Line 643:
$temp = $this->statistics_getmonthlystats($i, $visitors_count[0]);

Any clues?
thanks!

Posted: Tue Mar 07, 2006 4:15 pm
by garvinhicking
Hi!

It seems you did not declare a statistics_getmonthlystats method. Methods that are references with $this->... need to be declared within the Class { ... } parts. If you declare a function within a class, it's called a method and cann be accessed through $this->.

If you declare a function outside of class { ... } it's a simple function that may not be called with $this->, but directly like statistics_getmonthlystats().

See http://de2.php.net/manual/en/language.oop.php

Regards,
Garvin

Posted: Tue Mar 07, 2006 4:55 pm
by SHRIKEE
i kinda figured that yes.

i also figured im a huge and silly clown... Ive put the function inside another function :oops:

Posted: Tue Mar 07, 2006 4:58 pm
by garvinhicking
:-)

That's not a problem, BTW - PHP allows to define functions within functions. A funny concept. :-)

Code: Select all

<?php

function cool() {
  function verycool() { echo 'very cool'; }
  echo 'cool';
}

cool();
verycool();

?>
But this doesn't make sense in most cases ;-)

Best regards,
Garvin

Posted: Tue Mar 07, 2006 4:59 pm
by SHRIKEE
well it didnt work, when i put the function somewhere else it worked...

Posted: Tue Mar 07, 2006 8:49 pm
by SHRIKEE
is there any way to just run a query like this

$container[$i] = serendipity_db_query("SELECT count(visits) FROM blehblehtablename WHERE year='$year' AND month='$month'", true);

without getting the result put in a array or some other stupid value?
I just need a number returned.

thanks!