<?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>
<form method="post">
<table align="center" width="600">
	<tr>
		<td class="subTitle" width="100%" colspan="5">
		<b>Premielijst</b>
		</td>
	</tr>
	<tr>


<?php

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

?>

	<tr>
		<td class="mainTxt" align="center">

<?php

	$_POST['id']	=	$_POST['id']; 
	$dbres		=	mysql_query("SELECT * FROM `hitlist` WHERE `id`='{$_POST['id']}'"); 
	$controlle	=	mysql_num_rows($dbres); 
	$hitlist	=	mysql_fetch_object($dbres); 

		if($data->cash < ($hitlist->geld*2)){
		echo "Deze persoon kost €" . geld($hitlist->geld*2) . " om uit te kopen.<meta http-equiv=\"refresh\" content=\"3\">";
		} else if($controlle == 0){
		echo "Selecteer wel eerst een gebruiker.<meta http-equiv=\"refresh\" content=\"3\">";
		} else {
		mysql_query("UPDATE `gebruiker` SET `cash`=`cash`-'$geld'-'$geld' WHERE `login`='{$data->login}'"); 
		mysql_query("UPDATE `gebruiker` SET `hitlist`=`hitlist`-'1' WHERE `login`='{$hitlist->naam}'");
		mysql_query("DELETE FROM `hitlist` WHERE `id`='{$_POST['id']}'"); 
		mysql_query("INSERT INTO `berichten`(`tijd`,`ip`,`van`,`naar`,`titel`,`bericht`) VALUES(NOW(),'{$_SERVER['REMOTE_ADDR']}','Ultimatecrime','{$hitlist->naam}','Premielijst','{$data->login} heeft je van de premielijst gekocht.')");
		echo "Je hebt hem succesvol van de premielijst afgekocht.<meta http-equiv=\"refresh\" content=\"3\">";
		}  
	exit;
	} else if(isset($_POST['vt'])){

?>

	<tr>
		<td class="mainTxt" align="center">

<?php

	$_POST['naam']		=	$_POST['naam']; 
	$_POST['anoniem']	=	$_POST['anoniem'];
	$_POST['geld']		=	$_POST['geld'];

		if($_POST['anoniem'] == 0){ 
		$geld		=	round(($_POST['geld']/100)*10); 
		} else {
		$geld 		=	0; 
		}

	$geld			=	$_POST['geld']+$geld; 

	$dbres			=	mysql_query("SELECT * FROM `gebruiker` WHERE `login`='{$_POST['naam']}' AND `level`!='-2' AND `level`!='-1' AND `level`!='0'"); 
	$controlle		=	mysql_num_rows($dbres); 
	$man			=	mysql_fetch_object($dbres); 
	
		if($man->rank == "Junkie"){  
		$rgeld	=	100000;
		} else if($man->rank == "Straatrat"){  
		$rgeld	=	200000;
		} else if($man->rank == "Dief"){ 
		$rgeld	=	300000;
		} else if($man->rank == "Wietkweker"){  
		$rgeld	=	500000;
		} else if($man->rank == "Gangster"){ 
		$rgeld	=	700000;
		} else if($man->rank == "Handelaar"){ 
		$rgeld	=	900000;
		} else if($man->rank == "Arbeider"){ 
		$rgeld	=	1250000;
		} else if($man->rank == "Manager"){ 
		$rgeld	=	1750000;
		} else if($man->rank == "Baas Stadsnetwerk"){  
		$rgeld	=	2250000;
		} else if($man->rank == "Huurmoordenaar"){ 
		$rgeld	=	4000000;
		} else if($man->rank == "Nationaal crimineel"){  
		$rgeld	=	5000000;
		} else if($man->rank == "Internationaal Crimineel"){  
		$rgeld	=	6500000;
		} else if($man->rank == "Lid Grote Raad"){  
		$rgeld	=	10000000;
		}
     
		if($data->cash < $geld){ 
		echo "Voor {$man->login} met de rang {$man->rank} moet je €" . geld($rgeld) . " betalen.<meta http-equiv=\"refresh\" content=\"3\">";
		} else if(! is_numeric($geld)){ 
		echo "Het bedrag wat is ingevoerd bestaat niet helemaal uit cijvers.<meta http-equiv=\"refresh\" content=\"3\">"; 
		} else if($controlle == 0){ 
		echo "Deze gebruiker bestaat niet.<meta http-equiv=\"refresh\" content=\"3\">"; 
		} else if($data->login == $man->login){
		echo "Je kunt jezelf er niet op zetten.<meta http-equiv=\"refresh\" content=\"3\">";
		} else if($geld < $rgeld){ 
		echo "Voor {$man->login} met de rang {$man->rank} moet je €" . geld($rgeld) . " betalen.<meta http-equiv=\"refresh\" content=\"3\">"; 
		} else { 

			if($_POST['anoniem'] == 0){
			$login	=	"Een anoniem iemand";
			} else {
			$login	=	$data->login;
			}

		mysql_query("INSERT INTO `hitlist`(`naam`,`familie`,`geld`,`anoniem`,`invoeger`) values('{$man->login}','{$man->familie}','$geld','$anoniem','{$data->login}')"); 
		mysql_query("UPDATE `gebruiker` SET `hitlist`=`hitlist`+'1' WHERE `login`='{$man->login}'");
		mysql_query("UPDATE `gebruiker` SET `cash`=`cash`-'$geld' WHERE `login`='{$data->login}'"); 
		mysql_query("INSERT INTO `berichten`(`tijd`,`ip`,`van`,`naar`,`titel`,`bericht`) VALUES(NOW(),'{$_SERVER['REMOTE_ADDR']}','Ultimatecrime','{$man->login}','Premielijst','{$login} heeft je op de premielijst gezet.')");
		echo "Je hebt {$man->login} toegevoegd.<meta http-equiv=\"refresh\" content=\"3\">"; 
		}
	exit;
	}

?>


	<tr>
		<td class="subTitle" width="8%">&nbsp;</td>  
		<td class="subTitle" width="23%"><b>Login:</b></td>
		<td class="subTitle" width="23%"><b>Netwerk:</b></td>  
		<td class="subTitle" width="23%"><b>Bedrag:</b></td>  
		<td class="subTitle" width="23%"><b>Plaatser:</b></td>
	</tr>

<?php

$dbres			=	mysql_query("SELECT * FROM `hitlist`");
    
	while($hitlist = mysql_fetch_object($dbres)){

		if($hitlist->familie == "") {
		$familie	=	" - ";
		} else {
		$familie	=	"<a href=\"famprofiel.php?x={$hitlist->familie}\">{$hitlist->familie}</a>";
		}

		if($hitlist->anoniem == 0){
		$plaatser	=	"Anoniem";
		} else {
		$plaatser	=	"<a href=\"speler-profiel.php?x={$hitlist->invoeger}\">{$hitlist->invoeger}</a>";
		}

?>

	<tr>
		<td class="mainTxt" width="8%" align="center"><input type="radio" name="id" value="<?php echo $hitlist->id; ?>"></td>  
		<td class="mainTxt" width="23%" align="center"><a href="speler-profiel.php?x=<?php echo $hitlist->naam; ?>" target="content"><?php echo $hitlist->naam; ?></a></td>  
		<td class="mainTxt" width="23%" align="center"><?php echo $familie; ?></td>  
		<td class="mainTxt" width="23%" align="center">€<?php echo geld($hitlist->geld); ?></td>  
		<td class="mainTxt" width="23%" align="center"><?php echo $plaatser; ?></td>
	</tr>

<?php

	}
     
?>

</table>
<table align="center" width="600">
	<tr>
		<td width="100%"><input type="submit" name="ku" value="Koop vrij" style="width: 150;"></td>
	</tr>
</table>
<br>
<table align="center" width="600">
	<tr>
		<td class="subTitle" width="100%" colspan="5">
		<b>Plaatsen</b>
		</td>
	</tr>
	<tr>
		<td class="mainTxt">
		<table width="62%" border="0" align="center" cellpadding="0" cellspacing="2">
			<tr>
				<td width="49%">Login:</td>
				<td width="51%"><input type="text" name="naam" maxlength="16" style="width: 250;" value="" /></td>
			</tr>
			<tr>
				<td>Bedrag:</td>
				<td><input type="text" name="geld" maxlength="16" style="width: 250;" value="" /></td>
			</tr>
			<tr>
				<td>Anoniem:</td>
				<td>
				<select name="anoniem" style="width:250" class="form_select">
				<option value="1" selected>Ja</option>
				<option value="0">Nee</option>
				</select>
				</td>
			</tr>
			<tr>
				<td>&nbsp;</td>
				<td><input type="submit" name="vt" value="Zoek" style="width: 250;"></td>
			</tr>
		</table>
		</td>
	</tr>
</table>
</form>
</body>
</html>