ecshop 远程图片本地化
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 远程图片本地化的更多相关文章
- 火车头dede采集接口,图片加水印,远程图片本地化,远程无后缀的无图片本地化
<?php /* [LocoySpider] (C)2005-2010 Lewell Inc. 火车采集器 DedeCMS 5.7 UTF8 文章发布接口 Update content: 图片加 ...
- 【代码审计】EasySNS_V1.6远程图片本地化导致Getshell
0x00 环境准备 EasySNS官网:http://www.imzaker.com 网站源码版本:EasySNS极简社区V1.60 程序源码下载:http://es.imzaker.com/inde ...
- php 远程图片本地化
/** * 把新浪的远程图片下载到自己服务器上 * * @access public * @param goods_desc $goods_desc 要处理的内容 * @return mix 如果成功 ...
- php开发中将远程图片本地化的方法
检查文本内容中的远程图片,下载远程图片到本地的方法示例. /** * 下载远程图片到本地 * * @param string $txt 用户输入的文字,可能包含有图片的url * @param str ...
- ecshop_商品描述远程图片自动本地化插件
解压缩文件,覆盖 ecshop 的 \includes\fckeditor文件夹. 这样在后台添加商品的商品详细描述,编辑器最后一个按钮就是自动下载 远程图片到你的网站空间,这样可防止对方网站图片失效 ...
- 纯代码实现wordpress图片本地化【5.2.2版本可用】
最近用wordpress做了个网站,想复制些新闻过来用,但图片是别人的,就想怎么本地化,在网找到了方法,那就保存一下方法. 复制下面的代码,然后粘贴到你当前WordPress主题的模版函数(funct ...
- curl获取远程图片存到本地
$url = 'http://sssss/sss/xu0fLo9waqKSTDO7j0kSO41O5Luq3LB6ozUvY4O7OsXUWNicB49fBs8nGYzoqcwGDARQZHpVuic ...
- php 获取远程图片保存到本地
php 获取远程图片保存到本地 使用两个函数 1.获取远程文件 2.把图片保存到本地 /** * 获取远程图片并把它保存到本地 * $url 是远程图片的完整URL地址,不能为空. */ functi ...
- wordpress自动保存远程图片插件 DX-auto-save-images
wordpress自动保存远程图片插件DX-auto-save-images 解决了保存文章就可以自动将远程图片保存到你的服务器上了. 具体操作步骤如下: 1.安装启用wordpress自动保存远程图 ...
随机推荐
- 年中review
1. 做好已知的各种项目,争取能成立固定团队 (项目一期争取能在本月上线)2. 横向扩展技术学习,了解各种技术,加强技术素养(从Server到前端,现在要关注的知识点越来越多,fighting...) ...
- 2014 todo list
1. 做好已知的各种项目,争取能成立固定团队2. 横向扩展技术学习,了解各种技术,加强技术素养3. 争取找个妹子4. 加强音律学习5. 继续发展各业余爱好6. 努力摇号 年底看收成.
- linux开机自动启动
1 .vi /etc/rc.local 2.编写开机后运行的命令 如:service httpd start
- Linux配置无线网卡驱动实现无线上网
本机装Linux,需要配置的无线驱动.一般Ubuntu都集成无线驱动,基本上无线可以直接使用! 01.查看无线网卡的型号 [root@Mr-zhao software]# lspci | gre ...
- MAC OS上Nginx安装
admin@admindeMac:local]$ brew install nginx ==> Installing dependencies for nginx: pcre, openssl ...
- 工作框架各种使用整理 -- 展示数据列表并做update
<!--ProductCategory.xml--> <?xml version="1.0" encoding="UTF-8"?> &l ...
- iOS -- 神战
http://github.ibireme.com/github/list/ios/# https://github.com/Tim9Liu9/TimLiu-iOS http://www.ios122 ...
- springMvc接受日期类型参数处理
这个问题,也即是springMvc如何进行参数类型的转换 以把client传过来一个String类型,转换为日期类型为例: 1.controller /** * 接收日期类型参数 * 注意: * sp ...
- c#学习<一> 基础知识
http://www.25hoursaday.com/CsharpVsJava.html ECMA-334 关键字 累计103 个,其中关键字77个,上下文关键字26个.(c#5.0) 标识符 1. ...
- 100114B
bfs #include<iostream> #include<queue> #include<cstring> #include<cstdio> us ...