Changeset 682 for trunk/inc/player.php


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.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.