Location: PHPKode > projects > Trunk.net > tickets.php
<?

require "include/functions.php";

$res = mysql_query("SELECT * FROM lottery_config") or sqlerr(__FILE__, __LINE__);
while ($arr = mysql_fetch_assoc($res))
$arr_config[$arr['name']] = $arr['value'];

if (!$arr_config["enable"])
stderr("Sorry", "Lottery is disabled.");

$user_class = get_user_class();
$class_allowed = array_map('trim', @explode('|', $arr_config["class_allowed"]));
if (!in_array($user_class, $class_allowed))
{
stderr("Sorry", "This class level isn't allowed in this lottery.");
}

dbconn();

loggedinorreturn();

$ticket_amount_display = $arr_config['ticket_amount'];

if ($arr_config["ticket_amount_type"] == GB)
$arr_config['ticket_amount'] = 1024 * 1024 * 1024 * $arr_config['ticket_amount'];
else if ($arr_config["ticket_amount_type"] == MB)
$arr_config['ticket_amount'] = 1024 * 1024 * $arr_config['ticket_amount'];
$size = $arr_config['ticket_amount'];

if ($arr_config["ticket_amount_type"] == GB)
$arr_config['prize_fund'] = 1024 * 1024 * 1024 * $arr_config['prize_fund'];
else if ($arr_config["ticket_amount_type"] == MB)
$arr_config['prize_fund'] = 1024 * 1024 * $arr_config['prize_fund'];
$prize_fund = $arr_config['prize_fund'];

$ratioerr = "<font color=\"red\"><b>You must have uploaded atleast $arr_config[ticket_amount] $arr_config[ticket_amount_type] in order to buy a ticket!</b></font>";

stdhead("Tickets Page");

$total = mysql_num_rows(mysql_query("SELECT * FROM tickets"));
if ($arr_config["use_prize_fund"])
$pot = $prize_fund;
else
$pot = $total * $size;
$me = mysql_num_rows(mysql_query("SELECT * FROM tickets WHERE user=" . $CURUSER["id"]));
$me2 = mysql_query("SELECT * FROM tickets WHERE user=". $CURUSER['id'] ." ORDER BY id ASC");
while ($myrow = mysql_fetch_assoc($me2))
$ticketnumbers .= "$myrow[id] ";

$purchaseable = $arr_config['user_tickets'] - $me;

if ($me >= $arr_config["user_tickets"])
$purchaseable = 0;

if (get_date_time() > $arr_config['end_date'])
$purchaseable = 0;

print("<br>\n");

?>


<table border=1 width=600 cellspacing=0 cellpadding=5>
<tr><td class=tabletitle width=600 align=center>iMT Lottery</td></tr>
<tr><td align=left class=tableb>
<ul>
<li>Tickets are non-refundable</li>
<li>Each ticket costs <?= $ticket_amount_display . ' ' . $arr_config['ticket_amount_type']; ?> which is taken from your upload amount</li>
<li>Purchaseable shows how many tickets you can afford</li>
<li>You can only buy upto your purchaseable amount.</li>
<li>The competiton will end: <?= $arr_config["end_date"]; ?></li>
<li>There will be <?= $arr_config['total_winners']; ?> winners who will be picked at random</li>
<li>Each winner will get <?= mksize($pot/$arr_config['total_winners']); ?> added to their upload amount</li>
<li>The Winners will be announced once the lottery has closed and posted on the home page.</li>
<?
if (!$arr_config["use_prize_fund"])
{
?>
<li>The more tickets that are sold the bigger the pot will be!</li>
<?
}
?>
<li>You own ticket numbers: <?= $ticketnumbers; ?></li>
</ul>
Good Luck!
<hr>
<table align=center width=40% class=frame border=1 cellspacing=0 cellpadding=10><tr><td align=center>
<table width=100% class=tableb class=main border=1 cellspacing=0 cellpadding=5>
<tr>
<td class=tableb>Total Pot</td>
<td class=tableb><?= mksize($pot); ?></td>
</tr>
<tr>
<td class=tableb>Total Tickets Purchased</td>
<td class=tableb align=right><?= $total; ?> Tickets</td>
</tr>
<tr>
<td class=tableb>Tickets Purchased by You</td>
<td class=tableb align=right><?= $me; ?> Tickets</td>

</tr>
<tr>
<td class=tableb>Purchaseable</td>
<td class=tableb align=right><?= $purchaseable; ?> Tickets</td>
</tr>
</table>
</table>
<hr>
<?
if ($purchaseable > 0)
{
?>
<center>
<form method="post" action="purchasetickets.php">
Purchase <input type="text" name="number"> Tickets <input type="submit" value="Purchase">
</form>
</center>
<?
}
else if (get_date_time() > $arr_config['end_date'])
{
?>
<center><h1><font color = "red">Lottery is closed!</font></h1>
<?
}
?>
</td></tr></table>

<? print("<br>\n");

stdfoot();
die;

?>
Return current item: Trunk.net