Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- require("_game-header.php");
- $totaltickets = mysql_query("SELECT SUM(ticket) FROM raffle_tickets");
- $row = mysql_fetch_assoc($totaltickets, MYSQL_ASSOC);
- $totaltickets = $row["SUM(ticket)"];
- echo $totaltickets ."<br>";
- $usertickets = mysql_query("SELECT ticket FROM raffle_tickets WHERE owner='$accinfo[uniqueid]'");
- $row = mysql_fetch_assoc($usertickets, MYSQL_ASSOC);
- $usertickets = $row["ticket"];
- echo $usertickets;
- // Let's figure out the users win chance.
- if($usertickets > 0)
- {
- $winchance = ($usertickets / $totaltickets * 100);
- $winchance = number_format($winchance,2);
- }
- // The user doesn't have tickets, let's tell them.
- else
- {
- $winchance = "0.00";
- }
- $totalpot = $totaltickets * $_rafflecost;
- $totalpot = number_format($totalpot);
- if($action == "")
- {
- $q=mysql_query("SELECT field, data FROM settings WHERE field='rafflewinner' or field='rafflewinning' or field='raffleticket'");
- while($r=mysql_fetch_array($q))
- {
- if($r['field']=="rafflewinner")
- {
- $q2=mysql_query("SELECT uniqueid, username FROM user_maininfo WHERE uniqueid='{$r['data']}'");
- $winner=mysql_fetch_array($q2);
- }
- elseif($r['field']=="rafflewinning"){$totalpot=$r['data'];}
- else{$winningticket=$r['data'];}
- }
- }
- //echo "<br><center>
- //Last Week's Winner is Lottery Ticket Number <b><font color=yellow>$winner</font></b>!!!<br>The lucky owner of this ticket was none other than <b><a href=game-viewuser.php?idname=$winner[uniqueid]>$winner[username]</a></b> who received ".number_format($totalpot)." gold!!!
- echo "<br><center><table border=1 cellspacing=0 cellpadding=5><tr></center>";
- echo "<td><center><b>Total Lottery Tickets<td><center><b>Total Pot This Week<td><center><b>Your Tickets This Week<td><center><b>Your Chance of Winning";
- echo "<tr><td><center>$totaltickets Tickets<td><center>$totalpot Gold<td><center>$usertickets Tickets<td><center>$winchance%";
- echo "</table><br><br></center>";
- echo "<b>Raffle Organiser:</b> The Lottery of the Realm is a draw that occurs on a <u>Sunday Evening at 9pm GMT (Server Time)</u>. Out of all the tickets, there will be <b>one</b> winner that is lucky enough to take home the whole pot! Minus a small fee of course.<br><br><b>Raffle Organiser:</b> You can buy tickets here from myself for a mere <b>$_rafflecost gold</b> each, and bear in mind the more you have, the better chance you have to win. So how many do you want to buy from me today?";
- echo "<br><br><center><form action=lottery.php method=post><input type=hidden name=action value=buy2>";
- echo "<table border=1 cellspacing=0 cellpadding=5><tr>";
- echo "<td><center><b>Buy Tickets:<td><center><input type=text name=amount size=5>";
- echo "<tr><td colspan=2><center><input type=submit value='Buy Lottery Tickets'></table></form><br><br>";
- // If number isn't a positive amount to purchase tickets. Throw Error!
- if($action == "buy2") {
- echo "buy 2 check";
- $totalprice = $amount * $_rafflecost;
- if (isset($amount) && $amount < 1 && is_numeric($amount) && (ctype_digit($amount) != true)) {
- echo "<br><center><font color=red><b>Error:</b></font> You need to enter a whole positive amount to purchase tickets.<br>";
- echo "<br>[<a href=lottery.php>Back to Raffle Shop</a>]";
- }
- if ($action == "buy2") {
- echo "buy check";
- $totalprice = $amount * $_rafflecost;
- if ($amount == 0) ;
- {
- echo "<br><center><font color=red><b>Error:</b></font> You need to enter a whole positive amount to purchase tickets.<br>";
- echo "<br>[<a href=lottery.php>Back to Raffle Shop</a>]";
- }
- if ($amount > 1) {
- $ticket = "tickets";
- } elseif ($amount == 1) {
- $ticket = "ticket";
- echo "<br><center><b>Lottery Organiser:</b> So you want to buy <b>$amount</b> lottery $ticket at the price of $_rafflecost gold each, which totals <b>" . number_format($totalprice) . "</b> gold?";
- echo "<br><br><table border=1 cellspacing=0 cellpadding=5><tr>";
- echo "<td colspan=2><center><input type=submit value='Buy Tickets'></table></form>";
- }
- if ($accwealth[gold] < $totalprice) {
- echo "<br><center><font color=red><b>Error:</b></font> You don't have the funds available to buy this many tickets.<br>";
- echo "<br>[<a href=lottery.php>Back to Raffle Shop</a>]";
- include("_game-footer.php");
- exit;
- }
- if ($amount > 1) {
- $ticket = "tickets";
- } elseif ($amount == 1) {
- $ticket = "ticket";
- }
- echo "<br><center><font color=yellow><b>Success:</b></font> You have bought <b>$amount</b> $ticket for the cost of <b>$totalprice</b>. Your new lottery ticket numbers have been added to this weeks draw.";
- }
- }
- $newtickets = $ticketamount;
- mysql_query("INSERT INTO player_log (type,time,user,detail) VALUES ('Raffle-Buy','$fulltime','$accinfo[uniqueid]','Bought $amount lottery tickets for a cost of $totalprice gold.')");
- mysql_query("INSERT INTO raffle_tickets (ticket,owner) VALUES ('$ticketamount','$accinfo[uniqueid]') LIMIT 1");
- $totalprice = mysql_real_escape_string($totalprice);
- mysql_query("UPDATE user_economy SET gold=gold-$totalprice WHERE uniqueid='$accinfo[uniqueid]' LIMIT 1");
- echo "<br><br>[<a href=game-raffle.php>Back to Raffle Shop</a>]<br><br>";
- include("_game-footer.php");
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement