diff --git a/trunk/ACHTUNG_Updater.txt b/trunk/ACHTUNG_Updater.txt
new file mode 100644
index 0000000..86eb2c5
--- /dev/null
+++ b/trunk/ACHTUNG_Updater.txt
@@ -0,0 +1,10 @@
+
+UPDATE auf Version 3.3:
+
+Es ist zwingend erforderlich, SEMMELSTATZ zu deaktivieren und den alten Ordner
+SEMMELSTATZ aus dem Plugin-Verzeichnis zu löschen. Ein simples Überschreiben der
+Plugin-Dateien funktioniert nicht, da sich die Namen der Dateien geändert haben.
+Außerdem werden diverse Änderungen an den STATZ-Tabellen vorgenommen, die aber nur
+bei Aktivierung des Plugins abgearbeitet werden.
+
+Ich bitte um Beachtung...
\ No newline at end of file
diff --git a/trunk/img/arin.png b/trunk/img/arin.png
new file mode 100644
index 0000000..cdf3081
Binary files /dev/null and b/trunk/img/arin.png differ
diff --git a/trunk/img/icon_observe.png b/trunk/img/icon_observe.png
new file mode 100644
index 0000000..14fbffc
Binary files /dev/null and b/trunk/img/icon_observe.png differ
diff --git a/trunk/img/icon_template.png b/trunk/img/icon_template.png
new file mode 100644
index 0000000..ad4fc9a
Binary files /dev/null and b/trunk/img/icon_template.png differ
diff --git a/trunk/img/ripe.png b/trunk/img/ripe.png
new file mode 100644
index 0000000..8da70ba
Binary files /dev/null and b/trunk/img/ripe.png differ
diff --git a/trunk/img/statz.png b/trunk/img/statz.png
new file mode 100644
index 0000000..af8bfdd
Binary files /dev/null and b/trunk/img/statz.png differ
diff --git a/trunk/img/statz_small.png b/trunk/img/statz_small.png
new file mode 100644
index 0000000..eee9f5c
Binary files /dev/null and b/trunk/img/statz_small.png differ
diff --git a/trunk/img/utrace.png b/trunk/img/utrace.png
new file mode 100644
index 0000000..f59a10d
Binary files /dev/null and b/trunk/img/utrace.png differ
diff --git a/trunk/lies_mich.txt b/trunk/lies_mich.txt
new file mode 100644
index 0000000..d528d1b
--- /dev/null
+++ b/trunk/lies_mich.txt
@@ -0,0 +1,18 @@
+ ******************************************************
+ * *
+ * SEMMELSTATZ *
+ * Statistik-Plugin für Wordress >= 2.7.x *
+ * *
+ ******************************************************
+
+Plugin-URL: http://www.kopfhoch-studio.de/blog/2765
+Autor: Andreas Müller aka Redunzl Semmelmann
+Copyright (c) 2005-2009 Andreas Müller & kopfhoch-studio Waiblingen, Deutschland
+
+Die komplette Dokumentation befindet sich im Blog:
+
+*******************************************
+* *
+* http://www.kopfhoch-studio.de/blog/2765 *
+* *
+*******************************************
\ No newline at end of file
diff --git a/trunk/semmelstatz-database.php b/trunk/semmelstatz-database.php
new file mode 100644
index 0000000..609a284
--- /dev/null
+++ b/trunk/semmelstatz-database.php
@@ -0,0 +1,82 @@
+prefix; $lenpre = strlen($pre);
+ $tablesstatus = $wpdb->get_results("SHOW TABLE STATUS");
+
+ print "
";
+
+?>
\ No newline at end of file
diff --git a/trunk/semmelstatz-history.php b/trunk/semmelstatz-history.php
new file mode 100644
index 0000000..b5d1fbf
--- /dev/null
+++ b/trunk/semmelstatz-history.php
@@ -0,0 +1,189 @@
+get_results("ALTER TABLE ".$wpdb->statzhist." ORDER BY date ASC");
+ $results = $wpdb->get_results("SELECT DAY(date) as days, visitors FROM ".$wpdb->statzhist." WHERE date >= NOW() - INTERVAL 31 DAY");
+
+ print "
Besucher: Die letzten 30 Tage
";
+ print "
";
+
+ if (empty($results)) {
+ print "... noch keine Einträge
";
+
+ print "";
+ print "";
+ }
+
+### HISTORY Monatsgrafik GOOGLE-API
+
+ function sem_drawAllMonthGoo() {
+ global $wpdb;
+
+ $nummonths = $wpdb->get_var("SELECT MONTH(date) FROM ".$wpdb->statzhist);
+ $results = $wpdb->get_results("SELECT MONTH(date) as months, SUM(visitors) as visitors FROM ".$wpdb->statzhist." GROUP BY months ORDER BY date ASC");
+
+ print "
Besucher: Die letzten ".$nummonths." Monate
";
+ print "
";
+
+ if (empty($results)) {
+ print "... noch keine Einträge
";
+
+ print "";
+ print "";
+ }
+
+### HISTORY ALLE historischen Tage
+
+ function sem_drawAllDaysGoo() {
+ global $wpdb;
+
+ $numdays = $wpdb->get_var("SELECT COUNT(date) FROM ".$wpdb->statzhist);
+
+ $results = $wpdb->get_results("SELECT referers, visitors, hits, substring(date,1,10) AS date
+ FROM ".$wpdb->statzhist." GROUP BY date ORDER BY date ASC");
+ $visitors=$totaldays->visitors;
+
+ print "
Besucher: ".$numdays." Tage zurück
";
+ print "
";
+
+ if (empty($results)) {
+ print "... noch keine Einträge
";
+
+ print "";
+ print "";
+ }
+
+ function sem_showAllDaysInNumbers() {
+ global $wpdb;
+
+ $numdays = $wpdb->get_var("SELECT COUNT(date) as num FROM $wpdb->statzhist");
+
+ $results = $wpdb->get_results("SELECT referers, visitors, hits, substring(date,1,10) AS date
+ FROM ".$wpdb->statzhist." GROUP BY date ORDER BY date DESC");
+
+ print "
Die letzten ".$numdays." Tage
";
+ if (empty($results)) {
+ print "... noch keine Einträge";
+ return;
+ }
+ print "
";
+
+?>
\ No newline at end of file
diff --git a/trunk/semmelstatz-log.php b/trunk/semmelstatz-log.php
new file mode 100644
index 0000000..e9a93ba
--- /dev/null
+++ b/trunk/semmelstatz-log.php
@@ -0,0 +1,113 @@
+get_results("SELECT id, ip, time, referer, page, username FROM ".$wpdb->statz." ORDER BY time DESC LIMIT 0, ".$limit);
+
+ print "
";
+ print "
";
+ print "
Semmelstatz › Log
";
+ print "
Die neuesten ".$limit." Datensätze
";
+
+ if ($completerecords == NULL) {
+ print "... noch keine Einträge";
+ return;
+ }
+
+ print "
";
+
+?>
\ No newline at end of file
diff --git a/trunk/semmelstatz-options.php b/trunk/semmelstatz-options.php
new file mode 100644
index 0000000..044757b
--- /dev/null
+++ b/trunk/semmelstatz-options.php
@@ -0,0 +1,344 @@
+
+ statz-Tabelle: ,xx Tage (Der aktuelle Tag ist natürlich nie komplett!!!)
+ statzhist-Tabelle: Tage
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/trunk/semmelstatz-statz.php b/trunk/semmelstatz-statz.php
new file mode 100644
index 0000000..2d17d7b
--- /dev/null
+++ b/trunk/semmelstatz-statz.php
@@ -0,0 +1,501 @@
+get_results("SELECT DISTINCT username, page, ip, time
+ FROM ".$wpdb->statz." WHERE time > Now() - INTERVAL ".$onlinetime." SECOND GROUP BY ip ORDER BY page DESC");
+
+ print "
";
+ print "";
+ }
+
+ function sem_draw24HoursGoo() {
+ global $wpdb;
+
+ $results = $wpdb->get_results("SELECT time as hours, COUNT(DISTINCT ip) as visitors
+ FROM ".$wpdb->statz." WHERE time >= NOW() - INTERVAL 23 HOUR GROUP BY HOUR(time) ORDER BY time ASC");
+
+ print "
Besucher: Die letzten 24 Stunden
";
+ print "
";
+
+ if (empty($results)) {
+ print "... noch keine Einträge
";
+ print "";
+ print "";
+ }
+
+ function sem_showDailyStatz() {
+ global $wpdb;
+
+ $sem_options = get_option('semmelstatz_options'); ### optionsarray auslesen
+ $limit = $sem_options["statz_days_limit"];
+ $daylimit = $limit - 1;
+
+ $thedays = $wpdb->get_results("SELECT COUNT(ip) AS hits, COUNT(DISTINCT ip) AS visitors, COUNT(DISTINCT referer)
+ AS referers, substring(time,1,10) AS date FROM ".$wpdb->statz." WHERE time >= CURDATE() - INTERVAL ".$daylimit." DAY
+ GROUP BY date ORDER BY time DESC");
+
+ print "
".$limit."-Tage-Statistik
";
+ if (empty($thedays)) {
+ print "... noch keine Einträge";
+ print "";
+ return;
+ }
+ print "
";
+ print "";
+ }
+
+ function sem_showTodayTopReads() {
+ global $wpdb;
+ $today = date("Y-m-d");
+ $topreads = $wpdb->get_results("SELECT post_title AS posttitle, post_name as postname, guid AS postid,
+ COUNT(".$wpdb->statz.".page) AS count FROM ".$wpdb->posts.", ".$wpdb->statz." WHERE
+ ".$wpdb->statz.".page = ".$wpdb->posts.".ID AND time >= '$today' GROUP BY postid ORDER BY count DESC LIMIT 10");
+
+ print "
Die Top10 aller Posts & Pages heute
";
+ if (empty($topreads)) {
+ print "... noch keine Einträge";
+ print "";
+ return;
+ }
+ print "
";
+ print "";
+ }
+
+ function sem_showWhoWasOnlineToday() {
+ global $wpdb;
+ $today = date("Y-m-d");
+ $todaysonlineusers = $wpdb->get_results("SELECT DISTINCT username, COUNT(username) as num FROM ".$wpdb->statz." WHERE
+ time >= '$today' AND username != 'Gast' GROUP BY username ORDER BY num DESC");
+
+ print "
Bekannte Besucher heute
";
+ if (empty($todaysonlineusers)) {
+ print "... noch keine Einträge";
+ print "";
+ return;
+ }
+ print "
";
+ print "";
+ }
+
+ function sem_showTopCommented() {
+ global $wpdb;
+ $topcommentedposts = $wpdb->get_results("SELECT guid, id, post_title, COUNT(*) AS count FROM
+ ".$wpdb->comments.",". $wpdb->posts." WHERE comment_approved = '1' AND comment_post_id = id
+ GROUP BY guid ORDER BY count DESC LIMIT 0, 10");
+
+ print "
Die Top10 aller kommentierter Posts
";
+ if (empty($topcommentedposts)) {
+ print "... noch keine Einträge";
+ print "";
+ return;
+ }
+
+ print "
";
+ $sem_options = get_option('semmelstatz_options'); ### optionsarray auslesen
+ if ($sem_options["statz_show_useronline"]) sem_showWhoIsOnline();
+ sem_draw24HoursGoo();
+ if ($sem_options["statz_show_todayusers"]) sem_showWhoWasOnlineToday();
+ if ($sem_options["statz_show_dailystatz"]) sem_showDailyStatz();
+ if ($sem_options["statz_show_referers"]) sem_showReferers();
+ if ($sem_options["statz_show_keywords"]) sem_showKeyword();
+ if ($sem_options["statz_show_todayreads"]) sem_showTodayTopReads();
+ if ($sem_options["statz_show_reads"]) sem_showTopReads();
+ if ($sem_options["statz_show_topcommposts"]) sem_showTopCommented();
+ if ($sem_options["statz_show_commenters"]) sem_showCommenters();
+ sem_showCopyright();
+ print "
";
+
+?>
\ No newline at end of file
diff --git a/trunk/semmelstatz-templates.php b/trunk/semmelstatz-templates.php
new file mode 100644
index 0000000..9966562
--- /dev/null
+++ b/trunk/semmelstatz-templates.php
@@ -0,0 +1,217 @@
+";
+ print "
";
+ print "
";
+ print "
Semmelstatz › Template-Funktionen
";
+ print " ";
+ print "
";
+ print "";
+ print "
";
+ print "
Funktion
";
+ print "
Syntax
";
+ print "
Rückgabewert
";
+ print "
Hier
";
+ print "
Bemerkung
";
+ print "
";
+ print "";
+ print "";
+
+ print "
";
+ print "
sem_showTotalPosts
";
+ print "
";
+ print "
Ganzzahl
";
+ print "
$totalposts
";
+ print "
Anzahl aller Beiträge
";
+ print "
";
+
+ print "
";
+ print "
sem_showTotalComments
";
+ print "
";
+ print "
Ganzzahl
";
+ print "
$totalcomments
";
+ print "
Anzahl aller Kommentare
";
+ print "
";
+
+ print "
";
+ print "
sem_showTotalUsers
";
+ print "
";
+ print "
Ganzzahl
";
+ print "
$totalusers
";
+ print "
Gesamtzahl aller Besucher seit Statistikaufzeichnung
";
+ print "
";
+
+ print "
";
+ print "
sem_showAverageUserPerDay
";
+ print "
";
+ print "
Dezimal
";
+ print "
$averageuserperday
";
+ print "
Durchschnittliche Anzahl der täglichen Besucher
";
+ print "
";
+
+ print "
";
+ print "
sem_showFirstPostDate
";
+ print "
";
+ print "
Datum (d.m.y)
";
+ print "
$firstpostdate
";
+ print "
Datum des 1. Posts
";
+ print "
";
+
+ print "
";
+ print "
sem_showPostDays
";
+ print "
";
+ print "
Ganzzahl
";
+ print "
$postdays
";
+ print "
Zeitraum in Tagen seit 1. Beitrag
";
+ print "
";
+
+ print "
";
+ print "
em_showFirstCommentDate
";
+ print "
";
+ print "
Datum (d.m.y)
";
+ print "
$firstcommentdate
";
+ print "
Datum des 1. Kommentars
";
+ print "
";
+
+ print "
";
+ print "
sem_showCommentDays
";
+ print "
";
+ print "
Ganzzahl
";
+ print "
$commentdays
";
+ print "
Zeitraum in Tagen seit 1. Kommentar
";
+ print "
";
+
+ print "
";
+ print "
sem_showPostsPerDay
";
+ print "
";
+ print "
Dezimal
";
+ print "
$postsperday
";
+ print "
Durchschnittliche Anzahl der Beiträge pro Tag
";
+ print "
";
+
+ print "
";
+ print "
sem_showCommentsPerDay
";
+ print "
";
+ print "
Dezimal
";
+ print "
$commentsperday
";
+ print "
Durchschnittliche Anzahl der Kommentare pro Tag
";
+ print "
";
+
+ print "
sem_showNumCommenters
";
+ print "
";
+ print "
Ganzzahl
";
+ print "
$numcommenters
";
+ print "
Gesamtzahl aller Kommentierer
";
+ print "";
+
+ print "
";
+ print "
sem_showStatzStartDate
";
+ print "
";
+ print "
Datum (d.m.y)
";
+ print "
$statzstartdate
";
+ print "
Beginn der Statistik
";
+ print "
";
+
+ print "
";
+ print "
sem_showStatzDays
";
+ print "
";
+ print "
Ganzzahl
";
+ print "
$statzdays
";
+ print "
Zeitraum der Statistik in Tagen
";
+ print "
";
+
+ print "
";
+ print "
sem_showNumUsersOnline
";
+ print "
";
+ print "
Ganzzahl
";
+ print "
$numusersonline
";
+ print "
User Online
";
+ print "
";
+
+ print "
";
+ print "
sem_showLastComments
";
+ print "
";
+ print "
Formatierte Liste
";
+ print "
n/a
";
+ print "
Die neusten 'n' Kommentare mit Autor, Post, abwärts sortiert nach Datum CSS-ID: #lastcomments
";
+ print "
";
+
+ print "
";
+ print "
sem_showLastPosts
";
+ print "
";
+ print "
Formatierte Liste
";
+ print "
n/a
";
+ print "
Die neusten 'n' Posts mit Titel, abwärts sortiert nach Datum CSS-ID: #lastposts
";
+ print "
";
+
+ print "
";
+ print "
sem_showMostReads
";
+ print "
";
+ print "
Formatierte Liste
";
+ print "
n/a
";
+ print "
Die 'n' meist gelesenen Post/Pages mit Hits in Klammern CSS-ID: #mostreads
";
+ print "
";
+
+ print "
";
+ print "
sem_showPostHitsInLoop
";
+ print "
";
+ print "
Ganzzahl
";
+ print "
Nur im Loop
";
+ print "
Zeigt die Anzahl der Hits eines Posts an. Funktioniert nur im LOOP.
";
+ print "
";
+
+ print "
";
+ print "
";
+ print "Sämtliche Funktionen (bis auf die letzte) sind außerhalb des LOOPS zu verwenden. Wird
+ SEMMELSTATZ deaktiviert, und die Verfügbarkeit der Templatefunktion ist nicht mittels
+ if (function_exists... sichergestellt, wird die Indexseite des Blogs fehlerhaft bzw.
+ überhaupt nicht dargestellt.";
+ print "
";
+ }
+
+### statz-Tabelle leeren (NICHT LÖSCHEN!!!)
+ function sem_truncateStatzTable() {
+ global $wpdb, $userip;
+ $wpdb->query('TRUNCATE TABLE '.$wpdb->statz);
+ sem_optStatzTable();
+ $wpdb->query("INSERT INTO `$wpdb->statz`(ip, time, referer, page, username) VALUES('127.0.0.1', NOW(),NULL,0,'statz-Tabelle geleert')");
+ }
+
+### Obsolet, bleibt aber aus Kompatibilitätsgründen zu SEMMELSTATZ_DELETE
+ function sem_delOldRecords($days) {
+ return true;
+ }
+
+### simpleEncoding für die GoogleChartAPI
+ function sem_encodeChartData($values) {
+
+ $maxValue = max($values);
+ $simpleEncoding = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
+ $chartData = "s:";
+ for ($i = 0; $i < count($values); $i++) {
+ $currentValue = $values[$i];
+
+ if ($currentValue > -1) {
+ $chartData.=substr($simpleEncoding,61*($currentValue/$maxValue),1);
+ }
+ else {
+ $chartData.='_';
+ }
+ }
+ return $chartData;
+ }
+
+### Datensätze älter als statz_recdays_limit-Tage löschen
+ function sem_delOutOfLimit() {
+ global $wpdb;
+ $sem_options = get_option('semmelstatz_options'); ### optionsarray auslesen
+ $today = time(); $days = $sem_options["statz_recdays_limit"];
+ $enddatum = $today - ($days * 86400);
+ $enddatum = date("Y-m-d", $enddatum) . " 23:59:59";
+ $wpdb->query("DELETE FROM ".$wpdb->statz." WHERE time <= '".$enddatum."'");
+ sem_optStatzTable();
+ }
+
+### Wenn AUTOMATISCHES LIMIT aktiviert, dann LIMITIERE und erhöhe NEXT_CRON
+ function sem_doCronStatzLimit() {
+ sem_delOutOfLimit();
+ $sem_options = get_option('semmelstatz_options'); ### optionsarray auslesen
+ $statz_next_cron = $sem_options["statz_next_cron"] + 86400;
+ $sem_options["statz_next_cron"] = $statz_next_cron;
+ update_option("semmelstatz_options", $sem_options);
+ }
+
+### Konvertiert Strings von utf-8 in ISO-8859
+ function sem_encodeToIso($string) {
+ return mb_convert_encoding($string, "ISO-8859-1", mb_detect_encoding($string, "UTF-8, ISO-8859-1, ISO-8859-15", true));
+ }
+
+### statz-Tabelle optimieren
+ function sem_optStatzTable() {
+ global $wpdb;
+ $wpdb->query("OPTIMIZE TABLE ".$wpdb->statz);
+ }
+
+### Unter bestimmten Voraussetzungen den Vortag in die statzhist-Tabelle schreiben
+ function sem_writeYesterdayToHist() {
+ global $wpdb;
+ if(!$wpdb->get_var("SELECT date FROM ".$wpdb->statzhist." WHERE substring(date,1,10) = DATE_SUB(CURDATE(), INTERVAL 1 DAY)")) {
+
+ if($wpdb->get_var("SELECT COUNT(ip) FROM ".$wpdb->statz." WHERE substring(time,1,10) = DATE_SUB(CURDATE(), INTERVAL 1 DAY)")) {
+
+ $yesterdays = $wpdb->get_results("SELECT COUNT(ip) AS hits, COUNT(DISTINCT ip) AS visitors, COUNT(DISTINCT referer)
+ AS referers, substring(time,1,10) AS date FROM ".$wpdb->statz." WHERE substring(time,1,10) = DATE_SUB(CURDATE(),
+ INTERVAL 1 DAY) GROUP BY date");
+
+ foreach ($yesterdays as $yesterday) {
+ $date = $yesterday->date;
+ $visitors = $yesterday->visitors;
+ $hits = $yesterday->hits;
+ $referers = $yesterday->referers;
+ }
+
+ $sql = $wpdb->query("INSERT INTO ".$wpdb->statzhist." (date, referers, visitors, hits)
+ VALUES('$date', $referers, $visitors, $hits)");
+ }
+ else {
+ $date = $wpdb->get_var("SELECT DATE_SUB(CURDATE(), INTERVAL 1 DAY)");
+ $sql = $wpdb->query("INSERT INTO ".$wpdb->statzhist." (date, referers, visitors, hits) VALUES('$date', 0, 0, 0)");
+ }
+ }
+ }
+
+### Summen der vergangenen Tage in die statzhist schreiben */
+ function sem_writeOldDaysToHist() {
+ global $wpdb;
+ if(!$wpdb->get_var("SELECT date FROM ".$wpdb->statzhist." WHERE substring(date,1,10) <= DATE_SUB(CURDATE(), INTERVAL 1 DAY)")) {
+
+ $theolddays = $wpdb->get_results("SELECT COUNT(ip) AS hits, COUNT(DISTINCT ip) AS visitors,
+ COUNT(DISTINCT referer) AS referers, substring(time,1,10) AS date FROM ".$wpdb->statz." WHERE
+ substring(time,1,10) <= DATE_SUB(CURDATE(), INTERVAL 1 DAY) GROUP BY date ORDER BY time ASC");
+
+ foreach ($theolddays as $theoldday) {
+ $date = $theoldday->date;
+ $visitors = $theoldday->visitors; if(!$visitors) $visitors = 0;
+ $hits = $theoldday->hits; if(!$hits) $hits = 0;
+ $referers = $theoldday->referers; if(!$referers) $referers = 0;
+ $sql = $wpdb->query("INSERT INTO ".$wpdb->statzhist." (date, referers, visitors, hits)
+ VALUES('$date', $referers, $visitors, $hits)");
+ }
+ }
+ }
+
+############################################## Ende SEMMELSTATZ-interne Funktionen
+
+############################################## Beginn TEMPLATE-Funktionen
+
+### Zeigt die letzten $num_posts-Posts an: Titel und absolutes Datum - CSS-id: #lastposts
+ function sem_showLastPosts($num_posts = 10) {
+ global $wpdb;
+ $lastposts = $wpdb->get_results("SELECT ID, post_title FROM ".$wpdb->posts." WHERE post_status = 'publish'
+ AND post_type = 'post' ORDER BY post_date DESC LIMIT 0, ".$num_posts);
+ print "
";
+ if (empty($lastposts)) {
+ print "... noch keine Beiträge";
+ }
+ else {
+ print "Die letzten ".$num_posts." Beiträge ";
+ foreach ($lastposts as $lastpost) {
+ $posttitle = $lastpost->post_title;
+ $permalink = get_permalink($lastpost->ID);
+ $postdate = $lastpost->post_date;
+ print "".$posttitle." \n";
+ }
+ }
+ print "
";
+ }
+
+### Zeigt die letzten $num_comments-Kommentare an: Autor und Post mit relativem Datum - CSS-id: #lastcomments
+ function sem_showLastComments($num_comments = 10) {
+ global $wpdb;
+ $comments = $wpdb->get_results("SELECT comment_author, comment_ID, comment_post_ID, comment_date
+ FROM ".$wpdb->comments." WHERE comment_approved = '1' ORDER BY comment_date DESC LIMIT 0, $num_comments");
+ print "
";
+ }
+
+### Zeigt die $num_reads meist gelesenen Posts an - CSS-id: #mostreads
+ function sem_showMostReads($num_reads = 10) {
+ global $wpdb;
+ $mostreads = $wpdb->get_results("SELECT post_title AS posttitle, guid AS postid, hits AS hits FROM ".$wpdb->posts." WHERE hits != '0' GROUP BY postid ORDER BY hits DESC LIMIT 0, $num_reads");
+ print "
";
+ if (empty($mostreads)) {
+ print "... noch keine Einträge";
+ }
+ else {
+ print "Die ".$num_reads." meist gelesenen Beiträge ";
+ foreach ($mostreads as $mostread) {
+ $posttitle = $mostread->posttitle;
+ $postid = $mostread->postid;
+ //$permalink = get_permalink($mostread->postid);
+ $hits = $mostread->hits;
+ print "".$posttitle." (".$hits.") \n";
+ }
+ }
+ print "
";
+ }
+
+### Zeigt die $num_reads meist gelesenen Posts an - CSS-id: #mostreads - ACHTUNG: Das Ergebnis der Funktion basiert auf der statz-Tabelle
+ function sem_showMostReadsOld($num_reads = 10) {
+ global $wpdb;
+ $mostreads = $wpdb->get_results("SELECT post_title AS posttitle, ".$wpdb->posts.".guid AS postid,
+ COUNT(".$wpdb->statz.".page) AS count FROM ".$wpdb->posts.", ".$wpdb->statz." WHERE
+ ".$wpdb->statz.".page = ".$wpdb->posts.".ID GROUP BY postid ORDER BY count DESC LIMIT 0, $num_reads");
+ print "
";
+ if (empty($mostreads)) {
+ print "... noch keine Einträge";
+ }
+ else {
+ print "Die ".$num_reads." meist gelesenen Beiträge ";
+ foreach ($mostreads as $mostread) {
+ $posttitle = $mostread->posttitle;
+ $postid = $mostread->postid;
+ //$permalink = get_permalink($mostread->postid);
+ $count = $mostread->count;
+ print "".$posttitle." (".$count.") \n";
+ }
+ }
+ print "
";
+ }
+
+### Zeigt die $num_commented meist kommentierten Posts an - CSS-id: #mostcommented
+ function sem_showMostCommented($num_commented = 10) {
+ global $wpdb;
+ $mostcommented = $wpdb->get_results("SELECT guid, id, post_title, COUNT(*) AS count FROM ".$wpdb->comments.",". $wpdb->posts." WHERE
+ comment_approved = '1' AND comment_post_id = id GROUP BY id, post_title ORDER BY count DESC LIMIT 0, $num_commented");
+
+ print "
";
+ if (empty($mostcommented)) {
+ print "... noch keine Einträge";
+ }
+ else {
+ print "Die ".$num_commented." meist kommentierten Beiträge ";
+
+ foreach ($mostcommented as $key => $mostcommented) {
+ $posttitle = $mostcommented->post_title;
+ $count = $mostcommented->count;
+ $postid = $mostcommented->guid;
+ print "".$posttitle." (".$count.") \n";
+ }
+ }
+ print "
";
+ }
+
+### Zeigt einen Zähler der Hits im jeweiligen Post. ACHTUNG: FUNKTIONIERT NUR IM LOOP (index.php, single.php)
+ function sem_showPostHitsInLoop($postid) {
+ global $wpdb;
+ $hits = $wpdb->get_var("SELECT hits FROM $wpdb->posts WHERE ID = $postid LIMIT 0,1");
+ return $hits;
+ }
+
+### Anzahl aller Posts/Pages
+ function sem_showTotalPosts() {
+ global $wpdb;
+ $totalposts = $wpdb->get_var("SELECT COUNT(ID) AS num FROM ".$wpdb->posts." WHERE post_status = 'publish' LIMIT 0,1");
+ return $totalposts; // Ganzzahl
+ }
+
+### Anzahl aller Kommentare
+ function sem_showTotalComments() {
+ global $wpdb;
+ $totalcomments = $wpdb->get_var("SELECT COUNT(comment_ID) AS num FROM ".$wpdb->comments." WHERE comment_approved = '1' LIMIT 0,1");
+ return $totalcomments; // Ganzzahl
+ }
+
+### Anzahl aller User seit Beginn der Statzaufzeichnung
+ function sem_showTotalUsers() {
+ global $wpdb;
+ $totalusers = $wpdb->get_var("SELECT SUM(visitors) FROM ".$wpdb->statzhist." LIMIT 0,1");
+ if(!$totalusers) $totalusers = 0;
+ return $totalusers; // Ganzzahl
+ }
+
+### Anzahl User pro Tag im Durchschnitt
+ function sem_showAverageUserPerDay() {
+ $averageuser = ceil(sem_showTotalUsers() / sem_showStatzDays());
+ return $averageuser;
+ }
+
+### Datum des 1. Posts = Blogstart
+ function sem_showFirstPostDate() {
+ global $wpdb;
+ $firstpostdate = $wpdb->get_var("SELECT MIN(post_date) FROM ".$wpdb->posts." WHERE post_status = 'publish' AND post_date != '0000-00-00 00:00:00' LIMIT 0,1");
+ $firstpostdate = mysql2date("j.n.Y", $firstpostdate);
+ return $firstpostdate; // String T.M.JJJJ
+ }
+
+### Datum des 1. Kommentars
+ function sem_showFirstCommentDate() {
+ global $wpdb;
+ $firstcommentdate = $wpdb->get_var("SELECT MIN(comment_date) FROM ".$wpdb->comments." WHERE comment_approved = '1'
+ AND comment_date != '0000-00-00 00:00:00' LIMIT 0,1");
+ $firstcommentdate = mysql2date("j.n.Y", $firstcommentdate);
+ return $firstcommentdate; // String T.M.JJJJ
+ }
+
+### Anzahl der Kommentierer nach Nicknamen
+ function sem_showNumCommenters() {
+ global $wpdb;
+ $totalcommenters = $wpdb->get_var("SELECT COUNT(DISTINCT comment_author) FROM ".$wpdb->comments." WHERE comment_approved = '1' LIMIT 0,1");
+ if(!$totalcommenters) $totalcommenters = 0;
+ return $totalcommenters; // Ganzzahl
+ }
+
+### Blog besteht seit x Tagen
+ function sem_showPostDays() {
+ global $wpdb;
+ $firstdate = $wpdb->get_var("SELECT MIN(post_date) AS date FROM ".$wpdb->posts." WHERE post_status = 'publish' AND post_date != '0000-00-00 00:00' LIMIT 0,1");
+ $firstdate = strtotime($firstdate); $now = time();
+ $blogdays = (int) (($now - $firstdate) / (60*60*24));
+ $blogdays = $blogdays + 1;
+ return $blogdays; // Ganzzahl
+ }
+
+### Tage seit 1. Kommentar
+ function sem_showCommentDays() {
+ global $wpdb;
+ $firstdate = $wpdb->get_var("SELECT MIN(comment_date) AS date FROM ".$wpdb->comments." LIMIT 0,1");
+ $firstdate = strtotime($firstdate); $now = time();
+ $commentdays = (int) (($now - $firstdate) / (60*60*24));
+ $commentdays = $commentdays + 1;
+ return $commentdays; // Ganzzahl
+ }
+
+### durchschn. Posts pro Tag
+ function sem_showPostsPerDay() {
+ global $wpdb;
+ $postsperday = (int) sem_showTotalPosts() / (int) sem_showPostDays();
+ return $postsperday; // Ganzzahl
+ }
+
+### durchschn. Kommentare pro Tag
+ function sem_showCommentsPerDay() {
+ global $wpdb;
+ $commentsperday = (int) sem_showTotalComments() / (int) sem_showCommentDays();
+ return $commentsperday; // Ganzzahl
+ }
+
+### Startdatum der Gesamtstatistik (Basis: statzhist)
+ function sem_showStatzStartDate() {
+ global $wpdb;
+ $statzhiststartdate = $wpdb->get_var("SELECT MIN(date) FROM ".$wpdb->statzhist." WHERE date != '0000-00-00 00:00' LIMIT 0,1");
+ $statzhiststartdate = mysql2date("j.n.Y", $statzhiststartdate);
+ // if(!$statzhiststartdate) $statzhiststartdate= "xx.xx.xxxx";
+ return $statzhiststartdate; // String T.M.JJJJ
+ }
+
+### Dauer der Statistikaufzeichnung in Tagen (Basis: statzhist)
+ function sem_showStatzDays() {
+ global $wpdb;
+ $firstdate = $wpdb->get_var("SELECT MIN(date) FROM ".$wpdb->statzhist." LIMIT 0,1");
+ if(!$firstdate) {
+ return 1;
+ }
+ else {
+ $firstdate = strtotime($firstdate); $now = time();
+ $statzdays = (int) (($now - $firstdate) / (60*60*24));
+ return $statzdays; // Ganzzahl
+ }
+ }
+
+### Anzahl der Online-Besucher - Verweildauer in den Einstellungen
+ function sem_showNumUsersOnline() {
+ global $wpdb;
+ $sem_options = get_option('semmelstatz_options'); ### optionsarray auslesen
+ $onlinetime = $sem_options["statz_online_time"];
+ $numonline = $wpdb->get_var("SELECT COUNT(DISTINCT ip) FROM ".$wpdb->statz." WHERE time > Now() - INTERVAL ".$onlinetime." SECOND");
+ return $numonline; // Ganzzahl
+ }
+
+### Anzahl der heutigen Besucher
+ function sem_showUsersToday() {
+ global $wpdb; $today = date("Y-m-d");
+ $todayusers = $wpdb->get_var("SELECT COUNT(DISTINCT ip) FROM ".$wpdb->statz." WHERE time >= '$today' LIMIT 0, 1");
+ return $todayusers;
+ }
+
+### Anzahl der gestrigen Besucher
+ function sem_showUsersYesterday() {
+ global $wpdb;
+ $yesterdaysusers = $wpdb->get_var("SELECT visitors FROM ".$wpdb->statzhist." WHERE date = substr(DATE_SUB(NOW(), INTERVAL 1 DAY),1,10) LIMIT 0, 1");
+ return $yesterdaysusers;
+ }
+
+##################################################### Ende TEMPLATE-Funktionen
+
+?>
\ No newline at end of file