<?php require_once '../../incl/incl.php'; require_once '../../incl/memcache.incl.php'; require_once '../../incl/api.incl.php'; if (!isset($_GET['house']) || !isset($_GET['species'])) { json_return(array()); } $house = intval($_GET['house'], 10); $species = intval($_GET['species'], 10); if (!$species) { json_return(array()); } BotCheck(); HouseETag($house); $json = array('stats' => PetStats($house, $species), 'history' => PetHistory($house, $species), 'auctions' => PetAuctions($house, $species), 'globalnow' => PetGlobalNow(GetRegion($house), $species)); json_return($json); function PetStats($house, $species) { global $db; $key = 'battlepet_stats_l_' . $species; if (($tr = MCGetHouse($house, $key)) !== false) { return $tr; } DBConnect(); $names = LocaleColumns('i.name'); $sql = <<<EOF select i.id, {$names}, i.icon, i.type, i.npc, s.price, s.quantity, s.lastseen, s.breed from tblDBCPet i left join tblPetSummary s on s.house = ? and s.species = i.id
function CategoryDealsItemList($house, $dealsSql, $flags = 0) { global $canCache; $cacheKey = 'category_di4_' . md5($dealsSql) . '_' . $flags; if ($canCache && ($iidList = MCGetHouse($house, $cacheKey)) !== false) { return CategoryDealsItemListCached($house, $iidList, $flags); } $db = DBConnect(); $region = GetRegion($house); $fullSql = <<<EOF select aa.item, aa.bonusset, (select a.id from tblAuction a left join tblAuctionExtra ae on ae.house=a.house and ae.id = a.id join tblDBCItem i on a.item = i.id where a.buy > 0 and a.house=? and a.item=aa.item and ifnull(ae.bonusset,0) = aa.bonusset order by (a.buy/pow(1.15,(cast(ifnull(ae.level, i.level) as signed) - cast(i.level as signed))/15))/a.quantity limit 1) cheapestid from ( select ac.item, ac.bonusset, ac.c_total, ac.c_over, ac.price, gs.median from ( select ab.item, ab.bonusset, count(*) c_total, sum(if(tis2.price > ab.price,1,0)) c_over, ab.price from ( select tis.item, tis.bonusset, tis.price from tblItemSummary tis join tblDBCItem i on tis.item=i.id where tis.house = ? and tis.quantity > 0 and 0 = (select count(*) from tblDBCItemVendorCost ivc where ivc.item=i.id) and i.class not in (16) and {$dealsSql} EOF; if (($flags & CATEGORY_FLAGS_ALLOW_CRAFTED) == 0) { $fullSql .= ' and not exists (select 1 from tblDBCSpell s where s.crafteditem=i.id) '; } if ($flags & CATEGORY_FLAGS_DENY_NONCRAFTED) { $fullSql .= ' and exists (select 1 from tblDBCSpell s where s.crafteditem=i.id) '; } $fullSql .= <<<EOF ) ab join tblItemSummary tis2 on tis2.item = ab.item and tis2.bonusset = ab.bonusset join tblRealm r on r.house = tis2.house and r.canonical is not null where r.region = ? group by ab.item, ab.bonusset ) ac join tblItemGlobal gs on gs.item = ac.item and gs.bonusset = ac.bonusset and gs.region = ? where ((c_over/c_total) > 2/3 or c_total < 15) ) aa where median > 1500000 and median > price order by (cast(median as signed) - cast(price as signed))/greatest(5000000,price) * (c_over/c_total) desc limit 15 EOF; $stmt = $db->stmt_init(); if (!$stmt->prepare($fullSql)) { DebugMessage("Bad SQL: \n" . $fullSql, E_USER_ERROR); } $stmt->bind_param('iiss', $house, $house, $region, $region); $stmt->execute(); $result = $stmt->get_result(); if ($result === false && ($errMsg = $db->error)) { DebugMessage("No result: {$errMsg}\n" . $fullSql, E_USER_ERROR); } $iidList = DBMapArray($result, null); $stmt->close(); MCSetHouse($house, $cacheKey, $iidList); return CategoryDealsItemListCached($house, $iidList, $flags); }
function HouseDeals($house) { global $db; $cacheKey = 'house_deals_l2'; if (($tr = MCGetHouse($house, $cacheKey)) !== false) { PopulateLocaleCols($tr, [['func' => 'GetItemNames', 'key' => 'id', 'name' => 'name']]); return $tr; } DBConnect(); $sql = <<<EOF SELECT i.id FROM `tblItemSummary` tis join tblDBCItem i on tis.item = i.id join tblItemGlobal g on g.item = tis.item and g.bonusset = tis.bonusset and g.region = ? WHERE house = ? and tis.quantity > 0 and i.quality > 0 and g.median > 1000000 order by tis.price / g.median asc limit 10 EOF; $region = GetRegion($house); $stmt = $db->prepare($sql); $stmt->bind_param('si', $region, $house); $stmt->execute(); $result = $stmt->get_result(); $tr = $result->fetch_all(MYSQLI_ASSOC); $stmt->close(); MCSetHouse($house, $cacheKey, $tr); PopulateLocaleCols($tr, [['func' => 'GetItemNames', 'key' => 'id', 'name' => 'name']]); return $tr; }
require_once '../../incl/api.incl.php'; if (!isset($_GET['house']) || !isset($_GET['item'])) { json_return(array()); } $house = intval($_GET['house'], 10); $item = intval($_GET['item'], 10); if (!$item) { json_return(array()); } BotCheck(); HouseETag($house); $stats = ItemStats($house, $item); if (count($stats) == 0) { json_return([]); } $json = array('stats' => $stats, 'history' => ItemHistory($house, $item), 'daily' => ItemHistoryDaily($house, $item), 'monthly' => ItemHistoryMonthly($house, $item), 'expired' => ItemExpired($house, $item), 'sellers' => ItemSellers($house, $item), 'auctions' => ItemAuctions($house, $item), 'globalnow' => ItemGlobalNow(GetRegion($house), $item), 'globalmonthly' => ItemGlobalMonthly(GetRegion($house), $item)); json_return($json); function ItemStats($house, $item) { global $db; $cacheKey = 'item_stats_b4_' . $item; if (($tr = MCGetHouse($house, $cacheKey)) !== false) { return $tr; } DBConnect(); $localeCols = LocaleColumns('i.name'); $bonusTags = LocaleColumns('ifnull(group_concat(distinct ind.`desc%1$s` separator \' \'),\'\') bonustag%1$s', true); $sql = <<<EOF select i.id, {$localeCols}, i.icon, i.display, i.class as classid, i.subclass, i.quality, i.level, i.stacksize, i.binds, i.buyfromvendor, i.selltovendor, i.auctionable, s.price, s.quantity, s.lastseen,