Ejemplo n.º 1
0
 /**
  * Returns NPC info (infoType)
  * @category Mangos class
  * @access   public
  * @param    int $npc
  * @param    string $infoType
  * @return   mixed
  **/
 public function GetNpcInfo($npc, $infoType)
 {
     $info = null;
     switch ($infoType) {
         case 'maxlevel':
             $info = Armory::$wDB->selectCell("SELECT `maxlevel` FROM `creature_template` WHERE `entry`=%d", $npc);
             break;
         case 'minlevel':
             $info = Armory::$wDB->selectCell("SELECT `minlevel` FROM `creature_template` WHERE `entry`=%d", $npc);
             break;
         case 'map':
             $mapID = Armory::$wDB->selectCell("SELECT `map` FROM `creature` WHERE `id`=%d LIMIT 1", $npc);
             if (!$mapID) {
                 $killCredit = Armory::$wDB->selectRow("SELECT `KillCredit1`, `KillCredit2` FROM `creature_template` WHERE `entry`=%d", $npc);
                 if ($killCredit['KillCredit1'] > 0) {
                     $kc_entry = $killCredit['KillCredit1'];
                 } elseif ($killCredit['KillCredit2'] > 0) {
                     $kc_entry = $killCredit['KillCredit2'];
                 } else {
                     $kc_entry = false;
                 }
                 $mapID = Armory::$wDB->selectCell("SELECT `map` FROM `creature` WHERE `id`=%d LIMIT 1", $kc_entry);
                 if (!$mapID) {
                     return false;
                 }
             }
             if ($info = Armory::$aDB->selectCell("SELECT `name_%s` FROM `ARMORYDBPREFIX_instance_template` WHERE `map`=%d", Armory::GetLocale(), $mapID)) {
                 return $info;
             } else {
                 $info = Armory::$aDB->selectCell("SELECT `name_%s` FROM `ARMORYDBPREFIX_maps` WHERE `id`=%d", Armory::GetLocale(), $mapID);
             }
             break;
         case 'areaUrl':
             $mapID = Armory::$wDB->selectCell("SELECT `map` FROM `creature` WHERE `id`=%d LIMIT 1", $npc);
             if (!$mapID) {
                 $killCredit = Armory::$wDB->selectRow("SELECT `KillCredit1`, `KillCredit2` FROM `creature_template` WHERE `entry`=%d", $npc);
                 if ($killCredit['KillCredit1'] > 0) {
                     $kc_entry = $killCredit['KillCredit1'];
                 } elseif ($killCredit['KillCredit2'] > 0) {
                     $kc_entry = $killCredit['KillCredit2'];
                 } else {
                     $kc_entry = false;
                 }
                 $mapID = Armory::$wDB->selectCell("SELECT `map` FROM `creature` WHERE `id`=%d LIMIT 1", $kc_entry);
                 if (!$mapID) {
                     return false;
                 }
             }
             if ($info = Armory::$aDB->selectCell("SELECT `key` FROM `ARMORYDBPREFIX_instance_template` WHERE `map`=%d", $mapID)) {
                 $areaUrl = sprintf('source=dungeon&dungeon=%s&boss=all&difficulty=all', $info);
                 return $areaUrl;
             }
             break;
         case 'mapID':
             $info = Armory::$wDB->selectCell("SELECT `map` FROM `creature` WHERE `id`=%d LIMIT 1", $npc);
             break;
         case 'rank':
             return Armory::$wDB->selectCell("SELECT `rank` FROM `creature_template` WHERE `entry`=%d", $npc);
             break;
         case 'subname':
             if (Armory::GetLocale() == 'en_gb' || Armory::GetLocale() == 'en_us') {
                 return Armory::$wDB->selectCell("SELECT `subname` FROM `creature_template` WHERE `entry`=%d LIMIT 1", $npc);
             } else {
                 $info = Armory::$wDB->selectCell("SELECT `subname_loc%d` FROM `locales_creature` WHERE `entry`=%d LIMIT 1", Armory::GetLoc(), $npc);
                 if (!$info) {
                     $killCredit = Armory::$wDB->selectRow("SELECT `KillCredit1`, `KillCredit2` FROM `creature_template` WHERE `entry`=%d", $npc);
                     $kc_entry = false;
                     if ($killCredit['KillCredit1'] > 0) {
                         $kc_entry = $killCredit['KillCredit1'];
                     } elseif ($killCredit['KillCredit2'] > 0) {
                         $kc_entry = $killCredit['KillCredit2'];
                     }
                     if ($kc_entry) {
                         $info = Armory::$wDB->selectCell("SELECT `subname_loc%d` FROM `locales_creature` WHERE `entry`=%d LIMIT 1", Armory::GetLoc(), $kc_entry);
                     }
                     if (!$info) {
                         $info = Armory::$wDB->selectCell("SELECT `subname_loc%d` FROM `locales_creature` WHERE `entry`=%d LIMIT 1", Armory::GetLoc(), $npc);
                     }
                 }
             }
             break;
         case 'dungeonlevel':
             $query = Armory::$wDB->selectRow("\n\t\t\t\tSELECT `difficulty_entry_1`, `difficulty_entry_2`, `difficulty_entry_3`\n\t\t\t\t\tFROM `creature_template`\n\t\t\t\t\t\tWHERE `entry`=%d AND `difficulty_entry_1` > 0 or `difficulty_entry_2` > 0 or `difficulty_entry_3` > 0", $npc);
             if (!$query) {
                 // 10 Normal or 5 Normal
                 return 0;
             }
             if ($query['difficulty_entry_1'] > 0) {
                 // 25 Normal or 5 Heroic
                 return 1;
             } elseif ($query['difficulty_entry_2'] > 0) {
                 // 10 Heroic
                 return 2;
             } elseif ($query['difficulty_entry_3' > 0]) {
                 // 25 Heroic
                 return 3;
             } else {
                 // 10 Normal or 5 Normal
                 return 0;
             }
             break;
         case 'instance_type':
             $mapID = Armory::$wDB->selectCell("SELECT `map` FROM `creature` WHERE `id`=%d LIMIT 1", $npc);
             $instanceInfo = Armory::$aDB->selectCell("SELECT MAX(`max_players`) FROM `ARMORYDBPREFIX_instances_difficulty` WHERE `mapID`=%d", $mapID);
             if ($instanceInfo == 5) {
                 // Dungeon
                 return 1;
             } elseif ($instanceInfo > 5) {
                 // Raid
                 return 2;
             }
             break;
         case 'isBoss':
             $npc_data = Armory::$wDB->selectRow("SELECT `rank`, `KillCredit1`, `KillCredit2` FROM `creature_template` WHERE `entry`=%d LIMIT 1", $npc);
             if ($npc_data['rank'] == 3) {
                 return true;
             }
             if ($npc_data['KillCredit1'] > 0) {
                 $kc_entry = $npc_data['KillCredit1'];
             } elseif ($npc_data['KillCredit2'] > 0) {
                 $kc_entry = $npc_data['KillCredit2'];
             } else {
                 $kc_entry = 0;
             }
             $npc_id = $npc . ', ' . $kc_entry;
             $instance = Armory::$aDB->selectCell("SELECT `instance_id` FROM `ARMORYDBPREFIX_instance_data` WHERE `id` IN (%s) OR `name_id` IN (%s) OR `lootid_1` IN (%s) OR `lootid_2` IN (%s) OR `lootid_3` IN (%s) OR `lootid_4` IN (%s)", $npc_id, $npc_id, $npc_id, $npc_id, $npc_id, $npc_id);
             if ($instance > 0) {
                 return true;
             } else {
                 return false;
             }
             break;
         case 'bossData':
             $data = Armory::$aDB->selectRow("\n                SELECT `instance_id`, `key`, `lootid_1`, `lootid_2`, `lootid_3`, `lootid_4`\n                    FROM `ARMORYDBPREFIX_instance_data`\n                        WHERE `id`=%d OR `lootid_1`=%d OR `lootid_2`=%d OR `lootid_3`=%d OR `lootid_4`=%d", $npc, $npc, $npc, $npc, $npc);
             if (!$data) {
                 return false;
             }
             $info = array('difficulty' => 'all', 'key' => $data['key'], 'dungeon_key' => Armory::$aDB->selectCell("SELECT `key` FROM `ARMORYDBPREFIX_instance_template` WHERE `id`=%d", $data['instance_id']));
             for ($i = 1; $i < 5; $i++) {
                 if ($data['lootid_' . $i] == $npc) {
                     if ($i == 1 || $i == 2) {
                         $info['difficulty'] = 'normal';
                     } else {
                         $info['difficulty'] = 'heroic';
                     }
                 }
             }
             break;
     }
     if ($info) {
         return $info;
     }
     return false;
 }
Ejemplo n.º 2
0
     * This will automaticaly add missing realms to `armory_realm_data` table (if MySQL user have "INSERT" access to Armory database)
     **/
    $utils->CheckConfigRealmData();
    // Check $_GET variable
    $utils->CheckVariablesForPage();
}
/** Login **/
if (isset($_GET['login']) && $_GET['login'] == 1) {
    header('Location: login.xml');
} elseif (isset($_GET['logout']) && $_GET['logout'] == 1) {
    header('Location: login.xml?logoff');
}
/** Locale change **/
if (isset($_GET['locale'])) {
    $tmp = strtolower($_GET['locale']);
    $_SESSION['armoryLocaleId'] = $armory->GetLoc();
    switch ($tmp) {
        case 'ru_ru':
        case 'ruru':
        case 'ru':
            $_SESSION['armoryLocale'] = 'ru_ru';
            $_SESSION['armoryLocaleId'] = 8;
            break;
        case 'en_gb':
        case 'engb':
        case 'en':
            $_SESSION['armoryLocale'] = 'en_gb';
            $_SESSION['armoryLocaleId'] = 0;
            break;
        case 'es_es':
        case 'es_mx':
Ejemplo n.º 3
0
    $utils->UpdateVisitorsCount();
}
/** Login **/
if (isset($_GET['login']) && $_GET['login'] == 1) {
    header('Location: login.xml');
    exit;
} else {
    if (isset($_GET['logout']) && $_GET['logout'] == 1) {
        header('Location: login.xml?logoff');
        exit;
    }
}
/** Locale change **/
if (isset($_GET['locale'])) {
    $tmp = strtolower($_GET['locale']);
    $_SESSION['armoryLocaleId'] = Armory::GetLoc();
    switch ($tmp) {
        case 'zh_cn':
        case 'zhcn':
        case 'zh':
            $_SESSION['armoryLocale'] = 'zh_cn';
            $_SESSION['armoryLocaleId'] = 4;
            break;
        case 'ru_ru':
        case 'ruru':
        case 'ru':
            $_SESSION['armoryLocale'] = 'ru_ru';
            $_SESSION['armoryLocaleId'] = 8;
            break;
        case 'en_gb':
        case 'engb':
Ejemplo n.º 4
0
 /**
  * Returns info about last character activity. Requires MaNGOS/Trinity core patch (tools/character_feed)!
  * bool $full used only in character-feed.php
  * @category Characters class
  * @access   public
  * @param    bool $full = false
  * @return   array
  * @todo     Some bosses kills/achievement gains are not shown or shown with wrong date
  **/
 public function GetCharacterFeed($full = false)
 {
     if (!$this->guid) {
         Armory::Log()->writeError('%s : player guid not defined', __METHOD__);
         return false;
     }
     if (!$this->feed_data) {
         // Must be loaded from Character::BuildCharacter()
         return false;
     }
     $limit = $full == true ? 50 : 10;
     $currently_added = 0;
     $i = 0;
     $key = 0;
     $feed_data = array();
     // Strings
     $feed_strings = Armory::$aDB->select("SELECT `id`, `string_%s` AS `string` FROM `ARMORYDBPREFIX_string` WHERE `id` IN (13, 14, 15, 16, 17, 18)", Armory::GetLocale());
     if (!$feed_strings) {
         Armory::Log()->writeError('%s : unable to load strings from armory_string (current locale: %s; locId: %d)', __METHOD__, Armory::GetLocale(), Armory::GetLoc());
         return false;
     }
     $_strings = array();
     foreach ($feed_strings as $str) {
         $_strings[$str['id']] = $str['string'];
     }
     foreach ($this->feed_data as $event) {
         if ($currently_added == $limit) {
             break;
         }
         $event_date = $event['date'];
         $event_type = $event['type'];
         $event_data = $event['data'];
         $date_string = date('d.m.Y', $event_date);
         $feed_data[$i]['hard_date'] = $event_date;
         $feed_data[$i]['hard_data'] = $event_data;
         if (date('d.m.Y') == $date_string) {
             $sort = 'today';
             $diff = time() - $event_date;
             if (Armory::GetLocale() == 'ru_ru') {
                 $periods = array('сек.', 'мин.', 'ч.');
                 $ago_str = 'назад';
             } else {
                 $periods = array('seconds', 'minutes', 'hours');
                 $ago_str = 'ago';
             }
             $lengths = array(60, 60, 24);
             for ($j = 0; $diff >= $lengths[$j]; $j++) {
                 $diff /= $lengths[$j];
             }
             $diff = round($diff);
             $date_string = sprintf('%s %s %s', $diff, $periods[$j], $ago_str);
         } elseif (date('d.m.Y', strtotime('yesterday')) == $date_string) {
             $sort = 'yesterday';
         } else {
             $sort = 'earlier';
         }
         switch ($event_type) {
             case TYPE_ACHIEVEMENT_FEED:
                 $send_data = array('achievement' => $event_data, 'date' => $event_date);
                 $achievement_info = $this->GetAchievementMgr()->GetAchievementInfo($send_data);
                 if (!$achievement_info || !isset($achievement_info['title']) || !$achievement_info['title'] || empty($achievement_info['title'])) {
                     // Wrong achievement ID or achievement not found in DB.
                     continue;
                 }
                 if (date('d/m/Y', $event_date) != $this->GetAchievementMgr()->GetAchievementDate($event['data'])) {
                     // Wrong achievement date, skip. Related to Vasago's issue.
                     continue;
                 }
                 if (!isset($achievement_info['points'])) {
                     $achievement_info['points'] = 0;
                     // Feat of Strength has no points.
                 }
                 $feed_data[$i]['event'] = array('type' => 'achievement', 'date' => $date_string, 'time' => date('H:i:s', $event_date), 'id' => $event_data, 'points' => $achievement_info['points'], 'sort' => $sort);
                 $achievement_info['desc'] = str_replace("'", "\\'", $achievement_info['desc']);
                 $achievement_info['title'] = str_replace("'", "\\'", $achievement_info['title']);
                 $tooltip = sprintf('&lt;div class=\\&quot;myTable\\&quot;\\&gt;&lt;img src=\\&quot;wow-icons/_images/51x51/%s.jpg\\&quot; align=\\&quot;left\\&quot; class=\\&quot;ach_tooltip\\&quot; /\\&gt;&lt;strong style=\\&quot;color: #fff;\\&quot;\\&gt;%s (%d)&lt;/strong\\&gt;&lt;br /\\&gt;%s', $achievement_info['icon'], $achievement_info['title'], $achievement_info['points'], $achievement_info['desc']);
                 if ($achievement_info['categoryId'] == 81) {
                     // Feats of strenght
                     $feed_data[$i]['title'] = sprintf('%s [%s].', $_strings[14], $achievement_info['title']);
                     $feed_data[$i]['desc'] = sprintf('%s [<a class="achievement staticTip" href="character-achievements.xml?r=%s&amp;cn=%s" onMouseOver="setTipText(\'%s\')">%s</a>]', $_strings[14], urlencode($this->GetRealmName()), urlencode($this->name), $tooltip, $achievement_info['title']);
                 } else {
                     $points_string = sprintf($_strings[18], $achievement_info['points']);
                     $feed_data[$i]['title'] = sprintf('%s [%s].', $_strings[13], $achievement_info['title']);
                     $feed_data[$i]['desc'] = sprintf('%s [<a class="achievement staticTip" href="character-achievements.xml?r=%s&amp;cn=%s" onMouseOver="setTipText(\'%s\')">%s</a>] %s.', $_strings[13], urlencode($this->GetRealmName()), urlencode($this->name), $tooltip, $achievement_info['title'], $points_string);
                 }
                 $feed_data[$i]['tooltip'] = $tooltip;
                 break;
             case TYPE_ITEM_FEED:
                 $item = Armory::$wDB->selectRow("SELECT `displayid`, `InventoryType`, `name`, `Quality` FROM `item_template` WHERE `entry`=%d LIMIT 1", $event_data);
                 if (!$item) {
                     continue;
                 }
                 $item_icon = Armory::$aDB->selectCell("SELECT `icon` FROM `ARMORYDBPREFIX_icons` WHERE `displayid`=%d", $item['displayid']);
                 // Is item equipped?
                 if ($this->IsItemEquipped($event_data)) {
                     $item_slot = $item['InventoryType'];
                 } else {
                     $item_slot = -1;
                 }
                 $feed_data[$i]['event'] = array('type' => 'loot', 'date' => $date_string, 'time' => date('H:i:s', $event_date), 'icon' => $item_icon, 'id' => $event_data, 'slot' => $item_slot, 'sort' => $sort);
                 if (Armory::GetLocale() != 'en_gb' && Armory::GetLocale() != 'en_us') {
                     $item['name'] = Items::GetItemName($event_data);
                 }
                 $feed_data[$i]['title'] = sprintf('%s [%s].', $_strings[15], $item['name']);
                 $feed_data[$i]['desc'] = sprintf('%s <a class="staticTip itemToolTip" id="i=%d" href="item-info.xml?i=%d"><span class="stats_rarity%d">[%s]</span></a>.', $_strings[15], $event_data, $event_data, $item['Quality'], $item['name']);
                 $feed_data[$i]['tooltip'] = $feed_data[$i]['desc'];
                 break;
             case TYPE_BOSS_FEED:
                 // Get criterias
                 $achievement_ids = array();
                 $dungeonDifficulty = $event['difficulty'];
                 if ($dungeonDifficulty <= 0) {
                     $DifficultyEntry = $event_data;
                 } else {
                     // Search for difficulty_entry_X
                     $DifficultyEntry = Armory::$wDB->selectCell("SELECT `entry` FROM `creature_template` WHERE `difficulty_entry_%d` = %d", $event['difficulty'], $event_data);
                     if (!$DifficultyEntry || $DifficultyEntry == 0) {
                         $DifficultyEntry = $event['data'];
                     }
                 }
                 $criterias = Armory::$aDB->select("SELECT `referredAchievement` FROM `ARMORYDBPREFIX_achievement_criteria` WHERE `data` = %d", $DifficultyEntry);
                 if (!$criterias || !is_array($criterias)) {
                     continue;
                 }
                 foreach ($criterias as $crit) {
                     $achievement_ids[] = $crit['referredAchievement'];
                 }
                 if (!$achievement_ids || !is_array($achievement_ids)) {
                     continue;
                 }
                 $achievement = Armory::$aDB->selectRow("SELECT `id`, `name_%s` AS `name` FROM `ARMORYDBPREFIX_achievement` WHERE `id` IN (%s) AND `flags`=1 AND `dungeonDifficulty`=%d", Armory::GetLocale(), $achievement_ids, $dungeonDifficulty);
                 if (!$achievement || !is_array($achievement)) {
                     continue;
                 }
                 $feed_data[$i]['event'] = array('type' => 'bosskill', 'date' => $date_string, 'time' => date('H:i:s', $event_date), 'id' => $event_data, 'points' => 0, 'sort' => $sort);
                 $feed_data[$i]['title'] = sprintf('%s [%s] %d %s', $_strings[16], $achievement['name'], $event['counter'], $_strings[17]);
                 $feed_data[$i]['desc'] = sprintf('%d %s.', $event['counter'], $achievement['name']);
                 $feed_data[$i]['tooltip'] = $feed_data[$i]['desc'];
                 break;
             default:
                 continue;
                 break;
         }
         $i++;
         $currently_added++;
     }
     return $feed_data;
 }
Ejemplo n.º 5
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;
 }
Ejemplo n.º 6
0
 /**
  * Generates statistics page
  * @category Achievements class
  * @access   public
  * @param    int $page_id
  * @param    int $faction
  * @return   array
  **/
 public function LoadStatisticsPage($page_id, $faction)
 {
     if (!$this->guid) {
         Armory::Log()->writeError('%s : player guid not defined', __METHOD__);
         return false;
     }
     $achievements_data = Armory::$aDB->select("\n        SELECT `id`, `name_%s` AS `name`, `description_%s` AS `desc`, `categoryId`\n            FROM `ARMORYDBPREFIX_achievement`\n                WHERE `categoryId`=%d AND `factionFlag` IN (%d, -1)", Armory::GetLocale(), Armory::GetLocale(), $page_id, $faction);
     if (!$achievements_data) {
         Armory::Log()->writeError('%s : unable to get data for page_id %d, faction %d (current locale: %s, locId: %d)', __METHOD__, $page_id, $faction, Armory::GetLocale(), Armory::GetLoc());
         return false;
     }
     $return_data = array();
     $hide_id = array();
     foreach ($achievements_data as $achievement) {
         $this->achId = $achievement['id'];
         $return_data[$this->achId] = $achievement;
         $return_data[$this->achId]['quantity'] = self::GetCriteriaValue();
     }
     return $return_data;
 }
Ejemplo n.º 7
0
 /**
  * Returns available classes string (if mask > 0)
  * @category Items class
  * @access   public
  * @param    int $mask
  * @return   string
  **/
 public function AllowableClasses($mask)
 {
     $mask &= 0x5df;
     // Return zero if for all class (or for none)
     if ($mask == 0x5df || $mask == 0) {
         return 0;
     }
     $classes = Armory::$aDB->select("SELECT `id`, `name_%s` AS `name` FROM `ARMORYDBPREFIX_classes`", Armory::GetLocale());
     if (!is_array($classes)) {
         Armory::Log()->writeError('%s : unable to find classes names for locale %s (%d)', __METHOD__, Armory::GetLocale(), Armory::GetLoc());
         return false;
     }
     $classes_data = array();
     foreach ($classes as $class_tmp) {
         $classes_data[$class_tmp['id']] = $class_tmp['name'];
     }
     $i = 1;
     $rMask = array();
     while ($mask) {
         if ($mask & 1) {
             $rMask[$i] = $classes_data[$i];
         }
         $mask >>= 1;
         $i++;
     }
     return $rMask;
 }