⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 category.php

📁 在综合英文版XOOPS 2.09, 2.091, 2.092 的基础上正式发布XOOPS 2.09中文版 XOOPS 2.09x 版主要是PHP5升级、bug修正和安全补正: 1 全面兼容PHP 5.
💻 PHP
📖 第 1 页 / 共 2 页
字号:
            $create_tray -> addElement(new XoopsFormHidden('ok', 1));
            $create_tray -> addElement(new XoopsFormHidden('op', 'move'));
            $butt_save = new XoopsFormButton('', '', _AM_WFD_BMOVE, 'submit');
            $butt_save -> setExtra('onclick="this.form.elements.op.value=\'move\'"');
            $create_tray -> addElement($butt_save);
            $butt_cancel = new XoopsFormButton('', '', _AM_WFD_BCANCEL, 'submit');
            $butt_cancel -> setExtra('onclick="this.form.elements.op.value=\'cancel\'"');
            $create_tray -> addElement($butt_cancel);
            $sform -> addElement($create_tray);
            $sform -> display();
            xoops_cp_footer();
        } 
        else
        {
            global $xoopsDB;

            $source = $_POST['source'];
            $target = $_POST['target'];
            if ($target == $source)
            {
                redirect_header("category.php?op=move&ok=0&cid=$source", 5, _AM_WFD_CCATEGORY_MODIFY_FAILED);
            } 

            if (!$target)
            {
                redirect_header("category.php?op=move&ok=0&cid=$source", 5, _AM_WFD_CCATEGORY_MODIFY_FAILEDT);
            } 
            $sql = "UPDATE " . $xoopsDB -> prefix("wfdownloads_downloads") . " set cid = " . $target . " WHERE cid =" . $source;
            $result = $xoopsDB -> queryF($sql);
            $error = _AM_WFD_DBERROR . ": <br /><br />" . $sql;
            if (!$result)
            {
                trigger_error($error, E_USER_ERROR);
            } 
            redirect_header("category.php?op=default", 1, _AM_WFD_CCATEGORY_MODIFY_MOVED);
            exit();
        } 
        break;

    case "addCat":

        global $xoopsDB, $myts, $_FILES, $xoopsModuleConfig;

        $groups = isset($_POST['groups']) ? $_POST['groups'] : array();
        $cid = (isset($_POST["cid"])) ? $_POST["cid"] : 0;
        $pid = (isset($_POST["pid"])) ? $_POST["pid"] : 0;
        $weight = (isset($_POST["weight"]) && $_POST["weight"] > 0) ? $_POST["weight"] : 0;
        $spotlighthis = (isset($_POST["lid"])) ? $_POST["lid"] : 0;
        $spotlighttop = ($_POST["spotlighttop"] == 1) ? 1 : 0;
        $title = $myts -> addslashes($_POST["title"]);
        $description = $myts -> addslashes($_POST["description"]);
        $summary = $myts -> addslashes($_POST["summary"]);
        $imgurl = ($_POST["imgurl"] && $_POST["imgurl"] != "blank.png") ? $myts -> addslashes($_POST["imgurl"]) : "";

        $nohtml = isset($_POST['nohtml']);
        $nosmiley = isset($_POST['nosmiley']);
        $noxcodes = isset($_POST['noxcodes']);
        $noimages = isset($_POST['noimages']);
        $nobreak = isset($_POST['nobreak']);

        if (!$cid)
        {
            $sql = "INSERT INTO " . $xoopsDB -> prefix("wfdownloads_cat") . " 
				(cid, pid, title, imgurl, description, summary, nohtml, nosmiley, 
				noxcodes, noimages, nobreak, weight, spotlighttop, spotlighthis) VALUES 
				('', $pid, '$title', '$imgurl', '$description', '$summary', '$nohtml', '$nosmiley', 
				'$noxcodes', '$noimages', '$nobreak', '$weight',  $spotlighttop, $spotlighthis)";
            $result = $xoopsDB -> query($sql);
            $error = _AM_WFD_DBERROR . ": <br /><br />" . $sql;

            if ($cid == 0) $newid = $xoopsDB -> getInsertId();
            wfd_save_Permissions($groups, $newid, 'WFDownCatPerm');
            /**
             * Notify of new category
             */
            global $xoopsModule;
            $tags = array();
            $tags['CATEGORY_NAME'] = $title;
            $tags['CATEGORY_URL'] = XOOPS_URL . '/modules/wfdownloads/viewcat.php?cid=' . $newid;
            $notification_handler = & xoops_gethandler('notification');
            $notification_handler -> triggerEvent('global', 0, 'new_category', $tags);
            $database_mess = _AM_WFD_CCATEGORY_CREATED;
        } 
        else
        {
            $sql = "UPDATE " . $xoopsDB -> prefix("wfdownloads_cat") . " SET 
				title ='$title', imgurl = '$imgurl', pid =$pid, description = '$description', summary = '$summary', 
				spotlighthis = '$spotlighthis' , spotlighttop = '$spotlighttop', nohtml='$nohtml', nosmiley='$nosmiley', 
				noxcodes='$noxcodes', noimages='$noimages', nobreak='$nobreak', weight='$weight' WHERE cid = '$cid'";
            $result = $xoopsDB -> query($sql);
            $error = _AM_WFD_DBERROR . ": <br /><br />" . $sql;
            $database_mess = _AM_WFD_CCATEGORY_MODIFIED;
            wfd_save_Permissions($groups, $cid, 'WFDownCatPerm');
        } 
        if (!$result)
        {
            trigger_error($error, E_USER_ERROR);
        } 
        redirect_header("category.php", 1, $database_mess);
        break;

    case "del":

        global $xoopsDB, $xoopsModule;

        $cid = (isset($_POST['cid']) && is_numeric($_POST['cid'])) ? intval($_POST['cid']) : intval($_GET['cid']);
        $ok = (isset($_POST['ok']) && $_POST['ok'] == 1) ? intval($_POST['ok']) : 0;
        $mytree = new XoopsTree($xoopsDB -> prefix("wfdownloads_cat"), "cid", "pid");

        if ($ok == 1)
        { 
            // get all subcategories under the specified category
            $arr = $mytree -> getAllChildId($cid);
            $lcount = count($arr);

            for ($i = 0; $i < $lcount; $i++)
            { 
                // get all downloads in each subcategory
                $result = $xoopsDB -> query("SELECT lid FROM " . $xoopsDB -> prefix("wfdownloads_downloads") . " WHERE cid=" . $arr[$i] . ""); 
                // now for each download, delete the text data and vote ata associated with the download
                while (list($lid) = $xoopsDB -> fetchRow($result))
                {
                    $sql = sprintf("DELETE FROM %s WHERE lid = %u", $xoopsDB -> prefix("wfdownloads_votedata"), $lid);
                    $xoopsDB -> query($sql);
                    $sql = sprintf("DELETE FROM %s WHERE lid = %u", $xoopsDB -> prefix("wfdownloads_downloads"), $lid);
                    $xoopsDB -> query($sql); 
                    // delete comments
                    xoops_groupperm_deletebymoditem ($xoopsModule -> getVar('mid'), 'WFDownFilePerm', $lid);
                    xoops_comment_delete($xoopsModule -> getVar('mid'), $lid);
                } 
                // all downloads for each subcategory is deleted, now delete the subcategory data
                $sql = sprintf("DELETE FROM %s WHERE cid = %u", $xoopsDB -> prefix("wfdownloads_cat"), $arr[$i]);
                $xoopsDB -> query($sql);
            } 
            // all subcategory and associated data are deleted, now delete category data and its associated data
            $result = $xoopsDB -> query("SELECT lid FROM " . $xoopsDB -> prefix("wfdownloads_downloads") . " WHERE cid=" . $cid . "");
            while (list($lid) = $xoopsDB -> fetchRow($result))
            {
                $sql = sprintf("DELETE FROM %s WHERE lid = %u", $xoopsDB -> prefix("wfdownloads_downloads"), $lid);
                $xoopsDB -> query($sql); 
                // delete comments
                xoops_comment_delete($xoopsModule -> getVar('mid'), $lid);
                $sql = sprintf("DELETE FROM %s WHERE lid = %u", $xoopsDB -> prefix("wfdownloads_votedata"), $lid);
                $xoopsDB -> query($sql);
            } 
            $sql = sprintf("DELETE FROM %s WHERE cid = %u", $xoopsDB -> prefix("wfdownloads_cat"), $cid);
            $error = _AM_WFD_DBERROR . ": <br /><br />" . $sql;
            xoops_groupperm_deletebymoditem ($xoopsModule -> getVar('mid'), 'WFDownCatPerm', $cid);
            if (!$result = $xoopsDB -> query($sql))
            {
                trigger_error($error, E_USER_ERROR);
            } 
            redirect_header("category.php", 1, _AM_WFD_CCATEGORY_DELETED);
            exit();
        } 
        else
        {
            xoops_cp_header();
            xoops_confirm(array('op' => 'del', 'cid' => $cid, 'ok' => 1), 'category.php', _AM_WFD_CCATEGORY_AREUSURE);
            xoops_cp_footer();
        } 
        break;

    case "modCat":
        $cid = (isset($_POST['cid'])) ? $_POST['cid'] : 0;
        xoops_cp_header();
        wfd_adminmenu(_AM_WFD_MCATEGORY);
        createcat($cid);
        xoops_cp_footer();
        break;

    case 'main':
    default:

        xoops_cp_header();
        wfd_adminmenu(_AM_WFD_MCATEGORY);

        include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
        $mytree = new XoopsTree($xoopsDB -> prefix("wfdownloads_cat"), "cid", "pid");
        $sform = new XoopsThemeForm(_AM_WFD_CCATEGORY_MODIFY, "category", xoops_getenv('PHP_SELF'));
        $totalcats = wfd_totalcategory();

        if ($totalcats > 0)
        {
            ob_start();
            $sform -> addElement(new XoopsFormHidden('cid', ''));
            $mytree -> makeMySelBox("title", "title");
            $sform -> addElement(new XoopsFormLabel(_AM_WFD_CCATEGORY_MODIFY_TITLE, ob_get_contents()));
            ob_end_clean();
            $dup_tray = new XoopsFormElementTray('', '');
            $dup_tray -> addElement(new XoopsFormHidden('op', 'modCat'));
            $butt_dup = new XoopsFormButton('', '', _AM_WFD_BMODIFY, 'submit');
            $butt_dup -> setExtra('onclick="this.form.elements.op.value=\'modCat\'"');
            $dup_tray -> addElement($butt_dup);
            $butt_move = new XoopsFormButton('', '', _AM_WFD_BMOVE, 'submit');
            $butt_move -> setExtra('onclick="this.form.elements.op.value=\'move\'"');
            $dup_tray -> addElement($butt_move);
            $butt_dupct = new XoopsFormButton('', '', _AM_WFD_BDELETE, 'submit');
            $butt_dupct -> setExtra('onclick="this.form.elements.op.value=\'del\'"');
            $dup_tray -> addElement($butt_dupct);
            $sform -> addElement($dup_tray);
            $sform -> display();
        } 
        createcat(0);
        xoops_cp_footer();
        break;
} 

?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -