Guest User

lottery.php 500 error

a guest
Feb 13th, 2016
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.66 KB | None | 0 0
  1. <?php
  2. include('./includes/connections.php');
  3. include('./includes/brain_file.php');
  4. include('./includes/style_top.php');
  5.  
  6. echo "
  7. <center>
  8. <main>
  9. Lottery
  10. </main>
  11. ";
  12. if ($pl['my_jail'] > time() || $pl['my_hosp'] > time()) {
  13. echo "Sorry this page is not viewable while in jail or hospital!
  14. <hr width='750px'/>";
  15. } else {
  16. if ($lottoconfig['pagedisable'] == 'Yes' &&$pl['playerid'] != 1)
  17.  
  18. {
  19.  
  20.     echo "<span style='color:red'>Sorry but admin has disbaled the lottery system.</span>";
  21.  
  22.  
  23.  
  24.     exit;
  25.  
  26. }
  27.  
  28.  
  29.  
  30. $_GET['action'] = isset($_GET['action']) && ctype_alpha($_GET['action']) ? strtolower(trim($_GET['action'])) : '';
  31. switch($_GET['action'])
  32. {
  33. case 'buy': buy_tickets(); break;
  34. default: lotto(); break;
  35. }
  36.  
  37. function lotto()
  38. {
  39. global $pl,$set,$h,$lottoconfig,$q_ry ;
  40. $q_ry = array();
  41. $q_ry = ("SELECT COUNT(`user`) FROM `lottery_players`");
  42. mysql_query($q_ry);
  43. echo "
  44. <img src='http://4e7221.medialib.glogster.com/media/89879e031a5dbed8d1bf0e877ee49cb2a02e02f15f87bde3408ccfcc30c163b1/dollar-sign.png'
  45. width='200px' height='100px' /><br /><br />
  46. <span>Welcome to the lottery</span>
  47. <span>Each ticket costs <strong>".number_format($lottoconfig['ticketprice'])."</strong></span><br />
  48. <span>Maximum of <strong>".number_format($lottoconfig['maxtickets'], '')."</strong> tickets per person</span>
  49. <hr width='75%' align='center'>
  50. <strong>Loto Info</strong><br /><br />
  51. <span>Jackpot: ".number_format($lottoconfig['ticketprice'] * $amt)."</span><br />
  52. <span>Tickets Purchased: ".number_format($amt, '')."</span><br />
  53. <span>Your Tickets: ".number_format($pl['tickets'], '')."</span><br /><br />
  54. <form method='post' action='lottery.php?action=buy'>
  55. Buy Tickets: <input style='background: #BCC6CC;' type='text' name='amount' value='1' maxlength='2' />
  56. <button style='background: #BCC6CC; width: 100px; padding: 5px;'>Buy</button>
  57. </form>";
  58. if($pl['playerid'] == 1)
  59. {
  60. if(isset($_POST['updatesettings']))
  61. {
  62. $_POST['tp'] = isset($_POST['tp']) && ctype_digit($_POST['tp']) ? abs(intval($_POST['tp'])) : 0;
  63. $_POST['mut'] = isset($_POST['mut']) && ctype_digit($_POST['mut']) ? abs(intval($_POST['mut'])) : 0;
  64.  
  65. if(empty($_POST['tp']) || empty($_POST['mut']))
  66. {
  67. echo "You have missed a required field.";
  68.  
  69. exit;
  70. }
  71.  
  72. $check = mysql_query("SELECT `ticketprice`,`maxtickets` FROM `lottery_config`");
  73. if(mysql_num_rows($check))
  74. mysql_query("UPDATE `lottery_config` SET `ticketprice` = {$_POST['tp']}, `maxtickets` = {$_POST['mut']}");
  75. else
  76. mysql_query("INSERT INTO `lottery_config` VALUES('{$_POST['tp']}','{$_POST['mut']}')");
  77. echo "Info has been updated.";
  78. }
  79. else if(isset($_GET['disable']))
  80. {
  81. $select = mysql_query("SELECT `pagedisable` FROM `lottery_config`");
  82. if(mysql_fetch_single($select) == 'Yes')
  83. {
  84. mysql_query("UPDATE `lottery_config` SET `pagedisable` = 'No' WHERE `pagedisable` = 'Yes'");
  85. echo "You have enabled the page again users can access the lottery.";
  86. }
  87. else
  88. {
  89. mysql_query("UPDATE `lottery_config` SET `pagedisable` = 'Yes' WHERE `pagedisable` = 'No'");
  90. echo "You have disabled the page users can't access the lottery.";
  91. }
  92. }
  93. else
  94. {
  95. echo "<br /><br /><hr width='50%' align='center'>
  96. <h3>Lottery Admin Panel</h3>
  97. <p>Fill out the form below to create / update the price and max tickets.</p><br />
  98. <form method='post'>
  99. Cost Per Ticket: $<input type='text' name='tp' value='1' /><br /><br />
  100. Max Tickets Per User: <input type='text' name='mut' value='1' /><br /><br />
  101. <input type='submit' name='updatesettings' value='Update Lottery Settings' />
  102. </form><br /><br />
  103. <a href='lottery.php?disable'>[Turn On/Off Lottery Page]</a>";
  104. }
  105. }
  106. echo "</div>";
  107.  
  108. }
  109.  
  110. function buy_tickets()
  111. {
  112. $_POST['amount'] = isset($_POST['amount']) && ctype_digit($_POST['amount']) ? abs(intval($_POST['amount'])) : 0;
  113. if(empty($_POST['amount']))
  114. {
  115. echo "Invalid Format.";
  116.  
  117. exit;
  118. }
  119. $deficit = $lottoconfig['maxtickets'] - $pl['tickets'];
  120. if($pl['tickets'] + $_POST['amount'] > $lottoconfig['maxtickets'])
  121. {
  122. echo "The max tickets is ".number_format($lottoconfig['maxtickets']).".
  123. This means you can only buy ".number_format($lottoconfig['maxtickets'] - $pl['tickets'])." more ticket".($deficit == 1 ? '' : 's');
  124.  
  125. exit;
  126. }
  127. if($_POST['amount'] > $lottoconfig['maxtickets'])
  128. {
  129. echo "You can't purchase this amount of tickets..";
  130.  
  131. exit;
  132. }
  133. if($pl['wallet'] < $lottoconfig['ticketprice'] * $_POST['amount'])
  134. {
  135. echo "You don't have enough you need ".number_format($lottoconfig['ticketprice'] * $_POST['amount'] - $pl['wallet']) ." more.";
  136.  
  137. exit;
  138. }
  139. if($pl['wallet'] >= $lottoconfig['ticketprice'] * $_POST['amount'] && $_POST['amount'] <= $lottoconfig['maxtickets'])
  140. {
  141. $pl['wallet'] -= $lottoconfig['ticketprice'] * $_POST['amount'];
  142. $pl['tickets'] += $_POST['amount'];
  143. for($i = 1; $i <= $_POST['amount']; $i++)
  144. mysql_query("INSERT INTO `lottery_players` VALUES('{$pl['userid']}')");
  145. mysql_query("UPDATE `members` SET `wallet` = {$pl['wallet']}, `tickets` = {$pl['tickets']} WHERE `userid` = {$pl['userid']}");
  146. echo "You have purchased ".number_format($_POST['amount'], '')." tickets for ".number_format($lottoconfig['ticketprice'] * $_POST['amount']);
  147. }
  148. }
  149. }
Advertisement
Add Comment
Please, Sign In to add comment