Changeset 5
- Timestamp:
- Jun 9, 2009, 10:39:27 AM (15 years ago)
- Location:
- trunk/www
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/www/index.php
r4 r5 23 23 function ShowServer($Id) 24 24 { 25 $DbResult = $this->Database->query('SELECT * FROM Server WHERE Id='.$Id); 26 $Server = $DbResult->fetch_assoc(); 25 $Server = new Server($this->Database, $Id); 27 26 $Output = '<h4>Podrobnosti serveru</h4>'; 28 27 $Output .= '<table class="WideTable"><tr><th>Položka</th><th>Hodnota</th></tr>'; 29 $Output .= '<tr><td>Jméno</td><td>'.$Server['Name'].'</td></tr>'. 30 '<tr><td>Síťový port realmd</td><td>'.$Server['NetworkPortRealmd'].'</td></tr>'. 31 '<tr><td>Síťový port mangosd</td><td>'.$Server['NetworkPortMangosd'].'</td></tr>'. 32 '<tr><td>Emulátor</td><td>'.$Server['NetworkPortMangosd'].'</td></tr>'. 33 '<tr><td>Databáze</td><td>'.$this->System->Config['Web']['Host'].':'.$Server['NetworkPortRealmd'].'</td></tr>'; 28 $Output .= '<tr><td>Jméno</td><td>'.$Server->Server['Name'].'</td></tr>'. 29 '<tr><td>Zpráva dne</td><td>'.$Server->Server['Motd'].'</td></tr>'. 30 '<tr><td>Síťový port realmd</td><td>'.($Server->RealmdBaseNetworkPort + $Server->Id).'</td></tr>'. 31 '<tr><td>Síťový port mangosd</td><td>'.($Server->WorlddBaseNetworkPort + $Server->Id).'</td></tr>'. 32 '<tr><td>Emulátor</td><td>'.$Server->Server['Database']['Emulator']['Name'].'</td></tr>'. 33 '<tr><td>Databáze</td><td>'.$Server->Server['Database']['Name'].'</td></tr>'; 34 34 $Output .= '</table>'; 35 $Output .= '<br /><a hreg="'.$this->System->Config['Web']['Host'].'/mysql/">Správa databáze</a><br />'; 35 $Output .= '<br /><a href="'.$this->System->Config['Web']['Host'].'/mysql/">Správa databáze</a> '; 36 $ServerStatus = $Server->GetState(); 37 if($ServerStatus['RealmdPortState'] == true) $Output .= ' <a href="?Action=ServerStop">Zastavit server</a> <a href="?Action=ServerRestart">RestartovatServer</a>'; 38 else $Output .= ' <a href="?Action=ServerStart">Spustit server</a>'; 39 36 40 return($Output); 37 41 } … … 167 171 $Output .= $UserOptions->ShowEditForm(); 168 172 } else 169 if($_GET['Action'] == ' NewServer')173 if($_GET['Action'] == 'ServerAdd') 170 174 { 171 175 $Form = new Form('NewServer'); … … 183 187 $Output .= $UserOptions->ShowEditForm(); 184 188 } else 185 if($_GET['Action'] == 'EditServer') 189 if($_GET['Action'] == 'ServerShow') 190 { 191 $DbResult = $this->Database->query('SELECT Id FROM Server WHERE User='.$this->System->Modules['User']->User['Id']); 192 $Server = $DbResult->fetch_assoc(); 193 $Output .= $this->ShowServer($Server['Id']); 194 } else 195 if($_GET['Action'] == 'ServerEdit') 186 196 { 187 197 $Form = new Form('EditServer'); … … 200 210 $DbResult = $this->Database->query('SELECT Id FROM Server WHERE User='.$this->System->Modules['User']->User['Id']); 201 211 $Server = $DbResult->fetch_assoc(); 202 $ServerId = $Server['Id']; 203 $Server = new Server($this->Database, $ServerId); 204 205 // Setup mangosd.conf 206 $Config = new MangosConfigurationFile($this->Database); 207 $Config->Load('../emu/mangos/'.$Server->Server['Database']['Emulator']['Revision'].'/etc/mangosd.conf'); 208 $Config->ParameterList['LoginDatabaseInfo'] = 'localhost:3306:server'.$ServerId.':server'.$ServerId.':server'.$ServerId.'_realmd'; 209 $Config->ParameterList['WorldDatabaseInfo'] = 'localhost:3306:server'.$ServerId.':server'.$ServerId.':server'.$ServerId.'_mangos'; 210 $Config->ParameterList['CharacterDatabaseInfo'] = 'localhost:3306:server'.$ServerId.':server'.$ServerId.':server'.$ServerId.'_characters'; 211 $Config->ParameterList['WorldServerPort'] = 8085 + $ServerId; 212 $Config->ParameterList['Motd'] = $Server->Server['Motd']; 213 $Config->Save('../server/'.$ServerId.'/etc/mangosd.conf'); 214 // Setup realmd.conf 215 $Config = new MangosConfigurationFile($this->Database); 216 $Config->Load('../emu/mangos/'.$Server->Server['Database']['Emulator']['Revision'].'/etc/realmd.conf'); 217 $Config->ParameterList['LoginDatabaseInfo'] = 'localhost:3306:server'.$ServerId.':server'.$ServerId.':server'.$ServerId.'_realmd'; 218 $Config->ParameterList['RealmServerPort'] = 3724 + $ServerId; 219 $Config->Save('../server/'.$ServerId.'/etc/realmd.conf'); 220 // Setup realmd.conf 221 $Config = new MangosConfigurationFile($this->Database); 222 $Config->Load('../emu/mangos/'.$Server->Server['Database']['Emulator']['Revision'].'/etc/scriptdev2.conf'); 223 $Config->ParameterList['ScriptDev2DatabaseInfo'] = 'localhost:3306:server'.$ServerId.':server'.$ServerId.':server'.$ServerId.'_scriptdev2'; 224 $Config->Save('../server/'.$ServerId.'/etc/scriptdev2.conf'); 225 226 $Output .= $UserOptions->ShowEditForm(); 212 $Server = new Server($this->Database, $Server['Id']); 213 $Server->SetupConfigurationFiles(); 214 215 $Output .= $UserOptions->ShowEditForm(); 216 } else 217 if($_GET['Action'] == 'ServerStart') 218 { 219 $DbResult = $this->Database->query('SELECT Id FROM Server WHERE User='.$this->System->Modules['User']->User['Id']); 220 $Server = $DbResult->fetch_assoc(); 221 $Server = new Server($this->Database, $Server['Id']); 222 $Output .= $this->SystemMessage('Spuštění serveru', $Server->Start()); 223 } else 224 if($_GET['Action'] == 'ServerStop') 225 { 226 $DbResult = $this->Database->query('SELECT Id FROM Server WHERE User='.$this->System->Modules['User']->User['Id']); 227 $Server = $DbResult->fetch_assoc(); 228 $Server = new Server($this->Database, $Server['Id']); 229 $Output .= $this->SystemMessage('Zastavení serveru', $Server->Stop()); 227 230 } else 228 231 if($_GET['Action'] == 'Test') … … 236 239 { 237 240 $Output = $this->ShowServerList(); 238 $Output .= '<br /><a href="?Action= NewServer">Nový server</a>';241 $Output .= '<br /><a href="?Action=ServerAdd">Nový server</a>'; 239 242 } 240 243 } else 241 244 { 242 245 $Output = $this->ShowServerList(); 243 $Output .= '<br /><a href="?Action= NewServer">Nový server</a>';246 $Output .= '<br /><a href="?Action=ServerAdd">Nový server</a>'; 244 247 } 245 248 return($Output); -
trunk/www/process_tasks.php
r4 r5 8 8 while($Task = $DbResult->fetch_assoc()) 9 9 { 10 echo('Provádím '.$Task[' Command']."...\n");10 echo('Provádím '.$Task['Title']."...\n"); 11 11 foreach(explode("\n", $Task['CommandList']) as $Command) 12 12 { 13 13 $Output = array(); 14 echo($Command."\n"); 14 15 exec($Command, $Output); 15 16 echo(implode("\n", $Output)); -
trunk/www/server.php
r4 r5 5 5 var $Id; 6 6 var $Server; 7 var $WorlddBaseNetworkPort = 8085; 8 var $RealmdBaseNetworkPort = 3724; 7 9 8 10 function __construct($Database, $Id) … … 16 18 $DbResult = $this->Database->query('SELECT * FROM `Emulator` WHERE `Id`='.$this->Server['Database']['Emulator']); 17 19 $this->Server['Database']['Emulator'] = $DbResult->fetch_assoc(); 20 $DbResult = $this->Database->query('SELECT * FROM `ClientVersion` WHERE `Id`='.$this->Server['Database']['Emulator']['ClientVersion']); 21 $this->Server['Database']['Emulator']['ClientVersion'] = $DbResult->fetch_assoc(); 18 22 } 19 23 … … 45 49 function Start() 46 50 { 47 AddTask('Start emulátoru', array(48 'screen -A -m -d -S server'.$this->Id.'-realmd emu/mangos/'.$this->Server['Database']['Emulator']['Revision'].'/bin/mangos-realmd -c server/'.$this->Id.'/etc/realmd.conf',49 'screen -A -m -d -S server'.$this->Id.'- realmd emu/mangos/'.$this->Server['Database']['Emulator']['Revision'].'/bin/mangos-worldd -c server/'.$this->Id.'/etc/mangosd.conf',51 $this->AddTask('Start emulátoru', array( 52 'screen -A -m -d -S server'.$this->Id.'-realmd "emu/mangos/'.$this->Server['Database']['Emulator']['Revision'].'/bin/mangos-realmd -c server/'.$this->Id.'/etc/realmd.conf"', 53 'screen -A -m -d -S server'.$this->Id.'-worldd emu/mangos/'.$this->Server['Database']['Emulator']['Revision'].'/bin/mangos-worldd -c server/'.$this->Id.'/etc/mangosd.conf', 50 54 )); 55 return('Požadavek na start serveru zařazen.'); 51 56 } 52 57 53 58 function Stop() 54 59 { 55 AddTask('Zastavení emulátoru', array(60 $this->AddTask('Zastavení emulátoru', array( 56 61 'ps -ef | grep \'SCREEN -A -m -d -S server'.$this->Id.'-realmd\' | grep -v grep | awk \'{print $2}\' | xargs -i kill {}', 57 62 'ps -ef | grep \'SCREEN -A -m -d -S server'.$this->Id.'-worldd\' | grep -v grep | awk \'{print $2}\' | xargs -i kill {}', 58 63 )); 64 return('Požadavek na zastavení serveru zařazen.'); 65 } 66 67 function NetworkPortState($Address, $Port, $Timeout = 1) 68 { 69 if($Socket = @fsockopen($Address, $Port, $ERROR_NO, $ERROR_STR, (float)$Timeout)) 70 { 71 fclose($Socket); 72 return(true); 73 } else return(false); 74 } 75 76 function GetState() 77 { 78 $State = array(); 79 $State['RealmdPortState'] = $this->NetworkPortState('localhost', $this->RealmdBaseNetworkPort + $this->Server['Id']); 80 $State['WorlddPortState'] = $this->NetworkPortState('localhost', $this->WorlddBaseNetworkPort + $this->Server['Id']); 81 return($State); 82 } 83 84 function SetupConfigurationFiles() 85 { 86 // mangosd.conf 87 $Config = new MangosConfigurationFile($this->Database); 88 $Config->Load('../emu/mangos/'.$this->Server['Database']['Emulator']['Revision'].'/etc/mangosd.conf'); 89 $Config->ParameterList['LoginDatabaseInfo'] = 'localhost;3306;server'.$this->Id.';server'.$this->Id.';server'.$this->Id.'_realmd'; 90 $Config->ParameterList['WorldDatabaseInfo'] = 'localhost;3306;server'.$this->Id.';server'.$this->Id.';server'.$this->Id.'_mangos'; 91 $Config->ParameterList['CharacterDatabaseInfo'] = 'localhost;3306;server'.$this->Id.';server'.$this->Id.';server'.$this->Id.'_characters'; 92 $Config->ParameterList['ScriptDev2DatabaseInfo'] = 'localhost;3306;server'.$this->Id.';server'.$this->Id.';server'.$this->Id.'_scriptdev2'; 93 $Config->ParameterList['WorldServerPort'] = $this->WorlddBaseNetworkPort + $this->Id; 94 $Config->ParameterList['Motd'] = $this->Server['Motd']; 95 $Config->ParameterList['DataDir'] = 'wowclient/'.$this->Server['Database']['Emulator']['ClientVersion']['Version']; 96 $Config->Save('../server/'.$this->Id.'/etc/mangosd.conf'); 97 98 // realmd.conf 99 $Config = new MangosConfigurationFile($this->Database); 100 $Config->Load('../emu/mangos/'.$this->Server['Database']['Emulator']['Revision'].'/etc/realmd.conf'); 101 $Config->ParameterList['LoginDatabaseInfo'] = 'localhost;3306;server'.$this->Id.';server'.$this->Id.';server'.$this->Id.'_realmd'; 102 $Config->ParameterList['RealmServerPort'] = $this->RealmdBaseNetworkPort + $this->Id; 103 $Config->Save('../server/'.$this->Id.'/etc/realmd.conf'); 104 105 // scriptdev2.conf 106 $Config = new MangosConfigurationFile($this->Database); 107 $Config->Load('../emu/mangos/'.$this->Server['Database']['Emulator']['Revision'].'/etc/scriptdev2.conf'); 108 $Config->ParameterList['ScriptDev2DatabaseInfo'] = 'localhost;3306;server'.$this->Id.';server'.$this->Id.';server'.$this->Id.'_scriptdev2'; 109 $Config->Save('../server/'.$this->Id.'/etc/scriptdev2.conf'); 59 110 } 60 111 } -
trunk/www/sql/full.sql
r2 r5 4 4 -- 5 5 -- Počítač: localhost 6 -- Vygenerováno: Sobota 06. června 2009, 22:346 -- Vygenerováno: Úterý 09. června 2009, 09:32 7 7 -- Verze MySQL: 5.0.77 8 8 -- Verze PHP: 5.2.9 … … 82 82 `ACIDRevision` int(11) NOT NULL, 83 83 `SourceFileName` varchar(255) NOT NULL, 84 `Emulator` int(11) NOT NULL, 85 PRIMARY KEY (`Id`) 86 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ; 87 88 -- 89 -- Vypisuji data pro tabulku `Database` 90 -- 91 92 INSERT INTO `Database` (`Id`, `Name`, `Version`, `Revision`, `ScriptDev2Revision`, `ACIDRevision`, `SourceFileName`, `Emulator`) VALUES 93 (1, 'UDB', '0.11.5', 380, 1012, 0, 'UDB_0.11.5_Core_7681_SD2_1012.sql', 1); 94 95 -- -------------------------------------------------------- 96 97 -- 98 -- Struktura tabulky `Debug` 99 -- 100 101 CREATE TABLE IF NOT EXISTS `Debug` ( 102 `Id` int(11) NOT NULL auto_increment, 103 `Time` datetime NOT NULL, 104 `Server` int(11) NOT NULL, 105 `Backtrace` mediumtext NOT NULL, 106 `Log` text NOT NULL, 107 `MangosVersion` varchar(255) NOT NULL, 108 `DbVersion` varchar(255) NOT NULL, 109 `MaxPlayerCount` int(11) NOT NULL, 110 `Uptime` int(11) NOT NULL, 111 `ErrorLog` text NOT NULL, 112 `DbErrors` text NOT NULL, 113 `Configuration` text NOT NULL, 84 114 PRIMARY KEY (`Id`) 85 115 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; 86 116 87 117 -- 88 -- Vypisuji data pro tabulku `D atabase`118 -- Vypisuji data pro tabulku `Debug` 89 119 -- 90 120 … … 99 129 `Id` int(11) NOT NULL auto_increment, 100 130 `Name` varchar(255) NOT NULL, 101 `Emulator` int(11) NOT NULL, 131 `ClientVersion` int(11) NOT NULL, 132 `Revision` int(11) NOT NULL, 133 PRIMARY KEY (`Id`) 134 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ; 135 136 -- 137 -- Vypisuji data pro tabulku `Emulator` 138 -- 139 140 INSERT INTO `Emulator` (`Id`, `Name`, `ClientVersion`, `Revision`) VALUES 141 (1, 'MaNGOS', 6, 7681); 142 143 -- -------------------------------------------------------- 144 145 -- 146 -- Struktura tabulky `Server` 147 -- 148 149 CREATE TABLE IF NOT EXISTS `Server` ( 150 `Id` int(11) NOT NULL auto_increment, 151 `Name` varchar(255) NOT NULL, 152 `NetworkPortRealmd` int(11) NOT NULL, 153 `NetworkPortWorldd` int(11) NOT NULL, 154 `User` int(11) NOT NULL, 102 155 `Database` int(11) NOT NULL, 103 `ClientVersion` int(11) NOT NULL, 104 `User` int(11) NOT NULL, 156 `Motd` varchar(255) NOT NULL, 157 PRIMARY KEY (`Id`) 158 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ; 159 160 -- 161 -- Vypisuji data pro tabulku `Server` 162 -- 163 164 INSERT INTO `Server` (`Id`, `Name`, `NetworkPortRealmd`, `NetworkPortWorldd`, `User`, `Database`, `Motd`) VALUES 165 (1, 'Test', 3127, 8085, 2, 1, ''); 166 167 -- -------------------------------------------------------- 168 169 -- 170 -- Struktura tabulky `Task` 171 -- 172 173 CREATE TABLE IF NOT EXISTS `Task` ( 174 `Id` int(11) NOT NULL auto_increment, 175 `Time` datetime NOT NULL, 176 `Title` varchar(255) NOT NULL, 177 `CommandList` text NOT NULL, 178 `Server` int(11) NOT NULL, 179 `Executed` int(11) NOT NULL, 105 180 PRIMARY KEY (`Id`) 106 181 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; 107 182 108 183 -- 109 -- Vypisuji data pro tabulku `Emulator` 110 -- 111 112 113 -- -------------------------------------------------------- 114 115 -- 116 -- Struktura tabulky `Server` 117 -- 118 119 CREATE TABLE IF NOT EXISTS `Server` ( 120 `Id` int(11) NOT NULL auto_increment, 121 `Name` varchar(255) NOT NULL, 122 `Port` int(11) NOT NULL, 123 `User` int(11) NOT NULL, 124 `MangosVersion` int(11) NOT NULL, 125 PRIMARY KEY (`Id`) 126 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; 127 128 -- 129 -- Vypisuji data pro tabulku `Server` 184 -- Vypisuji data pro tabulku `Task` 130 185 -- 131 186 … … 140 195 `Id` int(11) NOT NULL auto_increment, 141 196 `Name` varchar(255) NOT NULL, 197 `Login` varchar(255) NOT NULL, 142 198 `Password` varchar(255) NOT NULL, 143 199 `Email` varchar(255) NOT NULL, 144 PRIMARY KEY (`Id`) 145 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; 200 `LastIpAddress` varchar(16) NOT NULL, 201 `LastLoginTime` datetime NOT NULL, 202 `RegistrationTime` datetime NOT NULL, 203 `Locked` int(11) NOT NULL, 204 PRIMARY KEY (`Id`) 205 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ; 146 206 147 207 -- … … 149 209 -- 150 210 211 INSERT INTO `User` (`Id`, `Name`, `Login`, `Password`, `Email`, `LastIpAddress`, `LastLoginTime`, `RegistrationTime`, `Locked`) VALUES 212 (1, 'Anonym', 'anonymous', '711a5c2497eca9d90a9cb92c188c7f4b8a7bf672', '', '', '0000-00-00 00:00:00', '0000-00-00 00:00:00', 0), 213 (2, 'Administrátor', 'admin', 'd033e22ae348aeb5660fc2140aec35850c4da997', 'root@localhost', '192.168.0.3', '2009-06-08 20:56:51', '0000-00-00 00:00:00', 0); 214 215 -- -------------------------------------------------------- 216 217 -- 218 -- Struktura tabulky `UserOnline` 219 -- 220 221 CREATE TABLE IF NOT EXISTS `UserOnline` ( 222 `Id` int(11) NOT NULL auto_increment, 223 `User` int(11) NOT NULL default '0', 224 `ActivityTime` datetime NOT NULL default '0000-00-00 00:00:00', 225 `LoginTime` datetime NOT NULL default '0000-00-00 00:00:00', 226 `SessionId` varchar(255) character set utf8 collate utf8_czech_ci NOT NULL default '', 227 `IpAddress` varchar(16) character set utf8 collate utf8_czech_ci NOT NULL default '', 228 `HostName` varchar(255) character set utf8 collate utf8_czech_ci NOT NULL default '', 229 `ScriptName` varchar(255) character set utf8 collate utf8_czech_ci NOT NULL, 230 PRIMARY KEY (`Id`), 231 KEY `User` (`User`) 232 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ; 233 234
Note:
See TracChangeset
for help on using the changeset viewer.