Changeset 682 for trunk/inc


Ignore:
Timestamp:
Jan 23, 2010, 4:03:37 PM (15 years ago)
Author:
george
Message:
  • Opraveno: Na dalších stránkách přepracován systém pro načítání údajů z databáze namísto konfiguračního souboru.
  • Přidáno: Skript pro periodickou kontrolu online stavu přihlašovacích serverů a světů. Online stav se načítá nově přímo z databáze a sníží se tak zátěž sítových portů služeb.
Location:
trunk/inc
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/inc/config.sample.php

    r634 r682  
    3434      'ArenaPoints' => 1649,
    3535    ),
    36     'RealmList' => array(
    37       1 => array(
    38         'Id' => 7,
    39         'Name' => 'Realm 1'
    40         'DatabaseHost' => 'localhost',
    41         'DatabaseUser' => 'server1',
    42         'DatabasePassword' => 'server1',
    43         'DatabaseCharacters' => 'realm1_characters',
    44         'DatabaseMangos' => 'realm1_mangos',
    45         'DatabaseScriptDev2' => 'realm1_scriptdev2',
    46         'Server' => 1,
    47         'MaxOnlinePlayers' => 100,
    48         'XPRate' => 1,
    49         'Type' => 'Normalní',
    50         'Description' => 'Hlavní realm',
    51       ),
    52     ),
    5336  ),
    5437  'Web' => array
     
    7053    'BankAccount' => '670100-2202937132/6210',
    7154    'TableRowPerPage' => 20,
    72     'ServerList' => array(
    73       1 => array(
    74         'OS' => 'GNU/Linux',
    75         'CPU' => 'AMD Athlon 64 X2 5600+, 2,8 GHz',
    76         'Memory' => '8 GB DDR2 800 MHz dual channel',
    77         'HDD' => 'WD Green 1 TB, 32 MB cache',
    78         'Address' => 'localhost',
    79         'Internet' => '16/16 Mbit/s, agregace 1:32',
    80         'Statistic' => 'http://localhost/stat/',
    81       },
    82     },
     55    'DefaultRealmIndex' => 1,
    8356  ),
    8457  'CheckRegistration' => array
     
    9366);
    9467
    95 // Zpětná kompatibilita
     68// Zastaralé, pro zpětnou kompatibilitu
    9669$db_server = $Config['Database']['Host'];
    9770$db_user = $Config['Database']['User'];
  • trunk/inc/html.php

    r637 r682  
    263263  {
    264264    global $server, $Config, $System;
     265   
     266    // Check servers online state.
     267    $DbResult = $System->Database->query('SELECT COUNT(*) FROM Logon WHERE Online = 1');
     268    $DbRow = $DbResult->fetch_row();
     269    $OnlineState = $DbRow[0] > 0; // Report online state if one of all servers is online.
    265270
    266271    if(isset($_COOKIE['hof-quick']) AND $_COOKIE['hof-quick'] == 'no')
     
    275280        '<tr>'.
    276281        '<td colspan="2">'.
    277         '<strong>Server : </strong>'.$server->OnlineStateImage($System->NetworkPortState($Config['Web']['WoWServerAddr'], 3724)).'<b> (<a href="?page=realmlist">'.$server->OnlineCharactersCount().' hráčů celkem</a>) | Patch '.$Config['Mangos']['ClientVersion'].' | <a href="'.$Config['Web']['BaseURL'].'/pages/realmlist.wtf">Realmlist</a> | <a href="?page=server">Server info</a> | <a href="?page=realmlist">Seznam světů</a></b>'.
     282        '<strong>Server : </strong>'.$server->OnlineStateImage($OnlineState).'<b> (<a href="?page=realmlist">'.$server->OnlineCharactersCount().' hráčů celkem</a>) | Patch '.$Config['Mangos']['ClientVersion'].' | <a href="'.$Config['Web']['BaseURL'].'/pages/realmlist.wtf">Realmlist</a> | <a href="?page=server">Server info</a> | <a href="?page=realmlist">Seznam světů</a></b>'.
    278283        '</td></tr></table><br />');
    279284    }
  • trunk/inc/player.php

    r609 r682  
    102102    global $Config;
    103103
    104     $this->db->select_db($Config['Mangos']['RealmList'][$_COOKIE['RealmIndex']]['DatabaseCharacters']);
    105     $DbResult = $this->db->query('SELECT CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(`data`, " ", '.($Config['Mangos']['CharacterDataOffset']['Level'] + 1).'), " ", -1) AS UNSIGNED) AS `level` FROM `characters` WHERE `guid` = "'.$guid.'" LIMIT 1;');
     104    $Realm = new Realm($System, $_COOKIE['RealmIndex']);
     105    $DbResult = $Realm->CharactersDatabase->query('SELECT CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(`data`, " ", '.($Config['Mangos']['CharacterDataOffset']['Level'] + 1).'), " ", -1) AS UNSIGNED) AS `level` FROM `characters` WHERE `guid` = "'.$guid.'" LIMIT 1;');
    106106    $row = $DbResult->fetch_assoc();
    107107    return($row['level']);
     
    135135  public function ResetXP($guid)
    136136  {
    137     global $Config;
     137    global $System, $Config;
    138138
    139139    if($this->CharInAcc($guid, 0))
     
    141141      if(!$this->IsOnline($guid))
    142142      {
    143         $this->db->select_db($Config['Mangos']['RealmList'][$_COOKIE['RealmIndex']]['DatabaseCharacters']);
    144         $row = $this->db->query('SELECT `data` FROM `characters` WHERE `guid` = "'.$guid.'" LIMIT 1')->fetch_assoc();
     143        $Realm = new Realm($System, $_COOKIE['RealmIndex']);
     144        $row = $Realm->CharactersDatabase->query('SELECT `data` FROM `characters` WHERE `guid` = "'.$guid.'" LIMIT 1')->fetch_assoc();
    145145        $data = explode(' ', $row['data']);
    146146        $data[$Config['Mangos']['CharacterDataOffset']['Exp']] = 0;
    147147        $data = implode(' ', $data);
    148         $this->db->query('UPDATE `characters` SET `data` = "'.$data.'" WHERE `guid` ="'.$guid.'" LIMIT 1');
     148        $Realm->CharactersDatabase->query('UPDATE `characters` SET `data` = "'.$data.'" WHERE `guid` ="'.$guid.'" LIMIT 1');
    149149        $this->Msg('Postavě resetováno XP.', 0);
    150150      } else $this->Msg('Postava musí být offline.', 1);
     
    154154  public function ResetPosition($guid)
    155155  {
    156     global $Config;
    157 
    158     $this->db->select_db($Config['Mangos']['RealmList'][$_COOKIE['RealmIndex']]['DatabaseCharacters']);
     156    global $System, $Config;
     157
     158    $Realm = new Realm($System, $_COOKIE['RealmIndex']);
    159159    if($this->CharInAcc($guid, 0))
    160160    {
    161161      if(!$this->IsOnline($guid))
    162162      {
    163         $row = $this->db->query('SELECT * FROM `character_homebind` WHERE `guid` = "'.$guid.'" LIMIT 1;')->fetch_array();
     163        $row = $Realm->CharactersDatabase->query('SELECT * FROM `character_homebind` WHERE `guid` = "'.$guid.'" LIMIT 1;')->fetch_array();
    164164        $home_char_map = $row['map'];
    165165        $home_char_position_x = $row['position_x'];
     
    168168        if(isset($home_char_map) and isset($home_char_position_x) and isset($home_char_position_y) and isset($home_char_position_z))
    169169        {
    170           $this->db->query('UPDATE `characters` SET '.
     170          $Realm->CharactersDatabase->query('UPDATE `characters` SET '.
    171171            '`map` = "'.$home_char_map.'" , '.
    172172            '`position_x` ="'.$home_char_position_x.'" , '.
     
    182182  public function PlayerJail($guid)
    183183  {
    184     global $Config;
    185 
    186     $this->db->select_db($Config['Mangos']['RealmList'][$_COOKIE['RealmIndex']]['DatabaseCharacters']);
     184    global $System, $Config;
     185
     186    $Realm = new Realm($System, $_COOKIE['RealmIndex']);
    187187    // .go xyz -90.54 41.35 -31.71
    188188    // .go xyz -91.01 100.46 -31.71
     
    208208    if(!$this->IsOnline($guid))
    209209    {
    210       $this->db->query('UPDATE `characters` SET `map` = 35 ,'.
     210      $Realm->CharactersDatabase->query('UPDATE `characters` SET `map` = 35 ,'.
    211211        '`orientation` = "'.$defined_positions['o'.$rand_place].'" ,'.
    212212        '`position_x` ="'.$defined_positions['x'.$rand_place].'" ,'.
     
    214214        '`position_z` = "'.$defined_positions['z'.$rand_place].'"'.
    215215        ' WHERE `guid` ="'.$guid.'" LIMIT 1;');
    216       $this->db->query('INSERT INTO `character_aura` (`guid`, `caster_guid`, `spell`, `effect_index`, `amount`, `maxduration`, `remaintime`, `remaincharges`) VALUES '.
     216      $Realm->CharactersDatabase->query('INSERT INTO `character_aura` (`guid`, `caster_guid`, `spell`, `effect_index`, `amount`, `maxduration`, `remaintime`, `remaincharges`) VALUES '.
    217217        '('.$guid.', '.$guid.', 23775, 0, 1, -1, -1, -1), '.
    218218        '('.$guid.', '.$guid.', 36558, 0, 1, -1, -1, -1);');               
     
    223223  public function IsOnline($guid)
    224224  {
    225     global $Config;
    226 
    227     $this->db->select_db($Config['Mangos']['RealmList'][$_COOKIE['RealmIndex']]['DatabaseCharacters']);
    228     $row = $this->db->query('SELECT `online` FROM `characters` WHERE `guid` = "'.$guid.'" LIMIT 1;')->fetch_assoc();
     225    global $System, $Config;
     226
     227    $Realm = new Realm($System, $_COOKIE['RealmIndex']);
     228    $row = $Realm->CharactersDatabase->query('SELECT `online` FROM `characters` WHERE `guid` = "'.$guid.'" LIMIT 1;')->fetch_assoc();
    229229    if($row['online'] == 1) return(true);
    230230      else return(false);
     
    258258  public function CharNameToGuid($name)
    259259  {
    260     global $Config;
    261 
    262     $this->db->select_db($Config['Mangos']['RealmList'][$_COOKIE['RealmIndex']]['DatabaseCharacters']);
    263     $row = $this->db->query('SELECT `guid` FROM `characters` WHERE `name` LIKE "'.$name.'" LIMIT 1;')->fetch_assoc();
     260    global $System, $Config;
     261
     262    $Realm = new Realm($System, $_COOKIE['RealmIndex']);
     263    $row = $Realm->CharactersDatabase->query('SELECT `guid` FROM `characters` WHERE `name` LIKE "'.$name.'" LIMIT 1;')->fetch_assoc();
    264264    if($row['guid'] != '')
    265265    {
     
    275275    global $Config;
    276276
    277     $this->db->select_db($Config['Mangos']['RealmList'][$_COOKIE['RealmIndex']]['DatabaseCharacters']);
    278     $row = $this->db->query('SELECT `name` FROM `characters` WHERE `guid` = "'.$guid.'" LIMIT 1;')->fetch_assoc();
     277    $Realm = new Realm($System, $_COOKIE['RealmIndex']);
     278    $row = $Realm->CharactersDatabase->query('SELECT `name` FROM `characters` WHERE `guid` = "'.$guid.'" LIMIT 1;')->fetch_assoc();
    279279    if($row['name'] != '')
    280280    {
     
    305305  {
    306306    global $Config;
    307 
     307 
    308308    $this->db->select_db($Config['Mangos']['DatabaseRealmd']);
    309309    $sha_pass = sha1(strtoupper($acc1_name).':'.strtoupper($acc1_pass));
     
    344344  public function CharsOnAcc($accid)
    345345  {
    346     global $Config;
     346    global $Config, $System;
    347347   
    348348    echo('<table class="BaseTable">
     
    354354            <th>Nahráno</th>
    355355          </tr>');
    356     $this->db->select_db($Config['Mangos']['RealmList'][$_COOKIE['RealmIndex']]['DatabaseCharacters']);
    357     echo($this->db->error);
    358     $sql = $this->db->query('SELECT `guid`,`name`,`race`,`totaltime`,`class`, mid(lpad( hex( CAST(substring_index(substring_index(data, " ", '.($Config['Mangos']['CharacterDataOffset']['Gender'] + 1).'), " ",-1) AS unsigned) ), 8, 0), 4, 1) AS gender FROM `characters` WHERE `account`='.$accid.' ORDER BY `totaltime` DESC LIMIT 0, 10');
    359     echo($this->db->error);
     356    $Realm = new Realm($System, $_COOKIE['RealmIndex']);   
     357    $sql = $Realm->CharactersDatabase->query('SELECT `guid`,`name`,`race`,`totaltime`,`class`, mid(lpad( hex( CAST(substring_index(substring_index(data, " ", '.($Config['Mangos']['CharacterDataOffset']['Gender'] + 1).'), " ",-1) AS unsigned) ), 8, 0), 4, 1) AS gender FROM `characters` WHERE `account`='.$accid.' ORDER BY `totaltime` DESC LIMIT 0, 10');
    360358    while($row = $sql->fetch_array())
    361359    {
Note: See TracChangeset for help on using the changeset viewer.