Changeset 35
- Timestamp:
- Jun 15, 2009, 10:19:02 AM (15 years ago)
- Location:
- trunk/www
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/www/backup.php
r31 r35 20 20 $ServerId = $this->Backup['Server']; 21 21 $this->Task->Add('Obnovení databáze', array( 22 'php www/shell.php ServerLock '.$ServerId, 22 23 'mysql --silent --skip-column-names -u server'.$ServerId.' -pserver'.$ServerId.' server'.$ServerId.'_mangos -e "show tables" | gawk \'{print "drop table " $1 ";"}\' | mysql -u server'.$ServerId.' -pserver'.$ServerId.' server'.$ServerId.'_mangos', 23 24 'mysql --silent --skip-column-names -u server'.$ServerId.' -pserver'.$ServerId.' server'.$ServerId.'_characters -e "show tables" | gawk \'{print "drop table " $1 ";"}\' | mysql -u server'.$ServerId.' -pserver'.$ServerId.' server'.$ServerId.'_characters', … … 31 32 'mysql --user=server'.$ServerId.' --password=server'.$ServerId.' server'.$ServerId.'_scriptdev2 < temp/wowhosting/scriptdev2.sql', 32 33 'rm -rf temp/wowhosting', 34 'php www/shell.php ServerUnLock '.$ServerId, 33 35 )); 34 36 return('Úloha obnovení databáze ze zálohy zařazena do fronty.'); … … 39 41 $Server = new Server($this->Database, $ServerId); 40 42 $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']; 41 $this->Database->insert('Backup', array('Server' => $ServerId, 'Time' => 'NOW()', 'Description' => $Description ));43 $this->Database->insert('Backup', array('Server' => $ServerId, 'Time' => 'NOW()', 'Description' => $Description, 'Lock' => 1)); 42 44 $this->Id = $this->Database->insert_id; 43 45 $this->Task->Add('Záloha databáze serveru', array( 46 'php www/shell.php ServerLock '.$ServerId, 44 47 'mkdir temp/wowhosting', 45 48 'mysqldump --user=server'.$ServerId.' --password=server'.$ServerId.' --opt server'.$ServerId.'_characters > temp/wowhosting/characters.sql', … … 50 53 'tar -c -j wowhosting > ../backup/wowhosting-'.$this->Id.'.tar.bz2', 51 54 'rm -rf wowhosting', 55 'php www/shell.php BackupUnLock '.$this->Id, 56 'php www/shell.php ServerUnLock '.$ServerId, 52 57 )); 53 58 return('Úloha zálohování byla zařazena do fronty.'); 54 59 } 60 61 function Lock() 62 { 63 $this->Database->update('Backup', 'Id='.$this->Id, array('Lock' => 1)); 64 } 65 66 function UnLock() 67 { 68 $this->Database->update('Backup', 'Id='.$this->Id, array('Lock' => 0)); 69 } 55 70 } 56 71 -
trunk/www/emulator.php
r34 r35 37 37 $this->Lock(); 38 38 $this->Task->Add('Stažení emulátoru', array( 39 'php www/shell.php EmulatorLock '.$this->Id, 39 40 'mkdir '.$Config['BaseDir'].'emulator/'.$this->Id.'/', 40 41 'cd '.$Config['BaseDir'].'emulator/'.$this->Id.'/', … … 45 46 'svn checkout -r '.$this->Emulator['ScriptDev2Revision'].' https://scriptdev2.svn.sourceforge.net/svnroot/scriptdev2/ src/bindings/ScriptDev2', 46 47 'git apply src/bindings/ScriptDev2/patches/'.$this->Emulator['ScriptDev2PatchFileName'], 48 'php www/shell.php EmulatorUnLock '.$this->Id, 47 49 )); 48 50 } … … 54 56 $this->Lock(); 55 57 $this->Task->Add('Překlad emulátoru', array( 58 'php www/shell.php EmulatorLock '.$this->Id, 56 59 'cd '.$Config['BaseDir'].'emulator/'.$this->Id.'/source', 57 60 'autoreconf -ifv', … … 63 66 'make', 64 67 'make install', 68 'php www/shell.php EmulatorUnLock '.$this->Id, 65 69 )); 66 70 } … … 70 74 $this->Lock(); 71 75 $this->Task->Add('Vygenerování souborů map', array( 76 'php www/shell.php EmulatorLock '.$this->Id, 72 77 'cd wowclient/'.$this->Emulator['Client']['Version'].'/client', 73 78 'wine emulator/'.$this->Id.'/source/contrib/extractor/ad.exe', 74 79 'mv wowclient/'.$this->Emulator['Client']['Version'].'/client/dbc wowclient/'.$this->Emulator['Client']['Version'].'/', 75 80 'mv wowclient/'.$this->Emulator['Client']['Version'].'/client/maps wowclient/'.$this->Emulator['Client']['Version'].'/', 81 'php www/shell.php EmulatorUnLock '.$this->Id, 76 82 )); 77 83 return('Požadavek na vygenerování map zařazen.'); 78 84 } 79 80 85 81 86 function Lock() -
trunk/www/global.php
r34 r35 1 1 <?php 2 3 chdir(substr($_SERVER['SCRIPT_FILENAME'], 0, strrpos($_SERVER['SCRIPT_FILENAME'], '/'))); 2 4 3 5 $ScriptTimeStart = GetMicrotime(); -
trunk/www/index.php
r34 r35 113 113 foreach($Table->Values as $Index => $Item) 114 114 { 115 $Table->Values[$Index]['Actions'] = '<a href="?Action=EmulatorShow&Id='.$Item['Id'].'">Pod probnosti</a>';115 $Table->Values[$Index]['Actions'] = '<a href="?Action=EmulatorShow&Id='.$Item['Id'].'">Podrobnosti</a>'; 116 116 if($Server->Server['Lock'] == 0) $Table->Values[$Index]['Actions'] .= ' <a href="?Action=Update&Server='.$ServerId.'&Update='.$Item['Id'].'">Aktualizovat</a>'; 117 117 unset($Table->Values[$Index]['Id']); … … 161 161 $Table->Table = '(SELECT * FROM `Backup` WHERE `Server` = '.$ServerId.')'; 162 162 $Table->Definition['Items']['Id'] = array('Type' => 'Hidden', 'Caption' => 'Id', 'Default' => ''); 163 $Table->Definition['Items']['Lock'] = array('Type' => 'Hidden', 'Caption' => 'Zámek', 'Default' => ''); 163 164 $Table->LoadValuesFromDatabase($this->Database); 164 165 $Table->Definition['Items']['Actions'] = array('Type' => 'String', 'Caption' => '', 'Default' => ''); 165 166 foreach($Table->Values as $Index => $Value) 166 167 { 167 $Table->Values[$Index]['Actions'] = '<a href="?Action=BackupDownload&Id='.$Value['Id'].'">Stáhnout</a>';168 if( $Server->Server['Lock'] == 0) $Table->Values[$Index]['Actions'] .= ' <a href="?Action=BackupRestore&Id='.$Value['Id'].'">Obnovit</a>';168 if($Value['Lock'] == 0) $Table->Values[$Index]['Actions'] = '<a href="?Action=BackupDownload&Id='.$Value['Id'].'">Stáhnout</a>'; 169 if(($Server->Server['Lock'] == 0) and ($Value['Lock'] == 0)) $Table->Values[$Index]['Actions'] .= ' <a href="?Action=BackupRestore&Id='.$Value['Id'].'">Obnovit</a>'; 169 170 unset($Table->Values[$Index]['Id']); 171 unset($Table->Values[$Index]['Lock']); 170 172 } 171 173 $Output .= $Table->Show(); … … 216 218 $Table = new Table('TaskList'); 217 219 $Table->OnRow = array($this, 'ShowTaskListOnRow'); 218 $Table->Definition['Table'] = '(SELECT ( UNIX_TIMESTAMP(TimeEnd) - UNIX_TIMESTAMP(TimeStart)) AS Duration, TimeCreate, Title, State FROM Task WHERE User='.$this->System->Modules['User']->User['Id'].' ORDER BY Id DESC)';220 $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)'; 219 221 $Table->LoadValuesFromDatabase($this->Database); 220 222 $Output .= $Table->Show(); … … 481 483 $Form = new Form('NewServer', array()); 482 484 $Form->LoadValuesFromForm(); 483 $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, 'NetworkPortWorldd' => $NewPortWorldd, 'NetworkPortRealmd' => $NewPortRealmd ));485 $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, 'NetworkPortWorldd' => $NewPortWorldd, 'NetworkPortRealmd' => $NewPortRealmd, 'Lock' => 1)); 484 486 $LastInsertId = $this->Database->insert_id; 485 487 $Server = new Server($this->Database, $LastInsertId); 486 $Server->CreateDatabase(); 487 $Server->ImportDatabase(true); 488 $Output .= $this->SystemMessage('Vytvoření serveru', 'Úloha načtení nové databáze zařazena do fronty'); 488 $Server->CreateDatabase(); 489 $Output .= $this->SystemMessage('Vytvoření serveru', $Server->ImportDatabase(true)); 489 490 $Output .= $this->ShowTaskList(); 490 491 //$UserOptions->LoadValuesFromDatabase($this->System->Modules['User']->User['Id']); -
trunk/www/server.php
r34 r35 58 58 $this->Lock(); 59 59 $CommandList = array( 60 'php www/shell.php ServerLock '.$this->Id, 61 ); 62 if($Delete == true) 63 { 64 $CommandList = array_merge($CommandList, array( 65 'mysql --silent --skip-column-names -u server'.$this->Id.' -pserver'.$this->Id.' server'.$this->Id.'_mangos -e "show tables" | gawk \'{print "drop table " $1 ";"}\' | mysql -u server'.$this->Id.' -pserver'.$this->Id.' server'.$this->Id.'_mangos', 66 'mysql --silent --skip-column-names -u server'.$this->Id.' -pserver'.$this->Id.' server'.$this->Id.'_characters -e "show tables" | gawk \'{print "drop table " $1 ";"}\' | mysql -u server'.$this->Id.' -pserver'.$this->Id.' server'.$this->Id.'_characters', 67 'mysql --silent --skip-column-names -u server'.$this->Id.' -pserver'.$this->Id.' server'.$this->Id.'_realmd -e "show tables" | gawk \'{print "drop table " $1 ";"}\' | mysql -u server'.$this->Id.' -pserver'.$this->Id.' server'.$this->Id.'_realmd', 68 'mysql --silent --skip-column-names -u server'.$this->Id.' -pserver'.$this->Id.' server'.$this->Id.'_scriptdev2 -e "show tables" | gawk \'{print "drop table " $1 ";"}\' | mysql -u server'.$this->Id.' -pserver'.$this->Id.' server'.$this->Id.'_scriptdev2', 69 )); 70 } 71 $CommandList = array_merge($CommandList, array( 60 72 'mysql --user=server'.$this->Id.' --password=server'.$this->Id.' server'.$this->Id.'_mangos < database/'.$this->Server['Database']['Id'].'/'.$this->Server['Database']['SourceFileName'], 61 73 'mysql --user=server'.$this->Id.' --password=server'.$this->Id.' server'.$this->Id.'_scriptdev2 < emulator/'.$this->Server['Database']['Emulator']['Id'].'/source/src/bindings/ScriptDev2/sql/scriptdev2_create_structure.sql', … … 64 76 'mysql --user=server'.$this->Id.' --password=server'.$this->Id.' server'.$this->Id.'_realmd < emulator/'.$this->Server['Database']['Emulator']['Id'].'/share/mangos/sql/realmd.sql', 65 77 'mysql --user=server'.$this->Id.' --password=server'.$this->Id.' server'.$this->Id.'_characters < emulator/'.$this->Server['Database']['Emulator']['Id'].'/share/mangos/sql/characters.sql', 66 ); 67 if($Delete == true) 68 { 69 array_unshift($CommandList, 'mysql --silent --skip-column-names -u server'.$this->Id.' -pserver'.$this->Id.' server'.$this->Id.'_mangos -e "show tables" | gawk \'{print "drop table " $1 ";"}\' | mysql -u server'.$this->Id.' -pserver'.$this->Id.' server'.$this->Id.'_mangos'); 70 array_unshift($CommandList, 'mysql --silent --skip-column-names -u server'.$this->Id.' -pserver'.$this->Id.' server'.$this->Id.'_characters -e "show tables" | gawk \'{print "drop table " $1 ";"}\' | mysql -u server'.$this->Id.' -pserver'.$this->Id.' server'.$this->Id.'_characters'); 71 array_unshift($CommandList, 'mysql --silent --skip-column-names -u server'.$this->Id.' -pserver'.$this->Id.' server'.$this->Id.'_realmd -e "show tables" | gawk \'{print "drop table " $1 ";"}\' | mysql -u server'.$this->Id.' -pserver'.$this->Id.' server'.$this->Id.'_realmd'); 72 array_unshift($CommandList, 'mysql --silent --skip-column-names -u server'.$this->Id.' -pserver'.$this->Id.' server'.$this->Id.'_scriptdev2 -e "show tables" | gawk \'{print "drop table " $1 ";"}\' | mysql -u server'.$this->Id.' -pserver'.$this->Id.' server'.$this->Id.'_scriptdev2'); 73 } 78 'php www/shell.php ServerDatabaseChange '.$this->Server['Database']['Id'], 79 'php www/shell.php ServerUnLock '.$thisr->Id, 80 )); 74 81 $this->Task->Add('Inicializace databáze', $CommandList); 82 return('Úloha načtení nové databáze zařazena do fronty.'); 75 83 } 76 84 … … 79 87 $this->Lock(); 80 88 $this->Task->Add('Start emulátoru', array( 89 'php www/shell.php ServerLock '.$this->Id, 81 90 'screen -A -m -d -S server'.$this->Id.'-realmd emulator/'.$this->Server['Database']['Emulator']['Id'].'/bin/mangos-realmd -c server/'.$this->Id.'/etc/realmd.conf', 82 91 'screen -A -m -d -S server'.$this->Id.'-worldd server/'.$this->Id.'/bin/start.sh', 92 'php www/shell.php ServerUnLock '.$this->Id, 83 93 )); 84 94 return('Požadavek na start serveru zařazen.'); … … 89 99 $this->Lock(); 90 100 $this->Task->Add('Zastavení emulátoru', array( 101 'php www/shell.php ServerLock '.$this->Id, 91 102 'server/'.$this->Id.'/bin/stop.sh', 103 'php www/shell.php ServerUnLock '.$this->Id, 92 104 )); 93 105 return('Požadavek na zastavení serveru zařazen.'); … … 283 295 284 296 // Do update 285 $Commands = array(); 297 $Commands = array( 298 'php www/shell.php ServerLock '.$this->Id, 299 ); 286 300 $DbResult = $this->Database->query('SELECT `Revision` FROM `Database` WHERE `Id` = '.$this->Server['Database']['Id']); 287 301 $DbRow = $DbResult->fetch_assoc(); … … 302 316 } 303 317 } 318 $Commands = array_merge($Commands, array( 319 'php www/shell.php ServerDatabaseChange '.$DatabaseId, 320 'php www/shell.php ServerUnLock '.$this->Id, 321 )); 322 304 323 $this->Task->Add('Aktualizace databáze', $Commands); 305 324 $Output .= '<br />Úloha aktualizace serveru byla přidána do fronty.'; … … 316 335 $this->Database->update('Server', 'Id='.$this->Id, array('Lock' => 0)); 317 336 } 337 338 function ChangeDatabaseId($Id) 339 { 340 $this->Database->update('Server', 'Id='.$this->Id, array('Database' => $Id)); 341 $this->SaveConfiguration(); 342 } 318 343 } 319 344 -
trunk/www/shell.php
r34 r35 3 3 include('global.php'); 4 4 5 $Output = ''; 5 6 if(count($_SERVER['argv']) > 1) 6 7 { … … 18 19 if((count($_SERVER['argv']) > 2) and is_numeric($_SERVER['argv'][2])) 19 20 { 20 $Server = new Server($ _SERVER['argv'][2]);21 $Server = new Server($Database, $_SERVER['argv'][2]); 21 22 $Server->Lock(); 22 23 } else $Output = 'Jako druhý parameter je nutno zadat Id serveru.'; … … 26 27 if((count($_SERVER['argv']) > 2) and is_numeric($_SERVER['argv'][2])) 27 28 { 28 $Server = new Server($ _SERVER['argv'][2]);29 $Server = new Server($Database, $_SERVER['argv'][2]); 29 30 $Server->UnLock(); 30 31 } else $Output = 'Jako druhý parameter je nutno zadat Id serveru.'; 32 } else 33 if($Command == 'EmulatorLock') 34 { 35 if((count($_SERVER['argv']) > 2) and is_numeric($_SERVER['argv'][2])) 36 { 37 $Emulator = new Emulator($Database, $_SERVER['argv'][2]); 38 $Emulator->Lock(); 39 } else $Output = 'Jako druhý parameter je nutno zadat Id emulátoru.'; 40 } else 41 if($Command == 'EmulatorUnLock') 42 { 43 if((count($_SERVER['argv']) > 2) and is_numeric($_SERVER['argv'][2])) 44 { 45 $Emulator = new Emulator($Database, $_SERVER['argv'][2]); 46 $Emulator->UnLock(); 47 } else $Output = 'Jako druhý parameter je nutno zadat Id emulátoru.'; 48 } else 49 if($Command == 'BackupLock') 50 { 51 if((count($_SERVER['argv']) > 2) and is_numeric($_SERVER['argv'][2])) 52 { 53 $Backup = new Backup($Database, $_SERVER['argv'][2]); 54 $Backup->Lock(); 55 } else $Output = 'Jako druhý parameter je nutno zadat Id zálohy.'; 56 } else 57 if($Command == 'BackupUnLock') 58 { 59 if((count($_SERVER['argv']) > 2) and is_numeric($_SERVER['argv'][2])) 60 { 61 $Backup = new Backup($Database, $_SERVER['argv'][2]); 62 $Backup->UnLock(); 63 } else $Output = 'Jako druhý parameter je nutno zadat Id zálohy.'; 31 64 } else 32 65 if($Command == 'TaskProcess') 33 66 { 34 67 $Task = new Task($Database); 35 while(1) 68 $Task->ProcessAllCycle(); 69 } else 70 if($Command == 'ServerDatabaseChange') 71 { 72 if((count($_SERVER['argv']) > 2) and is_numeric($_SERVER['argv'][2])) 36 73 { 37 $ Task->ProcessAll();38 sleep(1);39 } 74 $Server = new Server($Database, $_SERVER['argv'][2]); 75 $Server->ChangeDatabaseId($_SERVER['argv'][2]); 76 } else $Output = 'Jako druhý parameter je nutno zadat Id serveru.'; 40 77 } else 41 78 $Output = 'Neznámý příkaz '.$Command; 42 } else $Output = 'Jako první parameter je nutno zada rpovel.';79 } else $Output = 'Jako první parameter je nutno zadat povel.'; 43 80 echo($Output); 44 81 -
trunk/www/task.php
r34 r35 40 40 } 41 41 } 42 43 function ProcessAllCycle() 44 { 45 while(1) 46 { 47 $this->ProcessAll(); 48 sleep(1); 49 } 50 } 42 51 43 52 function Abort($Id)
Note:
See TracChangeset
for help on using the changeset viewer.