Exemple #1
0
<?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;
Exemple #2
0
echo "</form>";
echo "<button class=\"awardButton\">Exercise Benevolence/Malice</button>\n";
?>

</div>

<div id="auctions">
<h2>Current Auction:</h2>
<p/>
<form method="post" action="endAuction.php" id="endAuc">
<?php 
$stmt = $dbh->prepare("SELECT * FROM auctions WHERE pending=1");
$stmt->execute();
while ($row = $stmt->fetch()) {
    echo "The current auction lot is:<p/><img src=\"../img.php?img=" . $row['wid'] . "\" style=\"width:200px;\"><p/>Offered by " . getUsername($row['uid']) . ".";
    echo "High bid: " . $CURRENCY_SYMBOL . getHighBidAmountForAuction($row['id']) . " (" . getHighBidderForAuction($row['id']) . ")";
}
echo "<input type=\"hidden\" name=\"aid\" value=\"0\"/><button id=\"nextLot\">Next Lot</button>\n";
?>
</form>
<p/>
<h2>Upcoming Auction</h2>
<?php 
if (isAuctionPending()) {
    echo "An auction will be held at " . pendingAuctionDate() . ".";
} else {
    echo "There is no upcoming auction, but you can add one below.";
}
?>
<h2>Schedule an Auction</h2>
After you schedule the auction, it will appear in the list of upcoming auctions above.  For now, it's possible to
Exemple #3
0
$stmt = $dbh->prepare("SELECT * FROM auctions WHERE UNIX_TIMESTAMP(end) > UNIX_TIMESTAMP(NOW()) ORDER BY end ASC");
$stmt->execute();
while ($row = $stmt->fetch()) {
    // ..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";
    }