Changeset 12
- Timestamp:
- Jun 11, 2009, 9:37:46 PM (15 years ago)
- Location:
- trunk/www
- Files:
-
- 1 added
- 1 deleted
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/www/database.php
r6 r12 14 14 global $Config; 15 15 16 if($Config['Web']['ShowSQLQuery'] == true) 17 echo('<div style="border-bottom-width: 1px; border-bottom-style: solid; padding-bottom: 3px; padding-top: 3px; font-size: 12px; font-family: Arial;">'.$Query.'</div>'); 16 if($Config['Web']['ShowSQLQuery'] == true) 17 { 18 if(isset($_SERVER['REMOTE_ADDR'])) echo('<div style="border-bottom-width: 1px; border-bottom-style: solid; padding-bottom: 3px; padding-top: 3px; font-size: 12px; font-family: Arial;">'.$Query.'</div>'); 19 else echo($Query."\n"); 20 } 18 21 $Result = parent::query($Query); 19 22 if(($this->error != '') and ($Config['Web']['ShowSQLError'] == true)) 20 echo('<div><strong>SQL Error: </strong>'.$this->error.'<br />'.$Query.'</div>'); 23 { 24 if(isset($_SERVER['REMOTE_ADDR'])) echo('<div><strong>SQL Error: </strong>'.$this->error.'<br />'.$Query.'</div>'); 25 echo('SQL Error: '.$this->error.' '.$Query."\n"); 26 } 21 27 22 28 return($Result); -
trunk/www/emulator.php
r11 r12 36 36 } 37 37 38 function GetList()39 {40 }41 42 38 function Download() 43 39 { … … 64 60 'mkdir objdir', 65 61 'cd objdir', 66 '../configure --prefix='.$Config['BaseDir'].'emulator/'.$this->Id.'/ --enable-cli --enable-ra ',62 '../configure --prefix='.$Config['BaseDir'].'emulator/'.$this->Id.'/ --enable-cli --enable-ra --with-debug-info', 67 63 'make', 68 64 'make install', -
trunk/www/error.php
r11 r12 56 56 if($Config['Web']['ShowPHPError'] == true) 57 57 { 58 echo('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head>'."\n". 59 '<meta http-equiv="Content-Language" content="cs">'."\n". 60 '<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2"></head><body>'."\n". 61 'Došlo k vnitřní chybě!<br> O chybě byl uvědoměn správce webu a chybu brzy odstraní.<br><br>'); 62 echo('<pre>'.$Error.'</pre><br>'); // V případě ladění chybu i zobraz 58 echo('<?xml version="1.0" encoding="utf-8"?>'."\n". 59 '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'. 60 '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cs" lang="cs">'. 61 '<head>'. 62 '<meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8" />'. 63 '</head><body>'. 64 'Došlo k vnitřní chybě!<br /> O chybě byl uvědoměn správce webu a chybu brzy odstraní.<br /><br />'); 65 echo('<pre>'.$Error.'</pre><br />'); // V případě ladění chybu i zobraz 63 66 echo('</body></html>'); 64 67 } -
trunk/www/form_classes.php
r11 r12 81 81 'EmulatorList' => array( 82 82 'Title' => 'Emulátor', 83 'Table' => '(SELECT `Emulator`.`Name`, ` ClientVersion`.`Version` AS `ClientVersion`, `Emulator`.`Revision`, `Emulator`.`ScriptDev2Revision`, `Emulator`.`ScriptDev2PatchFileName`, `Emulator`.`CommitHash` FROM `Emulator` JOIN `ClientVersion` ON `ClientVersion`.`Id` = `Emulator`.`ClientVersion`) AS T',83 'Table' => '(SELECT `Emulator`.`Name`, `Emulator`.`Id`, `ClientVersion`.`Version` AS `ClientVersion`, `Emulator`.`Revision`, `Emulator`.`ScriptDev2Revision`, `Emulator`.`ScriptDev2PatchFileName`, `Emulator`.`CommitHash` FROM `Emulator` JOIN `ClientVersion` ON `ClientVersion`.`Id` = `Emulator`.`ClientVersion`) AS T', 84 84 'Items' => array( 85 85 'Name' => array('Type' => 'String', 'Caption' => 'Název', 'Default' => ''), -
trunk/www/global.php
r11 r12 24 24 include('emulator.php'); 25 25 include('mangos_configuration_file.php'); 26 include('mangos_debug.php'); 26 27 include('task.php'); 27 28 -
trunk/www/index.php
r11 r12 53 53 if(($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER) and ($this->System->Modules['User']->User['Id'] == $Server->Server['User'])) 54 54 { 55 $Output .= '<br /><a href=" '.$this->System->Config['Web']['Host'].'/mysql/">Správa databáze</a> ';55 $Output .= '<br /><a href="http://'.$this->System->Config['Web']['Host'].'/mysql/">Správa databáze</a> '; 56 56 if(array_key_exists('Id', $Server->Server['Database'])) 57 57 { -
trunk/www/mangos_debug.php
r6 r12 1 1 <?php 2 3 include('global.php');4 2 5 3 class MangosDebug extends Module 6 4 { 7 var $MangosConfFile = '/opt/mangos/etc/mangosd.conf';8 var $StdOutLogFile = '/opt/mangos/log/mangos-worldd.log';9 var $ErrOutLogFile = '/opt/mangos/log/mangos-worldd.err';10 var $MangosLogFile = '/opt/mangos/log/Server.log';11 var $MangosDbErrorsLogFile = '/opt/mangos/log/DBErrors.log';12 5 var $ItemPerPage = 35; 13 6 … … 95 88 function ProcessLog() 96 89 { 90 $Output = ''; 91 // Read server Id from first parameter 92 if((count($_SERVER['argv']) > 1) and is_numeric($_SERVER['argv'][1])) 93 { 94 $ServerId = $_SERVER['argv'][1]; 95 $LogDir = '../server/'.$ServerId.'/log/'; 96 $MangosConfFile = $LogDir.'mangosd.conf'; 97 $StdOutLogFile = $LogDir.'mangos-worldd.log'; 98 $ErrOutLogFile = $LogDir.'mangos-worldd.err'; 99 $MangosLogFile = $LogDir.'Server.log'; 100 $MangosDbErrorsLogFile = $LogDir.'DBErrors.log'; 101 102 if(!file_exists($StdOutLogFile)) exit; 103 97 104 $Content = file_get_contents($StdOutLogFile); 98 105 $Lines = explode("\n", $Content); … … 126 133 127 134 // Insert data to database 128 $Database->query('INSERT INTO `Debug` (`Time`, `MangosVersion`, `DbVersion`, `Uptime`, `MaxPlayerCount`) VALUES (NOW(), "'. 129 $MangosVersion.'", "'.$DbVersion.'", '.$Uptime.', '.$MaxPlayerCount.')'); 135 $Database->query('INSERT INTO `Debug` (`Server`, `Time`, `MangosVersion`, `DbVersion`, `Uptime`, `MaxPlayerCount`) VALUES ('.$ServerId.', NOW(), "'.$MangosVersion.'", "'.$DbVersion.'", '.$Uptime.', '.$MaxPlayerCount.')'); 130 136 $InsertId = $Database->insert_id; 131 137 … … 133 139 $Database->query('UPDATE `Debug` SET Backtrace="'.$Backtrace.'" WHERE Id='.$InsertId); 134 140 $Backtrace = ''; 135 //echo($Database->error); 136 $Log = addslashes(file_get_contents($MangosLogFile)); 137 $Database->query('UPDATE `Debug` SET Log="'.$Log.'" WHERE Id='.$InsertId); 138 //echo($Database->error); 139 $Log = addslashes(file_get_contents($MangosDbErrorsLogFile)); 140 $Database->query('UPDATE `Debug` SET DbErrors="'.$Log.'" WHERE Id='.$InsertId); 141 //echo($Database->error); 141 142 if(file_exists($MangosLogFile)) 143 { 144 $Log = addslashes(file_get_contents($MangosLogFile)); 145 $Database->query('UPDATE `Debug` SET Log="'.$Log.'" WHERE Id='.$InsertId); 146 unlink($MangosLogFile); 147 148 } 149 if(file_exists($MangosDbErrorLogFile)) 150 { 151 $Log = addslashes(file_get_contents($MangosDbErrorsLogFile)); 152 $Database->query('UPDATE `Debug` SET DbErrors="'.$Log.'" WHERE Id='.$InsertId); 153 unlink($MangosDbErrorsLogFile); 154 } 142 155 143 $Configuration = array(); 144 $Log = addslashes(file_get_contents($MangosConfFile)); 145 $LogLines = explode("\n", $Log); 146 foreach($LogLines as $LogLine) 156 if(file_exists($MangosConfFile)) 147 157 { 148 if(substr($LogLine, 0, 1) != '#') $Configuration[] = $LogLine; 158 $Configuration = array(); 159 $Log = addslashes(file_get_contents($MangosConfFile)); 160 $LogLines = explode("\n", $Log); 161 foreach($LogLines as $LogLine) 162 { 163 if(substr($LogLine, 0, 1) != '#') $Configuration[] = $LogLine; 164 } 165 $Database->query('UPDATE `Debug` SET Configuration="'.implode("\n", $Configuration).'" WHERE Id='.$InsertId); 149 166 } 150 $Database->query('UPDATE `Debug` SET Configuration="'.implode("\n", $Configuration).'" WHERE Id='.$InsertId);151 167 152 //echo($Database->error);153 $Log = addslashes(file_get_contents($ErrOutLogFile));154 $Database->query('UPDATE `Debug` SET ErrorLog="'.$Log.'" WHERE Id='.$InsertId);155 156 // Clear log files157 unlink($MangosLogFile);168 if(file_exists($ErrOutLogFile)) 169 { 170 $Log = addslashes(file_get_contents($ErrOutLogFile)); 171 $Database->query('UPDATE `Debug` SET ErrorLog="'.$Log.'" WHERE Id='.$InsertId); 172 unlink($ErrOutLogFile); 173 } 158 174 unlink($StdOutLogFile); 159 unlink($ErrOutLogFile);160 unlink($MangosDbErrorsLogFile);175 } else $Output = 'Je nutno zadat číslo serveru jako parameter'; 176 return($Output); 161 177 } 162 178 } -
trunk/www/page.php
r8 r12 25 25 '<title>'.$this->System->Config['Web']['Title'].' - '.$Path.'</title> 26 26 </head><body'.$BodyParam.'>'. 27 '<div class="Navigation"><span class="MenuItem"><a href="?">Se znam serverů</a>';27 '<div class="Navigation"><span class="MenuItem"><a href="?">Servery</a>'; 28 28 if($this->System->Modules['User']->User['Id'] != $this->System->Modules['User']->AnonymousUserId) 29 29 { … … 32 32 if($DbRow[0] > 0) $Output .= ' <a href="?Action=ServerShow">Vlastní server</a>'; 33 33 else $Output .= ' <a href="?Action=ServerAdd">Vytvořit vlastní server</a>'; 34 $Output .= '<a href="'.$this->System->Config['Web']['RootFolder'].'/?Action=UserOptions">Nastavení</a>'; 35 if($this->System->Modules['User']->User['Role'] == USER_ROLE_ADMINISTRATOR) 36 { 37 $Output .= '<a href="'.$this->System->Config['Web']['RootFolder'].'/?Action=EmulatorList">Emulátory</a>'; 38 } 34 39 } 35 40 $Output .= '</span><div class="MenuItem2">'; … … 37 42 $Output .= '<a href="'.$this->System->Config['Web']['RootFolder'].'/?Action=LoginForm">Přihlášení</a> <a href="'.$this->System->Config['Web']['RootFolder'].'/?Action=UserRegister">Registrace</a>'; 38 43 else $Output .= $this->System->Modules['User']->User['Name'].' <a href="'.$this->System->Config['Web']['RootFolder'].'/?Action=Logout">Odhlásit</a>'; 39 // <a href="'.$this->System->Config['Web']['RootFolder'].'/?Action=UserOptions">Nastavení</a>';40 44 $Output .= '</div></div>'; 41 45 return($Output); -
trunk/www/server.php
r11 r12 11 11 var $WorlddBaseNetworkPort = 8085; 12 12 var $RealmdBaseNetworkPort = 3724; 13 var $MangosWorlddThreadCountMax = 12; 13 14 14 15 function __construct($Database, $Id) … … 86 87 { 87 88 $this->AddTask('Start emulátoru', array( 88 'screen -A -m -d -S server'.$this->Id.'-realmd "emulator/'.$this->Server['Database']['Emulator']['Id'].'/bin/mangos-realmd -c server/'.$this->Id.'/etc/realmd.conf"',89 'screen -A -m -d -S server'.$this->Id.'-worldd "emulator/'.$this->Server['Database']['Emulator']['Id'].'/bin/mangos-worldd -c server/'.$this->Id.'/etc/mangosd.conf"',89 'screen -A -m -d -S server'.$this->Id.'-realmd emulator/'.$this->Server['Database']['Emulator']['Id'].'/bin/mangos-realmd -c server/'.$this->Id.'/etc/realmd.conf"', 90 'screen -A -m -d -S server'.$this->Id.'-worldd server/'.$this->Id.'/bin/start.sh', 90 91 )); 91 92 return('Požadavek na start serveru zařazen.'); … … 95 96 { 96 97 $this->AddTask('Zastavení emulátoru', array( 97 'ps -ef | grep \'SCREEN -A -m -d -S server'.$this->Id.'-realmd\' | grep -v grep | awk \'{print $2}\' | xargs -i kill {}', 98 'ps -ef | grep \'SCREEN -A -m -d -S server'.$this->Id.'-worldd\' | grep -v grep | awk \'{print $2}\' | xargs -i kill {}', 98 'server/'.$this->Id.'/bin/stop.sh', 99 99 )); 100 100 return('Požadavek na zastavení serveru zařazen.'); … … 152 152 $this->SetupConfigurationFiles(); 153 153 $this->UpdateRealmlist(); 154 $this->UpdateScripts(); 155 } 156 157 function UpdateScripts() 158 { 159 $ServerBinDir = '../server/'.$this->Id.'/bin/'; 160 if(!file_exists($ServerBinDir)) mkdir($ServerBinDir, 0777, true); 161 162 // GDB script 163 $ScriptFileName = '../server/'.$this->Id.'/bin/mangos.gdb'; 164 $Content = array 165 ( 166 'run -c server/'.$this->Id.'/etc/realmd.conf', 167 'info thread', 168 ); 169 for($I = 1; $I < $this->MangosWorlddThreadCountMax; $I++) 170 $Content[] = 'thread apply '.$I.' bt full'; 171 file_put_contents($ScriptFileName, implode("\n", $Content)); 172 chmod($ScriptFileName, 0666); 173 174 // Start script 175 $ScriptFileName = '../server/'.$this->Id.'/bin/start.sh'; 176 $Content = array 177 ( 178 '#!/bin/sh', 179 'while [ 1=1 ] ; do', 180 'gdb emulator/'.$this->Id.'/bin/mangos-realmd -x mangos.gdb --batch >>server/'.$this->Id.'/log/mangos-worldd.log 2>>server/'.$this->Id.'/log/mangos-worldd.err', 181 'cd www', 182 'php mangos_debug_process.php '.$this->Id.' >>server/'.$this->Id.'/log/mangos_debug.log 2>>server/'.$this->Id.'/log/mangos_debug.err', 183 'cd ..', 184 'sleep 3', 185 'done', 186 ); 187 file_put_contents($ScriptFileName, implode("\n", $Content)); 188 chmod($ScriptFileName, 0777); 189 190 // Stop script 191 $ScriptFileName = '../server/'.$this->Id.'/bin/stop.sh'; 192 $Content = array 193 ( 194 '#!/bin/sh', 195 'ps -ef | grep \'SCREEN -A -m -d -S server'.$this->Id.'-realmd\' | grep -v grep | awk \'{print $2}\' | xargs -i kill {}', 196 'ps -ef | grep \'SCREEN -A -m -d -S server'.$this->Id.'-worldd\' | grep -v grep | awk \'{print $2}\' | xargs -i kill {}', 197 ); 198 file_put_contents($ScriptFileName, implode("\n", $Content)); 199 chmod($ScriptFileName, 0777); 154 200 } 155 201
Note:
See TracChangeset
for help on using the changeset viewer.