Exemplo n.º 1
0
include_once "pv_core.php";
include_once "modules/module_userreg.php";
// convert encoding to UTF-8
i18n_array_to_utf8($Pivot_Vars, $dummy_variable);
if (isset($Pivot_Vars['w']) && $Pivot_Vars['w'] != "") {
    // weblog_from_para returns false if the weblog doesn't exist.
    $override_weblog = weblog_from_para($Pivot_Vars['w']);
    if (!$override_weblog) {
        piv_error("Weblog doesn't exist", "Selected weblog \"" . htmlspecialchars($Pivot_Vars['w']) . "\" doesn't exist.");
    } else {
        $Pivot_Vars['w'] = $override_weblog;
    }
}
if (isset($Pivot_Vars['c']) && $Pivot_Vars['c'] != "") {
    // category_from_para returns false if the category doesn't exist.
    $override_category = category_from_para($Pivot_Vars['c']);
    if (!$override_category) {
        piv_error("Category doesn't exist", "Selected category \"" . htmlspecialchars($Pivot_Vars['c']) . "\" doesn't exist.");
    } else {
        $Pivot_Vars['c'] = $override_category;
        // (By enabling the commented out code below you can also require that
        // the category is actually published by a weblog.)
        /*
        $in_weblogs = find_weblogs_with_cat($Pivot_Vars['c']);
        if (count($in_weblogs) == 0) {
        	piv_error(lang('error','category_404'), lang('error','category_404_desc'),0);
        }
        */
    }
}
if (!isset($Pivot_Vars['w']) || $Pivot_Vars['w'] == "") {
Exemplo n.º 2
0
/**
 * Delete a category, then show see_categories again. this function now also removes
 * deleted categories from the 'cat-searchexclusion' array
 *
 * @see see_categories()
 */
function delete_category()
{
    global $Cfg, $Pivot_Vars;
    // check against unauthorised direct access.
    check_csrf();
    if ($Pivot_Vars['delete'] != 1) {
        see_categories();
    } elseif ($Pivot_Vars['confirmed'] != 1) {
        $vars = array('category', $Pivot_Vars['cat'], 'delete', 1);
        ConfirmPage(lang('category', 'delete'), $vars, sprintf(lang('category', 'delete_message'), $Pivot_Vars['username']));
    } else {
        $cat_to_del = category_from_para($Pivot_Vars['category']);
        $cats = cfg_getarray('cats');
        foreach ($cats as $cat) {
            if ($cat != $cat_to_del) {
                $cats_to_keep[] = $cat;
            }
        }
        $Cfg['cats'] = implode($cats_to_keep, "|");
        unset($Cfg['cat-' . $cat_to_del]);
        // delete from searchexclusion categories
        if (isset($Cfg['cats-searchexclusion'])) {
            $searchexclusion_arr = explode("|", $Cfg['cats-searchexclusion']);
            if (in_array($cat_to_del, $searchexclusion_arr)) {
                $cats_to_keep = array();
                foreach ($searchexclusion_arr as $cat) {
                    if ($cat != $cat_to_del) {
                        $cats_to_keep[] = $cat;
                    }
                }
                $Cfg['cats-searchexclusion'] = implode($cats_to_keep, "|");
            }
        }
        // delete from non-public categories
        if (isset($Cfg['cats-nonpublic'])) {
            $nonpublic_arr = explode("|", $Cfg['cats-nonpublic']);
            if (in_array($cat_to_del, $nonpublic_arr)) {
                $cats_to_keep = array();
                foreach ($nonpublic_arr as $cat) {
                    if ($cat != $cat_to_del) {
                        $cats_to_keep[] = $cat;
                    }
                }
                $Cfg['cats-nonpublic'] = implode($cats_to_keep, "|");
            }
        }
        // delete from hidden categories
        if (isset($Cfg['cats-hidden'])) {
            $hidden_arr = explode("|", $Cfg['cats-hidden']);
            if (in_array($cat_to_del, $hidden_arr)) {
                $cats_to_keep = array();
                foreach ($hidden_arr as $cat) {
                    if ($cat != $cat_to_del) {
                        $cats_to_keep[] = $cat;
                    }
                }
                $Cfg['cats-hidden'] = implode($cats_to_keep, "|");
            }
        }
        see_categories();
    }
}