Changeset 62
- Timestamp:
- Aug 5, 2009, 7:30:23 AM (15 years ago)
- Location:
- trunk/www
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/www/index.php
r59 r62 142 142 $Output .= $EmulatorView->AddFinish(); 143 143 } else 144 if($_GET['Action'] == 'ServerDebug')145 {146 $DebugView = new DebugView($this->Database, $this->System);147 $Output .= $DebugView->Item();148 } else149 144 if($_GET['Action'] == 'ClientList') 150 145 { … … 157 152 $Output .= $BackupView->ItemList(); 158 153 } else 154 if($_GET['Action'] == 'DebugView') 155 { 156 $DebugView = new DebugView($this->Database, $this->System); 157 $Output .= $DebugView->Item(); 158 } else 159 159 if($_GET['Action'] == 'DebugList') 160 160 { -
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 -
trunk/www/model/realm.php
r59 r62 90 90 $CommandList = array_merge($CommandList, array( 91 91 'mysql --user=server'.$this->Data['Server'].' --password=server'.$this->Data['Server'].' realm'.$this->Id.'_mangos < database/'.$Database['Id'].'/'.$Database['SourceFileName'], 92 'mysql --user=server'.$this->Data['Server'].' --password=server'.$this->Data['Server'].' realm'.$this->Id.'_scriptdev2 < emulator/'.$Database['Emulator'] ['Id'].'/source/src/bindings/ScriptDev2/sql/scriptdev2_create_structure.sql',93 'mysql --user=server'.$this->Data['Server'].' --password=server'.$this->Data['Server'].' realm'.$this->Id.'_scriptdev2 < emulator/'.$Database['Emulator'] ['Id'].'/source/src/bindings/ScriptDev2/sql/scriptdev2_script_full.sql',94 'mysql --user=server'.$this->Data['Server'].' --password=server'.$this->Data['Server'].' realm'.$this->Id.'_mangos < emulator/'.$Database['Emulator'] ['Id'].'/source/src/bindings/ScriptDev2/sql/mangos_scriptname_full.sql',95 'mysql --user=server'.$this->Data['Server'].' --password=server'.$this->Data['Server'].' realm'.$this->Id.'_characters < emulator/'.$Database['Emulator'] ['Id'].'/share/mangos/sql/characters.sql',92 'mysql --user=server'.$this->Data['Server'].' --password=server'.$this->Data['Server'].' realm'.$this->Id.'_scriptdev2 < emulator/'.$Database['Emulator'].'/source/src/bindings/ScriptDev2/sql/scriptdev2_create_structure.sql', 93 'mysql --user=server'.$this->Data['Server'].' --password=server'.$this->Data['Server'].' realm'.$this->Id.'_scriptdev2 < emulator/'.$Database['Emulator'].'/source/src/bindings/ScriptDev2/sql/scriptdev2_script_full.sql', 94 'mysql --user=server'.$this->Data['Server'].' --password=server'.$this->Data['Server'].' realm'.$this->Id.'_mangos < emulator/'.$Database['Emulator'].'/source/src/bindings/ScriptDev2/sql/mangos_scriptname_full.sql', 95 'mysql --user=server'.$this->Data['Server'].' --password=server'.$this->Data['Server'].' realm'.$this->Id.'_characters < emulator/'.$Database['Emulator'].'/share/mangos/sql/characters.sql', 96 96 'php www/shell.php RealmDatabaseChange '.$this->Id.' '.$Database['Id'], 97 97 'php www/shell.php RealmUnLock '.$this->Id, … … 182 182 'while [ 1=1 ] ; do', 183 183 'gdb emulator/'.$this->Data['Database']['Emulator']['Id'].'/bin/mangos-worldd -x realm/'.$this->Id.'/bin/mangos.gdb --batch >>realm/'.$this->Id.'/log/mangos-worldd.log 2>>realm/'.$this->Id.'/log/mangos-worldd.err', 184 'cd www', 185 'php shell.php ServerProcessLog '.$this->Id.' >>realm/'.$this->Id.'/log/mangos_debug.log 2>>realm/'.$this->Id.'/log/mangos_debug.err', 186 'cd ..', 184 'php www/shell.php ServerProcessLog '.$this->Id.' >>realm/'.$this->Id.'/log/mangos_debug.log 2>>realm/'.$this->Id.'/log/mangos_debug.err', 187 185 'sleep 3', 188 186 'done', … … 215 213 $EmulatorConfig = new MangosConfigurationFile($this->Database); 216 214 $EmulatorConfig->Load($EmulatorEtcDir.'mangosd.conf.dist'); 217 $EmulatorConfig->ParameterList['LoginDatabaseInfo'] = 'localhost;3306;server'.$this->Id.';server'.$this->Id.';server'.$this-> Id.'_realmd';218 $EmulatorConfig->ParameterList['WorldDatabaseInfo'] = 'localhost;3306;server'.$this->Id.';server'.$this->Id.'; server'.$this->Id.'_mangos';215 $EmulatorConfig->ParameterList['LoginDatabaseInfo'] = 'localhost;3306;server'.$this->Id.';server'.$this->Id.';server'.$this->Data['Server'].'_realmd'; 216 $EmulatorConfig->ParameterList['WorldDatabaseInfo'] = 'localhost;3306;server'.$this->Id.';server'.$this->Id.';realm'.$this->Id.'_mangos'; 219 217 $EmulatorConfig->ParameterList['CharacterDatabaseInfo'] = 'localhost;3306;server'.$this->Data['Server'].';server'.$this->Data['Server'].';realm'.$this->Id.'_characters'; 220 218 $EmulatorConfig->ParameterList['ScriptDev2DatabaseInfo'] = 'localhost;3306;server'.$this->Data['Server'].';server'.$this->Data['Server'].';realm'.$this->Id.'_scriptdev2'; … … 258 256 // Do update 259 257 $Commands = array( 260 'php www/shell.php RealmLock '.$this->Id,258 'php www/shell.php RealmLock '.$this->Id, 261 259 ); 262 260 $DbResult = $this->Database->query('SELECT `Revision` FROM `Database` WHERE `Id` = '.$this->Data['Database']['Id']); … … 274 272 { 275 273 $Parts = explode('|', $Update); 276 $Command = 'mysql --user=server'.$this->Data['Server'].' --password=server'.$this->Data['Server'].' realm'.$this->Id.'_'.$Parts[0].' < database/'.$DbRow['Id'].'/'.$Parts[1]; 274 if($Parts[0] != 'realmd') 275 $Command = 'mysql --user=server'.$this->Data['Server'].' --password=server'.$this->Data['Server'].' realm'.$this->Id.'_'.$Parts[0].' < database/'.$DbRow['Id'].'/'.$Parts[1]; 277 276 $Commands[] = $Command; 278 277 } -
trunk/www/model/server.php
r57 r62 40 40 $this->Database->query('DROP USER "server'.$this->Id.'"@"localhost"'); 41 41 } 42 43 function ImportDatabase($Delete = false)44 {45 $this->Lock();46 $CommandList = array(47 'php www/shell.php ServerLock '.$this->Id,48 );49 if($Delete == true)50 {51 $CommandList = array_merge($CommandList, array(52 'mysql --silent --skip-column-names -u server'.$this->Id.' -pserver'.$this->Id.' server'.$this->Id.'_realmd -e "show tables" | gawk \'{print "drop table " $1 ";"}\' | mysql -u server'.$this->Id.' -pserver'.$this->Id.' server'.$this->Id.'_realmd',53 ));54 }55 // Lookup nearest database with full import56 $DbResult = $this->Database->query('SELECT * FROM `Database` WHERE (`Emulator` <> 0) AND (`Revision` <= '.$this->Server['Database']['Revision'].') AND (`SourceFileName` <> "") ORDER BY `Revision` DESC');57 $Database = $DbResult->fetch_assoc();58 59 $CommandList = array_merge($CommandList, array(60 'mysql --user=server'.$this->Id.' --password=server'.$this->Id.' server'.$this->Id.'_realmd < emulator/'.$Database['Emulator']['Id'].'/share/mangos/sql/realmd.sql',61 'php www/shell.php ServerDatabaseChange '.$this->Id.' '.$Database['Id'],62 'php www/shell.php ServerUnLock '.$this->Id,63 ));64 $this->Task->Add('Inicializace databáze', $CommandList);65 66 if($Database['Id'] != $this->Server['Database']['Id'])67 {68 $NewDatabaseId = $this->Server['Database']['Id'];69 $this->Server['Database']['Id'] = $Database['Id'];70 $this->Update($NewDatabaseId, false, false);71 }72 return('Úloha načtení nové databáze zařazena do fronty.');73 }74 42 75 43 function Start() … … 228 196 } 229 197 198 function ImportDatabase($Delete = false) 199 { 200 $this->Lock(); 201 $CommandList = array( 202 'php www/shell.php ServerLock '.$this->Id, 203 ); 204 if($Delete == true) 205 { 206 $CommandList = array_merge($CommandList, array( 207 'mysql --silent --skip-column-names -u server'.$this->Id.' -pserver'.$this->Id.' server'.$this->Id.'_realmd -e "show tables" | gawk \'{print "drop table " $1 ";"}\' | mysql -u server'.$this->Id.' -pserver'.$this->Id.' server'.$this->Id.'_realmd', 208 )); 209 } 210 // Lookup nearest database with full import 211 $DbResult = $this->Database->query('SELECT * FROM `Database` WHERE (`Emulator` <> 0) AND (`Revision` <= '.$this->Server['Database']['Revision'].') AND (`SourceFileName` <> "") ORDER BY `Revision` DESC'); 212 $Database = $DbResult->fetch_assoc(); 213 214 $CommandList = array_merge($CommandList, array( 215 'mysql --user=server'.$this->Id.' --password=server'.$this->Id.' server'.$this->Id.'_realmd < emulator/'.$Database['Emulator']['Id'].'/share/mangos/sql/realmd.sql', 216 'php www/shell.php ServerDatabaseChange '.$this->Id.' '.$Database['Id'], 217 'php www/shell.php ServerUnLock '.$this->Id, 218 )); 219 $this->Task->Add('Inicializace databáze', $CommandList); 220 221 if($Database['Id'] != $this->Server['Database']['Id']) 222 { 223 $NewDatabaseId = $this->Server['Database']['Id']; 224 $this->Server['Database']['Id'] = $Database['Id']; 225 $this->Update($NewDatabaseId, false, false); 226 } 227 return('Úloha načtení nové databáze zařazena do fronty.'); 228 } 229 230 230 function Update($DatabaseId, $DoBackup = true, $DoStop = true) 231 231 { … … 264 264 { 265 265 $Parts = explode('|', $Update); 266 $Command = 'mysql --user=server'.$this->Id.' --password=server'.$this->Id.' server'.$this->Id.'_'.$Parts[0].' < database/'.$DbRow['Id'].'/'.$Parts[1]; 266 if($Parts[0] == 'realmd') 267 $Command = 'mysql --user=server'.$this->Id.' --password=server'.$this->Id.' server'.$this->Id.'_'.$Parts[0].' < database/'.$DbRow['Id'].'/'.$Parts[1]; 267 268 $Commands[] = $Command; 268 269 } -
trunk/www/view/debug.php
r56 r62 28 28 function ShowListOnRow($Row) 29 29 { 30 $Row['Time'] = '<a href="?Action= ServerDebug&Id='.$Row['Id'].'&Show=Backtrace">'.str_replace(' ', ' ', $Row['Time']).'</a>';30 $Row['Time'] = '<a href="?Action=DebugView&Id='.$Row['Id'].'&Show=Backtrace">'.str_replace(' ', ' ', $Row['Time']).'</a>'; 31 31 $Row['Uptime'] = TimeToHumanTime($Row['Uptime']); 32 32 return($Row); … … 39 39 if($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER) 40 40 { 41 $ Server = new Server($this->Database, $_GET['Id']);42 if(($this->System->Modules['User']->User['Id'] == $ Server->Server['User']) or ($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR))41 $Realm = new Realm($this->Database, $_GET['Id']); 42 if(($this->System->Modules['User']->User['Id'] == $Realm->GetUser()) or ($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR)) 43 43 { 44 44 $Output = '<h4>Ladící záznamy restartů</h4>'; 45 45 $Table = new Table($this->ItemListFormClass); 46 46 $Table->OnRow = array($this, 'ShowListOnRow'); 47 $Table->Definition['Table'] = '(SELECT * FROM Debug WHERE Server='.$_GET['Id'].')';47 $Table->Definition['Table'] = '(SELECT * FROM Debug WHERE Realm='.$_GET['Id'].')'; 48 48 $Table->LoadValuesFromDatabase($this->Database); 49 49 $Output .= $Table->Show(); … … 59 59 function Item() 60 60 { 61 global $System; 62 61 63 if($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER) 62 64 { 63 $ Server = new Server($this->Database, $_GET['Id']);64 if(($this->System->Modules['User']->User['Id'] == $ Server->Server['User']) or ($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR))65 $Realm = new Realm($this->Database, $_GET['Id']); 66 if(($this->System->Modules['User']->User['Id'] == $Realm->GetUser()) or ($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR)) 65 67 { 66 68 $Output = '<div>Ladící informace serveru</div>'; 67 $MangosDebug = new MangosDebug($this->Database); 68 $Output .= $MangosDebug->Show($Server->Id); 69 70 $MangosDebug = new MangosDebug($this->Database, $this->System); 71 $Form = new Form($this->ItemFormClass); 72 if($Form->LoadValuesFromDatabase($_GET['Id'])) 73 { 74 $Form->Values['Uptime'] = TimeToHumanTime($Form->Values['Uptime']); 75 $Output .= $Form->ShowTable(); 76 77 $Output .= '<a href="?Action=DebugView&Id='.$_GET['Id'].'&Show=Backtrace">Backtrace</a>'. 78 ' <a href="?Action=DebugView&Id='.$_GET['Id'].'&Show=Log">Mangos log</a>'. 79 ' <a href="?Action=DebugView&Id='.$_GET['Id'].'&Show=Error">Console error log</a>'. 80 ' <a href="?Action=DebugView&Id='.$_GET['Id'].'&Show=DbErrors">Database error log</a>'. 81 ' <a href="?Action=DebugView&Id='.$_GET['Id'].'&Show=Configuration">Mangos configuration</a>'. 82 '<hr>'; 83 if(array_key_exists('Show', $_GET)) 84 { 85 $Show = addslashes($_GET['Show']); 86 switch($Show) 87 { 88 case 'Backtrace': 89 $DbResult = $this->Database->select('Debug', 'Backtrace', 'Id='.$_GET['Id']); 90 $DbRow = $DbResult->fetch_assoc(); 91 $Content = htmlspecialchars($DbRow['Backtrace']); 92 for($I = 1; $I < $MangosDebug->MaxMangosThreadCount; $I++) 93 { 94 $Content = str_replace('Thread '.$I.' ', '<hr><strong id="'.$I.'">Thread '.$I.'</strong>', $Content); 95 $Content = str_replace(' '.$I.' Thread ', '<a href="#'.$I.'"">'.$I.' Thread</a>', $Content); 96 } 97 $Output .= '<strong>Backtrace:</strong> <br><pre>'.$Content.'</pre>'; 98 break; 99 case 'Log': 100 $DbResult = $this->Database->select('Debug', 'Log', 'Id='.$_GET['Id']); 101 $DbRow = $DbResult->fetch_assoc(); 102 $Output .= '<strong>Console standard output log:</strong> <br><pre>'.htmlspecialchars($DbRow['Log']).'</pre>'; 103 break; 104 case 'Error': 105 $DbResult = $this->Database->select('Debug', 'ErrorLog', 'Id='.$_GET['Id']); 106 $DbRow = $DbResult->fetch_assoc(); 107 $Output .= '<strong>Console error log:</strong> <br><pre>'.htmlspecialchars($DbRow['ErrorLog']).'</pre>'; 108 break; 109 case 'DbErrors': 110 $DbResult = $this->Database->select('Debug', 'DbErrors', 'Id='.$_GET['Id']); 111 $DbRow = $DbResult->fetch_assoc(); 112 $Output .= '<strong>Database error log:</strong> <br><pre>'.htmlspecialchars($DbRow['DbErrors']).'</pre>'; 113 break; 114 case 'Configuration': 115 $DbResult = $this->Database->select('Debug', 'Configuration', 'Id='.$_GET['Id']); 116 $DbRow = $DbResult->fetch_assoc(); 117 $Output .= '<strong>Mangos configuration:</strong> <br><pre>'.htmlspecialchars($DbRow['Configuration']).'</pre>'; 118 break; 119 } 120 } 121 } else $Output = 'Položka nenalezena'; 69 122 } else $this->SystemMessage('Ladící informace', 'Nemáte oprávnění'); 70 123 } else $Output = USER_BAD_ROLE; 71 124 return($Output); 72 } 125 } 73 126 } 74 127 -
trunk/www/view/realm.php
r58 r62 157 157 $Output .= ' <a href="?Action=RealmEditDetailed&Id='.$Realm->Id.'">Upravit podrobné nastavení</a>'; 158 158 } 159 $Output .= ' <a href="?Action=DebugList&Id='.$Realm->Id.'">Ladící informace</a>'; 159 160 //$Output .= ' <a href="?Action=ServerDatabaseImport&Id='.$Server->Id.'">Načtení čisté databáze</a>'; 160 161 }
Note:
See TracChangeset
for help on using the changeset viewer.