目录结构更新,增加composer支持
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
.idea
|
||||
composer.lock
|
||||
*.log
|
||||
framework
|
||||
application/database.php
|
||||
application/install.lock
|
||||
application/upload.lock
|
||||
@@ -1,8 +0,0 @@
|
||||
<IfModule mod_rewrite.c>
|
||||
Options +FollowSymlinks
|
||||
RewriteEngine On
|
||||
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteRule ^(.*)$ index.php?s=/$1 [QSA,PT,L]
|
||||
</IfModule>
|
||||
@@ -16,15 +16,6 @@ return array(
|
||||
'template' => array(
|
||||
),
|
||||
|
||||
'view_replace_str' => array(
|
||||
'__ADDONS__' => BASE_PATH . '/addons',
|
||||
'__PUBLIC__' => BASE_PATH . '/public',
|
||||
'__STATIC__' => BASE_PATH . '/application/admin/static',
|
||||
'__IMG__' => BASE_PATH . '/application/admin/static/images',
|
||||
'__CSS__' => BASE_PATH . '/application/admin/static/css',
|
||||
'__JS__' => BASE_PATH . '/application/admin/static/js',
|
||||
),
|
||||
|
||||
'session' => array(
|
||||
'prefix' => 'admin',
|
||||
'type' => '',
|
||||
|
||||
@@ -40,7 +40,7 @@ class Action extends Admin {
|
||||
*/
|
||||
public function add() {
|
||||
$model = model('Action');
|
||||
if (IS_POST) {
|
||||
if ($this->request->isPost()) {
|
||||
$data = input('post.');
|
||||
$result = $model->save($data);
|
||||
if (false != $result) {
|
||||
@@ -65,7 +65,7 @@ class Action extends Admin {
|
||||
*/
|
||||
public function edit($id = null) {
|
||||
$model = model('Action');
|
||||
if (IS_POST) {
|
||||
if ($this->request->isPost()) {
|
||||
$data = input('post.');
|
||||
$result = $model->save($data, array('id' => $data['id']));
|
||||
if ($result !== false) {
|
||||
|
||||
@@ -42,7 +42,7 @@ class Ad extends Admin {
|
||||
*/
|
||||
public function add() {
|
||||
$place = model('AdPlace');
|
||||
if (IS_POST) {
|
||||
if ($this->request->isPost()) {
|
||||
$result = $place->change();
|
||||
if (false !== false) {
|
||||
return $this->success("添加成功!");
|
||||
@@ -61,7 +61,7 @@ class Ad extends Admin {
|
||||
|
||||
public function edit($id = null) {
|
||||
$place = model('AdPlace');
|
||||
if (IS_POST) {
|
||||
if ($this->request->isPost()) {
|
||||
$result = $place->change();
|
||||
if ($result) {
|
||||
return $this->success("修改成功!", url('admin/ad/index'));
|
||||
@@ -115,7 +115,7 @@ class Ad extends Admin {
|
||||
|
||||
public function addad($id) {
|
||||
$ad = model('ad');
|
||||
if (IS_POST) {
|
||||
if ($this->request->isPost()) {
|
||||
$result = $ad->change();
|
||||
if ($result) {
|
||||
return $this->success("添加成功!", url('admin/ad/lists', array('id' => $this->param['place_id'])));
|
||||
@@ -136,7 +136,7 @@ class Ad extends Admin {
|
||||
|
||||
public function editad($id = null) {
|
||||
$ad = model('ad');
|
||||
if (IS_POST) {
|
||||
if ($this->request->isPost()) {
|
||||
$result = $ad->change();
|
||||
if ($result) {
|
||||
return $this->success("修改成功!", url('admin/ad/lists', array('id' => $this->param['place_id'])));
|
||||
|
||||
@@ -43,7 +43,7 @@ class Addons extends Admin {
|
||||
|
||||
//创建向导首页
|
||||
public function add() {
|
||||
if (IS_POST) {
|
||||
if ($this->request->isPost()) {
|
||||
$data = $this->addons->create();
|
||||
if ($data) {
|
||||
if ($result) {
|
||||
@@ -150,7 +150,7 @@ class Addons extends Admin {
|
||||
* 设置插件页面
|
||||
*/
|
||||
public function config() {
|
||||
if (IS_POST) {
|
||||
if ($this->request->isPost()) {
|
||||
# code...
|
||||
} else {
|
||||
$id = input('id', '', 'trim,intval');
|
||||
@@ -232,7 +232,7 @@ class Addons extends Admin {
|
||||
|
||||
public function addhook() {
|
||||
$hooks = model('Hooks');
|
||||
if (IS_POST) {
|
||||
if ($this->request->isPost()) {
|
||||
$result = $hooks->change();
|
||||
if ($result !== false) {
|
||||
return $this->success("修改成功");
|
||||
@@ -253,7 +253,7 @@ class Addons extends Admin {
|
||||
//钩子出编辑挂载插件页面
|
||||
public function edithook($id) {
|
||||
$hooks = model('Hooks');
|
||||
if (IS_POST) {
|
||||
if ($this->request->isPost()) {
|
||||
$result = $hooks->change();
|
||||
if ($result !== false) {
|
||||
return $this->success("修改成功");
|
||||
|
||||
@@ -66,7 +66,7 @@ class Attribute extends Admin {
|
||||
* @author colin <colin@tensent.cn>
|
||||
*/
|
||||
public function add($model_id = '') {
|
||||
if (IS_POST) {
|
||||
if ($this->request->isPost()) {
|
||||
$result = $this->model->validate('attribute.add')->save($this->param);
|
||||
if (false !== $result) {
|
||||
return $this->success("创建成功!", url('Attribute/index', array('model_id' => $model_id)));
|
||||
@@ -89,7 +89,7 @@ class Attribute extends Admin {
|
||||
* @author colin <colin@tensent.cn>
|
||||
*/
|
||||
public function edit($id = '', $model_id = '') {
|
||||
if (IS_POST) {
|
||||
if ($this->request->isPost()) {
|
||||
$result = $this->model->validate('attribute.edit')->save($this->param, array('id'=>$id));
|
||||
if ($result) {
|
||||
return $this->success("修改成功!", url('Attribute/index', array('model_id' => $model_id)));
|
||||
|
||||
@@ -47,7 +47,7 @@ class Category extends Admin {
|
||||
|
||||
/* 编辑分类 */
|
||||
public function edit($id = null, $pid = 0) {
|
||||
if (IS_POST) {
|
||||
if ($this->request->isPost()) {
|
||||
$category = model('Category');
|
||||
//提交表单
|
||||
$result = $category->change();
|
||||
@@ -85,7 +85,7 @@ class Category extends Admin {
|
||||
public function add($pid = 0) {
|
||||
$Category = model('Category');
|
||||
|
||||
if (IS_POST) {
|
||||
if ($this->request->isPost()) {
|
||||
//提交表单
|
||||
$id = $Category->change();
|
||||
if (false !== $id) {
|
||||
@@ -250,7 +250,7 @@ class Category extends Admin {
|
||||
}
|
||||
|
||||
public function add_channel() {
|
||||
if (IS_POST) {
|
||||
if ($this->request->isPost()) {
|
||||
$Channel = model('Channel');
|
||||
$data = $this->request->param();
|
||||
if ($data) {
|
||||
|
||||
@@ -53,7 +53,7 @@ class Channel extends Admin {
|
||||
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
|
||||
*/
|
||||
public function add() {
|
||||
if (IS_POST) {
|
||||
if ($this->request->isPost()) {
|
||||
$Channel = model('Channel');
|
||||
$data = $this->request->post();
|
||||
if ($data) {
|
||||
@@ -89,7 +89,7 @@ class Channel extends Admin {
|
||||
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
|
||||
*/
|
||||
public function edit($id = 0) {
|
||||
if (IS_POST) {
|
||||
if ($this->request->isPost()) {
|
||||
$Channel = model('Channel');
|
||||
$data = $this->request->post();
|
||||
if ($data) {
|
||||
@@ -155,7 +155,7 @@ class Channel extends Admin {
|
||||
* @author huajie <banhuajie@163.com>
|
||||
*/
|
||||
public function sort() {
|
||||
if (IS_GET) {
|
||||
if ($this->request->isGet()) {
|
||||
$ids = input('ids');
|
||||
$pid = input('pid');
|
||||
//获取排序的数据
|
||||
@@ -172,7 +172,7 @@ class Channel extends Admin {
|
||||
$this->assign('list', $list);
|
||||
$this->setMeta('导航排序');
|
||||
return $this->fetch();
|
||||
} elseif (IS_POST) {
|
||||
} elseif ($this->request->isPost()) {
|
||||
$ids = input('post.ids');
|
||||
$ids = explode(',', $ids);
|
||||
foreach ($ids as $key => $value) {
|
||||
|
||||
@@ -30,7 +30,7 @@ class Client extends Admin {
|
||||
}
|
||||
|
||||
public function add(\think\Request $request){
|
||||
if (IS_POST) {
|
||||
if ($this->request->isPost()) {
|
||||
$data = $request->param();
|
||||
$result = $this->model->validate(true)->save($data);
|
||||
if (false !== $result) {
|
||||
@@ -51,7 +51,7 @@ class Client extends Admin {
|
||||
}
|
||||
|
||||
public function edit(\think\Request $request){
|
||||
if (IS_POST) {
|
||||
if ($this->request->isPost()) {
|
||||
$data = $request->param();
|
||||
$result = $this->model->validate(true)->save($data, array('id'=>$request->param('id')));
|
||||
if (false !== $result) {
|
||||
|
||||
@@ -52,7 +52,7 @@ class Config extends Admin {
|
||||
}
|
||||
|
||||
public function group($id = 1) {
|
||||
if (IS_POST) {
|
||||
if ($this->request->isPost()) {
|
||||
$config = $this->request->post('config/a');
|
||||
$model = model('Config');
|
||||
foreach ($config as $key => $value) {
|
||||
@@ -78,7 +78,7 @@ class Config extends Admin {
|
||||
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
|
||||
*/
|
||||
public function add() {
|
||||
if (IS_POST) {
|
||||
if ($this->request->isPost()) {
|
||||
$config = model('Config');
|
||||
$data = $this->request->post();
|
||||
if ($data) {
|
||||
@@ -106,7 +106,7 @@ class Config extends Admin {
|
||||
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
|
||||
*/
|
||||
public function edit($id = 0) {
|
||||
if (IS_POST) {
|
||||
if ($this->request->isPost()) {
|
||||
$config = model('Config');
|
||||
$data = $this->request->post();
|
||||
if ($data) {
|
||||
@@ -177,7 +177,7 @@ class Config extends Admin {
|
||||
* @author huajie <banhuajie@163.com>
|
||||
*/
|
||||
public function sort() {
|
||||
if (IS_GET) {
|
||||
if ($this->request->isGet()) {
|
||||
$ids = input('ids');
|
||||
//获取排序的数据
|
||||
$map = array('status' => array('gt', -1));
|
||||
@@ -191,7 +191,7 @@ class Config extends Admin {
|
||||
$this->assign('list', $list);
|
||||
$this->setMeta('配置排序');
|
||||
return $this->fetch();
|
||||
} elseif (IS_POST) {
|
||||
} elseif ($this->request->isPost()) {
|
||||
$ids = input('post.ids');
|
||||
$ids = explode(',', $ids);
|
||||
foreach ($ids as $key => $value) {
|
||||
|
||||
@@ -66,7 +66,7 @@ class Content extends Admin {
|
||||
* @author molong <ycgpp@126.com>
|
||||
*/
|
||||
public function add() {
|
||||
if (IS_POST) {
|
||||
if ($this->request->isPost()) {
|
||||
$result = $this->model->save($this->param);
|
||||
if ($result) {
|
||||
//记录行为
|
||||
@@ -99,7 +99,7 @@ class Content extends Admin {
|
||||
* @author molong <ycgpp@126.com>
|
||||
*/
|
||||
public function edit($id) {
|
||||
if (IS_POST) {
|
||||
if ($this->request->isPost()) {
|
||||
$result = $this->model->save($this->param, array('id'=> $id));
|
||||
if ($result !== false) {
|
||||
//记录行为
|
||||
|
||||
@@ -155,7 +155,7 @@ class Database extends Admin {
|
||||
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
|
||||
*/
|
||||
public function export($tables = null, $id = null, $start = null) {
|
||||
if (IS_POST && !empty($tables) && is_array($tables)) {
|
||||
if ($this->request->isPost() && !empty($tables) && is_array($tables)) {
|
||||
//初始化
|
||||
$path = config('data_backup_path');
|
||||
if (!is_dir($path)) {
|
||||
@@ -189,7 +189,7 @@ class Database extends Admin {
|
||||
} else {
|
||||
return $this->error('初始化失败,备份文件创建失败!');
|
||||
}
|
||||
} elseif (IS_GET && is_numeric($id) && is_numeric($start)) {
|
||||
} elseif ($this->request->isGet() && is_numeric($id) && is_numeric($start)) {
|
||||
//备份数据
|
||||
$tables = session('backup_tables');
|
||||
//备份指定表
|
||||
|
||||
@@ -42,7 +42,7 @@ class Form extends Admin {
|
||||
* 添加表单
|
||||
*/
|
||||
public function add(\think\Request $request) {
|
||||
if (IS_POST) {
|
||||
if ($this->request->isPost()) {
|
||||
$result = $this->model->validate('Form')->save($request->post());
|
||||
if (false !== $result) {
|
||||
return $this->success('添加成功!', url('admin/form/index'));
|
||||
@@ -63,7 +63,7 @@ class Form extends Admin {
|
||||
* 编辑表单
|
||||
*/
|
||||
public function edit(\think\Request $request) {
|
||||
if (IS_POST) {
|
||||
if ($this->request->isPost()) {
|
||||
$result = $this->model->validate('Form')->save($request->post(), array('id' => $request->post('id')));
|
||||
if (false !== $result) {
|
||||
return $this->success('修改成功!', url('admin/form/index'));
|
||||
@@ -170,7 +170,7 @@ class Form extends Admin {
|
||||
if (!$form_id) {
|
||||
return $this->error('非法操作!');
|
||||
}
|
||||
if (IS_POST) {
|
||||
if ($this->request->isPost()) {
|
||||
$data = $request->post();
|
||||
$result = $this->Fattr->save($data);
|
||||
if (false !== $result) {
|
||||
@@ -198,7 +198,7 @@ class Form extends Admin {
|
||||
if (!$form_id || !$id) {
|
||||
return $this->error('非法操作!');
|
||||
}
|
||||
if (IS_POST) {
|
||||
if ($this->request->isPost()) {
|
||||
$data = $request->post();
|
||||
$result = $this->Fattr->save($data, array('id'=>$data['id']));
|
||||
if (false !== $result) {
|
||||
|
||||
@@ -39,7 +39,7 @@ class Group extends Admin {
|
||||
|
||||
//会员分组添加控制器
|
||||
public function add($type = 'admin') {
|
||||
if (IS_POST) {
|
||||
if ($this->request->isPost()) {
|
||||
$result = $this->group->change();
|
||||
if ($result) {
|
||||
return $this->success("添加成功!", url('admin/group/index'));
|
||||
@@ -62,7 +62,7 @@ class Group extends Admin {
|
||||
if (!$id) {
|
||||
return $this->error("非法操作!");
|
||||
}
|
||||
if (IS_POST) {
|
||||
if ($this->request->isPost()) {
|
||||
$result = $this->group->change();
|
||||
if ($result) {
|
||||
return $this->success("编辑成功!", url('admin/group/index'));
|
||||
@@ -138,7 +138,7 @@ class Group extends Admin {
|
||||
if (!$id) {
|
||||
return $this->error("非法操作!");
|
||||
}
|
||||
if (IS_POST) {
|
||||
if ($this->request->isPost()) {
|
||||
$rule = $this->request->post('rule/a', array());
|
||||
$extend_rule = $this->request->post('extend_rule/a', array());
|
||||
$extend_result = $rule_result = false;
|
||||
@@ -194,7 +194,7 @@ class Group extends Admin {
|
||||
}
|
||||
|
||||
public function addnode($type = 'admin') {
|
||||
if (IS_POST) {
|
||||
if ($this->request->isPost()) {
|
||||
$result = $this->rule->change();
|
||||
if ($result) {
|
||||
return $this->success("创建成功!", url('admin/group/access'));
|
||||
@@ -213,7 +213,7 @@ class Group extends Admin {
|
||||
}
|
||||
|
||||
public function editnode($id) {
|
||||
if (IS_POST) {
|
||||
if ($this->request->isPost()) {
|
||||
$result = $this->rule->change();
|
||||
if (false !== $result) {
|
||||
return $this->success("更新成功!", url('admin/group/access'));
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\Admin;
|
||||
|
||||
class Index extends Admin {
|
||||
@@ -18,15 +19,17 @@ class Index extends Admin {
|
||||
}
|
||||
|
||||
public function login($username = '', $password = '', $verify = '') {
|
||||
if (IS_POST) {
|
||||
if ($this->request->isPost()) {
|
||||
if (!$username || !$password) {
|
||||
return $this->error('用户名或者密码不能为空!', '');
|
||||
}
|
||||
|
||||
//验证码验证
|
||||
$this->checkVerify($verify);
|
||||
if(!captcha_check($verify)){
|
||||
return $this->error('验证码错误!', '');
|
||||
}
|
||||
|
||||
$user = model('User');
|
||||
$user = model('Member');
|
||||
$uid = $user->login($username, $password);
|
||||
if ($uid > 0) {
|
||||
return $this->success('登录成功!', url('admin/index/index'));
|
||||
@@ -46,14 +49,23 @@ class Index extends Admin {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* title : 后台退出
|
||||
*
|
||||
*/
|
||||
public function logout() {
|
||||
$user = model('User');
|
||||
$user = model('Member');
|
||||
$user->logout();
|
||||
$this->redirect('admin/index/login');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* title : 清除缓存
|
||||
*
|
||||
*/
|
||||
public function clear() {
|
||||
if (IS_POST) {
|
||||
if ($this->request->isPost()) {
|
||||
$clear = input('post.clear/a', array());
|
||||
foreach ($clear as $key => $value) {
|
||||
if ($value == 'cache') {
|
||||
@@ -79,4 +91,4 @@ class Index extends Admin {
|
||||
return $this->fetch('public/edit');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ class Link extends Admin {
|
||||
//添加
|
||||
public function add() {
|
||||
$link = model('Link');
|
||||
if (IS_POST) {
|
||||
if ($this->request->isPost()) {
|
||||
$data = input('post.');
|
||||
if ($data) {
|
||||
unset($data['id']);
|
||||
@@ -57,7 +57,7 @@ class Link extends Admin {
|
||||
public function edit() {
|
||||
$link = model('Link');
|
||||
$id = input('id', '', 'trim,intval');
|
||||
if (IS_POST) {
|
||||
if ($this->request->isPost()) {
|
||||
$data = input('post.');
|
||||
if ($data) {
|
||||
$result = $link->save($data, array('id' => $data['id']));
|
||||
|
||||
@@ -46,7 +46,7 @@ class Menu extends Admin {
|
||||
* @author yangweijie <yangweijiester@gmail.com>
|
||||
*/
|
||||
public function add() {
|
||||
if (IS_POST) {
|
||||
if ($this->request->isPost()) {
|
||||
$Menu = model('Menu');
|
||||
$data = input('post.');
|
||||
$id = $Menu->save($data);
|
||||
@@ -80,7 +80,7 @@ class Menu extends Admin {
|
||||
* @author yangweijie <yangweijiester@gmail.com>
|
||||
*/
|
||||
public function edit($id = 0) {
|
||||
if (IS_POST) {
|
||||
if ($this->request->isPost()) {
|
||||
$Menu = model('Menu');
|
||||
$data = input('post.');
|
||||
if ($Menu->save($data, array('id' => $data['id'])) !== false) {
|
||||
@@ -176,7 +176,7 @@ class Menu extends Admin {
|
||||
}
|
||||
|
||||
public function import() {
|
||||
if (IS_POST) {
|
||||
if ($this->request->isPost()) {
|
||||
$tree = input('post.tree');
|
||||
$lists = explode(PHP_EOL, $tree);
|
||||
$menuModel = db('Menu');
|
||||
@@ -217,7 +217,7 @@ class Menu extends Admin {
|
||||
* @author huajie <banhuajie@163.com>
|
||||
*/
|
||||
public function sort() {
|
||||
if (IS_GET) {
|
||||
if ($this->request->isGet()) {
|
||||
$ids = input('ids');
|
||||
$pid = input('pid');
|
||||
|
||||
@@ -235,7 +235,7 @@ class Menu extends Admin {
|
||||
$this->assign('list', $list);
|
||||
$this->setMeta('菜单排序');
|
||||
return $this->fetch();
|
||||
} elseif (IS_POST) {
|
||||
} elseif ($this->request->isPost()) {
|
||||
$ids = input('post.ids');
|
||||
$ids = explode(',', $ids);
|
||||
foreach ($ids as $key => $value) {
|
||||
|
||||
@@ -46,7 +46,7 @@ class Model extends Admin {
|
||||
* @author huajie <banhuajie@163.com>
|
||||
*/
|
||||
public function add(\think\Request $request) {
|
||||
if (IS_POST) {
|
||||
if ($this->request->isPost()) {
|
||||
$result = $this->model->validate('Model.add')->save($request->post());
|
||||
if (false !== $result) {
|
||||
//记录行为
|
||||
@@ -66,7 +66,7 @@ class Model extends Admin {
|
||||
* @author molong <molong@tensent.cn>
|
||||
*/
|
||||
public function edit(\think\Request $request) {
|
||||
if (IS_POST) {
|
||||
if ($this->request->isPost()) {
|
||||
$result = $this->model->validate('Model.edit')->save($request->post(), array('id' => $request->post('id')));
|
||||
if (false !== $result) {
|
||||
//记录行为
|
||||
|
||||
@@ -37,7 +37,7 @@ class Seo extends Admin {
|
||||
}
|
||||
|
||||
public function add() {
|
||||
if (IS_POST) {
|
||||
if ($this->request->isPost()) {
|
||||
$data = $this->request->post();
|
||||
$result = $this->seo->save($data);
|
||||
if ($result) {
|
||||
@@ -56,7 +56,7 @@ class Seo extends Admin {
|
||||
}
|
||||
|
||||
public function edit($id = null) {
|
||||
if (IS_POST) {
|
||||
if ($this->request->isPost()) {
|
||||
$data = $this->request->post();
|
||||
$result = $this->seo->save($data, array('id' => $data['id']));
|
||||
if (false !== $result) {
|
||||
@@ -103,7 +103,7 @@ class Seo extends Admin {
|
||||
}
|
||||
|
||||
public function addrewrite() {
|
||||
if (IS_POST) {
|
||||
if ($this->request->isPost()) {
|
||||
$result = model('Rewrite')->change();
|
||||
if (false != $result) {
|
||||
return $this->success("添加成功!", url('admin/seo/rewrite'));
|
||||
@@ -121,7 +121,7 @@ class Seo extends Admin {
|
||||
}
|
||||
|
||||
public function editrewrite() {
|
||||
if (IS_POST) {
|
||||
if ($this->request->isPost()) {
|
||||
$result = model('Rewrite')->change();
|
||||
if (false != $result) {
|
||||
return $this->success("更新成功!", url('admin/seo/rewrite'));
|
||||
|
||||
@@ -26,7 +26,7 @@ class User extends Admin {
|
||||
}
|
||||
|
||||
$order = "uid desc";
|
||||
$list = model('User')->where($map)->order($order)->paginate(15);
|
||||
$list = model('Member')->where($map)->order($order)->paginate(15);
|
||||
|
||||
$data = array(
|
||||
'list' => $list,
|
||||
@@ -42,8 +42,8 @@ class User extends Admin {
|
||||
* @author colin <molong@tensent.cn>
|
||||
*/
|
||||
public function add() {
|
||||
$model = \think\Loader::model('User');
|
||||
if (IS_POST) {
|
||||
$model = \think\Loader::model('Member');
|
||||
if ($this->request->isPost()) {
|
||||
$data = $this->request->param();
|
||||
//创建注册用户
|
||||
$result = $model->register($data['username'], $data['password'], $data['repassword'], $data['email'], false);
|
||||
@@ -67,8 +67,8 @@ class User extends Admin {
|
||||
* @author huajie <banhuajie@163.com>
|
||||
*/
|
||||
public function edit() {
|
||||
$model = model('User');
|
||||
if (IS_POST) {
|
||||
$model = model('Member');
|
||||
if ($this->request->isPost()) {
|
||||
$data = $this->request->post();
|
||||
|
||||
$reuslt = $model->editUser($data, true);
|
||||
@@ -99,14 +99,14 @@ class User extends Admin {
|
||||
$uid = array('IN', is_array($id) ? implode(',', $id) : $id);
|
||||
//获取用户信息
|
||||
$find = $this->getUserinfo($uid);
|
||||
model('User')->where(array('uid' => $uid))->delete();
|
||||
model('Member')->where(array('uid' => $uid))->delete();
|
||||
return $this->success('删除用户成功!');
|
||||
}
|
||||
|
||||
public function auth() {
|
||||
$access = model('AuthGroupAccess');
|
||||
$group = model('AuthGroup');
|
||||
if (IS_POST) {
|
||||
if ($this->request->isPost()) {
|
||||
$uid = input('uid', '', 'trim,intval');
|
||||
$access->where(array('uid' => $uid))->delete();
|
||||
$group_type = config('user_group_type');
|
||||
@@ -152,7 +152,7 @@ class User extends Admin {
|
||||
* @author colin <colin@tensent.cn>
|
||||
*/
|
||||
private function getUserinfo($uid = null, $pass = null, $errormsg = null) {
|
||||
$user = model('User');
|
||||
$user = model('Member');
|
||||
$uid = $uid ? $uid : input('id');
|
||||
//如果无UID则修改当前用户
|
||||
$uid = $uid ? $uid : session('user_auth.uid');
|
||||
@@ -215,7 +215,7 @@ class User extends Admin {
|
||||
* @author huajie <banhuajie@163.com>
|
||||
*/
|
||||
public function editpwd() {
|
||||
if (IS_POST) {
|
||||
if ($this->request->isPost()) {
|
||||
$user = model('User');
|
||||
$data = $this->request->post();
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
Before Width: | Height: | Size: 7.8 KiB |
@@ -1,265 +0,0 @@
|
||||
$(function($) {
|
||||
var storage, fail, uid;
|
||||
try {
|
||||
uid = new Date; (storage = window.localStorage).setItem(uid, uid);
|
||||
fail = storage.getItem(uid) != uid;
|
||||
storage.removeItem(uid);
|
||||
fail && (storage = false);
|
||||
} catch(e) {}
|
||||
if (storage) {
|
||||
try {
|
||||
var usedSkin = localStorage.getItem('config-skin');
|
||||
if (usedSkin != '') {
|
||||
$('#skin-colors .skin-changer').removeClass('active');
|
||||
$('#skin-colors .skin-changer[data-skin="' + usedSkin + '"]').addClass('active');
|
||||
}
|
||||
|
||||
//固定头部、左侧菜单以及底部版权信息
|
||||
$('body').addClass('fixed-header');
|
||||
$('body').addClass('fixed-footer');
|
||||
$('body').addClass('fixed-leftmenu');
|
||||
if ($('#page-wrapper').hasClass('nav-small')) {
|
||||
$('#page-wrapper').removeClass('nav-small');
|
||||
}
|
||||
$('.fixed-leftmenu #col-left').nanoScroller({
|
||||
alwaysVisible: true,
|
||||
iOSNativeScrolling: false,
|
||||
preventPageScrolling: true,
|
||||
contentClass: 'col-left-nano-content'
|
||||
});
|
||||
|
||||
|
||||
var boxedLayout = localStorage.getItem('config-boxed-layout');
|
||||
if (boxedLayout == 'boxed-layout') {
|
||||
$('body').addClass(boxedLayout);
|
||||
$('#config-boxed-layout').prop('checked', true);
|
||||
}
|
||||
var sidebarSamll = localStorage.getItem('config-sidebar-samll');
|
||||
if (sidebarSamll == 'sidebar-samll') {
|
||||
$('#config-sidebar-samll').prop('checked', true);
|
||||
$('#page-wrapper').addClass('nav-small');
|
||||
} else {
|
||||
$('#page-wrapper').removeClass('nav-small');
|
||||
};
|
||||
} catch(e) {
|
||||
console.log(e);
|
||||
}
|
||||
}
|
||||
$('#config-tool-cog').on('click',
|
||||
function() {
|
||||
$('#config-tool').toggleClass('closed');
|
||||
});
|
||||
$('#config-boxed-layout').on('change',
|
||||
function() {
|
||||
var boxedLayout = '';
|
||||
if ($(this).is(':checked')) {
|
||||
$('body').addClass('boxed-layout');
|
||||
boxedLayout = 'boxed-layout';
|
||||
} else {
|
||||
$('body').removeClass('boxed-layout');
|
||||
}
|
||||
writeStorage(storage, 'config-boxed-layout', boxedLayout);
|
||||
});
|
||||
|
||||
$('#config-sidebar-samll').on('change',function(){
|
||||
var sidebarSamll = '';
|
||||
if ($(this).is(':checked')) {
|
||||
$('#page-wrapper').addClass('nav-small');
|
||||
sidebarSamll = 'sidebar-samll';
|
||||
writeStorage(storage, 'config-sidebar-samll', sidebarSamll);
|
||||
} else {
|
||||
$('#page-wrapper').removeClass('nav-small');
|
||||
writeStorage(storage, 'config-sidebar-samll', sidebarSamll);
|
||||
location.reload();
|
||||
}
|
||||
})
|
||||
if (!storage) {
|
||||
$('#config-boxed-layout').prop('checked', false);
|
||||
$('#config-sidebar-samll').prop('checked', false);
|
||||
}
|
||||
$('#skin-colors .skin-changer').on('click',
|
||||
function() {
|
||||
$('body').removeClassPrefix('theme-');
|
||||
$('body').addClass($(this).data('skin'));
|
||||
$('#skin-colors .skin-changer').removeClass('active');
|
||||
$(this).addClass('active');
|
||||
writeStorage(storage, 'config-skin', $(this).data('skin'));
|
||||
});
|
||||
|
||||
|
||||
//合并自script.js
|
||||
setTimeout(function() {
|
||||
$('#content-wrapper > .row').css({
|
||||
opacity: 1
|
||||
});
|
||||
},
|
||||
200);
|
||||
$('#sidebar-nav,#nav-col-submenu').on('click', '.dropdown-toggle',
|
||||
function(e) {
|
||||
e.preventDefault();
|
||||
var $item = $(this).parent();
|
||||
if (!$item.hasClass('open')) {
|
||||
$item.parent().find('.open .submenu').slideUp('fast');
|
||||
$item.parent().find('.open').toggleClass('open');
|
||||
}
|
||||
$item.toggleClass('open');
|
||||
if ($item.hasClass('open')) {
|
||||
$item.children('.submenu').slideDown('fast');
|
||||
} else {
|
||||
$item.children('.submenu').slideUp('fast');
|
||||
}
|
||||
});
|
||||
$('body').on('mouseenter', '#page-wrapper.nav-small #sidebar-nav .dropdown-toggle',
|
||||
function(e) {
|
||||
if ($(document).width() >= 992) {
|
||||
var $item = $(this).parent();
|
||||
if ($('body').hasClass('fixed-leftmenu')) {
|
||||
var topPosition = $item.position().top;
|
||||
if ((topPosition + 4 * $(this).outerHeight()) >= $(window).height()) {
|
||||
topPosition -= 6 * $(this).outerHeight();
|
||||
}
|
||||
$('#nav-col-submenu').html($item.children('.submenu').clone());
|
||||
$('#nav-col-submenu > .submenu').css({
|
||||
'top': topPosition
|
||||
});
|
||||
}
|
||||
$item.addClass('open');
|
||||
$item.children('.submenu').slideDown('fast');
|
||||
}
|
||||
});
|
||||
$('body').on('mouseleave', '#page-wrapper.nav-small #sidebar-nav > .nav-pills > li',
|
||||
function(e) {
|
||||
if ($(document).width() >= 992) {
|
||||
var $item = $(this);
|
||||
if ($item.hasClass('open')) {
|
||||
$item.find('.open .submenu').slideUp('fast');
|
||||
$item.find('.open').removeClass('open');
|
||||
$item.children('.submenu').slideUp('fast');
|
||||
}
|
||||
$item.removeClass('open');
|
||||
}
|
||||
});
|
||||
$('body').on('mouseenter', '#page-wrapper.nav-small #sidebar-nav a:not(.dropdown-toggle)',
|
||||
function(e) {
|
||||
if ($('body').hasClass('fixed-leftmenu')) {
|
||||
$('#nav-col-submenu').html('');
|
||||
}
|
||||
});
|
||||
$('body').on('mouseleave', '#page-wrapper.nav-small #nav-col',
|
||||
function(e) {
|
||||
if ($('body').hasClass('fixed-leftmenu')) {
|
||||
$('#nav-col-submenu').html('');
|
||||
}
|
||||
});
|
||||
$('#make-small-nav').click(function(e) {
|
||||
$('#page-wrapper').toggleClass('nav-small');
|
||||
});
|
||||
$(window).smartresize(function() {
|
||||
if ($(document).width() <= 991) {
|
||||
$('#page-wrapper').removeClass('nav-small');
|
||||
}
|
||||
});
|
||||
$('.mobile-search').click(function(e) {
|
||||
e.preventDefault();
|
||||
$('.mobile-search').addClass('active');
|
||||
$('.mobile-search form input.form-control').focus();
|
||||
});
|
||||
$(document).mouseup(function(e) {
|
||||
var container = $('.mobile-search');
|
||||
if (!container.is(e.target) && container.has(e.target).length === 0) {
|
||||
container.removeClass('active');
|
||||
}
|
||||
});
|
||||
$('.fixed-leftmenu #col-left').nanoScroller({
|
||||
alwaysVisible: true,
|
||||
iOSNativeScrolling: false,
|
||||
preventPageScrolling: true,
|
||||
contentClass: 'col-left-nano-content'
|
||||
});
|
||||
$("[data-toggle='tooltip']").each(function(index, el) {
|
||||
$(el).tooltip({
|
||||
placement: $(this).data("placement") || 'top'
|
||||
});
|
||||
});
|
||||
});
|
||||
function writeStorage(storage, key, value) {
|
||||
if (storage) {
|
||||
try {
|
||||
localStorage.setItem(key, value);
|
||||
} catch(e) {
|
||||
console.log(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$.fn.removeClassPrefix = function(prefix) {
|
||||
this.each(function(i, el) {
|
||||
var classes = el.className.split(" ").filter(function(c) {
|
||||
return c.lastIndexOf(prefix, 0) !== 0;
|
||||
});
|
||||
el.className = classes.join(" ");
|
||||
});
|
||||
return this;
|
||||
}; (function($, sr) {
|
||||
var debounce = function(func, threshold, execAsap) {
|
||||
var timeout;
|
||||
return function debounced() {
|
||||
var obj = this,
|
||||
args = arguments;
|
||||
function delayed() {
|
||||
if (!execAsap) func.apply(obj, args);
|
||||
timeout = null;
|
||||
};
|
||||
if (timeout) clearTimeout(timeout);
|
||||
else if (execAsap) func.apply(obj, args);
|
||||
timeout = setTimeout(delayed, threshold || 100);
|
||||
};
|
||||
}
|
||||
jQuery.fn[sr] = function(fn) {
|
||||
return fn ? this.bind('resize', debounce(fn)) : this.trigger(sr);
|
||||
};
|
||||
})(jQuery, 'smartresize');
|
||||
|
||||
function helpIntro(){
|
||||
var placementRight = 'right';
|
||||
var placementLeft = 'left';
|
||||
|
||||
if ($('body').hasClass('rtl')) {
|
||||
placementRight = 'left';
|
||||
placementLeft = 'right';
|
||||
}
|
||||
|
||||
// Define the tour!
|
||||
var tour = {
|
||||
id: "Cube-intro",
|
||||
steps: [
|
||||
{
|
||||
target: 'make-small-nav',
|
||||
title: "设置小菜单按钮",
|
||||
content: "点击小菜单可以把左侧菜单变成小菜单,增大右侧操作区域!",
|
||||
placement: "bottom",
|
||||
zindex: 999,
|
||||
xOffset: -8
|
||||
},
|
||||
{
|
||||
target: 'config-tool-options',
|
||||
title: "后台配置工具",
|
||||
content: "配置后台主题色彩,定制头部、左侧菜单以及底部信息",
|
||||
placement: placementLeft,
|
||||
zindex: 999,
|
||||
fixedElement: true,
|
||||
xOffset: -55
|
||||
},
|
||||
{
|
||||
target: 'sidebar-nav',
|
||||
title: "左侧导航区域",
|
||||
content: "左侧功能导航区域。",
|
||||
placement: placementRight
|
||||
}
|
||||
],
|
||||
showPrevButton: true
|
||||
};
|
||||
|
||||
// Start the tour!
|
||||
hopscotch.startTour(tour);
|
||||
}
|
||||
@@ -1,362 +0,0 @@
|
||||
CodeMirror.defineMode("clike", function(config, parserConfig) {
|
||||
var indentUnit = config.indentUnit,
|
||||
statementIndentUnit = parserConfig.statementIndentUnit || indentUnit,
|
||||
dontAlignCalls = parserConfig.dontAlignCalls,
|
||||
keywords = parserConfig.keywords || {},
|
||||
builtin = parserConfig.builtin || {},
|
||||
blockKeywords = parserConfig.blockKeywords || {},
|
||||
atoms = parserConfig.atoms || {},
|
||||
hooks = parserConfig.hooks || {},
|
||||
multiLineStrings = parserConfig.multiLineStrings;
|
||||
var isOperatorChar = /[+\-*&%=<>!?|\/]/;
|
||||
|
||||
var curPunc;
|
||||
|
||||
function tokenBase(stream, state) {
|
||||
var ch = stream.next();
|
||||
if (hooks[ch]) {
|
||||
var result = hooks[ch](stream, state);
|
||||
if (result !== false) return result;
|
||||
}
|
||||
if (ch == '"' || ch == "'") {
|
||||
state.tokenize = tokenString(ch);
|
||||
return state.tokenize(stream, state);
|
||||
}
|
||||
if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
|
||||
curPunc = ch;
|
||||
return null;
|
||||
}
|
||||
if (/\d/.test(ch)) {
|
||||
stream.eatWhile(/[\w\.]/);
|
||||
return "number";
|
||||
}
|
||||
if (ch == "/") {
|
||||
if (stream.eat("*")) {
|
||||
state.tokenize = tokenComment;
|
||||
return tokenComment(stream, state);
|
||||
}
|
||||
if (stream.eat("/")) {
|
||||
stream.skipToEnd();
|
||||
return "comment";
|
||||
}
|
||||
}
|
||||
if (isOperatorChar.test(ch)) {
|
||||
stream.eatWhile(isOperatorChar);
|
||||
return "operator";
|
||||
}
|
||||
stream.eatWhile(/[\w\$_]/);
|
||||
var cur = stream.current();
|
||||
if (keywords.propertyIsEnumerable(cur)) {
|
||||
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
|
||||
return "keyword";
|
||||
}
|
||||
if (builtin.propertyIsEnumerable(cur)) {
|
||||
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
|
||||
return "builtin";
|
||||
}
|
||||
if (atoms.propertyIsEnumerable(cur)) return "atom";
|
||||
return "variable";
|
||||
}
|
||||
|
||||
function tokenString(quote) {
|
||||
return function(stream, state) {
|
||||
var escaped = false, next, end = false;
|
||||
while ((next = stream.next()) != null) {
|
||||
if (next == quote && !escaped) {end = true; break;}
|
||||
escaped = !escaped && next == "\\";
|
||||
}
|
||||
if (end || !(escaped || multiLineStrings))
|
||||
state.tokenize = null;
|
||||
return "string";
|
||||
};
|
||||
}
|
||||
|
||||
function tokenComment(stream, state) {
|
||||
var maybeEnd = false, ch;
|
||||
while (ch = stream.next()) {
|
||||
if (ch == "/" && maybeEnd) {
|
||||
state.tokenize = null;
|
||||
break;
|
||||
}
|
||||
maybeEnd = (ch == "*");
|
||||
}
|
||||
return "comment";
|
||||
}
|
||||
|
||||
function Context(indented, column, type, align, prev) {
|
||||
this.indented = indented;
|
||||
this.column = column;
|
||||
this.type = type;
|
||||
this.align = align;
|
||||
this.prev = prev;
|
||||
}
|
||||
function pushContext(state, col, type) {
|
||||
var indent = state.indented;
|
||||
if (state.context && state.context.type == "statement")
|
||||
indent = state.context.indented;
|
||||
return state.context = new Context(indent, col, type, null, state.context);
|
||||
}
|
||||
function popContext(state) {
|
||||
var t = state.context.type;
|
||||
if (t == ")" || t == "]" || t == "}")
|
||||
state.indented = state.context.indented;
|
||||
return state.context = state.context.prev;
|
||||
}
|
||||
|
||||
// Interface
|
||||
|
||||
return {
|
||||
startState: function(basecolumn) {
|
||||
return {
|
||||
tokenize: null,
|
||||
context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
|
||||
indented: 0,
|
||||
startOfLine: true
|
||||
};
|
||||
},
|
||||
|
||||
token: function(stream, state) {
|
||||
var ctx = state.context;
|
||||
if (stream.sol()) {
|
||||
if (ctx.align == null) ctx.align = false;
|
||||
state.indented = stream.indentation();
|
||||
state.startOfLine = true;
|
||||
}
|
||||
if (stream.eatSpace()) return null;
|
||||
curPunc = null;
|
||||
var style = (state.tokenize || tokenBase)(stream, state);
|
||||
if (style == "comment" || style == "meta") return style;
|
||||
if (ctx.align == null) ctx.align = true;
|
||||
|
||||
if ((curPunc == ";" || curPunc == ":" || curPunc == ",") && ctx.type == "statement") popContext(state);
|
||||
else if (curPunc == "{") pushContext(state, stream.column(), "}");
|
||||
else if (curPunc == "[") pushContext(state, stream.column(), "]");
|
||||
else if (curPunc == "(") pushContext(state, stream.column(), ")");
|
||||
else if (curPunc == "}") {
|
||||
while (ctx.type == "statement") ctx = popContext(state);
|
||||
if (ctx.type == "}") ctx = popContext(state);
|
||||
while (ctx.type == "statement") ctx = popContext(state);
|
||||
}
|
||||
else if (curPunc == ctx.type) popContext(state);
|
||||
else if (((ctx.type == "}" || ctx.type == "top") && curPunc != ';') || (ctx.type == "statement" && curPunc == "newstatement"))
|
||||
pushContext(state, stream.column(), "statement");
|
||||
state.startOfLine = false;
|
||||
return style;
|
||||
},
|
||||
|
||||
indent: function(state, textAfter) {
|
||||
if (state.tokenize != tokenBase && state.tokenize != null) return CodeMirror.Pass;
|
||||
var ctx = state.context, firstChar = textAfter && textAfter.charAt(0);
|
||||
if (ctx.type == "statement" && firstChar == "}") ctx = ctx.prev;
|
||||
var closing = firstChar == ctx.type;
|
||||
if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : statementIndentUnit);
|
||||
else if (ctx.align && (!dontAlignCalls || ctx.type != ")")) return ctx.column + (closing ? 0 : 1);
|
||||
else if (ctx.type == ")" && !closing) return ctx.indented + statementIndentUnit;
|
||||
else return ctx.indented + (closing ? 0 : indentUnit);
|
||||
},
|
||||
|
||||
electricChars: "{}",
|
||||
blockCommentStart: "/*",
|
||||
blockCommentEnd: "*/",
|
||||
lineComment: "//",
|
||||
fold: "brace"
|
||||
};
|
||||
});
|
||||
|
||||
(function() {
|
||||
function words(str) {
|
||||
var obj = {}, words = str.split(" ");
|
||||
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
|
||||
return obj;
|
||||
}
|
||||
var cKeywords = "auto if break int case long char register continue return default short do sizeof " +
|
||||
"double static else struct entry switch extern typedef float union for unsigned " +
|
||||
"goto while enum void const signed volatile";
|
||||
|
||||
function cppHook(stream, state) {
|
||||
if (!state.startOfLine) return false;
|
||||
for (;;) {
|
||||
if (stream.skipTo("\\")) {
|
||||
stream.next();
|
||||
if (stream.eol()) {
|
||||
state.tokenize = cppHook;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
stream.skipToEnd();
|
||||
state.tokenize = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return "meta";
|
||||
}
|
||||
|
||||
// C#-style strings where "" escapes a quote.
|
||||
function tokenAtString(stream, state) {
|
||||
var next;
|
||||
while ((next = stream.next()) != null) {
|
||||
if (next == '"' && !stream.eat('"')) {
|
||||
state.tokenize = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return "string";
|
||||
}
|
||||
|
||||
function mimes(ms, mode) {
|
||||
for (var i = 0; i < ms.length; ++i) CodeMirror.defineMIME(ms[i], mode);
|
||||
}
|
||||
|
||||
mimes(["text/x-csrc", "text/x-c", "text/x-chdr"], {
|
||||
name: "clike",
|
||||
keywords: words(cKeywords),
|
||||
blockKeywords: words("case do else for if switch while struct"),
|
||||
atoms: words("null"),
|
||||
hooks: {"#": cppHook}
|
||||
});
|
||||
mimes(["text/x-c++src", "text/x-c++hdr"], {
|
||||
name: "clike",
|
||||
keywords: words(cKeywords + " asm dynamic_cast namespace reinterpret_cast try bool explicit new " +
|
||||
"static_cast typeid catch operator template typename class friend private " +
|
||||
"this using const_cast inline public throw virtual delete mutable protected " +
|
||||
"wchar_t"),
|
||||
blockKeywords: words("catch class do else finally for if struct switch try while"),
|
||||
atoms: words("true false null"),
|
||||
hooks: {"#": cppHook}
|
||||
});
|
||||
CodeMirror.defineMIME("text/x-java", {
|
||||
name: "clike",
|
||||
keywords: words("abstract assert boolean break byte case catch char class const continue default " +
|
||||
"do double else enum extends final finally float for goto if implements import " +
|
||||
"instanceof int interface long native new package private protected public " +
|
||||
"return short static strictfp super switch synchronized this throw throws transient " +
|
||||
"try void volatile while"),
|
||||
blockKeywords: words("catch class do else finally for if switch try while"),
|
||||
atoms: words("true false null"),
|
||||
hooks: {
|
||||
"@": function(stream) {
|
||||
stream.eatWhile(/[\w\$_]/);
|
||||
return "meta";
|
||||
}
|
||||
}
|
||||
});
|
||||
CodeMirror.defineMIME("text/x-csharp", {
|
||||
name: "clike",
|
||||
keywords: words("abstract as base break case catch checked class const continue" +
|
||||
" default delegate do else enum event explicit extern finally fixed for" +
|
||||
" foreach goto if implicit in interface internal is lock namespace new" +
|
||||
" operator out override params private protected public readonly ref return sealed" +
|
||||
" sizeof stackalloc static struct switch this throw try typeof unchecked" +
|
||||
" unsafe using virtual void volatile while add alias ascending descending dynamic from get" +
|
||||
" global group into join let orderby partial remove select set value var yield"),
|
||||
blockKeywords: words("catch class do else finally for foreach if struct switch try while"),
|
||||
builtin: words("Boolean Byte Char DateTime DateTimeOffset Decimal Double" +
|
||||
" Guid Int16 Int32 Int64 Object SByte Single String TimeSpan UInt16 UInt32" +
|
||||
" UInt64 bool byte char decimal double short int long object" +
|
||||
" sbyte float string ushort uint ulong"),
|
||||
atoms: words("true false null"),
|
||||
hooks: {
|
||||
"@": function(stream, state) {
|
||||
if (stream.eat('"')) {
|
||||
state.tokenize = tokenAtString;
|
||||
return tokenAtString(stream, state);
|
||||
}
|
||||
stream.eatWhile(/[\w\$_]/);
|
||||
return "meta";
|
||||
}
|
||||
}
|
||||
});
|
||||
CodeMirror.defineMIME("text/x-scala", {
|
||||
name: "clike",
|
||||
keywords: words(
|
||||
|
||||
/* scala */
|
||||
"abstract case catch class def do else extends false final finally for forSome if " +
|
||||
"implicit import lazy match new null object override package private protected return " +
|
||||
"sealed super this throw trait try trye type val var while with yield _ : = => <- <: " +
|
||||
"<% >: # @ " +
|
||||
|
||||
/* package scala */
|
||||
"assert assume require print println printf readLine readBoolean readByte readShort " +
|
||||
"readChar readInt readLong readFloat readDouble " +
|
||||
|
||||
"AnyVal App Application Array BufferedIterator BigDecimal BigInt Char Console Either " +
|
||||
"Enumeration Equiv Error Exception Fractional Function IndexedSeq Integral Iterable " +
|
||||
"Iterator List Map Numeric Nil NotNull Option Ordered Ordering PartialFunction PartialOrdering " +
|
||||
"Product Proxy Range Responder Seq Serializable Set Specializable Stream StringBuilder " +
|
||||
"StringContext Symbol Throwable Traversable TraversableOnce Tuple Unit Vector :: #:: " +
|
||||
|
||||
/* package java.lang */
|
||||
"Boolean Byte Character CharSequence Class ClassLoader Cloneable Comparable " +
|
||||
"Compiler Double Exception Float Integer Long Math Number Object Package Pair Process " +
|
||||
"Runtime Runnable SecurityManager Short StackTraceElement StrictMath String " +
|
||||
"StringBuffer System Thread ThreadGroup ThreadLocal Throwable Triple Void"
|
||||
|
||||
|
||||
),
|
||||
blockKeywords: words("catch class do else finally for forSome if match switch try while"),
|
||||
atoms: words("true false null"),
|
||||
hooks: {
|
||||
"@": function(stream) {
|
||||
stream.eatWhile(/[\w\$_]/);
|
||||
return "meta";
|
||||
}
|
||||
}
|
||||
});
|
||||
mimes(["x-shader/x-vertex", "x-shader/x-fragment"], {
|
||||
name: "clike",
|
||||
keywords: words("float int bool void " +
|
||||
"vec2 vec3 vec4 ivec2 ivec3 ivec4 bvec2 bvec3 bvec4 " +
|
||||
"mat2 mat3 mat4 " +
|
||||
"sampler1D sampler2D sampler3D samplerCube " +
|
||||
"sampler1DShadow sampler2DShadow" +
|
||||
"const attribute uniform varying " +
|
||||
"break continue discard return " +
|
||||
"for while do if else struct " +
|
||||
"in out inout"),
|
||||
blockKeywords: words("for while do if else struct"),
|
||||
builtin: words("radians degrees sin cos tan asin acos atan " +
|
||||
"pow exp log exp2 sqrt inversesqrt " +
|
||||
"abs sign floor ceil fract mod min max clamp mix step smootstep " +
|
||||
"length distance dot cross normalize ftransform faceforward " +
|
||||
"reflect refract matrixCompMult " +
|
||||
"lessThan lessThanEqual greaterThan greaterThanEqual " +
|
||||
"equal notEqual any all not " +
|
||||
"texture1D texture1DProj texture1DLod texture1DProjLod " +
|
||||
"texture2D texture2DProj texture2DLod texture2DProjLod " +
|
||||
"texture3D texture3DProj texture3DLod texture3DProjLod " +
|
||||
"textureCube textureCubeLod " +
|
||||
"shadow1D shadow2D shadow1DProj shadow2DProj " +
|
||||
"shadow1DLod shadow2DLod shadow1DProjLod shadow2DProjLod " +
|
||||
"dFdx dFdy fwidth " +
|
||||
"noise1 noise2 noise3 noise4"),
|
||||
atoms: words("true false " +
|
||||
"gl_FragColor gl_SecondaryColor gl_Normal gl_Vertex " +
|
||||
"gl_MultiTexCoord0 gl_MultiTexCoord1 gl_MultiTexCoord2 gl_MultiTexCoord3 " +
|
||||
"gl_MultiTexCoord4 gl_MultiTexCoord5 gl_MultiTexCoord6 gl_MultiTexCoord7 " +
|
||||
"gl_FogCoord " +
|
||||
"gl_Position gl_PointSize gl_ClipVertex " +
|
||||
"gl_FrontColor gl_BackColor gl_FrontSecondaryColor gl_BackSecondaryColor " +
|
||||
"gl_TexCoord gl_FogFragCoord " +
|
||||
"gl_FragCoord gl_FrontFacing " +
|
||||
"gl_FragColor gl_FragData gl_FragDepth " +
|
||||
"gl_ModelViewMatrix gl_ProjectionMatrix gl_ModelViewProjectionMatrix " +
|
||||
"gl_TextureMatrix gl_NormalMatrix gl_ModelViewMatrixInverse " +
|
||||
"gl_ProjectionMatrixInverse gl_ModelViewProjectionMatrixInverse " +
|
||||
"gl_TexureMatrixTranspose gl_ModelViewMatrixInverseTranspose " +
|
||||
"gl_ProjectionMatrixInverseTranspose " +
|
||||
"gl_ModelViewProjectionMatrixInverseTranspose " +
|
||||
"gl_TextureMatrixInverseTranspose " +
|
||||
"gl_NormalScale gl_DepthRange gl_ClipPlane " +
|
||||
"gl_Point gl_FrontMaterial gl_BackMaterial gl_LightSource gl_LightModel " +
|
||||
"gl_FrontLightModelProduct gl_BackLightModelProduct " +
|
||||
"gl_TextureColor gl_EyePlaneS gl_EyePlaneT gl_EyePlaneR gl_EyePlaneQ " +
|
||||
"gl_FogParameters " +
|
||||
"gl_MaxLights gl_MaxClipPlanes gl_MaxTextureUnits gl_MaxTextureCoords " +
|
||||
"gl_MaxVertexAttribs gl_MaxVertexUniformComponents gl_MaxVaryingFloats " +
|
||||
"gl_MaxVertexTextureImageUnits gl_MaxTextureImageUnits " +
|
||||
"gl_MaxFragmentUniformComponents gl_MaxCombineTextureImageUnits " +
|
||||
"gl_MaxDrawBuffers"),
|
||||
hooks: {"#": cppHook}
|
||||
});
|
||||
}());
|
||||
@@ -1,259 +0,0 @@
|
||||
/* BASICS */
|
||||
|
||||
.CodeMirror {
|
||||
/* Set height, width, borders, and global font properties here */
|
||||
font-family: monospace;
|
||||
height: 300px;
|
||||
}
|
||||
.CodeMirror-scroll {
|
||||
/* Set scrolling behaviour here */
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
/* PADDING */
|
||||
|
||||
.CodeMirror-lines {
|
||||
padding: 4px 0; /* Vertical padding around content */
|
||||
}
|
||||
.CodeMirror pre {
|
||||
padding: 0 4px; /* Horizontal padding of content */
|
||||
}
|
||||
|
||||
.CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
|
||||
background-color: white; /* The little square between H and V scrollbars */
|
||||
}
|
||||
|
||||
/* GUTTER */
|
||||
|
||||
.CodeMirror-gutters {
|
||||
border-right: 1px solid #ddd;
|
||||
background-color: #f7f7f7;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.CodeMirror-linenumbers {}
|
||||
.CodeMirror-linenumber {
|
||||
padding: 0 3px 0 5px;
|
||||
min-width: 20px;
|
||||
text-align: right;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
/* CURSOR */
|
||||
|
||||
.CodeMirror div.CodeMirror-cursor {
|
||||
border-left: 1px solid black;
|
||||
z-index: 3;
|
||||
}
|
||||
/* Shown when moving in bi-directional text */
|
||||
.CodeMirror div.CodeMirror-secondarycursor {
|
||||
border-left: 1px solid silver;
|
||||
}
|
||||
.CodeMirror.cm-keymap-fat-cursor div.CodeMirror-cursor {
|
||||
width: auto;
|
||||
border: 0;
|
||||
background: #7e7;
|
||||
z-index: 1;
|
||||
}
|
||||
/* Can style cursor different in overwrite (non-insert) mode */
|
||||
.CodeMirror div.CodeMirror-cursor.CodeMirror-overwrite {}
|
||||
|
||||
.cm-tab { display: inline-block; }
|
||||
|
||||
/* DEFAULT THEME */
|
||||
|
||||
.cm-s-default .cm-keyword {color: #708;}
|
||||
.cm-s-default .cm-atom {color: #219;}
|
||||
.cm-s-default .cm-number {color: #164;}
|
||||
.cm-s-default .cm-def {color: #00f;}
|
||||
.cm-s-default .cm-variable {color: black;}
|
||||
.cm-s-default .cm-variable-2 {color: #05a;}
|
||||
.cm-s-default .cm-variable-3 {color: #085;}
|
||||
.cm-s-default .cm-property {color: black;}
|
||||
.cm-s-default .cm-operator {color: black;}
|
||||
.cm-s-default .cm-comment {color: #a50;}
|
||||
.cm-s-default .cm-string {color: #a11;}
|
||||
.cm-s-default .cm-string-2 {color: #f50;}
|
||||
.cm-s-default .cm-meta {color: #555;}
|
||||
.cm-s-default .cm-error {color: #f00;}
|
||||
.cm-s-default .cm-qualifier {color: #555;}
|
||||
.cm-s-default .cm-builtin {color: #30a;}
|
||||
.cm-s-default .cm-bracket {color: #997;}
|
||||
.cm-s-default .cm-tag {color: #170;}
|
||||
.cm-s-default .cm-attribute {color: #00c;}
|
||||
.cm-s-default .cm-header {color: blue;}
|
||||
.cm-s-default .cm-quote {color: #090;}
|
||||
.cm-s-default .cm-hr {color: #999;}
|
||||
.cm-s-default .cm-link {color: #00c;}
|
||||
|
||||
.cm-negative {color: #d44;}
|
||||
.cm-positive {color: #292;}
|
||||
.cm-header, .cm-strong {font-weight: bold;}
|
||||
.cm-em {font-style: italic;}
|
||||
.cm-link {text-decoration: underline;}
|
||||
|
||||
.cm-invalidchar {color: #f00;}
|
||||
|
||||
div.CodeMirror span.CodeMirror-matchingbracket {color: #0f0;}
|
||||
div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
|
||||
.CodeMirror-activeline-background {background: #e8f2ff;}
|
||||
|
||||
/* STOP */
|
||||
|
||||
/* The rest of this file contains styles related to the mechanics of
|
||||
the editor. You probably shouldn't touch them. */
|
||||
|
||||
.CodeMirror {
|
||||
line-height: 1;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
background: white;
|
||||
color: black;
|
||||
}
|
||||
|
||||
.CodeMirror-scroll {
|
||||
/* 30px is the magic margin used to hide the element's real scrollbars */
|
||||
/* See overflow: hidden in .CodeMirror */
|
||||
margin-bottom: -30px; margin-right: -30px;
|
||||
padding-bottom: 30px; padding-right: 30px;
|
||||
height: 100%;
|
||||
outline: none; /* Prevent dragging from highlighting the element */
|
||||
position: relative;
|
||||
}
|
||||
.CodeMirror-sizer {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
/* The fake, visible scrollbars. Used to force redraw during scrolling
|
||||
before actuall scrolling happens, thus preventing shaking and
|
||||
flickering artifacts. */
|
||||
.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
|
||||
position: absolute;
|
||||
z-index: 6;
|
||||
display: none;
|
||||
}
|
||||
.CodeMirror-vscrollbar {
|
||||
right: 0; top: 0;
|
||||
overflow-x: hidden;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
.CodeMirror-hscrollbar {
|
||||
bottom: 0; left: 0;
|
||||
overflow-y: hidden;
|
||||
overflow-x: scroll;
|
||||
}
|
||||
.CodeMirror-scrollbar-filler {
|
||||
right: 0; bottom: 0;
|
||||
}
|
||||
.CodeMirror-gutter-filler {
|
||||
left: 0; bottom: 0;
|
||||
}
|
||||
|
||||
.CodeMirror-gutters {
|
||||
position: absolute; left: 0; top: 0;
|
||||
padding-bottom: 30px;
|
||||
z-index: 3;
|
||||
}
|
||||
.CodeMirror-gutter {
|
||||
white-space: normal;
|
||||
height: 100%;
|
||||
padding-bottom: 30px;
|
||||
margin-bottom: -32px;
|
||||
display: inline-block;
|
||||
/* Hack to make IE7 behave */
|
||||
*zoom:1;
|
||||
*display:inline;
|
||||
}
|
||||
.CodeMirror-gutter-elt {
|
||||
position: absolute;
|
||||
cursor: default;
|
||||
z-index: 4;
|
||||
}
|
||||
|
||||
.CodeMirror-lines {
|
||||
cursor: text;
|
||||
}
|
||||
.CodeMirror pre {
|
||||
/* Reset some styles that the rest of the page might have set */
|
||||
-moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0;
|
||||
border-width: 0;
|
||||
background: transparent;
|
||||
font-family: inherit;
|
||||
font-size: inherit;
|
||||
margin: 0;
|
||||
white-space: pre;
|
||||
word-wrap: normal;
|
||||
line-height: inherit;
|
||||
color: inherit;
|
||||
z-index: 2;
|
||||
position: relative;
|
||||
overflow: visible;
|
||||
}
|
||||
.CodeMirror-wrap pre {
|
||||
word-wrap: break-word;
|
||||
white-space: pre-wrap;
|
||||
word-break: normal;
|
||||
}
|
||||
.CodeMirror-code pre {
|
||||
border-right: 30px solid transparent;
|
||||
width: -webkit-fit-content;
|
||||
width: -moz-fit-content;
|
||||
width: fit-content;
|
||||
}
|
||||
.CodeMirror-wrap .CodeMirror-code pre {
|
||||
border-right: none;
|
||||
width: auto;
|
||||
}
|
||||
.CodeMirror-linebackground {
|
||||
position: absolute;
|
||||
left: 0; right: 0; top: 0; bottom: 0;
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
.CodeMirror-linewidget {
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.CodeMirror-widget {
|
||||
}
|
||||
|
||||
.CodeMirror-wrap .CodeMirror-scroll {
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
.CodeMirror-measure {
|
||||
position: absolute;
|
||||
width: 100%; height: 0px;
|
||||
overflow: hidden;
|
||||
visibility: hidden;
|
||||
}
|
||||
.CodeMirror-measure pre { position: static; }
|
||||
|
||||
.CodeMirror div.CodeMirror-cursor {
|
||||
position: absolute;
|
||||
visibility: hidden;
|
||||
border-right: none;
|
||||
width: 0;
|
||||
}
|
||||
.CodeMirror-focused div.CodeMirror-cursor {
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
.CodeMirror-selected { background: #d9d9d9; }
|
||||
.CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; }
|
||||
|
||||
.cm-searching {
|
||||
background: #ffa;
|
||||
background: rgba(255, 255, 0, .4);
|
||||
}
|
||||
|
||||
/* IE7 hack to prevent it from returning funny offsetTops on the spans */
|
||||
.CodeMirror span { *vertical-align: text-bottom; }
|
||||
|
||||
@media print {
|
||||
/* Hide the cursor when printing */
|
||||
.CodeMirror div.CodeMirror-cursor {
|
||||
visibility: hidden;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,480 +0,0 @@
|
||||
// TODO actually recognize syntax of TypeScript constructs
|
||||
|
||||
CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||
var indentUnit = config.indentUnit;
|
||||
var statementIndent = parserConfig.statementIndent;
|
||||
var jsonMode = parserConfig.json;
|
||||
var isTS = parserConfig.typescript;
|
||||
|
||||
// Tokenizer
|
||||
|
||||
var keywords = function(){
|
||||
function kw(type) {return {type: type, style: "keyword"};}
|
||||
var A = kw("keyword a"), B = kw("keyword b"), C = kw("keyword c");
|
||||
var operator = kw("operator"), atom = {type: "atom", style: "atom"};
|
||||
|
||||
var jsKeywords = {
|
||||
"if": kw("if"), "while": A, "with": A, "else": B, "do": B, "try": B, "finally": B,
|
||||
"return": C, "break": C, "continue": C, "new": C, "delete": C, "throw": C,
|
||||
"var": kw("var"), "const": kw("var"), "let": kw("var"),
|
||||
"function": kw("function"), "catch": kw("catch"),
|
||||
"for": kw("for"), "switch": kw("switch"), "case": kw("case"), "default": kw("default"),
|
||||
"in": operator, "typeof": operator, "instanceof": operator,
|
||||
"true": atom, "false": atom, "null": atom, "undefined": atom, "NaN": atom, "Infinity": atom,
|
||||
"this": kw("this")
|
||||
};
|
||||
|
||||
// Extend the 'normal' keywords with the TypeScript language extensions
|
||||
if (isTS) {
|
||||
var type = {type: "variable", style: "variable-3"};
|
||||
var tsKeywords = {
|
||||
// object-like things
|
||||
"interface": kw("interface"),
|
||||
"class": kw("class"),
|
||||
"extends": kw("extends"),
|
||||
"constructor": kw("constructor"),
|
||||
|
||||
// scope modifiers
|
||||
"public": kw("public"),
|
||||
"private": kw("private"),
|
||||
"protected": kw("protected"),
|
||||
"static": kw("static"),
|
||||
|
||||
"super": kw("super"),
|
||||
|
||||
// types
|
||||
"string": type, "number": type, "bool": type, "any": type
|
||||
};
|
||||
|
||||
for (var attr in tsKeywords) {
|
||||
jsKeywords[attr] = tsKeywords[attr];
|
||||
}
|
||||
}
|
||||
|
||||
return jsKeywords;
|
||||
}();
|
||||
|
||||
var isOperatorChar = /[+\-*&%=<>!?|~^]/;
|
||||
|
||||
function chain(stream, state, f) {
|
||||
state.tokenize = f;
|
||||
return f(stream, state);
|
||||
}
|
||||
|
||||
function nextUntilUnescaped(stream, end) {
|
||||
var escaped = false, next;
|
||||
while ((next = stream.next()) != null) {
|
||||
if (next == end && !escaped)
|
||||
return false;
|
||||
escaped = !escaped && next == "\\";
|
||||
}
|
||||
return escaped;
|
||||
}
|
||||
|
||||
// Used as scratch variables to communicate multiple values without
|
||||
// consing up tons of objects.
|
||||
var type, content;
|
||||
function ret(tp, style, cont) {
|
||||
type = tp; content = cont;
|
||||
return style;
|
||||
}
|
||||
function jsTokenBase(stream, state) {
|
||||
var ch = stream.next();
|
||||
if (ch == '"' || ch == "'")
|
||||
return chain(stream, state, jsTokenString(ch));
|
||||
else if (ch == "." && stream.match(/^\d+(?:[eE][+\-]?\d+)?/))
|
||||
return ret("number", "number");
|
||||
else if (/[\[\]{}\(\),;\:\.]/.test(ch))
|
||||
return ret(ch);
|
||||
else if (ch == "0" && stream.eat(/x/i)) {
|
||||
stream.eatWhile(/[\da-f]/i);
|
||||
return ret("number", "number");
|
||||
}
|
||||
else if (/\d/.test(ch)) {
|
||||
stream.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/);
|
||||
return ret("number", "number");
|
||||
}
|
||||
else if (ch == "/") {
|
||||
if (stream.eat("*")) {
|
||||
return chain(stream, state, jsTokenComment);
|
||||
}
|
||||
else if (stream.eat("/")) {
|
||||
stream.skipToEnd();
|
||||
return ret("comment", "comment");
|
||||
}
|
||||
else if (state.lastType == "operator" || state.lastType == "keyword c" ||
|
||||
/^[\[{}\(,;:]$/.test(state.lastType)) {
|
||||
nextUntilUnescaped(stream, "/");
|
||||
stream.eatWhile(/[gimy]/); // 'y' is "sticky" option in Mozilla
|
||||
return ret("regexp", "string-2");
|
||||
}
|
||||
else {
|
||||
stream.eatWhile(isOperatorChar);
|
||||
return ret("operator", null, stream.current());
|
||||
}
|
||||
}
|
||||
else if (ch == "#") {
|
||||
stream.skipToEnd();
|
||||
return ret("error", "error");
|
||||
}
|
||||
else if (isOperatorChar.test(ch)) {
|
||||
stream.eatWhile(isOperatorChar);
|
||||
return ret("operator", null, stream.current());
|
||||
}
|
||||
else {
|
||||
stream.eatWhile(/[\w\$_]/);
|
||||
var word = stream.current(), known = keywords.propertyIsEnumerable(word) && keywords[word];
|
||||
return (known && state.lastType != ".") ? ret(known.type, known.style, word) :
|
||||
ret("variable", "variable", word);
|
||||
}
|
||||
}
|
||||
|
||||
function jsTokenString(quote) {
|
||||
return function(stream, state) {
|
||||
if (!nextUntilUnescaped(stream, quote))
|
||||
state.tokenize = jsTokenBase;
|
||||
return ret("string", "string");
|
||||
};
|
||||
}
|
||||
|
||||
function jsTokenComment(stream, state) {
|
||||
var maybeEnd = false, ch;
|
||||
while (ch = stream.next()) {
|
||||
if (ch == "/" && maybeEnd) {
|
||||
state.tokenize = jsTokenBase;
|
||||
break;
|
||||
}
|
||||
maybeEnd = (ch == "*");
|
||||
}
|
||||
return ret("comment", "comment");
|
||||
}
|
||||
|
||||
// Parser
|
||||
|
||||
var atomicTypes = {"atom": true, "number": true, "variable": true, "string": true, "regexp": true, "this": true};
|
||||
|
||||
function JSLexical(indented, column, type, align, prev, info) {
|
||||
this.indented = indented;
|
||||
this.column = column;
|
||||
this.type = type;
|
||||
this.prev = prev;
|
||||
this.info = info;
|
||||
if (align != null) this.align = align;
|
||||
}
|
||||
|
||||
function inScope(state, varname) {
|
||||
for (var v = state.localVars; v; v = v.next)
|
||||
if (v.name == varname) return true;
|
||||
}
|
||||
|
||||
function parseJS(state, style, type, content, stream) {
|
||||
var cc = state.cc;
|
||||
// Communicate our context to the combinators.
|
||||
// (Less wasteful than consing up a hundred closures on every call.)
|
||||
cx.state = state; cx.stream = stream; cx.marked = null, cx.cc = cc;
|
||||
|
||||
if (!state.lexical.hasOwnProperty("align"))
|
||||
state.lexical.align = true;
|
||||
|
||||
while(true) {
|
||||
var combinator = cc.length ? cc.pop() : jsonMode ? expression : statement;
|
||||
if (combinator(type, content)) {
|
||||
while(cc.length && cc[cc.length - 1].lex)
|
||||
cc.pop()();
|
||||
if (cx.marked) return cx.marked;
|
||||
if (type == "variable" && inScope(state, content)) return "variable-2";
|
||||
return style;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Combinator utils
|
||||
|
||||
var cx = {state: null, column: null, marked: null, cc: null};
|
||||
function pass() {
|
||||
for (var i = arguments.length - 1; i >= 0; i--) cx.cc.push(arguments[i]);
|
||||
}
|
||||
function cont() {
|
||||
pass.apply(null, arguments);
|
||||
return true;
|
||||
}
|
||||
function register(varname) {
|
||||
function inList(list) {
|
||||
for (var v = list; v; v = v.next)
|
||||
if (v.name == varname) return true;
|
||||
return false;
|
||||
}
|
||||
var state = cx.state;
|
||||
if (state.context) {
|
||||
cx.marked = "def";
|
||||
if (inList(state.localVars)) return;
|
||||
state.localVars = {name: varname, next: state.localVars};
|
||||
} else {
|
||||
if (inList(state.globalVars)) return;
|
||||
state.globalVars = {name: varname, next: state.globalVars};
|
||||
}
|
||||
}
|
||||
|
||||
// Combinators
|
||||
|
||||
var defaultVars = {name: "this", next: {name: "arguments"}};
|
||||
function pushcontext() {
|
||||
cx.state.context = {prev: cx.state.context, vars: cx.state.localVars};
|
||||
cx.state.localVars = defaultVars;
|
||||
}
|
||||
function popcontext() {
|
||||
cx.state.localVars = cx.state.context.vars;
|
||||
cx.state.context = cx.state.context.prev;
|
||||
}
|
||||
function pushlex(type, info) {
|
||||
var result = function() {
|
||||
var state = cx.state, indent = state.indented;
|
||||
if (state.lexical.type == "stat") indent = state.lexical.indented;
|
||||
state.lexical = new JSLexical(indent, cx.stream.column(), type, null, state.lexical, info);
|
||||
};
|
||||
result.lex = true;
|
||||
return result;
|
||||
}
|
||||
function poplex() {
|
||||
var state = cx.state;
|
||||
if (state.lexical.prev) {
|
||||
if (state.lexical.type == ")")
|
||||
state.indented = state.lexical.indented;
|
||||
state.lexical = state.lexical.prev;
|
||||
}
|
||||
}
|
||||
poplex.lex = true;
|
||||
|
||||
function expect(wanted) {
|
||||
return function(type) {
|
||||
if (type == wanted) return cont();
|
||||
else if (wanted == ";") return pass();
|
||||
else return cont(arguments.callee);
|
||||
};
|
||||
}
|
||||
|
||||
function statement(type) {
|
||||
if (type == "var") return cont(pushlex("vardef"), vardef1, expect(";"), poplex);
|
||||
if (type == "keyword a") return cont(pushlex("form"), expression, statement, poplex);
|
||||
if (type == "keyword b") return cont(pushlex("form"), statement, poplex);
|
||||
if (type == "{") return cont(pushlex("}"), block, poplex);
|
||||
if (type == ";") return cont();
|
||||
if (type == "if") return cont(pushlex("form"), expression, statement, poplex, maybeelse);
|
||||
if (type == "function") return cont(functiondef);
|
||||
if (type == "for") return cont(pushlex("form"), expect("("), pushlex(")"), forspec1, expect(")"),
|
||||
poplex, statement, poplex);
|
||||
if (type == "variable") return cont(pushlex("stat"), maybelabel);
|
||||
if (type == "switch") return cont(pushlex("form"), expression, pushlex("}", "switch"), expect("{"),
|
||||
block, poplex, poplex);
|
||||
if (type == "case") return cont(expression, expect(":"));
|
||||
if (type == "default") return cont(expect(":"));
|
||||
if (type == "catch") return cont(pushlex("form"), pushcontext, expect("("), funarg, expect(")"),
|
||||
statement, poplex, popcontext);
|
||||
return pass(pushlex("stat"), expression, expect(";"), poplex);
|
||||
}
|
||||
function expression(type) {
|
||||
return expressionInner(type, false);
|
||||
}
|
||||
function expressionNoComma(type) {
|
||||
return expressionInner(type, true);
|
||||
}
|
||||
function expressionInner(type, noComma) {
|
||||
var maybeop = noComma ? maybeoperatorNoComma : maybeoperatorComma;
|
||||
if (atomicTypes.hasOwnProperty(type)) return cont(maybeop);
|
||||
if (type == "function") return cont(functiondef);
|
||||
if (type == "keyword c") return cont(noComma ? maybeexpressionNoComma : maybeexpression);
|
||||
if (type == "(") return cont(pushlex(")"), maybeexpression, expect(")"), poplex, maybeop);
|
||||
if (type == "operator") return cont(noComma ? expressionNoComma : expression);
|
||||
if (type == "[") return cont(pushlex("]"), commasep(expressionNoComma, "]"), poplex, maybeop);
|
||||
if (type == "{") return cont(pushlex("}"), commasep(objprop, "}"), poplex, maybeop);
|
||||
return cont();
|
||||
}
|
||||
function maybeexpression(type) {
|
||||
if (type.match(/[;\}\)\],]/)) return pass();
|
||||
return pass(expression);
|
||||
}
|
||||
function maybeexpressionNoComma(type) {
|
||||
if (type.match(/[;\}\)\],]/)) return pass();
|
||||
return pass(expressionNoComma);
|
||||
}
|
||||
|
||||
function maybeoperatorComma(type, value) {
|
||||
if (type == ",") return cont(expression);
|
||||
return maybeoperatorNoComma(type, value, false);
|
||||
}
|
||||
function maybeoperatorNoComma(type, value, noComma) {
|
||||
var me = noComma == false ? maybeoperatorComma : maybeoperatorNoComma;
|
||||
var expr = noComma == false ? expression : expressionNoComma;
|
||||
if (type == "operator") {
|
||||
if (/\+\+|--/.test(value)) return cont(me);
|
||||
if (value == "?") return cont(expression, expect(":"), expr);
|
||||
return cont(expr);
|
||||
}
|
||||
if (type == ";") return;
|
||||
if (type == "(") return cont(pushlex(")", "call"), commasep(expressionNoComma, ")"), poplex, me);
|
||||
if (type == ".") return cont(property, me);
|
||||
if (type == "[") return cont(pushlex("]"), maybeexpression, expect("]"), poplex, me);
|
||||
}
|
||||
function maybelabel(type) {
|
||||
if (type == ":") return cont(poplex, statement);
|
||||
return pass(maybeoperatorComma, expect(";"), poplex);
|
||||
}
|
||||
function property(type) {
|
||||
if (type == "variable") {cx.marked = "property"; return cont();}
|
||||
}
|
||||
function objprop(type, value) {
|
||||
if (type == "variable") {
|
||||
cx.marked = "property";
|
||||
if (value == "get" || value == "set") return cont(getterSetter);
|
||||
} else if (type == "number" || type == "string") {
|
||||
cx.marked = type + " property";
|
||||
}
|
||||
if (atomicTypes.hasOwnProperty(type)) return cont(expect(":"), expressionNoComma);
|
||||
}
|
||||
function getterSetter(type) {
|
||||
if (type == ":") return cont(expression);
|
||||
if (type != "variable") return cont(expect(":"), expression);
|
||||
cx.marked = "property";
|
||||
return cont(functiondef);
|
||||
}
|
||||
function commasep(what, end) {
|
||||
function proceed(type) {
|
||||
if (type == ",") {
|
||||
var lex = cx.state.lexical;
|
||||
if (lex.info == "call") lex.pos = (lex.pos || 0) + 1;
|
||||
return cont(what, proceed);
|
||||
}
|
||||
if (type == end) return cont();
|
||||
return cont(expect(end));
|
||||
}
|
||||
return function(type) {
|
||||
if (type == end) return cont();
|
||||
else return pass(what, proceed);
|
||||
};
|
||||
}
|
||||
function block(type) {
|
||||
if (type == "}") return cont();
|
||||
return pass(statement, block);
|
||||
}
|
||||
function maybetype(type) {
|
||||
if (type == ":") return cont(typedef);
|
||||
return pass();
|
||||
}
|
||||
function typedef(type) {
|
||||
if (type == "variable"){cx.marked = "variable-3"; return cont();}
|
||||
return pass();
|
||||
}
|
||||
function vardef1(type, value) {
|
||||
if (type == "variable") {
|
||||
register(value);
|
||||
return isTS ? cont(maybetype, vardef2) : cont(vardef2);
|
||||
}
|
||||
return pass();
|
||||
}
|
||||
function vardef2(type, value) {
|
||||
if (value == "=") return cont(expressionNoComma, vardef2);
|
||||
if (type == ",") return cont(vardef1);
|
||||
}
|
||||
function maybeelse(type, value) {
|
||||
if (type == "keyword b" && value == "else") return cont(pushlex("form"), statement, poplex);
|
||||
}
|
||||
function forspec1(type) {
|
||||
if (type == "var") return cont(vardef1, expect(";"), forspec2);
|
||||
if (type == ";") return cont(forspec2);
|
||||
if (type == "variable") return cont(formaybein);
|
||||
return pass(expression, expect(";"), forspec2);
|
||||
}
|
||||
function formaybein(_type, value) {
|
||||
if (value == "in") return cont(expression);
|
||||
return cont(maybeoperatorComma, forspec2);
|
||||
}
|
||||
function forspec2(type, value) {
|
||||
if (type == ";") return cont(forspec3);
|
||||
if (value == "in") return cont(expression);
|
||||
return pass(expression, expect(";"), forspec3);
|
||||
}
|
||||
function forspec3(type) {
|
||||
if (type != ")") cont(expression);
|
||||
}
|
||||
function functiondef(type, value) {
|
||||
if (type == "variable") {register(value); return cont(functiondef);}
|
||||
if (type == "(") return cont(pushlex(")"), pushcontext, commasep(funarg, ")"), poplex, statement, popcontext);
|
||||
}
|
||||
function funarg(type, value) {
|
||||
if (type == "variable") {register(value); return isTS ? cont(maybetype) : cont();}
|
||||
}
|
||||
|
||||
// Interface
|
||||
|
||||
return {
|
||||
startState: function(basecolumn) {
|
||||
return {
|
||||
tokenize: jsTokenBase,
|
||||
lastType: null,
|
||||
cc: [],
|
||||
lexical: new JSLexical((basecolumn || 0) - indentUnit, 0, "block", false),
|
||||
localVars: parserConfig.localVars,
|
||||
globalVars: parserConfig.globalVars,
|
||||
context: parserConfig.localVars && {vars: parserConfig.localVars},
|
||||
indented: 0
|
||||
};
|
||||
},
|
||||
|
||||
token: function(stream, state) {
|
||||
if (stream.sol()) {
|
||||
if (!state.lexical.hasOwnProperty("align"))
|
||||
state.lexical.align = false;
|
||||
state.indented = stream.indentation();
|
||||
}
|
||||
if (state.tokenize != jsTokenComment && stream.eatSpace()) return null;
|
||||
var style = state.tokenize(stream, state);
|
||||
if (type == "comment") return style;
|
||||
state.lastType = type == "operator" && (content == "++" || content == "--") ? "incdec" : type;
|
||||
return parseJS(state, style, type, content, stream);
|
||||
},
|
||||
|
||||
indent: function(state, textAfter) {
|
||||
if (state.tokenize == jsTokenComment) return CodeMirror.Pass;
|
||||
if (state.tokenize != jsTokenBase) return 0;
|
||||
var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical;
|
||||
// Kludge to prevent 'maybelse' from blocking lexical scope pops
|
||||
for (var i = state.cc.length - 1; i >= 0; --i) {
|
||||
var c = state.cc[i];
|
||||
if (c == poplex) lexical = lexical.prev;
|
||||
else if (c != maybeelse || /^else\b/.test(textAfter)) break;
|
||||
}
|
||||
if (lexical.type == "stat" && firstChar == "}") lexical = lexical.prev;
|
||||
if (statementIndent && lexical.type == ")" && lexical.prev.type == "stat")
|
||||
lexical = lexical.prev;
|
||||
var type = lexical.type, closing = firstChar == type;
|
||||
|
||||
if (type == "vardef") return lexical.indented + (state.lastType == "operator" || state.lastType == "," ? 4 : 0);
|
||||
else if (type == "form" && firstChar == "{") return lexical.indented;
|
||||
else if (type == "form") return lexical.indented + indentUnit;
|
||||
else if (type == "stat")
|
||||
return lexical.indented + (state.lastType == "operator" || state.lastType == "," ? statementIndent || indentUnit : 0);
|
||||
else if (lexical.info == "switch" && !closing && parserConfig.doubleIndentSwitch != false)
|
||||
return lexical.indented + (/^(?:case|default)\b/.test(textAfter) ? indentUnit : 2 * indentUnit);
|
||||
else if (lexical.align) return lexical.column + (closing ? 0 : 1);
|
||||
else return lexical.indented + (closing ? 0 : indentUnit);
|
||||
},
|
||||
|
||||
electricChars: ":{}",
|
||||
blockCommentStart: jsonMode ? null : "/*",
|
||||
blockCommentEnd: jsonMode ? null : "*/",
|
||||
lineComment: jsonMode ? null : "//",
|
||||
fold: "brace",
|
||||
|
||||
helperType: jsonMode ? "json" : "javascript",
|
||||
jsonMode: jsonMode
|
||||
};
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME("text/javascript", "javascript");
|
||||
CodeMirror.defineMIME("text/ecmascript", "javascript");
|
||||
CodeMirror.defineMIME("application/javascript", "javascript");
|
||||
CodeMirror.defineMIME("application/ecmascript", "javascript");
|
||||
CodeMirror.defineMIME("application/json", {name: "javascript", json: true});
|
||||
CodeMirror.defineMIME("application/x-json", {name: "javascript", json: true});
|
||||
CodeMirror.defineMIME("text/typescript", { name: "javascript", typescript: true });
|
||||
CodeMirror.defineMIME("application/typescript", { name: "javascript", typescript: true });
|
||||
File diff suppressed because one or more lines are too long
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
|
||||
Name: 3024 day
|
||||
Author: Jan T. Sott (http://github.com/idleberg)
|
||||
|
||||
CodeMirror template by Jan T. Sott (https://github.com/idleberg/base16-codemirror)
|
||||
Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16)
|
||||
|
||||
*/
|
||||
|
||||
.cm-s-3024-day.CodeMirror {background: #f7f7f7; color: #3a3432;}
|
||||
.cm-s-3024-day div.CodeMirror-selected {background: #d6d5d4 !important;}
|
||||
.cm-s-3024-day .CodeMirror-gutters {background: #f7f7f7; border-right: 0px;}
|
||||
.cm-s-3024-day .CodeMirror-linenumber {color: #807d7c;}
|
||||
.cm-s-3024-day .CodeMirror-cursor {border-left: 1px solid #5c5855 !important;}
|
||||
|
||||
.cm-s-3024-day span.cm-comment {color: #cdab53;}
|
||||
.cm-s-3024-day span.cm-atom {color: #a16a94;}
|
||||
.cm-s-3024-day span.cm-number {color: #a16a94;}
|
||||
|
||||
.cm-s-3024-day span.cm-property, .cm-s-3024-day span.cm-attribute {color: #01a252;}
|
||||
.cm-s-3024-day span.cm-keyword {color: #db2d20;}
|
||||
.cm-s-3024-day span.cm-string {color: #fded02;}
|
||||
|
||||
.cm-s-3024-day span.cm-variable {color: #01a252;}
|
||||
.cm-s-3024-day span.cm-variable-2 {color: #01a0e4;}
|
||||
.cm-s-3024-day span.cm-def {color: #e8bbd0;}
|
||||
.cm-s-3024-day span.cm-error {background: #db2d20; color: #5c5855;}
|
||||
.cm-s-3024-day span.cm-bracket {color: #3a3432;}
|
||||
.cm-s-3024-day span.cm-tag {color: #db2d20;}
|
||||
.cm-s-3024-day span.cm-link {color: #a16a94;}
|
||||
|
||||
.cm-s-3024-day .CodeMirror-activeline-background {background: #e8f2ff !important;}
|
||||
.cm-s-3024-day .CodeMirror-matchingbracket { text-decoration: underline; color: white !important;}
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
|
||||
Name: 3024 night
|
||||
Author: Jan T. Sott (http://github.com/idleberg)
|
||||
|
||||
CodeMirror template by Jan T. Sott (https://github.com/idleberg/base16-codemirror)
|
||||
Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16)
|
||||
|
||||
*/
|
||||
|
||||
.cm-s-3024-night.CodeMirror {background: #090300; color: #d6d5d4;}
|
||||
.cm-s-3024-night div.CodeMirror-selected {background: #3a3432 !important;}
|
||||
.cm-s-3024-night .CodeMirror-gutters {background: #090300; border-right: 0px;}
|
||||
.cm-s-3024-night .CodeMirror-linenumber {color: #5c5855;}
|
||||
.cm-s-3024-night .CodeMirror-cursor {border-left: 1px solid #807d7c !important;}
|
||||
|
||||
.cm-s-3024-night span.cm-comment {color: #cdab53;}
|
||||
.cm-s-3024-night span.cm-atom {color: #a16a94;}
|
||||
.cm-s-3024-night span.cm-number {color: #a16a94;}
|
||||
|
||||
.cm-s-3024-night span.cm-property, .cm-s-3024-night span.cm-attribute {color: #01a252;}
|
||||
.cm-s-3024-night span.cm-keyword {color: #db2d20;}
|
||||
.cm-s-3024-night span.cm-string {color: #fded02;}
|
||||
|
||||
.cm-s-3024-night span.cm-variable {color: #01a252;}
|
||||
.cm-s-3024-night span.cm-variable-2 {color: #01a0e4;}
|
||||
.cm-s-3024-night span.cm-def {color: #e8bbd0;}
|
||||
.cm-s-3024-night span.cm-error {background: #db2d20; color: #807d7c;}
|
||||
.cm-s-3024-night span.cm-bracket {color: #d6d5d4;}
|
||||
.cm-s-3024-night span.cm-tag {color: #db2d20;}
|
||||
.cm-s-3024-night span.cm-link {color: #a16a94;}
|
||||
|
||||
.cm-s-3024-night .CodeMirror-activeline-background {background: #2F2F2F !important;}
|
||||
.cm-s-3024-night .CodeMirror-matchingbracket { text-decoration: underline; color: white !important;}
|
||||
@@ -1,5 +0,0 @@
|
||||
.cm-s-ambiance.CodeMirror {
|
||||
-webkit-box-shadow: none;
|
||||
-moz-box-shadow: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
|
||||
Name: Base16 Default Dark
|
||||
Author: Chris Kempson (http://chriskempson.com)
|
||||
|
||||
CodeMirror template by Jan T. Sott (https://github.com/idleberg/base16-chrome-devtools)
|
||||
Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16)
|
||||
|
||||
*/
|
||||
|
||||
.cm-s-base16-dark.CodeMirror {background: #151515; color: #e0e0e0;}
|
||||
.cm-s-base16-dark div.CodeMirror-selected {background: #202020 !important;}
|
||||
.cm-s-base16-dark .CodeMirror-gutters {background: #151515; border-right: 0px;}
|
||||
.cm-s-base16-dark .CodeMirror-linenumber {color: #505050;}
|
||||
.cm-s-base16-dark .CodeMirror-cursor {border-left: 1px solid #b0b0b0 !important;}
|
||||
|
||||
.cm-s-base16-dark span.cm-comment {color: #8f5536;}
|
||||
.cm-s-base16-dark span.cm-atom {color: #aa759f;}
|
||||
.cm-s-base16-dark span.cm-number {color: #aa759f;}
|
||||
|
||||
.cm-s-base16-dark span.cm-property, .cm-s-base16-dark span.cm-attribute {color: #90a959;}
|
||||
.cm-s-base16-dark span.cm-keyword {color: #ac4142;}
|
||||
.cm-s-base16-dark span.cm-string {color: #f4bf75;}
|
||||
|
||||
.cm-s-base16-dark span.cm-variable {color: #90a959;}
|
||||
.cm-s-base16-dark span.cm-variable-2 {color: #6a9fb5;}
|
||||
.cm-s-base16-dark span.cm-def {color: #d28445;}
|
||||
.cm-s-base16-dark span.cm-error {background: #ac4142; color: #b0b0b0;}
|
||||
.cm-s-base16-dark span.cm-bracket {color: #e0e0e0;}
|
||||
.cm-s-base16-dark span.cm-tag {color: #ac4142;}
|
||||
.cm-s-base16-dark span.cm-link {color: #aa759f;}
|
||||
|
||||
.cm-s-base16-dark .CodeMirror-activeline-background {background: #2F2F2F !important;}
|
||||
.cm-s-base16-dark .CodeMirror-matchingbracket { text-decoration: underline; color: white !important;}
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
|
||||
Name: Base16 Default Light
|
||||
Author: Chris Kempson (http://chriskempson.com)
|
||||
|
||||
CodeMirror template by Jan T. Sott (https://github.com/idleberg/base16-chrome-devtools)
|
||||
Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16)
|
||||
|
||||
*/
|
||||
|
||||
.cm-s-base16-light.CodeMirror {background: #f5f5f5; color: #202020;}
|
||||
.cm-s-base16-light div.CodeMirror-selected {background: #e0e0e0 !important;}
|
||||
.cm-s-base16-light .CodeMirror-gutters {background: #f5f5f5; border-right: 0px;}
|
||||
.cm-s-base16-light .CodeMirror-linenumber {color: #b0b0b0;}
|
||||
.cm-s-base16-light .CodeMirror-cursor {border-left: 1px solid #505050 !important;}
|
||||
|
||||
.cm-s-base16-light span.cm-comment {color: #8f5536;}
|
||||
.cm-s-base16-light span.cm-atom {color: #aa759f;}
|
||||
.cm-s-base16-light span.cm-number {color: #aa759f;}
|
||||
|
||||
.cm-s-base16-light span.cm-property, .cm-s-base16-light span.cm-attribute {color: #90a959;}
|
||||
.cm-s-base16-light span.cm-keyword {color: #ac4142;}
|
||||
.cm-s-base16-light span.cm-string {color: #f4bf75;}
|
||||
|
||||
.cm-s-base16-light span.cm-variable {color: #90a959;}
|
||||
.cm-s-base16-light span.cm-variable-2 {color: #6a9fb5;}
|
||||
.cm-s-base16-light span.cm-def {color: #d28445;}
|
||||
.cm-s-base16-light span.cm-error {background: #ac4142; color: #505050;}
|
||||
.cm-s-base16-light span.cm-bracket {color: #202020;}
|
||||
.cm-s-base16-light span.cm-tag {color: #ac4142;}
|
||||
.cm-s-base16-light span.cm-link {color: #aa759f;}
|
||||
|
||||
.cm-s-base16-light .CodeMirror-activeline-background {background: #DDDCDC !important;}
|
||||
.cm-s-base16-light .CodeMirror-matchingbracket { text-decoration: underline; color: white !important;}
|
||||
@@ -1,28 +0,0 @@
|
||||
/* Port of TextMate's Blackboard theme */
|
||||
|
||||
.cm-s-blackboard.CodeMirror { background: #0C1021; color: #F8F8F8; }
|
||||
.cm-s-blackboard .CodeMirror-selected { background: #253B76 !important; }
|
||||
.cm-s-blackboard .CodeMirror-gutters { background: #0C1021; border-right: 0; }
|
||||
.cm-s-blackboard .CodeMirror-linenumber { color: #888; }
|
||||
.cm-s-blackboard .CodeMirror-cursor { border-left: 1px solid #A7A7A7 !important; }
|
||||
|
||||
.cm-s-blackboard .cm-keyword { color: #FBDE2D; }
|
||||
.cm-s-blackboard .cm-atom { color: #D8FA3C; }
|
||||
.cm-s-blackboard .cm-number { color: #D8FA3C; }
|
||||
.cm-s-blackboard .cm-def { color: #8DA6CE; }
|
||||
.cm-s-blackboard .cm-variable { color: #FF6400; }
|
||||
.cm-s-blackboard .cm-operator { color: #FBDE2D;}
|
||||
.cm-s-blackboard .cm-comment { color: #AEAEAE; }
|
||||
.cm-s-blackboard .cm-string { color: #61CE3C; }
|
||||
.cm-s-blackboard .cm-string-2 { color: #61CE3C; }
|
||||
.cm-s-blackboard .cm-meta { color: #D8FA3C; }
|
||||
.cm-s-blackboard .cm-error { background: #9D1E15; color: #F8F8F8; }
|
||||
.cm-s-blackboard .cm-builtin { color: #8DA6CE; }
|
||||
.cm-s-blackboard .cm-tag { color: #8DA6CE; }
|
||||
.cm-s-blackboard .cm-attribute { color: #8DA6CE; }
|
||||
.cm-s-blackboard .cm-header { color: #FF6400; }
|
||||
.cm-s-blackboard .cm-hr { color: #AEAEAE; }
|
||||
.cm-s-blackboard .cm-link { color: #8DA6CE; }
|
||||
|
||||
.cm-s-blackboard .CodeMirror-activeline-background {background: #3C3636 !important;}
|
||||
.cm-s-blackboard .CodeMirror-matchingbracket {outline:1px solid grey;color:white !important}
|
||||
@@ -1,21 +0,0 @@
|
||||
.cm-s-cobalt.CodeMirror { background: #002240; color: white; }
|
||||
.cm-s-cobalt div.CodeMirror-selected { background: #b36539 !important; }
|
||||
.cm-s-cobalt .CodeMirror-gutters { background: #002240; border-right: 1px solid #aaa; }
|
||||
.cm-s-cobalt .CodeMirror-linenumber { color: #d0d0d0; }
|
||||
.cm-s-cobalt .CodeMirror-cursor { border-left: 1px solid white !important; }
|
||||
|
||||
.cm-s-cobalt span.cm-comment { color: #08f; }
|
||||
.cm-s-cobalt span.cm-atom { color: #845dc4; }
|
||||
.cm-s-cobalt span.cm-number, .cm-s-cobalt span.cm-attribute { color: #ff80e1; }
|
||||
.cm-s-cobalt span.cm-keyword { color: #ffee80; }
|
||||
.cm-s-cobalt span.cm-string { color: #3ad900; }
|
||||
.cm-s-cobalt span.cm-meta { color: #ff9d00; }
|
||||
.cm-s-cobalt span.cm-variable-2, .cm-s-cobalt span.cm-tag { color: #9effff; }
|
||||
.cm-s-cobalt span.cm-variable-3, .cm-s-cobalt span.cm-def { color: white; }
|
||||
.cm-s-cobalt span.cm-error { color: #9d1e15; }
|
||||
.cm-s-cobalt span.cm-bracket { color: #d8d8d8; }
|
||||
.cm-s-cobalt span.cm-builtin, .cm-s-cobalt span.cm-special { color: #ff9e59; }
|
||||
.cm-s-cobalt span.cm-link { color: #845dc4; }
|
||||
|
||||
.cm-s-cobalt .CodeMirror-activeline-background {background: #002D57 !important;}
|
||||
.cm-s-cobalt .CodeMirror-matchingbracket {outline:1px solid grey;color:white !important}
|
||||
@@ -1,23 +0,0 @@
|
||||
.cm-s-eclipse span.cm-meta {color: #FF1717;}
|
||||
.cm-s-eclipse span.cm-keyword { line-height: 1em; font-weight: bold; color: #7F0055; }
|
||||
.cm-s-eclipse span.cm-atom {color: #219;}
|
||||
.cm-s-eclipse span.cm-number {color: #164;}
|
||||
.cm-s-eclipse span.cm-def {color: #00f;}
|
||||
.cm-s-eclipse span.cm-variable {color: black;}
|
||||
.cm-s-eclipse span.cm-variable-2 {color: #0000C0;}
|
||||
.cm-s-eclipse span.cm-variable-3 {color: #0000C0;}
|
||||
.cm-s-eclipse span.cm-property {color: black;}
|
||||
.cm-s-eclipse span.cm-operator {color: black;}
|
||||
.cm-s-eclipse span.cm-comment {color: #3F7F5F;}
|
||||
.cm-s-eclipse span.cm-string {color: #2A00FF;}
|
||||
.cm-s-eclipse span.cm-string-2 {color: #f50;}
|
||||
.cm-s-eclipse span.cm-error {color: #f00;}
|
||||
.cm-s-eclipse span.cm-qualifier {color: #555;}
|
||||
.cm-s-eclipse span.cm-builtin {color: #30a;}
|
||||
.cm-s-eclipse span.cm-bracket {color: #cc7;}
|
||||
.cm-s-eclipse span.cm-tag {color: #170;}
|
||||
.cm-s-eclipse span.cm-attribute {color: #00c;}
|
||||
.cm-s-eclipse span.cm-link {color: #219;}
|
||||
|
||||
.cm-s-eclipse .CodeMirror-activeline-background {background: #e8f2ff !important;}
|
||||
.cm-s-eclipse .CodeMirror-matchingbracket {outline:1px solid grey; color:black !important;}
|
||||
@@ -1,13 +0,0 @@
|
||||
.cm-s-elegant span.cm-number, .cm-s-elegant span.cm-string, .cm-s-elegant span.cm-atom {color: #762;}
|
||||
.cm-s-elegant span.cm-comment {color: #262; font-style: italic; line-height: 1em;}
|
||||
.cm-s-elegant span.cm-meta {color: #555; font-style: italic; line-height: 1em;}
|
||||
.cm-s-elegant span.cm-variable {color: black;}
|
||||
.cm-s-elegant span.cm-variable-2 {color: #b11;}
|
||||
.cm-s-elegant span.cm-qualifier {color: #555;}
|
||||
.cm-s-elegant span.cm-keyword {color: #730;}
|
||||
.cm-s-elegant span.cm-builtin {color: #30a;}
|
||||
.cm-s-elegant span.cm-error {background-color: #fdd;}
|
||||
.cm-s-elegant span.cm-link {color: #762;}
|
||||
|
||||
.cm-s-elegant .CodeMirror-activeline-background {background: #e8f2ff !important;}
|
||||
.cm-s-elegant .CodeMirror-matchingbracket {outline:1px solid grey; color:black !important;}
|
||||
@@ -1,30 +0,0 @@
|
||||
.cm-s-erlang-dark.CodeMirror { background: #002240; color: white; }
|
||||
.cm-s-erlang-dark div.CodeMirror-selected { background: #b36539 !important; }
|
||||
.cm-s-erlang-dark .CodeMirror-gutters { background: #002240; border-right: 1px solid #aaa; }
|
||||
.cm-s-erlang-dark .CodeMirror-linenumber { color: #d0d0d0; }
|
||||
.cm-s-erlang-dark .CodeMirror-cursor { border-left: 1px solid white !important; }
|
||||
|
||||
.cm-s-erlang-dark span.cm-atom { color: #f133f1; }
|
||||
.cm-s-erlang-dark span.cm-attribute { color: #ff80e1; }
|
||||
.cm-s-erlang-dark span.cm-bracket { color: #ff9d00; }
|
||||
.cm-s-erlang-dark span.cm-builtin { color: #eaa; }
|
||||
.cm-s-erlang-dark span.cm-comment { color: #77f; }
|
||||
.cm-s-erlang-dark span.cm-def { color: #e7a; }
|
||||
.cm-s-erlang-dark span.cm-error { color: #9d1e15; }
|
||||
.cm-s-erlang-dark span.cm-keyword { color: #ffee80; }
|
||||
.cm-s-erlang-dark span.cm-meta { color: #50fefe; }
|
||||
.cm-s-erlang-dark span.cm-number { color: #ffd0d0; }
|
||||
.cm-s-erlang-dark span.cm-operator { color: #d55; }
|
||||
.cm-s-erlang-dark span.cm-property { color: #ccc; }
|
||||
.cm-s-erlang-dark span.cm-qualifier { color: #ccc; }
|
||||
.cm-s-erlang-dark span.cm-quote { color: #ccc; }
|
||||
.cm-s-erlang-dark span.cm-special { color: #ffbbbb; }
|
||||
.cm-s-erlang-dark span.cm-string { color: #3ad900; }
|
||||
.cm-s-erlang-dark span.cm-string-2 { color: #ccc; }
|
||||
.cm-s-erlang-dark span.cm-tag { color: #9effff; }
|
||||
.cm-s-erlang-dark span.cm-variable { color: #50fe50; }
|
||||
.cm-s-erlang-dark span.cm-variable-2 { color: #e0e; }
|
||||
.cm-s-erlang-dark span.cm-variable-3 { color: #ccc; }
|
||||
|
||||
.cm-s-erlang-dark .CodeMirror-activeline-background {background: #013461 !important;}
|
||||
.cm-s-erlang-dark .CodeMirror-matchingbracket {outline:1px solid grey; color:white !important;}
|
||||
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
http://lesscss.org/ dark theme
|
||||
Ported to CodeMirror by Peter Kroon
|
||||
*/
|
||||
.cm-s-lesser-dark {
|
||||
line-height: 1.3em;
|
||||
}
|
||||
.cm-s-lesser-dark {
|
||||
font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', 'Monaco', Courier, monospace !important;
|
||||
}
|
||||
|
||||
.cm-s-lesser-dark.CodeMirror { background: #262626; color: #EBEFE7; text-shadow: 0 -1px 1px #262626; }
|
||||
.cm-s-lesser-dark div.CodeMirror-selected {background: #45443B !important;} /* 33322B*/
|
||||
.cm-s-lesser-dark .CodeMirror-cursor { border-left: 1px solid white !important; }
|
||||
.cm-s-lesser-dark pre { padding: 0 8px; }/*editable code holder*/
|
||||
|
||||
.cm-s-lesser-dark.CodeMirror span.CodeMirror-matchingbracket { color: #7EFC7E; }/*65FC65*/
|
||||
|
||||
.cm-s-lesser-dark .CodeMirror-gutters { background: #262626; border-right:1px solid #aaa; }
|
||||
.cm-s-lesser-dark .CodeMirror-linenumber { color: #777; }
|
||||
|
||||
.cm-s-lesser-dark span.cm-keyword { color: #599eff; }
|
||||
.cm-s-lesser-dark span.cm-atom { color: #C2B470; }
|
||||
.cm-s-lesser-dark span.cm-number { color: #B35E4D; }
|
||||
.cm-s-lesser-dark span.cm-def {color: white;}
|
||||
.cm-s-lesser-dark span.cm-variable { color:#D9BF8C; }
|
||||
.cm-s-lesser-dark span.cm-variable-2 { color: #669199; }
|
||||
.cm-s-lesser-dark span.cm-variable-3 { color: white; }
|
||||
.cm-s-lesser-dark span.cm-property {color: #92A75C;}
|
||||
.cm-s-lesser-dark span.cm-operator {color: #92A75C;}
|
||||
.cm-s-lesser-dark span.cm-comment { color: #666; }
|
||||
.cm-s-lesser-dark span.cm-string { color: #BCD279; }
|
||||
.cm-s-lesser-dark span.cm-string-2 {color: #f50;}
|
||||
.cm-s-lesser-dark span.cm-meta { color: #738C73; }
|
||||
.cm-s-lesser-dark span.cm-error { color: #9d1e15; }
|
||||
.cm-s-lesser-dark span.cm-qualifier {color: #555;}
|
||||
.cm-s-lesser-dark span.cm-builtin { color: #ff9e59; }
|
||||
.cm-s-lesser-dark span.cm-bracket { color: #EBEFE7; }
|
||||
.cm-s-lesser-dark span.cm-tag { color: #669199; }
|
||||
.cm-s-lesser-dark span.cm-attribute {color: #00c;}
|
||||
.cm-s-lesser-dark span.cm-header {color: #a0a;}
|
||||
.cm-s-lesser-dark span.cm-quote {color: #090;}
|
||||
.cm-s-lesser-dark span.cm-hr {color: #999;}
|
||||
.cm-s-lesser-dark span.cm-link {color: #00c;}
|
||||
|
||||
.cm-s-lesser-dark .CodeMirror-activeline-background {background: #3C3A3A !important;}
|
||||
.cm-s-lesser-dark .CodeMirror-matchingbracket {outline:1px solid grey; color:white !important;}
|
||||
@@ -1,43 +0,0 @@
|
||||
/* Based on the theme at http://bonsaiden.github.com/JavaScript-Garden */
|
||||
|
||||
/*<!--match-->*/
|
||||
.cm-s-midnight span.CodeMirror-matchhighlight { background: #494949 }
|
||||
.cm-s-midnight.CodeMirror-focused span.CodeMirror-matchhighlight { background: #314D67 !important; }
|
||||
|
||||
/*<!--activeline-->*/
|
||||
.cm-s-midnight .CodeMirror-activeline-background {background: #253540 !important;}
|
||||
|
||||
.cm-s-midnight.CodeMirror {
|
||||
background: #0F192A;
|
||||
color: #D1EDFF;
|
||||
}
|
||||
|
||||
.cm-s-midnight.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}
|
||||
|
||||
.cm-s-midnight div.CodeMirror-selected {background: #314D67 !important;}
|
||||
.cm-s-midnight .CodeMirror-gutters {background: #0F192A; border-right: 1px solid;}
|
||||
.cm-s-midnight .CodeMirror-linenumber {color: #D0D0D0;}
|
||||
.cm-s-midnight .CodeMirror-cursor {
|
||||
border-left: 1px solid #F8F8F0 !important;
|
||||
}
|
||||
|
||||
.cm-s-midnight span.cm-comment {color: #428BDD;}
|
||||
.cm-s-midnight span.cm-atom {color: #AE81FF;}
|
||||
.cm-s-midnight span.cm-number {color: #D1EDFF;}
|
||||
|
||||
.cm-s-midnight span.cm-property, .cm-s-midnight span.cm-attribute {color: #A6E22E;}
|
||||
.cm-s-midnight span.cm-keyword {color: #E83737;}
|
||||
.cm-s-midnight span.cm-string {color: #1DC116;}
|
||||
|
||||
.cm-s-midnight span.cm-variable {color: #FFAA3E;}
|
||||
.cm-s-midnight span.cm-variable-2 {color: #FFAA3E;}
|
||||
.cm-s-midnight span.cm-def {color: #4DD;}
|
||||
.cm-s-midnight span.cm-error {background: #F92672; color: #F8F8F0;}
|
||||
.cm-s-midnight span.cm-bracket {color: #D1EDFF;}
|
||||
.cm-s-midnight span.cm-tag {color: #449;}
|
||||
.cm-s-midnight span.cm-link {color: #AE81FF;}
|
||||
|
||||
.cm-s-midnight .CodeMirror-matchingbracket {
|
||||
text-decoration: underline;
|
||||
color: white !important;
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
/* Based on Sublime Text's Monokai theme */
|
||||
|
||||
.cm-s-monokai.CodeMirror {background: #272822; color: #f8f8f2;}
|
||||
.cm-s-monokai div.CodeMirror-selected {background: #49483E !important;}
|
||||
.cm-s-monokai .CodeMirror-gutters {background: #272822; border-right: 0px;}
|
||||
.cm-s-monokai .CodeMirror-linenumber {color: #d0d0d0;}
|
||||
.cm-s-monokai .CodeMirror-cursor {border-left: 1px solid #f8f8f0 !important;}
|
||||
|
||||
.cm-s-monokai span.cm-comment {color: #75715e;}
|
||||
.cm-s-monokai span.cm-atom {color: #ae81ff;}
|
||||
.cm-s-monokai span.cm-number {color: #ae81ff;}
|
||||
|
||||
.cm-s-monokai span.cm-property, .cm-s-monokai span.cm-attribute {color: #a6e22e;}
|
||||
.cm-s-monokai span.cm-keyword {color: #f92672;}
|
||||
.cm-s-monokai span.cm-string {color: #e6db74;}
|
||||
|
||||
.cm-s-monokai span.cm-variable {color: #a6e22e;}
|
||||
.cm-s-monokai span.cm-variable-2 {color: #9effff;}
|
||||
.cm-s-monokai span.cm-def {color: #fd971f;}
|
||||
.cm-s-monokai span.cm-error {background: #f92672; color: #f8f8f0;}
|
||||
.cm-s-monokai span.cm-bracket {color: #f8f8f2;}
|
||||
.cm-s-monokai span.cm-tag {color: #f92672;}
|
||||
.cm-s-monokai span.cm-link {color: #ae81ff;}
|
||||
|
||||
.cm-s-monokai .CodeMirror-activeline-background {background: #373831 !important;}
|
||||
.cm-s-monokai .CodeMirror-matchingbracket {
|
||||
text-decoration: underline;
|
||||
color: white !important;
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
.cm-s-neat span.cm-comment { color: #a86; }
|
||||
.cm-s-neat span.cm-keyword { line-height: 1em; font-weight: bold; color: blue; }
|
||||
.cm-s-neat span.cm-string { color: #a22; }
|
||||
.cm-s-neat span.cm-builtin { line-height: 1em; font-weight: bold; color: #077; }
|
||||
.cm-s-neat span.cm-special { line-height: 1em; font-weight: bold; color: #0aa; }
|
||||
.cm-s-neat span.cm-variable { color: black; }
|
||||
.cm-s-neat span.cm-number, .cm-s-neat span.cm-atom { color: #3a3; }
|
||||
.cm-s-neat span.cm-meta {color: #555;}
|
||||
.cm-s-neat span.cm-link { color: #3a3; }
|
||||
|
||||
.cm-s-neat .CodeMirror-activeline-background {background: #e8f2ff !important;}
|
||||
.cm-s-neat .CodeMirror-matchingbracket {outline:1px solid grey; color:black !important;}
|
||||
@@ -1,24 +0,0 @@
|
||||
/* Loosely based on the Midnight Textmate theme */
|
||||
|
||||
.cm-s-night.CodeMirror { background: #0a001f; color: #f8f8f8; }
|
||||
.cm-s-night div.CodeMirror-selected { background: #447 !important; }
|
||||
.cm-s-night .CodeMirror-gutters { background: #0a001f; border-right: 1px solid #aaa; }
|
||||
.cm-s-night .CodeMirror-linenumber { color: #f8f8f8; }
|
||||
.cm-s-night .CodeMirror-cursor { border-left: 1px solid white !important; }
|
||||
|
||||
.cm-s-night span.cm-comment { color: #6900a1; }
|
||||
.cm-s-night span.cm-atom { color: #845dc4; }
|
||||
.cm-s-night span.cm-number, .cm-s-night span.cm-attribute { color: #ffd500; }
|
||||
.cm-s-night span.cm-keyword { color: #599eff; }
|
||||
.cm-s-night span.cm-string { color: #37f14a; }
|
||||
.cm-s-night span.cm-meta { color: #7678e2; }
|
||||
.cm-s-night span.cm-variable-2, .cm-s-night span.cm-tag { color: #99b2ff; }
|
||||
.cm-s-night span.cm-variable-3, .cm-s-night span.cm-def { color: white; }
|
||||
.cm-s-night span.cm-error { color: #9d1e15; }
|
||||
.cm-s-night span.cm-bracket { color: #8da6ce; }
|
||||
.cm-s-night span.cm-comment { color: #6900a1; }
|
||||
.cm-s-night span.cm-builtin, .cm-s-night span.cm-special { color: #ff9e59; }
|
||||
.cm-s-night span.cm-link { color: #845dc4; }
|
||||
|
||||
.cm-s-night .CodeMirror-activeline-background {background: #1C005A !important;}
|
||||
.cm-s-night .CodeMirror-matchingbracket {outline:1px solid grey; color:white !important;}
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
|
||||
Name: Paraíso (Dark)
|
||||
Author: Jan T. Sott
|
||||
|
||||
Color scheme by Jan T. Sott (https://github.com/idleberg/Paraiso-CodeMirror)
|
||||
Inspired by the art of Rubens LP (http://www.rubenslp.com.br)
|
||||
|
||||
*/
|
||||
|
||||
.cm-s-paraiso-dark.CodeMirror {background: #2f1e2e; color: #b9b6b0;}
|
||||
.cm-s-paraiso-dark div.CodeMirror-selected {background: #41323f !important;}
|
||||
.cm-s-paraiso-dark .CodeMirror-gutters {background: #2f1e2e; border-right: 0px;}
|
||||
.cm-s-paraiso-dark .CodeMirror-linenumber {color: #776e71;}
|
||||
.cm-s-paraiso-dark .CodeMirror-cursor {border-left: 1px solid #8d8687 !important;}
|
||||
|
||||
.cm-s-paraiso-dark span.cm-comment {color: #e96ba8;}
|
||||
.cm-s-paraiso-dark span.cm-atom {color: #815ba4;}
|
||||
.cm-s-paraiso-dark span.cm-number {color: #815ba4;}
|
||||
|
||||
.cm-s-paraiso-dark span.cm-property, .cm-s-paraiso-dark span.cm-attribute {color: #48b685;}
|
||||
.cm-s-paraiso-dark span.cm-keyword {color: #ef6155;}
|
||||
.cm-s-paraiso-dark span.cm-string {color: #fec418;}
|
||||
|
||||
.cm-s-paraiso-dark span.cm-variable {color: #48b685;}
|
||||
.cm-s-paraiso-dark span.cm-variable-2 {color: #06b6ef;}
|
||||
.cm-s-paraiso-dark span.cm-def {color: #f99b15;}
|
||||
.cm-s-paraiso-dark span.cm-error {background: #ef6155; color: #8d8687;}
|
||||
.cm-s-paraiso-dark span.cm-bracket {color: #b9b6b0;}
|
||||
.cm-s-paraiso-dark span.cm-tag {color: #ef6155;}
|
||||
.cm-s-paraiso-dark span.cm-link {color: #815ba4;}
|
||||
|
||||
.cm-s-paraiso-dark .CodeMirror-activeline-background {background: #4D344A !important;}
|
||||
.cm-s-paraiso-dark .CodeMirror-matchingbracket { text-decoration: underline; color: white !important;}
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
|
||||
Name: Paraíso (Light)
|
||||
Author: Jan T. Sott
|
||||
|
||||
Color scheme by Jan T. Sott (https://github.com/idleberg/Paraiso-CodeMirror)
|
||||
Inspired by the art of Rubens LP (http://www.rubenslp.com.br)
|
||||
|
||||
*/
|
||||
|
||||
.cm-s-paraiso-light.CodeMirror {background: #e7e9db; color: #41323f;}
|
||||
.cm-s-paraiso-light div.CodeMirror-selected {background: #b9b6b0 !important;}
|
||||
.cm-s-paraiso-light .CodeMirror-gutters {background: #e7e9db; border-right: 0px;}
|
||||
.cm-s-paraiso-light .CodeMirror-linenumber {color: #8d8687;}
|
||||
.cm-s-paraiso-light .CodeMirror-cursor {border-left: 1px solid #776e71 !important;}
|
||||
|
||||
.cm-s-paraiso-light span.cm-comment {color: #e96ba8;}
|
||||
.cm-s-paraiso-light span.cm-atom {color: #815ba4;}
|
||||
.cm-s-paraiso-light span.cm-number {color: #815ba4;}
|
||||
|
||||
.cm-s-paraiso-light span.cm-property, .cm-s-paraiso-light span.cm-attribute {color: #48b685;}
|
||||
.cm-s-paraiso-light span.cm-keyword {color: #ef6155;}
|
||||
.cm-s-paraiso-light span.cm-string {color: #fec418;}
|
||||
|
||||
.cm-s-paraiso-light span.cm-variable {color: #48b685;}
|
||||
.cm-s-paraiso-light span.cm-variable-2 {color: #06b6ef;}
|
||||
.cm-s-paraiso-light span.cm-def {color: #f99b15;}
|
||||
.cm-s-paraiso-light span.cm-error {background: #ef6155; color: #776e71;}
|
||||
.cm-s-paraiso-light span.cm-bracket {color: #41323f;}
|
||||
.cm-s-paraiso-light span.cm-tag {color: #ef6155;}
|
||||
.cm-s-paraiso-light span.cm-link {color: #815ba4;}
|
||||
|
||||
.cm-s-paraiso-light .CodeMirror-activeline-background {background: #CFD1C4 !important;}
|
||||
.cm-s-paraiso-light .CodeMirror-matchingbracket { text-decoration: underline; color: white !important;}
|
||||
@@ -1,23 +0,0 @@
|
||||
.cm-s-rubyblue { font-family: Trebuchet, Verdana, sans-serif; } /* - customized editor font - */
|
||||
|
||||
.cm-s-rubyblue.CodeMirror { background: #112435; color: white; }
|
||||
.cm-s-rubyblue div.CodeMirror-selected { background: #38566F !important; }
|
||||
.cm-s-rubyblue .CodeMirror-gutters { background: #1F4661; border-right: 7px solid #3E7087; }
|
||||
.cm-s-rubyblue .CodeMirror-linenumber { color: white; }
|
||||
.cm-s-rubyblue .CodeMirror-cursor { border-left: 1px solid white !important; }
|
||||
|
||||
.cm-s-rubyblue span.cm-comment { color: #999; font-style:italic; line-height: 1em; }
|
||||
.cm-s-rubyblue span.cm-atom { color: #F4C20B; }
|
||||
.cm-s-rubyblue span.cm-number, .cm-s-rubyblue span.cm-attribute { color: #82C6E0; }
|
||||
.cm-s-rubyblue span.cm-keyword { color: #F0F; }
|
||||
.cm-s-rubyblue span.cm-string { color: #F08047; }
|
||||
.cm-s-rubyblue span.cm-meta { color: #F0F; }
|
||||
.cm-s-rubyblue span.cm-variable-2, .cm-s-rubyblue span.cm-tag { color: #7BD827; }
|
||||
.cm-s-rubyblue span.cm-variable-3, .cm-s-rubyblue span.cm-def { color: white; }
|
||||
.cm-s-rubyblue span.cm-error { color: #AF2018; }
|
||||
.cm-s-rubyblue span.cm-bracket { color: #F0F; }
|
||||
.cm-s-rubyblue span.cm-link { color: #F4C20B; }
|
||||
.cm-s-rubyblue span.CodeMirror-matchingbracket { color:#F0F !important; }
|
||||
.cm-s-rubyblue span.cm-builtin, .cm-s-rubyblue span.cm-special { color: #FF9D00; }
|
||||
|
||||
.cm-s-rubyblue .CodeMirror-activeline-background {background: #173047 !important;}
|
||||
File diff suppressed because one or more lines are too long
@@ -1,26 +0,0 @@
|
||||
.cm-s-the-matrix.CodeMirror { background: #000000; color: #00FF00; }
|
||||
.cm-s-the-matrix span.CodeMirror-selected { background: #a8f !important; }
|
||||
.cm-s-the-matrix .CodeMirror-gutters { background: #060; border-right: 2px solid #00FF00; }
|
||||
.cm-s-the-matrix .CodeMirror-linenumber { color: #FFFFFF; }
|
||||
.cm-s-the-matrix .CodeMirror-cursor { border-left: 1px solid #00FF00 !important; }
|
||||
|
||||
.cm-s-the-matrix span.cm-keyword {color: #008803; font-weight: bold;}
|
||||
.cm-s-the-matrix span.cm-atom {color: #3FF;}
|
||||
.cm-s-the-matrix span.cm-number {color: #FFB94F;}
|
||||
.cm-s-the-matrix span.cm-def {color: #99C;}
|
||||
.cm-s-the-matrix span.cm-variable {color: #F6C;}
|
||||
.cm-s-the-matrix span.cm-variable-2 {color: #C6F;}
|
||||
.cm-s-the-matrix span.cm-variable-3 {color: #96F;}
|
||||
.cm-s-the-matrix span.cm-property {color: #62FFA0;}
|
||||
.cm-s-the-matrix span.cm-operator {color: #999}
|
||||
.cm-s-the-matrix span.cm-comment {color: #CCCCCC;}
|
||||
.cm-s-the-matrix span.cm-string {color: #39C;}
|
||||
.cm-s-the-matrix span.cm-meta {color: #C9F;}
|
||||
.cm-s-the-matrix span.cm-error {color: #FF0000;}
|
||||
.cm-s-the-matrix span.cm-qualifier {color: #FFF700;}
|
||||
.cm-s-the-matrix span.cm-builtin {color: #30a;}
|
||||
.cm-s-the-matrix span.cm-bracket {color: #cc7;}
|
||||
.cm-s-the-matrix span.cm-tag {color: #FFBD40;}
|
||||
.cm-s-the-matrix span.cm-attribute {color: #FFF700;}
|
||||
|
||||
.cm-s-the-matrix .CodeMirror-activeline-background {background: #040;}
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
|
||||
Name: Tomorrow Night - Eighties
|
||||
Author: Chris Kempson
|
||||
|
||||
CodeMirror template by Jan T. Sott (https://github.com/idleberg/base16-codemirror)
|
||||
Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16)
|
||||
|
||||
*/
|
||||
|
||||
.cm-s-tomorrow-night-eighties.CodeMirror {background: #000000; color: #CCCCCC;}
|
||||
.cm-s-tomorrow-night-eighties div.CodeMirror-selected {background: #2D2D2D !important;}
|
||||
.cm-s-tomorrow-night-eighties .CodeMirror-gutters {background: #000000; border-right: 0px;}
|
||||
.cm-s-tomorrow-night-eighties .CodeMirror-linenumber {color: #515151;}
|
||||
.cm-s-tomorrow-night-eighties .CodeMirror-cursor {border-left: 1px solid #6A6A6A !important;}
|
||||
|
||||
.cm-s-tomorrow-night-eighties span.cm-comment {color: #d27b53;}
|
||||
.cm-s-tomorrow-night-eighties span.cm-atom {color: #a16a94;}
|
||||
.cm-s-tomorrow-night-eighties span.cm-number {color: #a16a94;}
|
||||
|
||||
.cm-s-tomorrow-night-eighties span.cm-property, .cm-s-tomorrow-night-eighties span.cm-attribute {color: #99cc99;}
|
||||
.cm-s-tomorrow-night-eighties span.cm-keyword {color: #f2777a;}
|
||||
.cm-s-tomorrow-night-eighties span.cm-string {color: #ffcc66;}
|
||||
|
||||
.cm-s-tomorrow-night-eighties span.cm-variable {color: #99cc99;}
|
||||
.cm-s-tomorrow-night-eighties span.cm-variable-2 {color: #6699cc;}
|
||||
.cm-s-tomorrow-night-eighties span.cm-def {color: #f99157;}
|
||||
.cm-s-tomorrow-night-eighties span.cm-error {background: #f2777a; color: #6A6A6A;}
|
||||
.cm-s-tomorrow-night-eighties span.cm-bracket {color: #CCCCCC;}
|
||||
.cm-s-tomorrow-night-eighties span.cm-tag {color: #f2777a;}
|
||||
.cm-s-tomorrow-night-eighties span.cm-link {color: #a16a94;}
|
||||
|
||||
.cm-s-tomorrow-night-eighties .CodeMirror-activeline-background {background: #343600 !important;}
|
||||
.cm-s-tomorrow-night-eighties .CodeMirror-matchingbracket { text-decoration: underline; color: white !important;}
|
||||
@@ -1,28 +0,0 @@
|
||||
.cm-s-twilight.CodeMirror { background: #141414; color: #f7f7f7; } /**/
|
||||
.cm-s-twilight .CodeMirror-selected { background: #323232 !important; } /**/
|
||||
|
||||
.cm-s-twilight .CodeMirror-gutters { background: #222; border-right: 1px solid #aaa; }
|
||||
.cm-s-twilight .CodeMirror-linenumber { color: #aaa; }
|
||||
.cm-s-twilight .CodeMirror-cursor { border-left: 1px solid white !important; }
|
||||
|
||||
.cm-s-twilight .cm-keyword { color: #f9ee98; } /**/
|
||||
.cm-s-twilight .cm-atom { color: #FC0; }
|
||||
.cm-s-twilight .cm-number { color: #ca7841; } /**/
|
||||
.cm-s-twilight .cm-def { color: #8DA6CE; }
|
||||
.cm-s-twilight span.cm-variable-2, .cm-s-twilight span.cm-tag { color: #607392; } /**/
|
||||
.cm-s-twilight span.cm-variable-3, .cm-s-twilight span.cm-def { color: #607392; } /**/
|
||||
.cm-s-twilight .cm-operator { color: #cda869; } /**/
|
||||
.cm-s-twilight .cm-comment { color:#777; font-style:italic; font-weight:normal; } /**/
|
||||
.cm-s-twilight .cm-string { color:#8f9d6a; font-style:italic; } /**/
|
||||
.cm-s-twilight .cm-string-2 { color:#bd6b18 } /*?*/
|
||||
.cm-s-twilight .cm-meta { background-color:#141414; color:#f7f7f7; } /*?*/
|
||||
.cm-s-twilight .cm-error { border-bottom: 1px solid red; }
|
||||
.cm-s-twilight .cm-builtin { color: #cda869; } /*?*/
|
||||
.cm-s-twilight .cm-tag { color: #997643; } /**/
|
||||
.cm-s-twilight .cm-attribute { color: #d6bb6d; } /*?*/
|
||||
.cm-s-twilight .cm-header { color: #FF6400; }
|
||||
.cm-s-twilight .cm-hr { color: #AEAEAE; }
|
||||
.cm-s-twilight .cm-link { color:#ad9361; font-style:italic; text-decoration:none; } /**/
|
||||
|
||||
.cm-s-twilight .CodeMirror-activeline-background {background: #27282E !important;}
|
||||
.cm-s-twilight .CodeMirror-matchingbracket {outline:1px solid grey; color:white !important;}
|
||||
@@ -1,30 +0,0 @@
|
||||
/* Taken from the popular Visual Studio Vibrant Ink Schema */
|
||||
|
||||
.cm-s-vibrant-ink.CodeMirror { background: black; color: white; }
|
||||
.cm-s-vibrant-ink .CodeMirror-selected { background: #35493c !important; }
|
||||
|
||||
.cm-s-vibrant-ink .CodeMirror-gutters { background: #002240; border-right: 1px solid #aaa; }
|
||||
.cm-s-vibrant-ink .CodeMirror-linenumber { color: #d0d0d0; }
|
||||
.cm-s-vibrant-ink .CodeMirror-cursor { border-left: 1px solid white !important; }
|
||||
|
||||
.cm-s-vibrant-ink .cm-keyword { color: #CC7832; }
|
||||
.cm-s-vibrant-ink .cm-atom { color: #FC0; }
|
||||
.cm-s-vibrant-ink .cm-number { color: #FFEE98; }
|
||||
.cm-s-vibrant-ink .cm-def { color: #8DA6CE; }
|
||||
.cm-s-vibrant-ink span.cm-variable-2, .cm-s-vibrant span.cm-tag { color: #FFC66D }
|
||||
.cm-s-vibrant-ink span.cm-variable-3, .cm-s-vibrant span.cm-def { color: #FFC66D }
|
||||
.cm-s-vibrant-ink .cm-operator { color: #888; }
|
||||
.cm-s-vibrant-ink .cm-comment { color: gray; font-weight: bold; }
|
||||
.cm-s-vibrant-ink .cm-string { color: #A5C25C }
|
||||
.cm-s-vibrant-ink .cm-string-2 { color: red }
|
||||
.cm-s-vibrant-ink .cm-meta { color: #D8FA3C; }
|
||||
.cm-s-vibrant-ink .cm-error { border-bottom: 1px solid red; }
|
||||
.cm-s-vibrant-ink .cm-builtin { color: #8DA6CE; }
|
||||
.cm-s-vibrant-ink .cm-tag { color: #8DA6CE; }
|
||||
.cm-s-vibrant-ink .cm-attribute { color: #8DA6CE; }
|
||||
.cm-s-vibrant-ink .cm-header { color: #FF6400; }
|
||||
.cm-s-vibrant-ink .cm-hr { color: #AEAEAE; }
|
||||
.cm-s-vibrant-ink .cm-link { color: blue; }
|
||||
|
||||
.cm-s-vibrant-ink .CodeMirror-activeline-background {background: #27282E !important;}
|
||||
.cm-s-vibrant-ink .CodeMirror-matchingbracket {outline:1px solid grey; color:white !important;}
|
||||
@@ -1,49 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2011 by MarkLogic Corporation
|
||||
Author: Mike Brevoort <mike@brevoort.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
.cm-s-xq-dark.CodeMirror { background: #0a001f; color: #f8f8f8; }
|
||||
.cm-s-xq-dark .CodeMirror-selected { background: #27007A !important; }
|
||||
.cm-s-xq-dark .CodeMirror-gutters { background: #0a001f; border-right: 1px solid #aaa; }
|
||||
.cm-s-xq-dark .CodeMirror-linenumber { color: #f8f8f8; }
|
||||
.cm-s-xq-dark .CodeMirror-cursor { border-left: 1px solid white !important; }
|
||||
|
||||
.cm-s-xq-dark span.cm-keyword {color: #FFBD40;}
|
||||
.cm-s-xq-dark span.cm-atom {color: #6C8CD5;}
|
||||
.cm-s-xq-dark span.cm-number {color: #164;}
|
||||
.cm-s-xq-dark span.cm-def {color: #FFF; text-decoration:underline;}
|
||||
.cm-s-xq-dark span.cm-variable {color: #FFF;}
|
||||
.cm-s-xq-dark span.cm-variable-2 {color: #EEE;}
|
||||
.cm-s-xq-dark span.cm-variable-3 {color: #DDD;}
|
||||
.cm-s-xq-dark span.cm-property {}
|
||||
.cm-s-xq-dark span.cm-operator {}
|
||||
.cm-s-xq-dark span.cm-comment {color: gray;}
|
||||
.cm-s-xq-dark span.cm-string {color: #9FEE00;}
|
||||
.cm-s-xq-dark span.cm-meta {color: yellow;}
|
||||
.cm-s-xq-dark span.cm-error {color: #f00;}
|
||||
.cm-s-xq-dark span.cm-qualifier {color: #FFF700;}
|
||||
.cm-s-xq-dark span.cm-builtin {color: #30a;}
|
||||
.cm-s-xq-dark span.cm-bracket {color: #cc7;}
|
||||
.cm-s-xq-dark span.cm-tag {color: #FFBD40;}
|
||||
.cm-s-xq-dark span.cm-attribute {color: #FFF700;}
|
||||
|
||||
.cm-s-xq-dark .CodeMirror-activeline-background {background: #27282E !important;}
|
||||
.cm-s-xq-dark .CodeMirror-matchingbracket {outline:1px solid grey; color:white !important;}
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2011 by MarkLogic Corporation
|
||||
Author: Mike Brevoort <mike@brevoort.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
.cm-s-xq-light span.cm-keyword {line-height: 1em; font-weight: bold; color: #5A5CAD; }
|
||||
.cm-s-xq-light span.cm-atom {color: #6C8CD5;}
|
||||
.cm-s-xq-light span.cm-number {color: #164;}
|
||||
.cm-s-xq-light span.cm-def {text-decoration:underline;}
|
||||
.cm-s-xq-light span.cm-variable {color: black; }
|
||||
.cm-s-xq-light span.cm-variable-2 {color:black;}
|
||||
.cm-s-xq-light span.cm-variable-3 {color: black; }
|
||||
.cm-s-xq-light span.cm-property {}
|
||||
.cm-s-xq-light span.cm-operator {}
|
||||
.cm-s-xq-light span.cm-comment {color: #0080FF; font-style: italic;}
|
||||
.cm-s-xq-light span.cm-string {color: red;}
|
||||
.cm-s-xq-light span.cm-meta {color: yellow;}
|
||||
.cm-s-xq-light span.cm-error {color: #f00;}
|
||||
.cm-s-xq-light span.cm-qualifier {color: grey}
|
||||
.cm-s-xq-light span.cm-builtin {color: #7EA656;}
|
||||
.cm-s-xq-light span.cm-bracket {color: #cc7;}
|
||||
.cm-s-xq-light span.cm-tag {color: #3F7F7F;}
|
||||
.cm-s-xq-light span.cm-attribute {color: #7F007F;}
|
||||
|
||||
.cm-s-xq-light .CodeMirror-activeline-background {background: #e8f2ff !important;}
|
||||
.cm-s-xq-light .CodeMirror-matchingbracket {outline:1px solid grey;color:black !important;background:yellow;}
|
||||
@@ -1,341 +0,0 @@
|
||||
CodeMirror.defineMode("xml", function(config, parserConfig) {
|
||||
var indentUnit = config.indentUnit;
|
||||
var multilineTagIndentFactor = parserConfig.multilineTagIndentFactor || 1;
|
||||
var multilineTagIndentPastTag = parserConfig.multilineTagIndentPastTag || true;
|
||||
|
||||
var Kludges = parserConfig.htmlMode ? {
|
||||
autoSelfClosers: {'area': true, 'base': true, 'br': true, 'col': true, 'command': true,
|
||||
'embed': true, 'frame': true, 'hr': true, 'img': true, 'input': true,
|
||||
'keygen': true, 'link': true, 'meta': true, 'param': true, 'source': true,
|
||||
'track': true, 'wbr': true},
|
||||
implicitlyClosed: {'dd': true, 'li': true, 'optgroup': true, 'option': true, 'p': true,
|
||||
'rp': true, 'rt': true, 'tbody': true, 'td': true, 'tfoot': true,
|
||||
'th': true, 'tr': true},
|
||||
contextGrabbers: {
|
||||
'dd': {'dd': true, 'dt': true},
|
||||
'dt': {'dd': true, 'dt': true},
|
||||
'li': {'li': true},
|
||||
'option': {'option': true, 'optgroup': true},
|
||||
'optgroup': {'optgroup': true},
|
||||
'p': {'address': true, 'article': true, 'aside': true, 'blockquote': true, 'dir': true,
|
||||
'div': true, 'dl': true, 'fieldset': true, 'footer': true, 'form': true,
|
||||
'h1': true, 'h2': true, 'h3': true, 'h4': true, 'h5': true, 'h6': true,
|
||||
'header': true, 'hgroup': true, 'hr': true, 'menu': true, 'nav': true, 'ol': true,
|
||||
'p': true, 'pre': true, 'section': true, 'table': true, 'ul': true},
|
||||
'rp': {'rp': true, 'rt': true},
|
||||
'rt': {'rp': true, 'rt': true},
|
||||
'tbody': {'tbody': true, 'tfoot': true},
|
||||
'td': {'td': true, 'th': true},
|
||||
'tfoot': {'tbody': true},
|
||||
'th': {'td': true, 'th': true},
|
||||
'thead': {'tbody': true, 'tfoot': true},
|
||||
'tr': {'tr': true}
|
||||
},
|
||||
doNotIndent: {"pre": true},
|
||||
allowUnquoted: true,
|
||||
allowMissing: true
|
||||
} : {
|
||||
autoSelfClosers: {},
|
||||
implicitlyClosed: {},
|
||||
contextGrabbers: {},
|
||||
doNotIndent: {},
|
||||
allowUnquoted: false,
|
||||
allowMissing: false
|
||||
};
|
||||
var alignCDATA = parserConfig.alignCDATA;
|
||||
|
||||
// Return variables for tokenizers
|
||||
var tagName, type;
|
||||
|
||||
function inText(stream, state) {
|
||||
function chain(parser) {
|
||||
state.tokenize = parser;
|
||||
return parser(stream, state);
|
||||
}
|
||||
|
||||
var ch = stream.next();
|
||||
if (ch == "<") {
|
||||
if (stream.eat("!")) {
|
||||
if (stream.eat("[")) {
|
||||
if (stream.match("CDATA[")) return chain(inBlock("atom", "]]>"));
|
||||
else return null;
|
||||
} else if (stream.match("--")) {
|
||||
return chain(inBlock("comment", "-->"));
|
||||
} else if (stream.match("DOCTYPE", true, true)) {
|
||||
stream.eatWhile(/[\w\._\-]/);
|
||||
return chain(doctype(1));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} else if (stream.eat("?")) {
|
||||
stream.eatWhile(/[\w\._\-]/);
|
||||
state.tokenize = inBlock("meta", "?>");
|
||||
return "meta";
|
||||
} else {
|
||||
var isClose = stream.eat("/");
|
||||
tagName = "";
|
||||
var c;
|
||||
while ((c = stream.eat(/[^\s\u00a0=<>\"\'\/?]/))) tagName += c;
|
||||
if (!tagName) return "error";
|
||||
type = isClose ? "closeTag" : "openTag";
|
||||
state.tokenize = inTag;
|
||||
return "tag";
|
||||
}
|
||||
} else if (ch == "&") {
|
||||
var ok;
|
||||
if (stream.eat("#")) {
|
||||
if (stream.eat("x")) {
|
||||
ok = stream.eatWhile(/[a-fA-F\d]/) && stream.eat(";");
|
||||
} else {
|
||||
ok = stream.eatWhile(/[\d]/) && stream.eat(";");
|
||||
}
|
||||
} else {
|
||||
ok = stream.eatWhile(/[\w\.\-:]/) && stream.eat(";");
|
||||
}
|
||||
return ok ? "atom" : "error";
|
||||
} else {
|
||||
stream.eatWhile(/[^&<]/);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function inTag(stream, state) {
|
||||
var ch = stream.next();
|
||||
if (ch == ">" || (ch == "/" && stream.eat(">"))) {
|
||||
state.tokenize = inText;
|
||||
type = ch == ">" ? "endTag" : "selfcloseTag";
|
||||
return "tag";
|
||||
} else if (ch == "=") {
|
||||
type = "equals";
|
||||
return null;
|
||||
} else if (ch == "<") {
|
||||
return "error";
|
||||
} else if (/[\'\"]/.test(ch)) {
|
||||
state.tokenize = inAttribute(ch);
|
||||
state.stringStartCol = stream.column();
|
||||
return state.tokenize(stream, state);
|
||||
} else {
|
||||
stream.eatWhile(/[^\s\u00a0=<>\"\']/);
|
||||
return "word";
|
||||
}
|
||||
}
|
||||
|
||||
function inAttribute(quote) {
|
||||
var closure = function(stream, state) {
|
||||
while (!stream.eol()) {
|
||||
if (stream.next() == quote) {
|
||||
state.tokenize = inTag;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return "string";
|
||||
};
|
||||
closure.isInAttribute = true;
|
||||
return closure;
|
||||
}
|
||||
|
||||
function inBlock(style, terminator) {
|
||||
return function(stream, state) {
|
||||
while (!stream.eol()) {
|
||||
if (stream.match(terminator)) {
|
||||
state.tokenize = inText;
|
||||
break;
|
||||
}
|
||||
stream.next();
|
||||
}
|
||||
return style;
|
||||
};
|
||||
}
|
||||
function doctype(depth) {
|
||||
return function(stream, state) {
|
||||
var ch;
|
||||
while ((ch = stream.next()) != null) {
|
||||
if (ch == "<") {
|
||||
state.tokenize = doctype(depth + 1);
|
||||
return state.tokenize(stream, state);
|
||||
} else if (ch == ">") {
|
||||
if (depth == 1) {
|
||||
state.tokenize = inText;
|
||||
break;
|
||||
} else {
|
||||
state.tokenize = doctype(depth - 1);
|
||||
return state.tokenize(stream, state);
|
||||
}
|
||||
}
|
||||
}
|
||||
return "meta";
|
||||
};
|
||||
}
|
||||
|
||||
var curState, curStream, setStyle;
|
||||
function pass() {
|
||||
for (var i = arguments.length - 1; i >= 0; i--) curState.cc.push(arguments[i]);
|
||||
}
|
||||
function cont() {
|
||||
pass.apply(null, arguments);
|
||||
return true;
|
||||
}
|
||||
|
||||
function pushContext(tagName, startOfLine) {
|
||||
var noIndent = Kludges.doNotIndent.hasOwnProperty(tagName) || (curState.context && curState.context.noIndent);
|
||||
curState.context = {
|
||||
prev: curState.context,
|
||||
tagName: tagName,
|
||||
indent: curState.indented,
|
||||
startOfLine: startOfLine,
|
||||
noIndent: noIndent
|
||||
};
|
||||
}
|
||||
function popContext() {
|
||||
if (curState.context) curState.context = curState.context.prev;
|
||||
}
|
||||
|
||||
function element(type) {
|
||||
if (type == "openTag") {
|
||||
curState.tagName = tagName;
|
||||
curState.tagStart = curStream.column();
|
||||
return cont(attributes, endtag(curState.startOfLine));
|
||||
} else if (type == "closeTag") {
|
||||
var err = false;
|
||||
if (curState.context) {
|
||||
if (curState.context.tagName != tagName) {
|
||||
if (Kludges.implicitlyClosed.hasOwnProperty(curState.context.tagName.toLowerCase())) {
|
||||
popContext();
|
||||
}
|
||||
err = !curState.context || curState.context.tagName != tagName;
|
||||
}
|
||||
} else {
|
||||
err = true;
|
||||
}
|
||||
if (err) setStyle = "error";
|
||||
return cont(endclosetag(err));
|
||||
}
|
||||
return cont();
|
||||
}
|
||||
function endtag(startOfLine) {
|
||||
return function(type) {
|
||||
var tagName = curState.tagName;
|
||||
curState.tagName = curState.tagStart = null;
|
||||
if (type == "selfcloseTag" ||
|
||||
(type == "endTag" && Kludges.autoSelfClosers.hasOwnProperty(tagName.toLowerCase()))) {
|
||||
maybePopContext(tagName.toLowerCase());
|
||||
return cont();
|
||||
}
|
||||
if (type == "endTag") {
|
||||
maybePopContext(tagName.toLowerCase());
|
||||
pushContext(tagName, startOfLine);
|
||||
return cont();
|
||||
}
|
||||
return cont();
|
||||
};
|
||||
}
|
||||
function endclosetag(err) {
|
||||
return function(type) {
|
||||
if (err) setStyle = "error";
|
||||
if (type == "endTag") { popContext(); return cont(); }
|
||||
setStyle = "error";
|
||||
return cont(arguments.callee);
|
||||
};
|
||||
}
|
||||
function maybePopContext(nextTagName) {
|
||||
var parentTagName;
|
||||
while (true) {
|
||||
if (!curState.context) {
|
||||
return;
|
||||
}
|
||||
parentTagName = curState.context.tagName.toLowerCase();
|
||||
if (!Kludges.contextGrabbers.hasOwnProperty(parentTagName) ||
|
||||
!Kludges.contextGrabbers[parentTagName].hasOwnProperty(nextTagName)) {
|
||||
return;
|
||||
}
|
||||
popContext();
|
||||
}
|
||||
}
|
||||
|
||||
function attributes(type) {
|
||||
if (type == "word") {setStyle = "attribute"; return cont(attribute, attributes);}
|
||||
if (type == "endTag" || type == "selfcloseTag") return pass();
|
||||
setStyle = "error";
|
||||
return cont(attributes);
|
||||
}
|
||||
function attribute(type) {
|
||||
if (type == "equals") return cont(attvalue, attributes);
|
||||
if (!Kludges.allowMissing) setStyle = "error";
|
||||
else if (type == "word") {setStyle = "attribute"; return cont(attribute, attributes);}
|
||||
return (type == "endTag" || type == "selfcloseTag") ? pass() : cont();
|
||||
}
|
||||
function attvalue(type) {
|
||||
if (type == "string") return cont(attvaluemaybe);
|
||||
if (type == "word" && Kludges.allowUnquoted) {setStyle = "string"; return cont();}
|
||||
setStyle = "error";
|
||||
return (type == "endTag" || type == "selfCloseTag") ? pass() : cont();
|
||||
}
|
||||
function attvaluemaybe(type) {
|
||||
if (type == "string") return cont(attvaluemaybe);
|
||||
else return pass();
|
||||
}
|
||||
|
||||
return {
|
||||
startState: function() {
|
||||
return {tokenize: inText, cc: [], indented: 0, startOfLine: true, tagName: null, tagStart: null, context: null};
|
||||
},
|
||||
|
||||
token: function(stream, state) {
|
||||
if (!state.tagName && stream.sol()) {
|
||||
state.startOfLine = true;
|
||||
state.indented = stream.indentation();
|
||||
}
|
||||
if (stream.eatSpace()) return null;
|
||||
|
||||
setStyle = type = tagName = null;
|
||||
var style = state.tokenize(stream, state);
|
||||
state.type = type;
|
||||
if ((style || type) && style != "comment") {
|
||||
curState = state; curStream = stream;
|
||||
while (true) {
|
||||
var comb = state.cc.pop() || element;
|
||||
if (comb(type || style)) break;
|
||||
}
|
||||
}
|
||||
state.startOfLine = false;
|
||||
return setStyle || style;
|
||||
},
|
||||
|
||||
indent: function(state, textAfter, fullLine) {
|
||||
var context = state.context;
|
||||
// Indent multi-line strings (e.g. css).
|
||||
if (state.tokenize.isInAttribute) {
|
||||
return state.stringStartCol + 1;
|
||||
}
|
||||
if ((state.tokenize != inTag && state.tokenize != inText) ||
|
||||
context && context.noIndent)
|
||||
return fullLine ? fullLine.match(/^(\s*)/)[0].length : 0;
|
||||
// Indent the starts of attribute names.
|
||||
if (state.tagName) {
|
||||
if (multilineTagIndentPastTag)
|
||||
return state.tagStart + state.tagName.length + 2;
|
||||
else
|
||||
return state.tagStart + indentUnit * multilineTagIndentFactor;
|
||||
}
|
||||
if (alignCDATA && /<!\[CDATA\[/.test(textAfter)) return 0;
|
||||
if (context && /^<\//.test(textAfter))
|
||||
context = context.prev;
|
||||
while (context && !context.startOfLine)
|
||||
context = context.prev;
|
||||
if (context) return context.indent + indentUnit;
|
||||
else return 0;
|
||||
},
|
||||
|
||||
electricChars: "/",
|
||||
blockCommentStart: "<!--",
|
||||
blockCommentEnd: "-->",
|
||||
|
||||
configuration: parserConfig.htmlMode ? "html" : "xml",
|
||||
helperType: parserConfig.htmlMode ? "html" : "xml"
|
||||
};
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME("text/xml", "xml");
|
||||
CodeMirror.defineMIME("application/xml", "xml");
|
||||
if (!CodeMirror.mimeModes.hasOwnProperty("text/html"))
|
||||
CodeMirror.defineMIME("text/html", {name: "xml", htmlMode: true});
|
||||
@@ -1,21 +0,0 @@
|
||||
var storage, fail, uid;
|
||||
try {
|
||||
uid = new Date; (storage = window.localStorage).setItem(uid, uid);
|
||||
fail = storage.getItem(uid) != uid;
|
||||
storage.removeItem(uid);
|
||||
fail && (storage = false);
|
||||
} catch(e) {}
|
||||
if (storage) {
|
||||
try {
|
||||
var usedSkin = localStorage.getItem('config-skin');
|
||||
if (usedSkin != '' && usedSkin != null) {
|
||||
document.body.className = usedSkin;
|
||||
} else {
|
||||
document.body.className = '';
|
||||
}
|
||||
} catch(e) {
|
||||
document.body.className = '';
|
||||
}
|
||||
} else {
|
||||
document.body.className = '';
|
||||
}
|
||||
@@ -5,16 +5,16 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
|
||||
<title>欢迎您登录SentCMS管理平台</title>
|
||||
<link href="__PUBLIC__/css/bootstrap/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" type="text/css" href="__PUBLIC__/css/libs/font-awesome.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="__CSS__/style.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="__PUBLIC__/css/common.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="__STATIC__/css/libs/bootstrap.min.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="__STATIC__/css/libs/font-awesome.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="__STATIC__/css/admin/style.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="__STATIC__/css/common.css"/>
|
||||
|
||||
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
|
||||
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="__PUBLIC__/js/html5shiv.min.js"></script>
|
||||
<script src="__PUBLIC__/js/ie8polyfill.min.js"></script>
|
||||
<script src="__STATIC__/js/html5shiv.min.js"></script>
|
||||
<script src="__STATIC__/js/ie8polyfill.min.js"></script>
|
||||
<![endif]-->
|
||||
</head>
|
||||
<body id="login-page-full">
|
||||
@@ -28,7 +28,7 @@
|
||||
<div class="col-xs-12">
|
||||
<header id="login-header">
|
||||
<div id="login-logo">
|
||||
<img src="__PUBLIC__/images/logo.png" alt=""/>
|
||||
<img src="__STATIC__/images/logo.png" alt=""/>
|
||||
</div>
|
||||
</header>
|
||||
<div id="login-box-inner">
|
||||
@@ -47,7 +47,7 @@
|
||||
<span class="input-group-addon"> <i class="fa fa-qrcode"></i>
|
||||
</span>
|
||||
<input type="text" name="verify" class="form-control" placeholder="验证码">
|
||||
<span class="input-group-addon reloadverify"><img src="{:url('admin/index/verify')}" alt="验证码" height="40" class="verifyimg"></span>
|
||||
<span class="input-group-addon reloadverify"><img src="{:captcha_src()}" alt="验证码" height="40" class="verifyimg"></span>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
@@ -78,8 +78,8 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="__PUBLIC__/js/jquery.js"></script>
|
||||
<script src="__PUBLIC__/js/messager.js"></script>
|
||||
<script src="__STATIC__/js/jquery.js"></script>
|
||||
<script src="__STATIC__/js/messager.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(function(){
|
||||
|
||||
|
||||
@@ -11,12 +11,12 @@
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a href="{:url('Index/index')}" id="logo" class="navbar-brand">
|
||||
<img src="__PUBLIC__/images/logo.png" alt="" class="normal-logo logo-white"/>
|
||||
<img src="__STATIC__/images/logo.png" alt="" class="normal-logo logo-white"/>
|
||||
</a>
|
||||
<ul class="nav navbar-nav pull-right visible-xs">
|
||||
<li class="dropdown profile-dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
|
||||
<img src="__PUBLIC__/images/samples/scarlet-159.png" alt=""/>
|
||||
<img src="__STATIC__/images/samples/scarlet-159.png" alt=""/>
|
||||
<span class="hidden-xs">{:session('user_auth.username')}</span> <b class="caret"></b>
|
||||
</a>
|
||||
<ul class="dropdown-menu dropdown-menu-right">
|
||||
@@ -70,7 +70,7 @@
|
||||
<ul class="nav navbar-nav pull-right">
|
||||
<li class="dropdown profile-dropdown hidden-sm hidden-xs">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
|
||||
<img src="__PUBLIC__/images/samples/scarlet-159.png" alt=""/>
|
||||
<img src="__STATIC__/images/samples/scarlet-159.png" alt=""/>
|
||||
<span class="hidden-xs">{:session('user_auth.username')}</span> <b class="caret"></b>
|
||||
</a>
|
||||
<ul class="dropdown-menu dropdown-menu-right">
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
<script src="__PUBLIC__/js/bootstrap.js"></script>
|
||||
<script src="__PUBLIC__/js/jquery.nanoscroller.min.js"></script>
|
||||
<script src="__PUBLIC__/js/pace.min.js"></script>
|
||||
<script src="__STATIC__/js/bootstrap.js"></script>
|
||||
<script src="__STATIC__/js/jquery.nanoscroller.min.js"></script>
|
||||
<script src="__STATIC__/js/pace.min.js"></script>
|
||||
|
||||
<script src="__PUBLIC__/js/hopscotch.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="__PUBLIC__/css/libs/hopscotch.css">
|
||||
<script src="__STATIC__/js/hopscotch.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="__STATIC__/css/libs/hopscotch.css">
|
||||
|
||||
<script src="__PUBLIC__/js/messager.js"></script>
|
||||
<script src="__JS__/app.js"></script>
|
||||
<script src="__STATIC__/js/messager.js"></script>
|
||||
<script src="__STATIC__/js/admin/app.js"></script>
|
||||
<script type="text/javascript">
|
||||
(function(){
|
||||
var SentCMS = window.Sent = {
|
||||
"ROOT" : "__ROOT__", //当前网站地址
|
||||
"APP" : "__APP__", //当前项目地址
|
||||
"PUBLIC" : "__PUBLIC__", //项目公共目录地址
|
||||
"PUBLIC" : "__STATIC__", //项目公共目录地址
|
||||
"DEEP" : "{:config('URL_PATHINFO_DEPR')}", //PATHINFO分割符
|
||||
"MODEL" : ["{:config('URL_MODEL')}", "{:config('URL_CASE_INSENSITIVE')}", "{:config('URL_HTML_SUFFIX')}"],
|
||||
"VAR" : ["{:config('VAR_MODULE')}", "{:config('VAR_CONTROLLER')}", "{:config('VAR_ACTION')}"]
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
<script src="__PUBLIC__/js/core.js"></script>
|
||||
<script src="__STATIC__/js/core.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -5,13 +5,13 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
|
||||
<title>SentCMS网站管理系统后台</title>
|
||||
<link rel="stylesheet" type="text/css" href="__PUBLIC__/css/bootstrap/bootstrap.min.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="__PUBLIC__/css/libs/font-awesome.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="__PUBLIC__/css/libs/nanoscroller.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="__PUBLIC__/css/common.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="__STATIC__/css/libs/bootstrap.min.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="__STATIC__/css/libs/font-awesome.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="__STATIC__/css/libs/nanoscroller.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="__STATIC__/css/common.css"/>
|
||||
<!-- <link href='//fonts.googleapis.com/css?family=Open+Sans:400,600,700,300|Titillium+Web:200,300,400' rel='stylesheet' type='text/css'> -->
|
||||
<link rel="stylesheet" type="text/css" href="__CSS__/style.css"/>
|
||||
<script src="__PUBLIC__/js/jquery.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="__STATIC__/css/admin/style.css"/>
|
||||
<script src="__STATIC__/js/jquery.js"></script>
|
||||
<script type="text/javascript">
|
||||
var BASE_URL = "{:config('base_url')}"; //根目录地址
|
||||
$(function(){
|
||||
@@ -22,8 +22,8 @@ $(function(){
|
||||
})
|
||||
</script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="__PUBLIC__/js/html5shiv.js"></script>
|
||||
<script src="__PUBLIC__/js/respond.min.js"></script>
|
||||
<script src="__STATIC__/js/html5shiv.js"></script>
|
||||
<script src="__STATIC__/js/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
</head>
|
||||
<body>
|
||||
@@ -48,4 +48,4 @@
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<script src="__JS__/skin-changer.js"></script>
|
||||
<script src="__STATIC__/js/admin/skin-changer.js"></script>
|
||||
@@ -1,12 +1,5 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
//配置文件
|
||||
return [
|
||||
|
||||
return array(
|
||||
'default_return_type' => 'json',
|
||||
);
|
||||
];
|
||||
@@ -1,35 +0,0 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\Api\controller;
|
||||
use app\common\controller\Api;
|
||||
|
||||
class Auth extends Api {
|
||||
|
||||
public function login(){
|
||||
if (!$this->request->post('username')) {
|
||||
$this->data['msg'] = "用户名不能为空!";
|
||||
return $this->data;
|
||||
}
|
||||
if (!$this->request->post('password')) {
|
||||
$this->data['msg'] = "密码不能为空!";
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
$user = model('User')->field('uid,username,password,salt')->where('username', $this->request->post('username'))->find();
|
||||
if ($user['password'] === md5($this->request->post('password').$user['salt'])) {
|
||||
$this->data['code'] = 1;
|
||||
$user['access_token'] = authcode($user['uid'].'|'.$user['username'].'|'.$user['password'], 'ENCODE');
|
||||
$this->data['data'] = $user;
|
||||
}else{
|
||||
$this->data['msg'] = "密码错误!";
|
||||
}
|
||||
return $this->data;
|
||||
}
|
||||
}
|
||||
@@ -1,44 +1,10 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\api\controller;
|
||||
|
||||
namespace app\Api\controller;
|
||||
use app\common\controller\Api;
|
||||
|
||||
class Index extends Api {
|
||||
|
||||
public function index(){
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
public function getToken(\think\Request $request){
|
||||
$appid = $request->post('appid', '');
|
||||
$appsecret = $request->post('appsecret', '');
|
||||
|
||||
$client = db('Client')->where('appid', $appid)->where('appsecret', $appsecret)->value('id');
|
||||
if ($client) {
|
||||
$this->data['time'] = time();
|
||||
$tokens = $appid . '|' . $appsecret . '|' . $this->data['time'];
|
||||
$this->data['token'] = authcode($tokens, 'ENCODE');
|
||||
$this->data['code'] = 1;
|
||||
return $this->data;
|
||||
}else{
|
||||
$this->data['msg'] = '未知信息,请联系管理员!';
|
||||
return $this->data;
|
||||
}
|
||||
}
|
||||
|
||||
public function getOauthUrl(\think\Request $request){
|
||||
$oauth = &load_wechat('Oauth');
|
||||
$url = $request->param('url');
|
||||
$uri = $oauth->getOauthRedirect('http://wx.tensent.cn' . $url);
|
||||
$this->data['code'] = 1;
|
||||
$this->data['data'] = $uri;
|
||||
return $this->data;
|
||||
}
|
||||
}
|
||||
class Index
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return '<style type="text/css">*{ padding: 0; margin: 0; } div{ padding: 4px 48px;} a{color:#2E5CD5;cursor: pointer;text-decoration: none} a:hover{text-decoration:underline; } body{ background: #fff; font-family: "Century Gothic","Microsoft yahei"; color: #333;font-size:18px;} h1{ font-size: 100px; font-weight: normal; margin-bottom: 12px; } p{ line-height: 1.6em; font-size: 42px }</style><div style="padding: 24px 48px;"> <h1>:)</h1><p> ThinkPHP V5<br/><span style="font-size:30px">十年磨一剑 - 为API开发设计的高性能框架</span></p><span style="font-size:22px;">[ V5.0 版本由 <a href="http://www.qiniu.com" target="qiniu">七牛云</a> 独家赞助发布 ]</span></div><script type="text/javascript" src="http://tajs.qq.com/stats?sId=9347272" charset="UTF-8"></script><script type="text/javascript" src="http://ad.topthink.com/Public/static/client.js"></script><thinkad id="ad_bd568ce7058a1091"></thinkad>';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\Api\controller;
|
||||
use app\common\controller\Api;
|
||||
|
||||
class User extends Api {
|
||||
|
||||
public $mustToken = true;
|
||||
|
||||
public function getuser(){
|
||||
$this->data['code'] = 1;
|
||||
$this->data['data'] = db('Member')->where('uid', $this->request->param('uid'))->find();
|
||||
return $this->data;
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\controller;
|
||||
use app\common\controller\Api;
|
||||
|
||||
class Wechat extends Api {
|
||||
|
||||
public function config(){
|
||||
$js = new \Wechat\WechatScript(config('wxapp'));
|
||||
$this->data['data'] = $js->getJsSign('http://test.tensent.cn:81/home');
|
||||
// dump($this->data);
|
||||
// $this->data['data'] = array(
|
||||
// 'appid' => 'dddd',
|
||||
// 'timestamp' => time()
|
||||
// );
|
||||
return $this->data;
|
||||
}
|
||||
}
|
||||
+1
-31
@@ -9,7 +9,7 @@
|
||||
|
||||
// SentCMS常量定义
|
||||
define('SENTCMS_VERSION', '3.1.201706');
|
||||
define('SENT_ADDON_PATH', ROOT_PATH . DS . 'addons' . DS);
|
||||
define('SENT_ADDON_PATH', __DIR__ . '/../addons' . DS);
|
||||
|
||||
//字符串解密加密
|
||||
function authcode($string, $operation = 'DECODE', $key = '', $expiry = 0) {
|
||||
@@ -1174,34 +1174,4 @@ 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;
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,7 @@ class Addons extends Base {
|
||||
public function _initialize() {
|
||||
$mc = $this->getAddonsName();
|
||||
|
||||
$this->addon_path = ROOT_PATH . "/addons/{$mc}/";
|
||||
$this->addon_path = SENT_ADDON_PATH . "{$mc}/";
|
||||
if (is_file($this->addon_path . 'config.php')) {
|
||||
$this->config_file = $this->addon_path . 'config.php';
|
||||
}
|
||||
@@ -38,13 +38,13 @@ class Addons extends Base {
|
||||
$mc = $this->getAddonsName();
|
||||
$ac = input('ac', '', 'trim,strtolower');
|
||||
$parse_str = \think\Config::get('parse_str');
|
||||
$parse_str['__ADDONROOT__'] = ROOT_PATH . "/addons/{$mc}";
|
||||
$parse_str['__ADDONROOT__'] = SENT_ADDON_PATH . "{$mc}";
|
||||
\think\Config::set('parse_str', $parse_str);
|
||||
|
||||
$this->view->engine(
|
||||
array(
|
||||
'view_path' => "addons/" . $mc . "/view/",
|
||||
'replace' => array('__ADDONROOT__'=>ROOT_PATH . "/addons/{$mc}")
|
||||
'view_path' => SENT_ADDON_PATH . $mc . "/view/",
|
||||
'replace' => array('__ADDONROOT__'=>SENT_ADDON_PATH . "{$mc}")
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,26 +1,19 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\common\controller;
|
||||
use app\common\model\AuthGroup;
|
||||
use app\common\model\AuthRule;
|
||||
|
||||
class Admin extends Base {
|
||||
|
||||
|
||||
public function _initialize() {
|
||||
parent::_initialize();
|
||||
|
||||
if (!is_login() and !in_array($this->url, array('admin/index/login', 'admin/index/logout', 'admin/index/verify'))) {
|
||||
if (!is_login() and !in_array($this->url_path, array('admin/index/login', 'admin/index/logout', 'admin/index/verify'))) {
|
||||
$this->redirect('admin/index/login');
|
||||
}
|
||||
|
||||
if (!in_array($this->url, array('admin/index/login', 'admin/index/logout', 'admin/index/verify'))) {
|
||||
if (!in_array($this->url_path, array('admin/index/login', 'admin/index/logout', 'admin/index/verify'))) {
|
||||
|
||||
// 是否是超级管理员
|
||||
define('IS_ROOT', is_administrator());
|
||||
@@ -119,7 +112,7 @@ class Admin extends Base {
|
||||
|
||||
protected function setMenu() {
|
||||
$hover_url = $this->request->module() . '/' . $this->request->controller();
|
||||
$controller = $this->url;
|
||||
$controller = $this->url_path;
|
||||
$menu = array(
|
||||
'main' => array(),
|
||||
'child' => array(),
|
||||
@@ -218,4 +211,4 @@ class Admin extends Base {
|
||||
$this->assign('extend_menu', array('管理插件' => $menu));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,14 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\common\controller;
|
||||
|
||||
class Base extends \think\Controller {
|
||||
use think\Controller;
|
||||
|
||||
protected $url;
|
||||
protected $request;
|
||||
protected $module;
|
||||
protected $controller;
|
||||
protected $action;
|
||||
class Base extends Controller{
|
||||
|
||||
public function _initialize() {
|
||||
protected $url_path = ""; //当前完全访问路径
|
||||
|
||||
public function _initialize(){
|
||||
$this->url_path = strtolower($this->request->module() . '/' . $this->request->controller() . '/' . $this->request->action());
|
||||
if (!is_file(APP_PATH . 'database.php') || !is_file(APP_PATH . 'install.lock')) {
|
||||
return $this->redirect('install/index/index');
|
||||
}
|
||||
@@ -28,8 +19,6 @@ class Base extends \think\Controller {
|
||||
cache('db_config_data', $config);
|
||||
}
|
||||
config($config);
|
||||
//获取request信息
|
||||
$this->requestInfo();
|
||||
}
|
||||
|
||||
public function execute($mc = null, $op = '', $ac = null) {
|
||||
@@ -110,34 +99,6 @@ class Base extends \think\Controller {
|
||||
$this->assign($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证码
|
||||
* @param integer $id 验证码ID
|
||||
* @author 郭平平 <molong@tensent.cn>
|
||||
*/
|
||||
public function verify($id = 1) {
|
||||
$verify = new \org\Verify(array('length' => 4));
|
||||
$verify->entry($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测验证码
|
||||
* @param integer $id 验证码ID
|
||||
* @return boolean 检测结果
|
||||
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
|
||||
*/
|
||||
public function checkVerify($code, $id = 1) {
|
||||
if ($code) {
|
||||
$verify = new \org\Verify();
|
||||
$result = $verify->check($code, $id);
|
||||
if (!$result) {
|
||||
return $this->error("验证码错误!", "");
|
||||
}
|
||||
} else {
|
||||
return $this->error("验证码为空!", "");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 后台设置title
|
||||
* @description 设置后台页面的title
|
||||
@@ -149,29 +110,6 @@ class Base extends \think\Controller {
|
||||
$this->assign('meta_title', $title);
|
||||
}
|
||||
|
||||
//request信息
|
||||
protected function requestInfo() {
|
||||
$this->param = $this->request->param();
|
||||
defined('MODULE_NAME') or define('MODULE_NAME', $this->request->module());
|
||||
defined('CONTROLLER_NAME') or define('CONTROLLER_NAME', $this->request->controller());
|
||||
defined('ACTION_NAME') or define('ACTION_NAME', $this->request->action());
|
||||
defined('IS_POST') or define('IS_POST', $this->request->isPost());
|
||||
defined('IS_GET') or define('IS_GET', $this->request->isGet());
|
||||
$this->url = strtolower($this->request->module() . '/' . $this->request->controller() . '/' . $this->request->action());
|
||||
$this->assign('request', $this->request);
|
||||
$this->assign('param', $this->param);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单个参数的数组形式
|
||||
*/
|
||||
protected function getArrayParam($param) {
|
||||
if (isset($this->param['id'])) {
|
||||
return array_unique((array) $this->param[$param]);
|
||||
} else {
|
||||
return array();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否为手机访问
|
||||
@@ -214,4 +152,4 @@ class Base extends \think\Controller {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,125 +1,35 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\common\controller;
|
||||
|
||||
class Front extends Base {
|
||||
class Front extends Base{
|
||||
|
||||
public $wechat_oauth;
|
||||
public function _initialize() {
|
||||
public function _initialize(){
|
||||
parent::_initialize();
|
||||
|
||||
//判读是否为关闭网站
|
||||
if (\think\Config::get('web_site_close')) {
|
||||
header("Content-type:text/html;charset=utf-8");
|
||||
echo $this->fetch('common@default/public/close');exit();
|
||||
}
|
||||
|
||||
//设置SEO
|
||||
$this->setSeo();
|
||||
|
||||
$this->setHoverNav();
|
||||
|
||||
//主题设置
|
||||
//设置主题信息
|
||||
$this->setThemes();
|
||||
|
||||
//微信访问时
|
||||
// if ($this->isMobile() && $this->is_wechat()) {
|
||||
// if (!session('oauth')) {
|
||||
// $this->getOpentId();
|
||||
// }else{
|
||||
// $this->wechat_oauth = session('oauth');
|
||||
// $this->assign('oauth', session('oauth'));
|
||||
// }
|
||||
|
||||
// //微信用户直接使用微信登录
|
||||
// $this->WechatUser();
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信用户登录
|
||||
*/
|
||||
protected function WechatUser(){
|
||||
if (!is_login()) {
|
||||
$openid = $this->wechat_oauth['openid'];
|
||||
//若系统内存在则直接登录,不存在不登录
|
||||
$result = model('User')->login($openid, '', 5);
|
||||
if ($result == -1) {
|
||||
$user = & load_wechat('User');
|
||||
$wechat_user = $user->getUserInfo($this->wechat_oauth['openid']);
|
||||
|
||||
$result = model('User')->register($openid, $openid, $openid, $openid.'@openid.com', true, array('openid'=>$openid,'nickname'=>$this->jsonName($wechat_user['nickname']),'headimgurl'=>$wechat_user['headimgurl']));
|
||||
}
|
||||
return $result;
|
||||
}else{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
+----------------------------------------------------------
|
||||
* 过滤用户昵称里面的特殊字符
|
||||
+----------------------------------------------------------
|
||||
* @param string $str 待输出的用户昵称
|
||||
+----------------------------------------------------------
|
||||
*/
|
||||
protected function jsonName($str) {
|
||||
if($str){
|
||||
$return = '';
|
||||
$length = mb_strlen($str,'utf-8');
|
||||
for ($i=0; $i < $length; $i++) {
|
||||
$_tmpStr = mb_substr($str,$i,1,'utf-8');
|
||||
if(strlen($_tmpStr) >= 4){
|
||||
$return .= '';
|
||||
}else{
|
||||
$return .= $_tmpStr;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$return = 'wechat_'.time();
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
protected function getOpentId(){
|
||||
$oauth = &load_wechat('Oauth');
|
||||
$user_oauth = $oauth->getOauthAccessToken();
|
||||
if ($user_oauth) {
|
||||
session('oauth',$user_oauth);
|
||||
}else{
|
||||
$uri = $oauth->getOauthRedirect('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
|
||||
header("Location:".$uri);
|
||||
}
|
||||
}
|
||||
|
||||
//当前栏目导航
|
||||
protected function setHoverNav() {
|
||||
//dump($_SERVER['PHP_SELF']);
|
||||
}
|
||||
|
||||
protected function setThemes() {
|
||||
//网站主题设置
|
||||
$themes['mobile'] = config('mobile_themes') ? config('mobile_themes') : 'mobile';
|
||||
$themes['pc'] = config('pc_themes') ? config('pc_themes') : 'default';
|
||||
$view_path = ($this->isMobile() && config('open_mobile_site') == '1') ? 'template/' . $themes['mobile'] . '/' : 'template/' . $themes['pc'] . '/';
|
||||
public function setThemes(){
|
||||
$theme = 'default';
|
||||
$module = $this->request->module();
|
||||
if (!in_array($module, array('index', 'install'))) {
|
||||
$view_path_pre = $module . '/';
|
||||
} else {
|
||||
$view_path_pre = '';
|
||||
if ($module == 'index') {
|
||||
$view_path = './template/' . $theme . '/' ;
|
||||
}else{
|
||||
$view_path = './template/' . $theme . '/' . $module . '/';
|
||||
}
|
||||
$this->view->config('view_path', $view_path . $view_path_pre)
|
||||
->config('tpl_replace_string',array(
|
||||
'__IMG__' => BASE_PATH . '/' . $view_path . 'static/images',
|
||||
'__JS__' => BASE_PATH . '/' . $view_path . 'static/js',
|
||||
'__CSS__' => BASE_PATH . '/' . $view_path . 'static/css',
|
||||
));
|
||||
|
||||
$tpl_replace = array(
|
||||
'__TPL__' => $view_path,
|
||||
'__CSS__' => $view_path . 'static/css/',
|
||||
'__JS__' => $view_path . 'static/js/',
|
||||
'__IMG__' => $view_path . 'static/images/',
|
||||
);
|
||||
$tpl_conf = array(
|
||||
'view_path' => $view_path,
|
||||
'tpl_replace_string' => $tpl_replace
|
||||
);
|
||||
$this->view->config($tpl_conf);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,105 +0,0 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
/**
|
||||
* 设置模型
|
||||
*/
|
||||
class Attribute extends Base{
|
||||
|
||||
protected $type = array(
|
||||
'id' => 'integer',
|
||||
);
|
||||
|
||||
protected static function init(){
|
||||
self::afterInsert(function($data){
|
||||
if ($data['model_id']) {
|
||||
$name = db('Model')->where('id', $data['model_id'])->value('name');
|
||||
$db = new \com\Datatable();
|
||||
$attr = $data->toArray();
|
||||
$model_attr = array(
|
||||
'model_id' => $data['model_id'],
|
||||
'attr_id' => $data->id,
|
||||
'group_id' => 0,
|
||||
'is_add_table' => 1,
|
||||
'is_show' => $data['is_show'],
|
||||
'is_must' => $data['is_must'],
|
||||
'sort' => 0,
|
||||
);
|
||||
$attr['after'] = db('Attribute')->where('name', '<>', $data['name'])->where('model_id', $data['model_id'])->order('id desc')->value('name');
|
||||
return $db->columField(strtolower($name), $attr)->query();
|
||||
}
|
||||
});
|
||||
self::beforeUpdate(function($data){
|
||||
$attr = $data->toArray();
|
||||
$attr['action'] = 'CHANGE';
|
||||
$attr['oldname'] = db('Attribute')->where('id', $attr['id'])->value('name');
|
||||
if ($attr['id']) {
|
||||
$name = db('Model')->where('id', $attr['model_id'])->value('name');
|
||||
$db = new \com\Datatable();
|
||||
return $db->columField(strtolower($name), $attr)->query();
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected function getTypeTextAttr($value, $data){
|
||||
$type = config('config_type_list');
|
||||
$type_text = explode(',', $type[$data['type']]);
|
||||
return $type_text[0];
|
||||
}
|
||||
|
||||
public function getFieldlist($map,$index='id'){
|
||||
$list = array();
|
||||
$row = db('Attribute')->field('*,remark as help,type,extra as "option",model_id')->where($map)->order('group_id asc, sort asc')->select();
|
||||
foreach ($row as $key => $value) {
|
||||
if (in_array($value['type'],array('checkbox','radio','select','bool'))) {
|
||||
$value['option'] = parse_field_attr($value['extra']);
|
||||
} elseif ($value['type'] == 'bind') {
|
||||
$extra = parse_field_bind($value['extra'], '', $value['model_id']);
|
||||
$option = array();
|
||||
foreach ($extra as $k => $v) {
|
||||
$option[$v['id']] = $v['title_show'];
|
||||
}
|
||||
$value['option'] = $option;
|
||||
}
|
||||
$list[$value['id']] = $value;
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
public function del($id, $model_id){
|
||||
$map['id'] = $id;
|
||||
$info = $this->find($id);
|
||||
$tablename = db('Model')->where(array('id'=>$model_id))->value('name');
|
||||
|
||||
//先删除字段表内的数据
|
||||
$result = $this->where($map)->delete();
|
||||
if ($result) {
|
||||
$tablename = strtolower($tablename);
|
||||
//删除模型表中字段
|
||||
$db = new \com\Datatable();
|
||||
if (!$db->CheckField($tablename,$info['name'])) {
|
||||
return true;
|
||||
}
|
||||
$result = $db->delField($tablename,$info['name'])->query();
|
||||
if ($result) {
|
||||
return true;
|
||||
}else{
|
||||
$this->error = "删除失败!";
|
||||
return false;
|
||||
}
|
||||
}else{
|
||||
$this->error = "删除失败!";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,40 +1,8 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
/**
|
||||
* 模型基类
|
||||
*/
|
||||
class Base extends \think\Model{
|
||||
use think\Model;
|
||||
|
||||
protected $param;
|
||||
protected $type = array(
|
||||
'id' => 'integer',
|
||||
'cover_id' => 'integer',
|
||||
);
|
||||
class Base extends Model {
|
||||
|
||||
public function initialize(){
|
||||
parent::initialize();
|
||||
$this->param = \think\Request::instance()->param();
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据修改
|
||||
* @return [bool] [是否成功]
|
||||
*/
|
||||
public function change(){
|
||||
$data = \think\Request::instance()->post();
|
||||
if (isset($data['id']) && $data['id']) {
|
||||
return $this->save($data, array('id'=>$data['id']));
|
||||
}else{
|
||||
return $this->save($data);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
/**
|
||||
* 设置模型
|
||||
*/
|
||||
class Channel extends Base{
|
||||
|
||||
protected $type = array(
|
||||
'id' => 'integer',
|
||||
);
|
||||
|
||||
protected $auto = array('update_time', 'status'=>1);
|
||||
protected $insert = array('create_time');
|
||||
}
|
||||
@@ -80,7 +80,7 @@ class Config extends Base{
|
||||
}
|
||||
|
||||
protected function getList($type){
|
||||
$path = ROOT_PATH . 'template/';
|
||||
$path = './template/';
|
||||
$file = opendir($path);
|
||||
while (false !== ($filename = readdir($file))) {
|
||||
if (!in_array($filename, array('.', '..'))) {
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
/**
|
||||
* 用户模型
|
||||
*/
|
||||
class MemberExtend extends Base{
|
||||
|
||||
protected $type = array(
|
||||
'uid' => 'integer',
|
||||
);
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
/**
|
||||
* 菜单模型类
|
||||
* @author molong <molong@tensent.cn>
|
||||
*/
|
||||
class Menu extends \app\common\model\Base {
|
||||
|
||||
protected $type = array(
|
||||
'id' => 'integer',
|
||||
);
|
||||
|
||||
public function getAuthNodes($type = 'admin'){
|
||||
$map['type'] = $type;
|
||||
$rows = $this->db()->field('id,pid,group,title,url')->where($map)->order('id asc')->select();
|
||||
foreach ($rows as $key => $value) {
|
||||
$data[$value['id']] = $value;
|
||||
}
|
||||
foreach ($data as $key => $value) {
|
||||
if ($value['pid'] > 0) {
|
||||
$value['group'] = $data[$value['pid']]['title'] . '管理';
|
||||
$list[] = $value;
|
||||
}
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
}
|
||||
@@ -1,282 +0,0 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
/**
|
||||
* 用户模型
|
||||
*/
|
||||
class User extends Base{
|
||||
|
||||
protected $name = "Member";
|
||||
protected $createTime = 'reg_time';
|
||||
protected $updateTime = 'last_login_time';
|
||||
|
||||
protected $type = array(
|
||||
'uid' => 'integer',
|
||||
'reg_time' => 'integer'
|
||||
);
|
||||
protected $insert = array('status', 'reg_time');
|
||||
protected $update = array();
|
||||
|
||||
public $editfield = array(
|
||||
array('name'=>'uid','type'=>'hidden'),
|
||||
array('name'=>'username','title'=>'用户名','type'=>'readonly','help'=>''),
|
||||
array('name'=>'nickname','title'=>'昵称','type'=>'text','help'=>''),
|
||||
array('name'=>'password','title'=>'密码','type'=>'password','help'=>'为空时则不修改'),
|
||||
array('name'=>'sex','title'=>'性别','type'=>'select','option'=>array('0'=>'保密','1'=>'男','2'=>'女'),'help'=>''),
|
||||
array('name'=>'email','title'=>'邮箱','type'=>'text','help'=>'用户邮箱,用于找回密码等安全操作'),
|
||||
array('name'=>'qq','title'=>'QQ','type'=>'text','help'=>''),
|
||||
array('name'=>'score','title'=>'用户积分','type'=>'text','help'=>''),
|
||||
array('name'=>'signature','title'=>'用户签名','type'=>'textarea','help'=>''),
|
||||
array('name'=>'status','title'=>'状态','type'=>'select','option'=>array('0'=>'禁用','1'=>'启用'),'help'=>''),
|
||||
);
|
||||
|
||||
public $addfield = array(
|
||||
array('name'=>'username','title'=>'用户名','type'=>'text','help'=>'用户名会作为默认的昵称'),
|
||||
array('name'=>'password','title'=>'密码','type'=>'password','help'=>'用户密码不能少于6位'),
|
||||
array('name'=>'repassword','title'=>'确认密码','type'=>'password','help'=>'确认密码'),
|
||||
array('name'=>'email','title'=>'邮箱','type'=>'text','help'=>'用户邮箱,用于找回密码等安全操作'),
|
||||
);
|
||||
|
||||
public $useredit = array(
|
||||
array('name'=>'uid','type'=>'hidden'),
|
||||
array('name'=>'nickname','title'=>'昵称','type'=>'text','help'=>''),
|
||||
array('name'=>'sex','title'=>'性别','type'=>'select','option'=>array('0'=>'保密','1'=>'男','2'=>'女'),'help'=>''),
|
||||
array('name'=>'email','title'=>'邮箱','type'=>'text','help'=>'用户邮箱,用于找回密码等安全操作'),
|
||||
array('name'=>'mobile','title'=>'联系电话','type'=>'text','help'=>''),
|
||||
array('name'=>'qq','title'=>'QQ','type'=>'text','help'=>''),
|
||||
array('name'=>'signature','title'=>'用户签名','type'=>'textarea','help'=>''),
|
||||
);
|
||||
|
||||
public $userextend = array(
|
||||
array('name'=>'company','title'=>'单位名称','type'=>'text','help'=>''),
|
||||
array('name'=>'company_addr','title'=>'单位地址','type'=>'text','help'=>''),
|
||||
array('name'=>'company_contact','title'=>'单位联系人','type'=>'text','help'=>''),
|
||||
array('name'=>'company_zip','title'=>'单位邮编','type'=>'text','help'=>''),
|
||||
array('name'=>'company_depart','title'=>'所属部门','type'=>'text','help'=>''),
|
||||
array('name'=>'company_post','title'=>'所属职务','type'=>'text','help'=>''),
|
||||
array('name'=>'company_type','title'=>'单位类型','type'=>'select', 'option'=>'', 'help'=>''),
|
||||
);
|
||||
|
||||
protected function setStatusAttr($value){
|
||||
return 1;
|
||||
}
|
||||
|
||||
protected function setPasswordAttr($value, $data){
|
||||
return md5($value.$data['salt']);
|
||||
}
|
||||
|
||||
protected function getGroupListAttr($value, $data){
|
||||
$sql = db('AuthGroupAccess')->where('uid', $data['uid'])->fetchSql(true)->column('group_id');
|
||||
return db('AuthGroup')->where('id in ('.$sql.')')->column('title', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户登录模型
|
||||
* @param string $username [description]
|
||||
* @param string $password [description]
|
||||
* @param integer $type 登录类型,1为用户名登录2为邮箱登录3为手机登录4为用户ID登录5为微信登录
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function login($username = '', $password = '', $type = 1) {
|
||||
$map = array();
|
||||
if (\think\Validate::is($username, 'email')) {
|
||||
$type = 2;
|
||||
} elseif (preg_match("/^1[34578]{1}\d{9}$/", $username)) {
|
||||
$type = 3;
|
||||
}
|
||||
switch ($type) {
|
||||
case 1:
|
||||
$map['username'] = $username;
|
||||
break;
|
||||
case 2:
|
||||
$map['email'] = $username;
|
||||
break;
|
||||
case 3:
|
||||
$map['mobile'] = $username;
|
||||
break;
|
||||
case 4:
|
||||
$map['uid'] = $username;
|
||||
break;
|
||||
case 5:
|
||||
$map['openid'] = $username;
|
||||
break;
|
||||
default:
|
||||
return 0; //参数错误
|
||||
}
|
||||
if (!$username) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$user = $this->where($map)->find();
|
||||
if (isset($user['uid']) && $user['uid'] && $user['status']) {
|
||||
if ($type == 3) {
|
||||
//手机验证手机动态密码
|
||||
if ($password == session('mobile_login_code')) {
|
||||
$this->autoLogin($user); //更新用户登录信息
|
||||
return $user['uid'];
|
||||
}else{
|
||||
return -5;
|
||||
}
|
||||
} elseif ($type == 5) {
|
||||
$this->autoLogin($user); //更新用户登录信息
|
||||
return $user['uid'];
|
||||
} else {
|
||||
/* 验证用户密码 */
|
||||
if (md5($password . $user['salt']) === $user['password']) {
|
||||
$this->autoLogin($user); //更新用户登录信息
|
||||
return $user['uid']; //登录成功,返回用户ID
|
||||
} else {
|
||||
return -2; //密码错误
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($type == 3 && preg_match("/^1[34578]{1}\d{9}$/", $username) && $password == session('mobile_login_code')) {
|
||||
$data = array(
|
||||
'username' => $username,
|
||||
'mobile' => $username,
|
||||
'salt' => rand_string(6),
|
||||
'password' => $password,
|
||||
);
|
||||
$result = $this->save($data);
|
||||
if ($result) {
|
||||
$this->autoLogin($this->data); //更新用户登录信息
|
||||
}
|
||||
return $this->data['uid'];
|
||||
} else {
|
||||
return -1; //用户不存在或被禁用
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户注册
|
||||
* @param integer $user 用户信息数组
|
||||
*/
|
||||
function register($username, $password, $repassword, $email, $isautologin = true, $other = array()){
|
||||
$data['username'] = $username;
|
||||
$data['salt'] = rand_string(6);
|
||||
$data['password'] = $password;
|
||||
$data['repassword'] = $repassword;
|
||||
$data['email'] = $email;
|
||||
if (!empty($other)) {
|
||||
$data = array_merge($data, $other);
|
||||
}
|
||||
$result = $this->validate(true)->save($data);
|
||||
if ($result) {
|
||||
$data['uid'] = $this->data['uid'];
|
||||
//$this->extend()->save($data);
|
||||
if ($isautologin) {
|
||||
$this->autoLogin($this->data);
|
||||
}
|
||||
return $result;
|
||||
}else{
|
||||
if (!$this->getError()) {
|
||||
$this->error = "注册失败!";
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动登录用户
|
||||
* @param integer $user 用户信息数组
|
||||
*/
|
||||
private function autoLogin($user){
|
||||
/* 更新登录信息 */
|
||||
$data = array(
|
||||
'uid' => $user['uid'],
|
||||
'login' => array('exp', '`login`+1'),
|
||||
'last_login_time' => time(),
|
||||
'last_login_ip' => get_client_ip(1),
|
||||
);
|
||||
$this->where(array('uid'=>$user['uid']))->update($data);
|
||||
$user = $this->where(array('uid'=>$user['uid']))->find();
|
||||
|
||||
/* 记录登录SESSION和COOKIES */
|
||||
$auth = array(
|
||||
'uid' => $user['uid'],
|
||||
'username' => $user['username'],
|
||||
'last_login_time' => $user['last_login_time'],
|
||||
);
|
||||
|
||||
session('user_auth', $auth);
|
||||
session('user_auth_sign', data_auth_sign($auth));
|
||||
}
|
||||
|
||||
public function logout(){
|
||||
session('user_auth', null);
|
||||
session('user_auth_sign', null);
|
||||
}
|
||||
|
||||
public function getInfo($uid){
|
||||
$data = $this->where(array('uid'=>$uid))->find();
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户资料
|
||||
*/
|
||||
public function editUser($data, $ischangepwd = false){
|
||||
if ($data['uid']) {
|
||||
if (!$ischangepwd || ($ischangepwd && $data['password'] == '')) {
|
||||
unset($data['salt']);
|
||||
unset($data['password']);
|
||||
}else{
|
||||
$data['salt'] = rand_string(6);
|
||||
}
|
||||
$result = $this->validate('member.edit')->save($data, array('uid'=>$data['uid']));
|
||||
if ($result) {
|
||||
return $this->extend->save($data, array('uid'=>$data['uid']));
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}else{
|
||||
$this->error = "非法操作!";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function editpw($data, $is_reset = false){
|
||||
$uid = $is_reset ? $data['uid'] : session('user_auth.uid');
|
||||
if (!$is_reset) {
|
||||
//后台修改用户时可修改用户密码时设置为true
|
||||
$this->checkPassword($uid,$data['oldpassword']);
|
||||
|
||||
$validate = $this->validate('member.password');
|
||||
if (false === $validate) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$data['salt'] = rand_string(6);
|
||||
|
||||
return $this->save($data, array('uid'=>$uid));
|
||||
}
|
||||
|
||||
protected function checkPassword($uid,$password){
|
||||
if (!$uid || !$password) {
|
||||
$this->error = '原始用户UID和密码不能为空';
|
||||
return false;
|
||||
}
|
||||
|
||||
$user = $this->where(array('uid'=>$uid))->find();
|
||||
if (md5($password.$user['salt']) === $user['password']) {
|
||||
return true;
|
||||
}else{
|
||||
$this->error = '原始密码错误!';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function extend(){
|
||||
return $this->hasOne('MemberExtend', 'uid');
|
||||
}
|
||||
}
|
||||
+227
-98
@@ -1,115 +1,244 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
||||
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: liu21st <liu21st@gmail.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
return array(
|
||||
return [
|
||||
// +----------------------------------------------------------------------
|
||||
// | 应用设置
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
// 调试模式
|
||||
'app_debug' => true,
|
||||
// 应用调试模式
|
||||
'app_debug' => true,
|
||||
// 应用Trace
|
||||
'app_trace' => false,
|
||||
// 应用模式状态
|
||||
'app_status' => '',
|
||||
// 是否支持多模块
|
||||
'app_multi_module' => true,
|
||||
// 入口自动绑定模块
|
||||
'auto_bind_module' => false,
|
||||
// 注册的根命名空间
|
||||
'root_namespace' => [],
|
||||
// 扩展函数文件
|
||||
'extra_file_list' => [THINK_PATH . 'helper' . EXT],
|
||||
// 默认输出类型
|
||||
'default_return_type' => 'html',
|
||||
// 默认AJAX 数据返回格式,可选json xml ...
|
||||
'default_ajax_return' => 'json',
|
||||
// 默认JSONP格式返回的处理方法
|
||||
'default_jsonp_handler' => 'jsonpReturn',
|
||||
// 默认JSONP处理方法
|
||||
'var_jsonp_handler' => 'callback',
|
||||
// 默认时区
|
||||
'default_timezone' => 'PRC',
|
||||
// 是否开启多语言
|
||||
'lang_switch_on' => false,
|
||||
// 默认全局过滤方法 用逗号分隔多个
|
||||
'default_filter' => '',
|
||||
// 默认语言
|
||||
'default_lang' => 'zh-cn',
|
||||
// 应用类库后缀
|
||||
'class_suffix' => false,
|
||||
// 控制器类后缀
|
||||
'controller_suffix' => false,
|
||||
|
||||
'charset' => 'UTF-8',
|
||||
'lang_switch_on' => true, // 开启语言包功能
|
||||
'lang_list' => ['zh-cn'], // 支持的语言列表
|
||||
// +----------------------------------------------------------------------
|
||||
// | 模块设置
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
'data_auth_key' => 'sent',
|
||||
// 默认模块名
|
||||
'default_module' => 'index',
|
||||
// 禁止访问模块
|
||||
'deny_module_list' => ['common'],
|
||||
// 默认控制器名
|
||||
'default_controller' => 'Index',
|
||||
// 默认操作名
|
||||
'default_action' => 'index',
|
||||
// 默认验证器
|
||||
'default_validate' => '',
|
||||
// 默认的空控制器名
|
||||
'empty_controller' => 'Error',
|
||||
// 操作方法后缀
|
||||
'action_suffix' => '',
|
||||
// 自动搜索控制器
|
||||
'controller_auto_search' => false,
|
||||
|
||||
'base_url' => BASE_PATH,
|
||||
'url_route_on' => true,
|
||||
'url_common_param' => false,
|
||||
// +----------------------------------------------------------------------
|
||||
// | URL设置
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
'template' => array(
|
||||
'taglib_build_in' => 'cx,com\Sent',
|
||||
),
|
||||
// PATHINFO变量名 用于兼容模式
|
||||
'var_pathinfo' => 's',
|
||||
// 兼容PATH_INFO获取
|
||||
'pathinfo_fetch' => ['ORIG_PATH_INFO', 'REDIRECT_PATH_INFO', 'REDIRECT_URL'],
|
||||
// pathinfo分隔符
|
||||
'pathinfo_depr' => '/',
|
||||
// URL伪静态后缀
|
||||
'url_html_suffix' => 'html',
|
||||
// URL普通方式参数 用于自动生成
|
||||
'url_common_param' => false,
|
||||
// URL参数方式 0 按名称成对解析 1 按顺序解析
|
||||
'url_param_type' => 0,
|
||||
// 是否开启路由
|
||||
'url_route_on' => true,
|
||||
// 路由使用完整匹配
|
||||
'route_complete_match' => false,
|
||||
// 路由配置文件(支持配置多个)
|
||||
'route_config_file' => ['route'],
|
||||
// 是否强制使用路由
|
||||
'url_route_must' => false,
|
||||
// 域名部署
|
||||
'url_domain_deploy' => false,
|
||||
// 域名根,如thinkphp.cn
|
||||
'url_domain_root' => '',
|
||||
// 是否自动转换URL中的控制器和操作名
|
||||
'url_convert' => true,
|
||||
// 默认的访问控制器层
|
||||
'url_controller_layer' => 'controller',
|
||||
// 表单请求类型伪装变量
|
||||
'var_method' => '_method',
|
||||
// 表单ajax伪装变量
|
||||
'var_ajax' => '_ajax',
|
||||
// 表单pjax伪装变量
|
||||
'var_pjax' => '_pjax',
|
||||
// 是否开启请求缓存 true自动缓存 支持设置请求缓存规则
|
||||
'request_cache' => false,
|
||||
// 请求缓存有效期
|
||||
'request_cache_expire' => null,
|
||||
// 全局请求缓存排除规则
|
||||
'request_cache_except' => [],
|
||||
|
||||
// 'dispatch_success_tmpl' => APP_PATH . 'common/view/default/jump.html',
|
||||
// 'dispatch_error_tmpl' => APP_PATH . 'common/view/default/jump.html',
|
||||
// +----------------------------------------------------------------------
|
||||
// | 模板设置
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
'attachment_upload' => array(
|
||||
// 允许上传的文件MiMe类型
|
||||
'mimes' => [],
|
||||
// 上传的文件大小限制 (0-不做限制)
|
||||
'maxSize' => 0,
|
||||
// 允许上传的文件后缀
|
||||
'exts' => [],
|
||||
// 子目录创建方式,[0]-函数名,[1]-参数,多个参数使用数组
|
||||
'subName' => ['date', 'Ymd'],
|
||||
//保存根路径
|
||||
'rootPath' => './uploads/attachment',
|
||||
// 保存路径
|
||||
'savePath' => '',
|
||||
// 上传文件命名规则,[0]-函数名,[1]-参数,多个参数使用数组
|
||||
'saveName' => ['uniqid', ''],
|
||||
// 文件上传驱动e,
|
||||
'driver' => 'Local',
|
||||
),
|
||||
'template' => [
|
||||
// 模板引擎类型 支持 php think 支持扩展
|
||||
'type' => 'Think',
|
||||
// 模板路径
|
||||
'view_path' => '',
|
||||
// 模板后缀
|
||||
'view_suffix' => 'html',
|
||||
// 模板文件名分隔符
|
||||
'view_depr' => DS,
|
||||
// 模板引擎普通标签开始标记
|
||||
'tpl_begin' => '{',
|
||||
// 模板引擎普通标签结束标记
|
||||
'tpl_end' => '}',
|
||||
// 标签库标签开始标记
|
||||
'taglib_begin' => '{',
|
||||
// 标签库标签结束标记
|
||||
'taglib_end' => '}',
|
||||
],
|
||||
|
||||
'editor_upload' => array(
|
||||
// 允许上传的文件MiMe类型
|
||||
'mimes' => [],
|
||||
// 上传的文件大小限制 (0-不做限制)
|
||||
'maxSize' => 0,
|
||||
// 允许上传的文件后缀
|
||||
'exts' => [],
|
||||
// 子目录创建方式,[0]-函数名,[1]-参数,多个参数使用数组
|
||||
'subName' => ['date', 'Ymd'],
|
||||
//保存根路径
|
||||
'rootPath' => './uploads/editor',
|
||||
// 保存路径
|
||||
'savePath' => '',
|
||||
// 上传文件命名规则,[0]-函数名,[1]-参数,多个参数使用数组
|
||||
'saveName' => ['uniqid', ''],
|
||||
// 文件上传驱动e,
|
||||
'driver' => 'Local',
|
||||
),
|
||||
// 视图输出字符串内容替换
|
||||
'view_replace_str' => [
|
||||
'__PUBLIC__' => '/static',
|
||||
'__STATIC__' => '/static',
|
||||
'__JS__' => '/static/js',
|
||||
'__CSS__' => '/static/css',
|
||||
],
|
||||
// 默认跳转页面对应的模板文件
|
||||
'dispatch_success_tmpl' => THINK_PATH . 'tpl' . DS . 'dispatch_jump.tpl',
|
||||
'dispatch_error_tmpl' => THINK_PATH . 'tpl' . DS . 'dispatch_jump.tpl',
|
||||
|
||||
'picture_upload' => array(
|
||||
// 允许上传的文件MiMe类型
|
||||
'mimes' => [],
|
||||
// 上传的文件大小限制 (0-不做限制)
|
||||
'maxSize' => 0,
|
||||
// 允许上传的文件后缀
|
||||
'exts' => [],
|
||||
// 子目录创建方式,[0]-函数名,[1]-参数,多个参数使用数组
|
||||
'subName' => ['date', 'Ymd'],
|
||||
//保存根路径
|
||||
'rootPath' => './uploads/picture',
|
||||
// 保存路径
|
||||
'savePath' => '',
|
||||
// 上传文件命名规则,[0]-函数名,[1]-参数,多个参数使用数组
|
||||
'saveName' => ['uniqid', ''],
|
||||
// 文件上传驱动e,
|
||||
'driver' => 'Local',
|
||||
),
|
||||
'session' => array(
|
||||
'prefix' => 'sent',
|
||||
'type' => '',
|
||||
'auto_start' => true,
|
||||
),
|
||||
// +----------------------------------------------------------------------
|
||||
// | 异常及错误设置
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
'log' => array(
|
||||
// 日志记录方式,支持 file sae
|
||||
'type' => 'file',
|
||||
// 日志保存目录
|
||||
'path' => LOG_PATH,
|
||||
),
|
||||
'app_trace' => false,
|
||||
// 页面Trace信息
|
||||
'trace' => array(
|
||||
//支持Html,Console 设为false则不显示
|
||||
'type' => 'Console',
|
||||
),
|
||||
// 异常页面的模板文件
|
||||
'exception_tmpl' => THINK_PATH . 'tpl' . DS . 'think_exception.tpl',
|
||||
|
||||
'view_replace_str' => array(
|
||||
'__ADDONS__' => BASE_PATH . '/addons',
|
||||
'__PUBLIC__' => BASE_PATH . '/public',
|
||||
),
|
||||
'wechat' => array(
|
||||
'appid'=>'wx4924a63b43e2fc1a',
|
||||
'appsecret'=>'0821fc43d2305d4b4722a591361df438'
|
||||
)
|
||||
);
|
||||
// 错误显示信息,非调试模式有效
|
||||
'error_message' => '页面错误!请稍后再试~',
|
||||
// 显示错误信息
|
||||
'show_error_msg' => false,
|
||||
// 异常处理handle类 留空使用 \think\exception\Handle
|
||||
'exception_handle' => '',
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | 日志设置
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
'log' => [
|
||||
// 日志记录方式,内置 file socket 支持扩展
|
||||
'type' => 'File',
|
||||
// 日志保存目录
|
||||
'path' => LOG_PATH,
|
||||
// 日志记录级别
|
||||
'level' => [],
|
||||
],
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Trace设置 开启 app_trace 后 有效
|
||||
// +----------------------------------------------------------------------
|
||||
'trace' => [
|
||||
// 内置Html Console 支持扩展
|
||||
'type' => 'Html',
|
||||
],
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | 缓存设置
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
'cache' => [
|
||||
// 驱动方式
|
||||
'type' => 'File',
|
||||
// 缓存保存目录
|
||||
'path' => CACHE_PATH,
|
||||
// 缓存前缀
|
||||
'prefix' => '',
|
||||
// 缓存有效期 0表示永久缓存
|
||||
'expire' => 0,
|
||||
],
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | 会话设置
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
'session' => [
|
||||
'id' => '',
|
||||
// SESSION_ID的提交变量,解决flash上传跨域
|
||||
'var_session_id' => '',
|
||||
// SESSION 前缀
|
||||
'prefix' => 'think',
|
||||
// 驱动方式 支持redis memcache memcached
|
||||
'type' => '',
|
||||
// 是否自动开启 SESSION
|
||||
'auto_start' => true,
|
||||
],
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Cookie设置
|
||||
// +----------------------------------------------------------------------
|
||||
'cookie' => [
|
||||
// cookie 名称前缀
|
||||
'prefix' => '',
|
||||
// cookie 保存时间
|
||||
'expire' => 0,
|
||||
// cookie 保存路径
|
||||
'path' => '/',
|
||||
// cookie 有效域名
|
||||
'domain' => '',
|
||||
// cookie 启用安全传输
|
||||
'secure' => false,
|
||||
// httponly设置
|
||||
'httponly' => '',
|
||||
// 是否使用 setcookie
|
||||
'setcookie' => true,
|
||||
],
|
||||
|
||||
//分页配置
|
||||
'paginate' => [
|
||||
'type' => 'bootstrap',
|
||||
'var_page' => 'page',
|
||||
'list_rows' => 15,
|
||||
],
|
||||
];
|
||||
|
||||
+27
-3
@@ -1,4 +1,28 @@
|
||||
<?php
|
||||
return array(
|
||||
'app_init' => array('app\\common\\behavior\\InitHook'),
|
||||
);
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: liu21st <liu21st@gmail.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
// 应用行为扩展定义文件
|
||||
return [
|
||||
// 应用初始化
|
||||
'app_init' => ['app\\common\\behavior\\InitHook'],
|
||||
// 应用开始
|
||||
'app_begin' => [],
|
||||
// 模块初始化
|
||||
'module_init' => [],
|
||||
// 操作开始执行
|
||||
'action_begin' => [],
|
||||
// 视图内容过滤
|
||||
'view_filter' => [],
|
||||
// 日志写入
|
||||
'log_write' => [],
|
||||
// 应用结束
|
||||
'app_end' => [],
|
||||
];
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: liu21st <liu21st@gmail.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
define('THINK_VERSION', '5.0.14');
|
||||
define('THINK_START_TIME', microtime(true));
|
||||
define('THINK_START_MEM', memory_get_usage());
|
||||
define('EXT', '.php');
|
||||
define('DS', DIRECTORY_SEPARATOR);
|
||||
defined('THINK_PATH') or define('THINK_PATH', __DIR__ . DS);
|
||||
define('LIB_PATH', THINK_PATH . 'library' . DS);
|
||||
define('CORE_PATH', LIB_PATH . 'think' . DS);
|
||||
define('TRAIT_PATH', LIB_PATH . 'traits' . DS);
|
||||
defined('APP_PATH') or define('APP_PATH', dirname($_SERVER['SCRIPT_FILENAME']) . DS);
|
||||
defined('ROOT_PATH') or define('ROOT_PATH', dirname(realpath(APP_PATH)) . DS);
|
||||
defined('EXTEND_PATH') or define('EXTEND_PATH', ROOT_PATH . 'extend' . DS);
|
||||
defined('VENDOR_PATH') or define('VENDOR_PATH', ROOT_PATH . 'vendor' . DS);
|
||||
defined('RUNTIME_PATH') or define('RUNTIME_PATH', ROOT_PATH . 'runtime' . DS);
|
||||
defined('LOG_PATH') or define('LOG_PATH', RUNTIME_PATH . 'log' . DS);
|
||||
defined('CACHE_PATH') or define('CACHE_PATH', RUNTIME_PATH . 'cache' . DS);
|
||||
defined('TEMP_PATH') or define('TEMP_PATH', RUNTIME_PATH . 'temp' . DS);
|
||||
defined('CONF_PATH') or define('CONF_PATH', APP_PATH); // 配置文件目录
|
||||
defined('CONF_EXT') or define('CONF_EXT', EXT); // 配置文件后缀
|
||||
defined('ENV_PREFIX') or define('ENV_PREFIX', 'PHP_'); // 环境变量的配置前缀
|
||||
|
||||
// 环境常量
|
||||
define('IS_CLI', PHP_SAPI == 'cli' ? true : false);
|
||||
define('IS_WIN', strpos(PHP_OS, 'WIN') !== false);
|
||||
|
||||
// 载入Loader类
|
||||
require CORE_PATH . 'Loader.php';
|
||||
|
||||
// 加载环境变量配置文件
|
||||
if (is_file(ROOT_PATH . '.env')) {
|
||||
$env = parse_ini_file(ROOT_PATH . '.env', true);
|
||||
|
||||
foreach ($env as $key => $val) {
|
||||
$name = ENV_PREFIX . strtoupper($key);
|
||||
|
||||
if (is_array($val)) {
|
||||
foreach ($val as $k => $v) {
|
||||
$item = $name . '_' . strtoupper($k);
|
||||
putenv("$item=$v");
|
||||
}
|
||||
} else {
|
||||
putenv("$name=$val");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 注册自动加载
|
||||
\think\Loader::register();
|
||||
|
||||
// 注册错误和异常处理机制
|
||||
\think\Error::register();
|
||||
|
||||
// 加载惯例配置文件
|
||||
\think\Config::set(include THINK_PATH . 'convention' . EXT);
|
||||
@@ -1,20 +0,0 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006-2017 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: yunwuxin <448901948@qq.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace think;
|
||||
|
||||
// ThinkPHP 引导文件
|
||||
// 加载基础文件
|
||||
require __DIR__ . '/base.php';
|
||||
|
||||
// 执行应用
|
||||
App::initCommon();
|
||||
Console::init();
|
||||
@@ -1,289 +0,0 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
// +----------------------------------------------------------------------
|
||||
// | 应用设置
|
||||
// +----------------------------------------------------------------------
|
||||
// 默认Host地址
|
||||
'app_host' => '',
|
||||
// 应用调试模式
|
||||
'app_debug' => false,
|
||||
// 应用Trace
|
||||
'app_trace' => false,
|
||||
// 应用模式状态
|
||||
'app_status' => '',
|
||||
// 是否支持多模块
|
||||
'app_multi_module' => true,
|
||||
// 入口自动绑定模块
|
||||
'auto_bind_module' => false,
|
||||
// 注册的根命名空间
|
||||
'root_namespace' => [],
|
||||
// 扩展函数文件
|
||||
'extra_file_list' => [THINK_PATH . 'helper' . EXT],
|
||||
// 默认输出类型
|
||||
'default_return_type' => 'html',
|
||||
// 默认AJAX 数据返回格式,可选json xml ...
|
||||
'default_ajax_return' => 'json',
|
||||
// 默认JSONP格式返回的处理方法
|
||||
'default_jsonp_handler' => 'jsonpReturn',
|
||||
// 默认JSONP处理方法
|
||||
'var_jsonp_handler' => 'callback',
|
||||
// 默认时区
|
||||
'default_timezone' => 'PRC',
|
||||
// 是否开启多语言
|
||||
'lang_switch_on' => false,
|
||||
// 默认全局过滤方法 用逗号分隔多个
|
||||
'default_filter' => '',
|
||||
// 默认语言
|
||||
'default_lang' => 'zh-cn',
|
||||
// 应用类库后缀
|
||||
'class_suffix' => false,
|
||||
// 控制器类后缀
|
||||
'controller_suffix' => false,
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | 模块设置
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
// 默认模块名
|
||||
'default_module' => 'index',
|
||||
// 禁止访问模块
|
||||
'deny_module_list' => ['common'],
|
||||
// 默认控制器名
|
||||
'default_controller' => 'Index',
|
||||
// 默认操作名
|
||||
'default_action' => 'index',
|
||||
// 默认验证器
|
||||
'default_validate' => '',
|
||||
// 默认的空控制器名
|
||||
'empty_controller' => 'Error',
|
||||
// 操作方法前缀
|
||||
'use_action_prefix' => false,
|
||||
// 操作方法后缀
|
||||
'action_suffix' => '',
|
||||
// 自动搜索控制器
|
||||
'controller_auto_search' => false,
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | URL设置
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
// PATHINFO变量名 用于兼容模式
|
||||
'var_pathinfo' => 's',
|
||||
// 兼容PATH_INFO获取
|
||||
'pathinfo_fetch' => ['ORIG_PATH_INFO', 'REDIRECT_PATH_INFO', 'REDIRECT_URL'],
|
||||
// pathinfo分隔符
|
||||
'pathinfo_depr' => '/',
|
||||
// HTTPS代理标识
|
||||
'https_agent_name' => '',
|
||||
// URL伪静态后缀
|
||||
'url_html_suffix' => 'html',
|
||||
// URL普通方式参数 用于自动生成
|
||||
'url_common_param' => false,
|
||||
// URL参数方式 0 按名称成对解析 1 按顺序解析
|
||||
'url_param_type' => 0,
|
||||
// 是否开启路由
|
||||
'url_route_on' => true,
|
||||
// 路由配置文件(支持配置多个)
|
||||
'route_config_file' => ['route'],
|
||||
// 路由使用完整匹配
|
||||
'route_complete_match' => false,
|
||||
// 是否强制使用路由
|
||||
'url_route_must' => false,
|
||||
// 域名部署
|
||||
'url_domain_deploy' => false,
|
||||
// 域名根,如thinkphp.cn
|
||||
'url_domain_root' => '',
|
||||
// 是否自动转换URL中的控制器和操作名
|
||||
'url_convert' => true,
|
||||
// 默认的访问控制器层
|
||||
'url_controller_layer' => 'controller',
|
||||
// 表单请求类型伪装变量
|
||||
'var_method' => '_method',
|
||||
// 表单ajax伪装变量
|
||||
'var_ajax' => '_ajax',
|
||||
// 表单pjax伪装变量
|
||||
'var_pjax' => '_pjax',
|
||||
// 是否开启请求缓存 true自动缓存 支持设置请求缓存规则
|
||||
'request_cache' => false,
|
||||
// 请求缓存有效期
|
||||
'request_cache_expire' => null,
|
||||
// 全局请求缓存排除规则
|
||||
'request_cache_except' => [],
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | 模板设置
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
'template' => [
|
||||
// 模板引擎类型 支持 php think 支持扩展
|
||||
'type' => 'Think',
|
||||
// 视图基础目录,配置目录为所有模块的视图起始目录
|
||||
'view_base' => '',
|
||||
// 当前模板的视图目录 留空为自动获取
|
||||
'view_path' => '',
|
||||
// 模板后缀
|
||||
'view_suffix' => 'html',
|
||||
// 模板文件名分隔符
|
||||
'view_depr' => DS,
|
||||
// 模板引擎普通标签开始标记
|
||||
'tpl_begin' => '{',
|
||||
// 模板引擎普通标签结束标记
|
||||
'tpl_end' => '}',
|
||||
// 标签库标签开始标记
|
||||
'taglib_begin' => '{',
|
||||
// 标签库标签结束标记
|
||||
'taglib_end' => '}',
|
||||
],
|
||||
|
||||
// 视图输出字符串内容替换
|
||||
'view_replace_str' => [],
|
||||
// 默认跳转页面对应的模板文件
|
||||
'dispatch_success_tmpl' => THINK_PATH . 'tpl' . DS . 'dispatch_jump.tpl',
|
||||
'dispatch_error_tmpl' => THINK_PATH . 'tpl' . DS . 'dispatch_jump.tpl',
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | 异常及错误设置
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
// 异常页面的模板文件
|
||||
'exception_tmpl' => THINK_PATH . 'tpl' . DS . 'think_exception.tpl',
|
||||
|
||||
// 错误显示信息,非调试模式有效
|
||||
'error_message' => '页面错误!请稍后再试~',
|
||||
// 显示错误信息
|
||||
'show_error_msg' => false,
|
||||
// 异常处理handle类 留空使用 \think\exception\Handle
|
||||
'exception_handle' => '',
|
||||
// 是否记录trace信息到日志
|
||||
'record_trace' => false,
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | 日志设置
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
'log' => [
|
||||
// 日志记录方式,内置 file socket 支持扩展
|
||||
'type' => 'File',
|
||||
// 日志保存目录
|
||||
'path' => LOG_PATH,
|
||||
// 日志记录级别
|
||||
'level' => [],
|
||||
],
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Trace设置 开启 app_trace 后 有效
|
||||
// +----------------------------------------------------------------------
|
||||
'trace' => [
|
||||
// 内置Html Console 支持扩展
|
||||
'type' => 'Html',
|
||||
],
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | 缓存设置
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
'cache' => [
|
||||
// 驱动方式
|
||||
'type' => 'File',
|
||||
// 缓存保存目录
|
||||
'path' => CACHE_PATH,
|
||||
// 缓存前缀
|
||||
'prefix' => '',
|
||||
// 缓存有效期 0表示永久缓存
|
||||
'expire' => 0,
|
||||
],
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | 会话设置
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
'session' => [
|
||||
'id' => '',
|
||||
// SESSION_ID的提交变量,解决flash上传跨域
|
||||
'var_session_id' => '',
|
||||
// SESSION 前缀
|
||||
'prefix' => 'think',
|
||||
// 驱动方式 支持redis memcache memcached
|
||||
'type' => '',
|
||||
// 是否自动开启 SESSION
|
||||
'auto_start' => true,
|
||||
'httponly' => true,
|
||||
'secure' => false,
|
||||
],
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Cookie设置
|
||||
// +----------------------------------------------------------------------
|
||||
'cookie' => [
|
||||
// cookie 名称前缀
|
||||
'prefix' => '',
|
||||
// cookie 保存时间
|
||||
'expire' => 0,
|
||||
// cookie 保存路径
|
||||
'path' => '/',
|
||||
// cookie 有效域名
|
||||
'domain' => '',
|
||||
// cookie 启用安全传输
|
||||
'secure' => false,
|
||||
// httponly设置
|
||||
'httponly' => '',
|
||||
// 是否使用 setcookie
|
||||
'setcookie' => true,
|
||||
],
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | 数据库设置
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
'database' => [
|
||||
// 数据库类型
|
||||
'type' => 'mysql',
|
||||
// 数据库连接DSN配置
|
||||
'dsn' => '',
|
||||
// 服务器地址
|
||||
'hostname' => '127.0.0.1',
|
||||
// 数据库名
|
||||
'database' => '',
|
||||
// 数据库用户名
|
||||
'username' => 'root',
|
||||
// 数据库密码
|
||||
'password' => '',
|
||||
// 数据库连接端口
|
||||
'hostport' => '',
|
||||
// 数据库连接参数
|
||||
'params' => [],
|
||||
// 数据库编码默认采用utf8
|
||||
'charset' => 'utf8',
|
||||
// 数据库表前缀
|
||||
'prefix' => '',
|
||||
// 数据库调试模式
|
||||
'debug' => false,
|
||||
// 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器)
|
||||
'deploy' => 0,
|
||||
// 数据库读写是否分离 主从式有效
|
||||
'rw_separate' => false,
|
||||
// 读写分离后 主服务器数量
|
||||
'master_num' => 1,
|
||||
// 指定从服务器序号
|
||||
'slave_no' => '',
|
||||
// 是否严格检查字段是否存在
|
||||
'fields_strict' => true,
|
||||
// 数据集返回类型
|
||||
'resultset_type' => 'array',
|
||||
// 自动写入时间戳字段
|
||||
'auto_timestamp' => false,
|
||||
// 时间字段取出后的默认时间格式
|
||||
'datetime_format' => 'Y-m-d H:i:s',
|
||||
// 是否需要进行SQL性能分析
|
||||
'sql_explain' => false,
|
||||
],
|
||||
|
||||
//分页配置
|
||||
'paginate' => [
|
||||
'type' => 'bootstrap',
|
||||
'var_page' => 'page',
|
||||
'list_rows' => 15,
|
||||
],
|
||||
|
||||
];
|
||||
@@ -1,3 +0,0 @@
|
||||
[2017/07/03 16:00:58] MSG - Get New AccessToken Success.
|
||||
[2017/07/03 18:02:14] MSG - Get New AccessToken Success.
|
||||
[2017/07/03 22:47:05] MSG - Get New AccessToken Success.
|
||||
@@ -1 +0,0 @@
|
||||
a:2:{s:5:"value";s:138:"hX91IMjz-VD6-uRvXuhwuQb47YPpPKVZ0LQu_ToussTNxywjwyzt26ROt5_wFsRRoGfE9kdLffZmZFgiGf_xRaFHfka8aYQvknDUWXKr5g5lGg84tCKMjCifMBiRjSTkPYYdAGAUDD";s:7:"expired";i:1499098225;}
|
||||
@@ -1 +0,0 @@
|
||||
a:2:{s:5:"value";s:86:"sM4AOVdWfPE4DxkXGEs8VIMcGjJAQX643GrxVbHHaF1crt_AsDafYIdQTn-FW5wCE3l-EU6K8o2ylaud4-1BAA";s:7:"expired";i:1499100325;}
|
||||
@@ -1,146 +0,0 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | wechat-php-sdk
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2017 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方文档: https://www.kancloud.cn/zoujingli/wechat-php-sdk
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/wechat-php-sdk
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace Wechat\Lib;
|
||||
|
||||
use Wechat\Loader;
|
||||
|
||||
/**
|
||||
* 微信SDK基础缓存类
|
||||
*
|
||||
* @author Anyon <zoujingli@qq.com>
|
||||
* @date 2016-08-20 17:50
|
||||
*/
|
||||
class Cache
|
||||
{
|
||||
|
||||
/**
|
||||
* 缓存位置
|
||||
* @var string
|
||||
*/
|
||||
static public $cachepath;
|
||||
|
||||
/**
|
||||
* 设置缓存
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
* @param int $expired
|
||||
* @return mixed
|
||||
*/
|
||||
static public function set($name, $value, $expired = 0)
|
||||
{
|
||||
if (isset(Loader::$callback['CacheSet'])) {
|
||||
return call_user_func_array(Loader::$callback['CacheSet'], func_get_args());
|
||||
}
|
||||
$data = serialize(array('value' => $value, 'expired' => $expired > 0 ? time() + $expired : 0));
|
||||
return self::check() && file_put_contents(self::$cachepath . $name, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取缓存
|
||||
* @param string $name
|
||||
* @return mixed
|
||||
*/
|
||||
static public function get($name)
|
||||
{
|
||||
if (isset(Loader::$callback['CacheGet'])) {
|
||||
return call_user_func_array(Loader::$callback['CacheGet'], func_get_args());
|
||||
}
|
||||
if (self::check() && ($file = self::$cachepath . $name) && file_exists($file) && ($data = file_get_contents($file)) && !empty($data)) {
|
||||
$data = unserialize($data);
|
||||
if (isset($data['expired']) && ($data['expired'] > time() || $data['expired'] === 0)) {
|
||||
return isset($data['value']) ? $data['value'] : null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除缓存
|
||||
* @param string $name
|
||||
* @return mixed
|
||||
*/
|
||||
static public function del($name)
|
||||
{
|
||||
if (isset(Loader::$callback['CacheDel'])) {
|
||||
return call_user_func_array(Loader::$callback['CacheDel'], func_get_args());
|
||||
}
|
||||
return self::check() && @unlink(self::$cachepath . $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* 输出内容到日志
|
||||
* @param string $line
|
||||
* @param string $filename
|
||||
* @return mixed
|
||||
*/
|
||||
static public function put($line, $filename = '')
|
||||
{
|
||||
if (isset(Loader::$callback['CachePut'])) {
|
||||
return call_user_func_array(Loader::$callback['CachePut'], func_get_args());
|
||||
}
|
||||
empty($filename) && $filename = date('Ymd') . '.log';
|
||||
return self::check() && file_put_contents(self::$cachepath . $filename, '[' . date('Y/m/d H:i:s') . "] {$line}\n", FILE_APPEND);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查缓存目录
|
||||
* @return bool
|
||||
*/
|
||||
static protected function check()
|
||||
{
|
||||
empty(self::$cachepath) && self::$cachepath = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'Cache' . DIRECTORY_SEPARATOR;
|
||||
self::$cachepath = rtrim(self::$cachepath, '/\\') . DIRECTORY_SEPARATOR;
|
||||
if (!is_dir(self::$cachepath) && !mkdir(self::$cachepath, 0755, true)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件缓存,成功返回文件路径
|
||||
* @param string $content 文件内容
|
||||
* @param string $filename 文件名称
|
||||
* @return bool|string
|
||||
*/
|
||||
static public function file($content, $filename = '')
|
||||
{
|
||||
if (isset(Loader::$callback['CacheFile'])) {
|
||||
return call_user_func_array(Loader::$callback['CacheFile'], func_get_args());
|
||||
}
|
||||
empty($filename) && $filename = md5($content) . '.' . self::getFileExt($content);
|
||||
if (self::check() && file_put_contents(self::$cachepath . $filename, $content)) {
|
||||
return self::$cachepath . $filename;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据文件流读取文件后缀
|
||||
* @param string $content
|
||||
* @return string
|
||||
*/
|
||||
static public function getFileExt($content)
|
||||
{
|
||||
$types = [
|
||||
255216 => 'jpg', 7173 => 'gif', 6677 => 'bmp', 13780 => 'png',
|
||||
7368 => 'mp3', 4838 => 'wma', 7784 => 'mid', 6063 => 'xml',
|
||||
];
|
||||
$typeInfo = @unpack("C2chars", substr($content, 0, 2));
|
||||
$typeCode = intval($typeInfo['chars1'] . $typeInfo['chars2']);
|
||||
return isset($types[$typeCode]) ? $types[$typeCode] : 'mp4';
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,232 +0,0 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | wechat-php-sdk
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2017 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方文档: https://www.kancloud.cn/zoujingli/wechat-php-sdk
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/wechat-php-sdk
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace Wechat\Lib;
|
||||
|
||||
use Prpcrypt;
|
||||
use Wechat\Loader;
|
||||
|
||||
/**
|
||||
* 微信SDK基础类
|
||||
*
|
||||
* @category WechatSDK
|
||||
* @subpackage library
|
||||
* @author Anyon <zoujingli@qq.com>
|
||||
* @date 2016/05/28 11:55
|
||||
*/
|
||||
class Common
|
||||
{
|
||||
|
||||
/** API接口URL需要使用此前缀 */
|
||||
const API_BASE_URL_PREFIX = 'https://api.weixin.qq.com';
|
||||
const API_URL_PREFIX = 'https://api.weixin.qq.com/cgi-bin';
|
||||
const GET_TICKET_URL = '/ticket/getticket?';
|
||||
const AUTH_URL = '/token?grant_type=client_credential&';
|
||||
public $token;
|
||||
public $encodingAesKey;
|
||||
public $encrypt_type;
|
||||
public $appid;
|
||||
public $appsecret;
|
||||
public $access_token;
|
||||
public $postxml;
|
||||
public $_msg;
|
||||
public $errCode = 0;
|
||||
public $errMsg = "";
|
||||
public $config = array();
|
||||
private $_retry = false;
|
||||
|
||||
/**
|
||||
* 构造方法
|
||||
* @param array $options
|
||||
*/
|
||||
public function __construct($options = array())
|
||||
{
|
||||
$config = Loader::config($options);
|
||||
$this->token = isset($config['token']) ? $config['token'] : '';
|
||||
$this->appid = isset($config['appid']) ? $config['appid'] : '';
|
||||
$this->appsecret = isset($config['appsecret']) ? $config['appsecret'] : '';
|
||||
$this->encodingAesKey = isset($config['encodingaeskey']) ? $config['encodingaeskey'] : '';
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前当前错误代码
|
||||
* @return int
|
||||
*/
|
||||
public function getErrorCode()
|
||||
{
|
||||
return $this->errCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前错误内容
|
||||
* @return string
|
||||
*/
|
||||
public function getError()
|
||||
{
|
||||
return $this->errMsg;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前操作公众号APPID
|
||||
* @return string
|
||||
*/
|
||||
public function getAppid()
|
||||
{
|
||||
return $this->appid;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取SDK配置参数
|
||||
* @return array
|
||||
*/
|
||||
public function getConfig()
|
||||
{
|
||||
return $this->config;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 接口验证
|
||||
* @return bool
|
||||
*/
|
||||
public function valid()
|
||||
{
|
||||
$encryptStr = "";
|
||||
if ($_SERVER['REQUEST_METHOD'] == "POST") {
|
||||
$postStr = file_get_contents("php://input");
|
||||
$array = (array)simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);
|
||||
$this->encrypt_type = isset($_GET["encrypt_type"]) ? $_GET["encrypt_type"] : '';
|
||||
if ($this->encrypt_type == 'aes') {
|
||||
$encryptStr = $array['Encrypt'];
|
||||
!class_exists('Prpcrypt', false) && require __DIR__ . '/Prpcrypt.php';
|
||||
$pc = new Prpcrypt($this->encodingAesKey);
|
||||
$array = $pc->decrypt($encryptStr, $this->appid);
|
||||
if (!isset($array[0]) || intval($array[0]) > 0) {
|
||||
$this->errCode = $array[0];
|
||||
$this->errMsg = $array[1];
|
||||
Tools::log("Interface Authentication Failed. {$this->errMsg}[{$this->errCode}]", 'ERR');
|
||||
return false;
|
||||
}
|
||||
$this->postxml = $array[1];
|
||||
empty($this->appid) && $this->appid = $array[2];
|
||||
} else {
|
||||
$this->postxml = $postStr;
|
||||
}
|
||||
} elseif (isset($_GET["echostr"])) {
|
||||
if ($this->checkSignature()) {
|
||||
exit($_GET["echostr"]);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (!$this->checkSignature($encryptStr)) {
|
||||
$this->errMsg = 'Interface authentication failed, please use the correct method to call.';
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证来自微信服务器
|
||||
* @param string $str
|
||||
* @return bool
|
||||
*/
|
||||
private function checkSignature($str = '')
|
||||
{
|
||||
$signature = isset($_GET["msg_signature"]) ? $_GET["msg_signature"] : (isset($_GET["signature"]) ? $_GET["signature"] : '');
|
||||
$timestamp = isset($_GET["timestamp"]) ? $_GET["timestamp"] : '';
|
||||
$nonce = isset($_GET["nonce"]) ? $_GET["nonce"] : '';
|
||||
$tmpArr = array($this->token, $timestamp, $nonce, $str);
|
||||
sort($tmpArr, SORT_STRING);
|
||||
if (sha1(implode($tmpArr)) == $signature) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取公众号访问 access_token
|
||||
* @param string $appid 如在类初始化时已提供,则可为空
|
||||
* @param string $appsecret 如在类初始化时已提供,则可为空
|
||||
* @param string $token 手动指定access_token,非必要情况不建议用
|
||||
* @return bool|string
|
||||
*/
|
||||
public function getAccessToken($appid = '', $appsecret = '', $token = '')
|
||||
{
|
||||
if (!$appid || !$appsecret) {
|
||||
$appid = $this->appid;
|
||||
$appsecret = $this->appsecret;
|
||||
}
|
||||
if ($token) {
|
||||
return $this->access_token = $token;
|
||||
}
|
||||
$cache = 'wechat_access_token_' . $appid;
|
||||
if (($access_token = Tools::getCache($cache)) && !empty($access_token)) {
|
||||
return $this->access_token = $access_token;
|
||||
}
|
||||
# 检测事件注册
|
||||
if (isset(Loader::$callback[__FUNCTION__])) {
|
||||
return $this->access_token = call_user_func_array(Loader::$callback[__FUNCTION__], array(&$this, &$cache));
|
||||
}
|
||||
$result = Tools::httpGet(self::API_URL_PREFIX . self::AUTH_URL . 'appid=' . $appid . '&secret=' . $appsecret);
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || isset($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
Tools::log("Get New AccessToken Error. {$this->errMsg}[{$this->errCode}]", 'ERR');
|
||||
return false;
|
||||
}
|
||||
$this->access_token = $json['access_token'];
|
||||
Tools::log("Get New AccessToken Success.");
|
||||
Tools::setCache($cache, $this->access_token, 5000);
|
||||
return $this->access_token;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 接口失败重试
|
||||
* @param $method SDK方法名称
|
||||
* @param array $arguments SDK方法参数
|
||||
* @return bool|mixed
|
||||
*/
|
||||
protected function checkRetry($method, $arguments = array())
|
||||
{
|
||||
if (!$this->_retry && in_array($this->errCode, array('40014', '40001', '41001', '42001'))) {
|
||||
Tools::log("Run {$method} Faild. {$this->errMsg}[{$this->errCode}]", 'ERR');
|
||||
($this->_retry = true) && $this->resetAuth();
|
||||
$this->errCode = 40001;
|
||||
$this->errMsg = 'no access';
|
||||
Tools::log("Retry Run {$method} ...");
|
||||
return call_user_func_array(array($this, $method), $arguments);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除验证数据
|
||||
* @param string $appid 如在类初始化时已提供,则可为空
|
||||
* @return bool
|
||||
*/
|
||||
public function resetAuth($appid = '')
|
||||
{
|
||||
$authname = 'wechat_access_token_' . (empty($appid) ? $this->appid : $appid);
|
||||
Tools::log("Reset Auth And Remove Old AccessToken.");
|
||||
$this->access_token = '';
|
||||
Tools::removeCache($authname);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,196 +0,0 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | wechat-php-sdk
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2017 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方文档: https://www.kancloud.cn/zoujingli/wechat-php-sdk
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/wechat-php-sdk
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* PKCS7算法 加解密
|
||||
* @category WechatSDK
|
||||
* @subpackage library
|
||||
* @date 2016/06/28 11:59
|
||||
*/
|
||||
class PKCS7Encoder
|
||||
{
|
||||
|
||||
public static $block_size = 32;
|
||||
|
||||
/**
|
||||
* 对需要加密的明文进行填充补位
|
||||
* @param string $text 需要进行填充补位操作的明文
|
||||
* @return string 补齐明文字符串
|
||||
*/
|
||||
function encode($text)
|
||||
{
|
||||
$amount_to_pad = PKCS7Encoder::$block_size - (strlen($text) % PKCS7Encoder::$block_size);
|
||||
if ($amount_to_pad == 0) {
|
||||
$amount_to_pad = PKCS7Encoder::$block_size;
|
||||
}
|
||||
$pad_chr = chr($amount_to_pad);
|
||||
$tmp = "";
|
||||
for ($index = 0; $index < $amount_to_pad; $index++) {
|
||||
$tmp .= $pad_chr;
|
||||
}
|
||||
return $text . $tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* 对解密后的明文进行补位删除
|
||||
* @param string $text 解密后的明文
|
||||
* @return string 删除填充补位后的明文
|
||||
*/
|
||||
function decode($text)
|
||||
{
|
||||
$pad = ord(substr($text, -1));
|
||||
if ($pad < 1 || $pad > PKCS7Encoder::$block_size) {
|
||||
$pad = 0;
|
||||
}
|
||||
return substr($text, 0, (strlen($text) - $pad));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 接收和推送给公众平台消息的加解密
|
||||
* @category WechatSDK
|
||||
* @subpackage library
|
||||
* @date 2016/06/28 11:59
|
||||
*/
|
||||
class Prpcrypt
|
||||
{
|
||||
|
||||
public $key;
|
||||
|
||||
function __construct($k)
|
||||
{
|
||||
$this->key = base64_decode($k . "=");
|
||||
}
|
||||
|
||||
/**
|
||||
* 对明文进行加密
|
||||
* @param string $text 需要加密的明文
|
||||
* @param string $appid 公众号APPID
|
||||
* @return array
|
||||
*/
|
||||
public function encrypt($text, $appid)
|
||||
{
|
||||
try {
|
||||
//获得16位随机字符串,填充到明文之前
|
||||
$random = $this->getRandomStr();//"aaaabbbbccccdddd";
|
||||
$text = $random . pack("N", strlen($text)) . $text . $appid;
|
||||
$iv = substr($this->key, 0, 16);
|
||||
$pkc_encoder = new PKCS7Encoder;
|
||||
$text = $pkc_encoder->encode($text);
|
||||
$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, null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 对密文进行解密
|
||||
* @param string $encrypted 需要解密的密文
|
||||
* @param string $appid 公众号APPID
|
||||
* @return array
|
||||
*/
|
||||
public function decrypt($encrypted, $appid)
|
||||
{
|
||||
try {
|
||||
$iv = substr($this->key, 0, 16);
|
||||
$decrypted = openssl_decrypt($encrypted, 'AES-256-CBC', substr($this->key, 0, 32), OPENSSL_ZERO_PADDING, $iv);
|
||||
} catch (Exception $e) {
|
||||
return array(ErrorCode::$DecryptAESError, null);
|
||||
}
|
||||
try {
|
||||
$pkc_encoder = new PKCS7Encoder;
|
||||
$result = $pkc_encoder->decode($decrypted);
|
||||
if (strlen($result) < 16) {
|
||||
return array(ErrorCode::$DecryptAESError, null);
|
||||
}
|
||||
$content = substr($result, 16, strlen($result));
|
||||
$len_list = unpack("N", substr($content, 0, 4));
|
||||
$xml_len = $len_list[1];
|
||||
$xml_content = substr($content, 4, $xml_len);
|
||||
$from_appid = substr($content, $xml_len + 4);
|
||||
return array(0, $xml_content, $from_appid);
|
||||
} catch (Exception $e) {
|
||||
return array(ErrorCode::$IllegalBuffer, null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 随机生成16位字符串
|
||||
* @return string 生成的字符串
|
||||
*/
|
||||
function getRandomStr()
|
||||
{
|
||||
$str = "";
|
||||
$str_pol = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz";
|
||||
$max = strlen($str_pol) - 1;
|
||||
for ($i = 0; $i < 16; $i++) {
|
||||
$str .= $str_pol[mt_rand(0, $max)];
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 仅用作类内部使用
|
||||
* 不用于官方API接口的errCode码
|
||||
* Class ErrorCode
|
||||
*/
|
||||
class ErrorCode
|
||||
{
|
||||
|
||||
public static $OK = 0;
|
||||
public static $ValidateSignatureError = 40001;
|
||||
public static $ParseXmlError = 40002;
|
||||
public static $ComputeSignatureError = 40003;
|
||||
public static $IllegalAesKey = 40004;
|
||||
public static $ValidateAppidError = 40005;
|
||||
public static $EncryptAESError = 40006;
|
||||
public static $DecryptAESError = 40007;
|
||||
public static $IllegalBuffer = 40008;
|
||||
public static $EncodeBase64Error = 40009;
|
||||
public static $DecodeBase64Error = 40010;
|
||||
public static $GenReturnXmlError = 40011;
|
||||
public static $errCode = array(
|
||||
'0' => '处理成功',
|
||||
'40001' => '校验签名失败',
|
||||
'40002' => '解析xml失败',
|
||||
'40003' => '计算签名失败',
|
||||
'40004' => '不合法的AESKey',
|
||||
'40005' => '校验AppID失败',
|
||||
'40006' => 'AES加密失败',
|
||||
'40007' => 'AES解密失败',
|
||||
'40008' => '公众平台发送的xml不合法',
|
||||
'40009' => 'Base64编码失败',
|
||||
'40010' => 'Base64解码失败',
|
||||
'40011' => '公众帐号生成回包xml失败'
|
||||
);
|
||||
|
||||
/**
|
||||
* 获取错误消息内容
|
||||
* @param string $err
|
||||
* @return bool
|
||||
*/
|
||||
public static function getErrText($err)
|
||||
{
|
||||
if (isset(self::$errCode[$err])) {
|
||||
return self::$errCode[$err];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,300 +0,0 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | wechat-php-sdk
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2017 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方文档: https://www.kancloud.cn/zoujingli/wechat-php-sdk
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/wechat-php-sdk
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace Wechat\Lib;
|
||||
|
||||
use CURLFile;
|
||||
|
||||
/**
|
||||
* 微信接口通用类
|
||||
*
|
||||
* @category WechatSDK
|
||||
* @subpackage library
|
||||
* @author Anyon <zoujingli@qq.com>
|
||||
* @date 2016/05/28 11:55
|
||||
*/
|
||||
class Tools
|
||||
{
|
||||
|
||||
/**
|
||||
* 产生随机字符串
|
||||
* @param int $length
|
||||
* @param string $str
|
||||
* @return string
|
||||
*/
|
||||
static public function createNoncestr($length = 32, $str = "")
|
||||
{
|
||||
$chars = "abcdefghijklmnopqrstuvwxyz0123456789";
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
$str .= substr($chars, mt_rand(0, strlen($chars) - 1), 1);
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取签名
|
||||
* @param array $arrdata 签名数组
|
||||
* @param string $method 签名方法
|
||||
* @return bool|string 签名值
|
||||
*/
|
||||
static public function getSignature($arrdata, $method = "sha1")
|
||||
{
|
||||
if (!function_exists($method)) {
|
||||
return false;
|
||||
}
|
||||
ksort($arrdata);
|
||||
$params = array();
|
||||
foreach ($arrdata as $key => $value) {
|
||||
$params[] = "{$key}={$value}";
|
||||
}
|
||||
return $method(join('&', $params));
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成支付签名
|
||||
* @param array $option
|
||||
* @param string $partnerKey
|
||||
* @return string
|
||||
*/
|
||||
static public function getPaySign($option, $partnerKey)
|
||||
{
|
||||
ksort($option);
|
||||
$buff = '';
|
||||
foreach ($option as $k => $v) {
|
||||
$buff .= "{$k}={$v}&";
|
||||
}
|
||||
return strtoupper(md5("{$buff}key={$partnerKey}"));
|
||||
}
|
||||
|
||||
/**
|
||||
* XML编码
|
||||
* @param mixed $data 数据
|
||||
* @param string $root 根节点名
|
||||
* @param string $item 数字索引的子节点名
|
||||
* @param string $id 数字索引子节点key转换的属性名
|
||||
* @return string
|
||||
*/
|
||||
static public function arr2xml($data, $root = 'xml', $item = 'item', $id = 'id')
|
||||
{
|
||||
return "<{$root}>" . self::_data_to_xml($data, $item, $id) . "</{$root}>";
|
||||
}
|
||||
|
||||
/**
|
||||
* XML内容生成
|
||||
* @param array $data 数据
|
||||
* @param string $item 子节点
|
||||
* @param string $id 节点ID
|
||||
* @param string $content 节点内容
|
||||
* @return string
|
||||
*/
|
||||
static private function _data_to_xml($data, $item = 'item', $id = 'id', $content = '')
|
||||
{
|
||||
foreach ($data as $key => $val) {
|
||||
is_numeric($key) && $key = "{$item} {$id}=\"{$key}\"";
|
||||
$content .= "<{$key}>";
|
||||
if (is_array($val) || is_object($val)) {
|
||||
$content .= self::_data_to_xml($val);
|
||||
} elseif (is_numeric($val)) {
|
||||
$content .= $val;
|
||||
} else {
|
||||
$content .= '<![CDATA[' . preg_replace("/[\\x00-\\x08\\x0b-\\x0c\\x0e-\\x1f]/", '', $val) . ']]>';
|
||||
}
|
||||
list($_key,) = explode(' ', $key . ' ');
|
||||
$content .= "</$_key>";
|
||||
}
|
||||
return $content;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 将xml转为array
|
||||
* @param string $xml
|
||||
* @return array
|
||||
*/
|
||||
static public function xml2arr($xml)
|
||||
{
|
||||
return json_decode(Tools::json_encode(simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA)), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成安全JSON数据
|
||||
* @param array $array
|
||||
* @return string
|
||||
*/
|
||||
static public function json_encode($array)
|
||||
{
|
||||
return preg_replace_callback('/\\\\u([0-9a-f]{4})/i', create_function('$matches', 'return mb_convert_encoding(pack("H*", $matches[1]), "UTF-8", "UCS-2BE");'), json_encode($array));
|
||||
}
|
||||
|
||||
/**
|
||||
* 以get方式提交请求
|
||||
* @param $url
|
||||
* @return bool|mixed
|
||||
*/
|
||||
static public function httpGet($url)
|
||||
{
|
||||
$oCurl = curl_init();
|
||||
if (stripos($url, "https://") !== false) {
|
||||
curl_setopt($oCurl, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($oCurl, CURLOPT_SSL_VERIFYHOST, false);
|
||||
curl_setopt($oCurl, CURLOPT_SSLVERSION, 1);
|
||||
}
|
||||
curl_setopt($oCurl, CURLOPT_URL, $url);
|
||||
curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, 1);
|
||||
$sContent = curl_exec($oCurl);
|
||||
$aStatus = curl_getinfo($oCurl);
|
||||
curl_close($oCurl);
|
||||
if (intval($aStatus["http_code"]) == 200) {
|
||||
return $sContent;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 以post方式提交请求
|
||||
* @param string $url
|
||||
* @param array|string $data
|
||||
* @return bool|mixed
|
||||
*/
|
||||
static public function httpPost($url, $data)
|
||||
{
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_HEADER, false);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
if (is_array($data)) {
|
||||
foreach ($data as &$value) {
|
||||
if (is_string($value) && stripos($value, '@') === 0 && class_exists('CURLFile', false)) {
|
||||
$value = new CURLFile(realpath(trim($value, '@')));
|
||||
}
|
||||
}
|
||||
}
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
$data = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
if ($data) {
|
||||
return $data;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用证书,以post方式提交xml到对应的接口url
|
||||
* @param string $url POST提交的内容
|
||||
* @param array $postdata 请求的地址
|
||||
* @param string $ssl_cer 证书Cer路径 | 证书内容
|
||||
* @param string $ssl_key 证书Key路径 | 证书内容
|
||||
* @param int $second 设置请求超时时间
|
||||
* @return bool|mixed
|
||||
*/
|
||||
static public function httpsPost($url, $postdata, $ssl_cer = null, $ssl_key = null, $second = 30)
|
||||
{
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, $second);
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
|
||||
curl_setopt($ch, CURLOPT_HEADER, false);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
if (!is_null($ssl_cer) && file_exists($ssl_cer) && is_file($ssl_cer)) {
|
||||
curl_setopt($ch, CURLOPT_SSLCERTTYPE, 'PEM');
|
||||
curl_setopt($ch, CURLOPT_SSLCERT, $ssl_cer);
|
||||
}
|
||||
if (!is_null($ssl_key) && file_exists($ssl_key) && is_file($ssl_key)) {
|
||||
curl_setopt($ch, CURLOPT_SSLKEYTYPE, 'PEM');
|
||||
curl_setopt($ch, CURLOPT_SSLKEY, $ssl_key);
|
||||
}
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
if (is_array($postdata)) {
|
||||
foreach ($postdata as &$data) {
|
||||
if (is_string($data) && stripos($data, '@') === 0 && class_exists('CURLFile', false)) {
|
||||
$data = new CURLFile(realpath(trim($data, '@')));
|
||||
}
|
||||
}
|
||||
}
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
|
||||
$result = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
if ($result) {
|
||||
return $result;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取微信客户端IP
|
||||
* @return null|string
|
||||
*/
|
||||
static public function getAddress()
|
||||
{
|
||||
foreach (array('HTTP_X_FORWARDED_FOR', 'HTTP_CLIENT_IP', 'HTTP_X_CLIENT_IP', 'HTTP_X_CLUSTER_CLIENT_IP', 'REMOTE_ADDR') as $header) {
|
||||
if (!isset($_SERVER[$header]) || ($spoof = $_SERVER[$header]) === null) {
|
||||
continue;
|
||||
}
|
||||
sscanf($spoof, '%[^,]', $spoof);
|
||||
if (!filter_var($spoof, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
|
||||
$spoof = null;
|
||||
} else {
|
||||
return $spoof;
|
||||
}
|
||||
}
|
||||
return '0.0.0.0';
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置缓存,按需重载
|
||||
* @param string $cachename
|
||||
* @param mixed $value
|
||||
* @param int $expired
|
||||
* @return bool
|
||||
*/
|
||||
static public function setCache($cachename, $value, $expired = 0)
|
||||
{
|
||||
return Cache::set($cachename, $value, $expired);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取缓存,按需重载
|
||||
* @param string $cachename
|
||||
* @return mixed
|
||||
*/
|
||||
static public function getCache($cachename)
|
||||
{
|
||||
return Cache::get($cachename);
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除缓存,按需重载
|
||||
* @param string $cachename
|
||||
* @return bool
|
||||
*/
|
||||
static public function removeCache($cachename)
|
||||
{
|
||||
return Cache::del($cachename);
|
||||
}
|
||||
|
||||
/**
|
||||
* SDK日志处理方法
|
||||
* @param string $msg 日志行内容
|
||||
* @param string $type 日志级别
|
||||
*/
|
||||
static public function log($msg, $type = 'MSG')
|
||||
{
|
||||
Cache::put($type . ' - ' . $msg);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,129 +0,0 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | wechat-php-sdk
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2017 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方文档: https://www.kancloud.cn/zoujingli/wechat-php-sdk
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/wechat-php-sdk
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace Wechat;
|
||||
|
||||
use Wechat\Lib\Cache;
|
||||
|
||||
/**
|
||||
* 注册SDK自动加载机制
|
||||
* @author Anyon <zoujingli@qq.com>
|
||||
* @date 2016/10/26 10:21
|
||||
*/
|
||||
spl_autoload_register(function ($class) {
|
||||
if (0 === stripos($class, 'Wechat\\')) {
|
||||
$filename = dirname(__DIR__) . DIRECTORY_SEPARATOR . str_replace('\\', DIRECTORY_SEPARATOR, $class) . '.php';
|
||||
file_exists($filename) && require($filename);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* 微信SDK加载器
|
||||
* @author Anyon <zoujingli@qq.com>
|
||||
* @date 2016-08-21 11:06
|
||||
*/
|
||||
class Loader
|
||||
{
|
||||
|
||||
/**
|
||||
* 事件注册函数
|
||||
* @var array
|
||||
*/
|
||||
static public $callback = array();
|
||||
|
||||
/**
|
||||
* 配置参数
|
||||
* @var array
|
||||
*/
|
||||
static protected $config = array();
|
||||
|
||||
/**
|
||||
* 对象缓存
|
||||
* @var array
|
||||
*/
|
||||
static protected $cache = array();
|
||||
|
||||
/**
|
||||
* 动态注册SDK事件处理函数
|
||||
* @param string $event 事件名称(getAccessToken|getJsTicket)
|
||||
* @param string $method 处理方法(可以是普通方法或者类中的方法)
|
||||
* @param string|null $class 处理对象(可以直接使用的类实例)
|
||||
*/
|
||||
static public function register($event, $method, $class = null)
|
||||
{
|
||||
if (!empty($class) && class_exists($class, false) && method_exists($class, $method)) {
|
||||
self::$callback[$event] = array($class, $method);
|
||||
} else {
|
||||
self::$callback[$event] = $method;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取微信SDK接口对象(别名函数)
|
||||
* @param string $type 接口类型(Card|Custom|Device|Extends|Media|Menu|Oauth|Pay|Receive|Script|User|Poi)
|
||||
* @param array $config SDK配置(token,appid,appsecret,encodingaeskey,mch_id,partnerkey,ssl_cer,ssl_key,qrc_img)
|
||||
* @return WechatCard|WechatCustom|WechatDevice|WechatExtends|WechatMedia|WechatMenu|WechatOauth|WechatPay|WechatPoi|WechatReceive|WechatScript|WechatService|WechatUser
|
||||
*/
|
||||
static public function & get_instance($type, $config = array())
|
||||
{
|
||||
return self::get($type, $config);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取微信SDK接口对象
|
||||
* @param string $type 接口类型(Card|Custom|Device|Extends|Media|Menu|Oauth|Pay|Receive|Script|User|Poi)
|
||||
* @param array $config SDK配置(token,appid,appsecret,encodingaeskey,mch_id,partnerkey,ssl_cer,ssl_key,qrc_img)
|
||||
* @return WechatCard|WechatCustom|WechatDevice|WechatExtends|WechatMedia|WechatMenu|WechatOauth|WechatPay|WechatPoi|WechatReceive|WechatScript|WechatService|WechatUser
|
||||
*/
|
||||
static public function & get($type, $config = array())
|
||||
{
|
||||
$index = md5(strtolower($type) . md5(json_encode(self::$config)));
|
||||
if (!isset(self::$cache[$index])) {
|
||||
$basicName = 'Wechat' . ucfirst(strtolower($type));
|
||||
$className = "\\Wechat\\{$basicName}";
|
||||
// 注册类的无命名空间别名,兼容未带命名空间的老版本SDK
|
||||
!class_exists($basicName, false) && class_alias($className, $basicName);
|
||||
self::$cache[$index] = new $className(self::config($config));
|
||||
}
|
||||
return self::$cache[$index];
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置配置参数
|
||||
* @param array $config
|
||||
* @return array
|
||||
*/
|
||||
static public function config($config = array())
|
||||
{
|
||||
!empty($config) && self::$config = array_merge(self::$config, $config);
|
||||
if (!empty(self::$config['cachepath'])) {
|
||||
Cache::$cachepath = self::$config['cachepath'];
|
||||
}
|
||||
if (empty(self::$config['component_verify_ticket'])) {
|
||||
self::$config['component_verify_ticket'] = Cache::get('component_verify_ticket');
|
||||
}
|
||||
if (empty(self::$config['token']) && !empty(self::$config['component_token'])) {
|
||||
self::$config['token'] = self::$config['component_token'];
|
||||
}
|
||||
if (empty(self::$config['appsecret']) && !empty(self::$config['component_appsecret'])) {
|
||||
self::$config['appsecret'] = self::$config['component_appsecret'];
|
||||
}
|
||||
if (empty(self::$config['encodingaeskey']) && !empty(self::$config['component_encodingaeskey'])) {
|
||||
self::$config['encodingaeskey'] = self::$config['component_encodingaeskey'];
|
||||
}
|
||||
return self::$config;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,815 +0,0 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | wechat-php-sdk
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2017 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方文档: https://www.kancloud.cn/zoujingli/wechat-php-sdk
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/wechat-php-sdk
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace Wechat;
|
||||
|
||||
use Wechat\Lib\Common;
|
||||
use Wechat\Lib\Tools;
|
||||
|
||||
/**
|
||||
* 微信卡卷
|
||||
*/
|
||||
class WechatCard extends Common
|
||||
{
|
||||
|
||||
/** 卡券相关地址 */
|
||||
const CARD_CREATE = '/card/create?';
|
||||
// 删除卡卷
|
||||
const CARD_DELETE = '/card/delete?';
|
||||
// 更新卡卷信息
|
||||
const CARD_UPDATE = '/card/update?';
|
||||
// 获取卡卷详细信息
|
||||
const CARD_GET = '/card/get?';
|
||||
// 读取粉丝拥有的卡卷列表
|
||||
const CARD_USER_GET_LIST = '/card/user/getcardlist?';
|
||||
// 卡卷核查接口
|
||||
const CARD_CHECKCODE = '/card/code/checkcode?';
|
||||
// 卡卷图文群发获取HTML
|
||||
const CARD_SET_SELFCONSUMECELL = '/card/selfconsumecell/set?';
|
||||
const CARD_SEND_HTML = '/card/mpnews/gethtml?';
|
||||
const CARD_BATCHGET = '/card/batchget?';
|
||||
const CARD_MODIFY_STOCK = '/card/modifystock?';
|
||||
const CARD_GETCOLORS = '/card/getcolors?';
|
||||
const CARD_QRCODE_CREATE = '/card/qrcode/create?';
|
||||
const CARD_CODE_CONSUME = '/card/code/consume?';
|
||||
const CARD_CODE_DECRYPT = '/card/code/decrypt?';
|
||||
const CARD_CODE_GET = '/card/code/get?';
|
||||
const CARD_CODE_UPDATE = '/card/code/update?';
|
||||
const CARD_CODE_UNAVAILABLE = '/card/code/unavailable?';
|
||||
const CARD_TESTWHILELIST_SET = '/card/testwhitelist/set?';
|
||||
const CARD_MEETINGCARD_UPDATEUSER = '/card/meetingticket/updateuser?'; //更新会议门票
|
||||
const CARD_MEMBERCARD_ACTIVATE = '/card/membercard/activate?'; //激活会员卡
|
||||
const CARD_MEMBERCARD_UPDATEUSER = '/card/membercard/updateuser?'; //更新会员卡
|
||||
const CARD_MOVIETICKET_UPDATEUSER = '/card/movieticket/updateuser?'; //更新电影票(未加方法)
|
||||
const CARD_BOARDINGPASS_CHECKIN = '/card/boardingpass/checkin?'; //飞机票-在线选座(未加方法)
|
||||
/** 更新红包金额 */
|
||||
const CARD_LUCKYMONEY_UPDATE = '/card/luckymoney/updateuserbalance?';
|
||||
/*买单接口*/
|
||||
const CARD_PAYCELL_SET = '/card/paycell/set?';
|
||||
/*设置开卡字段接口*/
|
||||
const CARD_MEMBERCARD_ACTIVATEUSERFORM_SET = '/card/membercard/activateuserform/set?';
|
||||
|
||||
/**
|
||||
* 获取微信卡券 api_ticket
|
||||
* @param string $appid
|
||||
* @param string $jsapi_ticket
|
||||
* @return bool|string
|
||||
*/
|
||||
public function getJsCardTicket($appid = '', $jsapi_ticket = '')
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$appid = empty($appid) ? $this->appid : $appid;
|
||||
if ($jsapi_ticket) {
|
||||
return $jsapi_ticket;
|
||||
}
|
||||
$authname = 'wechat_jsapi_ticket_wxcard_' . $appid;
|
||||
if (($jsapi_ticket = Tools::getCache($authname))) {
|
||||
return $jsapi_ticket;
|
||||
}
|
||||
$result = Tools::httpGet(self::API_URL_PREFIX . self::GET_TICKET_URL . "access_token={$this->access_token}" . '&type=wx_card');
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
$expire = $json['expires_in'] ? intval($json['expires_in']) - 100 : 3600;
|
||||
Tools::setCache($authname, $json['ticket'], $expire);
|
||||
return $json['ticket'];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成选择卡卷JS签名包
|
||||
* @param string $cardid 卡券Id
|
||||
* @param string $cardtype 卡券类型
|
||||
* @param string $shopid 门店Id
|
||||
* @return array
|
||||
*/
|
||||
public function createChooseCardJsPackage($cardid = null, $cardtype = null, $shopid = null)
|
||||
{
|
||||
$data = array();
|
||||
$data['api_ticket'] = $this->getJsCardTicket();
|
||||
$data['app_id'] = $this->appid;
|
||||
$data['timestamp'] = time();
|
||||
$data['nonceStr'] = Tools::createNoncestr();
|
||||
!empty($cardid) && $data['cardId'] = $cardid;
|
||||
!empty($cardtype) && $data['cardType'] = $cardtype;
|
||||
!empty($shopid) && $data['shopId'] = $shopid;
|
||||
$data['cardSign'] = $this->getTicketSignature($data);
|
||||
$data['signType'] = 'SHA1';
|
||||
unset($data['api_ticket'], $data['app_id']);
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成添加卡卷JS签名包
|
||||
* @param string|null $cardid 卡卷ID
|
||||
* @param array $data 其它限定参数
|
||||
* @return array
|
||||
*/
|
||||
public function createAddCardJsPackage($cardid = null, $data = array())
|
||||
{
|
||||
|
||||
function _sign($cardid = null, $attr = array(), $self)
|
||||
{
|
||||
unset($attr['outer_id']);
|
||||
$attr['cardId'] = $cardid;
|
||||
$attr['timestamp'] = time();
|
||||
$attr['api_ticket'] = $self->getJsCardTicket();
|
||||
$attr['nonce_str'] = Tools::createNoncestr();
|
||||
$attr['signature'] = $self->getTicketSignature($attr);
|
||||
unset($attr['api_ticket']);
|
||||
return $attr;
|
||||
}
|
||||
|
||||
$cardList = array();
|
||||
if (is_array($cardid)) {
|
||||
foreach ($cardid as $id) {
|
||||
$cardList[] = array('cardId' => $id, 'cardExt' => json_encode(_sign($id, $data, $this)));
|
||||
}
|
||||
} else {
|
||||
$cardList[] = array('cardId' => $cardid, 'cardExt' => json_encode(_sign($cardid, $data, $this)));
|
||||
}
|
||||
return array('cardList' => $cardList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取微信卡券签名
|
||||
* @param array $arrdata 签名数组
|
||||
* @param string $method 签名方法
|
||||
* @return bool|string 签名值
|
||||
*/
|
||||
public function getTicketSignature($arrdata, $method = "sha1")
|
||||
{
|
||||
if (!function_exists($method)) {
|
||||
return false;
|
||||
}
|
||||
$newArray = array();
|
||||
foreach ($arrdata as $value) {
|
||||
array_push($newArray, (string)$value);
|
||||
}
|
||||
sort($newArray, SORT_STRING);
|
||||
return $method(implode($newArray));
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建卡券
|
||||
* @param array $data 卡券数据
|
||||
* @return bool|array 返回数组中card_id为卡券ID
|
||||
*/
|
||||
public function createCard($data)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::CARD_CREATE . "access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更改卡券信息
|
||||
* 调用该接口更新信息后会重新送审,卡券状态变更为待审核。已被用户领取的卡券会实时更新票面信息。
|
||||
* @param string $data
|
||||
* @return bool
|
||||
*/
|
||||
public function updateCard($data)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::CARD_UPDATE . "access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除卡券
|
||||
* 允许商户删除任意一类卡券。删除卡券后,该卡券对应已生成的领取用二维码、添加到卡包 JS API 均会失效。
|
||||
* 注意:删除卡券不能删除已被用户领取,保存在微信客户端中的卡券,已领取的卡券依旧有效。
|
||||
* @param string $card_id 卡券ID
|
||||
* @return bool
|
||||
*/
|
||||
public function delCard($card_id)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$data = array('card_id' => $card_id);
|
||||
$result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::CARD_DELETE . "access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取粉丝下所有卡卷列表
|
||||
* @param $openid 粉丝openid
|
||||
* @param string $card_id 卡卷ID(可不给)
|
||||
* @return bool|array
|
||||
*/
|
||||
public function getCardList($openid, $card_id = '')
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$data = array('openid' => $openid);
|
||||
!empty($card_id) && $data['card_id'] = $card_id;
|
||||
$result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::CARD_USER_GET_LIST . "access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode']) || empty($json['card_list'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取图文消息群发卡券HTML
|
||||
* @param string $card_id 卡卷ID
|
||||
* @return bool|array
|
||||
*/
|
||||
public function getCardMpHtml($card_id)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$data = array('card_id' => $card_id);
|
||||
!empty($card_id) && $data['card_id'] = $card_id;
|
||||
$result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::CARD_SEND_HTML . "access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode']) || empty($json['card_list'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 卡卷code核查
|
||||
* @param string $card_id 卡卷ID
|
||||
* @param array $code_list 卡卷code列表(一维数组)
|
||||
* @return bool|array
|
||||
*/
|
||||
public function checkCardCodeList($card_id, $code_list)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$data = array('card_id' => $card_id, 'code' => $code_list);
|
||||
$result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::CARD_CHECKCODE . "access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode']) || empty($json['card_list'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询卡券详情
|
||||
* @param string $card_id 卡卷ID
|
||||
* @return bool|array
|
||||
*/
|
||||
public function getCardInfo($card_id)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$data = array('card_id' => $card_id);
|
||||
$result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::CARD_GET . "access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取颜色列表
|
||||
* 获得卡券的最新颜色列表,用于创建卡券
|
||||
* @return bool|array
|
||||
*/
|
||||
public function getCardColors()
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$result = Tools::httpGet(self::API_BASE_URL_PREFIX . self::CARD_GETCOLORS . "access_token={$this->access_token}");
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成卡券二维码
|
||||
* 成功则直接返回ticket值,可以用 getQRUrl($ticket) 换取二维码url
|
||||
* @param string $card_id 卡券ID 必须
|
||||
* @param string $code 指定卡券 code 码,只能被领一次。use_custom_code 字段为 true 的卡券必须填写,非自定义 code 不必填写。
|
||||
* @param string $openid 指定领取者的 openid,只有该用户能领取。bind_openid 字段为 true 的卡券必须填写,非自定义 openid 不必填写。
|
||||
* @param int $expire_seconds 指定二维码的有效时间,范围是 60 ~ 1800 秒。不填默认为永久有效。
|
||||
* @param bool $is_unique_code 指定下发二维码,生成的二维码随机分配一个 code,领取后不可再次扫描。填写 true 或 false。默认 false。
|
||||
* @param string $balance 红包余额,以分为单位。红包类型必填(LUCKY_MONEY),其他卡券类型不填。
|
||||
* @return bool|string
|
||||
*/
|
||||
public function createCardQrcode($card_id, $code = '', $openid = '', $expire_seconds = 0, $is_unique_code = false, $balance = '')
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$card = array('card_id' => $card_id);
|
||||
!empty($code) && $card['code'] = $code;
|
||||
!empty($openid) && $card['openid'] = $openid;
|
||||
!empty($is_unique_code) && $card['is_unique_code'] = $is_unique_code;
|
||||
!empty($balance) && $card['balance'] = $balance;
|
||||
$data = array('action_name' => "QR_CARD");
|
||||
!empty($expire_seconds) && $data['expire_seconds'] = $expire_seconds;
|
||||
$data['action_info'] = array('card' => $card);
|
||||
$result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::CARD_QRCODE_CREATE . "access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 消耗 code
|
||||
* 自定义 code(use_custom_code 为 true)的优惠券,在 code 被核销时,必须调用此接口。
|
||||
* @param string $code 要消耗的序列号
|
||||
* @param string $card_id 要消耗序列号所述的 card_id,创建卡券时use_custom_code 填写 true 时必填。
|
||||
* @return bool|array
|
||||
* {
|
||||
* "errcode":0,
|
||||
* "errmsg":"ok",
|
||||
* "card":{"card_id":"pFS7Fjg8kV1IdDz01r4SQwMkuCKc"},
|
||||
* "openid":"oFS7Fjl0WsZ9AMZqrI80nbIq8xrA"
|
||||
* }
|
||||
*/
|
||||
public function consumeCardCode($code, $card_id = '')
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$data = array('code' => $code);
|
||||
!empty($card_id) && $data['card_id'] = $card_id;
|
||||
$result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::CARD_CODE_CONSUME . "access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* code 解码
|
||||
* @param string $encrypt_code 通过 choose_card_info 获取的加密字符串
|
||||
* @return bool|array
|
||||
* {
|
||||
* "errcode":0,
|
||||
* "errmsg":"ok",
|
||||
* "code":"751234212312"
|
||||
* }
|
||||
*/
|
||||
public function decryptCardCode($encrypt_code)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$data = array('encrypt_code' => $encrypt_code,);
|
||||
$result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::CARD_CODE_DECRYPT . "access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询 code 的有效性(非自定义 code)
|
||||
* @param string $code
|
||||
* @return bool|array
|
||||
* {
|
||||
* "errcode":0,
|
||||
* "errmsg":"ok",
|
||||
* "openid":"oFS7Fjl0WsZ9AMZqrI80nbIq8xrA", //用户 openid
|
||||
* "card":{
|
||||
* "card_id":"pFS7Fjg8kV1IdDz01r4SQwMkuCKc",
|
||||
* "begin_time": 1404205036, //起始使用时间
|
||||
* "end_time": 1404205036, //结束时间
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
public function checkCardCode($code)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$data = array('code' => $code);
|
||||
$result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::CARD_CODE_GET . "access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量查询卡列表
|
||||
* @param int $offset 开始拉取的偏移,默认为0从头开始
|
||||
* @param int $count 需要查询的卡片的数量(数量最大50,默认50)
|
||||
* @return bool|array
|
||||
* {
|
||||
* "errcode":0,
|
||||
* "errmsg":"ok",
|
||||
* "card_id_list":["ph_gmt7cUVrlRk8swPwx7aDyF-pg"], //卡 id 列表
|
||||
* "total_num":1 //该商户名下 card_id 总数
|
||||
* }
|
||||
*/
|
||||
public function getCardIdList($offset = 0, $count = 50)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$count > 50 && $count = 50;
|
||||
$data = array('offset' => $offset, 'count' => $count);
|
||||
$result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::CARD_BATCHGET . "access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更改 code
|
||||
* 为确保转赠后的安全性,微信允许自定义code的商户对已下发的code进行更改。
|
||||
* 注:为避免用户疑惑,建议仅在发生转赠行为后(发生转赠后,微信会通过事件推送的方式告知商户被转赠的卡券code)对用户的code进行更改。
|
||||
* @param string $code 卡券的 code 编码
|
||||
* @param string $card_id 卡券 ID
|
||||
* @param string $new_code 新的卡券 code 编码
|
||||
* @return bool
|
||||
*/
|
||||
public function updateCardCode($code, $card_id, $new_code)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$data = array('code' => $code, 'card_id' => $card_id, 'new_code' => $new_code);
|
||||
$result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::CARD_CODE_UPDATE . "access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置卡券失效
|
||||
* 设置卡券失效的操作不可逆
|
||||
* @param string $code 需要设置为失效的 code
|
||||
* @param string $card_id 自定义 code 的卡券必填。非自定义 code 的卡券不填。
|
||||
* @return bool
|
||||
*/
|
||||
public function unavailableCardCode($code, $card_id = '')
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$data = array('code' => $code);
|
||||
!empty($card_id) && $data['card_id'] = $card_id;
|
||||
$result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::CARD_CODE_UNAVAILABLE . "access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 库存修改
|
||||
* @param string $data
|
||||
* @return bool
|
||||
*/
|
||||
public function modifyCardStock($data)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::CARD_MODIFY_STOCK . "access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新门票
|
||||
* @param string $data
|
||||
* @return bool
|
||||
*/
|
||||
public function updateMeetingCard($data)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::CARD_MEETINGCARD_UPDATEUSER . "access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 激活/绑定会员卡
|
||||
* @param string $data 具体结构请参看卡券开发文档(6.1.1 激活/绑定会员卡)章节
|
||||
* @return bool
|
||||
*/
|
||||
public function activateMemberCard($data)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::CARD_MEMBERCARD_ACTIVATE . "access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 会员卡交易
|
||||
* 会员卡交易后每次积分及余额变更需通过接口通知微信,便于后续消息通知及其他扩展功能。
|
||||
* @param string $data 具体结构请参看卡券开发文档(6.1.2 会员卡交易)章节
|
||||
* @return bool|array
|
||||
*/
|
||||
public function updateMemberCard($data)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::CARD_MEMBERCARD_UPDATEUSER . "access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置卡券测试白名单
|
||||
* @param array $openid 测试的 openid 列表
|
||||
* @param array $user 测试的微信号列表
|
||||
* @return bool
|
||||
*/
|
||||
public function setCardTestWhiteList($openid = array(), $user = array())
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$data = array();
|
||||
count($openid) > 0 && $data['openid'] = $openid;
|
||||
count($user) > 0 && $data['username'] = $user;
|
||||
$result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::CARD_TESTWHILELIST_SET . "access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新红包金额
|
||||
* @param string $code 红包的序列号
|
||||
* @param int $balance 红包余额
|
||||
* @param string $card_id 自定义 code 的卡券必填。非自定义 code 可不填。
|
||||
* @return bool|array
|
||||
*/
|
||||
public function updateLuckyMoney($code, $balance, $card_id = '')
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$data = array('code' => $code, 'balance' => $balance);
|
||||
!empty($card_id) && $data['card_id'] = $card_id;
|
||||
$result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::CARD_LUCKYMONEY_UPDATE . "access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置自助核销接口
|
||||
* @param string $card_id 卡券ID
|
||||
* @param bool $is_openid 是否开启自助核销功能,填true/false,默认为false
|
||||
* @param bool $need_verify_cod 用户核销时是否需要输入验证码,填true/false,默认为false
|
||||
* @param bool $need_remark_amount 用户核销时是否需要备注核销金额,填true/false,默认为false
|
||||
* @return bool|array
|
||||
*/
|
||||
public function setSelfconsumecell($card_id, $is_openid = false, $need_verify_cod = false, $need_remark_amount = false)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$data = array(
|
||||
'card_id' => $card_id,
|
||||
'is_open' => $is_openid,
|
||||
'need_verify_cod' => $need_verify_cod,
|
||||
'need_remark_amount' => $need_remark_amount,
|
||||
);
|
||||
$result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::CARD_SET_SELFCONSUMECELL . "access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置买单接口
|
||||
* @param string $card_id
|
||||
* @param bool $is_openid
|
||||
* @return bool|mixed
|
||||
*/
|
||||
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,);
|
||||
$result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::CARD_PAYCELL_SET . "access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置开卡字段信息接口
|
||||
* @param array $data
|
||||
* @return bool|array
|
||||
*/
|
||||
public function setMembercardActivateuserform($data)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::CARD_MEMBERCARD_ACTIVATEUSERFORM_SET . "access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,361 +0,0 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | wechat-php-sdk
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2017 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方文档: https://www.kancloud.cn/zoujingli/wechat-php-sdk
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/wechat-php-sdk
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace Wechat;
|
||||
|
||||
use Wechat\Lib\Common;
|
||||
use Wechat\Lib\Tools;
|
||||
|
||||
class WechatCustom extends Common
|
||||
{
|
||||
|
||||
/** 多客服相关地址 */
|
||||
const CUSTOM_SERVICE_GET_RECORD = '/customservice/getrecord?';
|
||||
const CUSTOM_SERVICE_GET_KFLIST = '/customservice/getkflist?';
|
||||
const CUSTOM_SERVICE_GET_ONLINEKFLIST = '/customservice/getonlinekflist?';
|
||||
const CUSTOM_SESSION_CREATE = '/customservice/kfsession/create?';
|
||||
const CUSTOM_SESSION_CLOSE = '/customservice/kfsession/close?';
|
||||
const CUSTOM_SESSION_SWITCH = '/customservice/kfsession/switch?';
|
||||
const CUSTOM_SESSION_GET = '/customservice/kfsession/getsession?';
|
||||
const CUSTOM_SESSION_GET_LIST = '/customservice/kfsession/getsessionlist?';
|
||||
const CUSTOM_SESSION_GET_WAIT = '/customservice/kfsession/getwaitcase?';
|
||||
const CS_KF_ACCOUNT_ADD_URL = '/customservice/kfaccount/add?';
|
||||
const CS_KF_ACCOUNT_UPDATE_URL = '/customservice/kfaccount/update?';
|
||||
const CS_KF_ACCOUNT_DEL_URL = '/customservice/kfaccount/del?';
|
||||
const CS_KF_ACCOUNT_UPLOAD_HEADIMG_URL = '/customservice/kfaccount/uploadheadimg?';
|
||||
|
||||
/**
|
||||
* 获取多客服会话记录
|
||||
* @param array $data 数据结构 {"starttime":123456789,"endtime":987654321,"openid":"OPENID","pagesize":10,"pageindex":1,}
|
||||
* @return bool|array
|
||||
*/
|
||||
public function getCustomServiceMessage($data)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$result = Tools::httpPost(self::API_URL_PREFIX . self::CUSTOM_SERVICE_GET_RECORD . "access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return false;
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取多客服客服基本信息
|
||||
*
|
||||
* @return bool|array
|
||||
*/
|
||||
public function getCustomServiceKFlist()
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$result = Tools::httpGet(self::API_URL_PREFIX . self::CUSTOM_SERVICE_GET_KFLIST . "access_token={$this->access_token}");
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取多客服在线客服接待信息
|
||||
*
|
||||
* @return bool|array
|
||||
*/
|
||||
public function getCustomServiceOnlineKFlist()
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$result = Tools::httpGet(self::API_URL_PREFIX . self::CUSTOM_SERVICE_GET_ONLINEKFLIST . "access_token={$this->access_token}");
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建指定多客服会话
|
||||
* @tutorial 当用户已被其他客服接待或指定客服不在线则会失败
|
||||
* @param string $openid //用户openid
|
||||
* @param string $kf_account //客服账号
|
||||
* @param string $text //附加信息,文本会展示在客服人员的多客服客户端,可为空
|
||||
* @return bool|array
|
||||
*/
|
||||
public function createKFSession($openid, $kf_account, $text = '')
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$data = array("openid" => $openid, "kf_account" => $kf_account);
|
||||
$text !== '' && $data["text"] = $text;
|
||||
$result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::CUSTOM_SESSION_CREATE . "access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭指定多客服会话
|
||||
* @tutorial 当用户被其他客服接待时则会失败
|
||||
* @param string $openid //用户openid
|
||||
* @param string $kf_account //客服账号
|
||||
* @param string $text //附加信息,文本会展示在客服人员的多客服客户端,可为空
|
||||
* @return bool | array //成功返回json数组
|
||||
* {
|
||||
* "errcode": 0,
|
||||
* "errmsg": "ok",
|
||||
* }
|
||||
*/
|
||||
public function closeKFSession($openid, $kf_account, $text = '')
|
||||
{
|
||||
$data = array("openid" => $openid, "kf_account" => $kf_account);
|
||||
if ($text) {
|
||||
$data["text"] = $text;
|
||||
}
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::CUSTOM_SESSION_CLOSE . "access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户会话状态
|
||||
* @param string $openid //用户openid
|
||||
* @return bool | array //成功返回json数组
|
||||
* {
|
||||
* "errcode" : 0,
|
||||
* "errmsg" : "ok",
|
||||
* "kf_account" : "test1@test", //正在接待的客服
|
||||
* "createtime": 123456789, //会话接入时间
|
||||
* }
|
||||
*/
|
||||
public function getKFSession($openid)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$result = Tools::httpGet(self::API_BASE_URL_PREFIX . self::CUSTOM_SESSION_GET . "access_token={$this->access_token}" . '&openid=' . $openid);
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定客服的会话列表
|
||||
* @param string $kf_account //用户openid
|
||||
* @return bool | array //成功返回json数组
|
||||
* array(
|
||||
* 'sessionlist' => array (
|
||||
* array (
|
||||
* 'openid'=>'OPENID', //客户 openid
|
||||
* 'createtime'=>123456789, //会话创建时间,UNIX 时间戳
|
||||
* ),
|
||||
* array (
|
||||
* 'openid'=>'OPENID', //客户 openid
|
||||
* 'createtime'=>123456789, //会话创建时间,UNIX 时间戳
|
||||
* ),
|
||||
* )
|
||||
* )
|
||||
*/
|
||||
public function getKFSessionlist($kf_account)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$result = Tools::httpGet(self::API_BASE_URL_PREFIX . self::CUSTOM_SESSION_GET_LIST . "access_token={$this->access_token}" . '&kf_account=' . $kf_account);
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取未接入会话列表
|
||||
* @return bool|array
|
||||
*/
|
||||
public function getKFSessionWait()
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$result = Tools::httpGet(self::API_BASE_URL_PREFIX . self::CUSTOM_SESSION_GET_WAIT . "access_token={$this->access_token}");
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加客服账号
|
||||
*
|
||||
* @param string $account 完整客服账号(账号前缀@公众号微信号,账号前缀最多10个字符)
|
||||
* @param string $nickname 客服昵称,最长6个汉字或12个英文字符
|
||||
* @param string $password 客服账号明文登录密码,会自动加密
|
||||
* @return bool|array
|
||||
*/
|
||||
public function addKFAccount($account, $nickname, $password)
|
||||
{
|
||||
$data = array("kf_account" => $account, "nickname" => $nickname, "password" => md5($password));
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::CS_KF_ACCOUNT_ADD_URL . "access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改客服账号信息
|
||||
*
|
||||
* @param string $account //完整客服账号,格式为:账号前缀@公众号微信号,账号前缀最多10个字符,必须是英文或者数字字符
|
||||
* @param string $nickname //客服昵称,最长6个汉字或12个英文字符
|
||||
* @param string $password //客服账号明文登录密码,会自动加密
|
||||
* @return bool|array
|
||||
* 成功返回结果
|
||||
* {
|
||||
* "errcode": 0,
|
||||
* "errmsg": "ok",
|
||||
* }
|
||||
*/
|
||||
public function updateKFAccount($account, $nickname, $password)
|
||||
{
|
||||
$data = array("kf_account" => $account, "nickname" => $nickname, "password" => md5($password));
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::CS_KF_ACCOUNT_UPDATE_URL . "access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除客服账号
|
||||
* @param string $account 完整客服账号(账号前缀@公众号微信号,账号前缀最多10个字符)
|
||||
* @return bool|array
|
||||
*/
|
||||
public function deleteKFAccount($account)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$result = Tools::httpGet(self::API_BASE_URL_PREFIX . self::CS_KF_ACCOUNT_DEL_URL . "access_token={$this->access_token}" . '&kf_account=' . $account);
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传客服头像
|
||||
* @param string $account 完整客服账号(账号前缀@公众号微信号,账号前缀最多10个字符)
|
||||
* @param string $imgfile 头像文件完整路径,如:'D:\user.jpg'。头像文件必须JPG格式,像素建议640*640
|
||||
* @return bool|array
|
||||
*/
|
||||
public function setKFHeadImg($account, $imgfile)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::CS_KF_ACCOUNT_UPLOAD_HEADIMG_URL . "access_token={$this->access_token}&kf_account={$account}", array('media' => '@' . $imgfile));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,467 +0,0 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | wechat-php-sdk
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2017 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方文档: https://www.kancloud.cn/zoujingli/wechat-php-sdk
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/wechat-php-sdk
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace Wechat;
|
||||
|
||||
use Wechat\Lib\Common;
|
||||
use Wechat\Lib\Tools;
|
||||
|
||||
/**
|
||||
* 微信设备相关SDK
|
||||
* @author Anyon <zoujingli@qq.com>
|
||||
* @date 2016-08-22 10:35
|
||||
*/
|
||||
class WechatDevice extends Common
|
||||
{
|
||||
|
||||
const SHAKEAROUND_DEVICE_APPLYID = '/shakearound/device/applyid?'; //申请设备ID
|
||||
const SHAKEAROUND_DEVICE_APPLYSTATUS = '/shakearound/device/applystatus?'; //查询设备ID申请审核状态
|
||||
const SHAKEAROUND_DEVICE_UPDATE = '/shakearound/device/update?'; //编辑设备信息
|
||||
const SHAKEAROUND_DEVICE_SEARCH = '/shakearound/device/search?'; //查询设备列表
|
||||
const SHAKEAROUND_DEVICE_BINDLOCATION = '/shakearound/device/bindlocation?'; //配置设备与门店ID的关系
|
||||
const SHAKEAROUND_DEVICE_BINDPAGE = '/shakearound/device/bindpage?'; //配置设备与页面的绑定关系
|
||||
const SHAKEAROUND_MATERIAL_ADD = '/shakearound/material/add?'; //上传摇一摇图片素材
|
||||
const SHAKEAROUND_PAGE_ADD = '/shakearound/page/add?'; //增加页面
|
||||
const SHAKEAROUND_PAGE_UPDATE = '/shakearound/page/update?'; //编辑页面
|
||||
const SHAKEAROUND_PAGE_SEARCH = '/shakearound/page/search?'; //查询页面列表
|
||||
const SHAKEAROUND_PAGE_DELETE = '/shakearound/page/delete?'; //删除页面
|
||||
const SHAKEAROUND_USER_GETSHAKEINFO = '/shakearound/user/getshakeinfo?'; //获取摇周边的设备及用户信息
|
||||
const SHAKEAROUND_STATISTICS_DEVICE = '/shakearound/statistics/device?'; //以设备为维度的数据统计接口
|
||||
const SHAKEAROUND_STATISTICS_PAGE = '/shakearound/statistics/page?'; //以页面为维度的数据统计接口
|
||||
|
||||
|
||||
/**
|
||||
* 申请设备ID
|
||||
* @param array $data
|
||||
* @return bool|array
|
||||
*/
|
||||
public function applyShakeAroundDevice($data)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::SHAKEAROUND_DEVICE_APPLYID . "access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询设备ID申请审核状态
|
||||
* @param int $apply_id
|
||||
* @return bool|array
|
||||
*/
|
||||
public function applyStatusShakeAroundDevice($apply_id)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$data = array("apply_id" => $apply_id);
|
||||
$result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::SHAKEAROUND_DEVICE_APPLYSTATUS . "access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑设备信息
|
||||
* @param array $data
|
||||
* @return bool
|
||||
*/
|
||||
public function updateShakeAroundDevice($data)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::SHAKEAROUND_DEVICE_UPDATE . "access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询设备列表
|
||||
* @param $data
|
||||
* @return bool|array
|
||||
*/
|
||||
public function searchShakeAroundDevice($data)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::SHAKEAROUND_DEVICE_SEARCH . "access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置设备与门店的关联关系
|
||||
* @param string $device_id 设备编号,若填了UUID、major、minor,则可不填设备编号,若二者都填,则以设备编号为优先
|
||||
* @param int $poi_id 待关联的门店ID
|
||||
* @param string $uuid UUID、major、minor,三个信息需填写完整,若填了设备编号,则可不填此信息
|
||||
* @param int $major
|
||||
* @param int $minor
|
||||
* @return bool|array
|
||||
*/
|
||||
public function bindLocationShakeAroundDevice($device_id, $poi_id, $uuid = '', $major = 0, $minor = 0)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
if (!$device_id) {
|
||||
if (!$uuid || !$major || !$minor) {
|
||||
return false;
|
||||
}
|
||||
$device_identifier = array('uuid' => $uuid, 'major' => $major, 'minor' => $minor);
|
||||
} else {
|
||||
$device_identifier = array('device_id' => $device_id);
|
||||
}
|
||||
$data = array('device_identifier' => $device_identifier, 'poi_id' => $poi_id);
|
||||
$result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::SHAKEAROUND_DEVICE_BINDLOCATION . "access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json; //这个可以更改为返回true
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置设备与其他公众账号门店的关联关系
|
||||
* @param type $device_identifier 设备信息
|
||||
* @param type $poi_id 待关联的门店ID
|
||||
* @param type $poi_appid 目标微信appid
|
||||
* @return boolean
|
||||
*/
|
||||
public function bindLocationOtherShakeAroundDevice($device_identifier, $poi_id, $poi_appid)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$data = array('device_identifier' => $device_identifier, 'poi_id' => $poi_id, "type" => 2, "poi_appid" => $poi_appid);
|
||||
$result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::SHAKEAROUND_DEVICE_BINDLOCATION . "access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置设备与页面的关联关系
|
||||
* @param string $device_id 设备编号,若填了UUID、major、minor,则可不填设备编号,若二者都填,则以设备编号为优先
|
||||
* @param array $page_ids 待关联的页面列表
|
||||
* @param int $bind 关联操作标志位, 0 为解除关联关系,1 为建立关联关系
|
||||
* @param int $append 新增操作标志位, 0 为覆盖,1 为新增
|
||||
* @param string $uuid UUID、major、minor,三个信息需填写完整,若填了设备编号,则可不填此信息
|
||||
* @param int $major
|
||||
* @param int $minor
|
||||
* @return bool|array
|
||||
*/
|
||||
public function bindPageShakeAroundDevice($device_id, $page_ids = array(), $bind = 1, $append = 1, $uuid = '', $major = 0, $minor = 0)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
if (!$device_id) {
|
||||
if (!$uuid || !$major || !$minor) {
|
||||
return false;
|
||||
}
|
||||
$device_identifier = array('uuid' => $uuid, 'major' => $major, 'minor' => $minor);
|
||||
} else {
|
||||
$device_identifier = array('device_id' => $device_id);
|
||||
}
|
||||
$data = array('device_identifier' => $device_identifier, 'page_ids' => $page_ids, 'bind' => $bind, 'append' => $append);
|
||||
$result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::SHAKEAROUND_DEVICE_BINDPAGE . "access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 上传在摇一摇页面展示的图片素材
|
||||
* @param array $data {"media":'@Path\filename.jpg'}
|
||||
* @return bool|array
|
||||
*/
|
||||
public function uploadShakeAroundMedia($data)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::SHAKEAROUND_MATERIAL_ADD . "access_token={$this->access_token}", $data);
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 增加摇一摇出来的页面信息
|
||||
* @param string $title 在摇一摇页面展示的主标题,不超过6 个字
|
||||
* @param string $description 在摇一摇页面展示的副标题,不超过7 个字
|
||||
* @param string $icon_url 在摇一摇页面展示的图片, 格式限定为:jpg,jpeg,png,gif; 建议120*120 , 限制不超过200*200
|
||||
* @param string $page_url 跳转链接
|
||||
* @param string $comment 页面的备注信息,不超过15 个字,可不填
|
||||
* @return bool|array
|
||||
*/
|
||||
public function addShakeAroundPage($title, $description, $icon_url, $page_url, $comment = '')
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$data = array("title" => $title, "description" => $description, "icon_url" => $icon_url, "page_url" => $page_url, "comment" => $comment);
|
||||
$result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::SHAKEAROUND_PAGE_ADD . "access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 编辑摇一摇出来的页面信息
|
||||
* @param int $page_id
|
||||
* @param string $title 在摇一摇页面展示的主标题,不超过6 个字
|
||||
* @param string $description 在摇一摇页面展示的副标题,不超过7 个字
|
||||
* @param string $icon_url 在摇一摇页面展示的图片, 格式限定为:jpg,jpeg,png,gif; 建议120*120 , 限制不超过200*200
|
||||
* @param string $page_url 跳转链接
|
||||
* @param string $comment 页面的备注信息,不超过15 个字,可不填
|
||||
* @return bool|array
|
||||
*/
|
||||
public function updateShakeAroundPage($page_id, $title, $description, $icon_url, $page_url, $comment = '')
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$data = array("page_id" => $page_id, "title" => $title, "description" => $description, "icon_url" => $icon_url, "page_url" => $page_url, "comment" => $comment);
|
||||
$result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::SHAKEAROUND_PAGE_UPDATE . "access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询已有的页面
|
||||
* @param array $page_ids
|
||||
* @param int $begin
|
||||
* @param int $count
|
||||
* @return bool|mixed
|
||||
*/
|
||||
public function searchShakeAroundPage($page_ids = array(), $begin = 0, $count = 1)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
if (!empty($page_ids)) {
|
||||
$data = array('page_ids' => $page_ids);
|
||||
} else {
|
||||
$data = array('begin' => $begin, 'count' => $count);
|
||||
}
|
||||
$result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::SHAKEAROUND_PAGE_SEARCH . "access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除已有的页面
|
||||
* @param array $page_ids
|
||||
* @return bool|array
|
||||
*/
|
||||
public function deleteShakeAroundPage($page_ids = array())
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$data = array('page_ids' => $page_ids);
|
||||
$result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::SHAKEAROUND_PAGE_DELETE . "access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取设备信息
|
||||
* @param string $ticket 摇周边业务的ticket(可在摇到的URL中得到,ticket生效时间为30 分钟)
|
||||
* @return bool|array
|
||||
*/
|
||||
public function getShakeInfoShakeAroundUser($ticket)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$data = array('ticket' => $ticket);
|
||||
$result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::SHAKEAROUND_USER_GETSHAKEINFO . "access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 以设备为维度的数据统计接口
|
||||
* @param int $device_id 设备编号,若填了UUID、major、minor,即可不填设备编号,二者选其一
|
||||
* @param int $begin_date 起始日期时间戳,最长时间跨度为30 天
|
||||
* @param int $end_date 结束日期时间戳,最长时间跨度为30 天
|
||||
* @param string $uuid UUID、major、minor,三个信息需填写完成,若填了设备编辑,即可不填此信息,二者选其一
|
||||
* @param int $major
|
||||
* @param int $minor
|
||||
* @return bool|array
|
||||
*/
|
||||
public function deviceShakeAroundStatistics($device_id, $begin_date, $end_date, $uuid = '', $major = 0, $minor = 0)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
if (!$device_id) {
|
||||
if (!$uuid || !$major || !$minor) {
|
||||
return false;
|
||||
}
|
||||
$device_identifier = array('uuid' => $uuid, 'major' => $major, 'minor' => $minor);
|
||||
} else {
|
||||
$device_identifier = array('device_id' => $device_id);
|
||||
}
|
||||
$data = array('device_identifier' => $device_identifier, 'begin_date' => $begin_date, 'end_date' => $end_date);
|
||||
$result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::SHAKEAROUND_STATISTICS_DEVICE . "access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 以页面为维度的数据统计接口
|
||||
* @param int $page_id 指定页面的ID
|
||||
* @param int $begin_date 起始日期时间戳,最长时间跨度为30 天
|
||||
* @param int $end_date 结束日期时间戳,最长时间跨度为30 天
|
||||
* @return bool|array
|
||||
*/
|
||||
public function pageShakeAroundStatistics($page_id, $begin_date, $end_date)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$data = array('page_id' => $page_id, 'begin_date' => $begin_date, 'end_date' => $end_date);
|
||||
$result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::SHAKEAROUND_STATISTICS_DEVICE . "access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,209 +0,0 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | wechat-php-sdk
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2017 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方文档: https://www.kancloud.cn/zoujingli/wechat-php-sdk
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/wechat-php-sdk
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace Wechat;
|
||||
|
||||
use Wechat\Lib\Common;
|
||||
use Wechat\Lib\Tools;
|
||||
|
||||
/**
|
||||
* 微信扩展功能
|
||||
*
|
||||
* @author Anyon <zoujingli@qq.com>
|
||||
* @date 2016-08-22 10:32
|
||||
*/
|
||||
class WechatExtends extends Common
|
||||
{
|
||||
|
||||
const QR_LIMIT_SCENE = 1;
|
||||
|
||||
/** 语义理解 */
|
||||
const SEMANTIC_API_URL = '/semantic/semproxy/search?';
|
||||
const QRCODE_IMG_URL = 'https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=';
|
||||
const QRCODE_CREATE_URL = '/qrcode/create?';
|
||||
const SHORT_URL = '/shorturl?';
|
||||
const QR_SCENE = 0;
|
||||
|
||||
/** 数据分析接口 */
|
||||
static $DATACUBE_URL_ARR = array(//用户分析
|
||||
'user' => array(
|
||||
'summary' => '/datacube/getusersummary?', //获取用户增减数据(getusersummary)
|
||||
'cumulate' => '/datacube/getusercumulate?', //获取累计用户数据(getusercumulate)
|
||||
),
|
||||
'article' => array(//图文分析
|
||||
'summary' => '/datacube/getarticlesummary?', //获取图文群发每日数据(getarticlesummary)
|
||||
'total' => '/datacube/getarticletotal?', //获取图文群发总数据(getarticletotal)
|
||||
'read' => '/datacube/getuserread?', //获取图文统计数据(getuserread)
|
||||
'readhour' => '/datacube/getuserreadhour?', //获取图文统计分时数据(getuserreadhour)
|
||||
'share' => '/datacube/getusershare?', //获取图文分享转发数据(getusershare)
|
||||
'sharehour' => '/datacube/getusersharehour?', //获取图文分享转发分时数据(getusersharehour)
|
||||
),
|
||||
'upstreammsg' => array(//消息分析
|
||||
'summary' => '/datacube/getupstreammsg?', //获取消息发送概况数据(getupstreammsg)
|
||||
'hour' => '/datacube/getupstreammsghour?', //获取消息分送分时数据(getupstreammsghour)
|
||||
'week' => '/datacube/getupstreammsgweek?', //获取消息发送周数据(getupstreammsgweek)
|
||||
'month' => '/datacube/getupstreammsgmonth?', //获取消息发送月数据(getupstreammsgmonth)
|
||||
'dist' => '/datacube/getupstreammsgdist?', //获取消息发送分布数据(getupstreammsgdist)
|
||||
'distweek' => '/datacube/getupstreammsgdistweek?', //获取消息发送分布周数据(getupstreammsgdistweek)
|
||||
'distmonth' => '/datacube/getupstreammsgdistmonth?', //获取消息发送分布月数据(getupstreammsgdistmonth)
|
||||
),
|
||||
'interface' => array(//接口分析
|
||||
'summary' => '/datacube/getinterfacesummary?', //获取接口分析数据(getinterfacesummary)
|
||||
'summaryhour' => '/datacube/getinterfacesummaryhour?', //获取接口分析分时数据(getinterfacesummaryhour)
|
||||
)
|
||||
);
|
||||
|
||||
/**
|
||||
* 获取二维码图片
|
||||
* @param string $ticket 传入由getQRCode方法生成的ticket参数
|
||||
* @return string url 返回http地址
|
||||
*/
|
||||
public function getQRUrl($ticket)
|
||||
{
|
||||
return self::QRCODE_IMG_URL . urlencode($ticket);
|
||||
}
|
||||
|
||||
/**
|
||||
* 长链接转短链接接口
|
||||
* @param string $long_url 传入要转换的长url
|
||||
* @return bool|string url 成功则返回转换后的短url
|
||||
*/
|
||||
public function getShortUrl($long_url)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$data = array('action' => 'long2short', 'long_url' => $long_url);
|
||||
$result = Tools::httpPost(self::API_URL_PREFIX . self::SHORT_URL . "access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json['short_url'];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建二维码ticket
|
||||
* @param int|string $scene_id 自定义追踪id,临时二维码只能用数值型
|
||||
* @param int $type 0:临时二维码;1:永久二维码(此时expire参数无效);2:永久二维码(此时expire参数无效)
|
||||
* @param int $expire 临时二维码有效期,最大为2592000秒(30天)
|
||||
* @return bool|array ('ticket'=>'qrcode字串','expire_seconds'=>2592000,'url'=>'二维码图片解析后的地址')
|
||||
*/
|
||||
public function getQRCode($scene_id, $type = 0, $expire = 2592000)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$type = ($type && is_string($scene_id)) ? 2 : $type;
|
||||
$data = array(
|
||||
'action_name' => $type ? ($type == 2 ? "QR_LIMIT_STR_SCENE" : "QR_LIMIT_SCENE") : "QR_SCENE",
|
||||
'expire_seconds' => $expire,
|
||||
'action_info' => array('scene' => ($type == 2 ? array('scene_str' => $scene_id) : array('scene_id' => $scene_id)))
|
||||
);
|
||||
if ($type == 1) {
|
||||
unset($data['expire_seconds']);
|
||||
}
|
||||
$result = Tools::httpPost(self::API_URL_PREFIX . self::QRCODE_CREATE_URL . "access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 语义理解接口
|
||||
* @param string $uid 用户唯一id(非开发者id),用户区分公众号下的不同用户(建议填入用户openid)
|
||||
* @param string $query 输入文本串
|
||||
* @param string $category 需要使用的服务类型,多个用“,”隔开,不能为空
|
||||
* @param float $latitude 纬度坐标,与经度同时传入;与城市二选一传入
|
||||
* @param float $longitude 经度坐标,与纬度同时传入;与城市二选一传入
|
||||
* @param string $city 城市名称,与经纬度二选一传入
|
||||
* @param string $region 区域名称,在城市存在的情况下可省略;与经纬度二选一传入
|
||||
* @return bool|array
|
||||
*/
|
||||
public function querySemantic($uid, $query, $category, $latitude = 0.00, $longitude = 0.00, $city = "", $region = "")
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$data = array(
|
||||
'query' => $query,
|
||||
'category' => $category,
|
||||
'appid' => $this->appid,
|
||||
'uid' => ''
|
||||
);
|
||||
//地理坐标或城市名称二选一
|
||||
if ($latitude) {
|
||||
$data['latitude'] = $latitude;
|
||||
$data['longitude'] = $longitude;
|
||||
} elseif ($city) {
|
||||
$data['city'] = $city;
|
||||
} elseif ($region) {
|
||||
$data['region'] = $region;
|
||||
}
|
||||
$result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::SEMANTIC_API_URL . "access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取统计数据
|
||||
* @param string $type 数据分类(user|article|upstreammsg|interface)分别为(用户分析|图文分析|消息分析|接口分析)
|
||||
* @param string $subtype 数据子分类,参考 DATACUBE_URL_ARR 常量定义部分 或者README.md说明文档
|
||||
* @param string $begin_date 开始时间
|
||||
* @param string $end_date 结束时间
|
||||
* @return bool|array 成功返回查询结果数组,其定义请看官方文档
|
||||
*/
|
||||
public function getDatacube($type, $subtype, $begin_date, $end_date = '')
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
if (!isset(self::$DATACUBE_URL_ARR[$type]) || !isset(self::$DATACUBE_URL_ARR[$type][$subtype])) {
|
||||
return false;
|
||||
}
|
||||
$data = array('begin_date' => $begin_date, 'end_date' => $end_date ? $end_date : $begin_date);
|
||||
$result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::$DATACUBE_URL_ARR[$type][$subtype] . "access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return isset($json['list']) ? $json['list'] : $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,161 +0,0 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | wechat-php-sdk
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2017 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方文档: https://www.kancloud.cn/zoujingli/wechat-php-sdk
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/wechat-php-sdk
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace Wechat;
|
||||
|
||||
use Wechat\Lib\Common;
|
||||
use Wechat\Lib\Tools;
|
||||
|
||||
class WechatHardware extends Common
|
||||
{
|
||||
|
||||
const DEVICE_AUTHORIZE_DEVICE = '/device/authorize_device?'; //设备设全
|
||||
const DEVICE_GETQRCODE = '/device/getqrcode?'; //设备授权新接口
|
||||
const DEVICE_CREATE_QRCODE = '/device/create_qrcode?'; //获取设备二维码
|
||||
const DEVICE_GET_STAT = '/device/get_stat?'; //获取设备状态
|
||||
const DEVICE_TRANSMSG = '/device/transmsg?'; //主动发送消息给设备
|
||||
const DEVICE_COMPEL_UNBINDHTTPS = '/device/compel_unbind?'; //强制解绑用户和设备
|
||||
|
||||
/**
|
||||
* 强制解绑用户和设备
|
||||
* @param $data
|
||||
* @return bool|mixed
|
||||
*/
|
||||
public function deviceCompelUnbindhttps($data)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::DEVICE_COMPEL_UNBINDHTTPS . "access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public function transmsg($data)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::DEVICE_TRANSMSG . "access_token={$this->access_token}", Tools::json_encode($data));
|
||||
//dump($result);
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getQrcode($product_id)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$result = Tools::httpGet(self::API_BASE_URL_PREFIX . self::DEVICE_GETQRCODE . "access_token={$this->access_token}&product_id=$product_id");
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设备授权
|
||||
* @param $data
|
||||
* @return bool|mixed
|
||||
*/
|
||||
public function deviceAuthorize($data)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::DEVICE_AUTHORIZE_DEVICE . "access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设备二维码
|
||||
* @param $data
|
||||
* @return bool|mixed
|
||||
*/
|
||||
public function getDeviceQrcode($data)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::DEVICE_CREATE_QRCODE . "access_token={$this->access_token}", Tools::json_encode($data));
|
||||
//dump($result);
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设备状态
|
||||
* @param $device_id
|
||||
* @return bool|mixed
|
||||
*/
|
||||
public function getDeviceStat($device_id)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$result = Tools::httpGet(self::API_BASE_URL_PREFIX . self::DEVICE_GET_STAT . "access_token={$this->access_token}&device_id=$device_id");
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,443 +0,0 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | wechat-php-sdk
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2017 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方文档: https://www.kancloud.cn/zoujingli/wechat-php-sdk
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/wechat-php-sdk
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace Wechat;
|
||||
|
||||
use Wechat\Lib\Cache;
|
||||
use Wechat\Lib\Common;
|
||||
use Wechat\Lib\Tools;
|
||||
|
||||
/**
|
||||
* 微信媒体素材管理类
|
||||
*
|
||||
* @author Anyon <zoujingli@qq.com>
|
||||
* @date 2016/10/26 14:47
|
||||
*/
|
||||
class WechatMedia extends Common
|
||||
{
|
||||
|
||||
const UPLOAD_MEDIA_URL = 'http://file.api.weixin.qq.com/cgi-bin';
|
||||
const MEDIA_UPLOAD_URL = '/media/upload?';
|
||||
const MEDIA_UPLOADIMG_URL = '/media/uploadimg?'; //图片上传接口
|
||||
const MEDIA_GET_URL = '/media/get?';
|
||||
const MEDIA_VIDEO_UPLOAD = '/media/uploadvideo?';
|
||||
const MEDIA_FOREVER_UPLOAD_URL = '/material/add_material?';
|
||||
const MEDIA_FOREVER_NEWS_UPLOAD_URL = '/material/add_news?';
|
||||
const MEDIA_FOREVER_NEWS_UPDATE_URL = '/material/update_news?';
|
||||
const MEDIA_FOREVER_GET_URL = '/material/get_material?';
|
||||
const MEDIA_FOREVER_DEL_URL = '/material/del_material?';
|
||||
const MEDIA_FOREVER_COUNT_URL = '/material/get_materialcount?';
|
||||
const MEDIA_FOREVER_BATCHGET_URL = '/material/batchget_material?';
|
||||
const MEDIA_UPLOADNEWS_URL = '/media/uploadnews?';
|
||||
|
||||
/**
|
||||
* 上传临时素材,有效期为3天(认证后的订阅号可用)
|
||||
* 注意:上传大文件时可能需要先调用 set_time_limit(0) 避免超时
|
||||
* 注意:数组的键值任意,但文件名前必须加@,使用单引号以避免本地路径斜杠被转义
|
||||
* 注意:临时素材的media_id是可复用的!
|
||||
* @param array $data {"media":'@Path\filename.jpg'}
|
||||
* @param string $type 类型:图片:image 语音:voice 视频:video 缩略图:thumb
|
||||
* @return bool|array
|
||||
*/
|
||||
public function uploadMedia($data, $type)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
list($cache_file, $media_content) = ['', base64_decode($data['media'])];
|
||||
if (!empty($media_content) && ($cache_file = Cache::file($media_content))) {
|
||||
$data['media'] = "@{$cache_file}";
|
||||
}
|
||||
$result = Tools::httpPost(self::API_URL_PREFIX . self::MEDIA_UPLOAD_URL . "access_token={$this->access_token}&type={$type}", $data);
|
||||
!empty($cache_file) && @unlink($cache_file);
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取临时素材(认证后的订阅号可用)
|
||||
* @param string $media_id 媒体文件id
|
||||
* @param bool $is_video 是否为视频文件,默认为否
|
||||
* @return bool|array
|
||||
*/
|
||||
public function getMedia($media_id, $is_video = false)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
//原先的上传多媒体文件接口使用 self::UPLOAD_MEDIA_URL 前缀
|
||||
//如果要获取的素材是视频文件时,不能使用https协议,必须更换成http协议
|
||||
$url_prefix = $is_video ? str_replace('https', 'http', self::API_URL_PREFIX) : self::API_URL_PREFIX;
|
||||
$result = Tools::httpGet($url_prefix . self::MEDIA_GET_URL . "access_token={$this->access_token}" . '&media_id=' . $media_id);
|
||||
if ($result) {
|
||||
if (is_string($result)) {
|
||||
$json = json_decode($result, true);
|
||||
if (isset($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取临时素材(认证后的订阅号可用) 包含返回的http头信息
|
||||
* @param string $media_id 媒体文件id
|
||||
* @param bool $is_video 是否为视频文件,默认为否
|
||||
* @return bool|array
|
||||
*/
|
||||
public function getMediaWithHttpInfo($media_id, $is_video = false)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
//原先的上传多媒体文件接口使用 self::UPLOAD_MEDIA_URL 前缀
|
||||
//如果要获取的素材是视频文件时,不能使用https协议,必须更换成http协议
|
||||
$url_prefix = $is_video ? str_replace('https', 'http', self::API_URL_PREFIX) : self::API_URL_PREFIX;
|
||||
$url = $url_prefix . self::MEDIA_GET_URL . "access_token={$this->access_token}" . '&media_id=' . $media_id;
|
||||
$oCurl = curl_init();
|
||||
if (stripos($url, "https://") !== false) {
|
||||
curl_setopt($oCurl, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($oCurl, CURLOPT_SSL_VERIFYHOST, false);
|
||||
curl_setopt($oCurl, CURLOPT_SSLVERSION, 1);
|
||||
}
|
||||
curl_setopt($oCurl, CURLOPT_URL, $url);
|
||||
curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, 1);
|
||||
$sContent = curl_exec($oCurl);
|
||||
$aStatus = curl_getinfo($oCurl);
|
||||
|
||||
$result = [];
|
||||
|
||||
if (intval($aStatus["http_code"]) !== 200) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($sContent) {
|
||||
if (is_string($sContent)) {
|
||||
$json = json_decode($sContent, true);
|
||||
if (isset($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
}
|
||||
$result['content'] = $sContent;
|
||||
$result['info'] = $aStatus;
|
||||
return $result;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传图片,本接口所上传的图片不占用公众号的素材库中图片数量的5000个的限制。图片仅支持jpg/png格式,大小必须在1MB以下。 (认证后的订阅号可用)
|
||||
* 注意:上传大文件时可能需要先调用 set_time_limit(0) 避免超时
|
||||
* 注意:数组的键值任意,但文件名前必须加@,使用单引号以避免本地路径斜杠被转义
|
||||
* @param array $data {"media":'@Path\filename.jpg'}
|
||||
* @return bool|array
|
||||
*/
|
||||
public function uploadImg($data)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
list($cache_file, $media_content) = ['', base64_decode($data['media'])];
|
||||
if (!empty($media_content) && ($cache_file = Cache::file($media_content))) {
|
||||
$data['media'] = "@{$cache_file}";
|
||||
}
|
||||
$result = Tools::httpPost(self::API_URL_PREFIX . self::MEDIA_UPLOADIMG_URL . "access_token={$this->access_token}", $data);
|
||||
!empty($cache_file) && @unlink($cache_file);
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传永久素材(认证后的订阅号可用)
|
||||
* 新增的永久素材也可以在公众平台官网素材管理模块中看到
|
||||
* 注意:上传大文件时可能需要先调用 set_time_limit(0) 避免超时
|
||||
* 注意:数组的键值任意,但文件名前必须加@,使用单引号以避免本地路径斜杠被转义
|
||||
* @param array $data {"media":'@Path\filename.jpg'}, 支持base64格式
|
||||
* @param string $type 类型:图片:image 语音:voice 视频:video 缩略图:thumb
|
||||
* @param bool $is_video 是否为视频文件,默认为否
|
||||
* @param array $video_info 视频信息数组,非视频素材不需要提供 array('title'=>'视频标题','introduction'=>'描述')
|
||||
* @return bool|array
|
||||
*/
|
||||
public function uploadForeverMedia($data, $type, $is_video = false, $video_info = array())
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$is_video && ($data['description'] = Tools::json_encode($video_info));
|
||||
list($cache_file, $media_content) = ['', base64_decode($data['media'])];
|
||||
if (!empty($media_content) && ($cache_file = Cache::file($media_content))) {
|
||||
$data['media'] = "@{$cache_file}";
|
||||
}
|
||||
$result = Tools::httpPost(self::API_URL_PREFIX . self::MEDIA_FOREVER_UPLOAD_URL . "access_token={$this->access_token}&type={$type}", $data);
|
||||
!empty($cache_file) && @unlink($cache_file);
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传永久图文素材(认证后的订阅号可用)
|
||||
* 新增的永久素材也可以在公众平台官网素材管理模块中看到
|
||||
* @param array $data 消息结构{"articles":[{...}]}
|
||||
* @return bool|array
|
||||
*/
|
||||
public function uploadForeverArticles($data)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$result = Tools::httpPost(self::API_URL_PREFIX . self::MEDIA_FOREVER_NEWS_UPLOAD_URL . "access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改永久图文素材(认证后的订阅号可用)
|
||||
* 永久素材也可以在公众平台官网素材管理模块中看到
|
||||
* @param string $media_id 图文素材id
|
||||
* @param array $data 消息结构{"articles":[{...}]}
|
||||
* @param int $index 更新的文章在图文素材的位置,第一篇为0,仅多图文使用
|
||||
* @return bool|array
|
||||
*/
|
||||
public function updateForeverArticles($media_id, $data, $index = 0)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
!isset($data['index']) && $data['index'] = $index;
|
||||
!isset($data['media_id']) && $data['media_id'] = $media_id;
|
||||
$result = Tools::httpPost(self::API_URL_PREFIX . self::MEDIA_FOREVER_NEWS_UPDATE_URL . "access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取永久素材(认证后的订阅号可用)
|
||||
* 返回图文消息数组或二进制数据,失败返回false
|
||||
* @param string $media_id 媒体文件id
|
||||
* @param bool $is_video 是否为视频文件,默认为否
|
||||
* @return bool|array
|
||||
*/
|
||||
public function getForeverMedia($media_id, $is_video = false)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$data = array('media_id' => $media_id);
|
||||
$result = Tools::httpPost(self::API_URL_PREFIX . self::MEDIA_FOREVER_GET_URL . "access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
if (is_string($result)) {
|
||||
$json = json_decode($result, true);
|
||||
if ($json) {
|
||||
if (isset($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除永久素材(认证后的订阅号可用)
|
||||
* @param string $media_id 媒体文件id
|
||||
* @return bool
|
||||
*/
|
||||
public function delForeverMedia($media_id)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$data = array('media_id' => $media_id);
|
||||
$result = Tools::httpPost(self::API_URL_PREFIX . self::MEDIA_FOREVER_DEL_URL . "access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取永久素材列表(认证后的订阅号可用)
|
||||
* @param string $type 素材的类型,图片(image)、视频(video)、语音 (voice)、图文(news)
|
||||
* @param int $offset 全部素材的偏移位置,0表示从第一个素材
|
||||
* @param int $count 返回素材的数量,取值在1到20之间
|
||||
* @return bool|array
|
||||
* 返回数组格式:
|
||||
* array(
|
||||
* 'total_count'=>0, //该类型的素材的总数
|
||||
* 'item_count'=>0, //本次调用获取的素材的数量
|
||||
* 'item'=>array() //素材列表数组,内容定义请参考官方文档
|
||||
* )
|
||||
*/
|
||||
public function getForeverList($type, $offset, $count)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$data = array('type' => $type, 'offset' => $offset, 'count' => $count,);
|
||||
$result = Tools::httpPost(self::API_URL_PREFIX . self::MEDIA_FOREVER_BATCHGET_URL . "access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (isset($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取永久素材总数(认证后的订阅号可用)
|
||||
* @return bool|array
|
||||
* 返回数组格式:
|
||||
* array(
|
||||
* 'voice_count'=>0, //语音总数量
|
||||
* 'video_count'=>0, //视频总数量
|
||||
* 'image_count'=>0, //图片总数量
|
||||
* 'news_count'=>0 //图文总数量
|
||||
* )
|
||||
*/
|
||||
public function getForeverCount()
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$result = Tools::httpGet(self::API_URL_PREFIX . self::MEDIA_FOREVER_COUNT_URL . "access_token={$this->access_token}");
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (isset($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传图文消息素材,用于群发(认证后的订阅号可用)
|
||||
* @param array $data 消息结构{"articles":[{...}]}
|
||||
* @return bool|array
|
||||
*/
|
||||
public function uploadArticles($data)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$result = Tools::httpPost(self::API_URL_PREFIX . self::MEDIA_UPLOADNEWS_URL . "access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传视频素材(认证后的订阅号可用)
|
||||
* @param array $data 消息结构
|
||||
* {
|
||||
* "media_id"=>"", //通过上传媒体接口得到的MediaId
|
||||
* "title"=>"TITLE", //视频标题
|
||||
* "description"=>"Description" //视频描述
|
||||
* }
|
||||
* @return bool|array
|
||||
* {
|
||||
* "type":"video",
|
||||
* "media_id":"mediaid",
|
||||
* "created_at":1398848981
|
||||
* }
|
||||
*/
|
||||
public function uploadMpVideo($data)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$result = Tools::httpPost(self::UPLOAD_MEDIA_URL . self::MEDIA_VIDEO_UPLOAD . "access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,183 +0,0 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | wechat-php-sdk
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2017 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方文档: https://www.kancloud.cn/zoujingli/wechat-php-sdk
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/wechat-php-sdk
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace Wechat;
|
||||
|
||||
use Wechat\Lib\Common;
|
||||
use Wechat\Lib\Tools;
|
||||
|
||||
/**
|
||||
* 微信菜单操作SDK
|
||||
*
|
||||
* @author Anyon <zoujingli@qq.com>
|
||||
* @date 2016/06/28 11:52
|
||||
*/
|
||||
class WechatMenu extends Common
|
||||
{
|
||||
|
||||
/** 创建自定义菜单 */
|
||||
const MENU_ADD_URL = '/menu/create?';
|
||||
/* 获取自定义菜单 */
|
||||
const MENU_GET_URL = '/menu/get?';
|
||||
/* 删除自定义菜单 */
|
||||
const MENU_DEL_URL = '/menu/delete?';
|
||||
|
||||
/** 添加个性菜单 */
|
||||
const COND_MENU_ADD_URL = '/menu/addconditional?';
|
||||
/* 删除个性菜单 */
|
||||
const COND_MENU_DEL_URL = '/menu/delconditional?';
|
||||
/* 测试个性菜单 */
|
||||
const COND_MENU_TRY_URL = '/menu/trymatch?';
|
||||
|
||||
/**
|
||||
* 创建自定义菜单
|
||||
* @param array $data 菜单数组数据
|
||||
* @link https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421141013&token=&lang=zh_CN 文档
|
||||
* @return bool
|
||||
*/
|
||||
public function createMenu($data)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$result = Tools::httpPost(self::API_URL_PREFIX . self::MENU_ADD_URL . "access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有菜单
|
||||
* @return bool|array
|
||||
*/
|
||||
public function getMenu()
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$result = Tools::httpGet(self::API_URL_PREFIX . self::MENU_GET_URL . "access_token={$this->access_token}");
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || isset($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除所有菜单
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteMenu()
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$result = Tools::httpGet(self::API_URL_PREFIX . self::MENU_DEL_URL . "access_token={$this->access_token}");
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建个性菜单
|
||||
* @param array $data 菜单数组数据
|
||||
* @link https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1455782296&token=&lang=zh_CN 文档
|
||||
* @return bool|string
|
||||
*/
|
||||
public function createCondMenu($data)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$result = Tools::httpPost(self::API_URL_PREFIX . self::COND_MENU_ADD_URL . "access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode']) || empty($json['menuid'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json['menuid'];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除个性菜单
|
||||
* @param string $menuid 菜单ID
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteCondMenu($menuid)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$data = array('menuid' => $menuid);
|
||||
$result = Tools::httpPost(self::API_URL_PREFIX . self::COND_MENU_DEL_URL . "access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试并返回个性化菜单
|
||||
* @param string $openid 粉丝openid
|
||||
* @return bool
|
||||
*/
|
||||
public function tryCondMenu($openid)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$data = array('user_id' => $openid);
|
||||
$result = Tools::httpPost(self::API_URL_PREFIX . self::COND_MENU_TRY_URL . "access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,352 +0,0 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | wechat-php-sdk
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2017 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方文档: https://www.kancloud.cn/zoujingli/wechat-php-sdk
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/wechat-php-sdk
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace Wechat;
|
||||
|
||||
use Wechat\Lib\Common;
|
||||
use Wechat\Lib\Tools;
|
||||
|
||||
/**
|
||||
* 微信模板消息
|
||||
*
|
||||
* @author Anyon <zoujingli@qq.com>
|
||||
* @date 2016/06/28 11:29
|
||||
*/
|
||||
class WechatMessage extends Common
|
||||
{
|
||||
|
||||
/**
|
||||
* 获取模板列表
|
||||
* @return bool|array
|
||||
*/
|
||||
public function getAllPrivateTemplate()
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$result = Tools::httpPost(self::API_URL_PREFIX . "/template/get_all_private_template?access_token={$this->access_token}", []);
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设置的行业信息
|
||||
* @return bool|array
|
||||
*/
|
||||
public function getTMIndustry()
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$result = Tools::httpPost(self::API_URL_PREFIX . "/template/get_industry?access_token={$this->access_token}", []);
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除模板消息
|
||||
* @param string $tpl_id
|
||||
* @return bool
|
||||
*/
|
||||
public function delPrivateTemplate($tpl_id)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$data = array('template_id' => $tpl_id);
|
||||
$result = Tools::httpPost(self::API_URL_PREFIX . "/template/del_private_template?access_token={$this->access_token}", [Tools::json_encode($data)]);
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 模板消息 设置所属行业
|
||||
* @param string $id1 公众号模板消息所属行业编号,参看官方开发文档 行业代码
|
||||
* @param string $id2 同$id1。但如果只有一个行业,此参数可省略
|
||||
* @return bool|mixed
|
||||
*/
|
||||
public function setTMIndustry($id1, $id2 = '')
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$data = array();
|
||||
!empty($id1) && $data['industry_id1'] = $id1;
|
||||
!empty($id2) && $data['industry_id2'] = $id2;
|
||||
$json = Tools::json_encode($data);
|
||||
$result = Tools::httpPost(self::API_URL_PREFIX . "/template/api_set_industry?access_token={$this->access_token}", $json);
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errMsg = $json['errmsg'];
|
||||
$this->errCode = $json['errcode'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 模板消息 添加消息模板
|
||||
* 成功返回消息模板的调用id
|
||||
* @param string $tpl_id 模板库中模板的编号,有“TM**”和“OPENTMTM**”等形式
|
||||
* @return bool|string
|
||||
*/
|
||||
public function addTemplateMessage($tpl_id)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$data = Tools::json_encode(array('template_id_short' => $tpl_id));
|
||||
$result = Tools::httpPost(self::API_URL_PREFIX . "/template/api_add_template?access_token={$this->access_token}", $data);
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errMsg = $json['errmsg'];
|
||||
$this->errCode = $json['errcode'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json['template_id'];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送模板消息
|
||||
* @param array $data 消息结构
|
||||
* {
|
||||
* "touser":"OPENID",
|
||||
* "template_id":"ngqIpbwh8bUfcSsECmogfXcV14J0tQlEpBO27izEYtY",
|
||||
* "url":"http://weixin.qq.com/download",
|
||||
* "topcolor":"#FF0000",
|
||||
* "data":{
|
||||
* "参数名1": {
|
||||
* "value":"参数",
|
||||
* "color":"#173177" //参数颜色
|
||||
* },
|
||||
* "Date":{
|
||||
* "value":"06月07日 19时24分",
|
||||
* "color":"#173177"
|
||||
* },
|
||||
* "CardNumber":{
|
||||
* "value":"0426",
|
||||
* "color":"#173177"
|
||||
* },
|
||||
* "Type":{
|
||||
* "value":"消费",
|
||||
* "color":"#173177"
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* @return bool|array
|
||||
*/
|
||||
public function sendTemplateMessage($data)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$result = Tools::httpPost(self::API_URL_PREFIX . "/message/template/send?access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errMsg = $json['errmsg'];
|
||||
$this->errCode = $json['errcode'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据标签进行群发 ( 订阅号与服务号认证后均可用 )
|
||||
* @param array $data 消息结构
|
||||
* 注意: 视频需要在调用uploadMedia()方法后,再使用 uploadMpVideo() 方法生成,
|
||||
* 然后获得的 mediaid 才能用于群发,且消息类型为 mpvideo 类型。
|
||||
* @return bool|array
|
||||
* {
|
||||
* "touser"=>array(
|
||||
* "OPENID1",
|
||||
* "OPENID2"
|
||||
* ),
|
||||
* "msgtype"=>"mpvideo",
|
||||
* // 在下面5种类型中选择对应的参数内容
|
||||
* // mpnews | voice | image | mpvideo => array( "media_id"=>"MediaId")
|
||||
* // text => array ( "content" => "hello")
|
||||
* }
|
||||
*/
|
||||
public function sendMassMessage($data)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$result = Tools::httpPost(self::API_URL_PREFIX . "/message/mass/send?access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据标签进行群发 ( 订阅号与服务号认证后均可用 )
|
||||
* @param array $data 消息结构
|
||||
* 注意:视频需要在调用uploadMedia()方法后,再使用 uploadMpVideo() 方法生成,
|
||||
* 然后获得的 mediaid 才能用于群发,且消息类型为 mpvideo 类型。
|
||||
* @return bool|array
|
||||
* {
|
||||
* "filter"=>array(
|
||||
* "is_to_all"=>False, //是否群发给所有用户.True不用分组id,False需填写分组id
|
||||
* "group_id"=>"2" //群发的分组id
|
||||
* ),
|
||||
* "msgtype"=>"mpvideo",
|
||||
* // 在下面5种类型中选择对应的参数内容
|
||||
* // mpnews | voice | image | mpvideo => array( "media_id"=>"MediaId")
|
||||
* // text => array ( "content" => "hello")
|
||||
* }
|
||||
*/
|
||||
public function sendGroupMassMessage($data)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$result = Tools::httpPost(self::API_URL_PREFIX . "/message/mass/sendall?access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除群发图文消息 ( 订阅号与服务号认证后均可用 )
|
||||
* @param string $msg_id 消息ID
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteMassMessage($msg_id)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$data = Tools::json_encode(array('msg_id' => $msg_id));
|
||||
$result = Tools::httpPost(self::API_URL_PREFIX . "/message/mass/delete?access_token={$this->access_token}", $data);
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 预览群发消息 ( 订阅号与服务号认证后均可用 )
|
||||
* @param array $data
|
||||
* 注意: 视频需要在调用uploadMedia()方法后,再使用 uploadMpVideo() 方法生成,
|
||||
* 然后获得的 mediaid 才能用于群发,且消息类型为 mpvideo 类型。
|
||||
* @消息结构
|
||||
* {
|
||||
* "touser"=>"OPENID",
|
||||
* "msgtype"=>"mpvideo",
|
||||
* // 在下面5种类型中选择对应的参数内容
|
||||
* // mpnews | voice | image | mpvideo => array( "media_id"=>"MediaId")
|
||||
* // text => array ( "content" => "hello")
|
||||
* }
|
||||
* @return bool|array
|
||||
*/
|
||||
public function previewMassMessage($data)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$result = Tools::httpPost(self::API_URL_PREFIX . "/message/mass/preview?access_token={$this->access_token}", Tools::json_encode($data));
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询群发消息发送状态 ( 订阅号与服务号认证后均可用 )
|
||||
* @param string $msg_id 消息ID
|
||||
* @return bool|array
|
||||
* {
|
||||
* "msg_id":201053012, //群发消息后返回的消息id
|
||||
* "msg_status":"SEND_SUCCESS", //消息发送后的状态,SENDING表示正在发送 SEND_SUCCESS表示发送成功
|
||||
* }
|
||||
*/
|
||||
public function queryMassMessage($msg_id)
|
||||
{
|
||||
if (!$this->access_token && !$this->getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
$data = Tools::json_encode(array('msg_id' => $msg_id));
|
||||
$result = Tools::httpPost(self::API_URL_PREFIX . "/message/mass/get?access_token={$this->access_token}", $data);
|
||||
if ($result) {
|
||||
$json = json_decode($result, true);
|
||||
if (!$json || !empty($json['errcode'])) {
|
||||
$this->errCode = $json['errcode'];
|
||||
$this->errMsg = $json['errmsg'];
|
||||
return $this->checkRetry(__FUNCTION__, func_get_args());
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user