From 84d0d57228ed159384c023e4f732d61b5cb25364 Mon Sep 17 00:00:00 2001 From: jhunkeler Date: Mon, 28 Dec 2009 06:25:49 +0000 Subject: Added SMF forum Added block to interface with SMF logins (called forum_login) Fixed pages by removing articles Added contentHeading to page generation git-svn-id: http://svn.3rd-infantry-division.org/testing/branches/Bayonet CMS v2@404 c5b2fb0a-d05d-0410-98c8-828840a80ff6 --- admin/pages/functions.php | 272 ++++++++-------------------------------------- 1 file changed, 43 insertions(+), 229 deletions(-) (limited to 'admin/pages/functions.php') diff --git a/admin/pages/functions.php b/admin/pages/functions.php index 7152546..8b1f3b6 100644 --- a/admin/pages/functions.php +++ b/admin/pages/functions.php @@ -22,177 +22,10 @@ * 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 = $row = $db->Fetch($result); - - echo ""; - - ?> - - - - -
-  Add New Article','?op=pages&edit='.$pageid.'&newarticle=true'); ?> -
No Articles Found.
"; - return; - } - - foreach($articles as $article) - { - if($_GET['aid'] == $article['article_id']) - echo ''; - else - echo ''; - ?> - - ^ - - - - v - - - "; -} - -function NewArticle($page_id) -{ - global $db; - if(isset($_POST['newarticleprocessed'])) - { - //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; - } - - $weight = 0; - $result = $db->Query("SELECT * FROM `bayonet_articles` WHERE `page_id` = $page_id ORDER BY `weight` DESC LIMIT 1"); - $row = $db->Fetch($result); - - $weight = $row['weight']; - $weight++; - - //Update the database with the new data. - $db->Query("INSERT INTO `bayonet_articles` (`article_id` ,`page_id` ,`title` ,`text`, `weight`)VALUES (NULL , $page_id, '$title', '$text', '$weight')"); - echo "New article, '$title', has been added.\n"; - PageRedirect(2, "?op=pages&edit={$_GET['edit']}"); - //die, because we have completed what we wanted to do. - return; - } - - ?> -

Add New Article

-
- - - - -
Title:
-
- Query("UPDATE bayonet_articles SET title = '$title', text = '$text' WHERE article_id = '$article_id'"); - echo "Article, '$title', has been edited.\n

Please wait while you are redirected.

- Click here if you don't feel like waiting."; - - //echo ""; - PageRedirect(2,"?op=pages&edit={$_GET['edit']}&aid={$article_id}"); - - //die, because we have completed what we wanted to do. - return; - } - - - //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'"); - $article = $db->Fetch($result); - $article = $row; - - ?> -
- - - -
- - - Delete This Article -
-
- Query("SELECT `title` FROM `bayonet_articles` WHERE `article_id` = '$article_id'"); - $article = $db->Fetch($result); - - if(isset($_POST['proceed'])) - { - echo "Article '{$article['title']}', was deleted."; - $db->Query("DELETE FROM bayonet_articles WHERE article_id = '$article_id' LIMIT 1"); - PageRedirect(2, "?op=pages&edit={$_GET['edit']}"); - return; - } - if(isset($_POST['cancel'])) - { - echo "User cancelled deletion of article: '{$article['title']}'"; - PageRedirect(2, "?op=pages&edit={$_GET['edit']}&aid={$article_id}"); - return; - } - ?> -
- - - -
Are you SURE you want to delete the article titled: ''?
   
-
- Query("SELECT page_id,title FROM bayonet_pages"); + $result = $db->Query("SELECT `page_id`,`title` FROM `bayonet_pages`"); $pages = $db->Fetch($result); echo ""; @@ -215,7 +48,7 @@ function ListPages($pid = NULL) foreach($pages as $page) { $edit = false; - if($pid == $page['page_id']){ + if($_GET['edit'] == $page['page_id']){ $edit = true; echo ''; }else @@ -230,25 +63,6 @@ function ListPages($pid = NULL) - - - - - - - - - - "; @@ -257,10 +71,11 @@ function ListPages($pid = NULL) function NewPage() { global $db; - if(isset($_POST['newpageprocessed'])) + if(isset($_POST['processed'])) { //Secure our data to prevent injection attacks. $title = addslashes($_POST['title']); + $text = addslashes($_POST['text']); if(empty($title)) { echo "You must fill everything out before proceeding."; @@ -271,6 +86,7 @@ function NewPage() $db->Query("INSERT INTO `bayonet_pages` (`page_id` ,`author_id` ,`page_created` ,`title` ,`text`)VALUES (NULL , '0',CURRENT_TIMESTAMP , '$title', '$text')"); echo "New page, '$title', has been added.\n"; + PageRedirect(2, "?op=pages"); //die, because we have completed what we wanted to do. return; } @@ -279,8 +95,9 @@ function NewPage()

Add New Page

-  View this Page','../index.php?load=page&id='.$pid.'" target=\"blank'); ?> -
-  Edit this Page','?op=pages&edit=true&pid='.$pid); ?> -
-  Delete this Page','?op=pages&delete='.$pid); ?> -
- - + + +
Title
Title:
Text:
Query("UPDATE bayonet_pages SET title = '$title' WHERE page_id = '$page_id'"); + $db->Query("UPDATE `bayonet_pages` SET `title` = '$title', `text` = '$text' WHERE `page_id` = '$page_id'"); echo "Page, '$title', has been edited.\n"; + PageRedirect(2, "?op=pages&edit={$page_id}"); //die, because we have completed what we wanted to do. return; } - -?> - - - - - - - - -
- - - - - 0){ - EditArticle($aid); - } - ?> -
+ + //Grab the page from the database according to the $article_id passed to the function. + $result = $db->Query("SELECT `title`, `text` FROM `bayonet_pages` WHERE `page_id` = '$page_id' LIMIT 1"); + $page = $db->FetchRow($result); + ?> +
+ + + + + + + + + + + + +
+ +  View this Page','../index.php?load=page&id='.$page_id.'" target=\"blank'); ?> + Delete This Page","?op=pages&delete={$page_id}"); ?> +
Title:
Text:
+
Query("SELECT title FROM bayonet_pages WHERE page_id = '$page_id'"); - $page = $db->Fetch($result); + $result = $db->Query("SELECT title FROM bayonet_pages WHERE page_id = '$page_id' LIMIT 1"); + $page = $db->FetchRow($result); if(isset($_POST['proceed'])) { echo "Page '{$page['title']}', was deleted."; $db->Query("DELETE FROM bayonet_pages WHERE page_id = '$page_id' LIMIT 1"); + PageRedirect(2, "?op=pages&edit={$page_id}"); return; } if(isset($_POST['cancel'])) { echo "User cancelled deletion of page: '{$page['title']}'"; + PageRedirect(2, "?op=pages&edit={$page_id}"); return; } if($page_id == 1){ - echo "You can not delete the home page."; + echo "You can not delete the home page."; + PageRedirect(2, "?op=pages&edit={$page_id}"); return; } ?> -
+ -- cgit
Are you SURE you want to delete the page titled: ''?
All articles attached to this page will be deleted as well.