Changeset 15


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.
Location:
trunk
Files:
1 added
1 deleted
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/www/backup.php

    r6 r15  
    1313  }
    1414 
    15   function Restore()
     15  function Restore($Id)
    1616  {
     17   
    1718  }
    1819 
    19   function Save()
     20  function Save($Id)
    2021  {
     22   
    2123  } 
    2224}
  • trunk/www/config.sample.php

    r9 r15  
    3030  'BaseDir' => '/opt/wowhosting/',
    3131  'MaxServerCount' => 20,
     32  'CompilerParameters' => '',
    3233);
    3334
  • trunk/www/emulator.php

    r14 r15  
    6060      'mkdir objdir',
    6161      'cd objdir',
    62       'export CFLAGS="-march=athlon64 -m64 -O2 -g -ggdb',
    63       'export CXXFLAGS="-march=athlon64 -m64 -O2 -g -ggdb',
     62      'export CFLAGS="-g -ggdb '.$Config['CompilerParameters'],
     63      'export CXXFLAGS="-g -ggdb '.$Config['CompilerParameters'],
    6464      '../configure --prefix='.$Config['BaseDir'].'emulator/'.$this->Id.'/ --enable-cli --enable-ra',
    6565      'make',
  • trunk/www/form.php

    r11 r15  
    7878    foreach($this->Definition['Items'] as $Index => $Item)
    7979    {
    80       $this->Values[$Index] = $DbRow[$Index];
     80      $this->Values[$Item['Name']] = $DbRow[$Item['Name']];
    8181    }
    8282  }
  • trunk/www/index.php

    r12 r15  
    1010  function ShowServerListOnRow($Row)
    1111  {
    12     $Server = new Server($this->Database, $Row['Id']);
    13     $ServerState = $Server->GetState();
    14     $Row['Online'] = $ServerState['Online'] * 1;
    1512    $Row['NetworkPortRealmd'] = $this->System->Config['Web']['Host'].':'.$Row['NetworkPortRealmd'];
    1613    $Row['Name'] = '<a href="?Action=ServerShow&amp;Id='.$Row['Id'].'">'.$Row['Name'].'</a>';
    17     $Row['AccountCount'] = $ServerState['AccountCount'];
    18     $Row['CharacterCount'] = $ServerState['CharacterCount'];
    19     $Row['OnlinePlayerCount'] = $ServerState['OnlinePlayerCount'];
    2014    return($Row);
    2115  }
     
    2519    global $Config;
    2620   
     21    $Server = new Server($this->Database, 0);
     22    $Server->UpdateServerList();
    2723    $Output = '<h4>Seznam serverů</h4>';
    2824    $Table = new Table('ServerList');
     
    125121        $Form = new Form('UserLogin');
    126122        $Form->OnSubmit = '?Action=Login';
    127         $Result = $this->System->Modules['User']->Login($_POST['Username'], $_POST['Password']);
     123        $Form->LoadValuesFromForm();
     124        $Result = $this->System->Modules['User']->Login($Form->Values['Username'], $Form->Values['Password']);
    128125        $Output .= $this->SystemMessage('Přihlášení', $Result);
    129126        if($Result <> USER_LOGGED_IN)
    130127        {
    131           $Form->LoadValuesFromForm();
    132128          $Form->Values['Password'] = '';
    133129          $Output .= $Form->ShowEditForm();
  • 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
  • trunk/www/table.php

    r11 r15  
    88  var $Header;
    99  var $OnRow;
     10  var $QueryParameters;
    1011 
    1112  function __construct($ClassName)
     
    1415
    1516    $this->Definition = &$FormClasses[$ClassName];   
     17    $this->QueryParameters = array();
    1618  }
    1719 
    1820  function Show()
    1921  {
     22    $Header = array();
     23    if(!array_key_exists('Order', $_GET)) $_GET['Order'] = 0;
     24    if(!array_key_exists('Column', $_GET)) $_GET['Column'] = 0;
     25    $QueryParts = explode('&', $_SERVER['QUERY_STRING']);
     26    foreach($QueryParts as $Part)
     27    {
     28      $Part2 = explode('=', $Part);
     29      $QueryItems[$Part2[0]] = $Part2[1];
     30    }
     31    $QueryItems['Order'] = $_GET['Order'];
     32    foreach($this->Definition['Items'] as $Index => $Item)
     33    {
     34      $QueryItems['Column'] = $Index;
     35      if($_GET['Column'] == $Index) $QueryItems['Order'] = 1 - $_GET['Order'];
     36        else $QueryItems['Order'] = $_GET['Order'];
     37      $QueryParts = array();
     38      foreach($QueryItems as $Index2 => $Item2)
     39      {
     40        $QueryParts[] = $Index2.'='.$Item2;
     41      }
     42      $Header[] = '<a href="?'.implode('&amp;', $QueryParts).'">'.$Item['Caption'].'</a>';
     43    }
    2044    $Table = array(
    21       'Header' => $this->Header,
     45      'Header' => $Header,
    2246      'Rows' => $this->Values,
    2347    );
     
    2852  function LoadValuesFromDatabase($Database)
    2953  {   
     54    $OrderType = array('ASC', 'DESC');
     55    if(!array_key_exists('Order', $_GET)) $_GET['Order'] = 0;
     56    else if($_GET['Order'] == 'Asc') $_GET['Order'] = 1;
     57    if(!array_key_exists('Column', $_GET))
     58    {
     59      $Keys = array_keys($this->Definition['Items']);
     60      $_GET['Column'] = $Keys[0];
     61    }
    3062    $this->Header = array();
    3163    foreach($this->Definition['Items'] as $Index => $Item)
    3264    {
    3365      $this->Header[] = $Item['Caption'];
    34 
    3566    }
    3667    $this->Values = array();
    37     $DbResult = $Database->query('SELECT * FROM '.$this->Definition['Table']);
     68    $Table = $this->Definition['Table'];
     69    foreach($this->QueryParameters as $Index => $Item)
     70      $Table = str_replace('%'.$Index, $Item, $Table);
     71    $DbResult = $Database->query('SELECT * FROM '.$Table.' ORDER BY T.'.$_GET['Column'].' '.$OrderType[$_GET['Order']]);
    3872    while($DbRow = $DbResult->fetch_assoc())
    3973    {
  • trunk/www/types/Password.php

    r11 r15  
    2323    global $Database;
    2424
    25     if(!array_key_exists('SourceItemId', $Item)) $Result = sha1($_POST[$Item['Name']]);
     25    $Result = sha1($_POST[$Item['Name']]);
     26    /*
     27    if(!array_key_exists('SourceItemId', $Item)) $Result = sha1($_POST[$Item['Name']]);   
    2628    else
    2729    {
     
    3436      } else $Result = sha1($_POST[$Item['Name']]);
    3537    }
     38    */
    3639    return($Result);
    3740  }
  • trunk/www/user.php

    r14 r15  
    141141    {
    142142      $Row = $Query->fetch_assoc();
    143       if($Row['Password'] != sha1($Password)) $Result = BAD_PASSWORD;
     143      if($Row['Password'] != $Password) $Result = BAD_PASSWORD;
    144144      else if($Row['Locked'] == 1) $Result = ACCOUNT_LOCKED;
    145145      else
Note: See TracChangeset for help on using the changeset viewer.