1
0
Fork 0

localistation, chart view and added some functions

Dieser Commit ist enthalten in:
oldperl 2011-12-01 17:40:57 +00:00
Ursprung a727168966
Commit e400b059d8
2 geänderte Dateien mit 177 neuen und 73 gelöschten Zeilen

Datei anzeigen

@ -415,5 +415,59 @@ function semr_i18np($sSingular, $sPlural, $iNumber, $sDomain = "semmelstatzR") {
return _n($sSingular, $sPlural, $iNumber, $sDomain);
}
/**
*
* @author anyexample.com
* @license http://www.anyexample.com/license/
* @link http://www.anyexample.com/programming/php/php_convert_rgb_from_to_html_hex_color.xml
*
* @param string $color
* @return array
*/
function semr_hex2rgb($color) {
if ($color[0] == '#')
$color = substr($color, 1);
if (strlen($color) == 6)
list($r, $g, $b) = array($color[0].$color[1],
$color[2].$color[3],
$color[4].$color[5]);
elseif (strlen($color) == 3)
list($r, $g, $b) = array($color[0].$color[0], $color[1].$color[1], $color[2].$color[2]);
else
return false;
$r = hexdec($r); $g = hexdec($g); $b = hexdec($b);
return array($r, $g, $b);
}
/**
*
* @author anyexample.com
* @license http://www.anyexample.com/license/
* @link http://www.anyexample.com/programming/php/php_convert_rgb_from_to_html_hex_color.xml
*
* @param int $r
* @param int $g
* @param int $b
* @return string
*/
function semr_rgb2hex($r, $g=-1, $b=-1) {
if (is_array($r) && sizeof($r) == 3)
list($r, $g, $b) = $r;
$r = intval($r); $g = intval($g);
$b = intval($b);
$r = dechex($r<0?0:($r>255?255:$r));
$g = dechex($g<0?0:($g>255?255:$g));
$b = dechex($b<0?0:($b>255?255:$b));
$color = (strlen($r) < 2?'0':'').$r;
$color .= (strlen($g) < 2?'0':'').$g;
$color .= (strlen($b) < 2?'0':'').$b;
return '#'.$color;
}
############################################## Ende SEMMELSTATZ-interne Funktionen
?>

Datei anzeigen

@ -59,99 +59,147 @@ include_once plugin_dir_path(__FILE__).'includes/pChart/class/pImage.class.php';
$sem_options = get_option('semmelstatzR_options'); ### optionsarray auslesen
$onlinetime = $sem_options["statz_online_time"];
/** @todo add show_vars to semr-config */
$sem_options['show_utrace'] = $sem_options['show_whois'] = $sem_options['show_arin'] = true;
$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");
print "<div class='statz'>".sem_showNumUsersOnline()." Besucher online - Heute: ".sem_showTodayStatz()."</div>";
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>";
if (empty($onlineusers)) {
print "<small>... keine Eintr&auml;ge</small>";
print "<hr />";
print "<small>... ".semr_i18n("no entries")."</small>";
print "<hr />";
return;
}
print "<table class='statzelement'>";
print "<thead>";
print "<tr>";
print "<th style='text-align:left;'>Username</th>";
print "<th style='text-align:left;'>Post/Page</th>";
print "<th style='text-align:left;'>TCP/IP</th>";
print "<th style='text-align:center;'>Zeit</th>";
print "</tr>";
print "</thead>";
print "<tbody>";
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>';
foreach ($onlineusers as $key=>$onlineuser) {
$username = $onlineuser->username;
$page = $onlineuser->page;
if ($page == 0) {
$link = get_option('siteurl');
$title = 'startseite'; //oder wie auch immer
}
else {
$title = semr_i18n("startpage");
} else {
$link = get_permalink($page);
$title = get_post($page); // muss so sein, da get_post = ARRAY
$title = $title->post_title; // sonst könnte man gleich diese Zeile nehmen
$title = get_post($page);
if(is_array($title)) {
$title = $title->post_title;
} else {
$link = null;
$title = semr_i18n("no page");
}
}
$ip = $onlineuser->ip;
if(sem_checkIfIPisEncoded($ip) == true) $ip = sem_decodeIP($ip);
$time = mysql2date("H:i",$onlineuser->time);
print "<tr"; if(1&$key) print " class='alternate'"; print ">";
print "<td style='text-align:left;'>".$username."</td>";
print "<td style='text-align:left;'><a target='_blank' href=".$link.">".$title."</td>";
print "<td style='white-space:nowrap;text-align:left;'>
<a target='_blank' style='border:none;' href='http://ws.arin.net/whois/?queryinput=".$ip."'>
<img src='".get_option('siteurl')."/wp-content/plugins/semmelstatzR/img/arin.png' /></a>&nbsp;
<a target='_blank' style='border:none;' href='http://www.ripe.net/whois?searchtext=".$ip."'>
<img src='".get_option('siteurl')."/wp-content/plugins/semmelstatzR/img/ripe.png' /></a>&nbsp;
<a target='_blank' style='border:none;' href='http://www.utrace.de/?query=".$ip."'>
<img src='".get_option('siteurl')."/wp-content/plugins/semmelstatzR/img/utrace.png' /></a></td>";
print "<td style='text-align:center;'>$time</td>";
print "</tr>";
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>&nbsp;';
}
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>&nbsp;';
}
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>&nbsp;';
}
print '</td>';
print '<td style="text-align:center;">'.$time.'</td>';
print '</tr>';
}
print "</tbody>";
print "</table>";
print "<hr />";
print '</tbody>';
print '</table>';
print "<hr />";
}
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'>Besucher: Die letzten 24 Stunden</div>";
print "<div align='left'>";
if (empty($results)) {
print "<small>... noch keine Eintr&auml;ge</small></div>";
print "<hr />";
return;
}
foreach ($results as $result) {
$visitors[] = $result->visitors;
$hours[] = mysql2date('H', $result->hours);
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)) {
print '<small>... '. semr_i18n("no entries at all").'</small></div>';
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;
}
$MyData = new pData();
$MyData->addPoints($visitors,"Visitors");
$MyData->addPoints($aVisitors,"Visitors");
$MyData->setAxisName(0,"Visitors");
$MyData->addPoints($hours,"Hours");
$MyData->addPoints($aHours,"Hours");
$MyData->setAbscissa("Hours");
$myPicture = new pImage(780,150,$MyData);
$myPicture->Antialias = FALSE;
$myPicture->Antialias = true;
$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);
$scaleSettings = array("GridR"=>200,"GridG"=>200,"GridB"=>200);
$scaleSettings = array(
//"DrawSubTicks"=>TRUE,
"GridR"=>200,
"GridG"=>200,
"GridB"=>200
);
$myPicture->drawScale($scaleSettings);
$myPicture->drawBarChart();
@$myPicture->Render(WP_CONTENT_DIR."/cache/24HourGoo.png");
print "<div class='chart'>";
$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);
@$myPicture->Render(WP_CONTENT_DIR."/cache/24HourGoo.png");
print '<div class="chart">';
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")) {
@ -177,8 +225,8 @@ include_once plugin_dir_path(__FILE__).'includes/pChart/class/pImage.class.php';
print "<div class='statz'>".$limit."-Tage-Statistik</div>";
if (empty($thedays)) {
print "<small>... noch keine Eintr&auml;ge</small>";
print "<hr />";
print '<small>... '. semr_i18n("no entries at all").'</small></div>';
print "<hr />";
return;
}
print "<table class='statzelement'>";
@ -238,8 +286,8 @@ include_once plugin_dir_path(__FILE__).'includes/pChart/class/pImage.class.php';
print "<div class='statz'>Die letzten ".$limit." Referer</div>";
if (empty($lastreferers)) {
print "<small>... noch keine Eintr&auml;ge</small>";
print "<hr />";
print '<small>... '. semr_i18n("no entries at all").'</small></div>';
print "<hr />";
return;
}
print "<table class='statzelement'>";
@ -285,8 +333,8 @@ include_once plugin_dir_path(__FILE__).'includes/pChart/class/pImage.class.php';
print "<div class='statz'>Die letzten $limit Suchbegriffe</div>";
if (empty($results)) {
print "<small>... noch keine Eintr&auml;ge</small>";
print "<hr />";
print '<small>... '. semr_i18n("no entries at all").'</small></div>';
print "<hr />";
return;
}
print "<table class='statzelement'>";
@ -336,8 +384,8 @@ include_once plugin_dir_path(__FILE__).'includes/pChart/class/pImage.class.php';
print "<div class='statz'>Die Top10 aller Posts & Pages heute</div>";
if (empty($topreads)) {
print "<small>... noch keine Eintr&auml;ge</small>";
print "<hr />";
print '<small>... '. semr_i18n("no entries at all").'</small></div>';
print "<hr />";
return;
}
print "<table class='statzelement'>";
@ -376,8 +424,8 @@ include_once plugin_dir_path(__FILE__).'includes/pChart/class/pImage.class.php';
print "<div class='statz'>Die Top".$limit." aller Posts & Pages</div>";
if (empty($topreads)) {
print "<small>... noch keine Eintr&auml;ge</small>";
print "<hr />";
print '<small>... '. semr_i18n("no entries at all").'</small></div>';
print "<hr />";
return;
}
print "<table class='statzelement'>";
@ -411,10 +459,12 @@ include_once plugin_dir_path(__FILE__).'includes/pChart/class/pImage.class.php';
$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 "<div class='statz'>Bekannte Besucher heute</div>";
print '<div class="statz">';
print semr_i18n("Known visitors today");
print '</div>';
if (empty($todaysonlineusers)) {
print "<small>... noch keine Eintr&auml;ge</small>";
print "<hr />";
print '<small>... '. semr_i18n("no entries at all").'</small></div>';
print "<hr />";
return;
}
print "<table class='statzelement'>";