ecshop编辑商品,远程图片自动本地化插件,自动上传外链图片

本文主要是介绍ecshop编辑商品,远程图片自动本地化插件,自动上传外链图片,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

1、admin\templates\goods_info.htm

 {$FCKeditor}下载远程图片和资源 

 

2、 admin\goods.php

    if (empty($_POST['goods_sn'])){  

    }else{

    }

 在这个下面添加代码:

$remote = !empty($_POST['remote']) ? $_POST['remote'] : 0;

 //保存远程资源

if($remote == 'true')

{

$goods_desc = GetContFile($_POST['goods_desc']);

}else{

  $goods_desc = $_POST['goods_desc'];

}

 

3、admin\includes\lib_main.php文件下添加

 

//上传文件保存路径

$cfg_image_dir = ROOT_PATH .'/images';

$cfg_soft_dir  = ROOT_PATH .'/soft';

$cfg_media_dir = ROOT_PATH .'/media';

//获得文章内容里的外部资源

function GetContFile($body)

{

global $cfg_image_dir;

//引入下载类

include_once(ROOT_PATH . 'includes/httpfile/down.class.php');

//初始化变量

$body = stripslashes($body);

$host = 'http://'.$_SERVER['HTTP_HOST'];

//过滤图片文件

$pic_arr = array();

preg_match_all("/src=[\"|'|\s]{0,}(http:\/\/([^>]*)\.(gif|jpg|png|bmp))/isU", $body, $pic_arr);

$pic_arr = array_unique($pic_arr[1]);

//初始化下载类

$htd = new HttpDown();

    foreach($pic_arr as $k=>$v)

    {

        if(preg_match('#'.$host.'#i', $v)) continue;

        if(!preg_match('#^http:\/\/#i', $v)) continue;

        $htd->OpenUrl($v);

        $type = $htd->GetHead('content-type');

        if($type == 'image/gif')

            $tempfile_ext = 'gif';

        else if($type == 'image/png')

            $tempfile_ext = 'png';

        else if($type == 'image/wbmp')

            $tempfile_ext = 'bmp';

        else

            $tempfile_ext = 'jpg';

$upload_url = 'images';

$upload_dir = $cfg_image_dir;

$ymd = date('Ymd');

$upload_url .= '/'.$ymd;

$upload_dir .= '/'.$ymd;

if(!file_exists($upload_dir))

{

mkdir($upload_dir);

$fp = fopen($upload_dir.'/index.htm', 'w');

fclose($fp);

}

//上传文件名称

$filename = time()+rand(1,9999).'.'.$tempfile_ext;

//上传文件路径

$save_url = '../'.$upload_url.'/'.$filename;

//生成本地路径

$self = explode('/', $_SERVER['PHP_SELF']);

$self_size = count($self) - 2;

$self_str  = '';

for($i=0; $i<$self_size; $i++)

{

$self_str .= $self[$i].'/';

}

   $save_url = $self_str.'../'.$upload_url.'/'.$filename;

   $save_dir = $upload_dir.'/'.$filename;

        $rs = $htd->SaveToBin($save_dir);

        if($rs)

        {

            $body = str_replace(trim($v), $save_url, $body);

        }

    }

    $htd->Close();

//回传转义字符串

    return addslashes($body);

}

 

4、这里修改,admin\goods.php

 

    if ($is_insert)

    {

        if ($code == '')

        {

            $sql = "INSERT INTO " . $ecs->table('goods') . " (goods_name, goods_name_style, goods_sn, " .

                    "cat_id, brand_id, shop_price, market_price, is_promote, promote_price, " .

                    "promote_start_date, promote_end_date, goods_img, goods_thumb, original_img, keywords, goods_brief, " .

                    "seller_note, goods_weight, goods_number, warn_number, integral, give_integral, is_best, is_new, is_hot, " .

                    "is_on_sale, is_alone_sale, is_shipping, goods_desc, add_time, last_update, goods_type, rank_integral, suppliers_id)" .

                "VALUES ('$_POST[goods_name]', '$goods_name_style', '$goods_sn', '$catgory_id', " .

                    "'$brand_id', '$shop_price', '$market_price', '$is_promote','$promote_price', ".

                    "'$promote_start_date', '$promote_end_date', '$goods_img', '$goods_thumb', '$original_img', ".

                    "'$_POST[keywords]', '$_POST[goods_brief]', '$_POST[seller_note]', '$goods_weight', '$goods_number',".

                    " '$warn_number', '$_POST[integral]', '$give_integral', '$is_best', '$is_new', '$is_hot', '$is_on_sale', '$is_alone_sale', $is_shipping, ".

                    " '$goods_desc', '" . gmtime() . "', '". gmtime() ."', '$goods_type', '$rank_integral', '$suppliers_id')";

        }

        else

        {

            $sql = "INSERT INTO " . $ecs->table('goods') . " (goods_name, goods_name_style, goods_sn, " .

                    "cat_id, brand_id, shop_price, market_price, is_promote, promote_price, " .

                    "promote_start_date, promote_end_date, goods_img, goods_thumb, original_img, keywords, goods_brief, " .

                    "seller_note, goods_weight, goods_number, warn_number, integral, give_integral, is_best, is_new, is_hot, is_real, " .

                    "is_on_sale, is_alone_sale, is_shipping, goods_desc, add_time, last_update, goods_type, extension_code, rank_integral)" .

                "VALUES ('$_POST[goods_name]', '$goods_name_style', '$goods_sn', '$catgory_id', " .

                    "'$brand_id', '$shop_price', '$market_price', '$is_promote','$promote_price', ".

                    "'$promote_start_date', '$promote_end_date', '$goods_img', '$goods_thumb', '$original_img', ".

                    "'$_POST[keywords]', '$_POST[goods_brief]', '$_POST[seller_note]', '$goods_weight', '$goods_number',".

                    " '$warn_number', '$_POST[integral]', '$give_integral', '$is_best', '$is_new', '$is_hot', 0, '$is_on_sale', '$is_alone_sale', $is_shipping, ".

                    " '$goods_desc', '" . gmtime() . "', '". gmtime() ."', '$goods_type', '$code', '$rank_integral')";

        }

    }

    else

    {

        

        $sql = "SELECT goods_thumb, goods_img, original_img " .

                    " FROM " . $ecs->table('goods') .

                    " WHERE goods_id = '$_REQUEST[goods_id]'";

        $row = $db->getRow($sql);

        if ($proc_thumb && $goods_img && $row['goods_img'] && !goods_parse_url($row['goods_img']))

        {

            @unlink(ROOT_PATH . $row['goods_img']);

            @unlink(ROOT_PATH . $row['original_img']);

        }

        if ($proc_thumb && $goods_thumb && $row['goods_thumb'] && !goods_parse_url($row['goods_thumb']))

        {

            @unlink(ROOT_PATH . $row['goods_thumb']);

        }

        $sql = "UPDATE " . $ecs->table('goods') . " SET " .

                "goods_name = '$_POST[goods_name]', " .

                "goods_name_style = '$goods_name_style', " .

                "goods_sn = '$goods_sn', " .

                "cat_id = '$catgory_id', " .

                "brand_id = '$brand_id', " .

                "shop_price = '$shop_price', " .

                "market_price = '$market_price', " .

                "is_promote = '$is_promote', " .

                "promote_price = '$promote_price', " .

                "promote_start_date = '$promote_start_date', " .

                "suppliers_id = '$suppliers_id', " .

                "promote_end_date = '$promote_end_date', ";

        

        if ($goods_img)

        {

            $sql .= "goods_img = '$goods_img', original_img = '$original_img', ";

        }

        if ($goods_thumb)

        {

            $sql .= "goods_thumb = '$goods_thumb', ";

        }

        if ($code != '')

        {

            $sql .= "is_real=0, extension_code='$code', ";

        }

        $sql .= "keywords = '$_POST[keywords]', " .

                "goods_brief = '$_POST[goods_brief]', " .

                "seller_note = '$_POST[seller_note]', " .

                "goods_weight = '$goods_weight'," .

                "goods_number = '$goods_number', " .

                "warn_number = '$warn_number', " .

                "integral = '$_POST[integral]', " .

                "give_integral = '$give_integral', " .

                "rank_integral = '$rank_integral', " .

                "is_best = '$is_best', " .

                "is_new = '$is_new', " .

                "is_hot = '$is_hot', " .

                "is_on_sale = '$is_on_sale', " .

                "is_alone_sale = '$is_alone_sale', " .

                "is_shipping = '$is_shipping', " .

                "goods_desc = '$goods_desc', " .

                "last_update = '". gmtime() ."', ".

                "goods_type = '$goods_type' " .

                "WHERE goods_id = '$_REQUEST[goods_id]' LIMIT 1";

    }

商品详情:
{$FCKeditor}下载远程图片和资源
商品详情:
{$FCKeditor}下载远程图片和资源

 

down.class.php代码:https://pan.baidu.com/s/1rBMZ2COP2i6A37FXo2-DCQ

 

这篇关于ecshop编辑商品,远程图片自动本地化插件,自动上传外链图片的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1044876

相关文章

W外链微信推广短连接怎么做?

制作微信推广链接的难点分析 一、内容创作难度 制作微信推广链接时,首先需要创作有吸引力的内容。这不仅要求内容本身有趣、有价值,还要能够激起人们的分享欲望。对于许多企业和个人来说,尤其是那些缺乏创意和写作能力的人来说,这是制作微信推广链接的一大难点。 二、精准定位难度 微信用户群体庞大,不同用户的需求和兴趣各异。因此,制作推广链接时需要精准定位目标受众,以便更有效地吸引他们点击并分享链接

使用opencv优化图片(画面变清晰)

文章目录 需求影响照片清晰度的因素 实现降噪测试代码 锐化空间锐化Unsharp Masking频率域锐化对比测试 对比度增强常用算法对比测试 需求 对图像进行优化,使其看起来更清晰,同时保持尺寸不变,通常涉及到图像处理技术如锐化、降噪、对比度增强等 影响照片清晰度的因素 影响照片清晰度的因素有很多,主要可以从以下几个方面来分析 1. 拍摄设备 相机传感器:相机传

基于51单片机的自动转向修复系统的设计与实现

文章目录 前言资料获取设计介绍功能介绍设计清单具体实现截图参考文献设计获取 前言 💗博主介绍:✌全网粉丝10W+,CSDN特邀作者、博客专家、CSDN新星计划导师,一名热衷于单片机技术探索与分享的博主、专注于 精通51/STM32/MSP430/AVR等单片机设计 主要对象是咱们电子相关专业的大学生,希望您们都共创辉煌!✌💗 👇🏻 精彩专栏 推荐订阅👇🏻 单片机

Python3 BeautifulSoup爬虫 POJ自动提交

POJ 提交代码采用Base64加密方式 import http.cookiejarimport loggingimport urllib.parseimport urllib.requestimport base64from bs4 import BeautifulSoupfrom submitcode import SubmitCodeclass SubmitPoj():de

Android 10.0 mtk平板camera2横屏预览旋转90度横屏拍照图片旋转90度功能实现

1.前言 在10.0的系统rom定制化开发中,在进行一些平板等默认横屏的设备开发的过程中,需要在进入camera2的 时候,默认预览图像也是需要横屏显示的,在上一篇已经实现了横屏预览功能,然后发现横屏预览后,拍照保存的图片 依然是竖屏的,所以说同样需要将图片也保存为横屏图标了,所以就需要看下mtk的camera2的相关横屏保存图片功能, 如何实现实现横屏保存图片功能 如图所示: 2.mtk

Spring MVC 图片上传

引入需要的包 <dependency><groupId>commons-logging</groupId><artifactId>commons-logging</artifactId><version>1.1</version></dependency><dependency><groupId>commons-io</groupId><artifactId>commons-

Prompt - 将图片的表格转换成Markdown

Prompt - 将图片的表格转换成Markdown 0. 引言1. 提示词2. 原始版本 0. 引言 最近尝试将图片中的表格转换成Markdown格式,需要不断条件和优化提示词。记录一下调整好的提示词,以后在继续优化迭代。 1. 提示词 英文版本: You are an AI assistant tasked with extracting the content of

Maven(插件配置和生命周期的绑定)

1.这篇文章很好,介绍的maven插件的。 2.maven的source插件为例,可以把源代码打成包。 Goals Overview就可以查看该插件下面所有的目标。 这里我们要使用的是source:jar-no-fork。 3.查看source插件的example,然后配置到riil-collect.xml中。  <build>   <plugins>    <pl

jenkins 插件执行shell命令时,提示“Command not found”处理方法

首先提示找不到“Command not found,可能我们第一反应是查看目标机器是否已支持该命令,不过如果相信能找到这里来的朋友估计遇到的跟我一样,其实目标机器是没有问题的通过一些远程工具执行shell命令是可以执行。奇怪的就是通过jenkinsSSH插件无法执行,经一番折腾各种搜索发现是jenkins没有加载/etc/profile导致。 【解决办法】: 需要在jenkins调用shell脚

Jenkins 插件 地址证书报错问题解决思路

问题提示摘要: SunCertPathBuilderException: unable to find valid certification path to requested target...... 网上很多的解决方式是更新站点的地址,我这里修改了一个日本的地址(清华镜像也好),其实发现是解决不了上述的报错问题的,其实,最终拉去插件的时候,会提示证书的问题,几经周折找到了其中一遍博文