diff options
Diffstat (limited to 'modules/admin')
-rw-r--r-- | modules/admin/admin_functions.php | 152 | ||||
-rw-r--r-- | modules/admin/blocks/functions.php | 173 | ||||
-rw-r--r-- | modules/admin/blocks/index.php | 59 | ||||
-rw-r--r-- | modules/admin/images/addnewarticle.png | bin | 0 -> 6420 bytes | |||
-rw-r--r-- | modules/admin/images/addnewpage.png | bin | 0 -> 7511 bytes | |||
-rw-r--r-- | modules/admin/images/announcement.png | bin | 0 -> 9409 bytes | |||
-rw-r--r-- | modules/admin/images/calendar.png | bin | 0 -> 10174 bytes | |||
-rw-r--r-- | modules/admin/images/editfiles.png | bin | 0 -> 7336 bytes | |||
-rw-r--r-- | modules/admin/images/editpage.png | bin | 0 -> 7775 bytes | |||
-rw-r--r-- | modules/admin/images/file_doc.png | bin | 0 -> 6993 bytes | |||
-rw-r--r-- | modules/admin/images/file_pdf.png | bin | 0 -> 7336 bytes | |||
-rw-r--r-- | modules/admin/images/file_rtf.png | bin | 0 -> 6958 bytes | |||
-rw-r--r-- | modules/admin/images/file_word.png | bin | 0 -> 9196 bytes | |||
-rw-r--r-- | modules/admin/images/photogallery.png | bin | 0 -> 9687 bytes | |||
-rw-r--r-- | modules/admin/index.php | 73 | ||||
-rw-r--r-- | modules/admin/operation.php | 53 | ||||
-rw-r--r-- | modules/admin/pages/functions.php | 227 | ||||
-rw-r--r-- | modules/admin/pages/index.php | 68 |
18 files changed, 805 insertions, 0 deletions
diff --git a/modules/admin/admin_functions.php b/modules/admin/admin_functions.php new file mode 100644 index 0000000..6c2b394 --- /dev/null +++ b/modules/admin/admin_functions.php @@ -0,0 +1,152 @@ +<?php
+/**
+ * Bayonet Content Management System
+ * Copyright (C) 2008 Joseph Hunkeler
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+ /*
+if(!defined("ADMIN_FILE"))
+{
+ die("Access denied.");
+ return;
+}
+
+function is_loggedin()
+{
+ $id = session_id();
+ if($id == "")
+ {
+ header("location: index.php");
+ return false;
+ }
+ return true;
+}
+
+function login()
+{
+ global $db;
+
+ if(isset($_SESSION['username']) || isset($_SESSION['password']))
+ {
+ return true;
+ }
+
+ if(isset($_POST['processed']))
+ {
+ $username = addslashes($_POST['username']);
+ $password = addslashes($_POST['password']);
+ $password = crypt(md5($password),'iamnotadirtywhorebitch');
+ $result = $db->Query("SELECT * FROM bayonet_users WHERE username = '$username' AND password = '$password'");
+ $rows = $db->Rows($result);
+
+ if($rows > 0)
+ {
+ $_SESSION['username'] = stripslashes($username);
+ $_SESSION['password'] = stripslashes($password);
+ return true;
+ }
+ else
+ {
+ ReportError("Login incorrect.");
+ return false;
+ }
+
+ }
+ else
+ {
+ echo "<form action=\"\" method=\"post\">\n";
+ OpenTable();
+ echo "<tr><th colspan=\"2\">Administrative Login</th></tr>\n";
+
+ echo "<tr><td><table width=\"5\" align=\"center\">\n
+ <tr><th style=\"text-align:right;\">Username</th><td><input size=\"20\" type=\"text\" name=\"username\"></td></tr>\n
+ <tr><th style=\"text-align:right;\">Password</th><td><input size=\"20\" type=\"password\" name=\"password\"></td></tr>\n
+ <tr><th colspan=\"2\" align=\"right\"><input type=\"Submit\" name=\"processed\" value=\"Submit\"></th></tr></td></tr>\n
+ </table>\n";
+ CloseTable();
+ echo "</form>\n";
+ return false;
+ }
+}
+
+function logout()
+{
+ session_unset();
+ session_destroy();
+}
+*/
+/**
+ * CompileAdmin()
+ *
+ * because we want to have a horizontal display of options, we need to have
+ * the data separated by arrays. the data is processed into single tables, and is
+ * echoed in realtime. we checked to make sure they were arrays, but there is no
+ * checking to make sure the data passed is not malicious in nature.
+ *
+ * @param mixed $head
+ * @param mixed $body
+ * @return
+ */
+ /*
+function CompileAdmin($head,$body)
+{
+ /*if we were not passed arrays, then say goodbye
+ if(!is_array($head) || !is_array($body))
+ {
+ echo "must be array\n";
+ return;
+ }
+
+ echo "<table class=\"cleartable\" width=\"100%\">";
+ echo "<tr style=\"text-align:center; height:90px;\">";
+
+ $num = 1;
+ foreach($body as $td)
+ {
+ echo "<td class=\"center\" style=\"width:25%;\">$td</td>\n";
+ if($num%4 == 0){
+ echo "</tr><tr style=\"text-align:center; height:90px;\">";
+ }
+ $num++;
+ }
+ echo "</tr></table>\n";
+}
+
+
+ * OpenTable()
+ *
+ * The administration OpenTable() function requires an argument to define
+ * the header title. It may be wise to replace the standard OpenTable() function
+ * with this one... that's alot of code to unfuck though.
+ *
+ * @param mixed $title
+ * @return
+
+function OpenTable_Ex($title)
+{
+ echo "<table align=\"center\"><tr><th>{$title}</th></tr><tr><td>";
+}
+
+
+ * CloseTable()
+ *
+ * @return
+
+function CloseTable_Ex()
+{
+ echo "</td></tr></table>";
+}
+ */
+?>
\ No newline at end of file diff --git a/modules/admin/blocks/functions.php b/modules/admin/blocks/functions.php new file mode 100644 index 0000000..0138839 --- /dev/null +++ b/modules/admin/blocks/functions.php @@ -0,0 +1,173 @@ +<?php
+/**
+ * Bayonet Content Management System
+ * Copyright (C) 2008 Joseph Hunkeler
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+function ListBlocks()
+{
+ global $db;
+ $result = $db->Query("SELECT * FROM bayonet_blocks");
+ $blocks = $db->Fetch();
+
+ echo "<table align=\"center\"><tr><th colspan=\"3\">Existing Blocks</th></tr>";
+ foreach($blocks as $block)
+ {
+ echo "<tr><td>{$block['weight']} : {$block['dir_name']}</td><td><a href=\"?load=admin&op=blocks&edit={$block['block_id']}\">Edit</a></td><td><a href=\"?load=admin&op=blocks&delete={$block['block_id']}\">Delete</a></td></tr>";
+ }
+ echo "</table>";
+}
+
+function NewBlock()
+{
+ global $db;
+ if(isset($_POST['processed']))
+ {
+ //Secure our data to prevent injection attacks.
+ $weight = addslashes($_POST['weight']);
+ $dir_name = addslashes($_POST['dir_name']);
+ $position = addslashes($_POST['position']);
+ $active = addslashes($_POST['active']);
+
+ if(empty($weight) || empty($dir_name) || empty($position))
+ {
+ echo "You must fill everything out before proceeding.";
+ return;
+ }
+ //Update the database with the new data.
+ $db->Query("INSERT INTO bayonet_blocks SET weight = '$weight', dir_name = '$dir_name', position = '$position', active = '$active'");
+ //die, because we have completed what we wanted to do.
+ echo "New block, '$dir_name', at position '$weight' added.\n";
+ return;
+ }
+
+ ?>
+ <form action="<?php $_SERVER['PHP_SELF']?>" method="post">
+ <table align="center">
+ <tr><th>Weight</th><td><input type="text" name="weight" value="<?php echo $block['weight'] ?>"></td></tr>
+ <tr><th>Position</th><td><input type="text" name="position" value="<?php echo $block['position'] ?>"></td></tr>
+ <tr><th>Directory Name</th><td><input type="text" name="dir_name" value="<?php echo $block['dir_name'] ?>"></td>
+ <tr><th>Active</th><td>
+ <select name="active">
+ <option value="1">Yes</option>
+ <option value="0">No</option>
+ </select></td>
+ <tr><th colspan="2"><input type="submit" name="processed" value="Submit"></th></tr>
+ </table>
+ </form>
+ <?php
+}
+
+function GetActive($block_id, &$active)
+{
+ $options = array(1 => 'Yes',0 => 'No');
+ foreach($options as $option => $value)
+ {
+ $selected = NULL;
+ if($active == $option)
+ {
+ $selected = "selected";
+ }
+ echo "<option " . $selected . " value=\"". $option ."\">" . $value . "</option>\n";
+ }
+
+
+}
+
+function EditBlock($block_id)
+{
+ global $db;
+ if(isset($_POST['processed']))
+ {
+ //Secure our data to prevent injection attacks.
+ $weight = addslashes($_POST['weight']);
+ $dir_name = addslashes($_POST['dir_name']);
+ $position = addslashes($_POST['position']);
+ $active = addslashes($_POST['active']);
+
+ if(empty($weight) || empty($dir_name) || empty($position))
+ {
+ echo "You must fill everything out before proceeding.";
+ return;
+ }
+
+ //Update the database with the new data.
+ $db->Query("UPDATE bayonet_blocks SET weight = '$weight', dir_name = '$dir_name', position = '$position', active = '$active' WHERE block_id = '$block_id'");
+ //$isActive = $active ? "IS" : "IS NOT";
+ echo "Block, '$dir_name', at position '$weight' has been edited.\n";
+ //die, because we have completed what we wanted to do.
+ return;
+ }
+
+ //Grab the page from the database according to the $page_id passed to the function.
+ // {{{ XXX: FIXME -- Re-write this
+ /*
+ $result = $db->Query("SELECT weight,dir_name,position,active FROM bayonet_blocks WHERE block_id = '$block_id'");
+ while(($row = $db->Fetch($result))!=false)
+ {
+ //We only want one row, so we don't have to $block[]... No foreach necessary.
+ $block = $row;
+ }
+ */
+ // }}}
+ ?>
+ <form action="<?php $_SERVER['PHP_SELF']?>" method="post">
+ <table align="center">
+ <tr><th>Weight</th><td><input type="text" name="weight" value="<?php echo $block['weight'] ?>"></td></tr>
+ <tr><th>Position</th><td><input type="text" name="position" value="<?php echo $block['position'] ?>"></td></tr>
+ <tr><th>Directory Name</th><td><input type="text" name="dir_name" value="<?php echo $block['dir_name'] ?>"></td>
+ <tr><th>Active</th><td>
+ <select name="active">
+ <?php GetActive($block_id, $block['active']) ?>
+ </select>
+ </td>
+
+ <tr><th colspan="2"><input type="submit" name="processed" value="Submit"></th></tr>
+ </table>
+ </form>
+ <?php
+}
+
+function DeleteBlock($block_id)
+{
+ global $db;
+
+ $result = $db->Query("SELECT dir_name FROM bayonet_blocks WHERE block_id = '$block_id'");
+ $block = $db->Fetch($result);
+
+ if(isset($_POST['proceed']))
+ {
+ echo "Block '{$block['dir_name']}', was deleted.";
+ $db->Query("DELETE FROM bayonet_blocks WHERE block_id = '$block_id' LIMIT 1");
+ return;
+ }
+ if(isset($_POST['cancel']))
+ {
+ echo "User cancelled deletion of page: '{$block['dir_name']}'";
+ return;
+ }
+
+ ?>
+ <form action="<?php $_SERVER['PHP_SELF'] ?>" method="post">
+ <table align="center">
+ <th>Are you SURE you want to delete the block titled: '<?php echo $block['dir_name']?>'?</th>
+ <tr><th><button name="proceed">Yes</button> <button name="cancel">No</button></th></tr>
+ </table>
+ </form>
+ <?php
+}
+
+?>
diff --git a/modules/admin/blocks/index.php b/modules/admin/blocks/index.php new file mode 100644 index 0000000..6dac3d2 --- /dev/null +++ b/modules/admin/blocks/index.php @@ -0,0 +1,59 @@ +<?php
+/**
+ * Bayonet Content Management System
+ * Copyright (C) 2008 Joseph Hunkeler
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * This file administers the site blocks.
+ *
+ * -weight
+ * -directory name
+ */
+
+if(!defined("ADMIN_FILE"))
+{
+ die("Access denied.");
+}
+
+
+include $basedir.'blocks/functions.php';
+
+if(isset($_GET['edit']))
+{
+ $block_id = $_GET['edit'];
+ EditBlock($block_id);
+ return;
+}
+
+if(isset($_GET['delete']))
+{
+ $block_id = $_GET['delete'];
+ DeleteBlock($block_id);
+ return;
+}
+
+if(isset($_GET['create']))
+{
+ NewBlock();
+ return;
+}
+
+echo "<table align=\"center\" width=\"200px\"><tr><th>".LinkInternal('Create a Block','?load=admin&op=blocks&create=true')."</th></tr></table>";
+
+ListBlocks();
+
+?>
\ No newline at end of file diff --git a/modules/admin/images/addnewarticle.png b/modules/admin/images/addnewarticle.png Binary files differnew file mode 100644 index 0000000..0e29960 --- /dev/null +++ b/modules/admin/images/addnewarticle.png diff --git a/modules/admin/images/addnewpage.png b/modules/admin/images/addnewpage.png Binary files differnew file mode 100644 index 0000000..c60c68c --- /dev/null +++ b/modules/admin/images/addnewpage.png diff --git a/modules/admin/images/announcement.png b/modules/admin/images/announcement.png Binary files differnew file mode 100644 index 0000000..c70591d --- /dev/null +++ b/modules/admin/images/announcement.png diff --git a/modules/admin/images/calendar.png b/modules/admin/images/calendar.png Binary files differnew file mode 100644 index 0000000..86b9861 --- /dev/null +++ b/modules/admin/images/calendar.png diff --git a/modules/admin/images/editfiles.png b/modules/admin/images/editfiles.png Binary files differnew file mode 100644 index 0000000..500e206 --- /dev/null +++ b/modules/admin/images/editfiles.png diff --git a/modules/admin/images/editpage.png b/modules/admin/images/editpage.png Binary files differnew file mode 100644 index 0000000..ab3fd58 --- /dev/null +++ b/modules/admin/images/editpage.png diff --git a/modules/admin/images/file_doc.png b/modules/admin/images/file_doc.png Binary files differnew file mode 100644 index 0000000..b1da1ef --- /dev/null +++ b/modules/admin/images/file_doc.png diff --git a/modules/admin/images/file_pdf.png b/modules/admin/images/file_pdf.png Binary files differnew file mode 100644 index 0000000..500e206 --- /dev/null +++ b/modules/admin/images/file_pdf.png diff --git a/modules/admin/images/file_rtf.png b/modules/admin/images/file_rtf.png Binary files differnew file mode 100644 index 0000000..39304c1 --- /dev/null +++ b/modules/admin/images/file_rtf.png diff --git a/modules/admin/images/file_word.png b/modules/admin/images/file_word.png Binary files differnew file mode 100644 index 0000000..3011f00 --- /dev/null +++ b/modules/admin/images/file_word.png diff --git a/modules/admin/images/photogallery.png b/modules/admin/images/photogallery.png Binary files differnew file mode 100644 index 0000000..a161a55 --- /dev/null +++ b/modules/admin/images/photogallery.png diff --git a/modules/admin/index.php b/modules/admin/index.php new file mode 100644 index 0000000..fc379ea --- /dev/null +++ b/modules/admin/index.php @@ -0,0 +1,73 @@ +<?php
+/**
+ * Bayonet Content Management System
+ * Copyright (C) 2008 Joseph Hunkeler
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+ /*
+ if(!defined("MODULE_FILE"))
+ {
+ die("Access denied.");
+ }
+
+ define("ADMIN_FILE",'admin_file');
+ include 'admin_functions.php';
+
+ if($_GET['op'] == 'logout')
+ {
+ logout();
+ }
+
+ if(login())
+ {
+ //this is so dirty... sigh.
+ if(is_loggedin())
+ {
+ ?>
+ <!-- Add id="wrapper" for full height -->
+ <table align="center" width="90%" >
+ <tr><td><div style="text-align:right"><a href="?load=admin&op=logout">Logout, <?php echo $_SESSION['username']?></a></div></td></tr>
+ <tr><td>
+
+ <div class="maincontent">
+ <fieldset>
+ <legend>Administrative Tools:</legend>
+ <?php
+ $th = array('Blocks','Pages');
+ $td = array(
+ //LinkInternal('Blocks','?load=admin&op=blocks'),
+ LinkInternal('<img src="images/editpage.png" /><br />Manage Pages','?load=admin&op=pages'),
+ LinkInternal('<img src="images/navigation.png" /><br />Edit Navigation','?load=admin'),
+ LinkInternal('<img src="images/announcement.png" /><br />Edit Announcements','?load=admin'),
+ LinkInternal('<img src="images/calendar.png" /><br />Manage Events','?load=admin'),
+ LinkInternal('<img src="images/photogallery.png" /><br />Manage Galleries', '?load=admin')
+
+ );
+
+ //render administration table
+ CompileAdmin($th,$td);
+ ?>
+ </fieldset>
+
+ </td></tr>
+ <tr><td><div style="text-align:center"><?php include 'operation.php' ?></div></td></tr>
+
+ </table>
+ </div>
+ <?php )
+ }
+ } */
+
+?>
\ No newline at end of file diff --git a/modules/admin/operation.php b/modules/admin/operation.php new file mode 100644 index 0000000..2c66ff4 --- /dev/null +++ b/modules/admin/operation.php @@ -0,0 +1,53 @@ +<?php
+/**
+ * Bayonet Content Management System
+ * Copyright (C) 2008 Joseph Hunkeler
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+ /*
+if(!defined("ADMIN_FILE"))
+{
+ die("Access denied.");
+ return;
+}
+
+if(!isset($_GET['op']))
+{
+ echo "<center>No operation selected</center>\n";
+ return;
+}
+
+$op = $_GET['op'];
+$basedir = 'modules/admin/';
+
+if(file_exists($basedir))
+{
+ if(file_exists($basedir . $op))
+ {
+ include $basedir . $op . '/index.php';
+ }
+ else
+ {
+ ReportError("Administrative operation '$op' does not exist.");
+ }
+}
+else
+{
+ ReportError("Administrative base directory path does not exist.");
+}
+
+
+*/
+?>
\ No newline at end of file diff --git a/modules/admin/pages/functions.php b/modules/admin/pages/functions.php new file mode 100644 index 0000000..fc97ffc --- /dev/null +++ b/modules/admin/pages/functions.php @@ -0,0 +1,227 @@ +<?php
+/**
+ * Bayonet Content Management System
+ * Copyright (C) 2008 Joseph Hunkeler
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * Note to anyone feeling the need to edit this file...
+ * You MUST declare $db as global inside your functions in order access MySQL from here.
+ */
+
+function ListArticles($pageid){
+
+ global $db;
+ $result = $db->Query("SELECT article_id,title FROM bayonet_articles WHERE `page_id` = $pageid ORDER BY `weight`");
+ $articles = $db->Fetch($result);
+
+ echo "<table class=\"cleartable\" width=\"100%\" cellspacing=\"0\">";
+
+ if(count($articles)==0){
+ echo "<tr><td>There are no articles posted on this page.<br /></td></tr></table>";
+ return;
+ }
+ foreach($articles as $article)
+ {
+ if($_GET['aid'] == $article['article_id'])
+ echo '<tr style="background-color:#c1c1c1; height:30px;">';
+ else
+ echo '<tr style="height:30px;">';
+ ?>
+
+ <td>^</td>
+ <td style="text-align:center; text-overflow:ellipsis; overflow:hidden;">
+ <a href="?load=admin&op=pages&edit=<?php echo $pageid; ?>&aid=<?php echo $article['article_id']?>"><?php echo $article['title']; ?></a>
+ </td>
+ <td>v</td>
+ </tr>
+
+ <?php
+ }
+
+ echo "</table>";
+
+
+
+}
+
+function EditArticle($article_id){
+
+ global $db;
+ //Grab the page from the database according to the $article_id passed to the function.
+ // {{{ XXX: FIXME -- Needs to be re-written
+ /*
+ $result = $db->Query("SELECT title,text FROM bayonet_articles WHERE article_id = '$article_id'");
+ while(($row = $db->Fetch($result))!=false)
+ {
+ //We only want one row, so we don't have to $article[]... No foreach necessary.
+ $article = $row;
+ }
+ */
+ // }}}
+ ?>
+ <form action="<?php $_SERVER['PHP_SELF'] ?>" method="post">
+ <table class="cleartable">
+ <tr><td>
+ <input type="text" name="title" value="<?php echo $article['title'] ?>" maxlength="50" size="30" />
+ <input type="submit" name="processed" value="Submit Changes" />
+ </td></tr>
+ <tr><td><textarea id="markItUp" rows="30" cols="80" name="text"><?php echo $article['text'] ?></textarea></td></tr>
+ </table>
+ </form>
+ <?php
+}
+
+function ListPages($pid = NULL)
+{
+ global $db;
+ $pages = $db->Query("SELECT page_id,title FROM bayonet_pages");
+
+ echo 'Select page: <select id="pagenames" onchange="gotoEditPage(this.id)">';
+ echo '<option value="0">- - - - - - - -</option>';
+ //echo "<table align=\"center\"><tr><th colspan=\"3\">Existing Pages</th></tr>";
+
+
+ foreach($pages as $page)
+ {
+ if($pid == $page['page_id'])
+ echo "<option value=\"{$page['page_id']}\" selected>{$page['title']}</option>";
+ else
+ echo "<option value=\"{$page['page_id']}\">{$page['title']}</option>";
+ }
+ echo '</select>';
+ // echo "</table>";
+}
+
+function NewPage()
+{
+ global $db;
+ if(isset($_POST['processed']))
+ {
+ //Secure our data to prevent injection attacks.
+ $title = addslashes($_POST['title']);
+ $text = addslashes($_POST['text']);
+ if(empty($title) || empty($text))
+ {
+ echo "You must fill everything out before proceeding.";
+ return;
+ }
+
+ //Update the database with the new data.
+ $db->Query("INSERT INTO bayonet_pages SET title = '$title', text = '$text'");
+ echo "New page, '$title', has been added.\n";
+ //die, because we have completed what we wanted to do.
+ return;
+ }
+
+ ?>
+ <h3>Add New Page</h3>
+ <form action="<?php $_SERVER['PHP_SELF']?>" method="post">
+ <table>
+ <tr><th>Title</th><td><input type="text" name="title" value="<?php echo $page['title'] ?>" /></td></tr>
+ <tr><th>Text</th><td><textarea id="markItUp" rows="30" cols="80" name="text"><?php echo $page['text'] ?></textarea></td>
+ <tr><th colspan="2"><input type="submit" name="processed" value="Submit" /></th></tr>
+ </table>
+ </form>
+ <?php
+}
+
+function EditPage($page_id)
+{
+ global $db;
+ $page_id = addslashes($page_id);
+
+ // If the user has submitted, then process their request.
+ if(isset($_POST['processed']))
+ {
+ //Secure our data to prevent injection attacks.
+ $title = addslashes($_POST['title']);
+ $text = addslashes($_POST['text']);
+ if(empty($title) || empty($text))
+ {
+ echo "You must fill everything out before proceeding.";
+ return;
+ }
+
+ //Update the database with the new data.
+ $db->Query("UPDATE bayonet_pages SET title = '$title', text = '$text' WHERE page_id = '$page_id'");
+ echo "Page, '$title', has been edited.\n";
+ //die, because we have completed what we wanted to do.
+ return;
+ }
+
+ $aid = $_GET['aid'];
+?>
+ <table width="100%">
+ <tr>
+ <td><?php ListPages($page_id); ?></td>
+ <td><?php echo LinkInternal('<img src="images/view.gif" /> View this Page','?load=page&id='.$page_id); ?></td>
+ <td class="right"><?php echo LinkInternal('<img src="images/delete.gif" /> Delete this Page','?load=admin&op=pages&delete='.$page_id); ?></td>
+ </tr>
+ </table>
+ <hr />
+ <table class="cleartable" width="100%" style="height:95%;" cellspacing="0">
+ <tr>
+ <td style="vertical-align:top;">
+ <?php ListArticles($page_id); ?>
+ </td>
+ <td style="width:589px; vertical-align:top; border-left:1px solid #848484;">
+ <?php
+ //if article is set then EditArticle();
+ if($aid > 0){
+ EditArticle($aid);
+ }
+ ?>
+ </td>
+ </tr>
+ </table>
+ <?php
+}
+
+function DeletePage($page_id)
+{
+ global $db;
+
+ $result = $db->Query("SELECT title FROM bayonet_pages WHERE page_id = '$page_id'");
+ $page = $db->Fetch($result);
+
+ if(isset($_POST['proceed']))
+ {
+ echo "Page '{$page['title']}', was deleted.";
+ $db->Query("DELETE FROM bayonet_pages WHERE page_id = '$page_id' LIMIT 1");
+ return;
+ }
+ if(isset($_POST['cancel']))
+ {
+ echo "User cancelled deletion of page: '{$page['title']}'";
+ return;
+ }
+ if($page_id == 1){
+ echo "You can not delete the home page.";
+ return;
+ }
+
+ ?>
+ <form action="<?php $_SERVER['PHP_SELF'] ?>" method="post">
+ <table>
+ <th>Are you SURE you want to delete the page titled: '<?php echo $page['title']?>'?</th>
+ <tr><th><button name="proceed">Yes</button> <button name="cancel">No</button></th></tr>
+ </table>
+ </form>
+ <?php
+}
+
+?>
diff --git a/modules/admin/pages/index.php b/modules/admin/pages/index.php new file mode 100644 index 0000000..0fb6cff --- /dev/null +++ b/modules/admin/pages/index.php @@ -0,0 +1,68 @@ +<?php
+/**
+ * Bayonet Content Management System
+ * Copyright (C) 2008 Joseph Hunkeler
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+ ?>
+
+ <div class="maincontent">
+ <fieldset style="height:500px">
+ <legend>Manage Pages:</legend>
+<?php
+
+if(!defined("ADMIN_FILE"))
+{
+ die("Access denied.");
+}
+
+include $basedir.'pages/functions.php';
+
+if(isset($_GET['edit']))
+{
+ $page_id = $_GET['edit'];
+ EditPage($page_id);
+ return;
+}
+
+if(isset($_GET['delete']))
+{
+ $page_id = $_GET['delete'];
+ DeletePage($page_id);
+ return;
+}
+
+if(isset($_GET['create']))
+{
+ $create = $_GET['create'];
+ if($create)
+ {
+ NewPage();
+ return;
+ }
+}
+?>
+
+ <table width="100%">
+ <tr>
+ <td><?php ListPages(); ?></td>
+ <td class="right">
+ <?php echo LinkInternal('<img src="images/add.gif" /> Create a Page','?load=admin&op=pages&create=true'); ?>
+ </td>
+
+ <tr>
+ </table>
+ </fieldset>
+</div>
|