Changeset 9
- Timestamp:
- Jun 11, 2009, 11:26:18 AM (15 years ago)
- Location:
- trunk
- Files:
-
- 1 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/www/config.sample.php
r8 r9 29 29 ), 30 30 'BaseDir' => '/opt/wowhosting/', 31 'MaxServerCount' => 20, 31 32 ); 32 33 -
trunk/www/global.php
r6 r9 18 18 include('page.php'); 19 19 include('log.php'); 20 include('forms.php'); 20 include('types/include.php'); 21 include('form.php'); 22 include('table.php'); 21 23 include('server.php'); 22 24 include('emulator.php'); 23 25 include('mangos_configuration_file.php'); 26 include('task.php'); 24 27 25 28 $PrefixMultipliers = array -
trunk/www/index.php
r6 r9 10 10 function ShowServerList() 11 11 { 12 global $Config; 13 12 14 $OnlineState = array(false => 'Neaktivní', true => 'Aktivní'); 13 15 $Output = '<h4>Seznam serverů</h4>'; … … 21 23 } 22 24 $Output .= '</table>'; 23 if($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER) $Output .= '<br /><div style="text-align: center;"><a href="?Action=ServerAdd">Vytvořit nový server</a></dev>'; 25 if($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER) 26 { 27 $DbResult = $this->Database->query('SELECT COUNT(*) FROM Server'); 28 $DbRow = $DbResult->fetch_row(); 29 $ServerCount = $DbRow[0]; 30 if($ServerCount < $Config['MaxServerCount']) 31 $Output .= '<br /><div style="text-align: center;"><a href="?Action=ServerAdd">Vytvořit nový server</a></dev>'; 32 } 24 33 return($Output); 25 34 } … … 147 156 } 148 157 } else 149 if($_GET['Action'] == 'MemberOptions')150 {151 $UserOptions = new Form('MemberOptions');152 $DbResult = $this->Database->query('SELECT Member.Id, Member.InternetTariffNextMonth, Member.FamilyMemberCount, Member.BillingPeriodNext, Subject.Name, Subject.AddressStreet, Subject.AddressTown, Subject.AddressPSC, Subject.IC, Subject.DIC FROM Member JOIN Subject ON Subject.Id = Member.Subject WHERE Member.Id='.$this->System->Modules['User']->User['Member']);153 $DbRow = $DbResult->fetch_array();154 foreach($UserOptions->Definition['Items'] as $Index => $Item)155 {156 $UserOptions->Values[$Index] = $DbRow[$Index];157 }158 $UserOptions->OnSubmit = '?Action=MemberOptionsSave';159 $Output .= $UserOptions->ShowEditForm();160 } else161 if($_GET['Action'] == 'MemberOptionsSave')162 {163 $UserOptions = new Form('MemberOptions');164 $UserOptions->LoadValuesFromForm();165 if($UserOptions->Values['FamilyMemberCount'] < 0)166 $UserOptions->Values['FamilyMemberCount'] = 0;167 if($UserOptions->Values['BillingPeriodNext'] < 2)168 $UserOptions->Values['BillingPeriodNext'] = 2;169 170 $DbResult = $this->Database->update('Member', 'Id='.$this->System->Modules['User']->User['Member'], array('InternetTariffNextMonth' => $UserOptions->Values['InternetTariffNextMonth'], 'FamilyMemberCount' => $UserOptions->Values['FamilyMemberCount'], 'BillingPeriodNext' => $UserOptions->Values['BillingPeriodNext']));171 $DbResult = $this->Database->query('SELECT Subject FROM Member WHERE Id='.$this->System->Modules['User']->User['Member']);172 $Member = $DbResult->fetch_assoc();173 $DbResult = $this->Database->update('Subject', 'Id='.$Member['Subject'], array('Name' => $UserOptions->Values['Name'], 'AddressStreet' => $UserOptions->Values['AddressStreet'], 'AddressTown' => $UserOptions->Values['AddressTown'], 'AddressPSC' => $UserOptions->Values['AddressPSC'], 'IC' => $UserOptions->Values['IC'], 'DIC' => $UserOptions->Values['DIC']));174 $Output .= $this->SystemMessage('Nastavení', 'Nastavení domácnosti uloženo.');175 $this->System->Modules['Log']->NewRecord('Member+Subject', 'Nastavení člena/subjektu změněno', $UserOptions->Values['Name']);176 $DbResult = $this->Database->query('SELECT Member.Id, Member.InternetTariffNextMonth, Member.FamilyMemberCount, Member.BillingPeriodNext, Subject.Name, Subject.AddressStreet, Subject.AddressTown, Subject.AddressPSC, Subject.IC, Subject.DIC FROM Member JOIN Subject ON Subject.Id = Member.Subject WHERE Member.Id='.$this->System->Modules['User']->User['Member']);177 $DbRow = $DbResult->fetch_array();178 foreach($UserOptions->Definition['Items'] as $Index => $Item)179 {180 $UserOptions->Values[$Index] = $DbRow[$Index];181 }182 $UserOptions->OnSubmit = '?Action=MemberOptionsSave';183 $Output .= $UserOptions->ShowEditForm();184 } else185 158 if($_GET['Action'] == 'ServerAdd') 186 159 { 187 160 if($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER) 188 161 { 189 $DbResult = $this->Database->query('SELECT COUNT(*) FROM Server WHERE User='.$this->System->Modules['User']->User['Id']);162 $DbResult = $this->Database->query('SELECT COUNT(*) FROM Server'); 190 163 $DbRow = $DbResult->fetch_row(); 191 if($DbRow[0] > 0) $Output .= $this->SystemMessage('Nový server', 'Lze vytvořit pouze jeden server pro každý uživatelský účet.');192 else164 $ServerCount = $DbRow[0]; 165 if($ServerCount < $Config['MaxServerCount']) 193 166 { 194 $Form = new Form('NewServer'); 195 $Form->LoadValuesFromForm(); 196 $Form->OnSubmit = '?Action=ServerCreate'; 197 $Output .= 'Tento formulář vám umožní si vytvořit nový server. Pečlivě vyplňte požadované údaje.'; 198 $Output .= $Form->ShowEditForm(); 199 } 167 $DbResult = $this->Database->query('SELECT COUNT(*) FROM Server WHERE User='.$this->System->Modules['User']->User['Id']); 168 $DbRow = $DbResult->fetch_row(); 169 if($DbRow[0] > 0) $Output .= $this->SystemMessage('Nový server', 'Lze vytvořit pouze jeden server pro každý uživatelský účet.'); 170 else 171 { 172 $Form = new Form('NewServer'); 173 $Form->LoadValuesFromForm(); 174 $Form->OnSubmit = '?Action=ServerCreate'; 175 $Output .= 'Tento formulář vám umožní si vytvořit nový server. Pečlivě vyplňte požadované údaje.'; 176 $Output .= $Form->ShowEditForm(); 177 } 178 } else $Output .= $this->SystemMessage('Nový serve', 'Nelze vytvářet další servery'); 200 179 } else $Output .= USER_BAD_ROLE; 201 180 } else -
trunk/www/process_tasks.php
r8 r9 3 3 include('global.php'); 4 4 5 chdir('..'); 6 7 $Script = '/tmp/wowhosting_script.sh'; 8 $DbResult = $Database->query('SELECT * FROM Task WHERE Executed = 0 ORDER BY Id,Time ASC'); 9 while($Task = $DbResult->fetch_assoc()) 10 { 11 echo('Provádím '.$Task['Title']."...\n"); 12 $Task['CommandList'] = "#!/bin/sh\n".$Task['CommandList']; 13 file_put_contents($Script, $Task['CommandList']); 14 chmod($Script, 0755); 15 passthru($Script, $Output); 16 //exec($Script, $Output); 17 $Output = ''; //implode("\n", $Output); 18 //echo($Output); 19 $Database->query('UPDATE Task SET Executed=1, Output="'.addslashes($Output).'" WHERE Id='.$Task['Id']); 20 } 5 $Task = new Task(); 6 $Task->ProcessAll(); 21 7 22 8 ?> -
trunk/www/server.php
r8 r9 31 31 function AddTask($Title, $Task) 32 32 { 33 $this->Database->insert('Task', array(' Server' => $this->Server['Id'], 'Title' => $Title, 'Time' => 'NOW()', 'CommandList' => implode("\n", $Task)));33 $this->Database->insert('Task', array('User' => $this->System->Modules['User']->User['Id'], 'Title' => $Title, 'Time' => 'NOW()', 'CommandList' => implode("\n", $Task))); 34 34 } 35 35 … … 66 66 'mysql --user=server'.$this->Id.' --password=server'.$this->Id.' server'.$this->Id.'_characters < emulator/'.$this->Server['Database']['Emulator']['Id'].'/share/mangos/sql/characters.sql', 67 67 ); 68 if($Delete = true)68 if($Delete == true) 69 69 { 70 70 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'); … … 162 162 // mangosd.conf 163 163 $Config = new MangosConfigurationFile($this->Database); 164 $Config->Load($EmulatorEtcDir.'mangosd.conf ');164 $Config->Load($EmulatorEtcDir.'mangosd.conf.dist'); 165 165 $Config->ParameterList['LoginDatabaseInfo'] = 'localhost;3306;server'.$this->Id.';server'.$this->Id.';server'.$this->Id.'_realmd'; 166 166 $Config->ParameterList['WorldDatabaseInfo'] = 'localhost;3306;server'.$this->Id.';server'.$this->Id.';server'.$this->Id.'_mangos'; … … 177 177 // realmd.conf 178 178 $Config = new MangosConfigurationFile($this->Database); 179 $Config->Load($EmulatorEtcDir.'realmd.conf ');179 $Config->Load($EmulatorEtcDir.'realmd.conf.dist'); 180 180 $Config->ParameterList['LoginDatabaseInfo'] = 'localhost;3306;server'.$this->Id.';server'.$this->Id.';server'.$this->Id.'_realmd'; 181 181 $Config->ParameterList['RealmServerPort'] = $this->RealmdBaseNetworkPort + $this->Id;
Note:
See TracChangeset
for help on using the changeset viewer.