Jump to content

Help with a keno code


Greenbox

Recommended Posts

Why dosent the keno show up at the page? i dont have any errors either :S Anyone who could have a check on the code and see whats missing og wrong? thanks  :-*

 

<?PHP
session_start();
include_once "includes/functions.php";
logincheck();
$username=$_SESSION['username'];
include_once "includes/db_connect.php";
include_once"casinoCP.php";

$fetch= mysql_fetch_object(mysql_query("SELECT * FROM users WHERE username='$username'"));
$keno = mysql_fetch_object(mysql_query("SELECT * FROM properties WHERE location='$fetch->location' AND casino='Keno'"));
$fetch_owner=mysql_fetch_object(mysql_query("SELECT * FROM users WHERE username='$keno->owner'"));

if (strtolower($keno->owner) == strtolower($fetch->username)){
casinoCP($input);
exit();
}
$query1=mysql_query("SELECT * FROM properties WHERE casino='Keno' AND location='$fetch->location' LIMIT 1");
$fetch1=mysql_fetch_object($query1);;
$getname = $_GET['pickupkeno'];
if ($getname == "yes" && $fetch1->owner == "0"){
mysql_query("UPDATE properties SET owner='$username' WHERE casino='Keno' AND location='$fetch->location'");
echo "<font color=orange><center><b>You are now the owner of $fetch->location Keno!</b></font>";
}
if (strip_tags(!$_POST['play']) && $_POST['bet'] == ""){
$ticked="0";
}elseif (strip_tags($_POST['play']) && $_POST['bet'] != ""){

$bet=intval(strip_tags($_POST['bet']));

	if ($bet > "99"){
	if ($bet == 99 || !$bet || ereg('[^0-99]',$bet)){
print "<font color=orange><center><br><br><b>You cant bet that amount.</font></b>";
$ticked="99";
}elseif ($bet != 99 || $bet || !ereg('[^0-99]',$bet)){


if ($bet > $keno->max){
echo "<font color=orange><center><br><br><b>Your bet exceeds the max bet.</font></b>";
$ticked="0";
}elseif ($bet <= $leno->max){
if ($bet > $fetch->money){
echo "<font color=orange><center><br><br><b>You dont have that much money.</font></b>";
$ticked="0";
}elseif ($bet <= $fetch->money){

$keno_numbers = array (
"0" => "",
"1" => "",
"2" => "",
"3" => "",
"4" => "",
"5" => "",
"6" => "",
"7" => "",
"8" => "",
"9" => "",
"10" => "",
"11" => "",
"12" => "",
"13" => "",
"14" => "",
"15" => "",
"16" => "",
"17" => "",
"18" => "",
"19" => "",
"20" => "");

if ($_REQUEST[resetall] != "")
{
$player_numbers = array ();
$action = "";
}
else
{
$player_numbers = array (
	"0" => "$n1",
	"1" => "$n2",
	"2" => "$n3",
	"3" => "$n4",
	"4" => "$n5",
	"5" => "$n6",
	"6" => "$n7",
	"7" => "$n8",
	"8" => "$n9",
	"9" => "$n10",
	"10" => "$n11",
	"11" => "$n12",
	"12" => "$n13",
	"13" => "$n14",
	"14" => "$n15",
	"15" => "$n16",
	"16" => "$n17",
	"17" => "$n18",
	"18" => "$n19",
	"19" => "$n20");
}

if ($action == "play")
{
$i = 0;
while ($i < 20)
{
	$temp = rand(1,80);
	if (!in_array($temp,$keno_numbers))
	{
		$keno_numbers[$i] = $temp;
		$i++;
	}
} 
sort($keno_numbers);
sort($player_numbers);
}
$i = 0;
$points = 0;
while ($i < 21)
{
if (in_array($keno_numbers[$i],$player_numbers))
	$points++;
$i++;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Keno - Coolio</title>
<style type="text/css">

.keno_blueline {
  background-color: #E3E4F7;
}
.keno_pickednumber {
  background-color: #F5F5C2;
}
.keno_winningandpickednumber {
  background-color: #C1F5C2;
}
.keno_winningnumber {
  background-color: #ECBCBC;
}
.keno_notpickednumber {

}
.keno_winningnumber, .keno_pickednumber, .keno_blueline, .keno_notpickednumber, .keno_winningandpickednumber { font-size: 12px; font-family: Verdana, Arial, Helvetica, sans-serif; color: #000000; }

</style>

<script type="text/javascript">
<!--
function selectkeno(v)
{
if (document.getElementById('picked' + v).value == 0)
{
	if (document.kenoform.n20.value > 0)
	{
		document.getElementById('keno' + document.kenoform.n20.value).className = document.getElementById('oldclass' + document.kenoform.n20.value).value;
		document.getElementById('picked' + document.kenoform.n20.value).value = 0;
	}
	document.kenoform.n20.value = document.kenoform.n19.value
	document.kenoform.n19.value = document.kenoform.n18.value
	document.kenoform.n18.value = document.kenoform.n17.value
	document.kenoform.n17.value = document.kenoform.n16.value
	document.kenoform.n16.value = document.kenoform.n15.value
	document.kenoform.n15.value = document.kenoform.n14.value
	document.kenoform.n14.value = document.kenoform.n13.value
	document.kenoform.n13.value = document.kenoform.n12.value
	document.kenoform.n12.value = document.kenoform.n11.value
	document.kenoform.n11.value = document.kenoform.n10.value
	document.kenoform.n10.value = document.kenoform.n9.value
	document.kenoform.n9.value = document.kenoform.n8.value
	document.kenoform.n8.value = document.kenoform.n7.value
	document.kenoform.n7.value = document.kenoform.n6.value
	document.kenoform.n6.value = document.kenoform.n5.value
	document.kenoform.n5.value = document.kenoform.n4.value
	document.kenoform.n4.value = document.kenoform.n3.value
	document.kenoform.n3.value = document.kenoform.n2.value
	document.kenoform.n2.value = document.kenoform.n1.value
	document.kenoform.n1.value = v
	document.getElementById('keno' + v).className = 'keno_pickednumber';
	document.getElementById('picked' + v).value = 1;
}
}


//-->
</script>
</head>

<body>
<center>
<?
echo "<A NAME=keno></A><FORM METHOD=post ACTION=\"$PHP_SELF?page=keno&". time(). "#keno\" NAME=kenoform>\n";
echo "<P>Click on the numbers you would like to pick. You may only select 20 numbers.</P>\n";
echo "<TABLE BORDER=0 CELLPADDING=5 CELLSPACING=0>";
$n = 1;
for ($i = 0; $i < 8; $i++)
{
if ($i % 2 == 1)
	echo "\n  <TR CLASS=keno_blueline>";
else
	echo "\n  <TR>";

for ($j = 0; $j < 10; $j++)
{
	$picked = 0;
	if (in_array ($n, $player_numbers) && in_array($n, $keno_numbers))
	{
		$picked = 1;
		$class = 'keno_winningandpickednumber';
		$oldclass = 'keno_winningnumber';
	}
	else if (in_array ($n, $player_numbers))
	{
		$picked = 1;
		$class = 'keno_pickednumber';
		$oldclass = 'keno_notpickednumber';
	}
	else if (in_array($n, $keno_numbers))
	{
		$class = 'keno_winningnumber';
		$oldclass = 'keno_winningnumber';
	}
	else
	{
		$class = 'keno_notpickednumber';
		$oldclass = 'keno_notpickednumber';
	}
	echo "    <TD ALIGN=center CLASS=". $class ." ID=\"keno$n\" onClick=\"javascript:selectkeno($n);\"><INPUT TYPE=hidden NAME=pickednumber[$n] VALUE=\"$picked\" ID=picked$n><INPUT TYPE=hidden NAME=oldclass[$n] VALUE=\"$oldclass\" ID=oldclass$n>   <B>$n</B>   </TD>\n";
	$n++;
}
echo "  </TR>\n";
}
echo " <TR><TD CLASS=keno_pickednumber> </TD><TD COLSPAN=9 CLASS=keno_notpickednumber>Number you picked</TD></TR>\n";
echo " <TR><TD CLASS=keno_winningnumber> </TD><TD COLSPAN=9 CLASS=keno_notpickednumber>Winning number you didn't have</TD></TR>\n";
echo " <TR><TD CLASS=keno_winningandpickednumber> </TD><TD COLSPAN=9 CLASS=keno_notpickednumber>Winning number you <B>did</B> pick!</TD></TR>\n";


echo "</TABLE>";

if ($action == "play")
{
$again = " again!";
echo "<B>The winning numbers are:</B><BR>";
$w = 0;
while ($w < 21)
{
	echo "   $keno_numbers[$w]";
	$w++;
	if ($w == 10)
		echo "<BR>";
}
echo "<BR><B>and you selected:</B><BR>";
$w = 0;
while ($w < 21)
{
	echo "   $player_numbers[$w]";
	$w++;
	if ($w == 10)
		echo "<BR>";
}
echo "<P><B>You have $points winning numbers!</B></P>";
}
if ($points == 18) {
$win = 6;
}elseif ($points == 19) {
$win = 8;
}elseif ($points == 20){
$win = 10; }

$new_money = $bet * $win;
$n_money = $fetch->money + $new_money;
$owner_money=$fetch_owner->money - $new_money;
if ($owner_money <= "0"){
echo "<font color=orange><center><br><br><b>Congratulations! You bankrupted the Keno owner. Refresh the page and click the link to pick it up</font></b>";
mysql_query("UPDATE properties SET owner='0' WHERE casino='Keno' AND location='$fetch->location'");
}elseif($owner_money > "0"){
mysql_query("INSERT INTO `logs` ( `id` , `username` , `prop` , `location` , `winloss` , `amount`, `date`)
VALUES (
'', '$username', 'Keno', '$fetch->location',  'win', '$new_money', '$date');") or die (mysql_error());
echo "<center><font color=orange><center>Congratulations! You've won $".makecomma($new_money)." from the bet</font></b>";


mysql_query("UPDATE users SET money='$n_money' WHERE username='$username'");
$ear = $keno->profit - $new_money;
mysql_query("UPDATE properties SET profit='$ear' WHERE location='$fetch->location' AND casino='Keno' AND owner !='0'");
mysql_query("UPDATE users SET money='$owner_money' WHERE username='$Keno->owner'");
}
}else{
$new_money2 = $fetch_owner->money + $bet;
$ear2 = $keno->profit + $bet;
$loose_money=$fetch->money-$bet;
mysql_query("INSERT INTO `logs` ( `id` , `username` , `prop` , `location` , `winloss`  , `amount`, `date`)
VALUES (
'', '$username', 'Keno', '$fetch->location',  'loss' , '$bet', '$date');") or die (mysql_error());
mysql_query("UPDATE properties SET profit='$ear2' WHERE location='$fetch->location' AND casino='Keno' AND owner !='0'");
mysql_query("UPDATE users SET money='$new_money2' WHERE username='$keno-s>owner'");
mysql_query("UPDATE users SET money='$loose_money' WHERE username='$username'"); 
echo "<center><font color=orange><center><b>You have lost $".makecomma($bet)."</b></font></center>";
}}

echo "<INPUT TYPE=hidden NAME=action VALUE=\"play\"> ";
echo "<INPUT TYPE=hidden SIZE=2 MAXLENGTH=2 NAME=n1 VALUE=\"". ($player_numbers[0] * 1) ."\"> ";
echo "<INPUT TYPE=hidden SIZE=2 MAXLENGTH=2 NAME=n2 VALUE=\"". ($player_numbers[1] * 1) ."\"> ";
echo "<INPUT TYPE=hidden SIZE=2 MAXLENGTH=2 NAME=n3 VALUE=\"". ($player_numbers[2] * 1) ."\"> ";
echo "<INPUT TYPE=hidden SIZE=2 MAXLENGTH=2 NAME=n4 VALUE=\"". ($player_numbers[3] * 1) ."\"> ";
echo "<INPUT TYPE=hidden SIZE=2 MAXLENGTH=2 NAME=n5 VALUE=\"". ($player_numbers[4] * 1) ."\"> ";
echo "<INPUT TYPE=hidden SIZE=2 MAXLENGTH=2 NAME=n6 VALUE=\"". ($player_numbers[5] * 1) ."\"> ";
echo "<INPUT TYPE=hidden SIZE=2 MAXLENGTH=2 NAME=n7 VALUE=\"". ($player_numbers[6] * 1) ."\"> ";
echo "<INPUT TYPE=hidden SIZE=2 MAXLENGTH=2 NAME=n8 VALUE=\"". ($player_numbers[7] * 1) ."\"> ";
echo "<INPUT TYPE=hidden SIZE=2 MAXLENGTH=2 NAME=n9 VALUE=\"". ($player_numbers[8] * 1) ."\"> ";
echo "<INPUT TYPE=hidden SIZE=2 MAXLENGTH=2 NAME=n10 VALUE=\"". ($player_numbers[9] * 1) ."\"><BR>";
echo "<INPUT TYPE=hidden SIZE=2 MAXLENGTH=2 NAME=n11 VALUE=\"". ($player_numbers[10] * 1) ."\"> ";
echo "<INPUT TYPE=hidden SIZE=2 MAXLENGTH=2 NAME=n12 VALUE=\"". ($player_numbers[11] * 1) ."\"> ";
echo "<INPUT TYPE=hidden SIZE=2 MAXLENGTH=2 NAME=n13 VALUE=\"". ($player_numbers[12] * 1) ."\"> ";
echo "<INPUT TYPE=hidden SIZE=2 MAXLENGTH=2 NAME=n14 VALUE=\"". ($player_numbers[13] * 1) ."\"> ";
echo "<INPUT TYPE=hidden SIZE=2 MAXLENGTH=2 NAME=n15 VALUE=\"". ($player_numbers[14] * 1) ."\"> ";
echo "<INPUT TYPE=hidden SIZE=2 MAXLENGTH=2 NAME=n16 VALUE=\"". ($player_numbers[15] * 1) ."\"> ";
echo "<INPUT TYPE=hidden SIZE=2 MAXLENGTH=2 NAME=n17 VALUE=\"". ($player_numbers[16] * 1) ."\"> ";
echo "<INPUT TYPE=hidden text SIZE=2 MAXLENGTH=2 NAME=n18 VALUE=\"". ($player_numbers[17] * 1) ."\"> ";
echo "<INPUT TYPE=hidden SIZE=2 MAXLENGTH=2 NAME=n19 VALUE=\"". ($player_numbers[18] * 1) ."\"> ";
echo "<INPUT TYPE=hidden SIZE=2 MAXLENGTH=2 NAME=n20 VALUE=\"". ($player_numbers[19] * 1) ."\"><BR>";
echo "<input name='bet' type='text' value=\"$_POST[bet]\"><br>";
echo "<INPUT TYPE=submit NAME=play VALUE=\"Play KENO$again\"> <INPUT TYPE=submit NAME=resetall VALUE=\"Re-start\"></FORM>";
echo "<br>";
if($fetch1->owner == "0"){
die("<center><u><a href='keno.php?pickupkeno=yes'><font color=red><b>Click here to pick up $fetch->location keno!</u></font></b></b></p></a>");
}
if($fetch1->owner == "0"){
die("");
}}}}
?>
</center>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/202769-help-with-a-keno-code/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.