Changeset 681 for trunk/inc


Ignore:
Timestamp:
Jan 23, 2010, 1:32:45 PM (15 years ago)
Author:
george
Message:
  • Upraveno: Nastavení počítačů, přihlašovacích serverů a světů přesunuto do databáze z konfiguračního souboru.
Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:ignore
      •  

        old new  
        1 mm
        2 Thumbs.db
         1gallery
         2armory
         3tester
         4test
         5minimanager
         6mmfpm
  • trunk/inc/realm.php

    r634 r681  
    1111    parent::__construct($System);
    1212    $this->Id = $Id;
    13     $this->Database = new Database($this->Config['Mangos']['RealmList'][$Id]['DatabaseHost'], $this->Config['Mangos']['RealmList'][$Id]['DatabaseUser'], $this->Config['Mangos']['RealmList'][$Id]['DatabasePassword'], $this->Config['Mangos']['RealmList'][$Id]['DatabaseCharacters']);
    14     if($this->Database->connect_error)
     13    $DbResult = $this->Database->query('SELECT * FROM Realm WHERE Id='.$Id);
     14    $this->Data = $DbResult->fetch_assoc();
     15    $this->CharactersDatabase = new Database($this->Data['DatabaseHost'], $this->Data['DatabaseUser'], $this->Data['DatabasePassword'], $this->Data['DatabaseCharacters']);
     16    $this->CharactersDatabase->select_db($this->Data['DatabaseCharacters']);
     17    if($this->CharactersDatabase->connect_error)
    1518    {
    16       //die('Přihlášení k databázi realmu '.$this->Id.' selhalo: '.$this->Database->connect_error);
     19      die('Přihlášení k databázi realmu '.$this->Id.' selhalo: '.$this->Database->connect_error);
    1720    }
    18     $this->Database->charset($this->Config['Database']['Charset']);
     21    $this->CharactersDatabase->charset($this->Config['Database']['Charset']);
     22   
     23    $this->MangosDatabase = new Database($this->Data['DatabaseHost'], $this->Data['DatabaseUser'], $this->Data['DatabasePassword'], $this->Data['DatabaseMangos']);
     24    $this->MangosDatabase->select_db($this->Data['DatabaseMangos']);
     25    if($this->MangosDatabase->connect_error)
     26    {
     27      die('Přihlášení k databázi realmu '.$this->Id.' selhalo: '.$this->MangosDatabase->connect_error);
     28    }
     29    $this->MangosDatabase->charset($this->Config['Database']['Charset']);
    1930  }
    2031 
    2132  function OnlineCharactersCount()
    2233  {
    23     if($this->Database->connect_error) return(0);
     34    if($this->CharactersDatabase->connect_error) return(0);
    2435    else {
    25       $this->Database->select_db($this->Config['Mangos']['RealmList'][$this->Id]['DatabaseCharacters']);   
    26       $DbResult = $this->Database->query('SELECT COUNT(*) FROM `characters` WHERE `online` = 1');
     36      $DbResult = $this->CharactersDatabase->query('SELECT COUNT(*) FROM `characters` WHERE `online` = 1');
    2737      $DbRow = $DbResult->fetch_row();
    2838      return($DbRow[0]);
     
    4757  public function CharacterCount()
    4858  {
    49     if($this->Database->connect_error) return('');
     59    if($this->CharactersDatabase->connect_error) return('');
    5060    else {
    51       $this->Database->select_db($this->Config['Mangos']['RealmList'][$this->Id]['DatabaseCharacters']);   
    52       $DbResult = $this->Database->query('SELECT COUNT(*) FROM `characters`');
     61      $DbResult = $this->CharactersDatabase->query('SELECT COUNT(*) FROM `characters`');
    5362      $DbRow = $DbResult->fetch_row();
    5463      return($DbRow[0]);
     
    5867  public function GuidToCharName($guid)
    5968  {
    60     if($this->Database->connect_error) return(0);
     69    if($this->CharactersDatabase->connect_error) return(0);
    6170    else {
    62       $this->Database->select_db($this->Config['Mangos']['RealmList'][$this->Id]['DatabaseCharacters']);
    63       $row = $this->Database->query('SELECT `name` FROM `characters` WHERE `guid` = "'.$guid.'" LIMIT 1')->fetch_array();
     71      $row = $this->CharactersDatabase->query('SELECT `name` FROM `characters` WHERE `guid` = "'.$guid.'" LIMIT 1')->fetch_array();
    6472      return($row['name']);
    6573    }
     
    8997        $edited = str_replace(")]", ";", $edited);          // 5 - selected guid
    9098        $edited_arr = explode(";",$edited);
    91         if($edited_arr[4] == "player") $sel_name = " - ".$this -> GuidToCharName($edited_arr[5]);
     99        if($edited_arr[4] == "player") $sel_name = " - ".$this->GuidToCharName($edited_arr[5]);
    92100          else $sel_name = '';
    93         $human_date = $this -> HumanDate ($edited_arr[0]);
     101        $human_date = $this -> HumanDate($edited_arr[0]);
    94102        echo('<tr>
    95103            <td><font size="2">'.$human_date.'</font></td>
     
    107115        $edited = str_replace(")", "", $edited);
    108116        $edited_arr = explode(";",$edited);
    109         $human_date = $this -> HumanDate ($edited_arr[0]);
     117        $human_date = $this -> HumanDate($edited_arr[0]);
    110118        echo('<tr>
    111119            <td><font size="2">'.$human_date.'</font></td>
  • trunk/inc/server.php

    r680 r681  
    1313    parent::__construct($System);
    1414    $this->Id = $Id;
     15    $DbResult = $this->Database->query('SELECT * FROM Logon WHERE Id='.$Id);
     16    $this->Data = $DbResult->fetch_assoc();
     17    $this->ServerDatabase = new Database($this->Data['DatabaseHost'], $this->Data['DatabaseUser'], $this->Data['DatabasePassword'], $this->Data['DatabaseRealmd']);
     18    $this->ServerDatabase->select_db($this->Data['DatabaseRealmd']);
     19    if($this->ServerDatabase->connect_error)
     20    {
     21      die('Přihlášení k databázi serveru '.$this->Id.' selhalo: '.$this->ServerDatabase->connect_error);
     22    }
     23    $this->ServerDatabase->charset($this->Config['Database']['Charset']);
    1524  }
    1625
     
    4453  {
    4554    $TotalCount = 0;
    46     foreach($this->Config['Mangos']['RealmList'] as $Index => $Realm)
     55    $DbResult = $this->Database->query('SELECT Id FROM Realm');
     56    while($DbRow = $DbResult->fetch_assoc())
    4757    {
    48       $Realm = new Realm($this->System, $Index);
     58      $Realm = new Realm($this->System, $DbRow['Id']);
    4959      $TotalCount += $Realm->OnlineCharactersCount();
    5060    }
     
    6171  {
    6272    $TotalCount = 0;
    63     foreach($this->Config['Mangos']['RealmList'] as $Index => $Realm)
     73    $DbResult = $this->Database->query('SELECT Id FROM Realm');
     74    while($DbRow = $DbResult->fetch_assoc())
    6475    {
    65       $Realm = new Realm($this->System, $Index);
    66       $TotalCount += $Realm->CharacterCount($Index);
     76      $Realm = new Realm($this->System, $DbRow['Id']);
     77      $TotalCount += $Realm->CharacterCount($DbRow['Id']);
    6778    }
    6879    return($TotalCount);
     
    7182  public function AccountCount()
    7283  {
    73     $this->Database->select_db($this->Config['Mangos']['DatabaseRealmd']);
    74     $row = $this->Database->query('SELECT COUNT(*) FROM account')->fetch_row();
     84    $row = $this->ServerDatabase->query('SELECT COUNT(*) FROM account')->fetch_row();
    7585    return($row[0]);
    7686  }
     
    362372  {
    363373    $Output = '';
    364     if(count($this->Config['Mangos']['RealmList']) > 1)
     374    $DbResult = $this->Database->query('SELECT COUNT(*) FROM Realm');
     375    $DbRow = $DbResult->fetch_row();
     376    $RealmCount = $DbRow[0];
     377   
     378    if($RealmCount > 1)
    365379    {
    366380      if(array_key_exists('page', $_GET)) $Target = '?page='.$_GET['page'];
     
    368382      $Output .= '<div style="text-align: center;"><form id="RealmSelection'.$FormNameSufix.'" action="'.$Target.'" method="post">'.
    369383      '<div>Výběr světa <select name="RealmIndex" onchange="document.getElementById(\'RealmSelection'.$FormNameSufix.'\').submit()">';
    370       foreach($this->Config['Mangos']['RealmList'] as $Index => $Realm)
     384     
     385      $DbResult = $this->Database->query('SELECT * FROM Realm');
     386      while($Realm = $DbResult->fetch_assoc())
    371387      {
    372         if($_COOKIE['RealmIndex'] == $Index) $Selected = ' selected="selected"';
     388        if($_COOKIE['RealmIndex'] == $Realm['Id']) $Selected = ' selected="selected"';
    373389         else $Selected = '';
    374         $Output .= '<option value="'.$Index.'"'.$Selected.'>'.$Realm['Name'].'</option>';
     390        $Output .= '<option value="'.$Realm['Id'].'"'.$Selected.'>'.$Realm['Name'].'</option>';
    375391      }
    376392      $Output .= '</select></div>'.
Note: See TracChangeset for help on using the changeset viewer.