<?php
ob_start();
include("config.php"); 
	if(! check_login()) { 
	exit;
	}

$dbres	=	mysql_query("SELECT *,UNIX_TIMESTAMP(`gevangenis`) AS `gevangenis`,0 FROM `gebruiker` WHERE `login`='{$data->login}'");
$data	=	mysql_fetch_object($dbres);

	if($data->gevangenis + $data->gevangenistijd > time()){
	header("Location: netwerken-gevangenis.php"); 
	exit;
	}

?>

<html>
<head>
<title>Ultimatecrime</title>
<link rel="stylesheet" type="text/css" href="style_general.css">
</head>
<body background="layout/images/layout_12.gif" bgproperties="fixed">
<br>
<br>
<br>
<table align="center" width="600">
	<tr>
		<td class="subTitle" colspan="2">
		<b>Gokkast - <?php echo $data->land; ?></b>
		</td>
	</tr>
	<tr>
		<td class="mainTxt" colspan="2" align="center">

<?php

$dbres		=	mysql_query("SELECT * FROM `casino` WHERE `spel`='2' AND `land`='{$data->land}'");
$casino		=	mysql_fetch_object($dbres);
$geld		=	geld($data->cash);
$geld2		=	geld($casino->inzet);

	if(isset($_GET['gokken'])){
	$nr1a	=	rand(1,9); 
	$nr2a	=	rand(1,9); 
	$nr3a	=	rand(1,9);
	$kans	=	rand(1,2);
		if(($nr1a == $nr2a) && ($nr2a == $nr3a)){
			if($kans == 1){
			$nr1	=	$nr1a; 
			$nr2	=	$nr2a; 
			$nr3	=	$nr3a;
			} else {
			$nr1	=	rand(5,9); 
			$nr2	=	rand(5,9); 
			$nr3	=	rand(5,9);
			}
		} else {
		$nr1	=	$nr1a; 
		$nr2	=	$nr2a; 
		$nr3	=	$nr3a;
		}
	if($data->cash >= $casino->inzet){
		if($nr1== 1 && $nr2== 1 && $nr3== 1){
		$prijs1		=	175000;
		$prijs2		=	geld($prijs1);
		$bericht	=	"Je hebt 3 belletjes! je hebt $prijs2 gewonnen,&nbsp;&nbsp;&nbsp; ";
		} else if($nr1== 2 && $nr2== 2 && $nr3== 2){
		$prijs1		=	25000;
		$prijs2		=	geld($prijs1);
		$bericht	=	"Je hebt 3 Sinasappels! je hebt $prijs2 gewonnen,&nbsp;&nbsp;&nbsp; ";
		} else if($nr1== 3 && $nr2== 3 && $nr3== 3){
		$prijs1		=	15000;
		$prijs2		=	geld($prijs1);
		$bericht	=	"Je hebt 3 Citroenen! je hebt $prijs2 gewonnen,&nbsp;&nbsp;&nbsp; ";
		} else if($nr1== 4 && $nr2== 4 && $nr3== 4){
		$prijs1		=	75000;
		$prijs2		=	geld($prijs1);
		$bericht	=	"Je hebt 3 Bessen! je hebt $prijs2 gewonnen,&nbsp;&nbsp;&nbsp; ";
		} else if($nr1== 5 && $nr2== 5 && $nr3== 5){
		$prijs1		=	200000;
		$prijs2		=	geld($prijs1);
		$bericht	=	"JACKPOT!!!!!!! Je hebt 3 sterren Je wint 200000!&nbsp;&nbsp;&nbsp; ";
		} else if($nr1== 6 && $nr2== 6 && $nr3== 6){
		$prijs1		=	50000;
		$prijs2		=	geld($prijs1);
		$bericht	=	"Je hebt 3 aardbeien! je hebt $prijs2 gewonnen,&nbsp;&nbsp;&nbsp; ";
		} else if($nr1== 7 && $nr2== 7 && $nr3== 7){
		$prijs1		=	100000;
		$prijs2		=	geld($prijs1);
		$bericht	=	"Je hebt 3 Druiven! je hebt $prijs2 gewonnen,&nbsp;&nbsp;&nbsp; ";
		} else if($nr1== 8 && $nr2== 8 && $nr3== 8){
		$prijs1		=	150000;
		$prijs2		=	geld($prijs1);
		$bericht	=	"Je hebt 3 Klavertjes! je hebt $prijs2 gewonnen,&nbsp;&nbsp;&nbsp; ";
		} else if($nr1== 9 && $nr2== 9 && $nr3== 9){
		$prijs1		=	125000;
		$prijs2		=	geld($prijs1);
		$bericht	=	"Je hebt 3 meloenen! je hebt $prijs2 gewonnen,&nbsp;&nbsp;&nbsp; ";
		} else if($nr1== 1 && $nr2== 1){
		$prijs1		=	4000;
		$prijs2		=	geld($prijs1);
		$bericht	=	"Je had 2 Belletjes je hebt $prijs2 gewonnen,&nbsp;&nbsp;&nbsp; ";
		} else if($nr1== 2 && $nr2== 2){
		$prijs1		=	1000;
		$prijs2		=	geld($prijs1);
		$bericht	=	"Je had 2 Sinasappels je hebt $prijs2 gewonnen,&nbsp;&nbsp;&nbsp; ";
		} else if($nr1== 3 && $nr2== 3){
		$prijs1		=	500;
		$prijs2		=	geld($prijs1);
		$bericht	=	"Je had 2 Citroenen je hebt $prijs2 gewonnen,&nbsp;&nbsp;&nbsp; ";
		} else if($nr1== 4 && $nr2== 4){
		$prijs1		=	2000;
		$prijs2		=	geld($prijs1);
		$bericht	=	"Je had 2 Bessen je hebt $prijs2 gewonnen,&nbsp;&nbsp;&nbsp; ";
		} else if($nr1== 5 && $nr2== 5){
		$prijs1		=	5000;
		$prijs2		=	geld($prijs1);
		$bericht	=	"Je had 2 Sterren je hebt $prijs2 gewonnen,&nbsp;&nbsp;&nbsp; ";
		} else if($nr1== 6 && $nr2== 6){
		$prijs1		=	1500;
		$prijs2		=	geld($prijs1);
		$bericht	=	"Je had 2 Aarbeien je hebt $prijs2 gewonnen,&nbsp;&nbsp;&nbsp; ";
		} else if($nr1== 7 && $nr2== 7){
		$prijs1		=	2500;
		$prijs2		=	geld($prijs1);
		$bericht	=	"Je had 2 Druiven je hebt $prijs2 gewonnen,&nbsp;&nbsp;&nbsp; ";
		} else if($nr1== 8 && $nr2== 8){
		$prijs1		=	3500;
		$prijs2		=	geld($prijs1);
		$bericht	=	"Je had 2 Klavertjes je hebt $prijs2 gewonnen,&nbsp;&nbsp;&nbsp; ";
		} else if($nr1== 9 && $nr2== 9){
		$prijs1		=	3000;
		$prijs2		=	geld($prijs1);
		$bericht	=	"Je had 2 Meloenen je hebt $prijs2 gewonnen,&nbsp;&nbsp;&nbsp; ";
		} else if($nr2== 1 && $nr3== 1){
		$prijs1		=	4000;
		$prijs2		=	geld($prijs1);
		$bericht	=	"Je had 2 Belletjes je hebt $prijs2 gewonnen,&nbsp;&nbsp;&nbsp; ";
		} else if($nr2== 2 && $nr3== 2){
		$prijs1		=	1000;
		$prijs2		=	geld($prijs1);
		$bericht	=	"Je had 2 Sinasappels je hebt $prijs2 gewonnen,&nbsp;&nbsp;&nbsp; ";
		} else if($nr2== 3 && $nr3== 3){
		$prijs1		=	500;
		$prijs2		=	geld($prijs1);
		$bericht	=	"Je had 2 Citroenen je hebt $prijs2 gewonnen,&nbsp;&nbsp;&nbsp; ";
		} else if($nr2== 4 && $nr3== 4){
		$prijs1		=	2000;
		$prijs2		=	geld($prijs1);
		$bericht	=	"Je had 2 Bessen je hebt $prijs2 gewonnen,&nbsp;&nbsp;&nbsp; ";
		} else if($nr2== 5 && $nr3== 5){
		$prijs1		=	5000;
		$prijs2		=	geld($prijs1);
		$bericht	=	"Je had 2 Sterren je hebt $prijs2 gewonnen,&nbsp;&nbsp;&nbsp; ";
		} else if($nr2== 6 && $nr3== 6){
		$prijs1		=	1500;
		$prijs2		=	geld($prijs1);
		$bericht	=	"Je had 2 Aardbeien je hebt $prijs2 gewonnen,&nbsp;&nbsp;&nbsp; ";
		} else if($nr2== 7 && $nr3== 7){
		$prijs1		=	2500;
		$prijs2		=	geld($prijs1);
		$bericht	=	"Je had 2 Druiven je hebt $prijs2 gewonnen,&nbsp;&nbsp;&nbsp; ";
		} else if($nr2== 8 && $nr3== 8){
		$prijs1		=	3500;
		$prijs2		=	geld($prijs1);
		$bericht	=	"Je had 2 Klavertjes je hebt $prijs2 gewonnen,&nbsp;&nbsp;&nbsp; ";
		} else if($nr2== 9 && $nr3== 9){
		$prijs1		=	3000;
		$prijs2		=	geld($prijs1);
		$bericht	=	"Je had 2 Meloenen je hebt $prijs2 gewonnen,&nbsp;&nbsp;&nbsp; ";
		} else {
		$prijs1		=	0;
		$bericht	=	"Helaas je hebt niets gewonnen,&nbsp;&nbsp;&nbsp; ";
		}
			
	$dbres		=	mysql_query("SELECT * FROM `gebruiker` WHERE `login`='{$casino->owner}'"); 
	$owner		=	mysql_fetch_object($dbres);

		if($owner->bank-$prijs1 < 0){ 
		mysql_query("UPDATE `casino` SET `owner`='' WHERE `land`='{$data->land}' AND `spel`='2'");
		mysql_query("INSERT INTO `berichten`(`tijd`,`ip`,`van`,`naar`,`titel`,`bericht`) VALUES(NOW(),'{$_SERVER['REMOTE_ADDR']}','Ultimatecrime','{$casino->owner}','Casino','Je Gokkast in {$data->land} is blut gespeeld.')");
		mysql_query("UPDATE `gebruiker` SET `bank`=`bank`-'{$owner->bank}'`casino_aantal` WHERE `login`='{$casino->owner}'");
		mysql_query("UPDATE `gebruiker` SET `cash`=`cash`+'{$owner->bank}' WHERE `login`='{$data->login}'");
		mysql_query("UPDATE `opbrensten` SET `geld`=`geld`-'{$owner->geld}' WHERE `land`='{$data->land}' AND `soort`='2'");
		} else {
		mysql_query("UPDATE `gebruiker` SET `bank`=`bank`+'{$casino->inzet}'-'$prijs1' WHERE `login`='{$casino->owner}'");
		mysql_query("UPDATE `gebruiker` SET `cash`=`cash`-'{$casino->inzet}'+'$prijs1' WHERE `login`='{$data->login}'");
		mysql_query("UPDATE `opbrensten` SET `geld`=`geld`+'{$casino->inzet}'-'$prijs1' WHERE `land`='{$data->land}' AND `soort`='2'");
		}
	} else {
	$bericht	=	"Je hebt niet genoeg geld contant,&nbsp;&nbsp;&nbsp; ";
	}
	}

	if($casino->verkoop == "1"){ 
	echo "Deze casino is momenteel te koop gezet op marktplaats."; 
	} else if($casino->owner == ""){ 
	echo "Dit casino is door niemand in bezit.";
	} else if($casino->owner == $data->login){ 
	echo "Je kunt niet op je eigen casino spelen.";
	} else {

?>

<table border="0" cellpadding="0" cellspacing="0"> 
	<tr> 
		<td colspan="10" height="92">
		<img src="images/gokkast/gokkast_01.gif" width="553" height="92"></td>
	</tr> 
	<tr> 
		<td colspan="8" height="129">
		<img src="images/gokkast/gokkast_02.gif" width="255" height="129"></td>
		<td colspan="2" rowspan="3" height="244">
		<img src="images/gokkast/gokkast_03.gif" width="298" height="244"></td>
	</tr> 
	<tr> 
		<td rowspan="5" height="67">
		<img src="images/gokkast/gokkast_04.gif" width="58" height="182"></td>
		<td height="82">

<?php

	if(isset($_GET['gokken'])){
		if($data->cash >= $casino->inzet){
		echo "<img src=\"images/gokkast/{$nr1}.gif\" width=\"47\" height=\"82\"></td>";
		} else {
		echo "<img src=\"images/gokkast/b1.gif\" width=\"47\" height=\"82\"></td>";
		}
	} else {
	echo "<img src=\"images/gokkast/b1.gif\" width=\"47\" height=\"82\"></td>";
	}

?>

		<td rowspan="5" height="67">
		<img src="images/gokkast/gokkast_06.gif" width="1" height="182"></td>
		<td height="82">

<?php

	if(isset($_GET['gokken'])){
		if($data->cash >= $casino->inzet){
		echo "<img src=\"images/gokkast/{$nr2}.gif\" width=\"47\" height=\"82\"></td>";
		} else {
		echo "<img src=\"images/gokkast/b2.gif\" width=\"47\" height=\"82\"></td>";
		}
	} else {
	echo "<img src=\"images/gokkast/b2.gif\" width=\"47\" height=\"82\"></td>";
	}

?>

		<td rowspan="5" height="67">
		<img src="images/gokkast/gokkast_08.gif" WIDTH="1" height="182"></td> 
		<td height="82">

<?php

	if(isset($_GET['gokken'])){
		if($data->cash >= $casino->inzet){
		echo "<img src=\"images/gokkast/{$nr3}.gif\" width=\"47\" height=\"82\"></td>";
		} else {
		echo "<img src=\"images/gokkast/b3.gif\" width=\"47\" height=\"82\"></td>";
		}
	} else {
	echo "<img src=\"images/gokkast/b3.gif\" width=\"47\" height=\"82\"></td>";
	}

?>

		<td colspan="2" rowspan="2" height="115"> 
 		<img src="images/gokkast/gokkast_10.gif" WIDTH="54" height="115"></td>
	</tr>
	<tr>
		<td rowspan="4" height="1"> 
		<img src="images/gokkast/gokkast_11.gif" width="47" height="100"></td> 
		<td rowspan="4" height="1"> 
		<img src="images/gokkast/gokkast_12.gif" width="47" height="100"></td> 
		<td height="33"> 
		<img src="images/gokkast/gokkast_13.gif" width="47" height="33"></td> 
	</tr> 
	<tr>
		<td colspan="2" rowspan="2" height="1"> 
		<a href="?gokken=ja"><img src="images/gokkast/gokkast_14.gif" width="77" height="54" ALT="Gok" border="0"></a></td> 
		<td colspan="3" height="40"> 
		<img src="images/gokkast/gokkast_15.gif" width="322" height="40"></td> 
	</tr> 
	<tr> 

<?php

	if(isset($_GET['gokken'])){ 

?>

<td colspan="2" height="1" bgcolor="#000000"><font style="font-family: Verdana; font-size: 9pt;" color="white"><marquee style="cursor: default" onmouseover="this.stop()" onmouseout="this.start()"><?php echo $bericht; ?>Eigenaar: <?php echo $casino->owner; ?>,&nbsp;&nbsp;&nbsp; Geld Contant: €<?php echo $geld; ?>&nbsp;&nbsp;&nbsp;Het kost €<?php echo $geld2; ?> per keer.</marquee></td> 	

<?php

	} else {

?>

<td colspan="2" height="1" bgcolor="#000000"><font style="font-family: Verdana; font-size: 9pt;" color="white"><marquee style="cursor: default" onmouseover="this.stop()" onmouseout="this.start()">Eigenaar: <?php echo $casino->owner; ?>,&nbsp;&nbsp;&nbsp; Geld Contant: €<?php echo $geld; ?>&nbsp;&nbsp;&nbsp;Het kost €<?php echo $geld2; ?> per keer.</marquee></td> 	

<?php

	}

?>

		<td height="1">
		<img src="images/gokkast/gokkast_17.gif" width="171" height="14"></td> 
	</tr> 
	<tr> 
		<td colspan="5" height="13"> 
		<img src="images/gokkast/gokkast_18.gif" width="399" height="13"></td> 
	</tr>
	<tr> 
		<td height="1" width=58></td> 
		<td height="1" width=47></td>  
		<td height="1" width=1></td> 
		<td height="1" width=47></td> 
		<td height="1" width=1></td> 
		<td height="1" width=47></td> 
		<td height="1" width=30></td> 
		<td height="1" width=24></td> 
		<td height="1" width=127></td>  
		<td height="1" width=171></td> 
	</tr>
</table>

<?php

	}

?>



		</td>
	</tr>
</table>
</body>
</html>