mirror of
https://git.code.sf.net/p/quake/website
synced 2024-11-26 22:20:54 +00:00
9e6f75ccbd
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. ??
116 lines
3.6 KiB
PHP
116 lines
3.6 KiB
PHP
<?php // Preamble
|
|
$pageName = "Edit Plan Entries";
|
|
$need = 'auth';
|
|
require "parts/preamble.php"; // Load most of document
|
|
|
|
if (!$userInfo['u_admin']) // no access from non-admin
|
|
bailout ('<P>You don\'t have access to this page (yet?). Bug an admin to delete a plan post.</P>');
|
|
|
|
need ('boxes date html news sql table');
|
|
|
|
function planEntrySummary ($a)
|
|
{
|
|
need ('date html');
|
|
|
|
return
|
|
'<TR>'
|
|
.' <TD><A href="' . thisURL . '?planID=' . $a['p_id'] . '">' . $a['p_id'] . '</A></TD>'
|
|
.' <TD>' . dateFromSQLDateTime ($a['p_date']) . '</TD>'
|
|
.' <TD>' . $a['p_user'] . '</TD>'
|
|
.' <TD>' . substr (convertFromHTML (StripSlashes ($a['p_plan'])), 0, 50) . '…</TD>'
|
|
.'</TR>';
|
|
}
|
|
|
|
function planEntryEditor ($array)
|
|
{
|
|
need ('boxes date html');
|
|
|
|
$id = $array['p_id'];
|
|
$usr = $array['p_user'];
|
|
$date = dateFromSQLDateTime ($array['p_date']);
|
|
$subj = convertFromHTML (stripSlashes ($array['p_title']));
|
|
$txt = convertFromHTML (stripSlashes ($array['p_plan']));
|
|
|
|
newsBoxOpen ("Edit Plan Entry #$id");
|
|
?>
|
|
<FORM action="<?=thisURL?>?planID=<?=$id?>" method="post">
|
|
<DL>
|
|
<DT><FONT size="-1"><EM>Posted on</EM> <?=$date?> <EM>by</EM>
|
|
<STRONG>
|
|
<INPUT type="text" name="planUser" size="20" value="<?=$usr?>">
|
|
</STRONG>
|
|
<INPUT align="center" type="submit" value="Modify User / Text"></INPUT>
|
|
</FONT></DT>
|
|
<DD>
|
|
Subject: <INPUT type="text" name="planSubj" size="59" value="<?=$subj?>"><BR>
|
|
<TEXTAREA name="planText" rows="25" cols="64"><?=$txt?></TEXTAREA>
|
|
</DD>
|
|
</DL>
|
|
</FORM>
|
|
<?
|
|
newsBoxClose ();
|
|
}
|
|
|
|
need ('boxes sql table');
|
|
|
|
$planID = addSlashes ($_REQUEST['planID']);
|
|
$planSubj = addSlashes ($_REQUEST['planSubj']);
|
|
$planText = addSlashes ($_REQUEST['planText']);
|
|
$planUser = addSlashes ($_REQUEST['planUser']);
|
|
|
|
if ($planID) {
|
|
if ($planSubj && $planText && $planUser) {
|
|
$query = 'UPDATE plans SET'
|
|
." p_user='$planUser', p_title='$planSubj', p_plan='$planText'"
|
|
." WHERE p_id='$planID'";
|
|
|
|
$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>Your edit was correctly formed, but had no effect on the database. Go fig, huh?</P>';
|
|
} else {
|
|
echo '<P>Your edit was processed successfully. Congratulations on your revision of history.<STRONG>:)</STRONG></P>';
|
|
}
|
|
} else {
|
|
$query = 'SELECT p_id, p_date, p_user, p_title, p_plan FROM plans'
|
|
." WHERE p_id=$planID";
|
|
|
|
$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) {
|
|
planEntryEditor ($entries[0]);
|
|
} else {
|
|
echo "<P>This shouldn't even be possible, but there's more than one plan entry with ID '$planID'!</P>";
|
|
}
|
|
}
|
|
} else {
|
|
newsBoxOpen ("All Plan Entries");
|
|
|
|
$query = 'SELECT p_id, p_date, p_user, p_title, p_plan FROM plans'
|
|
.' ORDER BY p_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 planEntrySummary ($entries[$i]);
|
|
}
|
|
tableFooter ();
|
|
} else {
|
|
echo "<P>No plan entries available.";
|
|
}
|
|
newsBoxClose ();
|
|
}
|
|
?>
|