define('IN_ECS', true);

require(dirname(__FILE__) . '/includes/init.php');
$smarty->assign('siteDomain','http://'.$_SERVER['HTTP_HOST'].'/'); /**
* 得到远程图片
*
* @access public
* @param goods_desc $goods_desc 要处理的内容
* @return mix 如果成功返回缩略图的路径,失败则返回false
*/ $str = '<p>
<img src="http://dealer0.autoimg.cn/dl/10982/newsimg/130364690780019046.jpg"/>
<img src="http://photocdn.sohu.com/20151028/mp38321387_1446018553478_10.jpeg"/>
</p>
<p style="word-wrap: break-word; white-space: normal; word-spacing: 0px; text-transform: none; word-break: normal; color: rgb(34,34,34); outline-width: medium; padding-bottom: 17px; padding-top: 0px; font: 16px/30px tahoma, arial, 'Microsoft YaHei'; outline-style: none; padding-left: 0px; widows: 1; margin: 0px; letter-spacing: normal; outline-color: invert; padding-right: 0px; background-color: rgb(245,248,253); text-indent: 0px; -webkit-text-stroke-width: 0px">
ddddddddddddddddddddddddddddddddd
</p>'; $test = GetCurContent($str); function GetCurContent($goods_desc)
{
$body = stripslashes($goods_desc);
$img_array = array();
//$body = ereg_replace("HTTP://".$_SERVER['SERVER_NAME']."/","",$body);//将源文件进行替换
preg_match_all("/src=[\"|'|\s]{0,}(http:\/\/([^>]*)\.(gif|jpg|png))/isU",$body,$img_array);
$img_array = array_unique($img_array[1]); set_time_limit(0);
$imgurl = IMAGE_DIR."/bdimages/upload1/".date('Ymd');
$imgpath = ROOT_PATH.$imgurl; $millisecond = date("YmdHms");
if (!file_exists($imgpath))
{
if (!make_dir($imgpath))
{
return false;
}
}
else
{ foreach($img_array as $key =>$value)
{
$value = trim($value);
$get_file = @file_get_contents($value);
$rndfilename = $imgpath."/".$millisecond.$key.".".substr($value,-3,3);
$fileurl = "http://".$_SERVER['SERVER_NAME']."/".$imgurl."/".$millisecond.$key.".".substr($value,-3,3);
// $fileurl = "/".$imgurl."/".$millisecond.$key.".".substr($value,-3,3);
if($get_file)
{
$fp = @fopen($rndfilename,"w");
@fwrite($fp,$get_file);
@fclose($fp);
}
//echo $rndfilename."<br/>".$fileurl."<br/>";
$body = str_replace($value,$fileurl,$body);;
echo $body;
}
}
$body = addslashes($body);
return $body;
}

  

ecshop 远程图片本地化的更多相关文章

  1. 火车头dede采集接口,图片加水印,远程图片本地化,远程无后缀的无图片本地化

    <?php /* [LocoySpider] (C)2005-2010 Lewell Inc. 火车采集器 DedeCMS 5.7 UTF8 文章发布接口 Update content: 图片加 ...

  2. 【代码审计】EasySNS_V1.6远程图片本地化导致Getshell

    0x00 环境准备 EasySNS官网:http://www.imzaker.com 网站源码版本:EasySNS极简社区V1.60 程序源码下载:http://es.imzaker.com/inde ...

  3. php 远程图片本地化

    /** * 把新浪的远程图片下载到自己服务器上 * * @access public * @param goods_desc $goods_desc 要处理的内容 * @return mix 如果成功 ...

  4. php开发中将远程图片本地化的方法

    检查文本内容中的远程图片,下载远程图片到本地的方法示例. /** * 下载远程图片到本地 * * @param string $txt 用户输入的文字,可能包含有图片的url * @param str ...

  5. ecshop_商品描述远程图片自动本地化插件

    解压缩文件,覆盖 ecshop 的 \includes\fckeditor文件夹. 这样在后台添加商品的商品详细描述,编辑器最后一个按钮就是自动下载 远程图片到你的网站空间,这样可防止对方网站图片失效 ...

  6. 纯代码实现wordpress图片本地化【5.2.2版本可用】

    最近用wordpress做了个网站,想复制些新闻过来用,但图片是别人的,就想怎么本地化,在网找到了方法,那就保存一下方法. 复制下面的代码,然后粘贴到你当前WordPress主题的模版函数(funct ...

  7. curl获取远程图片存到本地

    $url = 'http://sssss/sss/xu0fLo9waqKSTDO7j0kSO41O5Luq3LB6ozUvY4O7OsXUWNicB49fBs8nGYzoqcwGDARQZHpVuic ...

  8. php 获取远程图片保存到本地

    php 获取远程图片保存到本地 使用两个函数 1.获取远程文件 2.把图片保存到本地 /** * 获取远程图片并把它保存到本地 * $url 是远程图片的完整URL地址,不能为空. */ functi ...

  9. wordpress自动保存远程图片插件 DX-auto-save-images

    wordpress自动保存远程图片插件DX-auto-save-images 解决了保存文章就可以自动将远程图片保存到你的服务器上了. 具体操作步骤如下: 1.安装启用wordpress自动保存远程图 ...

随机推荐

  1. java lambda表达式学习笔记

    lambda是函数式编程(FP,functional program),在java8中引入,而C#很早之前就有了.在java中lambda表达式是'->',在C#中是‘=>’. 杜甫说:射 ...

  2. The median of multi ascending array

    Given 17 arrays,every array is ascending.The task is to get the median of all these numbers. 0 1 2 3 ...

  3. 【JQuery】jQuery.inArray 确定第一个参数在数组中的位置

    函数:jQuery.inArray(value,array,[fromIndex]) 解释:         value:用于在数组中查找是否存在         array:待处理数组.       ...

  4. 64-who 简明笔记

    显示已登录用户的信息 who [options] who am i who程序显示在本地系统上登录的用户的信息.这些信息包括每个用户的用户名.终端设备.登录时间和相应的远程主机名(如果可应用) 参数 ...

  5. C++的异常处理之一:throw是个一无是处的东西

    看这篇文章学习C++异常处理的基础知识.看完后,还不过瘾,为什么大家在C++代码中都不用Exception?为什么C++11会引入一些变化? 为什么C++ exception handling需要un ...

  6. auto refresh iframe

    <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <t ...

  7. jq mobile非ajax加载,ready执行两次

    jqm只有通过ajax加载的页面才只执行一次ready(正常情况) 页面刷新(同非ajax加载的页面)都会执行两次ready,包括pageinit和pageshow事件也是如此. 两种避免的方法是: ...

  8. SharePoint Web Part Error – The Specified Solution Was Not Found

    If you develop, release and add a SharePoint 2010 sandboxed solution web part to a page, then change ...

  9. re模块(正则表达式)

    re 模块:正则表达式import re 内置模块: 1> re.match(pattern,string) pattern:就是正则表达式 string:被操作的对象 match,search ...

  10. Thinking in java学习笔记之初始化

    1.基本数据类型:类的每个基本数据类型保证有一个初值(char为0输出则是空白) 2.构造器: 3.静态初始化顺序示例及总结 4.非静态初始化顺序 4.数组