コード例 #1
0
ファイル: itemInfo.php プロジェクト: roliandra/WebInterface
function getMarketPrice($itemTableId, $tableId)
{
    $table = "";
    switch ($tableId) {
        case 0:
            $table = "WA_Items";
            break;
        case 1:
            $table = "WA_Auctions";
            break;
        case 2:
            $table = "WA_Mail";
            break;
        case 3:
            $table = "WA_SellPrice";
            break;
    }
    $queryItem = mysql_query("SELECT * FROM {$table} WHERE id='{$itemTableId}'");
    $itemRow = mysql_fetch_row($queryItem);
    $itemId = $itemRow[1];
    $itemDamage = $itemRow[2];
    $foundIt = false;
    $queryMarket = "";
    //return $itemId;
    $queryEnchantLinks = mysql_query("SELECT * FROM WA_EnchantLinks WHERE itemId = '{$itemTableId}' AND itemTableId = '{$tableId}'");
    //return mysql_num_rows($queryEnchantLinks);
    $itemEnchantsArray = array();
    while (list($idt, $enchIdt, $itemTableIdt, $itemIdt) = mysql_fetch_row($queryEnchantLinks)) {
        $itemEnchantsArray[] = $enchIdt;
    }
    $queryEnchantLinksMarket = mysql_query("SELECT * FROM WA_EnchantLinks WHERE itemTableId = '4'");
    $base = isTrueDamage($itemId, $itemDamage);
    if ($base > 0) {
        if (mysql_num_rows($queryEnchantLinks) == 0) {
            $queryMarket1 = mysql_query("SELECT * FROM WA_MarketPrices WHERE name='{$itemId}' AND damage='0' ORDER BY id DESC");
            $maxId = -1;
            $foundIt = false;
            //echo "first";
            while (list($idm, $namem, $damagem, $timem, $pricem, $refm) = mysql_fetch_row($queryMarket1)) {
                $queryMarket2 = mysql_query("SELECT * FROM WA_EnchantLinks WHERE itemId = '{$idm}' AND itemTableId = '4'");
                if (mysql_num_rows($queryMarket2) == 0) {
                    if ($idm > $maxId) {
                        $maxId = $idm;
                        $foundIt = true;
                    }
                }
            }
            if ($foundIt) {
                $queryMarket = mysql_query("SELECT * FROM WA_MarketPrices WHERE id = '{$maxId}' ORDER BY id DESC");
                $foundIt = true;
            }
        } else {
            $queryMarket1 = mysql_query("SELECT * FROM WA_MarketPrices WHERE name='{$itemId}' AND damage='0' ORDER BY id DESC");
            $maxId = -1;
            $foundIt = false;
            //echo "second";
            while (list($idm, $namem, $damagem, $timem, $pricem, $refm) = mysql_fetch_row($queryMarket1)) {
                $marketEnchantsArray = array();
                $queryMarket2 = mysql_query("SELECT enchId FROM WA_EnchantLinks WHERE itemId = '{$idm}' AND itemTableId = '4'");
                while (list($enchIdt) = mysql_fetch_row($queryMarket2)) {
                    if ($idm > $maxId) {
                        $marketEnchantsArray[] = $enchIdt;
                    }
                }
                if (array_diff($itemEnchantsArray, $marketEnchantsArray) == null && array_diff($marketEnchantsArray, $itemEnchantsArray) == null) {
                    $maxId = $idm;
                    $foundIt = true;
                }
                //print_r($itemEnchantsArray);
            }
            if ($foundIt) {
                $queryMarket = mysql_query("SELECT * FROM WA_MarketPrices WHERE id = '{$maxId}' ORDER BY id DESC");
                $foundIt = true;
            }
        }
    } else {
        $queryMarket = mysql_query("SELECT * FROM WA_MarketPrices WHERE name='{$itemId}' AND damage='{$itemDamage}' ORDER BY id DESC");
        $foundIt = true;
    }
    if ($foundIt == false) {
        //market price not found
        //echo "cant find";
        return 0;
    } else {
        //found get first item
        $rowMarket = mysql_fetch_row($queryMarket);
        $marketId = $rowMarket[0];
        if ($base > 0) {
            $marketPrice = $rowMarket[4] / $base * ($base - $itemDamage);
        } else {
            $marketPrice = $rowMarket[4];
        }
        return round($marketPrice, 2);
    }
}
コード例 #2
0
 }
 if ($auction->quantity > 0) {
     if ($numberLeft != 0) {
         $itemDelete = mysql_query("UPDATE WA_Auctions SET quantity='{$numberLeft}' WHERE id='{$auction->id}'");
     } else {
         $toDelete = true;
     }
 }
 $logPrice = mysql_query("INSERT INTO WA_SellPrice (name, damage, time, buyer, seller, quantity, price) VALUES ('{$auction->name}', '{$auction->damage}', '{$timeNow}', '{$user}', '{$auction->owner}', '{$buyQuantity}', '{$auction->price}')");
 $queryLatestAuction = mysql_query("SELECT id FROM WA_SellPrice ORDER BY id DESC");
 list($latestId) = mysql_fetch_row($queryLatestAuction);
 $queryEnchants = mysql_query("SELECT * FROM WA_EnchantLinks WHERE itemId='{$itemId}' AND itemTableId ='1'");
 while (list($idk, $enchIdk, $tableIdk, $itemIdk) = mysql_fetch_row($queryEnchants)) {
     $updateEnch = mysql_query("INSERT INTO WA_EnchantLinks (enchId, itemTableId, itemId) VALUES ('{$enchIdk}', '3', '{$latestId}')");
 }
 $base = isTrueDamage($auction->name, $auction->damage);
 if ($base > 0) {
     $queryEnchantLinksMarket = mysql_query("SELECT * FROM WA_EnchantLinks WHERE itemTableId = '4'");
     $foundIt = false;
     if (count($itemEnchantsArray) == 0) {
         $queryMarket1 = mysql_query("SELECT * FROM WA_MarketPrices WHERE name='{$auction->name}' AND damage='0' ORDER BY id DESC");
         $maxId = -1;
         while (list($idm, $namem, $damagem, $timem, $pricem, $refm) = mysql_fetch_row($queryMarket1)) {
             $queryMarket2 = mysql_query("SELECT * FROM WA_EnchantLinks WHERE itemId = '{$idm}' AND itemTableId = '4'");
             if (mysql_num_rows($queryMarket2) == 0) {
                 if ($idm > $maxId) {
                     $maxId = $idm;
                     $foundIt = true;
                 }
             }
         }