0, "download_cat_parent" => 0, "download_cat_hidden" => [], "download_cat_name" => "", "download_cat_description" => "", "download_cat_language" => LANGUAGE, "download_cat_sort_by" => "", "download_cat_sort_order" => "ASC", ]; if (isset($_POST['save_cat'])) { $data = [ "download_cat_id" => form_sanitizer($_POST['download_cat_id'], "", "download_cat_id"), "download_cat_parent" => form_sanitizer($_POST['download_cat_parent'], "", "download_cat_parent"), "download_cat_hidden" => [], "download_cat_name" => form_sanitizer($_POST['download_cat_name'], "", "download_cat_name"), "download_cat_description" => form_sanitizer($_POST['download_cat_description'], "", "download_cat_description"), "download_cat_language" => form_sanitizer($_POST['download_cat_language'], "", "download_cat_language"), "download_cat_sort_by" => form_sanitizer($_POST['download_cat_sort_by'], "", "download_cat_sort_by"), "download_cat_sort_order" => form_sanitizer($_POST['download_cat_sort_order'], "DESC", "download_cat_sort_order"), ]; switch ($data['download_cat_sort_by']) { case 1: $data['download_cat_sorting'] = "download_id ".($data['download_cat_sort_order'] == "ASC" ? "ASC" : "DESC"); break; case 2: $data['download_cat_sorting'] = "download_title ".($_POST['download_cat_sort_order'] == "ASC" ? "ASC" : "DESC"); break; case 3: $data['download_cat_sorting'] = "download_datestamp ".($_POST['download_cat_sort_order'] == "ASC" ? "ASC" : "DESC"); break; default: $data['download_cat_sorting'] = "download_title ASC"; } // Category Name Check $categoryNameCheck = [ "when_updating" => "download_cat_name='".$data['download_cat_name']."' and download_cat_id !='".$data['download_cat_id']."'", "when_saving" => "download_cat_name='".$data['download_cat_name']."'", ]; if (defender::safe()) { if (dbcount("(download_cat_id)", DB_DOWNLOAD_CATS, "download_cat_id='".$data['download_cat_id']."'")) { if (!dbcount("(download_cat_id)", DB_DOWNLOAD_CATS, $categoryNameCheck['when_updating'])) { dbquery_insert(DB_DOWNLOAD_CATS, $data, "update"); addNotice("success", $locale['download_0151']); redirect(clean_request("cat_view=1", ["section", "aid"], TRUE)); } else { \defender::stop(); addNotice("danger", $locale['download_0352']); } } else { if (!dbcount("(download_cat_id)", DB_DOWNLOAD_CATS, $categoryNameCheck['when_saving'])) { dbquery_insert(DB_DOWNLOAD_CATS, $data, "save"); addNotice("success", $locale['download_0150']); redirect(clean_request("cat_view=1", ["section", "aid"], TRUE)); } else { \defender::stop(); addNotice("danger", $locale['download_0352']); } } } } if ((isset($_GET['action']) && $_GET['action'] == "edit") && (isset($_GET['cat_id']) && isnum($_GET['cat_id']))) { $result = dbquery("SELECT * FROM ".DB_DOWNLOAD_CATS." ".(multilang_table("DL") ? "WHERE ".in_group('download_cat_language', LANGUAGE)." AND" : "WHERE")." download_cat_id='".$_GET['cat_id']."'"); if (dbrows($result)) { $data = dbarray($result); $data['download_cat_hidden'] = [$data['download_cat_id']]; $cat_sorting = explode(" ", $data['download_cat_sorting']); $data['download_cat_sort_by'] = ""; if ($cat_sorting[0] == "download_id") { $data['download_cat_sort_by'] = "1"; } else if ($cat_sorting[0] == "download_title") { $data['download_cat_sort_by'] = "2"; } else if ($cat_sorting[0] == "download_datestamp") { $data['download_cat_sort_by'] = "3"; } $data['download_cat_sort_order'] = $cat_sorting[1]; } else { redirect(clean_request("", ["section", "aid"], TRUE)); } } $tab_cats['title'][] = $locale['download_0023']; $tab_cats['id'][] = "dlcats_form"; $tab_cats['icon'][] = ""; $tab_cats['title'][] = $locale['download_0020']; $tab_cats['id'][] = "dlcats"; $tab_cats['icon'][] = ""; $tab_cats_active = tab_active($tab_cats, isset($_GET['cat_view']) ? 1 : 0); echo opentab($tab_cats, $tab_cats_active, 'dcategory', FALSE, "nav-tabs m-t-10"); echo opentabbody($tab_cats['title'][0], $tab_cats['id'][0], $tab_cats_active); echo openform('addcat', 'post', FUSION_REQUEST, ['class' => 'm-t-20']); echo "