mirror of
https://git.code.sf.net/p/quake/website
synced 2025-02-18 18:01:41 +00:00
More plan stuff.
This commit is contained in:
parent
71b8369d08
commit
e7130ddc6b
3 changed files with 137 additions and 3 deletions
|
@ -6,6 +6,8 @@
|
|||
require "parts/preamble.php"; // Load most of document
|
||||
?>
|
||||
<H2>Welcome to Developer Central, <?=$userInfo['u_displayname']?>!</H2>
|
||||
<P>This is the area for developers to post news, edit your user information,
|
||||
check on the server(s), and so on. Members with Admin-level access can modify
|
||||
news items here as well.</P>
|
||||
<P>
|
||||
This is the area for developers to post news/plan entries, edit your user
|
||||
information, check on the server(s), and so on. Members with Admin-level
|
||||
access can modify news/plan entries here as well.
|
||||
</P>
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
@featureOpen ("Admin");
|
||||
?>
|
||||
<P>News: [ <A href="news_add.php">Add</A> | <A href="news_del.php">Del</A> | <A href="news_edit.php">Edit</A> ]</P>
|
||||
<P>Plans: [ <A href="plan_add.php">Add</A> | <A href="plan_del.php">Del</A> | <A href="plan_edit.php">Edit</A> ]</P>
|
||||
<P>Users: [ <A href="user_add.php">Add</A> | <A href="user_del.php">Del</A> | <A href="user_edit.php">Edit</A> ]</P>
|
||||
<?
|
||||
@featureClose ();
|
||||
|
|
131
plan_edit.php
Normal file
131
plan_edit.php
Normal file
|
@ -0,0 +1,131 @@
|
|||
<? // 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 ('sql');
|
||||
|
||||
function convertToHTML ($string)
|
||||
{
|
||||
$table = array_flip (get_html_translation_table (HTML_ENTITIES));
|
||||
|
||||
return strtr ($string, $table);
|
||||
}
|
||||
|
||||
function convertFromHTML ($string)
|
||||
{
|
||||
$table = get_html_translation_table (HTML_ENTITIES);
|
||||
|
||||
return strtr ($string, $table);
|
||||
}
|
||||
|
||||
function planEntrySummary ($a)
|
||||
{
|
||||
need ("date");
|
||||
|
||||
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 news");
|
||||
|
||||
$id = $array['p_id'];
|
||||
$usr = $array['p_user'];
|
||||
$date = dateFromSQLDateTime ($array['p_date']);
|
||||
$subj = convertFromHTML (stripSlashes ($array['p_subject']));
|
||||
$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 = $_GET['planID'];
|
||||
$planSubj = $_POST['planSubj'];
|
||||
$planText = $_POST['planText'];
|
||||
$planUser = $_POST['planUser'];
|
||||
|
||||
if ($planID) {
|
||||
if ($planSubj && $planText && $planUser) {
|
||||
$planText = addSlashes ($planText);
|
||||
$query = 'UPDATE plans SET'
|
||||
." p_user='$planUser', p_subject='$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_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_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 ();
|
||||
}
|
||||
?>
|
Loading…
Reference in a new issue