mirror of
https://git.code.sf.net/p/quake/website
synced 2025-02-17 01:12:10 +00:00
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. ??
91 lines
2.6 KiB
PHP
91 lines
2.6 KiB
PHP
<?php // Preamble
|
|
$pageName = "Delete News";
|
|
$need = 'auth';
|
|
require 'parts/preamble.php'; // Load most of document
|
|
|
|
if (!$userInfo['u_admin']) // no access from non-admin yet
|
|
bailout ("<P>You don't have access to this page (yet?). Bug an admin to delete a news post.</P>");
|
|
|
|
function newsEntrySummary ($it)
|
|
{
|
|
need ('date html');
|
|
|
|
return
|
|
'<TR>'
|
|
.' <TD><A href="' . thisURL . '?newsID=' . $it['n_id'] . '">' . $it['n_id'] . '</A></TD>'
|
|
.' <TD>' . dateFromSQLDateTime ($it['n_date']) . '</TD>'
|
|
.' <TD>' . $it['n_user'] . '</TD>'
|
|
.' <TD>' . substr (convertFromHTML (stripSlashes ($it['n_news'])), 0, 50) . '…</TD>'
|
|
.'</TR>';
|
|
}
|
|
|
|
function newsEntryConfirmation ($a)
|
|
{
|
|
need ('boxes date html news');
|
|
|
|
$id = $a['n_id'];
|
|
|
|
newsBoxOpen ();
|
|
newsBoxTitle ("Confirmation: Delete #$id?", thisURL . "?newsID=$id&confirm=yes");
|
|
printNewsArray ($a);
|
|
newsBoxClose ();
|
|
}
|
|
|
|
need ('boxes sql');
|
|
|
|
$newsID = addSlashes ($_REQUEST['newsID']);
|
|
$confirm = $_REQUEST['confirm'];
|
|
|
|
if ($newsID) {
|
|
if ($confirm) {
|
|
$query = "DELETE FROM news_main WHERE n_id='$newsID'";
|
|
|
|
$rows = sqlWriteQuery ($query);
|
|
if ($rows === null) {
|
|
echo "<P>Bad mojo, man. I couldn't talk to the SQL server. It said '$sqlError'.</P>";
|
|
} elseif ($rows === false) {
|
|
echo "<P>Something bad happened, and MySQL said '$sqlError'. Bug an admin.</P>";
|
|
} elseif (!$rows) {
|
|
echo "<P>News entry $newsID didn't exist.";
|
|
} else {
|
|
echo "<P>News entry $newsID has been deleted.";
|
|
}
|
|
} else {
|
|
$query = 'SELECT n_id, n_date, n_user, n_news FROM news_main'
|
|
." WHERE n_id='$newsID'";
|
|
$entries = sqlReadQuery ($query);
|
|
if ($entries === null) {
|
|
echo "<P>Bad mojo, man. I couldn't talk to the SQL server. It said '$sqlError'.</P>";
|
|
} elseif ($entries === false) {
|
|
echo "<P>Something bad happened, and MySQL said '$sqlError'. Bug an admin.</P>";
|
|
} elseif (count ($entries) == 1) {
|
|
newsEntryConfirmation ($entries[0]);
|
|
} else {
|
|
echo "<P>This shouldn't even be possible, but there's more than one news entry with ID '$newsID'!</P>";
|
|
}
|
|
}
|
|
} else {
|
|
newsBoxOpen ("All News Postings");
|
|
|
|
$query = 'SELECT n_id, n_date, n_user, n_news FROM news_main'
|
|
.' ORDER BY n_date DESC';
|
|
|
|
$entries = sqlReadQuery ($query);
|
|
if ($entries && is_array ($entries) && count ($entries)) {
|
|
tableHeader ("100%");
|
|
?><TR>
|
|
<TH align="left">ID</TH>
|
|
<TH align="left">Date</TH>
|
|
<TH align="left">User</TH>
|
|
<TH align="left">Text</TH>
|
|
</TR><?
|
|
for ($i = 0; $i < count ($entries); $i++) {
|
|
echo newsEntrySummary ($entries[$i]);
|
|
}
|
|
tableFooter ();
|
|
} else {
|
|
echo "<P>No news available.";
|
|
}
|
|
newsBoxClose ();
|
|
}
|
|
?>
|