2011-05-02 09:17:45 +00:00
|
|
|
<?php
|
2011-05-02 10:30:11 +00:00
|
|
|
/**
|
|
|
|
* file semmelstatzR_statz.php
|
|
|
|
*
|
2011-11-14 14:21:22 +00:00
|
|
|
* @package SemmelstatzR
|
|
|
|
* @version $Rev$
|
|
|
|
* @since 1.0.0 Beta
|
|
|
|
* @author SEM-Team
|
|
|
|
* @copyright (c)2011 SEM-Team
|
|
|
|
* @link http://sourceforge.net/projects/semmelstatz/
|
|
|
|
* @license http://www.gnu.org/licenses/gpl-3.0.html
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2011-05-02 10:30:11 +00:00
|
|
|
*
|
|
|
|
* $Id$
|
2011-11-14 14:21:22 +00:00
|
|
|
*
|
2011-05-02 10:30:11 +00:00
|
|
|
*/
|
2011-11-14 14:21:22 +00:00
|
|
|
/**
|
|
|
|
* based upon semmelstatz
|
|
|
|
* Copyright (c) 2005-2009 Andreas 'Redunzl' Mueller (redunzl@gmx.de)
|
|
|
|
*
|
|
|
|
* @license http://www.gnu.org/licenses/gpl-2.0.html
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License (version 2) as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
2011-05-02 09:17:45 +00:00
|
|
|
|
|
|
|
if(!current_user_can('manage_statz')) {
|
|
|
|
die('Zugriff verweigert');
|
|
|
|
}
|
2011-11-14 14:21:22 +00:00
|
|
|
|
|
|
|
include_once plugin_dir_path(__FILE__).'includes/pChart/class/pData.class.php';
|
|
|
|
include_once plugin_dir_path(__FILE__).'includes/pChart/class/pDraw.class.php';
|
|
|
|
include_once plugin_dir_path(__FILE__).'includes/pChart/class/pImage.class.php';
|
2011-05-02 09:17:45 +00:00
|
|
|
### AKTUELL - Funktionen
|
|
|
|
|
|
|
|
function sem_showWhoIsOnline() {
|
|
|
|
global $wpdb;
|
|
|
|
|
2011-05-02 10:30:11 +00:00
|
|
|
$sem_options = get_option('semmelstatzR_options'); ### optionsarray auslesen
|
2011-05-02 09:17:45 +00:00
|
|
|
$onlinetime = $sem_options["statz_online_time"];
|
2011-12-01 17:40:57 +00:00
|
|
|
|
|
|
|
/** @todo add show_vars to semr-config */
|
|
|
|
$sem_options['show_utrace'] = $sem_options['show_whois'] = $sem_options['show_arin'] = true;
|
2011-05-02 09:17:45 +00:00
|
|
|
|
|
|
|
$onlineusers = $wpdb->get_results("SELECT DISTINCT username, page, ip, time
|
|
|
|
FROM ".$wpdb->statz." WHERE time > Now() - INTERVAL ".$onlinetime." SECOND GROUP BY ip ORDER BY page DESC");
|
|
|
|
|
2011-12-01 17:40:57 +00:00
|
|
|
print "<div class='statz'>";
|
|
|
|
$iUsersOnline = (int) sem_showNumUsersOnline();
|
|
|
|
printf("%s ".semr_i18np("Visitor online", "Visitors online", $iUsersOnline), $iUsersOnline);
|
|
|
|
print " - ".semr_i18n("Today").": ".sem_showTodayStatz()."</div>";
|
2011-05-02 09:17:45 +00:00
|
|
|
|
|
|
|
if (empty($onlineusers)) {
|
2011-12-01 17:40:57 +00:00
|
|
|
print "<small>... ".semr_i18n("no entries")."</small>";
|
|
|
|
print "<hr />";
|
2011-05-02 09:17:45 +00:00
|
|
|
return;
|
|
|
|
}
|
2011-12-01 17:40:57 +00:00
|
|
|
print '<table class="statzelement">';
|
|
|
|
print '<thead>';
|
|
|
|
print '<tr>';
|
|
|
|
print '<th style="text-align:left;">'.semr_i18n("Username").'</th>';
|
|
|
|
print '<th style="text-align:left;">'.semr_i18n("Post/Page").'</th>';
|
|
|
|
print '<th style="text-align:left;">'.semr_i18n("TCP/IP").'</th>';
|
|
|
|
print '<th style="text-align:center;">'.semr_i18n("Time").'</th>';
|
|
|
|
print '</tr>';
|
|
|
|
print '</thead>';
|
|
|
|
print '<tbody>';
|
2011-05-02 09:17:45 +00:00
|
|
|
foreach ($onlineusers as $key=>$onlineuser) {
|
|
|
|
$username = $onlineuser->username;
|
|
|
|
$page = $onlineuser->page;
|
|
|
|
if ($page == 0) {
|
|
|
|
$link = get_option('siteurl');
|
2011-12-01 17:40:57 +00:00
|
|
|
$title = semr_i18n("startpage");
|
|
|
|
} else {
|
2011-05-02 09:17:45 +00:00
|
|
|
$link = get_permalink($page);
|
2011-12-01 17:40:57 +00:00
|
|
|
$title = get_post($page);
|
|
|
|
if(is_array($title)) {
|
|
|
|
$title = $title->post_title;
|
|
|
|
} else {
|
|
|
|
$link = null;
|
|
|
|
$title = semr_i18n("no page");
|
|
|
|
}
|
2011-05-02 09:17:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$ip = $onlineuser->ip;
|
|
|
|
if(sem_checkIfIPisEncoded($ip) == true) $ip = sem_decodeIP($ip);
|
|
|
|
$time = mysql2date("H:i",$onlineuser->time);
|
2011-12-01 17:40:57 +00:00
|
|
|
print '<tr'.((1&$key)?' class="alternate">':'>');
|
|
|
|
print '<td style="text-align:left;">'.$username.'</td>';
|
|
|
|
print '<td style="text-align:left;">';
|
|
|
|
print (is_null($link))?$title:'<a target="_blank" href="'.$link.'">'.$title.'</a>';
|
|
|
|
print '</td>';
|
|
|
|
print '<td style="white-space:nowrap;text-align:left;">';
|
|
|
|
if($sem_options['show_arin']) {
|
|
|
|
print '<a target="_blank" href="http://ws.arin.net/whois/?queryinput='.$ip.'">';
|
|
|
|
print '<img src="'.SEMMELSTATZR_HTML_RELPATH.'img/arin.png" alt="" />';
|
|
|
|
print '</a> ';
|
|
|
|
}
|
|
|
|
if($sem_options['show_whois']) {
|
|
|
|
print '<a target="_blank" href="http://www.ripe.net/whois?searchtext='.$ip.'">';
|
|
|
|
print '<img src="'.SEMMELSTATZR_HTML_RELPATH.'img/ripe.png" alt="" />';
|
|
|
|
print '</a> ';
|
|
|
|
}
|
|
|
|
if($sem_options['show_utrace']) {
|
|
|
|
print '<a target="_blank" href="http://www.utrace.de/?query='.$ip.'">';
|
|
|
|
print '<img src="'.SEMMELSTATZR_HTML_RELPATH.'img/utrace.png" alt="" />';
|
|
|
|
print '</a> ';
|
|
|
|
}
|
|
|
|
print '</td>';
|
|
|
|
print '<td style="text-align:center;">'.$time.'</td>';
|
|
|
|
print '</tr>';
|
2011-05-02 09:17:45 +00:00
|
|
|
}
|
2011-12-01 17:40:57 +00:00
|
|
|
print '</tbody>';
|
|
|
|
print '</table>';
|
|
|
|
print "<hr />";
|
2011-05-02 09:17:45 +00:00
|
|
|
}
|
|
|
|
|
2011-12-01 17:40:57 +00:00
|
|
|
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 '<div class="statz">';
|
|
|
|
print semr_i18n("Visitors: Last 24 hours").'</div>';
|
|
|
|
print "<div align='left'>";
|
|
|
|
|
|
|
|
if(empty($results)) {
|
2011-12-17 16:26:57 +00:00
|
|
|
print '<small>... '. semr_i18n("no entries at all").'</small>';
|
2011-12-01 17:40:57 +00:00
|
|
|
print "<hr />";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$aHours = array();
|
|
|
|
$aVisitors = array();
|
|
|
|
$iInterval = 86400-7200;
|
|
|
|
|
|
|
|
for($i=0;$i<24;$i++) {
|
|
|
|
$aHours[$i] = date("H", time() - $iInterval);
|
|
|
|
$iInterval = $iInterval - 3600;
|
|
|
|
$aVisitors[$i] = VOID;
|
|
|
|
}
|
|
|
|
|
|
|
|
$iCount = 0;
|
|
|
|
$bFirst = true;
|
|
|
|
$atemp = array();
|
|
|
|
|
|
|
|
foreach($results as $aResult) {
|
|
|
|
$iDbHour = mysql2date('H', $aResult->hours);
|
|
|
|
$iKey = array_search($iDbHour, $aHours);
|
|
|
|
$aVisitors[$iKey] = $aResult->visitors;
|
2011-11-14 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$MyData = new pData();
|
2011-12-01 17:40:57 +00:00
|
|
|
$MyData->addPoints($aVisitors,"Visitors");
|
2011-11-14 14:21:22 +00:00
|
|
|
$MyData->setAxisName(0,"Visitors");
|
2011-12-01 17:40:57 +00:00
|
|
|
$MyData->addPoints($aHours,"Hours");
|
2011-11-14 14:21:22 +00:00
|
|
|
$MyData->setAbscissa("Hours");
|
2011-12-01 17:40:57 +00:00
|
|
|
|
2011-11-14 14:21:22 +00:00
|
|
|
$myPicture = new pImage(780,150,$MyData);
|
2011-12-01 17:40:57 +00:00
|
|
|
$myPicture->Antialias = true;
|
2011-11-14 14:21:22 +00:00
|
|
|
$myPicture->drawRectangle(0,0,779,149,array("R"=>0,"G"=>0,"B"=>0));
|
|
|
|
$myPicture->setFontProperties(array("FontName"=>plugin_dir_path(__FILE__)."includes/pChart/fonts/Bedizen.ttf","FontSize"=>8));
|
|
|
|
$myPicture->setGraphArea(30,20,760,130);
|
2011-12-01 17:40:57 +00:00
|
|
|
$scaleSettings = array(
|
|
|
|
//"DrawSubTicks"=>TRUE,
|
|
|
|
"GridR"=>200,
|
|
|
|
"GridG"=>200,
|
|
|
|
"GridB"=>200
|
|
|
|
);
|
2011-11-14 14:21:22 +00:00
|
|
|
$myPicture->drawScale($scaleSettings);
|
2011-12-01 17:40:57 +00:00
|
|
|
$myPicture->drawBarChart(array("DisplayValues"=>true,"DisplayColor"=>DISPLAY_MANUAL,"DisplayPos"=>LABEL_POS_OUTSIDE));
|
|
|
|
//$myPicture->drawSplineChart();
|
|
|
|
|
|
|
|
$TextSettings = array("R"=>100,"G"=>100,"B"=>100,"FontSize"=>8,"Align"=>TEXT_ALIGN_TOPRIGHT);
|
|
|
|
$myPicture->drawText(770,5,"(c) 2011 semmelstatzR",$TextSettings);
|
2011-11-14 14:21:22 +00:00
|
|
|
|
2011-12-01 17:40:57 +00:00
|
|
|
@$myPicture->Render(WP_CONTENT_DIR."/cache/24HourGoo.png");
|
|
|
|
|
|
|
|
print '<div class="chart">';
|
|
|
|
|
2011-11-14 14:21:22 +00:00
|
|
|
if(is_readable(WP_CONTENT_DIR."/cache/24HourGoo.png")) {
|
|
|
|
print '<img src="'.WP_CONTENT_URL.'/cache/24HourGoo.png" />';
|
|
|
|
} else if(!is_dir(WP_CONTENT_DIR."/cache")) {
|
|
|
|
print semr_i18n('No Chart: Cannot find cache-folder!');
|
|
|
|
} else if(!is_writable(WP_CONTENT_DIR."/cache")) {
|
|
|
|
print semr_i18n('No Chart: Missing rights for cache-folder!');
|
|
|
|
}
|
|
|
|
print "</div>";
|
|
|
|
print "</div>";
|
|
|
|
print "<hr />";
|
|
|
|
}
|
2011-05-02 09:17:45 +00:00
|
|
|
|
|
|
|
function sem_showDailyStatz() {
|
|
|
|
global $wpdb;
|
|
|
|
|
2011-05-02 10:30:11 +00:00
|
|
|
$sem_options = get_option('semmelstatzR_options'); ### optionsarray auslesen
|
2011-05-02 09:17:45 +00:00
|
|
|
$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");
|
|
|
|
|
2011-12-17 16:26:57 +00:00
|
|
|
print '<div class="statz">';
|
|
|
|
printf (semr_i18n("%s-Days-Statz"), $limit);
|
|
|
|
print '</div>';
|
2011-05-02 09:17:45 +00:00
|
|
|
if (empty($thedays)) {
|
2011-12-17 16:26:57 +00:00
|
|
|
print '<small>... '. semr_i18n("no entries at all").'</small>';
|
2011-12-01 17:40:57 +00:00
|
|
|
print "<hr />";
|
2011-05-02 09:17:45 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
print "<table class='statzelement'>";
|
|
|
|
print "<thead>";
|
|
|
|
print "<tr>";
|
2011-12-17 16:26:57 +00:00
|
|
|
print "<th style='text-align:left;'>".semr_i18n("Date")."</th>";
|
|
|
|
print "<th style='width: 15%;text-align:center;'>".semr_i18n("Visitors")."</th>";
|
|
|
|
print "<th style='width: 15%;text-align:center;'>".semr_i18n("Hits")."</th>";
|
|
|
|
print "<th style='width: 15%;text-align:center;'>".semr_i18n("Referer")."</th>";
|
2011-05-02 09:17:45 +00:00
|
|
|
print "</tr>";
|
|
|
|
print "</thead>";
|
|
|
|
print "<tbody>";
|
|
|
|
foreach ($thedays as $key=>$theday) {
|
|
|
|
$date = $theday->date;
|
|
|
|
$date = strtotime(substr($theday->date,1,10));
|
|
|
|
$today = time();
|
|
|
|
$difference = ceil(($today - $date) / (60*60*24))-1;
|
|
|
|
if($difference == 0) {
|
2011-12-17 16:26:57 +00:00
|
|
|
$date = semr_i18n("Today");
|
2011-05-02 09:17:45 +00:00
|
|
|
}
|
|
|
|
elseif($difference == 1) {
|
2011-12-17 16:26:57 +00:00
|
|
|
$date = semr_i18n("Yesterday");
|
2011-05-02 09:17:45 +00:00
|
|
|
}
|
|
|
|
elseif($difference == 2) {
|
2011-12-17 16:26:57 +00:00
|
|
|
$date = semr_i18n("2 days ago");
|
2011-05-02 09:17:45 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
$date = mysql2date("d.m.Y",$theday->date);
|
|
|
|
}
|
|
|
|
$hits = $theday->hits;
|
|
|
|
$visitors = $theday->visitors;
|
|
|
|
$referers = $theday->referers;
|
|
|
|
print "<tr"; if(1&$key) print " class='alternate'"; print ">";
|
|
|
|
print "<td style='text-align:left;'>$date</td>";
|
|
|
|
print "<td style='text-align:center;'>$visitors</td>";
|
|
|
|
print "<td style='text-align:center;'>$hits</td>";
|
|
|
|
print "<td style='text-align:center;'>$referers</td>";
|
|
|
|
print "</tr>";
|
|
|
|
}
|
|
|
|
print "<tr>";
|
2011-12-17 16:26:57 +00:00
|
|
|
print "<td style='text-align:left;'><a href='".get_option('siteurl')."/wp-admin/admin.php?page=semmelstatzR/semmelstatzR-history.php'>".semr_i18n("more")."...</a></td>";
|
2011-05-02 09:17:45 +00:00
|
|
|
print "</tr>";
|
|
|
|
print "</tbody>";
|
|
|
|
print "</table>";
|
|
|
|
print "<hr />";
|
|
|
|
}
|
|
|
|
|
|
|
|
function sem_showReferers() {
|
|
|
|
global $wpdb, $homehost;
|
|
|
|
|
2011-05-02 10:30:11 +00:00
|
|
|
$sem_options = get_option('semmelstatzR_options'); ### optionsarray auslesen
|
2011-05-02 09:17:45 +00:00
|
|
|
$limit = $sem_options["statz_referer_limit"];
|
|
|
|
$mask = $sem_options["statz_mask_referer"];
|
|
|
|
|
|
|
|
$lastreferers = $wpdb->get_results("SELECT DISTINCT referer, time FROM ".$wpdb->statz." WHERE referer
|
|
|
|
NOT LIKE '".$homehost."' ORDER BY time DESC LIMIT 0, ".$limit);
|
|
|
|
|
2011-12-17 16:26:57 +00:00
|
|
|
print "<div class='statz'>";
|
|
|
|
printf (semr_i18n("The last %s Referrer"), $limit);
|
|
|
|
print "</div>";
|
2011-05-02 09:17:45 +00:00
|
|
|
if (empty($lastreferers)) {
|
2011-12-17 16:26:57 +00:00
|
|
|
print '<small>... '. semr_i18n("no entries at all").'</small>';
|
2011-12-01 17:40:57 +00:00
|
|
|
print "<hr />";
|
2011-05-02 09:17:45 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
print "<table class='statzelement'>";
|
|
|
|
print "<thead>";
|
|
|
|
print "<tr>";
|
2011-12-17 16:26:57 +00:00
|
|
|
print "<th style='text-align:center;width:12%;'>".semr_i18n("Time")."</th>";
|
|
|
|
print "<th style='text-align:left;'>".semr_i18n("Referrer")."</th>";
|
2011-05-02 09:17:45 +00:00
|
|
|
print "</tr>";
|
|
|
|
print "</thead>";
|
|
|
|
print "<tbody>";
|
|
|
|
foreach ($lastreferers as $key=>$lastreferer) {
|
|
|
|
$referer = $lastreferer->referer;
|
|
|
|
if(strlen($referer) >= 120) {
|
|
|
|
$printreferer = substr($referer, 0, 120)." ...";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$printreferer = $referer;
|
|
|
|
}
|
|
|
|
$time = mysql2date("d.m.Y - H:i",$lastreferer->time);
|
|
|
|
print "<tr"; if(1&$key) print " class='alternate'"; print ">";
|
|
|
|
print "<td style='text-align:center;'>".$time."</td>";
|
|
|
|
if($mask != true) {
|
|
|
|
print "<td style='text-align:left;'><a target='_blank' href='".$referer."'>".$printreferer."</a></td>";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$referer = htmlspecialchars($referer, ENT_QUOTES);
|
|
|
|
print "<td style='text-align:left;'><a target='_blank' href='http://www.google.com/url?sa=D&q=".$referer."'>".$printreferer."</a></td>";
|
|
|
|
}
|
|
|
|
print "</tr>";
|
|
|
|
}
|
|
|
|
print "</tbody>";
|
|
|
|
print "</table>";
|
|
|
|
print "<hr />";
|
|
|
|
}
|
|
|
|
|
|
|
|
function sem_showKeyword() {
|
2011-12-17 16:26:57 +00:00
|
|
|
global $wpdb;
|
|
|
|
|
|
|
|
$sem_options = get_option('semmelstatzR_options'); ### optionsarray auslesen
|
|
|
|
$limit = $sem_options["statz_keyword_limit"];
|
|
|
|
|
|
|
|
$results = $wpdb->get_results("SELECT referer, time, ip FROM $wpdb->statz WHERE referer != 'NULL' ORDER BY time DESC");
|
2011-05-02 09:17:45 +00:00
|
|
|
|
2011-12-17 16:26:57 +00:00
|
|
|
print "<div class='statz'>";
|
|
|
|
printf(semr_i18n("The last %s search terms"), $limit);
|
|
|
|
print "</div>";
|
|
|
|
if (empty($results)) {
|
|
|
|
print '<small>... '. semr_i18n("no entries at all").'</small>';
|
|
|
|
print "<hr />";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
print "<table class='statzelement'>";
|
|
|
|
print "<thead>";
|
|
|
|
print "<tr>";
|
|
|
|
print "<th style='text-align: center;width:12%;'>".semr_i18n("Time")."</th>";
|
|
|
|
print "<th style='text-align:left;width:70%;'>".semr_i18n("search term")."</th>";
|
|
|
|
print "<th style='text-align:left;'>".semr_i18n("TCP/IP")."</th>";
|
|
|
|
print "</tr>";
|
|
|
|
print "</thead>";
|
|
|
|
print "<tbody>";
|
|
|
|
$i=0;
|
2011-05-02 09:17:45 +00:00
|
|
|
foreach($results as $result) {
|
|
|
|
$referer = $result->referer;
|
|
|
|
$keyword = sem_getKeyword($referer);
|
|
|
|
$ip = $result->ip;
|
|
|
|
if(sem_checkIfIPisEncoded($ip) == true) $ip = sem_decodeIP($ip);
|
|
|
|
$time = mysql2date('d.m.Y - H:i',$result->time);
|
|
|
|
if($keyword) {
|
|
|
|
print "<tr"; if(1&$i) print " class='alternate'"; print ">";
|
|
|
|
print "<td style='text-align: center;'>".$time."</td>";
|
|
|
|
print "<td style='text-align: left;'><a target='_blank' href='".str_replace(' ','+',htmlspecialchars($referer, ENT_QUOTES))."'>".$keyword."</a></td>";
|
|
|
|
print "<td style='text-align: left;vertical-align:bottom;'>
|
|
|
|
<a target='_blank' href='http://ws.arin.net/whois/?queryinput=".$ip."'>
|
2011-05-02 10:30:11 +00:00
|
|
|
<img src='".get_option('siteurl')."/wp-content/plugins/semmelstatzR/img/arin.png' /></a>
|
2011-05-02 09:17:45 +00:00
|
|
|
<a target='_blank' href='http://www.ripe.net/whois?searchtext=".$ip."'>
|
2011-05-02 10:30:11 +00:00
|
|
|
<img src='".get_option('siteurl')."/wp-content/plugins/semmelstatzR/img/ripe.png' /></a>
|
2011-05-02 09:17:45 +00:00
|
|
|
<a target='_blank' href='http://www.utrace.de/?query=".$ip."'>
|
2011-05-02 10:30:11 +00:00
|
|
|
<img src='".get_option('siteurl')."/wp-content/plugins/semmelstatzR/img/utrace.png' /></a></td>";
|
2011-05-02 09:17:45 +00:00
|
|
|
|
|
|
|
print "</tr>";
|
|
|
|
$i++;
|
|
|
|
}
|
|
|
|
if($i == $limit) break;
|
|
|
|
}
|
|
|
|
print "</tbody>";
|
|
|
|
print "</table>";
|
|
|
|
print "<hr />";
|
|
|
|
}
|
|
|
|
|
|
|
|
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");
|
|
|
|
|
2011-12-17 16:26:57 +00:00
|
|
|
print "<div class='statz'>";
|
|
|
|
print semr_i18n("Top 10 of todays posts & pages")."</div>";
|
2011-05-02 09:17:45 +00:00
|
|
|
if (empty($topreads)) {
|
2011-12-17 16:26:57 +00:00
|
|
|
print '<small>... '. semr_i18n("no entries at all").'</small>';
|
2011-12-01 17:40:57 +00:00
|
|
|
print "<hr />";
|
2011-05-02 09:17:45 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
print "<table class='statzelement'>";
|
|
|
|
print "<thead>";
|
|
|
|
print "<tr>";
|
2011-12-17 16:26:57 +00:00
|
|
|
print "<th style='text-align: left; width: 45%;'>".semr_i18n("Post/Page")."</th>";
|
|
|
|
print "<th style='text-align: left; width: 45%;'>".semr_i18n("Postname")."</th>";
|
|
|
|
print "<th style='text-align: center; width: 10%;'>".semr_i18n("Hits")."</th>";
|
2011-05-02 09:17:45 +00:00
|
|
|
print "</tr>";
|
|
|
|
print "</thead>";
|
|
|
|
print "<tbody>";
|
2011-12-17 16:26:57 +00:00
|
|
|
foreach ($topreads as $key=>$topread) {
|
|
|
|
$posttitle = $topread->posttitle;
|
|
|
|
$postname = $topread->postname;
|
|
|
|
$postid = $topread->postid;
|
|
|
|
$count = $topread->count;
|
|
|
|
print "<tr"; if(1&$key) print " class='alternate'"; print ">";
|
|
|
|
print "<td style='text-align: left;'><a target='_blank' href='$postid'>".$posttitle."</a></td>";
|
|
|
|
print "<td style='text-align: left;'>".$postname."</td>";
|
|
|
|
print "<td style='text-align: center;'>".$count."</td>";
|
|
|
|
print "</tr>";
|
|
|
|
}
|
2011-05-02 09:17:45 +00:00
|
|
|
print "</tbody>";
|
|
|
|
print "</table>";
|
2011-12-17 16:26:57 +00:00
|
|
|
print "<hr />";
|
2011-05-02 09:17:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function sem_showTopReads() {
|
|
|
|
global $wpdb;
|
2011-12-17 16:26:57 +00:00
|
|
|
|
|
|
|
$sem_options = get_option('semmelstatzR_options'); ### optionsarray auslesen
|
2011-05-02 09:17:45 +00:00
|
|
|
$limit = $sem_options["statz_topreads_limit"];
|
|
|
|
|
|
|
|
$topreads = $wpdb->get_results("SELECT post_title AS posttitle, post_name as postname, guid AS postid,
|
|
|
|
hits AS count FROM ".$wpdb->posts." WHERE hits != '0' GROUP BY postid ORDER BY hits DESC LIMIT 0, ".$limit);
|
|
|
|
|
2011-12-17 16:26:57 +00:00
|
|
|
print "<div class='statz'>";
|
|
|
|
printf (semr_i18n("Top %s of all posts & pages"), $limit);
|
|
|
|
print "</div>";
|
2011-05-02 09:17:45 +00:00
|
|
|
if (empty($topreads)) {
|
2011-12-17 16:26:57 +00:00
|
|
|
print '<small>... '. semr_i18n("no entries at all").'</small>';
|
2011-12-01 17:40:57 +00:00
|
|
|
print "<hr />";
|
2011-05-02 09:17:45 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
print "<table class='statzelement'>";
|
|
|
|
print "<thead>";
|
|
|
|
print "<tr>";
|
2011-12-17 16:26:57 +00:00
|
|
|
print "<th style='text-align: left; width: 45%;'>".semr_i18n("Post/Page")."</th>";
|
|
|
|
print "<th style='text-align: left; width: 45%;'>".semr_i18n("Postname")."</th>";
|
|
|
|
print "<th style='text-align: center; width: 10%;'>".semr_i18n("Hits")."</th>";
|
2011-05-02 09:17:45 +00:00
|
|
|
print "</tr>";
|
|
|
|
print "</thead>";
|
|
|
|
print "<tbody>";
|
|
|
|
foreach ($topreads as $key=>$topread) {
|
|
|
|
$posttitle = $topread->posttitle;
|
|
|
|
$postname = $topread->postname;
|
|
|
|
$postid = $topread->postid;
|
|
|
|
$count = $topread->count;
|
|
|
|
print "<tr"; if(1&$key) print " class='alternate'"; print ">";
|
|
|
|
print "<td style='text-align: left;'><a target='_blank' href='".$postid."'>".$posttitle."</a></td>";
|
|
|
|
print "<td style='text-align: left;'>".$postname."</td>";
|
|
|
|
print "<td style='text-align: center;'>".$count."</td>";
|
|
|
|
print "</tr>";
|
|
|
|
}
|
|
|
|
print "</tbody>";
|
|
|
|
print "</table>";
|
2011-12-17 16:26:57 +00:00
|
|
|
print "<hr />";
|
2011-05-02 09:17:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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");
|
|
|
|
|
2011-12-01 17:40:57 +00:00
|
|
|
print '<div class="statz">';
|
|
|
|
print semr_i18n("Known visitors today");
|
|
|
|
print '</div>';
|
2011-05-02 09:17:45 +00:00
|
|
|
if (empty($todaysonlineusers)) {
|
2011-12-17 16:26:57 +00:00
|
|
|
print '<small>... '. semr_i18n("no entries at all").'</small>';
|
2011-12-01 17:40:57 +00:00
|
|
|
print "<hr />";
|
2011-05-02 09:17:45 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
print "<table class='statzelement'>";
|
|
|
|
print "<thead>";
|
|
|
|
print "<tr>";
|
2011-12-17 16:26:57 +00:00
|
|
|
print "<th style='text-align: left; width: 80%;'>".semr_i18n("Visitor (Hits)")."</th>";
|
2011-05-02 09:17:45 +00:00
|
|
|
print "</tr>";
|
|
|
|
print "</thead>";
|
|
|
|
print "<tbody>";
|
|
|
|
foreach ($todaysonlineusers as $key=>$todayonlineuser) {
|
|
|
|
$username = $todayonlineuser->username;
|
|
|
|
$num = $todayonlineuser->num;
|
|
|
|
print "<tr"; if(1&$key) print " class='alternate'"; print ">";
|
|
|
|
print "<td style='text-align: left;'>".$username." (".$num.")</td>";
|
|
|
|
print "</tr>";
|
|
|
|
}
|
|
|
|
print "</tbody>";
|
|
|
|
print "</table>";
|
2011-12-17 16:26:57 +00:00
|
|
|
print "<hr />";
|
2011-05-02 09:17:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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");
|
|
|
|
|
2011-12-17 16:26:57 +00:00
|
|
|
print "<div class='statz'>";
|
|
|
|
print semr_i18n("Top 10 of all commented posts")."</div>";
|
2011-05-02 09:17:45 +00:00
|
|
|
if (empty($topcommentedposts)) {
|
2011-12-17 16:26:57 +00:00
|
|
|
print '<small>... '. semr_i18n("no entries at all").'</small>';
|
|
|
|
print "<hr />";
|
2011-05-02 09:17:45 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
print "<table class='statzelement'>";
|
|
|
|
print "<thead>";
|
|
|
|
print "<tr>";
|
2011-12-17 16:26:57 +00:00
|
|
|
print "<th style='text-align: left; width: 80%;'>".semr_i18n("Post/Page")."</th>";
|
|
|
|
print "<th style='text-align: center; width: 20%;'>".semr_i18n("Comments")."</th>";
|
2011-05-02 09:17:45 +00:00
|
|
|
print "</tr>";
|
|
|
|
print "</thead>";
|
|
|
|
print "<tbody>";
|
|
|
|
|
2011-12-17 16:26:57 +00:00
|
|
|
foreach ($topcommentedposts as $key => $topcommentedpost) {
|
|
|
|
$posttitle = $topcommentedpost->post_title;
|
|
|
|
$count = $topcommentedpost->count;
|
|
|
|
$postid = $topcommentedpost->guid;
|
|
|
|
print "<tr"; if(1&$key) print " class='alternate'"; print ">";
|
|
|
|
print "<td style='text-align: left;'><a target='_blank' href='".$postid."'> ".$posttitle."</a></td>";
|
|
|
|
print "<td style='text-align: center;'>".$count."</td>";
|
|
|
|
print "</tr>";
|
|
|
|
}
|
2011-05-02 09:17:45 +00:00
|
|
|
print "</tbody>";
|
|
|
|
print "</table>";
|
2011-12-17 16:26:57 +00:00
|
|
|
print "<hr />";
|
2011-05-02 09:17:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function sem_showCommenters() {
|
|
|
|
global $wpdb;
|
|
|
|
|
2011-05-02 10:30:11 +00:00
|
|
|
$sem_options = get_option('semmelstatzR_options'); ### optionsarray auslesen
|
2011-05-02 09:17:45 +00:00
|
|
|
$limit = $sem_options["statz_comment_limit"];
|
|
|
|
|
|
|
|
$topcommenters = $wpdb->get_results("SELECT comment_author AS commenter, COUNT(comment_ID) AS count,
|
|
|
|
comment_author_email AS email, comment_author_url AS homepage FROM " .$wpdb->comments . " WHERE
|
|
|
|
comment_approved = '1' GROUP BY comment_author ORDER BY count DESC LIMIT 0, ".$limit);
|
|
|
|
|
2011-12-17 16:26:57 +00:00
|
|
|
print "<div class='statz'>";
|
|
|
|
printf(semr_i18n("Top %s of all commentators"), $limit);
|
|
|
|
print "</div>";
|
2011-05-02 09:17:45 +00:00
|
|
|
if (empty($topcommenters)) {
|
2011-12-17 16:26:57 +00:00
|
|
|
print '<small>... '. semr_i18n("no entries at all").'</small>';
|
|
|
|
print "<hr />";
|
2011-05-02 09:17:45 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
print "<table class='statzelement'>";
|
|
|
|
print "<thead>";
|
|
|
|
print "<tr>";
|
2011-12-17 16:26:57 +00:00
|
|
|
print "<th style='text-align: left; width: 20%;'>".semr_i18n("User")."</th>";
|
|
|
|
print "<th style='text-align: left; width: 30%;'>".semr_i18n("Email")."</th>";
|
|
|
|
print "<th style='text-align: left; width: 40%;'>".semr_i18n("Homepage")."</th>";
|
|
|
|
print "<th style='text-align: center; width: 10%;'>".semr_i18n("Comments")."</th>";
|
2011-05-02 09:17:45 +00:00
|
|
|
print "</tr>";
|
|
|
|
print "</thead>";
|
|
|
|
print "<tbody>";
|
|
|
|
|
2011-12-17 16:26:57 +00:00
|
|
|
foreach ($topcommenters as $key=>$topcommenter) {
|
|
|
|
$commenter = $topcommenter->commenter;
|
|
|
|
$email = $topcommenter->email;
|
|
|
|
$homepage = $topcommenter->homepage;
|
|
|
|
if($homepage=="http://") $homepage="";
|
|
|
|
$url=parse_url($homepage);
|
|
|
|
$homepage = $url['host'];
|
|
|
|
$count = $topcommenter->count;
|
|
|
|
print "<tr"; if(1&$key) print " class='alternate'"; print ">";
|
|
|
|
print "<td style='text-align: left;'>".$commenter."</td>";
|
|
|
|
print "<td style='text-align: left;'><a href='mailto:".$email."'>".$email."</a></td>";
|
|
|
|
print "<td style='text-align: left;'><a target='_blank' href='http://".$homepage."'>".$homepage."</a></td>";
|
|
|
|
print "<td style='text-align: center;'>".$count."</td>";
|
|
|
|
print "</tr>";
|
|
|
|
}
|
2011-05-02 09:17:45 +00:00
|
|
|
|
|
|
|
print "</tbody>";
|
|
|
|
print "</table>";
|
2011-12-17 16:26:57 +00:00
|
|
|
print "<hr />";
|
2011-05-02 09:17:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
### AKTUELL Anzeige
|
|
|
|
|
|
|
|
print "<div class='wrap'>";
|
|
|
|
print "<div><a name='top'></a></div>";
|
2011-05-02 10:30:11 +00:00
|
|
|
print "<div id='icon-semmelstatzR' class='icon32'><br /></div>";
|
2011-12-17 16:26:57 +00:00
|
|
|
print "<h2>SemmelstatzR > ".semr_i18n("Current Statz")."</h2>";
|
2011-05-02 10:30:11 +00:00
|
|
|
$sem_options = get_option('semmelstatzR_options'); ### optionsarray auslesen
|
2011-05-02 09:17:45 +00:00
|
|
|
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 "</div>";
|
|
|
|
|
|
|
|
?>
|