<?PHP
include "config.php";
if ($ingelogd == "0"){
echo "<meta http-equiv=\"refresh\" content=\"0;URL=login.php\">";
exit;
}
include('header.php');
?>

<html>
<head>
<title>Camoraworld</title>
<link rel="stylesheet" type="text/css" href="style_general.css">
</head>
<body background="layout/images/layout_12.gif" bgproperties="fixed">
<br>
<br>
<br>

<?php

	if(isset($_GET['id'])){
	$_GET['id']		=	$_GET['id'];
	$dbres			=	mysql_query("SELECT `inzet`,`land`,`id`,`spel` FROM `casino` WHERE `id`='{$_GET['id']}' AND `owner`='{$data->login}'");
		if($object = mysql_fetch_object($dbres)){

?>


<table align="center" width="600">
	<tr>
		<td class="subtitle">
		Camoraworld - <?php echo $_GET['type']; ?>
		</td>
	</tr>
	<tr>
		<td class="maintxt" align="center">
		<img src="images/gokken/roulettebanner.jpg">
		</td>
	</tr>
	<tr>
		<td class="maintxt" align="center">

<?php

			if(isset($_POST['submit'])){
			$getal1			=	md5($_SESSION['getal']);
			$getal2			=	$_GET['code'];
				if($getal1 != "" && $getal1 == $getal2){
				$_POST['bedrag']	=	$_POST['bedrag'];

					if($_POST['bedrag'] < 0 || $_POST['bedrag'] == ""){
					echo "Voer een geldig bedrag in.<meta http-equiv=\"refresh\" content=\"3\">";
					} else {
					mysql_query("UPDATE `casino` SET `inzet`='{$_POST['bedrag']}' WHERE `id`='{$_GET['id']}' AND `owner`='{$data->login}'");
					echo "Je hebt de inzet verandert.<meta http-equiv=\"refresh\" content=\"3\">";
					}
				}
	
			} else {

			$dbres			=	mysql_query("SELECT `geld` FROM `opbrensten` WHERE `soort`='{$object->spel}' AND `land`='{$object->land}'");
			$winst			=	mysql_fetch_object($dbres);

			$getal			=	rand(1,10);
			$_SESSION['getal']	=	$getal;
			$getalb			=	md5($getal);

?>

<form method="post" action="beheer-casino.php?id=<?php echo $object->id; ?>&code=<?php echo $getalb; ?>">
<table width="60%" align="center">
	<tr>
		<td width="50%">
		Id:
		</td>
		<td width="50%">
		<?php echo $object->id; ?>
		</td>
	</tr>
	<tr>
		<td width="50%">
		Land:
		</td>
		<td width="50%">
		<?php echo $object->land; ?>
		</td>
	</tr>
	<tr>
		<td width="50%">
		Winst:
		</td>
		<td width="50%">
		€<?php echo geld($winst->geld); ?>
		</td>
	</tr>
	<tr>
		<td width="50%">
		(Max)inzet:
		</td>
		<td width="50%">
		€<?php echo geld($object->inzet); ?>
		</td>
	</tr>
	<tr>
		<td width="100%" colspan="2">
		* Bij gokkast is de inzet het bedrag dat de mensen moeten betalen om te spelen!
		</td>
	</tr>
	<tr>
		<td width="50%">
		Verander:
		</td>
		<td width="50%">
		<input type="text" name="bedrag" value="<?php echo $object->inzet; ?>" size="8" maxlenght="16">
		</td>
	</tr>
	<tr>
		<td width="50%">
		</td>
		<td width="50%">
		<input type="submit" value="Verander" name="submit">
		</td>
	</tr>
</table>
</form>

<?php

			}


?>

		</td>
	</tr>
	<tr>
		<td class="maintxt" align="center">
		<b>Klik <a href="kopen.php">hier</a> om te kijken of er in dit land nog objecten te koop zijn.</b>
		</td>
	</tr>
	<tr>
		<td class="subtitle">&nbsp;</td>
	</tr>
</table>

<?php

		}
	} else {

?>

<table align="center" width="600">
	<tr>
		<td class="subtitle">
		Camoraworld - Casino beheer
		</td>
	</tr>
	<tr>
	<tr>
		<td class="maintxt" align="center">
		<img src="images/gokken/roulettebanner.jpg">
		</td>
	</tr>
	</tr>
	<tr>
		<td class="maintxt" align="center">

<?php


	$nummer		=	0;
	$dbres		=	mysql_query("SELECT `id`,`land` FROM `casino` WHERE `owner`='{$data->login}' AND `spel`='1'");
	$aantal		=	mysql_num_rows($dbres);

		if($aantal != 0){
		echo "<table width=\"72%\" valign=\"top\" cellpadding=\"0\" cellspacing=\"0\"><tr><td width=\"100%\" align=\"left\">";

			while($casino = mysql_fetch_object($dbres)){
			$nummer	=	$nummer+1;
			echo "$nummer. <a href=\"beheer-casino.php?type=Nummerspel&id={$casino->id}\"><u>Nummerspel in {$casino->land}</u></a><br>";
			}

		echo "</td></tr></table>";
		}

	$dbres		=	mysql_query("SELECT `id`,`land` FROM `casino` WHERE `owner`='{$data->login}' AND `spel`='2'");
	$aantal		=	mysql_num_rows($dbres);

		if($aantal != 0){
		echo "<table width=\"72%\" valign=\"top\" cellpadding=\"0\" cellspacing=\"0\"><tr><td width=\"100%\" align=\"left\">";

			while($casino = mysql_fetch_object($dbres)){
			$nummer	=	$nummer+1;
			echo "$nummer. <a href=\"beheer-casino.php?type=Gokkast&id={$casino->id}\"><u>Gokkast in {$casino->land}</u></a><br>";
			}

		echo "</td></tr></table>";
		}

	$dbres		=	mysql_query("SELECT `id`,`land` FROM `casino` WHERE `owner`='{$data->login}' AND `spel`='3'");
	$aantal		=	mysql_num_rows($dbres);

		if($aantal != 0){
		echo "<table width=\"72%\" valign=\"top\" cellpadding=\"0\" cellspacing=\"0\"><tr><td width=\"100%\" align=\"left\">";

			while($casino = mysql_fetch_object($dbres)){
			$nummer	=	$nummer+1;
			echo "$nummer. <a href=\"beheer-casino.php?type=Roulette&id={$casino->id}\"><u>Roulette in {$casino->land}</u></a><br>";
			}

		echo "</td></tr></table>";
		}

		if($nummer == 0){
		echo "<i>Je hebt op het moment nog geen casinos om te beheren.</i>";
		}

?>

		</td>
	</tr>
	<tr>
		<td class="maintxt" align="center">
		<b>Klik <a href="kopen.php">hier</a> om te kijken of er in dit land nog objecten te koop zijn.</b>
		</td>
	</tr>
	<tr>
		<td class="subtitle">&nbsp;</td>
	</tr>
</table>

<?php

	}

?>


</body>
</html>