<?php
ob_start();
include_once('_include-config.php');
include("functie_euros.php");
	if(! check_login()){
	header("Location: login.php");
	exit;
	}

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

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

$dbres	=	mysql_query("SELECT `Wiet`,`Hasj`,`Coke` FROM `drugs` WHERE `land`='{$data->land}'");
$drugs	=	mysql_fetch_object($dbres);
$prijs1	=	$drugs->Wiet;
$prijs2	=	$drugs->Hasj;
$prijs3	=	$drugs->Coke;

	if($data->rank == "Junkie"){
	$rank		=	1000;
	$drugs_max	=	1;
	} else if($data->rank == "Straatrat"){
	$rank		=	500;
	$drugs_max	=	2;
	} else if($data->rank == "Dief"){
	$rank		=	250;
	$drugs_max	=	3;
	} else if($data->rank == "Wietkweker"){
	$rank		=	100;
	$drugs_max	=	5;
	} else if($data->rank == "Drugsdealer"){
	$rank		=	90;
	$drugs_max	=	15;
	} else if($data->rank == "Gangster"){
	$rank		=	80;
	$drugs_max	=	25;
	} else if($data->rank == "Handelaar"){
	$rank		=	70;
	$drugs_max	=	50;
	} else if($data->rank == "Arbeider"){
	$rank		=	60;
	$drugs_max	=	75;
	} else if($data->rank == "Manager"){
	$rank		=	50;
	$drugs_max	=	150;
	} else if($data->rank == "Baas Stadsnetwerk"){
	$rank		=	40;
	$drugs_max	=	250;
	} else if($data->rank == "Huurmoordenaar"){
	$rank		=	30;
	$drugs_max	=	500;
	} else if($data->rank == "Nationaal crimineel"){
	$rank		=	20;  
	$drugs_max	=	1000;
	} else if($data->rank == "Internationaal Crimineel"){
	$rank		=	10;
	$drugs_max	=	2500;
	} else if($data->rank == "Lid Grote Raad"){
	$drugs_max	=	5000;
	}


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

?>

<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">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="description" content="Ultimatecrime is een gratis online multiplayer spel! Ontwikkel je eigen crimineel door verschillende criminele activiteiten te doen! Speel met duizenden andere criminelen en wordt nummer 1!">
<meta name="keywords" content="world, gangster, criminal, mafia, games, game, multiplayer, rpg, mmorpg, online game, online multiplayer">
<meta name="Robots" CONTENT="follow">
<meta name="REVISIT-AFTER" CONTENT="7 days">
<br>
<br>
<br>
<form method="post" action="handel-drugs.php?code=<?php echo $getalb; ?>" onSubmit="return submitForm(this.submit);">
<table align="center" width="600">
	<tr>
		<td class="subTitle" colspan="3">
		<b>Drugshandel - <?php echo $data->land; ?></b>
		</td>
	</tr>
	<tr>
		<td class="mainTxt" colspan="3">

<?php

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

	if($member->wachttijd_drugs + 120 > time()){

	$totaal		=	$member->wachttijd_drugs + 120 - time() - 3600;
	$tijd		=	date("i:s", "$totaal");
	echo "<center>Je moet nog $tijd seconden wachten voordat je weer kan dealen.";
	exit;
	}

?>
		<table width="560" border="0" cellspacing="0" cellpadding="0">
			<tr>
				<td width="25"><img src="layout/images/icons/light_usergo.jpg" width="16" height="16"></td>
				<td>[<font color="#00FF00"><b><?php echo $data->drugs1; ?> kg wiet</b></font>] - [<font color="#00FF00"><b><?php echo $data->drugs2; ?> kg hasj</b></font>] - [<font color="#00FF00"><b><?php echo $data->drugs3; ?> kg coke</b></font>]&nbsp;&nbsp;&nbsp;<i>Max <?php echo $drugs_max; ?> kg</i></td>
			</tr>
		</table>
		</td>
	</tr>

<?php

	if(isset($_POST['submit'])){

		if($_POST['type'] == 1){
			if($_POST['aantal'] < 0){
			exit;
			}
			if($_POST['aantal']+$data->drugs1+$data->drugs2+$data->drugs3 <= $drugs_max){

				if($_POST['drug'] == 1){
				$prijs	=	$_POST['aantal']*$prijs1;
				} else if($_POST['drug'] == 2){
				$prijs	=	$_POST['aantal']*$prijs2;
				} else {
				$prijs	=	$_POST['aantal']*$prijs3;
				}

				if($prijs <= $data->cash){

				$kans	=	mt_rand(1,3);

					if($kans != 1){

						if($_POST['drug'] == 1){
						mysql_query("UPDATE `gebruiker` SET `wachttijd_drugs`=NOW(),`rankvordering`=`rankvordering`+'$rank',`drugs1`=`drugs1`+'{$_POST['aantal']}',`cash`=`cash`-'$prijs' WHERE `login`='{$data->login}'");

?>

	<tr>
		<td class="mainTxt" colspan="3">
		<table width="560" border="0" cellspacing="0" cellpadding="0">
			<tr>
				<td width="25" valign="top"><img src="layout/images/icons/light_vink.jpg" width="16" height="16"></td>
				<td><strong class="tekstheader">Lekker bezig!</strong></td>
			</tr>
			<tr>
				<td>&nbsp;</td><td>Je kocht <?php echo $_POST['aantal']; ?> kilo wiet voor &euro; <?php echo geld($prijs); ?>!<br /><br />Goed bezig!<br /><br /><i>Probeer alleen om er met je tengels vanaf te blijven!<br />Voordat je het weet gaat het in rook op!</i></td>
			</tr>
		</table>
		</td>
	</tr>

<?php

						} else if($_POST['drug'] == 2){
						mysql_query("UPDATE `gebruiker` SET `wachttijd_drugs`=NOW(),`rankvordering`=`rankvordering`+'$rank',`drugs2`=`drugs2`+'{$_POST['aantal']}',`cash`=`cash`-'$prijs' WHERE `login`='{$data->login}'");

?>

	<tr>
		<td class="mainTxt" colspan="3">
		<table width="560" border="0" cellspacing="0" cellpadding="0">
			<tr>
				<td width="25" valign="top"><img src="layout/images/icons/light_vink.jpg" width="16" height="16"></td>
				<td><strong class="tekstheader">Lekker bezig!</strong></td>
			</tr>
			<tr>
				<td>&nbsp;</td><td>Je kocht <?php echo $_POST['aantal']; ?> kilo hasj voor &euro; <?php echo geld($prijs); ?>!<br /><br />Goed bezig!<br /><br /><i>Probeer alleen om er met je tengels vanaf te blijven!<br />Voordat je het weet gaat het in rook op!</i></td>
			</tr>
		</table>
		</td>
	</tr>

<?php

						} else {
						mysql_query("UPDATE `gebruiker` SET `wachttijd_drugs`=NOW(),`rankvordering`=`rankvordering`+'$rank',`drugs3`=`drugs3`+'{$_POST['aantal']}',`cash`=`cash`-'$prijs' WHERE `login`='{$data->login}'");

?>

	<tr>
		<td class="mainTxt" colspan="3">
		<table width="560" border="0" cellspacing="0" cellpadding="0">
			<tr>
				<td width="25" valign="top"><img src="layout/images/icons/light_vink.jpg" width="16" height="16"></td>
				<td><strong class="tekstheader">Lekker bezig!</strong></td>
			</tr>
			<tr>
				<td>&nbsp;</td><td>Je kocht <?php echo $_POST['aantal']; ?> kilo coke voor &euro; <?php echo geld($prijs); ?>!<br /><br />Goed bezig!<br /><br /><i>Probeer alleen om er met je tengels vanaf te blijven!<br />Het verdwijnt als sneeuw voor de zon!</i></td>
			</tr>
		</table>
		</td>
	</tr>

<?php

						}

					} else {
					mysql_query("UPDATE `gebruiker` SET `gevangenistijd`='300',`gevangenis`=NOW() WHERE `login`='{$data->login}'");


?>

	<tr>
		<td class="mainTxt" colspan="3">
		<table width="560" border="0" cellspacing="0" cellpadding="0">
			<tr>
				<td width="25" valign="top"><img src="layout/images/icons/light_error.jpg" width="16" height="16"></td>
				<td><strong class="header_rood">Je bent gepakt door de smeris!</strong></td>
			</tr>
			<tr>
				<td>&nbsp;</td><td>Je rende wat je kon, smeet nog snel de drugs op een veilige plek en struikeltje later over een steentje...</td>
			</tr>
		</table>
		</td>
	</tr>

<?php

					}

				} else {

?>

	<tr>
		<td class="mainTxt" colspan="3">
		<table width="560" border="0" cellspacing="0" cellpadding="0">
			<tr>
				<td width="25" valign="top"><img src="layout/images/icons/light_error.jpg" width="16" height="16"></td>
				<td><strong class="header_rood">Je hebt niet genoeg geld!</strong></td>
			</tr>
			<tr>
				<td>&nbsp;</td><td>Probeer eerst een wat geld te stelen!</td>
			</tr>
		</table>
		</td>
	</tr>

<?php

				}

			} else {

?>

	<tr>
		<td class="mainTxt" colspan="3">
		<table width="560" border="0" cellspacing="0" cellpadding="0">
			<tr>
				<td width="25" valign="top"><img src="layout/images/icons/light_error.jpg" width="16" height="16"></td>
				<td><strong class="header_rood">Teveel drugs voor jou!</strong></td>
			</tr>
			<tr>
				<td>&nbsp;</td><td>Je mag maar <?php echo $drugs_max; ?> kilo drugs op zak hebben!</td>
			</tr>
		</table>
		</td>
	</tr>

<?php

			}

		} else {

			if($_POST['drug'] == 1){
			$aantal	=	$data->drugs1;
			} else if($_POST['drug'] == 2){
			$aantal	=	$data->drugs2;
			} else {
			$aantal	=	$data->drugs3;
			}

			if($_POST['aantal'] <= $aantal){

				if($_POST['aantal'] < 0){
				exit;
				}

				if($_POST['drug'] == 1){
				$prijs	=	$_POST['aantal']*$prijs1;
				} else if($_POST['drug'] == 2){
				$prijs	=	$_POST['aantal']*$prijs2;
				} else {
				$prijs	=	$_POST['aantal']*$prijs3;
				}

			$kans	=	mt_rand(1,3);

				if($kans != 1){

						if($_POST['drug'] == 1){
						mysql_query("UPDATE `gebruiker` SET `wachttijd_drugs`=NOW(),`rankvordering`=`rankvordering`+'$rank',`drugs1`=`drugs1`-'{$_POST['aantal']}',`cash`=`cash`+'$prijs' WHERE `login`='{$data->login}'");

?>

	<tr>
		<td class="mainTxt" colspan="3">
		<table width="560" border="0" cellspacing="0" cellpadding="0">
			<tr>
				<td width="25" valign="top"><img src="layout/images/icons/light_vink.jpg" width="16" height="16"></td>
				<td><strong class="tekstheader">Lekker bezig!</strong></td>
			</tr>
			<tr>
				<td>&nbsp;</td><td>Je verkocht <?php echo $_POST['aantal']; ?> kilo wiet voor &euro; <?php echo geld($prijs); ?>!<br /><br />Goed bezig!</td>
			</tr>
		</table>
		</td>
	</tr>

<?php

						} else if($_POST['drug'] == 2){
						mysql_query("UPDATE `gebruiker` SET `wachttijd_drugs`=NOW(),`rankvordering`=`rankvordering`+'$rank',`drugs2`=`drugs2`-'{$_POST['aantal']}',`cash`=`cash`+'$prijs' WHERE `login`='{$data->login}'");

?>

	<tr>
		<td class="mainTxt" colspan="3">
		<table width="560" border="0" cellspacing="0" cellpadding="0">
			<tr>
				<td width="25" valign="top"><img src="layout/images/icons/light_vink.jpg" width="16" height="16"></td>
				<td><strong class="tekstheader">Lekker bezig!</strong></td>
			</tr>
			<tr>
				<td>&nbsp;</td><td>Je verkocht <?php echo $_POST['aantal']; ?> kilo hasj voor &euro; <?php echo geld($prijs); ?>!<br /><br />Goed bezig!</td>
			</tr>
		</table>
		</td>
	</tr>

<?php

						} else {
						mysql_query("UPDATE `gebruiker` SET `wachttijd_drugs`=NOW(),`rankvordering`=`rankvordering`+'$rank',`drugs3`=`drugs3`-'{$_POST['aantal']}',`cash`=`cash`+'$prijs' WHERE `login`='{$data->login}'");

?>

	<tr>
		<td class="mainTxt" colspan="3">
		<table width="560" border="0" cellspacing="0" cellpadding="0">
			<tr>
				<td width="25" valign="top"><img src="layout/images/icons/light_vink.jpg" width="16" height="16"></td>
				<td><strong class="tekstheader">Lekker bezig!</strong></td>
			</tr>
			<tr>
				<td>&nbsp;</td><td>Je verkocht <?php echo $_POST['aantal']; ?> kilo coke voor &euro; <?php echo geld($prijs); ?>!<br /><br />Goed bezig!</td>
			</tr>
		</table>
		</td>
	</tr>

<?php

						}

				} else {
				mysql_query("UPDATE `gebruiker` SET `gevangenistijd`='300',`gevangenis`=NOW() WHERE `login`='{$data->login}'");


?>

	<tr>
		<td class="mainTxt" colspan="3">
		<table width="560" border="0" cellspacing="0" cellpadding="0">
			<tr>
				<td width="25" valign="top"><img src="layout/images/icons/light_error.jpg" width="16" height="16"></td>
				<td><strong class="header_rood">Je bent gepakt door de smeris!</strong></td>
			</tr>
			<tr>
				<td>&nbsp;</td><td>Je rende wat je kon, smeet nog snel de drugs op een veilige plek en struikeltje later over een steentje...</td>
			</tr>
		</table>
		</td>
	</tr>

<?php

				}


			} else {

?>

	<tr>
		<td class="mainTxt" colspan="3">
		<table width="560" border="0" cellspacing="0" cellpadding="0">
			<tr>
				<td width="25" valign="top"><img src="layout/images/icons/light_error.jpg" width="16" height="16"></td>
				<td><strong class="header_rood">Te weinig drugs!</strong></td>
			</tr>
			<tr>
				<td>&nbsp;</td><td>Je hebt niet zoveel drugs om te verkopen!</td>
			</tr>
		</table>
		</td>
	</tr>

<?php

			}
		}
	}

?>
	<tr>
		<td class="subtitle" colspan="3">&nbsp;</td>
	</tr>
	<tr>
		<td class="maintxt" colspan="3">
		<table width="560" border="0" cellspacing="0" cellpadding="0">
			<tr>
				<td width="25"><img src="layout/images/icons/light_pill.jpg" width="16" height="16"></td>
				<td width="125"><select name="type" class="form_dropdown" id="type" style="width:100;"><option value="1" selected>Koop</option><option value="2">Verkoop</option></select></td>
				<td width="105"><input name="aantal" type="text" id="aantal" maxlength="5" style="width:100;"></td>
				<td width="30">kg</td>
				<td>
				<select name="drug" class="form_dropdown" style="width:250;">
				<option value="1">Thuiskweek wiet - &euro; <?php echo geld($prijs1); ?> kg</option>
				<option value="2" selected>Isolater hasj - &euro; <?php echo geld($prijs2); ?> kg</option>
				<option value="3">Pure cocaine - &euro; <?php echo geld($prijs3); ?> kg</option>
				</select>
				</td>
			</tr>
			<tr>
				<td>&nbsp;</td>
				<td colspan="4">&nbsp;</td>
			</tr>
			<tr>
				<td>&nbsp;</td>
				<td colspan="2" valign="middle"><input name="submit" type="submit" id="submit" value="Sluit de deal!" style="width: 200;"></td>
				<td colspan="2"></td>
			</tr>
		</table>
		</td>
	</tr>
	<tr>
		<td class="subtitle" colspan="3">&nbsp;</td>
	</tr>
</table>
</form>
</body>
</html>

