Changeset 55
- Timestamp:
- Aug 3, 2009, 11:39:13 PM (15 years ago)
- Location:
- trunk/www
- Files:
-
- 13 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/www/common/global.php
r54 r55 94 94 } 95 95 96 function SystemMessage($Title, $Text) 97 { 98 return('<table align="center"><tr><td><div class="SystemMessage"><h3>'.$Title.'</h3><div>'.$Text.'</div></div</td></tr></table>'); 99 //ShowFooter(); 100 //die(); 101 } 102 96 103 function MailUTF8($To, $Subject = '(No subject)', $Message = '', $Header = '') 97 104 { -
trunk/www/common/module.php
r54 r55 9 9 var $CurrentPath = '/'; 10 10 11 function __construct( )11 function __construct($Database, $System) 12 12 { 13 $this->Database = $Database; 14 $this->System = $System; 13 15 } 14 16 } -
trunk/www/common/page.php
r54 r55 4 4 { 5 5 var $TimeStart; 6 7 function SystemMessage($Title, $Text)8 {9 return('<table align="center"><tr><td><div class="SystemMessage"><h3>'.$Title.'</h3><div>'.$Text.'</div></div</td></tr></table>');10 //ShowFooter();11 //die();12 }13 6 14 7 function ShowHeader($Title, $Path) … … 20 13 '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'. 21 14 '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cs" lang="cs">'. 22 '<head><link rel="stylesheet" href="'.$this->System->Config['Web']['RootFolder'].'/style .css" type="text/css" media="all" />'.23 24 '<script type="text/javascript" src="'.$this->System->Config['Web']['RootFolder'].'/ global.js"></script>'.15 '<head><link rel="stylesheet" href="'.$this->System->Config['Web']['RootFolder'].'/style/style.css" type="text/css" media="all" />'. 16 '<meta http-equiv="content-type" content="application/xhtml+xml; charset='.$this->System->Config['Web']['Charset'].'" />'. 17 '<script type="text/javascript" src="'.$this->System->Config['Web']['RootFolder'].'/style/global.js"></script>'. 25 18 '<title>'.$this->System->Config['Web']['Title'].' - '.$Path.'</title> 26 19 </head><body'.$BodyParam.'>'. … … 33 26 $Output .= '</span><div class="MenuItem2">'; 34 27 if($this->System->Modules['User']->User['Id'] == $this->System->Modules['User']->AnonymousUserId) 35 $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>'; 36 else $Output .= $this->System->Modules['User']->User['Name'].' <a href="'.$this->System->Config['Web']['RootFolder'].'/?Action=Logout">Odhlásit</a>'. 28 { 29 $Output .= '<a href="'.$this->System->Config['Web']['RootFolder'].'/?Action=LoginForm">Přihlášení</a>'; 30 if($this->System->Config['Web']['UserRegistrationEnabled']) $Output .= ' <a href="'.$this->System->Config['Web']['RootFolder'].'/?Action=UserRegister">Registrace</a>'; 31 } else $Output .= $this->System->Modules['User']->User['Name'].' <a href="'.$this->System->Config['Web']['RootFolder'].'/?Action=Logout">Odhlásit</a>'. 37 32 ' <a href="'.$this->System->Config['Web']['RootFolder'].'/?Action=UserOptions">Nastavení</a>'; 38 33 $Output .= '</div></div>'; … … 42 37 function ShowFooter() 43 38 { 44 39 global $ScriptTimeStart; 45 40 46 41 $Time = round(GetMicrotime() - $ScriptTimeStart, 2); … … 52 47 ' | E-mail: '.$this->System->Config['Web']['AdminEmail']; 53 48 if($this->System->Config['Web']['ShowRuntimeInfo'] == true) $Output .= ' Doba generování: '.$Time.' s / '.ini_get('max_execution_time').' s | Použitá paměť: '.HumanSize(memory_get_peak_usage(FALSE)).' / '.ini_get('memory_limit').'B |'; 54 49 $Output .= '</i></div></body></html>'; 55 50 return($Output); 56 51 } … … 78 73 { 79 74 $Start = strpos($Text, '<'); 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 75 $End = strpos($Text, '>'); 76 if($Start != 0) 77 { 78 $End = $Start - 1; 79 $Start = 0; 80 } 81 $Line = trim(substr($Text, $Start, $End + 1)); 82 if(strlen($Line) > 0) 83 if($Line[0] == '<') 84 { 85 if($Text[$Start + 1] == '/') 86 { 87 $IndentNew = $IndentNew - $Indentation; 88 $Indent = $IndentNew; 89 } else 90 { 91 if(strpos($Line, ' ')) $Command = substr($Line, 1, strpos($Line, ' ') - 1); 92 else $Command = substr($Line, 1, strlen($Line) - $Indentation); 93 if(strpos($Text, '</'.$Command.'>')) $IndentNew = $IndentNew + $Indentation; 94 } 95 } 96 if($Line != '') $Output .= (str_repeat(' ', $Indent).$Line."\n"); 97 $Text = substr($Text, $End + 1, strlen($Text)); 98 $Indent = $IndentNew; 104 99 } 105 100 return($Output); -
trunk/www/config.sample.php
r54 r55 28 28 'ErrorLogFile' => 'php_script_error.log', 29 29 'TableRowPerPage' => 30, 30 'UserRegistrationEnabled' => false, 30 31 ), 31 32 'BaseDir' => '/opt/wowhosting/', -
trunk/www/include.php
r54 r55 2 2 3 3 include('config.php'); 4 4 5 include('types/include.php'); 6 5 7 include('common/database.php'); 6 8 include('common/module.php'); … … 12 14 include('common/form.php'); 13 15 include('common/table.php'); 16 14 17 include('model/user.php'); 15 18 include('model/server.php'); … … 23 26 include('model/history.php'); 24 27 28 include('view/user.php'); 29 include('view/server.php'); 30 include('view/realm.php'); 31 include('view/emulator.php'); 32 include('view/task.php'); 33 include('view/backup.php'); 34 include('view/update.php'); 35 include('view/database.php'); 36 include('view/base.php'); 37 include('view/news.php'); 38 include('view/client.php'); 39 include('view/debug.php'); 40 25 41 ?> -
trunk/www/index.php
r54 r55 15 15 $Database->charset($Config['Database']['Charset']); 16 16 17 $System = new System( );17 $System = new System($Database, null); 18 18 $System->Config = $Config; 19 $System->Database = &$Database; 20 $System->AddModule(new Log()); 21 $System->AddModule(new User()); 19 $System->AddModule(new Log($Database, $System)); 20 $System->AddModule(new User($Database, $System)); 22 21 if(isset($_SERVER['REMOTE_ADDR'])) $System->Modules['User']->Check(); 23 22 else $System->Modules['User']->User['Id'] = 0; … … 26 25 { 27 26 var $FullTitle = 'Seznam serverů'; 28 var $ShortTitle = 'Seznam serverů'; 29 30 function ShowServerListOnRow($Row) 31 { 32 $Row['NetworkPortRealmd'] = '<a href="realmlist.php?Id='.$Row['Id'].'">'.$Row['NetworkPortRealmd'].'</a>'; 33 if($Row['Homepage'] != '') $Row['Name'] = '<a href="'.$Row['Homepage'].'">'.$Row['Name'].'</a>'; 34 unset($Row['Homepage']); 35 return($Row); 36 } 37 38 function ShowServerList() 39 { 40 global $Config; 41 42 $Server = new Server($this->Database, 0); 43 $Server->UpdateServerList(); 44 $Output = '<h4>Seznam serverů</h4>'; 45 $Table = new Table('ServerList'); 46 $Table->OnRow = array($this, 'ShowServerListOnRow'); 47 $Table->Definition['Items']['Id'] = array('Type' => 'Hidden', 'Caption' => '', 'Default' => ''); 48 $Table->LoadValuesFromDatabase($this->Database); 49 $Table->Definition['Items']['Actions'] = array('Type' => 'String', 'Caption' => '', 'Default' => ''); 50 foreach($Table->Values as $Index => $Item) 51 { 52 $Table->Values[$Index]['Actions'] = '<a href="?Action=ServerShow&Id='.$Item['Id'].'">Podrobnosti</a>'; 53 unset($Table->Values[$Index]['Id']); 54 } 55 $Output .= $Table->Show(); 56 if($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER) 57 { 58 $DbResult = $this->Database->query('SELECT COUNT(*) FROM Server'); 59 $DbRow = $DbResult->fetch_row(); 60 $ServerCount = $DbRow[0]; 61 $DbResult = $this->Database->query('SELECT COUNT(*) FROM Server WHERE User='.$this->System->Modules['User']->User['Id']); 62 $DbRow = $DbResult->fetch_row(); 63 if(($ServerCount < $Config['MaxServerCount']) and ($DbRow[0] == 0)) 64 $Output .= '<br /><div style="text-align: center;"><a href="?Action=ServerAdd">Vytvořit nový server</a></dev>'; 65 } 66 return($Output); 67 } 68 69 function ShowServer($Id) 70 { 71 global $Config; 72 73 $Server = new Server($this->Database, $Id); 74 if(isset($Server->Server)) 75 { 76 $Output = '<h4>Podrobnosti serveru</h4>'; 77 $Form = new Form('ServerView'); 78 $Form->LoadValuesFromDatabase($Id); 79 $Form->Definition['Items']['Realmlist'] = array('Type' => 'String', 'Caption' => 'Adresa k připojení', 'Default' => ''); 80 $Form->Definition['Items']['Uptime'] = array('Type' => 'String', 'Caption' => 'Doba běhu', 'Default' => ''); 81 $Form->Definition['Items']['UsedMemory'] = array('Type' => 'String', 'Caption' => 'Použitá paměť', 'Default' => ''); 82 $Form->Definition['Items']['AccountCount'] = array('Type' => 'String', 'Caption' => 'Počet účtů', 'Default' => ''); 83 $ServerStatus = $Server->GetState(); 84 $Form->Values['Realmlist'] = $Config['Web']['Host'].':'.$Form->Values['NetworkPortRealmd']; 85 unset($Form->Definition['Items']['NetworkPortRealmd']); 86 $Form->Values['Uptime'] = $this->System->AddPrefixMultipliers($ServerStatus['Uptime'], '', 4, 'Time'); 87 $Form->Values['UsedMemory'] = $this->System->AddPrefixMultipliers($ServerStatus['UsedMemory'] * 1024, 'B', 4, 'Binary'); 88 $Form->Values['AccountCount'] = $ServerStatus['AccountCount']; 89 $Output .= $Form->ShowTable(); 90 $Output .= '<div style="text-align: center">'; 91 if((($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER) and ($this->System->Modules['User']->User['Id'] == $Server->Server['User'])) or ($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR)) 92 { 93 $Output .= '<br /><a href="http://'.$this->System->Config['Web']['Host'].'/mysql/">Správa databáze</a> '; 94 if(array_key_exists('Id', $Server->Server['Database']) and ($Server->Server['Lock'] == 0)) 95 { 96 if($ServerStatus['RealmdPortState'] == true) $Output .= ' <a href="?Action=ServerStop&Id='.$Server->Id.'">Zastavit</a> <a href="?Action=ServerRestart&Id='.$Server->Id.'">Restartovat</a>'; 97 else $Output .= ' <a href="?Action=ServerStart&Id='.$Server->Id.'">Spustit</a>'; 98 } 99 if($Server->Server['Lock'] == 0) 100 { 101 $Output .= ' <a href="?Action=ServerEdit&Id='.$Server->Id.'">Upravit základní nastavení</a>'; 102 $Output .= ' <a href="?Action=ServerEditDetailed&Id='.$Server->Id.'">Upravit podrobné nastavení</a>'; 103 } 104 //$Output .= ' <a href="?Action=ServerDatabaseImport&Id='.$Server->Id.'">Načtení čisté databáze</a>'; 105 } 106 $Output .= ' <a href="?Action=GameAccountRegister&Id='.$Server->Id.'">Vytvoření herního účtu</a>'; 107 $Output .= '</div>'; 108 } else $Output = $this->SystemMessage('Zobrazení serveru', 'Server se zadaným id nenalezen.'); 109 return($Output); 110 } 111 112 function ShowEmulatorList() 113 { 114 global $Config; 115 116 $Output = '<h4>Seznam verzí emulátoru</h4>'; 117 $Table = new Table('EmulatorList'); 118 $Table->Definition['Items']['Id'] = array('Type' => 'Hidden', 'Caption' => '', 'Default' => ''); 119 $Table->LoadValuesFromDatabase($this->Database); 120 $Table->Definition['Items']['Actions'] = array('Type' => 'String', 'Caption' => '', 'Default' => ''); 121 foreach($Table->Values as $Index => $Item) 122 { 123 $Table->Values[$Index]['Actions'] = '<a href="?Action=EmulatorShow&Id='.$Item['Id'].'">Podrobnosti</a>'; 124 unset($Table->Values[$Index]['Id']); 125 } 126 $Output .= $Table->Show(); 127 if($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR) 128 { 129 $Output .= '<br /><div style="text-align: center;"><a href="?Action=EmulatorAdd">Přidat emulátor</a></dev>'; 130 } 131 return($Output); 132 } 133 134 function ShowUpdateList($ServerId) 135 { 136 global $Config; 137 138 if($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER) 139 { 140 $Server = new Server($this->Database, $_GET['Id']); 141 if(($this->System->Modules['User']->User['Id'] == $Server->Server['User']) or ($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR)) 142 { 143 $Server = new Server($this->Database, $ServerId); 144 $Output = '<h4>Seznam dostupných aktulizací</h4>'; 145 $Output .= 'Před provedením aktualizace bude server zastaven a provedena záloha databáze.'; 146 $Table = new Table('EmulatorList'); 147 $Table->Definition['Table'] = substr($Table->Definition['Table'], 0, -1).' AND `Emulator`.`Revision` > '.$Server->Server['Database']['Emulator']['Revision'].' ORDER BY `Revision`)'; 148 $Table->Definition['Items']['Id'] = array('Type' => 'Hidden', 'Caption' => '', 'Default' => ''); 149 $Table->LoadValuesFromDatabase($this->Database); 150 $Table->Definition['Items']['Actions'] = array('Type' => 'String', 'Caption' => '', 'Default' => ''); 151 foreach($Table->Values as $Index => $Item) 152 { 153 $Table->Values[$Index]['Actions'] = '<a href="?Action=EmulatorShow&Id='.$Item['Id'].'">Podrobnosti</a>'; 154 if($Server->Server['Lock'] == 0) $Table->Values[$Index]['Actions'] .= ' <a href="?Action=Update&Server='.$ServerId.'&Update='.$Item['Id'].'">Aktualizovat</a>'; 155 unset($Table->Values[$Index]['Id']); 156 } 157 $Output .= $Table->Show(); 158 } else $this->SystemMessage('Dostupné aktualizace', 'Nemáte oprávnění'); 159 } else $Output = USER_BAD_ROLE; 160 return($Output); 161 } 162 163 function EmulatorShow($Id) 164 { 165 //$Server = new Server($this->Database, $Id); 166 $Output = '<h4>Podrobnosti emulátoru</h4>'; 167 $Form = new Form('EmulatorItem'); 168 $Form->LoadValuesFromDatabase($Id); 169 $Output .= $Form->ShowTable(); 170 $Output .= '<div style="text-align: center">'; 171 $Emulator = new Emulator($this->Database, $Id); 172 if($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR) 173 { 174 if($Emulator->Emulator['Lock'] == 0) $Output .= ' <a href="?Action=EmulatorDownload&Id='.$Id.'">Stáhnout</a>'; 175 if($Emulator->Emulator['Lock'] == 0) $Output .= ' <a href="?Action=EmulatorCompile&Id='.$Id.'">Přeložit</a>'; 176 } 177 $Output .= '</div>'; 178 return($Output); 179 } 180 181 function ShowBackupListOnRow($Row) 182 { 183 //$Row['Name'] = '<a href="?Action=EmulatorShow&Id='.$Row['Id'].'">'.$Row['Name'].'</a>'; 184 return($Row); 185 } 186 187 function ShowBackupList($ServerId) 188 { 189 global $Config; 190 191 if($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER) 192 { 193 $Server = new Server($this->Database, $_GET['Id']); 194 if(($this->System->Modules['User']->User['Id'] == $Server->Server['User']) or ($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR)) 195 { 196 $Output = '<h4>Dostupné zálohy</h4>'; 197 $Table = new Table('BackupList'); 198 $Table->OnRow = array($this, 'ShowBackupListOnRow'); 199 $Table->Definition['Table'] = '(SELECT * FROM `Backup` WHERE `Server` = '.$Server->Id.')'; 200 $Table->Definition['Items']['Id'] = array('Type' => 'Hidden', 'Caption' => 'Id', 'Default' => ''); 201 $Table->Definition['Items']['Lock'] = array('Type' => 'Hidden', 'Caption' => 'Zámek', 'Default' => ''); 202 $Table->LoadValuesFromDatabase($this->Database); 203 $Table->Definition['Items']['Actions'] = array('Type' => 'String', 'Caption' => '', 'Default' => ''); 204 foreach($Table->Values as $Index => $Value) 205 { 206 $Table->Values[$Index]['Actions'] = ''; 207 if($Value['Lock'] == 0) $Table->Values[$Index]['Actions'] = '<a href="?Action=BackupDownload&Id='.$Value['Id'].'">Stáhnout</a>'; 208 if(($Server->Server['Lock'] == 0) and ($Value['Lock'] == 0)) $Table->Values[$Index]['Actions'] .= ' <a href="?Action=BackupRestore&Id='.$Value['Id'].'">Obnovit</a>'; 209 unset($Table->Values[$Index]['Id']); 210 unset($Table->Values[$Index]['Lock']); 211 } 212 $Output .= $Table->Show(); 213 if($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR) 214 { 215 if($Server->Server['Lock'] == 0) $Output .= '<br /><div style="text-align: center;"><a href="?Action=BackupAdd&Id='.$ServerId.'">Zálohovat</a></dev>'; 216 } 217 } else $Output = $this->SystemMessage('Zastavení serveru', 'Nemáte oprávnění'); 218 } else $Output = USER_BAD_ROLE; 219 return($Output); 220 } 221 222 function ShowRealmList() 223 { 224 global $Config; 225 226 $Realm = new Realm($this->Database, 0); 227 //$Realm->UpdateServerList(); 228 $Output = '<h4>Seznam světů</h4>'; 229 $Table = new Table('RealmList'); 230 //$Table->OnRow = array($this, 'ShowRealmListOnRow'); 231 $Table->Definition['Items']['Id'] = array('Type' => 'Hidden', 'Caption' => '', 'Default' => ''); 232 $Table->LoadValuesFromDatabase($this->Database); 233 $Table->Definition['Items']['Actions'] = array('Type' => 'String', 'Caption' => '', 'Default' => ''); 234 foreach($Table->Values as $Index => $Item) 235 { 236 $Table->Values[$Index]['Actions'] = '<a href="?Action=RealmShow&Id='.$Item['Id'].'">Podrobnosti</a>'; 237 unset($Table->Values[$Index]['Id']); 238 } 239 $Output .= $Table->Show(); 240 if($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER) 241 { 242 $DbResult = $this->Database->query('SELECT COUNT(*) FROM Realm'); 243 $DbRow = $DbResult->fetch_row(); 244 $RealmCount = $DbRow[0]; 245 //$DbResult = $this->Database->query('SELECT COUNT(*) FROM Realm WHERE Server='.$this->System->Modules['User']->User['Id']); 246 //$DbRow = $DbResult->fetch_row(); 247 if(($RealmCount < $Config['MaxRealmPerServerCount'])) 248 $Output .= '<br /><div style="text-align: center;"><a href="?Action=RealmAdd">Vytvořit nový svět</a></dev>'; 249 } 250 return($Output); 251 } 252 253 function ShowClientListOnRow($Row) 254 { 255 $Row['Version'] = '<a href="http://www.wowwiki.com/Patch_'.$Row['Version'].'">'.$Row['Version'].'</a>'; 256 return($Row); 257 } 258 259 function ShowClientList() 260 { 261 global $Config; 262 263 $Output = '<h4>Verze herního klienta</h4>'; 264 $Table = new Table('ClientList'); 265 $Table->OnRow = array($this, 'ShowClientListOnRow'); 266 $Table->LoadValuesFromDatabase($this->Database); 267 $Output .= $Table->Show(); 268 if($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR) 269 { 270 //$Output .= '<br /><div style="text-align: center;"><a href="?Action=BackupAdd">Zálohovat</a></dev>'; 271 } 272 return($Output); 273 } 274 275 function ShowTaskListOnRow($Row) 276 { 277 $Row['Duration'] = $this->System->AddPrefixMultipliers($Row['Duration'], '', 4, 'Time'); 278 return($Row); 279 } 280 281 function ShowTaskList() 282 { 283 global $Config; 284 285 if($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER) 286 { 287 $Output = '<h4>Fronta úloh</h4>'; 288 $Table = new Table('TaskList'); 289 $Table->OnRow = array($this, 'ShowTaskListOnRow'); 290 $Table->Definition['Table'] = '(SELECT (COALESCE(UNIX_TIMESTAMP(TimeEnd), UNIX_TIMESTAMP(NOW())) - UNIX_TIMESTAMP(TimeStart)) AS Duration, TimeCreate, Title, State FROM Task WHERE User='.$this->System->Modules['User']->User['Id'].' ORDER BY Id DESC)'; 291 $Table->LoadValuesFromDatabase($this->Database); 292 $Output .= $Table->Show(); 293 $Output .= '<br /><div style="text-align: center;"><a href="?Action=TaskList">Obnovit pohled</a></dev>'; 294 } else $Output .= USER_BAD_ROLE; 295 return($Output); 296 } 297 298 function ShowDebugListOnRow($Row) 299 { 300 $Row['Time'] = '<a href="?Action=ServerDebug&Id='.$Row['Id'].'&Show=Backtrace">'.str_replace(' ', ' ', $Row['Time']).'</a>'; 301 $Row['Uptime'] = TimeToHumanTime($Row['Uptime']); 302 return($Row); 303 } 304 305 function ShowDebugList() 306 { 307 global $Config; 308 309 if($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER) 310 { 311 $Server = new Server($this->Database, $_GET['Id']); 312 if(($this->System->Modules['User']->User['Id'] == $Server->Server['User']) or ($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR)) 313 { 314 $Output = '<h4>Ladící záznamy restartů</h4>'; 315 $Table = new Table('DebugList'); 316 $Table->OnRow = array($this, 'ShowDebugListOnRow'); 317 $Table->Definition['Table'] = '(SELECT * FROM Debug WHERE Server='.$_GET['Id'].')'; 318 $Table->LoadValuesFromDatabase($this->Database); 319 $Output .= $Table->Show(); 320 if($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR) 321 { 322 //$Output .= '<br /><div style="text-align: center;"><a href="?Action=BackupAdd">Zálohovat</a></dev>'; 323 } 324 } else $this->SystemMessage('Ladící záznamy', 'Nemáte oprávnění'); 325 } else $Output .= USER_BAD_ROLE; 326 return($Output); 327 } 328 329 function ShowLoginForm() 330 { 331 $Form = new Form('UserLogin'); 332 $Form->OnSubmit = '?Action=Login'; 333 $Output = $Form->ShowEditForm(); 334 $Output .= '<div class="Centred"><a href="?Action=UserRegister">Registrovat se</a> '. 335 '<a href="?Action=PasswordRecovery">Obnova zapomenutého hesla</a></div>'; 336 return($Output); 337 } 338 339 function ImportDatabase() 340 { 341 if($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER) 342 { 343 $Server = new Server($this->Database, $_GET['Id']); 344 if(($this->System->Modules['User']->User['Id'] == $Server->Server['User']) or ($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR)) 345 { 346 $Server->ImportDatabase(true); 347 $Output .= $this->SystemMessage('Import čisté databáze', 'Úloha zařazena do fronty'); 348 $Output .= $this->ShowTaskList(); 349 } else $this->SystemMessage('Import databáze', 'Nemáte oprávnění'); 350 } else $Output .= USER_BAD_ROLE; 351 } 352 353 function ShowWelcome() 354 { 355 $Output = '<p>Vítejte v projektu zaměřeném na free hosting WoW serverů.</p>'. 356 '<strong>Použité technologie:</strong><br />'. 357 '<ul>'. 358 '<li><a href="http://www.worldofwarcraft.com/">World of Warcraft</a> - fantasy MMORPG</li>'. 359 '<li><a href="http://www.getmangos.com/">MaNGOS</a> - MMORPG server</li>'. 360 '<li><a href="http://www.udbforums.org/">UDB</a> - databáze pro MaNGOS</li>'. 361 '<li><a href="http://www.scriptdev2.com/">ScriptDev2</a> - doplňkový skriptovací systém pro MaNGOS</li>'. 362 '</ul>'; 363 return($Output); 364 } 365 366 function UserMenu() 367 { 368 $Output = '<strong>Uživatelské menu</strong><br />'; 369 if($this->System->Modules['User']->User['Id'] != $this->System->Modules['User']->AnonymousUserId) 370 { 371 $DbResult = $this->Database->query('SELECT COUNT(*) FROM Server WHERE User='.$this->System->Modules['User']->User['Id']); 372 $DbRow = $DbResult->fetch_row(); 373 if($DbRow[0] > 0) 374 { 375 $DbResult = $this->Database->query('SELECT Id FROM Server WHERE User='.$this->System->Modules['User']->User['Id']); 376 $Server = $DbResult->fetch_assoc(); 377 $Output .= '<div><a href="?Action=ServerShow&Id='.$Server['Id'].'">Můj server</a></div>'; 378 $Output .= '<div><a href="?Action=RealmList">Moje světy</a></div>'; 379 $Output .= '<div><a href="?Action=DebugList&Id='.$Server['Id'].'">Ladící záznamy</a></div>'; 380 $Output .= '<div><a href="?Action=BackupList&Id='.$Server['Id'].'">Zálohy</a></div>'; 381 $Output .= '<div><a href="?Action=TaskList">Fronta úloh</a></div>'; 382 $Output .= '<div><a href="?Action=UpdateList&Id='.$Server['Id'].'">Dostupné aktualizace</a></div>'; 383 } else $Output .= '<div><a href="?Action=ServerAdd">Vytvořit vlastní server</a></div>'; 384 if($this->System->Modules['User']->User['Role'] == USER_ROLE_ADMINISTRATOR) 385 { 386 $Output .= '<div><a href="?Action=NewsAdd">Přidat aktualitu</a></div>'; 387 } 388 } 389 return($Output); 390 } 391 392 function ShowInfo() 393 { 394 global $Config; 395 396 $Output = '<h4>Informace</h4>'. 397 '<p>Tento free hosting WoW serverů vám nabízí zdarma vytvoření vlastního malého serveru. Vytvoření a správa serveru nikdy nebyly jednodušší.</p>'. 398 '<strong>Pro koho je hosting určen?</strong>'. 399 '<ul>'. 400 '<li>Pro ty, kteří se chtějí starat o vlastní server, ale nemají dostatek financí nebo prostoru pro jeho provozování.</li>'. 401 '<li>Pro ty, kteří si chtějí vyzkoušet, jaké je to být administrátorem či GM na svém serveru.</li>'. 402 '</ul><br />'. 403 '<strong>Co získáte registrací?</strong>'. 404 '<ul>'. 405 '<li>Přístup k vlastnímu nepřetržitě běžícímu WoW serveru.</li>'. 406 '<li>Možnost si vybrat jednu z nabízených kombinací verze emulátoru, databáze a klienta.</li>'. 407 '<li>Možnost provádět aktualizace serveru na pár kliknutí.</li>'. 408 '<li>Periodické noční zálohování a možnost ruční obnovy.</li>'. 409 '<li>Max. 50 online hrajících hráčů.</li>'. 410 '<li>Neomezený počet účtů a postav.</li>'. 411 '<li>Možnost stáhnout si celou databázi serveru a v případě zájmů hráčů tak přejít na vlastní výkonější vyhrazený server.</li>'. 412 '<li>Automatické restartování serveru při selhání a automatický záznam ladících informací o pádu.</li>'. 413 '</ul><br />'. 414 '<p>Vámi vytvořený server může být bez předchozího upozornění smazán, např. pokud nebude již využíván nebo bude potřeba snížit vytížení hostingu.</p>'. 415 'Technická podpora: '.$Config['Web']['AdminEmail']; 416 return($Output); 417 } 27 var $ShortTitle = 'Seznam serverů'; 418 28 419 29 function Show() … … 426 36 if($_GET['Action'] == 'LoginForm') 427 37 { 428 $Output .= $this->ShowLoginForm(); 38 $UserView = new UserView($this->Database, $this->System); 39 $Output .= $UserView->LoginForm(); 429 40 } else 430 41 if($_GET['Action'] == 'Login') 431 42 { 432 $Form = new Form('UserLogin'); 433 $Form->OnSubmit = '?Action=Login'; 434 $Form->LoadValuesFromForm(); 435 $Result = $this->System->Modules['User']->Login($Form->Values['Username'], $Form->Values['Password']); 436 $Output = $this->SystemMessage('Přihlášení', $Result); 437 if($Result <> USER_LOGGED_IN) 438 { 439 $Form->Values['Password'] = ''; 440 $Output .= $Form->ShowEditForm(); 441 $Output .= '<div class="Centred"><a href="?Action=UserRegister">Registrovat se</a> '. 442 '<a href="?Action=PasswordRecovery">Obnova zapomenutého hesla</a></div>'; 443 } 43 $UserView = new UserView($this->Database, $this->System); 44 $Output .= $UserView->LoginResult(); 444 45 } else 445 46 if($_GET['Action'] == 'Logout') 446 47 { 447 $ Output .= $this->SystemMessage('Odhlášení', $this->System->Modules['User']->Logout());448 $Output .= $ this->ShowLoginForm();48 $UserView = new UserView($this->Database, $this->System); 49 $Output .= $UserView->Logout(); 449 50 } else 450 51 if($_GET['Action'] == 'UserOptions') 451 52 { 452 $UserOptions = new Form('UserOptions'); 453 $UserOptions->LoadValuesFromDatabase($this->System->Modules['User']->User['Id']); 454 $UserOptions->OnSubmit = '?Action=UserOptionsSave'; 455 $Output .= $UserOptions->ShowEditForm(); 53 $UserView = new UserView($this->Database, $this->System); 54 $Output .= $UserView->Options(); 456 55 } else 457 56 if($_GET['Action'] == 'UserOptionsSave') 458 57 { 459 $UserOptions = new Form('UserOptions', array()); 460 $UserOptions->LoadValuesFromForm(); 461 $UserOptions->SaveValuesToDatabase($this->System->Modules['User']->User['Id']); 462 $Output .= $this->SystemMessage('Nastavení', 'Nastavení uloženo.'); 463 $this->System->Modules['Log']->NewRecord('User', 'Nastavení uživatele změněno', $UserOptions->Values['Name']); 464 $UserOptions->LoadValuesFromDatabase($this->System->Modules['User']->User['Id']); 465 $UserOptions->OnSubmit = '?Action=UserOptionsSave'; 466 $Output .= $UserOptions->ShowEditForm(); 58 $UserView = new UserView($this->Database, $this->System); 59 $Output .= $UserView->OptionsSave(); 467 60 } else 468 61 if($_GET['Action'] == 'UserRegister') 469 62 { 470 $Form = new Form('UserRegister'); 471 $Form->LoadValuesFromForm(); 472 $Form->OnSubmit = '?Action=UserRegisterSave'; 473 $Output = 'Vyplňte správně požadované údaje. Na zadaný email vám bude zaslán aktivační email.'; 474 $Output .= $Form->ShowEditForm(); 63 $UserView = new UserView($this->Database, $this->System); 64 $Output .= $UserView->Register(); 475 65 } else 476 66 if($_GET['Action'] == 'UserRegisterConfirm') 477 67 { 478 $ Output .= $this->SystemMessage('Potvrzení registrace', $this->System->Modules['User']->RegisterConfirm($_GET['User'], $_GET['H']));479 $Output .= $ this->ShowLoginForm();68 $UserView = new UserView($this->Database, $this->System); 69 $Output .= $UserView->RegisterConfirm(); 480 70 } else 481 71 if($_GET['Action'] == 'PasswordRecovery') 482 72 { 483 $Form = new Form('PasswordRecovery'); 484 $Form->OnSubmit = '?Action=PasswordRecovery2'; 485 $Output .= $Form->ShowEditForm(); 486 } else 487 if($_GET['Action'] == 'PasswordRecovery2') 488 { 489 $Form = new Form('PasswordRecovery'); 490 $Form->LoadValuesFromForm(); 491 $Result = $this->System->Modules['User']->PasswordRecoveryRequest($Form->Values['Name'], $Form->Values['Email']); 492 $Output .= $this->SystemMessage('Obnova hesla', $Result); 493 if($Result <> USER_PASSWORD_RECOVERY_SUCCESS) 494 { 495 $Output .= $Form->ShowEditForm(); 496 } 73 $UserView = new UserView($this->Database, $this->System); 74 $Output .= $UserView->PasswordRecovery(); 75 } else 76 if($_GET['Action'] == 'PasswordRecoveryFinish') 77 { 78 $UserView = new UserView($this->Database, $this->System); 79 $Output .= $UserView->PasswordRecoveryFinish(); 497 80 } else 498 81 if($_GET['Action'] == 'PasswordRecoveryConfirm') 499 82 { 500 $ Output .= $this->SystemMessage('Obnova hesla', $this->System->Modules['User']->PasswordRecoveryConfirm($_GET['User'], $_GET['H'], $_GET['P']));501 $Output .= $ this->ShowLoginForm();83 $UserView = new UserView($this->Database, $this->System); 84 $Output .= $UserView->PasswordRecoveryConfirm(); 502 85 } else 503 86 if($_GET['Action'] == 'UserRegisterSave') 504 87 { 505 $Form = new Form('UserRegister', array()); 506 $Form->LoadValuesFromForm(); 507 $Result = $this->System->Modules['User']->Register($Form->Values['Login'], $Form->Values['Password'], $Form->Values['Password2'], $Form->Values['Email'], $Form->Values['Name']); 508 $Output .= $this->SystemMessage('Registrace nového účtu', $Result); 509 if($Result <> USER_REGISTRATED) 510 { 511 $Form->OnSubmit = '?Action=UserRegisterSave'; 512 $Output .= $Form->ShowEditForm(); 513 } 88 $UserView = new UserView($this->Database, $this->System); 89 $Output .= $UserView->RegisterSave(); 514 90 } else 515 91 if($_GET['Action'] == 'ServerAdd') 516 92 { 517 if($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER) 518 { 519 $DbResult = $this->Database->query('SELECT COUNT(*) FROM Server'); 520 $DbRow = $DbResult->fetch_row(); 521 $ServerCount = $DbRow[0]; 522 if($ServerCount < $Config['MaxServerCount']) 523 { 524 $DbResult = $this->Database->query('SELECT COUNT(*) FROM Server WHERE User='.$this->System->Modules['User']->User['Id']); 525 $DbRow = $DbResult->fetch_row(); 526 if($DbRow[0] > 0) $Output .= $this->SystemMessage('Nový server', 'Lze vytvořit pouze jeden server pro každý uživatelský účet.'); 527 else 528 { 529 $Form = new Form('ServerCreate'); 530 $Form->LoadValuesFromForm(); 531 $Form->OnSubmit = '?Action=ServerCreate'; 532 $Output .= 'Tento formulář vám umožní si vytvořit nový server. Pečlivě vyplňte požadované údaje.'; 533 $Output .= $Form->ShowEditForm(); 534 } 535 } else $Output .= $this->SystemMessage('Nový server', 'Nelze vytvářet další servery'); 536 } else $Output .= USER_BAD_ROLE; 93 $ServerView = new ServerView($this->Database, $this->System); 94 $Output .= $ServerView->Add(); 537 95 } else 538 96 if($_GET['Action'] == 'ServerCreate') 539 97 { 540 if($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER) 541 { 542 $DbResult = $this->Database->query('SELECT COUNT(*) FROM Server WHERE User='.$this->System->Modules['User']->User['Id']); 543 $DbRow = $DbResult->fetch_row(); 544 if($DbRow[0] > 0) $Output .= $this->SystemMessage('Nový server', 'Lze vytvořit pouze jeden server pro každý uživatelský účet.'); 545 else 546 { 547 $DbResult = $this->Database->query('SELECT MAX(NetworkPortRealmd), MAX(NetworkPortWorldd) FROM Server'); 548 $DbRow = $DbResult->fetch_row(); 549 $NewPortRealmd = $DbRow[0] + 1; 550 if($NewPortRealmd < $Config['BaseNetworkPortRealmd']) $NewPortRealmd = $Config['BaseNetworkPortRealmd']; 551 $NewPortWorldd = $DbRow[1] + 1; 552 if($NewPortWorldd < $Config['BaseNetworkPortWorldd']) $NewPortWorldd = $Config['BaseNetworkPortWorldd']; 553 554 $Form = new Form('ServerCreate', array()); 555 $Form->LoadValuesFromForm(); 556 $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' => $Form->Values['Database'], 'NetworkPortWorldd' => $NewPortWorldd, 'NetworkPortRealmd' => $NewPortRealmd, 'Lock' => 1, 'TimeCreate' => 'NOW()')); 557 $LastInsertId = $this->Database->insert_id; 558 $Server = new Server($this->Database, $LastInsertId); 559 $Server->CreateDatabase(); 560 $Output .= $this->SystemMessage('Vytvoření serveru', $Server->ImportDatabase(true)); 561 $Output .= $this->ShowTaskList(); 562 //$UserOptions->LoadValuesFromDatabase($this->System->Modules['User']->User['Id']); 563 //$Form->OnSubmit = '?Action=ServerCreate'; 564 //$Output .= $Form->ShowEditForm(); 565 } 566 } else $Output .= USER_BAD_ROLE; 98 $ServerView = new ServerView($this->Database, $this->System); 99 $Output .= $ServerView->Create(); 567 100 } else 568 101 if($_GET['Action'] == 'ServerShow') 569 102 { 570 if(array_key_exists('Id', $_GET)) $Output .= $this->ShowServer($_GET['Id']); 571 else $this->SystemMessage('Zobrazení serveru', 'Nebylo zadáno Id'); 103 $ServerView = new ServerView($this->Database, $this->System); 104 $Output .= $ServerView->Item(); 105 //if(array_key_exists('Id', $_GET)) $Output .= $this->ShowServer($_GET['Id']); 106 //else $this->SystemMessage('Zobrazení serveru', 'Nebylo zadáno Id'); 572 107 } else 573 108 if($_GET['Action'] == 'ServerEdit') 574 109 { 575 $Server = new Server($this->Database, $_GET['Id']); 576 if(($this->System->Modules['User']->User['Id'] == $Server->Server['User']) or ($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR)) 577 { 578 $Form = new Form('ServerEdit'); 579 $Form->LoadValuesFromDatabase($_GET['Id']); 580 $Form->Values['ServerId'] = $_GET['Id']; 581 $Form->OnSubmit = '?Action=ServerSave'; 582 $Output .= $Form->ShowEditForm(); 583 } else $this->SystemMessage('Nastavení serveru', 'Nemáte oprávnění'); 110 $ServerView = new ServerView($this->Database, $this->System); 111 $Output .= $ServerView->Edit(); 584 112 } else 585 113 if($_GET['Action'] == 'ServerSave') 586 114 { 587 $Server = new Server($this->Database, $_POST['ServerId']); 588 if(($this->System->Modules['User']->User['Id'] == $Server->Server['User']) or ($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR)) 589 { 590 $Form = new Form('ServerEdit', array()); 591 $Form->LoadValuesFromForm(); 592 $ServerId = $_POST['ServerId']; 593 unset($Form->Values['ServerId']); 594 $Output .= $this->SystemMessage('Upravit server', 'Nastavení serveru uloženo.'); 595 $Form->SaveValuesToDatabase($_POST['ServerId']); 596 $Form->OnSubmit = '?Action=ServerSave'; 597 598 $Server = new Server($this->Database, $_POST['ServerId']); 599 $Server->SaveConfiguration(); 600 $Form->Values['ServerId'] = $ServerId; 601 $Output .= $Form->ShowEditForm(); 602 } else $this->SystemMessage('Nastavení serveru', 'Nemáte oprávnění'); 115 $ServerView = new ServerView($this->Database, $this->System); 116 $Output .= $ServerView->Save(); 603 117 } else 604 118 if($_GET['Action'] == 'ServerEditDetailed') 605 119 { 606 $Server = new Server($this->Database, $_GET['Id']); 607 if(($this->System->Modules['User']->User['Id'] == $Server->Server['User']) or ($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR)) 608 { 609 $Form = new Form('ServerSettingDetailed'); 610 $EmulatorConfig = new MangosConfigurationFile($this->Database); 611 $EmulatorConfig->Load('../server/'.$Server->Id.'/etc/mangosd.conf'); 612 $Form->Values = $EmulatorConfig->ParameterList; 613 $Form->Values['ServerId'] = $_GET['Id']; 614 $Form->OnSubmit = '?Action=ServerSaveDetailed'; 615 $Output .= $Form->ShowEditForm(); 616 } else $this->SystemMessage('Nastavení serveru', 'Nemáte oprávnění'); 120 $ServerView = new ServerView($this->Database, $this->System); 121 $Output .= $ServerView->EditDetailed(); 617 122 } else 618 123 if($_GET['Action'] == 'ServerSaveDetailed') 619 124 { 620 $Server = new Server($this->Database, $_POST['ServerId']); 621 if(($this->System->Modules['User']->User['Id'] == $Server->Server['User']) or ($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR)) 622 { 623 $Form = new Form('ServerSettingDetailed', array()); 624 $Form->LoadValuesFromForm(); 625 $EmulatorConfig = new MangosConfigurationFile($this->Database); 626 $EmulatorConfig->Load('../server/'.$Server->Id.'/etc/mangosd.conf'); 627 foreach($Form->Values as $Index => $Item) 628 $EmulatorConfig->ParameterList[$Index] = $Item; 629 $EmulatorConfig->Save('../server/'.$Server->Id.'/etc/mangosd.conf'); 630 $ServerId = $_POST['ServerId']; 631 unset($Form->Values['ServerId']); 632 $Output .= $this->SystemMessage('Upravit server', 'Nastavení serveru uloženo.'); 633 //$Form->SaveValuesToDatabase($_POST['ServerId']); 634 $Form->OnSubmit = '?Action=ServerSaveDetailed'; 635 636 $Server = new Server($this->Database, $_POST['ServerId']); 637 $Server->SaveConfiguration(); 638 $Form->Values['ServerId'] = $ServerId; 639 $Output .= $Form->ShowEditForm(); 640 } else $this->SystemMessage('Nastavení serveru', 'Nemáte oprávnění'); 125 $ServerView = new ServerView($this->Database, $this->System); 126 $Output .= $ServerView->SaveDetailed(); 641 127 } else 642 128 if($_GET['Action'] == 'ServerStart') 643 129 { 644 if($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER) 645 { 646 $Server = new Server($this->Database, $_GET['Id']); 647 if(($this->System->Modules['User']->User['Id'] == $Server->Server['User']) or ($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR)) 648 { 649 $Output .= $this->SystemMessage('Spuštění serveru', $Server->Start()); 650 $Output .= $this->ShowTaskList(); 651 } else $this->SystemMessage('Spuštění serveru', 'Nemáte oprávnění'); 652 } else $Output .= USER_BAD_ROLE; 130 $ServerView = new ServerView($this->Database, $this->System); 131 $Output .= $ServerView->Start(); 653 132 } else 654 133 if($_GET['Action'] == 'ServerStop') 655 134 { 656 if($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER) 657 { 658 $Server = new Server($this->Database, $_GET['Id']); 659 if(($this->System->Modules['User']->User['Id'] == $Server->Server['User']) or ($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR)) 660 { 661 $Output .= $this->SystemMessage('Zastavení serveru', $Server->Stop()); 662 $Output .= $this->ShowTaskList(); 663 } else $this->SystemMessage('Zastavení serveru', 'Nemáte oprávnění'); 664 } else $Output .= USER_BAD_ROLE; 135 $ServerView = new ServerView($this->Database, $this->System); 136 $Output .= $ServerView->Stop(); 665 137 } else 666 138 if($_GET['Action'] == 'ServerDatabaseImport') 667 139 { 668 $this->ImportDatabase(); 140 $DatabaseView = new DatabaseView($this->Database, $this->System); 141 $Output .= $DatabaseView->Import(); 669 142 } else 670 143 if($_GET['Action'] == 'EmulatorShow') 671 144 { 672 if(array_key_exists('Id', $_GET)) 673 { 674 $Output .= $this->EmulatorShow($_GET['Id']); 675 } else $Output .= $this->SystemMessage('Překlad emulátoru', 'Nebylo zadáno Id'); 145 $EmulatorView = new EmulatorView($this->Database, $this->System); 146 $Output .= $EmulatorView->Item(); 676 147 } else 677 148 if($_GET['Action'] == 'EmulatorList') 678 149 { 679 $Output .= $this->ShowEmulatorList(); 150 $EmulatorView = new EmulatorView($this->Database, $this->System); 151 $Output .= $EmulatorView->ItemList(); 680 152 } else 681 153 if($_GET['Action'] == 'EmulatorCompile') 682 154 { 683 if(array_key_exists('Id', $_GET)) 684 { 685 $Emulator = new Emulator($this->Database, $_GET['Id']); 686 $Emulator->Compile(); 687 $Output .= $this->SystemMessage('Překlad emulátoru', 'Úloha zařazena do fronty'); 688 $Output .= $this->ShowTaskList(); 689 } else $Output .= $this->SystemMessage('Překlad emulátoru', 'Nebylo zadáno Id'); 155 $EmulatorView = new EmulatorView($this->Database, $this->System); 156 $Output .= $EmulatorView->Compile(); 690 157 } else 691 158 if($_GET['Action'] == 'EmulatorDownload') 692 159 { 693 if(array_key_exists('Id', $_GET)) 694 { 695 $Emulator = new Emulator($this->Database, $_GET['Id']); 696 $Emulator->Download(); 697 $Output .= $this->SystemMessage('Stažení emulátoru', 'Úloha zařazena do fronty'); 698 $Output .= $this->ShowTaskList(); 699 } else $Output .= $this->SystemMessage('Stažení emulátoru', 'Nebylo zadáno Id'); 160 $EmulatorView = new EmulatorView($this->Database, $this->System); 161 $Output .= $EmulatorView->Download(); 700 162 } else 701 163 if($_GET['Action'] == 'ServerDebug') 702 164 { 703 if($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER) 704 { 705 $Server = new Server($this->Database, $_GET['Id']); 706 if(($this->System->Modules['User']->User['Id'] == $Server->Server['User']) or ($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR)) 707 { 708 $Output .= '<div>Ladící informace serveru</div>'; 709 $MangosDebug = new MangosDebug($this->Database); 710 $Output .= $MangosDebug->Show($Server->Id); 711 } else $this->SystemMessage('Ladící informace', 'Nemáte oprávnění'); 712 } else $Output .= USER_BAD_ROLE; 165 $DebugView = new DebugView($this->Database, $this->System); 166 $Output .= $DebugView->Item(); 713 167 } else 714 168 if($_GET['Action'] == 'ClientList') 715 169 { 716 $Output .= $this->ShowClientList(); 170 $ClientView = new ClientView($this->Database, $this->System); 171 $Output .= $ClientView->ItemList(); 717 172 } else 718 173 if($_GET['Action'] == 'BackupList') 719 174 { 720 $Output .= $this->ShowBackupList($_GET['Id']); 175 $BackupView = new BackupView($this->Database, $this->System); 176 $Output .= $BackupView->ItemList(); 721 177 } else 722 178 if($_GET['Action'] == 'DebugList') 723 179 { 724 $Output .= $this->ShowDebugList($_GET['Id']); 180 $DebugView = new DebugView($this->Database, $this->System); 181 $Output .= $DebugView->ItemList(); 725 182 } else 726 183 if($_GET['Action'] == 'UpdateList') 727 184 { 728 $Output .= $this->ShowUpdateList($_GET['Id']); 185 $UpdateView = new UpdateView($this->Database, $this->System); 186 $Output .= $UpdateView->ItemList(); 729 187 } else 730 188 if($_GET['Action'] == 'GameAccountRegister') 731 189 { 732 $Form = new Form('GameAccountNew'); 733 $Form->LoadValuesFromForm(); 734 $Form->Values['ServerId'] = $_GET['Id']; 735 $Form->OnSubmit = '?Action=GameAccountRegister2'; 736 $Output .= $Form->ShowEditForm(); 190 $ServerView = new ServerView($this->Database, $this->System); 191 $Output .= $ServerView->AccountCreate(); 737 192 } else 738 193 if($_GET['Action'] == 'GameAccountRegister2') 739 194 { 740 $Form = new Form('GameAccountNew'); 741 $Form->LoadValuesFromForm(); 742 $Server = new Server($this->Database, $Form->Values['ServerId']); 743 $Output .= $this->SystemMessage('Vytvoření herního účtu', $Server->NewAccount($Form->Values['Name'], $Form->Values['Password'], $Form->Values['Password2'], $Form->Values['Email'], $Form->Values['Expansion'])); 744 $Output .= '<a href="?Action=GameAccountRegister&Id='.$Form->Values['ServerId'].'">Zpět k zadání údajů</a>'; 195 $ServerView = new ServerView($this->Database, $this->System); 196 $Output .= $ServerView->AccountCreateFinish(); 745 197 } else 746 198 if($_GET['Action'] == 'EmulatorAdd') 747 199 { 748 if($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR) 749 { 750 $Form = new Form('EmulatorItem'); 751 $Form->LoadValuesFromForm(); 752 $Form->OnSubmit = '?Action=EmulatorAdd2'; 753 $Output .= $Form->ShowEditForm(); 754 } else $Output .= USER_BAD_ROLE; 200 $EmulatorView = new EmulatorView($this->Database, $this->System); 201 $Output .= $EmulatorView->Add(); 755 202 } else 756 203 if($_GET['Action'] == 'EmulatorAdd2') 757 204 { 758 if($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR) 759 { 760 $Form = new Form('EmulatorItem'); 761 $Form->LoadValuesFromForm(); 762 $Form->SaveValuesToDatabase(0); 763 $Output .= $this->SystemMessage('Přidání nového emulátoru', 'Emulátor přidán.'); 764 } else $Output .= USER_BAD_ROLE; 205 $EmulatorView = new EmulatorView($this->Database, $this->System); 206 $Output .= $EmulatorView->AddFinish(); 765 207 } else 766 208 if($_GET['Action'] == 'Info') 767 209 { 768 $Output = $this->ShowInfo(); 210 $BaseView = new BaseView($this->Database, $this->System); 211 $Output .= $BaseView->Info(); 769 212 } else 770 213 if($_GET['Action'] == 'BackupAdd') 771 214 { 772 if(!array_key_exists('Id', $_GET)) $Output .= $this->SystemMessage('Ladící informace', 'Nebylo zadáno Id serveru'); 773 else if($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER) 774 { 775 $Server = new Server($this->Database, $_GET['Id']); 776 if(($this->System->Modules['User']->User['Id'] == $Server->Server['User']) or ($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR)) 777 { 778 $Backup = new Backup($this->Database, 0); 779 $Output .= $this->SystemMessage('Ruční zálohování', $Backup->Create($Server->Id)); 780 $Output .= $this->ShowTaskList(); 781 } else $this->SystemMessage('Ladící informace', 'Nemáte oprávnění'); 782 } else $Output .= USER_BAD_ROLE; 215 $BackupView = new BackupView($this->Database, $this->System); 216 $Output .= $BackupView->Add(); 783 217 } else 784 218 if($_GET['Action'] == 'BackupRestore') 785 219 { 786 if(!array_key_exists('Id', $_GET)) $Output .= $this->SystemMessage('Obnovení ze zálohy', 'Nebylo zadáno Id zálohy'); 787 else if($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER) 788 { 789 $Backup = new Backup($this->Database, $_GET['Id']); 790 $Server = new Server($this->Database, $Backup->Backup['Server']); 791 if(($this->System->Modules['User']->User['Id'] == $Server->Server['User']) or ($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR)) 792 { 793 $Output .= $this->SystemMessage('Obnovení ze zálohy', $Backup->Restore()); 794 $Output .= $this->ShowTaskList(); 795 } else $this->SystemMessage('Obnovení ze zálohy', 'Nemáte oprávnění'); 796 } else $Output .= USER_BAD_ROLE; 220 $BackupView = new BackupView($this->Database, $this->System); 221 $Output .= $BackupView->Restore(); 797 222 } else 798 223 if($_GET['Action'] == 'BackupDownload') 799 224 { 800 if(!array_key_exists('Id', $_GET)) $Output .= $this->SystemMessage('Stažení souboru zálohy', 'Nebylo zadáno Id zálohy'); 801 else if($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER) 802 { 803 $Backup = new Backup($this->Database, $_GET['Id']); 804 $Server = new Server($this->Database, $Backup->Backup['Server']); 805 if(($this->System->Modules['User']->User['Id'] == $Server->Server['User']) or ($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR)) 806 { 807 Header('Content-Type: application/x-tar-gz'); 808 Header('Content-Disposition: attachment; filename="wowhosting-'.$Backup->Id.'.tar.bz2"'); 809 echo(file_get_contents('../backup/wowhosting-'.$Backup->Id.'.tar.bz2')); 810 exit; 811 } else $this->SystemMessage('Stažení souboru zálohy', 'Nemáte oprávnění'); 812 } else $Output .= USER_BAD_ROLE; 225 $BackupView = new BackupView($this->Database, $this->System); 226 $Output .= $BackupView->Download(); 813 227 } else 814 228 if($_GET['Action'] == 'TaskList') 815 229 { 816 $Output .= $this->ShowTaskList(); 230 $TaskView = new TaskView($this->Database, $this->System); 231 $Output .= $TaskView->ItemList(); 817 232 } else 818 233 if($_GET['Action'] == 'Update') 819 234 { 820 if(!array_key_exists('Server', $_GET)) $Output .= $this->SystemMessage('Aktualizace serveru', 'Nebylo zadáno Id serveru'); 821 else if(!array_key_exists('Update', $_GET)) $Output .= $this->SystemMessage('Aktualizace serveru', 'Nebylo zadáno Id aktualizace'); 822 else if($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER) 823 { 824 $Server = new Server($this->Database, $_GET['Server']); 825 if(($this->System->Modules['User']->User['Id'] == $Server->Server['User']) or ($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR)) 826 { 827 $Output .= $this->SystemMessage('Aktualizace serveru', $Server->Update($_GET['Update'])); 828 $Output .= $this->ShowTaskList(); 829 } else $this->SystemMessage('Aktualizace serveru', 'Nemáte oprávnění'); 830 } else $Output .= USER_BAD_ROLE; 235 $UpdateView = new UpdateView($this->Database, $this->System); 236 $Output .= $UpdateView->Update(); 831 237 } else 832 238 if($_GET['Action'] == 'NewsAdd') 833 239 { 834 if($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR) 835 { 836 $Form = new Form('News'); 837 $Form->OnSubmit = '?Action=NewsAdd2'; 838 $Output = $Form->ShowEditForm(); 839 } else $Output .= USER_BAD_ROLE; 240 $NewsView = new NewsView($this->Database, $this->System); 241 $Output .= $NewsView->Add(); 840 242 } else 841 243 if($_GET['Action'] == 'NewsAdd2') 842 244 { 843 if($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR) 844 { 845 $Form = new Form('News'); 846 $Form->LoadValuesFromForm(); 847 $Form->Values['Time'] = 'NOW()'; 848 $Form->Values['User'] = $this->System->Modules['User']->User['Id']; 849 $Form->SaveValuesToDatabase(0); 850 $Output = $this->SystemMessage('Nová aktualita', 'Přidáno'); 851 } else $Output .= USER_BAD_ROLE; 245 $NewsView = new NewsView($this->Database, $this->System); 246 $Output .= $NewsView->AddFinish(); 852 247 } else 853 248 if($_GET['Action'] == 'EmulatorShow') 854 249 { 855 if(array_key_exists('Id', $_GET)) $Output .= $this->ShowEmulator($_GET['Id']);856 else $this->SystemMessage('Zobrazení emulátoru', 'Nebylo zadáno Id');250 $EmulatorView = new EmulatorView($this->Database, $this->System); 251 $Output .= $EmulatorView->Item(); 857 252 } else 858 253 if($_GET['Action'] == 'State') 859 254 { 860 $Platform = new Platform($this->Database); 861 $State = $Platform->State(); 862 $Output = '<h4>Stav systému</h4>'. 863 '<table class="WideTable">'. 864 '<tr><th>Veličina</th><th>Hodnota</th></tr>'. 865 '<tr><td>Doba běhu serveru</td><td>'.$this->System->AddPrefixMultipliers($State['Uptime'], '', 4, 'Time').'</td></tr>'. 866 '<tr><td>Použitá/celková paměť</td><td>'.$this->System->AddPrefixMultipliers($State['MemoryUsed'], 'B', 4, 'Binary').' / '.$this->System->AddPrefixMultipliers($State['MemoryTotal'], 'B', 4, 'Binary').'</td></tr>'. 867 '<tr><td>Počet serverů aktivních/všech/maxiální</td><td>'.$State['ServerOnlineCount'].' / '.$State['ServerCount'].' / '.$State['ServerMaxCount'].'</td></tr>'. 868 '<tr><td>Počet emulátorů</td><td>'.$State['EmulatorCount'].'</td></tr>'. 869 '<tr><td>Počet uživatelů</td><td>'.$State['UserCount'].'</td></tr>'. 870 '<tr><td>Počet databází</td><td>'.$State['DatabaseCount'].'</td></tr>'. 871 '<tr><td>Počet záloh</td><td>'.$State['BackupCount'].'</td></tr>'. 872 '<tr><td>Čekajících/všech úloh ve frontě</td><td>'.$State['TaskQueued'].' / '.$State['TaskCount'].'</td></tr>'. 873 '</table>'; 255 $BaseView = new BaseView($this->Database, $this->System); 256 $Output .= $BaseView->State(); 874 257 } else 875 258 if($_GET['Action'] == 'ServerList') 876 259 { 877 $Output .= $this->ShowServerList(); 260 $ServerView = new ServerView($this->Database, $this->System); 261 $Output .= $ServerView->ItemList(); 878 262 } else 879 263 if($_GET['Action'] == 'RealmList') 880 264 { 881 $Output .= $this->ShowRealmList(); 265 $RealmView = new RealmView($this->Database, $this->System); 266 $Output .= $RealmView->ItemList(); 882 267 } else 883 268 if($_GET['Action'] == 'Test') … … 892 277 } else 893 278 { 894 $Output .= $this->ShowWelcome(); 279 $BaseView = new BaseView($this->Database, $this->System); 280 $Output .= $BaseView->Welcome(); 895 281 } 896 282 } else 897 283 { 898 $Output .= $this->ShowWelcome(); 284 $BaseView = new BaseView($this->Database, $this->System); 285 $Output .= $BaseView->Welcome(); 899 286 } 287 288 $BaseView = new BaseView($this->Database, $this->System); 900 289 $Content = $Output; 901 290 $Output = '<table class="BasicTable"><tr>'; 902 291 if($this->System->Modules['User']->User['Id'] != $this->System->Modules['User']->AnonymousUserId) 903 $Output .= '<td class="UserMenu">'.$ this->UserMenu().'</td>';292 $Output .= '<td class="UserMenu">'.$BaseView->UserMenu().'</td>'; 904 293 $Output .= '<td class="Content">'.$Content.'</td>'; 905 294 if(!array_key_exists('Action', $_GET)) 906 295 { 907 $Output .= '<td class="News"><strong>Aktuálně:</strong><br />'; 908 $DbResult = $this->Database->query('SELECT * FROM News'); 909 while($DbRow = $DbResult->fetch_assoc()) 910 { 911 $Output .= '<div><strong>'.$DbRow['Title'].'</strong>('.HumanDate($DbRow['Time']).')<br />'.$DbRow['Content'].'</div>'; 912 } 913 $Output .= '</td>'; 296 $NewsView = new NewsView($this->Database, $this->System); 297 $Output .= $NewsView->View(); 914 298 } 915 299 $Output .= '</tr></table>'; … … 918 302 } 919 303 920 $System->AddModule(new Index( ));304 $System->AddModule(new Index($Database, $System)); 921 305 $System->Modules['Index']->GetOutput(); 922 306
Note:
See TracChangeset
for help on using the changeset viewer.