private static function GetQuestRelation($ItemID)
 {
     $Statement = Items::$WConnection->prepare('
         SELECT
             *
         FROM
             quest_template
         WHERE
                 RewardItem1 = :itemid
             OR
                 RewardItem2 = :itemid
             OR
                 RewardItem3 = :itemid
             OR
                 RewardItem4 = :itemid
     ');
     $Statement->bindParam(':itemid', $ItemID);
     $Statement->execute();
     $Result = $Statement->fetch(PDO::FETCH_ASSOC);
     if (!empty($Result)) {
         if ($Result['RewardItem1'] != 0) {
             $Result['RewardItemIcon1'] = Items::GetItemIcon($Result['RewardItem1']);
         }
         if ($Result['RewardItem2'] != 0) {
             $Result['RewardItemIcon2'] = Items::GetItemIcon($Result['RewardItem2']);
         }
         if ($Result['RewardItem3'] != 0) {
             $Result['RewardItemIcon3'] = Items::GetItemIcon($Result['RewardItem3']);
         }
         if ($Result['RewardItem4'] != 0) {
             $Result['RewardItemIcon4'] = Items::GetItemIcon($Result['RewardItem4']);
         }
         return $Result;
     } else {
         return false;
     }
 }
Exemple #2
0
 /**
  * Returns extended cost info for $costId cost.
  * @category Mangos class
  * @access   public
  * @param    int $costId
  * @return   array
  **/
 public function GetExtendedCost($costId)
 {
     if ($costId == 0) {
         return false;
     }
     if ($costId < 0) {
         $costId = abs($costId);
     }
     $costInfo = Armory::$aDB->selectRow("SELECT * FROM `ARMORYDBPREFIX_extended_cost` WHERE `id`=%d LIMIT 1", $costId);
     if (!$costInfo) {
         Armory::Log()->writeError('%s : wrong cost id: #%d', __METHOD__, $costId);
         return false;
     }
     $extended_cost = array();
     for ($i = 1; $i < 6; $i++) {
         if ($costInfo['item' . $i] > 0) {
             $extended_cost[$i]['count'] = $costInfo['item' . $i . 'count'];
             $extended_cost[$i]['icon'] = Items::GetItemIcon($costInfo['item' . $i]);
             $extended_cost[$i]['id'] = $costInfo['item' . $i];
         }
     }
     return $extended_cost;
 }
Exemple #3
0
 /**
  * Generates array with guild bank contents.
  * @category Guilds class
  * @example Guilds::showGuildBankContents()
  * @todo Manage rights to access some GB tabs
  * @return array
  **/
 public function showGuildBankContents()
 {
     if (!$this->guildId) {
         $this->Log()->writeError('%s : guildId not defined', __METHOD__);
         return false;
     }
     $GuildBankContents = null;
     $GB = null;
     $j = 0;
     for ($bank = 0; $bank < 7; $bank++) {
         $x = 0;
         for ($i = 0; $i < 14; $i++) {
             if ($x > 97) {
                 return $GuildBankContents;
             }
             for ($j = 0; $j < 7; $j++) {
                 $GuildBankContents[$bank][$i]['slot_' . $j]['item_entry'] = $this->cDB->selectCell("SELECT `item_entry` FROM `guild_bank_item` WHERE `SlotId`=? AND `TabId`=?", $x, $bank);
                 $GuildBankContents[$bank][$i]['slot_' . $j]['item_icon'] = Items::GetItemIcon($GuildBankContents[$bank][$i]['slot_' . $j]['item_entry']);
                 $GuildBankContents[$bank][$i]['slot_' . $j]['item_count'] = Items::GetItemDataField(14, 0, 0, $this->cDB->selectCell("SELECT `item_guid` FROM `guild_bank_item` WHERE `SlotId`=? AND `TabId`=?", $x, $bank));
                 $x++;
             }
         }
     }
     return $GuildBankContents;
 }
Exemple #4
0
 /**
  * @return array
  **/
 public function GetSocketInfo($num)
 {
     if ($num <= 0 || $num > 4) {
         return 0;
     }
     if (isset($this->m_socketInfo[$num])) {
         return $this->m_socketInfo[$num];
     }
     $data = array();
     switch ($this->m_server) {
         case SERVER_MANGOS:
             $socketfield = array(1 => ITEM_FIELD_ENCHANTMENT_3_2, 2 => ITEM_FIELD_ENCHANTMENT_4_2, 3 => ITEM_FIELD_ENCHANTMENT_5_2);
             $socketInfo = $this->GetUInt32Value($socketfield[$num] - 1);
             break;
         case SERVER_TRINITY:
             $socketfield = array(1 => 6, 2 => 9, 3 => 12);
             $socketInfo = $this->tc_ench[$socketfield[$num]];
             break;
         default:
             Armory::Log()->writeError('%s : unknown server type (%d)', __METHOD__, $this->m_server);
             return false;
             break;
     }
     if ($socketInfo > 0) {
         $gemData = Armory::$aDB->selectRow("SELECT `text_%s` AS `text`, `gem` FROM `ARMORYDBPREFIX_enchantment` WHERE `id`=%d", Armory::GetLocale(), $socketInfo);
         $data['enchant_id'] = $socketInfo;
         $data['item'] = $gemData['gem'];
         $data['icon'] = Items::GetItemIcon($data['item']);
         $data['enchant'] = $gemData['text'];
         $data['color'] = Armory::$aDB->selectCell("SELECT `color` FROM `ARMORYDBPREFIX_gemproperties` WHERE `spellitemenchantement`=%d", $socketInfo);
         $this->m_socketInfo[$num] = $data;
         // Is it neccessary?
         return $data;
     }
     return false;
 }
 /**
  * Returns array with data for item placed in $slot['slot']
  * @category Character class
  * @access   public
  * @param    array $slot
  * @return   array
  **/
 public function GetCharacterItemInfo($slot)
 {
     if (!$this->guid) {
         Armory::Log()->writeError('%s : player guid not provided', __METHOD__);
         return false;
     }
     if (!isset($this->m_items[$slot['slotid']])) {
         Armory::Log()->writeError('%s : slot %d is empty (nothing equipped?)', __METHOD__, $slot['slotid']);
         return false;
     }
     $item = $this->m_items[$slot['slotid']];
     $gems = array('g0' => $item->GetSocketInfo(1), 'g1' => $item->GetSocketInfo(2), 'g2' => $item->GetSocketInfo(3));
     $durability = $item->GetItemDurability();
     $item_data = Armory::$wDB->selectRow("SELECT `name`, `displayid`, `ItemLevel`, `Quality` FROM `item_template` WHERE `entry`=%d", $item->GetEntry());
     $enchantment = $item->GetEnchantmentId();
     $originalSpell = 0;
     $enchItemData = array();
     $enchItemDisplayId = 0;
     if ($enchantment > 0) {
         $originalSpell = Armory::$aDB->selectCell("SELECT `id` FROM `ARMORYDBPREFIX_spellenchantment` WHERE `Value`=%d", $enchantment);
         if ($originalSpell > 0) {
             $enchItemData = Armory::$wDB->selectRow("SELECT `entry`, `displayid` FROM `item_template` WHERE `spellid_1`=%d LIMIT 1", $originalSpell);
             if ($enchItemData) {
                 // Item
                 $enchItemDisplayId = Armory::$aDB->selectCell("SELECT `icon` FROM `ARMORYDBPREFIX_icons` WHERE `displayid`=%d", $enchItemData['displayid']);
             } else {
                 // Spell
                 $spellEnchData = Items::GenerateEnchantmentSpellData($originalSpell);
             }
         }
     }
     $item_info = array('displayInfoId' => $item_data['displayid'], 'durability' => $durability['current'], 'icon' => Items::GetItemIcon($item->GetEntry(), $item_data['displayid']), 'id' => $item->GetEntry(), 'level' => $item_data['ItemLevel'], 'maxDurability' => $durability['max'], 'name' => Armory::GetLocale() == 'en_gb' || Armory::GetLocale() == 'en_us' ? $item_data['name'] : Items::GetItemName($item->GetEntry()), 'permanentenchant' => $enchantment, 'pickUp' => 'PickUpLargeChain', 'putDown' => 'PutDownLArgeChain', 'randomPropertiesId' => 0, 'rarity' => $item_data['Quality'], 'seed' => $item->GetGUID(), 'slot' => $slot['slotid']);
     if (is_array($gems)) {
         for ($i = 0; $i < 3; $i++) {
             if ($gems['g' . $i]['item'] > 0) {
                 $item_info['gem' . $i . 'Id'] = $gems['g' . $i]['item'];
                 $item_info['gemIcon' . $i] = $gems['g' . $i]['icon'];
             }
         }
     }
     if (is_array($enchItemData) && isset($enchItemData['entry'])) {
         $item_info['permanentEnchantIcon'] = $enchItemDisplayId;
         $item_info['permanentEnchantItemId'] = $enchItemData['entry'];
     } elseif (isset($spellEnchData) && is_array($spellEnchData) && isset($spellEnchData['name'])) {
         $item_info['permanentEnchantIcon'] = 'trade_engraving';
         $item_info['permanentEnchantSpellName'] = $spellEnchData['name'];
         $item_info['permanentEnchantSpellDesc'] = $spellEnchData['desc'];
     }
     return $item_info;
 }
Exemple #6
0
 public function PerformAdvancedItemsSearch($count = false)
 {
     if ($this->itemSearchSkip == true) {
         return false;
     }
     if ((!$this->get_array || !is_array($this->get_array)) && !$this->searchQuery) {
         Armory::Log()->writeError('%s : start failed', __METHOD__);
         return false;
     }
     if (!isset($this->get_array['source'])) {
         Armory::Log()->writeError('%s : get_array[source] not defined', __METHOD__);
         return false;
     }
     $allowedDungeon = false;
     // Get item IDs first (if $this->searchQuery is defined)
     $item_id_string = null;
     if ($this->searchQuery) {
         if (Armory::GetLoc() == 0) {
             // No SQL injection - already escaped in search.php
             $_item_ids = Armory::$wDB->select("SELECT `entry` FROM `item_template` WHERE `name` LIKE '%s'", '%' . $this->searchQuery . '%');
         } else {
             $_item_ids = Armory::$wDB->select("SELECT `entry` FROM `item_template` WHERE `name` LIKE '%s' OR `entry` IN (SELECT `entry` FROM `locales_item` WHERE `name_loc%d` LIKE '%s')", '%' . $this->searchQuery . '%', Armory::GetLoc(), '%' . $this->searchQuery . '%');
         }
         if (is_array($_item_ids)) {
             $tmp_count_ids = count($_item_ids);
             for ($i = 0; $i < $tmp_count_ids; $i++) {
                 if ($i) {
                     $item_id_string .= ', ' . $_item_ids[$i]['entry'];
                 } else {
                     $item_id_string .= $_item_ids[$i]['entry'];
                 }
             }
             unset($tmp_count_ids, $_item_ids);
         }
     }
     switch ($this->get_array['source']) {
         case 'all':
             $global_sql_query = $this->HandleItemFilters($item_id_string);
             break;
         case 'quest':
             $tmp_quest_query = "SELECT `item` FROM `ARMORYDBPREFIX_source` WHERE `source`='sourceType.questReward'";
             if ($item_id_string != '') {
                 $tmp_quest_query .= sprintf(" AND `item` IN (%s)", $item_id_string);
             }
             $tmp_quest_query .= " ORDER BY `item` DESC LIMIT 200";
             $_quest_items = Armory::$aDB->select($tmp_quest_query);
             if (!$_quest_items) {
                 return false;
             }
             $quest_id_string = '';
             $qCount = count($_quest_items);
             for ($i = 0; $i < $qCount; $i++) {
                 if ($i) {
                     $quest_id_string .= ', ' . $_quest_items[$i]['item'];
                 } else {
                     $quest_id_string .= $_quest_items[$i]['item'];
                 }
             }
             unset($_quest_items, $qCount);
             $global_sql_query = $this->HandleItemFilters($quest_id_string);
             break;
         case 'dungeon':
             if (!isset($this->get_array['dungeon'])) {
                 $this->get_array['dungeon'] = 'all';
             }
             if (!isset($this->get_array['difficulty'])) {
                 $this->get_array['difficulty'] = 'all';
             }
             if (!isset($this->get_array['boss'])) {
                 $this->get_array['boss'] = 'all';
             }
             if (self::IsExtendedCost()) {
                 Armory::Log()->writeLog('%s : current ExtendedCost key: %s', __METHOD__, $this->get_array['dungeon']);
                 $item_extended_cost = Armory::$aDB->selectCell("SELECT `item` FROM `ARMORYDBPREFIX_item_sources` WHERE `key`='%s' LIMIT 1", $this->get_array['dungeon']);
                 if (!$item_extended_cost) {
                     Armory::Log()->writeError('%s : this->get_array[dungeon] is ExtendedCost key (%s) but data for this key is missed in `armory_item_sources`', __METHOD__, $this->get_array['dungeon']);
                     return false;
                 }
                 $extended_cost = Armory::$aDB->select("SELECT `id` FROM `ARMORYDBPREFIX_extended_cost` WHERE `item1`=%d OR `item2`=%d OR `item3`=%d OR `item4`=%d OR `item5`=%d", $item_extended_cost, $item_extended_cost, $item_extended_cost, $item_extended_cost, $item_extended_cost);
                 if (!$extended_cost) {
                     Armory::Log()->writeError('%s : this->get_array[dungeon] is ExtendedCost (key: %s, id: %d) but data for this id is missed in `armory_extended_cost`', __METHOD__, $this->get_array['dungeon'], $item_extended_cost);
                     return false;
                 }
                 $cost_ids = array();
                 foreach ($extended_cost as $cost) {
                     $cost_ids[] = $cost['id'];
                 }
                 $ex_cost_ids = null;
                 $mytmpcount = count($cost_ids);
                 for ($i = 0; $i < $mytmpcount; $i++) {
                     if ($i) {
                         $ex_cost_ids .= ', ' . $cost_ids[$i] . ', -' . $cost_ids[$i];
                     } else {
                         $ex_cost_ids .= $cost_ids[$i] . ', -' . $cost_ids[$i];
                     }
                 }
                 $global_sql_query = $this->HandleItemFilters($item_id_string, $ex_cost_ids);
             } else {
                 $allowedDungeon = true;
                 $instance_data = Utils::GetDungeonData($this->get_array['dungeon']);
                 if (!is_array($instance_data) || !isset($instance_data['difficulty'])) {
                     return false;
                 }
                 switch ($this->get_array['difficulty']) {
                     case 'normal':
                         switch ($instance_data['difficulty']) {
                             case 2:
                                 // 25 Man (icc/toc)
                                 $sql_query = "SELECT `lootid_2`, `type` FROM `ARMORYDBPREFIX_instance_data`";
                                 break;
                             default:
                                 // 10 Man (icc/toc) / all others
                                 $sql_query = "SELECT `lootid_1`, `type` FROM `ARMORYDBPREFIX_instance_data`";
                                 break;
                         }
                         $difficulty = 'n';
                         break;
                     case 'heroic':
                         switch ($instance_data['difficulty']) {
                             // instance diffuclty, not related to get_array['difficulty']
                             case 1:
                                 // 10 Man (icc/toc)
                                 $sql_query = "SELECT `lootid_3`, `type` FROM `ARMORYDBPREFIX_instance_data`";
                                 break;
                             case 2:
                                 // 25 Man (icc/toc)
                                 $sql_query = "SELECT `lootid_4`, `type` FROM `ARMORYDBPREFIX_instance_data`";
                                 break;
                             default:
                                 // All others
                                 $sql_query = "SELECT `lootid_2`, `type` FROM `ARMORYDBPREFIX_instance_data`";
                                 break;
                         }
                         $difficulty = 'h';
                         break;
                         // All
                     // All
                     default:
                         $difficulty = null;
                         switch ($instance_data['difficulty']) {
                             case 1:
                                 // 10 Man
                                 if ($instance_data['is_heroic'] == 1) {
                                     $sql_query = "SELECT `lootid_1`, `lootid_3`, `type` FROM `ARMORYDBPREFIX_instance_data`";
                                 } else {
                                     $sql_query = "SELECT `lootid_1`, `type` FROM `ARMORYDBPREFIX_instance_data`";
                                 }
                                 break;
                             case 2:
                                 // 25 Man
                                 if ($instance_data['is_heroic'] == 1) {
                                     $sql_query = "SELECT `lootid_2`, `lootid_4`, `type` FROM `ARMORYDBPREFIX_instance_data`";
                                 } else {
                                     $sql_query = "SELECT `lootid_2`, `type` FROM `ARMORYDBPREFIX_instance_data`";
                                 }
                                 break;
                             default:
                                 if ($instance_data['is_heroic'] == 1) {
                                     $sql_query = "SELECT `lootid_1`, `lootid_2`, `lootid_3`, `lootid_4`, `type` FROM `ARMORYDBPREFIX_instance_data`";
                                 } else {
                                     $sql_query = "SELECT `lootid_1`, `lootid_2`, `type` FROM `ARMORYDBPREFIX_instance_data`";
                                 }
                                 break;
                         }
                         break;
                 }
                 if (isset($this->get_array['dungeon']) && $this->get_array['dungeon'] != 'all' && !empty($this->get_array['dungeon'])) {
                     $instance_id = Utils::GetDungeonId($this->get_array['dungeon']);
                     $sql_query .= sprintf(" WHERE `instance_id`=%d", $instance_id);
                 }
                 if (isset($this->get_array['boss']) && $this->get_array['boss'] != 'all' && !empty($this->get_array['boss'])) {
                     if (is_numeric($this->get_array['boss'])) {
                         $sql_query .= sprintf(" AND (`id`=%d OR `lootid_1`=%d OR `lootid_2`=%d OR `lootid_3`=%d OR `lootid_4`=%d)", $this->get_array['boss'], $this->get_array['boss'], $this->get_array['boss'], $this->get_array['boss'], $this->get_array['boss']);
                     } else {
                         $sql_query .= sprintf(" AND `key`='%s'", $this->get_array['boss']);
                     }
                 }
                 $boss_lootids = Armory::$aDB->select($sql_query);
                 if (!$boss_lootids) {
                     Armory::Log()->writeLog('%s : unable to find loot IDs for boss %s (instance: %s)', __METHOD__, $this->get_array['boss'], $this->get_array['dungeon']);
                     return false;
                 }
                 $loot_table = '-1';
                 foreach ($boss_lootids as $loot_id) {
                     for ($i = 1; $i < 5; $i++) {
                         if (isset($loot_id['lootid_' . $i])) {
                             if ($i) {
                                 $loot_table .= ', ' . $loot_id['lootid_' . $i];
                             } else {
                                 $loot_table .= $loot_id['lootid_' . $i];
                             }
                         }
                     }
                 }
                 $global_sql_query = $this->HandleItemFilters($item_id_string, $loot_table);
             }
             break;
         case 'reputation':
             if (!isset($this->get_array['faction'])) {
                 $this->get_array['faction'] = 'all';
             }
             $global_sql_query = $this->HandleItemFilters($item_id_string, $this->get_array['faction']);
             break;
         case 'pvpAlliance':
         case 'pvpHorde':
             if (!isset($this->get_array['pvp'])) {
                 $this->get_array['pvp'] = 'all';
             }
             if ($this->get_array['pvp'] == 'all' || $this->get_array['pvp'] == -1) {
                 $pvpVendorsId = Armory::$aDB->select("SELECT `item` FROM `ARMORYDBPREFIX_item_sources` WHERE `key` IN ('wintergrasp', 'arena8', 'arena7', 'arena6', 'arena5', 'arena4', 'arena3', 'arena2', 'arena1', 'honor', 'ab', 'av', 'wsg', 'halaa', 'honorhold', 'terrokar', 'zangarmarsh', 'thrallmar')");
                 if (!$pvpVendorsId) {
                     Armory::Log()->writeError('%s : unable to get data for pvpVendors from armory_item_sources', __METHOD__);
                     return false;
                 }
             } else {
                 $pvpVendorsId = Armory::$aDB->select("SELECT `item` FROM `ARMORYDBPREFIX_item_sources` WHERE `key`='%s'", $this->get_array['pvp']);
                 if (!$pvpVendorsId) {
                     Armory::Log()->writeError('%s : unable to get data for pvpVendors from armory_item_sources (faction: %s, key: %s)', __METHOD__, $this->get_array['source'], $this->get_array['pvp']);
                     return false;
                 }
             }
             $countVendors = count($pvpVendorsId);
             $string_vendors = null;
             for ($i = 0; $i < $countVendors; $i++) {
                 $tmpVendID = explode('/', $pvpVendorsId[$i]['item']);
                 if (is_array($tmpVendID) && isset($tmpVendID[0]) && isset($tmpVendID[1])) {
                     if ($this->get_array['source'] == 'pvpAlliance') {
                         $vendors_id = $tmpVendID[0];
                     } else {
                         $vendors_id = $tmpVendID[1];
                     }
                 } else {
                     $vendors_id = $pvpVendorsId[$i]['item'];
                 }
                 if ($i) {
                     $string_vendors .= ', ' . $vendors_id;
                 } else {
                     $string_vendors .= $vendors_id;
                 }
             }
             $global_sql_query = $this->HandleItemFilters($item_id_string, $string_vendors);
             break;
     }
     if (!isset($global_sql_query) || !$global_sql_query) {
         Armory::Log()->writeError('%s : SQL query was not created (probably "%s" is unknown source).', __METHOD__, $this->get_array['source']);
         return false;
     }
     $items_query = Armory::$wDB->select($global_sql_query);
     if (!$items_query) {
         Armory::Log()->writeError('%s : unable to execute SQL query "%s"', __METHOD__, $global_sql_query);
         unset($global_sql_query);
         return false;
     }
     $items_result = array();
     $exists_items = array();
     $source_items = self::GetItemSourceArray($items_query);
     $i = 0;
     $icons_to_add = array();
     $names_to_add = array();
     $icons_holder = array();
     $names_holder = array();
     foreach ($items_query as $tmp_item) {
         $icons_to_add[] = $tmp_item['displayid'];
         $names_to_add[] = $tmp_item['id'];
     }
     $tmp_icons_holder = Armory::$aDB->select("SELECT `displayid`, `icon` FROM `ARMORYDBPREFIX_icons` WHERE `displayid` IN (%s)", $icons_to_add);
     foreach ($tmp_icons_holder as $icon) {
         $icons_holder[$icon['displayid']] = $icon['icon'];
     }
     if (Armory::GetLoc() == 0) {
         $tmp_names_holder = Armory::$wDB->select("SELECT `entry`, `name` AS `name` FROM `item_template` WHERE `entry` IN (%s)", $names_to_add);
     } else {
         $tmp_names_holder = Armory::$wDB->select("SELECT `entry`, `name_loc%d` AS `name` FROM `locales_item` WHERE `entry` IN (%s)", Armory::GetLoc(), $names_to_add);
     }
     foreach ($tmp_names_holder as $name) {
         if ($name['name'] == null) {
             $name['name'] = Items::GetItemName($name['entry']);
         }
         $names_holder[$name['entry']] = $name['name'];
     }
     unset($tmp_icons_holder, $tmp_names_holder, $names_to_add, $icons_to_add);
     foreach ($items_query as $item) {
         if (isset($exists_items[$item['id']])) {
             continue;
             // Do not add the same items to result array
         }
         if ($i >= 200) {
             if ($count) {
                 return count($exists_items);
             } else {
                 return $items_result;
             }
         } elseif (!$count) {
             $tmp_src = isset($source_items[$item['id']]) ? $source_items[$item['id']] : null;
             $items_result[$i]['data'] = array();
             $items_result[$i]['filters'] = array();
             $items_result[$i]['data']['id'] = $item['id'];
             if (!isset($names_holder[$item['id']])) {
                 $items_result[$i]['data']['name'] = Items::GetItemName($item['id']);
             } else {
                 $items_result[$i]['data']['name'] = $names_holder[$item['id']];
             }
             if (self::CanAuction($item)) {
                 $items_result[$i]['data']['canAuction'] = 1;
             }
             $items_result[$i]['data']['rarity'] = $item['rarity'];
             if (!isset($icons_holder[$item['displayid']])) {
                 $items_result[$i]['data']['icon'] = Items::GetItemIcon($item['id'], $item['displayid']);
             } else {
                 $items_result[$i]['data']['icon'] = $icons_holder[$item['displayid']];
             }
             $items_result[$i]['filters'][0] = array('name' => 'itemLevel', 'value' => $item['ItemLevel']);
             $items_result[$i]['filters'][1] = array('name' => 'relevance', 'value' => 100);
             // TODO: add relevance calculation for items
             // Add some filters (according with item source)
             if ($tmp_src != null) {
                 if ($tmp_src['source'] == 'sourceType.dungeon' && $tmp_src['areaKey'] != null && $tmp_src['areaUrl'] != null) {
                     $items_result[$i]['filters'][] = array('areaId' => $tmp_src['areaId'], 'areaKey' => $tmp_src['areaKey'], 'areaName' => $tmp_src['areaName'], 'name' => 'source', 'value' => 'sourceType.creatureDrop');
                 } else {
                     $items_result[$i]['filters'][] = array('name' => 'source', 'value' => $tmp_src['source']);
                 }
             } else {
                 switch ($this->get_array['source']) {
                     case 'reputation':
                         $items_result[$i]['filters'][] = array('name' => 'source', 'value' => 'sourceType.factionReward');
                         break;
                     case 'quest':
                         $items_result[$i]['filters'][] = array('name' => 'source', 'value' => 'sourceType.questReward');
                         break;
                     case 'pvpAlliance':
                     case 'pvpHorde':
                         $items_result[$i]['filters'][2] = array('name' => 'source', 'value' => 'sourceType.vendor');
                         break;
                 }
             }
         }
         $exists_items[$item['id']] = $item['id'];
         $i++;
     }
     if ($count == true) {
         return count($exists_items);
     }
     return $items_result;
 }
Exemple #7
0
 /**
  * Returns guild bank items
  * @category Guilds class
  * @category Guilds class
  * @access   public
  * @return   array
  **/
 public function BuildGuildBankItemList()
 {
     if (!$this->guildId) {
         Armory::Log()->writeError('%s : guildId not defined', __METHOD__);
         return false;
     }
     $items_list = Armory::$cDB->select("SELECT `item_entry` AS `id`, `item_guid` AS `seed`, `SlotId` AS `slot`, `TabId` AS `bag` FROM `guild_bank_item` WHERE `guildid`=%d", $this->guildId);
     $count_items = count($items_list);
     for ($i = 0; $i < $count_items; $i++) {
         $item_data = Armory::$wDB->selectRow("SELECT `RandomProperty`, `RandomSuffix` FROM `item_template` WHERE `entry` = %d LIMIT 1", $items_list[$i]['id']);
         $tmp_durability = Items::GetItemDurabilityByItemGuid($items_list[$i]['seed'], $this->m_server);
         $items_list[$i]['durability'] = (int) $tmp_durability['current'];
         $items_list[$i]['maxDurability'] = (int) $tmp_durability['max'];
         $items_list[$i]['icon'] = Items::GetItemIcon($items_list[$i]['id']);
         $items_list[$i]['name'] = Items::GetItemName($items_list[$i]['id']);
         $items_list[$i]['qi'] = Items::GetItemInfo($items_list[$i]['id'], 'quality');
         if ($this->m_server == SERVER_MANGOS) {
             $items_list[$i]['quantity'] = Items::GetItemDataField(ITEM_FIELD_STACK_COUNT, 0, 0, $items_list[$i]['seed']);
         } elseif ($this->m_server == SERVER_TRINITY) {
             $items_list[$i]['quantity'] = Armory::$cDB->selectCell("SELECT `count` FROM `item_instance` WHERE `guid`=%d", $items_list[$i]['seed']);
         }
         //TODO: Find correct random property/suffix for items in guild vault.
         $items_list[$i]['randomPropertiesId'] = Items::GetRandomPropertiesData($items_list[$i]['id'], 0, $items_list[$i]['seed'], true, $this->m_server, null, $item_data);
         $tmp_classinfo = Items::GetItemSubTypeInfo($items_list[$i]['id']);
         $items_list[$i]['subtype'] = null;
         $items_list[$i]['subtypeLoc'] = $tmp_classinfo['subclass_name'];
         $items_list[$i]['type'] = $tmp_classinfo['key'];
         $items_list[$i]['slot']++;
     }
     return $items_list;
 }
Exemple #8
0
 /**
  * Returns guild bank logs
  * @category Guilds class
  * @category Guilds class
  * @access   public
  * @return   array
  **/
 public function BuildGuildBankLogList()
 {
     if (!$this->guildId) {
         Armory::Log()->writeError('%s : guildId not defined', __METHOD__);
         return false;
     }
     $log_list = Armory::$cDB->select("SELECT `LogGuid` AS `logId`, `TabId` AS `obag`, `EventType` AS `type`,\n\t\t`DestTabId` AS `dbag`, (SELECT `name` FROM `characters` WHERE `guid`=`PlayerGuid`) AS `player`,\t\n\t\t(SELECT `guild_rank`.`rname` FROM `guild_rank` WHERE `guildid`=%d AND `rid`=`guild_member`.`rank`) AS `rname`,\n\t\t`guild_member`.`rank`, `ItemOrMoney` AS `entry`, `ItemStackCount` AS `quantity`, `TimeStamp` AS `ts`\n\t\tFROM `guild_bank_eventlog` AS `guild_bank_eventlog`\n\t\tLEFT JOIN `guild_member` AS `guild_member` ON `guild_member`.`guid`=`guild_bank_eventlog`.`PlayerGuid` AND `guild_member`.`guildid`=%d\n\t\tWHERE `guild_bank_eventlog`.`guildid`=%d ORDER BY `ts` DESC LIMIT 500;", $this->guildId, $this->guildId, $this->guildId);
     $count_logs = count($log_list);
     for ($i = 0; $i < $count_logs; $i++) {
         $log_list[$i]['ts'] = date('Y-m-d H:i:s', $log_list[$i]['ts']);
         switch ($log_list[$i]['type']) {
             case 1:
                 //deposit
                 $log_list[$i]['item'] = 1;
                 $log_list[$i]['dbag'] = $log_list[$i]['obag'];
                 $log_list[$i]['obag'] = '';
                 break;
             case 2:
                 //withdraw
                 $log_list[$i]['item'] = 1;
                 $log_list[$i]['dbag'] = '';
                 break;
             case 3:
                 //move
             //move
             case 7:
                 //move
                 $log_list[$i]['item'] = 1;
                 break;
             case 4:
             case 5:
             case 6:
                 //repair
             //repair
             case 8:
             case 9:
                 //buytab
             //buytab
             default:
                 $log_list[$i]['item'] = 0;
                 $log_list[$i]['dbag'] = '';
                 $log_list[$i]['obag'] = '';
                 $log_list[$i]['money'] = $log_list[$i]['entry'];
                 break;
         }
         if ($log_list[$i]['item']) {
             $log_list[$i]['icon'] = Items::GetItemIcon($log_list[$i]['entry']);
             $log_list[$i]['name'] = Items::GetItemName($log_list[$i]['entry']);
             $log_list[$i]['qi'] = Items::GetItemInfo($log_list[$i]['entry'], 'quality');
         }
     }
     return $log_list;
 }
Exemple #9
0
 /**
  * Search items with $query name. If $num == true, function will return only number of 
  * @category Utils/Armory class
  * @example Utils::SearchItems('ashes of al'ar')
  * @return array, int
  **/
 public function SearchItems($query, $num = false)
 {
     if ($num == true) {
         $Q = $this->wDB->selectPage($itemsNum, "SELECT `entry` FROM `item_template` WHERE `name` LIKE ? LIMIT 200", '%' . $query . '%');
         $QQ = $this->wDB->selectPage($itemsNumRuRU, "SELECT `entry` FROM `locales_item` WHERE `name_loc8` LIKE ? LIMIT 200", '%' . $query . '%');
         $rNum = $itemsNum + $itemsNumRuRU;
         if ($rNum > 200) {
             $rNum = 200;
         }
         return $rNum;
     }
     $searchResults = $this->wDB->select("\n        SELECT `entry`, `Quality`, `ItemLevel`\n            FROM `item_template`\n                WHERE `name` LIKE ? OR `entry` IN \n                (\n                    SELECT `entry`\n                    FROM `locales_item`\n                    WHERE `name_loc8` LIKE ?\n                )\n                LIMIT 200", '%' . $query . '%', '%' . $query . '%');
     if (!$searchResults) {
         return false;
     }
     $countItems = count($searchResults);
     for ($i = 0; $i < $countItems; $i++) {
         $searchResults[$i]['name'] = Items::GetItemName($searchResults[$i]['entry']);
         $searchResults[$i]['icon'] = Items::GetItemIcon($searchResults[$i]['entry']);
     }
     return $searchResults;
 }