<?php
if (!isset($_SESSION))
{
	session_start();
}
require_once ('header.php');
echo "<h1>Alert</h1>";
if ($aangemeld == "ja")
{
	if (($member_status == "manager") or ($member_status == "staff"))
	{
		if (ISSET($_GET['alert']))
		{
			$_GET['alert'] = str_replace ("'", "", $_GET['alert']);
			$_GET['alert'] = str_replace ('"', "", $_GET['alert']);
			$_GET['alert'] = str_replace("\n", "[br]", $_GET['alert']);
			$query = mysql_query("SELECT naam FROM members WHERE DATE_SUB(NOW(),INTERVAL 5 MINUTE) <= last_online;");
			while($rij = mysql_fetch_array($query))
			{
				$warning = halen("SELECT warning FROM members WHERE naam='".$rij['naam']."';");
				$warning .= "[br]Bericht aan iedereen:[br]".$_GET['alert']."[br]";
				mysql_query("UPDATE members SET warning='".$warning."' WHERE naam='".$rij['naam']."';");
			}
			echo "Alert gegeven aan alle online Jabbo's.";
		}
		else
		{
			echo "(gebruik geen enters maar [br])";
			echo "<form action='?' method='get'>";
			echo "<textarea name='alert' rows='10' cols='63'>";
			echo "</textarea>";
			echo "<input type='submit' value='Geef Alert >'>";
			echo "</form>";
		}
	}
	else
	{
		action("probeert zonder rechten een site alert te doen");
		echo "Oeps! Hiervoor moet je <b>Hotel Manager</b> of <b>Staff Lid</b> zijn.";
	}
}
else
{
	echo "Oeps! Hiervoor moet je aangemeld zijn!";
}
require_once ('footer.php');
?>