コード例 #1
0
function ReturnAddF($add, $modid, $userid, $username, $do = 0, $rdata = 0, $ch = 0)
{
    global $empire, $public_r, $dbtbpre, $emod_r;
    if ($do == 0 || $do == 1) {
        //导入gd处理文件
        if ($add['mark'] || $add['getfirsttitlespic'] || $add['mcreatespic']) {
            include_once ECMS_PATH . 'e/class/gd.php';
        }
    }
    $ret_r['tb'] = $emod_r[$modid]['deftb'];
    $r = explode(',', $emod_r[$modid][enter]);
    $count = count($r) - 1;
    if (empty($do)) {
        //数据库操作
        for ($i = 1; $i < $count; $i++) {
            $f = $r[$i];
            if ($f == 'special.field' || !strstr($emod_r[$modid]['canaddf'], ',' . $f . ',')) {
                continue;
            }
            $add[$f] = ReturnCheckboxAddF($add[$f], $modid, $f);
            //复选框
            $value = RepPhpAspJspcodeText($add[$f]);
            if ($f == 'newstime') {
                $value = empty($value) ? time() : to_time($value);
            } elseif ($f == "morepic") {
                $value = ReturnMorepicpath($add['msmallpic'], $add['mbigpic'], $add['mpicname'], $add['mdelpicid'], $add['mpicid'], $add, $add['mpicurl_qz'], 0);
            } elseif ($f == "downpath") {
                $value = ReturnDownpath($add['downname'], $add['downpath'], $add['delpathid'], $add['pathid'], $add['downuser'], $add['fen'], $add['thedownqz'], $add, $add['foruser'], $add['downurl_qz'], 0);
            } elseif ($f == "onlinepath") {
                $value = ReturnDownpath($add['odownname'], $add['odownpath'], $add['odelpathid'], $add['opathid'], $add['odownuser'], $add['ofen'], $add['othedownqz'], $add, $add['oforuser'], $add['onlineurl_qz'], 0);
            } elseif ($f == "smalltext") {
                if (!trim($value)) {
                    $value = SubSmalltextVal($add[newstext], $public_r[smalltextlen]);
                    //截取新闻内容
                }
            } elseif ($f == 'infoip') {
                $value = egetip();
            } elseif ($f == 'infozm') {
                $value = $value ? $value : GetInfoZm($add[title]);
            }
            //处理函数
            $value = DoFFun($modid, $f, $value, 1, 0);
            //检测必填字段
            if ($ch == 1 && empty($add['titleurl'])) {
                ChMustAddF($modid, $f, $value);
                ChIsOnlyAddF($modid, 0, $f, $value, 0);
                //唯一值
            }
            //编辑器
            if ($f == "newstext") {
                //远程保存
                $value = addslashes(CopyImg(stripSlashes($value), $add[copyimg], $add[copyflash], $add[classid], $add[qz_url], $username, $add['id'], $add['filepass'], $add['mark']));
                //替换关键字和字符
                $value = DoReplaceKeyAndWord($value, $add['dokey']);
                //自动分页
                if ($add[autopage] && !strstr($value, "[!--empirenews.page--]")) {
                    if (empty($add[autosize])) {
                        $add[autosize] = 5000;
                    }
                    $value = AutoDoPage($value, $add[autosize]);
                }
            }
            //存文本
            if ($emod_r[$modid]['savetxtf'] && $f == $emod_r[$modid]['savetxtf']) {
                //建立目录
                $thetxtfile = GetFileMd5();
                $truevalue = MkDirTxtFile(date("Y/md"), $thetxtfile);
                //写放文件
                EditTxtFieldText($truevalue, $value);
                $value = $truevalue;
            }
            if (strstr($emod_r[$modid]['tbdataf'], ',' . $f . ',')) {
                $ret_r['datafields'] .= "," . $f;
                $ret_r['datavalues'] .= ",'" . addslashes($value) . "'";
            } else {
                $ret_r['fields'] .= "," . $f;
                $ret_r['values'] .= ",'" . addslashes($value) . "'";
            }
        }
    } elseif ($do == 1) {
        //数据库操作
        for ($i = 1; $i < $count; $i++) {
            $f = $r[$i];
            if ($f == "special.field" || !strstr($emod_r[$modid]['caneditf'], ',' . $f . ',')) {
                continue;
            }
            $add[$f] = ReturnCheckboxAddF($add[$f], $modid, $f);
            //复选框
            $value = RepPhpAspJspcodeText($add[$f]);
            if ($f == 'newstime') {
                $value = empty($value) ? time() : to_time($value);
            } elseif ($f == "morepic") {
                $value = ReturnMorepicpath($add['msmallpic'], $add['mbigpic'], $add['mpicname'], $add['mdelpicid'], $add['mpicid'], $add, $add['mpicurl_qz'], 1);
            } elseif ($f == "downpath") {
                $value = ReturnDownpath($add['downname'], $add['downpath'], $add['delpathid'], $add['pathid'], $add['downuser'], $add['fen'], $add['thedownqz'], $add, $add['foruser'], $add['downurl_qz'], 1);
            } elseif ($f == "onlinepath") {
                $value = ReturnDownpath($add['odownname'], $add['odownpath'], $add['odelpathid'], $add['opathid'], $add['odownuser'], $add['ofen'], $add['othedownqz'], $add, $add['oforuser'], $add['onlineurl_qz'], 1);
            } elseif ($f == "smalltext") {
                if (!trim($value)) {
                    $value = SubSmalltextVal($add[newstext], $public_r[smalltextlen]);
                    //截取新闻内容
                }
            } elseif ($f == 'infozm') {
                $value = $value ? $value : GetInfoZm($add[title]);
            }
            //处理函数
            $value = DoFFun($modid, $f, $value, 0, 0);
            //检测必填字段
            if ($ch == 1 && empty($add['titleurl'])) {
                ChMustAddF($modid, $f, $value);
                ChIsOnlyAddF($modid, $add[id], $f, $value, 0);
                //唯一值
            }
            //数据同步
            SameDataAddF($add[id], $add[classid], $modid, $f, $value);
            //内容
            if ($f == "newstext") {
                //远程保存
                $value = addslashes(CopyImg(stripSlashes($value), $add[copyimg], $add[copyflash], $add[classid], $add[qz_url], $username, $add['id'], $add['filepass'], $add['mark']));
                //自动分页
                if ($add[autopage] && !strstr($value, "[!--empirenews.page--]")) {
                    if (empty($add[autosize])) {
                        $add[autosize] = 5000;
                    }
                    $value = AutoDoPage($value, $add[autosize]);
                }
            }
            //存文本
            if ($emod_r[$modid]['savetxtf'] && $f == $emod_r[$modid]['savetxtf']) {
                //建立目录
                $newstexttxt_r = explode("/", $add[newstext_url]);
                $thetxtfile = $newstexttxt_r[2];
                $truevalue = MkDirTxtFile($newstexttxt_r[0] . "/" . $newstexttxt_r[1], $thetxtfile);
                //写放文件
                EditTxtFieldText($truevalue, $value);
                $value = $truevalue;
            }
            if (strstr($emod_r[$modid]['tbdataf'], ',' . $f . ',')) {
                $ret_r['datafields'] .= "," . $f;
                $ret_r['datavalues'] .= "," . $f . "='" . addslashes($value) . "'";
            } else {
                $ret_r['fields'] .= "," . $f;
                $ret_r['values'] .= "," . $f . "='" . addslashes($value) . "'";
            }
        }
    } elseif ($do == 8) {
        //数据库操作
        for ($i = 1; $i < $count; $i++) {
            $f = $r[$i];
            if ($f == 'special.field') {
                continue;
            }
            $value = $add[$f];
            //存文本
            if ($emod_r[$modid]['savetxtf'] && $f == $emod_r[$modid]['savetxtf']) {
                //建立目录
                $newstexttxt_r = explode("/", $add[newstext_url]);
                $thetxtfile = $newstexttxt_r[2];
                $truevalue = MkDirTxtFile($newstexttxt_r[0] . "/" . $newstexttxt_r[1], $thetxtfile);
                //写放文件
                EditTxtFieldText($truevalue, $value);
                $value = $truevalue;
            }
            if (strstr($emod_r[$modid]['tbdataf'], ',' . $f . ',')) {
                $ret_r['datafields'] .= "," . $f;
                $ret_r['datavalues'] .= "," . $f . "='" . StripAddsData($value) . "'";
            } else {
                $ret_r['fields'] .= "," . $f;
                $ret_r['values'] .= "," . $f . "='" . StripAddsData($value) . "'";
            }
        }
    } elseif ($do == 9) {
        //数据库操作
        for ($i = 1; $i < $count; $i++) {
            $f = $r[$i];
            if ($f == 'special.field') {
                continue;
            }
            $value = $add[$f];
            //存文本
            if ($emod_r[$modid]['savetxtf'] && $f == $emod_r[$modid]['savetxtf']) {
                //建立目录
                $thetxtfile = GetFileMd5();
                $truevalue = MkDirTxtFile(date("Y/md"), $thetxtfile);
                //写放文件
                EditTxtFieldText($truevalue, $value);
                $value = $truevalue;
            }
            if (strstr($emod_r[$modid]['tbdataf'], ',' . $f . ',')) {
                $ret_r['datafields'] .= "," . $f;
                $ret_r['datavalues'] .= ",'" . StripAddsData($value) . "'";
            } else {
                $ret_r['fields'] .= "," . $f;
                $ret_r['values'] .= ",'" . StripAddsData($value) . "'";
            }
        }
    } elseif ($do == 10) {
        //数据库操作
        for ($i = 1; $i < $count; $i++) {
            $f = $r[$i];
            if ($f == 'special.field') {
                continue;
            }
            $value = $add[$f];
            if (strstr($emod_r[$modid]['tbdataf'], ',' . $f . ',')) {
                $ret_r['datafields'] .= "," . $f;
                $ret_r['datavalues'] .= ",'" . StripAddsData($value) . "'";
            } else {
                $ret_r['fields'] .= "," . $f;
                $ret_r['values'] .= ",'" . StripAddsData($value) . "'";
            }
        }
    }
    return $ret_r;
}
コード例 #2
0
ファイル: cjfun.php プロジェクト: novnan/meiju
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;
}