diff --git a/Application/Admin/Controller/ApiManageController.class.php b/Application/Admin/Controller/ApiManageController.class.php index 5ab64b4..47f0861 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,8 +87,11 @@ 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)); + S('ApiRequest_' . $hash, null); + S('ApiResponse_' . $hash, null); + D('ApiFields')->where(array('hash' => $hash))->delete(); $this->ajaxSuccess('操作成功'); } else { $this->ajaxError('缺少参数'); diff --git a/Application/Admin/Controller/FieldsManageController.class.php b/Application/Admin/Controller/FieldsManageController.class.php index 9ea6450..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 { @@ -78,9 +80,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 +103,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 +145,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(); 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(); } 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 @@ +正在加载验证码......
+请先完成验证
+