[更新]更新Node模型名称

This commit is contained in:
邹景立 2017-04-11 11:43:14 +08:00
parent 2b2b852361
commit d84a16e8b6
25 changed files with 188 additions and 160 deletions

View File

@ -14,7 +14,7 @@
namespace app\admin\controller;
use app\admin\model\Node as NodeModal;
use app\admin\model\NodeModel;
use controller\BasicAdmin;
use service\DataService;
use service\ToolsService;
@ -51,7 +51,7 @@ class Auth extends BasicAdmin {
$auth_id = $this->request->get('id', '0');
switch (strtolower($this->request->get('action', '0'))) {
case 'getnode':
$nodes = NodeModal::get();
$nodes = NodeModel::get();
$checked = Db::name('SystemAuthNode')->where('auth', $auth_id)->column('node');
foreach ($nodes as $key => &$node) {
$node['checked'] = in_array($node['node'], $checked);

View File

@ -14,7 +14,7 @@
namespace app\admin\controller;
use app\admin\model\Node;
use app\admin\model\NodeModel;
use controller\BasicAdmin;
use service\DataService;
use service\ToolsService;
@ -35,7 +35,7 @@ class Index extends BasicAdmin {
* @return View
*/
public function index() {
Node::applyAuthNode();
NodeModel::applyAuthNode();
$list = Db::name('SystemMenu')->where('status', '1')->order('sort asc,id asc')->select();
$menus = $this->_filterMenu(ToolsService::arr2tree($list));
$this->assign('title', '后台管理');

View File

@ -14,7 +14,7 @@
namespace app\admin\controller;
use app\admin\model\Node as NodeModal;
use app\admin\model\NodeModel as NodeModal;
use controller\BasicAdmin;
use service\LogService;
use think\Db;

View File

@ -14,7 +14,7 @@
namespace app\admin\controller;
use app\admin\model\Node;
use app\admin\model\NodeModel;
use controller\BasicAdmin;
use service\DataService;
use service\ToolsService;
@ -96,7 +96,7 @@ class Menu extends BasicAdmin {
}
}
// 读取系统功能节点
$nodes = Node::get(APP_PATH);
$nodes = NodeModel::get(APP_PATH);
foreach ($nodes as $key => $_vo) {
if (empty($_vo['is_menu'])) {
unset($nodes[$key]);

View File

@ -14,7 +14,7 @@
namespace app\admin\controller;
use app\admin\model\Node as NodeModel;
use app\admin\model\NodeModel as NodeModel;
use controller\BasicAdmin;
use service\DataService;
use service\ToolsService;

View File

@ -47,7 +47,7 @@ class Plugs extends BasicAdmin {
$types = $this->request->get('type', 'jpg,png');
$this->assign('mode', $mode);
$this->assign('types', $types);
$this->assign('uptype', sysconf('storage_type'));
$this->assign('uptype', $this->request->get('uptype', sysconf('storage_type')));
$this->assign('mimes', FileService::getFileMine($types));
$this->assign('field', $this->request->get('field', 'file'));
return view();
@ -61,8 +61,11 @@ class Plugs extends BasicAdmin {
if ($this->request->isPost()) {
$md5s = str_split($this->request->post('md5'), 16);
if (($info = $this->request->file('file')->move('upload' . DS . $md5s[0], $md5s[1], true))) {
$site_url = FileService::getFileUrl(join('/', $md5s) . '.' . $info->getExtension());
return json(['data' => ['site_url' => $site_url], 'code' => 'SUCCESS']);
$filename = join('/', $md5s) . '.' . $info->getExtension();
$site_url = FileService::getFileUrl($filename, 'local');
if ($site_url) {
return json(['data' => ['site_url' => $site_url], 'code' => 'SUCCESS']);
}
}
}
return json(['code' => 'ERROR']);
@ -70,7 +73,6 @@ class Plugs extends BasicAdmin {
/**
* 文件状态检查
* @return string
*/
public function upstate() {
$post = $this->request->post();
@ -81,7 +83,7 @@ class Plugs extends BasicAdmin {
}
// 需要上传文件,生成上传配置参数
$config = ['uptype' => $post['uptype'], 'file_url' => $filename, 'server' => url('admin/plugs/upload')];
switch (strtolower(sysconf('storage_type'))) {
switch (strtolower($post['uptype'])) {
case 'qiniu':
$config['server'] = sysconf('storage_qiniu_is_https') ? 'https://up.qbox.me' : 'http://upload.qiniu.com';
$config['token'] = $this->_getQiniuToken($filename);

View File

@ -24,7 +24,7 @@ use think\Db;
* @author Anyon <zoujingli@qq.com>
* @date 2017/03/14 18:12
*/
class Node {
class NodeModel {
/**
* 应用用户权限节点

View File

@ -13,7 +13,7 @@
// +----------------------------------------------------------------------
use app\admin\model\Node as NodeModal;
use app\admin\model\NodeModel as NodeModal;
use think\Config;
use think\Db;
use Wechat\Loader;

View File

@ -46,7 +46,7 @@ class Api extends Controller {
$this->wechat = &load_wechat('Receive');
/* 验证接口请求 */
if ($this->wechat->valid() === false) {
$msg = "微信消息验证失败,{$this->wechat->errMsg}[{$this->wechat->errCode}]";
$msg = "{$this->wechat->errMsg}[{$this->wechat->errCode}]";
Log::error($msg);
exit($msg);
}

View File

@ -58,6 +58,16 @@ class Config extends BasicAdmin {
return view();
}
$data = $this->request->post();
if (!empty($data['cert_zip_md5'])) {
$filename = ROOT_PATH . 'public/upload/' . join('/', str_split($data['cert_zip_md5'], 16)) . '.zip';
if (file_exists($filename)) {
$zip = new \PclZip($filename);
$dirpath = APP_PATH . 'extra/wechat/cert';
!file_exists($dirpath) && mkdir($dirpath, 0755, true);
$result = $zip->extract(PCLZIP_OPT_PATH, $dirpath);
dump($result);
}
}
foreach ($data as $key => $vo) {
DataService::save($this->table, ['name' => $key, 'value' => $vo], 'name');
}

View File

@ -8,9 +8,10 @@
<div class="form-group">
<label class="col-sm-2 col-xs-3 control-label">URL(服务器地址)</label>
<div class="col-sm-8">
<input readonly onmouseenter="this.select()" value="{:url('@wechat/api','',true,true)}" class="layui-input">
<input data-tips-text="请点鼠标右键复制URL地址" onmouseenter="this.select()" class="layui-input"
value="{:url('@wechat/api','',true,true)}" readonly/>
<p class="help-block">
注意:接口链接的域名必需要备案,目前微信官方只支持80端口和443端口。
注意:服务器域名必需备案,微信官方只支持80端口和443端口。
</p>
</div>
</div>
@ -30,7 +31,7 @@
<div class="form-group">
<label class="col-sm-2 col-xs-3 control-label">AppSecret(应用密钥)</label>
<div class='col-sm-8'>
<input type="text" name="wechat_appsecret" required="required" title="请输入公众号AppSecret"
<input type="password" name="wechat_appsecret" required="required" title="请输入公众号AppSecret"
placeholder="公众号AppSecret必填" value="{:sysconf('wechat_appsecret')}"
class="layui-input">
</div>

View File

@ -36,10 +36,9 @@
<div class="form-group">
<label class="col-sm-2 control-label">支付证书</label>
<div class="col-sm-7">
<input onchange="$(this).next().html('已选择支付证书 (cert.zip)'), $('[data-pay-test]').remove()"
type="hidden" name="cert_zip" value=""/>
<div class="well" style="text-align:center;cursor:pointer" data-file
data-type="zip" data-field="cert_zip" data-uptype="local" data-one="true">
<input type="hidden" name="cert_zip_md5" value="" onchange="this.value=$(this).attr('data-md5')"/>
<div data-file="one" data-type="zip" data-field="cert_zip_md5" data-uptype="local"
class="well" style="text-align:center;cursor:pointer">
<span class="fa fa-check-circle-o" style="color:#00B83F;font-size:16px"></span>
已设置支付证书 (cert.zip)
</div>

38
composer.lock generated
View File

@ -9,16 +9,16 @@
"packages": [
{
"name": "endroid/qrcode",
"version": "1.9.1",
"version": "1.9.3",
"source": {
"type": "git",
"url": "https://github.com/endroid/QrCode.git",
"reference": "ab09b42778ad67cfe850f9c23165f8d08b756680"
"reference": "c9644bec2a9cc9318e98d1437de3c628dcd1ef93"
},
"dist": {
"type": "zip",
"url": "https://files.phpcomposer.com/files/endroid/QrCode/ab09b42778ad67cfe850f9c23165f8d08b756680.zip",
"reference": "ab09b42778ad67cfe850f9c23165f8d08b756680",
"url": "https://files.phpcomposer.com/files/endroid/QrCode/c9644bec2a9cc9318e98d1437de3c628dcd1ef93.zip",
"reference": "c9644bec2a9cc9318e98d1437de3c628dcd1ef93",
"shasum": ""
},
"require": {
@ -65,7 +65,7 @@
"qrcode",
"symfony"
],
"time": "2017-01-03 11:02:14"
"time": "2017-04-08 09:13:59"
},
{
"name": "pclzip/pclzip",
@ -157,16 +157,16 @@
},
{
"name": "symfony/options-resolver",
"version": "v3.2.6",
"version": "v3.2.7",
"source": {
"type": "git",
"url": "https://github.com/symfony/options-resolver.git",
"reference": "56e3d0a41313f8a54326851f10690d591e62a24c"
"reference": "6a19be85237fe8bbd4975f86942b4763bb0da6ca"
},
"dist": {
"type": "zip",
"url": "https://files.phpcomposer.com/files/symfony/options-resolver/56e3d0a41313f8a54326851f10690d591e62a24c.zip",
"reference": "56e3d0a41313f8a54326851f10690d591e62a24c",
"url": "https://files.phpcomposer.com/files/symfony/options-resolver/6a19be85237fe8bbd4975f86942b4763bb0da6ca.zip",
"reference": "6a19be85237fe8bbd4975f86942b4763bb0da6ca",
"shasum": ""
},
"require": {
@ -207,7 +207,7 @@
"configuration",
"options"
],
"time": "2017-02-21 09:12:04"
"time": "2017-03-21 21:44:32"
},
{
"name": "topthink/framework",
@ -298,16 +298,16 @@
},
{
"name": "topthink/think-helper",
"version": "v1.0.5",
"version": "v1.0.6",
"source": {
"type": "git",
"url": "https://github.com/top-think/think-helper.git",
"reference": "ed64408cdc4cdbd390365ba0906d208b987af520"
"reference": "0c99dc625b0d2d4124e1b6ca15a3ad6f0125963f"
},
"dist": {
"type": "zip",
"url": "https://files.phpcomposer.com/files/top-think/think-helper/ed64408cdc4cdbd390365ba0906d208b987af520.zip",
"reference": "ed64408cdc4cdbd390365ba0906d208b987af520",
"url": "https://files.phpcomposer.com/files/top-think/think-helper/0c99dc625b0d2d4124e1b6ca15a3ad6f0125963f.zip",
"reference": "0c99dc625b0d2d4124e1b6ca15a3ad6f0125963f",
"shasum": ""
},
"type": "library",
@ -330,7 +330,7 @@
}
],
"description": "The ThinkPHP5 Helper Package",
"time": "2016-12-01 07:08:40"
"time": "2017-04-05 07:15:37"
},
{
"name": "topthink/think-installer",
@ -492,12 +492,12 @@
"source": {
"type": "git",
"url": "https://github.com/zoujingli/wechat-php-sdk.git",
"reference": "a7590727eac59b918274399eea3c16eb01242087"
"reference": "e04062d1c1cfb25e56bccb237e59382cfcc8facc"
},
"dist": {
"type": "zip",
"url": "https://files.phpcomposer.com/files/zoujingli/wechat-php-sdk/a7590727eac59b918274399eea3c16eb01242087.zip",
"reference": "a7590727eac59b918274399eea3c16eb01242087",
"url": "https://files.phpcomposer.com/files/zoujingli/wechat-php-sdk/e04062d1c1cfb25e56bccb237e59382cfcc8facc.zip",
"reference": "e04062d1c1cfb25e56bccb237e59382cfcc8facc",
"shasum": ""
},
"require": {
@ -518,7 +518,7 @@
"keywords": [
"wechat-php-sdk"
],
"time": "2017-03-27 06:30:12"
"time": "2017-04-07 03:34:14"
}
],
"packages-dev": [],

2
vendor/autoload.php vendored
View File

@ -4,4 +4,4 @@
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit8520da1d36357c0d503d181bd00e9d82::getLoader();
return ComposerAutoloaderInit42475d352d15c1c328bfca6e545ab2b5::getLoader();

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit8520da1d36357c0d503d181bd00e9d82
class ComposerAutoloaderInit42475d352d15c1c328bfca6e545ab2b5
{
private static $loader;
@ -19,15 +19,15 @@ class ComposerAutoloaderInit8520da1d36357c0d503d181bd00e9d82
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit8520da1d36357c0d503d181bd00e9d82', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit42475d352d15c1c328bfca6e545ab2b5', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInit8520da1d36357c0d503d181bd00e9d82', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit42475d352d15c1c328bfca6e545ab2b5', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION');
if ($useStaticLoader) {
require_once __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit8520da1d36357c0d503d181bd00e9d82::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit42475d352d15c1c328bfca6e545ab2b5::getInitializer($loader));
} else {
$map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
@ -48,19 +48,19 @@ class ComposerAutoloaderInit8520da1d36357c0d503d181bd00e9d82
$loader->register(true);
if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInit8520da1d36357c0d503d181bd00e9d82::$files;
$includeFiles = Composer\Autoload\ComposerStaticInit42475d352d15c1c328bfca6e545ab2b5::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire8520da1d36357c0d503d181bd00e9d82($fileIdentifier, $file);
composerRequire42475d352d15c1c328bfca6e545ab2b5($fileIdentifier, $file);
}
return $loader;
}
}
function composerRequire8520da1d36357c0d503d181bd00e9d82($fileIdentifier, $file)
function composerRequire42475d352d15c1c328bfca6e545ab2b5($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInit8520da1d36357c0d503d181bd00e9d82
class ComposerStaticInit42475d352d15c1c328bfca6e545ab2b5
{
public static $files = array (
'9b552a3cc426e3287cc811caefa3cf53' => __DIR__ . '/..' . '/topthink/think-helper/src/helper.php',
@ -314,9 +314,9 @@ class ComposerStaticInit8520da1d36357c0d503d181bd00e9d82
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit8520da1d36357c0d503d181bd00e9d82::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit8520da1d36357c0d503d181bd00e9d82::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit8520da1d36357c0d503d181bd00e9d82::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit42475d352d15c1c328bfca6e545ab2b5::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit42475d352d15c1c328bfca6e545ab2b5::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit42475d352d15c1c328bfca6e545ab2b5::$classMap;
}, null, ClassLoader::class);
}

View File

@ -88,18 +88,18 @@
"source": {
"type": "git",
"url": "https://github.com/zoujingli/wechat-php-sdk.git",
"reference": "a7590727eac59b918274399eea3c16eb01242087"
"reference": "e04062d1c1cfb25e56bccb237e59382cfcc8facc"
},
"dist": {
"type": "zip",
"url": "https://files.phpcomposer.com/files/zoujingli/wechat-php-sdk/a7590727eac59b918274399eea3c16eb01242087.zip",
"reference": "a7590727eac59b918274399eea3c16eb01242087",
"url": "https://files.phpcomposer.com/files/zoujingli/wechat-php-sdk/e04062d1c1cfb25e56bccb237e59382cfcc8facc.zip",
"reference": "e04062d1c1cfb25e56bccb237e59382cfcc8facc",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"time": "2017-03-27 06:30:12",
"time": "2017-04-07 03:34:14",
"type": "project",
"installation-source": "dist",
"autoload": {
@ -335,20 +335,20 @@
},
{
"name": "topthink/think-helper",
"version": "v1.0.5",
"version_normalized": "1.0.5.0",
"version": "v1.0.6",
"version_normalized": "1.0.6.0",
"source": {
"type": "git",
"url": "https://github.com/top-think/think-helper.git",
"reference": "ed64408cdc4cdbd390365ba0906d208b987af520"
"reference": "0c99dc625b0d2d4124e1b6ca15a3ad6f0125963f"
},
"dist": {
"type": "zip",
"url": "https://files.phpcomposer.com/files/top-think/think-helper/ed64408cdc4cdbd390365ba0906d208b987af520.zip",
"reference": "ed64408cdc4cdbd390365ba0906d208b987af520",
"url": "https://files.phpcomposer.com/files/top-think/think-helper/0c99dc625b0d2d4124e1b6ca15a3ad6f0125963f.zip",
"reference": "0c99dc625b0d2d4124e1b6ca15a3ad6f0125963f",
"shasum": ""
},
"time": "2016-12-01 07:08:40",
"time": "2017-04-05 07:15:37",
"type": "library",
"installation-source": "dist",
"autoload": {
@ -420,23 +420,23 @@
},
{
"name": "symfony/options-resolver",
"version": "v3.2.6",
"version_normalized": "3.2.6.0",
"version": "v3.2.7",
"version_normalized": "3.2.7.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/options-resolver.git",
"reference": "56e3d0a41313f8a54326851f10690d591e62a24c"
"reference": "6a19be85237fe8bbd4975f86942b4763bb0da6ca"
},
"dist": {
"type": "zip",
"url": "https://files.phpcomposer.com/files/symfony/options-resolver/56e3d0a41313f8a54326851f10690d591e62a24c.zip",
"reference": "56e3d0a41313f8a54326851f10690d591e62a24c",
"url": "https://files.phpcomposer.com/files/symfony/options-resolver/6a19be85237fe8bbd4975f86942b4763bb0da6ca.zip",
"reference": "6a19be85237fe8bbd4975f86942b4763bb0da6ca",
"shasum": ""
},
"require": {
"php": ">=5.5.9"
},
"time": "2017-02-21 09:12:04",
"time": "2017-03-21 21:44:32",
"type": "library",
"extra": {
"branch-alias": {
@ -476,17 +476,17 @@
},
{
"name": "endroid/qrcode",
"version": "1.9.1",
"version_normalized": "1.9.1.0",
"version": "1.9.3",
"version_normalized": "1.9.3.0",
"source": {
"type": "git",
"url": "https://github.com/endroid/QrCode.git",
"reference": "ab09b42778ad67cfe850f9c23165f8d08b756680"
"reference": "c9644bec2a9cc9318e98d1437de3c628dcd1ef93"
},
"dist": {
"type": "zip",
"url": "https://files.phpcomposer.com/files/endroid/QrCode/ab09b42778ad67cfe850f9c23165f8d08b756680.zip",
"reference": "ab09b42778ad67cfe850f9c23165f8d08b756680",
"url": "https://files.phpcomposer.com/files/endroid/QrCode/c9644bec2a9cc9318e98d1437de3c628dcd1ef93.zip",
"reference": "c9644bec2a9cc9318e98d1437de3c628dcd1ef93",
"shasum": ""
},
"require": {
@ -501,7 +501,7 @@
"symfony/framework-bundle": "^2.3|^3.0",
"symfony/http-kernel": "^2.3|^3.0"
},
"time": "2017-01-03 11:02:14",
"time": "2017-04-08 09:13:59",
"type": "library",
"extra": {
"branch-alias": {

View File

@ -1397,7 +1397,10 @@ class QrCode
++$i;
}
$mib = $max_modules_1side + 8;
$mib = $max_modules_1side;
if ($this->draw_quiet_zone) {
$mib += 8;
}
if ($this->size == 0) {
$this->size = $mib * $qrcode_module_size;
@ -1458,7 +1461,7 @@ class QrCode
if ($this->draw_quiet_zone == true) {
imagecopyresampled($output_image, $base_image, $this->padding, $this->padding, 0, 0, $this->size, $this->size, $mib, $mib);
} else {
imagecopyresampled($output_image, $base_image, $this->padding, $this->padding, 4, 4, $this->size, $this->size, $mib - 8, $mib - 8);
imagecopyresampled($output_image, $base_image, $this->padding, $this->padding, 4, 4, $this->size, $this->size, $mib, $mib);
}
if ($this->draw_border == true) {
@ -1559,7 +1562,15 @@ class QrCode
$output_image = imagecreatetruecolor($image_width, $image_height);
imagecopy($output_image, $output_image_org, 0, 0, 0, 0, $image_width, $image_height);
$logo_image = call_user_func('imagecreatefrom'.$this->image_type, $this->logo);
$image_info = getimagesize($this->logo);
if ($image_info !== false) {
$image_type = strtolower(substr(image_type_to_extension($image_info [2]), 1));
$logo_image = call_user_func('imagecreatefrom'.$image_type, $this->logo);
} else {
$logo_image = call_user_func('imagecreatefrom'.$this->image_type, $this->logo);
}
if (!$logo_image) {
throw new ImageFunctionFailedException('imagecreatefrom'.$this->image_type.' '.$this->logo.' failed');
}

View File

@ -1102,7 +1102,7 @@ class OptionsResolverTest extends TestCase
$this->resolver->resolve();
}
public function testCatchedExceptionFromNormalizerDoesNotCrashOptionResolver()
public function testCaughtExceptionFromNormalizerDoesNotCrashOptionResolver()
{
$throw = true;
@ -1116,7 +1116,7 @@ class OptionsResolverTest extends TestCase
}
});
$this->resolver->setNormalizer('thrower', function (Options $options) use (&$throw) {
$this->resolver->setNormalizer('thrower', function () use (&$throw) {
if ($throw) {
$throw = false;
throw new \UnexpectedValueException('throwing');
@ -1125,10 +1125,10 @@ class OptionsResolverTest extends TestCase
return true;
});
$this->resolver->resolve();
$this->assertSame(array('catcher' => false, 'thrower' => true), $this->resolver->resolve());
}
public function testCatchedExceptionFromLazyDoesNotCrashOptionResolver()
public function testCaughtExceptionFromLazyDoesNotCrashOptionResolver()
{
$throw = true;
@ -1149,7 +1149,7 @@ class OptionsResolverTest extends TestCase
return true;
});
$this->resolver->resolve();
$this->assertSame(array('catcher' => false, 'thrower' => true), $this->resolver->resolve());
}
public function testInvokeEachNormalizerOnlyOnce()

View File

@ -64,4 +64,30 @@ if (!function_exists('trait_uses_recursive')) {
return $traits;
}
}
if (!function_exists('classnames')) {
/**
* css样式名生成器
* classnames("foo", "bar"); // => "foo bar"
* classnames("foo", [ "bar"=> true ]); // => "foo bar"
* classnames([ "foo-bar"=> true ]); // => "foo-bar"
* classnames([ "foo-bar"=> false ]); // => "
* classnames([ "foo" => true ], [ "bar"=> true ]); // => "foo bar"
* classnames([ "foo" => true, "bar"=> true ]); // => "foo bar"
* classnames("foo", [ "bar"=> true, "duck"=> false ], "baz", [ "quux"=> true ]); // => "foo bar baz quux"
* classnames(null, false, "bar", 0, 1, [ "baz"=> null ]); // => "bar 1"
*/
function classnames()
{
$args = func_get_args();
$classes = array_map(function ($arg) {
if (is_array($arg)) {
return implode(" ", array_filter(array_map(function ($expression, $class) {
return $expression ? $class : false;
}, $arg, array_keys($arg))));
}
return $arg;
}, $args);
return implode(" ", array_filter($classes));
}
}

View File

@ -12,15 +12,13 @@ class PKCS7Encoder {
/**
* 对需要加密的明文进行填充补位
* @param $text 需要进行填充补位操作的明文
* @return 补齐明文字符串
* @param string $text 需要进行填充补位操作的明文
* @return string 补齐明文字符串
*/
function encode($text) {
$block_size = PKCS7Encoder::$block_size;
$text_length = strlen($text);
$amount_to_pad = PKCS7Encoder::$block_size - ($text_length % PKCS7Encoder::$block_size);
$amount_to_pad = PKCS7Encoder::$block_size - (strlen($text) % PKCS7Encoder::$block_size);
if ($amount_to_pad == 0) {
$amount_to_pad = PKCS7Encoder::block_size;
$amount_to_pad = PKCS7Encoder::$block_size;
}
$pad_chr = chr($amount_to_pad);
$tmp = "";
@ -32,8 +30,8 @@ class PKCS7Encoder {
/**
* 对解密后的明文进行补位删除
* @param decrypted 解密后的明文
* @return 删除填充补位后的明文
* @param string $text 解密后的明文
* @return string 删除填充补位后的明文
*/
function decode($text) {
$pad = ord(substr($text, -1));
@ -62,46 +60,39 @@ class Prpcrypt {
/**
* 对明文进行加密
* @param string $text 需要加密的明文
* @param string $appid 公众号APPID
* @return string 加密后的密文
*/
public function encrypt($text, $appid) {
try {
$random = $this->getRandomStr();
//获得16位随机字符串填充到明文之前
$random = $this->getRandomStr();//"aaaabbbbccccdddd";
$text = $random . pack("N", strlen($text)) . $text . $appid;
$size = mcrypt_get_block_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);
$module = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CBC, '');
$iv = substr($this->key, 0, 16);
$pkc_encoder = new PKCS7Encoder();
$pkc_encoder = new PKCS7Encoder;
$text = $pkc_encoder->encode($text);
mcrypt_generic_init($module, $this->key, $iv);
$encrypted = mcrypt_generic($module, $text);
mcrypt_generic_deinit($module);
mcrypt_module_close($module);
return array(ErrorCode::$OK, base64_encode($encrypted));
$encrypted = openssl_encrypt($text, 'AES-256-CBC', substr($this->key, 0, 32), OPENSSL_ZERO_PADDING, $iv);
return array(ErrorCode::$OK, $encrypted);
} catch (Exception $e) {
return array(ErrorCode::$EncryptAESError, ErrorCode::getErrText(ErrorCode::$EncryptAESError));
return array(ErrorCode::$EncryptAESError, null);
}
}
/**
* 对密文进行解密
* @param string $encrypted 需要解密的密文
* @param string $appid 公众号APPID
* @return string 解密得到的明文
*/
public function decrypt($encrypted, $appid) {
try {
$ciphertext_dec = base64_decode($encrypted);
$module = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CBC, '');
$iv = substr($this->key, 0, 16);
mcrypt_generic_init($module, $this->key, $iv);
$decrypted = mdecrypt_generic($module, $ciphertext_dec);
mcrypt_generic_deinit($module);
mcrypt_module_close($module);
$decrypted = openssl_decrypt($encrypted, 'AES-256-CBC', substr($this->key, 0, 32), OPENSSL_ZERO_PADDING, $iv);
} catch (Exception $e) {
return array(ErrorCode::$DecryptAESError, ErrorCode::getErrText(ErrorCode::$DecryptAESError));
return array(ErrorCode::$DecryptAESError, null);
}
try {
$pkc_encoder = new PKCS7Encoder();
$pkc_encoder = new PKCS7Encoder;
$result = $pkc_encoder->decode($decrypted);
if (strlen($result) < 16) {
return "";
@ -115,7 +106,7 @@ class Prpcrypt {
$appid = $from_appid;
}
} catch (Exception $e) {
return array(ErrorCode::$IllegalBuffer, ErrorCode::getErrText(ErrorCode::$IllegalBuffer));
return array(ErrorCode::$IllegalBuffer, null);
}
return array(0, $xml_content, $from_appid);
}
@ -137,10 +128,9 @@ class Prpcrypt {
}
/**
* 仅用作类内部使用不用于官方API接口的errCode码
* @category WechatSDK
* @subpackage library
* @date 2016/06/28 11:59
* 仅用作类内部使用
* 不用于官方API接口的errCode码
* Class ErrorCode
*/
class ErrorCode {
@ -173,15 +163,14 @@ class ErrorCode {
/**
* 获取错误消息内容
* @param type $err
* @param string $err
* @return bool
*/
public static function getErrText($err) {
if (isset(self::$errCode[$err])) {
return self::$errCode[$err];
} else {
return false;
}
return false;
}
}

View File

@ -136,7 +136,7 @@ class Tools {
/**
* 以post方式提交请求
* @param string $url
* @param array|string $postdata
* @param array|string $data
* @return bool|mixed
*/
static public function httpPost($url, $data) {

View File

@ -76,7 +76,7 @@ class Loader {
if (!isset(self::$cache[$index])) {
$basicName = 'Wechat' . ucfirst(strtolower($type));
$className = "\\Wechat\\{$basicName}";
/* 注册类的无命名空间别名兼容未带命名空间的老版本SDK */
// 注册类的无命名空间别名兼容未带命名空间的老版本SDK
!class_exists($basicName, FALSE) && class_alias($className, $basicName);
self::$cache[$index] = new $className(self::config($config));
}

View File

@ -46,6 +46,7 @@ class WechatCard extends Common {
const CARD_PAYCELL_SET = '/card/paycell/set?';
/*设置开卡字段接口*/
const CARD_MEMBERCARD_ACTIVATEUSERFORM_SET = '/card/membercard/activateuserform/set?';
/**
* 获取微信卡券 api_ticket
* @param string $appid
@ -722,19 +723,20 @@ class WechatCard extends Common {
}
return false;
}
/**
* 设置买单接口
* @DateTime 2016-12-02T19:19:45+0800
* @param [type] $card_id [description]
* @param boolean $is_openid [description]
* @param string $card_id
* @param bool $is_openid
* @return bool|mixed
*/
public function setPaycell($card_id,$is_openid = true){
public function setPaycell($card_id, $is_openid = true) {
if (!$this->access_token && !$this->getAccessToken()) {
return false;
}
$data = array(
'card_id' => $card_id,
'is_open' => $is_openid,
'card_id' => $card_id,
'is_open' => $is_openid,
);
$result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::CARD_PAYCELL_SET . "access_token={$this->access_token}", Tools::json_encode($data));
if ($result) {
@ -751,10 +753,10 @@ class WechatCard extends Common {
/**
* 设置开卡字段信息接口
* @DateTime 2016-12-02T20:31:43+0800
* @param [type] $data [description]
* @param array $data
* @return bool|array
*/
public function setMembercardActivateuserform($data){
public function setMembercardActivateuserform($data) {
if (!$this->access_token && !$this->getAccessToken()) {
return false;
}

View File

@ -51,7 +51,7 @@ class WechatReceive extends Common {
return $this;
}
$postStr = !empty($this->postxml) ? $this->postxml : file_get_contents("php://input");
!empty($postStr) && $this->_receive = (array) simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);
!empty($postStr) && $this->_receive = (array)simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);
return $this;
}
@ -70,9 +70,8 @@ class WechatReceive extends Common {
public function getRevFrom() {
if (isset($this->_receive['FromUserName'])) {
return $this->_receive['FromUserName'];
} else {
return false;
}
return false;
}
/**
@ -82,9 +81,8 @@ class WechatReceive extends Common {
public function getRevTo() {
if (isset($this->_receive['ToUserName'])) {
return $this->_receive['ToUserName'];
} else {
return false;
}
return false;
}
/**
@ -94,9 +92,8 @@ class WechatReceive extends Common {
public function getRevType() {
if (isset($this->_receive['MsgType'])) {
return $this->_receive['MsgType'];
} else {
return false;
}
return false;
}
/**
@ -106,9 +103,8 @@ class WechatReceive extends Common {
public function getRevID() {
if (isset($this->_receive['MsgId'])) {
return $this->_receive['MsgId'];
} else {
return false;
}
return false;
}
/**
@ -118,9 +114,8 @@ class WechatReceive extends Common {
public function getRevCtime() {
if (isset($this->_receive['CreateTime'])) {
return $this->_receive['CreateTime'];
} else {
return false;
}
return false;
}
/**
@ -131,9 +126,8 @@ class WechatReceive extends Common {
public function getRevCardPass() {
if (isset($this->_receive['CardId'])) {
return $this->_receive['CardId'];
} else {
return false;
}
return false;
}
/**
@ -155,9 +149,8 @@ class WechatReceive extends Common {
}
if (isset($array) && count($array) > 0) {
return $array;
} else {
return false;
}
return false;
}
/**
@ -174,9 +167,8 @@ class WechatReceive extends Common {
}
if (isset($array) && count($array) > 0) {
return $array;
} else {
return false;
}
return false;
}
/**
@ -188,9 +180,8 @@ class WechatReceive extends Common {
return $this->_receive['Content'];
} else if (isset($this->_receive['Recognition'])) { //获取语音识别文字内容,需申请开通
return $this->_receive['Recognition'];
} else {
return false;
}
return false;
}
/**
@ -201,11 +192,10 @@ class WechatReceive extends Common {
if (isset($this->_receive['PicUrl'])) {
return array(
'mediaid' => $this->_receive['MediaId'],
'picurl' => (string) $this->_receive['PicUrl'], //防止picurl为空导致解析出错
'picurl' => (string)$this->_receive['PicUrl'], //防止picurl为空导致解析出错
);
} else {
return false;
}
return false;
}
/**
@ -219,9 +209,8 @@ class WechatReceive extends Common {
'title' => $this->_receive['Title'],
'description' => $this->_receive['Description']
);
} else {
return false;
}
return false;
}
/**
@ -236,9 +225,8 @@ class WechatReceive extends Common {
'scale' => $this->_receive['Scale'],
'label' => $this->_receive['Label']
);
} else {
return false;
}
return false;
}
/**
@ -284,7 +272,7 @@ class WechatReceive extends Common {
public function getRevScanInfo() {
if (isset($this->_receive['ScanCodeInfo'])) {
if (!is_array($this->_receive['ScanCodeInfo'])) {
$array = (array) $this->_receive['ScanCodeInfo'];
$array = (array)$this->_receive['ScanCodeInfo'];
$this->_receive['ScanCodeInfo'] = $array;
} else {
$array = $this->_receive['ScanCodeInfo'];
@ -319,13 +307,13 @@ class WechatReceive extends Common {
public function getRevSendPicsInfo() {
if (isset($this->_receive['SendPicsInfo'])) {
if (!is_array($this->_receive['SendPicsInfo'])) {
$array = (array) $this->_receive['SendPicsInfo'];
$array = (array)$this->_receive['SendPicsInfo'];
if (isset($array['PicList'])) {
$array['PicList'] = (array) $array['PicList'];
$array['PicList'] = (array)$array['PicList'];
$item = $array['PicList']['item'];
$array['PicList']['item'] = array();
foreach ($item as $key => $value) {
$array['PicList']['item'][$key] = (array) $value;
$array['PicList']['item'][$key] = (array)$value;
}
}
$this->_receive['SendPicsInfo'] = $array;
@ -358,7 +346,7 @@ class WechatReceive extends Common {
public function getRevSendGeoInfo() {
if (isset($this->_receive['SendLocationInfo'])) {
if (!is_array($this->_receive['SendLocationInfo'])) {
$array = (array) $this->_receive['SendLocationInfo'];
$array = (array)$this->_receive['SendLocationInfo'];
if (empty($array['Poiname'])) {
$array['Poiname'] = "";
}