init: initial import of org semmelstatz 3.3 version
							
								
								
									
										10
									
								
								trunk/ACHTUNG_Updater.txt
									
										
									
									
									
										Normale Datei
									
								
							
							
						
						| 
						 | 
				
			
			@ -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...
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								trunk/img/arin.png
									
										
									
									
									
										Normale Datei
									
								
							
							
						
						| 
		 Nachher Breite: | Höhe: | Größe: 157 B  | 
							
								
								
									
										
											BIN
										
									
								
								trunk/img/icon_observe.png
									
										
									
									
									
										Normale Datei
									
								
							
							
						
						| 
		 Nachher Breite: | Höhe: | Größe: 1,1 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								trunk/img/icon_template.png
									
										
									
									
									
										Normale Datei
									
								
							
							
						
						| 
		 Nachher Breite: | Höhe: | Größe: 1,2 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								trunk/img/ripe.png
									
										
									
									
									
										Normale Datei
									
								
							
							
						
						| 
		 Nachher Breite: | Höhe: | Größe: 152 B  | 
							
								
								
									
										
											BIN
										
									
								
								trunk/img/statz.png
									
										
									
									
									
										Normale Datei
									
								
							
							
						
						| 
		 Nachher Breite: | Höhe: | Größe: 2,8 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								trunk/img/statz_small.png
									
										
									
									
									
										Normale Datei
									
								
							
							
						
						| 
		 Nachher Breite: | Höhe: | Größe: 568 B  | 
							
								
								
									
										
											BIN
										
									
								
								trunk/img/utrace.png
									
										
									
									
									
										Normale Datei
									
								
							
							
						
						| 
		 Nachher Breite: | Höhe: | Größe: 166 B  | 
							
								
								
									
										18
									
								
								trunk/lies_mich.txt
									
										
									
									
									
										Normale Datei
									
								
							
							
						
						| 
						 | 
				
			
			@ -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 *
 | 
			
		||||
*                                         *
 | 
			
		||||
*******************************************
 | 
			
		||||
							
								
								
									
										82
									
								
								trunk/semmelstatz-database.php
									
										
									
									
									
										Normale Datei
									
								
							
							
						
						| 
						 | 
				
			
			@ -0,0 +1,82 @@
 | 
			
		|||
<?php
 | 
			
		||||
 | 
			
		||||
/***********************************************
 | 
			
		||||
 *                                             *
 | 
			
		||||
 *   semmelstatz_database.php v3.3             *
 | 
			
		||||
 *   Copyright: © 2005-2009 kopfhoch-studio    *
 | 
			
		||||
 *                                             *
 | 
			
		||||
 ***********************************************/
 | 
			
		||||
 
 | 
			
		||||
if(!current_user_can('manage_statz')) {
 | 
			
		||||
	die('Zugriff verweigert');
 | 
			
		||||
}
 | 
			
		||||
	
 | 
			
		||||
	global $wpdb;
 | 
			
		||||
	$pre = $wpdb->prefix; $lenpre = strlen($pre);
 | 
			
		||||
	$tablesstatus = $wpdb->get_results("SHOW TABLE STATUS");
 | 
			
		||||
 
 | 
			
		||||
	print "<div class='wrap'>";
 | 
			
		||||
		print "<div><a name='top'></a></div>";
 | 
			
		||||
		print "<div id='icon-semmelstatz' class='icon32'><br /></div>";
 | 
			
		||||
		print "<h2>Semmelstatz › Datenbank</h2>";
 | 
			
		||||
	
 | 
			
		||||
		print "<div class='statz'>Datenbank</div>";
 | 
			
		||||
        print "<table class='statzelement'>";
 | 
			
		||||
		print "<tr>";
 | 
			
		||||
		print "<th style='text-align:center;width:6%'>Nr.</th>";
 | 
			
		||||
		print "<th style='text-align:left;width:20%'>Tabellen</th>";
 | 
			
		||||
		print "<th style='text-align:right;width:10%'>Datensätze</th>";
 | 
			
		||||
		print "<th style='text-align:right;width:10%'>Daten</th>";
 | 
			
		||||
		print "<th style='text-align:right;width:10%'>Index</th>";
 | 
			
		||||
		print "<th style='text-align:right;width:10%'>Daten & Index</th>";
 | 
			
		||||
		print "<th style='text-align:right;width:7%'>Überhang</th>";
 | 
			
		||||
		
 | 
			
		||||
		foreach($tablesstatus as $key=>$tablestatus) {
 | 
			
		||||
			
 | 
			
		||||
			if(substr($tablestatus->Name,0,$lenpre) != $pre) continue;
 | 
			
		||||
			
 | 
			
		||||
			print "<tr"; if(1&$key) print " class='alternate'"; print ">";
 | 
			
		||||
			print "<td style='text-align:center;'>".($key+1)."</td>";
 | 
			
		||||
			print "<td style='text-align:left;'>".$tablestatus->Name."</td>";
 | 
			
		||||
			print "<td style='text-align:right;'>".number_format($tablestatus->Rows,0,',','.')."</td>";
 | 
			
		||||
			print "<td style='text-align:right;'>".number_format($tablestatus->Data_length/1024,0,',','.')." kb</td>";
 | 
			
		||||
			print "<td style='text-align:right;'>".number_format($tablestatus->Index_length/1024,0,',','.')." kb</td>";
 | 
			
		||||
			print "<td style='text-align:right;'>".number_format(($tablestatus->Data_length + $tablestatus->Index_length)/1024,0,',','.')." kb</td>";
 | 
			
		||||
			
 | 
			
		||||
			if($tablestatus->Data_free > 0) {
 | 
			
		||||
				print "<td style='color:#ff0000;text-align:right;'>";
 | 
			
		||||
				print " ".number_format($tablestatus->Data_free/1024,2,',','.')." kb"; 
 | 
			
		||||
				print "</td>";
 | 
			
		||||
			}
 | 
			
		||||
			else {
 | 
			
		||||
				print "<td style='text-align:right;'>--</td>";
 | 
			
		||||
			}
 | 
			
		||||
			
 | 
			
		||||
			$row_usage += $tablestatus->Rows;
 | 
			
		||||
			$data_usage += $tablestatus->Data_length;
 | 
			
		||||
			$index_usage +=  $tablestatus->Index_length;
 | 
			
		||||
			$total_usage += $tablestatus->Data_length + $tablestatus->Index_length;
 | 
			
		||||
			$overhead_usage += $tablestatus->Data_free;
 | 
			
		||||
			echo '</tr>';
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		print "<tr>";
 | 
			
		||||
		print "<th style='text-align:center;'>Gesamt</th>";
 | 
			
		||||
		print "<th style='text-align:left;'> </th>";
 | 
			
		||||
		print "<th style='text-align:right;'>".number_format($row_usage,0,',','.')."</th>";
 | 
			
		||||
		print "<th style='text-align:right;'>".number_format($data_usage/1024,0,',','.')." kb</th>";
 | 
			
		||||
		print "<th style='text-align:right;'>".number_format($index_usage/1024,0,',','.')." kb</th>";
 | 
			
		||||
		print "<th style='text-align:right;'>".number_format($total_usage/1024,0,',','.')." kb</th>";
 | 
			
		||||
		print "<th style='color:#ff0000;text-align:right;'>".number_format($overhead_usage/1024,2,',','.')." kb</th>";
 | 
			
		||||
		print "</tr>";
 | 
			
		||||
		
 | 
			
		||||
		print "<tr><td colspan='7'><p align='right'>Es werden ausschließlich die WORDPRESS-Tabellen angezeigt, die zum Blog <b>'".get_option('blogname')."'</b> gehören.</p></td></tr>";
 | 
			
		||||
		
 | 
			
		||||
		print "</table>";
 | 
			
		||||
		print "<hr />";
 | 
			
		||||
		
 | 
			
		||||
		sem_showCopyright();
 | 
			
		||||
 
 | 
			
		||||
	print "</div>";
 | 
			
		||||
	
 | 
			
		||||
?>
 | 
			
		||||
							
								
								
									
										189
									
								
								trunk/semmelstatz-history.php
									
										
									
									
									
										Normale Datei
									
								
							
							
						
						| 
						 | 
				
			
			@ -0,0 +1,189 @@
 | 
			
		|||
<?php
 | 
			
		||||
 | 
			
		||||
/***********************************************
 | 
			
		||||
 *                                             *
 | 
			
		||||
 *   semmelstatz_history.php v3.3              *
 | 
			
		||||
 *   Copyright: © 2005-2009 kopfhoch-studio    *
 | 
			
		||||
 *                                             *
 | 
			
		||||
 ***********************************************/
 | 
			
		||||
 
 | 
			
		||||
 if(!current_user_can('manage_statz')) {
 | 
			
		||||
	die('Zugriff verweigert');
 | 
			
		||||
}
 | 
			
		||||
	
 | 
			
		||||
	function sem_drawLast30DaysGoo() {
 | 
			
		||||
		global $wpdb;
 | 
			
		||||
		
 | 
			
		||||
        $sql = $wpdb->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 "<div class='statz'>Besucher: Die letzten 30 Tage</div>";
 | 
			
		||||
        print "<div align='left'>";
 | 
			
		||||
		
 | 
			
		||||
			if (empty($results)) {
 | 
			
		||||
				print "<small>... noch keine Einträge</small></div>";
 | 
			
		||||
				return;
 | 
			
		||||
			}
 | 
			
		||||
			
 | 
			
		||||
			foreach ($results as $result) {
 | 
			
		||||
				$visitors[] = $result->visitors;
 | 
			
		||||
				$days[] = $result->days;
 | 
			
		||||
			}
 | 
			
		||||
			
 | 
			
		||||
			$maxvalue = max($visitors);
 | 
			
		||||
			$daylabels = implode('|', $days);
 | 
			
		||||
			
 | 
			
		||||
			print "<div class='chart'>";
 | 
			
		||||
			
 | 
			
		||||
				print "<img src=http://chart.apis.google.com/chart?chg=25,25&chxl=0:|".$daylabels."|1:|0|".$maxvalue."&chbh=a&cht=bvs&chs=600x150&chxt=x,y&chd=".sem_encodeChartData($visitors).">";
 | 
			
		||||
			
 | 
			
		||||
			print "</div>";
 | 
			
		||||
			
 | 
			
		||||
		print "</div>";
 | 
			
		||||
		print "<hr />";
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
### 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 "<div class='statz'>Besucher: Die letzten ".$nummonths." Monate</div>";
 | 
			
		||||
        print "<div align='left'>";
 | 
			
		||||
		
 | 
			
		||||
			if (empty($results)) {
 | 
			
		||||
				print "<small>... noch keine Einträge</small></div>";
 | 
			
		||||
				return;
 | 
			
		||||
			}
 | 
			
		||||
			
 | 
			
		||||
			foreach ($results as $result) {
 | 
			
		||||
				$visitors[] = $result->visitors;
 | 
			
		||||
				$months[] = $result->months;
 | 
			
		||||
			}
 | 
			
		||||
			
 | 
			
		||||
			$maxvalue = max($visitors);
 | 
			
		||||
			
 | 
			
		||||
			$monthlabels = implode('|', $months);
 | 
			
		||||
			
 | 
			
		||||
			print "<div class='chart'>";
 | 
			
		||||
		
 | 
			
		||||
				print "<img src=http://chart.apis.google.com/chart?chg=25,25&chxt=x,y&chxl=0:|".$monthlabels."|1:|0|".$maxvalue."&chbh=a&cht=bvs&chs=600x150&chd=".sem_encodeChartData($visitors).">";
 | 
			
		||||
			
 | 
			
		||||
			print "</div>";
 | 
			
		||||
			
 | 
			
		||||
		print "</div>";
 | 
			
		||||
		print "<hr />";
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
### 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 "<div class='statz'>Besucher: ".$numdays." Tage zurück</div>";
 | 
			
		||||
		print "<div align='left'>";
 | 
			
		||||
		
 | 
			
		||||
			if (empty($results)) {
 | 
			
		||||
				print "<small>... noch keine Einträge</small></div>";
 | 
			
		||||
				return;
 | 
			
		||||
			}
 | 
			
		||||
			
 | 
			
		||||
			foreach($results as $result) {
 | 
			
		||||
				$visitors[] = $result->visitors;
 | 
			
		||||
				$hits[] = $result->hits;
 | 
			
		||||
				$referers[] = $result->referers;
 | 
			
		||||
			}
 | 
			
		||||
				
 | 
			
		||||
			$maxvalue = max($visitors); 
 | 
			
		||||
			
 | 
			
		||||
			print "<div class='chart'>";
 | 
			
		||||
			
 | 
			
		||||
				print "<img src=http://chart.apis.google.com/chart?chg=25,25&cht=lc&chs=600x200&chd=".sem_encodeChartData($visitors)."&chxt=y&chxl=0:|0|".$maxvalue.">";
 | 
			
		||||
			
 | 
			
		||||
			print "</div>";
 | 
			
		||||
		
 | 
			
		||||
		print "</div>";
 | 
			
		||||
		print "<hr />";
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	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 "<div class='statz'>Die letzten ".$numdays." Tage</div>";
 | 
			
		||||
        if (empty($results)) {
 | 
			
		||||
            print "<small>... noch keine Einträge</small>";
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        print "<table class='statzelement'>";
 | 
			
		||||
        print "<thead>";
 | 
			
		||||
        print "<tr>";
 | 
			
		||||
        print "<th style='width:15%;text-align:center;'>Datum</th>";
 | 
			
		||||
        print "<th style='width:10%;text-align:right;'>Besucher</th>";
 | 
			
		||||
        print "<th style='width:10%;text-align:right;'>Hits</th>";
 | 
			
		||||
        print "<th style='width:10%;text-align:right;'>Referer</th>";
 | 
			
		||||
		print "<th style='text-align:right;'> </th>";
 | 
			
		||||
        print "</tr>";
 | 
			
		||||
        print "</thead>";
 | 
			
		||||
        print "<tbody>";
 | 
			
		||||
            foreach($results as $key=>$result) {
 | 
			
		||||
                $date = mysql2date('d.m.Y',$result->date);
 | 
			
		||||
                $visitors = $result->visitors; $sum_visitors += $visitors;
 | 
			
		||||
                $hits = $result->hits; $sum_hits += $hits;
 | 
			
		||||
                $referers = $result->referers; $sum_referers += $referers;
 | 
			
		||||
                print "<tr"; if(1&$key) print " class='alternate'"; print ">";
 | 
			
		||||
                print "<td style='text-align:center;'>".$date."</td>";
 | 
			
		||||
                print "<td style='text-align:right;'>".$visitors."</td>";
 | 
			
		||||
                print "<td style='text-align:right;'>".$hits."</td>";
 | 
			
		||||
                print "<td style='text-align:right;'>".$referers."</td>";
 | 
			
		||||
				print "<td style='text-align:right;'> </td>";
 | 
			
		||||
                print "</tr>";
 | 
			
		||||
            }
 | 
			
		||||
			
 | 
			
		||||
        print "<tr><td> </td></tr>";
 | 
			
		||||
        print "<tr class='alternate'"; print ">";
 | 
			
		||||
        print "<td style='text-align:center;'><b>Gesamt</b></td>";
 | 
			
		||||
        print "<td style='text-align:right;'><b>".$sum_visitors."</b></td>";
 | 
			
		||||
        print "<td style='text-align:right;'><b>".$sum_hits."</b></td>";
 | 
			
		||||
        print "<td style='text-align:right;'><b>".$sum_referers."</b></td>";
 | 
			
		||||
        print "</tr>";
 | 
			
		||||
        print "<tr>";
 | 
			
		||||
        print "<td style='text-align:center;'><b>Durchschnitt</b></td>";
 | 
			
		||||
        print "<td style='text-align:right;'>".ceil($sum_visitors / $numdays)."</td>";
 | 
			
		||||
        print "<td style='text-align:right;'>".ceil($sum_hits / $numdays)."</td>";
 | 
			
		||||
        print "<td style='text-align:right;'>".ceil($sum_referers / $numdays)."</td>";
 | 
			
		||||
        print "</tr>";
 | 
			
		||||
        print "</tbody>";
 | 
			
		||||
        print "</table>";
 | 
			
		||||
		print "<hr />";
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	
 | 
			
		||||
### ANZEIGE HISTORY
 | 
			
		||||
	
 | 
			
		||||
	print "<div class='wrap'>";
 | 
			
		||||
		print "<div id='icon-semmelstatz' class='icon32'><br /></div>";
 | 
			
		||||
		print "<h2>Semmelstatz › Historie</h2>";
 | 
			
		||||
		
 | 
			
		||||
		sem_drawLast30DaysGoo();
 | 
			
		||||
		sem_drawAllMonthGoo();
 | 
			
		||||
		sem_drawAllDaysGoo();
 | 
			
		||||
		sem_showAllDaysInNumbers();
 | 
			
		||||
		sem_showCopyright();
 | 
			
		||||
	
 | 
			
		||||
	print "</div>";
 | 
			
		||||
		
 | 
			
		||||
?>
 | 
			
		||||
							
								
								
									
										113
									
								
								trunk/semmelstatz-log.php
									
										
									
									
									
										Normale Datei
									
								
							
							
						
						| 
						 | 
				
			
			@ -0,0 +1,113 @@
 | 
			
		|||
<?php
 | 
			
		||||
 | 
			
		||||
/***********************************************
 | 
			
		||||
 *                                             *
 | 
			
		||||
 *   semmelstatz_log.php v3.3                  *
 | 
			
		||||
 *   Copyright: © 2005-2009 kopfhoch-studio    *
 | 
			
		||||
 *                                             *
 | 
			
		||||
 ***********************************************/
 | 
			
		||||
 
 | 
			
		||||
if(!current_user_can('manage_statz')) {
 | 
			
		||||
	die('Zugriff verweigert');
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
### ANZEIGE LOG
 | 
			
		||||
 | 
			
		||||
		global $wpdb;
 | 
			
		||||
		
 | 
			
		||||
		$sem_options = get_option('semmelstatz_options'); ### optionsarray auslesen
 | 
			
		||||
        $limit = $sem_options["statz_datarecs_limit"]; $mask = $sem_options["statz_mask_referer"];
 | 
			
		||||
        $completerecords =
 | 
			
		||||
			$wpdb->get_results("SELECT id, ip, time, referer, page, username FROM ".$wpdb->statz." ORDER BY time DESC LIMIT 0, ".$limit);
 | 
			
		||||
        
 | 
			
		||||
		print "<div class='wrap'>";
 | 
			
		||||
		print "<div id='icon-semmelstatz' class='icon32'><br /></div>";
 | 
			
		||||
        print "<h2>Semmelstatz › Log</h2>";
 | 
			
		||||
        print "<div class='statz'>Die neuesten ".$limit." Datensätze</div>";
 | 
			
		||||
 | 
			
		||||
        if ($completerecords == NULL) {
 | 
			
		||||
            print "<small>... noch keine Einträge</small>";
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        print "<table cellpadding='5' style='text-align:center; width:100%;'>";
 | 
			
		||||
        print "<thead>";
 | 
			
		||||
        print "<tr>";
 | 
			
		||||
        print "<th style='text-align:center;width:110px;'><small>Datum</small></th>";
 | 
			
		||||
        print "<th style='text-align:center;width:80px;'><small>TCP/IP</small></th>";
 | 
			
		||||
        print "<th style='text-align:left;'><small>Referer</small></th>";
 | 
			
		||||
        print "<th style='text-align:left;'><small>Suchbegriff</small></th>";
 | 
			
		||||
        print "<th style='text-align:left;'><small>Post/Page</small></th>";
 | 
			
		||||
        print "<th style='text-align:left;'><small>Username</small></th>";
 | 
			
		||||
        print "</tr>";
 | 
			
		||||
        print "</thead>";
 | 
			
		||||
        print "<tbody>";
 | 
			
		||||
        
 | 
			
		||||
            foreach ($completerecords as $key=>$completerecord) {
 | 
			
		||||
                $id = $completerecord->id;
 | 
			
		||||
                $ip = $completerecord->ip;
 | 
			
		||||
                if(sem_checkIfIPisEncoded($ip) == true) $ip = sem_decodeIP($ip);
 | 
			
		||||
                $date = mysql2date("d.m.Y G:i", $completerecord->time);
 | 
			
		||||
                $referer = $completerecord->referer;
 | 
			
		||||
                    if($referer == "") {
 | 
			
		||||
                        $referer = "--";
 | 
			
		||||
                    }
 | 
			
		||||
                    else {
 | 
			
		||||
                        if(strlen($referer) >= 50) {
 | 
			
		||||
                            $printreferer = substr($referer, 0, 50)."...";
 | 
			
		||||
                        }
 | 
			
		||||
                        else {
 | 
			
		||||
                            $printreferer = $referer;
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                $keyword = sem_getKeyword($referer);
 | 
			
		||||
					if(empty($keyword)) $keyword ='--';
 | 
			
		||||
                $page = $completerecord->page;
 | 
			
		||||
                if ($page == 0) {
 | 
			
		||||
                    $link = get_option('siteurl');
 | 
			
		||||
                    $title = "0"; //oder wie auch immer
 | 
			
		||||
                    }
 | 
			
		||||
                else {
 | 
			
		||||
                    $link = get_permalink($page);
 | 
			
		||||
					$postarray = get_post($page, ARRAY_A);
 | 
			
		||||
                    $title = $postarray['post_title'];
 | 
			
		||||
                }
 | 
			
		||||
                $username = $completerecord->username;
 | 
			
		||||
                print "<tr"; if(1&$key) print " class='alternate'"; print ">";
 | 
			
		||||
                print "<td style='white-space:nowrap;text-align:center;'><small>".$date."</small></td>";
 | 
			
		||||
                print "<td style='white-space:nowrap;text-align:center;'>
 | 
			
		||||
                <a target='_blank' style='border:none;' href='http://ws.arin.net/whois/?queryinput=".$ip."'>
 | 
			
		||||
                <img src='".get_option('siteurl')."/wp-content/plugins/semmelstatz/img/arin.png' /></a> 
 | 
			
		||||
                <a target='_blank' style='border:none;' href='http://www.ripe.net/whois?searchtext=".$ip."'>
 | 
			
		||||
                <img src='".get_option('siteurl')."/wp-content/plugins/semmelstatz/img/ripe.png' /></a> 
 | 
			
		||||
                <a target='_blank' style='border:none;' href='http://www.utrace.de/?query=".$ip."'>
 | 
			
		||||
                <img src='".get_option('siteurl')."/wp-content/plugins/semmelstatz/img/utrace.png' /></a></td>";
 | 
			
		||||
                print "<td style='text-align:left;'><small>";
 | 
			
		||||
                    if ($referer == "--") {
 | 
			
		||||
                        print "--</small></td>";
 | 
			
		||||
                    }
 | 
			
		||||
                    else {
 | 
			
		||||
                        if($mask != true) {
 | 
			
		||||
                            print "<a target='_blank' style='text-decoration:none;' href='".$referer."'>".$printreferer."</a></td>";
 | 
			
		||||
                        }
 | 
			
		||||
                        else {
 | 
			
		||||
                            $referer = htmlspecialchars($referer, ENT_QUOTES);
 | 
			
		||||
                            print "<a target='_blank' style='text-decoration:none;' href='http://www.google.com/url?sa=D&q=".$referer."'>".$printreferer."</a></td>";
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    
 | 
			
		||||
                print "<td style='text-align:left;'><small>".$keyword."</small></td>";
 | 
			
		||||
                print "<td style='text-align:left;'><small><a target='_blank' style='text-decoration:none;' href='".$link."'>".$title."</small></td>";
 | 
			
		||||
                print "<td style='text-align:left;'><small>".$username."</small></td>";
 | 
			
		||||
                print "</tr>";
 | 
			
		||||
            }
 | 
			
		||||
        
 | 
			
		||||
        print "</tbody>";
 | 
			
		||||
        print "</table>";
 | 
			
		||||
		print "<hr />";
 | 
			
		||||
		
 | 
			
		||||
        if (function_exists('sem_showCopyright')) sem_showCopyright();
 | 
			
		||||
		
 | 
			
		||||
        print "</div>";
 | 
			
		||||
 | 
			
		||||
?>
 | 
			
		||||
							
								
								
									
										344
									
								
								trunk/semmelstatz-options.php
									
										
									
									
									
										Normale Datei
									
								
							
							
						
						| 
						 | 
				
			
			@ -0,0 +1,344 @@
 | 
			
		|||
<?php
 | 
			
		||||
 | 
			
		||||
/*******************************************
 | 
			
		||||
 *                                         *
 | 
			
		||||
 *  semmelstatz_options.php v3.3           *
 | 
			
		||||
 *  Copyright: © 2005-2009 kopfhoch-studio *
 | 
			
		||||
 *                                         *
 | 
			
		||||
 *******************************************/
 | 
			
		||||
 | 
			
		||||
if(!current_user_can('manage_statz')) {
 | 
			
		||||
	die('Zugriff verweigert');
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
    if(isset($_POST['options_save'])) {
 | 
			
		||||
		
 | 
			
		||||
		$sem_options['statz_write_admins'] = $_POST['statz_write_admins'];
 | 
			
		||||
		$sem_options['statz_write_users'] = $_POST['statz_write_users'];
 | 
			
		||||
		$sem_options['statz_encode_ip'] = $_POST['statz_encode_ip'];
 | 
			
		||||
		$sem_options['statz_days_limit'] = $_POST['statz_days_limit'];
 | 
			
		||||
		$sem_options['statz_show_dailystatz'] = $_POST['statz_show_dailystatz'];
 | 
			
		||||
		$sem_options['statz_referer_limit'] = $_POST['statz_referer_limit'];
 | 
			
		||||
		$sem_options['statz_show_referers'] = $_POST['statz_show_referers'];
 | 
			
		||||
		$sem_options['statz_mask_referer'] = $_POST['statz_mask_referer'];
 | 
			
		||||
		$sem_options['statz_keyword_limit'] = $_POST['statz_keyword_limit'];
 | 
			
		||||
		$sem_options['statz_show_keywords'] = $_POST['statz_show_keywords'];
 | 
			
		||||
		$sem_options['statz_topreads_limit'] = $_POST['statz_topreads_limit'];
 | 
			
		||||
		$sem_options['statz_show_reads'] = $_POST['statz_show_reads'];
 | 
			
		||||
		$sem_options['statz_show_todayreads'] = $_POST['statz_show_todayreads'];
 | 
			
		||||
		$sem_options['statz_comment_limit'] = $_POST['statz_comment_limit'];
 | 
			
		||||
		$sem_options['statz_show_commenters'] = $_POST['statz_show_commenters'];
 | 
			
		||||
		$sem_options['statz_show_topcommposts'] = $_POST['statz_show_topcommposts'];
 | 
			
		||||
		$sem_options['statz_show_useronline'] = $_POST['statz_show_useronline'];
 | 
			
		||||
		$sem_options['statz_online_time'] = $_POST['statz_online_time'];
 | 
			
		||||
		$sem_options['statz_show_todayusers'] = $_POST['statz_show_todayusers'];
 | 
			
		||||
		$sem_options['statz_on_dashboard'] = $_POST['statz_on_dashboard'];
 | 
			
		||||
		$sem_options['statz_datarecs_limit'] = $_POST['statz_datarecs_limit'];
 | 
			
		||||
		update_option("semmelstatz_options", $sem_options);
 | 
			
		||||
		
 | 
			
		||||
		echo '<div class="updated fade"><p>Einstellungen gespeichert</strong></p></div>';
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if(isset($_POST['trunc_save'])) {
 | 
			
		||||
        if ($result == sem_truncateStatzTable()) {
 | 
			
		||||
            echo "<div class='updated'><p>Die <i>statz</i>-Tabelle wurde erfolgreich geleert.</p></div>";
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    if(isset($_POST['limit_save'])) {
 | 
			
		||||
		$sem_options["statz_recdays_limit"] = $_POST["statz_recdays_limit"];
 | 
			
		||||
		
 | 
			
		||||
        if($sem_options["statz_recdays_limit"] < 1 || (!is_numeric($sem_options["statz_recdays_limit"]))) $sem_options["statz_recdays_limit"] = 1;
 | 
			
		||||
        update_option("semmelstatz_options", $sem_options);
 | 
			
		||||
		
 | 
			
		||||
		echo "<div class='updated fade'><p>Der Wert für das Limit wurde erfolgreich gespeichert.</p></div>";
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    if(isset($_POST['limit_execute'])) {
 | 
			
		||||
		$days = $sem_options["statz_recdays_limit"];
 | 
			
		||||
        if(($days >= sem_showStatzDays()) || (!is_numeric($days))) {
 | 
			
		||||
            echo "<div class='error fade'><p>Der eingegebene Wert ist keine Zahl oder zu groß!</p></div>";
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            if ($result == sem_delOutOfLimit()) {
 | 
			
		||||
                echo "<div class='updated fade'><p>Die <i>statz</i>-Tabelle wurde erfolgreich auf ".$days." Tage gekürzt.</p></div>";
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    if(isset($_POST['cron_save'])) {
 | 
			
		||||
		if($sem_options['statz_do_cron'] == true) {
 | 
			
		||||
            $sem_options['statz_do_cron'] = false;
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            $sem_options['statz_do_cron'] = true;
 | 
			
		||||
            $sem_options['statz_next_cron'] = time() + 86400;
 | 
			
		||||
        }
 | 
			
		||||
		update_option("semmelstatz_options", $sem_options);
 | 
			
		||||
    }
 | 
			
		||||
	
 | 
			
		||||
?>
 | 
			
		||||
 | 
			
		||||
	<div class="wrap">
 | 
			
		||||
		
 | 
			
		||||
		<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>?page=<?php echo plugin_basename(__FILE__); ?>">
 | 
			
		||||
		
 | 
			
		||||
		<div id='icon-semmelstatz' class='icon32'><br /></div>
 | 
			
		||||
		<h2>Semmelstatz › Einstellungen</h2>
 | 
			
		||||
	   
 | 
			
		||||
			<p><input type="submit" class="button-secondary" name="options_save" value="Änderungen übernehmen" /></p>
 | 
			
		||||
			
 | 
			
		||||
			<table class="form-table">
 | 
			
		||||
				
 | 
			
		||||
				<tr style="background:#eee;" valign="middle">
 | 
			
		||||
					<th>Blog-Administratoren aufzeichnen</th>
 | 
			
		||||
					<td><input name="statz_write_admins" type="checkbox" id="statz_write_admins" value="statz_write_admins"
 | 
			
		||||
						<?php if($sem_options["statz_write_admins"] == TRUE) {?> checked="checked" <?php } ?> />
 | 
			
		||||
					</td>
 | 
			
		||||
					<td>Trackt alle Zugriffe des/der Blog-Admins im Frontend des Blogs - (default: AUS)</td>
 | 
			
		||||
				</tr>
 | 
			
		||||
				
 | 
			
		||||
				<tr valign="middle">
 | 
			
		||||
					<th>Blog-User aufzeichnen</th>
 | 
			
		||||
					<td><input name="statz_write_users" type="checkbox" id="statz_write_users" value="statz_write_users"
 | 
			
		||||
						<?php if($sem_options["statz_write_users"] == TRUE) {?> checked="checked" <?php } ?> />
 | 
			
		||||
					</td>
 | 
			
		||||
					<td>Trackt alle Zugriffe der registrierten Blog-User im Frontend des Blogs - (default: AUS)</td>
 | 
			
		||||
				</tr>
 | 
			
		||||
				
 | 
			
		||||
				<tr style="background:#eee;"  valign="middle">
 | 
			
		||||
					<th>IP-Adressen codiert aufzeichnen</th>
 | 
			
		||||
					<td><input name="statz_encode_ip" type="checkbox" id="statz_encode_ip" value="statz_encode_ip"
 | 
			
		||||
						<?php if($sem_options["statz_encode_ip"] == TRUE) {?> checked="checked" <?php } ?> />
 | 
			
		||||
					</td>
 | 
			
		||||
					<td>Der Gesetzgeber verbietet die Aufzeichnung der IP-Adresse eines Besuchers über dessen
 | 
			
		||||
                     zeitlichen Verbleib auf einer Webseite hinaus. Nach Aktivierung dieser Option rechnet SEMMELSTATZ
 | 
			
		||||
                     die IP-Adresse des Besuchers nach einem simplen arithmetischen Verfahren um. Somit schreibt
 | 
			
		||||
						SEMMELSTATZ keine IP-Adressen im Klartext in die <i>statz</i>-Tabelle - (default: AUS)</td>
 | 
			
		||||
				</tr>
 | 
			
		||||
				
 | 
			
		||||
				<tr valign="middle">
 | 
			
		||||
					<th>Statz der letzten <input name="statz_days_limit" type="text" id="statz_days_limit"
 | 
			
		||||
						value="<?php echo $sem_options["statz_days_limit"]; ?>" style="text-align:center;" size="2" maxlength="2" />
 | 
			
		||||
                     Tage anzeigen
 | 
			
		||||
					</th>
 | 
			
		||||
					<td><input name="statz_show_dailystatz" type="checkbox" id="statz_show_dailystatz" value="statz_show_dailystatz"
 | 
			
		||||
						<?php if($sem_options["statz_show_dailystatz"] == TRUE) {?> checked="checked" <?php } ?> />
 | 
			
		||||
					</td>
 | 
			
		||||
					<td>Tagesübersicht Besucher-Hits-Referer in absoluten Zahlen mit absteigendem Datum - (default: 7, AN)</td>
 | 
			
		||||
				</tr>
 | 
			
		||||
				
 | 
			
		||||
				<tr  style="background:#eee;"  valign="middle">
 | 
			
		||||
					<th><input name="statz_referer_limit" type="text" id="statz_referer_limit"
 | 
			
		||||
						value="<?php echo $sem_options["statz_referer_limit"]; ?>" style="text-align:center;" size="2" maxlength="2" />
 | 
			
		||||
                     Referer anzeigen
 | 
			
		||||
					</th>
 | 
			
		||||
					<td><input name="statz_show_referers" type="checkbox" id="statz_show_referers" value="statz_show_referers"
 | 
			
		||||
						<?php if($sem_options["statz_show_referers"] == TRUE) {?> checked="checked" <?php } ?> />
 | 
			
		||||
					</td>
 | 
			
		||||
					<td>Listet <?php echo $sem_options["statz_referer_limit"]; ?> Links auf Webseiten, die auf dieses Blog
 | 
			
		||||
						verweisen - (default: 10, AN)</td>
 | 
			
		||||
				</tr>
 | 
			
		||||
				
 | 
			
		||||
				<tr  valign="middle">
 | 
			
		||||
					<th>Referer-Links via Google maskieren</th>
 | 
			
		||||
					<td><input name="statz_mask_referer" type="checkbox" id="statz_mask_referer" value="statz_mask_referer"
 | 
			
		||||
						<?php if($sem_options["statz_mask_referer"] == TRUE) {?> checked="checked" <?php } ?> />
 | 
			
		||||
					</td>
 | 
			
		||||
					<td>Der Aufruf einer referenzierenden Webseite aus SEMMELSTATZ heraus würde die komplette URL
 | 
			
		||||
					des Adminbereichs an den Webserver dieser Webseite übermitteln. Die Maskierung der Referer-Links
 | 
			
		||||
					als GOOGLE-Weiterleitung verhindert dies. Funktioniert nicht mit allen Links - (default: AUS)</td>
 | 
			
		||||
				</tr>
 | 
			
		||||
				
 | 
			
		||||
				<tr  style="background:#eee;" valign="middle">
 | 
			
		||||
					<th><input name="statz_keyword_limit" type="text" id="statz_keyword_limit"
 | 
			
		||||
						value="<?php echo $sem_options["statz_keyword_limit"]; ?>" style="text-align:center;" size="2" maxlength="2" />
 | 
			
		||||
                     Suchbegriffe anzeigen
 | 
			
		||||
					</th>
 | 
			
		||||
					<td><input name="statz_show_keywords" type="checkbox" id="statz_show_keywords" value="statz_show_keywords"
 | 
			
		||||
						<?php if($sem_options["statz_show_keywords"] == TRUE) {?> checked="checked" <?php } ?> />
 | 
			
		||||
					</td>
 | 
			
		||||
					<td>Listet <?php echo $sem_options["statz_keyword_limit"]; ?> Links zu Suchbegriffen, mit denen Besucher
 | 
			
		||||
						das Blog gefunden haben. Der Name der entsprechenden Searchengine (soweit bekannt) ist dem
 | 
			
		||||
						Suchbegriff vorangestellt. Der WP-internen Suche steht ein INTERN voraus	- (default: 10, AN)</td>
 | 
			
		||||
				</tr>
 | 
			
		||||
				
 | 
			
		||||
				<tr valign="middle">
 | 
			
		||||
					<th>Top<input name="statz_topreads_limit" type="text" id="statz_topreads_limit"
 | 
			
		||||
						value="<?php echo $sem_options["statz_topreads_limit"]; ?>" style="text-align:center;" size="2" maxlength="2" />
 | 
			
		||||
						Posts & Pages anzeigen
 | 
			
		||||
					</th>
 | 
			
		||||
					<td><input name="statz_show_reads" type="checkbox" id="statz_show_reads" value="statz_show_reads"
 | 
			
		||||
						<?php if($sem_options["statz_show_reads"] == TRUE) {?> checked="checked" <?php } ?> />
 | 
			
		||||
					</td>
 | 
			
		||||
					<td>Die <?php echo $sem_options["statz_topreads_limit"]; ?> meist gelesenen Posts & Pages, basierend
 | 
			
		||||
					auf dem seit SEMMELSTATZ 3.2 neuen Zähler in der <i>posts</i>-Tabelle. Dieser Zähler ist, im Gegensatz
 | 
			
		||||
					zur Ermittlung aus der <i>statz</i>-Tabelle, dauerhaft - (default: 10, AN)</td>
 | 
			
		||||
				</tr>
 | 
			
		||||
				
 | 
			
		||||
				<tr  style="background:#eee;" valign="middle">
 | 
			
		||||
					<th>Top10 Posts & Pages heute anzeigen</th>
 | 
			
		||||
					<td><input name="statz_show_todayreads" type="checkbox" id="statz_show_todayreads" value="statz_show_todayreads"
 | 
			
		||||
						<?php if($sem_options["statz_show_todayreads"] == TRUE) {?> checked="checked" <?php } ?> />
 | 
			
		||||
					</td>
 | 
			
		||||
					<td>Die 10 meist gelesenen Posts & Pages des laufenden Tages mit Anzahl der Klicks - (default: AN)</td>
 | 
			
		||||
				</tr>
 | 
			
		||||
				
 | 
			
		||||
				<tr valign="middle">
 | 
			
		||||
					<th>Top<input name="statz_comment_limit" type="text" id="statz_comment_limit"
 | 
			
		||||
						value="<?php echo $sem_options["statz_comment_limit"]; ?>" style="text-align:center;" size="2" maxlength="2" />
 | 
			
		||||
                     Kommentierer anzeigen
 | 
			
		||||
					</th>
 | 
			
		||||
					<td><input name="statz_show_commenters" type="checkbox" id="statz_show_commenters" value="statz_show_commenters"
 | 
			
		||||
						<?php if($sem_options["statz_show_commenters"] == TRUE) {?> checked="checked" <?php } ?> />
 | 
			
		||||
					</td>
 | 
			
		||||
					<td>Die Top<?php echo $sem_options["statz_comment_limit"]; ?> der Kommentierer auf Basis der
 | 
			
		||||
					<i>comments</i>-Tabelle mit Anzahl ihrer Kommentare - (default: 10, AN)</td>
 | 
			
		||||
				</tr>
 | 
			
		||||
				
 | 
			
		||||
				<tr  style="background:#eee;" valign="middle">
 | 
			
		||||
					<th>Top10 kommentierter Posts anzeigen</th>
 | 
			
		||||
					<td><input name="statz_show_topcommposts" type="checkbox" id="statz_show_topcommposts" value="statz_show_topcommposts"
 | 
			
		||||
						<?php if($sem_options["statz_show_topcommposts"] == TRUE) {?> checked="checked" <?php } ?> />
 | 
			
		||||
					</td>
 | 
			
		||||
					<td>Die Top10 der kommentierten Posts mit Anzahl der Kommentare - (default: AN)</td>
 | 
			
		||||
				</tr>
 | 
			
		||||
				
 | 
			
		||||
				<tr valign="middle">
 | 
			
		||||
					<th>Online-User anzeigen</th>
 | 
			
		||||
					<td><input name="statz_show_useronline" type="checkbox" id="statz_show_useronline" value="statz_show_useronline"
 | 
			
		||||
						<?php if($sem_options["statz_show_useronline"] == TRUE) {?> checked="checked" <?php } ?> />
 | 
			
		||||
					</td>
 | 
			
		||||
					<td>Zeigt einen Besucher an, sobald er das Blog 'betreten' hat. Ist er ein Administrator oder regsitrierter
 | 
			
		||||
						User des Blogs oder kommt mit einem Kommentar-COOKIE, wird er mit seinem Login- bzw. Kommentierer-Namen und
 | 
			
		||||
						nicht als GAST angezeigt - (default: AN)</td>
 | 
			
		||||
				</tr>
 | 
			
		||||
				
 | 
			
		||||
				<tr  style="background:#eee;" valign="middle">
 | 
			
		||||
					<th>Sekunden, die ein User als anwesend gilt</th>
 | 
			
		||||
					<td><input name="statz_online_time" type="text" id="statz_onlinetime_time"
 | 
			
		||||
						value="<?php echo $sem_options["statz_online_time"]; ?>" style="text-align:center;" size="3" maxlength="4" />
 | 
			
		||||
					</td>
 | 
			
		||||
					<td>Dieser Wert legt fest, dass ein Besucher <?php echo $sem_options["statz_online_time"]; ?> Sekunden als
 | 
			
		||||
						anwesend gilt und so lange als ONLINE-Besucher angezeigt wird - (default: 180)</td>
 | 
			
		||||
				</tr>
 | 
			
		||||
				
 | 
			
		||||
				<tr valign="middle">
 | 
			
		||||
					<th>Heutige User anzeigen</th>
 | 
			
		||||
					<td><input name="statz_show_todayusers" type="checkbox" id="statz_show_todayusers" value="statz_show_todayusers"
 | 
			
		||||
						<?php if($sem_options["statz_show_todayusers"] == TRUE) {?> checked="checked" <?php } ?> /></td>
 | 
			
		||||
					<td>(default: AN)</td>
 | 
			
		||||
				</tr>
 | 
			
		||||
				
 | 
			
		||||
				<tr style="background:#eee;"  valign="middle">
 | 
			
		||||
					<th>Mini-Statz im Dashboard anzeigen</th>
 | 
			
		||||
					<td><input name="statz_on_dashboard" type="checkbox" id="statz_on_dashboard" value="statz_on_dashboard"
 | 
			
		||||
						<?php if($sem_options["statz_on_dashboard"] == TRUE) {?> checked="checked" <?php } ?> />
 | 
			
		||||
					</td>
 | 
			
		||||
					<td>Aktiviert das SEMMELSTATZ-Widget im Dashboard - (default: AUS)</td>
 | 
			
		||||
				</tr>
 | 
			
		||||
				
 | 
			
		||||
				<tr valign="middle">
 | 
			
		||||
					<th>Anzahl Datensätze im <a href='admin.php?page=semmelstatz/semmelstatz-log.php'>Log</a></th>
 | 
			
		||||
					<td><input name="statz_datarecs_limit" type="text" id="statz_datarecs_limit"
 | 
			
		||||
						value="<?php echo $sem_options["statz_datarecs_limit"]; ?>" style="text-align:center;" size="3" maxlength="4" />
 | 
			
		||||
					</td>
 | 
			
		||||
					<td>Anzahl der kompletten Datensätze <i>DATUM-TCP/IP-REFERER-SUCHBEGRIFF-POST/PAGE-USERNAME</i>
 | 
			
		||||
					im SEMMELSTATZ-Log - (default: 100)</td>
 | 
			
		||||
				</tr>
 | 
			
		||||
				
 | 
			
		||||
				<tr valign="middle">
 | 
			
		||||
					<th></th>
 | 
			
		||||
					<td></td>
 | 
			
		||||
				</tr>
 | 
			
		||||
				
 | 
			
		||||
			</table>
 | 
			
		||||
			
 | 
			
		||||
			<p><input type="submit" class="button-secondary" name="options_save" value="Änderungen übernehmen" /></p>
 | 
			
		||||
			
 | 
			
		||||
       </form>
 | 
			
		||||
 | 
			
		||||
       <div id='icon-semmelstatz' class='icon32'><br /></div>
 | 
			
		||||
	   <h2>Semmelstatz › Statz-Tabellen</h2>
 | 
			
		||||
 | 
			
		||||
			<table class="form-table">
 | 
			
		||||
				
 | 
			
		||||
				<tr valign="middle">
 | 
			
		||||
					<td colspan="2">
 | 
			
		||||
						<i>statz</i>-Tabelle: <?php echo sem_countDaysInStatzTable()-1; ?>,xx Tage (Der aktuelle Tag ist natürlich nie komplett!!!)<br />
 | 
			
		||||
						<i>statzhist</i>-Tabelle: <?php echo sem_showStatzDays(); ?> Tage
 | 
			
		||||
					</td>
 | 
			
		||||
			   </tr>
 | 
			
		||||
			   <tr style="background:#eee;"  valign="middle">
 | 
			
		||||
					<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>?page=<?php echo plugin_basename(__FILE__); ?>">
 | 
			
		||||
					<th><input name="statz_recdays_limit" type="input" id="statz_recdays_limit"
 | 
			
		||||
						value="<?php echo $sem_options["statz_recdays_limit"]; ?>" style="text-align:center;"
 | 
			
		||||
						size="2" maxlength="3" />-Tage-Limit für die <i>statz</i>-Tabelle festlegen.
 | 
			
		||||
					</th>
 | 
			
		||||
					<td>
 | 
			
		||||
						<input type="submit" class="button-secondary" name="limit_save" value="Limit speichern" />
 | 
			
		||||
					</td>
 | 
			
		||||
					<td>
 | 
			
		||||
						Um die <i>statz</i>-Tabelle nicht ins Unendliche anwachsen zu lassen, macht es Sinn sie zu limitieren,
 | 
			
		||||
						egal, ob nun manuell oder automatisch. Links die Anzahl der Statistiktage (nicht der zu löschenden Tage)
 | 
			
		||||
						eintragen und speichern. Der Wert muss eine Ganzzahl <b>>= 1</b> (default: 20) sein, sonst werden falsche
 | 
			
		||||
						Werte in die <i>statzhist</i>-Tabelle übertragen. Der Wert gilt dann sowohl für das manuelle, wie
 | 
			
		||||
						auch das automatische Limit.<br /><u>Dieser Schritt löscht noch keine Daten, sondern speichert nur den Wert
 | 
			
		||||
						fü das Limit!</u>
 | 
			
		||||
					</td>
 | 
			
		||||
					</form>
 | 
			
		||||
				</tr>
 | 
			
		||||
				<tr valign="middle">
 | 
			
		||||
					<form  method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>?page=<?php echo plugin_basename(__FILE__); ?>">
 | 
			
		||||
					<th><i>statz</i>-Tabelle manuell limitieren</th>
 | 
			
		||||
					<td>
 | 
			
		||||
						<input type="submit" class="button-secondary" name="limit_execute" value="statz-Tabelle kürzen" />
 | 
			
		||||
					</td>
 | 
			
		||||
					<td>Es erfolgt <u>keine</u> Rückfrage! Die <i>statz</i>-Tabelle wird <u>einmalig</u> auf
 | 
			
		||||
						<b><?php echo $sem_options["statz_recdays_limit"]; ?></b> Tage gekürzt. Alle Datensätze <u>über diesen
 | 
			
		||||
						Zeitraum hinaus</u> werden unwiderruflich gelöscht. Dies gilt nicht für die historischen Daten.
 | 
			
		||||
					</td>
 | 
			
		||||
					</form>
 | 
			
		||||
				</tr>
 | 
			
		||||
				<tr style="background:#eee;"  valign="middle">
 | 
			
		||||
					<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>?page=<?php echo plugin_basename(__FILE__); ?>">
 | 
			
		||||
					<th><i>statz</i>-Tabelle automatisch limitieren</th>
 | 
			
		||||
					<td>
 | 
			
		||||
						<?php if($sem_options["statz_do_cron"] == true): ?>
 | 
			
		||||
							<input type="submit" class="button-secondary" name="cron_save" value="Automatisches Limit deaktivieren" />
 | 
			
		||||
						<?php else:?>
 | 
			
		||||
							<input type="submit" class="button-secondary" name="cron_save" value="Automatisches Limit aktivieren" />
 | 
			
		||||
						<?php endif ?>
 | 
			
		||||
					</td>
 | 
			
		||||
					<td>Das automatische Limitieren der statz-Tabelle ist <?php if ($sem_options["statz_do_cron"] == false): ?>
 | 
			
		||||
						<span style="color:#fff;background:red;font-weight:bold;"> deaktiviert </span>
 | 
			
		||||
						<?php else: ?>
 | 
			
		||||
						<span style="color:#fff;background:green;font-weight:bold;"> aktiviert </span>
 | 
			
		||||
						<?php endif ?>
 | 
			
		||||
						<?php if ($sem_options["statz_do_cron"] == true): ?>
 | 
			
		||||
						<br />Nächster Lauf am <?php echo date("j.n.Y", $sem_options["statz_next_cron"]); ?>
 | 
			
		||||
						gegen <?php echo date("G:i", $sem_options["statz_next_cron"]); ?> Uhr.
 | 
			
		||||
						<?php else: ?>
 | 
			
		||||
						<br />Es erfolgt keine automatische Limitierung
 | 
			
		||||
						<?php endif ?>
 | 
			
		||||
					</td>
 | 
			
		||||
					</form>
 | 
			
		||||
				</tr>
 | 
			
		||||
				<tr valign="middle">
 | 
			
		||||
					<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>?page=<?php echo plugin_basename(__FILE__); ?>">
 | 
			
		||||
					<th><i>statz</i>-Tabelle leeren</th>
 | 
			
		||||
					<td>
 | 
			
		||||
						<input type="submit" class="button-secondary" name="trunc_save" value="statz-Tabelle leeren" />
 | 
			
		||||
					</td>
 | 
			
		||||
					<td>Die Datensätze der <b>statz</b>-Tabelle werden unwiderruflich geleert, und der Speicherplatz in der Datenbank mittels
 | 
			
		||||
						<b>OPTIMIZE TABLE</b> freigegeben. ACHTUNG: Es erfolgt <u>keine</u> Rückfrage! Die Aufzeichnung
 | 
			
		||||
						läuft ohne Unterbrechung weiter. Die Daten der <i>statzhist</i>-Tabelle bleiben unberührt.
 | 
			
		||||
					</td>
 | 
			
		||||
					</form>
 | 
			
		||||
				</tr>
 | 
			
		||||
			</table>
 | 
			
		||||
		<hr />
 | 
			
		||||
		
 | 
			
		||||
		<?php sem_showCopyright(); ?>
 | 
			
		||||
 | 
			
		||||
	</div>
 | 
			
		||||
							
								
								
									
										501
									
								
								trunk/semmelstatz-statz.php
									
										
									
									
									
										Normale Datei
									
								
							
							
						
						| 
						 | 
				
			
			@ -0,0 +1,501 @@
 | 
			
		|||
<?php
 | 
			
		||||
 | 
			
		||||
/***********************************************
 | 
			
		||||
 *                                             *
 | 
			
		||||
 *   semmelstatz_statz.php v3.3           *
 | 
			
		||||
 *   Copyright: © 2005-2009 kopfhoch-studio    *
 | 
			
		||||
 *                                             *
 | 
			
		||||
 ***********************************************/
 | 
			
		||||
 
 | 
			
		||||
if(!current_user_can('manage_statz')) {
 | 
			
		||||
	die('Zugriff verweigert');
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
### AKTUELL - Funktionen
 | 
			
		||||
 | 
			
		||||
	function sem_showWhoIsOnline() {
 | 
			
		||||
        global $wpdb;
 | 
			
		||||
		
 | 
			
		||||
		$sem_options = get_option('semmelstatz_options'); ### optionsarray auslesen
 | 
			
		||||
		$onlinetime = $sem_options["statz_online_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");
 | 
			
		||||
        
 | 
			
		||||
        print "<div class='statz'>".sem_showNumUsersOnline()." Besucher online - Heute: ".sem_showTodayStatz()."</div>";
 | 
			
		||||
        
 | 
			
		||||
        if (empty($onlineusers)) {
 | 
			
		||||
            print "<small>... keine Einträge</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>";
 | 
			
		||||
            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 {
 | 
			
		||||
                    $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
 | 
			
		||||
                }
 | 
			
		||||
                
 | 
			
		||||
                $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/semmelstatz/img/arin.png' /></a> 
 | 
			
		||||
                <a target='_blank' style='border:none;' href='http://www.ripe.net/whois?searchtext=".$ip."'>
 | 
			
		||||
                <img src='".get_option('siteurl')."/wp-content/plugins/semmelstatz/img/ripe.png' /></a> 
 | 
			
		||||
                <a target='_blank' style='border:none;' href='http://www.utrace.de/?query=".$ip."'>
 | 
			
		||||
                <img src='".get_option('siteurl')."/wp-content/plugins/semmelstatz/img/utrace.png' /></a></td>";
 | 
			
		||||
                print "<td style='text-align:center;'>$time</td>";
 | 
			
		||||
                print "</tr>";
 | 
			
		||||
            }
 | 
			
		||||
        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äge</small></div>";
 | 
			
		||||
			print "<hr />";
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
		
 | 
			
		||||
		foreach ($results as $result) {
 | 
			
		||||
			$visitors[] = $result->visitors;
 | 
			
		||||
			$hours[] = mysql2date('H', $result->hours);
 | 
			
		||||
        }
 | 
			
		||||
		
 | 
			
		||||
		$maxvalue = max($visitors);
 | 
			
		||||
		$visitors = implode(',', $visitors);
 | 
			
		||||
		$hours = "|".implode('|', $hours)."|";
 | 
			
		||||
		
 | 
			
		||||
		$charturl = "http://chart.apis.google.com/chart?";
 | 
			
		||||
		$chartsize = "chs=600x150&";
 | 
			
		||||
		$charttype = "cht=bvs&";
 | 
			
		||||
		$chartgrid = "chg=25,25&";
 | 
			
		||||
		$chartdata = "chd=t:".$visitors."&";
 | 
			
		||||
		$chartminmax = "chds=0,".$maxvalue."&";
 | 
			
		||||
		$barsize = "chbh=a&";
 | 
			
		||||
		$axis = "chxt=x,y&";
 | 
			
		||||
		$axisdataX = "chxl=0:".$hours;
 | 
			
		||||
		$axisdataY = "1:|0|".$maxvalue."&";
 | 
			
		||||
		$datalabels = "chm=N,000000,0,-1,10";
 | 
			
		||||
		
 | 
			
		||||
		$chart = $charturl.$chartsize.$charttype.$chartgrid.$chartdata.$chartminmax.$barsize.$axis.$axisdataX.$axisdataY.$datalabels;
 | 
			
		||||
		
 | 
			
		||||
		print "<div class='chart'>";
 | 
			
		||||
		
 | 
			
		||||
			print "<img src=".$chart." alt='Chart nicht verfügbar'/>";
 | 
			
		||||
		
 | 
			
		||||
		print "</div>";
 | 
			
		||||
		print "</div>";
 | 
			
		||||
		print "<hr />";
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	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 "<div class='statz'>".$limit."-Tage-Statistik</div>";
 | 
			
		||||
        if (empty($thedays)) {
 | 
			
		||||
            print "<small>... noch keine Einträge</small>";
 | 
			
		||||
			print "<hr />";
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        print "<table class='statzelement'>";
 | 
			
		||||
        print "<thead>";
 | 
			
		||||
        print "<tr>";
 | 
			
		||||
        print "<th style='text-align:left;'>Datum</th>";
 | 
			
		||||
        print "<th style='width: 15%;text-align:center;'>Besucher</th>";
 | 
			
		||||
        print "<th style='width: 15%;text-align:center;'>Hits</th>";
 | 
			
		||||
        print "<th style='width: 15%;text-align:center;'>Referer</th>";
 | 
			
		||||
        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) {
 | 
			
		||||
                    $date = "Heute";
 | 
			
		||||
                }
 | 
			
		||||
                elseif($difference == 1) {
 | 
			
		||||
                    $date = "Gestern";
 | 
			
		||||
                }
 | 
			
		||||
                elseif($difference == 2) {
 | 
			
		||||
                    $date = "Vorgestern";
 | 
			
		||||
                }
 | 
			
		||||
                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>";
 | 
			
		||||
        print "<td style='text-align:left;'><a href='".get_option('siteurl')."/wp-admin/admin.php?page=semmelstatz/semmelstatz-history.php'>mehr...</a></td>";
 | 
			
		||||
        print "</tr>";
 | 
			
		||||
        print "</tbody>";
 | 
			
		||||
        print "</table>";
 | 
			
		||||
		print "<hr />";
 | 
			
		||||
	}
 | 
			
		||||
    
 | 
			
		||||
	function sem_showReferers() {
 | 
			
		||||
        global $wpdb, $homehost;
 | 
			
		||||
		
 | 
			
		||||
		$sem_options = get_option('semmelstatz_options'); ### optionsarray auslesen
 | 
			
		||||
		$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);
 | 
			
		||||
        
 | 
			
		||||
        print "<div class='statz'>Die letzten ".$limit." Referer</div>";
 | 
			
		||||
        if (empty($lastreferers)) {
 | 
			
		||||
            print "<small>... noch keine Einträge</small>";
 | 
			
		||||
			print "<hr />";
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        print "<table class='statzelement'>";
 | 
			
		||||
        print "<thead>";
 | 
			
		||||
        print "<tr>";
 | 
			
		||||
		print "<th style='text-align:center;width:12%;'>Zeit</th>";
 | 
			
		||||
        print "<th style='text-align:left;'>Referer</th>";
 | 
			
		||||
        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() {
 | 
			
		||||
        global $wpdb;
 | 
			
		||||
		
 | 
			
		||||
		$sem_options = get_option('semmelstatz_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");
 | 
			
		||||
		
 | 
			
		||||
		print "<div class='statz'>Die letzten $limit Suchbegriffe</div>";
 | 
			
		||||
        if (empty($results)) {
 | 
			
		||||
            print "<small>... noch keine Einträge</small>";
 | 
			
		||||
			print "<hr />";
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        print "<table class='statzelement'>";
 | 
			
		||||
        print "<thead>";
 | 
			
		||||
        print "<tr>";
 | 
			
		||||
		print "<th style='text-align: center;width:12%;'>Zeit</th>";
 | 
			
		||||
        print "<th style='text-align:left;width:70%;'>Suchbegriff</th>";
 | 
			
		||||
        print "<th style='text-align:left;'>TCP/IP</th>";
 | 
			
		||||
        print "</tr>";
 | 
			
		||||
        print "</thead>";
 | 
			
		||||
        print "<tbody>";
 | 
			
		||||
		$i=0;
 | 
			
		||||
			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."'>
 | 
			
		||||
						<img src='".get_option('siteurl')."/wp-content/plugins/semmelstatz/img/arin.png' /></a> 
 | 
			
		||||
						<a target='_blank' href='http://www.ripe.net/whois?searchtext=".$ip."'>
 | 
			
		||||
						<img src='".get_option('siteurl')."/wp-content/plugins/semmelstatz/img/ripe.png' /></a> 
 | 
			
		||||
						<a target='_blank' href='http://www.utrace.de/?query=".$ip."'>
 | 
			
		||||
						<img src='".get_option('siteurl')."/wp-content/plugins/semmelstatz/img/utrace.png' /></a></td>";
 | 
			
		||||
						
 | 
			
		||||
						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");
 | 
			
		||||
        
 | 
			
		||||
        print "<div class='statz'>Die Top10 aller Posts & Pages heute</div>";
 | 
			
		||||
        if (empty($topreads)) {
 | 
			
		||||
            print "<small>... noch keine Einträge</small>";
 | 
			
		||||
			print "<hr />";
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        print "<table class='statzelement'>";
 | 
			
		||||
        print "<thead>";
 | 
			
		||||
        print "<tr>";
 | 
			
		||||
        print "<th style='text-align: left; width: 45%;'>Post/Page</th>";
 | 
			
		||||
        print "<th style='text-align: left; width: 45%;'>Postname</th>";
 | 
			
		||||
        print "<th style='text-align: center; width: 10%;'>Hits</th>";
 | 
			
		||||
        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>";
 | 
			
		||||
		print "<hr />";
 | 
			
		||||
    }
 | 
			
		||||
	
 | 
			
		||||
	function sem_showTopReads() {
 | 
			
		||||
        global $wpdb;
 | 
			
		||||
		
 | 
			
		||||
		$sem_options = get_option('semmelstatz_options'); ### optionsarray auslesen
 | 
			
		||||
        $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);
 | 
			
		||||
        
 | 
			
		||||
        print "<div class='statz'>Die Top".$limit." aller Posts & Pages</div>";
 | 
			
		||||
        if (empty($topreads)) {
 | 
			
		||||
            print "<small>... noch keine Einträge</small>";
 | 
			
		||||
			print "<hr />";
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        print "<table class='statzelement'>";
 | 
			
		||||
        print "<thead>";
 | 
			
		||||
        print "<tr>";
 | 
			
		||||
        print "<th style='text-align: left; width: 45%;'>Post/Page</th>";
 | 
			
		||||
        print "<th style='text-align: left; width: 45%;'>Postname</th>";
 | 
			
		||||
        print "<th style='text-align: center; width: 10%;'>Hits</th>";
 | 
			
		||||
        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>";
 | 
			
		||||
		print "<hr />";
 | 
			
		||||
    }
 | 
			
		||||
	
 | 
			
		||||
    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 "<div class='statz'>Bekannte Besucher heute</div>";
 | 
			
		||||
        if (empty($todaysonlineusers)) {
 | 
			
		||||
            print "<small>... noch keine Einträge</small>";
 | 
			
		||||
			print "<hr />";
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        print "<table class='statzelement'>";
 | 
			
		||||
        print "<thead>";
 | 
			
		||||
        print "<tr>";
 | 
			
		||||
        print "<th style='text-align: left; width: 80%;'>Besucher (Hits)</th>";
 | 
			
		||||
        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>";
 | 
			
		||||
		print "<hr />";
 | 
			
		||||
    }
 | 
			
		||||
	
 | 
			
		||||
	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 "<div class='statz'>Die Top10 aller kommentierter Posts</div>";
 | 
			
		||||
        if (empty($topcommentedposts)) {
 | 
			
		||||
            print "<small>... noch keine Einträge</small>";
 | 
			
		||||
			print "<hr />";
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        print "<table class='statzelement'>";
 | 
			
		||||
        print "<thead>";
 | 
			
		||||
        print "<tr>";
 | 
			
		||||
        print "<th style='text-align: left; width: 80%;'>Post/Page</th>";
 | 
			
		||||
        print "<th style='text-align: center; width: 20%;'>Kommentare</th>";
 | 
			
		||||
        print "</tr>";
 | 
			
		||||
        print "</thead>";
 | 
			
		||||
        print "<tbody>";
 | 
			
		||||
        
 | 
			
		||||
            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>";
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
        print "</tbody>";
 | 
			
		||||
        print "</table>";
 | 
			
		||||
		print "<hr />";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    function sem_showCommenters() {
 | 
			
		||||
        global $wpdb;
 | 
			
		||||
		
 | 
			
		||||
		$sem_options = get_option('semmelstatz_options'); ### optionsarray auslesen
 | 
			
		||||
        $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);
 | 
			
		||||
        
 | 
			
		||||
        print "<div class='statz'>Die Top".$limit." aller Kommentierer</div>";
 | 
			
		||||
        if (empty($topcommenters)) {
 | 
			
		||||
            print "<small>... noch keine Einträge</small>";
 | 
			
		||||
			print "<hr />";
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        print "<table class='statzelement'>";
 | 
			
		||||
        print "<thead>";
 | 
			
		||||
        print "<tr>";
 | 
			
		||||
        print "<th style='text-align: left; width: 20%;'>User</th>";
 | 
			
		||||
        print "<th style='text-align: left; width: 30%;'>Email</th>";
 | 
			
		||||
        print "<th style='text-align: left; width: 40%;'>Homepage</th>";
 | 
			
		||||
        print "<th style='text-align: center; width: 10%;'>Kommentare</th>";
 | 
			
		||||
        print "</tr>";
 | 
			
		||||
        print "</thead>";
 | 
			
		||||
        print "<tbody>";
 | 
			
		||||
        
 | 
			
		||||
            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>";
 | 
			
		||||
            }
 | 
			
		||||
        
 | 
			
		||||
        print "</tbody>";
 | 
			
		||||
        print "</table>";
 | 
			
		||||
		print "<hr />";
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
### AKTUELL Anzeige
 | 
			
		||||
 | 
			
		||||
	print "<div class='wrap'>";
 | 
			
		||||
		print "<div><a name='top'></a></div>";
 | 
			
		||||
		print "<div id='icon-semmelstatz' class='icon32'><br /></div>";
 | 
			
		||||
		print "<h2>Semmelstatz › Aktuell</h2>";
 | 
			
		||||
		$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 "</div>";
 | 
			
		||||
		
 | 
			
		||||
?>
 | 
			
		||||
							
								
								
									
										217
									
								
								trunk/semmelstatz-templates.php
									
										
									
									
									
										Normale Datei
									
								
							
							
						
						| 
						 | 
				
			
			@ -0,0 +1,217 @@
 | 
			
		|||
<?php
 | 
			
		||||
 | 
			
		||||
/***********************************************
 | 
			
		||||
 *                                             *
 | 
			
		||||
 *   semmelstatz_templates.php v3.3            *
 | 
			
		||||
 *   Copyright: © 2005-2009 kopfhoch-studio    *
 | 
			
		||||
 *                                             *
 | 
			
		||||
 ***********************************************/
 | 
			
		||||
 
 | 
			
		||||
if(!current_user_can('manage_statz')) {
 | 
			
		||||
	die('Zugriff verweigert');
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
### TEMPLATES
 | 
			
		||||
 | 
			
		||||
		$totalposts = sem_showTotalPosts();
 | 
			
		||||
		$totalcomments = sem_showTotalComments();
 | 
			
		||||
		$totalusers = sem_showTotalUsers();
 | 
			
		||||
		$averageuserperday = sem_showAverageUserPerDay();
 | 
			
		||||
		$firstpostdate = sem_showFirstPostDate();
 | 
			
		||||
		$postdays =	sem_showPostDays();
 | 
			
		||||
		$firstcommentdate =	sem_showFirstCommentDate();
 | 
			
		||||
		$commentdays = sem_showCommentDays();
 | 
			
		||||
		$postsperday = sem_showPostsPerDay();
 | 
			
		||||
		$commentsperday = sem_showCommentsPerDay();
 | 
			
		||||
		$numcommenters = sem_showNumCommenters();
 | 
			
		||||
		$statzstartdate = sem_showStatzStartDate();
 | 
			
		||||
		$statzdays = sem_showStatzDays();
 | 
			
		||||
		$numusersonline = sem_showNumUsersOnline();
 | 
			
		||||
 | 
			
		||||
	### DIE ANZEIGE
 | 
			
		||||
 | 
			
		||||
		print "<form>";
 | 
			
		||||
		print "<div class='wrap'>";
 | 
			
		||||
		print "<div id='icon-template' class='icon32'><br /></div>";
 | 
			
		||||
		print "<h2>Semmelstatz › Template-Funktionen</h2>";
 | 
			
		||||
		print "<br />";
 | 
			
		||||
		print "<table class='statzelement'>";
 | 
			
		||||
		print "<thead>";
 | 
			
		||||
		print "<tr>";
 | 
			
		||||
		print "<th style='text-align:left;'>Funktion</th>";
 | 
			
		||||
		print "<th style='text-align:left;width:26em;'>Syntax</th>";
 | 
			
		||||
		print "<th style='text-align:left;'>Rückgabewert</th>";
 | 
			
		||||
		print "<th style='text-align:left;'>Hier</th>";
 | 
			
		||||
		print "<th style='text-align:left;'>Bemerkung</th>";
 | 
			
		||||
		print "</tr>";
 | 
			
		||||
		print "</thead>";
 | 
			
		||||
		print "<tbody>";
 | 
			
		||||
 | 
			
		||||
		print "<tr>";
 | 
			
		||||
		print "<td>sem_showTotalPosts</td>";
 | 
			
		||||
		print "<td><input type='text' value='<?php sem_showTotalPosts(); ?>' class='regular-text' /></td>";
 | 
			
		||||
		print "<td>Ganzzahl</td>";
 | 
			
		||||
		print "<td>$totalposts</td>";
 | 
			
		||||
		print "<td>Anzahl aller Beiträge</td>";
 | 
			
		||||
		print "</tr>";
 | 
			
		||||
		
 | 
			
		||||
		print "<tr>";
 | 
			
		||||
		print "<td>sem_showTotalComments</td>";
 | 
			
		||||
		print "<td><input type='text' value='<?php sem_showTotalComments(); ?>' class='regular-text' /></td>";
 | 
			
		||||
		print "<td>Ganzzahl</td>";
 | 
			
		||||
		print "<td>$totalcomments</td>";
 | 
			
		||||
		print "<td>Anzahl aller Kommentare</td>";
 | 
			
		||||
		print "</tr>";
 | 
			
		||||
		
 | 
			
		||||
		print "<tr>";
 | 
			
		||||
		print "<td>sem_showTotalUsers</td>";
 | 
			
		||||
		print "<td><input type='text' value='<?php sem_showTotalUsers(); ?>' class='regular-text' /></td>";
 | 
			
		||||
		print "<td>Ganzzahl</td>";
 | 
			
		||||
		print "<td>$totalusers</td>";
 | 
			
		||||
		print "<td>Gesamtzahl aller Besucher seit Statistikaufzeichnung</td>";
 | 
			
		||||
		print "</tr>";
 | 
			
		||||
		
 | 
			
		||||
		print "<tr>";
 | 
			
		||||
		print "<td>sem_showAverageUserPerDay</td>";
 | 
			
		||||
		print "<td><input type='text' value='<?php sem_showAverageUserPerDay(); ?>' class='regular-text' /></td>";
 | 
			
		||||
		print "<td>Dezimal</td>";
 | 
			
		||||
		print "<td>$averageuserperday</td>";
 | 
			
		||||
		print "<td>Durchschnittliche Anzahl der täglichen Besucher</td>";
 | 
			
		||||
		print "</tr>";
 | 
			
		||||
		
 | 
			
		||||
		print "<tr>";
 | 
			
		||||
		print "<td>sem_showFirstPostDate</td>";
 | 
			
		||||
		print "<td><input type='text' value='<?php sem_showFirstPostDate(); ?>' class='regular-text' /></td>";
 | 
			
		||||
		print "<td>Datum (d.m.y)</td>";
 | 
			
		||||
		print "<td>$firstpostdate</td>";
 | 
			
		||||
		print "<td>Datum des 1. Posts</td>";
 | 
			
		||||
		print "</tr>";
 | 
			
		||||
		
 | 
			
		||||
		print "<tr>";
 | 
			
		||||
		print "<td>sem_showPostDays</td>";
 | 
			
		||||
		print "<td><input type='text' value='<?php sem_showPostDays(); ?>' class='regular-text' /></td>";
 | 
			
		||||
		print "<td>Ganzzahl</td>";
 | 
			
		||||
		print "<td>$postdays</td>";
 | 
			
		||||
		print "<td>Zeitraum in Tagen seit 1. Beitrag</td>";
 | 
			
		||||
		print "</tr>";
 | 
			
		||||
		
 | 
			
		||||
		print "<tr>";
 | 
			
		||||
		print "<td>em_showFirstCommentDate</td>";
 | 
			
		||||
		print "<td><input type='text' value='<?php sem_showFirstCommentDate(); ?>' class='regular-text' /></td>";
 | 
			
		||||
		print "<td>Datum (d.m.y)</td>";
 | 
			
		||||
		print "<td>$firstcommentdate</td>";
 | 
			
		||||
		print "<td>Datum des 1. Kommentars</td>";
 | 
			
		||||
		print "</tr>";
 | 
			
		||||
		
 | 
			
		||||
		print "<tr>";
 | 
			
		||||
		print "<td>sem_showCommentDays</td>";
 | 
			
		||||
		print "<td><input type='text' value='<?php sem_showCommentDays(); ?>' class='regular-text' /></td>";
 | 
			
		||||
		print "<td>Ganzzahl</td>";
 | 
			
		||||
		print "<td>$commentdays</td>";
 | 
			
		||||
		print "<td>Zeitraum in Tagen seit 1. Kommentar</td>";
 | 
			
		||||
		print "</tr>";
 | 
			
		||||
		
 | 
			
		||||
		print "<tr>";
 | 
			
		||||
		print "<td>sem_showPostsPerDay</td>";
 | 
			
		||||
		print "<td><input type='text' value='<?php sem_showPostsPerDay(); ?>' class='regular-text' /></td>";
 | 
			
		||||
		print "<td>Dezimal</td>";
 | 
			
		||||
		print "<td>$postsperday</td>";
 | 
			
		||||
		print "<td>Durchschnittliche Anzahl der Beiträge pro Tag</td>";
 | 
			
		||||
		print "</tr>";
 | 
			
		||||
		
 | 
			
		||||
		print "<tr>";
 | 
			
		||||
		print "<td>sem_showCommentsPerDay</td>";
 | 
			
		||||
		print "<td><input type='text' value='<?php sem_showCommentsPerDay(); ?>' class='regular-text' /></td>";
 | 
			
		||||
		print "<td>Dezimal</td>";
 | 
			
		||||
		print "<td>$commentsperday</td>";
 | 
			
		||||
		print "<td>Durchschnittliche Anzahl der Kommentare pro Tag</td>";
 | 
			
		||||
		print "</tr>";
 | 
			
		||||
		
 | 
			
		||||
		print "<td>sem_showNumCommenters</td>";
 | 
			
		||||
		print "<td><input type='text' value='<?php sem_showNumCommenters(); ?>' class='regular-text' /></td>";
 | 
			
		||||
		print "<td>Ganzzahl</td>";
 | 
			
		||||
		print "<td>$numcommenters</td>";
 | 
			
		||||
		print "<td>Gesamtzahl aller Kommentierer</td>";
 | 
			
		||||
		print "</tr>";
 | 
			
		||||
		
 | 
			
		||||
		print "<tr>";
 | 
			
		||||
		print "<td>sem_showStatzStartDate</td>";
 | 
			
		||||
		print "<td><input type='text' value='<?php sem_showStatzStartDate(); ?>' class='regular-text' /></td>";
 | 
			
		||||
		print "<td>Datum (d.m.y)</td>";
 | 
			
		||||
		print "<td>$statzstartdate</td>";
 | 
			
		||||
		print "<td>Beginn der Statistik</td>";
 | 
			
		||||
		print "</tr>";
 | 
			
		||||
		
 | 
			
		||||
		print "<tr>";
 | 
			
		||||
		print "<td>sem_showStatzDays</td>";
 | 
			
		||||
		print "<td><input type='text' value='<?php sem_showStatzDays(); ?>' class='regular-text' /></td>";
 | 
			
		||||
		print "<td>Ganzzahl</td>";
 | 
			
		||||
		print "<td>$statzdays</td>";
 | 
			
		||||
		print "<td>Zeitraum der Statistik in Tagen</td>";
 | 
			
		||||
		print "</tr>";
 | 
			
		||||
		
 | 
			
		||||
		print "<tr>";
 | 
			
		||||
		print "<td>sem_showNumUsersOnline</td>";
 | 
			
		||||
		print "<td><input type='text' value='<?php sem_showNumUsersOnline(); ?>' class='regular-text' /></td>";
 | 
			
		||||
		print "<td>Ganzzahl</td>";
 | 
			
		||||
		print "<td>$numusersonline</td>";
 | 
			
		||||
		print "<td>User Online</td>";
 | 
			
		||||
		print "</tr>";
 | 
			
		||||
		
 | 
			
		||||
		print "<tr>";
 | 
			
		||||
		print "<td>sem_showLastComments</td>";
 | 
			
		||||
		print "<td><input type='text' value='<?php sem_showLastComments(10); ?>' class='regular-text' /></td>";
 | 
			
		||||
		print "<td>Formatierte Liste</td>";
 | 
			
		||||
		print "<td>n/a</td>";
 | 
			
		||||
		print "<td>Die neusten 'n' Kommentare mit Autor, Post, abwärts sortiert nach Datum<br />CSS-ID: #lastcomments</td>";
 | 
			
		||||
		print "</tr>";
 | 
			
		||||
		
 | 
			
		||||
		print "<tr>";
 | 
			
		||||
		print "<td>sem_showLastPosts</td>";
 | 
			
		||||
		print "<td><input type='text' value='<?php sem_showLastPosts(10); ?>' class='regular-text' /></td>";
 | 
			
		||||
		print "<td>Formatierte Liste</td>";
 | 
			
		||||
		print "<td>n/a</td>";
 | 
			
		||||
		print "<td>Die neusten 'n' Posts mit Titel, abwärts sortiert nach Datum<br />CSS-ID: #lastposts</td>";
 | 
			
		||||
		print "</tr>";
 | 
			
		||||
		
 | 
			
		||||
		print "<tr>";
 | 
			
		||||
		print "<td>sem_showMostReads</td>";
 | 
			
		||||
		print "<td><input type='text' value='<?php sem_showMostReads(10); ?>' class='regular-text' /></td>";
 | 
			
		||||
		print "<td>Formatierte Liste</td>";
 | 
			
		||||
		print "<td>n/a</td>";
 | 
			
		||||
		print "<td>Die 'n' meist gelesenen Post/Pages mit Hits in Klammern<br />CSS-ID: #mostreads</td>";
 | 
			
		||||
		print "</tr>";
 | 
			
		||||
		
 | 
			
		||||
		print "<tr>";
 | 
			
		||||
		print "<td>sem_showPostHitsInLoop</td>";
 | 
			
		||||
		print "<td><input type='text' value='<?php sem_showPostHitsInLoop(get_the_ID()); ?>' class='regular-text' /></td>";
 | 
			
		||||
		print "<td>Ganzzahl</td>";
 | 
			
		||||
		print "<td>Nur im Loop</td>";
 | 
			
		||||
		print "<td>Zeigt die Anzahl der Hits eines Posts an. Funktioniert nur im LOOP.</td>";
 | 
			
		||||
		print "</tr>";
 | 
			
		||||
		
 | 
			
		||||
		print "<tr>";
 | 
			
		||||
		print "<td colspan='5'>";
 | 
			
		||||
		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
 | 
			
		||||
				<code>if (function_exists...</code> sichergestellt, wird die Indexseite des Blogs fehlerhaft bzw.
 | 
			
		||||
				überhaupt nicht dargestellt.";
 | 
			
		||||
		print "</td>";
 | 
			
		||||
		print "</tr>";
 | 
			
		||||
		
 | 
			
		||||
		print "<tr>";
 | 
			
		||||
		print "<td>";
 | 
			
		||||
		print "</td>";
 | 
			
		||||
		print "</tr>";
 | 
			
		||||
		
 | 
			
		||||
		print "</tbody>";
 | 
			
		||||
		print "</table>";
 | 
			
		||||
		print "<hr />";
 | 
			
		||||
		
 | 
			
		||||
		if (function_exists('sem_showCopyright')) sem_showCopyright();
 | 
			
		||||
		
 | 
			
		||||
		print "</div>";
 | 
			
		||||
		
 | 
			
		||||
		print "</form>";
 | 
			
		||||
	
 | 
			
		||||
?>
 | 
			
		||||
							
								
								
									
										126
									
								
								trunk/semmelstatz.css
									
										
									
									
									
										Normale Datei
									
								
							
							
						
						| 
						 | 
				
			
			@ -0,0 +1,126 @@
 | 
			
		|||
 | 
			
		||||
 /**********************************************
 | 
			
		||||
 *                                             *
 | 
			
		||||
 *   semmelstatz.css v3.3                      *
 | 
			
		||||
 *   Copyright: © 2005-2009 kopfhoch-studio    *
 | 
			
		||||
 *   Kontakt: http://www.kopfhoch-studio.de/   *
 | 
			
		||||
 *                                             *
 | 
			
		||||
 ***********************************************/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
p.statz, div.statz {
 | 
			
		||||
	/* font-family: tahoma,verdana,arial,helvetica; */
 | 
			
		||||
	font-size: 17px;
 | 
			
		||||
	font-weight: normal;
 | 
			
		||||
	color: #344964;
 | 
			
		||||
	text-align: left;
 | 
			
		||||
	padding: 10px 0 5px 5px;
 | 
			
		||||
	margin-top: 10px;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
hr {
 | 
			
		||||
	color: #ddd;
 | 
			
		||||
	background-color: #ddd;
 | 
			
		||||
	height: 2px;
 | 
			
		||||
	border: none;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.statz a {
 | 
			
		||||
	border: none;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.statz a img {
 | 
			
		||||
	border: none;
 | 
			
		||||
	padding-top: 0px;	
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
table.statzelement {
 | 
			
		||||
	width: 100%;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.statzelement th, .statzelement td {
 | 
			
		||||
	/* font-family: tahoma,verdana,arial,helvetica; */
 | 
			
		||||
	font-size: 11px;
 | 
			
		||||
	color: #344964;
 | 
			
		||||
	padding: 3px 0 3px 5px;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.statzelement th {
 | 
			
		||||
	font-weight: bold;
 | 
			
		||||
	background: #eee;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.statzelement td {
 | 
			
		||||
	font-weight: normal;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.statzelement td a {
 | 
			
		||||
	text-decoration: none;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.statzelement p {
 | 
			
		||||
	/* font-family: tahoma,verdana,arial,helvetica; */
 | 
			
		||||
	font-size: 11px;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.optionstable {
 | 
			
		||||
	border:none;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.optioncell {
 | 
			
		||||
	border:1px solid #ccc;
 | 
			
		||||
	padding:5px;
 | 
			
		||||
	font-size:11px;
 | 
			
		||||
	vertical-align:top;
 | 
			
		||||
	width:20%;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
div.chart {
 | 
			
		||||
	margin: 10px 0px 20px 30px;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
table.chartelement {
 | 
			
		||||
	border: none;
 | 
			
		||||
	border-collapse: collapse;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.chartelement td {
 | 
			
		||||
	vertical-align: bottom;
 | 
			
		||||
	text-align: center;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.chartelement td div {
 | 
			
		||||
	border-top: 2px solid #dedede;
 | 
			
		||||
	border-left: 2px solid #dedede;
 | 
			
		||||
	border-right: 2px solid #999;
 | 
			
		||||
	border-bottom: 2px solid #999;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.chartelement th {
 | 
			
		||||
	vertical-align: middle;
 | 
			
		||||
	text-align: right;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.copyright {
 | 
			
		||||
	/* font-family: tahoma,verdana,arial,helvetica; */
 | 
			
		||||
	font-size: 11px;
 | 
			
		||||
	text-align:center;
 | 
			
		||||
	margin-top: 20px
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.alternate {
 | 
			
		||||
	background: #eee;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#icon-semmelstatz {
 | 
			
		||||
	background: transparent url(img/icon_observe.png);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#icon-template {
 | 
			
		||||
	background: transparent url(img/icon_template.png);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
input.regular-text {
 | 
			
		||||
	font-size: 11px;
 | 
			
		||||
	width: 28em;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										975
									
								
								trunk/semmelstatz.php
									
										
									
									
									
										Normale Datei
									
								
							
							
						
						| 
						 | 
				
			
			@ -0,0 +1,975 @@
 | 
			
		|||
<?php
 | 
			
		||||
/*
 | 
			
		||||
Plugin Name: Semmelstatz
 | 
			
		||||
Plugin URI: http://www.kopfhoch-studio.de/blog/2765
 | 
			
		||||
Description: Besucherstatistik fuer den Wordpress-Admin
 | 
			
		||||
Version: 3.3
 | 
			
		||||
Author: Andreas 'Redunzl' Mueller
 | 
			
		||||
Author URI: http://www.kopfhoch-studio.de/blog/kontakt
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
Copyright (c) 2005-2009 Andreas 'Redunzl' Mueller (redunzl@gmx.de)
 | 
			
		||||
 | 
			
		||||
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
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
### konstante für version
 | 
			
		||||
	define('SEMMELSTATZ_VERSION', '3.3');
 | 
			
		||||
	
 | 
			
		||||
### Deklaration der Tabellennamen
 | 
			
		||||
    global $wpdb;
 | 
			
		||||
    $wpdb->statz = $wpdb->prefix . 'statz';
 | 
			
		||||
    $wpdb->statzhist = $wpdb->prefix . 'statzhist';
 | 
			
		||||
    
 | 
			
		||||
### Auslesen des Domainnamens
 | 
			
		||||
    global $homehost;
 | 
			
		||||
	if(substr($_SERVER['SERVER_NAME'],0,4) == 'www.') {
 | 
			
		||||
        $homehost = '%' . substr($_SERVER['SERVER_NAME'],4) . '%';
 | 
			
		||||
    }
 | 
			
		||||
    else {
 | 
			
		||||
        $homehost = '%' . $_SERVER['SERVER_NAME'] . '%';
 | 
			
		||||
    }
 | 
			
		||||
	
 | 
			
		||||
### Erstellen des Top-Level-Menus im Adminbereich
 | 
			
		||||
	add_action('admin_menu', 'semmelstatz_menu');
 | 
			
		||||
	function semmelstatz_menu() {
 | 
			
		||||
		if (function_exists('add_menu_page')) {
 | 
			
		||||
			add_menu_page('Semmelstatz','Semmelstatz', 'manage_statz', 'semmelstatz/semmelstatz-statz.php', '', plugins_url('semmelstatz/img/statz_small.png'));
 | 
			
		||||
		}
 | 
			
		||||
		if (function_exists('add_submenu_page')) {
 | 
			
		||||
			add_submenu_page('semmelstatz/semmelstatz-statz.php', 'Aktuell', 'Aktuell', 'manage_statz', 'semmelstatz/semmelstatz-statz.php');
 | 
			
		||||
			add_submenu_page('semmelstatz/semmelstatz-statz.php', 'Historie', 'Historie', 'manage_statz', 'semmelstatz/semmelstatz-history.php');
 | 
			
		||||
			add_submenu_page('semmelstatz/semmelstatz-statz.php', 'Log', 'Log', 'manage_statz', 'semmelstatz/semmelstatz-log.php');
 | 
			
		||||
			add_submenu_page('semmelstatz/semmelstatz-statz.php', 'Datenbank', 'Datenbank', 'manage_statz', 'semmelstatz/semmelstatz-database.php');
 | 
			
		||||
			add_submenu_page('semmelstatz/semmelstatz-statz.php', 'Templates', 'Templates', 'manage_statz', 'semmelstatz/semmelstatz-templates.php');
 | 
			
		||||
			add_submenu_page('semmelstatz/semmelstatz-statz.php', 'Einstellungen', 'Einstellungen', 'manage_statz', 'semmelstatz/semmelstatz-options.php');
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
### Default-Werte der statz-Optionen in das Array 'semmelstatz_options' schreiben
 | 
			
		||||
add_action('init', 'sem_init_options');
 | 
			
		||||
    function sem_init_options() {
 | 
			
		||||
		global $wpdb;
 | 
			
		||||
		
 | 
			
		||||
		if(get_option('statz_options')) {
 | 
			
		||||
			$wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE 'statz%';"); // Löschen der alten Optionen
 | 
			
		||||
		}
 | 
			
		||||
        
 | 
			
		||||
        if(!get_option('semmelstatz_options')) {
 | 
			
		||||
			$sem_options = array(
 | 
			
		||||
				"statz_comment_limit" => 10,
 | 
			
		||||
				"statz_datarecs_limit" => 100,
 | 
			
		||||
				"statz_days_limit" => 7,
 | 
			
		||||
				"statz_do_cron" => false,
 | 
			
		||||
				"statz_encode_ip" => false,
 | 
			
		||||
				"statz_keyword_limit" =>10,
 | 
			
		||||
				"statz_referer_limit" => 10,
 | 
			
		||||
				"statz_mask_referer" => false,
 | 
			
		||||
				"statz_on_dashboard" => false,
 | 
			
		||||
				"statz_online_time" => 180,
 | 
			
		||||
				"statz_recdays_limit" => 20,
 | 
			
		||||
				"statz_show_commenters" => true,
 | 
			
		||||
				"statz_show_dailystatz" => true,
 | 
			
		||||
				"statz_show_keywords" => true,
 | 
			
		||||
				"statz_show_reads" => true,
 | 
			
		||||
				"statz_show_referers" => true,
 | 
			
		||||
				"statz_show_todayreads" => true,
 | 
			
		||||
				"statz_show_todayusers" => true,
 | 
			
		||||
				"statz_show_topcommposts" => true,
 | 
			
		||||
				"statz_show_useronline" => true,
 | 
			
		||||
				"statz_topreads_limit" => 10,
 | 
			
		||||
				"statz_write_admins" => false,
 | 
			
		||||
				"statz_write_users" => false
 | 
			
		||||
			);
 | 
			
		||||
			add_option( 'semmelstatz_options', $sem_options );
 | 
			
		||||
		}
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
### Anlegen der Tabellen, Optionen schreiben   
 | 
			
		||||
    add_action('activate_semmelstatz/semmelstatz.php', 'sem_statzsetup');
 | 
			
		||||
    function sem_statzsetup() {
 | 
			
		||||
        global $wpdb;
 | 
			
		||||
        if(@is_file(ABSPATH.'/wp-admin/upgrade-functions.php')) {
 | 
			
		||||
            include_once(ABSPATH.'/wp-admin/upgrade-functions.php');
 | 
			
		||||
        } elseif(@is_file(ABSPATH.'/wp-admin/includes/upgrade.php')) {
 | 
			
		||||
            include_once(ABSPATH.'/wp-admin/includes/upgrade.php');
 | 
			
		||||
        } else {
 | 
			
		||||
            die('Kann <i>wp-admin/upgrade-functions.php</i> und <i>wp-admin/includes/upgrade.php</i> nicht finden!');
 | 
			
		||||
        }
 | 
			
		||||
		
 | 
			
		||||
        $create_table = array();
 | 
			
		||||
        $create_table['statz'] = "CREATE TABLE $wpdb->statz (
 | 
			
		||||
            id int(11) unsigned NOT NULL auto_increment,
 | 
			
		||||
            ip varchar(39) default NULL,
 | 
			
		||||
            time datetime NOT NULL default '0000-00-00 00:00:00',
 | 
			
		||||
            referer varchar(255) default NULL,
 | 
			
		||||
            page int(11) unsigned NOT NULL default '0',
 | 
			
		||||
            username varchar(255) default NULL,
 | 
			
		||||
            PRIMARY KEY  (`id`))";
 | 
			
		||||
        $create_table['statzhist'] = "CREATE TABLE $wpdb->statzhist (
 | 
			
		||||
            id int(10) unsigned NOT NULL auto_increment,
 | 
			
		||||
            date datetime NOT NULL default '0000-00-00 00:00:00',
 | 
			
		||||
            visitors int(10) unsigned NOT NULL default '0',
 | 
			
		||||
            hits int(10) unsigned NOT NULL default '0',
 | 
			
		||||
            referers int(10) unsigned NOT NULL default '0',
 | 
			
		||||
            PRIMARY KEY  (`id`))";
 | 
			
		||||
            
 | 
			
		||||
        maybe_create_table($wpdb->statz, $create_table['statz']);    
 | 
			
		||||
        maybe_create_table($wpdb->statzhist, $create_table['statzhist']);
 | 
			
		||||
		
 | 
			
		||||
		$sql = $wpdb->query("SELECT host FROM $wpdb->statz");
 | 
			
		||||
		if($sql) { $wpdb->query("ALTER TABLE $wpdb->statz DROP host"); }
 | 
			
		||||
 | 
			
		||||
		$sql = $wpdb->query("SELECT keyword FROM $wpdb->statz");
 | 
			
		||||
		if($sql) { $wpdb->query("ALTER TABLE $wpdb->statz DROP keyword"); }
 | 
			
		||||
        
 | 
			
		||||
        maybe_add_column($wpdb->posts, 'hits', "ALTER TABLE $wpdb->posts ADD hits bigint(20) NOT NULL DEFAULT '0';"); // ab 3.2
 | 
			
		||||
		
 | 
			
		||||
		$wpdb->query("ALTER TABLE $wpdb->statz CHANGE ip ip VARCHAR(39) NULL DEFAULT NULL;"); 
 | 
			
		||||
		
 | 
			
		||||
		sem_init_options();
 | 
			
		||||
        sem_writeOldDaysToHist();
 | 
			
		||||
		
 | 
			
		||||
		$role = get_role('administrator');
 | 
			
		||||
		if(!$role->has_cap('manage_statz')) {
 | 
			
		||||
			$role->add_cap('manage_statz');
 | 
			
		||||
		}
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
### Zugriff analysieren und in statz-Tabelle schreiben
 | 
			
		||||
    add_action('wp_head', 'sem_writeStatz');
 | 
			
		||||
    function sem_writeStatz() {
 | 
			
		||||
        global $wpdb, $wp_query, $isBot, $isAdmin, $page;
 | 
			
		||||
		$sem_options = get_option('semmelstatz_options'); ### optionsarray auslesen
 | 
			
		||||
        
 | 
			
		||||
        sem_writeYesterdayToHist();
 | 
			
		||||
        $useragent = $wpdb->escape($_SERVER['HTTP_USER_AGENT']);
 | 
			
		||||
        $isBot = sem_AreYouBot($useragent);
 | 
			
		||||
        $username = sem_getUsername();
 | 
			
		||||
        
 | 
			
		||||
        if(($isBot == true)
 | 
			
		||||
        || ($isAdmin == 0 && $sem_options['statz_write_users'] == false)
 | 
			
		||||
        || ($isAdmin == 1 && $sem_options['statz_write_admins'] == false)
 | 
			
		||||
        || is_404()
 | 
			
		||||
        ) return;
 | 
			
		||||
        
 | 
			
		||||
        $userip = $wpdb->escape($_SERVER['REMOTE_ADDR']);
 | 
			
		||||
        if($sem_options['statz_encode_ip'] == true) $userip = sem_encodeIP($userip);
 | 
			
		||||
        
 | 
			
		||||
		$referer = $wpdb->escape(urldecode($_SERVER['HTTP_REFERER']));
 | 
			
		||||
        $blogtime = gmdate('Y-m-d H:i:s', current_time('timestamp'));
 | 
			
		||||
        
 | 
			
		||||
        if (!empty($referer)) {
 | 
			
		||||
            if(get_option('blog_charset') == 'iso-8859-1') $referer = utf8_decode($referer);
 | 
			
		||||
			$referer = "'".$referer."'";
 | 
			
		||||
        }
 | 
			
		||||
		else {
 | 
			
		||||
			$referer = 'NULL';
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
        $readingnow = wp_title('', false);
 | 
			
		||||
        if(empty($readingnow)) {
 | 
			
		||||
            $page = 0;
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
			$page = $wp_query->post->ID;
 | 
			
		||||
        }
 | 
			
		||||
		
 | 
			
		||||
		$wpdb->query("INSERT INTO $wpdb->statz (ip, time, referer, page, username)
 | 
			
		||||
        VALUES('$userip', '$blogtime', $referer, $page, '$username')");
 | 
			
		||||
        
 | 
			
		||||
        if($wpdb->query("SELECT COUNT(hits) FROM $wpdb->posts")) {
 | 
			
		||||
            $wpdb->query("UPDATE $wpdb->posts SET hits = hits + 1 WHERE ID = $page"); // neu ab 3.2
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
### Zeitgesteuertes Limitieren der statz-Tabelle
 | 
			
		||||
    // Wenn semmelKron JA UND statz_next_cron älter JETZT, dann...
 | 
			
		||||
	$sem_options = get_option('semmelstatz_options'); ### optionsarray auslesen
 | 
			
		||||
	if($sem_options['statz_do_cron'] == true && $sem_options['statz_next_cron'] < time()) { 
 | 
			
		||||
        add_action('shutdown', 'sem_doCronStatzLimit'); // ...limitiere statz-Tabelle auf vorgegebenen Wert
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
### CSS für den SEMMELSTATZ-Admin-Bereich
 | 
			
		||||
    add_action('admin_head', 'semmelstatz_css');
 | 
			
		||||
    function semmelstatz_css() {
 | 
			
		||||
        print "<link rel='stylesheet' href='".get_option('siteurl')."/wp-content/plugins/semmelstatz/semmelstatz.css' type='text/css' media='screen' />\n";
 | 
			
		||||
    }
 | 
			
		||||
	
 | 
			
		||||
### Rendert eine Mini-STATZ. Idee: René Tauchnitz
 | 
			
		||||
    function sem_dashboardStatz() {
 | 
			
		||||
		print "<p>".sem_showNumUsersOnline() . " Besucher online - Heute: ".sem_showTodayStatz()." 
 | 
			
		||||
		<a title='mehr...' href='".get_option('siteurl')."/wp-admin/admin.php?page=semmelstatz/semmelstatz-statz.php'>»»</a></p>";
 | 
			
		||||
    }
 | 
			
		||||
	
 | 
			
		||||
### Widget für die Mini-STATZ
 | 
			
		||||
	add_action('wp_dashboard_setup', 'sem_dashboardStatz_setup');
 | 
			
		||||
	function sem_dashboardStatz_setup() {
 | 
			
		||||
		$sem_options = get_option('semmelstatz_options'); ### optionsarray auslesen
 | 
			
		||||
		if(!current_user_can('manage_statz')) return;
 | 
			
		||||
        if($sem_options['statz_on_dashboard'] != TRUE) return;
 | 
			
		||||
		wp_add_dashboard_widget( 'sem_dashboardStatz', 'Semmelstatz', 'sem_dashboardStatz' );
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
### Mini-Statz für Dashboard-Widget & AKTUELL-Anzeige 
 | 
			
		||||
	function sem_showTodayStatz() {
 | 
			
		||||
        global $wpdb;
 | 
			
		||||
        $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() GROUP BY date");
 | 
			
		||||
        if (empty($thedays)) {
 | 
			
		||||
            return "<small>... noch keine Einträge</small>";
 | 
			
		||||
        }
 | 
			
		||||
        foreach($thedays as $key=>$theday) {
 | 
			
		||||
            $date = mysql2date("l",$theday->date);
 | 
			
		||||
            $hits = $theday->hits;
 | 
			
		||||
            $visitors = $theday->visitors;
 | 
			
		||||
            $referers = $theday->referers;
 | 
			
		||||
        }
 | 
			
		||||
        return $visitors." Besucher - ".$hits." Hits -  ".$referers." Referer"; 
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
### Encodierung der IP-Adresse durch simple arithmetische Operation
 | 
			
		||||
    function sem_encodeIP($ip) {
 | 
			
		||||
        $ip_parts = split("[.]", $ip);
 | 
			
		||||
        $new_ip = ($ip_parts[0]+700) . "." . ($ip_parts[1]*2) . "." . ($ip_parts[2]+600) . "." . ($ip_parts[3]*3);
 | 
			
		||||
        return $new_ip;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
### Decodierung der IP-Adresse durch simple arithmetische Operation
 | 
			
		||||
    function sem_decodeIP($ip) {
 | 
			
		||||
        $ip_parts = split("[.]", $ip);
 | 
			
		||||
        $new_ip = ($ip_parts[0]-700) . "." . ($ip_parts[1] / 2) . "." . ($ip_parts[2]-600) . "." . ($ip_parts[3]/3);
 | 
			
		||||
        return $new_ip;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
### Ist IP-Adresse codiert?
 | 
			
		||||
    function sem_checkIfIPisEncoded($ip) {
 | 
			
		||||
        $ip_parts = split("[.]", $ip);
 | 
			
		||||
        if($ip_parts[0]>700) {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
### Auslesen der höchsten Post-ID
 | 
			
		||||
    function sem_getMaxPostID() {
 | 
			
		||||
        global $wpdb;
 | 
			
		||||
        $maxpostid = $wpdb->get_var("SELECT MAX(ID) FROM ".$wpdb->posts." LIMIT 0,1");
 | 
			
		||||
        return $maxpostid; //Ganzzahl
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
### Auslesen des User- bzw. Kommentarautornamen
 | 
			
		||||
	function sem_getUsername() {
 | 
			
		||||
        global $user_ID, $user_login, $isAdmin;
 | 
			
		||||
		
 | 
			
		||||
		get_currentuserinfo();
 | 
			
		||||
		
 | 
			
		||||
		if($user_ID > 0) {
 | 
			
		||||
		    $useronline = $user_login;
 | 
			
		||||
            
 | 
			
		||||
            if(current_user_can('manage_options')) {
 | 
			
		||||
                $isAdmin = 1;
 | 
			
		||||
            }
 | 
			
		||||
            else { 
 | 
			
		||||
                $isAdmin = 0;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        elseif(isset($_COOKIE["comment_author_".COOKIEHASH])) {
 | 
			
		||||
            $useronline = trim($_COOKIE["comment_author_".COOKIEHASH]);
 | 
			
		||||
            $isAdmin = -1;
 | 
			
		||||
		}
 | 
			
		||||
		else {
 | 
			
		||||
			$useronline = "Gast";
 | 
			
		||||
			$isAdmin = -1;
 | 
			
		||||
		}
 | 
			
		||||
        return $useronline;
 | 
			
		||||
    }
 | 
			
		||||
	
 | 
			
		||||
### Prüfen, ob Besucher ein Bot ist
 | 
			
		||||
    function sem_AreYouBot($user_agent) {
 | 
			
		||||
        global $isBot;
 | 
			
		||||
        $bots = array(
 | 
			
		||||
            'aipbot',
 | 
			
		||||
            'amfibibot',
 | 
			
		||||
            'appie',
 | 
			
		||||
            'ask jeeves/teoma',
 | 
			
		||||
            'aspseek',
 | 
			
		||||
            'axadine',
 | 
			
		||||
            'baiduspider',
 | 
			
		||||
            'becomebot',
 | 
			
		||||
            'blogcorpuscrawler',
 | 
			
		||||
            'blogpulse',
 | 
			
		||||
            'blogsnowbot',
 | 
			
		||||
            'boitho.com',
 | 
			
		||||
            'bruinbot',
 | 
			
		||||
            'cerberian',
 | 
			
		||||
            'cfnetwork',
 | 
			
		||||
            'check_http',
 | 
			
		||||
            'cipinetbot',
 | 
			
		||||
            'claymont',
 | 
			
		||||
            'cometsearch@cometsystems.com',
 | 
			
		||||
            'converacrawler',
 | 
			
		||||
            'cydralspider',
 | 
			
		||||
            'digger',
 | 
			
		||||
            'es.net_crawler',
 | 
			
		||||
            'eventax',
 | 
			
		||||
            'everyfeed-spider',
 | 
			
		||||
            'exabot@exava.com',
 | 
			
		||||
            'faxobot',
 | 
			
		||||
            'findlinks',
 | 
			
		||||
            'fireball',
 | 
			
		||||
            'francis',
 | 
			
		||||
            'gaisbot',
 | 
			
		||||
            'gamekitbot',
 | 
			
		||||
            'gazz@nttr.co.jp',
 | 
			
		||||
            'geonabot',
 | 
			
		||||
            'getrax crawler',
 | 
			
		||||
            'gigabot',
 | 
			
		||||
            'girafa.com',
 | 
			
		||||
            'goforitbot',
 | 
			
		||||
            'googlebot',
 | 
			
		||||
            'grub-client',
 | 
			
		||||
            'holmes',
 | 
			
		||||
            'houxoucrawler',
 | 
			
		||||
            'http://www.almaden.ibm.com/cs/crawler',
 | 
			
		||||
            'http://www.istarthere.com',
 | 
			
		||||
            'http://www.relevantnoise.com',
 | 
			
		||||
            'httrack ?',
 | 
			
		||||
            'ia_archiver',
 | 
			
		||||
            'ichiro',
 | 
			
		||||
            'iltrovatore-setaccio',
 | 
			
		||||
            'inelabot',
 | 
			
		||||
            'infoseek',
 | 
			
		||||
            'inktomi.com',
 | 
			
		||||
            'irlbot',
 | 
			
		||||
            'jetbot',
 | 
			
		||||
            'jobspider_ba',
 | 
			
		||||
            'kazoombot',
 | 
			
		||||
            'larbin',
 | 
			
		||||
            'libwww',
 | 
			
		||||
            'linkwalker',
 | 
			
		||||
            'lmspider',
 | 
			
		||||
            'mackster',
 | 
			
		||||
            'mediapartners-google',
 | 
			
		||||
            'microsoft url control',
 | 
			
		||||
            'mj12bot',
 | 
			
		||||
            'moreoverbot',
 | 
			
		||||
            'mozdex',
 | 
			
		||||
            'msnbot',
 | 
			
		||||
            'msrbot',
 | 
			
		||||
            'naverbot',
 | 
			
		||||
            'netresearchserver',
 | 
			
		||||
            'ng/2.0',
 | 
			
		||||
            'np(bot)',
 | 
			
		||||
            'nutch',
 | 
			
		||||
            'objectssearch',
 | 
			
		||||
            'ocelli',
 | 
			
		||||
            'omniexplorer_bot',
 | 
			
		||||
            'openbot',
 | 
			
		||||
            'overture',
 | 
			
		||||
            'patwebbot',
 | 
			
		||||
            'php',
 | 
			
		||||
            'phpdig',
 | 
			
		||||
            'pilgrim html-crawler',
 | 
			
		||||
            'pipeliner',
 | 
			
		||||
            'pompos',
 | 
			
		||||
            'psbot',
 | 
			
		||||
            'python-urllib',
 | 
			
		||||
            'quepasacreep',
 | 
			
		||||
            'robozilla',
 | 
			
		||||
            'rpt-httpclient',
 | 
			
		||||
            'savvybot',
 | 
			
		||||
            'scooter',
 | 
			
		||||
            'search.ch',
 | 
			
		||||
            'seekbot',
 | 
			
		||||
            'semager',
 | 
			
		||||
            'seznambot',
 | 
			
		||||
            'sherlock',
 | 
			
		||||
            'shelob',
 | 
			
		||||
            'sitesearch',
 | 
			
		||||
            'snapbot',
 | 
			
		||||
            'snappreviewbot',
 | 
			
		||||
            'speedy spider',
 | 
			
		||||
            'sphere scout',
 | 
			
		||||
            'stackrambler',
 | 
			
		||||
            'steeler',
 | 
			
		||||
            'surveybot',
 | 
			
		||||
            'szukacz',
 | 
			
		||||
            'technoratibot',
 | 
			
		||||
            'telnet',
 | 
			
		||||
            'themiragorobot',
 | 
			
		||||
            'thesubot',
 | 
			
		||||
            'thumbshots-de-bot',
 | 
			
		||||
            'topicblogs',
 | 
			
		||||
            'turnitinbot',
 | 
			
		||||
            'tutorgigbot',
 | 
			
		||||
            'tutorial crawler',
 | 
			
		||||
			'twiceler',
 | 
			
		||||
            'vagabondo',
 | 
			
		||||
            'versus',
 | 
			
		||||
            'voilabot',
 | 
			
		||||
            'w3c_css_validator',
 | 
			
		||||
            'w3c_validator',
 | 
			
		||||
            'w3c-checklink',
 | 
			
		||||
            'web downloader',
 | 
			
		||||
            'webcopier',
 | 
			
		||||
            'webcrawler',
 | 
			
		||||
            'webfilter robot',
 | 
			
		||||
            'west wind internet protocols',
 | 
			
		||||
            'wget',
 | 
			
		||||
            'wwweasel robot',
 | 
			
		||||
            'wwwster',
 | 
			
		||||
            'xaldon webspider',
 | 
			
		||||
            'xenu',
 | 
			
		||||
            'yahoo! slurp',
 | 
			
		||||
            'yahoofeedseeker',
 | 
			
		||||
            'yahoo-mmcrawler',
 | 
			
		||||
            'zao',
 | 
			
		||||
            'zipppbot',
 | 
			
		||||
            'zyborg',
 | 
			
		||||
        );
 | 
			
		||||
        foreach($bots as $bot) { 
 | 
			
		||||
            if(stristr($user_agent, $bot) !== false) {
 | 
			
		||||
                return true;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
### Referer nach Suchmaschinen-Queries und interner Suche prüfen und Suchstring extrahieren	
 | 
			
		||||
	function sem_getKeyword($referer) {
 | 
			
		||||
		$keyword = @parse_url($referer);
 | 
			
		||||
		
 | 
			
		||||
		if (preg_match("/google\./i", $keyword["host"])) {
 | 
			
		||||
			if (preg_match("/imgurl/i", $keyword["query"])) {
 | 
			
		||||
				parse_str($keyword["query"],$q);
 | 
			
		||||
				$keyword = substr($q["prev"],10);
 | 
			
		||||
			}
 | 
			
		||||
			else if (preg_match("/translate\./i", $keyword["host"])) {
 | 
			
		||||
				parse_str($keyword["query"],$q);
 | 
			
		||||
				$keyword = $q["q"];
 | 
			
		||||
			}
 | 
			
		||||
			else {
 | 
			
		||||
				parse_str($keyword["query"],$q);
 | 
			
		||||
				$keyword = $q["q"];
 | 
			
		||||
			}
 | 
			
		||||
			if($keyword == "") return; return "Google: ".$keyword;
 | 
			
		||||
		}
 | 
			
		||||
		elseif (preg_match("/search\.live\./i", $keyword["host"])) {
 | 
			
		||||
			parse_str($keyword["query"],$q);
 | 
			
		||||
			$keyword = $q["q"];
 | 
			
		||||
			if($keyword == "") return; return "LiveSearch: ".$keyword;
 | 
			
		||||
		}
 | 
			
		||||
		elseif (preg_match("/bing\./i", $keyword["host"])) {
 | 
			
		||||
			parse_str($keyword["query"],$q);
 | 
			
		||||
			$keyword = $q["q"];
 | 
			
		||||
			if($keyword == "") return; return "Bing: ".$keyword;
 | 
			
		||||
		}
 | 
			
		||||
		elseif (preg_match("/yahoo\./i", $keyword["host"])) {
 | 
			
		||||
			if (preg_match("/images/i", $keyword["query"])) {
 | 
			
		||||
				parse_str($keyword["query"],$q);
 | 
			
		||||
				$keyword = $q["p"];
 | 
			
		||||
			}
 | 
			
		||||
			else {
 | 
			
		||||
				parse_str($keyword["query"],$q);
 | 
			
		||||
				$keyword = $q["p"];
 | 
			
		||||
			}
 | 
			
		||||
			if($keyword == "") return; return "Yahoo: ".$keyword;
 | 
			
		||||
		}
 | 
			
		||||
		elseif (preg_match("/aol\./i", $keyword["host"])) {
 | 
			
		||||
			parse_str($keyword["query"],$q);
 | 
			
		||||
			$keyword = $q["q"];
 | 
			
		||||
			if($keyword == "") return; return "AOL: ".$keyword;
 | 
			
		||||
		}
 | 
			
		||||
		elseif (preg_match("/aolsvc\./i", $keyword["host"])) {
 | 
			
		||||
			parse_str($keyword["query"],$q);
 | 
			
		||||
			$keyword = $q["q"];
 | 
			
		||||
			if($keyword == "") return; return "AOL: ".$keyword;
 | 
			
		||||
		}
 | 
			
		||||
		elseif (preg_match("/search\.msn\./i", $keyword["host"])) {
 | 
			
		||||
			parse_str($keyword["query"],$q);
 | 
			
		||||
			$keyword = $q["q"];
 | 
			
		||||
			if($keyword == "") return; return "MSN: ".$keyword;
 | 
			
		||||
		}
 | 
			
		||||
		elseif (preg_match("/gmx\./i", $keyword["host"])) {
 | 
			
		||||
			parse_str($keyword["query"],$q);
 | 
			
		||||
			$keyword = $q["su"];
 | 
			
		||||
			if($keyword == "") return; return "GMX: ".$keyword;
 | 
			
		||||
		}
 | 
			
		||||
		elseif (preg_match("/\.bild\.t\-/i", $keyword["host"])) {
 | 
			
		||||
			parse_str($keyword["query"],$q);
 | 
			
		||||
			$keyword = $q["query"];
 | 
			
		||||
			if($keyword == "") return; return "BILD: ".$keyword;
 | 
			
		||||
		}        
 | 
			
		||||
		elseif (preg_match("/t\-online\./i", $keyword["host"])) {
 | 
			
		||||
			parse_str($keyword["query"],$q);
 | 
			
		||||
			$keyword = $q["q"];
 | 
			
		||||
			if($keyword == "") return; return "T-Online: ".$keyword;
 | 
			
		||||
		}
 | 
			
		||||
		elseif (preg_match("/suche\.web\./i", $keyword["host"])) {
 | 
			
		||||
			parse_str($keyword["query"],$q);
 | 
			
		||||
			$keyword = $q["su"];
 | 
			
		||||
			if($keyword == "") return; return "WEB.de: ".$keyword;
 | 
			
		||||
		}
 | 
			
		||||
		elseif (preg_match("/suche\.lycos\./i", $keyword["host"])) {
 | 
			
		||||
			parse_str($keyword["query"],$q);
 | 
			
		||||
			$keyword = $q["query"];
 | 
			
		||||
			if($keyword == "") return; return "Lycos: ".$keyword;
 | 
			
		||||
		}
 | 
			
		||||
		elseif (preg_match("/altavista\./i", $keyword["host"])) {
 | 
			
		||||
			parse_str($keyword["query"],$q);
 | 
			
		||||
			$keyword = $q["q"];
 | 
			
		||||
			if($keyword == "") return; return "Altavista: ".$keyword;
 | 
			
		||||
		}
 | 
			
		||||
		elseif (preg_match("/alltheweb\./i", $keyword["host"])) {
 | 
			
		||||
			parse_str($keyword["query"],$q);
 | 
			
		||||
			$keyword = $q["q"];
 | 
			
		||||
			if($keyword == "") return; return "alltheweb: ".$keyword;
 | 
			
		||||
		}
 | 
			
		||||
		elseif (preg_match("/technorati\.com\/search\//", $referer)) {
 | 
			
		||||
			$q = preg_split("/technorati\.com\/search\//", $referer,-1,PREG_SPLIT_NO_EMPTY);
 | 
			
		||||
			$keyword = $q[1];
 | 
			
		||||
			if($keyword == "") return; return "Technorati: ".$keyword;
 | 
			
		||||
		}
 | 
			
		||||
		elseif (preg_match("/".$homehost."/i", $keyword["host"])) {
 | 
			
		||||
			parse_str($keyword["query"],$q);
 | 
			
		||||
			$keyword = $q["s"];
 | 
			
		||||
			if($keyword == "") return; return "Interne Suche: ".$keyword;
 | 
			
		||||
		}
 | 
			
		||||
		else {
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
### Anzahl der Datensätze in der statz-Tabelle
 | 
			
		||||
    function sem_showNumStatzEntries() {
 | 
			
		||||
        global $wpdb;
 | 
			
		||||
        $numstatzentries = $wpdb->get_var("SELECT COUNT(id) FROM ".$wpdb->statz);
 | 
			
		||||
        return $numstatzentries; // Zahl
 | 
			
		||||
    }
 | 
			
		||||
	
 | 
			
		||||
### Aufgezeichnete Tage in der statz-Tabelle
 | 
			
		||||
	function sem_countDaysInStatzTable() {
 | 
			
		||||
		global $wpdb;
 | 
			
		||||
		$firstdate = $wpdb->get_var("SELECT MIN(time) FROM ".$wpdb->statz." LIMIT 0,1");
 | 
			
		||||
        if(!$firstdate) {
 | 
			
		||||
            return 1;
 | 
			
		||||
        }
 | 
			
		||||
        else {        
 | 
			
		||||
            $firstdate = strtotime($firstdate); $now = time();
 | 
			
		||||
            $days = (int) (($now - $firstdate) / (60*60*24)+1);
 | 
			
		||||
            return $days; // KOMPLETTE! Tage
 | 
			
		||||
        }
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
### Wenn Tage in statz-Tabelle kleiner als Tage in Daily-Statz, dann nimm Tage in Daily-Statz
 | 
			
		||||
	function sem_compareLimitDays2DailyStatz () {
 | 
			
		||||
		global $wpdb;
 | 
			
		||||
		$sem_options = get_option('semmelstatz_options'); ### optionsarray auslesen
 | 
			
		||||
		if (sem_countDaysInStatzTable() << $sem_options["statz_days_limit"]) {
 | 
			
		||||
			$sem_options["statz_days_limit"] = sem_countDaysInStatzTable();
 | 
			
		||||
			update_option("semmelstatz_options", $sem_options);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
### Zeigt Copyright-Notiz an
 | 
			
		||||
    function sem_showCopyright() {
 | 
			
		||||
        print "<p class='copyright'>semmelstatz ". SEMMELSTATZ_VERSION . " ist (c) kopfhoch-studio 2005-2009<br />
 | 
			
		||||
		<a target='_blank' style='border:none;' href='http://www.kopfhoch-studio.de/blog/2765'>
 | 
			
		||||
		<img src='".get_option('siteurl')."/wp-content/plugins/semmelstatz/img/statz.png' /></a></p>";
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
### 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 "<div id='lastposts'>";
 | 
			
		||||
        if (empty($lastposts)) {
 | 
			
		||||
            print "... noch keine Beiträge";
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            print "<b>Die letzten ".$num_posts." Beiträge</b><br />";
 | 
			
		||||
            foreach ($lastposts as $lastpost) {
 | 
			
		||||
                $posttitle = $lastpost->post_title;
 | 
			
		||||
                $permalink = get_permalink($lastpost->ID);
 | 
			
		||||
                $postdate = $lastpost->post_date;
 | 
			
		||||
                print "<a href='".$permalink."'>".$posttitle."</a><br />\n";
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        print "</div>";
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
### 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 "<div id='lastcomments'>";
 | 
			
		||||
        if (empty($comments)) {
 | 
			
		||||
            print "Keine Kommentare";
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            print "<b>Die letzten ".$num_comments." Kommentare</b><br />";
 | 
			
		||||
            foreach ($comments as $comment) {
 | 
			
		||||
                $commentday = strtotime(substr($comment->comment_date,1,10));
 | 
			
		||||
                $today = time();
 | 
			
		||||
                $difference = ceil(($today - $commentday) / (60*60*24))-1;
 | 
			
		||||
                if($difference == 0) {
 | 
			
		||||
                    $commentdate = "Heute um " . mysql2date("G:i", $comment->comment_date);
 | 
			
		||||
                }
 | 
			
		||||
                elseif($difference == 1) {
 | 
			
		||||
                    $commentdate = "Gestern um " . mysql2date("G:i", $comment->comment_date);
 | 
			
		||||
                }
 | 
			
		||||
                elseif($difference == 2) {
 | 
			
		||||
                    $commentdate = "Vorgestern um " . mysql2date("G:i", $comment->comment_date);
 | 
			
		||||
                }
 | 
			
		||||
                else {           
 | 
			
		||||
                    $commentdate = mysql2date("j. F G:i", $comment->comment_date);
 | 
			
		||||
                }
 | 
			
		||||
                
 | 
			
		||||
                print "<a href='" . get_permalink($comment->comment_post_ID) . "#comment-$comment->comment_ID'>$comment->comment_author@". get_the_title($comment->comment_post_ID) .", $commentdate</a><br />\n";
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        print "</div>";
 | 
			
		||||
    }
 | 
			
		||||
	
 | 
			
		||||
### 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 "<div id='mostreads'>";
 | 
			
		||||
        if (empty($mostreads)) {
 | 
			
		||||
            print "... noch keine Einträge";
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            print "<b>Die ".$num_reads." meist gelesenen Beiträge</b><br />";
 | 
			
		||||
            foreach ($mostreads as $mostread) {
 | 
			
		||||
                $posttitle = $mostread->posttitle;
 | 
			
		||||
                $postid = $mostread->postid;
 | 
			
		||||
                //$permalink = get_permalink($mostread->postid);
 | 
			
		||||
                $hits = $mostread->hits;
 | 
			
		||||
                print "<a target='_blank' href='".$postid."'>".$posttitle." (".$hits.")</a><br />\n";
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        print "</div>";
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
### 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 "<div id='mostreads'>";
 | 
			
		||||
        if (empty($mostreads)) {
 | 
			
		||||
            print "... noch keine Einträge";
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            print "<b>Die ".$num_reads." meist gelesenen Beiträge</b><br />";
 | 
			
		||||
            foreach ($mostreads as $mostread) {
 | 
			
		||||
                $posttitle = $mostread->posttitle;
 | 
			
		||||
                $postid = $mostread->postid;
 | 
			
		||||
                //$permalink = get_permalink($mostread->postid);
 | 
			
		||||
                $count = $mostread->count;
 | 
			
		||||
                print "<a target='_blank' href='".$postid."'>".$posttitle." (".$count.")</a><br />\n";
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        print "</div>";
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
### 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 "<div id='mostcommented'>";
 | 
			
		||||
        if (empty($mostcommented)) {
 | 
			
		||||
            print "... noch keine Einträge";
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            print "<b>Die ".$num_commented." meist kommentierten Beiträge</b><br />";
 | 
			
		||||
        
 | 
			
		||||
            foreach ($mostcommented as $key => $mostcommented) {
 | 
			
		||||
                $posttitle = $mostcommented->post_title;
 | 
			
		||||
                $count = $mostcommented->count;
 | 
			
		||||
                $postid = $mostcommented->guid;
 | 
			
		||||
                print "<a target='_blank' href='".$postid."'>".$posttitle." (".$count.")</a><br />\n";
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        print "</div>";
 | 
			
		||||
    }
 | 
			
		||||
	
 | 
			
		||||
### 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
 | 
			
		||||
 | 
			
		||||
?>
 | 
			
		||||