<?php


session_start();
include("include/config.php");
include("include/functions/import.php");
$thebaseurl = $config['baseurl'];

if ($_SESSION[USERID] != "" && $_SESSION[USERID] >= 0 && is_numeric($_SESSION[USERID]))
{
	$messageid = htmlentities(strip_tags($_REQUEST[messageid]));
	$messageid = escape($messageid);
	
	if (is_numeric($messageid))
	{
		$query = "SELECT * from messages_inbox where MID='".mysql_real_escape_string($messageid)."' order by MID desc limit 1";
		$executequery = $conn->Execute($query);
		$msgarray = $executequery->getarray();
		STemplate::assign('msgarray',$msgarray);

		if (count($msgarray) < 1)
		{
			$error = "$lang[694]";
		}
		else
		{
			$query = "UPDATE messages_inbox SET unread='0' WHERE MID='".mysql_real_escape_string($messageid)."'";
			$executequery = $conn->Execute($query);
		}
	
	}
	else
	{
		$error = "$lang[695]";
	}


}
else
{
	header("Location:$config[baseurl]/login.php");exit;
}

STemplate::assign('pagetitle',"$lang[483]");

//TEMPLATES BEGIN
STemplate::assign('error',$error);
STemplate::assign('message',$message);
STemplate::display('header.tpl');
STemplate::display('viewmessage.tpl');
STemplate::display('footer.tpl');
//TEMPLATES END
?>