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;
}
Beispiel #2
0
function ReturnQAddinfoF($mid, $add, $infor, $classid, $filepass, $userid, $username, $ecms = 0)
{
    global $empire, $dbtbpre, $public_r, $emod_r, $ecms_config;
    $ret_r = array();
    $pr = $empire->fetch1("select qaddtran,qaddtransize,qaddtranimgtype,qaddtranfile,qaddtranfilesize,qaddtranfiletype,closewords,closewordsf from {$dbtbpre}enewspublic limit 1");
    $isadd = $ecms == 0 ? 1 : 0;
    qCheckInfoCloseWord($mid, $add, $pr['closewordsf'], $pr['closewords']);
    //屏蔽字符验证
    //检测必填字段
    $pagef = $emod_r[$mid]['pagef'];
    $mustr = explode(",", $emod_r[$mid]['mustqenterf']);
    $mustcount = count($mustr) - 1;
    for ($i = 1; $i < $mustcount; $i++) {
        $mf = $mustr[$i];
        if (strstr($emod_r[$mid]['filef'], ',' . $mf . ',') || strstr($emod_r[$mid]['imgf'], ',' . $mf . ',') || strstr($emod_r[$mid]['flashf'], ',' . $mf . ',') || $mf == 'downpath' || $mf == 'onlinepath') {
            $mfilef = $mf . "file";
            //上传文件
            if ($_FILES[$mfilef]['name']) {
                if (strstr($emod_r[$mid]['imgf'], ',' . $mf . ',')) {
                    if (!$pr['qaddtran']) {
                        printerror("CloseQTranPic", "", 1);
                    }
                } else {
                    if (!$pr['qaddtranfile']) {
                        printerror("CloseQTranFile", "", 1);
                    }
                }
            } elseif (!trim($add[$mf]) && !$infor[$mf]) {
                printerror("EmptyQMustF", "", 1);
            }
        } else {
            $chmustval = ReturnCheckboxAddF($add[$mf], $mid, $mf);
            //复选框
            $chmustval = ReturnMoreValueAddF($add, $chmustval, $mid, $mf, $ecms);
            //多值
            if (!trim($chmustval)) {
                printerror("EmptyQMustF", "", 1);
            }
        }
    }
    //字段处理
    $dh = "";
    $tranf = "";
    $fr = explode(',', $emod_r[$mid]['qenter']);
    $count = count($fr) - 1;
    for ($i = 1; $i < $count; $i++) {
        $f = $fr[$i];
        if ($f == 'special.field' || $ecms == 0 && !strstr($emod_r[$mid]['canaddf'], ',' . $f . ',') || $ecms == 1 && !strstr($emod_r[$mid]['caneditf'], ',' . $f . ',')) {
            continue;
        }
        //附件
        $add[$f] = str_replace('[!#@-', 'ecms', $add[$f]);
        if (strstr($emod_r[$mid]['filef'], ',' . $f . ',') || strstr($emod_r[$mid]['imgf'], ',' . $f . ',') || strstr($emod_r[$mid]['flashf'], ',' . $f . ',') || $f == 'downpath' || $f == 'onlinepath') {
            //上传附件
            $filetf = $f . "file";
            if ($_FILES[$filetf]['name']) {
                $filetype = GetFiletype($_FILES[$filetf]['name']);
                //取得文件类型
                if (CheckSaveTranFiletype($filetype)) {
                    printerror("NotQTranFiletype", "", 1);
                }
                if (strstr($emod_r[$mid]['imgf'], ',' . $f . ',')) {
                    if (!$pr['qaddtran']) {
                        printerror("CloseQTranPic", "", 1);
                    }
                    if (!strstr($pr['qaddtranimgtype'], "|" . $filetype . "|")) {
                        printerror("NotQTranFiletype", "", 1);
                    }
                    if ($_FILES[$filetf]['size'] > $pr['qaddtransize'] * 1024) {
                        printerror("TooBigQTranFile", "", 1);
                    }
                    if (!strstr($ecms_config['sets']['tranpicturetype'], ',' . $filetype . ',')) {
                        printerror("NotQTranFiletype", "", 1);
                    }
                } else {
                    if (!$pr['qaddtranfile']) {
                        printerror("CloseQTranFile", "", 1);
                    }
                    if (!strstr($pr['qaddtranfiletype'], "|" . $filetype . "|")) {
                        printerror("NotQTranFiletype", "", 1);
                    }
                    if ($_FILES[$filetf]['size'] > $pr['qaddtranfilesize'] * 1024) {
                        printerror("TooBigQTranFile", "", 1);
                    }
                    if (strstr($emod_r[$mid]['flashf'], ',' . $f . ',')) {
                        if (!strstr($ecms_config['sets']['tranflashtype'], "," . $filetype . ",")) {
                            printerror("NotQTranFiletype", "", 1);
                        }
                    }
                    if ($f == "onlinepath") {
                        if (strstr($wmv_type, "," . $filetype . ",")) {
                        }
                    }
                }
                $tranf .= $dh . $f;
                $dh = ",";
                $fval = "[!#@-" . $f . "-@!]";
            } else {
                if ($public_r['modinfoedittran'] == 1) {
                    $fval = $add[$f];
                    if ($ecms == 1 && $infor[$f] && !trim($fval)) {
                        $fval = $infor[$f];
                        //特殊字段
                        if ($f == "downpath" || $f == "onlinepath") {
                            $fval = DoReqDownPath($fval);
                        }
                    }
                } else {
                    $fval = '';
                    if ($ecms == 1) {
                        $fval = $infor[$f];
                        //特殊字段
                        if ($f == "downpath" || $f == "onlinepath") {
                            $fval = DoReqDownPath($fval);
                        }
                    }
                }
            }
        } elseif ($f == 'newstime') {
            if ($add[$f]) {
                $fval = to_time($add[$f]);
            } else {
                $fval = time();
            }
        } elseif ($f == 'newstext') {
            if ($ecms == 0) {
                $fval = DoReplaceKeyAndWord($add[$f], 1, $classid);
                //替换关键字和字符
            } else {
                $fval = $add[$f];
            }
        } elseif ($f == 'infoip') {
            $fval = egetip();
        } elseif ($f == 'infoipport') {
            $fval = egetipport();
        } elseif ($f == 'infozm') {
            $fval = $add[$f] ? $add[$f] : GetInfoZm($add[title]);
        } else {
            $add[$f] = ReturnCheckboxAddF($add[$f], $mid, $f);
            //复选框
            $add[$f] = ReturnMoreValueAddF($add, $add[$f], $mid, $f, $ecms);
            //多值
            $fval = $add[$f];
        }
        $fval = DoFFun($mid, $f, $fval, $isadd, 1);
        //执行函数
        $modispagef = $pagef == $f ? 1 : 0;
        $fval = RepTempvarPostStrT($fval, $modispagef);
        if ($pagef != $f) {
            $fval = RepTempvarPostStr($fval);
        }
        ChIsOnlyAddF($mid, $infor[id], $f, $fval, 1);
        //唯一值
        $fval = DoqValue($mid, $f, $fval);
        $fval = DoqSpecialValue($mid, $f, $fval, $add, $infor, $ecms);
        $fval = RepPostStr2($fval);
        if ($ecms == 1) {
            SameDataAddF($info[id], $classid, $mid, $f, $fval);
        }
        $fval = addslashes($fval);
        if ($ecms == 0) {
            if (strstr($emod_r[$mid]['tbdataf'], ',' . $f . ',')) {
                $ret_r[2] .= "," . $f;
                $ret_r[3] .= ",'" . $fval . "'";
            } else {
                $ret_r[0] .= "," . $f;
                $ret_r[1] .= ",'" . $fval . "'";
            }
        } else {
            if ($f == 'infoip' || $f == 'infoipport') {
                continue;
            }
            if (strstr($emod_r[$mid]['tbdataf'], ',' . $f . ',')) {
                $ret_r[3] .= "," . $f . "='" . $fval . "'";
            } else {
                $ret_r[0] .= "," . $f . "='" . $fval . "'";
            }
        }
    }
    //上传附件
    if ($tranf) {
        if ($ecms == 0) {
            $infoid = 0;
        } else {
            $infoid = $infor['id'];
            $filepass = 0;
        }
        $tranr = explode(",", $tranf);
        $count = count($tranr);
        for ($i = 0; $i < $count; $i++) {
            $tf = $tranr[$i];
            $tffile = $tf . "file";
            $tfr = DoTranFile($_FILES[$tffile]['tmp_name'], $_FILES[$tffile]['name'], $_FILES[$tffile]['type'], $_FILES[$tffile]['size'], $classid);
            if ($tfr['tran']) {
                //文件类型
                $mvf = $tf . "mtfile";
                if (strstr($emod_r[$mid]['imgf'], ',' . $tf . ',')) {
                    $type = 1;
                } elseif (strstr($emod_r[$mid]['flashf'], ',' . $tf . ',')) {
                    $type = 2;
                } elseif ($add[$mvf] == 1) {
                    $type = 3;
                } else {
                    $type = 0;
                }
                //写入数据库
                $filetime = time();
                $filesize = (int) $_FILES[$tffile]['size'];
                $classid = (int) $classid;
                eInsertFileTable($tfr[filename], $filesize, $tfr[filepath], '[Member]' . $username, $classid, '[' . $tf . ']' . addslashes(RepPostStr($add[title])), $type, $infoid, $filepass, $public_r[fpath], 0, 0, $ecms == 1 ? $infor['fstb'] : $public_r['filedeftb']);
                //删除旧文件
                if ($ecms == 1 && $infor[$tf]) {
                    DelYQTranFile($classid, $infor['id'], $infor[$tf], $tf, $infor['fstb']);
                }
                $repfval = $tfr['url'];
            } else {
                $repfval = $infor[$tf];
                //特殊字段
                if ($tf == "downpath" || $tf == "onlinepath") {
                    $repfval = DoReqDownPath($repfval);
                }
            }
            if ($ecms == 0) {
                $ret_r[1] = str_replace("[!#@-" . $tf . "-@!]", $repfval, $ret_r[1]);
                $ret_r[3] = str_replace("[!#@-" . $tf . "-@!]", $repfval, $ret_r[3]);
            } else {
                $ret_r[0] = str_replace("[!#@-" . $tf . "-@!]", $repfval, $ret_r[0]);
                $ret_r[3] = str_replace("[!#@-" . $tf . "-@!]", $repfval, $ret_r[3]);
            }
        }
    }
    $ret_r[4] = $emod_r[$mid]['deftb'];
    return $ret_r;
}