Changeset 17 for trunk/www/mangos_debug.php
- Timestamp:
- Jun 12, 2009, 9:23:36 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/www/mangos_debug.php
r12 r17 4 4 { 5 5 var $ItemPerPage = 35; 6 var $MaxMangosThreadCount = 12; 6 7 7 function TimeToHumanTime($Value)8 function __construct($Database) 8 9 { 9 return(floor($Value / 3600 / 24).' days, '.date('H:i:s', $Value - 3600));10 $this->Database = $Database; 10 11 } 11 12 function Show Page()12 13 function Show($ServerId) 13 14 { 14 15 $Output = '<table width="100%"><tr><td width="10%" valign="top" style="">'. … … 20 21 else $Page = 0; 21 22 22 $DbResult = $this->Database->query('SELECT COUNT(*) FROM Debug ');23 $DbResult = $this->Database->query('SELECT COUNT(*) FROM Debug WHERE Server='.$ServerId); 23 24 $DbRow = $DbResult->fetch_array(); 24 25 $Total = $DbRow[0]; 25 26 26 $DbResult = $ Database->query('SELECT Id, Time FROM Debug WHERE 1 ORDER BY Time DESC LIMIT '.($Page * $ItemPerPage).','.$ItemPerPage);27 $DbResult = $this->Database->query('SELECT Id, Time FROM Debug WHERE Server='.$ServerId.' ORDER BY Time DESC LIMIT '.($Page * $this->ItemPerPage).','.$this->ItemPerPage); 27 28 while($DbRow = $DbResult->fetch_array()) 28 29 { 29 30 if($DbRow['Id'] == $Id) $Output .= '<strong>'; 30 $Output .= '<a href="? Id='.$DbRow['Id'].'&Page='.$Page.'&Show=Backtrace">'.str_replace(' ', ' ', $DbRow['Time']).'</a>';31 $Output .= '<a href="?Action=ServerDebug&Id='.$DbRow['Id'].'&Page='.$Page.'&Show=Backtrace">'.str_replace(' ', ' ', $DbRow['Time']).'</a>'; 31 32 if($DbRow['Id'] == $Id) $Output .= '</strong>'; 32 33 $Output .= '<br />'; 33 34 } 34 $Output .= PagesList('?Page=', $Page, $Total, $ ItemPerPage, 2);35 $Output .= PagesList('?Page=', $Page, $Total, $this->ItemPerPage, 2); 35 36 36 37 $Output .= '</td><td valign="top" width="90%">'; … … 38 39 if($Id > 0) 39 40 { 40 $DbResult = $ Database->query('SELECT * FROM Debug WHERE Id="'.$Id.'" ORDER BY Time');41 $DbResult = $this->Database->query('SELECT * FROM Debug WHERE Id="'.$Id.'" ORDER BY Time'); 41 42 if($DbResult->num_rows > 0) 42 43 { 43 44 $DbRow = $DbResult->fetch_array(); 44 $Output .= '<strong> Time:</strong> '.$DbRow['Time'].'<br />';45 $Output .= '<strong> MaNGOS version:</strong> '.$DbRow['MangosVersion'].'<br />';46 $Output .= '<strong> Database version:</strong> '.$DbRow['DbVersion'].'<br />';47 $Output .= '<strong> Uptime:</strong> '.$this->TimeToHumanTime($DbRow['Uptime']).'<br />';48 $Output .= '<strong>Max PlayerCount:</strong> '.$DbRow['MaxPlayerCount'].'<br /><br />';49 $Output .= '<a href="? Id='.$Id.'&Page='.$Page.'&Show=Backtrace">Backtrace</a>'.50 ' <a href="? Id='.$Id.'&Page='.$Page.'&Show=Log">Mangos log</a>'.51 ' <a href="? Id='.$Id.'&Page='.$Page.'&Show=Error">Console error log</a>'.52 ' <a href="? Id='.$Id.'&Page='.$Page.'&Show=DbErrors">Database error log</a>'.53 ' <a href="? Id='.$Id.'&Page='.$Page.'&Show=Configuration">Mangos configuration</a>'.45 $Output .= '<strong>Čas záznamu:</strong> '.$DbRow['Time'].'<br />'; 46 $Output .= '<strong>Verze MaNGOSu:</strong> '.$DbRow['MangosVersion'].'<br />'; 47 $Output .= '<strong>Verze databáze:</strong> '.$DbRow['DbVersion'].'<br />'; 48 $Output .= '<strong>Doba běhu:</strong> '.TimeToHumanTime($DbRow['Uptime']).'<br />'; 49 $Output .= '<strong>Maximum hráčů:</strong> '.$DbRow['MaxPlayerCount'].'<br /><br />'; 50 $Output .= '<a href="?Action=ServerDebug&Id='.$Id.'&Page='.$Page.'&Show=Backtrace">Backtrace</a>'. 51 ' <a href="?Action=ServerDebug&Id='.$Id.'&Page='.$Page.'&Show=Log">Mangos log</a>'. 52 ' <a href="?Action=ServerDebug&Id='.$Id.'&Page='.$Page.'&Show=Error">Console error log</a>'. 53 ' <a href="?Action=ServerDebug&Id='.$Id.'&Page='.$Page.'&Show=DbErrors">Database error log</a>'. 54 ' <a href="?Action=ServerDebug&Id='.$Id.'&Page='.$Page.'&Show=Configuration">Mangos configuration</a>'. 54 55 '<hr>'; 55 56 if(array_key_exists('Show', $_GET)) … … 60 61 case 'Backtrace': 61 62 $Content = htmlspecialchars($DbRow['Backtrace']); 62 for($I = 1; $I < $ MaxMangosThreadCount; $I++)63 for($I = 1; $I < $this->MaxMangosThreadCount; $I++) 63 64 { 64 65 $Content = str_replace('Thread '.$I.' ', '<hr><strong id="'.$I.'">Thread '.$I.'</strong>', $Content); … … 84 85 } 85 86 $Output .= '</td></tr></table>'; 87 return($Output); 86 88 } 87 89 88 90 function ProcessLog() 89 91 { 92 global $Config; 93 90 94 $Output = ''; 91 95 // Read server Id from first parameter … … 121 125 122 126 // Get used database version from database 123 $DbResult = $ Database->query('SELECT * FROM `'.$Config['Mangos']['DatabaseMangos'].'`.`db_version`');127 $DbResult = $this->Database->query('SELECT * FROM `server'.$ServerId.'_mangos`.`db_version`'); 124 128 $DbRow = $DbResult->fetch_array(); 125 129 $DbVersion = $DbRow['version']; 126 130 127 131 // Get last uptime info 128 $DbResult = $ Database->query('SELECT * FROM `'.$Config['Mangos']['DatabaseRealmd'].'`.`uptime` ORDER BY `starttime` DESC LIMIT 1');129 $Output = $Database->error;132 $DbResult = $this->Database->query('SELECT * FROM `server'.$ServerId.'_realmd`.`uptime` ORDER BY `starttime` DESC LIMIT 1'); 133 //$Output = $this->Database->error; 130 134 $DbRow = $DbResult->fetch_array(); 131 135 $MaxPlayerCount = $DbRow['maxplayers']; … … 133 137 134 138 // Insert data to database 135 $ Database->query('INSERT INTO `Debug` (`Server`, `Time`, `MangosVersion`, `DbVersion`, `Uptime`, `MaxPlayerCount`) VALUES ('.$ServerId.', NOW(), "'.$MangosVersion.'", "'.$DbVersion.'", '.$Uptime.', '.$MaxPlayerCount.')');136 $InsertId = $ Database->insert_id;139 $this->Database->query('INSERT INTO `Debug` (`Server`, `Time`, `MangosVersion`, `DbVersion`, `Uptime`, `MaxPlayerCount`) VALUES ('.$ServerId.', NOW(), "'.$MangosVersion.'", "'.$DbVersion.'", '.$Uptime.', '.$MaxPlayerCount.')'); 140 $InsertId = $this->Database->insert_id; 137 141 138 142 // Insert data in separate query to partly avoid too long query packet error 139 $ Database->query('UPDATE `Debug` SET Backtrace="'.$Backtrace.'" WHERE Id='.$InsertId);143 $this->Database->query('UPDATE `Debug` SET Backtrace="'.$Backtrace.'" WHERE Id='.$InsertId); 140 144 $Backtrace = ''; 141 145 … … 143 147 { 144 148 $Log = addslashes(file_get_contents($MangosLogFile)); 145 $ Database->query('UPDATE `Debug` SET Log="'.$Log.'" WHERE Id='.$InsertId);149 $this->Database->query('UPDATE `Debug` SET Log="'.$Log.'" WHERE Id='.$InsertId); 146 150 unlink($MangosLogFile); 147 151 148 152 } 149 if(file_exists($MangosDbError LogFile))153 if(file_exists($MangosDbErrorsLogFile)) 150 154 { 151 155 $Log = addslashes(file_get_contents($MangosDbErrorsLogFile)); 152 $ Database->query('UPDATE `Debug` SET DbErrors="'.$Log.'" WHERE Id='.$InsertId);156 $this->Database->query('UPDATE `Debug` SET DbErrors="'.$Log.'" WHERE Id='.$InsertId); 153 157 unlink($MangosDbErrorsLogFile); 154 158 } … … 163 167 if(substr($LogLine, 0, 1) != '#') $Configuration[] = $LogLine; 164 168 } 165 $ Database->query('UPDATE `Debug` SET Configuration="'.implode("\n", $Configuration).'" WHERE Id='.$InsertId);169 $this->Database->query('UPDATE `Debug` SET Configuration="'.implode("\n", $Configuration).'" WHERE Id='.$InsertId); 166 170 } 167 171 … … 169 173 { 170 174 $Log = addslashes(file_get_contents($ErrOutLogFile)); 171 $ Database->query('UPDATE `Debug` SET ErrorLog="'.$Log.'" WHERE Id='.$InsertId);175 $this->Database->query('UPDATE `Debug` SET ErrorLog="'.$Log.'" WHERE Id='.$InsertId); 172 176 unlink($ErrOutLogFile); 173 177 }
Note:
See TracChangeset
for help on using the changeset viewer.