Changeset 28
- Timestamp:
- Jun 13, 2009, 9:01:40 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/www/backup.php
r16 r28 12 12 $this->Id = $Id; 13 13 $DbResult = $this->Database->query('SELECT * FROM `Backup` WHERE `Id`='.$Id); 14 $this->Backup = $DbResult->fetch_assoc(); 14 if($DbResult->num_rows > 0) $this->Backup = $DbResult->fetch_assoc(); 15 else $this->Backup = array(); 15 16 } 16 17 … … 22 23 'mysql --silent --skip-column-names -u server'.$ServerId.' -pserver'.$ServerId.' server'.$ServerId.'_realmd -e "show tables" | gawk \'{print "drop table " $1 ";"}\' | mysql -u server'.$ServerId.' -pserver'.$ServerId.' server'.$ServerId.'_realmd', 23 24 'mysql --silent --skip-column-names -u server'.$ServerId.' -pserver'.$ServerId.' server'.$ServerId.'_scriptdev2 -e "show tables" | gawk \'{print "drop table " $1 ";"}\' | mysql -u server'.$ServerId.' -pserver'.$ServerId.' server'.$ServerId.'_scriptdev2', 24 'mkdir /tmp/wowhosting',25 'tar -xjf backup/ '.$ServerId.'/backup.tar.bz2 -C /tmp/wowhosting',26 'mysql --user server'.$ServerId.' --password server'.$ServerId.' server'.$ServerId.'_characters < /tmp/wowhosting/characters.sql',27 'mysql --user server'.$ServerId.' --password server'.$ServerId.' server'.$ServerId.'_realmd < /tmp/wowhosting/realmd.sql',28 'mysql --user server'.$ServerId.' --password server'.$ServerId.' server'.$ServerId.'_mangos < /tmp/wowhosting/mangos.sql',29 'mysql --user server'.$ServerId.' --password server'.$ServerId.' server'.$ServerId.'_scriptdev2 < /tmp/wowhosting/scriptdev2.sql',30 'rm -f /tmp/wowhosting',25 'mkdir temp/wowhosting', 26 'tar -xjf backup/wowhosting-'.$ServerId.'.tar.bz2 -C temp/wowhosting', 27 'mysql --user server'.$ServerId.' --password server'.$ServerId.' server'.$ServerId.'_characters < temp/wowhosting/characters.sql', 28 'mysql --user server'.$ServerId.' --password server'.$ServerId.' server'.$ServerId.'_realmd < temp/wowhosting/realmd.sql', 29 'mysql --user server'.$ServerId.' --password server'.$ServerId.' server'.$ServerId.'_mangos < temp/wowhosting/mangos.sql', 30 'mysql --user server'.$ServerId.' --password server'.$ServerId.' server'.$ServerId.'_scriptdev2 < temp/wowhosting/scriptdev2.sql', 31 'rm -f temp/wowhosting', 31 32 )); 32 33 } … … 34 35 function Create($ServerId) 35 36 { 37 $Server = new Server($this->Database, $ServerId); 38 $Description = 'MaNGOS r'.$Server->Server['Database']['Emulator']['Revision'].', UDB r'.$Server->Server['Database']['Revision'].', SD2 r'.$Server->Server['Database']['ScriptDev2Revision'].', Client '.$Server->Server['Database']['Emulator']['Client']['Version']; 39 $this->Database->insert('Backup', array('Server' => $ServerId, 'Time' => 'NOW()', 'Description' => $Description)); 40 $this->Id = $this->Database->insert_id; 36 41 $this->Task->Add('Záloha databáze serveru', array( 37 'mkdir /tmp/wowhosting', 38 'mysqldump --user server'.$ServerId.' --password server'.$ServerId.' --opt server'.$ServerId.'_characters > /tmp/wowhosting/characters.sql', 39 'mysqldump --user server'.$ServerId.' --password server'.$ServerId.' --opt server'.$ServerId.'_realmd > /tmp/wowhosting/realmd.sql', 40 'mysqldump --user server'.$ServerId.' --password server'.$ServerId.' --opt server'.$ServerId.'_mangos > /tmp/wowhosting/mangos.sql', 41 'mysqldump --user server'.$ServerId.' --password server'.$ServerId.' --opt server'.$ServerId.'_scriptdev2 > /tmp/wowhosting/scriptdev2.sql', 42 'tar -c -j /tmp/wowhosting > backup/'.$ServerId.'/backup.tar.bz2', 43 'rm -f /tmp/wowhosting', 42 'mkdir temp/wowhosting', 43 'mysqldump --user=server'.$ServerId.' --password=server'.$ServerId.' --opt server'.$ServerId.'_characters > temp/wowhosting/characters.sql', 44 'mysqldump --user=server'.$ServerId.' --password=server'.$ServerId.' --opt server'.$ServerId.'_realmd > temp/wowhosting/realmd.sql', 45 'mysqldump --user=server'.$ServerId.' --password=server'.$ServerId.' --opt server'.$ServerId.'_mangos > temp/wowhosting/mangos.sql', 46 'mysqldump --user=server'.$ServerId.' --password=server'.$ServerId.' --opt server'.$ServerId.'_scriptdev2 > temp/wowhosting/scriptdev2.sql', 47 'cd temp', 48 'tar -c -j wowhosting > ../backup/wowhosting-'.$this->Id.'.tar.bz2', 49 'rm -rf wowhosting', 44 50 )); 51 return('Úloha zálohování byla zařazena do fronty'); 45 52 } 46 53 } -
trunk/www/form_classes.php
r27 r28 77 77 'ServerList' => array( 78 78 'Title' => 'Server', 79 'Table' => '(SELECT `Client`.`Version`, `Server`.`Name`, `Server`.` Id`, `Server`.`NetworkPortRealmd`, `User`.`Name` AS `UserName`, Server.Online, Server.CharacterOnlineCount, Server.CharacterCount, Server.AccountCount FROM `Server` JOIN `User` ON `User`.`Id` = `Server`.`User` JOIN `Database` ON `Database`.`Id` = `Server`.`Database` JOIN `Emulator` ON `Emulator`.`Id` = `Database`.`Emulator` JOIN `Client` ON `Client`.`Id` = `Emulator`.`Client`)',79 'Table' => '(SELECT `Client`.`Version`, `Server`.`Name`, `Server`.`Homepage`, `Server`.`Id`, `Server`.`NetworkPortRealmd`, `User`.`Name` AS `UserName`, Server.Online, Server.CharacterOnlineCount, Server.CharacterCount, Server.AccountCount FROM `Server` JOIN `User` ON `User`.`Id` = `Server`.`User` JOIN `Database` ON `Database`.`Id` = `Server`.`Database` JOIN `Emulator` ON `Emulator`.`Id` = `Database`.`Emulator` JOIN `Client` ON `Client`.`Id` = `Emulator`.`Client`)', 80 80 'Items' => array( 81 81 'Name' => array('Type' => 'String', 'Caption' => 'Název', 'Default' => ''), … … 92 92 'Title' => 'Emulátory', 93 93 'Table' => '(SELECT `Emulator`.`Name`, `Emulator`.`Id`, `Client`.`Version` AS `ClientVersion`, `Emulator`.`Revision`, `Emulator`.`ScriptDev2Revision`, `Emulator`.`ScriptDev2PatchFileName`, `Emulator`.`Version`, `Emulator`.`CommitHash` FROM `Emulator` JOIN `Client` ON `Client`.`Id` = `Emulator`.`Client`)', 94 'DefaultOrderColumn' => 'Revision', 95 'DefaultOrderDirection' => 1, 94 96 'Items' => array( 95 97 'Name' => array('Type' => 'String', 'Caption' => 'Název', 'Default' => ''), … … 126 128 'Title' => 'Verze klienta', 127 129 'Table' => 'Client', 130 'DefaultOrderColumn' => 'BuildNumber', 131 'DefaultOrderDirection' => 1, 128 132 'Items' => array( 129 133 'Version' => array('Type' => 'String', 'Caption' => 'Verze', 'Default' => ''), … … 167 171 ), 168 172 ), 173 'TaskList' => array( 174 'Title' => 'Seznam úloh', 175 'Table' => 'Task', 176 'DefaultOrderColumn' => 'Time', 177 'DefaultOrderDirection' => 1, 178 'Items' => array( 179 'Time' => array('Type' => 'DateTime', 'Caption' => 'Čas', 'Default' => ''), 180 'Title' => array('Type' => 'String', 'Caption' => 'Akce', 'Default' => ''), 181 'State' => array('Type' => 'TaskState', 'Caption' => 'Stav', 'Default' => ''), 182 ), 183 ), 169 184 ); 170 185 186 RegisterType('TaskState', 'Enumeration', array('Čekající', 'Běžící', 'Dokončeno')); 171 187 RegisterType('ServerExpansion', 'Enumeration', array('Classic', 'The Burning Crusade', 'Wrath of The Lich King')); 172 188 RegisterType('ServerType', 'Enumeration', array('Normální', 'PvP', 'RP', 'RPPvP')); -
trunk/www/global.php
r24 r28 26 26 include('mangos_debug.php'); 27 27 include('task.php'); 28 include('backup.php'); 28 29 29 30 $PrefixMultipliers = array -
trunk/www/index.php
r27 r28 11 11 { 12 12 $Row['NetworkPortRealmd'] = '<a href="realmlist.php?Id='.$Row['Id'].'">'.$Row['NetworkPortRealmd'].'</a>'; 13 $Row['Name'] = '<a href="?Action=ServerShow&Id='.$Row['Id'].'">'.$Row['Name'].'</a>'; 13 if($Row['Homepage'] != '') $Row['Name'] = '<a href="'.$Row['Homepage'].'">'.$Row['Name'].'</a>'; 14 unset($Row['Homepage']); 14 15 return($Row); 15 16 } … … 24 25 $Table = new Table('ServerList'); 25 26 $Table->OnRow = array($this, 'ShowServerListOnRow'); 27 $Table->Definition['Items']['Id'] = array('Type' => 'Hidden', 'Caption' => '', 'Default' => ''); 26 28 $Table->LoadValuesFromDatabase($this->Database); 29 $Table->Definition['Items']['Actions'] = array('Type' => 'String', 'Caption' => '', 'Default' => ''); 30 foreach($Table->Values as $Index => $Item) 31 { 32 $Table->Values[$Index]['Actions'] = '<a href="?Action=ServerShow&Id='.$Item['Id'].'">Podrobnosti</a>'; 33 unset($Table->Values[$Index]['Id']); 34 } 27 35 $Output .= $Table->Show(); 28 36 if($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER) … … 109 117 } 110 118 111 function ShowBackupList() 112 { 113 global $Config; 114 115 $Output = '<h4>Dostupné zálohy</h4>'; 116 $Table = new Table('BackupList'); 117 $Table->OnRow = array($this, 'ShowBackupListOnRow'); 118 $Table->LoadValuesFromDatabase($this->Database); 119 $Output .= $Table->Show(); 120 if($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR) 121 { 122 $Output .= '<br /><div style="text-align: center;"><a href="?Action=BackupAdd">Zálohovat</a></dev>'; 123 } 119 function ShowBackupList($ServerId) 120 { 121 global $Config; 122 123 if($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER) 124 { 125 $Server = new Server($this->Database, $_GET['Id']); 126 if(($this->System->Modules['User']->User['Id'] == $Server->Server['User']) or ($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR)) 127 { 128 $Output = '<h4>Dostupné zálohy</h4>'; 129 $Table = new Table('BackupList'); 130 $Table->OnRow = array($this, 'ShowBackupListOnRow'); 131 $Table->Table = '(SELECT * FROM `Backup` WHERE `Server` = '.$ServerId.')'; 132 $Table->Definition['Items']['Id'] = array('Type' => 'Hidden', 'Caption' => 'Id', 'Default' => ''); 133 $Table->LoadValuesFromDatabase($this->Database); 134 $Table->Definition['Items']['Actions'] = array('Type' => 'String', 'Caption' => '', 'Default' => ''); 135 foreach($Table->Values as $Index => $Value) 136 { 137 $Table->Values[$Index]['Actions'] = '<a href="?Action=BackupDownload&Id='.$Value['Id'].'">Stáhnout</a>'; 138 unset($Table->Values[$Index]['Id']); 139 } 140 $Output .= $Table->Show(); 141 if($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR) 142 { 143 $Output .= '<br /><div style="text-align: center;"><a href="?Action=BackupAdd&Id='.$ServerId.'">Zálohovat</a></dev>'; 144 } 145 } else $this->SystemMessage('Zastavení serveru', 'Nemáte oprávnění'); 146 } else $Output .= USER_BAD_ROLE; 124 147 return($Output); 125 148 } … … 127 150 function ShowClientListOnRow($Row) 128 151 { 129 //$Row['Name'] = '<a href="?Action=EmulatorShow&Id='.$Row['Id'].'">'.$Row['Name'].'</a>';152 $Row['Version'] = '<a href="http://www.wowwiki.com/Patch_'.$Row['Version'].'">'.$Row['Version'].'</a>'; 130 153 return($Row); 131 154 } … … 144 167 //$Output .= '<br /><div style="text-align: center;"><a href="?Action=BackupAdd">Zálohovat</a></dev>'; 145 168 } 169 return($Output); 170 } 171 172 function ShowTaskList() 173 { 174 global $Config; 175 176 if($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER) 177 { 178 $Output = '<h4>Fronta úloh</h4>'; 179 $Table = new Table('TaskList'); 180 $Table->Definition['Table'] = '(SELECT Time, Title, State FROM Task WHERE User='.$this->System->Modules['User']->User['Id'].')'; 181 $Table->LoadValuesFromDatabase($this->Database); 182 $Output .= $Table->Show(); 183 $Output .= '<br /><div style="text-align: center;"><a href="?Action=TaskList">Obnovit pohled</a></dev>'; 184 } else $Output .= USER_BAD_ROLE; 146 185 return($Output); 147 186 } … … 184 223 $Output .= '<div><a href="?Action=DebugList&Id='.$Server['Id'].'">Ladící záznamy</a></div>'; 185 224 $Output .= '<div><a href="?Action=BackupList&Id='.$Server['Id'].'">Zálohy</a></div>'; 225 $Output .= '<div><a href="?Action=TaskList">Fronta úloh</a></div>'; 186 226 } else $Output .= '<div><a href="?Action=ServerAdd">Vytvořit vlastní server</a></div>'; 187 227 if($this->System->Modules['User']->User['Role'] == USER_ROLE_ADMINISTRATOR) … … 409 449 { 410 450 $Output .= $this->SystemMessage('Spuštění serveru', $Server->Start()); 451 $Output .= $this->ShowTaskList(); 411 452 } else $this->SystemMessage('Spuštění serveru', 'Nemáte oprávnění'); 412 453 } else $Output .= USER_BAD_ROLE; … … 420 461 { 421 462 $Output .= $this->SystemMessage('Zastavení serveru', $Server->Stop()); 463 $Output .= $this->ShowTaskList(); 422 464 } else $this->SystemMessage('Zastavení serveru', 'Nemáte oprávnění'); 423 465 } else $Output .= USER_BAD_ROLE; … … 432 474 $Server->ImportDatabase(true); 433 475 $Output .= $this->SystemMessage('Import čisté databáze', 'Úloha zařazena do fronty'); 476 $Output .= $this->ShowTaskList(); 434 477 } else $this->SystemMessage('Zastavení serveru', 'Nemáte oprávnění'); 435 478 } else $Output .= USER_BAD_ROLE; … … 453 496 $Emulator->Compile(); 454 497 $Output .= $this->SystemMessage('Překlad emulátoru', 'Úloha zařazena do fronty'); 498 $Output .= $this->ShowTaskList(); 455 499 } else $Output .= $this->SystemMessage('Překlad emulátoru', 'Nebylo zadáno Id'); 456 500 } else … … 458 502 { 459 503 if($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER) 460 { 461 $Output .= '<div>Ladící informace serveru</div>'; 462 $DbResult = $this->Database->query('SELECT Id FROM Server WHERE User='.$this->System->Modules['User']->User['Id']); 463 $Server = $DbResult->fetch_assoc(); 464 $MangosDebug = new MangosDebug($this->Database); 465 $Output .= $MangosDebug->Show($Server['Id']); 504 { 505 $Server = new Server($this->Database, $_GET['Id']); 506 if(($this->System->Modules['User']->User['Id'] == $Server->Server['User']) or ($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR)) 507 { 508 $Output .= '<div>Ladící informace serveru</div>'; 509 $MangosDebug = new MangosDebug($this->Database); 510 $Output .= $MangosDebug->Show($Server->Id); 511 } else $this->SystemMessage('Ladící informace', 'Nemáte oprávnění'); 466 512 } else $Output .= USER_BAD_ROLE; 467 513 } else … … 498 544 $Output = $this->ShowInfo(); 499 545 } else 546 if($_GET['Action'] == 'BackupAdd') 547 { 548 if(!array_key_exists('Id', $_GET)) $Output .= $this->SystemMessage('Ladící informace', 'Nebylo zadáno Id serveru'); 549 else if($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER) 550 { 551 $Server = new Server($this->Database, $_GET['Id']); 552 if(($this->System->Modules['User']->User['Id'] == $Server->Server['User']) or ($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR)) 553 { 554 $Backup = new Backup($this->Database, 0); 555 $Output .= $this->SystemMessage('Ruční zálohování', $Backup->Create($Server->Id)); 556 $Output .= $this->ShowTaskList(); 557 } else $this->SystemMessage('Ladící informace', 'Nemáte oprávnění'); 558 } else $Output .= USER_BAD_ROLE; 559 } else 560 if($_GET['Action'] == 'BackupDownload') 561 { 562 if(!array_key_exists('Id', $_GET)) $Output .= $this->SystemMessage('Stažení souboru zálohy', 'Nebylo zadáno Id zálohy'); 563 else if($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER) 564 { 565 $Backup = new Backup($this->Database, $_GET['Id']); 566 $Server = new Server($this->Database, $Backup->Backup['Server']); 567 if(($this->System->Modules['User']->User['Id'] == $Server->Server['User']) or ($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR)) 568 { 569 Header('Content-Type: application/x-tar-gz'); 570 Header('Content-Disposition: attachment; filename="wowhosting-'.$Backup->Id.'.tar.bz2"'); 571 echo(file_get_contents('../backup/wowhosting-'.$Backup->Id.'.tar.bz2')); 572 exit; 573 } else $this->SystemMessage('Stažení souboru zálohy', 'Nemáte oprávnění'); 574 } else $Output .= USER_BAD_ROLE; 575 } else 576 if($_GET['Action'] == 'TaskList') 577 { 578 $Output .= $this->ShowTaskList(); 579 } else 500 580 if($_GET['Action'] == 'Test') 501 581 { -
trunk/www/table.php
r24 r28 19 19 } 20 20 21 function CheckOrder() 22 { 23 if(!array_key_exists('Order', $_GET)) 24 { 25 if(array_key_exists('DefaultOrderDirection', $this->Definition)) $_GET['Order'] = $this->Definition['DefaultOrderDirection']; 26 else $_GET['Order'] = 0; 27 }; 28 if(!array_key_exists('Column', $_GET)) 29 { 30 if(array_key_exists('DefaultOrderColumn', $this->Definition)) $_GET['Column'] = $this->Definition['DefaultOrderColumn']; 31 else 32 { 33 $Keys = array_keys($this->Definition['Items']); 34 $_GET['Column'] = $Keys[0]; 35 } 36 } 37 } 38 21 39 function Show() 22 40 { 23 41 global $Config; 24 42 43 $this->CheckOrder(); 25 44 $Header = array(); 26 if(!array_key_exists('Order', $_GET)) $_GET['Order'] = 0;27 if(!array_key_exists('Column', $_GET)) $_GET['Column'] = 0;28 45 $QueryStringArray = GetQueryStringArray(); 29 46 $QueryStringArray['Order'] = $_GET['Order']; 30 47 foreach($this->Definition['Items'] as $Index => $Item) 31 48 { 32 $QueryStringArray['Column'] = $Index; 33 if($_GET['Column'] == $Index) $QueryStringArray['Order'] = 1 - $_GET['Order']; 34 else $QueryStringArray['Order'] = $_GET['Order']; 35 $Header[] = '<a href="?'.SetQueryStringArray($QueryStringArray).'">'.$Item['Caption'].'</a>'; 49 if($Item['Type'] != 'Hidden') 50 { 51 $QueryStringArray['Column'] = $Index; 52 if($_GET['Column'] == $Index) $QueryStringArray['Order'] = 1 - $_GET['Order']; 53 else $QueryStringArray['Order'] = $_GET['Order']; 54 $Header[] = '<a href="?'.SetQueryStringArray($QueryStringArray).'">'.$Item['Caption'].'</a>'; 55 } 36 56 } 37 57 $Table = array( … … 48 68 global $Config; 49 69 70 $this->CheckOrder(); 50 71 $OrderType = array('ASC', 'DESC'); 51 if(!array_key_exists('Order', $_GET)) $_GET['Order'] = 0;52 else if($_GET['Order'] == 'Asc') $_GET['Order'] = 1;53 if(!array_key_exists('Column', $_GET))54 {55 $Keys = array_keys($this->Definition['Items']);56 $_GET['Column'] = $Keys[0];57 }58 72 $this->Header = array(); 59 73 foreach($this->Definition['Items'] as $Index => $Item) … … 84 98 $DbRow[$Index] = ExecuteTypeEvent($Item['Type'], 'OnView', 85 99 array('Name' => $Index, 'Value' => $DbRow[$Index], 'Type' => $Item['Type'])); 86 $Row[ ] = $DbRow[$Index];100 $Row[$Index] = $DbRow[$Index]; 87 101 } 88 102 $this->Values[] = $Row; -
trunk/www/task.php
r22 r28 22 22 23 23 chdir($Config['BaseDir']); 24 $DbResult = $this->Database->query('SELECT * FROM Task WHERE State = "Waiting"ORDER BY Id,Time ASC');24 $DbResult = $this->Database->query('SELECT * FROM Task WHERE State = 0 ORDER BY Id,Time ASC'); 25 25 while($Task = $DbResult->fetch_assoc()) 26 26 { 27 $this->Database->query('UPDATE Task SET State= "Running"WHERE Id='.$Task['Id']);27 $this->Database->query('UPDATE Task SET State=1 WHERE Id='.$Task['Id']); 28 28 echo('Provádím úlohu '.$Task['Id'].': '.$Task['Title']."...\n"); 29 29 $Task['CommandList'] = "#!/bin/sh\n".$Task['CommandList']; … … 34 34 $Output = implode("\n", $Output); 35 35 echo($Output); 36 $this->Database->query('UPDATE Task SET State="Finished", Output="'.addslashes($Output).'" WHERE Id='.$Task['Id']); 36 echo("Hotovo\n"); 37 $this->Database->query('UPDATE Task SET State=2, Output="'.addslashes($Output).'" WHERE Id='.$Task['Id']); 37 38 } 38 return($Output);39 39 } 40 41 function GetUserTaskList($UserId) 42 { 43 $Output = ''; 44 $DbResult = $this->Database->query('SELECT * FROM Task WHERE (State IN ("Waiting", "Running")) AND (User='.$UserId.') ORDER BY Id,Time ASC'); 45 while($DbRow = $DbResult->fetch_assoc()) 46 { 47 $Output .= ''; 48 } 49 return($Output); 50 } 51 40 52 41 function Abort($Id) 53 42 { -
trunk/www/task_process.php
r13 r28 4 4 5 5 $Task = new Task($Database); 6 $Task->ProcessAll(); 6 while(1) 7 { 8 $Task->ProcessAll(); 9 sleep(1); 10 } 7 11 8 12 ?>
Note:
See TracChangeset
for help on using the changeset viewer.