コード例 #1
0
function TogZt($add, $userid, $username)
{
    global $empire, $class_r, $dbtbpre;
    $ztid = (int) $add['ztid'];
    if (empty($ztid)) {
        printerror("ErrorUrl", "history.go(-1)");
    }
    $r = $empire->fetch1("select ztid,ztname,tbname from {$dbtbpre}enewszt where ztid={$ztid}");
    if (empty($r['ztid']) || empty($r['tbname'])) {
        printerror("ErrorUrl", "history.go(-1)");
    }
    $wheresql = "";
    $formvar = "";
    //关键字
    $keyboard = RepPostVar2($add['keyboard']);
    if ($keyboard) {
        $formvar .= ReturnFormHidden('keyboard', $add['keyboard']);
        $searchfsql = '';
        if ($add['stitle']) {
            $searchfsql .= "title like '%{$keyboard}%'";
            $formvar .= ReturnFormHidden('stitle', $add['stitle']);
        }
        if ($add['susername']) {
            if ($searchfsql) {
                $or = " or ";
            }
            $searchfsql .= $or . "username like '%{$keyboard}%'";
            $formvar .= ReturnFormHidden('susername', $add['susername']);
        }
        if ($add['snewstext']) {
            $or = "";
            if ($searchfsql) {
                $or = " or ";
            }
            $searchfsql .= $or . "newstext like '%{$keyboard}%'";
            $formvar .= ReturnFormHidden('snewstext', $add['snewstext']);
        }
        if ($searchfsql) {
            $wheresql = " and (" . $searchfsql . ")";
        }
    }
    //是否推荐
    if ($add['isgood']) {
        $wheresql .= " and isgood>0";
        $formvar .= ReturnFormHidden('isgood', $add['isgood']);
    }
    //头条
    if ($add['firsttitle']) {
        $wheresql .= " and firsttitle>0";
        $formvar .= ReturnFormHidden('firsttitle', $add['firsttitle']);
    }
    //有标题图片
    if ($add['titlepic']) {
        $wheresql .= " and ispic=1";
        $formvar .= ReturnFormHidden('titlepic', $add['titlepic']);
    }
    //审核
    if ($add['checked']) {
        $wheresql .= " and checked=1";
        $formvar .= ReturnFormHidden('checked', $add['checked']);
    }
    //按栏目刷新
    $classid = (int) $add['classid'];
    if ($classid) {
        $formvar .= ReturnFormHidden('classid', $add['classid']);
        //大栏目
        if (empty($class_r[$classid][islast])) {
            $where = ReturnClass($class_r[$classid][sonclass]);
        } else {
            $where = "classid='{$classid}'";
        }
        $wheresql .= " and (" . $where . ")";
    }
    $startid = (int) $add[startid];
    $endid = (int) $add[endid];
    $startday = RepPostVar($add[startday]);
    $endday = RepPostVar($add[endday]);
    $formvar .= ReturnFormHidden('retype', $add['retype']);
    //按ID
    if ($add['retype']) {
        if ($endid) {
            $wheresql .= " and id>={$startid} and id<={$endid}";
            $formvar .= ReturnFormHidden('startid', $add[startid]) . ReturnFormHidden('endid', $add[endid]);
        }
    } else {
        if ($startday && $endday) {
            $wheresql .= " and truetime>=" . to_time($startday . " 00:00:00") . " and truetime<=" . to_time($endday . " 23:59:59");
            $formvar .= ReturnFormHidden('startday', $add[startday]) . ReturnFormHidden('endday', $add[endday]);
        }
    }
    //附件sql条件
    $query = $add['query'];
    if ($query) {
        $query = ClearAddsData($query);
        //去除adds
        $wheresql .= " and (" . $query . ")";
        $formvar .= ReturnFormHidden('query', $add['query']);
    }
    $wheresql = " where ztid not like '%|" . $ztid . "|%'" . $wheresql;
    $owheresql = $wheresql . " and ztid=''";
    if ($add['doecmszt']) {
        if ($add['inid']) {
            $add['inid'] = RepPostVar($add['inid']);
            $wheresql .= " and id not in (" . $add['inid'] . ")";
            $owheresql .= " and id not in (" . $add['inid'] . ")";
        }
        $repztid = "|" . $ztid . "|";
        $conztid = $ztid . "|";
        //将空格转换成|
        $usql = $empire->query("update {$dbtbpre}ecms_" . $r['tbname'] . " set ztid='|'" . $owheresql);
        //组成新专题
        $sql = $empire->query("update {$dbtbpre}ecms_" . $r['tbname'] . " set ztid=CONCAT(REPLACE(ztid,'" . $repztid . "','|'),'" . $conztid . "')" . $wheresql);
        if ($usql && $sql) {
            //操作日志
            insert_dolog("ztid={$ztid}&ztname={$r['ztname']}");
            printerror("TogZtSuccess", "TogZt.php?ztid={$ztid}");
        } else {
            printerror("DbError", "history.go(-1)");
        }
    }
    $re[0] = $wheresql;
    $re[1] = $formvar . ReturnFormHidden('ztid', $ztid) . ReturnFormHidden('pline', $add[pline]) . ReturnFormHidden('doecmszt', $add[doecmszt]) . ReturnFormHidden('enews', $add[enews]) . ReturnFormHidden('inid', $add[inid]);
    $re[2] = $r['tbname'];
    $re[3] = $r['ztname'];
    return $re;
}
コード例 #2
0
ファイル: classfun.php プロジェクト: novnan/meiju
function TogZt($add, $userid, $username)
{
    global $empire, $class_r, $dbtbpre;
    $ztid = (int) $add['ztid'];
    if (empty($ztid)) {
        printerror("ErrorUrl", "history.go(-1)");
    }
    $r = $empire->fetch1("select ztid,ztname from {$dbtbpre}enewszt where ztid='{$ztid}'");
    if (empty($r['ztid'])) {
        printerror("ErrorUrl", "history.go(-1)");
    }
    $zcid = (int) $add['zcid'];
    $tbname = RepPostVar($add['tbname']);
    if (!$tbname) {
        printerror('EmptyTogZt', 'history.go(-1)');
    }
    $tbr = $empire->fetch1("select tid from {$dbtbpre}enewstable where tbname='{$tbname}' limit 1");
    if (!$tbr['tid']) {
        printerror('EmptyTogZt', 'history.go(-1)');
    }
    $wheresql = "";
    $formvar = "";
    //关键字
    $keyboard = RepPostVar2($add['keyboard']);
    if ($keyboard) {
        $formvar .= ReturnFormHidden('keyboard', $add['keyboard']);
        $searchfsql = '';
        if ($add['stitle']) {
            $searchfsql .= "title like '%{$keyboard}%'";
            $formvar .= ReturnFormHidden('stitle', $add['stitle']);
        }
        if ($add['susername']) {
            if ($searchfsql) {
                $or = " or ";
            }
            $searchfsql .= $or . "username like '%{$keyboard}%'";
            $formvar .= ReturnFormHidden('susername', $add['susername']);
        }
        if ($searchfsql) {
            $wheresql = " and (" . $searchfsql . ")";
        }
    }
    //是否推荐
    if ($add['isgood']) {
        $wheresql .= " and isgood>0";
        $formvar .= ReturnFormHidden('isgood', $add['isgood']);
    }
    //头条
    if ($add['firsttitle']) {
        $wheresql .= " and firsttitle>0";
        $formvar .= ReturnFormHidden('firsttitle', $add['firsttitle']);
    }
    //有标题图片
    if ($add['titlepic']) {
        $wheresql .= " and ispic=1";
        $formvar .= ReturnFormHidden('titlepic', $add['titlepic']);
    }
    //按栏目刷新
    $classid = (int) $add['classid'];
    if ($classid) {
        $formvar .= ReturnFormHidden('classid', $classid);
        if (empty($class_r[$classid][islast])) {
            $where = ReturnClass($class_r[$classid][sonclass]);
        } else {
            $where = "classid='{$classid}'";
        }
        $wheresql .= " and (" . $where . ")";
    }
    $startid = (int) $add[startid];
    $endid = (int) $add[endid];
    $startday = RepPostVar($add[startday]);
    $endday = RepPostVar($add[endday]);
    $formvar .= ReturnFormHidden('retype', $add['retype']);
    //按ID
    if ($add['retype']) {
        if ($endid) {
            $wheresql .= " and id>={$startid} and id<={$endid}";
            $formvar .= ReturnFormHidden('startid', $add[startid]) . ReturnFormHidden('endid', $add[endid]);
        }
    } else {
        if ($startday && $endday) {
            $wheresql .= " and truetime>=" . to_time($startday . " 00:00:00") . " and truetime<=" . to_time($endday . " 23:59:59");
            $formvar .= ReturnFormHidden('startday', $add[startday]) . ReturnFormHidden('endday', $add[endday]);
        }
    }
    //附件sql条件
    $query = $add['query'];
    if ($query) {
        $query = ClearAddsData($query);
        //去除adds
        $wheresql .= " and (" . $query . ")";
        $formvar .= ReturnFormHidden('query', $add['query']);
    }
    if (empty($wheresql)) {
        printerror('EmptyTogZt', 'history.go(-1)');
    }
    $wheresql = substr($wheresql, 5);
    if ($add['doecmszt']) {
        $togtype = (int) $add['togtype'];
        if ($togtype == 1) {
            $add['inid'] = eReturnInids($add['inid']);
            $wheresql = "id in (" . $add['inid'] . ")";
        } else {
            if ($add['inid']) {
                $add['inid'] = eReturnInids($add['inid']);
                $wheresql .= " and id not in (" . $add['inid'] . ")";
            }
        }
        AddMoreInfoToZt($ztid, $zcid, $tbname, $wheresql);
        //操作日志
        insert_dolog("ztid={$ztid}&ztname={$r['ztname']}");
        printerror("TogZtSuccess", "TogZt.php?ztid={$ztid}" . hReturnEcmsHashStrHref2(0));
    }
    $re[0] = $wheresql;
    $re[1] = $formvar . ReturnFormHidden('ztid', $ztid) . ReturnFormHidden('zcid', $zcid) . ReturnFormHidden('tbname', $tbname) . ReturnFormHidden('pline', $add[pline]) . ReturnFormHidden('doecmszt', $add[doecmszt]) . ReturnFormHidden('enews', $add[enews]) . ReturnFormHidden('inid', $add[inid]);
    $re[2] = $tbname;
    $re[3] = $r['ztname'];
    return $re;
}