当前位置: 首页>>代码示例>>PHP>>正文


PHP WaterImg函数代码示例

本文整理汇总了PHP中WaterImg函数的典型用法代码示例。如果您正苦于以下问题:PHP WaterImg函数的具体用法?PHP WaterImg怎么用?PHP WaterImg使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了WaterImg函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: preg_replace

    //创建远程文件夹
    $remotedir = preg_replace('/[^\\/]*\\.(jpg|gif|bmp|png)/', '', $remotefile);
    $ftp->rmkdir($remotedir);
    $ftp->upload($localfile, $remotefile);
}
@unlink($imgfile);
if (empty($resize)) {
    $resize = 0;
}
if ($resize == 1) {
    if (in_array($imgfile_type, $cfg_photo_typenames)) {
        ImageResize($fullfilename, $iwidth, $iheight);
    }
} else {
    if (in_array($imgfile_type, $cfg_photo_typenames)) {
        WaterImg($fullfilename, 'up');
    }
}
$info = '';
$sizes[0] = 0;
$sizes[1] = 0;
$sizes = getimagesize($fullfilename, $info);
$imgwidthValue = $sizes[0];
$imgheightValue = $sizes[1];
$imgsize = filesize($fullfilename);
$inquery = "INSERT INTO `#@__uploads`(arcid,title,url,mediatype,width,height,playtime,filesize,uptime,mid)\r\n  VALUES ('0','{$filename}','" . $activepath . "/" . $filename . "','1','{$imgwidthValue}','{$imgheightValue}','0','{$imgsize}','{$nowtme}','" . $cuserLogin->getUserID() . "'); ";
$dsql->ExecuteNoneQuery($inquery);
$fid = $dsql->GetLastID();
AddMyAddon($fid, $activepath . '/' . $filename);
$CKUpload = isset($CKUpload) ? $CKUpload : FALSE;
if ($GLOBALS['cfg_html_editor'] == 'ckeditor' && $CKUpload) {
开发者ID:Miliup,项目名称:miliofficeweb,代码行数:31,代码来源:select_images_post.php

示例2: MemberUploads

function MemberUploads($upname, $handname, $userid = 0, $utype = 'image', $exname = '', $maxwidth = 0, $maxheight = 0, $water = false, $isadmin = false)
{
    global $cfg_imgtype, $cfg_mb_addontype, $cfg_mediatype, $cfg_user_dir, $cfg_basedir, $cfg_dir_purview;
    //当为游客投稿的情况下,这个 id 为 0
    if (empty($userid)) {
        $userid = 0;
    }
    if (!is_dir($cfg_basedir . $cfg_user_dir . "/{$userid}")) {
        MkdirAll($cfg_basedir . $cfg_user_dir . "/{$userid}", $cfg_dir_purview);
        CloseFtp();
    }
    //有上传文件
    $allAllowType = str_replace('||', '|', $cfg_imgtype . '|' . $cfg_mediatype . '|' . $cfg_mb_addontype);
    if (!empty($GLOBALS[$upname]) && is_uploaded_file($GLOBALS[$upname])) {
        $nowtme = time();
        $GLOBALS[$upname . '_name'] = trim(ereg_replace("[ \r\n\t\\*\\%\\/\\?><\\|\":]{1,}", '', $GLOBALS[$upname . '_name']));
        //源文件类型检查
        if ($utype == 'image') {
            if (!eregi("\\.(" . $cfg_imgtype . ")\$", $GLOBALS[$upname . '_name'])) {
                ShowMsg("你所上传的图片类型不在许可列表,请上传{$cfg_imgtype}类型!", '-1');
                exit;
            }
            $sparr = array("image/pjpeg", "image/jpeg", "image/gif", "image/png", "image/xpng", "image/wbmp");
            $imgfile_type = strtolower(trim($GLOBALS[$upname . '_type']));
            if (!in_array($imgfile_type, $sparr)) {
                ShowMsg('上传的图片格式错误,请使用JPEG、GIF、PNG、WBMP格式的其中一种!', '-1');
                exit;
            }
        } else {
            if ($utype == 'flash' && !eregi("\\.swf\$", $GLOBALS[$upname . '_name'])) {
                ShowMsg('上传的文件必须为flash文件!', '-1');
                exit;
            } else {
                if ($utype == 'media' && !eregi("\\.(" . $cfg_mediatype . ")\$", $GLOBALS[$upname . '_name'])) {
                    ShowMsg('你所上传的文件类型必须为:' . $cfg_mediatype, '-1');
                    exit;
                } else {
                    if (!eregi("\\.(" . $allAllowType . ")\$", $GLOBALS[$upname . '_name'])) {
                        ShowMsg("你所上传的文件类型不被允许!", '-1');
                        exit;
                    }
                }
            }
        }
        //再次严格检测文件扩展名是否符合系统定义的类型
        $fs = explode('.', $GLOBALS[$upname . '_name']);
        $sname = $fs[count($fs) - 1];
        $alltypes = explode('|', $allAllowType);
        if (!in_array(strtolower($sname), $alltypes)) {
            ShowMsg('你所上传的文件类型不被允许!', '-1');
            exit;
        }
        //强制禁止的文件类型
        if (eregi("\\.(asp|php|pl|cgi|shtm|js)", $sname)) {
            ShowMsg('你上传的文件为系统禁止的类型!', '-1');
            exit;
        }
        if ($exname == '') {
            $filename = $cfg_user_dir . "/{$userid}/" . dd2char($nowtme . '-' . mt_rand(1000, 9999)) . '.' . $sname;
        } else {
            $filename = $cfg_user_dir . "/{$userid}/{$exname}." . $sname;
        }
        move_uploaded_file($GLOBALS[$upname], $cfg_basedir . $filename) or die("上传文件到 {$filename} 失败!");
        @unlink($GLOBALS[$upname]);
        if (@filesize($cfg_basedir . $filename) > $GLOBALS['cfg_mb_upload_size'] * 1024) {
            @unlink($cfg_basedir . $filename);
            ShowMsg('你上传的文件超出系统大小限制!', '-1');
            exit;
        }
        //加水印或缩小图片
        if ($utype == 'image') {
            include_once DEDEINC . '/image.func.php';
            if ($maxwidth > 0 || $maxheight > 0) {
                ImageResize($cfg_basedir . $filename, $maxwidth, $maxheight);
            } else {
                if ($water) {
                    WaterImg($cfg_basedir . $filename);
                }
            }
        }
        return $filename;
    } else {
        //强制禁止的文件类型
        if ($handname == '') {
            return $handname;
        } else {
            if (eregi("\\.(asp|php|pl|cgi|shtm|js)", $handname)) {
                exit('Not allow filename for not safe!');
            } else {
                if (!eregi("\\.(" . $allAllowType . ")\$", $handname)) {
                    exit('Not allow filename for filetype!');
                } else {
                    if (!eregi('^http:', $handname) && !eregi('^' . $cfg_user_dir . '/' . $userid, $handname) && !$isadmin) {
                        exit('Not allow filename for not userdir!');
                    }
                }
            }
        }
        return $handname;
    }
//.........这里部分代码省略.........
开发者ID:klr2003,项目名称:sourceread,代码行数:101,代码来源:common.func.php

示例3: filesize

		$imgwidthValue = $sizes[0];
	  $imgheightValue = $sizes[1];
	  $imgsize = filesize($fullfilename);
	}
	$info = '';
	$bsizes = getimagesize($fullfilename,$info);
  $bimgwidthValue = $bsizes[0];
	$bimgheightValue = $bsizes[1];
	$bimgsize = filesize($fullfilename);
	$inquery = "
    INSERT INTO #@__uploads(title,url,mediatype,width,height,playtime,filesize,uptime,adminid,memberid)
    VALUES ('{$dbbigfile}','$bfilename','1','$bimgwidthValue','$bimgheightValue','0','{$bimgsize}','{$nowtme}','".$cuserLogin->getUserID()."','0');
   ";
  $dsql->ExecuteNoneQuery($inquery);
  $dsql->Close();
	if(in_array($imgfile_type,$cfg_photo_typenames) &&( $imgfile_type!='image/gif' || $cfg_gif_wartermark=='Y')) WaterImg($fullfilename,'up');
	$kkkimg = $urlValue;
}
if(empty($kkkimg)) $kkkimg="picview.gif";
if(!eregi("^http:",$imgsrcValue)){
  $imgsrcValue = ereg_replace("/{1,}",'/',$imgsrcValue);
  $urlValue = ereg_replace("/{1,}",'/',$urlValue);
}
?>
<HTML>
<HEAD>
<title>插入图片</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style>
td{font-size:10pt;}
</style>
开发者ID:BGCX262,项目名称:zyyhong-svn-to-git,代码行数:31,代码来源:image.php

示例4: UploadOneImage

/**
 *  上传一个未经处理的图片
 *
 * @access    public
 * @param     string  $upname 上传框名称
 * @param     string  $handurl 手工填写的网址
 * @param     string  $ddisremote 是否下载远程图片 0 不下, 1 下载
 * @param     string  $ntitle 注解文字 如果表单有 title 字段可不管
 * @return    mixed
 */
function UploadOneImage($upname, $handurl = '', $isremote = 1, $ntitle = '')
{
    global $cuserLogin, $cfg_basedir, $cfg_image_dir, $title, $dsql;
    if ($ntitle != '') {
        $title = $ntitle;
    }
    $ntime = time();
    $filename = '';
    $isrm_up = FALSE;
    $handurl = trim($handurl);
    //如果用户自行上传了图片
    if (!empty($_FILES[$upname]['tmp_name']) && is_uploaded_file($_FILES[$upname]['tmp_name'])) {
        $istype = 0;
        $sparr = array("image/pjpeg", "image/jpeg", "image/gif", "image/png");
        $_FILES[$upname]['type'] = strtolower(trim($_FILES[$upname]['type']));
        if (!in_array($_FILES[$upname]['type'], $sparr)) {
            ShowMsg("上传的图片格式错误,请使用JPEG、GIF、PNG格式的其中一种!", "-1");
            exit;
        }
        if (!empty($handurl) && !preg_match("#^http:\\/\\/#i", $handurl) && file_exists($cfg_basedir . $handurl)) {
            if (!is_object($dsql)) {
                $dsql = new DedeSql();
            }
            $dsql->ExecuteNoneQuery("DELETE FROM `#@__uploads` WHERE url LIKE '{$handurl}' ");
            $fullUrl = preg_replace("#\\.([a-z]*)\$#i", "", $handurl);
        } else {
            $savepath = $cfg_image_dir . '/' . strftime("%Y-%m", $ntime);
            CreateDir($savepath);
            $fullUrl = $savepath . '/' . strftime("%d", $ntime) . dd2char(strftime("%H%M%S", $ntime) . '0' . $cuserLogin->getUserID() . '0' . mt_rand(1000, 9999));
        }
        if (strtolower($_FILES[$upname]['type']) == "image/gif") {
            $fullUrl = $fullUrl . ".gif";
        } else {
            if (strtolower($_FILES[$upname]['type']) == "image/png") {
                $fullUrl = $fullUrl . ".png";
            } else {
                $fullUrl = $fullUrl . ".jpg";
            }
        }
        //保存
        @move_uploaded_file($_FILES[$upname]['tmp_name'], $cfg_basedir . $fullUrl);
        $filename = $fullUrl;
        //水印
        @WaterImg($imgfile, 'up');
        $isrm_up = TRUE;
    } else {
        if ($handurl == '') {
            return '';
        }
        //远程图片并要求本地化
        if ($isremote == 1 && preg_match("#^http:\\/\\/#i", $handurl)) {
            $ddinfos = GetRemoteImage($handurl, $cuserLogin->getUserID());
            if (!is_array($ddinfos)) {
                $litpic = "";
            } else {
                $filename = $ddinfos[0];
            }
            $isrm_up = TRUE;
            //本地图片或远程不要求本地化
        } else {
            $filename = $handurl;
        }
    }
    $imgfile = $cfg_basedir . $filename;
    if (is_file($imgfile) && $isrm_up && $filename != '') {
        $info = "";
        $imginfos = GetImageSize($imgfile, $info);
        //把新上传的图片信息保存到媒体文档管理档案中
        $inquery = "\n        INSERT INTO #@__uploads(title,url,mediatype,width,height,playtime,filesize,uptime,mid)\n        VALUES ('{$title}','{$filename}','1','" . $imginfos[0] . "','" . $imginfos[1] . "','0','" . filesize($imgfile) . "','" . time() . "','" . $cuserLogin->getUserID() . "');\n    ";
        $dsql->ExecuteNoneQuery($inquery);
    }
    return $filename;
}
开发者ID:playfay,项目名称:FlowDedeCmsBackstageTemplets,代码行数:83,代码来源:inc_archives_functions.php

示例5: DownMedia

 /**
  *  下载特定资源,并保存为指定文件
  *
  * @access    public
  * @param     string  $dourl  操作地址
  * @param     string  $mtype  附件类型
  * @param     string  $islitpic  是否缩略图
  * @return    string
  */
 function DownMedia($dourl, $mtype = 'img', $islitpic = FALSE)
 {
     global $notckpic;
     if (empty($notckpic)) {
         $notckpic = 0;
     }
     //检测是否已经下载此文件
     $wi = FALSE;
     $tofile = $filename = '';
     if ($notckpic == 0) {
         $row = $this->dsql->GetOne("SELECT hash,tofile FROM `#@__co_mediaurls` WHERE nid='{$this->noteId}' AND hash='" . md5($dourl) . "' ");
         if (isset($row['tofile'])) {
             $tofile = $filename = $row['tofile'];
         }
     }
     //如果不存在,下载文件
     if ($tofile == '' || !file_exists($GLOBALS['cfg_basedir'] . $filename)) {
         $filename = $this->GetRndName($dourl, $mtype);
         if (!preg_match("#^\\/#", $filename)) {
             $filename = "/" . $filename;
         }
         //防盗链模式
         if ($this->noteInfos['isref'] == 'yes' && $this->noteInfos['refurl'] != '') {
             if ($this->noteInfos['exptime'] == '') {
                 $this->noteInfos['exptime'] = 10;
             }
             DownImageKeep($dourl, $this->noteInfos['refurl'], $GLOBALS['cfg_basedir'] . $filename, '', 0, $this->Item['exptime']);
         } else {
             $this->cHttpDown->OpenUrl($dourl);
             $this->cHttpDown->SaveToBin($GLOBALS['cfg_basedir'] . $filename);
             $this->cHttpDown->Close();
         }
         //下载文件成功,保存记录
         if (file_exists($GLOBALS['cfg_basedir'] . $filename)) {
             if ($tofile == '') {
                 $query = "INSERT INTO `#@__co_mediaurls`(nid,hash,tofile) VALUES ('" . $this->noteId . "', '" . md5($dourl) . "', '" . addslashes($filename) . "');";
             } else {
                 $query = "UPDATE `#@__co_mediaurls` SET tofile='" . addslashes($filename) . "' WHERE hash='" . md5($dourl) . "' ";
             }
             $this->dsql->ExecuteNoneQuery($query);
         }
     }
     //如果下载图片失败或图片不存在,返回网址
     if (!file_exists($GLOBALS['cfg_basedir'] . $filename)) {
         return $dourl;
     }
     //生成缩略图
     if ($mtype == 'img' && !$islitpic && $this->breImage == '') {
         $this->breImage = $filename;
         if (!preg_match("#^http:\\/\\/#", $this->breImage) && file_exists($GLOBALS['cfg_basedir'] . $filename)) {
             $filenames = explode('/', $filename);
             $filenamed = $filenames[count($filenames) - 1];
             $nfilename = str_replace('.', '_lit.', $filenamed);
             $nfilename = str_replace($filenamed, $nfilename, $filename);
             if (@copy($GLOBALS['cfg_basedir'] . $filename, $GLOBALS['cfg_basedir'] . $nfilename)) {
                 ImageResize($GLOBALS['cfg_basedir'] . $nfilename, $GLOBALS['cfg_ddimg_width'], $GLOBALS['cfg_ddimg_height']);
                 $this->breImage = $nfilename;
             }
         }
     }
     if ($mtype == 'img' && !$islitpic) {
         @WaterImg($GLOBALS['cfg_basedir'] . $filename, 'collect');
     }
     return $filename;
 }
开发者ID:soonfine,项目名称:leread,代码行数:74,代码来源:dedecollection.class.php

示例6: GetImageMapDD

             $litpicname = $pagestyle > 2 ? GetImageMapDD($iurl, $cfg_ddimg_width) : $iurl;
             //指定了提取第一张为缩略图的情况强制使用第一张缩略图
             if ($i == '1') {
                 if (!$hasone && $ddisfirst == 1 && $litpic == '' && empty($litpicname)) {
                     $litpicname = GetImageMapDD($iurl, $cfg_ddimg_width);
                 }
             }
             $info = '';
             $imginfos = GetImageSize($imgfile, $info);
             $imgurls .= "{dede:img ddimg='{$litpicname}' text='' width='" . $imginfos[0] . "' height='" . $imginfos[1] . "'} {$iurl} {/dede:img}\r\n";
             //把图片信息保存到媒体文档管理档案中
             $inquery = "\n                   INSERT INTO #@__uploads(title,url,mediatype,width,height,playtime,filesize,uptime,mid)\n                    VALUES ('{$title}','{$iurl}','1','" . $imginfos[0] . "','" . $imginfos[1] . "','0','" . filesize($imgfile) . "','" . $ntime . "','{$adminid}');\n                 ";
             $dsql->ExecuteNoneQuery($inquery);
             $fid = $dsql->GetLastID();
             AddMyAddon($fid, $iurl);
             WaterImg($imgfile, 'up');
             if (!$hasone && $ddisfirst == 1 && $litpic == '') {
                 if (empty($litpicname)) {
                     $litpicname = $iurl;
                     $litpicname = GetImageMapDD($iurl, $cfg_ddimg_width);
                 }
                 $litpic = $litpicname;
                 $hasone = TRUE;
             }
         }
     }
     if ($delzip == 1) {
         unlink($zipfile);
     }
     $fm->RmDirFiles($tmpzipdir);
 }
开发者ID:nanhuacrab,项目名称:www,代码行数:31,代码来源:album_add.php

示例7: UploadOneImage

function UploadOneImage($upname,$handurl='',$ddisremote=1,$ntitle='')
{
	
	global $cuserLogin,$cfg_basedir,$cfg_image_dir,$dsql,$title;
	if($ntitle!='') $title = $ntitle; 
	$ntime = time();
	$filename = '';
	$isrm_up = false;
	$handurl = trim($handurl);
	//如果用户自行上传了图片
	if(!empty($_FILES[$upname]['tmp_name']) && is_uploaded_file($_FILES[$upname]['tmp_name']))
  {
      $istype = 0;
      $sparr = Array("image/pjpeg","image/jpeg","image/gif","image/png");
      $_FILES[$upname]['type'] = strtolower(trim($_FILES[$upname]['type']));
      if(!in_array($_FILES[$upname]['type'],$sparr)){
		     ShowMsg("上传的图片格式错误,请使用JPEG、GIF、PNG格式的其中一种!","-1");
		     exit();
	    }
      
      
      if(!empty($handurl) && !eregi("^http://",$handurl) && file_exists($cfg_basedir.$handurl) ){
	    	 if(!is_object($dsql)) $dsql = new DedeSql();
         $dsql->ExecuteNoneQuery("Delete From #@__uploads where url like '$handurl' ");
	    	 $fullUrl = eregi_replace("\.([a-z]*)$","",$handurl);
	    }else{
	    	 $savepath = $cfg_image_dir."/".strftime("%Y-%m",$ntime);
         CreateDir($savepath);
         $fullUrl = $savepath."/".strftime("%d",$ntime).dd2char(strftime("%H%M%S",$ntime).'0'.$cuserLogin->getUserID().'0'.mt_rand(1000,9999));
	    }
      
      if(strtolower($_FILES[$upname]['type'])=="image/gif") $fullUrl = $fullUrl.".gif";
      else if(strtolower($_FILES[$upname]['type'])=="image/png") $fullUrl = $fullUrl.".png";
      else $fullUrl = $fullUrl.".jpg";
      
      //保存
      @move_uploaded_file($_FILES[$upname]['tmp_name'],$cfg_basedir.$fullUrl);
	    $filename = $fullUrl;

	    //水印
	    @WaterImg($imgfile,'up');
	    $isrm_up = true;
	    
  }
  //远程或选择本地图片
  else{
	    if($handurl=='') return '';
	    //远程图片并要求本地化
	    if($isremote==1 && eregi("^http://",$handurl)){
	  	   $ddinfos = GetRemoteImage($handurl,$cuserLogin->getUserID());
	  	   if(!is_array($ddinfos)) $litpic = "";
	  	   else $filename = $ddinfos[0];
	  	   $isrm_up = true;
	    //本地图片或远程不要求本地化
	    }else{
	    	$filename = $handurl;
	    }
  }
  $imgfile = $cfg_basedir.$filename;
  if(is_file($imgfile) && $isrm_up && $filename!=''){
		$info = "";
		$imginfos = GetImageSize($imgfile,$info);
		//把新上传的图片信息保存到媒体文档管理档案中
		$inquery = "
        INSERT INTO #@__uploads(title,url,mediatype,width,height,playtime,filesize,uptime,adminid,memberid) 
        VALUES ('$title','$filename','1','".$imginfos[0]."','".$imginfos[1]."','0','".filesize($imgfile)."','".time()."','".$cuserLogin->getUserID()."','0');
    ";
     $dsql = new DedeSql(false);
     $dsql->ExecuteNoneQuery($inquery);
	}
  return $filename;
}
开发者ID:BGCX262,项目名称:zyyhong-svn-to-git,代码行数:72,代码来源:inc_archives_functions.php

示例8: explode

		$filename = "{$adminid}_".strftime("%H%M%S",$uptime).mt_rand(100,999).$i;
		$fs = explode(".",${"upfile".$i."_name"});
		$filename = $filename.".".$fs[count($fs)-1];
		$filename = $savePath."/".$filename;
		if(!is_dir($cfg_basedir.$savePath)){
			MkdirAll($cfg_basedir.$savePath,$GLOBALS['cfg_dir_purview']);
			CloseFtp();
		}
		$fullfilename = $cfg_basedir.$filename;
    if($mediatype==1){
       @move_uploaded_file(${"upfile".$i},$fullfilename);
       $info = "";
    	 $data = getImagesize($fullfilename,$info);
    	 $width = $data[0];
    	 $height = $data[1];
		 	if(in_array($upfile_type,$cfg_photo_typenames)) WaterImg($fullfilename,'up');
    }else{
       @move_uploaded_file(${"upfile".$i},$fullfilename);
    }
    if($i>1){ $ntitle = $title."_".$i; }
    else $ntitle = $title;
    $inquery = "
       INSERT INTO #@__uploads(title,url,mediatype,width,height,playtime,filesize,uptime,adminid,memberid) 
       VALUES ('$ntitle','$filename','$mediatype','$width','$height','$playtime','$filesize','$uptime','$adminid','0');
    ";
    $okdd++;
    $dsql->SetQuery($inquery);
    $dsql->ExecuteNoneQuery();
  }
}
$dsql->Close();
开发者ID:BGCX262,项目名称:zyyhong-svn-to-git,代码行数:31,代码来源:media_add.php

示例9: GetUpImage

function GetUpImage($litpic,$isdd=false,$exitErr=false,$iw=0,$ih=0,$iname='')
{
	global $cfg_ml,$cfg_ddimg_width,$cfg_ddimg_height;
	global $cfg_basedir,$cfg_user_dir,$title,$cfg_mb_upload_size,$cfg_photo_typenames;
	if($iw==0) $iw = $cfg_ddimg_width;
	if($ih==0) $ih = $cfg_ddimg_height;
	$ntime = $nowtme = mytime();
	if(!isset($_FILES[$litpic])) return "";
	if(is_uploaded_file($_FILES[$litpic]['tmp_name']))
	{
      //超过限定大小的文件不给上传
      if($_FILES[$litpic]['size'] > $cfg_mb_upload_size*1024){
      	@unlink($_FILES[$litpic]['tmp_name']);
      	return "";
      }
      $sparr = $cfg_photo_typenames;
      $_FILES[$litpic]['type'] = strtolower(trim($_FILES[$litpic]['type']));
      if(!in_array($_FILES[$litpic]['type'],$sparr)){
		    if($exitErr){
		    	ShowMsg("上传的缩略图片格式错误,请使用JPEG、GIF、PNG格式的其中一种!","-1");
		      exit();
		    }else{ return ""; }
	    }

      $savepath = $cfg_user_dir."/".$cfg_ml->M_ID;
      CreateDir($savepath);

      if($iname=='') $itname = dd2char($cfg_ml->M_ID."0".strftime("%y%m%d%H%M%S",$nowtme)."0".mt_rand(1000,9999)).'-lit';
      else $itname = $iname;

      $fullUrl = $savepath."/".$itname;

      //强制检测文件类型
      if($iname==''){
          if(strtolower($_FILES[$litpic]['type'])=="image/gif") $fullUrl = $fullUrl.".gif";
          else if(strtolower($_FILES[$litpic]['type'])=="image/png") $fullUrl = $fullUrl.".png";
          else $fullUrl = $fullUrl.".jpg";
      }else{
      	  $fullUrl = $fullUrl.'.jpg';
      }

      @move_uploaded_file($_FILES[$litpic]['tmp_name'],$cfg_basedir.$fullUrl);
	    $litpic = $fullUrl;

	    if($isdd) @ImageResize($cfg_basedir.$fullUrl,$iw,$ih);
	    else @WaterImg($cfg_basedir.$fullUrl,'up');

	    //保存用户上传的记录到数据库
	    if($title==''){
	    	if($isdd) $title = '用户上传的图片';
	    	else $title = '用户上传的略略图';
	    }
	    $info = "";
	    $datas[0] = 0;
	    $datas[1] = 0;
	    $datas = GetImageSize($cfg_basedir.$fullUrl,$info);
	    $addinfos[0] = $datas[0];
	    $addinfos[1] = $datas[1];
	    $addinfos[2] = filesize($cfg_basedir.$fullUrl);
	    SaveUploadInfo($title,$fullUrl,1,$addinfos);

	    return $litpic;
  }else{
  	 return "";
  }
}
开发者ID:BGCX262,项目名称:zyyhong-svn-to-git,代码行数:66,代码来源:inc_archives_functions.php

示例10: DownMedia

	function DownMedia($dourl,$mtype='img'){
		//检测是否已经下载此文件
		$isError = false;
		$errfile = $GLOBALS['cfg_phpurl'].'/img/etag.gif';
		$row = $this->dsql->GetOne("Select nurl from #@__co_mediaurl where rurl like '$dourl'");
		$wi = false;
		if(!empty($row['nurl'])){
			$filename = $row['nurl'];
			return $filename;
		}else{
		   //如果不存在,下载该文件
		   $filename = $this->GetRndName($dourl,$mtype);
		   if(!ereg("^/",$filename)) $filename = "/".$filename;
		   
		   //反盗链模式
		   if($this->Item["isref"]=='yes' && $this->Item["refurl"]!=''){
		      if($this->Item["exptime"]=='') $this->Item["exptime"] = 10;
		      $rs = DownImageKeep($dourl,$this->Item["refurl"],$GLOBALS['cfg_basedir'].$filename,"",0,$this->Item["exptime"]);
		      if($rs){
		         $inquery = "INSERT INTO #@__co_mediaurl(nid,rurl,nurl) VALUES ('".$this->NoteId."', '".addslashes($dourl)."', '".addslashes($filename)."');";
		         $this->dsql->ExecuteNoneQuery($inquery);
		      }else{
		      	$inquery = "INSERT INTO #@__co_mediaurl(nid,rurl,nurl) VALUES ('".$this->NoteId."', '".addslashes($dourl)."', '".addslashes($errfile)."');";
		        $this->dsql->ExecuteNoneQuery($inquery);
		      	$isError = true;
		      }
		      if($mtype=='img'){ $wi = true; }
	     //常规模式
	     }else{
		      $this->CHttpDown->OpenUrl($dourl);
		      $this->CHttpDown->SaveToBin($GLOBALS['cfg_basedir'].$filename);
		      $inquery = "INSERT INTO #@__co_mediaurl(nid,rurl,nurl) VALUES ('".$this->NoteId."', '".addslashes($dourl)."', '".addslashes($filename)."');";
		      $this->dsql->ExecuteNoneQuery($inquery);
		      if($mtype=='img'){ $wi = true; }
	        $this->CHttpDown->Close();
	     }
	  }
	  //生成缩略图
	  if($mtype=='img' && $this->breImage=='' && !$isError){
	  	$this->breImage = $filename;
	  	if(!eregi("^http://",$this->breImage) && file_exists($GLOBALS['cfg_basedir'].$filename)){
	  		$filenames = explode('/',$filename);
	  		$filenamed = $filenames[count($filenames)-1];
	  		$nfilename = "lit_".$filenamed;
	  		$nfilename = str_replace($filenamed,$nfilename,$filename);
	  		if(file_exists($GLOBALS['cfg_basedir'].$nfilename)){
	  			$this->breImage = $nfilename;
	  	  }else if(copy($GLOBALS['cfg_basedir'].$filename,$GLOBALS['cfg_basedir'].$nfilename)){
	  			ImageResize($GLOBALS['cfg_basedir'].$nfilename,$GLOBALS['cfg_ddimg_width'],$GLOBALS['cfg_ddimg_height']);
	  			$this->breImage = $nfilename;
	  		}
	    }
	  }
	  if($wi && !$isError) @WaterImg($GLOBALS['cfg_basedir'].$filename,'up');
		if(!$isError) return $filename;
		else return $errfile;
	}
开发者ID:BGCX262,项目名称:zyyhong-svn-to-git,代码行数:57,代码来源:pub_collection.php


注:本文中的WaterImg函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。