<?php 
if (!isset($_SESSION))
{
	session_start();
}
require_once ('header.php');
echo "<h1>Bericht bewerken</h1>";
if ($aangemeld == "ja")
{
	$poster = halen("SELECT naam FROM replys WHERE id='".$_GET['post']."';");
	if ($poster == $_SESSION['naam'])
	{
		if (ISSET($_POST['script1']))
		{
			action("wijzigt zijn/haar post");
			$post_id = $_GET['post'];
			$post_tid = halen("SELECT tid FROM replys WHERE id='".$post_id."';");
			$post_bericht = $_POST['script1'];
			$post_datum = date("d.m.Y H:i");
			$post_changer = $_SESSION['naam'];
			$post_bericht = $post_bericht.'\n\n';
			$post_bericht = $post_bericht."[i] Gewijzigd door [b] ".$post_changer." [/b] op ".$post_datum." [/i]";
			mysql_query("UPDATE replys SET bericht='".$post_bericht."' WHERE id='".$post_id."'");
			echo "Even geduld a.u.b...";
			echo "<meta http-equiv=\"refresh\" content='1;url=replys.php?id=".$post_tid."'>";
		}
		else
		{
			$bericht = halen("SELECT bericht FROM replys WHERE id='".$_GET['post']."';");
			echo "<center>";
			echo '<table width="490" border="0" cellspacing="0" cellpadding="8">';
			echo '<tr><td colspan="2"><center><script language="JavaScript1.2" type="text/javascript" src="javascript/ubbc.js">';
			echo '</script>';
			require('knoppen.php');
			echo '<br><script language="JavaScript1.2" type="text/javascript" src="javascript/smileys.js"></script></center>';
			echo '</td></tr><form name="formulier" method="post" action="?post='.$_GET['post'].'"><tr>';
			echo '<td width="120" valign="top"><small>Bericht: </small></td><td valign="top">';
			echo '<textarea name="script1" rows="10" cols="50">';
			echo $bericht;
			echo '</textarea></td></tr><tr><td width="120" valign="top">&nbsp;</td>';
			echo '<td><input type="submit" name="submit" value="Bericht bewerken"></td></tr></form></table>';
			echo "</center>";
		}
	}
	else
	{
		echo "Dit bericht is niet door jou gepost!";
	}
}
else
{
	echo "Oeps! Hiervoor moet je aangemeld zijn!";
}
require_once ('footer.php');
?>