Changeset 57 for trunk/www/view


Ignore:
Timestamp:
Aug 4, 2009, 5:32:06 PM (16 years ago)
Author:
george
Message:
  • Opraveno: Dále posunuta funkčnost podpory více světů na server.
Location:
trunk/www/view
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/www/view/base.php

    r56 r57  
    2424    {
    2525      $Output .= '<div><a href="?Action=ServerList&amp;Filter=User">Moje servery</a></div>';
    26       $Output .= '<div><a href="?Action=RealmList&amp;Filter=User">Moje světy</a></div>';
     26      //$Output .= '<div><a href="?Action=RealmList&amp;Filter=User">Moje světy</a></div>';
    2727      //$Output .= '<div><a href="?Action=DebugList&amp;Id='.$Server['Id'].'">Ladící záznamy</a></div>';
    2828      //$Output .= '<div><a href="?Action=BackupList&amp;Id='.$Server['Id'].'">Zálohy</a></div>';
  • trunk/www/view/emulator.php

    r56 r57  
    9292      $Form->LoadValuesFromForm();
    9393      $Form->SaveValuesToDatabase(0);
    94       $Output = $this->SystemMessage('Přidání nového emulátoru', 'Emulátor přidán.');
     94      $Output = $this->System->SystemMessage('Přidání nového emulátoru', 'Emulátor přidán.');
    9595    } else $Output = USER_BAD_ROLE;
    9696    return($Output);   
     
    103103      $Emulator = new Emulator($this->Database, $_GET['Id']);
    104104      $Emulator->Download();       
    105       $Output = $this->SystemMessage('Stažení emulátoru', 'Úloha zařazena do fronty');
    106       $Output .= $this->ShowTaskList();
    107     } else $Output = $this->SystemMessage('Stažení emulátoru', 'Nebylo zadáno Id');
     105      $Output = $this->System->SystemMessage('Stažení emulátoru', 'Úloha zařazena do fronty');
     106      $TaskView = new TaskView($this->Database, $this->System);
     107      $Output .= $TaskView->ItemList();
     108    } else $Output = $this->System->SystemMessage('Stažení emulátoru', 'Nebylo zadáno Id');
    108109    return($Output);
    109110  }
     
    115116      $Emulator = new Emulator($this->Database, $_GET['Id']);
    116117      $Emulator->Compile();       
    117       $Output = $this->SystemMessage('Překlad emulátoru', 'Úloha zařazena do fronty');
    118       $Output .= $this->ShowTaskList();
    119     } else $Output = $this->SystemMessage('Překlad emulátoru', 'Nebylo zadáno Id');
     118      $Output = $this->System->SystemMessage('Překlad emulátoru', 'Úloha zařazena do fronty');
     119      $TaskView = new TaskView($this->Database, $this->System);
     120      $Output .= $TaskView->ItemList();
     121    } else $Output = $this->System->SystemMessage('Překlad emulátoru', 'Nebylo zadáno Id');
    120122    return($Output);
    121123  }
  • trunk/www/view/realm.php

    r56 r57  
    44{
    55  var $ItemFormClass = array(
    6     'Title' => 'Nastavení',
    7     'Table' => 'Svět',
     6    'Title' => 'Nastavení světa',
     7    'Table' => 'Realm',
    88    'SubmitText' => 'Uložit',
    99    'Items' => array(
     
    3131    ),
    3232  );
    33 
     33  var $CreateFormClass = array(
     34    'Title' => 'Nový svět',
     35    'Table' => 'Realm',
     36    'SubmitText' => 'Vytvořit',
     37    'Items' => array(
     38      'Name' => array('Type' => 'String', 'Caption' => 'Název', 'Default' => 'Svět'),
     39      'Description' => array('Type' => 'Text', 'Caption' => 'Popis', 'Default' => ''),
     40      'Homepage' => array('Type' => 'Hyperlink', 'Caption' => 'Webové stránky', 'Default' => ''),
     41      'Type' => array('Type' => 'ServerType', 'Caption' => 'Typ', 'Default' => 0),
     42      'Database' => array('Type' => 'Database', 'Caption' => 'Databáze', 'Default' => 0),
     43      'Motd' => array('Type' => 'String', 'Caption' => 'Zpráva dne', 'Default' => 'Vítejte na free WoW serveru'),
     44    ),
     45  );
     46  var $EditFormClass = array(
     47    'Title' => 'Nastavení',
     48    'Table' => 'Realm',
     49    'SubmitText' => 'Uložit',
     50    'Items' => array(
     51      'Name' => array('Type' => 'String', 'Caption' => 'Název', 'Default' => 'WoW server'),
     52      'Description' => array('Type' => 'Text', 'Caption' => 'Popis', 'Default' => ''),
     53      'Homepage' => array('Type' => 'Hyperlink', 'Caption' => 'Webové stránky', 'Default' => ''),
     54      'Type' => array('Type' => 'ServerType', 'Caption' => 'Typ', 'Default' => 0),
     55      'Database' => array('Type' => 'Database', 'Caption' => 'Databáze', 'Default' => 0),
     56      'Motd' => array('Type' => 'String', 'Caption' => 'Zpráva dne', 'Default' => 'Vítejte na free WoW serveru'),
     57      'RealmId' => array('Type' => 'Hidden', 'Caption' => 'Id', 'Default' => 0),
     58      //'TimeCreation' => array('Type' => 'DateTime', 'Caption' => 'Datum založení', 'Default' => 'NOW()'),
     59    ),
     60  );
     61  var $SettingDetailedFormClass = array(
     62    'Title' => 'Podrobné nastavení serveru',
     63    'Table' => '',
     64    'Items' => array(
     65      'ServerId' => array('Type' => 'Hidden', 'Caption' => 'Id', 'Default' => 0),
     66      'SkipCinematics' => array('Type' => 'SkipCinematics', 'Caption' => 'Zobrazovat úvodní video', 'Default' => ''),
     67      'StartPlayerLevel' => array('Type' => 'Integer', 'Caption' => 'Počáteční úroveň hráčů', 'Default' => 1),
     68      'MaxPlayerLevel' => array('Type' => 'Integer', 'Caption' => 'Max. úroveň hráčů', 'Default' => 80),
     69      'StartHeroicPlayerLevel' => array('Type' => 'Integer', 'Caption' => 'Počáteční úroveň hrdinských postav', 'Default' => 55),
     70      'StartPlayerMoney' => array('Type' => 'Integer', 'Caption' => 'Počáteční množství peněz', 'Default' => 0),
     71      'StartHonorPoints' => array('Type' => 'Integer', 'Caption' => 'Počáteční počet bodů cti', 'Default' => 0),
     72      'MaxHonorPoints' => array('Type' => 'Integer', 'Caption' => 'Max. počet bodů cti', 'Default' => 75000),
     73      'StartArenaPoints' => array('Type' => 'Integer', 'Caption' => 'Počáteční počet bodů arén', 'Default' => 0),
     74      'MaxArenaPoints' => array('Type' => 'Integer', 'Caption' => 'Max. počet bodů arén', 'Default' => 5000),
     75      'MaxArenaPoints' => array('Type' => 'Integer', 'Caption' => 'Max. počet bodů arén', 'Default' => 5000),
     76      'InstantLogout' => array('Type' => 'SecurityLevel', 'Caption' => 'Povolit okamžitého odhlášení', 'Default' => 1),
     77      'DisableWaterBreath' => array('Type' => 'SecurityLevel', 'Caption' => 'Zakázat dýchání pod vodou', 'Default' => 1),         
     78      'AllFlightPaths' => array('Type' => 'Boolean', 'Caption' => 'Povoleny všechny létací cesty', 'Default' => 0),         
     79      'AlwaysMaxSkillForLevel' => array('Type' => 'Boolean', 'Caption' => 'Vždy max. dovednost na úroveň', 'Default' => 0),         
     80      'ActivateWeather' => array('Type' => 'Boolean', 'Caption' => 'Aktivní počasí', 'Default' => 1),         
     81      'CastUnstuck' => array('Type' => 'Boolean', 'Caption' => 'Povolit odblokovací kouzlo pomocí .start', 'Default' => 1),         
     82      'MinPetitionSigns' => array('Type' => 'Integer', 'Caption' => 'Min. počet podpisů k zápisu spolku', 'Default' => 9),         
     83      'MaxGroupXPDistance' => array('Type' => 'Integer', 'Caption' => 'Max. rozdíl XP ve skupině', 'Default' => 74),         
     84      'MailDeliveryDelay' => array('Type' => 'Integer', 'Caption' => 'Zpoždění doručení pošty', 'Default' => 3600),         
     85      'Event.Announce' => array('Type' => 'Boolean', 'Caption' => 'Ohlašování událostí', 'Default' => 0),         
     86      'AllowTwoSide.Accounts' => array('Type' => 'Boolean', 'Caption' => 'Povolit účty s postavami obou stran', 'Default' => 0),         
     87      'AllowTwoSide.Interaction.Chat' => array('Type' => 'Boolean', 'Caption' => 'Povolit komunikaci mezi stranami', 'Default' => 0),         
     88      'AllowTwoSide.Interaction.Channel' => array('Type' => 'Boolean', 'Caption' => 'Povolit kanály mezi stranami', 'Default' => 0),
     89      'AllowTwoSide.WhoList' => array('Type' => 'Boolean', 'Caption' => 'Povolit obě strany v seznamu přítomných', 'Default' => 0),               
     90    ),
     91  ); 
    3492
    3593  function ItemList()
    3694  {
    3795    global $Config;
     96   
     97    if(array_key_exists('Id', $_GET)) $ServerId = $_GET['Id'];
    3898   
    3999    $Realm = new Realm($this->Database, 0);
     
    42102    $Table = new Table($this->ItemListFormClass);
    43103    //$Table->OnRow = array($this, 'ShowRealmListOnRow');
     104    $Table->Definition['Table'] = substr($Table->Definition['Table'], 0, -1).' WHERE `Realm`.`Server`='.$ServerId.')';
    44105    $Table->Definition['Items']['Id'] = array('Type' => 'Hidden', 'Caption' => '', 'Default' => '');
    45106    $Table->LoadValuesFromDatabase($this->Database);
     
    63124    return($Output);
    64125  }
     126 
     127  function Item()
     128  {
     129    global $Config;
     130   
     131    $Id = $_GET['Id'];
     132    $Realm = new Realm($this->Database, $Id);
     133    //if(isset($Server->Server))
     134    //{
     135    $Output = '<h4>Podrobnosti světa</h4>';
     136    $Form = new Form($this->ItemFormClass);
     137    $Form->LoadValuesFromDatabase($Id);
     138    $Form->Definition['Items']['Uptime'] = array('Type' => 'String', 'Caption' => 'Doba běhu', 'Default' => '');
     139    $Form->Definition['Items']['UsedMemory'] = array('Type' => 'String', 'Caption' => 'Použitá paměť', 'Default' => '');   
     140    $RealmStatus = $Realm->GetState();
     141    unset($Form->Definition['Items']['NetworkPortWorldd']);
     142    //$Form->Values['Uptime'] = $this->System->AddPrefixMultipliers($RealmStatus['Uptime'], '', 4, 'Time');
     143    //$Form->Values['UsedMemory'] = $this->System->AddPrefixMultipliers($RealmStatus['UsedMemory'] * 1024, 'B', 4, 'Binary');
     144    $Output .= $Form->ShowTable();
     145    $Server = new Server($this->Database, $Realm->Data['Server']);
     146    $Output .= '<div style="text-align: center">';
     147    if((($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER) and ($this->System->Modules['User']->User['Id'] == $Server->Server['User'])) or ($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR))
     148    {
     149      $Output .= '<br /><a href="http://'.$this->System->Config['Web']['Host'].'/mysql/">Správa databáze</a> ';
     150      if(array_key_exists('Id', $Realm->Data['Database']) and ($Realm->Data['Lock'] == 0))
     151      {
     152        if($ServerStatus['WorlddPortState'] == true) $Output .= ' <a href="?Action=RealmStop&amp;Id='.$Realm->Id.'">Zastavit</a>  <a href="?Action=RealmRestart&amp;Id='.$Realm->Id.'">Restartovat</a>';
     153          else $Output .= ' <a href="?Action=RealmStart&amp;Id='.$Realm->Id.'">Spustit</a>';
     154      }
     155      if($Realm->Data['Lock'] == 0)
     156      {
     157        $Output .= ' <a href="?Action=RealmEdit&amp;Id='.$Realm->Id.'">Upravit základní nastavení</a>';
     158        $Output .= ' <a href="?Action=RealmEditDetailed&amp;Id='.$Realm->Id.'">Upravit podrobné nastavení</a>';
     159      }
     160      //$Output .= ' <a href="?Action=ServerDatabaseImport&amp;Id='.$Server->Id.'">Načtení čisté databáze</a>';
     161    }
     162    $Output .= '</div>';   
     163    return($Output);
     164  }
     165 
     166  function Add()
     167  {
     168    global $Config;
     169   
     170    if(array_key_exists('Id', $_GET))
     171    {
     172      $ServerId = $_GET['Id'];
     173    $Output = '';
     174    if($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER)
     175    {
     176      $DbResult = $this->Database->query('SELECT COUNT(*) FROM Realm');
     177      $DbRow = $DbResult->fetch_row();
     178      $RealmCount = $DbRow[0];
     179      if($RealmCount < $Config['MaxRealmCount'])
     180      {
     181        if($this->System->Modules['User']->RealmCount() >= $Config['MaxServerCountPerUser']) $Output .= $this->System->SystemMessage('Nový svět', 'Na jeden účet lze vytvořit maximálně '.$Config['MaxServerCountPerUser'].' světů');
     182        else
     183        {
     184          $Form = new Form($this->CreateFormClass);
     185          $Form->LoadValuesFromForm();
     186          $Form->OnSubmit = '?Action=RealmCreate&amp;Id='.$ServerId;
     187          $Output .= 'Tento formulář vám umožní si vytvořit nový svět. Pečlivě vyplňte požadované údaje.';
     188          $Output .= $Form->ShowEditForm();
     189        }
     190      } else $Output .= $this->System->SystemMessage('Nový svět', 'Nelze vytvářet další světyservery');
     191    } else $Output .= USER_BAD_ROLE;
     192    } else $Output = $this->System->SystemMessage('Vytvoření světa', 'Nezadáno Id serveru');
     193    return($Output);
     194  }
     195
     196  function Create()
     197  {
     198    global $Config;   
     199     
     200    if(array_key_exists('Id', $_GET))
     201    {
     202      $ServerId = $_GET['Id'];
     203    if($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER)
     204    {
     205      if($this->System->Modules['User']->RealmCount() >= $Config['MaxServerCountPerUser']) $Output = $this->System->SystemMessage('Nový svět', 'Na jeden účet lze vytvořit maximálně '.$Config['MaxServerCountPerUser'].' světů');
     206      else
     207      {
     208        // Allocate unused network port for realm
     209        $DbResult = $this->Database->query('SELECT MAX(NetworkPortWorldd) FROM Realm');
     210        $DbRow = $DbResult->fetch_row();
     211        $NewPortWorldd = $DbRow[0] + 1;
     212        if($NewPortWorldd < $Config['BaseNetworkPortWorldd']) $NewPortWorldd = $Config['BaseNetworkPortWorldd'];
     213           
     214        $Form = new Form($this->CreateFormClass, array());
     215        $Form->LoadValuesFromForm();
     216        $this->Database->insert('Realm', array('Name' => $Form->Values['Name'], 'Description' => $Form->Values['Description'], 'Server' => $ServerId, 'Motd' => $Form->Values['Motd'], 'Homepage' => $Form->Values['Homepage'], 'Type' => $Form->Values['Type'], 'Database' => $Form->Values['Database'], 'NetworkPortWorldd' => $NewPortWorldd, 'Lock' => 1, 'TimeCreate' => 'NOW()'));
     217        $LastInsertId = $this->Database->insert_id;
     218        $Realm = new Realm($this->Database, $LastInsertId);
     219        $Realm->CreateDatabase();           
     220        $Output = $this->System->SystemMessage('Vytvoření světu', $Realm->ImportDatabase(true));
     221        $TaskView = new TaskView($this->Database, $this->System);
     222        $Output .= $TaskView->ItemList();
     223        //$UserOptions->LoadValuesFromDatabase($this->System->Modules['User']->User['Id']);
     224        //$Form->OnSubmit = '?Action=ServerCreate';
     225        //$Output .= $Form->ShowEditForm();
     226      }
     227    } else $Output = USER_BAD_ROLE;
     228    } else $Output = $this->System->SystemMessage('Vytvoření světa', 'Nezadáno Id serveru');
     229    return($Output);
     230  }
     231 
     232  function Save()
     233  {
     234    $Output = '';
     235    $Realm = new Realm($this->Database, $_POST['RealmId']);
     236    if(($this->System->Modules['User']->User['Id'] == $Realm->GetUser()) or ($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR))
     237    {
     238      $Form = new Form($this->EditFormClass, array());
     239      $Form->LoadValuesFromForm();
     240      $RealmId = $_POST['RealmId'];
     241      unset($Form->Values['RealmId']);
     242      $Output .= $this->System->SystemMessage('Upravit svět', 'Nastavení světa uloženo.');
     243      $Form->SaveValuesToDatabase($_POST['RealmId']);
     244      $Form->OnSubmit = '?Action=RealmSave';
     245       
     246      $Realm = new Realm($this->Database, $_POST['RealmId']);
     247      $Realm->SaveConfiguration();
     248      $Form->Values['RealmId'] = $RealmId;
     249      $Output .= $Form->ShowEditForm();
     250    } else $Output = $this->System->SystemMessage('Nastavení serveru', 'Nemáte oprávnění');
     251    return($Output);
     252  }
     253
     254  function Edit()
     255  {
     256    $Output = '';
     257    $Realm = new Realm($this->Database, $_GET['Id']);
     258    if(($this->System->Modules['User']->User['Id'] == $Realm->GetUser()) or ($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR))
     259    {
     260      $Form = new Form($this->EditFormClass);
     261      $Form->LoadValuesFromDatabase($_GET['Id']);
     262      $Form->Values['RealmId'] = $_GET['Id'];
     263      $Form->OnSubmit = '?Action=RealmSave';
     264      $Output .= $Form->ShowEditForm();
     265    } else $Output = $this->System->SystemMessage('Nastavení světa', 'Nemáte oprávnění');
     266    return($Output);
     267  }
     268 
     269  function EditDetailed()
     270  {
     271    $Output = '';
     272    $Realm = new Realm($this->Database, $_GET['Id']);
     273    if(($this->System->Modules['User']->User['Id'] == $Realm->GetUser()) or ($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR))
     274    {
     275      $Form = new Form($this->SettingDetailedFormClass);
     276      $EmulatorConfig = new MangosConfigurationFile($this->Database);
     277      $EmulatorConfig->Load('../realm/'.$Realm->Id.'/etc/mangosd.conf');
     278      $Form->Values = $EmulatorConfig->ParameterList;
     279      $Form->Values['RealmId'] = $_GET['Id'];
     280      $Form->OnSubmit = '?Action=RealmSaveDetailed';
     281      $Output .= $Form->ShowEditForm();
     282    } else $this->System->SystemMessage('Nastavení světa', 'Nemáte oprávnění');
     283    return($Output);   
     284  }
     285 
     286  function SaveDetailed()
     287  {
     288    $Output = '';
     289    $Realm = new Realm($this->Database, $_POST['ServerId']);
     290    if(($this->System->Modules['User']->User['Id'] == $Realm->GetUser()) or ($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR))
     291    {
     292      $Form = new Form($this->$SettingDetailedFormClass, array());
     293      $Form->LoadValuesFromForm();
     294      $EmulatorConfig = new MangosConfigurationFile($this->Database);
     295      $EmulatorConfig->Load('../realm/'.$Realm->Id.'/etc/mangosd.conf');
     296      foreach($Form->Values as $Index => $Item)
     297        $EmulatorConfig->ParameterList[$Index] = $Item;
     298      $EmulatorConfig->Save('../server/'.$Realm->Id.'/etc/mangosd.conf');
     299      $RealmId = $_POST['RealmId'];
     300      unset($Form->Values['RealmId']);
     301      $Output .= $this->System->SystemMessage('Upravit svět', 'Nastavení světa uloženo.');
     302      //$Form->SaveValuesToDatabase($_POST['ServerId']);
     303      $Form->OnSubmit = '?Action=RealmSaveDetailed';
     304       
     305      $Realm = new Realm($this->Database, $_POST['RealmId']);
     306      $Realm->SaveConfiguration();
     307      $Form->Values['RealmId'] = $RealmId;
     308      $Output .= $Form->ShowEditForm();
     309    } else $this->System->SystemMessage('Nastavení světa', 'Nemáte oprávnění');
     310    return($Output);
     311  }
     312 
     313  function Start()
     314  {
     315    $Output = '';
     316    if($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER)
     317    {
     318      $Realm = new Realm($this->Database, $_GET['Id']);
     319      if(($this->System->Modules['User']->User['Id'] == $Realm->GetUser()) or ($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR))
     320      {
     321        $Output .= $this->System->SystemMessage('Spuštění serveru', $Realm->Start());
     322        $TaskView = new TaskView($this->Database, $this->System);
     323        $Output .= $TaskView->ItemList();;
     324      } else $this->System->SystemMessage('Spuštění serveru', 'Nemáte oprávnění');
     325    } else $Output .= USER_BAD_ROLE;
     326    return($Output);
     327  }
     328 
     329  function Stop()
     330  {
     331    $Output = '';
     332    if($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER)
     333    {
     334      $Realm = new Realm($this->Database, $_GET['Id']);
     335      if(($this->System->Modules['User']->User['Id'] == $Realm->GetUser()) or ($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR))
     336      {
     337        $Output .= $this->System->SystemMessage('Zastavení serveru', $Realm->Stop());
     338        $TaskView = new TaskView($this->Database, $this->System);
     339        $Output .= $TaskView->ItemList();;
     340      } else $this->System->SystemMessage('Zastavení serveru', 'Nemáte oprávnění');
     341    } else $Output .= USER_BAD_ROLE;
     342    return($Output);
     343  }
    65344}
    66345
  • trunk/www/view/server.php

    r56 r57  
    33class ServerView extends Module
    44{
    5   var $ViewFormClass = array(
     5  var $ItemFormClass = array(
    66    'Title' => 'Nastavení',
    77    'Table' => 'Server',
     
    3939      'Description' => array('Type' => 'Text', 'Caption' => 'Popis', 'Default' => ''),
    4040      'Homepage' => array('Type' => 'Hyperlink', 'Caption' => 'Webové stránky', 'Default' => ''),
    41       'Type' => array('Type' => 'ServerType', 'Caption' => 'Typ', 'Default' => 0),
     41      //'Type' => array('Type' => 'ServerType', 'Caption' => 'Typ', 'Default' => 0),
    4242      'Database' => array('Type' => 'Database', 'Caption' => 'Databáze', 'Default' => 0),
    43       'Motd' => array('Type' => 'String', 'Caption' => 'Zpráva dne', 'Default' => 'Vítejte na free WoW serveru'),
     43      //'Motd' => array('Type' => 'String', 'Caption' => 'Zpráva dne', 'Default' => 'Vítejte na free WoW serveru'),
    4444    ),
    4545  );
     
    5252      'Description' => array('Type' => 'Text', 'Caption' => 'Popis', 'Default' => ''),
    5353      'Homepage' => array('Type' => 'Hyperlink', 'Caption' => 'Webové stránky', 'Default' => ''),
    54       'Type' => array('Type' => 'ServerType', 'Caption' => 'Typ', 'Default' => 0),
    55       //'Database' => array('Type' => 'Database', 'Caption' => 'Databáze', 'Default' => 0),
    56       'Motd' => array('Type' => 'String', 'Caption' => 'Zpráva dne', 'Default' => 'Vítejte na free WoW serveru'),
     54      //'Type' => array('Type' => 'ServerType', 'Caption' => 'Typ', 'Default' => 0),
     55      'Database' => array('Type' => 'Database', 'Caption' => 'Databáze', 'Default' => 0),
     56      //'Motd' => array('Type' => 'String', 'Caption' => 'Zpráva dne', 'Default' => 'Vítejte na free WoW serveru'),
    5757      'ServerId' => array('Type' => 'Hidden', 'Caption' => 'Id', 'Default' => 0),
    5858      //'TimeCreation' => array('Type' => 'DateTime', 'Caption' => 'Datum založení', 'Default' => 'NOW()'),
     
    7171    ),
    7272  ); 
    73   var $SettingDetailedFormClass = array(
    74     'Title' => 'Podrobné nastavení serveru',
    75     'Table' => '',
    76     'Items' => array(
    77       'ServerId' => array('Type' => 'Hidden', 'Caption' => 'Id', 'Default' => 0),
    78       'SkipCinematics' => array('Type' => 'SkipCinematics', 'Caption' => 'Zobrazovat úvodní video', 'Default' => ''),
    79       'StartPlayerLevel' => array('Type' => 'Integer', 'Caption' => 'Počáteční úroveň hráčů', 'Default' => 1),
    80       'MaxPlayerLevel' => array('Type' => 'Integer', 'Caption' => 'Max. úroveň hráčů', 'Default' => 80),
    81       'StartHeroicPlayerLevel' => array('Type' => 'Integer', 'Caption' => 'Počáteční úroveň hrdinských postav', 'Default' => 55),
    82       'StartPlayerMoney' => array('Type' => 'Integer', 'Caption' => 'Počáteční množství peněz', 'Default' => 0),
    83       'StartHonorPoints' => array('Type' => 'Integer', 'Caption' => 'Počáteční počet bodů cti', 'Default' => 0),
    84       'MaxHonorPoints' => array('Type' => 'Integer', 'Caption' => 'Max. počet bodů cti', 'Default' => 75000),
    85       'StartArenaPoints' => array('Type' => 'Integer', 'Caption' => 'Počáteční počet bodů arén', 'Default' => 0),
    86       'MaxArenaPoints' => array('Type' => 'Integer', 'Caption' => 'Max. počet bodů arén', 'Default' => 5000),
    87       'MaxArenaPoints' => array('Type' => 'Integer', 'Caption' => 'Max. počet bodů arén', 'Default' => 5000),
    88       'InstantLogout' => array('Type' => 'SecurityLevel', 'Caption' => 'Povolit okamžitého odhlášení', 'Default' => 1),
    89       'DisableWaterBreath' => array('Type' => 'SecurityLevel', 'Caption' => 'Zakázat dýchání pod vodou', 'Default' => 1),         
    90       'AllFlightPaths' => array('Type' => 'Boolean', 'Caption' => 'Povoleny všechny létací cesty', 'Default' => 0),         
    91       'AlwaysMaxSkillForLevel' => array('Type' => 'Boolean', 'Caption' => 'Vždy max. dovednost na úroveň', 'Default' => 0),         
    92       'ActivateWeather' => array('Type' => 'Boolean', 'Caption' => 'Aktivní počasí', 'Default' => 1),         
    93       'CastUnstuck' => array('Type' => 'Boolean', 'Caption' => 'Povolit odblokovací kouzlo pomocí .start', 'Default' => 1),         
    94       'MinPetitionSigns' => array('Type' => 'Integer', 'Caption' => 'Min. počet podpisů k zápisu spolku', 'Default' => 9),         
    95       'MaxGroupXPDistance' => array('Type' => 'Integer', 'Caption' => 'Max. rozdíl XP ve skupině', 'Default' => 74),         
    96       'MailDeliveryDelay' => array('Type' => 'Integer', 'Caption' => 'Zpoždění doručení pošty', 'Default' => 3600),         
    97       'Event.Announce' => array('Type' => 'Boolean', 'Caption' => 'Ohlašování událostí', 'Default' => 0),         
    98       'AllowTwoSide.Accounts' => array('Type' => 'Boolean', 'Caption' => 'Povolit účty s postavami obou stran', 'Default' => 0),         
    99       'AllowTwoSide.Interaction.Chat' => array('Type' => 'Boolean', 'Caption' => 'Povolit komunikaci mezi stranami', 'Default' => 0),         
    100       'AllowTwoSide.Interaction.Channel' => array('Type' => 'Boolean', 'Caption' => 'Povolit kanály mezi stranami', 'Default' => 0),
    101       'AllowTwoSide.WhoList' => array('Type' => 'Boolean', 'Caption' => 'Povolit obě strany v seznamu přítomných', 'Default' => 0),               
    102     ),
    103   ); 
    10473 
    10574  function ShowListOnRow($Row)
     
    11988    $Output = '<h4>Seznam serverů</h4>';
    12089    $Table = new Table($this->ItemListFormClass);
     90    if(array_key_exists('Filter', $_GET))
     91    {
     92      if($_GET['Filter'] == 'User')
     93        $Table->Definition['Table'] = substr($Table->Definition['Table'], 0, -1).' WHERE User='.$this->System->Modules['User']->User['Id'].')';
     94    }
    12195    $Table->OnRow = array($this, 'ShowListOnRow');
    12296    $Table->Definition['Items']['Id'] = array('Type' => 'Hidden', 'Caption' => '', 'Default' => '');
     
    136110      $DbResult = $this->Database->query('SELECT COUNT(*) FROM Server WHERE User='.$this->System->Modules['User']->User['Id']);
    137111      $DbRow = $DbResult->fetch_row();
    138       if(($ServerCount < $Config['MaxServerCount']) and ($DbRow[0] == 0))
     112      if(($ServerCount < $Config['MaxServerCount']) and ($DbRow[0] < $Config['MaxServerCountPerUser']))
    139113        $Output .= '<br /><div style="text-align: center;"><a href="?Action=ServerAdd">Vytvořit nový server</a></dev>';     
    140114    }
     
    151125    {
    152126    $Output = '<h4>Podrobnosti serveru</h4>';
    153     $Form = new Form($this->ViewFormClass);
     127    $Form = new Form($this->ItemFormClass);
    154128    $Form->LoadValuesFromDatabase($Id);
    155129    $Form->Definition['Items']['Realmlist'] = array('Type' => 'String', 'Caption' => 'Adresa k připojení', 'Default' => '');   
     
    176150      {
    177151        $Output .= ' <a href="?Action=ServerEdit&amp;Id='.$Server->Id.'">Upravit základní nastavení</a>';
    178         $Output .= ' <a href="?Action=ServerEditDetailed&amp;Id='.$Server->Id.'">Upravit podrobné nastavení</a>';
    179152      }
    180153      //$Output .= ' <a href="?Action=ServerDatabaseImport&amp;Id='.$Server->Id.'">Načtení čisté databáze</a>';
     154      $Output .= ' <a href="?Action=RealmAdd&amp;Id='.$Server->Id.'">Vytvořit nový svět</a>';
    181155    }
    182156    $Output .= ' <a href="?Action=GameAccountRegister&amp;Id='.$Server->Id.'">Vytvoření herního účtu</a>';
     
    204178        $DbResult = $this->Database->query('SELECT COUNT(*) FROM Server WHERE User='.$this->System->Modules['User']->User['Id']);
    205179        $DbRow = $DbResult->fetch_row();
    206         if($DbRow[0] > 0) $Output .= $this->System->SystemMessage('Nový server', 'Lze vytvořit pouze jeden server pro každý uživatelský účet.');
     180        if($DbRow[0] >= $Config['MaxServerCountPerUser']) $Output .= $this->System->SystemMessage('Nový server', 'Na jeden účet lze vytvořit maximálně '.$Config['MaxServerCountPerUser'].' serverů');
    207181        else
    208182        {
     
    220194  function Create()
    221195  {
     196    global $Config;
     197   
    222198    $Output = '';
    223199    if($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER)
     
    225201      $DbResult = $this->Database->query('SELECT COUNT(*) FROM Server WHERE User='.$this->System->Modules['User']->User['Id']);
    226202      $DbRow = $DbResult->fetch_row();
    227       if($DbRow[0] > 0) $Output .= $this->System->SystemMessage('Nový server', 'Lze vytvořit pouze jeden server pro každý uživatelský účet.');
     203      if($DbRow[0] >= $Config['MaxServerCountPerUser']) $Output .= $this->System->SystemMessage('Nový server', 'Na jeden účet lze vytvořit maximálně '.$Config['MaxServerCountPerUser'].' serverů');
    228204      else
    229205      {
    230         $DbResult = $this->Database->query('SELECT MAX(NetworkPortRealmd), MAX(NetworkPortWorldd) FROM Server');
     206        $DbResult = $this->Database->query('SELECT MAX(NetworkPortRealmd) FROM Server');
    231207        $DbRow = $DbResult->fetch_row();
    232208        $NewPortRealmd = $DbRow[0] + 1;
    233209        if($NewPortRealmd < $Config['BaseNetworkPortRealmd']) $NewPortRealmd = $Config['BaseNetworkPortRealmd'];
    234         $NewPortWorldd = $DbRow[1] + 1;
    235         if($NewPortWorldd < $Config['BaseNetworkPortWorldd']) $NewPortWorldd = $Config['BaseNetworkPortWorldd'];
    236210           
    237211        $Form = new Form($this->CreateFormClass, array());
    238212        $Form->LoadValuesFromForm();
    239         $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' => $Form->Values['Database'], 'NetworkPortWorldd' => $NewPortWorldd, 'NetworkPortRealmd' => $NewPortRealmd, 'Lock' => 1, 'TimeCreate' => 'NOW()'));
     213        $this->Database->insert('Server', array('Name' => $Form->Values['Name'], 'Description' => $Form->Values['Description'], 'User' => $this->System->Modules['User']->User['Id'], 'Homepage' => $Form->Values['Homepage'], 'Database' => $Form->Values['Database'], 'NetworkPortRealmd' => $NewPortRealmd, 'Lock' => 1, 'TimeCreate' => 'NOW()'));
    240214        $LastInsertId = $this->Database->insert_id;
    241215        $Server = new Server($this->Database, $LastInsertId);
    242216        $Server->CreateDatabase();           
    243217        $Output .= $this->System->SystemMessage('Vytvoření serveru', $Server->ImportDatabase(true));
    244         $Output .= $this->ShowTaskList();
     218        $TaskView = new TaskView($this->Database, $this->System);
     219        $Output .= $TaskView->ItemList();
    245220        //$UserOptions->LoadValuesFromDatabase($this->System->Modules['User']->User['Id']);
    246221        //$Form->OnSubmit = '?Action=ServerCreate';
     
    284259      $Form->OnSubmit = '?Action=ServerSave';
    285260      $Output .= $Form->ShowEditForm();
    286     } else $Output = $this->SystemMessage('Nastavení serveru', 'Nemáte oprávnění');
    287     return($Output);
    288   }
    289  
    290   function EditDetailed()
    291   {
    292     $Output = '';
    293     $Server = new Server($this->Database, $_GET['Id']);
    294     if(($this->System->Modules['User']->User['Id'] == $Server->Server['User']) or ($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR))
    295     {
    296       $Form = new Form($this->$SettingDetailedFormClass);
    297       $EmulatorConfig = new MangosConfigurationFile($this->Database);
    298       $EmulatorConfig->Load('../server/'.$Server->Id.'/etc/mangosd.conf');
    299       $Form->Values = $EmulatorConfig->ParameterList;
    300       $Form->Values['ServerId'] = $_GET['Id'];
    301       $Form->OnSubmit = '?Action=ServerSaveDetailed';
    302       $Output .= $Form->ShowEditForm();
    303     } else $this->System->SystemMessage('Nastavení serveru', 'Nemáte oprávnění');
    304     return($Output);   
    305   }
    306  
    307   function SaveDetailed()
    308   {
    309     $Output = '';
    310     $Server = new Server($this->Database, $_POST['ServerId']);
    311     if(($this->System->Modules['User']->User['Id'] == $Server->Server['User']) or ($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR))
    312     {
    313       $Form = new Form($this->$SettingDetailedFormClass, array());
    314       $Form->LoadValuesFromForm();
    315       $EmulatorConfig = new MangosConfigurationFile($this->Database);
    316       $EmulatorConfig->Load('../server/'.$Server->Id.'/etc/mangosd.conf');
    317       foreach($Form->Values as $Index => $Item)
    318         $EmulatorConfig->ParameterList[$Index] = $Item;
    319       $EmulatorConfig->Save('../server/'.$Server->Id.'/etc/mangosd.conf');
    320       $ServerId = $_POST['ServerId'];
    321       unset($Form->Values['ServerId']);
    322       $Output .= $this->System->SystemMessage('Upravit server', 'Nastavení serveru uloženo.');
    323       //$Form->SaveValuesToDatabase($_POST['ServerId']);
    324       $Form->OnSubmit = '?Action=ServerSaveDetailed';
    325        
    326       $Server = new Server($this->Database, $_POST['ServerId']);
    327       $Server->SaveConfiguration();
    328       $Form->Values['ServerId'] = $ServerId;
    329       $Output .= $Form->ShowEditForm();
    330     } else $this->System->SystemMessage('Nastavení serveru', 'Nemáte oprávnění');
    331     return($Output);
    332   }
     261    } else $Output = $this->System->SystemMessage('Nastavení serveru', 'Nemáte oprávnění');
     262    return($Output);
     263  }
    333264 
    334265  function Start()
     
    341272      {
    342273        $Output .= $this->System->SystemMessage('Spuštění serveru', $Server->Start());
    343         $Output .= $this->ShowTaskList();
     274        $TaskView = new TaskView($this->Database, $this->System);
     275        $Output .= $TaskView->ItemList();;
    344276      } else $this->System->SystemMessage('Spuštění serveru', 'Nemáte oprávnění');
    345277    } else $Output .= USER_BAD_ROLE;
     
    356288      {
    357289        $Output .= $this->System->SystemMessage('Zastavení serveru', $Server->Stop());
    358         $Output .= $this->ShowTaskList();
     290        $TaskView = new TaskView($this->Database, $this->System);
     291        $Output .= $TaskView->ItemList();;
    359292      } else $this->System->SystemMessage('Zastavení serveru', 'Nemáte oprávnění');
    360293    } else $Output .= USER_BAD_ROLE;
Note: See TracChangeset for help on using the changeset viewer.