<?php

	$phpgw_info["flags"] = array(
		"currentapp" => "chat",
		"noheader"   => True,
		"nonavbar"   => True
	);
	include("../header.inc.php");

	$loginid = $phpgw_info["user"]["userid"];
//	$date=date("YmdHis");

	if ($action=="post")
	{
		if ($location=="public")
		{
			$phpgw->db->query("INSERT INTO chat_messages (channel,"
				."loginid, message, messagetype,"
				."timesent) values ('$channel',"
				."'$loginid','" . addslashes($message)."','1','"
			. time() . "')");
		}
		else
		{
			$phpgw->db->query("INSERT INTO chat_privatechat "
				."(user1,user2,sentby,"
				."message, messagetype,"
				."timesent) values ('$loginid',"
				."'$channel','$loginid','" . addslashes($message)."','1','"
				. time() . "')");
			$phpgw->db->query("INSERT INTO chat_privatechat (user1, user2, sentby, message, messagetype, timesent) values ('$loginid','$channel','$loginid','$message','1','" . time() . "')");			
		}
	}

	echo "<html><body><center>";
	echo '<form  name="sendmsg" method="post" action="' . $phpgw->link('/chat/sendmsg.php') . '">';
	echo '<input type="hidden" name="channel" value="' . $channel . '">';
	echo '<input type="hidden" name="message" value="' . $message . '">';
	echo '<input type="hidden" name="action" value="post">';
	echo '<input type="hidden" name="location" value="' . $location . '">';
	echo '<input type="text"   size="50" name="message"><br>';
	echo '<input type="submit" value="' . lang('Send Message') . '"></center></form>';
	echo '<script> form.sendmsg.message.focus(); </script></body></html>';
?>
