Example #1
0
 private static function HandleSellingItems()
 {
     if (self::$selling_count <= 0 || !is_array(self::$myitems_storage)) {
         return false;
     }
     $item_ids = array();
     $item_ids_guids = array();
     $items_data = array();
     foreach (self::$myitems_storage as $item) {
         $item_ids[] = $item['item_template'];
         $item_ids_guids[$item['itemguid']] = $item['item_template'];
         $items_data[$item['itemguid']] = $item;
     }
     $items = DB::World()->select("SELECT `entry`, `name`, `Quality`, `displayid` FROM `item_template` WHERE `entry` IN (%s)", $item_ids);
     if (!$items) {
         return false;
     }
     $items_storage = array();
     $displayids = array();
     foreach ($items as $item) {
         $items_storage[$item['entry']] = $item;
         $displayids[] = $item['displayid'];
     }
     $icons = DB::WoW()->select("SELECT `displayid`, `icon` FROM `DBPREFIX_icons` WHERE `displayid` IN (%s)", $displayids);
     if (!$icons) {
         return false;
     }
     $icons_storage = array();
     foreach ($icons as $icon) {
         $icons_storage[$icon['displayid']] = $icon['icon'];
     }
     unset($icons);
     self::$items_storage = array();
     self::$buyout_price = 0;
     foreach ($item_ids_guids as $item_guid => $item_id) {
         if (isset($items_storage[$item_id])) {
             $item = new WoW_Item(WoWConfig::$Realms[WoW_Account::GetActiveCharacterInfo('realmId')]['type']);
             $item->LoadFromDBByEntry($item_guid, $item_id);
             $auc_time = $items_data[$item_guid]['time'];
             $now = time();
             $auction_time = 0;
             if ($now - $auc_time <= 48 * IN_HOURS) {
                 $auction_time = 3;
             } elseif ($now - $auc_time <= 24 * IN_HOURS) {
                 $auction_time = 2;
             } elseif ($now - $auc_time <= 12 * IN_HOURS) {
                 $auction_time = 1;
             }
             self::$items_storage[] = array('auction_id' => $items_data[$item_guid]['id'], 'guid' => $item_guid, 'id' => $items_storage[$item_id]['entry'], 'quality' => $items_storage[$item_id]['Quality'], 'name' => WoW_Locale::GetLocaleId() == LOCALE_EN ? $items_storage[$item_id]['name'] : WoW_Items::GetItemName($item_id), 'icon' => $icons_storage[$items_storage[$item_id]['displayid']], 'price_raw' => $items_data[$item_guid]['startbid'], 'price' => WoW_Utils::GetMoneyFormat($items_data[$item_guid]['startbid']), 'buyout_raw' => $items_data[$item_guid]['buyoutprice'], 'buyout' => WoW_Utils::GetMoneyFormat($items_data[$item_guid]['buyoutprice']), 'lastbid' => $items_data[$item_guid]['lastbid'], 'count' => $item->GetStackCount(), 'time' => $auction_time);
             self::$buyout_price += $items_data[$item_guid]['buyoutprice'];
         }
     }
     unset($items, $items_storage, $displayids);
     return true;
 }
 public function FindItemSourceInfo($entry, $type)
 {
     $source_info = false;
     switch ($type) {
         case 'sourceType.questReward':
             $source_info = DB::World()->selectRow("\n                SELECT\n                `a`.`entry` AS `questId`,\n                `a`.`Title`,\n                `a`.`ZoneOrSort` AS `questZone`,\n                %s\n                FROM `quest_template` AS `a`\n                %s\n                WHERE\n                `a`.`RewChoiceItemId1` = %d OR `a`.`RewChoiceItemId2` = %d OR `a`.`RewChoiceItemId3` = %d OR `a`.`RewChoiceItemId4` = %d OR `a`.`RewChoiceItemId5` = %d OR `a`.`RewChoiceItemId6` = %d OR\n                `a`.`RewItemId1` = %d OR `a`.`RewItemId2` = %d OR `a`.`RewItemId3` = %d OR `a`.`RewItemId4` = %d\n                LIMIT 1", WoW_Locale::GetLocale() != LOCALE_EN ? '`b`.`Title_loc' . WoW_Locale::GetLocaleId() . '` AS `Title_Loc`' : 'NULL', WoW_Locale::GetLocale() != LOCALE_EN ? 'LEFT JOIN `locale_quest` AS `b` ON `b`.`entry` = `a`.`entry`' : null, $entry, $entry, $entry, $entry, $entry, $entry, $entry, $entry, $entry, $entry);
             if (!$source_info) {
                 return false;
             }
             if (WoW_Locale::GetLocale() != LOCALE_EN && $source_info['Title_Loc'] != null) {
                 $source_info['Title'] = $source_info['Title_Loc'];
             }
             break;
         case 'sourceType.creatureDrop':
             $source_info = DB::World()->selectRow("\n                SELECT\n                `a`.`entry` AS `npcId`,\n                `b`.`name`,\n                %s\n                FROM\n                LEFT JOIN `creature_template` AS `b` ON `b`.`entry` = `a`.`entry`\n                %s\n                WHERE\n                `b`.`item` = %d\n                LIMIT 1", WoW_Locale::GetLocale() != LOCALE_EN ? '`c`.`name_loc`' . WoW_Locale::GetLocaleId() . '` AS `name_loc`' : 'NULL', WoW_Locale::GetLocale() != LOCALE_EN ? 'LEFT JOIN `locale_creature` AS `c` ON `c`.`entry` = `a`.`entry`' : null, $entry);
             if ($source_info && WoW_Locale::GetLocale() != LOCALE_EN && $source_info['name_loc'] != null) {
                 $source_info['name'] = $source_info['name_loc'];
             }
             break;
         case 'sourceType.vendor':
             break;
     }
     $source_info['type'] = $type;
     return $source_info;
 }