Changeset 15 for trunk/www/server.php


Ignore:
Timestamp:
Jun 12, 2009, 8:09:48 AM (15 years ago)
Author:
george
Message:
  • Přidáno: Nastavení parametrů gcc překladu emulátoru přes konfigurační soubor.
  • Přidáno: Podpora řazení dle sloupců v tabulkách.
  • Upraveno: Nezjišťovat informace o stavu serverů z tabulek mangosu, ale ukládat stavové informace serverů přímo do tabulky Server. Nutno provádět aktualizaci tabulky.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/www/server.php

    r14 r15  
    1818    $this->Id = $Id;
    1919    $DbResult = $this->Database->query('SELECT * FROM `Server` WHERE `Id`='.$Id);
    20     $this->Server = $DbResult->fetch_assoc();
    21     $DbResult = $this->Database->query('SELECT * FROM `Database` WHERE `Id`='.$this->Server['Database']);
    22     if($DbResult->num_rows > 0) $this->Server['Database'] = $DbResult->fetch_assoc();
    23       else $this->Server['Database'] = array('Emulator' => 0);
    24     $DbResult = $this->Database->query('SELECT * FROM `Emulator` WHERE `Id`='.$this->Server['Database']['Emulator']);
    25     if($DbResult->num_rows > 0) $this->Server['Database']['Emulator'] = $DbResult->fetch_assoc();
    26       else $this->Server['Database']['Emulator'] = array('ClientVersion' => 0);
    27     $DbResult = $this->Database->query('SELECT * FROM `ClientVersion` WHERE `Id`='.$this->Server['Database']['Emulator']['ClientVersion']);
    28     if($DbResult->num_rows > 0) $this->Server['Database']['Emulator']['ClientVersion'] = $DbResult->fetch_assoc();
    29       else $this->Server['Database']['Emulator']['ClientVersion'] = array();
     20    if($DbResult->num_rows > 0)
     21    {
     22      $this->Server = $DbResult->fetch_assoc();
     23      $DbResult = $this->Database->query('SELECT * FROM `Database` WHERE `Id`='.$this->Server['Database']);
     24      if($DbResult->num_rows > 0) $this->Server['Database'] = $DbResult->fetch_assoc();
     25        else $this->Server['Database'] = array('Emulator' => 0);
     26      $DbResult = $this->Database->query('SELECT * FROM `Emulator` WHERE `Id`='.$this->Server['Database']['Emulator']);
     27      if($DbResult->num_rows > 0) $this->Server['Database']['Emulator'] = $DbResult->fetch_assoc();
     28        else $this->Server['Database']['Emulator'] = array('ClientVersion' => 0);
     29      $DbResult = $this->Database->query('SELECT * FROM `ClientVersion` WHERE `Id`='.$this->Server['Database']['Emulator']['ClientVersion']);
     30      if($DbResult->num_rows > 0) $this->Server['Database']['Emulator']['ClientVersion'] = $DbResult->fetch_assoc();
     31        else $this->Server['Database']['Emulator']['ClientVersion'] = array();
     32    }
    3033  }
    3134 
     
    125128      $DbResult = $this->Database->query('SELECT COUNT(*) FROM server'.$this->Id.'_characters.characters AS T WHERE T.online = 1');
    126129      $DbRow = $DbResult->fetch_row();
    127       $State['OnlinePlayerCount'] = $DbRow[0];
     130      $State['CharacterOnlineCount'] = $DbRow[0];
    128131      $DbResult = $this->Database->query('SELECT COUNT(*) FROM server'.$this->Id.'_characters.characters AS T');
    129132      $DbRow = $DbResult->fetch_row();
     
    237240    $Config->Save($ServerEtcDir.'scriptdev2.conf'); 
    238241  }
     242 
     243  function UpdateServerList()
     244  {
     245    $DbResult = $this->Database->select('Server', 'Id');
     246    while($DbRow = $DbResult->fetch_assoc())
     247    {
     248      $Server = new Server($this->Database, $DbRow['Id']);
     249      $ServerState = $Server->GetState();
     250      $this->Database->update('Server', 'Id='.$DbRow['Id'], array(
     251        'Online' => $ServerState['Online'],
     252        'CharacterOnlineCount' => $ServerState['CharacterOnlineCount'],
     253        'CharacterCount' => $ServerState['CharacterCount'],
     254        'AccountCount' => $ServerState['AccountCount'],
     255      ));
     256    }   
     257  }
    239258}
    240259
Note: See TracChangeset for help on using the changeset viewer.