Example #1
0
function CjNewsIn_all($classid, $checked, $uptime, $start, $userid, $username)
{
    global $class_r, $empire, $public_r, $dbtbpre, $fun_r, $emod_r;
    $checked = (int) $checked;
    $classid = (int) $classid;
    $start = (int) $start;
    if (empty($classid)) {
        printerror("ErrorUrl", "history.go(-1)");
    }
    //操作权限
    CheckLevel($userid, $username, $classid, "cj");
    $cr = $empire->fetch1("select * from {$dbtbpre}enewsinfoclass where classid='{$classid}'");
    //副表
    $cra = $empire->fetch1("select * from {$dbtbpre}ecms_infoclass_" . $cr[tbname] . " where classid='{$classid}'");
    //组合两数组
    $cr = TogTwoArray($cr, $cra);
    //导入gd处理文件
    if ($cr['mark'] || $cr['getfirstspic']) {
        @(include_once "gd.php");
    }
    if (empty($cr[insertnum])) {
        $cr[insertnum] = 10;
    }
    $mid = $class_r[$cr[newsclassid]][modid];
    $savetxtf = $emod_r[$mid]['savetxtf'];
    $stb = $emod_r[$mid]['deftb'];
    //取得采集字段
    $record = "<!--record-->";
    $field = "<!--field--->";
    $mr = $empire->fetch1("select cj from {$dbtbpre}enewsmod where mid='" . $class_r[$cr[newsclassid]][modid] . "'");
    $cjr = explode($record, $mr[cj]);
    $ccount = count($cjr);
    $sql = $empire->query("select * from {$dbtbpre}ecms_infotmp_" . $cr[tbname] . " where classid='{$classid}' and checked=0 and id>{$start} order by id limit " . $cr[insertnum]);
    $todaytime = time();
    $filetime = $todaytime;
    $b = 0;
    while ($r = $empire->fetch($sql)) {
        $b = 1;
        $newstart = $r[id];
        $ivalue = '';
        $ifield = '';
        $dataivalue = '';
        $dataifield = '';
        $titlepicnoval = 0;
        for ($j = 0; $j < $ccount - 1; $j++) {
            $cjr1 = explode($field, $cjr[$j]);
            $dofield = $cjr1[1];
            $var = "zz_" . $dofield;
            $var1 = "z_" . $dofield;
            $var2 = "qz_" . $dofield;
            $var3 = "save_" . $dofield;
            $value = $r[$dofield];
            //自身链接
            if ($dofield == "empireselfurl") {
                $value = $r['oldurl'];
            }
            //内容
            if ($dofield == "newstext") {
                if ($cr[copyimg] || $cr[copyflash]) {
                    $GLOBALS['cjnewsurl'] = $r[oldurl];
                    $value = addslashes(CopyImg(stripSlashes($value), $cr[copyimg], $cr[copyflash], $cr[newsclassid], $cr[imgurl], $username, 0, $r['id'], $cr['mark'], $public_r['filedeftb']));
                }
                //替换关键字和字符
                $value = DoReplaceKeyAndWord($value, 1, $cr[newsclassid]);
            }
            //简介
            if ($dofield == "smalltext") {
                if (empty($value)) {
                    $value = SubSmalltextVal($r[newstext], $cr[smalltextlen]);
                } else {
                    $value = DoClearSmalltextVal($value);
                }
            }
            //图片集
            if ($dofield == "morepic") {
                if ($cr[$var3] == " checked") {
                    $msavepic = 1;
                    $r['filepass'] = $r['id'];
                    $value = LoadInSaveMorepicFile($value, $msavepic, $cr[newsclassid], 0, $r, 0, $public_r['filedeftb']);
                }
            }
            //时间
            if ($dofield == "newstime") {
                continue;
            }
            //图片标题
            if ($dofield == "titlepic" && $cr[zz_titlepicl]) {
                $cr[$var] = $cr[zz_titlepicl];
                $cr[$var1] = $cr[z_titlepicl];
                $cr[$var2] = $cr[qz_titlepicl];
                $cr[$var3] = $cr[save_titlepicl];
            }
            if ($dofield == "titlepic" && empty($value)) {
                $titlepicnoval = 1;
            }
            //是否远程保存
            if ($value && !$cr[$var1] && $cr[$var3] == " checked" && $dofield != "morepic") {
                $tranr = DoTranUrl($value, $cr[newsclassid]);
                if ($tranr[tran]) {
                    $tranr[filesize] = (int) $tranr[filesize];
                    $tranr[type] = (int) $tranr[type];
                    $r[id] = (int) $r[id];
                    //记录数据库
                    eInsertFileTable($tranr[filename], $tranr[filesize], $tranr[filepath], $username, $cr[newsclassid], '[URL]' . $tranr[filename], $tranr[type], 0, $r[id], $public_r[fpath], 0, 0, $public_r['filedeftb']);
                    $value = $tranr[url];
                }
            }
            //存放文本
            if ($savetxtf == $dofield) {
                //建立目录
                $thetxtfile = GetFileMd5();
                $truevalue = MkDirTxtFile(date("Y/md"), $thetxtfile);
                //写放文件
                EditTxtFieldText($truevalue, $value);
                $value = $truevalue;
            }
            $value = addslashes($value);
            if (strstr($emod_r[$mid]['tbdataf'], ',' . $dofield . ',')) {
                $dataifield .= "," . $dofield;
                $dataivalue .= ",'" . $value . "'";
            } else {
                $ifield .= "," . $dofield;
                $ivalue .= ",'" . $value . "'";
            }
        }
        $r[keyboard] = addslashes($r[keyboard]);
        //时间
        if ($uptime) {
            $r[newstime] = $todaytime;
            $r[truetime] = $todaytime;
        } else {
            if ($r[newstime] == "0000-00-00 00:00:00") {
                $r[newstime] = $todaytime;
            } else {
                $r[newstime] = to_time($r[newstime]);
            }
        }
        //查看目录是否存在,不存在则建立
        $newspath = FormatPath($cr[newsclassid], "", 0);
        //强制签发
        if ($class_r[$cr[newsclassid]][wfid]) {
            $checked = 0;
            $isqf = 1;
        } else {
            $checked = $checked;
            $isqf = 0;
        }
        //变量处理
        $newstempid = 0;
        $ispic = $r[titlepic] ? 1 : 0;
        //返回关键字
        $keyid = GetKeyid($r[keyboard], $cr[newsclassid], 0, $class_r[$cr[newsclassid]][link_num]);
        //索引表
        $havehtml = 0;
        $indexsql = $empire->query("insert into {$dbtbpre}ecms_" . $class_r[$cr[newsclassid]][tbname] . "_index(classid,checked,newstime,truetime,lastdotime,havehtml) values('{$cr['newsclassid']}','{$checked}','{$r['newstime']}','{$r['truetime']}','{$r['truetime']}','{$havehtml}');");
        $id = $empire->lastid();
        $infotbr = ReturnInfoTbname($class_r[$cr[newsclassid]][tbname], $checked, $stb);
        //主表
        $isurl = $r['titleurl'] ? 1 : 0;
        $isql = $empire->query("insert into " . $infotbr['tbname'] . "(id,classid,ttid,onclick,plnum,totaldown,newspath,filename,userid,username,firsttitle,isgood,ispic,istop,isqf,ismember,isurl,truetime,lastdotime,havehtml,groupid,userfen,titlefont,titleurl,stb,fstb,restb,keyboard,newstime" . $ifield . ") values('{$id}','{$cr['newsclassid']}',0,0,0,0,'{$newspath}','{$filename}','{$r['userid']}','{$r['username']}',0,0,'{$ispic}',0,'{$isqf}',0,'{$isurl}','{$r['truetime']}','{$r['truetime']}','{$havehtml}',0,0,'{$r['titlefont']}','{$r['titleurl']}','{$stb}','{$public_r['filedeftb']}','{$public_r['pldeftb']}','{$r['keyboard']}','{$r['newstime']}'" . $ivalue . ");");
        //副表
        $fisql = $empire->query("insert into " . $infotbr['datatbname'] . "(id,classid,keyid,dokey,newstempid,closepl,haveaddfen,infotags" . $dataifield . ") values('{$id}','{$cr['newsclassid']}','{$keyid}',1,'{$newstempid}',0,0,''" . $dataivalue . ");");
        //更新栏目信息数
        AddClassInfos($cr['newsclassid'], '+1', '+1', $checked);
        //更新新信息数
        DoUpdateAddDataNum('info', $class_r[$cr['newsclassid']]['tid'], 1);
        //签发
        if ($isqf == 1) {
            InfoInsertToWorkflow($id, $cr[newsclassid], $class_r[$cr[newsclassid]][wfid], $userid, $username);
        }
        //更新附件
        UpdateTheFile($id, $r['id'], $cr[newsclassid], $public_r['filedeftb']);
        //取第一张图片为标题图片
        $addtitlepic = "";
        if ($cr['getfirstpic'] && $titlepicnoval) {
            $firsttitlepic = GetFpicToTpic($cr[newsclassid], $id, $cr['getfirstpic'], $cr['getfirstspic'], $cr['getfirstspicw'], $cr['getfirstspich'], $public_r['filedeftb']);
            if ($firsttitlepic) {
                $addtitlepic = ",titlepic='" . addslashes($firsttitlepic) . "',ispic=1";
            }
        }
        //文件命名
        $filename = ReturnInfoFilename($cr[newsclassid], $id, $r[filenameqz]);
        //信息地址
        $updateinfourl = '';
        if (!$isurl) {
            $infourl = GotoGetTitleUrl($cr['newsclassid'], $id, $newspath, $filename, 0, $isurl, '');
            $updateinfourl = ",titleurl='{$infourl}'";
        }
        $usql = $empire->query("update " . $infotbr['tbname'] . " set filename='{$filename}'" . $updateinfourl . $addtitlepic . " where id='{$id}'");
    }
    $fm = ehtmlspecialchars($_GET['fm']);
    //全部入库完毕
    if (empty($b)) {
        //取得忧化字段
        for ($ci = 0; $ci < $ccount - 1; $ci++) {
            $cir = explode($field, $cjr[$ci]);
            $cifield = $cir[1];
            if ($cifield == "title") {
                continue;
            }
            $updatefield .= "," . $cifield . "=''";
        }
        //状态原记录
        if ($cr['delloadinfo']) {
            $del = $empire->query("delete from {$dbtbpre}ecms_infotmp_" . $cr[tbname] . " where classid='{$classid}'");
        } else {
            $del = $empire->query("update {$dbtbpre}ecms_infotmp_" . $cr[tbname] . " set checked=1,keyboard=''" . $updatefield . " where classid='{$classid}'");
        }
        if ($fm) {
            echo "<link rel=\"stylesheet\" href=\"../data/images/css.css\" type=\"text/css\"><body topmargin=0><font color=red>" . $cr[classname] . "  " . $fun_r['CjLoadInInfosSuccess'] . "</font>,  <input type=button name=button value='" . $fun_r['OnlickLoadInCj'] . "' onclick=\"window.open('CheckCj.php?classid={$classid}&from=" . ehtmlspecialchars($_GET[from]) . hReturnEcmsHashStrHref2(0) . "');\"></body>";
            exit;
        } else {
            printerror("CjLoadDbSuccess", "CheckCj.php?classid={$classid}&from=" . ehtmlspecialchars($_GET[from]) . hReturnEcmsHashStrHref2(0));
        }
    }
    echo "<b>{$cr['classname']}</b>&nbsp;&nbsp;" . $fun_r['OneCjLoadDbSuccess'] . "(ID:<font color=red><b>" . $newstart . "</b></font>)<script>self.location.href='ecmscj.php?enews=CjNewsIn_all&checked={$checked}&uptime={$uptime}&classid={$classid}&start={$newstart}&fm={$fm}&from=" . ehtmlspecialchars($_GET[from]) . hReturnEcmsHashStrHref(0) . "';</script>";
    exit;
}
Example #2
0
function AddPl($username, $password, $nomember, $key, $saytext, $id, $classid, $repid, $add)
{
    global $empire, $dbtbpre, $public_r, $class_r, $level_r;
    //验证本时间允许操作
    eCheckTimeCloseDo('pl');
    //验证IP
    eCheckAccessDoIp('pl');
    $id = (int) $id;
    $repid = (int) $repid;
    $classid = (int) $classid;
    //验证码
    $keyvname = 'checkplkey';
    if ($public_r['plkey_ok']) {
        ecmsCheckShowKey($keyvname, $key, 1);
    }
    $username = RepPostVar($username);
    $password = RepPostVar($password);
    $muserid = (int) getcvar('mluserid');
    $musername = RepPostVar(getcvar('mlusername'));
    $mgroupid = (int) getcvar('mlgroupid');
    if ($muserid) {
        $cklgr = qCheckLoginAuthstr();
        if ($cklgr['islogin']) {
            $username = $musername;
        } else {
            $muserid = 0;
        }
    } else {
        if (empty($nomember)) {
            if (!$username || !$password) {
                printerror("FailPassword", "history.go(-1)", 1);
            }
            $ur = $empire->fetch1("select " . eReturnSelectMemberF('userid,salt,password,checked,groupid') . " from " . eReturnMemberTable() . " where " . egetmf('username') . "='{$username}' limit 1");
            if (empty($ur['userid'])) {
                printerror("FailPassword", "history.go(-1)", 1);
            }
            if (!eDoCkMemberPw($password, $ur['password'], $ur['salt'])) {
                printerror("FailPassword", "history.go(-1)", 1);
            }
            if ($ur['checked'] == 0) {
                printerror("NotCheckedUser", '', 1);
            }
            $muserid = $ur['userid'];
            $mgroupid = $ur['groupid'];
        } else {
            $muserid = 0;
        }
    }
    if ($public_r['plgroupid']) {
        if (!$muserid) {
            printerror("GuestNotToPl", "history.go(-1)", 1);
        }
        if ($level_r[$mgroupid][level] < $level_r[$public_r['plgroupid']][level]) {
            printerror("NotLevelToPl", "history.go(-1)", 1);
        }
    }
    //专题
    $doaction = $add['doaction'];
    if ($doaction == 'dozt') {
        if (!trim($saytext) || !$classid) {
            printerror("EmptyPl", "history.go(-1)", 1);
        }
        //是否关闭评论
        $r = $empire->fetch1("select ztid,closepl,checkpl,restb from {$dbtbpre}enewszt where ztid='{$classid}'");
        if (!$r['ztid']) {
            printerror("ErrorUrl", "history.go(-1)", 1);
        }
        if ($r['closepl']) {
            printerror("CloseClassPl", "history.go(-1)", 1);
        }
        //审核
        if ($r['checkpl']) {
            $checked = 1;
        } else {
            $checked = 0;
        }
        $restb = $r['restb'];
        $pubid = '-' . $classid;
        $id = 0;
        $pagefunr = eReturnRewritePlUrl($classid, $id, 'dozt', 0, 0, 1);
        $returl = $pagefunr['pageurl'];
    } else {
        if (!trim($saytext) || !$id || !$classid) {
            printerror("EmptyPl", "history.go(-1)", 1);
        }
        //表存在
        if (empty($class_r[$classid][tbname])) {
            printerror("ErrorUrl", "history.go(-1)", 1);
        }
        //是否关闭评论
        $r = $empire->fetch1("select classid,stb,restb from {$dbtbpre}ecms_" . $class_r[$classid][tbname] . " where id='{$id}' limit 1");
        if (!$r['classid'] || $r['classid'] != $classid) {
            printerror("ErrorUrl", "history.go(-1)", 1);
        }
        if ($class_r[$r[classid]][openpl]) {
            printerror("CloseClassPl", "history.go(-1)", 1);
        }
        //单信息关闭评论
        $pubid = ReturnInfoPubid($classid, $id);
        $finfor = $empire->fetch1("select closepl from {$dbtbpre}ecms_" . $class_r[$classid][tbname] . "_data_" . $r['stb'] . " where id='{$id}' limit 1");
        if ($finfor['closepl']) {
            printerror("CloseInfoPl", "history.go(-1)", 1);
        }
        //审核
        if ($class_r[$classid][checkpl]) {
            $checked = 1;
        } else {
            $checked = 0;
        }
        $restb = $r['restb'];
        $pagefunr = eReturnRewritePlUrl($classid, $id, 'doinfo', 0, 0, 1);
        $returl = $pagefunr['pageurl'];
    }
    //设置参数
    $plsetr = $empire->fetch1("select pltime,plsize,plincludesize,plclosewords,plmustf,plf,plmaxfloor,plquotetemp from {$dbtbpre}enewspl_set limit 1");
    if (strlen($saytext) > $plsetr['plsize']) {
        $GLOBALS['setplsize'] = $plsetr['plsize'];
        printerror("PlSizeTobig", "history.go(-1)", 1);
    }
    $time = time();
    $saytime = $time;
    $pltime = getcvar('lastpltime');
    if ($pltime) {
        if ($time - $pltime < $plsetr['pltime']) {
            $GLOBALS['setpltime'] = $plsetr['pltime'];
            printerror("PlOutTime", "history.go(-1)", 1);
        }
    }
    $sayip = egetip();
    $eipport = egetipport();
    $username = str_replace("\r\n", "", $username);
    $username = RepPostStr($username);
    $saytext = nl2br(RepFieldtextNbsp(RepPostStr($saytext)));
    if ($repid) {
        $saytext = RepPlTextQuote($repid, $saytext, $plsetr, $restb);
        CkPlQuoteFloor($plsetr['plmaxfloor'], $saytext);
        //验证楼层
    }
    //过滤字符
    $saytext = ReplacePlWord($plsetr['plclosewords'], $saytext);
    if ($level_r[$mgroupid]['plchecked']) {
        $checked = 0;
    }
    $ret_r = ReturnPlAddF($add, $plsetr, 0);
    //主表
    $sql = $empire->query("insert into {$dbtbpre}enewspl_" . $restb . "(pubid,username,sayip,saytime,id,classid,checked,zcnum,fdnum,userid,isgood,saytext,eipport" . $ret_r['fields'] . ") values('{$pubid}','" . $username . "','{$sayip}','{$saytime}','{$id}','{$classid}','{$checked}',0,0,'{$muserid}',0,'" . addslashes($saytext) . "','{$eipport}'" . $ret_r['values'] . ");");
    $plid = $empire->lastid();
    if ($doaction != 'dozt') {
        //信息表加1
        $usql = $empire->query("update {$dbtbpre}ecms_" . $class_r[$classid][tbname] . " set plnum=plnum+1 where id='{$id}' limit 1");
    }
    //更新新评论数
    DoUpdateAddDataNum('pl', $restb, 1);
    //设置最后发表时间
    $set1 = esetcookie("lastpltime", time(), time() + 3600 * 24);
    ecmsEmptyShowKey($keyvname);
    //清空验证码
    if ($sql) {
        $reurl = DoingReturnUrl($returl, $_POST['ecmsfrom']);
        printerror("AddPlSuccess", $reurl, 1);
    } else {
        printerror("DbError", "history.go(-1)", 1);
    }
}
Example #3
0
function AddInfoToCopyInfo($classid, $id, $to_classid, $userid, $username, $usergroupr)
{
    global $empire, $public_r, $class_r, $dbtbpre, $emod_r;
    $classid = (int) $classid;
    $id = (int) $id;
    $cr = $to_classid;
    $count = count($cr);
    if (empty($classid) || empty($id) || empty($count)) {
        return '';
    }
    $mid = $class_r[$classid][modid];
    $tbname = $class_r[$classid][tbname];
    $stf = $emod_r[$mid]['savetxtf'];
    //索引表
    $index_r = $empire->fetch1("select id,checked from {$dbtbpre}ecms_" . $tbname . "_index where id='{$id}' limit 1");
    if (empty($index_r['id'])) {
        return '';
    }
    //返回表
    $infotb = ReturnInfoMainTbname($tbname, $index_r['checked']);
    //主表
    $r = $empire->fetch1("select * from " . $infotb . " where id='{$id}'");
    //返回表信息
    $infotbr = ReturnInfoTbname($tbname, $index_r['checked'], $r['stb']);
    //副表
    $fr = $empire->fetch1("select " . ReturnSqlFtextF($mid) . " from " . $infotbr['datatbname'] . " where id='{$id}' limit 1");
    $r = array_merge($r, $fr);
    if ($stf) {
        $r[newstext_url] = $r[$stf];
        $r[$stf] = GetTxtFieldText($r[$stf]);
    }
    //返回信息地址
    $copyinfourl = 0;
    if ($_POST['copyinfotitleurl'] && !$r['isurl']) {
        $r['titleurl'] = sys_ReturnBqTitleLink($r);
        $r['isurl'] = 1;
        $copyinfourl = 1;
    }
    $ids = ',';
    for ($i = 0; $i < $count; $i++) {
        $newclassid = (int) $cr[$i];
        //发布权限
        if (empty($usergroupr['doall']) && !strstr($usergroupr['add_adminclass'], '|' . $newclassid . '|')) {
            continue;
        }
        if (!$newclassid || !$class_r[$newclassid][islast] || $mid != $class_r[$newclassid][modid] || $newclassid == $classid) {
            continue;
        }
        //查看目录是否存在,不存在则建立
        $newspath = FormatPath($newclassid, "", 0);
        $newstempid = 0;
        $copyids = '1';
        //返回自定义字段
        $ret_r = ReturnAddF($r, $mid, $userid, $username, 9, 1, 0);
        if ($class_r[$newclassid][wfid]) {
            $checked = 0;
            $isqf = 1;
        } else {
            $checked = $class_r[$newclassid][checked];
            $isqf = 0;
        }
        //必须审核
        if ($usergroupr['domustcheck']) {
            $checked = 0;
        }
        $checked = (int) $checked;
        //索引表
        $empire->query("insert into {$dbtbpre}ecms_" . $tbname . "_index(classid,checked,newstime,truetime,lastdotime,havehtml) values('{$newclassid}','{$checked}','{$r['newstime']}','{$r['truetime']}','{$r['truetime']}','{$r['havehtml']}');");
        $l_id = $empire->lastid();
        $infotbr = ReturnInfoTbname($tbname, $checked, $ret_r['tb']);
        //主表
        $empire->query("insert into " . $infotbr['tbname'] . "(id,classid,ttid,onclick,plnum,totaldown,newspath,filename,userid,username,firsttitle,isgood,ispic,istop,isqf,ismember,isurl,truetime,lastdotime,havehtml,groupid,userfen,titlefont,titleurl,stb,fstb,restb,keyboard" . $ret_r[fields] . ") values('{$l_id}','{$newclassid}','{$r['ttid']}',0,0,0,'{$newspath}','{$filename}','{$r['userid']}','" . StripAddsData($r[username]) . "',0,0,'{$r['ispic']}',0,'{$isqf}',0,'{$r['isurl']}','{$r['truetime']}',{$r['truetime']},{$r['havehtml']},{$r['groupid']},{$r['userfen']},'" . StripAddsData($r[titlefont]) . "','" . StripAddsData($r[titleurl]) . "','{$ret_r['tb']}','{$public_r['filedeftb']}','{$public_r['pldeftb']}','" . StripAddsData($r[keyboard]) . "'" . $ret_r[values] . ");");
        //副表
        $empire->query("insert into " . $infotbr['datatbname'] . "(id,classid,keyid,dokey,newstempid,closepl,haveaddfen,infotags" . $ret_r[datafields] . ") values('{$l_id}','{$newclassid}','{$r['keyid']}',{$r['dokey']},'" . $newstempid . "',{$r['closepl']},0,''" . $ret_r[datavalues] . ");");
        //公共表
        UpdateInfoCopyids($newclassid, $l_id, $copyids);
        //更新栏目信息数
        AddClassInfos($newclassid, '+1', '+1', $checked);
        //更新新信息数
        DoUpdateAddDataNum('info', $class_r[$newclassid]['tid'], 1);
        //签发
        if ($isqf == 1) {
            InfoInsertToWorkflow($l_id, $newclassid, $class_r[$newclassid][wfid], $userid, $username);
        }
        //文件命名
        $filename = ReturnInfoFilename($newclassid, $l_id, $r[filenameqz]);
        //信息地址
        $updateinfourl = '';
        if (!$copyinfourl) {
            $infourl = GotoGetTitleUrl($newclassid, $l_id, $newspath, $filename, $r['groupid'], $r['isurl'], $r['titleurl']);
            $updateinfourl = ",titleurl='{$infourl}'";
        }
        $empire->query("update " . $infotbr['tbname'] . " set filename='{$filename}'" . $updateinfourl . " where id='{$l_id}' limit 1");
        //生成信息文件
        if ($checked) {
            $addr = $empire->fetch1("select * from " . $infotbr['tbname'] . " where id='{$l_id}' limit 1");
            GetHtml($addr['classid'], $addr['id'], $addr, 1);
        }
        $ids .= $l_id . ',';
    }
    if ($ids == ',') {
        $ids = '';
    }
    return $ids;
}
Example #4
0
function DodoInfo($add, $ecms = 0)
{
    global $empire, $public_r, $emod_r, $level_r, $class_r, $dbtbpre, $fun_r;
    //验证来源
    if ($ecms == 0 || $ecms == 1) {
        CheckCanPostUrl();
    }
    //开启投稿
    if ($public_r['addnews_ok']) {
        printerror("CloseQAdd", "", 1);
    }
    //验证本时间允许操作
    eCheckTimeCloseDo('info');
    $classid = (int) $add['classid'];
    $mid = (int) $class_r[$classid]['modid'];
    if (!$mid || !$classid) {
        printerror("EmptyQinfoCid", "", 1);
    }
    $tbname = $emod_r[$mid]['tbname'];
    $qenter = $emod_r[$mid]['qenter'];
    if (!$tbname || !$qenter || $qenter == ',') {
        printerror("ErrorUrl", "history.go(-1)", 1);
    }
    $muserid = (int) getcvar('mluserid');
    $musername = RepPostVar(getcvar('mlusername'));
    $mrnd = RepPostVar(getcvar('mlrnd'));
    //取得栏目信息
    $isadd = 0;
    if ($ecms == 0) {
        $isadd = 1;
    }
    $setuserday = '';
    $cr = DoQCheckAddLevel($classid, $muserid, $musername, $mrnd, $ecms, $isadd);
    $setuserday = $cr['checkaddnumquery'];
    $filepass = (int) $add['filepass'];
    $id = (int) $add['id'];
    $infor = array();
    //组合标题属性
    $titlecolor = RepPostStr(RepPhpAspJspcodeText($add[titlecolor]));
    $titlefont = TitleFont($add[titlefont], $titlecolor);
    $titlecolor = "";
    $titlefont = "";
    $ttid = (int) $add['ttid'];
    $keyboard = addslashes(RepPostStr(trim(DoReplaceQjDh($add[keyboard]))));
    $keyid = '';
    //返回关键字组合
    if ($keyboard && strstr($qenter, ',special.field,')) {
        $keyboard = str_replace('[!--f--!]', 'ecms', $keyboard);
        $keyid = GetKeyid($keyboard, $classid, $id, $class_r[$classid][link_num]);
    }
    //验证码
    $keyvname = 'checkinfokey';
    //moreport
    if (Moreport_ReturnMustDt()) {
        define('ECMS_SELFPATH', eReturnEcmsMainPortPath());
        Moreport_ResetMainTempGid();
    }
    //-----------------增加
    if ($ecms == 0) {
        //时间
        $lasttime = getcvar('lastaddinfotime');
        if ($lasttime) {
            if (time() - $lasttime < $public_r['readdinfotime']) {
                printerror("QAddInfoOutTime", "", 1);
            }
        }
        //验证码
        if ($cr['qaddshowkey']) {
            ecmsCheckShowKey($keyvname, $add['key'], 1);
        }
        //IP发布数限制
        $check_ip = egetip();
        $check_checked = $cr['wfid'] ? 0 : $cr['checkqadd'];
        eCheckIpAddInfoNum($check_ip, $tbname, $mid, $check_checked);
        //返回字段
        $ret_r = ReturnQAddinfoF($mid, $add, $infor, $classid, $filepass, $muserid, $musername, 0);
        $checked = $cr['checkqadd'];
        $havehtml = 0;
        $newspath = date($cr['newspath']);
        $truetime = time();
        $newstime = $truetime;
        $newstempid = $cr['newstempid'];
        $haveaddfen = 0;
        //强制签发
        $isqf = 0;
        if ($cr['wfid']) {
            $checked = 0;
            $isqf = 1;
        }
        //增扣点
        if ($checked && $muserid) {
            AddInfoFen($cr['addinfofen'], $muserid);
            $haveaddfen = 1;
        }
        if (empty($muserid)) {
            $musername = $fun_r['guest'];
        }
        //会员投稿数更新
        if ($setuserday) {
            $empire->query($setuserday);
        }
        //发布时间
        if (!strstr($qenter, ',newstime,')) {
            $ret_r[0] = ",newstime" . $ret_r[0];
            $ret_r[1] = ",'{$newstime}'" . $ret_r[1];
        } else {
            if ($add['newstime']) {
                $newstime = to_time($add['newstime']);
                $newstime = intval($newstime);
            }
        }
        //附加链接参数
        $addecmscheck = empty($checked) ? '&ecmscheck=1' : '';
        //索引表
        $indexsql = $empire->query("insert into {$dbtbpre}ecms_" . $tbname . "_index(classid,checked,newstime,truetime,lastdotime,havehtml) values('{$classid}','{$checked}','{$newstime}','{$truetime}','{$truetime}','{$havehtml}');");
        $id = $empire->lastid();
        //返回表信息
        $infotbr = ReturnInfoTbname($tbname, $checked, $ret_r[4]);
        //主表
        $sql = $empire->query("insert into " . $infotbr['tbname'] . "(id,classid,ttid,onclick,plnum,totaldown,newspath,filename,userid,username,firsttitle,isgood,istop,isqf,ismember,isurl,truetime,lastdotime,havehtml,groupid,userfen,titlefont,titleurl,stb,fstb,restb,keyboard" . $ret_r[0] . ") values('{$id}','{$classid}','{$ttid}',0,0,0,'{$newspath}','','" . $muserid . "','" . addslashes($musername) . "',0,0,0,'{$isqf}',1,0,'{$truetime}','{$truetime}','{$havehtml}',0,0,'{$titlefont}','','{$ret_r['4']}','{$public_r['filedeftb']}','{$public_r['pldeftb']}','{$keyboard}'" . $ret_r[1] . ");");
        //副表
        $fsql = $empire->query("insert into " . $infotbr['datatbname'] . "(id,classid,keyid,dokey,newstempid,closepl,haveaddfen,infotags" . $ret_r[2] . ") values('{$id}','{$classid}','{$keyid}',1,'{$newstempid}',0,'{$haveaddfen}',''" . $ret_r[3] . ");");
        //扣点记录
        if ($haveaddfen) {
            if ($cr['addinfofen'] < 0) {
                BakDown($classid, $id, 0, $muserid, $musername, RepPostStr($add[title]), abs($cr['addinfofen']), 3);
            }
        }
        //签发
        if ($isqf == 1) {
            InfoInsertToWorkflow($id, $classid, $cr['wfid'], $muserid, addslashes($musername));
        }
        //文件命名
        $filename = ReturnInfoFilename($classid, $id, '');
        //信息地址
        $infourl = GotoGetTitleUrl($classid, $id, $newspath, $filename, 0, 0, '');
        $usql = $empire->query("update " . $infotbr['tbname'] . " set filename='{$filename}',titleurl='{$infourl}' where id='{$id}'");
        //修改ispic
        UpdateTheIspic($classid, $id, $checked);
        //修改附件
        if ($filepass) {
            UpdateTheFile($id, $filepass, $classid, $public_r['filedeftb']);
        }
        //更新栏目信息数
        AddClassInfos($classid, '+1', '+1', $checked);
        //更新新信息数
        DoUpdateAddDataNum('info', $class_r[$classid]['tid'], 1);
        //清除验证码
        ecmsEmptyShowKey($keyvname);
        esetcookie("qeditinfo", "", 0);
        //生成页面
        if ($checked && !$cr['showdt']) {
            $titleurl = qAddGetHtml($classid, $id);
        }
        //生成列表
        if ($checked) {
            qAddListHtml($classid, $mid, $cr['qaddlist'], $cr['listdt']);
            //生成上一篇
            if ($cr['repreinfo']) {
                $prer = $empire->fetch1("select * from {$dbtbpre}ecms_" . $tbname . " where id<{$id} and classid='{$classid}' order by id desc limit 1");
                GetHtml($prer['classid'], $prer['id'], $prer, 1);
            }
        }
        if ($sql) {
            $reurl = DoingReturnUrl("AddInfo.php?classid={$classid}&mid={$mid}" . $addecmscheck, $add['ecmsfrom']);
            if ($add['gotoinfourl'] && $checked) {
                if ($cr['showdt'] == 1) {
                    $reurl = $public_r[newsurl] . "e/action/ShowInfo/?classid={$classid}&id={$id}";
                } elseif ($cr['showdt'] == 2) {
                    $rewriter = eReturnRewriteInfoUrl($classid, $id, 1);
                    $reurl = $rewriter['pageurl'];
                } else {
                    $reurl = $titleurl;
                }
            }
            esetcookie("lastaddinfotime", time(), time() + 3600 * 24);
            //设置最后发表时间
            printerror("AddQinfoSuccess", $reurl, 1);
        } else {
            printerror("DbError", "history.go(-1)", 1);
        }
    } elseif ($ecms == 1) {
        if (!$id) {
            printerror("ErrorUrl", "history.go(-1)", 1);
        }
        //检测权限
        $infor = CheckQdoinfo($classid, $id, $muserid, $tbname, $cr['adminqinfo'], 1);
        //检测时间
        if ($public_r['qeditinfotime']) {
            if (time() - $infor['truetime'] > $public_r['qeditinfotime'] * 60) {
                printerror("QEditInfoOutTime", "history.go(-1)", 1);
            }
        }
        $iaddfield = '';
        $addfield = '';
        $faddfield = '';
        //返回字段
        $ret_r = ReturnQAddinfoF($mid, $add, $infor, $classid, $filepass, $muserid, $musername, 1);
        if ($keyboard) {
            $addfield = ",keyboard='{$keyboard}'";
            $faddfield = ",keyid='{$keyid}'";
        }
        //时间
        if (strstr($qenter, ',newstime,')) {
            if ($add['newstime']) {
                $newstime = to_time($add['newstime']);
                $newstime = intval($newstime);
                $iaddfield .= ",newstime='{$newstime}'";
            }
        }
        //修改是否需要审核
        $ychecked = $infor['checked'];
        if ($cr['qeditchecked']) {
            $infor['checked'] = 0;
            $iaddfield .= ",checked=0";
            $relist = 1;
            //删除原页面
            DelNewsFile($infor[filename], $infor[newspath], $infor[classid], $infor[newstext], $infor[groupid]);
        }
        //会员投稿数更新
        if ($setuserday) {
            //$empire->query($setuserday);
        }
        $lastdotime = time();
        //附加链接参数
        $addecmscheck = empty($infor['checked']) ? '&ecmscheck=1' : '';
        //索引表
        $indexsql = $empire->query("update {$dbtbpre}ecms_" . $tbname . "_index set lastdotime={$lastdotime},havehtml=0" . $iaddfield . " where id='{$id}'");
        //返回表信息
        $infotbr = ReturnInfoTbname($tbname, $ychecked, $infor['stb']);
        //主表
        $sql = $empire->query("update " . $infotbr['tbname'] . " set lastdotime={$lastdotime},havehtml=0,ttid='{$ttid}'" . $addfield . $ret_r[0] . " where id={$id} and classid={$classid} and userid='{$muserid}' and ismember=1");
        //副表
        $fsql = $empire->query("update " . $infotbr['datatbname'] . " set classid='{$classid}'" . $faddfield . $ret_r[3] . " where id='{$id}'");
        //修改ispic
        UpdateTheIspic($classid, $id, $ychecked);
        //更新附件
        UpdateTheFileEdit($classid, $id, $infor['fstb']);
        //未审核信息互转
        if ($ychecked != $infor['checked']) {
            MoveCheckInfoData($tbname, $ychecked, $infor['stb'], "id='{$id}'");
            //更新栏目信息数
            if ($infor['checked']) {
                AddClassInfos($classid, '', '+1');
            } else {
                AddClassInfos($classid, '', '-1');
            }
        }
        esetcookie("qeditinfo", "", 0);
        //生成页面
        if ($infor['checked'] && !$cr['showdt']) {
            $titleurl = qAddGetHtml($classid, $id);
        }
        //生成列表
        if ($infor['checked'] || $relist == 1) {
            qAddListHtml($classid, $mid, $cr['qaddlist'], $cr['listdt']);
        }
        //生成上一篇
        if ($cr['repreinfo'] && $infor['checked']) {
            $prer = $empire->fetch1("select * from {$dbtbpre}ecms_" . $tbname . " where id<{$id} and classid='{$classid}' order by id desc limit 1");
            GetHtml($prer['classid'], $prer['id'], $prer, 1);
        }
        if ($sql) {
            $reurl = DoingReturnUrl("ListInfo.php?mid={$mid}" . $addecmscheck, $add['ecmsfrom']);
            if ($add['editgotoinfourl'] && $infor['checked']) {
                if ($cr['showdt'] == 1) {
                    $reurl = $public_r[newsurl] . "e/action/ShowInfo/?classid={$classid}&id={$id}";
                } elseif ($cr['showdt'] == 2) {
                    $rewriter = eReturnRewriteInfoUrl($classid, $id, 1);
                    $reurl = $rewriter['pageurl'];
                } else {
                    $reurl = $titleurl;
                }
            }
            printerror("EditQinfoSuccess", $reurl, 1);
        } else {
            printerror("DbError", "history.go(-1)", 1);
        }
    } elseif ($ecms == 2) {
        if (!$id) {
            printerror("ErrorUrl", "history.go(-1)", 1);
        }
        //检测权限
        $r = CheckQdoinfo($classid, $id, $muserid, $tbname, $cr['adminqinfo'], 2);
        //附加链接参数
        $addecmscheck = empty($r['checked']) ? '&ecmscheck=1' : '';
        //返回表信息
        $infotbr = ReturnInfoTbname($tbname, $r['checked'], $r['stb']);
        $stf = $emod_r[$mid]['savetxtf'];
        $pf = $emod_r[$mid]['pagef'];
        //分页字段
        if ($pf) {
            if (strstr($emod_r[$mid]['tbdataf'], ',' . $pf . ',')) {
                $finfor = $empire->fetch1("select " . $pf . " from " . $infotbr['datatbname'] . " where id='{$id}' limit 1");
                $r[$pf] = $finfor[$pf];
            }
        }
        //存文本
        if ($stf) {
            $newstextfile = $r[$stf];
            $r[$stf] = GetTxtFieldText($r[$stf]);
            //删除文件
            DelTxtFieldText($newstextfile);
        }
        //删除信息文件
        DelNewsFile($r[filename], $r[newspath], $classid, $r[$pf], $r[groupid]);
        $indexsql = $empire->query("delete from {$dbtbpre}ecms_" . $tbname . "_index where id='{$id}'");
        $sql = $empire->query("delete from " . $infotbr['tbname'] . " where id={$id} and classid={$classid} and userid='{$muserid}' and ismember=1");
        $fsql = $empire->query("delete from " . $infotbr['datatbname'] . " where id={$id}");
        esetcookie("qdelinfo", "", 0);
        //更新栏目信息数
        AddClassInfos($classid, '-1', '-1', $r['checked']);
        //删除其它表记录和附件
        DelSingleInfoOtherData($classid, $id, $r, 0, 0);
        //生成列表
        if ($r['checked']) {
            qAddListHtml($classid, $mid, $cr['qaddlist'], $cr['listdt']);
            //生成上一篇
            if ($cr['repreinfo']) {
                $prer = $empire->fetch1("select * from {$dbtbpre}ecms_" . $tbname . " where id<{$id} and classid='{$classid}' order by id desc limit 1");
                GetHtml($prer['classid'], $prer['id'], $prer, 1);
                //下一篇
                $nextr = $empire->fetch1("select * from {$dbtbpre}ecms_" . $tbname . " where id>{$id} and classid='{$classid}' order by id limit 1");
                if ($nextr['id']) {
                    GetHtml($nextr['classid'], $nextr['id'], $nextr, 1);
                }
            }
        }
        if ($sql) {
            $reurl = DoingReturnUrl("ListInfo.php?mid={$mid}", $add['ecmsfrom']);
            printerror("DelQinfoSuccess", $reurl, 1);
        } else {
            printerror("DbError", "history.go(-1)", 1);
        }
    } else {
        printerror("ErrorUrl", "", 1);
    }
}