WP ShortStat 1.2 Modification

I wondered this morning why the data looked quite odd in WP ShortStat 1.2. After analyzing the PHP, I noticed the column “Hits in the last week” and a few other parts are calculated with a wrong date. I modified the following parts, and now the data output expresses the identic values which are found in the database. I hope Jeff will test these changes… and include them in the official version (open the article to read the code changes).

function getTodaysHits() {
global $wpdb;
$dt = time();
$dt = mktime(0, 0, 0, date(”m”,$dt), date(”d”,$dt), date(”Y”,$dt));

$query = “SELECT COUNT(*) AS ‘total’ FROM $this->table_stats WHERE dt >= $dt”;
return $wpdb->get_var($query);
}

function getTodaysUniqueHits() {
global $wpdb;
$dt = time();
$dt = mktime(0, 0, 0, date(”m”,$dt), date(”d”,$dt), date(”Y”,$dt));

$query = “SELECT COUNT(DISTINCT remote_ip) AS ‘total’ FROM $this->table_stats WHERE dt >= $dt”;
return $wpdb->get_var($query);
}

function getWeeksHits() {
global $wpdb;

$tmp = “”;
$dt_start = time();

$tmp = “<table cellpadding=\”0\” cellspacing=\”0\” border=\”0\”>\n”;
$tmp .= “\t<tr><th colspan=\”2\”>Hits in the last week</th></tr>\n”;
$tmp .= “\t<tr><td class=\”accent\”>Day</td><td class=\”accent last\”>Hits</td></tr>\n”;

for ($i=0; $i<7; $i++) {

$dt_start = mktime(0, 0, 0, date(”m”,$dt_start), date(”d”,$dt_start), date(”Y”,$dt_start));
$dt_stop = $dt_start;
$dt_start = $dt_start - (60 * 60 * 24);
$day = date(”l, j M Y”,$dt_start);

$query = “SELECT COUNT(*) AS ‘total’ FROM $this->table_stats WHERE dt > $dt_start AND dt <=$dt_stop";
if ($total = $wpdb->get_var($query)) {
$tmp .= “\t<tr><td>$day</td><td class=\”last\”>$total</td></tr>\n”;
}
}
$tmp .= “</table>”;
return $tmp;
}

Link speichern...

3 Antworten to “WP ShortStat 1.2 Modification”


  1. 1 Robert Aug 27th, 2005 at 12:57

    take a look at SlimStat: http://wettone.com/code/slimstat

    and a user experience
    Einfach-Persoenlich.de

    SlimStat is better since it doesnt produce such a huge datasize (a so called “pruning”-process deleting old datas)

  2. 2 Mike Aug 27th, 2005 at 13:22

    Thanks! That’s what I’ve been searching for. Guess you using it too, Robert? ;)

  3. 3 Robert Aug 27th, 2005 at 15:34

    nope, not yet, since an error ocurred during the creation of the database table. I have to contact the developer of SlimStat to solve the problem.

Kommentare sind geschlossen.

Mein Name ist Mike Schnoor und ich präsentiere dem frivolen Internetuser ein erstklassig privat geführtes Medienblog. Die Themen siedeln sich zentral in der Medienwelt an: Web 2.0, Weblogs, Video on Demand, TV, Radio, Print, Medien, Marketing und Kommunikation.

Wer anderer Meinung ist, erreicht mich schnell über das Kontaktformular.

Subscribe to Bloglines TopBlogs.de


© Copyright 1997-2007 by Mike Schnoor. All rights reserved. Telagon Sichelputzer is powered by WordPress: RSS Beiträge und RSS Kommentare
Über uns | Archiv | Kontakt | Login | Datenschutz | Impressum