Changeset 17 for web/stat.php
Legend:
- Unmodified
- Added
- Removed
-
web
-
Property svn:ignore
set to
config.php
.buildpath
.project
.settings
-
Property svn:ignore
set to
-
web/stat.php
r16 r17 1 1 <?php 2 2 3 // Pojmenov ání statistických kategorií4 $StatCategory = array( 5 'browser' => 'Prohl íľeče',6 'referer' => 'Odkud p řiąli',3 // Pojmenovánà statistických kategorià 4 $StatCategory = array( 5 'browser' => 'ProhlÞeÄe', 6 'referer' => 'Odkud pÅiÅ¡li', 7 7 'module' => 'Sekce webu', 8 'host' => 'Adresy n ávątěvníků',9 'word' => 'Hledan áslova',10 'user' => 'U ľivatelé',8 'host' => 'Adresy návÅ¡tÄvnÃků', 9 'word' => 'Hledaná slova', 10 'user' => 'Uživatelé', 11 11 'action' => 'Akce', 12 12 ); 13 13 14 $StatMonths = array('Leden',' Únor','Březen','Duben','Květen','Červen','Červenec','Srpen','Září','Říjen','Listopad','Prosinec');14 $StatMonths = array('Leden','Ãnor','BÅezen','Duben','KvÄten','Äerven','Äervenec','Srpen','ZáÅÃ','ÅÃjen','Listopad','Prosinec'); 15 15 16 16 /* … … 32 32 function StatUpdate($Cat, $Name) 33 33 { 34 global $DB_Prefix; 34 global $DB_Prefix, $Database; 35 35 36 $Date = System_Date(); 36 DB_Select('stat', '*', "category='$Cat' AND name='$Name' AND date='$Date'");37 if( DB_NumRows()>0) DB_Query("UPDATE ".$DB_Prefix."stat SET hits=hits+1 WHERE category='$Cat' AND name='$Name' AND date='$Date'");38 else 37 $DbResult = $Database->select('stat', '*', "category='$Cat' AND name='$Name' AND date='$Date'"); 38 if($DbResult->num_rows > 0) $Database->query("UPDATE ".$DB_Prefix."stat SET hits=hits+1 WHERE category='$Cat' AND name='$Name' AND date='$Date'"); 39 else 39 40 { 40 41 $Data = array( … … 44 45 'hits' => 1, 45 46 ); 46 DB_Insert('stat',$Data);47 $Database->insert('stat', $Data); 47 48 } 48 49 } … … 51 52 { 52 53 global $Options; 53 // Zjist í zobrazenýmodul54 // Zjistà zobrazený modul 54 55 StatUpdate('module', substr($_SERVER['SCRIPT_NAME'], $Options['StatPathCut'])); 55 56 // Zjist í stránku odkud uzivatel přisel56 57 // Zjistà stránku odkud uzivatel pÅisel 57 58 if(array_key_exists('HTTP_REFERER', $_SERVER)) 58 59 { 59 60 $Url = explode('/',$_SERVER['HTTP_REFERER']); 60 if(strpos($Url[2],':')) 61 if(strpos($Url[2],':')) 61 62 { 62 63 $Hostname = explode(':',$Url[2]); … … 64 65 } else $ServerIP = gethostbyname($Url[2]); 65 66 //echo($ServerIP.'-'.$_SERVER["SERVER_ADDR"]); 66 if(($ServerIP != $_SERVER["SERVER_ADDR"]) && ($ServerIP!='127.0.0.1')) 67 StatUpdate('referer', $_SERVER['HTTP_REFERER']); 67 if(($ServerIP != $_SERVER["SERVER_ADDR"]) && ($ServerIP!='127.0.0.1')) 68 StatUpdate('referer', $_SERVER['HTTP_REFERER']); 68 69 } else StatUpdate('referer', 'direct'); 69 70 // Zjist í typ prohlíµeče70 71 // Zjistà typ prohlÃľeÄe 71 72 StatUpdate('browser', $_SERVER['HTTP_USER_AGENT']); 72 // Zjist íDNS a IP adresu klienta73 // Zjistà DNS a IP adresu klienta 73 74 StatUpdate('host', $_SERVER['REMOTE_ADDR']); 74 75 } … … 97 98 function StatShowYears() 98 99 { 99 global $Options; 100 global $Options, $Database; 101 100 102 if(array_key_exists('name', $_GET) and array_key_exists('category', $_GET)) 101 103 { 102 $Output = '<div class="StatList"><strong>Ro čnístatistika</strong><br><br>'.103 '<table class="StatTable"><tr><th>Rok</th><th>Prohl édnutých stránek</th></tr>';104 105 // Zjisti rozmez í roků106 DB_Select('stat', 'DISTINCT date', 'name="'.$_GET['name'].'" AND category="'.$_GET['category'].'"');107 while($Row = DB_Row())104 $Output = '<div class="StatList"><strong>RoÄnà statistika</strong><br><br>'. 105 '<table class="StatTable"><tr><th>Rok</th><th>Prohlédnutých stránek</th></tr>'; 106 107 // Zjisti rozmezà roků 108 $DbResult = $Database->select('stat', 'DISTINCT date', 'name="'.$_GET['name'].'" AND category="'.$_GET['category'].'"'); 109 while($Row = $DbResult->fetch_assoc()) 108 110 { 109 111 $Year = substr($Row['date'],0,4); … … 113 115 if($Year > $Max) $Max = $Year; 114 116 } 115 // Na čti body rokůa body celkem117 // NaÄti body roků a body celkem 116 118 for($I=$Min;$I<=$Max;$I++) 117 119 { … … 119 121 $DateTo = $DateFrom.'-12-31'; 120 122 $DateFrom .= '-01-01'; 121 122 DB_Select('stat', 'SUM(hits)', 'name="'.$_GET['name'].'" AND category="'.$_GET['category'].'"');123 $Row = DB_Row();123 124 $DbResult = $Database->select('stat', 'SUM(hits)', 'name="'.$_GET['name'].'" AND category="'.$_GET['category'].'"'); 125 $Row = $DbResult->fetch_row(); 124 126 $Total = $Row[0]; 125 126 DB_Select('stat', 'hits', 'name="'.$_GET['name'].'" AND date>="'.$DateFrom.'" AND date<="'.$DateTo.'" AND category="'.$_GET['category'].'"');127 $Row = DB_Row();127 128 $DbResult = $Database->select('stat', 'hits', 'name="'.$_GET['name'].'" AND date>="'.$DateFrom.'" AND date<="'.$DateTo.'" AND category="'.$_GET['category'].'"'); 129 $Row = $DbResult->fetch_row(); 128 130 $Percent = round($Row[0]/$Total*100,2); 129 131 if($Percent==0) $Percent = '0'; 130 132 $Output .= '<tr><td><a href="?module=stat&category='.$_GET['category'].'&name='.$_GET['name'].'&period=months&year='.$I.'">'.$I.'</a></td>'. 131 '<td><img src="images/leftbar.gif" width="7" height="15"><img src="images/mainbar.gif" width="'.round($Percent*2).'" height="15"><img src="images/rightbar.gif" width="7" height="15"> '.$Percent.'% ('.$Row[0].')</td></tr>'; 132 } 133 $Output .= '</table><a href="?module=stat&category='.$_GET['category'].'">Zp átky přehled statistiky</a></div>';133 '<td><img src="images/leftbar.gif" width="7" height="15"><img src="images/mainbar.gif" width="'.round($Percent*2).'" height="15"><img src="images/rightbar.gif" width="7" height="15"> '.$Percent.'% ('.$Row[0].')</td></tr>'; 134 } 135 $Output .= '</table><a href="?module=stat&category='.$_GET['category'].'">Zpátky pÅehled statistiky</a></div>'; 134 136 } 135 137 return($Output); 136 138 } 137 139 138 // Zobraz í statistiku měsícu //140 // Zobrazà statistiku mÄsÃcu // 139 141 function StatShowMonths() 140 142 { 141 global $StatMonths ;143 global $StatMonths, $Database; 142 144 if(array_key_exists('name', $_GET) and array_key_exists('category', $_GET) and array_key_exists('year', $_GET)) 143 145 { 144 145 $Output = '<div class="StatList"><strong>M ěsíčnístatistika pro rok '.$_GET['year'].'</strong><br><br>'.146 '<table class="StatTable" cellspacing="0"><tr><th>M ěsíc</th><th>Prohlédnutých stránek</th></tr>';147 148 // Spo čítej počty pro měsíce146 147 $Output = '<div class="StatList"><strong>MÄsÃÄnà statistika pro rok '.$_GET['year'].'</strong><br><br>'. 148 '<table class="StatTable" cellspacing="0"><tr><th>MÄsÃc</th><th>Prohlédnutých stránek</th></tr>'; 149 150 // SpoÄÃtej poÄty pro mÄsÃce 149 151 for($I=1;$I<13;$I++) 150 152 { … … 152 154 $DateTo = $DateFrom.'31'; 153 155 $DateFrom .= '01'; 154 155 DB_Select('stat', 'SUM(hits)', 'name="'.$_GET['name'].'" AND category="'.$_GET['category'].'"');156 $Row = DB_Row();156 157 $DbResult = $Database('stat', 'SUM(hits)', 'name="'.$_GET['name'].'" AND category="'.$_GET['category'].'"'); 158 $Row = $DbResult->fetch_row(); 157 159 $Total = $Row[0]; 158 160 159 DB_Select('stat', 'hits', 'name="'.$_GET['name'].'" AND date>="'.$DateFrom.'" AND date<="'.$DateTo.'" AND category="'.$_GET['category'].'"');160 $Row = DB_Row();161 $DbResult = $Datbase->select('stat', 'hits', 'name="'.$_GET['name'].'" AND date>="'.$DateFrom.'" AND date<="'.$DateTo.'" AND category="'.$_GET['category'].'"'); 162 $Row = $DbResult->fetch_row(); 161 163 $Percent = round($Row[0]/$Total*100,2); 162 164 if($Percent==0) $Percent = '0'; 163 165 $Output .= '<tr><td><a href="?module=stat&category='.$_GET['category'].'&name='.$_GET['name'].'&period=days&year='.$_GET['year'].'&month='.$I.'">'.$StatMonths[$I-1].'</a></td>'. 164 '<td><img src="images/leftbar.gif" width="7" height="15"><img src="images/mainbar.gif" width="'.round($Percent*2).'" height="15"><img src="images/rightbar.gif" width="7" height="15">  '.$Percent.'% ('.$Row[0].')</td></tr>'; 165 } 166 $Output .= '</table><a href="?module=stat&period=years&category='.$_GET['category'].'&name='.$_GET['name'].'">Zp átky na statistiku roků</a></div>';166 '<td><img src="images/leftbar.gif" width="7" height="15"><img src="images/mainbar.gif" width="'.round($Percent*2).'" height="15"><img src="images/rightbar.gif" width="7" height="15">  '.$Percent.'% ('.$Row[0].')</td></tr>'; 167 } 168 $Output .= '</table><a href="?module=stat&period=years&category='.$_GET['category'].'&name='.$_GET['name'].'">Zpátky na statistiku roků</a></div>'; 167 169 return($Output); 168 170 } … … 171 173 function StatShowDays() 172 174 { 173 global $StatMonths; 175 global $StatMonths, $Database; 176 174 177 if(array_key_exists('name', $_GET) and array_key_exists('category', $_GET) and array_key_exists('year', $_GET) and array_key_exists('month', $_GET)) 175 178 { 176 $Output = '<div class="StatList"><strong>Denn í statistika pro měsic '.$StatMonths[$_GET['month']].'</strong><br><br>'.177 '<table class="StatTable" cellspacing="0"><tr><th>Den</th><th>Prohl édnutých stránek</th></tr>';179 $Output = '<div class="StatList"><strong>Dennà statistika pro mÄsic '.$StatMonths[$_GET['month']].'</strong><br><br>'. 180 '<table class="StatTable" cellspacing="0"><tr><th>Den</th><th>Prohlédnutých stránek</th></tr>'; 178 181 for($I=1;$I<32;$I++) 179 182 { 180 DB_Select('stat', 'SUM(hits)', 'name="'.$_GET['name'].'" AND category="'.$_GET['category'].'"');181 $Row = DB_Row();183 $DbResult = $Database->select('stat', 'SUM(hits)', 'name="'.$_GET['name'].'" AND category="'.$_GET['category'].'"'); 184 $Row = $DbResult->fetch_row(); 182 185 $Total = $Row[0]; 183 186 184 187 $Date = $_GET['year'].'-'.$_GET['month'].'-'.$I; 185 DB_Select('stat', 'hits', 'name="'.$_GET['name'].'" AND date="'.$Date.'" AND category="'.$_GET['category'].'"');186 $Row = DB_Row();187 188 $DbResult = $Database->select('stat', 'hits', 'name="'.$_GET['name'].'" AND date="'.$Date.'" AND category="'.$_GET['category'].'"'); 189 $Row = $DbResult->fetch_row(); 190 188 191 $Percent = round($Row[0]/$Total*100,2); 189 192 if($Percent==0) $Percent = '0'; 190 193 $Output .= '<tr><td>'.$I.'</td>'. 191 '<td><img src="images/leftbar.gif" width="7" height="15"><img src="images/mainbar.gif" width="'.round($Percent*2).'" height="15"><img src="images/rightbar.gif" width="7" height="15">  '.$Percent.'% ('.$Row[0].')</td></tr>'; 192 } 193 $Output .= '</table><a href="?module=stat&period=months&name='.$_GET['name'].'&category='.$_GET['category'].'&year='.$_GET['year'].'">Zp átky na statistiku měsíců</a></div>';194 '<td><img src="images/leftbar.gif" width="7" height="15"><img src="images/mainbar.gif" width="'.round($Percent*2).'" height="15"><img src="images/rightbar.gif" width="7" height="15">  '.$Percent.'% ('.$Row[0].')</td></tr>'; 195 } 196 $Output .= '</table><a href="?module=stat&period=months&name='.$_GET['name'].'&category='.$_GET['category'].'&year='.$_GET['year'].'">Zpátky na statistiku mÄsÃců</a></div>'; 194 197 } 195 198 return($Output); … … 198 201 function StatShowMain() 199 202 { 200 global $StatCategory; 201 DB_Select('stat', 'DISTINCT category'); 202 $Output = '<div class="StatList"><strong>Seznam kategorií:</strong><br><br><table class="StatTable" cellspacing="0"><tr><th>Název</t></tr>'; 203 while($Row = DB_Row()) 203 global $StatCategory, $Database; 204 205 $DbResult = $Database->select('stat', 'DISTINCT category'); 206 $Output = '<div class="StatList"><strong>Seznam kategoriÃ:</strong><br><br><table class="StatTable" cellspacing="0"><tr><th>Název</t></tr>'; 207 while($Row = $DbResult->fetch_assoc()) 204 208 { 205 209 $Output .= '<tr><td><a href="?module=stat&category='.$Row['category'].'">'.$StatCategory[$Row['category']].'</a></td></tr>'; … … 208 212 if(array_key_exists('category', $_GET)) 209 213 { 210 DB_Select('stat', 'SUM(hits)', 'category="'.$_GET['category'].'"');211 $Row = DB_Row();214 $DbResult = $Database->select('stat', 'SUM(hits)', 'category="'.$_GET['category'].'"'); 215 $Row = $DbResult->fetch_row(); 212 216 $All = $Row[0]; 213 $Output .= '<br><strong>V ýpis kategorie:</strong><br><br><table class="StatTable" cellspacing="0"><tr><th>Název</th><th>Stránek</th></tr>';214 DB_Select('stat', 'DISTINCT name', "category='".$_GET['category']."' ORDER BY 'name'");215 while($Row = DB_Row())217 $Output .= '<br><strong>Výpis kategorie:</strong><br><br><table class="StatTable" cellspacing="0"><tr><th>Název</th><th>Stránek</th></tr>'; 218 $DbResult = $Database->select('stat', 'DISTINCT name', "category='".$_GET['category']."' ORDER BY 'name'"); 219 while($Row = $DbResult->fetch_assoc()) 216 220 { 217 DB_Save(); 218 DB_Select('stat', 'SUM(hits)', "name='".$Row['name']."' AND category='".$_GET['category']."'"); 219 $Row2 = DB_Row(); 220 if($Row['name'] == 'direct') $Nazev = 'Zadáno přímo'; else $Nazev = $Row['name']; 221 if($_GET['category'] == 'host') $Nazev = gethostbyaddr($Nazev); 221 $DbResult2 = $Datbase->select('stat', 'SUM(hits)', "name='".$Row['name']."' AND category='".$_GET['category']."'"); 222 $Row2 = $DbResult2->fetch_array(); 223 if($Row['name'] == 'direct') $Nazev = 'Zadáno pÅÃmo'; else $Nazev = $Row['name']; 224 if($_GET['category'] == 'host') $Nazev = gethostbyaddr($Nazev); 222 225 $Output .= '<tr><td><a href="?module=stat&category='.$_GET['category'].'&period=years&name='.$Row['name'].'">'.$Nazev.'</a></td>'. 223 226 '<td><img src="images/leftbar.gif" width="7" height="15"><img src="images/mainbar.gif" width="'.(round($Row2[0]/$All*100,2)).'" height="15"><img src="images/rightbar.gif" width="7" height="15">'.$Row2[0].'</td></tr>'; 224 DB_Load();225 227 } 226 228 $Output .= '</table></div>';
Note:
See TracChangeset
for help on using the changeset viewer.