<?php
require "inc/init.php";
require "inc/small_functions.php";
$post_vars = array(
'sendto','subject','message','new','cancel'
);
include "import_vars_post.inc";
$get_vars = array('subject','sendto','message');
include "import_vars_get.inc";
$message = StripSlashes($message);
$subject = StripSlashes($subject);
if ($cancel) {
header ("Location: home.php");
exit;
}
if ($sendto && $new) {
// explode users separated by "," and get their IDs
$sendto = Addslashes(StripSlashes($sendto));
$to = explode (",", $sendto);
for ($x=0; $x<=sizeof($to)-1; $x++) {
$this_to = trim($to[$x]);
if (!GetUserId($this_to,$id)) {
$error = "$strInvalidUsername ($this_to)";
$sendto = StripSlashes($sendto);
} else {
$to_id[$x] = $id;
}
}
}
if ($message && $to_id && !$error && $new) {
// validate data
$message = Addslashes((StripSlashes($message)));
$subject = Addslashes(StripSlashes($subject));
for ($x=0; $x<=sizeof($to_id)-1; $x++) {
$this_to = $to_id[$x];
NewMessage($user_id,$this_to,$subject,$message);
}
header ("Location: home.php");
} else {
?>
<html>
<head>
<title><? print $strNewMessage; ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=<? if ($charset) print $charset; else print "ISO-8859-1"; ?>">
<link href="css/pman.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor=<? print $bgcolorMessages; ?>>
<table width=100% height=100%>
<tr>
<td width=30% valign=middle align=center>
<form action="new_message.php" method=post>
<?
if ($error) $error = "\n<p align=center><font color=#FF0000>$error</font></p>\n";
$content = "
<div align=center>$error</div>
$strSendTo:<br><input type=text name=sendto size=45 value=\"$sendto\"><br>
$strSubject:<br><input type=text name=subject size=45 maxlenght=100 value=\"$subject\"><br>
$strMessage:<br><textarea name=message cols=70 rows=10>$message</textarea><br>
<div align=center>
$before<input name=new type=submit value=\"$strSend\">
<input type=submit name=cancel value=\"$strCancel\">
</div>
";
$title = $strNewMessage;
$color = $boxcolorMessage;
include "templates/box.php";
?>
<form>
</td>
</tr>
</table>
</body>
</html>
<?
}
?>