Exemplo n.º 1
0
function uploadfile($field, $intro = "", $SaveDir = "", $SaveFileName = "", $type = "upload")
{
    global $iCMS;
    $UploadDir = $iCMS->config['uploadfiledir'] . "/";
    $RelativePath = $iCMS->dir . $UploadDir;
    //相对路径
    $RootPath = iPATH . $UploadDir;
    //绝对路径
    if ($_FILES[$field]['name']) {
        $tmp_name = $_FILES[$field]['tmp_name'];
        !is_uploaded_file($tmp_name) && exit("What are you doing?");
        if ($_FILES[$field]['error'] > 0) {
            switch ((int) $_FILES[$field]['error']) {
                case UPLOAD_ERR_NO_FILE:
                    @unlink($tmp_name);
                    alert('请选择上传文件!');
                    return false;
                    break;
                case UPLOAD_ERR_FORM_SIZE:
                    @unlink($tmp_name);
                    alert('上传的文件超过大小!');
                    return false;
                    break;
            }
            return false;
        }
        $_FileSize = @filesize($tmp_name);
        //文件类型
        preg_match("/\\.([a-zA-Z0-9]{2,4})\$/", $_FILES[$field]['name'], $exts);
        $FileExt = strtolower($exts[1]);
        //ļʽ
        CheckValidExt($FileExt);
        //判断文件类型
        //过滤文件;
        strstr($FileExt, 'ph') && ($FileExt = "phpfile");
        in_array($FileExt, array('cer', 'htr', 'cdx', 'asa', 'asp', 'jsp', 'aspx', 'cgi')) && ($FileExt .= "file");
        $FileNameTmp = get_date('', "YmdHis") . rand(1, 999999);
        empty($SaveFileName) && ($SaveFileName = $FileNameTmp . "." . $FileExt);
        $oFileName = $_FILES[$field]['name'];
        // 文件保存目录方式
        $_CreateDir = "";
        if (empty($SaveDir)) {
            if ($iCMS->config['savedir']) {
                $_CreateDir = str_replace(array('Y', 'y', 'm', 'n', 'd', 'j', 'EXT'), array(get_date('', 'Y'), get_date('', 'y'), get_date('', 'm'), get_date('', 'n'), get_date('', 'd'), get_date('', 'j'), $FileExt), $iCMS->config['savedir']) . "/";
            }
        } else {
            $_CreateDir = $SaveDir . "/";
        }
        //	$UploadDir		= $UploadDir.$_CreateDir;
        $RelativePath = $RelativePath . $_CreateDir;
        $RootPath = $RootPath . $_CreateDir;
        //创建目录
        createdir($RootPath);
        //文件名
        //	$sFileName				= $UploadDir.$SaveFileName;
        $RelativePath_FileName = $RelativePath . $SaveFileName;
        $RootPath_FileName = $RootPath . $SaveFileName;
        savefile($tmp_name, $RootPath_FileName);
        if (in_array($FileExt, array('gif', 'jpg', 'jpeg', 'png'))) {
            if ($iCMS->config['isthumb'] && ($iCMS->config['thumbwidth'] || $iCMS->config['thumbhight'])) {
                $Thumb = MakeThumbnail($RootPath, $RootPath_FileName, $FileNameTmp);
                !empty($Thumb['src']) && imageWaterMark($Thumb['src']);
            }
            imageWaterMark($RootPath . $SaveFileName);
        }
        $RelativePath_FileName = getfilepath($RelativePath_FileName, '', '-');
        // 写入数据库
        if ($type == "upload") {
            $iCMS->db->query("INSERT INTO `#iCMS@__file` (`filename`,`ofilename`,`path`,`intro`,`ext`,`size`,`time`,`type`) VALUES ('{$SaveFileName}', '{$oFileName}', '{$RelativePath_FileName}','{$intro}', '{$FileExt}', '{$_FileSize}', '" . time() . "', 'upload') ");
        }
        $_File = array('fid' => $iCMS->db->insert_id, 'FilePath' => $RelativePath_FileName, 'OriginalFileName' => $oFileName, 'FileName' => $SaveFileName);
        return $_File;
    } else {
        return;
    }
}
Exemplo n.º 2
0
function GetMyMarkImg($groundImage)
{
    global $public_r;
    if (empty($groundImage)) {
        return "";
    }
    imageWaterMark($groundImage, $public_r['markpos'], $public_r['markimg'], $public_r['marktext'], $public_r['markfontsize'], $public_r['markfontcolor'], $public_r['markfont'], $public_r['markpct'], $public_r['jpgquality']);
}
Exemplo n.º 3
0
function get_outpic($str, $fid = 0, $getpic = 1)
{
    global $webdb, $lfjuid;
    if (!$getpic) {
        return $str;
    }
    preg_match_all("/http:\\/\\/([^ '\"<>]+)\\.(gif|jpg|png)/is", $str, $array);
    $filedb = $array[0];
    foreach ($filedb as $key => $value) {
        if (strstr($value, $webdb[www_url])) {
            continue;
        }
        $listdb["{$value}"] = $value;
    }
    unset($filedb);
    foreach ($listdb as $key => $value) {
        $filedb[] = $value;
        $name = $lfjuid . '_' . rands(5) . "__" . basename($value);
        if (!is_dir(ROOT_PATH . "{$webdb['updir']}/article/{$fid}")) {
            makepath(ROOT_PATH . "{$webdb['updir']}/article/{$fid}");
        }
        $ck = 0;
        if (@copy($value, ROOT_PATH . "{$webdb['updir']}/article/{$fid}/{$name}")) {
            $ck = 1;
        } elseif ($filestr = file_get_contents($value)) {
            $ck = 1;
            write_file(ROOT_PATH . "{$webdb['updir']}/article/{$fid}/{$name}", $filestr);
        }
        /*加水印*/
        if ($ck && $webdb[is_waterimg] && $webdb[if_gdimg]) {
            include_once ROOT_PATH . "inc/waterimage.php";
            $uploadfile = ROOT_PATH . "{$webdb['updir']}/article/{$fid}/{$name}";
            imageWaterMark($uploadfile, $webdb[waterpos], ROOT_PATH . $webdb[waterimg]);
        }
        if ($ck) {
            //$str=str_replace("$value","http://www_php168_com/Tmp_updir/article/$fid/$name",$str);
            $str = str_replace("{$value}", "{$webdb['www_url']}/{$webdb['updir']}/article/{$fid}/{$name}", $str);
        }
    }
    return $str;
}
Exemplo n.º 4
0
 /**
  * 图片重新加水印接口
  *
  * 参数:picurl
  */
 public function imageWatermark()
 {
     // 大尺寸图片上传时内存需要增大
     ini_set("memory_limit", "100M");
     // 配置文件
     global $uploadConfig;
     // 图片上传全局配置
     $imageUpload = $uploadConfig['IMAGE_UPLOAD'];
     // 上传错误
     $uploadError = $uploadConfig['UPLOAD_ERROR'];
     // 待处理图片地址
     $imgpath = $_POST['picurl'];
     // 1.判断是否需要加水印
     // 1.1 原图不需要加水印
     if (strpos($imgpath, '_') === false) {
         callBack(array('status' => 'error', 'tip' => '原图不需要加水印!'));
     }
     // 1.2 非JPG或PNG图片不需要加水印
     // 图片后缀名
     $suffix = strrchr($imgpath, ".");
     if ($suffix !== '.jpg' && $suffix !== '.jpeg' && $suffix !== '.png') {
         callBack(array('status' => 'error', 'tip' => '非JPG或PNG图片不需要加水印!'));
     }
     // 1.3 低于指定尺寸不需要加水印
     $imageInfo = getimagesize($imgpath);
     if (!$imageInfo) {
         callBack(array('status' => 'error', 'tip' => '图片出错,请确认!'));
     }
     // 图片水印
     // 水印配置
     $watermark = $uploadConfig['WATERMARK'];
     if ($watermark['WATERMARK_IMAGE_WIDTH']) {
         if ($imageInfo[0] < $watermark['WATERMARK_IMAGE_WIDTH'] || $imageInfo[1] < $watermark['WATERMARK_IMAGE_HEIGHT']) {
             callBack(array('status' => 'error', 'tip' => '图片宽度低于' . $watermark['WATERMARK_IMAGE_WIDTH'] . 'px或高度低于' . $watermark['WATERMARK_IMAGE_HEIGHT'] . 'px不需要加水印!'));
         }
     }
     // 待处理图片宽度
     $width = $imageInfo[0];
     // 待处理图片高度
     $height = $imageInfo[1];
     // 2.根据原图片加水印
     // 原图片地址
     $oimgpath = str_replace(str_replace(strrchr($imgpath, "."), '', strrchr($imgpath, "_")), '', $imgpath);
     // 原图片高度
     $oimageInfo = getimagesize($oimgpath);
     if (!$oimageInfo) {
         callBack(array('status' => 'error', 'tip' => '图片出错,请确认!'));
     }
     switch ($oimageInfo[2]) {
         case 2:
             $image2 = imagecreatefromjpeg($oimgpath);
             break;
         case 3:
             $image2 = imagecreatefrompng($oimgpath);
             break;
         default:
             break;
     }
     // 原图片宽度
     $owidth = $oimageInfo[0];
     // 原图片高度
     $oheight = $oimageInfo[1];
     // 去域名后文件名
     $filename = str_replace($imageUpload['DOMAIN'], '', $imgpath);
     // 目标图绝对地址
     $cFilepath = $imageUpload['FILE_PATH'] . $filename;
     // 水印图片路径
     $waterImage = $imageUpload['FILE_PATH'] . "Data/Public/watermark_new.png";
     if ($width && $height) {
         $cimage = imagecreatetruecolor($width, $height);
         $cred = imagecolorallocate($cimage, 255, 255, 255);
         imagefilledrectangle($cimage, 0, 0, $width, $height, $cred);
         // 填充背景色
         imagecopyresampled($cimage, $image2, 0, 0, 0, 0, floor($width), floor($height), $owidth, $oheight);
         $compress = imagejpeg($cimage, $cFilepath, 100);
         if (!$compress) {
             callBack(array('status' => 'error', 'tip' => $uploadError['MSG_UPLOADFALSEERROR']));
             //文件上传错误
         }
     }
     // 图片需要加水印
     if ($watermark['WATERMARK_IMAGE_WIDTH']) {
         if ($width >= $watermark['WATERMARK_IMAGE_WIDTH'] && $height >= $watermark['WATERMARK_IMAGE_HEIGHT']) {
             $waterPosition = $watermark['WATERMARK_POSITION'] ? $watermark['WATERMARK_POSITION'] : 10;
             $re = imageWaterMark($cFilepath, $waterPosition, $waterImage);
             if ($re !== true) {
                 //unlink($cFilepath);
                 callBack(array('status' => 'error', 'tip' => $re));
                 //加水印错误
             }
         }
     }
     imagedestroy($image2);
     //上传成功,返回访问url以及图片目录
     callBack(array('status' => 'ok'));
 }
Exemplo n.º 5
0
/**
 * 保存本地图片文件,并是否打水印
 * @param $fileName   文件名        没有默认值,必须指定
 * @param $ImagePath  保存路径      没有默认值
 * @param $ext_name   后缀名        没有默认值
 * @param $watermark  是否打水印    默认值为1,打水印
 *
 * @return 文件路径
 */
function savePicLocal($fileName, $ImagePath, $ext_name, $watermark = 0)
{
    $s_filename = basename($fileName);
    //  $ext_name = strtolower( strrchr( $s_filename, "." ) );
    //  if( ( ".jpg" && ".gif" && ".png" && ".bmp" ) != strtolower( $ext_name ) )  {
    //    return "";
    //  }
    /*
       if( 0 == strpos( $fileName, "/" ) )
       {
       //    preg_match( "@http://(.*?)/@i", $this->URL, $url );
       $url = $url[0];
       }
       //*/
    //  $contents = file_get_contents( $url . $fileName );
    $contents = file_get_contents($fileName);
    $s_filename = date("His", time()) . rand(1000, 9999) . $ext_name;
    //file_put_contents( $this->saveImagePath.$s_filename, $contents );
    $handle = fopen($ImagePath . $s_filename, "w");
    fwrite($handle, $contents);
    fclose($handle);
    if ($watermark == 1) {
        imageWaterMark($ImagePath . $s_filename, 9, WATERMARKPIC);
        //imageWaterMark($ImagePath.$s_filename,9,"","http://www.zerolone.com/",5,"#FF0000");
    }
    return $s_filename;
}
Exemplo n.º 6
0
    //生成上传实例对象并完成上传
    $up = new Uploader( "upfile" , $config );

    /**
     * 得到上传文件所对应的各个参数,数组结构
     * array(
     *     "originalName" => "",   //原始文件名
     *     "name" => "",           //新文件名
     *     "url" => "",            //返回的地址
     *     "size" => "",           //文件大小
     *     "type" => "" ,          //文件类型
     *     "state" => ""           //上传状态,上传成功时必须返回"SUCCESS"
     * )
     */
    $info = $up->getFileInfo();

    /**
     * 向浏览器返回数据json数据
     * {
     *   'url'      :'a.jpg',   //保存后的文件路径
     *   'title'    :'hello',   //文件描述,对图片来说在前端会添加到title属性上
     *   'original' :'b.jpg',   //原始文件名
     *   'state'    :'SUCCESS'  //上传状态,成功时返回SUCCESS,其他任何值将原样返回至图片上传框中
     * }
     */
	 //
	$cfg==1&&@imageWaterMark($info["url"],9,'../../css/watermark.png');
    echo "{'url':'" . $info["url"] . "','title':'" . $title . "','original':'" . $info["originalName"] . "','state':'" . $info["state"] . "'}";
	

Exemplo n.º 7
0
 function swfsave_action(){
     if (is_array($_FILES['Filedata'])) {
         $upload = new upload();
         $upload->dir = 'images';
         $upload->max_size = 2048000;
         $attachment = new attachment();
         $_file_type = str_replace(',','|',config::get('upload_filetype'));
         $file = $_FILES['Filedata'];
         $file['name'] = strtolower($file['name']);
         if ($file['size'] > $upload->max_size) {
             echo "附件超过上限(".ceil($upload->max_size / 1024)."K)!');";
             exit;
         }
         if (!front::checkstr(file_get_contents($file['tmp_name']))) {
             echo '上传失败!请将图片保存为WEB格式!';
             exit;
         }
         if (!$file['name'] || !preg_match('/\.('.$_file_type.')$/',$file['name'])){
             echo '上传失败!不允许的文件类型!';
             exit;
         }
         $filename = $upload->run($file);
         if(config::get('watermark_open')) {
             include_once ROOT.'/lib/plugins/watermark.php';
             imageWaterMark($filename,config::get('watermark_pos'),config::get('watermark_path'),null,5,"#FF0000",config::get('watermark_ts'),config::get('watermark_qs'));
         }
         if (!$filename) {
             echo "附件保存失败!";
             exit;
         }
         echo 'ok_'.$filename;
         exit;
     }else{
         exit('请添加文件');
     }
 }
Exemplo n.º 8
0
function move_attachment($uid, $str, $newdir, $type = '')
{
    global $webdb, $db, $pre, $id, $aid, $fid, $timestamp, $webdb, $Fid_db;
    if (!$str || !$uid || !$newdir) {
        return $str;
    }
    $_id = $id ? $id : $aid;
    //Ä¿Ç°½ö¶ÔÎÄÕÂ×÷´¦Àí,з¢ÎÄÕÂʱ,Éè·¨»ñÈ¡ID
    if (!$webdb[module_id] && !$_id) {
        $erp = $Fid_db[iftable][$fid];
        $rs = $db->get_one("SHOW TABLE STATUS LIKE '{$pre}article{$erp}'");
        $_id = $rs[Auto_increment];
    }
    $filedb = get_content_attachment($str);
    foreach ($filedb as $key => $value) {
        $name = basename($value);
        if ($rs = $db->get_one("SELECT * FROM {$pre}upfile WHERE filename='{$name}'")) {
            if ($_id && !in_array($_id, explode(",", $rs[ids]))) {
                $db->query("UPDATE `{$pre}upfile` SET `num`=`num`+1,ids='{$rs['ids']},{$_id}' WHERE filename='{$name}'");
            }
            continue;
        }
        $detail = explode("_", $name);
        //»ñÈ¡ÎļþµÄUIDÓëÓû§µÄUIDÒ»Ñùʱ.²Åɾ³ý.²»ÒªÂÒɾ³ý
        if ($detail[0] && $detail[0] == $uid) {
            $turepath = ROOT_PATH . $webdb[updir] . "/" . $value;
            if (!is_dir(ROOT_PATH . $webdb[updir] . "/" . $newdir)) {
                makepath(ROOT_PATH . $webdb[updir] . "/" . $newdir);
            }
            //×Ô¶¯ËõС̫´óÕŵÄͼƬ
            if ($webdb[ArticlePicWidth] && $webdb[ArticlePicHeight] && (eregi(".gif\$", $turepath) || eregi(".jpg\$", $turepath))) {
                $img_array = getimagesize($turepath);
                if ($img_array[0] > $webdb[ArticlePicWidth] || $img_array[1] > $webdb[ArticlePicHeight]) {
                    gdpic($turepath, $turepath, $webdb[ArticlePicWidth], $webdb[ArticlePicHeight], 1);
                }
            }
            //ͼƬ¼Óˮӡ
            if ($type != 'small' && $webdb[is_waterimg] && (eregi(".gif\$", $turepath) || eregi(".jpg\$", $turepath))) {
                include_once ROOT_PATH . "inc/waterimage.php";
                imageWaterMark($turepath, $webdb[waterpos], ROOT_PATH . $webdb[waterimg]);
            }
            if (@rename($turepath, ROOT_PATH . $webdb[updir] . "/{$newdir}/{$name}")) {
                $str = str_replace("{$value}", "{$newdir}/{$name}", $str);
                $db->query("INSERT INTO `{$pre}upfile` ( `module_id` , `ids` , `fid` , `uid` , `posttime` , `url` , `filename` , `num` ) VALUES ('{$webdb['module_id']}','{$_id}','{$fid}','{$uid}','{$timestamp}','{$newdir}/{$name}','{$name}','1')");
            }
        }
    }
    return $str;
}
Exemplo n.º 9
0
function remote(&$content, $one = false)
{
    global $DreamCMS, $title;
    $content = stripslashes($content);
    $img = array();
    preg_match_all("/(src|SRC)=[\"|'| ]{0,}(http:\\/\\/(.*)\\.(gif|jpg|jpeg|bmp|png))/isU", $content, $img);
    $_array = array_unique($img[2]);
    foreach ($_array as $_k => $imgurl) {
        if (strstr(strtolower($imgurl), $DreamCMS->config['url'])) {
            unset($_array[$_k]);
        }
    }
    set_time_limit(0);
    $UploadDir = $DreamCMS->config['uploadfiledir'] . "/";
    $RelativePath = $DreamCMS->dir . $UploadDir;
    //相对路径
    $RootPath = DCPATH . $UploadDir;
    //绝对路径
    switch ($DreamCMS->config['savedir']) {
        case "0":
            $_CreateDir = "";
            break;
            //全部保存在一起
        //全部保存在一起
        case 'ym':
            $_CreateDir = _getdate("Ym") . "/";
            break;
            //按年月
        //按年月
        case 'ymd':
            $_CreateDir = _getdate("Ymd") . "/";
            break;
            //按年月日
        //按年月日
        case 'ext':
            $_CreateDir = $FileExt . "/";
            break;
            //按文件类型
    }
    $RelativePath = $RelativePath . $_CreateDir;
    $RootPath = $RootPath . $_CreateDir;
    $milliSecond = 'remote_' . _getdate("YmdHis") . rand(1, 99999);
    createdir($RootPath);
    foreach ($_array as $key => $value) {
        $value = trim($value);
        preg_match("/\\.([a-zA-Z0-9]{2,4})\$/", $value, $exts);
        $FileExt = strtolower($exts[1]);
        //&#316;&#701;
        CheckValidExt($FileExt);
        //判断文件类型
        //过滤文件;
        strstr($FileExt, 'ph') && ($FileExt = "phpfile");
        in_array($FileExt, array('cer', 'htr', 'cdx', 'asa', 'asp', 'jsp', 'aspx', 'cgi')) && ($FileExt .= "file");
        $sFileName = $milliSecond . $key . "." . $FileExt;
        $RootPath_FileName = $RootPath . $sFileName;
        $RelativePath_FileName = $RelativePath . $sFileName;
        $get_file = fopen_url($value);
        $get_file && writefile($RootPath_FileName, $get_file);
        if (in_array($FileExt, array('gif', 'jpg', 'png')) && $DreamCMS->config['isthumb'] && ($DreamCMS->config['thumbwidth'] || $DreamCMS->config['thumbhight'])) {
            list($width, $height, $imagetype) = GetImageSize($RootPath_FileName);
            if ($width > $DreamCMS->config['thumbwidth'] || $height > $DreamCMS->config['thumbhight']) {
                createdir($RootPath . "thumb");
            }
            $Thumbnail = MakeThumbnail($RootPath, $RootPath_FileName, $milliSecond . $key);
            if (!empty($Thumbnail['filepath'])) {
                $SmallImagePath_FileName = str_replace($RootPath, $RelativePath, $Thumbnail['filepath']);
                imageWaterMark($Thumbnail['filepath']);
            }
            imageWaterMark($RootPath_FileName);
        } else {
            $SmallImagePathFile = '';
        }
        $_FileSize = @filesize($RootPath_FileName);
        $RelativePath_FileName = str_replace($DreamCMS->dir . $UploadDir, $UploadDir, $RelativePath_FileName);
        $SmallImagePath_FileName = str_replace($DreamCMS->dir . $UploadDir, $UploadDir, $SmallImagePath_FileName);
        $DreamCMS->db->query("INSERT INTO `#DC@__file` (`filename`,`ofilename`,`path`,`thumbpath`,`intro`,`ext`,`size` ,`time`,`type`) VALUES ('{$sFileName}', '{$value}', '{$RelativePath_FileName}','{$SmallImagePath_FileName}', '{$title}', '{$FileExt}', '{$_FileSize}', '" . time() . "', 'remote') ");
        $content = str_replace($value, $DreamCMS->dir . $RelativePath_FileName, $content);
        if ($one && $key == 0) {
            break;
        }
    }
    $content = add_magic_quotes($content);
}
Exemplo n.º 10
0
function post_info_photo()
{
    global $ftype, $fid, $webdb, $photodb, $groupdb, $_pre, $web_admin;
    if ($web_admin) {
        $picnum = 80;
    } else {
        $picnum = $groupdb[post_info_pic_num];
    }
    foreach ($_FILES as $key => $value) {
        $i = (int) substr($key, 10);
        if (is_array($value)) {
            $postfile = $value['tmp_name'];
            $array[name] = $value['name'];
            $array[size] = $value['size'];
        } else {
            $postfile = ${$key};
            $array[name] = ${$key . '_name'};
            $array[size] = ${$key . '_size'};
        }
        if ($ftype[$i] == 'in' && $array[name]) {
            $jj++;
            if ($jj > $picnum) {
                unset($photodb[$i]);
                continue;
            }
            if (!eregi("(gif|jpg|png)\$", $array[name])) {
                showerr("只能上传GIF,JPG,PNG格式的文件,你不能上传此文件:{$array['name']}");
            }
            $array[path] = $webdb[updir] . "/{$_pre}/{$fid}";
            $array[updateTable] = 1;
            //统计用户上传的文件占用空间大小
            $filename = upfile($postfile, $array);
            $photodb[$i] = "{$_pre}/{$fid}/{$filename}";
            $smallimg = $photodb[$i] . '.gif';
            $Newpicpath = ROOT_PATH . "{$webdb['updir']}/{$smallimg}";
            gdpic(ROOT_PATH . "{$webdb['updir']}/{$photodb[$i]}", $Newpicpath, 300, 220);
            /*加水印*/
            if ($webdb[is_waterimg] && $webdb[if_gdimg]) {
                include_once ROOT_PATH . "inc/waterimage.php";
                $uploadfile = ROOT_PATH . "{$webdb['updir']}/{$photodb[$i]}";
                imageWaterMark($uploadfile, $webdb[waterpos], ROOT_PATH . $webdb[waterimg]);
            }
        }
    }
}
Exemplo n.º 11
0
    $targetDir = "../" . $_SESSION["upfolder"] . "/" . getSavePicPath() . "/";
    $targetFile = date('Ymd') . time() . substr($FILEa['name'], -4, 4);
    $realFile = $targetDir . $targetFile;
    if (function_exists('move_uploaded_file')) {
        move_uploaded_file($FILEa['tmp_name'], $realFile);
        if (app_watermark == 1) {
            imageWaterMark($targetDir . $targetFile, getcwd(), app_waterlocation, app_waterfont);
        }
        if (app_ftp == 1) {
            uploadftp($targetDir, $targetFile);
        }
        if ($action == "xht") {
            echo "{'err':'" . $errm . "','msg':'" . app_installdir . replaceStr($upfileDir, "../../", "") . $targetFile . "'}";
        } else {
            die("<script>parent.document.getElementById('pic').value='" . "http://" . $_SERVER["HTTP_HOST"] . '/' . "cms" . '/' . replaceStr($upfileDir, "../../", "") . $targetFile . "'</script>上传成功!");
        }
    } else {
        @copy($FILEa['tmp_name'], $realFile);
        if (app_watermark == 1) {
            imageWaterMark($targetDir . $targetFile, getcwd(), app_waterlocation, app_waterfont);
        }
        if (app_ftp == 1) {
            uploadftp($targetDir . $targetFile);
        }
        if ($action == "xht") {
            echo "{'err':'" . $errm . "','msg':'" . app_installdir . replaceStr($upfileDir, "../../", "") . $targetFile . "'}";
        } else {
            die("<script>parent.document.getElementById('pic').value='" . replaceStr($upfileDir, "../../", "") . $targetFile . "'</script> 上传成功!");
        }
    }
}
Exemplo n.º 12
0
function savepic($url, $path, $thumbpath, $fname, $flag, &$msg)
{
    $res = false;
    $pathlink = '../' . $path;
    $thumblink = '../' . $thumbpath;
    if (!is_dir($pathlink)) {
        mkdirs($pathlink);
    }
    if (!is_dir($thumblink)) {
        mkdirs($thumblink);
    }
    $st = strrpos($url, "/");
    $tmpfpath = substring($url, $st, 0);
    $tmpfname = rawurlencode(substring($url, strlen($url) - $st, $st + 1));
    $url = $tmpfpath . "/" . $tmpfname;
    $errsize = 3;
    $byte = getPage($url, "utf-8");
    $bytelen = strlen($byte);
    $size = round($bytelen / 1024, 2);
    fwrite(fopen($pathlink . $fname, "wb"), $byte);
    $img_mime = array('image/gif', 'image/jpeg', 'image/png', 'image/bmp');
    $re = getimagesize($pathlink . $fname);
    if (!in_array($re['mime'], $img_mime)) {
        $msg = "(<font color=red>该文件可能是无效图片,跳过保存</font>)<a target=_blank href=" . $url . ">查看</a>";
        $status = false;
    } else {
        if ($flag == 'vod') {
            if ($GLOBALS['MAC']['upload']['watermark'] == 1) {
                imageWaterMark($pathlink . $fname, MAC_ROOT . '/inc/common/', $GLOBALS['MAC']['upload']['waterlocation'], $GLOBALS['MAC']['upload']['waterfont']);
            }
            if ($GLOBALS['MAC']['upload']['thumb'] == 1) {
                $thumbst = img2thumb($pathlink . $fname, $thumblink . $fname, $GLOBALS['MAC']['upload']['thumbw'], $GLOBALS['MAC']['upload']['thumbh']);
            }
            if ($GLOBALS['MAC']['upload']['ftp'] == 1) {
                uploadftp($path, $fname);
                if ($thumbst) {
                    uploadftp($thumbpath, $fname);
                }
            }
        }
        $msg = "PicView:<a href='" . $pathlink . $fname . "' target='_blank'>" . $pathlink . $fname . "</a> <font color=red>" . $size . "</font>Kb";
        $status = true;
    }
    unset($img_mime, $re);
    return $status;
}
Exemplo n.º 13
0
     echo $errm;
     exit;
 }
 $fname = date('Ymd') . time() . '.' . $ext;
 while (file_exists($updir . $fname)) {
     sleep(1);
     $fname = date('Ymd') . time() . '.' . $ext;
 }
 if (function_exists('move_uploaded_file')) {
     @move_uploaded_file($FILEa['tmp_name'], $updir . $fname);
 } else {
     @copy($FILEa['tmp_name'], $updir . $fname);
 }
 $thumbjs = '';
 if ($MAC['upload']['watermark'] == 1) {
     imageWaterMark($updir . $fname, getcwd(), $MAC['upload']['waterlocation'], $MAC['upload']['waterfont']);
 }
 if ($id == 'd_pic' && $MAC['upload']['thumb'] == 1) {
     $thumbst = img2thumb($updir . $fname, "../../" . $thumbdir . $fname, $MAC['upload']['thumbw'], $MAC['upload']['thumbh']);
     if ($thumbst) {
         $thumbjs = '<script>parent.document.getElementById("d_picthumb").value="' . $thumbdir . $fname . '"</script>';
     }
 }
 if ($path == 'vod' && $action != "xht" && $MAC['upload']['ftp'] == 1) {
     uploadftp($showdir, $fname);
     if ($thumbst) {
         uploadftp($thumbdir, $fname);
     }
 }
 if ($action == "xht") {
     echo '{"status":"true","err":"' . $errm . '","msg":"' . $MAC['site']['installdir'] . $showdir . $fname . '"}';
Exemplo n.º 14
0
function savepic($picUrl, $picpath, $picfile)
{
    global $wjs;
    if ($picfile == "") {
        echo "file参数不正确";
        $status = false;
    } else {
        mkdirs(dirname($picpath));
        $imgsbyte = getPage($picUrl, "utf-8");
        $size = round(strlen($imgsbyte) / 1024, 3);
        if (strlen($imgsbyte) < 100 || strpos("," . $imgsbyte, "<html") > 0 || strpos("," . $imgsbyte, "<HTML") > 0) {
            echo "保存失败:<font color=red>非正常的图片文件,请编辑数据复制图片地址在浏览器中访问测试下是否正常</font>图片地址是: <a target=_blank href=" . $picUrl . ">" . $picUrl . "</a><br>";
            $status = false;
        } else {
            fwrite(fopen($picpath . $picfile, "wb"), $imgsbyte);
            if (app_watermark == 1) {
                imageWaterMark($picpath . $picfile, getcwd() . "\\editor", app_waterlocation, app_waterfont);
            }
            if (app_ftp == 1) {
                uploadftp($picpath, $picfile);
            }
            echo "<a target=_blank href=" . $picpath . $picfile . ">" . $picpath . $picfile . "</a>保存成功:<font color=red>" . $size . "Kb</font><br>";
            $status = true;
        }
        if (!isN($wjs)) {
            echo "<script>parent.dstate=true;</script>";
        }
    }
    return $status;
}