Example #1
0
         } else {
             sql_query("UPDATE blackjack SET status = 'waiting', date=" . $now . ", gameover='yes' WHERE userid = " . sqlesc($CURUSER['id']));
             $HTMLOUT .= "<tr><td align='center'>There are no other players, so you'll have to wait until someone plays against you.<br />You will receive a PM with the game results.<br /><br /><b><a href='/blackjack.php'>Back</a></b><br /></td></tr>";
         }
         $HTMLOUT .= "</table></td></tr></table><br />";
         echo stdhead('Blackjack') . $HTMLOUT . stdfoot();
     } else {
         cheater_check(empty($playerarr));
         $HTMLOUT .= "<h1>Welcome, {$CURUSER['username']}!</h1>\n\t\t\t<table cellspacing='0' cellpadding='3' width='600'>\n\t\t\t<tr><td colspan='2'>\n\t\t\t<table class='message' width='100%' cellspacing='0' cellpadding='5' bgcolor='white'>\n\t\t\t<tr><td align='center'>{$showcards}</td></tr>\n\t\t\t<tr><td align='center'><b>Points = {$points}</b></td></tr>";
         $HTMLOUT .= "<tr>\n      <td align='center'><form method='post' action='" . $_SERVER['PHP_SELF'] . "'><input type='hidden' name='game' value='hit' readonly='readonly' /><input type='submit' value='HitMe' /></form></td>\n      </tr>";
         $HTMLOUT .= "<tr>\n      <td align='center'><form method='post' action='" . $_SERVER['PHP_SELF'] . "'><input type='hidden' name='game' value='stop' readonly='readonly' /><input type='submit' value='Stay' /></form></td>\n      </tr>";
         $HTMLOUT .= "</table></td></tr></table><br />";
         echo stdhead('Blackjack') . $HTMLOUT . stdfoot();
     }
 } elseif ($_POST["game"] == 'stop') {
     cheater_check(empty($playerarr));
     $waitres = sql_query("SELECT COUNT(userid) AS c FROM blackjack WHERE status='waiting' AND userid != " . sqlesc($CURUSER['id']));
     $waitarr = mysqli_fetch_assoc($waitres);
     $HTMLOUT .= "<h1>Game over</h1>\n\t\t<table cellspacing='0' cellpadding='3' width='600'>\n\t\t<tr><td colspan='2'>\n\t\t<table class='message' width='100%' cellspacing='0' cellpadding='5' bgcolor='white'>\n\t\t<tr><td align='center'>{$showcards}</td></tr>\n\t\t<tr><td align='center'><b>Points = " . htmlsafechars($playerarr['points']) . "</b></td></tr>";
     if ($waitarr['c'] > 0) {
         $r = sql_query("SELECT bj.*, u.username, u.uploaded, u.downloaded, u.bjwins, u.bjlosses FROM blackjack AS bj LEFT JOIN users AS u ON u.id=bj.userid WHERE bj.status='waiting' AND bj.userid != " . sqlesc($CURUSER['id']) . " ORDER BY bj.date ASC LIMIT 1");
         $a = mysqli_fetch_assoc($r);
         if ($a["points"] == $playerarr['points']) {
             $subject = sqlesc("Blackjack Results");
             $winorlose = "nobody won";
             $msg = sqlesc("Your opponent was " . $CURUSER['username'] . ", you both had " . htmlsafechars($a['points']) . " points - it was a tie.\n\n");
         } else {
             if ($a["points"] < $playerarr['points'] && $a['points'] < 21 || $a["points"] > $playerarr['points'] && $a['points'] > 21) {
                 $subject = sqlesc("Blackjack Results");
                 $msg = sqlesc("You lost to " . $CURUSER['username'] . " (You had " . htmlsafechars($a['points']) . " points, " . $CURUSER['username'] . " had " . htmlsafechars($playerarr['points']) . " points).\n\n");
                 $winorlose = "you won " . mksize($mb);
Example #2
0
         } else {
             sql_query("UPDATE blackjack SET status = 'waiting', date=" . $now . ", gameover='yes' WHERE userid = " . sqlesc($CURUSER['id']));
             $HTMLOUT .= "<tr><td align='center'>There are no other players, so you'll have to wait until someone plays against you.<br />You will receive a PM with the game results.<br /><br /><b><a href='/blackjack.php'>Back</a></b><br /></td></tr>";
         }
         $HTMLOUT .= "</table></td></tr></table><br />";
         echo stdhead('Blackjack') . $HTMLOUT . stdfoot();
     } else {
         $HTMLOUT .= cheater_check(empty($playerarr));
         $HTMLOUT .= "<h1>Welcome, {$CURUSER['username']}!</h1>\r\n\t\t\t<table cellspacing='0' cellpadding='3' width='600'>\r\n\t\t\t<tr><td colspan='2'>\r\n\t\t\t<table class='message' width='100%' cellspacing='0' cellpadding='5' bgcolor='white'>\r\n\t\t\t<tr><td align='center'>{$showcards}</td></tr>\r\n\t\t\t<tr><td align='center'><b>Points = {$points}</b></td></tr>";
         $HTMLOUT .= "<tr>\r\n      <td align='center'><form method='post' action='" . $_SERVER['PHP_SELF'] . "'><input type='hidden' name='game' value='hit' readonly='readonly' /><input type='submit' value='HitMe' /></form></td>\r\n      </tr>";
         $HTMLOUT .= "<tr>\r\n      <td align='center'><form method='post' action='" . $_SERVER['PHP_SELF'] . "'><input type='hidden' name='game' value='stop' readonly='readonly' /><input type='submit' value='Stay' /></form></td>\r\n      </tr>";
         $HTMLOUT .= "</table></td></tr></table><br />";
         echo stdhead('Blackjack') . $HTMLOUT . stdfoot();
     }
 } elseif ($_POST["game"] == 'stop') {
     $HTMLOUT .= cheater_check(empty($playerarr));
     $waitres = sql_query("SELECT COUNT(userid) AS c FROM blackjack WHERE status='waiting' AND userid != " . sqlesc($CURUSER['id']));
     $waitarr = mysql_fetch_assoc($waitres);
     $HTMLOUT .= "<h1>Game over</h1>\r\n\t\t<table cellspacing='0' cellpadding='3' width='600'>\r\n\t\t<tr><td colspan='2'>\r\n\t\t<table class='message' width='100%' cellspacing='0' cellpadding='5' bgcolor='white'>\r\n\t\t<tr><td align='center'>{$showcards}</td></tr>\r\n\t\t<tr><td align='center'><b>Points = {$playerarr['points']}</b></td></tr>";
     if ($waitarr['c'] > 0) {
         $r = sql_query("SELECT bj.*, u.username, u.uploaded, u.bjwins, u.bjlosses FROM blackjack AS bj LEFT JOIN users AS u ON u.id=bj.userid WHERE bj.status='waiting' AND bj.userid != " . sqlesc($CURUSER['id']) . " ORDER BY bj.date ASC LIMIT 1");
         $a = mysql_fetch_assoc($r);
         if ($a["points"] == $playerarr['points']) {
             $subject = sqlesc("Blackjack Results");
             $winorlose = "nobody won";
             $msg = sqlesc("Your opponent was " . $CURUSER['username'] . ", you both had " . $a['points'] . " points - it was a tie.\n\n");
         } else {
             if ($a["points"] < $playerarr['points'] && $a['points'] < 21 || $a["points"] > $playerarr['points'] && $a['points'] > 21) {
                 $subject = sqlesc("Blackjack Results");
                 $msg = sqlesc("You lost to " . $CURUSER['username'] . " (You had " . $a['points'] . " points, " . $CURUSER['username'] . " had " . $playerarr['points'] . " points).\n\n");
                 $winorlose = "you won " . mksize($mb);