addBreadCrumb(['link' => INFUSIONS.'blog/blog_admin.php'.fusion_get_aidlink(), 'title' => $locale['blog_0405']]); add_to_title($locale['blog_0405']); if (!empty($_GET['section'])) { switch ($_GET['section']) { case "blog_form": \PHPFusion\BreadCrumbs::getInstance()->addBreadCrumb(['link' => FUSION_REQUEST, 'title' => $locale['blog_0401']]); break; case "blog_category": \PHPFusion\BreadCrumbs::getInstance()->addBreadCrumb(['link' => FUSION_REQUEST, 'title' => $locale['blog_0502']]); break; case "settings": \PHPFusion\BreadCrumbs::getInstance()->addBreadCrumb(['link' => FUSION_REQUEST, 'title' => $locale['blog_0406']]); break; case "submissions": \PHPFusion\BreadCrumbs::getInstance()->addBreadCrumb(["link" => FUSION_REQUEST, "title" => $locale['blog_0600']]); break; default: } } if (isset($_POST['cancel'])) { redirect(FUSION_SELF.$aidlink); } if (isset($_GET['action']) && $_GET['action'] == 'delete' && isset($_GET['blog_id']) && isnum($_GET['blog_id'])) { $del_data['blog_id'] = $_GET['blog_id']; $result = dbquery("SELECT blog_image, blog_image_t1, blog_image_t2 FROM ".DB_BLOG." WHERE blog_id='".$del_data['blog_id']."'"); if (dbrows($result)) { $data = dbarray($result); if (!empty($data['blog_image']) && file_exists(IMAGES_B.$data['blog_image'])) { unlink(IMAGES_B.$data['blog_image']); } if (!empty($data['blog_image_t1']) && file_exists(IMAGES_B_T.$data['blog_image_t1'])) { unlink(IMAGES_B_T.$data['blog_image_t1']); } if (!empty($data['blog_image_t2']) && file_exists(IMAGES_B_T.$data['blog_image_t2'])) { unlink(IMAGES_B_T.$data['blog_image_t2']); } $result = dbquery("DELETE FROM ".DB_BLOG." WHERE blog_id='".$del_data['blog_id']."'"); $result = dbquery("DELETE FROM ".DB_COMMENTS." WHERE comment_item_id='".$del_data['blog_id']."' and comment_type='B'"); $result = dbquery("DELETE FROM ".DB_RATINGS." WHERE rating_item_id='".$del_data['blog_id']."' and rating_type='B'"); addNotice('success', $locale['blog_0412']); redirect(FUSION_SELF.$aidlink); } else { redirect(FUSION_SELF.$aidlink); } } $allowed_pages = [ "blog", "blog_category", "blog_form", "submissions", "settings" ]; $_GET['section'] = isset($_GET['section']) && in_array($_GET['section'], $allowed_pages) ? $_GET['section'] : "blog"; $edit = (isset($_GET['action']) && $_GET['action'] == 'edit' && isset($_GET['blog_id']) && isnum($_GET['blog_id'])) ? TRUE : FALSE; $tab['title'][] = $locale['blog_0400']; $tab['id'][] = 'blog'; $tab['icon'][] = 'fa fa-graduation-cap'; $tab['title'][] = $edit ? $locale['blog_0402'] : $locale['blog_0401']; $tab['id'][] = 'blog_form'; $tab['icon'][] = 'fa fa-plus'; $tab['title'][] = $locale['blog_0502']; $tab['id'][] = 'blog_category'; $tab['icon'][] = 'fa fa-folder'; $tab['title'][] = $locale['blog_0600']." ".dbcount("(submit_id)", DB_SUBMISSIONS, "submit_type='b'").""; $tab['id'][] = 'submissions'; $tab['icon'][] = 'fa fa-fw fa-inbox'; $tab['title'][] = $locale['blog_0406']; $tab['id'][] = 'settings'; $tab['icon'][] = 'fa fa-cogs'; $tab_active = $_GET['section']; opentable($locale['blog_0405']); echo opentab($tab, $tab_active, "blog", TRUE, "", "section", ['rowstart', 'filter_cid']); switch ($_GET['section']) { case "blog_form": include "admin/blog.php"; break; case "blog_category": include "admin/blog_cat.php"; break; case "settings": include "admin/blog_settings.php"; break; case "submissions": include "admin/blog_submissions.php"; break; default: blog_listing(); } echo closetab(); closetable(); require_once THEMES.'templates/footer.php'; /** * Blog Listing HTML */ function blog_listing() { $locale = fusion_get_locale(); $aidlink = fusion_get_aidlink(); // Remodel display results into straight view instead category container sorting. // consistently monitor sql results rendertime. -- Do not Surpass 0.15 // all blog are uncategorized by default unless specified. $limit = 15; $total_rows = dbcount("(blog_id)", DB_BLOG, (multilang_table("BL") ? in_group('blog_language', LANGUAGE) : "")); $rowstart = isset($_GET['rowstart']) && ($_GET['rowstart'] <= $total_rows) ? $_GET['rowstart'] : 0; // add a filter browser $catOpts = [ "all" => $locale['blog_0460'], "0" => $locale['blog_0424'] ]; $categories = dbquery("select blog_cat_id, blog_cat_name FROM ".DB_BLOG_CATS." ".(multilang_table("BL") ? "where ".in_group('blog_cat_language', LANGUAGE) : "").""); if (dbrows($categories) > 0) { while ($cat_data = dbarray($categories)) { $catOpts[$cat_data['blog_cat_id']] = $cat_data['blog_cat_name']; } } // prevent xss $catFilter = ""; if (isset($_GET['filter_cid']) && isnum($_GET['filter_cid']) && isset($catOpts[$_GET['filter_cid']])) { if ($_GET['filter_cid'] > 0) { $catFilter = in_group("blog_cat", intval($_GET['filter_cid'])); } } $langFilter = multilang_table("BL") ? ($catFilter != '' ? " AND " : '').in_group('blog_language', LANGUAGE) : ""; $filter = $catFilter.$langFilter; $result = dbquery(" SELECT blog_id, blog_cat, blog_subject, blog_image, blog_image_t1, blog_image_t2, blog_blog, blog_draft FROM ".DB_BLOG." ".($filter ? "WHERE ".$filter : "")." ORDER BY blog_draft DESC, blog_sticky DESC, blog_datestamp DESC LIMIT $rowstart, $limit "); $rows = dbrows($result); echo "