<?php /** * aucval.php: In the live auction system, this script is called by client-side polling * every couple seconds to update the high bidder, time of last bid, and bid amount in * JSON format. * * @param i (via GET): the auction id. Corresponds with primary key of auctions table. * * Called by: marketplace.php (within JavaScript polling function). * * @author William Shaw <*****@*****.**> * @author Katherine Jentleson <*****@*****.**>, designer * @version 0.1, 10/2012 * */ if (session_id() == '') { session_start(); } header('Content-type: application/json'); ob_start(); require 'db.php'; require 'functions.php'; ob_end_clean(); $requested = $_GET['i']; // Set upt he JSON object containing our data. Sample format: {"amt":120,"u":16,"t":128974918274, "metReserve":0 } // amt = bid amount; u = user ID of high bidder; t: epoch timestamp of last bid; metReserve: was reserve met? 1/0 $JSON = "{\"amt\":" . getHighBidAmountForAuction($requested) . ", \"u\":\"" . getHighBidderForAuction($requested) . "\", \"t\":" . getLastBidTimeForAuction($requested) . ", \"metReserve\":" . didAuctionMeetReserve($requested) . "}"; echo $JSON;
// ..and for each one, display a form with the work image, a link to workview,php, the work tombstone, // the amount of time left in the auction, and basic auction data (curent bid, minimum bid if nobody // has bid yet, buy-it-now price); includes text input for bid amount and button(s) for placing // a bid / buying outright, if applicable. Buttons are handled in (document).ready() above. echo "<form>\n"; echo "<input type=\"hidden\" name=\"aid\" value=\"" . $row['id'] . "\"/>"; echo "<input type=\"hidden\" name=\"seller\" value=\"" . $row['uid'] . "\"/>"; echo "<input type=\"hidden\" name=\"work\" value=\"" . $row['wid'] . "\"/> "; echo "<div style=\"background-color:lightgray;width:100%;height:200px;padding:8px;\">\n"; echo "<div style=\"float:left;display:inline;\"><a rel=\"shadowbox\" href=\"workview.php?wid=" . $row['wid'] . "\"><img src=\"img.php?img=" . $row['wid'] . "\" style=\"height:150px;\"/></a>\n"; echo "</div><div style=\"float:left;display:inline;width:80%;padding:10px;\">"; echo "<span style=\"font-size:1.5em;\">" . getTombstoneOrBlank($row['wid'], true) . "</span><br/>"; echo "Offered by " . getUsername($row['uid']) . " (ends in <b>" . secondsToString(strtotime($row['end']) - strtotime('-0 seconds')) . "</b>, on " . $row['end'] . ")<p/>Current high bid: " . getHighBidderForAuction($row['id']); echo " (" . $CURRENCY_SYMBOL . getHighBidAmountForAuction($row['id']); if (getReserve($row['id'] > 0)) { echo ", reserve" . (didAuctionMeetReserve($row['id']) > 0 ? " met" : " not met"); } echo ")<p/>\n"; echo "<input type=\"text\" name=\"amount\" size=\"5\"/>\n"; echo "<button type=\"submit\" style=\"\" class=\"buyClassified\" name=\"" . $row['id'] . "\" id=\"#buy" . $row['wid'] . "\">Place Bid"; if (getMinimumBidForAuction($row['id']) > getHighBidAmountForAuction($row['id'])) { echo " (Minimum bid: " . $CURRENCY_SYMBOL . getMinimumBidForAuction($row['id']) . ")"; } echo "</button>\n"; if (getAuctionBIN($row['id']) > 0 && getHighBidAmountForAuction($row['id']) <= getMinimumBidForAuction($row['id'])) { echo "<input type=\"hidden\" name=\"amountOutright\" value=\"" . getAuctionBIN($row['id']) . "\"/>\n"; echo "<button class=\"buyBIN\" name=\"" . $row['id'] . "\" id=\"#bin" . $row['wid'] . "\">Buy outright for " . $CURRENCY_SYMBOL . getAuctionBIN($row['id']) . "</button>\n"; } echo "</div></div><p/>\n"; echo "</form>\n"; }