2007-03-16 00:49:05 +00:00
|
|
|
<? // Preamble
|
|
|
|
$pageName = "Add News";
|
|
|
|
$need = 'auth';
|
|
|
|
require "parts/preamble.php"; // Load most of document
|
|
|
|
|
2007-03-18 09:27:20 +00:00
|
|
|
$newsText = addSlashes ($_REQUEST['newsText']);
|
2007-03-16 00:49:05 +00:00
|
|
|
$mode = $_REQUEST['mode'];
|
2007-03-18 04:34:44 +00:00
|
|
|
$user = $userInfo['u_displayname'];
|
2007-03-16 00:49:05 +00:00
|
|
|
|
2007-03-18 04:34:44 +00:00
|
|
|
if ($newsText && $mode == "Post") {
|
2007-03-16 00:49:05 +00:00
|
|
|
need ('sql');
|
|
|
|
|
2007-03-18 04:34:44 +00:00
|
|
|
$query = 'INSERT into news_main (n_date, n_user, n_news) VALUES ('
|
|
|
|
."NOW(), '$user', '$newsText')";
|
2007-03-16 00:49:05 +00:00
|
|
|
|
2007-03-18 04:34:44 +00:00
|
|
|
$rows = sqlWriteQuery ($query);
|
|
|
|
if ($rows === null) {
|
|
|
|
echo '<P>You suck, butthead.</P>';
|
|
|
|
} elseif ($rows === false) {
|
|
|
|
echo '<P>There was an error in your input. If you don\'t know what it is, I\'m not going to tell you.</P>';
|
2007-03-16 00:49:05 +00:00
|
|
|
} else {
|
2007-03-18 04:34:44 +00:00
|
|
|
echo '<P>Your news item has been processed successfully.</P>';
|
2007-03-16 00:49:05 +00:00
|
|
|
}
|
|
|
|
} else {
|
2007-03-18 04:34:44 +00:00
|
|
|
$date = date ('d M Y');
|
2007-03-16 00:49:05 +00:00
|
|
|
|
2007-03-18 04:34:44 +00:00
|
|
|
need ('boxes news');
|
2007-03-16 00:49:05 +00:00
|
|
|
|
2007-03-18 04:34:44 +00:00
|
|
|
newsBoxOpen ();
|
|
|
|
if ($newsText) {
|
|
|
|
newsBoxTitle ("Latest News (Preview)");
|
|
|
|
printNews ($date, $user, stripSlashes ($newsText));
|
|
|
|
}
|
|
|
|
newsBoxTitle ("Post News");
|
|
|
|
$form = '<FORM action="' . thisURL . '" method="post">'
|
|
|
|
. '<TEXTAREA name="newsText" rows="25" cols="64">'
|
|
|
|
. stripSlashes ($newsText)
|
|
|
|
. '</TEXTAREA><BR>'
|
|
|
|
. '<INPUT align="center" type="submit" name="mode" value="Post"></INPUT>'
|
|
|
|
. '<INPUT align="center" type="submit" name="mode" value="Preview"></INPUT>'
|
|
|
|
.'</FORM>';
|
|
|
|
printNews ($date, $user, $form);
|
|
|
|
newsBoxClose ();
|
|
|
|
}
|
|
|
|
?>
|