<?php
/*

 ################################
 #								#	
 #   ROULETTE 					#
 #    v 1.0						#
 #   							#
 #    Auteur: Stefan Van Elsas	#
 #    Cyberstefan@hotmail.com	#
 #								#
 ################################
 
 */

?>
[code]
<style type="text/css">
table {color:#464646; border-style:hidden; border-color: #464646;}
.board {background-color:#464646; border-style:none; border-color:#464646 #464646 #464646 #464646; }
.wit { background-color: #003366; font-size: 12px; color: #FFFFFF; border-style: solid; border-width:thin; border-color: #000000 #000000 #000000 #000000; font-weight: bold;  }
.red { background-color: #990000; font-size: 12px; color: #FFFFFF; border-style: solid; border-width:thin; border-color: #000000 #000000 #000000 #000000; font-weight: bold;  }
.black { background-color: #000000; font-size: 12px; color: #FFFFFF; border-style: solid; border-width:thin;  border-color: #000000 #000000 #000000 #000000; font-weight: bold;  }
.groen { background-color: #009933; font-size: 12px; color: #FFFFFF; border-style: solid; border-width:thin;  border-color: #000000 #000000 #000000 #000000; font-weight: bold;  }
</style>

<SCRIPT TYPE="text/javascript">
function numbersonly(myfield, e, dec)
{
	var key;
	var keychar;

	if (window.event)
	key = window.event.keyCode;
	else if (e)
	key = e.which;
	else
	return true;
	keychar = String.fromCharCode(key);

	// control keys
	if ((key==null) || (key==0) || (key==8) ||
	(key==9) || (key==13) || (key==27) )
	return true;

	// numbers
	else if ((("0123456789").indexOf(keychar) > -1))
	return true;

	// decimal point jump
	else if (dec && (keychar == "."))
	{
		myfield.form.elements[dec].focus();
		return false;
	}
	else
	return false;
}

</SCRIPT>

</head>

<body>
<div align="center">
[/code]
<?php
$iBeginMoney=50000;
$iMaxbet=100000;
if (empty($_SESSION['yourmoney'])){
	$_SESSION['yourmoney'] = $iBeginMoney;//set standaard start geld in sessie
}else{
	$_SESSION['yourmoney'] = $_SESSION['yourmoney'];
}
// geld ressetten
if (isset($_POST['reset2'])){
	$_SESSION['yourmoney'] = $iBeginMoney;
}
if(isset($_POST['gok'])){

	//inzet
	$iBet = 0;
	for($i=1;$i<=48;$i++){
		if(trim($_POST[$i]) != ""){
			if(!preg_match("/^[0-9]{1,10}$/i",$_POST[$i])){
				die('Foute input!');
			}
			$iBet= $iBet + $_POST[$i];
		}
	}
	$err = 0;
	if($iBet == 0) {
		echo "<b><i>Je moet wel wat inzetten!</i></b>";
		$err = 1;
	}
	if($err == 0 && $iBet > $iMaxbet){
		echo "<b><i>De maxbet is,€".number_format($iMaxbet,0,",",".").". hier voldoet je inzet niet aan!</i></b><br>";
		$err = 1;
	}
	if($err == 0 && $iBet > $_SESSION['yourmoney']) {
		echo "<br><br><b><i>Dit geld heb je niet!</i></b><br>";
		$err = 1;
	}
	if($err == 0){
		function make_seed()
		{
			list($usec, $sec) = explode(' ', microtime());
			return (float) $sec + ((float) $usec * 100000);
		}
		srand(make_seed());

		$iNumber = rand(0,36);
		$sColor = "red";
		switch($iNumber){
			case 2: case 4: case 6: case 8: case 11: case 13: case 15: case 17: case 20:
			case 22: case 24: case 26: case 28: case 29: case 31: case 33: case 35:
			$sColor = "black"; break;
			case 0: $sColor = "green"; break;
		}

		echo "<br><br><table width = \"150\" border = \"1\"><tr>";
		if($sColor == "black") echo "<tr><td valign = \"center\" align = \"center\" class = \"black\">$iNumber</td></tr>";
		elseif($sColor == "red") echo "<tr><td valign = \"center\" align = \"center\" class = \"red\">$iNumber</td></tr>";
		else echo "<tr><td valign = \"center\" align = \"center\" class = \"groen\">$iNumber</td></tr>";
		echo "</table>";


		//nummer check
		$p_number = 0;
		for($i=1;$i<=36;$i++){
			if($_POST[$i] != "" && $i == $iNumber){
				$p_number = $_POST[$i] * 36;
				break;
			}
		}

		//color check
		$p_color = 0;
		if($_POST['40'] != "" && $sColor == "black"){
			$p_color = $_POST['40'] * 2;
		}
		if($_POST['42'] != "" && $sColor == "red"){
			$p_color = $_POST['42'] * 2;
		}

		//1-18 and 19-36
		$p_half = 0;
		if($iNumber >=1 && $iNumber <=18 && $_POST['37'] != ""){
			$p_half = $_POST['37'] * 2;
		}elseif($iNumber >=19 && $iNumber <=36 && $_POST['45'] != ""){
			$p_half = $_POST['45'] * 2;
		}

		//even and odd
		$p_even_odd = 0;
		if($iNumber % 2 == 0 && $_POST['39'] != ""){
			$p_even_odd  = $_POST['39'] * 2;
		}elseif($iNumber % 2 != 0 && $_POST['43'] != ""){
			$p_even_odd  = $_POST['43'] * 2;
		}

		//1-12, 13-24, 25-36
		$p_parts = 0;
		if($iNumber >=1 && $iNumber <=12 && $_POST['38'] != ""){
			$p_parts = $_POST['38'] * 3;
		}elseif($iNumber >=13 && $iNumber <=24 && $_POST['41'] != ""){
			$p_parts = $_POST['41'] * 3;
		}elseif($iNumber >=25 && $iNumber <=36 && $_POST['44'] != ""){
			$p_parts = $_POST['44'] * 3;
		}

		//2 to 1
		$p_2to1 = 0;
		switch($iNumber){
			case 1: case 4: case 7: case 10: case 13: case 16: case 19: case 22: case 25:
			case 28: case 31: case 34: {
				if($_POST['46'] != "") $p_2to1 = $_POST['46'] * 3;
				break;
			}
			case 2: case 5: case 8: case 11: case 14: case 17: case 20: case 23: case 26:
			case 29: case 32: case 35:{
				if($_POST['47'] != "") $p_2to1 = $_POST['47'] * 3;
				break;
			}
			case 3: case 6: case 9: case 12: case 15: case 18: case 21: case 24: case 27:
			case 30: case 33: case 36:{
				if($_POST['48']!= "") $p_2to1 = $_POST['48'] * 3;
				break;
			}
		}

		$enigewinst = $p_color + $p_number + $p_half + $p_even_odd + $p_parts + $p_2to1;
		$erbij = $p_color + $p_number + $p_half + $p_even_odd + $p_parts + $p_2to1 - $iBet;

		if($enigewinst > 0){
			if($erbij == 0) echo "<br><b>Je hebt teruggespeeld</b>";
			else {
				if($erbij > 0){
					echo "<br><b>Je zette  €".number_format($iBet, 0, ',', '.')." in en won €".number_format(($erbij + $iBet), 0, ',', '.').".</b>";
				}else{
					echo "<br><b>Je zette €".number_format($iBet, 0, ',', '.')." in en won €".number_format(($enigewinst	), 0, ',', '.').".</b>";
				}
				$_SESSION['yourmoney'] = $_SESSION['yourmoney'] + $erbij;

			}
		}else {
			echo "<br><b>Je zette €".number_format($iBet, 0, ',', '.')." in en verloor €".number_format(($erbij * -1), 0, ',', '.').".</b>";
			$_SESSION['yourmoney'] = $_SESSION['yourmoney'] + $erbij;
		}

		//	echo "<br><br>nummerwinst : $p_number<br>colorwinst: $p_color<br>half winst: $p_half<br>even/odd: $p_even_odd<br>parts: $p_parts<br>2to1: $p_2to1<br><br>";
	}
	unset($_POST);
}


echo "<br><table align = \"center\" width=\"300\" border=\"1\" cellpadding=\"0\" cellspacing=\"0\">
<tr class = \"tr3\"><td colspan = 2><b>Roulette</b></td></tr>
<tr><td class = \"tr2\"><b>Maxbet:</b></td><td class = \"tr1\">&nbsp;€".number_format($iMaxbet, 0, ',', '.')."</td></tr>
<tr><td class = \"tr2\"><b>Jij hebt:</b></td><td class = \"tr1\">&nbsp;€".number_format($_SESSION['yourmoney'],0, ',', '.')."</td></tr>
</table>";
?>
[code]

<form method="post">
  <table width="50%" border="0" align="center" cellpadding="2" cellspacing="0">
    <tr>
      <td align="center" valign="middle" bgcolor="#333366" class="board"><br>
        <table width="250" border="0" cellpadding="2" cellspacing="0">
          <tr>
            <td colspan="2" align="center" valign="middle" class="board">&nbsp;</td>
            <td colspan="3" align="center" valign="middle" class="groen">0</td>
          </tr>
          <tr>
            <td width="50" rowspan="2" align="center" valign="middle" bgcolor="#666699" class="wit">1-18<br>
              <input onKeyPress="return numbersonly(this, event)" style="height:15px; width:45px" type="text" name="37" maxlength="8" class="input"></td>
            <td width="50" rowspan="4" align="center" class="wit">1st<br>12<br>
              <input onKeyPress="return numbersonly(this, event)" onKeyPress="return numbersonly(this, event)" style="height:15px; width:45px " type="text" name="38" maxlength="8" class="input"></td>
            <td width="50" align="center" valign="middle" class="red"> 1<br>
              <input onKeyPress="return numbersonly(this, event)" onKeyPress="return numbersonly(this, event)" style="height:15px; width:45px" type="text" name="1" maxlength="8" class="input"></td>
            <td width="50" align="center" valign="middle" class="black"> 2<br>
              <input onKeyPress="return numbersonly(this, event)" style="height:15px; width:45px" type="text" name="2" maxlength="8" class="input"></td>
            <td width="50" align="center" valign="middle" class="red"> 3<br>
              <input onKeyPress="return numbersonly(this, event)" style="height:15px; width:45px" type="text" name="3" maxlength="8" class="input"></td>
          </tr>
          <tr>
            <td width="50" align="center" valign="middle" class="black"> 4<br>
              <input onKeyPress="return numbersonly(this, event)" style="height:15px; width:45px" type="text" name="4" maxlength="8" class="input"></td>
            <td width="50" align="center" valign="middle" class="red"> 5<br>
              <input onKeyPress="return numbersonly(this, event)" style="height:15px; width:45px" type="text" name="5" maxlength="8" class="input"></td>
            <td width="50" align="center" valign="middle" class="black"> 6<br>
              <input onKeyPress="return numbersonly(this, event)" style="height:15px; width:45px" type="text" name="6" maxlength="8" class="input"></td>
          </tr>
          <tr>
            <td width="50" rowspan="2" align="center" valign="middle" class="wit">Even<br>
                  <input onKeyPress="return numbersonly(this, event)" style="height:15px; width:45px" type="text" name="39" maxlength="8" class="input"></td>
            <td width="50" align="center" valign="middle" class="red"> 7<br>
              <input onKeyPress="return numbersonly(this, event)" style="height:15px; width:45px" type="text" name="7" maxlength="8" class="input"></td>
            <td width="50" align="center" valign="middle" class="black"> 8<br>
              <input onKeyPress="return numbersonly(this, event)" style="height:15px; width:45px" type="text" name="8" maxlength="8" class="input"></td>
            <td width="50" align="center" valign="middle" class="red"> 9<br>
              <input onKeyPress="return numbersonly(this, event)" style="height:15px; width:45px" type="text" name="9" maxlength="8" class="input"></td>
          </tr>
          <tr>
            <td width="50" align="center" valign="middle" class="red"> 10<br>
                <input onKeyPress="return numbersonly(this, event)" style="height:15px; width:45px" type="text" name="10" maxlength="8" class="input"></td>
            <td width="50" align="center" valign="middle" class="black"> 11<br>
              <input onKeyPress="return numbersonly(this, event)" style="height:15px; width:45px" type="text" name="11" maxlength="8" class="input"></td>
            <td width="50" align="center" valign="middle" class="red"> 12<br>
              <input onKeyPress="return numbersonly(this, event)" style="height:15px; width:45px" type="text" name="12" maxlength="8" class="input"></td>
          </tr>
          <tr>
            <td width="50" rowspan="2" align="center" valign="middle" class="black">Black<br>
                  <input onKeyPress="return numbersonly(this, event)" style="height:15px; width:45px" type="text" name="40" maxlength="8" class="input"></td>
            <td width="50" rowspan="4" align="center" bgcolor="#003366" class="wit">2nd<br>
              12<br>
              <input onKeyPress="return numbersonly(this, event)" style="height:15px; width:45px" type="text" name="41" maxlength="8" class="input"></td>
            <td width="50" align="center" valign="middle" class="black"> 13<br>
              <input onKeyPress="return numbersonly(this, event)" style="height:15px; width:45px" type="text" name="13" maxlength="8" class="input"></td>
            <td width="50" align="center" valign="middle" class="red"> 14<br>
              <input onKeyPress="return numbersonly(this, event)" style="height:15px; width:45px" type="text" name="14" maxlength="8" class="input"></td>
            <td width="50" align="center" valign="middle" class="black"> 15<br>
              <input onKeyPress="return numbersonly(this, event)" style="height:15px; width:45px" type="text" name="15" maxlength="8" class="input"></td>
          </tr>
          <tr>
            <td width="50" align="center" valign="middle" class="red"> 16<br>
              <input onKeyPress="return numbersonly(this, event)" style="height:15px; width:45px" type="text" name="16" maxlength="8" class="input"></td>
            <td width="50" align="center" valign="middle" class="black"> 17<br>
              <input onKeyPress="return numbersonly(this, event)" style="height:15px; width:45px" type="text" name="17" maxlength="8" class="input"></td>
            <td width="50" align="center" valign="middle" class="red"> 18<br>
              <input onKeyPress="return numbersonly(this, event)" style="height:15px; width:45px" type="text" name="18" maxlength="8" class="input"></td>
          </tr>
          <tr>
            <td width="50" rowspan="2" align="center" valign="middle" class="red">Red<br>
                  <input onKeyPress="return numbersonly(this, event)" style="height:15px; width:45px" type="text" name="42" maxlength="8" class="input"></td>
            <td width="50" align="center" valign="middle" class="red"> 19<br>
              <input onKeyPress="return numbersonly(this, event)" style="height:15px; width:45px" type="text" name="19" maxlength="8" class="input"></td>
            <td width="50" align="center" valign="middle" class="black"> 20<br>
              <input onKeyPress="return numbersonly(this, event)" style="height:15px; width:45px" type="text" name="20" maxlength="8" class="input"></td>
            <td width="50" align="center" valign="middle" class="red"> 21<br>
              <input onKeyPress="return numbersonly(this, event)" style="height:15px; width:45px" type="text" name="21" maxlength="8" class="input"></td>
          </tr>
          <tr>
            <td width="50" align="center" valign="middle" class="black"> 22<br>
              <input onKeyPress="return numbersonly(this, event)" style="height:15px; width:45px" type="text" name="22" maxlength="8" class="input"></td>
            <td width="50" align="center" valign="middle" class="red"> 23<br>
              <input onKeyPress="return numbersonly(this, event)" style="height:15px; width:45px" type="text" name="23" maxlength="8" class="input"></td>
            <td width="50" align="center" valign="middle" class="black"> 24<br>
              <input onKeyPress="return numbersonly(this, event)" style="height:15px; width:45px" type="text" name="24" maxlength="8" class="input"></td>
          </tr>
          <tr>
            <td width="50" rowspan="2" align="center" valign="middle" class="wit">Odd<br>
                  <input onKeyPress="return numbersonly(this, event)" style="height:15px; width:45px" type="text" name="43" maxlength="8" class="input"></td>
            <td width="50" rowspan="4" align="center" class="wit"> 3rd<br>
              12<br>
              <input onKeyPress="return numbersonly(this, event)" style="height:15px; width:45px" type="text" name="44" maxlength="8" class="input"></td>
            <td width="50" align="center" valign="middle" class="red"> 25<br>
              <input onKeyPress="return numbersonly(this, event)" style="height:15px; width:45px" type="text" name="25" maxlength="8" class="input"></td>
            <td width="50" align="center" valign="middle" class="black"> 26<br>
              <input onKeyPress="return numbersonly(this, event)" style="height:15px; width:45px" type="text" name="26" maxlength="8" class="input"></td>
            <td width="50" align="center" valign="middle" class="red"> 27<br>
              <input onKeyPress="return numbersonly(this, event)" style="height:15px; width:45px" type="text" name="27" maxlength="8" class="input"></td>
          </tr>
          <tr>
            <td width="50" align="center" valign="middle" class="black"> 28<br>
              <input onKeyPress="return numbersonly(this, event)" style="height:15px; width:45px" type="text" name="28" maxlength="8" class="input"></td>
            <td width="50" align="center" valign="middle" class="black"> 29<br>
              <input onKeyPress="return numbersonly(this, event)" style="height:15px; width:45px" type="text" name="29" maxlength="8" class="input"></td>
            <td width="50" align="center" valign="middle" class="red"> 30<br>
              <input onKeyPress="return numbersonly(this, event)" style="height:15px; width:45px" type="text" name="30" maxlength="8" class="input"></td>
          </tr>
          <tr>
            <td width="50" rowspan="2" align="center" valign="middle" class="wit">19-36<br>
              <input onKeyPress="return numbersonly(this, event)" style="height:15px; width:45px" type="text" name="45" maxlength="8" class="input"></td>
            <td width="50" align="center" valign="middle" class="black"> 31<br>
              <input onKeyPress="return numbersonly(this, event)" style="height:15px; width:45px" type="text" name="31" maxlength="8" class="input"></td>
            <td width="50" align="center" valign="middle" class="red"> 32<br>
              <input onKeyPress="return numbersonly(this, event)" style="height:15px; width:45px" type="text" name="32" maxlength="8" class="input"></td>
            <td width="50" align="center" valign="middle" class="black"> 33<br>
              <input onKeyPress="return numbersonly(this, event)" style="height:15px; width:45px" type="text" name="33" maxlength="8" class="input"></td>
          </tr>
          <tr>
            <td width="50" align="center" valign="middle" class="red"> 34<br>
              <input onKeyPress="return numbersonly(this, event)" style="height:15px; width:45px" type="text" name="34" maxlength="8" class="input"></td>
            <td width="50" align="center" valign="middle" class="black"> 35<br>
              <input onKeyPress="return numbersonly(this, event)" style="height:15px; width:45px" type="text" name="35" maxlength="8" class="input"></td>
            <td width="50" align="center" valign="middle" class="red"> 36<br>
              <input onKeyPress="return numbersonly(this, event)" style="height:15px; width:45px" type="text" name="36" maxlength="8" class="input"></td>
          </tr>
          <tr>
            <td colspan="2" align="center" valign="middle" class="board">&nbsp;</td>
            <td width="50" align="center" valign="middle" class="wit"> 2 to 1<br>
              <input onKeyPress="return numbersonly(this, event)" style="height:15px; width:45px" type="text" name="46" maxlength="8" class="input"></td>
            <td width="50" align="center" valign="middle" class="wit"> 2 to 1<br>
              <input onKeyPress="return numbersonly(this, event)" style="height:15px; width:45px" type="text" name="47" maxlength="8" class="input"></td>
            <td width="50" align="center" valign="middle" class="wit"> 2 to 1<br>
              <input onKeyPress="return numbersonly(this, event)" style="height:15px; width:45px" type="text" name="48" maxlength="8" class="input"></td>
          </tr>
          <tr>
            <td colspan="2" align="center" valign="middle" class="board">&nbsp;</td>
            <td colspan="3" align="center" valign="middle" class="board"><br>
              <input onKeyPress="return numbersonly(this, event)" name="gok" type="submit" class="input" value="Gamble!">&nbsp;&nbsp;<input onKeyPress="return numbersonly(this, event)" name="reset" type="reset" class="input" value="Reset"><input onKeyPress="return numbersonly(this, event)" name="reset2" type="submit" class="input" value="Reset Geld!"></td>
          </tr>
          </tr>
        </table>
      <br></td>
    </tr>
  </table>
  <br>
</form>
[/code]