Changeset 38
- Timestamp:
- Jun 16, 2009, 5:26:23 PM (15 years ago)
- Location:
- trunk/www
- Files:
-
- 2 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/www/backup.php
r36 r38 54 54 'tar -c -j wowhosting > ../backup/wowhosting-'.$this->Id.'.tar.bz2', 55 55 'rm -rf wowhosting', 56 'cd ..', 56 57 'php www/shell.php BackupUnLock '.$this->Id, 57 58 'php www/shell.php ServerUnLock '.$ServerId, -
trunk/www/config.sample.php
r21 r38 35 35 'BaseNetworkPortRealmd' => 3724, 36 36 'MangosWorlddThreadCountMax' => 12, 37 'BackupCountPerServer' => 20, 37 38 ); 38 39 -
trunk/www/form_classes.php
r34 r38 69 69 'Homepage' => array('Type' => 'Hyperlink', 'Caption' => 'Webové stránky', 'Default' => ''), 70 70 'Type' => array('Type' => 'ServerType', 'Caption' => 'Typ', 'Default' => 0), 71 'Database' => array('Type' => 'Database', 'Caption' => 'Databáze', 'Default' => 0),71 //'Database' => array('Type' => 'Database', 'Caption' => 'Databáze', 'Default' => 0), 72 72 'Motd' => array('Type' => 'String', 'Caption' => 'Zpráva dne', 'Default' => 'Vítejte na free WoW serveru'), 73 73 'ServerId' => array('Type' => 'Hidden', 'Caption' => 'Id', 'Default' => 0), -
trunk/www/global.php
r35 r38 30 30 include('backup.php'); 31 31 include('platform.php'); 32 include('history.php'); 32 33 33 34 $PrefixMultipliers = array -
trunk/www/platform.php
r33 r38 73 73 $State['ServerMaxCount'] = $Config['MaxServerCount']; 74 74 return($State); 75 } 76 75 } 77 76 } 78 77 -
trunk/www/server.php
r36 r38 341 341 $this->SaveConfiguration(); 342 342 } 343 344 function GetUsedMemory() 345 { 346 $Output = array(); 347 exec('ps -aux|grep "emulator/'.$this->Server['Database']['Emulator']['Id'].'/bin/mangos-worldd -c server/'.$this->Id.'/etc/mangosd.conf"| grep -v grep', $Output); 348 print_r($Output); 349 if(count($Output) > 0) 350 { 351 while(strpos($Output[0], ' ') > 0) $Output[0] = str_replace(' ', ' ', $Output[0]); 352 $Parts = explode(' ', $Output[0]); 353 return($Parts[4]); 354 } else return(0); 355 } 356 343 357 } 344 358 -
trunk/www/shell.php
r36 r38 3 3 include('global.php'); 4 4 5 $Output = ''; 6 if(count($_SERVER['argv']) > 1) 5 class Shell extends Module 7 6 { 8 $Command = $_SERVER['argv'][1]; 9 if($Command == 'ServerProcessLog') 7 var $Database; 8 9 function __construct($Database) 10 10 { 11 if((count($_SERVER['argv']) > 2) and is_numeric($_SERVER['argv'][2])) 11 $this->Database = $Database; 12 } 13 14 function HistoryUpdate() 15 { 16 $DbResult = $this->Database->query('SELECT Id FROM Server'); 17 while($Server = $DbResult->fetch_assoc()) 12 18 { 13 $MangosDebug = new MangosDebug($Database); 14 $Output = $MangosDebug->ProcessLog($_SERVER['argv'][2]); 15 } else $Output = 'Jako druhý parameter je nutno zadat Id serveru.'; 16 } else 17 if($Command == 'ServerLock') 19 $History = new History($this->Database, $Server['Id'], 1); 20 $Server = new Server($this->Database, $Server['Id']); 21 $History->AddValue($Server->GetUsedMemory()); 22 } 23 } 24 25 function Show() 18 26 { 19 if((count($_SERVER['argv']) > 2) and is_numeric($_SERVER['argv'][2])) 27 $Output = ''; 28 if(count($_SERVER['argv']) > 1) 20 29 { 21 $Server = new Server($Database, $_SERVER['argv'][2]); 22 $Server->Lock(); 23 } else $Output = 'Jako druhý parameter je nutno zadat Id serveru.'; 24 } else 25 if($Command == 'ServerUnLock') 26 { 27 if((count($_SERVER['argv']) > 2) and is_numeric($_SERVER['argv'][2])) 28 { 29 $Server = new Server($Database, $_SERVER['argv'][2]); 30 $Server->UnLock(); 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.'; 64 } else 65 if($Command == 'TaskProcess') 66 { 67 $Task = new Task($Database); 68 $Task->ProcessAllCycle(); 69 } else 70 if($Command == 'ServerDatabaseChange') 71 { 72 if((count($_SERVER['argv']) > 3) and is_numeric($_SERVER['argv'][2]) and is_numeric($_SERVER['argv'][3])) 73 { 74 $Server = new Server($Database, $_SERVER['argv'][2]); 75 $Server->ChangeDatabaseId($_SERVER['argv'][3]); 76 } else $Output = 'Jako druhý parameter je nutno zadat Id serveru, jako třetí Id databáze.'; 77 } else 78 $Output = 'Neznámý příkaz '.$Command; 79 } else $Output = 'Jako první parameter je nutno zadat povel.'; 80 echo($Output); 30 $Command = $_SERVER['argv'][1]; 31 if($Command == 'ServerProcessLog') 32 { 33 if((count($_SERVER['argv']) > 2) and is_numeric($_SERVER['argv'][2])) 34 { 35 $MangosDebug = new MangosDebug($this->Database); 36 $Output = $MangosDebug->ProcessLog($_SERVER['argv'][2]); 37 } else $Output = 'Jako druhý parameter je nutno zadat Id serveru.'; 38 } else 39 if($Command == 'ServerLock') 40 { 41 if((count($_SERVER['argv']) > 2) and is_numeric($_SERVER['argv'][2])) 42 { 43 $Server = new Server($this->Database, $_SERVER['argv'][2]); 44 $Server->Lock(); 45 } else $Output = 'Jako druhý parameter je nutno zadat Id serveru.'; 46 } else 47 if($Command == 'ServerUnLock') 48 { 49 if((count($_SERVER['argv']) > 2) and is_numeric($_SERVER['argv'][2])) 50 { 51 $Server = new Server($this->Database, $_SERVER['argv'][2]); 52 $Server->UnLock(); 53 } else $Output = 'Jako druhý parameter je nutno zadat Id serveru.'; 54 } else 55 if($Command == 'EmulatorLock') 56 { 57 if((count($_SERVER['argv']) > 2) and is_numeric($_SERVER['argv'][2])) 58 { 59 $Emulator = new Emulator($this->Database, $_SERVER['argv'][2]); 60 $Emulator->Lock(); 61 } else $Output = 'Jako druhý parameter je nutno zadat Id emulátoru.'; 62 } else 63 if($Command == 'EmulatorUnLock') 64 { 65 if((count($_SERVER['argv']) > 2) and is_numeric($_SERVER['argv'][2])) 66 { 67 $Emulator = new Emulator($this->Database, $_SERVER['argv'][2]); 68 $Emulator->UnLock(); 69 } else $Output = 'Jako druhý parameter je nutno zadat Id emulátoru.'; 70 } else 71 if($Command == 'BackupLock') 72 { 73 if((count($_SERVER['argv']) > 2) and is_numeric($_SERVER['argv'][2])) 74 { 75 $Backup = new Backup($this->Database, $_SERVER['argv'][2]); 76 $Backup->Lock(); 77 } else $Output = 'Jako druhý parameter je nutno zadat Id zálohy.'; 78 } else 79 if($Command == 'BackupUnLock') 80 { 81 if((count($_SERVER['argv']) > 2) and is_numeric($_SERVER['argv'][2])) 82 { 83 $Backup = new Backup($this->Database, $_SERVER['argv'][2]); 84 $Backup->UnLock(); 85 } else $Output = 'Jako druhý parameter je nutno zadat Id zálohy.'; 86 } else 87 if($Command == 'TaskProcess') 88 { 89 $Task = new Task($this->Database); 90 $Task->ProcessAllCycle(); 91 } else 92 if($Command == 'HistoryUpdate') 93 { 94 $this->HistoryUpdate(); 95 } else 96 if($Command == 'ServerDatabaseChange') 97 { 98 if((count($_SERVER['argv']) > 3) and is_numeric($_SERVER['argv'][2]) and is_numeric($_SERVER['argv'][3])) 99 { 100 $Server = new Server($this->Database, $_SERVER['argv'][2]); 101 $Server->ChangeDatabaseId($_SERVER['argv'][3]); 102 } else $Output = 'Jako druhý parameter je nutno zadat Id serveru, jako třetí Id databáze.'; 103 } else 104 $Output = 'Neznámý příkaz '.$Command; 105 } else $Output = 'Jako první parameter je nutno zadat povel.'; 106 return($Output); 107 } 108 } 109 110 $Shell = new Shell($Database); 111 echo($Shell->Show()); 81 112 82 113 ?> -
trunk/www/task.php
r35 r38 25 25 $DbResult = $this->Database->query('SELECT * FROM Task WHERE State = 0 ORDER BY Id,TimeCreate ASC'); 26 26 $this->Database->query('UPDATE Task SET State=2 WHERE State=1'); // Change not finished running tasks to finished 27 $this->Database->query('UPDATE Task SET TimeEnd=NOW() WHERE State=2'); // Set end time to finished tasks 27 28 while($Task = $DbResult->fetch_assoc()) 28 29 { … … 32 33 file_put_contents($this->TempScript, $Task['CommandList']); 33 34 chmod($this->TempScript, 0755); 34 //passthru($this->TempScript, $Output); 35 exec($this->TempScript, $Output); 36 $Output = implode("\n", $Output); 37 echo($Output); 35 exec($this->TempScript.' >'.$this->TempScript.'.log 2>'.$this->TempScript.'.err'); 36 $StdOut = file_get_contents($this->TempScript.'.log'); 37 unlink($this->TempScript.'.log'); 38 $StdErr = file_get_contents($this->TempScript.'.err'); 39 unlink($this->TempScript.'.err'); 38 40 echo("Hotovo\n"); 39 $this->Database->query('UPDATE Task SET TimeEnd=NOW(), State=2, Output="'.addslashes($Output).'" WHERE Id='.$Task['Id']);41 $this->Database->query('UPDATE `Task` SET `TimeEnd`=NOW(), `State`=2, `Output`="'.addslashes($StdOut).'", `Error`="'.addslashes($StdErr).'" WHERE `Id`='.$Task['Id']); 40 42 } 41 43 }
Note:
See TracChangeset
for help on using the changeset viewer.