|
ob_start();
//the above line needs to be above ALL HTML and PHP (except for ).
include("config.php");
//gets the config page, which connects to the database and gets the user's information
if ($logged[username])
{
//checks to see if they are logged in
switch($_GET[page])
{
//this allows us to use one page for the entire thing
default:
echo ("- Inbox - New Message - Outbox"); if($logged[username] && $logged[level] == 5) echo (" - New Sticky Message"); if($logged[username] && $logged[level] == 3) echo (" - New Sticky Message"); break; case 'write': if (!$_POST[send]) { //the form hasnt been submitted yet.... echo (" "); } if ($_POST[to]) { //the form has been submitted. Now we have to make it secure and insert it into the database $subject = htmlspecialchars(addslashes("$_POST[subject]")); $message = htmlspecialchars(addslashes("$_POST[message]")); $to = htmlspecialchars(addslashes("$_POST[to]")); //the above lines remove html and add \ before all " $send = mysql_query("INSERT INTO `pmessages` ( `title` , `message` , `touser` , `from` , `unread` , `date` ) VALUES ('$subject', '$message', '$to', '$logged[username]', 'unread', NOW())"); echo ("Your message has been sent."); } break; case 'sticky': if (!$_POST[send]) { //the form hasnt been submitted yet.... echo (" "); } if ($_POST[to]) { //the form has been submitted. Now we have to make it secure and insert it into the database $subject = htmlspecialchars(addslashes("$_POST[subject]")); $message = htmlspecialchars(addslashes("$_POST[message]")); $to = htmlspecialchars(addslashes("$_POST[to]")); //the above lines remove html and add \ before all " $send = mysql_query("INSERT INTO `pmessages` ( `title` , `message` , `touser` , `from` , `unread` , `date` , `sticky` ) VALUES ('$subject', '$message', '$to', '$logged[username]', 'unread', NOW(), 1)"); echo ("Your message has been sent."); } break; case 'delete': if (!$_GET[msgid]) { echo ("Sorry, but this is an invalid message!"); } else { $getmsg = mysql_query("SELECT * from pmessages where id = '$_GET[msgid]'"); $msg = mysql_fetch_array($getmsg); //hmm..someones trying to delete someone elses messages! This keeps them from doing it if ($msg[touser] != $logged[username]) { echo ("This message was not sent to you!"); } elseif ($msg[sticky] != '1') { $delete = mysql_query("delete from pmessages where id = '$_GET[msgid]'"); echo "Your message has been deleted."; } else { echo "This Message Cannot Be Deleted."; } } break; case 'inbox': $get = mysql_query("SELECT * from pmessages where touser = '$logged[username]' order by id desc"); echo("
"); echo ("This message was sent incorrectly to you. It might be because the sender missed out capitals in your name. please send a message back to the sender saying you can't veiw the message because they spelt your name wrong."); } } break; case 'outbox': $get = mysql_query("SELECT * from pmessages where fromuser = '$logged[username]' order by id desc"); // gets the messages that you sent echo("
"); } else { if(isset($_POST['delete_all'])) { $query = mysql_query("DELETE FROM pmessages WHERE touser = '$logged[username]'"); echo ("Your Inbox Is Now Empty!)"; echo ("You Will Be Redirected.. "); } } break; } echo(" Inbox · New Message · Outbox");
if($logged[username] && $logged[level] == 5)
echo (" · New Sticky Message");
if($logged[username] && $logged[level] == 3)
echo (" · New Sticky Message");
}
else
{
echo("You are not loged in. Please login to veiw the message system.");
}
?>
|
|||||||||||||||||||||