From 5874c994fd3de733034aa10a72b6c3506efdca96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9A=94=E5=A3=81=E8=80=81=E6=9D=8E?= <2777314125@qq.com> Date: Thu, 28 May 2020 14:19:52 +0800 Subject: [PATCH] =?UTF-8?q?add=20=E5=AE=9E=E7=8E=B0=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E5=B8=90=E5=8F=B7=E6=8B=A5=E6=9C=89N=E4=B8=AA=E5=AF=86?= =?UTF-8?q?=E7=A0=81=E7=9A=84PHP=E4=BB=A3=E7=A0=81.md.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...347\232\204PHP\344\273\243\347\240\201.md" | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 "\345\256\236\347\216\260\344\270\200\344\270\252\345\270\220\345\217\267\346\213\245\346\234\211N\344\270\252\345\257\206\347\240\201\347\232\204PHP\344\273\243\347\240\201.md" diff --git "a/\345\256\236\347\216\260\344\270\200\344\270\252\345\270\220\345\217\267\346\213\245\346\234\211N\344\270\252\345\257\206\347\240\201\347\232\204PHP\344\273\243\347\240\201.md" "b/\345\256\236\347\216\260\344\270\200\344\270\252\345\270\220\345\217\267\346\213\245\346\234\211N\344\270\252\345\257\206\347\240\201\347\232\204PHP\344\273\243\347\240\201.md" new file mode 100644 index 0000000..5c0a1ed --- /dev/null +++ "b/\345\256\236\347\216\260\344\270\200\344\270\252\345\270\220\345\217\267\346\213\245\346\234\211N\344\270\252\345\257\206\347\240\201\347\232\204PHP\344\273\243\347\240\201.md" @@ -0,0 +1,36 @@ +那位老锅甩下这一段代码转身离职; +``` + public function login() + { + + $phone = $this->request->post('phone'); + $password = $this->request->post('password'); + + $user = $this->model->where('mobile', $phone)->find(); + if (empty($user)) { + $this->error('该用户不存在'); + } + if (md5($password + $user->salt) == $user->login_pwd) { + session('userInfo', $user); + $this->success('登录成功'); + } else { + $this->error('密码错误'); + } + } + + + protected function saveFilter(&$row) + { + $row['nickname'] = '用户:' . $row['mobile']; + $row['salt'] = rand(1000, 9999); + if (isset($row['login_pwd']) && !empty($row['login_pwd'])) { + $row['login_pwd'] = md5(md5($row['login_pwd']) + $row['salt']); + } + if (isset($row['trade_pwd']) && !empty($row['trade_pwd'])) { + $row['trade_pwd'] = md5(md5($row['trade_pwd']) + $row['trade_pwd']); + } + } +``` +项目已经正式运行了,user表记录有几百条了; +一个账号有N个密码 +一改代码,所有的用户密码都得重置! \ No newline at end of file -- Gitee