Changeset 6
- Timestamp:
- Jun 10, 2009, 4:57:51 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 7 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Readme.txt
r3 r6 2 2 ============================== 3 3 4 1) Konfigurační soubory 4 1) Popis složek 5 6 www - webové administrační rozhraní v PHP 7 server - složka pro ukládání konfigurací a ladících záznamů vytvořených serverů 8 emulator - složka obsahující dostupné emulátory 9 database - složka obsahující zdrojové sql soubory pro nastavení databáze 10 wowclient - složka obsahující datové soubory pro jednotlivé verze herního klienta 11 12 13 2) Konfigurační soubory 5 14 6 15 Zkopírovat soubor www/config.sample.php na www/config.php a vyplnit údaje. 7 16 8 17 9 2) Práva pro zápis18 3) Práva pro zápis 10 19 11 20 Nastavit práva pro zápis pro web server pro složku server. 12 21 22 23 4) Uživatel mangos 24 25 Z důvodu ochrany bezpečí vytvořte v systému uživatele mangos. -
trunk/www/config.sample.php
r3 r6 28 28 'ErrorLogFile' => 'php_script_error.log', 29 29 ), 30 'BaseDir' => '/opt/wowhosting', 30 31 ); 31 32 -
trunk/www/database.php
r3 r6 54 54 { 55 55 if(!in_array($Value, $this->Functions)) $Value = '"'.$this->real_escape_string($Value).'"'; 56 $Values .= ', '.$Key.'='.$Value;56 $Values .= ', `'.$Key.'`='.$Value; 57 57 } 58 58 $Values = substr($Values, 2); -
trunk/www/emulator.php
r5 r6 23 23 function Add() 24 24 { 25 $this->AddTask('Vytovření nového emulátoru', array( 26 'ln -s wowclient/'.$this->Emulator['ClientVersion']['Version'].'/maps emu/mangos/'.$this->Emulator['Revision'].'/mangos/maps', 27 'ln -s wowclient/'.$this->Emulator['ClientVersion']['Version'].'/dbc emu/mangos/'.$this->Emulator['Revision'].'/mangos/dbc', 28 )); 25 $EmulatorDir = '../emulator/'.$this->Id.'/'; 26 if(!file_exists($EmulatorDir)) mkdir($EmulatorDir, 0777, true); 27 28 //$this->AddTask('Vytvoření nového emulátoru', array( 29 // 'ln -s wowclient/'.$this->Emulator['ClientVersion']['Version'].'/maps emulator/'.$this->Emulator['Id'].'/mangos/maps', 30 // 'ln -s wowclient/'.$this->Emulator['ClientVersion']['Version'].'/dbc emulator/'.$this->Emulator['Id'].'/mangos/dbc', 31 //)); 32 $this->Download(); 33 $this->Compile(); 29 34 } 30 35 … … 35 40 function Download() 36 41 { 42 global $Config; 43 44 $this->AddTask('Stažení emulátoru', array( 45 'cd '.$Config['BaseDir'].'emulator/'.$this->Id.'/', 46 'git clone git://github.com/mangos/mangos.git source', 47 'cd source', 48 'git checkout '.$this->Emulator['CommitHash'], 49 'mkdir src/bindings/ScriptDev2', 50 'svn checkout -r '.$this->Emulator['ScriptDev2Revision'].' https://scriptdev2.svn.sourceforge.net/svnroot/scriptdev2/ src/bindings/ScriptDev2', 51 'git apply src/bindings/ScriptDev2/patches/'.$this->Emulator['ScriptDev2PatchFileName'], 52 )); 37 53 } 38 54 39 55 function Compile() 40 56 { 57 global $Config; 58 59 $this->AddTask('Překlad emulátoru', array( 60 'cd '.$Config['BaseDir'].'emulator/'.$this->Id.'/source', 61 'autoreconf -ifv', 62 'mkdir objdir', 63 'cd objdir', 64 '../configure --prefix='.$Config['BaseDir'].'emulator/'.$this->Id.'/ --enable-cli --enable-ra', 65 'make', 66 'make install', 67 )); 41 68 } 42 69 } -
trunk/www/form_classes.php
r4 r6 2 2 3 3 $FormClasses = array( 4 'NewPayment' => array(5 'Title' => 'Nová platba',6 'Items' => array(7 'Time' => array('Type' => 'Time', 'Caption' => 'Čas', 'Default' => 'Now'),8 'Subject' => array('Type' => 'TFinanceSubject', 'Caption' => 'Subjekt', 'Default' => 0),9 'Value' => array('Type' => 'Float', 'Caption' => 'Částka [Kč]', 'Default' => '0'),10 'Text' => array('Type' => 'String', 'Caption' => 'Popis', 'Default' => 'Přijatá záloha'),11 'Cash' => array('Type' => 'Boolean', 'Caption' => 'Hotovost', 'Default' => '1'),12 'Taxable' => array('Type' => 'Boolean', 'Caption' => 'Ovlivňující daňový základ', 'Default' => '1'),13 ),14 ),15 'NewInvoice' => array(16 'Title' => 'Nová faktura',17 'Items' => array(18 'Time' => array('Type' => 'Time', 'Caption' => 'Čas', 'Default' => 'Now'),19 'Contractor' => array('Type' => 'TFinanceSubject', 'Caption' => 'Dodavatel', 'Default' => 1),20 'Customer' => array('Type' => 'TFinanceSubject', 'Caption' => 'Odběratel', 'Default' => 0),21 'Items' => array('Type' => 'Array', 'Caption' => 'Položky', 'ItemClass' => 'FinanceInvoiceItem'),22 ),23 ),24 'FinanceInvoiceItem' => array(25 'Title' => 'Položka faktury',26 'Items' => array(27 'Value' => array('Type' => 'Float', 'Caption' => 'Částka [Kč]', 'Default' => '0'),28 'Text' => array('Type' => 'String', 'Caption' => 'Popis', 'Default' => 'Položka'),29 'Quantity' => array('Type' => 'Integer', 'Caption' => 'Množství', 'Default' => '1'),30 'Tax' => array('Type' => 'Integer', 'Caption' => 'Daň [%]', 'Default' => '19'),31 ),32 ),33 'Measure' => array(34 'Title' => 'Měření',35 'Table' => 'Measure',36 'Items' => array(37 'Name' => array('Type' => 'String', 'Caption' => 'Zkratka', 'Default' => 'measure'),38 'Title' => array('Type' => 'String', 'Caption' => 'Název', 'Default' => 'Měření'),39 'Description' => array('Type' => 'String', 'Caption' => 'Popis', 'Default' => 'Měření veličiny'),40 'Unit' => array('Type' => 'String', 'Caption' => 'Jednotka', 'Default' => ''),41 'Continuity' => array('Type' => 'Boolean', 'Caption' => 'Spojitost', 'Default' => '0'),42 'Period' => array('Type' => 'Integer', 'Caption' => 'Perioda měření', 'Default' => '60'),43 'PermissionAdd' => array('Type' => 'String', 'Caption' => 'Oprávnění k měření', 'Default' => 'localhost.localdomain'),44 'PermissionView' => array('Type' => 'String', 'Caption' => 'Oprávnění k prohlížení', 'Default' => 'all'),45 'Enabled' => array('Type' => 'Boolean', 'Caption' => 'Povolení', 'Default' => '1'),46 'DataType' => array('Type' => 'String', 'Caption' => 'Typ datových položek', 'Default' => 'int'),47 'DataTable' => array('Type' => 'String', 'Caption' => 'Tabulka měřených dat', 'Default' => 'data'),48 ),49 ),50 4 'UserOptions' => array( 51 5 'Title' => 'Základní nastavení', … … 57 11 'Name' => array('Type' => 'String', 'Caption' => 'Zobrazované jméno', 'Default' => ''), 58 12 'Email' => array('Type' => 'String', 'Caption' => 'E-mail', 'Default' => ''), 59 'PhoneNumber' => array('Type' => 'String', 'Caption' => 'Telefón', 'Default' => ''),60 'ICQ' => array('Type' => 'String', 'Caption' => 'ICQ', 'Default' => ''),13 //'PhoneNumber' => array('Type' => 'String', 'Caption' => 'Telefón', 'Default' => ''), 14 //'ICQ' => array('Type' => 'String', 'Caption' => 'ICQ', 'Default' => ''), 61 15 ), 62 16 ), … … 71 25 'Name' => array('Type' => 'String', 'Caption' => 'Zobrazované jméno', 'Default' => ''), 72 26 'Email' => array('Type' => 'String', 'Caption' => 'E-mail', 'Default' => ''), 73 'PhoneNumber' => array('Type' => 'String', 'Caption' => 'Telefón', 'Default' => ''), 74 'ICQ' => array('Type' => 'String', 'Caption' => 'ICQ', 'Default' => ''), 75 ), 76 ), 77 'MemberOptions' => array( 78 'Title' => 'Nastavení domácnosti', 79 'Table' => '(SELECT Member.Id, Member.InternetTariffNextMonth, Member.FamilyMemberCount, Subject.Name, Subject.AddressStreet, Subject.AddressTown, Subject.AddressPSC, Subject.IC, Subject.DIC FROM Member JOIN Subject ON Subject.Id = Member.Subject)', 80 'Items' => array( 81 'Name' => array('Type' => 'String', 'Caption' => 'Fakturační jméno', 'Default' => ''), 82 'AddressStreet' => array('Type' => 'String', 'Caption' => 'Ulice', 'Default' => 'Zděchov'), 83 'AddressTown' => array('Type' => 'String', 'Caption' => 'Město', 'Default' => 'Zděchov'), 84 'AddressPSC' => array('Type' => 'String', 'Caption' => 'PSČ', 'Default' => '75607'), 85 'IC' => array('Type' => 'String', 'Caption' => 'IČ', 'Default' => ''), 86 'DIC' => array('Type' => 'String', 'Caption' => 'DIČ', 'Default' => ''), 87 'FamilyMemberCount' => array('Type' => 'Integer', 'Caption' => 'Počet osob v domácnosti', 'Default' => ''), 88 'BillingPeriodNext' => array('Type' => 'TFinanceBillingPeriod', 'Caption' => 'Požadované fakturované období', 'Default' => ''), 89 'InternetTariffNextMonth' => array('Type' => 'TFinanceTariff', 'Caption' => 'Tarif internetu od dalšího období', 'Default' => 2), 90 ), 91 ), 92 'PasswordRecovery' => array( 93 'Title' => 'Obnova hesla', 94 'SubmitText' => 'Obnovit', 95 'Table' => '', 96 'Items' => array( 97 'Name' => array('Type' => 'String', 'Caption' => 'Přihlašovací jméno', 'Default' => ''), 98 'Email' => array('Type' => 'String', 'Caption' => 'E-mail', 'Default' => ''), 27 //'PhoneNumber' => array('Type' => 'String', 'Caption' => 'Telefón', 'Default' => ''), 28 //'ICQ' => array('Type' => 'String', 'Caption' => 'ICQ', 'Default' => ''), 99 29 ), 100 30 ), … … 108 38 ), 109 39 ), 110 'NewNetworkDevice' => array(111 'Title' => 'Vložit nové zařízení',112 'Table' => 'network_devices',113 'Items' => array(114 'name' => array('Type' => 'String', 'Caption' => 'Název', 'Default' => ''),115 'price' => array('Type' => 'Float', 'Caption' => 'Cena', 'Default' => 0),116 'count' => array('Type' => 'Integer', 'Caption' => 'Počet', 'Default' => 1),117 'date' => array('Type' => 'Time', 'Caption' => 'Datum zakoupení', 'Default' => 'Now'),118 'segment' => array('Type' => 'TNetworkSegment', 'Caption' => 'Segment sítě', 'Default' => 0),119 'date' => array('Type' => 'Time', 'Caption' => 'Datum zakoupení', 'Default' => 'Now'),120 'used' => array('Type' => 'TNetworkDeviceState', 'Caption' => 'Stav', 'Default' => 0),121 'consumption' => array('Type' => 'Integer', 'Caption' => 'Spotřeba', 'Default' => 0),122 'user' => array('Type' => 'TFinanceSubject', 'Caption' => 'Subjekt', 'Default' => 0),123 'info' => array('Type' => 'String', 'Caption' => 'Poznámky', 'Default' => ''),124 'shop' => array('Type' => 'String', 'Caption' => 'Obchod', 'Default' => ''),125 'device_id' => array('Type' => 'String', 'Caption' => 'Sériové číslo', 'Default' => ''),126 ),127 ),128 'NewNetworkDeviceHistory' => array(129 'Title' => 'Vložit záznam historie zařízení',130 'Table' => 'NetworkDeviceHistory',131 'Items' => array(132 'Device' => array('Type' => 'TNetworkDevice', 'Caption' => 'Zařízení', 'Default' => 0),133 'Time' => array('Type' => 'Time', 'Caption' => 'Čas', 'Default' => 'Now'),134 'Action' => array('Type' => 'TNetworkDeviceAction', 'Caption' => 'Akce', 'Default' => 0),135 'Notice' => array('Type' => 'String', 'Caption' => 'Poznámka', 'Default' => ''),136 ),137 ),138 'News' => array(139 'Title' => 'Nová aktualita',140 'Table' => '',141 'SubmitText' => 'Vložit',142 'Items' => array(143 'Category' => array('Type' => 'TNewsCategory', 'Caption' => 'Kategorie', 'Default' => 0),144 'Title' => array('Type' => 'String', 'Caption' => 'Nadpis', 'Default' => ''),145 'Content' => array('Type' => 'Text', 'Caption' => 'Obsah', 'Default' => ''),146 'Enclosure1' => array('Type' => 'File', 'Caption' => 'Přílohy (Max. velikost souboru 1 MB)', 'Default' => ''),147 'Enclosure2' => array('Type' => 'File', 'Caption' => '', 'Default' => ''),148 'Enclosure3' => array('Type' => 'File', 'Caption' => '', 'Default' => ''),149 ),150 ),151 'Email' => array(152 'Title' => 'Nový email',153 'Table' => 'EmailQueue',154 'SubmitText' => 'Odeslat',155 'Items' => array(156 'Address' => array('Type' => 'String', 'Caption' => 'Adresa', 'Default' => ''),157 'Subject' => array('Type' => 'String', 'Caption' => 'Předmět', 'Default' => ''),158 'Content' => array('Type' => 'Text', 'Caption' => 'Obsah', 'Default' => ''),159 ),160 ),161 40 'NewServer' => array( 162 41 'Title' => 'Nový server', … … 165 44 'Items' => array( 166 45 'Name' => array('Type' => 'String', 'Caption' => 'Název', 'Default' => 'WoW server'), 46 'Description' => array('Type' => 'Text', 'Caption' => 'Popis', 'Default' => ''), 47 'Homepage' => array('Type' => 'String', 'Caption' => 'Webové stránky', 'Default' => ''), 48 'Type' => array('Type' => 'TServerType', 'Caption' => 'Typ', 'Default' => 0), 49 'Database' => array('Type' => 'TDatabase', 'Caption' => 'Databáze', 'Default' => 0), 50 'Motd' => array('Type' => 'String', 'Caption' => 'Zpráva dne', 'Default' => 'Vítejte na free WoW serveru'), 167 51 ), 168 52 ), … … 173 57 'Items' => array( 174 58 'Name' => array('Type' => 'String', 'Caption' => 'Název', 'Default' => 'WoW server'), 59 'Description' => array('Type' => 'Text', 'Caption' => 'Popis', 'Default' => ''), 60 'Homepage' => array('Type' => 'String', 'Caption' => 'Webové stránky', 'Default' => ''), 61 'Type' => array('Type' => 'TServerType', 'Caption' => 'Typ', 'Default' => 0), 62 'Database' => array('Type' => 'TDatabase', 'Caption' => 'Databáze', 'Default' => 0), 175 63 'Motd' => array('Type' => 'String', 'Caption' => 'Zpráva dne', 'Default' => 'Vítejte na free WoW serveru'), 176 64 ), … … 179 67 180 68 $FormTypes = array( 181 'T NetworkDeviceState' => array(69 'TServerType' => array( 182 70 'Type' => 'Enumeration', 183 'States' => array(' Vyřazeno', 'Použito', 'Na skladě'),71 'States' => array('Normální', 'PvP', 'RP', 'RPPvP'), 184 72 ), 185 'TNetworkDeviceAction' => array( 186 'Type' => 'Enumeration', 187 'States' => array('Zakoupeno', 'Prodáno', 'Zařazeno do použití', 'Vyřazeno z použití', 'Zasláno do reklamace', 'Přijato z reklamace'), 188 ), 189 'TFinanceTariff' => array( 190 'Type' => 'Enumeration', 191 'States' => array(6 => 'Zdarma', 0 => 'Pomalejší', 1 => 'Pomalý', 2 => 'Střední', 3 => 'Rychlý', 4 => 'Rychlejší'), 192 ), 193 'TFinanceBillingPeriod' => array( 194 'Type' => 'Enumeration', 195 'States' => array(2 => 'Měsíčně', 3 => 'Čtvrtletně', 4 => 'Pololetně', 5 => 'Ročně'), 196 ), 197 'TFinanceSubject' => array( 73 'TDatabase' => array( 198 74 'Type' => 'Reference', 199 'Table' => ' Subject',75 'Table' => 'Database', 200 76 'Id' => 'Id', 201 'Name' => 'Name', 202 'Filter' => '1', 203 ), 204 'TNetworkDevice' => array( 205 'Type' => 'Reference', 206 'Table' => 'network_devices', 207 'Id' => 'id', 208 'Name' => 'name', 209 'Filter' => '1', 210 ), 211 'TNetworkSegment' => array( 212 'Type' => 'Reference', 213 'Table' => 'network_segments', 214 'Id' => 'id', 215 'Name' => 'name', 216 'Filter' => '1', 217 ), 218 'TNewsCategory' => array( 219 'Type' => 'Reference', 220 'Table' => 'NewsCategory', 221 'Id' => 'Id', 222 'Name' => 'Caption', 77 'Name' => 'CONCAT(Name, " ", Version, " r", Revision)', 223 78 'Filter' => '1', 224 79 ), -
trunk/www/global.php
r3 r6 17 17 include('module.php'); 18 18 include('page.php'); 19 include('log.php'); 19 20 include('forms.php'); 20 21 include('server.php'); 22 include('emulator.php'); 21 23 include('mangos_configuration_file.php'); 22 24 … … 177 179 $System->Config = $Config; 178 180 $System->Database = &$Database; 181 include_once('log.php'); 182 $System->AddModule(new Log()); 179 183 include_once('user.php'); 180 184 $System->AddModule(new User()); … … 251 255 252 256 // Zobrazení číselný seznamu stránek 253 function PagesList($URL,$Page,$TotalCount,$CountPerPage) 254 { 255 $Count = ceil($TotalCount/$CountPerPage); 256 $Around = 10; 257 function PagesList($URL, $Page, $TotalCount, $CountPerPage, $Around = 10) 258 { 259 $Count = ceil($TotalCount / $CountPerPage); 257 260 $Result = ''; 258 if($Count >1)259 { 260 if($Page >0)261 { 262 $Result .= '<a href="'.$URL.'0"><<</a> ';263 $Result .= '<a href="'.$URL.($Page-1).'"><</a> ';264 } 265 $PagesMax = $Count -1;261 if($Count > 1) 262 { 263 if($Page > 0) 264 { 265 $Result .= '<a href="'.$URL.'0"><<</a> '; 266 $Result .= '<a href="'.$URL.($Page - 1).'"><</a> '; 267 } 268 $PagesMax = $Count - 1; 266 269 $PagesMin = 0; 267 if($PagesMax >($Page+$Around)) $PagesMax = $Page+$Around;268 if($PagesMin <($Page-$Around))270 if($PagesMax > ($Page + $Around)) $PagesMax = $Page + $Around; 271 if($PagesMin < ($Page - $Around)) 269 272 { 270 273 $Result.= ' .. '; 271 $PagesMin = $Page -$Around;272 } 273 for($i =$PagesMin;$i<=$PagesMax;$i++)274 { 275 if($i ==$Page) $Result.= '<strong>';276 $Result .= '<a href="'.$URL.$i.'">'.($i+1).'</a> ';277 if($i ==$Page) $Result.= '</strong>';278 } 279 if($PagesMax <($Count-1)) $Result .= ' .. ';280 if($Page <($Count-1))281 { 282 $Result .= '<a href="'.$URL.($Page+1).'">></a> ';283 $Result .= '<a href="'.$URL.($Count-1).'">>></a>';274 $PagesMin = $Page - $Around; 275 } 276 for($i = $PagesMin; $i <= $PagesMax; $i++) 277 { 278 if($i == $Page) $Result .= '<strong>'; 279 $Result .= '<a href="'.$URL.$i.'">'.($i + 1).'</a> '; 280 if($i == $Page) $Result .= '</strong>'; 281 } 282 if($PagesMax < ($Count - 1)) $Result .= ' .. '; 283 if($Page < ($Count - 1)) 284 { 285 $Result .= '<a href="'.$URL.($Page + 1).'">></a> '; 286 $Result .= '<a href="'.$URL.($Count - 1).'">>></a>'; 284 287 } 285 288 } 286 289 return($Result); 287 } 290 } 288 291 289 292 function GetRemoteAddress() -
trunk/www/index.php
r5 r6 10 10 function ShowServerList() 11 11 { 12 $OnlineState = array(false => 'Neaktivní', true => 'Aktivní'); 12 13 $Output = '<h4>Seznam serverů</h4>'; 13 $Output .= '<table class="WideTable"><tr><th>Název</th><th>Uživatel</th><th>Realmd</th><th>Verze hry</th>< /tr>';14 $DbResult = $this->Database->query('SELECT `ClientVersion`.`Version`, `Server`.`Name`, `Server`.` NetworkPortRealmd`, `User`.`Name` AS `UserName` FROM `Server` JOIN `User` ON `User`.`Id` = `Server`.`User` JOIN `Database` ON `Database`.`Id` = `Server`.`Database` JOIN `Emulator` ON `Emulator`.`Id` = `Database`.`Emulator` JOIN `ClientVersion` ON `ClientVersion`.`Id` = `Emulator`.`ClientVersion`');15 while($ Server= $DbResult->fetch_assoc())14 $Output .= '<table class="WideTable"><tr><th>Název</th><th>Uživatel</th><th>Realmd</th><th>Verze hry</th><th>Stav</th><th>Hráčů online</th><th>Účtů</th><th>Postav</th></tr>'; 15 $DbResult = $this->Database->query('SELECT `ClientVersion`.`Version`, `Server`.`Name`, `Server`.`Id`, `Server`.`NetworkPortRealmd`, `User`.`Name` AS `UserName` FROM `Server` JOIN `User` ON `User`.`Id` = `Server`.`User` JOIN `Database` ON `Database`.`Id` = `Server`.`Database` JOIN `Emulator` ON `Emulator`.`Id` = `Database`.`Emulator` JOIN `ClientVersion` ON `ClientVersion`.`Id` = `Emulator`.`ClientVersion`'); 16 while($DbRow = $DbResult->fetch_assoc()) 16 17 { 17 $Output .= '<tr><td>'.$Server['Name'].'</td><td>'.$Server['UserName'].'</td><td>'.$this->System->Config['Web']['Host'].':'.$Server['NetworkPortRealmd'].'</td><td>'.$Server['Version'].'</td></tr>'; 18 $Server = new Server($this->Database, $DbRow['Id']); 19 $ServerState = $Server->GetState(); 20 $Output .= '<tr><td><a href="?Action=ServerShow&Id='.$DbRow['Id'].'">'.$DbRow['Name'].'</a></td><td>'.$DbRow['UserName'].'</td><td>'.$this->System->Config['Web']['Host'].':'.$DbRow['NetworkPortRealmd'].'</td><td>'.$DbRow['Version'].'</td><td>'.$OnlineState[$ServerState['Online']].'</td><td>'.$ServerState['OnlinePlayerCount'].'</td><td>'.$ServerState['AccountCount'].'</td><td>'.$ServerState['CharacterCount'].'</td></tr>'; 18 21 } 19 22 $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>'; 20 24 return($Output); 21 25 } … … 27 31 $Output .= '<table class="WideTable"><tr><th>Položka</th><th>Hodnota</th></tr>'; 28 32 $Output .= '<tr><td>Jméno</td><td>'.$Server->Server['Name'].'</td></tr>'. 33 '<tr><td>Webové stránky</td><td><a href="'.$Server->Server['Homepage'].'">'.$Server->Server['Homepage'].'</a></td></tr>'. 34 '<tr><td>Popis</td><td>'.$Server->Server['Description'].'</td></tr>'. 29 35 '<tr><td>Zpráva dne</td><td>'.$Server->Server['Motd'].'</td></tr>'. 30 36 '<tr><td>Síťový port realmd</td><td>'.($Server->RealmdBaseNetworkPort + $Server->Id).'</td></tr>'. 31 '<tr><td>Síťový port mangosd</td><td>'.($Server->WorlddBaseNetworkPort + $Server->Id).'</td></tr>'. 32 '<tr><td>Emulátor</td><td>'.$Server->Server['Database']['Emulator']['Name'].'</td></tr>'. 33 '<tr><td>Databáze</td><td>'.$Server->Server['Database']['Name'].'</td></tr>'; 34 $Output .= '</table>'; 35 $Output .= '<br /><a href="'.$this->System->Config['Web']['Host'].'/mysql/">Správa databáze</a> '; 36 $ServerStatus = $Server->GetState(); 37 if($ServerStatus['RealmdPortState'] == true) $Output .= ' <a href="?Action=ServerStop">Zastavit server</a> <a href="?Action=ServerRestart">RestartovatServer</a>'; 38 else $Output .= ' <a href="?Action=ServerStart">Spustit server</a>'; 39 37 '<tr><td>Síťový port mangosd</td><td>'.($Server->WorlddBaseNetworkPort + $Server->Id).'</td></tr>'; 38 $Output .= '</table><div style="text-align: center">'; 39 if($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER) 40 { 41 $Output .= '<br /><a href="'.$this->System->Config['Web']['Host'].'/mysql/">Správa databáze</a> '; 42 if(array_key_exists('Id', $Server->Server['Database'])) 43 { 44 $ServerStatus = $Server->GetState(); 45 if($ServerStatus['RealmdPortState'] == true) $Output .= ' <a href="?Action=ServerStop">Zastavit server</a> <a href="?Action=ServerRestart">RestartovatServer</a>'; 46 else $Output .= ' <a href="?Action=ServerStart">Spustit server</a>'; 47 } 48 $Output .= ' <a href="?Action=ServerEdit">Upravit server</a>'; 49 $Output .= ' <a href="?Action=ServerDatabaseImport">Načtení čisté databáze</a>'; 50 } 51 $Output .= '</div>'; 40 52 return($Output); 41 53 } … … 127 139 $Form = new Form('UserRegister', array()); 128 140 $Form->LoadValuesFromForm(); 129 $Result = $this->System->Modules['User']->Register($Form->Values['Login'], $Form->Values['Password'], $Form->Values['Password2'], $Form->Values['Email'], $Form->Values['Name'] , $Form->Values['PhoneNumber'], $Form->Values['ICQ']);141 $Result = $this->System->Modules['User']->Register($Form->Values['Login'], $Form->Values['Password'], $Form->Values['Password2'], $Form->Values['Email'], $Form->Values['Name']); 130 142 $Output .= $this->SystemMessage('Registrace nového účtu', $Result); 131 143 if($Result <> USER_REGISTRATED) … … 173 185 if($_GET['Action'] == 'ServerAdd') 174 186 { 175 $Form = new Form('NewServer'); 176 $Form->LoadValuesFromForm(); 177 $Form->OnSubmit = '?Action=ServerCreate'; 178 $Output .= $Form->ShowEditForm(); 187 if($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER) 188 { 189 $DbResult = $this->Database->query('SELECT COUNT(*) FROM Server WHERE User='.$this->System->Modules['User']->User['Id']); 190 $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 else 193 { 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 } 200 } else $Output .= USER_BAD_ROLE; 179 201 } else 180 202 if($_GET['Action'] == 'ServerCreate') 181 203 { 182 $UserOptions = new Form('NewServer', array()); 183 $UserOptions->LoadValuesFromForm(); 184 $Output .= $this->SystemMessage('Nový server', 'Server vytvořen.'); 185 //$UserOptions->LoadValuesFromDatabase($this->System->Modules['User']->User['Id']); 186 $UserOptions->OnSubmit = '?Action=ServerCreate'; 187 $Output .= $UserOptions->ShowEditForm(); 204 if($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER) 205 { 206 $DbResult = $this->Database->query('SELECT COUNT(*) FROM Server WHERE User='.$this->System->Modules['User']->User['Id']); 207 $DbRow = $DbResult->fetch_row(); 208 if($DbRow[0] > 0) $Output .= $this->SystemMessage('Nový server', 'Lze vytvořit pouze jeden server pro každý uživatelský účet.'); 209 else 210 { 211 $Form = new Form('NewServer', array()); 212 $Form->LoadValuesFromForm(); 213 $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)); 214 $LastInsertId = $this->Database->insert_id; 215 $Server = new Server($this->Database, $LastInsertId); 216 $Server->CreateDatabase(); 217 $Output .= $this->SystemMessage('Nový server', 'Server vytvořen.'); 218 //$UserOptions->LoadValuesFromDatabase($this->System->Modules['User']->User['Id']); 219 //$Form->OnSubmit = '?Action=ServerCreate'; 220 //$Output .= $Form->ShowEditForm(); 221 } 222 } else $Output .= USER_BAD_ROLE; 188 223 } else 189 224 if($_GET['Action'] == 'ServerShow') 190 225 { 191 $DbResult = $this->Database->query('SELECT Id FROM Server WHERE User='.$this->System->Modules['User']->User['Id']); 192 $Server = $DbResult->fetch_assoc(); 193 $Output .= $this->ShowServer($Server['Id']); 226 if(array_key_exists('Id', $_GET)) $Output .= $this->ShowServer($_GET['Id']); 227 else 228 { 229 $DbResult = $this->Database->query('SELECT Id FROM Server WHERE User='.$this->System->Modules['User']->User['Id']); 230 $Server = $DbResult->fetch_assoc(); 231 $Output .= $this->ShowServer($Server['Id']); 232 } 194 233 } else 195 234 if($_GET['Action'] == 'ServerEdit') 196 235 { 197 $Form = new Form('EditServer'); 198 $Form->LoadValuesFromForm(); 199 $Form->OnSubmit = '?Action=ServerSave'; 200 $Output .= $Form->ShowEditForm(); 236 if($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER) 237 { 238 $DbResult = $this->Database->query('SELECT Id FROM Server WHERE User='.$this->System->Modules['User']->User['Id']); 239 $Server = $DbResult->fetch_assoc(); 240 $Form = new Form('EditServer'); 241 $Form->LoadValuesFromDatabase($Server['Id']); 242 $Form->OnSubmit = '?Action=ServerSave'; 243 $Output .= $Form->ShowEditForm(); 244 } else $Output .= USER_BAD_ROLE; 201 245 } else 202 246 if($_GET['Action'] == 'ServerSave') 203 247 { 204 $UserOptions = new Form('EditServer', array()); 205 $UserOptions->LoadValuesFromForm(); 206 $Output .= $this->SystemMessage('Upravit server', 'Nastavení serveru uloženo.'); 207 $UserOptions->LoadValuesFromDatabase($this->System->Modules['User']->User['Id']); 208 $UserOptions->OnSubmit = '?Action=ServerSave'; 248 if($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER) 249 { 250 $DbResult = $this->Database->query('SELECT Id FROM Server WHERE User='.$this->System->Modules['User']->User['Id']); 251 $Server = $DbResult->fetch_assoc(); 252 $UserOptions = new Form('EditServer', array()); 253 $UserOptions->LoadValuesFromForm(); 254 $Output .= $this->SystemMessage('Upravit server', 'Nastavení serveru uloženo.'); 255 $UserOptions->SaveValuesToDatabase($Server['Id']); 256 $UserOptions->OnSubmit = '?Action=ServerSave'; 209 257 210 $DbResult = $this->Database->query('SELECT Id FROM Server WHERE User='.$this->System->Modules['User']->User['Id']); 211 $Server = $DbResult->fetch_assoc(); 212 $Server = new Server($this->Database, $Server['Id']); 213 $Server->SetupConfigurationFiles(); 214 215 $Output .= $UserOptions->ShowEditForm(); 258 $Server = new Server($this->Database, $Server['Id']); 259 $Server->SaveConfiguration(); 260 261 $Output .= $UserOptions->ShowEditForm(); 262 } else $Output .= USER_BAD_ROLE; 216 263 } else 217 264 if($_GET['Action'] == 'ServerStart') 218 265 { 219 $DbResult = $this->Database->query('SELECT Id FROM Server WHERE User='.$this->System->Modules['User']->User['Id']); 220 $Server = $DbResult->fetch_assoc(); 221 $Server = new Server($this->Database, $Server['Id']); 222 $Output .= $this->SystemMessage('Spuštění serveru', $Server->Start()); 266 if($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER) 267 { 268 $DbResult = $this->Database->query('SELECT Id FROM Server WHERE User='.$this->System->Modules['User']->User['Id']); 269 $Server = $DbResult->fetch_assoc(); 270 $Server = new Server($this->Database, $Server['Id']); 271 $Output .= $this->SystemMessage('Spuštění serveru', $Server->Start()); 272 } else $Output .= USER_BAD_ROLE; 223 273 } else 224 274 if($_GET['Action'] == 'ServerStop') 225 275 { 226 $DbResult = $this->Database->query('SELECT Id FROM Server WHERE User='.$this->System->Modules['User']->User['Id']); 227 $Server = $DbResult->fetch_assoc(); 228 $Server = new Server($this->Database, $Server['Id']); 229 $Output .= $this->SystemMessage('Zastavení serveru', $Server->Stop()); 276 if($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER) 277 { 278 $DbResult = $this->Database->query('SELECT Id FROM Server WHERE User='.$this->System->Modules['User']->User['Id']); 279 $Server = $DbResult->fetch_assoc(); 280 $Server = new Server($this->Database, $Server['Id']); 281 $Output .= $this->SystemMessage('Zastavení serveru', $Server->Stop()); 282 } else $Output .= USER_BAD_ROLE; 283 } else 284 if($_GET['Action'] == 'ServerDatabaseImport') 285 { 286 if($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER) 287 { 288 $DbResult = $this->Database->query('SELECT Id FROM Server WHERE User='.$this->System->Modules['User']->User['Id']); 289 $Server = $DbResult->fetch_assoc(); 290 $Server = new Server($this->Database, $Server['Id']); 291 $Server->ImportDatabase(true); 292 $Output .= $this->SystemMessage('Import čisté databáze', 'Úloha zařazena do fronty'); 293 } else $Output .= USER_BAD_ROLE; 230 294 } else 231 295 if($_GET['Action'] == 'Test') 232 296 { 297 $Emulator = new Emulator($this->Database, 2); 298 $Emulator->Compile(); 233 299 //$Server = new Server($this->Database, 1); 234 300 //$Output .= $Server->ImportDatabase(); 235 $Config = new MangosConfigurationFile($this->Database);236 $Config->Load('../emu/mangos/7681/etc/mangosd.conf');237 $Config->Save('../server/1/etc/mangosd.conf');301 //$Config = new MangosConfigurationFile($this->Database); 302 //$Config->Load('../emu/mangos/7681/etc/mangosd.conf'); 303 //$Config->Save('../server/1/etc/mangosd.conf'); 238 304 } else 239 305 { 240 306 $Output = $this->ShowServerList(); 241 $Output .= '<br /><a href="?Action=ServerAdd">Nový server</a>';242 307 } 243 308 } else 244 309 { 245 310 $Output = $this->ShowServerList(); 246 $Output .= '<br /><a href="?Action=ServerAdd">Nový server</a>';247 311 } 248 312 return($Output); -
trunk/www/page.php
r3 r6 25 25 '<title>'.$this->System->Config['Web']['Title'].' - '.$Path.'</title> 26 26 </head><body'.$BodyParam.'>'. 27 '<div class="Navigation"><div class="MenuItem2">'; 27 '<div class="Navigation"><span class="MenuItem"><a href="?">Seznam serverů</a>'; 28 if($this->System->Modules['User']->User['Id'] != $this->System->Modules['User']->AnonymousUserId) 29 { 30 $DbResult = $this->Database->query('SELECT COUNT(*) FROM Server WHERE User='.$this->System->Modules['User']->User['Id']); 31 $DbRow = $DbResult->fetch_row(); 32 if($DbRow[0] > 0) $Output .= '<a href="?Action=ServerShow">Vlastní server</a>'; 33 else $Output .= '<a href="?Action=ServerAdd">Vytvořit vlastní server</a>'; 34 } 35 $Output .= '</span><div class="MenuItem2">'; 28 36 if($this->System->Modules['User']->User['Id'] == $this->System->Modules['User']->AnonymousUserId) 29 37 $Output .= '<a href="'.$this->System->Config['Web']['RootFolder'].'/?Action=LoginForm">Přihlášení</a> <a href="'.$this->System->Config['Web']['RootFolder'].'/?Action=UserRegister">Registrace</a>'; -
trunk/www/process_tasks.php
r5 r6 5 5 chdir('..'); 6 6 7 $Script = '/tmp/wowhosting_script.sh'; 7 8 $DbResult = $Database->query('SELECT * FROM Task WHERE Executed = 0 ORDER BY Time ASC'); 8 9 while($Task = $DbResult->fetch_assoc()) 9 10 { 10 11 echo('Provádím '.$Task['Title']."...\n"); 11 foreach(explode("\n", $Task['CommandList']) as $Command)12 {13 $Output = array();14 echo($Command."\n");15 exec($Command, $Output);16 echo(implode("\n", $Output));17 }18 $Database->query('UPDATE Task SET Executed=1 WHERE Id='.$Task['Id']);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']); 19 20 } 20 21 -
trunk/www/server.php
r5 r6 1 1 <?php 2 2 3 function ErrorHandler() 4 { 5 } 6 3 7 class Server extends Module 4 8 { … … 15 19 $this->Server = $DbResult->fetch_assoc(); 16 20 $DbResult = $this->Database->query('SELECT * FROM `Database` WHERE `Id`='.$this->Server['Database']); 17 $this->Server['Database'] = $DbResult->fetch_assoc(); 21 if($DbResult->num_rows > 0) $this->Server['Database'] = $DbResult->fetch_assoc(); 22 else $this->Server['Database'] = array('Emulator' => 0); 18 23 $DbResult = $this->Database->query('SELECT * FROM `Emulator` WHERE `Id`='.$this->Server['Database']['Emulator']); 19 $this->Server['Database']['Emulator'] = $DbResult->fetch_assoc(); 24 if($DbResult->num_rows > 0) $this->Server['Database']['Emulator'] = $DbResult->fetch_assoc(); 25 else $this->Server['Database']['Emulator'] = array('ClientVersion' => 0); 20 26 $DbResult = $this->Database->query('SELECT * FROM `ClientVersion` WHERE `Id`='.$this->Server['Database']['Emulator']['ClientVersion']); 21 $this->Server['Database']['Emulator']['ClientVersion'] = $DbResult->fetch_assoc(); 27 if($DbResult->num_rows > 0) $this->Server['Database']['Emulator']['ClientVersion'] = $DbResult->fetch_assoc(); 28 else $this->Server['Database']['Emulator']['ClientVersion'] = array(); 22 29 } 23 30 … … 27 34 } 28 35 29 function ImportDatabase()36 function CreateDatabase() 30 37 { 31 $DbResult = $this->Database->query('SELECT * FROM `Database` WHERE `Id`='.$this->Server['Database']); 32 $Database = $DbResult->fetch_assoc(); 33 $DbResult = $this->Database->query('SELECT `Revision` FROM `Emulator` WHERE `Id`='.$Database['Emulator']); 34 $Emulator = $DbResult->fetch_assoc(); 35 $this->AddTask('Inicializace databáze', array( 36 'mysql --user=server'.$this->Id.' --password=server'.$this->Id.' server'.$this->Id.'_mangos < emu/mangos/'.$Emulator['Revision'].'/udb/'.$Database['SourceFileName'], 37 'mysql --user=server'.$this->Id.' --password=server'.$this->Id.' server'.$this->Id.'_scriptdev2 < emu/mangos/'.$Emulator['Revision'].'/source/src/bindings/ScriptDev2/sql/scriptdev2_create_structure.sql', 38 'mysql --user=server'.$this->Id.' --password=server'.$this->Id.' server'.$this->Id.'_scriptdev2 < emu/mangos/'.$Emulator['Revision'].'/source/src/bindings/ScriptDev2/sql/scriptdev2_script_full.sql', 39 'mysql --user=server'.$this->Id.' --password=server'.$this->Id.' server'.$this->Id.'_mangos < emu/mangos/'.$Emulator['Revision'].'/source/src/bindings/ScriptDev2/sql/mangos_scriptname_full.sql', 40 'mysql --user=server'.$this->Id.' --password=server'.$this->Id.' server'.$this->Id.'_realmd < emu/mangos/'.$Emulator['Revision'].'/mangos/sql/realmd.sql', 41 'mysql --user=server'.$this->Id.' --password=server'.$this->Id.' server'.$this->Id.'_characters < emu/mangos/'.$Emulator['Revision'].'/mangos/sql/characters.sql')); 38 $this->Database->query('CREATE DATABASE `server'.$this->Id.'_realmd`'); 39 $this->Database->query('CREATE DATABASE `server'.$this->Id.'_mangos`'); 40 $this->Database->query('CREATE DATABASE `server'.$this->Id.'_characters`'); 41 $this->Database->query('CREATE DATABASE `server'.$this->Id.'_scriptdev2`'); 42 $this->Database->query('CREATE USER "server'.$this->Id.'"@"localhost" IDENTIFIED BY "server'.$this->Id.'"'); 43 $this->Database->query('GRANT ALL PRIVILEGES ON `server'.$this->Id.'\_realmd` . * TO "server'.$this->Id.'"@"localhost" WITH GRANT OPTION'); 44 $this->Database->query('GRANT ALL PRIVILEGES ON `server'.$this->Id.'\_mangos` . * TO "server'.$this->Id.'"@"localhost" WITH GRANT OPTION'); 45 $this->Database->query('GRANT ALL PRIVILEGES ON `server'.$this->Id.'\_characters` . * TO "server'.$this->Id.'"@"localhost" WITH GRANT OPTION'); 46 $this->Database->query('GRANT ALL PRIVILEGES ON `server'.$this->Id.'\_scriptdev2` . * TO "server'.$this->Id.'"@"localhost" WITH GRANT OPTION'); 47 } 48 49 function DeleteDatabase() 50 { 51 $this->Database->query('DROP DATABASE `server'.$this->Id.'_realmd`'); 52 $this->Database->query('DROP DATABASE `server'.$this->Id.'_mangos`'); 53 $this->Database->query('DROP DATABASE `server'.$this->Id.'_characters`'); 54 $this->Database->query('DROP DATABASE `server'.$this->Id.'_scriptdev2`'); 55 $this->Database->query('DROP USER "server'.$this->Id.'"@"localhost"'); 56 } 57 58 function ImportDatabase($Delete = false) 59 { 60 $CommandList = array( 61 'mysql --user=server'.$this->Id.' --password=server'.$this->Id.' server'.$this->Id.'_mangos < database/'.$this->Server['Database']['Id'].'/'.$this->Server['Database']['SourceFileName'], 62 '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', 63 '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_script_full.sql', 64 'mysql --user=server'.$this->Id.' --password=server'.$this->Id.' server'.$this->Id.'_mangos < emulator/'.$this->Server['Database']['Emulator']['Id'].'/source/src/bindings/ScriptDev2/sql/mangos_scriptname_full.sql', 65 'mysql --user=server'.$this->Id.' --password=server'.$this->Id.' server'.$this->Id.'_realmd < emulator/'.$this->Server['Database']['Emulator']['Id'].'/mangos/sql/realmd.sql', 66 'mysql --user=server'.$this->Id.' --password=server'.$this->Id.' server'.$this->Id.'_characters < emulator/'.$this->Server['Database']['Emulator']['Id'].'/mangos/sql/characters.sql', 67 ); 68 if($Delete = true) 69 { 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'); 71 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'); 72 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'); 73 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'); 74 } 75 $this->AddTask('Inicializace databáze', $CommandList); 42 76 } 43 77 … … 50 84 { 51 85 $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',86 '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"', 87 'screen -A -m -d -S server'.$this->Id.'-worldd emulator/'.$this->Server['Database']['Emulator']['Id'].'/bin/mangos-worldd -c server/'.$this->Id.'/etc/mangosd.conf', 54 88 )); 55 89 return('Požadavek na start serveru zařazen.'); … … 67 101 function NetworkPortState($Address, $Port, $Timeout = 1) 68 102 { 103 set_error_handler('ErrorHandler'); 69 104 if($Socket = @fsockopen($Address, $Port, $ERROR_NO, $ERROR_STR, (float)$Timeout)) 70 105 { 71 106 fclose($Socket); 72 return(true); 73 } else return(false); 107 $Result = true; 108 } else $Result = false; 109 restore_error_handler(); 110 return($Result); 74 111 } 75 112 … … 79 116 $State['RealmdPortState'] = $this->NetworkPortState('localhost', $this->RealmdBaseNetworkPort + $this->Server['Id']); 80 117 $State['WorlddPortState'] = $this->NetworkPortState('localhost', $this->WorlddBaseNetworkPort + $this->Server['Id']); 118 $State['Online'] = $State['RealmdPortState'] and $State['WorlddPortState']; 119 $DbResult = $this->Database->query('SELECT COUNT(*) FROM information_schema.TABLES WHERE TABLE_SCHEMA = "server'.$this->Id.'_characters"'); 120 $DbRow = $DbResult->fetch_row(); 121 if($DbRow[0] > 0) 122 { 123 $DbResult = $this->Database->query('SELECT COUNT(*) FROM server'.$this->Id.'_characters.characters AS T WHERE T.online = 1'); 124 $DbRow = $DbResult->fetch_row(); 125 $State['OnlinePlayerCount'] = $DbRow[0]; 126 $DbResult = $this->Database->query('SELECT COUNT(*) FROM server'.$this->Id.'_characters.characters AS T'); 127 $DbRow = $DbResult->fetch_row(); 128 $State['CharacterCount'] = $DbRow[0]; 129 $DbResult = $this->Database->query('SELECT COUNT(*) FROM server'.$this->Id.'_realmd.account AS T'); 130 $DbRow = $DbResult->fetch_row(); 131 $State['AccountCount'] = $DbRow[0]; 132 } else 133 { 134 $State['OnlinePlayerCount'] = 0; 135 $State['CharacterCount'] = 0; 136 $State['AccountCount'] = 0; 137 } 81 138 return($State); 139 } 140 141 function UpdateRealmlist() 142 { 143 global $Config; 144 145 $this->Database->query('UPDATE server'.$this->Id.'_realmd.realmlist SET name="'.addslashes($this->Server['Name']).'", address="'.$Config['Web']['Host'].'", port='.($this->WorlddBaseNetworkPort + $this->Id)); 146 } 147 148 function SaveConfiguration() 149 { 150 $this->SetupConfigurationFiles(); 151 $this->UpdateRealmlist(); 82 152 } 83 153 84 154 function SetupConfigurationFiles() 85 155 { 156 $EmulatorEtcDir = '../emulator/'.$this->Server['Database']['Emulator']['Id'].'/etc/'; 157 $ServerEtcDir = '../server/'.$this->Id.'/etc/'; 158 $ServerLogDir = '../server/'.$this->Id.'/log/'; 159 if(!file_exists($ServerEtcDir)) mkdir($ServerEtcDir, 0777, true); 160 if(!file_exists($ServerLogDir)) mkdir($ServerLogDir, 0777, true); 161 86 162 // mangosd.conf 87 163 $Config = new MangosConfigurationFile($this->Database); 88 $Config->Load( '../emu/mangos/'.$this->Server['Database']['Emulator']['Revision'].'/etc/mangosd.conf');164 $Config->Load($EmulatorEtcDir.'mangosd.conf'); 89 165 $Config->ParameterList['LoginDatabaseInfo'] = 'localhost;3306;server'.$this->Id.';server'.$this->Id.';server'.$this->Id.'_realmd'; 90 166 $Config->ParameterList['WorldDatabaseInfo'] = 'localhost;3306;server'.$this->Id.';server'.$this->Id.';server'.$this->Id.'_mangos'; … … 94 170 $Config->ParameterList['Motd'] = $this->Server['Motd']; 95 171 $Config->ParameterList['DataDir'] = 'wowclient/'.$this->Server['Database']['Emulator']['ClientVersion']['Version']; 96 $Config->Save('../server/'.$this->Id.'/etc/mangosd.conf'); 172 $Config->ParameterList['LogsDir'] = 'server/'.$this->Id.'/log'; 173 $ServerTypes = array(0 => 0, 1 => 1, 2 => 6, 3 => 8); 174 $Config->ParameterList['GameType'] = $ServerTypes[$this->Server['Type']]; 175 $Config->Save($ServerEtcDir.'mangosd.conf'); 97 176 98 177 // realmd.conf 99 178 $Config = new MangosConfigurationFile($this->Database); 100 $Config->Load( '../emu/mangos/'.$this->Server['Database']['Emulator']['Revision'].'/etc/realmd.conf');179 $Config->Load($EmulatorEtcDir.'realmd.conf'); 101 180 $Config->ParameterList['LoginDatabaseInfo'] = 'localhost;3306;server'.$this->Id.';server'.$this->Id.';server'.$this->Id.'_realmd'; 102 181 $Config->ParameterList['RealmServerPort'] = $this->RealmdBaseNetworkPort + $this->Id; 103 $Config->Save('../server/'.$this->Id.'/etc/realmd.conf'); 182 $Config->ParameterList['LogsDir'] = 'server/'.$this->Id.'/log'; 183 $Config->Save($ServerEtcDir.'realmd.conf'); 104 184 105 185 // scriptdev2.conf 106 186 $Config = new MangosConfigurationFile($this->Database); 107 $Config->Load( '../emu/mangos/'.$this->Server['Database']['Emulator']['Revision'].'/etc/scriptdev2.conf');187 $Config->Load($EmulatorEtcDir.'scriptdev2.conf'); 108 188 $Config->ParameterList['ScriptDev2DatabaseInfo'] = 'localhost;3306;server'.$this->Id.';server'.$this->Id.';server'.$this->Id.'_scriptdev2'; 109 $Config->Save( '../server/'.$this->Id.'/etc/scriptdev2.conf');189 $Config->Save($ServerEtcDir.'scriptdev2.conf'); 110 190 } 111 191 } -
trunk/www/style.css
r3 r6 310 310 margin-left: auto; 311 311 margin-right: auto; 312 border-collapse: collapse; 312 313 } 313 314 -
trunk/www/user.php
r4 r6 21 21 define('USER_PASSWORD_RECOVERY_CONFIRMED', 'Nové heslo bylo aktivováno.'); 22 22 23 define('USER_BAD_ROLE', 'Nemáte dostatečná oprávnění'); 24 23 25 define('USER_EVENT_REGISTER', 1); 24 26 define('USER_EVENT_LOGIN', 2); 25 27 define('USER_EVENT_LOGOUT', 3); 26 28 define('USER_EVENT_OPTIONS_CHANGED', 4); 29 30 define('USER_ROLE_ANONYMOUS', 1); 31 define('USER_ROLE_USER', 2); 32 define('USER_ROLE_ADMINISTRATOR', 3); 27 33 28 34 class User extends Module … … 75 81 } 76 82 77 function Register($Login, $Password, $Password2, $Email, $Name , $PhoneNumber, $ICQ)83 function Register($Login, $Password, $Password2, $Email, $Name) 78 84 { 79 85 global $Options, $Config; … … 96 102 else 97 103 { 98 $this->Database->insert('User', array('Name' => $Name, 'Login' => $Login, 'Password' => sha1($Password), 'Email' => $Email, 'RegistrationTime' => 'NOW()', 'Locked' => 1, 'PhoneNumber' => $PhoneNumber, 'ICQ' => $ICQ)); 99 $UserId = $this->Database->insert_id; 100 $this->Database->insert('PermissionUserAssignment', array('User' => $UserId, 'GroupOrOperation' => 2, 'Type' => 'Group')); 101 104 $this->Database->insert('User', array('Name' => $Name, 'Login' => $Login, 'Password' => sha1($Password), 'Email' => $Email, 'RegistrationTime' => 'NOW()', 'Locked' => 1, 'Role' => 2)); 105 102 106 $Subject = FromUTF8('Registrace nového účtu', 'iso2'); 103 107 $Message = 'Provedli jste registraci nového účtu na serveru <a href="http://'.$Config['Web']['Host'].$Config['Web']['RootFolder'].'">http://'.$Config['Web']['Host'].$Config['Web']['RootFolder']."</a>.<br>\nPokud jste tak neučinili, měli by jste tento email ignorovat.<br><br>\n\nVáš účet je: ".$Login."\n<br>Pro dokončení registrace klikněte na tento odkaz: ".'<a href="http://'.$Config['Web']['Host'].$Config['Web']['RootFolder'].'/?Action=UserRegisterConfirm&User='.$UserId.'&H='.sha1($Password).'">http://'.$Config['Web']['Host'].$Config['Web']['RootFolder'].'/?Action=UserRegisterConfirm&User='.$UserId.'&H='.sha1($Password).'</a>.'."\n<br> \n\n<br><br>Na tento email neodpovídejte."; … … 144 148 // načtení stavu stromu 145 149 $Result = USER_LOGGED_IN; 146 //$this->System->Modules['Log']->NewRecord('User', 'Login', 'Login='.$Login.',Host='.gethostbyaddr(GetRemoteAddress()));150 $this->System->Modules['Log']->NewRecord('User', 'Login', 'Login='.$Login.',Host='.gethostbyaddr(GetRemoteAddress())); 147 151 } 148 152 } else $Result = USER_NOT_REGISTRED;
Note:
See TracChangeset
for help on using the changeset viewer.