Ejemplo n.º 1
0
function ReturnDoMemberF($fid, $add, $mr, $ecms = 0, $username = '', $admin = 0)
{
    global $empire, $dbtbpre, $tranpicturetype, $public_r;
    $pr = $empire->fetch1("select openmembertranimg,memberimgsize,memberimgtype,openmembertranfile,memberfilesize,memberfiletype from {$dbtbpre}enewspublic limit 1");
    $formr = $empire->fetch1("select fid,enter,mustenter,filef,imgf,canaddf,caneditf,checkboxf from {$dbtbpre}enewsmemberform where fid='{$fid}'");
    //检测必填字段
    $mustr = explode(",", $formr['mustenter']);
    $mustcount = count($mustr);
    for ($i = 1; $i < $mustcount - 1; $i++) {
        $mf = $mustr[$i];
        if (strstr($formr['filef'], "," . $mf . ",") || strstr($formr['imgf'], "," . $mf . ",")) {
            $mfilef = $mf . "file";
            //上传文件
            if ($_FILES[$mfilef]['name']) {
                if (strstr($formr['imgf'], "," . $mf . ",")) {
                    if (!$pr['openmembertranimg']) {
                        printerror("CloseQTranPic", "", 1);
                    }
                } else {
                    if (!$pr['openmembertranfile']) {
                        printerror("CloseQTranFile", "", 1);
                    }
                }
            } elseif (!trim($add[$mf]) && !$mr[$mf]) {
                printerror("EmptyQMustF", "", 1);
            }
        } else {
            $chmustval = ReturnMCheckboxAddF($add[$mf], $mf, $formr['checkboxf']);
            if (!trim($chmustval)) {
                printerror("EmptyQMustF", "", 1);
            }
        }
    }
    //字段处理
    $dh = "";
    $tranf = "";
    $record = "<!--record-->";
    $field = "<!--field--->";
    $fr = explode($record, $formr['enter']);
    $count = count($fr);
    for ($i = 0; $i < $count - 1; $i++) {
        $fr1 = explode($field, $fr[$i]);
        $f = $fr1[1];
        if ($admin == 0 && ($ecms == 0 && !strstr($formr['canaddf'], ',' . $f . ',') || $ecms == 1 && !strstr($formr['caneditf'], ',' . $f . ','))) {
            continue;
        }
        //附件
        $add[$f] = str_replace('[!#@-', '', $add[$f]);
        if (strstr($formr['filef'], "," . $f . ",") || strstr($formr['imgf'], "," . $f . ",")) {
            //上传附件
            $filetf = $f . "file";
            if ($_FILES[$filetf]['name']) {
                $filetype = GetFiletype($_FILES[$filetf]['name']);
                //取得文件类型
                if (CheckSaveTranFiletype($filetype)) {
                    printerror("NotQTranFiletype", "", 1);
                }
                if (strstr($formr['imgf'], "," . $f . ",")) {
                    if (!$pr['openmembertranimg']) {
                        printerror("CloseQTranPic", "", 1);
                    }
                    if (!strstr($pr['memberimgtype'], "|" . $filetype . "|")) {
                        printerror("NotQTranFiletype", "", 1);
                    }
                    if ($_FILES[$filetf]['size'] > $pr['memberimgsize'] * 1024) {
                        printerror("TooBigQTranFile", "", 1);
                    }
                    if (!strstr($tranpicturetype, ',' . $filetype . ',')) {
                        printerror("NotQTranFiletype", "", 1);
                    }
                } else {
                    if (!$pr['openmembertranfile']) {
                        printerror("CloseQTranFile", "", 1);
                    }
                    if (!strstr($pr['memberfiletype'], "|" . $filetype . "|")) {
                        printerror("NotQTranFiletype", "", 1);
                    }
                    if ($_FILES[$filetf]['size'] > $pr['memberfilesize'] * 1024) {
                        printerror("TooBigQTranFile", "", 1);
                    }
                }
                $tranf .= $dh . $f;
                $dh = ",";
                $fval = "[!#@-" . $f . "-@!]";
            } else {
                $fval = $add[$f];
                if ($ecms == 1 && $mr[$f] && !trim($fval)) {
                    $fval = $mr[$f];
                }
            }
        } else {
            $add[$f] = ReturnMCheckboxAddF($add[$f], $f, $formr['checkboxf']);
            $fval = $add[$f];
        }
        $fval = DoMemberFValue($fval);
        $fval = RepPostStr2($fval);
        $fval = addslashes($fval);
        if ($ecms == 0) {
            $ret_r[0] .= ",`" . $f . "`";
            $ret_r[1] .= ",'" . $fval . "'";
        } else {
            $ret_r[0] .= ",`" . $f . "`='" . $fval . "'";
        }
    }
    //上传附件
    if ($tranf) {
        $infoid = 0;
        $filepass = 0;
        $classid = 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']) {
                if (strstr($formr['imgf'], "," . $tf . ",")) {
                    $type = 1;
                } else {
                    $type = 0;
                }
                //写入数据库
                $filetime = date("Y-m-d H:i:s");
                $filesize = (int) $_FILES[$tffile]['size'];
                $sql = $empire->query("insert into {$dbtbpre}enewsfile(filename,filesize,adduser,path,filetime,classid,no,type,id,cjid,fpath) values('{$tfr['filename']}',{$filesize},'[EditInfo]" . $username . "','{$tfr['filepath']}','{$filetime}',{$classid},'Member[" . $tf . "]',{$type},{$infoid},{$filepass},'{$public_r['fpath']}');");
                //删除旧文件
                if ($ecms == 1 && $mr[$tf]) {
                    DelYMemberTranFile($mr[$tf], $tf, $username);
                }
                $repfval = $tfr['url'];
            } else {
                $repfval = $mr[$tf];
            }
            if ($ecms == 0) {
                $ret_r[1] = str_replace("[!#@-" . $tf . "-@!]", $repfval, $ret_r[1]);
            } else {
                $ret_r[0] = str_replace("[!#@-" . $tf . "-@!]", $repfval, $ret_r[0]);
            }
        }
    }
    return $ret_r;
}
Ejemplo n.º 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;
}