From 3c98e6a3f3529e6ccc3398ba75cd34030cfbd94d Mon Sep 17 00:00:00 2001
From: zhaoxiang <756958008@qq.com>
Date: Tue, 9 May 2017 14:48:17 +0800
Subject: [PATCH 01/16] =?UTF-8?q?modified=20=E4=BC=98=E5=8C=96Log=E6=A0=BC?=
=?UTF-8?q?=E5=BC=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Application/Home/ORG/ApiLog.class.php | 142 +++++++++++++-------------
1 file changed, 73 insertions(+), 69 deletions(-)
diff --git a/Application/Home/ORG/ApiLog.class.php b/Application/Home/ORG/ApiLog.class.php
index e54095a..4127546 100644
--- a/Application/Home/ORG/ApiLog.class.php
+++ b/Application/Home/ORG/ApiLog.class.php
@@ -7,87 +7,91 @@
namespace Home\ORG;
-class ApiLog{
+class ApiLog {
- private static $appInfo = 'null';
- private static $apiInfo = 'null';
- private static $request = 'null';
- private static $requestAfterFilter = 'null';
- private static $response = 'null';
- private static $header = 'null';
- private static $userInfo = 'null';
- private static $separator = '###';
+ private static $appInfo = 'null';
+ private static $apiInfo = 'null';
+ private static $request = 'null';
+ private static $requestAfterFilter = 'null';
+ private static $response = 'null';
+ private static $header = 'null';
+ private static $userInfo = 'null';
+ private static $separator = '###';
- public static function setAppInfo($data){
- self::$appInfo = $data['app_id'] . "({$data['app_name']}) {$data['device_id']}";
- }
+ public static function setAppInfo($data) {
+ self::$appInfo = $data['app_id'] . self::$separator . $data['app_name'] . self::$separator . $data['device_id'];
+ }
- public static function setHeader($data){
- $userToken = (isset($data['USER-TOKEN']) && !empty($data['USER-TOKEN'])) ? $data['USER-TOKEN'] : 'null';
- $accessToken = (isset($data['ACCESS-TOKEN']) && !empty($data['ACCESS-TOKEN'])) ? $data['ACCESS-TOKEN'] : 'null';
- self::$header = $accessToken . self::$separator . $userToken . self::$separator . $data['VERSION'] . self::$separator . $cas;
- }
+ public static function setHeader($data) {
+ $userToken = (isset($data['USER-TOKEN']) && !empty($data['USER-TOKEN'])) ? $data['USER-TOKEN'] : 'null';
+ $accessToken = (isset($data['ACCESS-TOKEN']) && !empty($data['ACCESS-TOKEN'])) ? $data['ACCESS-TOKEN'] : 'null';
+ $cas = (isset($data['CAS']) && !empty($data['CAS'])) ? $data['CAS'] : 'null';
+ self::$header = $accessToken . self::$separator . $userToken . self::$separator . $data['VERSION'] . self::$separator . $cas;
+ }
- public static function setApiInfo($data){
- self::$apiInfo = $data['apiName'] . self::$separator . $data['hash'];
- }
+ public static function setApiInfo($data) {
+ self::$apiInfo = $data['apiName'] . self::$separator . $data['hash'];
+ }
- public static function setUserInfo($data){
- if (is_array($data)) {
- $data = json_encode($data);
- }
- self::$userInfo = $data;
- }
+ public static function setUserInfo($data) {
+ if (is_array($data)) {
+ $data = json_encode($data);
+ }
+ self::$userInfo = $data;
+ }
- public static function setRequest($data){
- if (is_array($data)) {
- $data = json_encode($data);
- }
- self::$request = $data;
- }
+ public static function setRequest($data) {
+ if (is_array($data)) {
+ $data = json_encode($data);
+ }
+ self::$request = $data;
+ }
- public static function setRequestAfterFilter($data){
- if (is_array($data)) {
- $data = json_encode($data);
- }
- self::$requestAfterFilter = $data;
- }
+ public static function setRequestAfterFilter($data) {
+ if (is_array($data)) {
+ $data = json_encode($data);
+ }
+ self::$requestAfterFilter = $data;
+ }
- public static function setResponse($data){
- if (is_array($data)) {
- $data = json_encode($data);
- }
- self::$response = $data;
- }
+ public static function setResponse($data, $code) {
+ if (is_array($data)) {
+ $data = json_encode($data);
+ }
+ self::$response = $code . self::$separator . $data;
+ }
- public static function save(){
- $logPath = APP_PATH . '/ApiLog/' . date('YmdH') . '.log';
- $logStr = implode(self::$separator, array(
- self::$apiInfo,
- date('H:i:s'),
- self::$request,
- self::$header,
- self::$response,
- self::$requestAfterFilter,
- self::$appInfo,
- self::$userInfo
- ));
+ public static function save() {
+ $logPath = APP_PATH . '/ApiLog/' . date('YmdH') . '.log';
+ if (self::$appInfo == 'null') {
+ self::$appInfo = 'null' . self::$separator . 'null' . self::$separator . 'null';
+ }
+ $logStr = implode(self::$separator, array(
+ self::$apiInfo,
+ date('Y-m-d H:i:s'),
+ self::$request,
+ self::$header,
+ self::$response,
+ self::$requestAfterFilter,
+ self::$appInfo,
+ self::$userInfo
+ ));
- @file_put_contents($logPath, $logStr . "\n", FILE_APPEND);
- }
+ @file_put_contents($logPath, $logStr . "\n", FILE_APPEND);
+ }
- /**
- * @param string $log 被记录的内容
- * @param string $type 日志文件名称
- * @param string $filePath
- */
- public static function writeLog($log, $type = 'sql', $filePath = './Application/Runtime/'){
- $filename = $filePath . date("Ymd") . '_' . $type . ".log";
- @$handle = fopen($filename, "a+");
- @fwrite($handle, date('Y-m-d H:i:s') . "\t" . $log . "\r\n");
- @fclose($handle);
- }
+ /**
+ * @param string $log 被记录的内容
+ * @param string $type 日志文件名称
+ * @param string $filePath
+ */
+ public static function writeLog($log, $type = 'sql', $filePath = './Application/Runtime/') {
+ $filename = $filePath . date("Ymd") . '_' . $type . ".log";
+ @$handle = fopen($filename, "a+");
+ @fwrite($handle, date('Y-m-d H:i:s') . "\t" . $log . "\r\n");
+ @fclose($handle);
+ }
}
\ No newline at end of file
From 0bc5b202f67be98bb7c36a578bb929ed51fb77f6 Mon Sep 17 00:00:00 2001
From: zhaoxiang <756958008@qq.com>
Date: Wed, 10 May 2017 14:15:44 +0800
Subject: [PATCH 02/16] =?UTF-8?q?modified=20=E6=96=B0=E5=A2=9E=E7=94=A8?=
=?UTF-8?q?=E6=88=B7=E4=BF=A1=E6=81=AFLog=E8=AE=B0=E5=BD=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Application/Home/Controller/ApiController.class.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Application/Home/Controller/ApiController.class.php b/Application/Home/Controller/ApiController.class.php
index 9ad439a..a262259 100644
--- a/Application/Home/Controller/ApiController.class.php
+++ b/Application/Home/Controller/ApiController.class.php
@@ -167,7 +167,7 @@ class ApiController extends BaseController {
if (!is_array($userInfo) || !isset($userInfo['passport_uid'])) {
Response::error(ReturnCode::AUTH_ERROR, 'user-token不匹配');
}
- C('USER_INFO', $userInfo);
+ ApiLog::setUserInfo($userInfo);
}
}
From ef53faeaf58a2febc4f223db070ea1407feccbca Mon Sep 17 00:00:00 2001
From: zhaoxiang <756958008@qq.com>
Date: Thu, 18 May 2017 10:35:42 +0800
Subject: [PATCH 03/16] =?UTF-8?q?modified=20=E4=BF=AE=E5=A4=8D=E7=BC=93?=
=?UTF-8?q?=E5=AD=98=E5=A4=84=E7=90=86=E6=96=B9=E5=BC=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Admin/Controller/ApiManageController.class.php | 8 ++++----
.../Controller/FieldsManageController.class.php | 14 +++++++-------
2 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/Application/Admin/Controller/ApiManageController.class.php b/Application/Admin/Controller/ApiManageController.class.php
index 5ab64b4..b610145 100644
--- a/Application/Admin/Controller/ApiManageController.class.php
+++ b/Application/Admin/Controller/ApiManageController.class.php
@@ -30,9 +30,9 @@ class ApiManageController extends BaseController {
$data = I('post.');
$res = D('ApiList')->where(array('id' => $data['id']))->save($data);
if( $res === false ) {
- S('ApiInfo_' . $data['hash'], 0);
$this->ajaxError('操作失败');
} else {
+ S('ApiInfo_' . $data['hash'], null);
$this->ajaxSuccess('添加成功');
}
}
@@ -59,7 +59,7 @@ class ApiManageController extends BaseController {
$id = I('post.id');
if( $id ) {
$hash = D('ApiList')->where(array('id' => $id))->getField('hash');
- S('ApiInfo_' . $hash, 0);
+ S('ApiInfo_' . $hash, null);
D('ApiList')->open(array('id' => $id));
$this->ajaxSuccess('操作成功');
} else {
@@ -73,7 +73,7 @@ class ApiManageController extends BaseController {
$id = I('post.id');
if( $id ) {
$hash = D('ApiList')->where(array('id' => $id))->getField('hash');
- S('ApiInfo_' . $hash, 0);
+ S('ApiInfo_' . $hash, null);
D('ApiList')->close(array('id' => $id));
$this->ajaxSuccess('操作成功');
} else {
@@ -87,7 +87,7 @@ class ApiManageController extends BaseController {
$id = I('post.id');
if( $id ) {
$hash = D('ApiList')->where(array('id' => $id))->getField('hash');
- S('ApiInfo_' . $hash, 0);
+ S('ApiInfo_' . $hash, null);
D('ApiList')->del(array('id' => $id));
$this->ajaxSuccess('操作成功');
} else {
diff --git a/Application/Admin/Controller/FieldsManageController.class.php b/Application/Admin/Controller/FieldsManageController.class.php
index 9ea6450..20ba598 100644
--- a/Application/Admin/Controller/FieldsManageController.class.php
+++ b/Application/Admin/Controller/FieldsManageController.class.php
@@ -78,9 +78,9 @@ class FieldsManageController extends BaseController {
$this->ajaxError('操作失败');
} else {
if ($data['type'] == 0) {
- S('ApiRequest_' . $data['hash'], 0);
+ S('ApiRequest_' . $data['hash'], null);
} else {
- S('ApiResponse_' . $data['hash'], 0);
+ S('ApiResponse_' . $data['hash'], null);
}
$this->ajaxSuccess('添加成功');
}
@@ -101,9 +101,9 @@ class FieldsManageController extends BaseController {
if ($id) {
$detail = D('ApiFields')->where(array('id' => $id))->find();
if ($detail['type'] == 0) {
- S('ApiRequest_' . $detail['hash'], 0);
+ S('ApiRequest_' . $detail['hash'], null);
} else {
- S('ApiResponse_' . $detail['hash'], 0);
+ S('ApiResponse_' . $detail['hash'], null);
}
D('ApiFields')->where(array('id' => $id))->delete();
$this->ajaxSuccess('操作成功');
@@ -143,11 +143,11 @@ class FieldsManageController extends BaseController {
D('ApiFields')->addAll($addData);
}
if ($type == 0) {
- S('ApiRequest_' . $hash, 0);
+ S('ApiRequest_' . $hash, null);
} else {
- S('ApiResponse_' . $hash, 0);
+ S('ApiResponse_' . $hash, null);
}
- S('ApiReturnType_' . $hash, 0);
+ S('ApiReturnType_' . $hash, null);
$this->ajaxSuccess('操作成功');
} else {
$this->display();
From 3d95891dd72e96b52a9429b13820042f7b4b85bb Mon Sep 17 00:00:00 2001
From: zhaoxiang <756958008@qq.com>
Date: Sat, 27 May 2017 15:22:48 +0800
Subject: [PATCH 04/16] =?UTF-8?q?modified=20=E8=BF=9B=E4=B8=80=E6=AD=A5?=
=?UTF-8?q?=E6=8F=90=E9=AB=98wiki=E7=9A=84=E9=80=82=E9=85=8D=E6=80=A7?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Application/Home/View/Wiki/apiField.html | 2 +-
Application/Home/View/Wiki/apiList.html | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/Application/Home/View/Wiki/apiField.html b/Application/Home/View/Wiki/apiField.html
index 1653aae..14f920d 100644
--- a/Application/Home/View/Wiki/apiField.html
+++ b/Application/Home/View/Wiki/apiField.html
@@ -13,7 +13,7 @@
-
+
POST
GET
diff --git a/Application/Home/View/Wiki/apiList.html b/Application/Home/View/Wiki/apiList.html
index 47cf1dd..a5e285e 100644
--- a/Application/Home/View/Wiki/apiList.html
+++ b/Application/Home/View/Wiki/apiList.html
@@ -17,7 +17,8 @@
-
API统一访问地址: http://{$_SERVER['HTTP_HOST']}/api/接口唯一标识
+
$http_type = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https://' : 'http://';
+
API统一访问地址: {$http_type}{$_SERVER['HTTP_HOST']}/api/接口唯一标识
From ae44ec5ac5450dee279ef9ccb5077959f3772f80 Mon Sep 17 00:00:00 2001
From: Zhao <756958008@qq.com>
Date: Wed, 31 May 2017 17:47:45 +0800
Subject: [PATCH 05/16] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20README.md?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.md | 3 +++
1 file changed, 3 insertions(+)
diff --git a/README.md b/README.md
index 711bed2..5a5c6d7 100644
--- a/README.md
+++ b/README.md
@@ -21,6 +21,9 @@
[http://git.oschina.net/xiaoxunzhao/ApiAdmin/wikis/%E9%A1%B9%E7%9B%AE%E5%AE%89%E8%A3%852.0](http://git.oschina.net/xiaoxunzhao/ApiAdmin/wikis/%E9%A1%B9%E7%9B%AE%E5%AE%89%E8%A3%852.0)
+**二次开发文档**
+[http://www.w3cschool.cn/apiadmin_v2/](http://www.w3cschool.cn/apiadmin_v2/)
+
**源码地址**
国内OSC:[http://git.oschina.net/xiaoxunzhao/ApiAdmin](http://git.oschina.net/xiaoxunzhao/ApiAdmin)
From 24f36b2125e9c56c56dd81608b087920a7d13233 Mon Sep 17 00:00:00 2001
From: zhaoxiang <756958008@qq.com>
Date: Wed, 31 May 2017 17:51:00 +0800
Subject: [PATCH 06/16] =?UTF-8?q?added=202.0=E7=9A=84=E5=BC=80=E5=8F=91?=
=?UTF-8?q?=E6=96=87=E6=A1=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/README.md b/README.md
index 5a5c6d7..6acbb66 100644
--- a/README.md
+++ b/README.md
@@ -22,6 +22,7 @@
[http://git.oschina.net/xiaoxunzhao/ApiAdmin/wikis/%E9%A1%B9%E7%9B%AE%E5%AE%89%E8%A3%852.0](http://git.oschina.net/xiaoxunzhao/ApiAdmin/wikis/%E9%A1%B9%E7%9B%AE%E5%AE%89%E8%A3%852.0)
**二次开发文档**
+
[http://www.w3cschool.cn/apiadmin_v2/](http://www.w3cschool.cn/apiadmin_v2/)
**源码地址**
From f7cb28802616520fe7a435457a9a172c97addda8 Mon Sep 17 00:00:00 2001
From: zhaoxiang <756958008@qq.com>
Date: Fri, 2 Jun 2017 11:04:01 +0800
Subject: [PATCH 07/16] =?UTF-8?q?modified=20=E6=9B=B4=E6=96=B0github?=
=?UTF-8?q?=E7=89=88=E6=9C=AC=E5=BA=93?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index 6acbb66..208ce80 100644
--- a/README.md
+++ b/README.md
@@ -29,13 +29,13 @@
国内OSC:[http://git.oschina.net/xiaoxunzhao/ApiAdmin](http://git.oschina.net/xiaoxunzhao/ApiAdmin)
-国际GitHub(暂未开通):[https://github.com/Zhao-github/ApiAdmin](https://github.com/Zhao-github/ApiAdmin)
+国际GitHub:[https://github.com/Zhao-github/ApiAdmin](https://github.com/Zhao-github/ApiAdmin)
**下载地址**
国内OSC:[http://git.oschina.net/xiaoxunzhao/ApiAdmin/releases](http://git.oschina.net/xiaoxunzhao/ApiAdmin)
-国际GitHub(暂未开通):[https://github.com/Zhao-github/ApiAdmin/releases](https://github.com/Zhao-github/ApiAdmin/releases)
+国际GitHub:[https://github.com/Zhao-github/ApiAdmin/releases](https://github.com/Zhao-github/ApiAdmin/releases)
**项目构成**
From 3dda26e893fb945358e6ca00669c849d483ed897 Mon Sep 17 00:00:00 2001
From: zhaoxiang <756958008@qq.com>
Date: Mon, 5 Jun 2017 19:40:40 +0800
Subject: [PATCH 08/16] =?UTF-8?q?modified=20=E4=BF=AE=E5=A4=8DJS=E4=B8=89?=
=?UTF-8?q?=E7=BA=A7=E7=9B=AE=E5=BD=95=E7=9A=84BUG?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Public/js/forTree.js | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/Public/js/forTree.js b/Public/js/forTree.js
index 9886a18..b8cf2cc 100644
--- a/Public/js/forTree.js
+++ b/Public/js/forTree.js
@@ -60,21 +60,20 @@ layui.define(function(exports) {
/**
* 开始循环
*/
- this.each = function(arr) {
+ this.each = function(arr,index) {
if(arr == undefined) {
arr = _father;
}
-
+ var index = index ? index: 0;
for(var i in arr) {
var children = _that.getChildren(arr[i][_idName]);
var counter = children.length;
-
_that.forBefore(arr[i], i, counter);
_that.forCurr(arr[i], i, counter);
- if(counter) {
+ if(counter && index==0) {
_that.callBefore(arr[i], i);
- _that.each(children);
+ _that.each(children,2);
_that.callAfter(arr[i], i);
}
@@ -82,4 +81,4 @@ layui.define(function(exports) {
}
}
});
-});
\ No newline at end of file
+});
From 471fcdb600fc902051eb847077013dac539ad96c Mon Sep 17 00:00:00 2001
From: ggd0920 <3276996802@qq.com>
Date: Fri, 9 Jun 2017 15:43:22 +0800
Subject: [PATCH 09/16] =?UTF-8?q?fixed=20=E4=BF=AE=E5=A4=8D=E6=9D=83?=
=?UTF-8?q?=E9=99=90=E9=80=89=E6=8B=A9=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Application/Admin/View/Permission/rule.html | 31 +++++++++++----------
1 file changed, 16 insertions(+), 15 deletions(-)
diff --git a/Application/Admin/View/Permission/rule.html b/Application/Admin/View/Permission/rule.html
index 37b0638..1304df7 100644
--- a/Application/Admin/View/Permission/rule.html
+++ b/Application/Admin/View/Permission/rule.html
@@ -7,21 +7,21 @@
-
+
@@ -39,13 +39,14 @@
layui.use('form', function(){
var form = layui.form();
form.on('checkbox(admin-check)', function(data){
+ var dataId = $(this).attr('data-id');
var $el = data.elem;
if( $el.checked ){
- $('input[fid="'+$el.value+'"]').prop('checked','checked');
- $('input[pid="'+$el.value+'"]').prop('checked','checked');
+ $('input[fid="'+dataId+'"]').prop('checked','checked');
+ $('input[pid="'+dataId+'"]').prop('checked','checked');
}else{
- $('input[fid="'+$el.value+'"]').prop('checked', false);
- $('input[pid="'+$el.value+'"]').prop('checked', false);
+ $('input[fid="'+dataId+'"]').prop('checked', false);
+ $('input[pid="'+dataId+'"]').prop('checked', false);
}
form.render();
});
From 16ce1907465e86477389cf0657f2fed65c33b8d1 Mon Sep 17 00:00:00 2001
From: zhaoxiang <756958008@qq.com>
Date: Mon, 12 Jun 2017 17:21:26 +0800
Subject: [PATCH 10/16] =?UTF-8?q?modified=20=E4=BC=98=E5=8C=96=E8=8F=9C?=
=?UTF-8?q?=E5=8D=95=E6=98=BE=E7=A4=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Controller/IndexController.class.php | 29 +++++++++++--------
1 file changed, 17 insertions(+), 12 deletions(-)
diff --git a/Application/Admin/Controller/IndexController.class.php b/Application/Admin/Controller/IndexController.class.php
index c468dc8..bc2b3a4 100644
--- a/Application/Admin/Controller/IndexController.class.php
+++ b/Application/Admin/Controller/IndexController.class.php
@@ -1,4 +1,5 @@
allMenu;
- foreach ($menuAll as $key => $menu) {
- if($menu['hide'] != 0){
- unset($menuAll[$key]);
- }
- }
foreach ($menuAll as $menu) {
- if($isAdmin){
- $menu['url'] = U($menu['url']);
- $list[] = $menu;
- }else{
- $authObj = new Auth();
- $authList = $authObj->getAuthList($this->uid);
- if (in_array(strtolower($menu['url']), $authList) || $menu['url'] == '') {
+ if ($menu['hide'] == 0) {
+ if ($isAdmin) {
$menu['url'] = U($menu['url']);
$list[] = $menu;
+ } else {
+ $authObj = new Auth();
+ $authList = $authObj->getAuthList($this->uid);
+ if (in_array(strtolower($menu['url']), $authList) || $menu['url'] == '') {
+ $menu['url'] = U($menu['url']);
+ $list[] = $menu;
+ }
}
}
}
+ $list = listToTree($list);
+ foreach ($list as $key => $item) {
+ if(empty($item['_child']) && $item['url'] != U('Index/welcome')){
+ unset($list[$key]);
+ }
+ }
+ $list = formatTree($list);
$this->assign('list', $list);
$this->display();
}
From 31649100a2db85ac648cdc9f5bda12a2459b9478 Mon Sep 17 00:00:00 2001
From: zhaoxiang <756958008@qq.com>
Date: Thu, 15 Jun 2017 10:41:11 +0800
Subject: [PATCH 11/16] =?UTF-8?q?modified=20=E5=8F=98=E6=9B=B4=E8=A7=84?=
=?UTF-8?q?=E5=88=99=E7=BC=93=E5=AD=98=E7=9A=84=E6=B8=85=E7=90=86=E6=97=B6?=
=?UTF-8?q?=E6=9C=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Application/Admin/Controller/FieldsManageController.class.php | 2 ++
1 file changed, 2 insertions(+)
diff --git a/Application/Admin/Controller/FieldsManageController.class.php b/Application/Admin/Controller/FieldsManageController.class.php
index 20ba598..67c5458 100644
--- a/Application/Admin/Controller/FieldsManageController.class.php
+++ b/Application/Admin/Controller/FieldsManageController.class.php
@@ -61,6 +61,8 @@ class FieldsManageController extends BaseController {
if ($res === false) {
$this->ajaxError('操作失败');
} else {
+ S('ApiRequest_' . $data['hash'], null);
+ S('ApiResponse_' . $data['hash'], null);
$this->ajaxSuccess('添加成功');
}
} else {
From fe7ed9d6a48e53b25c65c8f8e208242515fa2cdf Mon Sep 17 00:00:00 2001
From: zhaoxiang <756958008@qq.com>
Date: Tue, 20 Jun 2017 15:09:30 +0800
Subject: [PATCH 12/16] =?UTF-8?q?modified=20=E5=88=A0=E9=99=A4=E6=8E=A5?=
=?UTF-8?q?=E5=8F=A3=EF=BC=8C=E5=88=A0=E9=99=A4=E7=9B=B8=E5=85=B3=E5=AD=97?=
=?UTF-8?q?=E6=AE=B5=E9=85=8D=E7=BD=AE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Application/Admin/Controller/ApiManageController.class.php | 3 +++
1 file changed, 3 insertions(+)
diff --git a/Application/Admin/Controller/ApiManageController.class.php b/Application/Admin/Controller/ApiManageController.class.php
index b610145..47f0861 100644
--- a/Application/Admin/Controller/ApiManageController.class.php
+++ b/Application/Admin/Controller/ApiManageController.class.php
@@ -89,6 +89,9 @@ class ApiManageController extends BaseController {
$hash = D('ApiList')->where(array('id' => $id))->getField('hash');
S('ApiInfo_' . $hash, null);
D('ApiList')->del(array('id' => $id));
+ S('ApiRequest_' . $hash, null);
+ S('ApiResponse_' . $hash, null);
+ D('ApiFields')->where(array('hash' => $hash))->delete();
$this->ajaxSuccess('操作成功');
} else {
$this->ajaxError('缺少参数');
From 40eff4e80eae4ec390d2c1ea9c4797e12c54a58e Mon Sep 17 00:00:00 2001
From: zhaoxiang <756958008@qq.com>
Date: Thu, 22 Jun 2017 17:37:29 +0800
Subject: [PATCH 13/16] =?UTF-8?q?modified=20=E5=8F=98=E6=9B=B4=E6=97=A5?=
=?UTF-8?q?=E5=BF=97=E8=AE=B0=E5=BD=95=E4=BD=8D=E7=BD=AE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Home/Controller/ApiController.class.php | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/Application/Home/Controller/ApiController.class.php b/Application/Home/Controller/ApiController.class.php
index a262259..ca16f85 100644
--- a/Application/Home/Controller/ApiController.class.php
+++ b/Application/Home/Controller/ApiController.class.php
@@ -67,15 +67,6 @@ class ApiController extends BaseController {
$this->header = array_change_key_case($this->header, CASE_UPPER);
ApiLog::setHeader($this->header);
- if ($this->apiDetail['accessToken'] && !$this->apiDetail['isTest']) {
- $this->checkAccessToken();
- }
- if (!$this->apiDetail['isTest']) {
- $this->checkVersion();
- }
- $this->checkLogin();
-
- unset($getArr['hash']);
switch ($this->apiDetail['method']) {
case 0:
$this->param = array_merge($getArr, $postArr);
@@ -93,6 +84,15 @@ class ApiController extends BaseController {
$this->param = $data;
}
ApiLog::setRequest($this->param);
+
+ if ($this->apiDetail['accessToken'] && !$this->apiDetail['isTest']) {
+ $this->checkAccessToken();
+ }
+ if (!$this->apiDetail['isTest']) {
+ $this->checkVersion();
+ }
+ $this->checkLogin();
+ unset($getArr['hash']);
$this->iniApi();
}
From caacd7342575d1ce4e7b5eabe7936c584082b67d Mon Sep 17 00:00:00 2001
From: zhaoxiang <756958008@qq.com>
Date: Fri, 23 Jun 2017 14:34:35 +0800
Subject: [PATCH 14/16] =?UTF-8?q?added=20ApiAdmin=E6=B7=BB=E5=8A=A0?=
=?UTF-8?q?=E7=99=BB=E5=BD=95=E9=AA=8C=E8=AF=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Controller/LoginController.class.php | 7 +
.../VerificationController.class.php | 30 ++
Application/Admin/View/Login/index.html | 70 ++++-
Public/js/gt.js | 277 ++++++++++++++++++
4 files changed, 383 insertions(+), 1 deletion(-)
create mode 100644 Application/Admin/Controller/VerificationController.class.php
create mode 100644 Public/js/gt.js
diff --git a/Application/Admin/Controller/LoginController.class.php b/Application/Admin/Controller/LoginController.class.php
index 9c27085..6099839 100644
--- a/Application/Admin/Controller/LoginController.class.php
+++ b/Application/Admin/Controller/LoginController.class.php
@@ -16,6 +16,13 @@ class LoginController extends BaseController {
public function login() {
$pass = user_md5(I('post.password'));
$user = I('post.username');
+
+ $challenge = I('post.geetest_challenge');
+ $validate = I('post.geetest_validate');
+ if(!$challenge || md5($challenge) != $validate){
+ $this->ajaxError('请先通过验证!');
+ }
+
$userInfo = D('ApiUser')->where(array('username' => $user, 'password' => $pass))->find();
if (!empty($userInfo)) {
if ($userInfo['status']) {
diff --git a/Application/Admin/Controller/VerificationController.class.php b/Application/Admin/Controller/VerificationController.class.php
new file mode 100644
index 0000000..2c06a1e
--- /dev/null
+++ b/Application/Admin/Controller/VerificationController.class.php
@@ -0,0 +1,30 @@
+
+ */
+
+namespace Admin\Controller;
+
+
+use Think\Controller;
+
+class VerificationController extends Controller {
+
+ private $gt_captcha_id = 'YourID';
+ private $gt_private_key = 'YourKey';
+
+ public function gt(){
+ $rnd1 = md5(rand(0, 100));
+ $rnd2 = md5(rand(0, 100));
+ $challenge = $rnd1 . substr($rnd2, 0, 2);
+ $result = array(
+ 'success' => 0,
+ 'gt' => $this->gt_captcha_id,
+ 'challenge' => $challenge,
+ 'new_captcha'=>1
+ );
+ $this->ajaxReturn($result);
+ }
+}
\ No newline at end of file
diff --git a/Application/Admin/View/Login/index.html b/Application/Admin/View/Login/index.html
index 2afd9df..13ffa61 100644
--- a/Application/Admin/View/Login/index.html
+++ b/Application/Admin/View/Login/index.html
@@ -1,4 +1,3 @@
-
@@ -52,6 +51,33 @@
.login-box .version{
font-size: 12px;
}
+ .inp {
+ border: 1px solid gray;
+ padding: 0 10px;
+ width: 200px;
+ height: 30px;
+ font-size: 18px;
+ }
+ .btn {
+ border: 1px solid gray;
+ width: 100px;
+ height: 30px;
+ font-size: 18px;
+ cursor: pointer;
+ }
+ #embed-captcha {
+ width: 300px;
+ margin: 0 auto;
+ }
+ .show {
+ display: block;
+ }
+ .hide {
+ display: none;
+ }
+ #notice {
+ color: red;
+ }
@@ -73,6 +99,13 @@
+
@@ -80,6 +113,8 @@
+
+
+
\ No newline at end of file
diff --git a/Public/js/gt.js b/Public/js/gt.js
new file mode 100644
index 0000000..e5c8569
--- /dev/null
+++ b/Public/js/gt.js
@@ -0,0 +1,277 @@
+/* initGeetest 1.0.0
+ * 用于加载id对应的验证码库,并支持宕机模式
+ * 暴露 initGeetest 进行验证码的初始化
+ * 一般不需要用户进行修改
+ */
+(function (global, factory) {
+ "use strict";
+ if (typeof module === "object" && typeof module.exports === "object") {
+ // CommonJS
+ module.exports = global.document ?
+ factory(global, true) :
+ function (w) {
+ if (!w.document) {
+ throw new Error("Geetest requires a window with a document");
+ }
+ return factory(w);
+ };
+ } else {
+ factory(global);
+ }
+})(typeof window !== "undefined" ? window : this, function (window, noGlobal) {
+ "use strict";
+ if (typeof window === 'undefined') {
+ throw new Error('Geetest requires browser environment');
+ }
+ var document = window.document;
+ var Math = window.Math;
+ var head = document.getElementsByTagName("head")[0];
+
+ function _Object(obj) {
+ this._obj = obj;
+ }
+
+ _Object.prototype = {
+ _each: function (process) {
+ var _obj = this._obj;
+ for (var k in _obj) {
+ if (_obj.hasOwnProperty(k)) {
+ process(k, _obj[k]);
+ }
+ }
+ return this;
+ }
+ };
+ function Config(config) {
+ var self = this;
+ new _Object(config)._each(function (key, value) {
+ self[key] = value;
+ });
+ }
+
+ Config.prototype = {
+ api_server: 'api.geetest.com',
+ protocol: 'http://',
+ type_path: '/gettype.php',
+ fallback_config: {
+ slide: {
+ static_servers: ["static.geetest.com", "dn-staticdown.qbox.me"],
+ type: 'slide',
+ slide: '/static/js/geetest.0.0.0.js'
+ },
+ fullpage: {
+ static_servers: ["static.geetest.com", "dn-staticdown.qbox.me"],
+ type: 'fullpage',
+ fullpage: '/static/js/fullpage.0.0.0.js'
+ }
+ },
+ _get_fallback_config: function () {
+ var self = this;
+ if (isString(self.type)) {
+ return self.fallback_config[self.type];
+ } else if (self.new_captcha) {
+ return self.fallback_config.fullpage;
+ } else {
+ return self.fallback_config.slide;
+ }
+ },
+ _extend: function (obj) {
+ var self = this;
+ new _Object(obj)._each(function (key, value) {
+ self[key] = value;
+ })
+ }
+ };
+ var isNumber = function (value) {
+ return (typeof value === 'number');
+ };
+ var isString = function (value) {
+ return (typeof value === 'string');
+ };
+ var isBoolean = function (value) {
+ return (typeof value === 'boolean');
+ };
+ var isObject = function (value) {
+ return (typeof value === 'object' && value !== null);
+ };
+ var isFunction = function (value) {
+ return (typeof value === 'function');
+ };
+ var callbacks = {};
+ var status = {};
+ var random = function () {
+ return parseInt(Math.random() * 10000) + (new Date()).valueOf();
+ };
+ var loadScript = function (url, cb) {
+ var script = document.createElement("script");
+ script.charset = "UTF-8";
+ script.async = true;
+ script.onerror = function () {
+ cb(true);
+ };
+ var loaded = false;
+ script.onload = script.onreadystatechange = function () {
+ if (!loaded &&
+ (!script.readyState ||
+ "loaded" === script.readyState ||
+ "complete" === script.readyState)) {
+
+ loaded = true;
+ setTimeout(function () {
+ cb(false);
+ }, 0);
+ }
+ };
+ script.src = url;
+ head.appendChild(script);
+ };
+ var normalizeDomain = function (domain) {
+ return domain.replace(/^https?:\/\/|\/$/g, '');
+ };
+ var normalizePath = function (path) {
+ path = path.replace(/\/+/g, '/');
+ if (path.indexOf('/') !== 0) {
+ path = '/' + path;
+ }
+ return path;
+ };
+ var normalizeQuery = function (query) {
+ if (!query) {
+ return '';
+ }
+ var q = '?';
+ new _Object(query)._each(function (key, value) {
+ if (isString(value) || isNumber(value) || isBoolean(value)) {
+ q = q + encodeURIComponent(key) + '=' + encodeURIComponent(value) + '&';
+ }
+ });
+ if (q === '?') {
+ q = '';
+ }
+ return q.replace(/&$/, '');
+ };
+ var makeURL = function (protocol, domain, path, query) {
+ domain = normalizeDomain(domain);
+
+ var url = normalizePath(path) + normalizeQuery(query);
+ if (domain) {
+ url = protocol + domain + url;
+ }
+
+ return url;
+ };
+ var load = function (protocol, domains, path, query, cb) {
+ var tryRequest = function (at) {
+
+ var url = makeURL(protocol, domains[at], path, query);
+ loadScript(url, function (err) {
+ if (err) {
+ if (at >= domains.length - 1) {
+ cb(true);
+ } else {
+ tryRequest(at + 1);
+ }
+ } else {
+ cb(false);
+ }
+ });
+ };
+ tryRequest(0);
+ };
+ var jsonp = function (domains, path, config, callback) {
+ if (isObject(config.getLib)) {
+ config._extend(config.getLib);
+ callback(config);
+ return;
+ }
+ if (config.offline) {
+ callback(config._get_fallback_config());
+ return;
+ }
+ var cb = "geetest_" + random();
+ window[cb] = function (data) {
+ if (data.status === 'success') {
+ callback(data.data);
+ } else if (!data.status) {
+ callback(data);
+ } else {
+ callback(config._get_fallback_config());
+ }
+ window[cb] = undefined;
+ try {
+ delete window[cb];
+ } catch (e) {
+ }
+ };
+ load(config.protocol, domains, path, {
+ gt: config.gt,
+ callback: cb
+ }, function (err) {
+ if (err) {
+ callback(config._get_fallback_config());
+ }
+ });
+ };
+ var throwError = function (errorType, config) {
+ var errors = {
+ networkError: '网络错误'
+ };
+ if (typeof config.onError === 'function') {
+ config.onError(errors[errorType]);
+ } else {
+ throw new Error(errors[errorType]);
+ }
+ };
+ var detect = function () {
+ return !!window.Geetest;
+ };
+ if (detect()) {
+ status.slide = "loaded";
+ }
+ var initGeetest = function (userConfig, callback) {
+ var config = new Config(userConfig);
+ if (userConfig.https) {
+ config.protocol = 'https://';
+ } else if (!userConfig.protocol) {
+ config.protocol = window.location.protocol + '//';
+ }
+ jsonp([config.api_server || config.apiserver], config.type_path, config, function (newConfig) {
+ var type = newConfig.type;
+ var init = function () {
+ config._extend(newConfig);
+ callback(new window.Geetest(config));
+ };
+ callbacks[type] = callbacks[type] || [];
+ var s = status[type] || 'init';
+ if (s === 'init') {
+ status[type] = 'loading';
+ callbacks[type].push(init);
+ load(config.protocol, newConfig.static_servers || newConfig.domains, newConfig[type] || newConfig.path, null, function (err) {
+ if (err) {
+ status[type] = 'fail';
+ throwError('networkError', config);
+ } else {
+ status[type] = 'loaded';
+ var cbs = callbacks[type];
+ for (var i = 0, len = cbs.length; i < len; i = i + 1) {
+ var cb = cbs[i];
+ if (isFunction(cb)) {
+ cb();
+ }
+ }
+ callbacks[type] = [];
+ }
+ });
+ } else if (s === "loaded") {
+ init();
+ } else if (s === "fail") {
+ throwError('networkError', config);
+ } else if (s === "loading") {
+ callbacks[type].push(init);
+ }
+ });
+ };
+ window.initGeetest = initGeetest;
+ return initGeetest;
+});
+
From 5f5c5025b725eecb2ae5d867d8f728cd5778dcbf Mon Sep 17 00:00:00 2001
From: zhaoxiang <756958008@qq.com>
Date: Fri, 23 Jun 2017 16:21:57 +0800
Subject: [PATCH 15/16] =?UTF-8?q?added=20=E6=96=B0=E5=A2=9E=E5=8A=A0?=
=?UTF-8?q?=E6=96=87=E6=A1=A3=E8=A1=A8=EF=BC=8C=E7=94=A8=E4=BA=8E=E5=A4=84?=
=?UTF-8?q?=E7=90=86Api=E6=96=87=E6=A1=A3=E7=9A=84=E5=AE=89=E5=85=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Application/Data/apiAdmin.sql | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/Application/Data/apiAdmin.sql b/Application/Data/apiAdmin.sql
index 4000c36..a507d6c 100644
--- a/Application/Data/apiAdmin.sql
+++ b/Application/Data/apiAdmin.sql
@@ -298,6 +298,24 @@ CREATE TABLE `api_user_data` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='管理员数据表';
+# Dump of table api_document
+# ------------------------------------------------------------
+
+DROP TABLE IF EXISTS `api_document`;
+
+CREATE TABLE `api_document` (
+ `id` INT(11) NOT NULL AUTO_INCREMENT,
+ `key` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '授权秘钥',
+ `endTime` INT(11) NOT NULL DEFAULT '0' COMMENT '失效时间戳',
+ `times` INT(11) NOT NULL DEFAULT '0' COMMENT '访问次数',
+ `lastTime` INT(11) NOT NULL DEFAULT '0' COMMENT '最后访问时间',
+ `lastIp` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '最后访问IP',
+ `createTime` INT(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
+ `keep` INT(11) NOT NULL DEFAULT '0' COMMENT '有效时长(单位小时)',
+ PRIMARY KEY (`id`),
+ UNIQUE INDEX `key` (`key`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='文档访问秘钥';
+
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
From 509bde90b1e0ba530c1f1f631bf9410b48cdb57c Mon Sep 17 00:00:00 2001
From: zhaoxiang <756958008@qq.com>
Date: Fri, 23 Jun 2017 16:24:32 +0800
Subject: [PATCH 16/16] =?UTF-8?q?added=20=E6=96=B0=E5=A2=9E=E5=8A=A0?=
=?UTF-8?q?=E6=96=87=E6=A1=A3=E8=A1=A8=EF=BC=8C=E7=94=A8=E4=BA=8E=E5=A4=84?=
=?UTF-8?q?=E7=90=86Api=E6=96=87=E6=A1=A3=E7=9A=84=E5=AE=89=E5=85=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Application/Data/apiAdmin.sql | 1 +
1 file changed, 1 insertion(+)
diff --git a/Application/Data/apiAdmin.sql b/Application/Data/apiAdmin.sql
index a507d6c..e98091f 100644
--- a/Application/Data/apiAdmin.sql
+++ b/Application/Data/apiAdmin.sql
@@ -312,6 +312,7 @@ CREATE TABLE `api_document` (
`lastIp` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '最后访问IP',
`createTime` INT(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
`keep` INT(11) NOT NULL DEFAULT '0' COMMENT '有效时长(单位小时)',
+ `status` TINYINT(1) NOT NULL DEFAULT '1' COMMENT '1生效,0失效',
PRIMARY KEY (`id`),
UNIQUE INDEX `key` (`key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='文档访问秘钥';