From b174b074257605d9782ed1bee13f06060254c5cc Mon Sep 17 00:00:00 2001 From: molong Date: Mon, 18 Sep 2017 19:59:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=80=E5=A4=84=E6=A8=A1?= =?UTF-8?q?=E7=89=88=E4=B8=AD=E7=9A=84=E5=B0=8Fbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/common.php | 34 ++++++++++++++++++-- application/config.php | 2 +- template/default/content/article/detail.html | 4 +-- 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/application/common.php b/application/common.php index 2300b775..6a4e702a 100644 --- a/application/common.php +++ b/application/common.php @@ -998,10 +998,10 @@ function send_email($to, $subject, $message) { } //实例化模型 -function M($name, $type = 'model'){ +function M($name, $type = 'model') { if ($type == 'model') { return new \app\common\model\Content(strtolower($name)); - }elseif ($type == 'form'){ + } elseif ($type == 'form') { return new \app\common\model\DiyForm(strtolower($name)); } } @@ -1128,4 +1128,34 @@ function PyFirst($zh) { } } return $ret; +} + +/** + * 获取微信操作对象(单例模式) + * @staticvar array $wechat 静态对象缓存对象 + * @param type $type 接口名称 ( Card|Custom|Device|Extend|Media|Oauth|Pay|Receive|Script|User ) + * @return \Wehcat\WechatReceive 返回接口对接 + */ +function &load_wechat($type = '') { + vendor('Wechat.Loader'); + static $wechat = array(); + $index = md5(strtolower($type)); + if (!isset($wechat[$index])) { + $config = \think\Config::get('wechat'); + $config['cachepath'] = CACHE_PATH . 'wechat/'; + $wechat[$index] = & Wechat\Loader::get($type, $config); + } + return $wechat[$index]; +} + +if (!function_exists('getallheaders')) { + function getallheaders() { + $headers = []; + foreach ($_SERVER as $name => $value) { + if (substr($name, 0, 5) == 'HTTP_') { + $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value; + } + } + return $headers; + } } \ No newline at end of file diff --git a/application/config.php b/application/config.php index 8e67e94e..5c1b3352 100644 --- a/application/config.php +++ b/application/config.php @@ -108,7 +108,7 @@ return array( '__ADDONS__' => BASE_PATH . '/addons', '__PUBLIC__' => BASE_PATH . '/public', ), - 'wxapp' => array( + 'wechat' => array( 'appid'=>'wx4924a63b43e2fc1a', 'appsecret'=>'0821fc43d2305d4b4722a591361df438' ) diff --git a/template/default/content/article/detail.html b/template/default/content/article/detail.html index cd880694..8c624b58 100644 --- a/template/default/content/article/detail.html +++ b/template/default/content/article/detail.html @@ -22,12 +22,12 @@ {prev id="$info['id']" cate="$info['category_id']" model="article"} - {/prev} {next id="$info['id']" cate="$info['category_id']" model="article"} - {/next}