Changeset 5 for trunk/www/server.php
- Timestamp:
- Jun 9, 2009, 10:39:27 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/www/server.php
r4 r5 5 5 var $Id; 6 6 var $Server; 7 var $WorlddBaseNetworkPort = 8085; 8 var $RealmdBaseNetworkPort = 3724; 7 9 8 10 function __construct($Database, $Id) … … 16 18 $DbResult = $this->Database->query('SELECT * FROM `Emulator` WHERE `Id`='.$this->Server['Database']['Emulator']); 17 19 $this->Server['Database']['Emulator'] = $DbResult->fetch_assoc(); 20 $DbResult = $this->Database->query('SELECT * FROM `ClientVersion` WHERE `Id`='.$this->Server['Database']['Emulator']['ClientVersion']); 21 $this->Server['Database']['Emulator']['ClientVersion'] = $DbResult->fetch_assoc(); 18 22 } 19 23 … … 45 49 function Start() 46 50 { 47 AddTask('Start emulátoru', array(48 'screen -A -m -d -S server'.$this->Id.'-realmd emu/mangos/'.$this->Server['Database']['Emulator']['Revision'].'/bin/mangos-realmd -c server/'.$this->Id.'/etc/realmd.conf',49 'screen -A -m -d -S server'.$this->Id.'- realmd emu/mangos/'.$this->Server['Database']['Emulator']['Revision'].'/bin/mangos-worldd -c server/'.$this->Id.'/etc/mangosd.conf',51 $this->AddTask('Start emulátoru', array( 52 'screen -A -m -d -S server'.$this->Id.'-realmd "emu/mangos/'.$this->Server['Database']['Emulator']['Revision'].'/bin/mangos-realmd -c server/'.$this->Id.'/etc/realmd.conf"', 53 'screen -A -m -d -S server'.$this->Id.'-worldd emu/mangos/'.$this->Server['Database']['Emulator']['Revision'].'/bin/mangos-worldd -c server/'.$this->Id.'/etc/mangosd.conf', 50 54 )); 55 return('Požadavek na start serveru zařazen.'); 51 56 } 52 57 53 58 function Stop() 54 59 { 55 AddTask('Zastavení emulátoru', array(60 $this->AddTask('Zastavení emulátoru', array( 56 61 'ps -ef | grep \'SCREEN -A -m -d -S server'.$this->Id.'-realmd\' | grep -v grep | awk \'{print $2}\' | xargs -i kill {}', 57 62 'ps -ef | grep \'SCREEN -A -m -d -S server'.$this->Id.'-worldd\' | grep -v grep | awk \'{print $2}\' | xargs -i kill {}', 58 63 )); 64 return('Požadavek na zastavení serveru zařazen.'); 65 } 66 67 function NetworkPortState($Address, $Port, $Timeout = 1) 68 { 69 if($Socket = @fsockopen($Address, $Port, $ERROR_NO, $ERROR_STR, (float)$Timeout)) 70 { 71 fclose($Socket); 72 return(true); 73 } else return(false); 74 } 75 76 function GetState() 77 { 78 $State = array(); 79 $State['RealmdPortState'] = $this->NetworkPortState('localhost', $this->RealmdBaseNetworkPort + $this->Server['Id']); 80 $State['WorlddPortState'] = $this->NetworkPortState('localhost', $this->WorlddBaseNetworkPort + $this->Server['Id']); 81 return($State); 82 } 83 84 function SetupConfigurationFiles() 85 { 86 // mangosd.conf 87 $Config = new MangosConfigurationFile($this->Database); 88 $Config->Load('../emu/mangos/'.$this->Server['Database']['Emulator']['Revision'].'/etc/mangosd.conf'); 89 $Config->ParameterList['LoginDatabaseInfo'] = 'localhost;3306;server'.$this->Id.';server'.$this->Id.';server'.$this->Id.'_realmd'; 90 $Config->ParameterList['WorldDatabaseInfo'] = 'localhost;3306;server'.$this->Id.';server'.$this->Id.';server'.$this->Id.'_mangos'; 91 $Config->ParameterList['CharacterDatabaseInfo'] = 'localhost;3306;server'.$this->Id.';server'.$this->Id.';server'.$this->Id.'_characters'; 92 $Config->ParameterList['ScriptDev2DatabaseInfo'] = 'localhost;3306;server'.$this->Id.';server'.$this->Id.';server'.$this->Id.'_scriptdev2'; 93 $Config->ParameterList['WorldServerPort'] = $this->WorlddBaseNetworkPort + $this->Id; 94 $Config->ParameterList['Motd'] = $this->Server['Motd']; 95 $Config->ParameterList['DataDir'] = 'wowclient/'.$this->Server['Database']['Emulator']['ClientVersion']['Version']; 96 $Config->Save('../server/'.$this->Id.'/etc/mangosd.conf'); 97 98 // realmd.conf 99 $Config = new MangosConfigurationFile($this->Database); 100 $Config->Load('../emu/mangos/'.$this->Server['Database']['Emulator']['Revision'].'/etc/realmd.conf'); 101 $Config->ParameterList['LoginDatabaseInfo'] = 'localhost;3306;server'.$this->Id.';server'.$this->Id.';server'.$this->Id.'_realmd'; 102 $Config->ParameterList['RealmServerPort'] = $this->RealmdBaseNetworkPort + $this->Id; 103 $Config->Save('../server/'.$this->Id.'/etc/realmd.conf'); 104 105 // scriptdev2.conf 106 $Config = new MangosConfigurationFile($this->Database); 107 $Config->Load('../emu/mangos/'.$this->Server['Database']['Emulator']['Revision'].'/etc/scriptdev2.conf'); 108 $Config->ParameterList['ScriptDev2DatabaseInfo'] = 'localhost;3306;server'.$this->Id.';server'.$this->Id.';server'.$this->Id.'_scriptdev2'; 109 $Config->Save('../server/'.$this->Id.'/etc/scriptdev2.conf'); 59 110 } 60 111 }
Note:
See TracChangeset
for help on using the changeset viewer.