<?php
ob_start();
include("config.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;
	}

?>

<html>
<head>
<title>Ultimatecrime</title>
<link rel="stylesheet" type="text/css" href="style_general.css">
<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">
</head>
<body background="layout/images/layout_12.gif" bgproperties="fixed">
<br>
<br>
<br>

<table align="center" width="600">
	<tr>
		<td class="subTitle"><b>Ultimatecrime - Respect credits</b></td>
	</tr>
	<tr>
		<td class="mainTxt"><table width="560" border="0" cellspacing="0" cellpadding="0">
			<tr>
				<td width="25"><img src="layout/images/icons/light_respect.jpg" width="16" height="16"></td>
				<td><span class="tekstheader">Uitleg over respect credis in Ultimatecrime</span><span class="tekstheader"> </span></td>
			</tr>
			<tr>
				<td>&nbsp;</td>
				<td><p>Op deze pagina kan jij een andere crimineel respect credits geven. Hiermee toon je ten eerste aan dat jij hem/haar respecteert, maar zet je hem/haar ook in een beter daglicht want het aantal respect credits dat je hebt ontvangen staat op je profiel en hoe hoger, hoe meer voordelen het oplevert. </p></td>
			</tr>
			<tr>
				<td>&nbsp;</td>
				<td>&nbsp;</td>
			</tr>
			<tr>
				<td><img src="layout/images/icons/light_uitroepteken.jpg" width="16" height="16"></td>
				<td><span class="tekstheader">Wanneer en hoeveel respect credits krijg jij om uit te delen?</span></td>
			</tr>
			<tr>
				<td>&nbsp;</td>
				<td>De Grote Raad deelt 1x per week respect credits uit, in de nacht van zondag op maandag om 00.00 uur Ultimatecrime Tijd. <a href="algemeen-help.php?item=faq&word=respect" target="content">Kijk hier hoeveel je krijgt</a>! </td>
			</tr>
		</table></td>
	</tr>
	<tr>
		<td class="subtitle">&nbsp;</td>
	</tr>
	<tr>
		<td class="maintxt"><table width="560" border="0" cellspacing="0" cellpadding="0">

<?php

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

		$_POST['naam']		=	$_POST['naam'];
		$_POST['aantal']	=	$_POST['aantal'];
		$_POST['description']	=	$_POST['description'];

		$dbres			=	mysql_query("SELECT `login` FROM `gebruiker` WHERE `login`='{$_POST['naam']}' AND `level`!='-1' AND `level`!='-2' AND `level`!='0'");
		$controlle		=	mysql_num_rows($dbres);
		$man			=	mysql_fetch_object($dbres);

			if($_POST['aantal'] > $data->punten){
			echo "<tr><td width=\"25\"><img src=\"layout/images/icons/light_uitroepteken.jpg\" width=\"16\" height=\"16\"></td><td><span class=\"header_rood\">Heb je poep in je ogen? Zoveel credits heb je niet...</span></td></tr><tr><td colspan=\"2\">&nbsp;</td></tr>";
			} else if($_POST['aantal'] < 1){
			echo "<tr><td width=\"25\"><img src=\"layout/images/icons/light_uitroepteken.jpg\" width=\"16\" height=\"16\"></td><td><span class=\"header_rood\">Vul een geldig aantal eerpunten in.</span></td></tr><tr><td colspan=\"2\">&nbsp;</td></tr>";
			} else if(! is_numeric($_POST['aantal'])){
			echo "<tr><td width=\"25\"><img src=\"layout/images/icons/light_uitroepteken.jpg\" width=\"16\" height=\"16\"></td><td><span class=\"header_rood\">Vul een geldig aantal eerpunten in.</span></td></tr><tr><td colspan=\"2\">&nbsp;</td></tr>";
			} else if(strlen($_POST['naam']) == 0){
			echo "<tr><td width=\"25\"><img src=\"layout/images/icons/light_uitroepteken.jpg\" width=\"16\" height=\"16\"></td><td><span class=\"header_rood\">Vul een geldige login in.</span></td></tr><tr><td colspan=\"2\">&nbsp;</td></tr>";
			} else if($man->login == $data->login){
			echo "<tr><td width=\"25\"><img src=\"layout/images/icons/light_uitroepteken.jpg\" width=\"16\" height=\"16\"></td><td><span class=\"header_rood\">Je kan jezelf geen eerpunten sturen.</span></td></tr><tr><td colspan=\"2\">&nbsp;</td></tr>";
			} else if($controlle == 0){
			echo "<tr><td width=\"25\"><img src=\"layout/images/icons/light_uitroepteken.jpg\" width=\"16\" height=\"16\"></td><td><span class=\"header_rood\">Deze gebruiker bestaat niet is dood of verbannen.</span></td></tr><tr><td colspan=\"2\">&nbsp;</td></tr>";
			} else if($_POST['description'] == ""){
			echo "<tr><td width=\"25\"><img src=\"layout/images/icons/light_uitroepteken.jpg\" width=\"16\" height=\"16\"></td><td><span class=\"header_rood\">Voer wel een berichtje in.</span></td></tr><tr><td colspan=\"2\">&nbsp;</td></tr>";
			} else {

				if($_POST['type'] == "1"){
				$data->punten	=		$data->punten-$_POST['aantal'];
				mysql_query("INSERT INTO `eerpunten`(`tijd`,`ip`,`van`,`naar`,`aantal`,`bericht`) VALUES(NOW(),'{$_SERVER['REMOTE_ADDR']}','{$data->login}','{$_POST['naam']}','{$_POST['aantal']}','{$_POST['description']}')");
				mysql_query("UPDATE `gebruiker` SET `respect`=`respect`+'{$_POST['aantal']}' WHERE `login`='{$_POST['naam']}'");
				} else {
				$data->punten	=		$data->punten-$_POST['aantal'];
				mysql_query("INSERT INTO `eerpunten`(`tijd`,`ip`,`van`,`naar`,`aantal`,`bericht`) VALUES(NOW(),'{$_SERVER['REMOTE_ADDR']}','{$data->login}','{$_POST['naam']}','-{$_POST['aantal']}','{$_POST['description']}')");
				mysql_query("UPDATE `gebruiker` SET `respect`=`respect`-'{$_POST['aantal']}' WHERE `login`='{$_POST['naam']}'");
				}

			mysql_query("UPDATE `gebruiker` SET `punten`=`punten`-'{$_POST['aantal']}' WHERE `login`='{$data->login}'");
			echo "<tr><td width=\"25\"><img src=\"layout/images/icons/light_vink.jpg\" width=\"16\" height=\"16\"></td><td><span class=\"headertekst\">Eerpunten succesvol verstuurd.</span></td></tr><tr><td colspan=\"2\">&nbsp;</td></tr>";
			}

		}
	}

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

?>

			<tr>
				<td width="25"><img src="layout/images/icons/light_respect.jpg" width="16" height="16"></td>
				<td><strong>Je hebt nog <?php echo $data->punten; ?> respect credits uit te delen!  -<span class="tekstheader"> <a href="speler-respect-bekijk.php" target="content"><strong>Bekijk transacties!</strong></a></span></strong></td>
			</tr>
		</table>
		<form method="post" action="speler-respect.php?code=<?php echo $getalb; ?>" onsubmit="return submitForm(this.submit);">
		<table width="560" border="0" cellspacing="0" cellpadding="0">
			<tr>
				<td colspan="6">&nbsp;</td>
			</tr>
			<tr>
				<td width="150"><select name="type" class="form_dropdown" style="width:140;"><option value="1" selected>Ik respecteer</option><option value="2">Ik disrespecteer</option></select></td>
				<td width="75"><div align="center">crimineel </div></td>
				<td width="175"><div align="center"><span class="mainTxt"><input type="text" name="naam" maxlength="16" style="width:150;"></span></div></td>
				<td width="50"><div align="center">met</div></td>
				<td><div align="center"><span class="mainTxt"><input name="aantal" type="text" style="width:50;" maxlength="4"></span></div></td>
				<td><div align="right"><span class="mainTxt">credits </span></div></td>
			</tr>
			<tr>
				<td colspan="6">&nbsp;</td>
			</tr>
		</table>
		<table width="560" border="0" cellpadding="0">
			<tr>
				<td width="25"><img src="layout/images/icons/light_comment.jpg" width="16" height="16"></td>
				<td colspan="5"><input type="text" maxlength="50" style="width:400;" name="description"></td>
			</tr>
			<tr>
				<td colspan="6">&nbsp;</td>
			</tr>
			<tr>
				<td colspan="6"><span class="mainTxt"><input type="submit" name="submit" value="Verstuur credits" size="50"></span></td>
			</tr>
		</table></td>
	</tr>
	<tr>
		<td class="subtitle">&nbsp;</td>
	</tr>
</table>
</form>
</body>
</html>