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); 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 ############################################## Ende SEMMELSTATZ-interne Funktionen
?> ?>

Datei anzeigen

@ -60,57 +60,79 @@ include_once plugin_dir_path(__FILE__).'includes/pChart/class/pImage.class.php';
$sem_options = get_option('semmelstatzR_options'); ### optionsarray auslesen $sem_options = get_option('semmelstatzR_options'); ### optionsarray auslesen
$onlinetime = $sem_options["statz_online_time"]; $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 $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"); 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)) { if (empty($onlineusers)) {
print "<small>... keine Eintr&auml;ge</small>"; print "<small>... ".semr_i18n("no entries")."</small>";
print "<hr />"; print "<hr />";
return; return;
} }
print "<table class='statzelement'>"; print '<table class="statzelement">';
print "<thead>"; print '<thead>';
print "<tr>"; print '<tr>';
print "<th style='text-align:left;'>Username</th>"; print '<th style="text-align:left;">'.semr_i18n("Username").'</th>';
print "<th style='text-align:left;'>Post/Page</th>"; print '<th style="text-align:left;">'.semr_i18n("Post/Page").'</th>';
print "<th style='text-align:left;'>TCP/IP</th>"; print '<th style="text-align:left;">'.semr_i18n("TCP/IP").'</th>';
print "<th style='text-align:center;'>Zeit</th>"; print '<th style="text-align:center;">'.semr_i18n("Time").'</th>';
print "</tr>"; print '</tr>';
print "</thead>"; print '</thead>';
print "<tbody>"; print '<tbody>';
foreach ($onlineusers as $key=>$onlineuser) { foreach ($onlineusers as $key=>$onlineuser) {
$username = $onlineuser->username; $username = $onlineuser->username;
$page = $onlineuser->page; $page = $onlineuser->page;
if ($page == 0) { if ($page == 0) {
$link = get_option('siteurl'); $link = get_option('siteurl');
$title = 'startseite'; //oder wie auch immer $title = semr_i18n("startpage");
} } else {
else {
$link = get_permalink($page); $link = get_permalink($page);
$title = get_post($page); // muss so sein, da get_post = ARRAY $title = get_post($page);
$title = $title->post_title; // sonst könnte man gleich diese Zeile nehmen if(is_array($title)) {
$title = $title->post_title;
} else {
$link = null;
$title = semr_i18n("no page");
}
} }
$ip = $onlineuser->ip; $ip = $onlineuser->ip;
if(sem_checkIfIPisEncoded($ip) == true) $ip = sem_decodeIP($ip); if(sem_checkIfIPisEncoded($ip) == true) $ip = sem_decodeIP($ip);
$time = mysql2date("H:i",$onlineuser->time); $time = mysql2date("H:i",$onlineuser->time);
print "<tr"; if(1&$key) print " class='alternate'"; print ">"; print '<tr'.((1&$key)?' class="alternate">':'>');
print "<td style='text-align:left;'>".$username."</td>"; print '<td style="text-align:left;">'.$username.'</td>';
print "<td style='text-align:left;'><a target='_blank' href=".$link.">".$title."</td>"; print '<td style="text-align:left;">';
print "<td style='white-space:nowrap;text-align:left;'> print (is_null($link))?$title:'<a target="_blank" href="'.$link.'">'.$title.'</a>';
<a target='_blank' style='border:none;' href='http://ws.arin.net/whois/?queryinput=".$ip."'> print '</td>';
<img src='".get_option('siteurl')."/wp-content/plugins/semmelstatzR/img/arin.png' /></a>&nbsp; print '<td style="white-space:nowrap;text-align:left;">';
<a target='_blank' style='border:none;' href='http://www.ripe.net/whois?searchtext=".$ip."'> if($sem_options['show_arin']) {
<img src='".get_option('siteurl')."/wp-content/plugins/semmelstatzR/img/ripe.png' /></a>&nbsp; print '<a target="_blank" href="http://ws.arin.net/whois/?queryinput='.$ip.'">';
<a target='_blank' style='border:none;' href='http://www.utrace.de/?query=".$ip."'> print '<img src="'.SEMMELSTATZR_HTML_RELPATH.'img/arin.png" alt="" />';
<img src='".get_option('siteurl')."/wp-content/plugins/semmelstatzR/img/utrace.png' /></a></td>"; print '</a>&nbsp;';
print "<td style='text-align:center;'>$time</td>";
print "</tr>";
} }
print "</tbody>"; if($sem_options['show_whois']) {
print "</table>"; 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 "<hr />";
} }
@ -120,37 +142,63 @@ include_once plugin_dir_path(__FILE__).'includes/pChart/class/pImage.class.php';
$results = $wpdb->get_results("SELECT time as hours, COUNT(DISTINCT ip) as visitors $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"); 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 class="statz">';
print semr_i18n("Visitors: Last 24 hours").'</div>';
print "<div align='left'>"; print "<div align='left'>";
if(empty($results)) { if(empty($results)) {
print "<small>... noch keine Eintr&auml;ge</small></div>"; print '<small>... '. semr_i18n("no entries at all").'</small></div>';
print "<hr />"; print "<hr />";
return; return;
} }
foreach ($results as $result) { $aHours = array();
$visitors[] = $result->visitors; $aVisitors = array();
$hours[] = mysql2date('H', $result->hours); $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 = new pData();
$MyData->addPoints($visitors,"Visitors"); $MyData->addPoints($aVisitors,"Visitors");
$MyData->setAxisName(0,"Visitors"); $MyData->setAxisName(0,"Visitors");
$MyData->addPoints($hours,"Hours"); $MyData->addPoints($aHours,"Hours");
$MyData->setAbscissa("Hours"); $MyData->setAbscissa("Hours");
$myPicture = new pImage(780,150,$MyData); $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->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->setFontProperties(array("FontName"=>plugin_dir_path(__FILE__)."includes/pChart/fonts/Bedizen.ttf","FontSize"=>8));
$myPicture->setGraphArea(30,20,760,130); $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->drawScale($scaleSettings);
$myPicture->drawBarChart(); $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"); @$myPicture->Render(WP_CONTENT_DIR."/cache/24HourGoo.png");
print "<div class='chart'>"; print '<div class="chart">';
if(is_readable(WP_CONTENT_DIR."/cache/24HourGoo.png")) { if(is_readable(WP_CONTENT_DIR."/cache/24HourGoo.png")) {
print '<img src="'.WP_CONTENT_URL.'/cache/24HourGoo.png" />'; print '<img src="'.WP_CONTENT_URL.'/cache/24HourGoo.png" />';
@ -177,7 +225,7 @@ include_once plugin_dir_path(__FILE__).'includes/pChart/class/pImage.class.php';
print "<div class='statz'>".$limit."-Tage-Statistik</div>"; print "<div class='statz'>".$limit."-Tage-Statistik</div>";
if (empty($thedays)) { if (empty($thedays)) {
print "<small>... noch keine Eintr&auml;ge</small>"; print '<small>... '. semr_i18n("no entries at all").'</small></div>';
print "<hr />"; print "<hr />";
return; return;
} }
@ -238,7 +286,7 @@ include_once plugin_dir_path(__FILE__).'includes/pChart/class/pImage.class.php';
print "<div class='statz'>Die letzten ".$limit." Referer</div>"; print "<div class='statz'>Die letzten ".$limit." Referer</div>";
if (empty($lastreferers)) { if (empty($lastreferers)) {
print "<small>... noch keine Eintr&auml;ge</small>"; print '<small>... '. semr_i18n("no entries at all").'</small></div>';
print "<hr />"; print "<hr />";
return; return;
} }
@ -285,7 +333,7 @@ include_once plugin_dir_path(__FILE__).'includes/pChart/class/pImage.class.php';
print "<div class='statz'>Die letzten $limit Suchbegriffe</div>"; print "<div class='statz'>Die letzten $limit Suchbegriffe</div>";
if (empty($results)) { if (empty($results)) {
print "<small>... noch keine Eintr&auml;ge</small>"; print '<small>... '. semr_i18n("no entries at all").'</small></div>';
print "<hr />"; print "<hr />";
return; return;
} }
@ -336,7 +384,7 @@ include_once plugin_dir_path(__FILE__).'includes/pChart/class/pImage.class.php';
print "<div class='statz'>Die Top10 aller Posts & Pages heute</div>"; print "<div class='statz'>Die Top10 aller Posts & Pages heute</div>";
if (empty($topreads)) { if (empty($topreads)) {
print "<small>... noch keine Eintr&auml;ge</small>"; print '<small>... '. semr_i18n("no entries at all").'</small></div>';
print "<hr />"; print "<hr />";
return; return;
} }
@ -376,7 +424,7 @@ include_once plugin_dir_path(__FILE__).'includes/pChart/class/pImage.class.php';
print "<div class='statz'>Die Top".$limit." aller Posts & Pages</div>"; print "<div class='statz'>Die Top".$limit." aller Posts & Pages</div>";
if (empty($topreads)) { if (empty($topreads)) {
print "<small>... noch keine Eintr&auml;ge</small>"; print '<small>... '. semr_i18n("no entries at all").'</small></div>';
print "<hr />"; print "<hr />";
return; return;
} }
@ -411,9 +459,11 @@ 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 $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"); 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)) { if (empty($todaysonlineusers)) {
print "<small>... noch keine Eintr&auml;ge</small>"; print '<small>... '. semr_i18n("no entries at all").'</small></div>';
print "<hr />"; print "<hr />";
return; return;
} }