2018年12月

pbootcms是与aspcms一家公司开发的企业网站系统,非常完美的企业网站系统,功能齐全,方便灵活,支持sqlite/mysql数据库

模板中支持简单的php语句

 {php}echo 111+222;{/php}

数据库快速操作类 类似THINKPHP框架的方式 比较容易上手

引入命名空间
use core\basic\Model;
use core\basic\Db;

$a = Db::table('ay_content')->where('id=1')->find();
var_dump($a); 
$model = new Model();
$r = $model->table('ay_content')->where('id=1')->find();
var_dump($r);

以上两种是等价的,第一种Db通过__callstatic静态魔术方法来调用Model类的方法

pbootcms导入其它数据库的信息

public function importold()
{
    exit('已經導入新聞');
    set_time_limit(0);
    $data = json_decode('{"acode":"cn","scode":"16","subscode":"","title":"\u6807\u9898","titlecolor":"#333333","subtitle":"","filename":"","author":"admin","source":"\u672c\u7ad9","outlink":"","date":"2018-12-30 10:45:46","ico":"\/static\/upload\/image\/20181230\/1546137994102175.png","pics":"\/static\/upload\/image\/20181230\/1546138005227320.png,\/static\/upload\/image\/20181230\/1546138006814526.png","content":"<p>\u5185\u5bb9<\/p>","enclosure":"","keywords":"","description":"\u5185\u5bb9","sorting":255,"status":"1","istop":0,"isrecommend":0,"isheadline":0,"visits":0,"likes":0,"oppose":0,"create_user":"admin","update_user":"admin"}',true);
    //var_dump($data);die();

    //对应关系数组 文章 产品 单页

    $relation =  array(
        1   =>  16,
        3   =>  12,
        6   =>  38,
        8   =>  35,
        10  =>  18,
        13  =>  25,
        15  =>  31,
        18  =>  13,
        20  =>  14,
        31  =>  22,
        33  =>  27,
        34  =>  33
    );

    $i = 0;
    //php访问mdb 数据库
    //成功导入数据1611条
    $connstr = "DRIVER=Microsoft Access Driver (*.mdb);DBQ=#Database#.mdb";
    $connid = @odbc_connect($connstr,"","",SQL_CUR_USE_ODBC ) or die ("数据库连接错误!");
    $sql = "select * from jtbc_articles";
    $exec = odbc_exec($connid,$sql);
    while($row = odbc_fetch_array($exec))
    {
        //重置这些内容 以免下一个
        $data['ico'] = '';
        $data['pics'] = '';
        if(isset($relation[$row['a_class']]) && $row['a_id'] != 540) {
            //有相应的栏目对应关系的话
            $data['scode'] = $relation[$row['a_class']];
            $data['title'] = escape_string(iconv('gb2312', 'utf-8', $row['a_topic']));
            $data['content'] = iconv('gb2312', 'utf-8', $row['a_content']);
            $data['content'] = escape_string(str_replace('{$->>repath}articles/common/upload/', '/static/upload/', $data['content']));
            $data['description'] = mb_substr(strip_tags($data['content']), 0, 150, 'utf-8');
            $data['date'] = $row['a_time'];
            $data['visits'] = $row['a_count'];

            if ($row['a_content_images'] != '') {
                if (strpos($row['a_content_images'], '|') !== false) {
                    $data['pics'] = str_replace('|', ',', $row['a_content_images']);
                    $data['pics'] = str_replace('common/upload/', '/static/upload/', $data['pics']);
                    $data['ico'] = explode(',', $data['pics'])[0];
                } else {
                    $data['ico'] = $row['a_content_images'];
                }
            }

            //var_dump($data);
            //exit();
            if (! ! $id = $this->model->addContent($data)) {
                $i++;
            }

        }
    }
    echo "成功导入数据" . $i  .   '条';
}

先断点获取到输入文章时的数组,每条导入数据只需要赋值需要变更的部分,注意每次重置数据项为空

碰到的大坑
php odbc连接 查询显示不完整问题
在php.ini里找到[ODBC] 下面有odbc.defaultlrl = 4096 你改正你想要设置 的大小就ok

Kernel文件解密 仅供学习

<?php 
/**
 * @copyright (C)2016-2099 Hnaoyun Inc.
 * @license This is not a freeware, use is subject to license terms
 * @author XingMeng
 * @email hnxsh@foxmail.com
 * @date 2018-08-09 16:03:55
 *  翱云科技版权所有,除本授权文件其余代码均开源,未经许可擅自破解本文件将依法追究法律责任。
 */


namespace core\basic;
class Kernel
{
    private static $controllerPath;

    public static function run()
    {
        //self::license();
        self::loadCache();
        $path_info = self::getPathInfo();
        $path_info = self::urlBlind($path_info);
        $path_info = self::urlRoute($path_info);
        $access_path = self::getAccessPath($path_info);
        self::regAppPath($access_path);
        self::loadComm();
        self::loadController();
    }

    private static function getPathInfo()
    {
        if (isset($_SERVER['PATH_INFO']) && !mb_check_encoding($_SERVER['PATH_INFO'], 'utf-8')) {
            $_SERVER['PATH_INFO'] = mb_convert_encoding($_SERVER['PATH_INFO'], 'UTF-8', 'GBK');
        }
        if (isset($_SERVER['PATH_INFO'])) {
            $path_info = $_SERVER['PATH_INFO'];
        } elseif (isset($_SERVER["REDIRECT_URL"])) {
            $path_info = str_replace('/' . basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['REDIRECT_URL']);
            $path_info = str_replace(SITE_DIR, '', $path_info);
            $_SERVER['PATH_INFO'] = $path_info;
        } elseif (isset($_GET['s'])) {
            $path_info = $_GET['s'];
        } else {
            $path_info = '';
        }
        if ($path_info) {
            $pattern = '{^\/?([\x{4e00}-\x{9fa5}\w-\/\.' . Config::get('url_allow_char') . ']+?)?\/?$}u';
            if (preg_match($pattern, $path_info)) {
                $path_info = preg_replace($pattern, '$1', $path_info);
                $url_html_suffix = Config::get('url_suffix');
                if (substr($path_info, -strlen($url_html_suffix)) == $url_html_suffix) {
                    $path_info = substr($path_info, 0, -strlen($url_html_suffix));
                }
            } else {
                error('您访问路径含有非法字符,防注入系统提醒您请勿尝试非法操作!');
            }
        }
        return $path_info;
    }

    private static function urlBlind($pathInfo)
    {
        $path = '';
        if (!!$domains = Config::get('app_domain_blind')) {
            $server_name = str_replace(':' . $_SERVER['SERVER_PORT'], '', $_SERVER['HTTP_HOST']);
            if (isset($domains[$server_name])) {
                $path = $domains[$server_name];
            }
        }
        if (defined('URL_BLIND')) {
            if ($path) {
                if (strpos($path, URL_BLIND) === false && strpos(URL_BLIND, $path) === false) {
                    error('系统配置的域名地址绑定与入口文件地址绑定冲突,请核对!');
                } elseif (strpos($path, URL_BLIND) === false && strpos(URL_BLIND, $path) !== false) {
                    $path = URL_BLIND;
                }
            } else {
                $path = URL_BLIND;
            }
        }
        if ($path) {
            $path = trim_slash($path) . '/' . $pathInfo;
        } else {
            $path = $pathInfo;
        }
        return $path;
    }

    private static function urlRoute($pathInfo)
    {
        if (!!$route = Config::get('url_route')) {
            if (!$pathInfo && isset($route['/'])) {
                return $route['/'];
            }
            foreach ($route as $key => $value) {
                $key = str_replace('/', '\\/', trim_slash($key));
                $reg = "{(.*\/|^)" . $key . "(\/.*|$)}Ui";
                if (preg_match($reg, $pathInfo)) {
                    $value = trim_slash($value);
                    $pathInfo = preg_replace($reg, "$1$value$2", $pathInfo);
                    break;
                }
            }
        }
        return $pathInfo;
    }

    private static function getAccessPath($pathInfo)
    {
        $apps = Config::get('public_app', true);
        if ($pathInfo) {
            $path_info = trim_slash($pathInfo);
            $path_array = explode('/', $path_info);
            $path_count = count($path_array);
            if ($path_count >= 3) {
                $access_path['m'] = $path_array[0];
                $access_path['c'] = $path_array[1];
                $access_path['f'] = $path_array[2];
                for ($i = 3; $i < $path_count; $i = $i + 2) {
                    if (isset($path_array[$i + 1])) {
                        $_GET[$path_array[$i]] = $path_array[$i + 1];
                    } else {
                        $_GET[$path_array[$i]] = null;
                    }
                }
            } elseif ($path_count == 2) {
                $access_path['m'] = $path_array[0];
                $access_path['c'] = $path_array[1];
            } elseif ($path_count == 1) {
                $access_path['m'] = $path_array[0];
            }
        }
        if (!isset($access_path['m'])) {
            $access_path['m'] = $apps[0];
        }
        if (!isset($access_path['c'])) {
            $access_path['c'] = 'Index';
        }
        if (!isset($access_path['f'])) {
            $access_path['f'] = 'index';
        }
        if (!in_array(strtolower($access_path['m']), $apps)) {
            error('您访问的模块' . $access_path['m'] . '未开放,请核对后重试!');
        }
        return $access_path;
    }

    private static function regAppPath($accessPath)
    {
        define('M', strtolower($accessPath['m']));
        self::$controllerPath = self::adjustController($accessPath['c']);
        if (!!$pos = strrpos(self::$controllerPath, '/')) {
            define('C', ucfirst(substr(self::$controllerPath, $pos + 1)));
            self::$controllerPath = substr(self::$controllerPath, 0, $pos + 1) . ucfirst(substr(self::$controllerPath, $pos + 1));
        } else {
            define('C', ucfirst(self::$controllerPath));
            self::$controllerPath = ucfirst(self::$controllerPath);
        }
        define('F', $accessPath['f']);
        if (isset($_SERVER["REQUEST_URI"])) {
            define('URL', $_SERVER["REQUEST_URI"]);
        } else {
            define('URL', $_SERVER["ORIG_PATH_INFO"] . '?' . $_SERVER["QUERY_STRING"]);
        }
        define('CORE_VERSION', Config::get('core_version'));
        define('APP_CONTROLLER_PATH', APP_PATH . '/' . M . '/controller');
        define('APP_MODEL_PATH', APP_PATH . '/' . M . '/model');
        if (($tpl_dir = Config::get('tpl_dir')) && array_key_exists(M, $tpl_dir)) {
            if (strpos($tpl_dir[M], ROOT_PATH) === false) {
                define('APP_VIEW_PATH', ROOT_PATH . $tpl_dir[M]);
            } else {
                define('APP_VIEW_PATH', $tpl_dir[M]);
            }
        } else {
            define('APP_VIEW_PATH', APP_PATH . '/' . M . '/view');
        }
    }

    private static function adjustController($string)
    {
        $string = str_replace('.', '/', $string);
        $string_arr = explode('_', $string);
        if (count($string_arr) > 1) {
            $count = count($string_arr);
            for ($i = 1; $i < $count; $i++) {
                $string_arr[$i] = ucfirst($string_arr[$i]);
            }
            $string = implode($string_arr);
        }
        return $string;
    }

    private static function loadComm()
    {
        Config::get('debug') ? Check::checkAppFile() : '';
        $app_config = APP_PATH . '/' . M . '/config/config.php';
        if (file_exists($app_config)) {
            Config::assign($app_config);
        }
        define('APP_VERSION', Config::get('app_version'));
        define('RELEASE_TIME', Config::get('release_time'));
        if (M == 'api') {
            if (!!$sid = request('sid')) {
                session_id($sid);
                session_start();
            }
            header("Access-Control-Allow-Origin: *");
        } else {
            if (!ini_get('session.auto_start') && !isset($_SESSION)) {
                session_start();
            }
            Check::checkBs();
            Check::checkOs();
        }
    }

    private static function loadController()
    {
        $class_file = self::$controllerPath . 'Controller.php';
        $class_file_path = APP_CONTROLLER_PATH . '/' . $class_file;
        $class_name = '\\app\\' . M . '\\controller\\' . str_replace('/', '\\', self::$controllerPath) . 'Controller';
        $function = F;
        if (!file_exists($class_file_path)) {
            header('HTTP/1.1 404 Not Found');
            header('status: 404 Not Found');
            $file_404 = ROOT_PATH . '/404.html';
            if (file_exists($file_404)) {
                require $file_404;
                exit();
            } else {
                error('对不起,您访问的页面不存在,请核对后再试!');
            }
        }
        if (!class_exists($class_name)) {
            error('类' . $class_name . '不存在!类文件' . $class_file_path . '中无法找到!');
        }
        $app_function = APP_PATH . '/' . M . '/function/function.php';
        if (file_exists($app_function)) {
            require $app_function;
        }
        if (file_exists(APP_PATH . '/common/function.php')) {
            require APP_PATH . '/common/function.php';
        }
        if (file_exists(APP_PATH . '/common/' . ucfirst(M) . 'Controller.php')) {
            $comm_class_name = '\\app\\common\\' . ucfirst(M) . 'Controller';
            $comm_class = new $comm_class_name();
        }
        $controller = new $class_name();
        if (method_exists($class_name, $function)) {
            if (strtolower($class_name) != strtolower($function)) {
                $return = $controller->$function();
            } else {
                $return = $controller;
            }
        } else {
            if (method_exists($class_name, '_empty')) {
                $return = $controller->_empty();
            } else {
                error('方法不存在!' . M . '模块下控制器文件' . $class_file . '中不存在您调用的方法' . $function . ',可能正在开发中,请耐心等待!');
            }
        }
        if ($return !== null) {
            Response::handle($return);
        }
    }

    private static function loadCache()
    {
        if (!Config::get('tpl_html_cache') || URL_BLIND == 'api') {
            return;
        }
        $lg = isset($_COOKIE['lg']) ? cookie('lg') : '';
        Config::get();
        $config_file = RUN_PATH . '/config/' . md5('config' . $lg) . '.php';
        if (!Config::assign($config_file)) {
            return;
        }
        $lg = $lg ?: Config::get('lgs.0.acode');
        if (Config::get('open_wap') && (is_mobile() || Config::get('wap_domain') == get_http_host())) {
            $wap = 'wap';
        } else {
            $wap = '';
        }
        $cache_file = RUN_PATH . '/cache/' . md5($_SERVER["REQUEST_URI"] . $lg . $wap) . '.html';
        if (file_exists($cache_file) && time() - filemtime($cache_file) < Config::get('tpl_html_cache_time')) {
            ob_start();
            include $cache_file;
            $content = ob_get_contents();
            ob_end_clean();
            if (Config::get('gzip') && !headers_sent() && extension_loaded("zlib") && strstr($_SERVER["HTTP_ACCEPT_ENCODING"], "gzip")) {
                $content = gzencode($content, 6);
                header("Content-Encoding: gzip");
                header("Vary: Accept-Encoding");
                header("Content-Length: " . strlen($content));
            }
            echo $content;
            exit();
        }
    }

    private static function license()
    {
        if (URL_BLIND == 'admin') {
            return;
        }
        if (!!$sn = Config::get('sn', true)) {
            $host = $_SERVER['HTTP_HOST'];
            $key = strtoupper(substr(md5(substr(sha1($host), 0, 10)), 10, 10));
            $sip = isset($_SERVER['LOCAL_ADDR']) ? $_SERVER['LOCAL_ADDR'] : $_SERVER['SERVER_ADDR'];
            if ($sip != '::1' && substr($sip, 0, 6) != '127.0.' && !in_array($key, $sn)) {
                error('未匹配到本域名有效授权码,请到<a href="http://www.pbootcms.com" target="_blank">PbootCMS</a>官网获取,并填写到后台"全局配置>>配置参数"中。');
            }
        } else {
            error('配置文件中授权码为空,请到<a href="http://www.pbootcms.com" target="_blank">PbootCMS</a>官网获取,并填写到后台"全局配置>>配置参数"中。');
        }
    }
}

有子分类调用子分类 没有子分类显示同级分类

修改标签解析控制器方法 ParserController.php中的 paseSortLabel,添加case分支

case 'soncount':
                        $content = str_replace($matches[0][$i], count($this->model->getSubScodes($sort->scode)), $content);
                        break;

将apps\home\model\ParserModel.php中的getSubScodes方法改为public

 public function getSubScodes($scode)

模板标签写法

<!--没有子类-->
                        {pboot:if({sort:soncount} == 1)}
                        <div class="module-inner">
                            <div class="t3_nav1_t nav1_color1">
                                <dl>
                                    <dt>{sort:parentname}</dt>
                                    <dd>Zibo Central Hospital</dd>
                                </dl>
                            </div>
                            <div class="module-ct t3_nav1_b">
                                <ul>
                                    {pboot:nav num=100 parent={sort:pcode}}
                                    <li class="item-399 {pboot:2if('[nav:scode]'=='{sort:scode}')}current active{/pboot:2if}"><a href="[nav:link]">[nav:name]</a>
                                    </li>
                                    {/pboot:nav}

                                </ul>
                            </div>
                        </div>
                        {else}
                        <div class="module-inner">
                            <div class="t3_nav1_t nav1_color1">
                                <dl>
                                    <dt>{sort:name}</dt>
                                    <dd>Zibo Central Hospital</dd>
                                </dl>
                            </div>
                            <div class="module-ct t3_nav1_b">
                                <ul>
                                    {pboot:nav num=100 parent={sort:scode}}
                                    <li class="item-399"><a href="[nav:link]">[nav:name]</a>
                                    </li>
                                    {/pboot:nav}
                                </ul>
                            </div>
                        </div>
                        {/pboot:if}

自带分页条及样式

{page:bar}
/* 分页样式 */
.paging { margin-top: 32px; font-size: 14px; }
.paging > span { margin: auto 16px; }
.paging .page-numbar { margin: auto 0; }
.paging .page-numbar .page-num,
.paging .page-index,
.paging .page-pre,
.paging .page-next,
.paging .page-last { display: inline-block; margin: auto 4px; padding: 2px 12px; border: 1px solid #EEE; border-radius: 2px; }
.paging .page-numbar .page-num-current,
.paging .page-numbar .page-num:hover { border-color: #8667F7; color: #8667F7; }

多语言网站

系统管理>数据区域添加区域,切换数据区域,设置相应的模板目录,为不同的语言建立不同的模板文件,添加栏目版块,添加内容,前台语言切换导航添加

今晚浏览博客园看到推荐文章里的一篇名为dnSpy 强大的.Net反编译软件的文章,虽然许久不开发.net程序,不过对反编译.net也有过一定的研究,忍不住进入阅读并下载了dnSpy进行尝试,随手打开常用的基于.NET开发的仿站神器 仿站小工具,如下图
混淆后.png

代码是经过Xenocode混淆的,无法清晰的查看程序的执行流程逻辑,遂又百度有无新的反混淆工具,又发现了de4dot神器,官方的GITHUB是源码没有编译版的,找到编译版下载地址分享一下:

吾爱破解在线工具包
官方编译下载

下载后对仿站小工具进行反混淆处理:
de4dot.png

再次用dnSpy打开反混淆后的文件,可以看到代码已经清晰的多了:
反混淆后.png

dnSpy编辑dll,exe文件的功能很方便,不用其他插件或者辅助,就可以进行修改。可以根据自己的需要来对程序进行DIY改造了。

之前给客户用了一套独立的单商户微商城系统CRMEB,功能比较薄弱,不能满足客户的一些分销、积分兑换的需求,二次开发成本太高,所以决定还是换到人人商城中,做为程序员懒是一种美德,写代码导入商品信息,又有趣又能拜托人工录入商品的痛苦,之前也对微擎有过点研究做过一次修改扩展,不过好久没再弄也忘记差不多了,再次快速查看微擎的开发文档,主要是如何连接外部数据库,下载远程文件,再就是根据微擎的路由规则找到人人商城快速添加商品goods.create的程序位置,添加断点输出json,看人人商城添加商品添加的参数,只需要对某些字段进行修改处理 再入库就可以了。

还有就是要从一个合作商那的APP接口中直接采集最新的产品,合作商的APP接口我们用FIDDLER抓https包的方式获得,需要设置手机代理到开发机器中,并在手机安装相关证书文件,合作商的APP其实是用APICLOUD制作的可以很容易看到源码。有接口就用微擎框架自带的http相关方法获得json数据并解析,处理入库。

<?php
public function importold()
    {
        exit("已经导入");
        error_reporting(E_ALL);
        set_time_limit(0);
        ignore_user_abort();
        load()->func('file');


        //导入商品 为编程的方式解决问题
        $data = json_decode('{"uniacid":3,"title":"\u6563\u517b\u9ed1\u732a\u4e94\u82b1\u8089","unit":"\u4ef6","keywords":"","type":1,"thumb_first":0,"isrecommand":0,"isnew":0,"ishot":0,"issendfree":0,"isnodiscount":0,"marketprice":100,"minprice":100,"maxprice":100,"productprice":"100","costprice":"100","virtualsend":0,"virtualsendcontent":"","virtual":0,"cash":0,"cashier":0,"invoice":0,"dispatchtype":0,"dispatchprice":"","dispatchid":0,"status":0,"goodssn":"","productsn":"","weight":"","total":0,"showtotal":0,"totalcnf":0,"hasoption":0,"subtitle":"","shorttitle":"","content":"<p><img src=\"http:\/\/wx.xunza.com\/web\/index.php?c=utility&a=wxcode&do=image&attach=http%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2FMoL5lIhnW9tpHAq13hGLbEVhxZxuK4zM9amH5atS9YyWSChOvOcgl5kGSHXtN1uUc1HnKKtqDcLwGVyRyGOVyw%2F0%3Fwx_fmt%3Djpeg\" width=\"100%\"\/><\/p>","createtime":1545794595,"video":"","discounts":"{\"type\":0,\"default\":\"\",\"default_pay\":\"\"}","pcate":"3","ccate":"9","tcate":0,"cates":"9","pcates":"","ccates":"9","tcates":"","thumb":"images\/3\/2018\/12\/kCbCcZiEccDBEy8Wz4WWlqwD9Ifmjx.jpg","thumb_url":"a:0:{}","isstatustime":0,"statustimestart":1545794220,"statustimeend":1548472620}',true);
        //var_dump($data);die();

        //遍历以前数据库 重置数组相关参数 下载远程文件 保存商品
        $other_database = array(
            'host' => 'www.linsen18.com', //数据库IP或是域名
            'username' => '', // 数据库连接用户名
            'password' => '', // 数据库连接密码
            'database' => 'wx_zchszxx_com', // 数据库名
            'port' => 3306, // 数据库连接端口
            'tablepre' => 'eb_', // 表前缀,如果没有前缀留空即可
            'charset' => 'utf8', // 数据库默认编码
            'pconnect' => 0, // 是否使用长连接
        );
        $other_db = new DB($other_database);
//查询uid为1的会员信息
        $products = $other_db->getall('store_product');

        foreach ($products as $product)
        {
            if($product["id"] > 43 && $product["id"] < 46 ) {
                $data["title"] = $product['store_name'];
                $data["unit"] = $product['unit_name'];
                $data["marketprice"] = $product['price'];
                $data["minprice"] = $product['price'];
                $data["maxprice"] = $product['price'];
                $data["productprice"] = $product['price'];
                $data["costprice"] = $product['price'];
                $data["content"] = $this->replaceimg($product['description']);
                $data["createtime"] = $product['add_time'];
                $data["thumb"] = $product['image'];

                $file = file_remote_attach_fetch($product['image']);
                if (!is_error($file)) {
                    $data->thumb = $file;
                }
                //var_dump($data);
                //远程文件保存
                pdo_insert("ewei_shop_goods", $data);
                echo $data["title"] . "导入成功<br />";

            }
        }
        
    }


    public function importkl()
    {
        exit();
        error_reporting(E_ALL);
        set_time_limit(0);
        ignore_user_abort();
        load()->func('file');
        load()->func("communication");
        $data = json_decode('{"uniacid":3,"title":"\u6563\u517b\u9ed1\u732a\u4e94\u82b1\u8089","unit":"\u4ef6","keywords":"","type":1,"thumb_first":0,"isrecommand":0,"isnew":0,"ishot":0,"issendfree":0,"isnodiscount":0,"marketprice":100,"minprice":100,"maxprice":100,"productprice":"100","costprice":"100","virtualsend":0,"virtualsendcontent":"","virtual":0,"cash":0,"cashier":0,"invoice":0,"dispatchtype":0,"dispatchprice":"","dispatchid":0,"status":0,"goodssn":"","productsn":"","weight":"","total":0,"showtotal":0,"totalcnf":0,"hasoption":0,"subtitle":"","shorttitle":"","content":"<p><img src=\"http:\/\/wx.xunza.com\/web\/index.php?c=utility&a=wxcode&do=image&attach=http%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2FMoL5lIhnW9tpHAq13hGLbEVhxZxuK4zM9amH5atS9YyWSChOvOcgl5kGSHXtN1uUc1HnKKtqDcLwGVyRyGOVyw%2F0%3Fwx_fmt%3Djpeg\" width=\"100%\"\/><\/p>","createtime":1545794595,"video":"","discounts":"{\"type\":0,\"default\":\"\",\"default_pay\":\"\"}","pcate":"3","ccate":"9","tcate":0,"cates":"9","pcates":"","ccates":"9","tcates":"","thumb":"images\/3\/2018\/12\/kCbCcZiEccDBEy8Wz4WWlqwD9Ifmjx.jpg","thumb_url":"a:0:{}","isstatustime":0,"statustimestart":1545794220,"statustimeend":1548472620}',true);
        //var_dump($data);die();

        $resp = ihttp_get("https://odoapi.kangerys.com:8443/odoapi/product/list/c270a2babe5946c8b82a09a8eb25ad00?pageSize=100&pageOffset=1&phone=undefined&version=1.0");
        $json = $resp['content'];

        foreach (json_decode($json)->data->datas as $key => $pro) {
            //存入实体
            //var_dump($pro);

            if($key > 20) {
                //打开详情页
                $info = ihttp_get("https://odoapi.kangerys.com:8443/odoapi/product/get/" . $pro->productId . "?version=1.0");

                //下载缩略图
                //正则匹配内容中的图片 下载到本地并替换成新地址  下载不能同时下载多个?文章重名
                $proinfo = json_decode($info['content'])->data;
                $data["title"] = $proinfo->name;
                $file = file_remote_attach_fetch($proinfo->thumbUrl);
                if (!is_error($file)) {
                    $data["thumb"] = $file;
                }

                $data["marketprice"] = $proinfo->retailPrice / 100;
                $data["minprice"] = $proinfo->retailPrice / 100;
                $data["maxprice"] = $proinfo->retailPrice / 100;
                $data["productprice"] = $proinfo->retailPrice / 100;
                $data["costprice"] = $proinfo->retailPrice / 100;
                $data["content"] = $this->replaceimg($proinfo->details);
                $data["createtime"] = time();
                $data["total"] = $proinfo->stock;
                $data["sales"] = $proinfo->sales;

                //var_dump($data);
                //远程文件保存
                pdo_insert("ewei_shop_goods", $data);
                echo $data["title"] . "导入成功<br />";

            }


        }



    }

有几点注意就是json解码后生成对象还是数组的问题,微擎的数据库入库要求是数组,所以在json_decode($data,true)要加true

聊斋书画院lzsy.com的网站8年前是由我们进行改版的,系统是基于ASP.NET开发,当时费用问题并没有更换系统,访问速度实在是不能忍,鉴于客户这么多年一直在我们这边服务器,出于技术的好奇,准备分析一下网站访问慢的原因何在。

经过分析,该系统最大的问题就是把access数据库放在了bin目录下,数据库随时都在更新,bin目录里有文件更新,asp.net就会重新编译,所以每次访问都要经过编译的过程,肯定会慢,由于系统的源码(asp.net是编译的没有cs源码文件没法修改)太久了找不到了,不能通过修改代码的方式将数据库位置移动出去,百度搜索能否将bin及dll移动到别的目录,得到如下方法:web.config中添加以前配置,就可以将bin目录移出

<runtime> 
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
<probing privatePath="bin1"/> 
</assemblyBinding> 
</runtime> 

.net默认web.config文件修改是不重启的,所以自行重启服务器后,再次说观察,速度提升很大,再在aspx中添加页面缓存配置,速度再次提升。优化完成