Changeset 39


Ignore:
Timestamp:
Jun 16, 2009, 6:11:15 PM (15 years ago)
Author:
george
Message:
  • Upraveno: Zobrazení více informací o serverech včetně počtu účtů, postav a online hráčů, dále pak zabraná paměť a doba běhu.
Location:
trunk/www
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/www/form_classes.php

    r38 r39  
    4747    ),
    4848  ),
    49   'NewServer' => array(
     49  'ServerCreate' => array(
    5050    'Title' => 'Nový server',
    5151    'Table' => 'Server',
     
    6060    ),
    6161  ),
    62   'EditServer' => array(
     62  'ServerEdit' => array(
    6363    'Title' => 'Nastavení',
    6464    'Table' => 'Server',
     
    7373      'ServerId' => array('Type' => 'Hidden', 'Caption' => 'Id', 'Default' => 0),
    7474      //'TimeCreation' => array('Type' => 'DateTime', 'Caption' => 'Datum založení', 'Default' => 'NOW()'),
     75    ),
     76  ),
     77  'ServerView' => array(
     78    'Title' => 'Nastavení',
     79    'Table' => 'Server',
     80    'SubmitText' => 'Uložit',
     81    'Items' => array(
     82      'Name' => array('Type' => 'String', 'Caption' => 'Název', 'Default' => 'WoW server'),
     83      'Description' => array('Type' => 'Text', 'Caption' => 'Popis', 'Default' => ''),
     84      'Homepage' => array('Type' => 'Hyperlink', 'Caption' => 'Webové stránky', 'Default' => ''),
     85      'Type' => array('Type' => 'ServerType', 'Caption' => 'Typ', 'Default' => 0),
     86      'Database' => array('Type' => 'Database', 'Caption' => 'Databáze', 'Default' => 0),
     87      'Motd' => array('Type' => 'String', 'Caption' => 'Zpráva dne', 'Default' => 'Vítejte na free WoW serveru'),
     88      'ServerId' => array('Type' => 'Hidden', 'Caption' => 'Id', 'Default' => 0),
     89      'TimeCreate' => array('Type' => 'DateTime', 'Caption' => 'Datum založení', 'Default' => 'NOW()'),
     90      'NetworkPortRealmd' => array('Type' => 'Integer', 'Caption' => 'Port realmd', 'Default' => ''),
    7591    ),
    7692  ),
  • trunk/www/index.php

    r36 r39  
    4949  function ShowServer($Id)
    5050  {
     51    global $Config;
     52   
    5153    $Server = new Server($this->Database, $Id);
    5254    $Output = '<h4>Podrobnosti serveru</h4>';
    53     $Form = new Form('EditServer');
     55    $Form = new Form('ServerView');
    5456    $Form->LoadValuesFromDatabase($Id);
     57    $Form->Definition['Items']['Realmlist'] = array('Type' => 'String', 'Caption' => 'Adresa k připojení', 'Default' => '');   
     58    $Form->Definition['Items']['Uptime'] = array('Type' => 'String', 'Caption' => 'Doba běhu', 'Default' => '');
     59    $Form->Definition['Items']['UsedMemory'] = array('Type' => 'String', 'Caption' => 'Použitá paměť', 'Default' => '');   
     60    $Form->Definition['Items']['AccountCount'] = array('Type' => 'String', 'Caption' => 'Počet účtů', 'Default' => '');   
     61    $Form->Definition['Items']['CharacterCount'] = array('Type' => 'String', 'Caption' => 'Počet postav', 'Default' => '');   
     62    $Form->Definition['Items']['CharacterOnlineCount'] = array('Type' => 'String', 'Caption' => 'Počet hráčů online', 'Default' => '');   
     63    $ServerStatus = $Server->GetState();
     64    $Form->Values['Realmlist'] = $Config['Web']['Host'].':'.$Form->Values['NetworkPortRealmd'];
     65    unset($Form->Values['NetworkPortRealmd']);
     66    $Form->Values['Uptime'] = $this->System->AddPrefixMultipliers($ServerStatus['Uptime'], '', 4, 'Time');
     67    $Form->Values['UsedMemory'] = $this->System->AddPrefixMultipliers($ServerStatus['UsedMemory'] * 1024, 'B', 4, 'Binary');
     68    $Form->Values['AccountCount'] = $ServerStatus['AccountCount'];
     69    $Form->Values['CharacterCount'] = $ServerStatus['CharacterCount'];
     70    $Form->Values['CharacterOnlineCount'] = $ServerStatus['CharacterOnlineCount'];
    5571    $Output .= $Form->ShowTable();
    5672    $Output .= '<div style="text-align: center">';
     
    6076      if(array_key_exists('Id', $Server->Server['Database']) and ($Server->Server['Lock'] == 0))
    6177      {
    62         $ServerStatus = $Server->GetState();
    6378        if($ServerStatus['RealmdPortState'] == true) $Output .= ' <a href="?Action=ServerStop&amp;Id='.$Server->Id.'">Zastavit</a>  <a href="?Action=ServerRestart&amp;Id='.$Server->Id.'">Restartovat</a>';
    6479          else $Output .= ' <a href="?Action=ServerStart&amp;Id='.$Server->Id.'">Spustit</a>';
     
    457472            else
    458473            {
    459               $Form = new Form('NewServer');
     474              $Form = new Form('ServerCreate');
    460475              $Form->LoadValuesFromForm();
    461476              $Form->OnSubmit = '?Action=ServerCreate';
     
    482497            if($NewPortWorldd < $Config['BaseNetworkPortWorldd']) $NewPortWorldd = $Config['BaseNetworkPortWorldd'];
    483498           
    484             $Form = new Form('NewServer', array());
     499            $Form = new Form('ServerCreate', array());
    485500            $Form->LoadValuesFromForm();
    486             $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, 'NetworkPortWorldd' => $NewPortWorldd, 'NetworkPortRealmd' => $NewPortRealmd, 'Lock' => 1));
     501            $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, 'NetworkPortWorldd' => $NewPortWorldd, 'NetworkPortRealmd' => $NewPortRealmd, 'Lock' => 1, 'TimeCreate' => 'NOW()'));
    487502            $LastInsertId = $this->Database->insert_id;
    488503            $Server = new Server($this->Database, $LastInsertId);
     
    506521        if(($this->System->Modules['User']->User['Id'] == $Server->Server['User']) or ($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR))
    507522        {
    508           $Form = new Form('EditServer');
     523          $Form = new Form('ServerEdit');
    509524          $Form->LoadValuesFromDatabase($_GET['Id']);
    510525          $Form->Values['ServerId'] = $_GET['Id'];
     
    518533        if(($this->System->Modules['User']->User['Id'] == $Server->Server['User']) or ($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR))
    519534        {
    520           $Form = new Form('EditServer', array());
     535          $Form = new Form('ServerEdit', array());
    521536          $Form->LoadValuesFromForm();
    522537          $ServerId = $_POST['ServerId'];
  • trunk/www/server.php

    r38 r39  
    137137      $DbRow = $DbResult->fetch_row();
    138138      $State['AccountCount'] = $DbRow[0];
     139      $DbResult = $this->Database->query('SELECT uptime FROM server'.$this->Id.'_realmd.uptime AS T ORDER BY T.startstring DESC');
     140      $DbRow = $DbResult->fetch_assoc();
     141      $State['Uptime'] = $DbRow['uptime'];
    139142    } else
    140143    {
     
    143146      $State['AccountCount'] = 0;
    144147    }
     148    $State['UsedMemory'] = $this->GetUsedMemory();
    145149    return($State);
    146150  }
     
    345349  {
    346350    $Output = array();
    347     exec('ps -aux|grep "emulator/'.$this->Server['Database']['Emulator']['Id'].'/bin/mangos-worldd -c server/'.$this->Id.'/etc/mangosd.conf"| grep -v grep', $Output);
    348     print_r($Output);
     351    if(isset($this->Server['Database']['Emulator']['Id']))
     352      exec('ps -aux|grep "emulator/'.$this->Server['Database']['Emulator']['Id'].'/bin/mangos-worldd -c server/'.$this->Id.'/etc/mangosd.conf"| grep -v grep', $Output);
    349353    if(count($Output) > 0)
    350354    {
Note: See TracChangeset for help on using the changeset viewer.