// Preamble
$pageName = "Add News";
$need = 'auth';
require "parts/preamble.php"; // Load most of document
function showPreview ($date, $user, $def)
{?>
Add News (Preview)
- (Will be) posted on =$date?> by =$user?>
-
}
$newsItem = $_REQUEST['newsItem'];
$mode = $_REQUEST['mode'];
if ($newsItem && $mode == "Post") {
need ('sql');
$user = ucfirst ($REMOTE_USER);
$newsItem = AddSlashes ($newsItem);
$conn = mysql_connect (sqlHost, sqlRWUser, sqlRWPass);
if ($conn) {
$query = 'INSERT into news_main (n_date, n_user, n_news) VALUES (' .
" NOW(), '$user', '$newsItem')";
$result = mysql_db_query (sqlDB, $query, $conn);
if ($result) {
$numRows = mysql_affected_rows ($conn);
if ($numRows) {
echo 'Your news item has been processed successfully.';
} else {
echo '
There was an error in your input. If you don\'t know what it is, I\'m not going to tell you.';
}
}
mysql_close ($conn);
} else {
echo '
You suck, butthead.';
}
} else {
$date = strftime ('%d %b %Y', time ());
$user = ucfirst ($REMOTE_USER);
if ($newsItem) {?>
Latest News
- Posted on =$date?> by =$user?>
-
=StripSlashes($newsItem)?>
}
showPreview ($date, $user, $newsItem);
}
require siteHome . "/parts/postamble.php"; // Finish this sucker up
?>