From be4f83cd2a17a0ec05f5bce50c91befaafaa6e0c Mon Sep 17 00:00:00 2001 From: jhunkeler Date: Sun, 20 Dec 2009 18:38:08 +0000 Subject: Test. git-svn-id: http://svn.3rd-infantry-division.org/testing/branches/Bayonet CMS v2@376 c5b2fb0a-d05d-0410-98c8-828840a80ff6 --- modules/admin/pages/functions.php | 230 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 230 insertions(+) create mode 100644 modules/admin/pages/functions.php (limited to 'modules/admin/pages/functions.php') diff --git a/modules/admin/pages/functions.php b/modules/admin/pages/functions.php new file mode 100644 index 0000000..104a19a --- /dev/null +++ b/modules/admin/pages/functions.php @@ -0,0 +1,230 @@ +. + */ + +/** + * 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`"); + while(($row = $db->Fetch($result))!=false) + { + $articles[] = $row; + } + + echo ""; + + if(count($articles)==0){ + echo "
There are no articles posted on this page.
"; + return; + } + foreach($articles as $article) + { + if($_GET['aid'] == $article['article_id']) + echo ''; + else + echo ''; + ?> + + ^ + + + + v + + + "; + + + +} + +function EditArticle($article_id){ + + global $db; + //Grab the page from the database according to the $article_id passed to the function. + $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; + } + ?> +
+ + + +
+ + +
+
+ Query("SELECT page_id,title FROM bayonet_pages"); + while(($row = $db->Fetch($result))!=false) + { + $pages[] = $row; + } + + echo 'Select page: '; + // echo ""; +} + +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; + } + + ?> +

Add New Page

+
+ + + + +
Title
Text
+
+ 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']; +?> + + + + + + +
 View this Page','?load=page&id='.$page_id); ?> Delete this Page','?load=admin&op=pages&delete='.$page_id); ?>
+
+ + + + + +
+ + + 0){ + EditArticle($aid); + } + ?> +
+ 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; + } + + ?> +
+ + + +
Are you SURE you want to delete the page titled: ''?
   
+
+ \ No newline at end of file -- cgit