<?
require "include/bittorrent.php";

dbconn();
loggedinorreturn();                                                    
if (get_user_class() < UC_MODERATOR)
stderr("Sorry", "but your just a little bitch on this tracker");


$takesubject = $_POST['subject'];
$sender_id = ($_POST['sender'] == 'system' ? 0 : $CURUSER['id']);
$dt = sqlesc(get_date_time());
$body = $_POST['body'];
if (!$body)
stderr("Error","Please, enter a message!");

$updateset = $_POST['clases'];
if(!$_POST['clases'])
stderr("Error","please check 1 or more classes");
$query = mysql_query("SELECT id FROM users WHERE class IN (".implode(",", $updateset).")");

while($dat=mysql_fetch_assoc($query))
{
mysql_query("INSERT INTO `messages` (`sender`,`receiver`,`folder_in`,`folder_out`,`added`,`subject`,`msg`) VALUES ($sender_id, $dat[id], -3, -3, '" . get_date_time() . "', " . sqlesc($takesubject) .", " . sqlesc($body) .")") or sqlerr(__FILE__,__LINE__);
}
header("Refresh: 0; url=staffmess.php");
hit_end();

?>