Changeset 11 for trunk/www/index.php
- Timestamp:
- Jun 11, 2009, 8:28:50 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/www/index.php
r10 r11 8 8 var $ShortTitle = 'Seznam serverů'; 9 9 10 function ShowServerListOnRow($Row) 11 { 12 $Server = new Server($this->Database, $Row['Id']); 13 $ServerState = $Server->GetState(); 14 $Row['Online'] = $ServerState['Online'] * 1; 15 $Row['NetworkPortRealmd'] = $this->System->Config['Web']['Host'].':'.$Row['NetworkPortRealmd']; 16 $Row['Name'] = '<a href="?Action=ServerShow&Id='.$Row['Id'].'">'.$Row['Name'].'</a>'; 17 $Row['AccountCount'] = $ServerState['AccountCount']; 18 $Row['CharacterCount'] = $ServerState['CharacterCount']; 19 $Row['OnlinePlayerCount'] = $ServerState['OnlinePlayerCount']; 20 return($Row); 21 } 22 10 23 function ShowServerList() 11 24 { 12 25 global $Config; 13 26 14 $OnlineState = array(false => 'Neaktivní', true => 'Aktivní');15 27 $Output = '<h4>Seznam serverů</h4>'; 16 $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>'; 17 $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`'); 18 while($DbRow = $DbResult->fetch_assoc()) 19 { 20 $Server = new Server($this->Database, $DbRow['Id']); 21 $ServerState = $Server->GetState(); 22 $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>'; 23 } 24 $Output .= '</table>'; 28 $Table = new Table('ServerList'); 29 $Table->OnRow = array($this, 'ShowServerListOnRow'); 30 $Table->LoadValuesFromDatabase($this->Database); 31 $Output .= $Table->Show(); 25 32 if($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER) 26 33 { … … 28 35 $DbRow = $DbResult->fetch_row(); 29 36 $ServerCount = $DbRow[0]; 30 if($ServerCount < $Config['MaxServerCount']) 37 $DbResult = $this->Database->query('SELECT COUNT(*) FROM Server WHERE User='.$this->System->Modules['User']->User['Id']); 38 $DbRow = $DbResult->fetch_row(); 39 if(($ServerCount < $Config['MaxServerCount']) and ($DbRow[0] == 0)) 31 40 $Output .= '<br /><div style="text-align: center;"><a href="?Action=ServerAdd">Vytvořit nový server</a></dev>'; 32 41 } … … 41 50 $Form->LoadValuesFromDatabase($Id); 42 51 $Output .= $Form->ShowTable(); 43 /*44 $Output .= '<table class="WideTable"><tr><th>Položka</th><th>Hodnota</th></tr>';45 $Output .= '<tr><td>Jméno</td><td>'.$Server->Server['Name'].'</td></tr>'.46 '<tr><td>Webové stránky</td><td><a href="'.$Server->Server['Homepage'].'">'.$Server->Server['Homepage'].'</a></td></tr>'.47 '<tr><td>Popis</td><td>'.$Server->Server['Description'].'</td></tr>'.48 '<tr><td>Zpráva dne</td><td>'.$Server->Server['Motd'].'</td></tr>'.49 '<tr><td>Síťový port realmd</td><td>'.($Server->RealmdBaseNetworkPort + $Server->Id).'</td></tr>'.50 '<tr><td>Síťový port mangosd</td><td>'.($Server->WorlddBaseNetworkPort + $Server->Id).'</td></tr>';51 $Output .= '</table>52 */53 52 $Output .= '<div style="text-align: center">'; 54 53 if(($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER) and ($this->System->Modules['User']->User['Id'] == $Server->Server['User'])) … … 58 57 { 59 58 $ServerStatus = $Server->GetState(); 60 if($ServerStatus['RealmdPortState'] == true) $Output .= ' <a href="?Action=ServerStop">Zastavit server</a> <a href="?Action=ServerRestart">RestartovatServer</a>';61 else $Output .= ' <a href="?Action=ServerStart">Spustit server</a>';59 if($ServerStatus['RealmdPortState'] == true) $Output .= ' <a href="?Action=ServerStop">Zastavit</a> <a href="?Action=ServerRestart">Restartovat</a>'; 60 else $Output .= ' <a href="?Action=ServerStart">Spustit</a>'; 62 61 } 63 $Output .= ' <a href="?Action=ServerEdit">Upravit server</a>';62 $Output .= ' <a href="?Action=ServerEdit">Upravit</a>'; 64 63 $Output .= ' <a href="?Action=ServerDatabaseImport">Načtení čisté databáze</a>'; 65 64 } … … 68 67 } 69 68 69 function ShowEmulatorListOnRow($Row) 70 { 71 $Row['Name'] = '<a href="?Action=EmulatorShow&Id='.$Row['Id'].'">'.$Row['Name'].'</a>'; 72 return($Row); 73 } 74 75 function ShowEmulatorList() 76 { 77 global $Config; 78 79 $Output = '<h4>Seznam verzí emulátoru</h4>'; 80 $Table = new Table('EmulatorList'); 81 $Table->OnRow = array($this, 'ShowEmulatorListOnRow'); 82 $Table->LoadValuesFromDatabase($this->Database); 83 $Output .= $Table->Show(); 84 if($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR) 85 { 86 $Output .= '<br /><div style="text-align: center;"><a href="?Action=EmulatorAdd">Přidat emulátor</a></dev>'; 87 } 88 return($Output); 89 } 90 91 function EmulatorShow($Id) 92 { 93 //$Server = new Server($this->Database, $Id); 94 $Output = '<h4>Podrobnosti emulátoru</h4>'; 95 $Form = new Form('EmulatorItem'); 96 $Form->LoadValuesFromDatabase($Id); 97 $Output .= $Form->ShowTable(); 98 $Output .= '<div style="text-align: center">'; 99 if($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR) 100 { 101 $Output .= ' <a href="?Action=EmulatorCompile&Id='.$Id.'">Přeložit</a>'; 102 $Output .= ' <a href="?Action=EmulatorDownloadAndCompile&Id='.$Id.'">Stáhnout a přeložit</a>'; 103 } 104 $Output .= '</div>'; 105 return($Output); 106 } 107 70 108 function Show() 71 109 { 110 global $Config; 111 72 112 $Output = ''; 73 113 if(array_key_exists('Action', $_GET)) … … 278 318 } else $Output .= USER_BAD_ROLE; 279 319 } else 320 if($_GET['Action'] == 'EmulatorShow') 321 { 322 if(array_key_exists('Id', $_GET)) 323 { 324 $Output .= $this->EmulatorShow($_GET['Id']); 325 } else $Output .= $this->SystemMessage('Překlad emulátoru', 'Nebylo zadáno Id'); 326 } else 327 if($_GET['Action'] == 'EmulatorList') 328 { 329 $Output .= $this->ShowEmulatorList(); 330 } else 331 if($_GET['Action'] == 'EmulatorCompile') 332 { 333 if(array_key_exists('Id', $_GET)) 334 { 335 $Emulator = new Emulator($this->Database, $_GET['Id']); 336 $Emulator->Compile(); 337 $Output .= $this->SystemMessage('Překlad emulátoru', 'Úloha zařazena do fronty'); 338 } else $Output .= $this->SystemMessage('Překlad emulátoru', 'Nebylo zadáno Id'); 339 } else 280 340 if($_GET['Action'] == 'Test') 281 341 { 282 $Emulator = new Emulator($this->Database, 2);283 $Emulator->Compile();342 //$Emulator = new Emulator($this->Database, 2); 343 // $Emulator->Compile(); 284 344 //$Server = new Server($this->Database, 1); 285 345 //$Output .= $Server->ImportDatabase();
Note:
See TracChangeset
for help on using the changeset viewer.