".$locale['blog_0523'].""); redirect(FUSION_SELF.$aidlink); } else { $result = dbquery("DELETE FROM ".DB_BLOG_CATS." WHERE blog_cat_id='".intval($_GET['cat_id'])."'"); addNotice("success", $locale['blog_0524b']); redirect(FUSION_SELF.$aidlink); } redirect(clean_request("", ["action"], FALSE)); } $data = [ "blog_cat_id" => 0, "blog_cat_name" => "", "blog_cat_hidden" => [], "blog_cat_parent" => 0, "blog_cat_image" => "", "blog_cat_language" => LANGUAGE, ]; $formAction = FUSION_REQUEST; $formTitle = $locale['blog_0409']; // if edit, override $data if (isset($_POST['save_cat'])) { $inputArray = [ "blog_cat_id" => form_sanitizer($_POST['blog_cat_id'], "", "blog_cat_id"), "blog_cat_name" => form_sanitizer($_POST['blog_cat_name'], "", "blog_cat_name"), "blog_cat_parent" => form_sanitizer($_POST['blog_cat_parent'], 0, "blog_cat_parent"), "blog_cat_image" => form_sanitizer($_POST['blog_cat_image'], "", "blog_cat_image"), "blog_cat_language" => form_sanitizer($_POST['blog_cat_language'], LANGUAGE, "blog_cat_language"), ]; $categoryNameCheck = [ "when_updating" => "blog_cat_name='".$inputArray['blog_cat_name']."' and blog_cat_id !='".$inputArray['blog_cat_id']."' ".(multilang_table("BL") ? "and ".in_group('blog_cat_language', LANGUAGE) : ""), "when_saving" => "blog_cat_name='".$inputArray['blog_cat_name']."' ".(multilang_table("BL") ? "and ".in_group('blog_cat_language', LANGUAGE) : ""), ]; if (defender::safe()) { // check category name is unique when updating if (dbcount("(blog_cat_id)", DB_BLOG_CATS, "blog_cat_id='".$inputArray['blog_cat_id']."'")) { if (!dbcount("(blog_cat_id)", DB_BLOG_CATS, $categoryNameCheck['when_updating'])) { dbquery_insert(DB_BLOG_CATS, $inputArray, "update"); addNotice("success", $locale['blog_0521']); // FUSION_REQUEST without the "action" gets redirect(clean_request("", ["action"], FALSE)); } else { addNotice('danger', $locale['blog_0561']); } } else { // check category name is unique when saving new if (!dbcount("(blog_cat_id)", DB_BLOG_CATS, $categoryNameCheck['when_saving'])) { dbquery_insert(DB_BLOG_CATS, $inputArray, "save"); addNotice("success", $locale['blog_0520']); redirect(FUSION_REQUEST); } else { addNotice('danger', $locale['blog_0561']); } } } } else if ((isset($_GET['action']) && $_GET['action'] == "edit") && (isset($_GET['cat_id']) && isnum($_GET['cat_id']))) { $result = dbquery("SELECT blog_cat_id, blog_cat_name, blog_cat_parent, blog_cat_image, blog_cat_language FROM ".DB_BLOG_CATS." ".(multilang_table("BL") ? "WHERE ".in_group('blog_cat_language', LANGUAGE)." AND" : "WHERE")." blog_cat_id='".intval($_GET['cat_id'])."'"); if (dbrows($result)) { $data = dbarray($result); $data['blog_cat_hidden'] = [$data['blog_cat_id']]; $formTitle = $locale['blog_0402']; } else { // FUSION_REQUEST without the "action" gets redirect(clean_request("", ["action"], FALSE)); } } \PHPFusion\BreadCrumbs::getInstance()->addBreadCrumb(['link' => FUSION_REQUEST, 'title' => $formTitle]); echo '