website/news_add.php
Jeff Teunissen 9e6f75ccbd Update for PHP 7.x
PHP 7 doesn't like the old short tags we were using (it's possible to re-enable
them, but won't be for version 8, so we might as well switch now), and the old
MySQL APIs are now gone entirely, replaced with something different.

This should make everything work at least as well as it used to.

Also, one file used to be checked in with CRLF line endings. ??
2022-04-27 13:14:47 -04:00

44 lines
1.3 KiB
PHP

<?php // Preamble
$pageName = "Add News";
$need = 'auth';
require "parts/preamble.php"; // Load most of document
need ('boxes html news sql');
$newsText = addSlashes($_REQUEST['newsText']);
$mode = $_REQUEST['mode'];
$user = $userInfo['u_displayname'];
if ($newsText && $mode == "Post") {
$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');
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">'
. convertFromHTML (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 ();
}
?>