Changeset 6 for trunk/www/index.php
- Timestamp:
- Jun 10, 2009, 4:57:51 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/www/index.php
r5 r6 10 10 function ShowServerList() 11 11 { 12 $OnlineState = array(false => 'Neaktivní', true => 'Aktivní'); 12 13 $Output = '<h4>Seznam serverů</h4>'; 13 $Output .= '<table class="WideTable"><tr><th>Název</th><th>Uživatel</th><th>Realmd</th><th>Verze hry</th>< /tr>';14 $DbResult = $this->Database->query('SELECT `ClientVersion`.`Version`, `Server`.`Name`, `Server`.` NetworkPortRealmd`, `User`.`Name` AS `UserName` FROM `Server` JOIN `User` ON `User`.`Id` = `Server`.`User` JOIN `Database` ON `Database`.`Id` = `Server`.`Database` JOIN `Emulator` ON `Emulator`.`Id` = `Database`.`Emulator` JOIN `ClientVersion` ON `ClientVersion`.`Id` = `Emulator`.`ClientVersion`');15 while($ Server= $DbResult->fetch_assoc())14 $Output .= '<table class="WideTable"><tr><th>Název</th><th>Uživatel</th><th>Realmd</th><th>Verze hry</th><th>Stav</th><th>Hráčů online</th><th>Účtů</th><th>Postav</th></tr>'; 15 $DbResult = $this->Database->query('SELECT `ClientVersion`.`Version`, `Server`.`Name`, `Server`.`Id`, `Server`.`NetworkPortRealmd`, `User`.`Name` AS `UserName` FROM `Server` JOIN `User` ON `User`.`Id` = `Server`.`User` JOIN `Database` ON `Database`.`Id` = `Server`.`Database` JOIN `Emulator` ON `Emulator`.`Id` = `Database`.`Emulator` JOIN `ClientVersion` ON `ClientVersion`.`Id` = `Emulator`.`ClientVersion`'); 16 while($DbRow = $DbResult->fetch_assoc()) 16 17 { 17 $Output .= '<tr><td>'.$Server['Name'].'</td><td>'.$Server['UserName'].'</td><td>'.$this->System->Config['Web']['Host'].':'.$Server['NetworkPortRealmd'].'</td><td>'.$Server['Version'].'</td></tr>'; 18 $Server = new Server($this->Database, $DbRow['Id']); 19 $ServerState = $Server->GetState(); 20 $Output .= '<tr><td><a href="?Action=ServerShow&Id='.$DbRow['Id'].'">'.$DbRow['Name'].'</a></td><td>'.$DbRow['UserName'].'</td><td>'.$this->System->Config['Web']['Host'].':'.$DbRow['NetworkPortRealmd'].'</td><td>'.$DbRow['Version'].'</td><td>'.$OnlineState[$ServerState['Online']].'</td><td>'.$ServerState['OnlinePlayerCount'].'</td><td>'.$ServerState['AccountCount'].'</td><td>'.$ServerState['CharacterCount'].'</td></tr>'; 18 21 } 19 22 $Output .= '</table>'; 23 if($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER) $Output .= '<br /><div style="text-align: center;"><a href="?Action=ServerAdd">Vytvořit nový server</a></dev>'; 20 24 return($Output); 21 25 } … … 27 31 $Output .= '<table class="WideTable"><tr><th>Položka</th><th>Hodnota</th></tr>'; 28 32 $Output .= '<tr><td>Jméno</td><td>'.$Server->Server['Name'].'</td></tr>'. 33 '<tr><td>Webové stránky</td><td><a href="'.$Server->Server['Homepage'].'">'.$Server->Server['Homepage'].'</a></td></tr>'. 34 '<tr><td>Popis</td><td>'.$Server->Server['Description'].'</td></tr>'. 29 35 '<tr><td>Zpráva dne</td><td>'.$Server->Server['Motd'].'</td></tr>'. 30 36 '<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 $Output .= '</table>'; 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 37 '<tr><td>Síťový port mangosd</td><td>'.($Server->WorlddBaseNetworkPort + $Server->Id).'</td></tr>'; 38 $Output .= '</table><div style="text-align: center">'; 39 if($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER) 40 { 41 $Output .= '<br /><a href="'.$this->System->Config['Web']['Host'].'/mysql/">Správa databáze</a> '; 42 if(array_key_exists('Id', $Server->Server['Database'])) 43 { 44 $ServerStatus = $Server->GetState(); 45 if($ServerStatus['RealmdPortState'] == true) $Output .= ' <a href="?Action=ServerStop">Zastavit server</a> <a href="?Action=ServerRestart">RestartovatServer</a>'; 46 else $Output .= ' <a href="?Action=ServerStart">Spustit server</a>'; 47 } 48 $Output .= ' <a href="?Action=ServerEdit">Upravit server</a>'; 49 $Output .= ' <a href="?Action=ServerDatabaseImport">Načtení čisté databáze</a>'; 50 } 51 $Output .= '</div>'; 40 52 return($Output); 41 53 } … … 127 139 $Form = new Form('UserRegister', array()); 128 140 $Form->LoadValuesFromForm(); 129 $Result = $this->System->Modules['User']->Register($Form->Values['Login'], $Form->Values['Password'], $Form->Values['Password2'], $Form->Values['Email'], $Form->Values['Name'] , $Form->Values['PhoneNumber'], $Form->Values['ICQ']);141 $Result = $this->System->Modules['User']->Register($Form->Values['Login'], $Form->Values['Password'], $Form->Values['Password2'], $Form->Values['Email'], $Form->Values['Name']); 130 142 $Output .= $this->SystemMessage('Registrace nového účtu', $Result); 131 143 if($Result <> USER_REGISTRATED) … … 173 185 if($_GET['Action'] == 'ServerAdd') 174 186 { 175 $Form = new Form('NewServer'); 176 $Form->LoadValuesFromForm(); 177 $Form->OnSubmit = '?Action=ServerCreate'; 178 $Output .= $Form->ShowEditForm(); 187 if($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER) 188 { 189 $DbResult = $this->Database->query('SELECT COUNT(*) FROM Server WHERE User='.$this->System->Modules['User']->User['Id']); 190 $DbRow = $DbResult->fetch_row(); 191 if($DbRow[0] > 0) $Output .= $this->SystemMessage('Nový server', 'Lze vytvořit pouze jeden server pro každý uživatelský účet.'); 192 else 193 { 194 $Form = new Form('NewServer'); 195 $Form->LoadValuesFromForm(); 196 $Form->OnSubmit = '?Action=ServerCreate'; 197 $Output .= 'Tento formulář vám umožní si vytvořit nový server. Pečlivě vyplňte požadované údaje.'; 198 $Output .= $Form->ShowEditForm(); 199 } 200 } else $Output .= USER_BAD_ROLE; 179 201 } else 180 202 if($_GET['Action'] == 'ServerCreate') 181 203 { 182 $UserOptions = new Form('NewServer', array()); 183 $UserOptions->LoadValuesFromForm(); 184 $Output .= $this->SystemMessage('Nový server', 'Server vytvořen.'); 185 //$UserOptions->LoadValuesFromDatabase($this->System->Modules['User']->User['Id']); 186 $UserOptions->OnSubmit = '?Action=ServerCreate'; 187 $Output .= $UserOptions->ShowEditForm(); 204 if($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER) 205 { 206 $DbResult = $this->Database->query('SELECT COUNT(*) FROM Server WHERE User='.$this->System->Modules['User']->User['Id']); 207 $DbRow = $DbResult->fetch_row(); 208 if($DbRow[0] > 0) $Output .= $this->SystemMessage('Nový server', 'Lze vytvořit pouze jeden server pro každý uživatelský účet.'); 209 else 210 { 211 $Form = new Form('NewServer', array()); 212 $Form->LoadValuesFromForm(); 213 $this->Database->insert('Server', array('Name' => $Form->Values['Name'], 'Description' => $Form->Values['Description'], 'User' => $this->System->Modules['User']->User['Id'], 'Motd' => $Form->Values['Motd'], 'Homepage' => $Form->Values['Homepage'], 'Type' => $Form->Values['Type'], 'Database' => 1)); 214 $LastInsertId = $this->Database->insert_id; 215 $Server = new Server($this->Database, $LastInsertId); 216 $Server->CreateDatabase(); 217 $Output .= $this->SystemMessage('Nový server', 'Server vytvořen.'); 218 //$UserOptions->LoadValuesFromDatabase($this->System->Modules['User']->User['Id']); 219 //$Form->OnSubmit = '?Action=ServerCreate'; 220 //$Output .= $Form->ShowEditForm(); 221 } 222 } else $Output .= USER_BAD_ROLE; 188 223 } else 189 224 if($_GET['Action'] == 'ServerShow') 190 225 { 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']); 226 if(array_key_exists('Id', $_GET)) $Output .= $this->ShowServer($_GET['Id']); 227 else 228 { 229 $DbResult = $this->Database->query('SELECT Id FROM Server WHERE User='.$this->System->Modules['User']->User['Id']); 230 $Server = $DbResult->fetch_assoc(); 231 $Output .= $this->ShowServer($Server['Id']); 232 } 194 233 } else 195 234 if($_GET['Action'] == 'ServerEdit') 196 235 { 197 $Form = new Form('EditServer'); 198 $Form->LoadValuesFromForm(); 199 $Form->OnSubmit = '?Action=ServerSave'; 200 $Output .= $Form->ShowEditForm(); 236 if($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER) 237 { 238 $DbResult = $this->Database->query('SELECT Id FROM Server WHERE User='.$this->System->Modules['User']->User['Id']); 239 $Server = $DbResult->fetch_assoc(); 240 $Form = new Form('EditServer'); 241 $Form->LoadValuesFromDatabase($Server['Id']); 242 $Form->OnSubmit = '?Action=ServerSave'; 243 $Output .= $Form->ShowEditForm(); 244 } else $Output .= USER_BAD_ROLE; 201 245 } else 202 246 if($_GET['Action'] == 'ServerSave') 203 247 { 204 $UserOptions = new Form('EditServer', array()); 205 $UserOptions->LoadValuesFromForm(); 206 $Output .= $this->SystemMessage('Upravit server', 'Nastavení serveru uloženo.'); 207 $UserOptions->LoadValuesFromDatabase($this->System->Modules['User']->User['Id']); 208 $UserOptions->OnSubmit = '?Action=ServerSave'; 248 if($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER) 249 { 250 $DbResult = $this->Database->query('SELECT Id FROM Server WHERE User='.$this->System->Modules['User']->User['Id']); 251 $Server = $DbResult->fetch_assoc(); 252 $UserOptions = new Form('EditServer', array()); 253 $UserOptions->LoadValuesFromForm(); 254 $Output .= $this->SystemMessage('Upravit server', 'Nastavení serveru uloženo.'); 255 $UserOptions->SaveValuesToDatabase($Server['Id']); 256 $UserOptions->OnSubmit = '?Action=ServerSave'; 209 257 210 $DbResult = $this->Database->query('SELECT Id FROM Server WHERE User='.$this->System->Modules['User']->User['Id']); 211 $Server = $DbResult->fetch_assoc(); 212 $Server = new Server($this->Database, $Server['Id']); 213 $Server->SetupConfigurationFiles(); 214 215 $Output .= $UserOptions->ShowEditForm(); 258 $Server = new Server($this->Database, $Server['Id']); 259 $Server->SaveConfiguration(); 260 261 $Output .= $UserOptions->ShowEditForm(); 262 } else $Output .= USER_BAD_ROLE; 216 263 } else 217 264 if($_GET['Action'] == 'ServerStart') 218 265 { 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()); 266 if($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER) 267 { 268 $DbResult = $this->Database->query('SELECT Id FROM Server WHERE User='.$this->System->Modules['User']->User['Id']); 269 $Server = $DbResult->fetch_assoc(); 270 $Server = new Server($this->Database, $Server['Id']); 271 $Output .= $this->SystemMessage('Spuštění serveru', $Server->Start()); 272 } else $Output .= USER_BAD_ROLE; 223 273 } else 224 274 if($_GET['Action'] == 'ServerStop') 225 275 { 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()); 276 if($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER) 277 { 278 $DbResult = $this->Database->query('SELECT Id FROM Server WHERE User='.$this->System->Modules['User']->User['Id']); 279 $Server = $DbResult->fetch_assoc(); 280 $Server = new Server($this->Database, $Server['Id']); 281 $Output .= $this->SystemMessage('Zastavení serveru', $Server->Stop()); 282 } else $Output .= USER_BAD_ROLE; 283 } else 284 if($_GET['Action'] == 'ServerDatabaseImport') 285 { 286 if($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER) 287 { 288 $DbResult = $this->Database->query('SELECT Id FROM Server WHERE User='.$this->System->Modules['User']->User['Id']); 289 $Server = $DbResult->fetch_assoc(); 290 $Server = new Server($this->Database, $Server['Id']); 291 $Server->ImportDatabase(true); 292 $Output .= $this->SystemMessage('Import čisté databáze', 'Úloha zařazena do fronty'); 293 } else $Output .= USER_BAD_ROLE; 230 294 } else 231 295 if($_GET['Action'] == 'Test') 232 296 { 297 $Emulator = new Emulator($this->Database, 2); 298 $Emulator->Compile(); 233 299 //$Server = new Server($this->Database, 1); 234 300 //$Output .= $Server->ImportDatabase(); 235 $Config = new MangosConfigurationFile($this->Database);236 $Config->Load('../emu/mangos/7681/etc/mangosd.conf');237 $Config->Save('../server/1/etc/mangosd.conf');301 //$Config = new MangosConfigurationFile($this->Database); 302 //$Config->Load('../emu/mangos/7681/etc/mangosd.conf'); 303 //$Config->Save('../server/1/etc/mangosd.conf'); 238 304 } else 239 305 { 240 306 $Output = $this->ShowServerList(); 241 $Output .= '<br /><a href="?Action=ServerAdd">Nový server</a>';242 307 } 243 308 } else 244 309 { 245 310 $Output = $this->ShowServerList(); 246 $Output .= '<br /><a href="?Action=ServerAdd">Nový server</a>';247 311 } 248 312 return($Output);
Note:
See TracChangeset
for help on using the changeset viewer.