function GetCurContentAlbum($body,$rfurl,&$firstdd)
{
	global $cfg_multi_site,$cfg_basehost,$ddmaxwidth,$cfg_basedir;
	include_once(DEDEADMIN."/../include/pub_collection_functions.php");
	if(empty($ddmaxwidth)) $ddmaxwidth = 150;
	$rsimg = '';
	$cfg_uploaddir = $GLOBALS['cfg_image_dir'];
	$cfg_basedir = $GLOBALS['cfg_basedir'];
	$basehost = "http://".$_SERVER["HTTP_HOST"];
  if($cfg_multi_site == 'N'){
    $body = str_replace(strtolower($basehost),"",$body);
    $body = str_replace(strtoupper($basehost),"",$body);
  }else{
  	if($cfg_basehost!=$basehost){
  		$body = str_replace(strtolower($basehost),$cfg_basehost,$body);
  		$body = str_replace(strtoupper($basehost),$cfg_basehost,$body);
  	}
  }
	$img_array = array();
	preg_match_all("/(src|SRC)=[\"|'| ]{0,}(http:\/\/(.*)\.(gif|jpg|jpeg|png))/isU",$body,$img_array);
	$img_array = array_unique($img_array[2]);
	
	$imgUrl = $cfg_uploaddir."/".strftime("%y%m%d",time());
	$imgPath = $cfg_basedir.$imgUrl;
	if(!is_dir($imgPath."/")){
		MkdirAll($imgPath,$GLOBALS['cfg_dir_purview']);
		CloseFtp();
	}
	$milliSecond = strftime("%H%M%S",time());
	
	foreach($img_array as $key=>$value)
	{
		if(eregi($basehost,$value)) continue;
		if($cfg_basehost!=$basehost && eregi($cfg_basehost,$value)) continue;
		if(!eregi("^http://",$value)) continue;
		
		$value = trim($value);
		$itype =  substr($value,0,-3);
		if(!eregi("gif|jpg|png",$itype)) $itype = ".jpg";
		
		$rndFileName = $imgPath."/".$milliSecond.$key.$itype;
		$iurl = $imgUrl."/".$milliSecond.$key.$itype;
		//下载并保存文件
		//$rs = $htd->SaveToBin($rndFileName);
		$rs = DownImageKeep($value,$rfurl,$rndFileName,"",0,30);
		if($rs){
			$litpicname = GetImageMapDD($iurl,$ddmaxwidth);
			if(empty($firstdd) && !empty($litpicname)){
				$firstdd = $litpicname;
				if(!file_exists($cfg_basedir.$firstdd)) $firstdd = $iurl;
			}
			@WaterImg($rndFileName,'down');
			$info = '';
			$imginfos = GetImageSize($rndFileName,$info);
			$rsimg .= "{dede:img ddimg='$litpicname' text='' width='".$imginfos[0]."' height='".$imginfos[1]."'} $iurl {/dede:img}\r\n";
	  }
	}
	return $rsimg;
}
/**
 * 获得HTML里的外部资源,针对图集
 *
 * @access    public
 * @param     string  $body  文档内容
 * @param     string  $rfurl  来源地址
 * @param     string  $firstdd  开始标记
 * @return    string
 */
function GetCurContentAlbum($body, $rfurl, &$firstdd)
{
    global $dsql, $cfg_multi_site, $cfg_basehost, $cfg_ddimg_width;
    global $cfg_basedir, $pagestyle, $cuserLogin, $cfg_addon_savetype;
    require_once DEDEINC . '/dedecollection.func.php';
    if (empty($cfg_ddimg_width)) {
        $cfg_ddimg_width = 320;
    }
    $rsimg = '';
    $cfg_uploaddir = $GLOBALS['cfg_image_dir'];
    $cfg_basedir = $GLOBALS['cfg_basedir'];
    $basehost = 'http://' . $_SERVER['HTTP_HOST'];
    $img_array = array();
    preg_match_all("/(src)=[\"|'| ]{0,}(http:\\/\\/([^>]*)\\.(gif|jpg|png))/isU", $body, $img_array);
    $img_array = array_unique($img_array[2]);
    $imgUrl = $cfg_uploaddir . '/' . MyDate($cfg_addon_savetype, time());
    $imgPath = $cfg_basedir . $imgUrl;
    if (!is_dir($imgPath . '/')) {
        MkdirAll($imgPath, $GLOBALS['cfg_dir_purview']);
        CloseFtp();
    }
    $milliSecond = 'co' . dd2char(MyDate('ymdHis', time()));
    foreach ($img_array as $key => $value) {
        $value = trim($value);
        if (preg_match("#" . $basehost . "#i", $value) || !preg_match("#^http:\\/\\/#i", $value) || $cfg_basehost != $basehost && preg_match("#" . $cfg_basehost . "#i", $value)) {
            continue;
        }
        $itype = substr($value, -4, 4);
        if (!preg_match("#\\.(gif|jpg|png)#", $itype)) {
            $itype = ".jpg";
        }
        $rndFileName = $imgPath . '/' . $milliSecond . '-' . $key . $itype;
        $iurl = $imgUrl . '/' . $milliSecond . '-' . $key . $itype;
        //下载并保存文件
        $rs = DownImageKeep($value, $rfurl, $rndFileName, '', 0, 30);
        if ($rs) {
            $info = '';
            $imginfos = GetImageSize($rndFileName, $info);
            $fsize = filesize($rndFileName);
            $filename = $milliSecond . '-' . $key . $itype;
            //保存图片附件信息
            $inquery = "INSERT INTO `#@__uploads`(arcid,title,url,mediatype,width,height,playtime,filesize,uptime,mid)\n            VALUES ('0','{$filename}','{$iurl}','1','{$imginfos[0]}','{$imginfos['1']}','0','{$fsize}','" . time() . "','" . $cuserLogin->getUserID() . "'); ";
            $dsql->ExecuteNoneQuery($inquery);
            $fid = $dsql->GetLastID();
            AddMyAddon($fid, $iurl);
            if ($pagestyle > 2) {
                $litpicname = GetImageMapDD($iurl, $cfg_ddimg_width);
            } else {
                $litpicname = $iurl;
            }
            if (empty($firstdd) && !empty($litpicname)) {
                $firstdd = $litpicname;
                if (!file_exists($cfg_basedir . $firstdd)) {
                    $firstdd = $iurl;
                }
            }
            @WaterImg($rndFileName, 'down');
            $rsimg .= "{dede:img ddimg='{$litpicname}' text='' width='" . $imginfos[0] . "' height='" . $imginfos[1] . "'} {$iurl} {/dede:img}\r\n";
        }
    }
    return $rsimg;
}
示例#3
0
 }
 /*---------------------
   function _getformupload()
   通过swfupload正常上传的图片
   ---------------------*/
 if (is_array($_SESSION['bigfile_info'])) {
     foreach ($_SESSION['bigfile_info'] as $k => $v) {
         $truefile = $cfg_basedir . $v;
         if (strlen($v) < 2 || !file_exists($truefile)) {
             continue;
         }
         $info = '';
         $imginfos = GetImageSize($truefile, $info);
         $litpicname = $pagestyle > 2 ? GetImageMapDD($v, $cfg_ddimg_width) : '';
         if (!$hasone && $ddisfirst == 1 && $litpic == '') {
             $litpic = empty($litpicname) ? GetImageMapDD($v, $cfg_ddimg_width) : $litpicname;
             $hasone = TRUE;
         }
         $imginfo = !empty(${'picinfook' . $k}) ? ${'picinfook' . $k} : '';
         $imgurls .= "{dede:img ddimg='{$v}' text='{$imginfo}' width='" . $imginfos[0] . "' height='" . $imginfos[1] . "'} {$v} {/dede:img}\r\n";
     }
 }
 $imgurls = addslashes($imgurls);
 //处理body字段自动摘要、自动提取缩略图等
 $body = AnalyseHtmlBody($body, $description, $litpic, $keywords, 'htmltext');
 //分析处理附加表数据
 $inadd_f = '';
 $inadd_v = '';
 if (!empty($dede_addonfields)) {
     $addonfields = explode(';', $dede_addonfields);
     $inadd_f = '';
示例#4
0
 if (isset($_FILES['imgfile' . $i]['tmp_name']) && is_uploaded_file($_FILES['imgfile' . $i]['tmp_name'])) {
     $iinfo = str_replace("'", "`", stripslashes(${'imgmsg' . $i}));
     if (!is_uploaded_file($_FILES['imgfile' . $i]['tmp_name'])) {
         continue;
     } else {
         $sparr = array("image/pjpeg", "image/jpeg", "image/gif", "image/png", "image/xpng", "image/wbmp");
         if (!in_array($_FILES['imgfile' . $i]['type'], $sparr)) {
             continue;
         }
         $filename = MemberUploads('imgfile' . $i, '', $cfg_ml->M_ID, 'image', '', 0, 0, false);
         if ($filename != '') {
             SaveUploadInfo($title, $filename, 1);
         }
         //缩图
         if ($pagestyle > 2) {
             $litpicname = GetImageMapDD($filename, $ddmaxwidth);
             if ($litpicname != '') {
                 SaveUploadInfo($title . ' 小图', $litpicname, 1);
             }
         } else {
             $litpicname = $filename;
         }
         $imgfile = $cfg_basedir . $filename;
         if (is_file($imgfile)) {
             $iurl = $filename;
             $info = '';
             $imginfos = @getimagesize($imgfile, $info);
             $imgurls .= "{dede:img ddimg='{$litpicname}' text='{$iinfo}' width='" . $imginfos[0] . "' height='" . $imginfos[1] . "'} {$iurl} {/dede:img}\r\n";
         }
     }
     if (!$hasone && $litpic == '' && !empty($litpicname)) {
示例#5
0
         $fm->RmDirFiles($tmpzipdir);
     }
 }
 /*---------------------
   function _swfupload()
   通过swfupload上传的新图片
   ---------------------*/
 if (is_array($_SESSION['bigfile_info'])) {
     foreach ($_SESSION['bigfile_info'] as $k => $v) {
         $truefile = $cfg_basedir . $v;
         if (strlen($v) < 2 || !file_exists($truefile)) {
             continue;
         }
         $info = '';
         $imginfos = GetImageSize($truefile, $info);
         $litpicname = $pagestyle > 2 ? GetImageMapDD($v, $cfg_ddimg_width) : $v;
         $imginfo = !empty(${'picinfook' . $k}) ? ${'picinfook' . $k} : '';
         $imgurls .= "{dede:img ddimg='{$litpicname}' text='{$imginfo}' width='" . $imginfos[0] . "' height='" . $imginfos[1] . "'} {$v} {/dede:img}\r\n";
     }
 }
 $imgurls = addslashes($imgurls);
 //分析处理附加表数据
 $inadd_f = '';
 $inadd_v = '';
 if (!empty($dede_addonfields)) {
     $addonfields = explode(';', $dede_addonfields);
     $inadd_f = '';
     $inadd_v = '';
     if (is_array($addonfields)) {
         foreach ($addonfields as $v) {
             if ($v == '') {
		 $fm->GetMatchFiles($tmpzipdir,"jpg|png|gif",$imgs);
		 $i = 0;

		 foreach($imgs as $imgold)
		 {
			   $i++;
			   $savepath = $cfg_image_dir."/".strftime("%Y-%m",$ntime);
         CreateDir($savepath);
         $iurl = $savepath."/".strftime("%d",$ntime).dd2char(strftime("%H%M%S",$ntime).'-'.$adminID."-{$i}".mt_rand(1000,9999));
         $iurl = $iurl.substr($imgold,-4,4);
			   $imgfile = $cfg_basedir.$iurl;
			   copy($imgold,$imgfile);
			   unlink($imgold);
			   if(is_file($imgfile))
			   {
			      $litpicname = GetImageMapDD($iurl,$ddmaxwidth);
				    $info = '';
				    $imginfos = GetImageSize($imgfile,$info);
				    $imgurls .= "{dede:img ddimg='$litpicname' text='' width='".$imginfos[0]."' height='".$imginfos[1]."'} $iurl {/dede:img}\r\n";
			      //把图片信息保存到媒体文档管理档案中
			      $inquery = "
               INSERT INTO #@__uploads(title,url,mediatype,width,height,playtime,filesize,uptime,adminid,memberid)
                VALUES ('{$title}','{$iurl}','1','".$imginfos[0]."','".$imginfos[1]."','0','".filesize($imgfile)."','".$ntime."','$adminID','0');
             ";
            $dsql->ExecuteNoneQuery($inquery);
            if(!$hasone && $ddisfirst==1
            && $litpic=="" && !empty($litpicname))
            {
	  	         if( file_exists($cfg_basedir.$litpicname) )
	  	         {
	  		          $litpic = $litpicname;
/**
 *  获得HTML里的外部资源,针对图集
 *
 * @param     string  $body  内容
 * @param     string  $rfurl  地址
 * @param     string  $firstdd  第一个缩略图
 * @return    string 
 */
function GetCurContentAlbum($body, $rfurl, &$firstdd)
{
    global $cfg_multi_site, $cfg_basehost, $ddmaxwidth, $cfg_basedir, $pagestyle, $cfg_mb_rmdown, $title, $cfg_ml, $cfg_user_dir;
    include_once DEDEINC . "/dedecollection.func.php";
    if (empty($ddmaxwidth)) {
        $ddmaxwidth = 240;
    }
    $rsimg = '';
    $basehost = "http://" . $_SERVER["HTTP_HOST"];
    $img_array = array();
    preg_match_all("/(src|SRC)=[\"|'| ]{0,}(http:\\/\\/([^>]*)\\.(gif|jpg|png))/isU", $body, $img_array);
    $img_array = array_unique($img_array[2]);
    $imgUrl = $cfg_user_dir . "/" . $cfg_ml->M_ID;
    $imgPath = $cfg_basedir . $imgUrl;
    if (!is_dir($imgPath . "/")) {
        MkdirAll($imgPath, $GLOBALS['cfg_dir_purview']);
        CloseFtp();
    }
    $milliSecond = MyDate("ymdHis", time());
    foreach ($img_array as $key => $value) {
        if (preg_match("#" . $basehost . "#i", $value)) {
            continue;
        }
        if ($cfg_basehost != $basehost && preg_match("#" . $cfg_basehost . "#i", $value)) {
            continue;
        }
        if (!preg_match("#^http:\\/\\/#i", $value)) {
            continue;
        }
        if ($cfg_mb_rmdown == 'Y') {
            $value = trim($value);
            $itype = substr($value, -4, 4);
            if (!preg_match("#\\.(gif|jpg|png)#i", $itype)) {
                $itype = ".jpg";
            }
            $rndFileName = $imgPath . "/" . $milliSecond . $key . $itype;
            $iurl = $imgUrl . "/" . $milliSecond . $key . $itype;
            //下载并保存文件
            //$rs = $htd->SaveToBin($rndFileName);
            $rs = DownImageKeep($value, $rfurl, $rndFileName, '', 0, 30);
            if ($rs) {
                if ($pagestyle > 2) {
                    $litpicname = GetImageMapDD($iurl, $ddmaxwidth);
                    if ($litpicname != '') {
                        SaveUploadInfo($title, $litpicname, 1, $addinfos);
                    }
                } else {
                    $litpicname = '';
                }
                if (empty($firstdd)) {
                    $firstdd = $litpicname;
                    if (!file_exists($cfg_basedir . $firstdd)) {
                        $firstdd = $iurl;
                    }
                }
                @WaterImg($rndFileName, 'down');
                $info = '';
                $imginfos = GetImageSize($rndFileName, $info);
                SaveUploadInfo($title, $iurl, 1, $imginfos);
                $rsimg .= "{dede:img ddimg='{$litpicname}' text='' width='" . $imginfos[0] . "' height='" . $imginfos[1] . "'} {$iurl} {/dede:img}\r\n";
            }
        } else {
            $rsimg .= "{dede:img ddimg='{$value}' text='' width='0' height='0'} {$value} {/dede:img}\r\n";
        }
    }
    return $rsimg;
}