<?php
if (!isset($_SESSION))
{
	session_start();
}
require_once ('header.php');
if ($aangemeld == "ja")
{
	if ($member_status == "manager")
	{
		if (ISSET($_GET['naam']))
		{
			echo "<h1>Consolegeschiedenis van ".$_GET['naam']."</h1>";
			echo "<center>";
			echo "<form action='console.php' method='get'>";
			echo "<input type='text' length='20' maxlength='20' name='naam' value='".$_GET['naam']."'>";
			echo "<input type='submit' value='Ga'>";
			echo "</form>";
			echo "</center>";
			error_reporting(0);
	   		$bestaat_mss_al = halen("SELECT * FROM members WHERE naam='".$_GET['naam']."';");
		   	error_reporting(E_ALL);
			if($bestaat_mss_al != "")
			{
				$sql = mysql_query("SELECT * FROM berichten WHERE van='".$_GET['naam']."' OR voor='".$_GET['naam']."' ORDER BY id;");
				if(mysql_num_rows($sql) >= 1)
				{
					echo "<tt>";
					while($row = mysql_fetch_array($sql))
		    		{
			    		if($row['voor'] == $_GET['naam'])
			    		{
				    		echo "--> ontvangen<br>";
				    		echo "van ".$row['van']."<br>";
				    		echo "op ".$row['datum']."<br>";
				    		echo "id: ".$row['id']."<br>";
				    		echo "gelezen: ".$row['read']."<br><br>";
				    		echo $row['bericht']."<hr>";
			    		}
			    		else
			    		{
				    		echo "--> verzonden<br>";
				    		echo "voor ".$row['voor']."<br>";
				    		echo "op ".$row['datum']."<br>";
				    		echo "id: ".$row['id']."<br>";
				    		echo "gelezen: ".$row['read']."<br><br>";
				    		echo $row['bericht']."<hr>";
			    		}
		    		}
		    		echo "</tt>";
	    		}
				action("bekijkt de consolegeschiedenis van ".$_GET['naam']);
			}
			else
			{
				echo "Dit account bestaat niet.</center>";
			}
		}
		else
		{
			echo "<h1>Console Geschiedenis</h1>";
			echo "<center>";
			echo "<form action='console.php' method='get'>";
			echo "<input type='text' length='20' maxlength='20' name='naam'>";
			echo "<input type='submit' value='Ga'>";
			echo "</form>";
			echo "</center><br>";
		}
	}
}
else
{
	echo "Oeps! Hiervoor moet je aangemeld zijn!";
}
require_once('footer.php');
?>