Advertisement
Script47

50/50

Dec 20th, 2013
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.69 KB | None | 0 0
  1. <html>
  2.  
  3. <head>
  4. <title>50/50</title>
  5. <style>
  6.  
  7.     .win {
  8.         color:green;
  9.         font-weight:bold;
  10.     }
  11.    
  12.     .lose {
  13.         color:red;
  14.         font-weight:bold;
  15.     }
  16.          
  17.     </style>
  18. </head>
  19.  
  20.   <?php
  21.  
  22. include 'globals.php';
  23.  
  24.  /*
  25.  * Designed and developed by Script47
  26.  * Module idea given by Brodiep
  27.  * The code here (named "5050" or "50/50") is provided "as is" with no warranty or gurantee of safety to existing code.
  28.  * 50/50 has been fully tested and is found to work as intended.
  29.  * 50/50 is released freely under the GNU License. Feel free to modify as you wish, as long as this comment block remains atuynd remains untouched.
  30.  * This module is free, if you have purchased it from anyone, demand a full refund.
  31.  */
  32.  
  33. $_GET['action'] = isset($_GET['action']) && ctype_alpha($_GET['action']) ? trim($_GET['action']) : null;
  34.  
  35. switch ($_GET['action']) {
  36.    
  37.   case "placeBetMoney":
  38.       placeBetMoney();
  39.       break;
  40.  
  41.   case "placeBetCrystals":
  42.       placeBetCrystals();
  43.       break;
  44.  
  45.     default:
  46.         index();
  47.         break;
  48.     }
  49.  
  50. function index() {
  51.    
  52.     echo '<h3>50/50</h3>';
  53.    
  54.     echo '<a href="index.php">Home</a>';
  55.    
  56.     echo '<br/>';
  57.     echo '<br/>';
  58.    
  59.     echo 'Here you can bet sums of money up to 5K or 100 crystals, this game is full of chance do it at <strong>your own risk.</strong></b><br/>';
  60.    
  61.     ?>
  62.  
  63. <br/>
  64. <br/>
  65.    
  66. <form action='5050.php?action=placeBetMoney' method='post'>
  67. <strong>Money:</strong> <input type='number' name='money'><br/>
  68. <input type='submit' value='Go!'><br/>
  69. </form>
  70. <br/>  
  71. <form action='5050.php?action=placeBetCrystals' method='post'>
  72. <strong>Crystals:</strong> <input type='number' name='crystals'><br/>
  73. <input type='submit' value='Go!'><br/>
  74. </form>
  75.    
  76.     <?php
  77.  
  78.     }
  79.  
  80. function placeBetMoney() {
  81.    
  82.     global $db, $ir, $h;
  83.    
  84. if ($_POST['money'] > $ir['money']) {
  85.     echo '<br/>';  
  86.     echo "<font color='red'>You don't have that much money!</br></font";
  87.     echo '<a href="5050.php">Back</a>';    
  88.     $h->endpage();
  89.     exit();
  90. }    
  91.  
  92. $maxMoney = 5000;
  93.  
  94. if ($_POST['money'] > $maxMoney) {
  95.     echo '<br/>';  
  96.     echo "<font color='red'>Maximum amount of money is $5000!</br></p>";
  97.     echo '<a href="5050.php">Back</a>';    
  98.     $h->endpage();
  99.     exit();
  100. }  
  101.  
  102. if (!ctype_digit($_POST['money'])) {
  103.     echo '<br/>';
  104.     echo 'The Money field refers to a numerical value, please go back and try again.<br/>';
  105.     echo '<a href="5050.php">Back</a>';    
  106.     $h->endpage();
  107.     exit();    
  108. } else {
  109.     $money = abs(intval($_POST['money']));
  110. }
  111.  
  112. $chance = rand(1, 2);
  113. $winnings = $_POST['money'] + $_POST['money'];
  114.  
  115. if ($chance == 2) {
  116.     echo '<br/>';
  117.     echo '<p class="lose">Unlucky, you lost $' .$_POST['money']. '<br/></p>';    
  118.     echo "<a href='5050.php'>Back</a>";    
  119.     $db->query("UPDATE `users` SET money=money-$money WHERE userid={$_SESSION['userid']}");
  120. } else {
  121.     echo '<br/>';    
  122.     echo '<p class="win">Congratulations! You win $' .$winnings. '<br/></p>';
  123.     echo "<a href='5050.php'>Back</a>";  
  124.     $db->query("UPDATE `users` SET money=money+$money WHERE userid={$_SESSION['userid']}");    
  125. }
  126. }
  127.  
  128. function placeBetCrystals() {
  129.    
  130.     global $db, $ir, $h;
  131.    
  132. if ($_POST['crystals'] > $ir['crystals']) {
  133.     echo '<br/>';  
  134.     echo "<p class='lose'>You don't have that many crystals!</br></p>";
  135.     echo '<a href="5050.php">Back</a>';    
  136.     $h->endpage();
  137.     exit();
  138. }      
  139.  
  140. $maxCrystals = 100;
  141.    
  142. if ($_POST['crystals'] > $maxCrystals) {
  143.     echo '<br/>';  
  144.     echo "<p class='lose'>Maximum amount of crystals is 100!</br></p>";
  145.     echo '<a href="5050.php">Back</a>';    
  146.     $h->endpage();
  147.     exit();
  148. }    
  149.  
  150. if (!ctype_digit($_POST['crystals'])) {
  151.     echo '<br/>';
  152.     echo '<p class="lose">The Crystals field refers to a numerical value, please go back and try again.<br/></p>';
  153.     echo '<a href="5050.php">Back</a>';    
  154.     $h->endpage();
  155.     exit();    
  156. } else {
  157.     $crystals = abs(intval($_POST['crystals']));
  158. }    
  159.  
  160. $chance = rand(1, 2);
  161. $winnings = $_POST['crystals'] + $_POST['crystals'];
  162.  
  163. if ($chance == 2) {
  164.     echo '<br/>';
  165.     echo '<p class="lose">Unlucky, you lost ' .$_POST['crystals']. ' crystals</p>';    
  166.     echo "<a href='5050.php'>Back</a>";    
  167.     $db->query("UPDATE `users` SET crystals=crystals-$crystals WHERE userid={$_SESSION['userid']}");
  168. } else {
  169.     echo '<br/>';    
  170.     echo '<p class="win">Congratulations! You win ' .$winnings. ' crystals<br/></p>';
  171.     echo '<br/>';
  172.     echo "<a href='5050.php'>Back</a>";  
  173.     $db->query("UPDATE `users` SET crystals=crystals+$crystals WHERE userid={$_SESSION['userid']}");    
  174. }
  175. }
  176.  
  177. $h->endpage();
  178. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement