<?php $page = "user_blog"; include "header.php"; $task = !empty($_POST['task']) ? $_POST['task'] : (!empty($_GET['task']) ? $_GET['task'] : NULL); $search = !empty($_POST['search']) ? $_POST['search'] : (!empty($_GET['search']) ? $_GET['search'] : NULL); $p = !empty($_POST['p']) ? $_POST['p'] : (!empty($_GET['p']) ? $_GET['p'] : 1); $s = !empty($_POST['s']) ? $_POST['s'] : (!empty($_GET['s']) ? $_GET['s'] : NULL); // CREATE BLOG OBJECT $entries_per_page = 10; $blog = new se_blog($user->user_info['user_id']); // DELETE NECESSARY ENTRIES if ($task == "delete" && !empty($_POST['delete_blogentries']) && is_array($_POST['delete_blogentries'])) { $blog->blog_entry_delete($_POST['delete_blogentries']); } // SET ENTRY SORT-BY VARIABLES FOR HEADING LINKS $s = "blogentry_date DESC"; $where = NULL; if (trim($search)) { $where = "(blogentry_title LIKE '%{$search}%' OR blogentry_body LIKE '%{$search}%')"; } // GET ENTRIES $total_blogentries = $blog->blog_entries_total($where); $page_vars = make_page($total_blogentries, $entries_per_page, $p); $blogentries = $blog->blog_entries_list($page_vars[0], $entries_per_page, $s, $where); // ASSIGN VARIABLES AND SHOW VIEW ENTRIES PAGE $smarty->assign('total_blogentries', $total_blogentries); $smarty->assign_by_ref('blogentries', $blogentries); $smarty->assign('s', $s); $smarty->assign('search', $search); $smarty->assign('p', $page_vars[1]);
} else { $blogentry_id = 0; } if (isset($_POST['delete_blogentries'])) { $delete_blogentries = $_POST['delete_blogentries']; } elseif (isset($_GET['delete_blogentries'])) { $delete_blogentries = $_GET['delete_blogentries']; } else { $delete_blogentries = NULL; } // CREATE BLOG OBJECT $entries_per_page = 100; $blog = new se_blog(); // DELETE ENTRIES if ($task == "deleteentries" && !empty($delete_blogentries)) { $blog->blog_entry_delete($delete_blogentries); header('Location: admin_viewblogs.php'); exit; } // SET BLOG ENTRY SORT-BY VARIABLES FOR HEADING LINKS $i = "id"; // BLOGENTRY_ID $t = "t"; // BLOGENTRY_TITLE $o = "o"; // OWNER OF ENTRY $v = "v"; // VIEWS OF ENTRY $d = "d"; // DATE OF ENTRY // SET SORT VARIABLE FOR DATABASE QUERY
if (!empty($blogentry_id) && empty($_POST['url']) && empty($_GET['url'])) { $blogentry_info = $blog->blog_entry_info($blogentry_id); header('Location: ' . $url->url_create('blog_entry', $blogentry_info['user_username'], $blogentry_id)); exit; } echo $blog->blog_trackback_receive(); exit; } /* ***** ACTIONS BELOW THIS LINE REQUIRE THE USER TO BE LOGGED IN ***** */ if (!$user->user_exists) { echo json_encode(array('result' => FALSE)); exit; } // DELETE if ($task == "deleteblog") { $result = $blog->blog_entry_delete($blogentry_id); echo json_encode(array('result' => $result ? 'success' : 'failure')); exit; } elseif ($task == "previewblog") { $page = "blog"; $owner =& $user; $blog->user_id = $user->user_info['user_id']; $blogentry_title = $_POST['blogentry_title']; $blogentry_body = $_POST['blogentry_body']; $blogentry_blogentrycat_id = $_POST['blogentry_blogentrycat_id']; $blogentry_body = str_replace("\r\n", "", htmlspecialchars_decode($blogentry_body)); // GET CUSTOM BLOG STYLE IF ALLOWED if ($user->level_info['level_blog_style']) { $blogstyle_info = $database->database_fetch_assoc($database->database_query("SELECT blogstyle_css FROM se_blogstyles WHERE blogstyle_user_id='{$owner->user_info['user_id']}' LIMIT 1")); $global_css = $blogstyle_info['blogstyle_css']; }