<?php define('path', '../../../'); include path . 'inc/init.php'; $page = "admin"; $user = new User(); $blog = new Blog(); $val = new Validation(); if ($user->isLoggedIn() && $user->hasPermission('delete')) { if (input::exists()) { if (Token::check(input::get('token'))) { $val->check($_POST, array('ConfirmDel' => array('required' => true), 'post_id' => array('required' => true))); if ($val->passed()) { $blog->deletePost(Input::get('post_id')); session::flash('complete', 'You have deleted a post!'); Redirect::to(path . 'index.php'); } } } } ?> <html> <head> <?php include path . 'assets/php/css.php'; ?> </head> <body> <?php include path . 'assets/php/nav.php'; ?>
$categories = ''; } Blog::editPost($_POST['title'], $_POST['body'], $categories, $_POST['rewrite'], $_POST['pid']); echo '<p class="message success">Post Edited Sucessfully</p>'; } if (isset($_POST['publish'])) { if (isset($_POST['categories'])) { $categories = $_POST['categories']; } else { $categories = ''; } Blog::editPost($_POST['title'], $_POST['body'], $categories, $_POST['rewrite'], $_POST['pid'], 'published'); echo '<p class="message success">Post Published Sucessfully</p>'; } if (isset($_GET['delete'])) { Blog::deletePost($_GET['delete']); echo '<p class="message success">Post Deleted</p>'; } ?> <?php Blog::postsTable(); ?> </div> <div id="box2" class="boxes"> <h3 class="left">Categories</h3> <a href="javascript:void(0);" id="addcategory" class="button right">Add +</a>
<?php // Required classes for the Delete Post demo require_once "engine/blog.php"; // Settings include "settings/globalvars.php"; // Creates a new Blog and a new Visitor $blog = new Blog($GLOB_username, $GLOB_password, $GLOB_server, $GLOB_database); // Delete Post Variables $id = $_GET['id']; // Deletes the post $blog->deletePost($id); // Redirect to Index header('Location:index.php');
function blog_admin_controller() { $Blog = new Blog(); getBlogUserPermissions(); global $blogUserPermissions, $SITEURL; if (!isset($_GET['update'])) { $update = blog_version_check(); if ($update[0] == 'current') { $ucolor = '#308000'; } elseif ($update[0] == 'update') { $ucolor = '#FFA500'; } elseif ($update[0] == 'beta') { $ucolor = '#2B5CB3'; } else { $ucolor = '#D94136'; } } else { $ucolor = '#777777'; } if (isset($_GET['edit_post']) && $blogUserPermissions['blogeditpost'] == true) { editPost($_GET['edit_post']); } elseif (isset($_GET['create_post']) && $blogUserPermissions['blogcreatepost'] == true) { editPost(); } elseif (isset($_GET['categories']) && $blogUserPermissions['blogcategories'] == true) { if (isset($_GET['edit_category'])) { $add_category = $Blog->saveCategory($_POST['new_category']); if ($add_category == true) { echo '<div class="updated">' . i18n_r(BLOGFILE . '/CATEGORY_ADDED') . '</div>'; } else { echo '<div class="error">' . i18n_r(BLOGFILE . '/CATEGORY_ERROR') . '</div>'; } } if (isset($_GET['delete_category'])) { $Blog->deleteCategory($_GET['delete_category']); } #edit_categories $category_file = getXML(BLOGCATEGORYFILE); require_once 'html/category-management.php'; } elseif (isset($_GET['auto_importer']) && $blogUserPermissions['blogrssimporter'] == true) { if (isset($_POST['post-rss'])) { $post_data = array(); $post_data['name'] = $_POST['post-rss']; $post_data['category'] = $_POST['post-category']; $add_feed = $Blog->saveRSS($post_data); if ($add_feed == true) { echo '<div class="updated">' . i18n_r(BLOGFILE . '/FEED_ADDED') . '</div>'; } else { echo '<div class="error">' . i18n_r(BLOGFILE . '/FEED_ERROR') . '</div>'; } } elseif (isset($_GET['delete_rss'])) { $delete_feed = $Blog->deleteRSS($_GET['delete_rss']); if ($delete_feed == true) { echo '<div class="updated">' . i18n_r(BLOGFILE . '/FEED_DELETED') . '</div>'; } else { echo '<div class="error">' . i18n_r(BLOGFILE . '/FEED_DELETE_ERROR') . '</div>'; } } #edit_rss $rss_file = getXML(BLOGRSSFILE); require_once 'html/feed-management.php'; } elseif (isset($_GET['settings']) && $blogUserPermissions['blogsettings'] == true) { show_settings_admin(); } elseif (isset($_GET['update']) && $blogUserPermissions['blogsettings'] == true) { show_update_admin(); } elseif (isset($_GET['help']) && $blogUserPermissions['bloghelp'] == true) { require_once 'html/help-admin.php'; } elseif (isset($_GET['custom_fields']) && $blogUserPermissions['blogcustomfields'] == true) { $CustomFields = new customFields(); if (isset($_POST['save_custom_fields'])) { $saveCustomFields = $CustomFields->saveCustomFields(); if ($saveCustomFields) { echo '<div class="updated">' . i18n_r(BLOGFILE . '/EDIT_OK') . '</div>'; } } show_custom_fields(); } else { if (isset($_GET['save_post'])) { savePost(); } elseif (isset($_GET['delete_post']) && $blogUserPermissions['blogdeletepost'] == true) { $post_id = urldecode($_GET['delete_post']); $delete_post = $Blog->deletePost($post_id); if ($delete_post == true) { echo '<div class="updated">' . i18n_r(BLOGFILE . '/POST_DELETED') . '</div>'; } else { echo '<div class="error">' . i18n(BLOGFILE . '/FEED_DELETE_ERROR') . '</div>'; } } #show_posts_admin $all_posts = $Blog->listPosts(true, true); // Get a list of all the posts in the blog require_once 'html/posts-admin.php'; // Bring in the HTML to show this section } }
/** * Handles conditionals for admin functions * * @return void */ function blog_admin_controller() { $Blog = new Blog(); getBlogUserPermissions(); global $blogUserPermissions; showAdminNav(); if (isset($_GET['edit_post']) && $blogUserPermissions['blogeditpost'] == true) { editPost($_GET['edit_post']); } elseif (isset($_GET['create_post']) && $blogUserPermissions['blogcreatepost'] == true) { editPost(); } elseif (isset($_GET['categories']) && $blogUserPermissions['blogcategories'] == true) { if (isset($_GET['edit_category'])) { $add_category = $Blog->saveCategory($_POST['new_category']); if ($add_category == true) { echo '<div class="updated">'; i18n(BLOGFILE . '/CATEGORY_ADDED'); echo '</div>'; } else { echo '<div class="error">'; i18n(BLOGFILE . '/CATEGORY_ERROR'); echo '</div>'; } } if (isset($_GET['delete_category'])) { $Blog->deleteCategory($_GET['delete_category']); } edit_categories(); } elseif (isset($_GET['auto_importer']) && $blogUserPermissions['blogrssimporter'] == true) { if (isset($_POST['post-rss'])) { $post_data = array(); $post_data['name'] = $_POST['post-rss']; $post_data['category'] = $_POST['post-category']; $add_feed = $Blog->saveRSS($post_data); if ($add_feed == true) { echo '<div class="updated">'; i18n(BLOGFILE . '/FEED_ADDED'); echo '</div>'; } else { echo '<div class="error">'; i18n(BLOGFILE . '/FEED_ERROR'); echo '</div>'; } } elseif (isset($_GET['delete_rss'])) { $delete_feed = $Blog->deleteRSS($_GET['delete_rss']); if ($delete_feed == true) { echo '<div class="updated">'; i18n(BLOGFILE . '/FEED_DELETED'); echo '</div>'; } else { echo '<div class="error">'; i18n(BLOGFILE . '/FEED_DELETE_ERROR'); echo '</div>'; } } edit_rss(); } elseif (isset($_GET['settings']) && $blogUserPermissions['blogsettings'] == true) { show_settings_admin(); } elseif (isset($_GET['help']) && $blogUserPermissions['bloghelp'] == true) { show_help_admin(); } elseif (isset($_GET['custom_fields']) && $blogUserPermissions['blogcustomfields'] == true) { $CustomFields = new customFields(); if (isset($_POST['save_custom_fields'])) { $saveCustomFields = $CustomFields->saveCustomFields(); if ($saveCustomFields) { echo '<div class="updated">' . i18n_r(BLOGFILE . '/EDIT_OK') . '</div>'; } } show_custom_fields(); } else { if (isset($_GET['save_post'])) { savePost(); } elseif (isset($_GET['delete_post']) && $blogUserPermissions['blogdeletepost'] == true) { $post_id = urldecode($_GET['delete_post']); $delete_post = $Blog->deletePost($post_id); if ($delete_post == true) { echo '<div class="updated">'; i18n(BLOGFILE . '/POST_DELETED'); echo '</div>'; } else { echo '<div class="error">'; i18n(BLOGFILE . '/FEED_DELETE_ERROR'); echo '</div>'; } } show_posts_admin(); } }