<?PHP
require("config.php");
$ots = POT::getInstance();
$ots->connect(POT::DB_MYSQL, connection());
$SQL = $ots->getDBHandle();
$ide = new IDE;
$config['site']['vdarkborder']='#FFFFFF';
$config['site']['darkborder']='#D0D0D0';
$config['site']['lightborder']='#B0B0B0';
$auctions = $SQL->query('SELECT `auction_system`.`player`, `auction_system`.`id`, `auction_system`.`item_name`, `auction_system`.`item_id`, `auction_system`.`count`, `auction_system`.`cost`, `auction_system`.`date`, `players`.`name` FROM `auction_system`, `players` WHERE `players`.`id` = `auction_system`.`player` ORDER BY `auction_system`.`id`')->fetchAll();
$players = 0;
echo '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR="'.$config['site']['vdarkborder'].'"><TD CLASS=white><b>Instruction<b></TD></TR><TR BGCOLOR='.$config['site']['darkborder'].'><TD><center><h2>Commands</h2><b>!offer add, itemName, itemPrice, itemCount</b><br /><small>example: !offer add, plate armor, 500, 1</small><br /><br /><B>!offer buy, AuctionID</b><br /><small>example: !offer buy, 1943</small><br /><br /><b>!offer remove, AuctionID</b><br /><small>example: !offer remove, 1943</small><br /><br /><b>!offer withdraw</b><br /><small>Use this command to get money for sold items.</small></center></TR></TD></TABLE><br />';
if(empty($auctions))
{
echo '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR="'.$config['site']['vdarkborder'].'"><TD CLASS=white><b>Auctions</b></td></TR><TR BGCOLOR='.$config['site']['darkborder'].'><TD>Currently is no one active Auction.</TD></TR></TABLE>';
}
else
{
foreach($auctions as $auction) {
if(is_int($players / 2))
$bgcolor = $config['site']['lightborder'];
else
$bgcolor = $config['site']['darkborder'];
$cost = round($auction['cost']/1000, 2);
$content .= "<TR BGCOLOR=".$bgcolor.">
<TD><center>".$auction['id']."</center></TD>
<TD><center><img src='http://www.nefs.es/images/items/".$auction['item_id'].".gif'/></center></TD>
<TD><center>".$auction['item_name']."</center></TD>
<TD><center><a href='".urlencode($auction['name'])."'>".$auction['name']."</a></center></TD>
<TD><center>".$auction['count']."</center></TD>
<TD><center>".$cost."k<br /><small>".$auction['cost']."gp</small></center></TD>
<TD><center>!offer buy, ".$auction['id']."</center></TD></TR>";
$players++;
}
echo '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR="'.$config['site']['vdarkborder'].'"><TD CLASS=white><b><center>ID</center></b></TD><TD class="white"><b><center>#</center></b></TD><TD class="white"><b><center>Item Name</center></b></TD><TD class="white"><b><center>Player</center></b></TD><TD class="white"><b><center>Count</center></b></TD><TD class="white"><b><center>Cost</center></b></td><TD class="white"><b><center>Buy</center></b></td></TR>';
echo $content;
echo '</TABLE>';
}
?>