Changeset 54 for trunk/www/index.php
- Timestamp:
- Aug 3, 2009, 8:44:23 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/www/index.php
r48 r54 1 1 <?php 2 2 3 include('global.php'); 3 include('include.php'); 4 5 chdir(substr($_SERVER['SCRIPT_FILENAME'], 0, strrpos($_SERVER['SCRIPT_FILENAME'], '/'))); 6 7 $ScriptTimeStart = GetMicrotime(); 8 // SQL injection hack protection 9 foreach($_POST as $Index => $Item) $_POST[$Index] = addslashes($Item); 10 foreach($_GET as $Index => $Item) $_GET[$Index] = addslashes($Item); 11 12 if(isset($_SERVER['REMOTE_ADDR'])) session_start(); 13 $Database = new Database($Config['Database']['Host'], $Config['Database']['User'], $Config['Database']['Password'], $Config['Database']['Database']); 14 $Database->Prefix = $Config['Database']['Prefix']; 15 $Database->charset($Config['Database']['Charset']); 16 17 $System = new System(); 18 $System->Config = $Config; 19 $System->Database = &$Database; 20 $System->AddModule(new Log()); 21 $System->AddModule(new User()); 22 if(isset($_SERVER['REMOTE_ADDR'])) $System->Modules['User']->Check(); 23 else $System->Modules['User']->User['Id'] = 0; 4 24 5 25 class Index extends Page … … 61 81 $Form->Definition['Items']['UsedMemory'] = array('Type' => 'String', 'Caption' => 'Použitá paměť', 'Default' => ''); 62 82 $Form->Definition['Items']['AccountCount'] = array('Type' => 'String', 'Caption' => 'Počet účtů', 'Default' => ''); 63 $Form->Definition['Items']['CharacterCount'] = array('Type' => 'String', 'Caption' => 'Počet postav', 'Default' => '');64 $Form->Definition['Items']['CharacterOnlineCount'] = array('Type' => 'String', 'Caption' => 'Počet hráčů online', 'Default' => '');65 83 $ServerStatus = $Server->GetState(); 66 84 $Form->Values['Realmlist'] = $Config['Web']['Host'].':'.$Form->Values['NetworkPortRealmd']; … … 69 87 $Form->Values['UsedMemory'] = $this->System->AddPrefixMultipliers($ServerStatus['UsedMemory'] * 1024, 'B', 4, 'Binary'); 70 88 $Form->Values['AccountCount'] = $ServerStatus['AccountCount']; 71 $Form->Values['CharacterCount'] = $ServerStatus['CharacterCount'];72 $Form->Values['CharacterOnlineCount'] = $ServerStatus['CharacterOnlineCount'];73 89 $Output .= $Form->ShowTable(); 74 90 $Output .= '<div style="text-align: center">'; … … 204 220 } 205 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 206 253 function ShowClientListOnRow($Row) 207 254 { … … 329 376 $Server = $DbResult->fetch_assoc(); 330 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>'; 331 379 $Output .= '<div><a href="?Action=DebugList&Id='.$Server['Id'].'">Ladící záznamy</a></div>'; 332 380 $Output .= '<div><a href="?Action=BackupList&Id='.$Server['Id'].'">Zálohy</a></div>'; … … 392 440 $Output .= $Form->ShowEditForm(); 393 441 $Output .= '<div class="Centred"><a href="?Action=UserRegister">Registrovat se</a> '. 394 442 '<a href="?Action=PasswordRecovery">Obnova zapomenutého hesla</a></div>'; 395 443 } 396 444 } else … … 803 851 } else $Output .= USER_BAD_ROLE; 804 852 } else 853 if($_GET['Action'] == 'EmulatorShow') 854 { 855 if(array_key_exists('Id', $_GET)) $Output .= $this->ShowEmulator($_GET['Id']); 856 else $this->SystemMessage('Zobrazení emulátoru', 'Nebylo zadáno Id'); 857 } else 805 858 if($_GET['Action'] == 'State') 806 859 { … … 824 877 $Output .= $this->ShowServerList(); 825 878 } else 879 if($_GET['Action'] == 'RealmList') 880 { 881 $Output .= $this->ShowRealmList(); 882 } else 826 883 if($_GET['Action'] == 'Test') 827 884 {
Note:
See TracChangeset
for help on using the changeset viewer.