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

	if($data->level != 3){
	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">
		Admin - Donatie	
		</td>
	</tr>
	<tr>
		<td align="center" class="mainTxt">

<?php

	if(isset($_POST['submit1'])) {
	$dbres		=	mysql_query("SELECT `login` FROM `gebruiker` WHERE `login`='{$_POST['to']}' AND `level`!='0' AND `level`!='-1' AND `level`!='-2'");
	$member		=	mysql_fetch_object($dbres);
	$rijen		=	mysql_num_rows($dbres);
		if($_POST['amount'] < 1) {
		print"Wel boven de 0 euro doneren.<meta http-equiv=\"refresh\" content=\"3\">";
		} else if($rijen == 0){
		print"Deze gebruiker bestaat niet is verbannen of is dood.<meta http-equiv=\"refresh\" content=\"3\">";
		} else if($member->login == $data->login){
		print"Beveileging: Je kunt als admin niet jezelf doneren.<meta http-equiv=\"refresh\" content=\"3\">";
		} else {
		mysql_query("UPDATE `gebruiker` SET `bank`=`bank`+'{$_POST['amount']}' WHERE `login`='{$member->login}'");
		mysql_query("INSERT INTO `logs`(`time`,`ip`,`van`,`naar`,`bedrag`,`message`) VALUES(NOW(),'{$_SERVER['REMOTE_ADDR']}','ultimatecrime','{$member->login}','{$_POST['amount']}','Het zal wel ergens goed voor zijn hè...')"); 
		$geld	=	geld($_POST['amount']);
		print"Er is €{$geld} aan {$member->login} gedoneerd.<meta http-equiv=\"refresh\" content=\"3\">";
		}
	} else {

?>

		<form method="post">
		<table>
			<tr>
				<td width=100>Aan:</td>
				<td><input type="text" name="to"></td>
			</tr>
			<tr>
				<td width=100>Bedrag:</td>  	
				<td><input type="text" name="amount"></td>
			</tr>
			<tr>
				<td></td>  
				<td align="right"><input type="submit" name="submit1" value="Doneer" style="width: 75px;"></td>
			</tr>
		</table>
		</form>

<?php

	}

?>

		</td>

	</tr>
	<tr>
		<td class="subTitle"&nbsp;</td>
	</tr>
</table>
<br>
<table align="center" width="600">
	<tr>
		<td class="subTitle">
		Admin - Geld versnipperaar
		</td>
	</tr>
	<tr>
		<td align="center" class="mainTxt">

<?php

	if(isset($_POST['submit2'])){
	$dbres		=	mysql_query("SELECT `login`,`bank` FROM `gebruiker` WHERE `login`='{$_POST['to']}' AND `level`!='0' AND `level`!='-1' AND `level`!='-2'");
	$member		=	mysql_fetch_object($dbres);
	$rijen		=	mysql_num_rows($dbres);
		if($_POST['amount'] < 1) {
		print"Wel boven de 0 euro versnipperen.<meta http-equiv=\"refresh\" content=\"3\">";
		} else if($rijen == 0){
		print"Deze gebruiker bestaat niet is verbannen of is dood.<meta http-equiv=\"refresh\" content=\"3\">";
		} else if($member->bank-$_POST['amount'] < 1){
		print"Deze gebruiker heeft slechts €". geld($member->bank) . " op de bank staan.<meta http-equiv=\"refresh\" content=\"3\">";
		} else {
		mysql_query("UPDATE `gebruiker` SET `bank`=`bank`-'{$_POST['amount']}' WHERE `login`='{$member->login}'");
		$geld	=	geld($_POST['amount']);
		print"Er is €{$geld} van {$member->login} versnippert.<meta http-equiv=\"refresh\" content=\"3\">";
		}

	} else {

?>

		<form method="post">
		<table>
			<tr>
				<td width=100>Van:</td>
				<td><input type="text" name="to"></td>
			</tr>
			<tr>
				<td width=100>Bedrag:</td>  	
				<td><input type="text" name="amount"></td>
			</tr>
			<tr>
				<td></td>  
				<td align="right"><input type="submit" name="submit2" value="Versnipper" style="width: 75px;"></td>
			</tr>
		</table>
		</form>

<?php

	}

?>

		</td>

	</tr>
	<tr>
		<td class="subTitle">&nbsp;</td>
	</tr>

<?php

	$dbres		=	mysql_query("SELECT *,DATE_FORMAT(`time`,'%d-%m-%Y %H:%i') AS `time` FROM `logs` WHERE `van`='ultimatecrime' ORDER BY `id` DESC LIMIT 100");

?>

	<tr>
		<td>&nbsp;</td>
	</tr>
	<tr>
		<td class="subtitle" align="center">Laatste donaties</td>
	</tr>
	<tr>
		<td class="mainTxt">

<?php

		while($info = mysql_fetch_object($dbres)){

?>
		<table width="565" border="0" align="center" cellpadding="0" cellspacing="0">
			<tr>
				<td width="25" valign="top"><img src="layout/images/icons/light_money_plus.jpg" width="16" height="16"></td>
				<td width="190"><a href="speler-profiel.php?x=<?php echo $info->naar; ?>" target="content"><strong><?php echo $info->naar; ?></strong></a></td>
				<td><strong><?php echo $info->time; ?></strong></td>
				<td align="right"><strong>&euro; <?php echo geld($info->bedrag); ?></strong></td>
			</tr>
			</tr>
			<tr>
				<td width="25"></td>
				<td colspan="3"><i><?php echo $info->message; ?></i></td>
			</tr>
			<tr>
				<td colspan="4">&nbsp;</td>
			</tr>
		</table>

<?php

		}

?>

		&nbsp;</td>
	</tr>
</table>
</body>
</html>