Changeset 17
- Timestamp:
- Jun 12, 2009, 9:23:36 AM (15 years ago)
- Location:
- trunk/www
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/www/emulator.php
r16 r17 10 10 { 11 11 $this->Database = $Database; 12 $this->Task = new Task( &$Database);12 $this->Task = new Task($Database); 13 13 $this->Id = $Id; 14 14 $DbResult = $this->Database->query('SELECT * FROM `Emulator` WHERE `Id`='.$Id); -
trunk/www/global.php
r12 r17 258 258 } 259 259 260 function TimeToHumanTime($Value) 261 { 262 return(floor($Value / 3600 / 24).' days, '.date('H:i:s', $Value - 3600)); 263 } 264 260 265 // Zobrazení číselný seznamu stránek 261 266 function PagesList($URL, $Page, $TotalCount, $CountPerPage, $Around = 10) -
trunk/www/index.php
r15 r17 334 334 } else $Output .= $this->SystemMessage('Překlad emulátoru', 'Nebylo zadáno Id'); 335 335 } else 336 if($_GET['Action'] == 'ServerDebug') 337 { 338 if($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER) 339 { 340 $Output = '<div>Ladící informace serveru</div>'; 341 $DbResult = $this->Database->query('SELECT Id FROM Server WHERE User='.$this->System->Modules['User']->User['Id']); 342 $Server = $DbResult->fetch_assoc(); 343 $MangosDebug = new MangosDebug($this->Database); 344 $Output .= $MangosDebug->Show($Server['Id']); 345 } else $Output .= USER_BAD_ROLE; 346 } else 336 347 if($_GET['Action'] == 'Test') 337 348 { -
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 } -
trunk/www/mangos_debug_process.php
r12 r17 3 3 include('global.php'); 4 4 5 $MangosDebug = new MangosDebug( );5 $MangosDebug = new MangosDebug($Database); 6 6 echo($MangosDebug->ProcessLog()); 7 7 -
trunk/www/server.php
r16 r17 17 17 { 18 18 $this->Database = $Database; 19 $this->Task = new Task( &$Database);19 $this->Task = new Task($Database); 20 20 $this->Id = $Id; 21 21 $DbResult = $this->Database->query('SELECT * FROM `Server` WHERE `Id`='.$Id); … … 162 162 $Content = array 163 163 ( 164 'run -c server/'.$this->Id.'/etc/ realmd.conf',164 'run -c server/'.$this->Id.'/etc/mangosd.conf', 165 165 'info thread', 166 166 ); … … 176 176 '#!/bin/sh', 177 177 'while [ 1=1 ] ; do', 178 'gdb emulator/'.$this->Id.'/bin/mangos-worldd -x mangos.gdb --batch >>server/'.$this->Id.'/log/mangos-worldd.log 2>>server/'.$this->Id.'/log/mangos-worldd.err',178 'gdb emulator/'.$this->Id.'/bin/mangos-worldd -x emulator/'.$this->Id.'/bin/mangos.gdb --batch >>server/'.$this->Id.'/log/mangos-worldd.log 2>>server/'.$this->Id.'/log/mangos-worldd.err', 179 179 'cd www', 180 180 'php mangos_debug_process.php '.$this->Id.' >>server/'.$this->Id.'/log/mangos_debug.log 2>>server/'.$this->Id.'/log/mangos_debug.err', … … 217 217 $Config->ParameterList['DataDir'] = 'wowclient/'.$this->Server['Database']['Emulator']['ClientVersion']['Version']; 218 218 $Config->ParameterList['LogsDir'] = 'server/'.$this->Id.'/log'; 219 $Config->ParameterList['LogLevel'] = 1; 220 $Config->ParameterList['LogSQL'] = 0; 219 221 $ServerTypes = array(0 => 0, 1 => 1, 2 => 6, 3 => 8); 220 222 $Config->ParameterList['GameType'] = $ServerTypes[$this->Server['Type']];
Note:
See TracChangeset
for help on using the changeset viewer.