Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>50/50</title>
- <style>
- .win {
- color:green;
- font-weight:bold;
- }
- .lose {
- color:red;
- font-weight:bold;
- }
- </style>
- </head>
- <?php
- include 'globals.php';
- /*
- * Designed and developed by Script47
- * Module idea given by Brodiep
- * The code here (named "5050" or "50/50") is provided "as is" with no warranty or gurantee of safety to existing code.
- * 50/50 has been fully tested and is found to work as intended.
- * 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.
- * This module is free, if you have purchased it from anyone, demand a full refund.
- */
- $_GET['action'] = isset($_GET['action']) && ctype_alpha($_GET['action']) ? trim($_GET['action']) : null;
- switch ($_GET['action']) {
- case "placeBetMoney":
- placeBetMoney();
- break;
- case "placeBetCrystals":
- placeBetCrystals();
- break;
- default:
- index();
- break;
- }
- function index() {
- echo '<h3>50/50</h3>';
- echo '<a href="index.php">Home</a>';
- echo '<br/>';
- echo '<br/>';
- 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/>';
- ?>
- <br/>
- <br/>
- <form action='5050.php?action=placeBetMoney' method='post'>
- <strong>Money:</strong> <input type='number' name='money'><br/>
- <input type='submit' value='Go!'><br/>
- </form>
- <br/>
- <form action='5050.php?action=placeBetCrystals' method='post'>
- <strong>Crystals:</strong> <input type='number' name='crystals'><br/>
- <input type='submit' value='Go!'><br/>
- </form>
- <?php
- }
- function placeBetMoney() {
- global $db, $ir, $h;
- if ($_POST['money'] > $ir['money']) {
- echo '<br/>';
- echo "<font color='red'>You don't have that much money!</br></font";
- echo '<a href="5050.php">Back</a>';
- $h->endpage();
- exit();
- }
- $maxMoney = 5000;
- if ($_POST['money'] > $maxMoney) {
- echo '<br/>';
- echo "<font color='red'>Maximum amount of money is $5000!</br></p>";
- echo '<a href="5050.php">Back</a>';
- $h->endpage();
- exit();
- }
- if (!ctype_digit($_POST['money'])) {
- echo '<br/>';
- echo 'The Money field refers to a numerical value, please go back and try again.<br/>';
- echo '<a href="5050.php">Back</a>';
- $h->endpage();
- exit();
- } else {
- $money = abs(intval($_POST['money']));
- }
- $chance = rand(1, 2);
- $winnings = $_POST['money'] + $_POST['money'];
- if ($chance == 2) {
- echo '<br/>';
- echo '<p class="lose">Unlucky, you lost $' .$_POST['money']. '<br/></p>';
- echo "<a href='5050.php'>Back</a>";
- $db->query("UPDATE `users` SET money=money-$money WHERE userid={$_SESSION['userid']}");
- } else {
- echo '<br/>';
- echo '<p class="win">Congratulations! You win $' .$winnings. '<br/></p>';
- echo "<a href='5050.php'>Back</a>";
- $db->query("UPDATE `users` SET money=money+$money WHERE userid={$_SESSION['userid']}");
- }
- }
- function placeBetCrystals() {
- global $db, $ir, $h;
- if ($_POST['crystals'] > $ir['crystals']) {
- echo '<br/>';
- echo "<p class='lose'>You don't have that many crystals!</br></p>";
- echo '<a href="5050.php">Back</a>';
- $h->endpage();
- exit();
- }
- $maxCrystals = 100;
- if ($_POST['crystals'] > $maxCrystals) {
- echo '<br/>';
- echo "<p class='lose'>Maximum amount of crystals is 100!</br></p>";
- echo '<a href="5050.php">Back</a>';
- $h->endpage();
- exit();
- }
- if (!ctype_digit($_POST['crystals'])) {
- echo '<br/>';
- echo '<p class="lose">The Crystals field refers to a numerical value, please go back and try again.<br/></p>';
- echo '<a href="5050.php">Back</a>';
- $h->endpage();
- exit();
- } else {
- $crystals = abs(intval($_POST['crystals']));
- }
- $chance = rand(1, 2);
- $winnings = $_POST['crystals'] + $_POST['crystals'];
- if ($chance == 2) {
- echo '<br/>';
- echo '<p class="lose">Unlucky, you lost ' .$_POST['crystals']. ' crystals</p>';
- echo "<a href='5050.php'>Back</a>";
- $db->query("UPDATE `users` SET crystals=crystals-$crystals WHERE userid={$_SESSION['userid']}");
- } else {
- echo '<br/>';
- echo '<p class="win">Congratulations! You win ' .$winnings. ' crystals<br/></p>';
- echo '<br/>';
- echo "<a href='5050.php'>Back</a>";
- $db->query("UPDATE `users` SET crystals=crystals+$crystals WHERE userid={$_SESSION['userid']}");
- }
- }
- $h->endpage();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement