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

	if($data->famconsig == 0 && $data->famsotto == 0 && $data->famleader == 0){
	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['message'])) {

?>

<table align="center" width="600">
	<tr>
		<td class="subtitle" colspan="2">
		<b>Netwerk - E-mail</b>
		</td>
	</tr>
	<tr>
		<td class="maintxts" width="600" align="center">

<?php

		if(strlen($_POST['subject']) > 3 && strlen($_POST['message']) > 10){
		$dbres				= mysql_query("SELECT `login` FROM `gebruiker` WHERE `familie`='{$data->familie}'");
			while($member = mysql_fetch_object($dbres)) {
			mysql_query("INSERT INTO `berichten`(`tijd`,`ip`,`van`,`naar`,`titel`,`bericht`) VALUES(NOW(),'{$_SERVER['REMOTE_ADDR']}','Netwerk: {$data->familie}','{$member->login}','{$_POST['subject']}','{$_POST['message']}')");
			}      
		echo "Bericht verzonden.<meta http-equiv=\"refresh\" content=\"3\">";
		} else {
		echo "Niet spammen! Je titel moet 3 tekens lang zijn en je bericht minimaal 10 tekens.<meta http-equiv=\"refresh\" content=\"3\">";
		}

?>

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

<?php

	} else {

?>

<form name="form1" method="POST" onsubmit="return submitForm(this.SEND);">
<table align="center" width="600">
	<tr>
		<td class="subtitle" colspan="2">
		<b>Netwerk - E-mail</b>
		</td>
	</tr>
	<tr>
		<td class="maintxts" width="50%">Van</td>
		<td class="maintxts" width="50%">Netwerk: <?php echo $data->familie; ?></td>
	</tr>
	<tr>
		<td class="maintxts" width="50%">Onderwerp</td>
		<td class="maintxts" width="50%"><input type="text" name="subject" maxlength=25 size="40"></td>
	</tr>
	<tr>
		<td class="maintxt" colspan="2" align="center">
		<table width="360">
			<tr>
				<td align="center">
				<a href="javascript://" onClick="document.form1.message.value += ':grin:'"><img src=images/smiles/icon_biggrin.gif border=0></a>
				<a href="javascript://" onClick="document.form1.message.value += ':S'"><img src=images/smiles/icon_confused.gif border=0></a>
				<a href="javascript://" onClick="document.form1.message.value += '8)'"><img src=images/smiles/icon_cool.gif border=0></a>
				<a href="javascript://" onClick="document.form1.message.value += ':.('"><img src=images/smiles/icon_cry.gif border=0></a>
				<a href="javascript://" onClick="document.form1.message.value += ':eek:'"><img src=images/smiles/icon_eek.gif border=0></a>
				<a href="javascript://" onClick="document.form1.message.value += ':evil:'"><img src=images/smiles/icon_evil.gif border=0></a>
				<a href="javascript://" onClick="document.form1.message.value += ':lol:'"><img src=images/smiles/icon_lol.gif border=0></a>
				<a href="javascript://" onClick="document.form1.message.value += ':@'"><img src=images/smiles/icon_mad.gif border=0></a>
				<a href="javascript://" onClick="document.form1.message.value += ':D'"><img src=images/smiles/icon_mrgreen.gif border=0></a>
				<a href="javascript://" onClick="document.form1.message.value += ':|'"><img src=images/smiles/icon_neutral.gif border=0></a>
				<a href="javascript://" onClick="document.form1.message.value += ':P'"><img src=images/smiles/icon_razz.gif border=0></a>
				<a href="javascript://" onClick="document.form1.message.value += ':$'"><img src=images/smiles/icon_redface.gif border=0></a>
				<a href="javascript://" onClick="document.form1.message.value += ':roll:'"><img src=images/smiles/icon_rolleyes.gif border=0></a>
				<a href="javascript://" onClick="document.form1.message.value += ':('"><img src=images/smiles/icon_sad.gif border=0></a>
				<a href="javascript://" onClick="document.form1.message.value += ':)'"><img src=images/smiles/icon_smile.gif border=0></a>
				<a href="javascript://" onClick="document.form1.message.value += ':o'"><img src=images/smiles/icon_surprised.gif border=0></a>
				<a href="javascript://" onClick="document.form1.message.value += ':twisted:'"><img src=images/smiles/icon_twisted.gif border=0></a>
				<a href="javascript://" onClick="document.form1.message.value += ';)'"><img src=images/smiles/icon_wink.gif border=0></a>
				<a href="javascript://" onClick="document.form1.message.value += ':{'"><img src=images/smiles/icon_dracula.gif border=0></a>
				<a href="javascript://" onClick="document.form1.message.value += ':sick:'"><img src=images/smiles/icon_sick.gif border=0></a>
				<a href="javascript://" onClick="document.form1.message.value += ':uhm:'"><img src=images/smiles/icon_uhm.gif border=0></a>
				<a href="javascript://" onClick="document.form1.message.value += ':clap:'"><img src=images/smiles/icon_clap.gif border=0></a>
				<a href="javascript://" onClick="document.form1.message.value += ':dance:'"><img src=images/smiles/icon_dance.gif border=0></a>
				<a href="javascript://" onClick="document.form1.message.value += ':stop:'"><img src=images/smiles/icon_stop.gif border=0></a>
				<a href="javascript://" onClick="document.form1.message.value += ':doh:'"><img src=images/smiles/icon_doh.gif border=0></a>
				<a href="javascript://" onClick="document.form1.message.value += ':nono:'"><img src=images/smiles/icon_nono.gif border=0></a>
				<a href="javascript://" onClick="document.form1.message.value += ':think:'"><img src=images/smiles/icon_think.gif border=0></a>
				<a href="javascript://" onClick="document.form1.message.value += ':ssht:'"><img src=images/smiles/icon_ssht.gif border=0></a>
				<a href="javascript://" onClick="document.form1.message.value += ':nope:'"><img src=images/smiles/icon_nope.gif border=0></a>
				<a href="javascript://" onClick="document.form1.message.value += ':salut:'"><img src=images/smiles/icon_salut.gif border=0></a>
				<a href="javascript://" onClick="document.form1.message.value += ':wall:'"><img src=images/smiles/icon_wall.gif border=0></a>
				</td>
			</tr>
		</table>
		</td>
	</tr>
	<tr>
		<td class="maintxt" align="center" colspan="2"><textarea name="message" cols=65 rows=10></textarea></td>
	</tr>
	<tr>
		<td class="maintxt" width="100%" colspan="2" align="center"><input type="submit" name="submit" value="Email verzenden!" style="width: 200;"></td>
	</tr>
</table>
</form>

<?php

	}

?>

</body>
</html>