website/news_add.php

46 lines
No EOL
1.3 KiB
PHP

<? // Preamble
$pageName = "Add News";
$need = 'auth';
require "parts/preamble.php"; // Load most of document
$newsText = $_REQUEST['newsText'];
$mode = $_REQUEST['mode'];
$user = $userInfo['u_displayname'];
if ($newsText && $mode == "Post") {
need ('sql');
$newsText = addSlashes ($newsText);
$query = 'INSERT into news_main (n_date, n_user, n_news) VALUES ('
."NOW(), '$user', '$newsText')";
$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>';
} else {
echo '<P>Your news item has been processed successfully.</P>';
}
} else {
$date = date ('d M Y');
need ('boxes news');
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 ();
}
?>