Changeset 681


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:
1 added
13 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>'.
  • trunk/pages/arena.php

    r630 r681  
    1919
    2020$Realm = new Realm($System, $_COOKIE['RealmIndex']);
    21 $db = $Realm->Database;
    22 $db->select_db($Config['Mangos']['RealmList'][$Realm->Id]['DatabaseCharacters']);
     21$db = $Realm->CharactersDatabase;
    2322
    2423$count = $db->query('SELECT COUNT(*) FROM arena_team')->fetch_row();
  • trunk/pages/commands.php

    r630 r681  
    55
    66$Realm = new Realm($System, $_COOKIE['RealmIndex']);
    7 $db = $Realm->Database;
    8 $db->select_db($Config['Mangos']['RealmList'][$Realm->Id]['DatabaseMangos']);
     7$db = $Realm->MangosDatabase;
    98
    109$Output .= '<ul>';
  • trunk/pages/events.php

    r630 r681  
    9191echo($server->RealmSelection());
    9292$Realm = new Realm($System, $_COOKIE['RealmIndex']);
    93 $db = $Realm->Database;
    94 $db->select_db($Config['Mangos']['RealmList'][$Realm->Id]['DatabaseMangos']);
     93$db = $Realm->MangosDatabase;
    9594
    9695$Events = Events();
  • trunk/pages/gmteam.php

    r635 r681  
    5050
    5151$Realm = new Realm($System, $_COOKIE['RealmIndex']);
    52 $db2 = $Realm->Database;
    53 $db2->select_db($Config['Mangos']['RealmList'][$Realm->Id]['DatabaseCharacters']);
     52$db2 = $Realm->CharactersDatabase;
    5453
    55 $db->select_db($Config['Database']['Database']);
    5654$Output = '<h2 class="PageTitle">GM tým</h2>';
    5755
  • trunk/pages/guilda.php

    r634 r681  
    1111
    1212$Realm = new Realm($System, $_COOKIE['RealmIndex']);
    13 $db2 = $Realm->Database;
    14 $db2->select_db($Config['Mangos']['RealmList'][$Realm->Id]['DatabaseCharacters']);
     13$db2 = $Realm->CharactersDatabase;
    1514$id = (isset($_GET['id'])) ? $_GET['id'] : 0;
    1615if($id != 0)
  • trunk/pages/guildy.php

    r634 r681  
    4444
    4545$Realm = new Realm($System, $_COOKIE['RealmIndex']);
    46 $db2 = $Realm->Database;
    47 $db2->select_db($Config['Mangos']['RealmList'][$Realm->Id]['DatabaseCharacters']);
     46$db2 = $Realm->CharactersDatabase;
    4847
    4948$sql = $db2->query('SELECT `guild`.name, `guild`.guildid, `guild`.createdate, COUNT(`guild_member`.`guildid`) AS member_count ,`leader`.`race` IN (1, 3, 4, 7, 11) AS fraction , `leader`.`guid` AS leader FROM `guild` JOIN `guild_member` ON `guild_member`.`guildid` = `guild`.`guildid` JOIN `characters` AS `memebers` ON `memebers`.`guid`= `guild_member`.`guid` JOIN `characters` AS `leader` ON `leader`.`guid`= `guild`.`leaderguid` GROUP BY guild.name ORDER BY '.$order_by.' '.$order_dir.';');
  • trunk/pages/online.php

    r632 r681  
    3737    MakeLink('Body arén', 'arena_points').'</th></tr>');
    3838
    39 $Realm->Database->select_db($Config['Mangos']['RealmList'][$_COOKIE['RealmIndex']]['DatabaseCharacters']);
    40 $sql = $Realm->Database->query('SELECT guid, name, race, class, zone, map, '.
     39$sql = $Realm->CharactersDatabase->query('SELECT guid, name, race, class, zone, map, '.
    4140  'CAST( SUBSTRING_INDEX(SUBSTRING_INDEX(`data`, " ", '.$Config['Mangos']['CharacterDataOffset']['HonorPoints'].'+1), " ", -1) AS UNSIGNED) AS highest_rank, '.
    4241  'CAST( SUBSTRING_INDEX(SUBSTRING_INDEX(`data`, " ", '.$Config['Mangos']['CharacterDataOffset']['Level'].' + 1), " ", -1) AS UNSIGNED) AS level, '.
  • trunk/pages/realmlist.php

    r677 r681  
    11<?php
    22
    3 $Output = '<h2 align="center">Seznam světů</h2>';
    4 
    5 $Output .= '<table class="BaseTable">'.
    6   '<tr>'.
    7   '<th>Název</th>'.
    8   '<th>Násobek XP</th>'.
    9   '<th>Zaměření</th>'.
    10   '<th>Stav</th>'.
    11   '<th>Hráči online / max. online / celkem</th>'.
    12   '</tr>';
    13  
    14 foreach($Config['Mangos']['RealmList'] as $Index => $RealmConfig)
     3if(array_key_exists('Server', $_GET))
    154{
    16   $db->select_db($Config['Mangos']['DatabaseRealmd']);
    17   $DbResult = $db->query('SELECT * FROM `realmlist` WHERE id='.$RealmConfig['Id']); 
     5  $DbResult = $System->Database->query('SELECT Logon.Id, Host.Address, Logon.Port FROM Logon JOIN Host ON Host.Id=Logon.Host WHERE Logon.Id='.$_GET['Server']);
    186  if($DbResult->num_rows > 0)
    197  {
    20     $Realm = new Realm($System, $Index);
    21     $DbRow = $DbResult->fetch_assoc();
    22     $Output .= '<tr><td><a href="?page=online&amp;RealmIndex='.$Index.'">'.$RealmConfig['Name'].'</a></td><td>'.$RealmConfig['XPRate'].'</td><td>'.$RealmConfig['Type'].'</td><td>'.$server->OnlineStateImage($System->NetworkPortState($DbRow['address'], $DbRow['port'])).'</td><td>'.$Realm->OnlineCharactersCount($Index).' / '.$RealmConfig['MaxOnlinePlayers'].' / '.$Realm->CharacterCount($Index).'</td></tr>';
    23     $Output .= '<tr><td colspan="5">'.$RealmConfig['Description'].'</td></tr>';
    24     //if(array_key_exists($Index + 1, $Config['Mangos']['RealmList']))
    25     $Output .= '<tr><td colspan="5">&nbsp;</td></tr>';
     8    $Realm = $DbResult->fetch_assoc();
     9    echo('set realmlist '.$Realm['Address']);
     10    if($Realm['Port'] != 3724) echo(':'.$Realm['Port']);
     11    echo('</div>');
     12  } else echo('Neznámé Id serveru');
     13} else
     14{
     15  $Output = '<h2 align="center">Seznam světů</h2>';
     16
     17  $DbResult = $System->Database->query('SELECT Logon.Id, Host.Address, Logon.Port FROM Logon JOIN Host ON Host.Id=Logon.Host');
     18  while($DbRow = $DbResult->fetch_assoc())
     19  {
     20    $Server = new Server($System, $DbRow['Id']);
     21    $Output .= '<div style="text-align: center">Realmlist <a href="?page=realmlist&amp;Server='.$DbRow['Id'].'">'.$DbRow['Address'];
     22    if($DbRow['Port'] != 3724) $Output .= ':'.$DbRow['Port'];
     23    $Output .= '</a></div>';
     24    $Output .= '<table class="BaseTable">'.
     25    '<tr>'.
     26    '<th>Název</th>'.
     27    '<th>Násobek XP</th>'.
     28    '<th>Zaměření</th>'.
     29    '<th>Stav</th>'.
     30    '<th>Hráči online / max. online / celkem</th>'.
     31    '</tr>';
     32 
     33    $DbResult2 = $System->Database->query('SELECT * FROM Realm WHERE Logon='.$Server->Id.' ORDER BY Name');
     34    while($DbRow = $DbResult2->fetch_assoc())
     35    {
     36      $Realm = new Realm($System, $DbRow['Id']);
     37      $Output .= '<tr><td><a href="?page=online&amp;RealmIndex='.$Realm->Id.'">'.$Realm->Data['Name'].'</a></td><td>'.$Realm->Data['Rate'].'</td><td>'.$Realm->Data['Type'].'</td><td>'.$Server->OnlineStateImage($Realm->Data['Online']).'</td><td>'.$Realm->OnlineCharactersCount().' / '.$Realm->Data['MaxOnlinePlayers'].' / '.$Realm->CharacterCount().'</td></tr>';
     38      $Output .= '<tr><td colspan="5">'.$Realm->Data['Description'].'</td></tr>';
     39      //if(array_key_exists($Index + 1, $Config['Mangos']['RealmList']))
     40      $Output .= '<tr><td colspan="5">&nbsp;</td></tr>';
     41    }
     42    $Output .= '</table><br/>';
    2643  }
     44  echo($Output);
    2745}
    28 $Output .= '</table>';
    29 echo($Output);
    3046
    3147?>
  • trunk/pages/server.php

    r650 r681  
    5757  </tr>
    5858  <tr><td colspan="2" style="padding: 5px;">';
    59  
    60 foreach($Config['Web']['ServerList'] as $Index => $Server)
     59
     60$DbResult = $System->Database->query('SELECT * FROM Host');
     61while($Host = $DbResult->fetch_assoc())
    6162{
    6263  $Realms = array();
    63   foreach($Config['Mangos']['RealmList'] as $RealmIndex => $Realm)
     64  $DbResult2 = $System->Database->query('SELECT * FROM Realm');
     65  while($Realm = $DbResult2->fetch_assoc())
    6466  {
    65     if($Realm['Server'] == $Index) $Realms[] = $Realm['Name'];
     67    if($Realm['Host'] == $Host['Id']) $Realms[] = $Realm['Name'];
    6668  }
    6769   
     
    7274  <tr>
    7375    <td>Operační systém</td>
    74     <td>'.$Server['OS'].'</td>
     76    <td>'.$Host['OS'].'</td>
    7577  </tr>
    7678  <tr>
    7779    <td>Procesor</td>
    78     <td>'.$Server['CPU'].'</td>
     80    <td>'.$Host['CPU'].'</td>
    7981  </tr>
    8082  <tr>
    8183    <td>Operační paměť</td>
    82     <td>'.$Server['Memory'].'</td>
     84    <td>'.$Host['Memory'].'</td>
    8385  </tr>
    8486  <tr>
    8587    <td>Pevný disk</td>
    86     <td>'.$Server['HDD'].'</td>
     88    <td>'.$Host['HDD'].'</td>
    8789  </tr>
    8890  <tr>
    8991    <td>Adresa serveru</td>
    90     <td>'.$Server['Address'].'</td>
     92    <td>'.$Host['Address'].'</td>
    9193  </tr>
    9294  <tr>
    9395    <td>Internetová linka</td>
    94     <td>'.$Server['Internet'].'</td>
     96    <td>'.$Host['Internet'].'</td>
    9597  </tr>
    9698  <tr>
     
    100102  <tr>
    101103    <td>Grafy</td>
    102     <td><a href="'.$Server['Statistic'].'">'.$Server['Statistic'].'</a></td>
     104    <td><a href="'.$Host['Statistic'].'">'.$Host['Statistic'].'</a></td>
    103105  </tr>
    104106  </table>';
  • trunk/pages/tophraci.php

    r630 r681  
    2222
    2323$Realm = new Realm($System, $_COOKIE['RealmIndex']);
    24 $db = $Realm->Database;
    25 $db->select_db($Config['Mangos']['RealmList'][$Realm->Id]['DatabaseCharacters']);
     24$db = $Realm->CharactersDatabase;
    2625
    2726$sql = 'SELECT name, totaltime, online FROM characters ORDER BY totaltime DESC LIMIT '.$top;
Note: See TracChangeset for help on using the changeset viewer.