Exemplo n.º 1
0
function ListHtml($classid, $fields, $enews = 0, $userlistr = "")
{
    global $empire, $dbtbpre, $emod_r, $public_r, $class_r, $class_zr, $fun_r, $class_tr, $level_r, $etable_r;
    //不生成栏目
    if (($enews == 0 || $enews == 3) && ($class_r[$classid]['listdt'] || $class_r[$classid]['wburl'] || strstr($public_r['nreclass'], ',' . $classid . ','))) {
        return '';
    }
    $GLOBALS['navclassid'] = $classid;
    $doclass = "index";
    $classlevel = '';
    $yhvar = 'qlist';
    if ($enews == 0) {
        $selfclassid = $classid;
        $doenews = 0;
        $cr = $empire->fetch1("select classpagekey,intro,classimg,cgroupid from {$dbtbpre}enewsclass where classid='{$classid}'");
        $mid = $class_r[$classid][modid];
        //权限
        if ($cr['cgroupid']) {
            $classlevel = AddCheckClassLevel($classid, $cr['cgroupid'], '');
        }
        //页面
        $pagetitle = htmlspecialchars($class_r[$classid][classname]);
        $pagekey = htmlspecialchars($cr['classpagekey']);
        $pagedes = htmlspecialchars($cr['intro']);
        $classimg = $cr['classimg'];
        $url = ReturnClassLink($classid);
        $haveclass = 0;
        //排序
        if (empty($class_r[$classid][reorder])) {
            $addorder = "newstime desc";
        } else {
            $addorder = $class_r[$classid][reorder];
        }
        if ($class_r[$classid][maxnum]) {
            $limit = " limit " . $class_r[$classid][maxnum];
            $limitnum = $class_r[$classid][maxnum];
        }
        //优化
        $yhid = $class_r[$classid][yhid];
        if ($yhid) {
            $yhadd = ReturnYhSql($yhid, $yhvar);
        }
        $query = "select " . ReturnSqlListF($mid) . " from {$dbtbpre}ecms_" . $class_r[$classid][tbname] . " where " . $yhadd . "classid='{$classid}' and checked=1 order by " . ReturnSetTopSql('list') . $addorder . $limit;
        $totalquery = "select count(*) as total from {$dbtbpre}ecms_" . $class_r[$classid][tbname] . " where " . $yhadd . "classid='{$classid}' and checked=1";
        //统计
        $doclasspath = ReturnSaveClassPath($classid, 0);
        $dopath = ECMS_PATH . $doclasspath . "/";
        if (empty($class_r[$classid][classurl])) {
            $dolink = $public_r[newsurl] . $doclasspath . "/";
        } else {
            $dolink = $class_r[$classid][classurl] . "/";
        }
        $dotype = $class_r[$classid][classtype];
        $classname = $class_r[$classid][classname];
        $lencord = $class_r[$classid][lencord];
        //记录数
        $onclick = "<script src='" . $public_r[newsurl] . "e/public/onclick/?enews=doclass&classid={$classid}'></script>";
        //模板
        $listtempid = $class_r[$classid][listtempid];
    } elseif ($enews == 1) {
        $selfclassid = $classid;
        $doenews = 1;
        $cr = $empire->fetch1("select ztpagekey,intro,ztimg,classtempid from {$dbtbpre}enewszt where ztid='{$classid}'");
        //页面
        $pagetitle = htmlspecialchars($class_zr[$classid][ztname]);
        $pagekey = htmlspecialchars($cr['ztpagekey']);
        $pagedes = htmlspecialchars($cr['intro']);
        $classimg = $cr['ztimg'];
        $url = ReturnZtLink($classid);
        $haveclass = 1;
        if ($class_zr[$classid][islist] != 1) {
            $classtemp = $class_zr[$classid][islist] == 2 ? GetZtText($classid) : GetClassTemp($cr['classtempid']);
            NewsBq($classid, $classtemp, 3, 0);
            return "";
        }
        //排序
        if (empty($class_zr[$classid][reorder])) {
            $addorder = "newstime desc";
        } else {
            $addorder = $class_zr[$classid][reorder];
        }
        if ($class_zr[$classid][maxnum]) {
            $limit = " limit " . $class_zr[$classid][maxnum];
            $limitnum = $class_zr[$classid][maxnum];
        }
        //优化
        $tbname = $class_zr[$classid][tbname];
        $mid = $etable_r[$tbname][mid];
        $yhid = $class_zr[$classid][yhid];
        if ($yhid) {
            $yhadd = ReturnYhSql($yhid, $yhvar);
        }
        $query = "select " . ReturnSqlListF($mid) . " from {$dbtbpre}ecms_" . $class_zr[$classid][tbname] . " where " . $yhadd . "ztid like '%|" . $classid . "|%' and checked=1 order by " . $addorder . $limit;
        $totalquery = "select count(*) as total from {$dbtbpre}ecms_" . $class_zr[$classid][tbname] . " where " . $yhadd . "ztid like '%|" . $classid . "|%' and checked=1";
        //统计
        $doclasspath = ReturnSaveZtPath($classid, 0);
        $dopath = ECMS_PATH . $doclasspath . "/";
        if (empty($class_zr[$classid][zturl])) {
            $dolink = $public_r[newsurl] . $doclasspath . "/";
        } else {
            $dolink = $class_zr[$classid][zturl] . "/";
        }
        $dotype = $class_zr[$classid][zttype];
        $classname = $class_zr[$classid][ztname];
        $lencord = $class_zr[$classid][ztnum];
        //记录数
        $onclick = "<script src='" . $public_r[newsurl] . "e/public/onclick/?enews=dozt&ztid={$classid}'></script>";
        //模板
        $listtempid = $class_zr[$classid][listtempid];
    } elseif ($enews == 3) {
        $selfclassid = $classid;
        $doenews = 0;
        $cr = $empire->fetch1("select classpagekey,intro,classimg,cgroupid from {$dbtbpre}enewsclass where classid='{$classid}'");
        $mid = $class_r[$classid][modid];
        //权限
        if ($cr['cgroupid']) {
            $classlevel = AddCheckClassLevel($classid, $cr['cgroupid'], '');
        }
        //页面
        $pagetitle = htmlspecialchars($class_r[$classid][classname]);
        $pagekey = htmlspecialchars($cr['classpagekey']);
        $pagedes = htmlspecialchars($cr['intro']);
        $classimg = $cr['classimg'];
        $url = ReturnClassLink($classid);
        $haveclass = 1;
        //排序
        if (empty($class_r[$classid][reorder])) {
            $addorder = "newstime desc";
        } else {
            $addorder = $class_r[$classid][reorder];
        }
        if ($class_r[$classid][maxnum]) {
            $limit = " limit " . $class_r[$classid][maxnum];
            $limitnum = $class_r[$classid][maxnum];
        }
        $whereclass = ReturnClass($class_r[$classid][sonclass]);
        //优化
        $yhid = $class_r[$classid][yhid];
        if ($yhid) {
            $yhadd = ReturnYhSql($yhid, $yhvar);
        }
        $query = "select " . ReturnSqlListF($mid) . " from {$dbtbpre}ecms_" . $class_r[$classid][tbname] . " where " . $yhadd . "(" . $whereclass . ") and checked=1 order by " . ReturnSetTopSql('list') . $addorder . $limit;
        $totalquery = "select count(*) as total from {$dbtbpre}ecms_" . $class_r[$classid][tbname] . " where " . $yhadd . "(" . $whereclass . ") and checked=1";
        //统计
        $doclasspath = ReturnSaveClassPath($classid, 0);
        $dopath = ECMS_PATH . $doclasspath . "/";
        if (empty($class_r[$classid][classurl])) {
            $dolink = $public_r[newsurl] . $doclasspath . "/";
        } else {
            $dolink = $class_r[$classid][classurl] . "/";
        }
        $dotype = $class_r[$classid][classtype];
        $classname = $class_r[$classid][classname];
        $lencord = $class_r[$classid][lencord];
        //记录数
        $onclick = "<script src='" . $public_r[newsurl] . "e/public/onclick/?enews=doclass&classid={$classid}'></script>";
        //模板
        $listtempid = $class_r[$classid][listtempid];
    } elseif ($enews == 4) {
        $selfclassid = 0;
        $doenews = 1;
        $userlistr['listsql'] = RepSqlTbpre($userlistr['listsql']);
        $userlistr['totalsql'] = RepSqlTbpre($userlistr['totalsql']);
        //页面
        $pagetitle = htmlspecialchars($userlistr['pagetitle']);
        $pagekey = $pagetitle;
        $pagedes = $pagetitle;
        $haveclass = 1;
        if ($userlistr['maxnum']) {
            $limit = " limit " . $userlistr['maxnum'];
            $limitnum = $userlistr['maxnum'];
        }
        $query = stripSlashes($userlistr['listsql']) . $limit;
        //统计
        $totalquery = stripSlashes($userlistr['totalsql']);
        $dopath = $userlistr['addpath'] . $userlistr['filepath'];
        $dolink = $public_r[newsurl] . str_replace($userlistr['addpath'] . '../../', '', $dopath);
        $dotype = $userlistr['filetype'];
        $classname = $userlistr['pagetitle'];
        $lencord = $userlistr['lencord'];
        //记录数
        $onclick = '';
        $url = ReturnUserPLink($pagetitle, $dolink);
        //模板
        $listtempid = $userlistr['listtempid'];
    }
    if (empty($lencord)) {
        $lencord = 25;
    }
    //列表模板
    $listtemp_r = GetListTemp($listtempid);
    $listtemp = $listtemp_r[temptext];
    $subnews = $listtemp_r[subnews];
    $subtitle = $listtemp_r[subtitle];
    $docode = $listtemp_r[docode];
    $listvar = str_replace('[!--news.url--]', $public_r[newsurl], $listtemp_r[listvar]);
    $rownum = $listtemp_r[rownum];
    $formatdate = $listtemp_r[showdate];
    if (empty($rownum)) {
        $rownum = 1;
    }
    if (empty($mid)) {
        $mid = $listtemp_r[modid];
    }
    $field = ReturnReplaceListF($mid);
    //分页列表函数
    if (!empty($public_r['listpagefun']) || !empty($public_r['listpagelistfun'])) {
        if (strstr($listtemp, '[!--show.page--]')) {
            $thefun = $public_r['listpagefun'];
            $bereplistpage = '[!--show.page--]';
        } else {
            $thefun = $public_r['listpagelistfun'];
            $bereplistpage = '[!--show.listpage--]';
        }
    } else {
        $thefun = 'sys_ShowListPage';
        $bereplistpage = '[!--show.page--]';
    }
    //替换模板变量
    $listtemp = str_replace('[!--newsnav--]', $url, $listtemp);
    //位置导航
    $listtemp = Class_ReplaceSvars($listtemp, $url, $selfclassid, $pagetitle, $pagekey, $pagedes, $classimg, $add, $doenews);
    $listtemp = str_replace('[!--page.stats--]', $onclick, $listtemp);
    $no = 1;
    $ok = 0;
    $changerow = 1;
    $num = $empire->gettotal($totalquery);
    //最大数
    if ($limitnum && $limitnum < $num) {
        $num = $limitnum;
    }
    $page = ceil($num / $lencord);
    //取得列表模板
    $list_exp = "[!--empirenews.listtemp--]";
    $list_r = explode($list_exp, $listtemp);
    //无信息
    if (empty($num)) {
        $noinfopath = $dopath . "index" . $dotype;
        NotinfoListHtml($noinfopath, $list_r, $classlevel);
        return "";
    }
    $sql = $empire->query($query);
    $listtext = $list_r[1];
    while ($k = $empire->fetch($sql)) {
        //替换列表变量
        $repvar = ReplaceListVars($no, $listvar, $subnews, $subtitle, $formatdate, $url, $haveclass, $k, $field, $docode);
        $listtext = str_replace("<!--list.var" . $changerow . "-->", $repvar, $listtext);
        $changerow += 1;
        //超过行数
        if ($changerow > $rownum) {
            $changerow = 1;
            $string .= $listtext;
            $listtext = $list_r[1];
        }
        if ($no % $lencord == 0 || $num % $lencord != 0 && $num == $no) {
            $ok += 1;
            $pagenum = ceil($no / $lencord);
            //首页
            if ($pagenum == 1) {
                $path = $dopath . "index" . $dotype;
            } else {
                $path = $dopath . "index_" . $ok . $dotype;
            }
            //取得分页参数
            $returnpager = $thefun($num, $pagenum, $dolink, $dotype, $page, $lencord, $ok, $myoptions);
            $showpage = $returnpager['showpage'];
            $myoptions = $returnpager['option'];
            $list1 = str_replace($bereplistpage, $showpage, $list_r[0]);
            $list2 = str_replace($bereplistpage, $showpage, $list_r[2]);
            //多余数据
            if ($changerow <= $rownum && $listtext != $list_r[1]) {
                $string .= $listtext;
            }
            $listtext = $list_r[1];
            $changerow = 1;
            $string = $list1 . $string . $list2;
            //替换分页数
            $string = str_replace('[!--list.pageno--]', $pagenum, $string);
            WriteFiletext($path, $classlevel . $string);
            $string = '';
        }
        $no++;
    }
    $empire->free($sql);
}
Exemplo n.º 2
0
function EditZt($add, $userid, $username)
{
    global $empire, $class_r, $dbtbpre;
    $add[ztid] = (int) $add[ztid];
    $add[ztpath] = trim($add[ztpath]);
    if (!$add[ztname] || !$add[listtempid] || !$add[ztpath] || !$add[ztid]) {
        printerror("EmptyZt", "");
    }
    CheckLevel($userid, $username, $classid, "zt");
    $add = DoPostZtVar($add);
    //改变目录
    if ($add[oldztpath] != $add[ztpath]) {
        $createpath = '../../' . $add[ztpath];
        if (file_exists($createpath)) {
            printerror("ReZtpath", "");
        }
        if ($add['oldpripath'] == $add['pripath']) {
            $new = "../../";
            @rename($new . $add[oldztpath], $new . $add[ztpath]);
            //改变目录名
        } else {
            CreateZtPath($add[ztpath]);
            //建立专题目录
        }
    }
    //取得表名
    $tabler = GetModTable(GetListtempMid($add[listtempid]));
    $tabler[tid] = (int) $tabler[tid];
    $sql = $empire->query("update {$dbtbpre}enewszt set ztname='{$add['ztname']}',ztnum={$add['ztnum']},listtempid={$add['listtempid']},ztpath='{$add['ztpath']}',zttype='{$add['zttype']}',newline={$add['newline']},zturl='{$add['zturl']}',hotline={$add['hotline']},goodline={$add['goodline']},classid={$add['classid']},hotplline={$add['hotplline']},firstline={$add['firstline']},islist={$add['islist']},maxnum={$add['maxnum']},tid={$tabler['tid']},tbname='{$tabler['tbname']}',reorder='{$add['reorder']}',intro='{$add['intro']}',ztimg='{$add['ztimg']}',zcid={$add['zcid']},jstempid={$add['jstempid']},showzt={$add['showzt']},ztpagekey='{$add['ztpagekey']}',classtempid='{$add['classtempid']}',myorder={$add['myorder']},nrejs={$add['nrejs']},usezt='{$add['usezt']}',yhid='{$add['yhid']}' where ztid='{$add['ztid']}'");
    //副表
    $ret_zr = ReturnZtAddF($add, 1);
    $empire->query("update {$dbtbpre}enewsztadd set classtext='" . addslashes($add[classtext]) . "'" . $ret_zr[0] . " where ztid='{$add['ztid']}'");
    GetClass();
    //更新缓存
    //生成页面
    if ($add[islist] == 0 || $add[islist] == 2) {
        $classtemp = $add[islist] == 2 ? GetZtText($add[ztid]) : GetClassTemp($add['classtempid']);
        NewsBq($add[ztid], $classtemp, 3, 1);
    }
    if ($sql) {
        insert_dolog("ztid=" . $add[ztid] . "<br>ztname=" . $add[ztname]);
        //操作日志
        printerror("EditZtSuccess", "ListZt.php");
    } else {
        printerror("DbError", "");
    }
}
Exemplo n.º 3
0
function EditZt($add, $userid, $username)
{
    global $empire, $class_r, $dbtbpre, $loginlevel;
    $add[ztid] = (int) $add[ztid];
    $add[ztpath] = trim($add[ztpath]);
    if (!$add[ztname] || !$add[listtempid] || !$add[ztpath] || !$add[ztid]) {
        printerror("EmptyZt", "");
    }
    $add = DoPostZtVar($add);
    //CheckLevel($userid,$username,$classid,"zt");
    $returnandlevel = CheckAndUsernamesLevel('dozt', $add[ztid], $userid, $username, $loginlevel);
    $upusernames = '';
    if ($returnandlevel == 2) {
        $upusernames = ",usernames='{$add['usernames']}'";
    }
    //改变目录
    if ($add[oldztpath] != $add[ztpath]) {
        $createpath = '../../' . $add[ztpath];
        if (file_exists($createpath)) {
            printerror("ReZtpath", "");
        }
        if ($add['oldpripath'] == $add['pripath']) {
            $new = "../../";
            @rename($new . $add[oldztpath], $new . $add[ztpath]);
            //改变目录名
        } else {
            CreateZtPath($add[ztpath]);
            //建立专题目录
        }
    }
    //取得表名
    $tabler = GetModTable(GetListtempMid($add[listtempid]));
    $tabler[tid] = (int) $tabler[tid];
    $sql = $empire->query("update {$dbtbpre}enewszt set ztname='{$add['ztname']}',ztnum={$add['ztnum']},listtempid={$add['listtempid']},ztpath='{$add['ztpath']}',zttype='{$add['zttype']}',zturl='{$add['zturl']}',classid={$add['classid']},islist={$add['islist']},maxnum={$add['maxnum']},reorder='{$add['reorder']}',intro='{$add['intro']}',ztimg='{$add['ztimg']}',zcid={$add['zcid']},showzt={$add['showzt']},ztpagekey='{$add['ztpagekey']}',classtempid='{$add['classtempid']}',myorder={$add['myorder']},usezt='{$add['usezt']}',yhid='{$add['yhid']}',endtime='{$add['endtime']}',closepl='{$add['closepl']}',checkpl='{$add['checkpl']}',pltempid='{$add['pltempid']}'" . $upusernames . " where ztid='{$add['ztid']}'");
    //副表
    $ret_zr = ReturnZtAddF($add, 1);
    $empire->query("update {$dbtbpre}enewsztadd set classtext='" . eaddslashes2($add[classtext]) . "'" . $ret_zr[0] . " where ztid='{$add['ztid']}'");
    //更新专题子类
    if ($add['endtime'] != $add['oldendtime']) {
        $empire->query("update {$dbtbpre}enewszttype set endtime='{$add['endtime']}' where ztid='{$add['ztid']}'");
    }
    //更新附件
    UpdateTheFileEditOther(2, $add['ztid'], 'other');
    GetClass();
    //更新缓存
    //生成页面
    if ($add[islist] == 0 || $add[islist] == 2) {
        $classtemp = $add[islist] == 2 ? GetZtText($add[ztid]) : GetClassTemp($add['classtempid']);
        NewsBq($add[ztid], $classtemp, 3, 1);
    }
    if ($sql) {
        $returnurl = 'special/ListZt.php' . hReturnEcmsHashStrHref2(1);
        if ($add['from']) {
            $returnurl = 'special/AddZt.php?enews=EditZt&ztid=' . $add[ztid] . '&from=1' . hReturnEcmsHashStrHref2(0);
        }
        insert_dolog("ztid=" . $add[ztid] . "<br>ztname=" . $add[ztname]);
        //操作日志
        printerror("EditZtSuccess", $returnurl);
    } else {
        printerror("DbError", "");
    }
}