Changeset 62 for trunk/www/model/mangos_debug.php
- Timestamp:
- Aug 5, 2009, 7:30:23 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/www/model/mangos_debug.php
r54 r62 9 9 { 10 10 $this->Database = $Database; 11 } 11 } 12 12 13 function Show($ServerId) 14 { 15 global $System; 16 17 $Output = ''; 18 $Form = new Form('DebugItem'); 19 if($Form->LoadValuesFromDatabase($_GET['Id'])) 20 { 21 $Form->Values['Uptime'] = TimeToHumanTime($Form->Values['Uptime']); 22 $Output .= $Form->ShowTable(); 23 24 $Output .= '<a href="?Action=ServerDebug&Id='.$_GET['Id'].'&Show=Backtrace">Backtrace</a>'. 25 ' <a href="?Action=ServerDebug&Id='.$_GET['Id'].'&Show=Log">Mangos log</a>'. 26 ' <a href="?Action=ServerDebug&Id='.$_GET['Id'].'&Show=Error">Console error log</a>'. 27 ' <a href="?Action=ServerDebug&Id='.$_GET['Id'].'&Show=DbErrors">Database error log</a>'. 28 ' <a href="?Action=ServerDebug&Id='.$_GET['Id'].'&Show=Configuration">Mangos configuration</a>'. 29 '<hr>'; 30 if(array_key_exists('Show', $_GET)) 31 { 32 $Show = addslashes($_GET['Show']); 33 switch($Show) 34 { 35 case 'Backtrace': 36 $DbResult = $this->Database->select('Debug', 'Backtrace', 'Id='.$_GET['Id']); 37 $DbRow = $DbResult->fetch_assoc(); 38 $Content = htmlspecialchars($DbRow['Backtrace']); 39 for($I = 1; $I < $this->MaxMangosThreadCount; $I++) 40 { 41 $Content = str_replace('Thread '.$I.' ', '<hr><strong id="'.$I.'">Thread '.$I.'</strong>', $Content); 42 $Content = str_replace(' '.$I.' Thread ', '<a href="#'.$I.'"">'.$I.' Thread</a>', $Content); 43 } 44 $Output .= '<strong>Backtrace:</strong> <br><pre>'.$Content.'</pre>'; 45 break; 46 case 'Log': 47 $DbResult = $this->Database->select('Debug', 'Log', 'Id='.$_GET['Id']); 48 $DbRow = $DbResult->fetch_assoc(); 49 $Output .= '<strong>Console standard output log:</strong> <br><pre>'.htmlspecialchars($DbRow['Log']).'</pre>'; 50 break; 51 case 'Error': 52 $DbResult = $this->Database->select('Debug', 'ErrorLog', 'Id='.$_GET['Id']); 53 $DbRow = $DbResult->fetch_assoc(); 54 $Output .= '<strong>Console error log:</strong> <br><pre>'.htmlspecialchars($DbRow['ErrorLog']).'</pre>'; 55 break; 56 case 'DbErrors': 57 $DbResult = $this->Database->select('Debug', 'DbErrors', 'Id='.$_GET['Id']); 58 $DbRow = $DbResult->fetch_assoc(); 59 $Output .= '<strong>Database error log:</strong> <br><pre>'.htmlspecialchars($DbRow['DbErrors']).'</pre>'; 60 break; 61 case 'Configuration': 62 $DbResult = $this->Database->select('Debug', 'Configuration', 'Id='.$_GET['Id']); 63 $DbRow = $DbResult->fetch_assoc(); 64 $Output .= '<strong>Mangos configuration:</strong> <br><pre>'.htmlspecialchars($DbRow['Configuration']).'</pre>'; 65 break; 66 } 67 } 68 } else $Output = 'Položka nenalezena'; 69 return($Output); 70 } 71 72 function ProcessLog($ServerId) 13 function ProcessLog() 73 14 { 74 15 global $Config; … … 76 17 $Output = ''; 77 18 // Read server Id from first parameter 78 $ServerId = $_SERVER['argv'][1]; 79 $LogDir = '../server/'.$ServerId.'/log/'; 80 $MangosConfFile = '../server/'.$ServerId.'/etc/mangosd.conf'; 19 $RealmId = $_SERVER['argv'][1]; 20 $Realm = new Realm($this->Database, $RealmId); 21 22 $LogDir = '../realm/'.$RealmId.'/log/'; 23 $MangosConfFile = '../realm/'.$RealmId.'/etc/mangosd.conf'; 81 24 $StdOutLogFile = $LogDir.'mangos-worldd.log'; 82 25 $ErrOutLogFile = $LogDir.'mangos-worldd.err'; … … 105 48 106 49 // Get used database version from database 107 $DbResult = $this->Database->query('SELECT * FROM ` server'.$ServerId.'_mangos`.`db_version`');50 $DbResult = $this->Database->query('SELECT * FROM `realm'.$RealmId.'_mangos`.`db_version`'); 108 51 $DbRow = $DbResult->fetch_array(); 109 52 $DbVersion = $DbRow['version']; 110 53 111 54 // Get last uptime info 112 $DbResult = $this->Database->query('SELECT * FROM `server'.$ ServerId.'_realmd`.`uptime` ORDER BY `starttime` DESC LIMIT 1');55 $DbResult = $this->Database->query('SELECT * FROM `server'.$Realm->Data['Server'].'_realmd`.`uptime` ORDER BY `starttime` DESC LIMIT 1'); 113 56 //$Output = $this->Database->error; 114 57 $DbRow = $DbResult->fetch_array(); … … 117 60 118 61 // Insert data to database 119 $this->Database->query('INSERT INTO `Debug` (` Server`, `Time`, `MangosVersion`, `DbVersion`, `Uptime`, `MaxPlayerCount`) VALUES ('.$ServerId.', NOW(), "'.$MangosVersion.'", "'.$DbVersion.'", '.$Uptime.', '.$MaxPlayerCount.')');62 $this->Database->query('INSERT INTO `Debug` (`Realm`, `Time`, `MangosVersion`, `DbVersion`, `Uptime`, `MaxPlayerCount`) VALUES ('.$RealmId.', NOW(), "'.$MangosVersion.'", "'.$DbVersion.'", '.$Uptime.', '.$MaxPlayerCount.')'); 120 63 $InsertId = $this->Database->insert_id; 121 64
Note:
See TracChangeset
for help on using the changeset viewer.