示例#1
0
function TranFile($file, $file_name, $file_type, $file_size, $tranurl, $no, $classid, $type, $post, $userid, $username)
{
    global $empire, $public_r, $loginrnd, $dbtbpre, $ecms_config;
    if (!$no) {
        $no = $file_name;
    }
    $tranfrom = (int) $post['tranfrom'];
    $classid = (int) $classid;
    $modtype = (int) $post['modtype'];
    $infoid = (int) $post['infoid'];
    $fstb = 0;
    if (empty($modtype)) {
        $fstb = GetInfoTranFstb($classid, $infoid, 0);
    }
    //是否为空
    if (!$file_name) {
        if (empty($tranurl) || $tranurl == "http://") {
            $tranfrom == 0 ? printerror("EmptyHttp", "history.go(-1)", 8) : ECMS_EditorPrintError(1, '', '', 'EmptyHttp', '', '');
        }
        $filetype = GetFiletype($tranurl);
        //取得文件类型
        $file_size = 0;
    } else {
        $filetype = GetFiletype($file_name);
        //取得文件类型
    }
    //如果是.php文件
    if (CheckSaveTranFiletype($filetype)) {
        $tranfrom == 0 ? printerror("TranPHP", "history.go(-1)", 8) : ECMS_EditorPrintError(1, '', '', 'TranPHP', '', '');
    }
    $type_r = explode("|" . $filetype . "|", $public_r['filetype']);
    if (count($type_r) < 2) {
        $tranfrom == 0 ? printerror("TranFiletypeFail", "history.go(-1)", 8) : ECMS_EditorPrintError(1, '', '', 'TranFiletypeFail', '', '');
    }
    if ($file_size > $public_r['filesize'] * 1024) {
        $tranfrom == 0 ? printerror("TranFilesizeFail", "history.go(-1)", 8) : ECMS_EditorPrintError(1, '', '', 'TranFilesizeFail', '', '');
    }
    if ($type == 1) {
        if (!strstr($ecms_config['sets']['tranpicturetype'], ',' . $filetype . ',')) {
            $tranfrom == 0 ? printerror("NotTranImg", "history.go(-1)", 8) : ECMS_EditorPrintError(1, '', '', 'NotTranImg', '', '');
        }
    } elseif ($type == 2) {
        if (!strstr($ecms_config['sets']['tranflashtype'], ',' . $filetype . ',')) {
            $tranfrom == 0 ? printerror("NotTranFlash", "history.go(-1)", 8) : ECMS_EditorPrintError(1, '', '', 'NotTranFlash', '', '');
        }
    } elseif ($type == 3) {
    } else {
    }
    //远程保存
    if (empty($file_name)) {
        $r = DoTranUrl($tranurl, $classid);
        if (empty($r[tran])) {
            $tranfrom == 0 ? printerror("TranHttpFail", "history.go(-1)", 8) : ECMS_EditorPrintError(1, '', '', 'TranHttpFail', '', '');
        }
    } else {
        $r = DoTranFile($file, $file_name, $file_type, $file_size, $classid);
        if (empty($r[tran])) {
            $tranfrom == 0 ? printerror("TranFail", "history.go(-1)", 8) : ECMS_EditorPrintError(1, '', '', 'TranFail', '', '');
        }
    }
    if (!$no) {
        $no = $r[filename];
    }
    //写入数据库
    $r[filesize] = (int) $r[filesize];
    $classid = (int) $classid;
    $post[filepass] = (int) $post[filepass];
    $type = (int) $type;
    $sql = eInsertFileTable($r[filename], $r[filesize], $r[filepath], $username, $classid, $no, $type, $post[filepass], $post[filepass], $public_r[fpath], 0, $modtype, $fstb);
    $fileid = $empire->lastid();
    //导入gd.php文件
    if ($type == 1 && ($post['getsmall'] || $post['getmark'])) {
        @(include ECMS_PATH . DASHBOARD . "/class/gd.php");
    }
    //缩略图
    if ($type == 1 && $post['getsmall']) {
        GetMySmallImg($classid, $no, $r[insertfile], $r[filepath], $r[yname], $post[width], $post[height], $r[name], $post['filepass'], $post['filepass'], $userid, $username, $modtype, $fstb);
    }
    //水印
    if ($type == 1 && $post['getmark']) {
        GetMyMarkImg($r['yname']);
    }
    if ($sql) {
        if ($tranfrom == 1) {
            //$imgstr=EditorSetTranPic($r[url],$r[url],$post);
            ECMS_EditorPrintError(0, $r[url], $r[filename], '', $no, $r[filesize]);
            db_close();
            exit;
        }
        echo "<script>parent.location.reload();</script>";
        db_close();
        exit;
    } else {
        $tranfrom == 0 ? printerror("InTranRecordFail", "history.go(-1)", 8) : ECMS_EditorPrintError(1, '', '', 'InTranRecordFail', '', '');
    }
}
示例#2
0
function TranFile($file, $file_name, $file_type, $file_size, $tranurl, $no, $classid, $type, $post, $userid, $username)
{
    global $empire, $public_r, $loginrnd, $dbtbpre, $tranpicturetype, $tranflashtype, $mediaplayertype, $realplayertype;
    if (!$no) {
        $no = $file_name;
    }
    $tranfrom = (int) $post['tranfrom'];
    $classid = (int) $classid;
    //是否为空
    if (!$file_name) {
        if (empty($tranurl) || $tranurl == "http://") {
            $tranfrom == 0 ? printerror("EmptyHttp", "history.go(-1)", 8) : ECMS_EditorPrintError(1, '', '', 'EmptyHttp', '', '');
        }
        $filetype = GetFiletype($tranurl);
        //取得文件类型
        $file_size = 0;
    } else {
        $filetype = GetFiletype($file_name);
        //取得文件类型
    }
    //如果是.php文件
    if (CheckSaveTranFiletype($filetype)) {
        $tranfrom == 0 ? printerror("TranPHP", "history.go(-1)", 8) : ECMS_EditorPrintError(1, '', '', 'TranPHP', '', '');
    }
    $type_r = explode("|" . $filetype . "|", $public_r['filetype']);
    if (count($type_r) < 2) {
        $tranfrom == 0 ? printerror("TranFiletypeFail", "history.go(-1)", 8) : ECMS_EditorPrintError(1, '', '', 'TranFiletypeFail', '', '');
    }
    if ($file_size > $public_r['filesize'] * 1024) {
        $tranfrom == 0 ? printerror("TranFilesizeFail", "history.go(-1)", 8) : ECMS_EditorPrintError(1, '', '', 'TranFilesizeFail', '', '');
    }
    if ($type == 1) {
        if (!strstr($tranpicturetype, ',' . $filetype . ',')) {
            $tranfrom == 0 ? printerror("NotTranImg", "history.go(-1)", 8) : ECMS_EditorPrintError(1, '', '', 'NotTranImg', '', '');
        }
    } elseif ($type == 2) {
        if (!strstr($tranflashtype, ',' . $filetype . ',')) {
            $tranfrom == 0 ? printerror("NotTranFlash", "history.go(-1)", 8) : ECMS_EditorPrintError(1, '', '', 'NotTranFlash', '', '');
        }
    } elseif ($type == 3) {
    } else {
    }
    //远程保存
    if (empty($file_name)) {
        $r = DoTranUrl($tranurl, $classid);
        if (empty($r[tran])) {
            $tranfrom == 0 ? printerror("TranHttpFail", "history.go(-1)", 8) : ECMS_EditorPrintError(1, '', '', 'TranHttpFail', '', '');
        }
    } else {
        $r = DoTranFile($file, $file_name, $file_type, $file_size, $classid);
        if (empty($r[tran])) {
            $tranfrom == 0 ? printerror("TranFail", "history.go(-1)", 8) : ECMS_EditorPrintError(1, '', '', 'TranFail', '', '');
        }
    }
    if (!$no) {
        $no = $r[filename];
    }
    //写入数据库
    $r[filesize] = (int) $r[filesize];
    $classid = (int) $classid;
    $post[filepass] = (int) $post[filepass];
    $type = (int) $type;
    $filetime = date("Y-m-d H:i:s");
    $sql = $empire->query("insert into {$dbtbpre}enewsfile(filename,filesize,adduser,path,filetime,classid,no,type,id,cjid,fpath) values('{$r['filename']}',{$r['filesize']},'{$username}','{$r['filepath']}','{$filetime}',{$classid},'{$no}',{$type},{$post['filepass']},{$post['filepass']},'{$public_r['fpath']}');");
    $fileid = $empire->lastid();
    //导入gd.php文件
    if ($type == 1 && ($post['getsmall'] || $post['getmark'])) {
        @(include ECMS_PATH . "e/class/gd.php");
    }
    //缩略图
    if ($type == 1 && $post['getsmall']) {
        GetMySmallImg($classid, $no, $r[insertfile], $r[filepath], $r[yname], $post[width], $post[height], $r[name], $post['filepass'], $post['filepass'], $userid, $username);
    }
    //水印
    if ($type == 1 && $post['getmark']) {
        GetMyMarkImg($r['yname']);
    }
    if ($sql) {
        if ($tranfrom == 1) {
            //$imgstr=EditorSetTranPic($r[url],$r[url],$post);
            ECMS_EditorPrintError(0, $r[url], $r[filename], '', $no, $r[filesize]);
            db_close();
            exit;
        }
        echo "<script>parent.location.reload();</script>";
        db_close();
        exit;
    } else {
        $tranfrom == 0 ? printerror("InTranRecordFail", "history.go(-1)", 8) : ECMS_EditorPrintError(1, '', '', 'InTranRecordFail', '', '');
    }
}