1
|
-<?php
|
|
|
2
|
-use Action\WebAction;
|
|
|
3
|
-use LibModels\Web\Passport\RegData;
|
|
|
4
|
-use Passport\PassportModel;
|
|
|
5
|
-use Plugin\Helpers;
|
|
|
6
|
-use LibModels\Wap\Passport\BackData;
|
|
|
7
|
-use Plugin\AuthCode;
|
|
|
8
|
-
|
|
|
9
|
-class BackController extends WebAction
|
|
|
10
|
-{
|
|
|
11
|
- /**
|
|
|
12
|
- * 找回密码
|
|
|
13
|
- */
|
|
|
14
|
- public function indexAction()
|
|
|
15
|
- {
|
|
|
16
|
- $banner = PassportModel::getLeftBanner(PassportModel::BACK_LFFT_BANNER_CODE);
|
|
|
17
|
- $data = array(
|
|
|
18
|
- 'simpleHeader' => PassportModel::getSimpleHeader(false),
|
|
|
19
|
- 'backPage' => true,
|
|
|
20
|
- 'back' => array(
|
|
|
21
|
- 'coverHref' => $banner['url'],
|
|
|
22
|
- 'coverImg' => $banner['img'],
|
|
|
23
|
- 'countryCode' => '86',
|
|
|
24
|
- 'countryName' => '中国',
|
|
|
25
|
- 'captchaUrl'=>'/passport/images?t=1449799445',
|
|
|
26
|
- 'countryList' => RegData::getAreasData(),
|
|
|
27
|
- )
|
|
|
28
|
- );
|
|
|
29
|
- $this->_view->display('index', $data);
|
|
|
30
|
- }
|
|
|
31
|
-
|
|
|
32
|
- public function authcodeAction()
|
|
|
33
|
- {
|
|
|
34
|
- echo $this->echoJson(array('code'=> 200));
|
|
|
35
|
- }
|
|
|
36
|
-
|
|
|
37
|
- /**
|
|
|
38
|
- *
|
|
|
39
|
- */
|
|
|
40
|
- public function emailAction()
|
|
|
41
|
- {
|
|
|
42
|
- $phoneNum = $this->post('phoneNum','');
|
|
|
43
|
- $area = $this->post('area','86');
|
|
|
44
|
- $verifyCode = $this->post('verifyCode','');
|
|
|
45
|
- if(Helpers::verifyEmail($phoneNum)){ //验证邮箱
|
|
|
46
|
- $email = $phoneNum;
|
|
|
47
|
- $data = BackData::sendCodeToEmail($email);
|
|
|
48
|
- $this->setSession('phoneNum', $phoneNum);
|
|
|
49
|
- if($data['code'] == 200) {
|
|
|
50
|
- $this->redirect('sendemail');
|
|
|
51
|
- }
|
|
|
52
|
- else {
|
|
|
53
|
- $this->redirect('index');
|
|
|
54
|
- }
|
|
|
55
|
- } else if(Helpers::verifyMobile($phoneNum)) {//验证手机号
|
|
|
56
|
- $mobile = $phoneNum;
|
|
|
57
|
- $data = BackData::sendCodeToMobile($mobile);
|
|
|
58
|
- $this->setSession('phoneNum', $phoneNum);
|
|
|
59
|
- $this->setSession('area', $area);
|
|
|
60
|
- $this->setSession('verifyCode', $verifyCode);
|
|
|
61
|
- if($data['code'] == 200) {
|
|
|
62
|
- $this->redirect('verification');
|
|
|
63
|
- }
|
|
|
64
|
- else {
|
|
|
65
|
- $this->redirect('index');
|
|
|
66
|
- }
|
|
|
67
|
- }
|
|
|
68
|
- }
|
|
|
69
|
-
|
|
|
70
|
- /**
|
|
|
71
|
- * 发送邮件页面
|
|
|
72
|
- */
|
|
|
73
|
- public function sendemailAction() {
|
|
|
74
|
- $phoneNum = $this->getSession('phoneNum');
|
|
|
75
|
- if(empty($phoneNum)) {
|
|
|
76
|
- $this->redirect('index');
|
|
|
77
|
- }
|
|
|
78
|
- $banner = PassportModel::getLeftBanner(PassportModel::BACK_LFFT_BANNER_CODE);
|
|
|
79
|
- $data = array(
|
|
|
80
|
- 'simpleHeader' => PassportModel::getSimpleHeader(false),
|
|
|
81
|
- 'sendEmail' => array(
|
|
|
82
|
- 'coverHref' => $banner['url'],
|
|
|
83
|
- 'coverImg' => $banner['img'],
|
|
|
84
|
- 'countrys' => array(),
|
|
|
85
|
- )
|
|
|
86
|
- );
|
|
|
87
|
- $this->_view->display('send-email', $data);
|
|
|
88
|
- }
|
|
|
89
|
-
|
|
|
90
|
- /**
|
|
|
91
|
- * 重置密码页面
|
|
|
92
|
- */
|
|
|
93
|
- public function backcodeAction() {
|
|
|
94
|
- $code = $this->get('code');
|
|
|
95
|
- $info = $this->checkCode($code);
|
|
|
96
|
- if(empty($info)) {
|
|
|
97
|
- $this->redirect('index');
|
|
|
98
|
- }
|
|
|
99
|
- $banner = PassportModel::getLeftBanner(PassportModel::BACK_LFFT_BANNER_CODE);
|
|
|
100
|
- $data = array(
|
|
|
101
|
- 'simpleHeader' => PassportModel::getSimpleHeader(false),
|
|
|
102
|
- 'resetPage' => true,
|
|
|
103
|
- 'resetPwd' => array(
|
|
|
104
|
- 'coverHref' => $banner['url'],
|
|
|
105
|
- 'coverImg' => $banner['img'],
|
|
|
106
|
- 'countrys' => array(),
|
|
|
107
|
- 'code' => $code,
|
|
|
108
|
- )
|
|
|
109
|
- );
|
|
|
110
|
- $this->_view->display('reset-pwd', $data);
|
|
|
111
|
- }
|
|
|
112
|
-
|
|
|
113
|
- /**
|
|
|
114
|
- * 更新密码接口
|
|
|
115
|
- *
|
|
|
116
|
- */
|
|
|
117
|
- public function updateAction()
|
|
|
118
|
- {
|
|
|
119
|
- $code = $this->post('code');
|
|
|
120
|
- $password = $this->post('pwd');
|
|
|
121
|
- $info = $this->checkCode($code);
|
|
|
122
|
- if(Helpers::verifyPassword($password) && !empty($info)) {
|
|
|
123
|
- //修改密码
|
|
|
124
|
- if(isset($info['mobile'])) {//手机号修改密码
|
|
|
125
|
- $mobile = $info['mobile'];
|
|
|
126
|
- $token = $info['token'];
|
|
|
127
|
- $area = $info['area'];
|
|
|
128
|
- $data = BackData::modifyPasswordByMobile($mobile, $token, $password, $area);
|
|
|
129
|
- if($data['code']) {
|
|
|
130
|
- $this->redirect('resetSuccess');
|
|
|
131
|
- }
|
|
|
132
|
- } else if(isset($info['uid'])) {//其他方式修改密码
|
|
|
133
|
- $uid = $info['uid'];
|
|
|
134
|
- $this->redirect('resetSuccess');
|
|
|
135
|
- }
|
|
|
136
|
- }
|
|
|
137
|
- //跳转错误页面
|
|
|
138
|
- $this->redirect('/error/index');
|
|
|
139
|
- }
|
|
|
140
|
-
|
|
|
141
|
- /**
|
|
|
142
|
- * 重置密码成功
|
|
|
143
|
- */
|
|
|
144
|
- public function resetSuccessAction() {
|
|
|
145
|
- $banner = PassportModel::getLeftBanner(PassportModel::BACK_LFFT_BANNER_CODE);
|
|
|
146
|
- $data = array(
|
|
|
147
|
- 'simpleHeader' => PassportModel::getSimpleHeader(false),
|
|
|
148
|
- 'resetSuccess' => array(
|
|
|
149
|
- 'coverHref' => $banner['url'],
|
|
|
150
|
- 'coverImg' => $banner['img'],
|
|
|
151
|
- 'countrys' => array()
|
|
|
152
|
- )
|
|
|
153
|
- );
|
|
|
154
|
- $this->_view->display('reset-success', $data);
|
|
|
155
|
- }
|
|
|
156
|
-
|
|
|
157
|
- /**
|
|
|
158
|
- * 手机验证页面
|
|
|
159
|
- */
|
|
|
160
|
- public function verificationAction() {
|
|
|
161
|
- $phoneNum = $this->getSession('phoneNum');
|
|
|
162
|
- $area = $this->getSession('area');
|
|
|
163
|
- $verifyCode = $this->getSession('verifyCode');
|
|
|
164
|
- if(empty($phoneNum)) {
|
|
|
165
|
- $this->redirect('index');
|
|
|
166
|
- }
|
|
|
167
|
- $banner = PassportModel::getLeftBanner(PassportModel::BACK_LFFT_BANNER_CODE);
|
|
|
168
|
- $data = array(
|
|
|
169
|
- 'simpleHeader' => PassportModel::getSimpleHeader(false),
|
|
|
170
|
- 'vertificationPage' => true,
|
|
|
171
|
- 'verification' => array(
|
|
|
172
|
- 'coverHref' => $banner['url'],
|
|
|
173
|
- 'coverImg' => $banner['img'],
|
|
|
174
|
- 'phoneNum' => $phoneNum,
|
|
|
175
|
- 'area' => $area,
|
|
|
176
|
- 'captcha'=> $captcha,
|
|
|
177
|
- 'countrys' => array()
|
|
|
178
|
- )
|
|
|
179
|
- );
|
|
|
180
|
- $this->_view->display('verification', $data);
|
|
|
181
|
- }
|
|
|
182
|
-
|
|
|
183
|
- /**
|
|
|
184
|
- * 手机找回密码验证
|
|
|
185
|
- */
|
|
|
186
|
- public function backmobileAction()
|
|
|
187
|
- {
|
|
|
188
|
- $mobile = $this->post('mobile');//phoneNum
|
|
|
189
|
- $area = $this->post('area');
|
|
|
190
|
- //$captcha = $this->post('captcha');
|
|
|
191
|
- $code = $this->post('captcha');//code
|
|
|
192
|
- if($this->getSession('phoneNum') == $mobile && $this->getSession('area') == $area)
|
|
|
193
|
- {
|
|
|
194
|
- $result = BackData::validateMobileCode($mobile, $code, $area);
|
|
|
195
|
- if($result['code'] == 200) {
|
|
|
196
|
- $str = json_encode(array(
|
|
|
197
|
- 'mobile'=> $mobile,
|
|
|
198
|
- 'area' => $area,
|
|
|
199
|
- 'token'=> $result['data']['token'],
|
|
|
200
|
- 'create_time' => time()
|
|
|
201
|
- ));
|
|
|
202
|
- $code = AuthCode::encode($str, PassportModel::BACK_FIND_SECRET_KEY);
|
|
|
203
|
- $url = '/passport/back/backcode?code='.base64_encode($code);
|
|
|
204
|
- $this->redirect(SITE_MAIN.$url);
|
|
|
205
|
- }
|
|
|
206
|
- }
|
|
|
207
|
- }
|
|
|
208
|
-
|
|
|
209
|
- /**
|
|
|
210
|
- * 检查code
|
|
|
211
|
- *
|
|
|
212
|
- * @param string $code
|
|
|
213
|
- * @return boolean
|
|
|
214
|
- */
|
|
|
215
|
- private function checkCode($code)
|
|
|
216
|
- {
|
|
|
217
|
- $code = base64_decode($code);
|
|
|
218
|
- $info = json_decode(AuthCode::decode($code, PassportModel::BACK_FIND_SECRET_KEY), true);
|
|
|
219
|
- if ($info['create_time'] < 1 || (time() - $info['create_time']) > 86400) {
|
|
|
220
|
- return array();
|
|
|
221
|
- }
|
|
|
222
|
- return $info;
|
|
|
223
|
- }
|
1
|
+<?php
|
|
|
2
|
+use Action\WebAction;
|
|
|
3
|
+use LibModels\Web\Passport\RegData;
|
|
|
4
|
+use Passport\PassportModel;
|
|
|
5
|
+use Plugin\Helpers;
|
|
|
6
|
+use LibModels\Wap\Passport\BackData;
|
|
|
7
|
+use Plugin\AuthCode;
|
|
|
8
|
+
|
|
|
9
|
+class BackController extends WebAction
|
|
|
10
|
+{
|
|
|
11
|
+ /**
|
|
|
12
|
+ * 找回密码
|
|
|
13
|
+ */
|
|
|
14
|
+ public function indexAction()
|
|
|
15
|
+ {
|
|
|
16
|
+ $banner = PassportModel::getLeftBanner(PassportModel::BACK_LFFT_BANNER_CODE);
|
|
|
17
|
+ $data = array(
|
|
|
18
|
+ 'simpleHeader' => PassportModel::getSimpleHeader(false),
|
|
|
19
|
+ 'backPage' => true,
|
|
|
20
|
+ 'back' => array(
|
|
|
21
|
+ 'coverHref' => $banner['url'],
|
|
|
22
|
+ 'coverImg' => $banner['img'],
|
|
|
23
|
+ 'countryCode' => '86',
|
|
|
24
|
+ 'countryName' => '中国',
|
|
|
25
|
+ 'captchaUrl'=>'/passport/images?t=1449799445',
|
|
|
26
|
+ 'countryList' => RegData::getAreasData(),
|
|
|
27
|
+ )
|
|
|
28
|
+ );
|
|
|
29
|
+ $this->_view->display('index', $data);
|
|
|
30
|
+ }
|
|
|
31
|
+
|
|
|
32
|
+ public function authcodeAction()
|
|
|
33
|
+ {
|
|
|
34
|
+ echo $this->echoJson(array('code'=> 200));
|
|
|
35
|
+ }
|
|
|
36
|
+
|
|
|
37
|
+ /**
|
|
|
38
|
+ *
|
|
|
39
|
+ */
|
|
|
40
|
+ public function emailAction()
|
|
|
41
|
+ {
|
|
|
42
|
+ $phoneNum = $this->post('phoneNum','');
|
|
|
43
|
+ $area = $this->post('area','86');
|
|
|
44
|
+ $verifyCode = $this->post('verifyCode','');
|
|
|
45
|
+ if(Helpers::verifyEmail($phoneNum)){ //验证邮箱
|
|
|
46
|
+ $email = $phoneNum;
|
|
|
47
|
+ $data = BackData::sendCodeToEmail($email);
|
|
|
48
|
+ $this->setSession('email', $email);
|
|
|
49
|
+ if($data['code'] == 200) {
|
|
|
50
|
+ $this->redirect('sendemail');
|
|
|
51
|
+ }
|
|
|
52
|
+ else {
|
|
|
53
|
+ $this->redirect('index');
|
|
|
54
|
+ }
|
|
|
55
|
+ } else if(Helpers::verifyMobile($phoneNum)) {//验证手机号
|
|
|
56
|
+ $mobile = $phoneNum;
|
|
|
57
|
+ $data = BackData::sendCodeToMobile($mobile);
|
|
|
58
|
+ $this->setSession('mobile', $mobile);
|
|
|
59
|
+ $this->setSession('area', $area);
|
|
|
60
|
+ $this->setSession('verifyCode', $verifyCode);
|
|
|
61
|
+ if($data['code'] == 200) {
|
|
|
62
|
+ $this->redirect('verification');
|
|
|
63
|
+ }
|
|
|
64
|
+ else {
|
|
|
65
|
+ $this->redirect('index');
|
|
|
66
|
+ }
|
|
|
67
|
+ }
|
|
|
68
|
+ }
|
|
|
69
|
+
|
|
|
70
|
+ /**
|
|
|
71
|
+ * 发送邮件页面
|
|
|
72
|
+ */
|
|
|
73
|
+ public function sendemailAction() {
|
|
|
74
|
+ $email = $this->getSession('email');
|
|
|
75
|
+ if(empty($email)) {
|
|
|
76
|
+ $this->redirect('index');
|
|
|
77
|
+ }
|
|
|
78
|
+ $banner = PassportModel::getLeftBanner(PassportModel::BACK_LFFT_BANNER_CODE);
|
|
|
79
|
+ $data = array(
|
|
|
80
|
+ 'simpleHeader' => PassportModel::getSimpleHeader(false),
|
|
|
81
|
+ 'sendEmail' => array(
|
|
|
82
|
+ 'coverHref' => $banner['url'],
|
|
|
83
|
+ 'coverImg' => $banner['img'],
|
|
|
84
|
+ 'countrys' => array(),
|
|
|
85
|
+ )
|
|
|
86
|
+ );
|
|
|
87
|
+ $this->_view->display('send-email', $data);
|
|
|
88
|
+ }
|
|
|
89
|
+
|
|
|
90
|
+ /**
|
|
|
91
|
+ * 重置密码页面
|
|
|
92
|
+ */
|
|
|
93
|
+ public function backcodeAction() {
|
|
|
94
|
+ $code = $this->get('code');
|
|
|
95
|
+ $info = $this->checkCode($code);
|
|
|
96
|
+ if(empty($info)) {
|
|
|
97
|
+ $this->redirect('index');
|
|
|
98
|
+ }
|
|
|
99
|
+ $banner = PassportModel::getLeftBanner(PassportModel::BACK_LFFT_BANNER_CODE);
|
|
|
100
|
+ $data = array(
|
|
|
101
|
+ 'simpleHeader' => PassportModel::getSimpleHeader(false),
|
|
|
102
|
+ 'resetPage' => true,
|
|
|
103
|
+ 'resetPwd' => array(
|
|
|
104
|
+ 'coverHref' => $banner['url'],
|
|
|
105
|
+ 'coverImg' => $banner['img'],
|
|
|
106
|
+ 'countrys' => array(),
|
|
|
107
|
+ 'code' => $code,
|
|
|
108
|
+ )
|
|
|
109
|
+ );
|
|
|
110
|
+ $this->_view->display('reset-pwd', $data);
|
|
|
111
|
+ }
|
|
|
112
|
+
|
|
|
113
|
+ /**
|
|
|
114
|
+ * 更新密码接口
|
|
|
115
|
+ *
|
|
|
116
|
+ */
|
|
|
117
|
+ public function updateAction()
|
|
|
118
|
+ {
|
|
|
119
|
+ $code = $this->post('code');
|
|
|
120
|
+ $password = $this->post('pwd');
|
|
|
121
|
+ $info = $this->checkCode($code);
|
|
|
122
|
+ if(Helpers::verifyPassword($password) && !empty($info)) {
|
|
|
123
|
+ //修改密码
|
|
|
124
|
+ if(isset($info['mobile'])) {//手机号修改密码
|
|
|
125
|
+ $mobile = $info['mobile'];
|
|
|
126
|
+ $token = $info['token'];
|
|
|
127
|
+ $area = $info['area'];
|
|
|
128
|
+ $data = BackData::modifyPasswordByMobile($mobile, $token, $password, $area);
|
|
|
129
|
+ if($data['code']) {
|
|
|
130
|
+ $this->redirect('resetSuccess');
|
|
|
131
|
+ }
|
|
|
132
|
+ } else if(isset($info['uid'])) {//其他方式修改密码
|
|
|
133
|
+ $uid = $info['uid'];
|
|
|
134
|
+ $this->redirect('resetSuccess');
|
|
|
135
|
+ }
|
|
|
136
|
+ }
|
|
|
137
|
+ //跳转错误页面
|
|
|
138
|
+ $this->redirect('/error/index');
|
|
|
139
|
+ }
|
|
|
140
|
+
|
|
|
141
|
+ /**
|
|
|
142
|
+ * 重置密码成功
|
|
|
143
|
+ */
|
|
|
144
|
+ public function resetSuccessAction() {
|
|
|
145
|
+ $banner = PassportModel::getLeftBanner(PassportModel::BACK_LFFT_BANNER_CODE);
|
|
|
146
|
+ $data = array(
|
|
|
147
|
+ 'simpleHeader' => PassportModel::getSimpleHeader(false),
|
|
|
148
|
+ 'resetSuccess' => array(
|
|
|
149
|
+ 'coverHref' => $banner['url'],
|
|
|
150
|
+ 'coverImg' => $banner['img'],
|
|
|
151
|
+ 'countrys' => array()
|
|
|
152
|
+ )
|
|
|
153
|
+ );
|
|
|
154
|
+ $this->_view->display('reset-success', $data);
|
|
|
155
|
+ }
|
|
|
156
|
+
|
|
|
157
|
+ /**
|
|
|
158
|
+ * 手机验证页面
|
|
|
159
|
+ */
|
|
|
160
|
+ public function verificationAction() {
|
|
|
161
|
+ $mobile = $this->getSession('mobile');
|
|
|
162
|
+ $area = $this->getSession('area');
|
|
|
163
|
+ $verifyCode = $this->getSession('verifyCode');
|
|
|
164
|
+ if(empty($mobile)) {
|
|
|
165
|
+ $this->redirect('index');
|
|
|
166
|
+ }
|
|
|
167
|
+ $banner = PassportModel::getLeftBanner(PassportModel::BACK_LFFT_BANNER_CODE);
|
|
|
168
|
+ $data = array(
|
|
|
169
|
+ 'simpleHeader' => PassportModel::getSimpleHeader(false),
|
|
|
170
|
+ 'vertificationPage' => true,
|
|
|
171
|
+ 'verification' => array(
|
|
|
172
|
+ 'coverHref' => $banner['url'],
|
|
|
173
|
+ 'coverImg' => $banner['img'],
|
|
|
174
|
+ 'mobile' => $mobile,
|
|
|
175
|
+ 'area' => $area,
|
|
|
176
|
+ 'verifyCode'=> $verifyCode,
|
|
|
177
|
+ 'countrys' => array()
|
|
|
178
|
+ )
|
|
|
179
|
+ );
|
|
|
180
|
+ $this->_view->display('verification', $data);
|
|
|
181
|
+ }
|
|
|
182
|
+
|
|
|
183
|
+ /**
|
|
|
184
|
+ * 手机找回密码验证
|
|
|
185
|
+ */
|
|
|
186
|
+ public function backmobileAction()
|
|
|
187
|
+ {
|
|
|
188
|
+ $mobile = $this->post('mobile');
|
|
|
189
|
+ $area = $this->post('area');
|
|
|
190
|
+ $verifyCode = $this->post('verifyCode');
|
|
|
191
|
+ $code = $this->post('code');//code
|
|
|
192
|
+ if($this->getSession('mobile') == $mobile && $this->getSession('area') == $area)
|
|
|
193
|
+ {
|
|
|
194
|
+ $result = BackData::validateMobileCode($mobile, $code, $area);
|
|
|
195
|
+ if($result['code'] == 200) {
|
|
|
196
|
+ $str = json_encode(array(
|
|
|
197
|
+ 'mobile'=> $mobile,
|
|
|
198
|
+ 'area' => $area,
|
|
|
199
|
+ 'token'=> $result['data']['token'],
|
|
|
200
|
+ 'create_time' => time()
|
|
|
201
|
+ ));
|
|
|
202
|
+ $code = AuthCode::encode($str, PassportModel::BACK_FIND_SECRET_KEY);
|
|
|
203
|
+ $url = '/passport/back/backcode?code='.base64_encode($code);
|
|
|
204
|
+ $this->redirect(SITE_MAIN.$url);
|
|
|
205
|
+ }
|
|
|
206
|
+ }
|
|
|
207
|
+ }
|
|
|
208
|
+
|
|
|
209
|
+ /**
|
|
|
210
|
+ * 检查code
|
|
|
211
|
+ *
|
|
|
212
|
+ * @param string $code
|
|
|
213
|
+ * @return boolean
|
|
|
214
|
+ */
|
|
|
215
|
+ private function checkCode($code)
|
|
|
216
|
+ {
|
|
|
217
|
+ $code = base64_decode($code);
|
|
|
218
|
+ $info = json_decode(AuthCode::decode($code, PassportModel::BACK_FIND_SECRET_KEY), true);
|
|
|
219
|
+ if ($info['create_time'] < 1 || (time() - $info['create_time']) > 86400) {
|
|
|
220
|
+ return array();
|
|
|
221
|
+ }
|
|
|
222
|
+ return $info;
|
|
|
223
|
+ }
|
224
|
} |
224
|
} |