diff --git a/application/admin/controller/Index.php b/application/admin/controller/Index.php
index 7ed0cc9f..c20735cd 100644
--- a/application/admin/controller/Index.php
+++ b/application/admin/controller/Index.php
@@ -288,4 +288,58 @@ class Index extends Base
return json($data);
}
+
+ // 修改自己的密码
+ public function editPassword($id)
+ {
+ $list['id'] = $id;
+
+ // 模板赋值
+ $this->assign('list',$list);
+
+ // 渲染模板
+ return $this->fetch();
+ }
+
+
+ // 保存新密码
+ public function updatePassword($id)
+ {
+ // 获取表单数据
+ $list = request()->post();
+
+ if($list['newpassword'] != $list['newpassword2'])
+ {
+ $data = ['msg'=>'两次密码输入不一致'];
+ return json($data);
+ }
+
+ // 获取用户名
+ $serpassword = AD::where('id',$id)->value('password');
+
+ // 实例化加密类
+ $md5 = new APR1_MD5();
+ //验证密码
+ $check = $md5->check($list['oldpassword'],$serpassword);
+
+ if(!$check)
+ {
+ $data=['msg'=>'旧密码错误','val'=>0];
+ return json($data);
+ }
+
+
+
+ // 更新密码
+ $password = $md5->hash($list['newpassword']);
+ $data = AD::update(['id'=>$id,'password'=>$password]);
+
+
+ // 根据更新结果设置返回提示信息
+ $data ? $data=['msg'=>'修改成功','val'=>1] : $data=['msg'=>'数据处理错误','val'=>0];
+
+ // 返回信息
+ return json($data);
+ }
+
}
diff --git a/application/admin/view/index/edit_password.html b/application/admin/view/index/edit_password.html
new file mode 100644
index 00000000..ae649445
--- /dev/null
+++ b/application/admin/view/index/edit_password.html
@@ -0,0 +1,57 @@
+{extend name="common@create" /}
+{block name="formaa"}
+
+{/block}
+{block name="yanzheng"}
+
+{/block}
\ No newline at end of file
diff --git a/application/admin/view/index/edit_password1.html b/application/admin/view/index/edit_password1.html
new file mode 100644
index 00000000..fd7d2e3d
--- /dev/null
+++ b/application/admin/view/index/edit_password1.html
@@ -0,0 +1,73 @@
+
+
+
+
+
+
+
+
+
+{css href="/static/H-ui.admin_v3.1.3.1/H-ui.admin/static/h-ui/css/H-ui.min.css" /}
+{css href="/static/H-ui.admin_v3.1.3.1/H-ui.admin/static/h-ui.admin/css/H-ui.admin.css" /}
+{css href="/static/H-ui.admin_v3.1.3.1/H-ui.admin/font/font-awesome.min.css" /}
+
+修改密码
+
+
+
+
+
+
+
+
+{js href="/static/H-ui.admin_v3.1.3.1/H-ui.admin/lib/jquery/1.9.1/jquery.js"}
+{js href="/static/H-ui.admin_v3.1.3.1/H-ui.admin/lib/layer/2.4/layer.js"}
+{js href="/static/H-ui.admin_v3.1.3.1/H-ui.admin/static/h-ui/js/H-ui.min.js"}
+{js href="/static/H-ui.admin_v3.1.3.1/H-ui.admin/static/h-ui.admin/js/H-ui.admin.js"}
+{js href="/static/H-ui.admin_v3.1.3.1/H-ui.admin/lib/jquery.validation/1.14.0/jquery.validate.js"}
+{js href="/static/H-ui.admin_v3.1.3.1/H-ui.admin/lib/jquery.validation/1.14.0/validate-methods.js"}
+{js href="/static/H-ui.admin_v3.1.3.1/H-ui.admin/lib/jquery.validation/1.14.0/messages_zh.js"}
+
+
+
\ No newline at end of file
diff --git a/application/http/middleware/YanZheng.php b/application/http/middleware/YanZheng.php
index 0cbe3847..f31f0dbc 100644
--- a/application/http/middleware/YanZheng.php
+++ b/application/http/middleware/YanZheng.php
@@ -51,7 +51,11 @@ class YanZheng extends Controller
// 排除控制器
$uneed_c = array(); # 荣誉器名首字母要大写
// 排除方法
- $uneed_a = array('welcome','update','save','index','mybanji','banjilist','ajaxnianji');
+ $uneed_a = array(
+ 'welcome','update','save',
+ 'index','mybanji','banjilist',
+ 'ajaxnianji','setmypassword'
+ );
// 排除指定模块下的指定方法
$uneed_u = array('index/Index/index');
diff --git a/application/index/controller/Index.php b/application/index/controller/Index.php
index fc18b8b1..4722ffe8 100644
--- a/application/index/controller/Index.php
+++ b/application/index/controller/Index.php
@@ -30,8 +30,10 @@ class Index extends Base
->field('title,keywords,description')
->find();
+ // 实例化管理员数据模型
+ $admin = new \app\admin\model\Admin;
// 获取管理员信息
- $userinfo = db('admin')
+ $userinfo = $admin
->where('username',session('username'))
->field('username,id')
->find();
@@ -82,5 +84,7 @@ class Index extends Base
}
+
+
}
diff --git a/application/index/view/index/index.html b/application/index/view/index/index.html
index 7f76aebd..b1886414 100644
--- a/application/index/view/index/index.html
+++ b/application/index/view/index/index.html
@@ -54,6 +54,8 @@
diff --git a/application/login/controller/Index.php b/application/login/controller/Index.php
index f7364caa..58fefd00 100644
--- a/application/login/controller/Index.php
+++ b/application/login/controller/Index.php
@@ -5,9 +5,10 @@ namespace app\login\controller;
use think\Controller;
// 引用用户数据模型
use app\admin\model\Admin as AD;
-
// 引用加密类
use WhiteHat101\Crypt\APR1_MD5;
+// 引用Session类
+use \think\facade\Session;
class Index extends Controller
@@ -29,8 +30,9 @@ class Index extends Controller
// 获取表单数据
- $data = request()->only(['username','password']);
+ $data = request()->only(['username','password','captcha']);
+
// 验证表单数据
$result = $validate->check($data);
$msg = $validate->getError();
@@ -38,6 +40,11 @@ class Index extends Controller
$this->error($msg);
}
+ if(!captcha_check($data['captcha']))
+ {
+ $this->error('验证码错误');
+ }
+
// 验证用户名和密码
$check = $this->check($data['username'],$data['password']);
@@ -109,23 +116,6 @@ class Index extends Controller
}
- // 生成验证码
- public function verify()
- {
- $captcha = new \think\captcha\Captcha;
- return $captcha->entry();
- }
-
- public function checkcaptcha($value)
- {
- dump($value);
- $captcha = new \think\captcha\Captcha;
- if( $captcha->check($value))
- {
- return true;
- }else{
- return false;
- }
- }
+
}
diff --git a/application/login/validate/Yanzheng.php b/application/login/validate/Yanzheng.php
index 6751b7d5..6648350c 100644
--- a/application/login/validate/Yanzheng.php
+++ b/application/login/validate/Yanzheng.php
@@ -14,12 +14,14 @@ class Yanzheng extends Validate
*/
protected $rule = [
'username' => 'require',
- 'password' => 'require'
+ 'password' => 'require',
+ 'captcha' => 'require'
];
protected $message = [
'username.require' => '用户名必须填写',
'password.require' => '密码必须填写',
'password.number' => '密码必须是数字',
+ 'captcha.require' => '验证码必须填写',
];
}
diff --git a/application/login/view/index/index.html b/application/login/view/index/index.html
index 911b026e..d2732c55 100644
--- a/application/login/view/index/index.html
+++ b/application/login/view/index/index.html
@@ -44,7 +44,7 @@
+
})
@@ -65,31 +65,6 @@
{js href="/static/H-ui.admin_v3.1.3.1/H-ui.admin/lib/jquery/1.9.1/jquery.min.js"}
{js href="/static/H-ui.admin_v3.1.3.1/H-ui.admin/static/h-ui/js/H-ui.min.js"}
-
-
-
+