<?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>

<?php

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

?>

<table align="center" width="600">
	<tr>
		<td class="subTitle" colspan="2">Admin - Massa e-mail</td>
	</tr>
	<tr>
		<td width="600" class="mainTxt" align="center">

<?php

	$dbres		=	mysql_query("SELECT * FROM `help` WHERE `soort`='{$_POST['subject']}'");
	$controlle	=	mysql_num_rows($dbres);
		if($controlle != 0){
		mysql_query("UPDATE `help` SET `help`='{$_POST['message']}' WHERE `soort`='{$_POST['subject']}'");
		echo "Help pagina aangepast.<meta http-equiv=\"refresh\" content=\"3\">";
		} else {
		mysql_query("INSERT INTO `help`(`soort`,`help`) VALUES('{$_POST['subject']}','{$_POST['message']}')");
		echo "Help pagina toevoegen.<meta http-equiv=\"refresh\" content=\"3\">";
		}

?>

		</td>
	</tr>
</table>

<?php

	exit;
	} if($_GET['actie'] == "delete"){

?>

<table align="center" width="600">
	<tr>
		<td class="subTitle" colspan="2">Admin - Massa e-mail</td>
	</tr>
	<tr>
		<td width="600" class="mainTxt" align="center">

<?php

	mysql_query("DELETE FROM `help` WHERE `id`='{$_GET['id']}'");
	echo "Help pagina verwijdert.<meta http-equiv=\"refresh\" content=\"3\">";

?>

		</td>
	</tr>
</table>

<?php

	exit;
	}

$dbres	=	mysql_query("SELECT * FROM `help` WHERE `soort`='{$_GET['soort']}'");
$help	=	mysql_fetch_object($dbres);

?>

<form name="form1" method="POST" onsubmit="return submitForm(this.SEND);">
<table align="center" width="600">
	<tr>
		<td class="subtitle" colspan="2">
		<b>Help pagina toevoegen</b>
		</td>
	</tr>
	<tr>
		<td class="maintxts" width="50%">Onderwerp</td>
		<td class="maintxts" width="50%"><input type="text" name="subject" value="<?php echo $help->soort; ?>" maxlength=10 size="40"></td>
	</tr>
	<tr>
		<td class="maintxt" align="center" colspan="2"><textarea name="message" cols=65 rows=10><?php echo $help->help; ?></textarea></td>
	</tr>
	<tr>
		<td class="maintxt" width="100%" colspan="2" align="center"><input type="submit" name="submit" value="Submit" style="width: 200;"></td>
	</tr>
</table>
</form>
<br>
<table align="center" width="600">
	<tr>
		<td class="subTitle" colspan="2">
		<b>Help pagina's</b>
		</td>
	</tr>
	<tr>
		<td>
		<table width=100%>
			<tr>
				<td class="subTitle" style="letter-spacing: normal;" align="center" width=90%>
				<b>Naam</b>
				</td>
				<td class="subTitle" style="letter-spacing: normal;" align="center" width=10%>
				<b>Delete</b>
				</td>
			</tr>

<?php

$dbres		=	mysql_query("SELECT * FROM `help`");
	while($help = mysql_fetch_object($dbres)){
?>

			<tr onMouseOver="this.style.backgroundColor='#6F5E4A';" onMouseOut="this.style.backgroundColor='#4B3D32';" style="background-color: #4B3D32;">
				<td align="center" class="justborderS" width="90%"><a href="admin-helppagina.php?soort=<?php echo $help->soort; ?>"><?php echo $help->soort; ?></a></td>
				<td align="center" class="justborderS" width="10%"><a href="admin-helppagina.php?actie=delete&id=<?php echo $help->id; ?>"><img src="layout/images/icons/light_delete.jpg" border=0 width="16" height="16"></a></td>
			</tr>

<?php

	}

?>

		</table>
		</td>
	</tr>
</table>
</body>
</html>