commit | author | age
|
3e083b
|
1 |
<?php |
B |
2 |
|
|
3 |
/** |
|
4 |
* 账户安全 |
|
5 |
*/ |
|
6 |
define('IN_ECS', true); |
|
7 |
|
|
8 |
require (dirname(__FILE__) . '/includes/init.php'); |
|
9 |
/* 载入语言文件 */ |
|
10 |
require_once (ROOT_PATH . 'languages/' . $_CFG['lang'] . '/user.php'); |
|
11 |
|
|
12 |
$ui_arr = array(); |
|
13 |
|
|
14 |
$ui_arr[] = 'default'; |
|
15 |
|
|
16 |
$affiliate = unserialize($GLOBALS['_CFG']['affiliate']); |
|
17 |
$smarty->assign('affiliate', $affiliate); |
|
18 |
$user_id = $_SESSION['user_id']; |
|
19 |
$back_act = ''; |
|
20 |
|
|
21 |
$action = isset($_REQUEST['act']) ? trim($_REQUEST['act']) : 'default'; |
|
22 |
|
|
23 |
/* 未登录处理 */ |
|
24 |
if(empty($_SESSION['user_id'])) |
|
25 |
{ |
|
26 |
$query_string = $_SERVER['QUERY_STRING']; |
|
27 |
if(! empty($query_string)) |
|
28 |
{ |
|
29 |
$back_act = 'user.php?' . strip_tags($query_string); |
|
30 |
} |
|
31 |
$action = 'login'; |
|
32 |
header("Location: user.php?act=login"); |
|
33 |
} |
|
34 |
|
|
35 |
/* 如果是显示页面,对页面进行相应赋值 */ |
|
36 |
if(in_array($action, $ui_arr) || true) |
|
37 |
{ |
|
38 |
assign_template(); |
|
39 |
$position = assign_ur_here(0, $_LANG['user_center']); |
|
40 |
$smarty->assign('page_title', $position['title']); // 页面标题 |
|
41 |
$smarty->assign('ur_here', $position['ur_here']); |
|
42 |
$sql = "SELECT value FROM " . $ecs->table('shop_config') . " WHERE id = 419"; |
|
43 |
$row = $db->getRow($sql); |
|
44 |
$car_off = $row['value']; |
|
45 |
$smarty->assign('car_off', $car_off); |
|
46 |
/* 是否显示积分兑换 */ |
|
47 |
if(! empty($_CFG['points_rule']) && unserialize($_CFG['points_rule'])) |
|
48 |
{ |
|
49 |
$smarty->assign('show_transform_points', 1); |
|
50 |
} |
|
51 |
$smarty->assign('helps', get_shop_help()); // 网店帮助 |
|
52 |
$smarty->assign('data_dir', DATA_DIR); // 数据目录 |
|
53 |
$smarty->assign('action', $action); |
|
54 |
$smarty->assign('lang', $_LANG); |
|
55 |
} |
|
56 |
/* 代码增加_Start 用户中心获取会员信息*/ |
|
57 |
|
|
58 |
include_once (ROOT_PATH . 'includes/lib_clips.php'); |
|
59 |
if($rank = get_rank_info()) |
|
60 |
{ |
|
61 |
$smarty->assign('rank_name', $rank['rank_name']); |
|
62 |
if(! empty($rank['next_rank_name'])) |
|
63 |
{ |
|
64 |
$smarty->assign('next_rank_name', sprintf($_LANG['next_level'], $rank['next_rank'], $rank['next_rank_name'])); |
|
65 |
} |
|
66 |
$rn = $rank['rank_name']; |
|
67 |
$recomm = $db->getOne("SELECT is_recomm FROM " . $GLOBALS['ecs']->table('user_rank') . " WHERE rank_name= '$rn'"); |
|
68 |
$smarty->assign('recomm', $recomm); // 获取当前用户是否是分成用户判断是否显示我的推荐 |
|
69 |
} |
|
70 |
|
|
71 |
/* 代码增加_End */ |
|
72 |
/* 路由 */ |
|
73 |
|
|
74 |
$smarty->assign('is_security', 'true'); |
|
75 |
|
|
76 |
$function_name = 'action_' . $action; |
|
77 |
|
|
78 |
if(! function_exists($function_name)) |
|
79 |
{ |
|
80 |
$function_name = "action_default"; |
|
81 |
} |
|
82 |
|
|
83 |
call_user_func($function_name); |
|
84 |
|
|
85 |
return; |
|
86 |
|
|
87 |
/* 路由 */ |
|
88 |
function action_check_email_exist () |
|
89 |
{ |
|
90 |
$_LANG = $GLOBALS['_LANG']; |
|
91 |
$_CFG = $GLOBALS['_CFG']; |
|
92 |
$smarty = $GLOBALS['smarty']; |
|
93 |
$db = $GLOBALS['db']; |
|
94 |
$ecs = $GLOBALS['ecs']; |
|
95 |
|
|
96 |
$email = empty($_POST['email']) ? '' : $_POST['email']; |
|
97 |
|
|
98 |
$user = $GLOBALS['user']; |
|
99 |
|
|
100 |
if($user->check_email($email)) |
|
101 |
{ |
|
102 |
echo 'false'; |
|
103 |
} |
|
104 |
else |
|
105 |
{ |
|
106 |
echo 'true'; |
|
107 |
} |
|
108 |
} |
|
109 |
|
|
110 |
function action_check_mobile_exist () |
|
111 |
{ |
|
112 |
$_LANG = $GLOBALS['_LANG']; |
|
113 |
$_CFG = $GLOBALS['_CFG']; |
|
114 |
$smarty = $GLOBALS['smarty']; |
|
115 |
$db = $GLOBALS['db']; |
|
116 |
$ecs = $GLOBALS['ecs']; |
|
117 |
|
|
118 |
$mobile = empty($_POST['mobile']) ? '' : $_POST['mobile']; |
|
119 |
|
|
120 |
$user = $GLOBALS['user']; |
|
121 |
|
|
122 |
if($user->check_mobile_phone($mobile)) |
|
123 |
{ |
|
124 |
echo 'false'; |
|
125 |
} |
|
126 |
else |
|
127 |
{ |
|
128 |
echo 'true'; |
|
129 |
} |
|
130 |
} |
|
131 |
|
|
132 |
/** |
|
133 |
* 发送邮箱验证码 |
|
134 |
*/ |
|
135 |
function action_send_email_code () |
|
136 |
{ |
|
137 |
$_LANG = $GLOBALS['_LANG']; |
|
138 |
$_CFG = $GLOBALS['_CFG']; |
|
139 |
$smarty = $GLOBALS['smarty']; |
|
140 |
$db = $GLOBALS['db']; |
|
141 |
$ecs = $GLOBALS['ecs']; |
|
142 |
|
|
143 |
require_once (ROOT_PATH . 'includes/lib_validate_record.php'); |
|
144 |
|
|
145 |
$email = empty($_POST['email']) ? '' : trim($_POST['email']); |
|
146 |
|
|
147 |
if(empty($email)) |
|
148 |
{ |
|
149 |
exit("邮箱不能为空"); |
|
150 |
return; |
|
151 |
} |
|
152 |
else if(! is_email($email)) |
|
153 |
{ |
|
154 |
exit("邮箱格式不正确"); |
|
155 |
return; |
|
156 |
} |
|
157 |
else if(check_validate_record_exist($email)) |
|
158 |
{ |
|
159 |
|
|
160 |
$record = get_validate_record($email); |
|
161 |
|
|
162 |
/** |
|
163 |
* 检查是过了限制发送邮件的时间 |
|
164 |
*/ |
|
165 |
if(time() - $record['last_send_time'] < 60) |
|
166 |
{ |
|
167 |
echo ("每60秒内只能发送一次注册邮箱验证码,请稍候重试"); |
|
168 |
return; |
|
169 |
} |
|
170 |
} |
|
171 |
|
|
172 |
require_once (ROOT_PATH . 'includes/lib_passport.php'); |
|
173 |
|
|
174 |
/* 设置验证邮件模板所需要的内容信息 */ |
|
175 |
$template = get_mail_template('email_validate'); |
|
176 |
|
|
177 |
// 生成邮箱验证码 |
|
178 |
$email_code = rand_number(6); |
|
179 |
|
|
180 |
$GLOBALS['smarty']->assign('email_code', $email_code); |
|
181 |
$GLOBALS['smarty']->assign('shop_name', $GLOBALS['_CFG']['shop_name']); |
|
182 |
$GLOBALS['smarty']->assign('send_date', date($GLOBALS['_CFG']['date_format'])); |
|
183 |
|
|
184 |
$content = $GLOBALS['smarty']->fetch('str:' . $template['template_content']); |
|
185 |
|
|
186 |
/* 发送激活验证邮件 */ |
|
187 |
$result = send_mail($email, $email, $template['template_subject'], $content, $template['is_html']); |
|
188 |
if($result) |
|
189 |
{ |
|
190 |
// 保存验证码到Session中 |
|
191 |
$_SESSION[VT_EMAIL_VALIDATE] = $email; |
|
192 |
// 保存验证记录 |
|
193 |
save_validate_record($email, $email_code, VT_EMAIL_VALIDATE, time(), time() + 30 * 60); |
|
194 |
|
|
195 |
echo 'ok'; |
|
196 |
} |
|
197 |
else |
|
198 |
{ |
|
199 |
echo '邮箱验证码发送失败'; |
|
200 |
} |
|
201 |
} |
|
202 |
|
|
203 |
/** |
|
204 |
* 发送短信验证码 |
|
205 |
*/ |
|
206 |
function action_send_mobile_code () |
|
207 |
{ |
|
208 |
$_LANG = $GLOBALS['_LANG']; |
|
209 |
$smarty = $GLOBALS['smarty']; |
|
210 |
$db = $GLOBALS['db']; |
|
211 |
$ecs = $GLOBALS['ecs']; |
|
212 |
|
|
213 |
require_once (ROOT_PATH . 'includes/lib_validate_record.php'); |
|
214 |
|
|
215 |
$mobile_phone = trim($_POST['mobile']); |
|
216 |
|
|
217 |
if(empty($mobile_phone)) |
|
218 |
{ |
|
219 |
exit("手机号不能为空"); |
|
220 |
return; |
|
221 |
} |
|
222 |
else if(! is_mobile_phone($mobile_phone)) |
|
223 |
{ |
|
224 |
exit("手机号格式不正确"); |
|
225 |
return; |
|
226 |
} |
|
227 |
else if(check_validate_record_exist($mobile_phone)) |
|
228 |
{ |
|
229 |
// 获取数据库中的验证记录 |
|
230 |
$record = get_validate_record($mobile_phone); |
|
231 |
|
|
232 |
/** |
|
233 |
* 检查是过了限制发送短信的时间 |
|
234 |
*/ |
|
235 |
$last_send_time = $record['last_send_time']; |
|
236 |
$expired_time = $record['expired_time']; |
|
237 |
$create_time = $record['create_time']; |
|
238 |
$count = $record['count']; |
|
239 |
|
|
240 |
// 每天每个手机号最多发送的验证码数量 |
|
241 |
$max_sms_count = 10; |
|
242 |
// 发送最多验证码数量的限制时间,默认为24小时 |
|
243 |
$max_sms_count_time = 60 * 60 * 24; |
|
244 |
|
|
245 |
if((time() - $last_send_time) < 60) |
|
246 |
{ |
|
247 |
echo ("每60秒内只能发送一次短信验证码,请稍候重试"); |
|
248 |
return; |
|
249 |
} |
|
250 |
else if(time() - $create_time < $max_sms_count_time && $record['count'] > $max_sms_count) |
|
251 |
{ |
|
252 |
echo ("您发送验证码太过于频繁,请稍后重试!"); |
|
253 |
return; |
|
254 |
} |
|
255 |
else |
|
256 |
{ |
|
257 |
$count ++; |
|
258 |
} |
|
259 |
} |
|
260 |
|
|
261 |
require_once (ROOT_PATH . 'includes/lib_passport.php'); |
|
262 |
|
|
263 |
// 设置为空 |
|
264 |
$_SESSION[VT_MOBILE_VALIDATE] = array(); |
|
265 |
|
|
266 |
require_once (ROOT_PATH . 'sms/sms.php'); |
|
267 |
|
|
268 |
// 生成6位短信验证码 |
|
269 |
$mobile_code = rand_number(6); |
|
270 |
// 短信内容 |
|
271 |
$content = sprintf($GLOBALS['_CFG']['sms_register_tpl'],$mobile_code,$GLOBALS['_CFG']['shop_name']); |
|
272 |
|
|
273 |
/* 发送激活验证邮件 */ |
|
274 |
$result = sendSMS($mobile_phone, $content); |
|
275 |
if($result) |
|
276 |
{ |
|
277 |
|
|
278 |
if(! isset($count)) |
|
279 |
{ |
|
280 |
$ext_info = array( |
|
281 |
"count" => 1 |
|
282 |
); |
|
283 |
} |
|
284 |
else |
|
285 |
{ |
|
286 |
$ext_info = array( |
|
287 |
"count" => $count |
|
288 |
); |
|
289 |
} |
|
290 |
// 保存验证的手机号 |
|
291 |
$_SESSION[VT_MOBILE_VALIDATE] = $mobile_phone; |
|
292 |
// 保存验证信息 |
|
293 |
save_validate_record($mobile_phone, $mobile_code, VT_MOBILE_VALIDATE, time(), time() + 30 * 60, $ext_info); |
|
294 |
echo 'ok'; |
|
295 |
} |
|
296 |
else |
|
297 |
{ |
|
298 |
echo '短信验证码发送失败'; |
|
299 |
} |
|
300 |
} |
|
301 |
|
|
302 |
/** |
|
303 |
* 账户安全中心 |
|
304 |
*/ |
|
305 |
function action_default () |
|
306 |
{ |
|
307 |
// 获取全局变量 |
|
308 |
$user = $GLOBALS['user']; |
|
309 |
$_CFG = $GLOBALS['_CFG']; |
|
310 |
$_LANG = $GLOBALS['_LANG']; |
|
311 |
$smarty = $GLOBALS['smarty']; |
|
312 |
$db = $GLOBALS['db']; |
|
313 |
$ecs = $GLOBALS['ecs']; |
|
314 |
$user_id = $GLOBALS['user_id']; |
|
315 |
|
|
316 |
include_once (ROOT_PATH . 'includes/lib_transaction.php'); |
|
317 |
|
|
318 |
$user_info = get_profile($user_id); |
|
319 |
$user_info['email'] = encrypt_email($user_info['email']); |
|
320 |
$user_info['mobile_phone'] = encrypt_mobile($user_info['mobile_phone']); |
|
321 |
|
|
322 |
// 判断当前用户是否为商家用户 |
|
323 |
$is_supplier = is_supplier($user_id); |
|
324 |
if($is_supplier == true) |
|
325 |
{ |
|
326 |
$smarty->assign('is_supplier', 1); |
|
327 |
} |
|
328 |
else |
|
329 |
{ |
|
330 |
$smarty->assign('is_supplier', 0); |
|
331 |
} |
|
332 |
|
|
333 |
$smarty->assign('info', $user_info); |
|
334 |
$smarty->assign('action', 'account_security'); |
|
335 |
$smarty->display('user_security.dwt'); |
|
336 |
} |
|
337 |
|
|
338 |
/** |
|
339 |
* 身份验证 |
|
340 |
*/ |
|
341 |
function action_validate () |
|
342 |
{ |
|
343 |
// 获取全局变量 |
|
344 |
$_LANG = $GLOBALS['_LANG']; |
|
345 |
$smarty = $GLOBALS['smarty']; |
|
346 |
$db = $GLOBALS['db']; |
|
347 |
$ecs = $GLOBALS['ecs']; |
|
348 |
|
|
349 |
/* 开启验证码检查 */ |
|
350 |
if(((intval($_CFG['captcha']) & CAPTCHA_REGISTER) && gd_version() > 0) || TRUE) |
|
351 |
{ |
|
352 |
if(empty($_POST['captcha'])) |
|
353 |
{ |
|
354 |
exit(json_encode(array( |
|
355 |
'error' => 1, 'content' => $_LANG['invalid_captcha'], 'url' => '' |
|
356 |
))); |
|
357 |
} |
|
358 |
|
|
359 |
/* 检查验证码 */ |
|
360 |
include_once ('includes/cls_captcha.php'); |
|
361 |
|
|
362 |
$captcha = new captcha(); |
|
363 |
|
|
364 |
if(! $captcha->check_word(trim($_POST['captcha']))) |
|
365 |
{ |
|
366 |
exit(json_encode(array( |
|
367 |
'error' => 1, 'content' => $_LANG['invalid_captcha'], 'url' => '' |
|
368 |
))); |
|
369 |
} |
|
370 |
} |
|
371 |
|
|
372 |
$validate_type = $_POST['validate_type']; |
|
373 |
|
|
374 |
if(! isset($_POST['validate_type']) || empty($_POST['validate_type'])) |
|
375 |
{ |
|
376 |
exit(json_encode(array( |
|
377 |
'error' => 1, 'content' => '验证类型不能为空', 'url' => 'security.php' |
|
378 |
))); |
|
379 |
} |
|
380 |
|
|
381 |
require_once (ROOT_PATH . 'includes/lib_passport.php'); |
|
382 |
|
|
383 |
if($validate_type == 'email') |
|
384 |
{ |
|
385 |
|
|
386 |
// $post_email =isset($_POST['email']) ? $_POST['email'] : ''; |
|
387 |
$email = $_SESSION[VT_EMAIL_VALIDATE]; |
|
388 |
$email_code = ! empty($_POST['email_code']) ? trim($_POST['email_code']) : ''; |
|
389 |
|
|
390 |
$result = validate_email_code($email, $email_code); |
|
391 |
|
|
392 |
if($result == 1) |
|
393 |
{ |
|
394 |
exit(json_encode(array( |
|
395 |
'error' => 1, 'content' => $_LANG['msg_email_blank'], 'url' => '' |
|
396 |
))); |
|
397 |
} |
|
398 |
else if($result == 2) |
|
399 |
{ |
|
400 |
exit(json_encode(array( |
|
401 |
'error' => 1, 'content' => $_LANG['msg_email_format'], 'url' => '' |
|
402 |
))); |
|
403 |
} |
|
404 |
else if($result == 3) |
|
405 |
{ |
|
406 |
exit(json_encode(array( |
|
407 |
'error' => 1, 'content' => $_LANG['msg_email_code_blank'], 'url' => '' |
|
408 |
))); |
|
409 |
} |
|
410 |
else if($result == 4) |
|
411 |
{ |
|
412 |
exit(json_encode(array( |
|
413 |
'error' => 1, 'content' => $_LANG['invalid_email_code'], 'url' => '' |
|
414 |
))); |
|
415 |
} |
|
416 |
else if($result == 5) |
|
417 |
{ |
|
418 |
exit(json_encode(array( |
|
419 |
'error' => 1, 'content' => $_LANG['invalid_email_code'], 'url' => '' |
|
420 |
))); |
|
421 |
} |
|
422 |
} |
|
423 |
else if($validate_type == 'mobile_phone') |
|
424 |
{ |
|
425 |
|
|
426 |
$mobile_phone = $_SESSION[VT_MOBILE_VALIDATE]; |
|
427 |
$mobile_code = ! empty($_POST['mobile_code']) ? trim($_POST['mobile_code']) : ''; |
|
428 |
|
|
429 |
$result = validate_mobile_code($mobile_phone, $mobile_code); |
|
430 |
if($result == 1) |
|
431 |
{ |
|
432 |
exit(json_encode(array( |
|
433 |
'error' => 1, 'content' => $_LANG['msg_mobile_phone_blank'], 'url' => '' |
|
434 |
))); |
|
435 |
} |
|
436 |
else if($result == 2) |
|
437 |
{ |
|
438 |
exit(json_encode(array( |
|
439 |
'error' => 1, 'content' => $_LANG['msg_mobile_phone_format'], 'url' => '' |
|
440 |
))); |
|
441 |
} |
|
442 |
else if($result == 3) |
|
443 |
{ |
|
444 |
exit(json_encode(array( |
|
445 |
'error' => 1, 'content' => $_LANG['msg_mobile_phone_code_blank'], 'url' => '' |
|
446 |
))); |
|
447 |
} |
|
448 |
else if($result == 4) |
|
449 |
{ |
|
450 |
exit(json_encode(array( |
|
451 |
'error' => 1, 'content' => $_LANG['invalid_mobile_phone_code'], 'url' => '' |
|
452 |
))); |
|
453 |
} |
|
454 |
else if($result == 5) |
|
455 |
{ |
|
456 |
exit(json_encode(array( |
|
457 |
'error' => 1, 'content' => $_LANG['invalid_mobile_phone_code'], 'url' => '' |
|
458 |
))); |
|
459 |
} |
|
460 |
} |
|
461 |
else if($validate_type == 'password') |
|
462 |
{ |
|
463 |
$user = $GLOBALS['user']; |
|
464 |
$user_name = $_SESSION['user_name']; |
|
465 |
$password = empty($_POST['password']) ? '' : $_POST['password']; |
|
466 |
if($user->check_user($user_name, $password) == 0) |
|
467 |
{ |
|
468 |
exit(json_encode(array( |
|
469 |
'error' => 1, 'content' => '登录密码错误', 'url' => '' |
|
470 |
))); |
|
471 |
} |
|
472 |
} |
|
473 |
else |
|
474 |
{ |
|
475 |
/* 无效的注册类型 */ |
|
476 |
exit(json_encode(array( |
|
477 |
'error' => 1, 'content' => '非法验证参数', 'url' => '' |
|
478 |
))); |
|
479 |
} |
|
480 |
|
|
481 |
// 设置为第二步 |
|
482 |
$_SESSION['security_validate'] = true; |
|
483 |
|
|
484 |
exit(json_encode(array( |
|
485 |
'error' => 0, 'content' => '', 'url' => '' |
|
486 |
))); |
|
487 |
} |
|
488 |
|
|
489 |
/** |
|
490 |
* 修改密码 |
|
491 |
*/ |
|
492 |
function action_password_reset () |
|
493 |
{ |
|
494 |
// 获取全局变量 |
|
495 |
$_LANG = $GLOBALS['_LANG']; |
|
496 |
$smarty = $GLOBALS['smarty']; |
|
497 |
$db = $GLOBALS['db']; |
|
498 |
$ecs = $GLOBALS['ecs']; |
|
499 |
$user_id = $GLOBALS['user_id']; |
|
500 |
|
|
501 |
// 获取验证方式 |
|
502 |
$validate_types = get_validate_types($user_id); |
|
503 |
$smarty->assign('validate_types', $validate_types); |
|
504 |
|
|
505 |
$smarty->assign('step', 'step_1'); |
|
506 |
|
|
507 |
$smarty->display('user_security.dwt'); |
|
508 |
} |
|
509 |
|
|
510 |
/** |
|
511 |
* 修改密码 |
|
512 |
*/ |
|
513 |
function action_to_password_reset () |
|
514 |
{ |
|
515 |
// 获取全局变量 |
|
516 |
$_LANG = $GLOBALS['_LANG']; |
|
517 |
$smarty = $GLOBALS['smarty']; |
|
518 |
$db = $GLOBALS['db']; |
|
519 |
$ecs = $GLOBALS['ecs']; |
|
520 |
$user_id = $GLOBALS['user_id']; |
|
521 |
|
|
522 |
if($_SESSION['security_validate'] != true) |
|
523 |
{ |
|
524 |
show_message('非法操作!', '返回上一页', 'security.php?act=password_reset', 'info'); |
|
525 |
} |
|
526 |
$smarty->assign('step', 'step_2'); |
|
527 |
$smarty->assign('action', 'password_reset'); |
|
528 |
|
|
529 |
$smarty->display('user_security.dwt'); |
|
530 |
} |
|
531 |
|
|
532 |
/** |
|
533 |
* 修改密码 |
|
534 |
*/ |
|
535 |
function action_do_password_reset () |
|
536 |
{ |
|
537 |
// 检查是否通过安全验证 |
|
538 |
if($_SESSION['security_validate'] != true) |
|
539 |
{ |
|
540 |
exit(json_encode(array( |
|
541 |
'error' => 1, 'content' => '非法操作', 'url' => 'security.php' |
|
542 |
))); |
|
543 |
} |
|
544 |
|
|
545 |
$password = $_POST['password']; |
|
546 |
|
|
547 |
if(! isset($_POST['password']) || empty($_POST['password'])) |
|
548 |
{ |
|
549 |
exit(json_encode(array( |
|
550 |
'error' => 1, 'content' => '密码不能为空', 'url' => '' |
|
551 |
))); |
|
552 |
} |
|
553 |
|
|
554 |
$user_name = $_SESSION['user_name']; |
|
555 |
|
|
556 |
$result = $GLOBALS['user']->edit_user(array( |
|
557 |
'username' => $user_name, 'password' => $password |
|
558 |
)); |
|
559 |
|
|
560 |
if($result == false) |
|
561 |
{ |
|
562 |
exit(json_encode(array( |
|
563 |
'error' => 1, 'content' => '重置密码失败,请重新尝试', 'url' => '' |
|
564 |
))); |
|
565 |
} |
|
566 |
else |
|
567 |
{ |
|
568 |
exit(json_encode(array( |
|
569 |
'error' => 0, 'content' => '', 'url' => '' |
|
570 |
))); |
|
571 |
} |
|
572 |
} |
|
573 |
|
|
574 |
/** |
|
575 |
* 修改密码成功 |
|
576 |
*/ |
|
577 |
function action_password_reset_success () |
|
578 |
{ |
|
579 |
// 获取全局变量 |
|
580 |
$_LANG = $GLOBALS['_LANG']; |
|
581 |
$smarty = $GLOBALS['smarty']; |
|
582 |
$db = $GLOBALS['db']; |
|
583 |
$ecs = $GLOBALS['ecs']; |
|
584 |
$user_id = $GLOBALS['user_id']; |
|
585 |
|
|
586 |
// 检查是否通过安全验证 |
|
587 |
if($_SESSION['security_validate'] != true) |
|
588 |
{ |
|
589 |
header('Location: security.php'); |
|
590 |
} |
|
591 |
|
|
592 |
$smarty->assign('action', 'password_reset'); |
|
593 |
$smarty->assign('step', 'step_3'); |
|
594 |
|
|
595 |
// 释放变量 |
|
596 |
$_SESSION['security_validate'] = false; |
|
597 |
|
|
598 |
$smarty->display('user_security.dwt'); |
|
599 |
} |
|
600 |
|
|
601 |
/** |
|
602 |
* 绑定邮箱 |
|
603 |
*/ |
|
604 |
function action_email_binding () |
|
605 |
{ |
|
606 |
// 获取全局变量 |
|
607 |
$_LANG = $GLOBALS['_LANG']; |
|
608 |
$smarty = $GLOBALS['smarty']; |
|
609 |
$db = $GLOBALS['db']; |
|
610 |
$ecs = $GLOBALS['ecs']; |
|
611 |
$user_id = $GLOBALS['user_id']; |
|
612 |
|
|
613 |
// 获取验证方式 |
|
614 |
$validate_types = get_validate_types($user_id); |
|
615 |
$smarty->assign('validate_types', $validate_types); |
|
616 |
|
|
617 |
$smarty->assign('step', 'step_1'); |
|
618 |
|
|
619 |
$smarty->display('user_security.dwt'); |
|
620 |
} |
|
621 |
|
|
622 |
/** |
|
623 |
* 绑定邮箱 |
|
624 |
*/ |
|
625 |
function action_to_email_binding () |
|
626 |
{ |
|
627 |
// 获取全局变量 |
|
628 |
$_LANG = $GLOBALS['_LANG']; |
|
629 |
$smarty = $GLOBALS['smarty']; |
|
630 |
$db = $GLOBALS['db']; |
|
631 |
$ecs = $GLOBALS['ecs']; |
|
632 |
$user_id = $GLOBALS['user_id']; |
|
633 |
|
|
634 |
if($_SESSION['security_validate'] != true) |
|
635 |
{ |
|
636 |
show_message('非法操作!', '返回上一页', 'security.php', 'info'); |
|
637 |
} |
|
638 |
|
|
639 |
// 获取验证方式 |
|
640 |
$smarty->assign('step', 'step_2'); |
|
641 |
$smarty->assign('action', 'email_binding'); |
|
642 |
|
|
643 |
$smarty->display('user_security.dwt'); |
|
644 |
} |
|
645 |
|
|
646 |
/** |
|
647 |
* 绑定邮箱 |
|
648 |
*/ |
|
649 |
function action_do_email_binding () |
|
650 |
{ |
|
651 |
// 获取全局变量 |
|
652 |
$_LANG = $GLOBALS['_LANG']; |
|
653 |
$smarty = $GLOBALS['smarty']; |
|
654 |
$db = $GLOBALS['db']; |
|
655 |
$ecs = $GLOBALS['ecs']; |
|
656 |
|
|
657 |
// 检查是否通过安全验证 |
|
658 |
if($_SESSION['security_validate'] != true) |
|
659 |
{ |
|
660 |
exit(json_encode(array( |
|
661 |
'error' => 1, 'content' => '非法操作', 'url' => '' |
|
662 |
))); |
|
663 |
} |
|
664 |
|
|
665 |
require_once (ROOT_PATH . 'includes/lib_passport.php'); |
|
666 |
|
|
667 |
$email = trim($_SESSION[VT_EMAIL_VALIDATE]); |
|
668 |
$email_code = ! empty($_POST['email_code']) ? trim($_POST['email_code']) : ''; |
|
669 |
|
|
670 |
// 如果Session中没有验证邮箱地址那么提示验证码错误 |
|
671 |
if(! isset($_POST['email']) || empty($_POST['email'])) |
|
672 |
{ |
|
673 |
exit(json_encode(array( |
|
674 |
'error' => 1, 'content' => $_LANG['msg_email_blank'], 'url' => '' |
|
675 |
))); |
|
676 |
} |
|
677 |
else if(! isset($email) || empty($email)) |
|
678 |
{ |
|
679 |
exit(json_encode(array( |
|
680 |
'error' => 1, 'content' => $_LANG['invalid_email_code'], 'url' => '' |
|
681 |
))); |
|
682 |
} |
|
683 |
else if($_POST['email'] != $email) |
|
684 |
{ |
|
685 |
exit(json_encode(array( |
|
686 |
'error' => 1, 'content' => $_LANG['email_changed'], 'url' => '' |
|
687 |
))); |
|
688 |
} |
|
689 |
|
|
690 |
$result = validate_email_code($email, $email_code); |
|
691 |
|
|
692 |
if($result == 1) |
|
693 |
{ |
|
694 |
exit(json_encode(array( |
|
695 |
'error' => 1, 'content' => $_LANG['msg_email_blank'], 'url' => '' |
|
696 |
))); |
|
697 |
} |
|
698 |
else if($result == 2) |
|
699 |
{ |
|
700 |
exit(json_encode(array( |
|
701 |
'error' => 1, 'content' => $_LANG['msg_email_format'], 'url' => '' |
|
702 |
))); |
|
703 |
} |
|
704 |
else if($result == 3) |
|
705 |
{ |
|
706 |
exit(json_encode(array( |
|
707 |
'error' => 1, 'content' => $_LANG['msg_email_code_blank'], 'url' => '' |
|
708 |
))); |
|
709 |
} |
|
710 |
else if($result == 4) |
|
711 |
{ |
|
712 |
exit(json_encode(array( |
|
713 |
'error' => 1, 'content' => $_LANG['invalid_email_code'], 'url' => '' |
|
714 |
))); |
|
715 |
} |
|
716 |
else if($result == 5) |
|
717 |
{ |
|
718 |
exit(json_encode(array( |
|
719 |
'error' => 1, 'content' => $_LANG['invalid_email_code'], 'url' => '' |
|
720 |
))); |
|
721 |
} |
|
722 |
|
|
723 |
$user_name = $_SESSION['user_name']; |
|
724 |
|
|
725 |
$result = $GLOBALS['user']->edit_user(array( |
|
726 |
'username' => $user_name, 'email' => $email, 'email_validated' => 1 |
|
727 |
)); |
|
728 |
|
|
729 |
if($result == false) |
|
730 |
{ |
|
731 |
exit(json_encode(array( |
|
732 |
'error' => 1, 'content' => '绑定邮箱失败,请重新尝试', 'url' => '' |
|
733 |
))); |
|
734 |
} |
|
735 |
else |
|
736 |
{ |
|
737 |
// 设置为第二步 |
|
738 |
$_SESSION['security_validate'] = true; |
|
739 |
|
|
740 |
exit(json_encode(array( |
|
741 |
'error' => 0, 'content' => '', 'url' => '' |
|
742 |
))); |
|
743 |
} |
|
744 |
} |
|
745 |
|
|
746 |
/** |
|
747 |
* 绑定邮箱成功 |
|
748 |
*/ |
|
749 |
function action_email_binding_success () |
|
750 |
{ |
|
751 |
// 获取全局变量 |
|
752 |
$_LANG = $GLOBALS['_LANG']; |
|
753 |
$smarty = $GLOBALS['smarty']; |
|
754 |
$db = $GLOBALS['db']; |
|
755 |
$ecs = $GLOBALS['ecs']; |
|
756 |
$user_id = $GLOBALS['user_id']; |
|
757 |
|
|
758 |
// 检查是否通过安全验证 |
|
759 |
if($_SESSION['security_validate'] != true) |
|
760 |
{ |
|
761 |
header('Location: security.php'); |
|
762 |
} |
|
763 |
|
|
764 |
$smarty->assign('action', 'email_binding'); |
|
765 |
$smarty->assign('step', 'step_3'); |
|
766 |
|
|
767 |
// 释放变量 |
|
768 |
$_SESSION['security_validate'] = false; |
|
769 |
|
|
770 |
$smarty->display('user_security.dwt'); |
|
771 |
} |
|
772 |
|
|
773 |
/** |
|
774 |
* 验证邮箱 |
|
775 |
*/ |
|
776 |
function action_email_validate () |
|
777 |
{ |
|
778 |
// 获取全局变量 |
|
779 |
$_LANG = $GLOBALS['_LANG']; |
|
780 |
$smarty = $GLOBALS['smarty']; |
|
781 |
$db = $GLOBALS['db']; |
|
782 |
$ecs = $GLOBALS['ecs']; |
|
783 |
$user_id = $GLOBALS['user_id']; |
|
784 |
|
|
785 |
$sql = "select email from " . $ecs->table('users') . " where user_name = '" . $_SESSION['user_name'] . "'"; |
|
786 |
|
|
787 |
$email = $db->getOne($sql); |
|
788 |
|
|
789 |
if(empty($email)) |
|
790 |
{ |
|
791 |
show_message('您还未绑定邮箱地址!', array( |
|
792 |
'去绑定邮箱', "返回账户安全中心" |
|
793 |
), array( |
|
794 |
'security.php?act=email_binding', 'security.php' |
|
795 |
), 'info'); |
|
796 |
} |
|
797 |
|
|
798 |
$_SESSION[VT_EMAIL_VALIDATE] = $email; |
|
799 |
|
|
800 |
// 释放变量 |
|
801 |
$_SESSION['security_validate'] = false; |
|
802 |
|
|
803 |
$smarty->assign('action', 'email_validate'); |
|
804 |
$smarty->assign('step', 'step_1'); |
|
805 |
$smarty->assign('email', encrypt_email($email)); |
|
806 |
|
|
807 |
$smarty->display('user_security.dwt'); |
|
808 |
} |
|
809 |
|
|
810 |
/** |
|
811 |
* 验证邮箱 |
|
812 |
*/ |
|
813 |
function action_do_email_validate () |
|
814 |
{ |
|
815 |
// 获取全局变量 |
|
816 |
$_LANG = $GLOBALS['_LANG']; |
|
817 |
$smarty = $GLOBALS['smarty']; |
|
818 |
$db = $GLOBALS['db']; |
|
819 |
$ecs = $GLOBALS['ecs']; |
|
820 |
|
|
821 |
// // 检查是否通过安全验证 |
|
822 |
// if($_SESSION['security_validate'] != true) |
|
823 |
// { |
|
824 |
// exit(json_encode(array('error' => 1, 'content' => '非法操作', 'url' => ''))); |
|
825 |
// } |
|
826 |
|
|
827 |
/* 开启验证码检查 */ |
|
828 |
if(((intval($_CFG['captcha']) & CAPTCHA_REGISTER) && gd_version() > 0) || TRUE) |
|
829 |
{ |
|
830 |
if(empty($_POST['captcha'])) |
|
831 |
{ |
|
832 |
exit(json_encode(array( |
|
833 |
'error' => 1, 'content' => $_LANG['invalid_captcha'], 'url' => '' |
|
834 |
))); |
|
835 |
} |
|
836 |
|
|
837 |
/* 检查验证码 */ |
|
838 |
include_once ('includes/cls_captcha.php'); |
|
839 |
|
|
840 |
$captcha = new captcha(); |
|
841 |
|
|
842 |
if(! $captcha->check_word(trim($_POST['captcha']))) |
|
843 |
{ |
|
844 |
exit(json_encode(array( |
|
845 |
'error' => 1, 'content' => $_LANG['invalid_captcha'], 'url' => '' |
|
846 |
))); |
|
847 |
} |
|
848 |
} |
|
849 |
|
|
850 |
require_once (ROOT_PATH . 'includes/lib_passport.php'); |
|
851 |
|
|
852 |
$email = trim($_SESSION[VT_EMAIL_VALIDATE]); |
|
853 |
$email_code = ! empty($_POST['email_code']) ? trim($_POST['email_code']) : ''; |
|
854 |
|
|
855 |
$result = validate_email_code($email, $email_code); |
|
856 |
|
|
857 |
if($result == 1) |
|
858 |
{ |
|
859 |
exit(json_encode(array( |
|
860 |
'error' => 1, 'content' => $_LANG['msg_email_blank'], 'url' => '' |
|
861 |
))); |
|
862 |
} |
|
863 |
else if($result == 2) |
|
864 |
{ |
|
865 |
exit(json_encode(array( |
|
866 |
'error' => 1, 'content' => $_LANG['msg_email_format'], 'url' => '' |
|
867 |
))); |
|
868 |
} |
|
869 |
else if($result == 3) |
|
870 |
{ |
|
871 |
exit(json_encode(array( |
|
872 |
'error' => 1, 'content' => $_LANG['msg_email_code_blank'], 'url' => '' |
|
873 |
))); |
|
874 |
} |
|
875 |
else if($result == 4) |
|
876 |
{ |
|
877 |
exit(json_encode(array( |
|
878 |
'error' => 1, 'content' => $_LANG['invalid_email_code'], 'url' => '' |
|
879 |
))); |
|
880 |
} |
|
881 |
else if($result == 5) |
|
882 |
{ |
|
883 |
exit(json_encode(array( |
|
884 |
'error' => 1, 'content' => $_LANG['invalid_email_code'], 'url' => '' |
|
885 |
))); |
|
886 |
} |
|
887 |
|
|
888 |
$user_name = $_SESSION['user_name']; |
|
889 |
|
|
890 |
$result = $GLOBALS['user']->edit_user(array( |
|
891 |
'username' => $user_name, 'email' => $email, 'email_validated' => 1 |
|
892 |
)); |
|
893 |
|
|
894 |
if($result == false) |
|
895 |
{ |
|
896 |
exit(json_encode(array( |
|
897 |
'error' => 1, 'content' => '邮箱地址验证失败,请重新尝试', 'url' => '' |
|
898 |
))); |
|
899 |
} |
|
900 |
else |
|
901 |
{ |
|
902 |
// 验证完成 |
|
903 |
$_SESSION['security_validate'] = false; |
|
904 |
|
|
905 |
exit(json_encode(array( |
|
906 |
'error' => 0, 'content' => '', 'url' => '' |
|
907 |
))); |
|
908 |
} |
|
909 |
} |
|
910 |
|
|
911 |
/** |
|
912 |
* 验证邮箱完成 |
|
913 |
*/ |
|
914 |
function action_email_validate_success () |
|
915 |
{ |
|
916 |
// 获取全局变量 |
|
917 |
$_LANG = $GLOBALS['_LANG']; |
|
918 |
$smarty = $GLOBALS['smarty']; |
|
919 |
$db = $GLOBALS['db']; |
|
920 |
$ecs = $GLOBALS['ecs']; |
|
921 |
$user_id = $GLOBALS['user_id']; |
|
922 |
|
|
923 |
// 检查是否通过安全验证 |
|
924 |
if($_SESSION['security_validate'] != true) |
|
925 |
{ |
|
926 |
header('Location: security.php'); |
|
927 |
} |
|
928 |
|
|
929 |
$smarty->assign('action', 'email_validate'); |
|
930 |
$smarty->assign('step', 'step_2'); |
|
931 |
|
|
932 |
// 释放变量 |
|
933 |
$_SESSION['security_validate'] = false; |
|
934 |
|
|
935 |
$smarty->display('user_security.dwt'); |
|
936 |
} |
|
937 |
|
|
938 |
/** |
|
939 |
* 修改邮箱,重新绑定 |
|
940 |
*/ |
|
941 |
function action_email_reset () |
|
942 |
{ |
|
943 |
} |
|
944 |
|
|
945 |
/** |
|
946 |
* 取消绑定邮箱 |
|
947 |
*/ |
|
948 |
function action_email_unbinding () |
|
949 |
{ |
|
950 |
} |
|
951 |
|
|
952 |
/** |
|
953 |
* 绑定手机号 |
|
954 |
*/ |
|
955 |
function action_mobile_binding () |
|
956 |
{ |
|
957 |
// 获取全局变量 |
|
958 |
$_LANG = $GLOBALS['_LANG']; |
|
959 |
$smarty = $GLOBALS['smarty']; |
|
960 |
$db = $GLOBALS['db']; |
|
961 |
$ecs = $GLOBALS['ecs']; |
|
962 |
$user_id = $GLOBALS['user_id']; |
|
963 |
|
|
964 |
// 获取验证方式 |
|
965 |
$validate_types = get_validate_types($user_id); |
|
966 |
$smarty->assign('validate_types', $validate_types); |
|
967 |
|
|
968 |
$smarty->assign('step', 'step_1'); |
|
969 |
|
|
970 |
$smarty->display('user_security.dwt'); |
|
971 |
} |
|
972 |
|
|
973 |
/** |
|
974 |
* 绑定邮箱 |
|
975 |
*/ |
|
976 |
function action_to_mobile_binding () |
|
977 |
{ |
|
978 |
// 获取全局变量 |
|
979 |
$_LANG = $GLOBALS['_LANG']; |
|
980 |
$smarty = $GLOBALS['smarty']; |
|
981 |
$db = $GLOBALS['db']; |
|
982 |
$ecs = $GLOBALS['ecs']; |
|
983 |
$user_id = $GLOBALS['user_id']; |
|
984 |
|
|
985 |
if($_SESSION['security_validate'] != true) |
|
986 |
{ |
|
987 |
show_message('您还未绑定手机号码!', array( |
|
988 |
'去绑定手机号', "返回账户安全中心" |
|
989 |
), array( |
|
990 |
'security.php?act=mobile_binding', 'security.php' |
|
991 |
), 'info'); |
|
992 |
} |
|
993 |
|
|
994 |
// 获取验证方式 |
|
995 |
$smarty->assign('step', 'step_2'); |
|
996 |
$smarty->assign('action', 'mobile_binding'); |
|
997 |
|
|
998 |
$smarty->display('user_security.dwt'); |
|
999 |
} |
|
1000 |
|
|
1001 |
/** |
|
1002 |
* 绑定手机 |
|
1003 |
*/ |
|
1004 |
function action_do_mobile_binding () |
|
1005 |
{ |
|
1006 |
// 获取全局变量 |
|
1007 |
$_LANG = $GLOBALS['_LANG']; |
|
1008 |
$smarty = $GLOBALS['smarty']; |
|
1009 |
$db = $GLOBALS['db']; |
|
1010 |
$ecs = $GLOBALS['ecs']; |
|
1011 |
|
|
1012 |
// 检查是否通过安全验证 |
|
1013 |
if($_SESSION['security_validate'] != true) |
|
1014 |
{ |
|
1015 |
exit(json_encode(array( |
|
1016 |
'error' => 1, 'content' => '非法操作', 'url' => '' |
|
1017 |
))); |
|
1018 |
} |
|
1019 |
|
|
1020 |
require_once (ROOT_PATH . 'includes/lib_passport.php'); |
|
1021 |
|
|
1022 |
$mobile = trim($_SESSION[VT_MOBILE_VALIDATE]); |
|
1023 |
$mobile_code = ! empty($_POST['mobile_code']) ? trim($_POST['mobile_code']) : ''; |
|
1024 |
|
|
1025 |
// 如果Session中没有验证邮箱地址那么提示验证码错误 |
|
1026 |
if(! isset($_POST['mobile']) || empty($_POST['mobile'])) |
|
1027 |
{ |
|
1028 |
exit(json_encode(array( |
|
1029 |
'error' => 1, 'content' => $_LANG['msg_mobile_phone_blank'], 'url' => '' |
|
1030 |
))); |
|
1031 |
} |
|
1032 |
else if(! isset($mobile) || empty($mobile)) |
|
1033 |
{ |
|
1034 |
exit(json_encode(array( |
|
1035 |
'error' => 1, 'content' => $_LANG['invalid_mobile_phone_code'], 'url' => '' |
|
1036 |
))); |
|
1037 |
} |
|
1038 |
else if($_POST['mobile'] != $mobile) |
|
1039 |
{ |
|
1040 |
exit(json_encode(array( |
|
1041 |
'error' => 1, 'content' => $_LANG['mobile_phone_changed'], 'url' => '' |
|
1042 |
))); |
|
1043 |
} |
|
1044 |
|
|
1045 |
$result = validate_mobile_code($mobile, $mobile_code); |
|
1046 |
|
|
1047 |
if($result == 1) |
|
1048 |
{ |
|
1049 |
exit(json_encode(array( |
|
1050 |
'error' => 1, 'content' => $_LANG['msg_mobile_phone_blank'], 'url' => '' |
|
1051 |
))); |
|
1052 |
} |
|
1053 |
else if($result == 2) |
|
1054 |
{ |
|
1055 |
exit(json_encode(array( |
|
1056 |
'error' => 1, 'content' => $_LANG['msg_mobile_phone_format'], 'url' => '' |
|
1057 |
))); |
|
1058 |
} |
|
1059 |
else if($result == 3) |
|
1060 |
{ |
|
1061 |
exit(json_encode(array( |
|
1062 |
'error' => 1, 'content' => $_LANG['msg_mobile_phone_code_blank'], 'url' => '' |
|
1063 |
))); |
|
1064 |
} |
|
1065 |
else if($result == 4) |
|
1066 |
{ |
|
1067 |
exit(json_encode(array( |
|
1068 |
'error' => 1, 'content' => $_LANG['invalid_mobile_phone_code'], 'url' => '' |
|
1069 |
))); |
|
1070 |
} |
|
1071 |
else if($result == 5) |
|
1072 |
{ |
|
1073 |
exit(json_encode(array( |
|
1074 |
'error' => 1, 'content' => $_LANG['invalid_mobile_phone_code'], 'url' => '' |
|
1075 |
))); |
|
1076 |
} |
|
1077 |
|
|
1078 |
$user_name = $_SESSION['user_name']; |
|
1079 |
|
|
1080 |
$result = $GLOBALS['user']->edit_user(array( |
|
1081 |
'username' => $user_name, 'mobile_phone' => $mobile, 'mobile_validated' => 1 |
|
1082 |
)); |
|
1083 |
|
|
1084 |
if($result == false) |
|
1085 |
{ |
|
1086 |
exit(json_encode(array( |
|
1087 |
'error' => 1, 'content' => '绑定手机号码失败,请重新尝试', 'url' => '' |
|
1088 |
))); |
|
1089 |
} |
|
1090 |
else |
|
1091 |
{ |
|
1092 |
// 设置为第二步 |
|
1093 |
$_SESSION['security_validate'] = true; |
|
1094 |
|
|
1095 |
exit(json_encode(array( |
|
1096 |
'error' => 0, 'content' => '', 'url' => '' |
|
1097 |
))); |
|
1098 |
} |
|
1099 |
} |
|
1100 |
|
|
1101 |
/** |
|
1102 |
* 绑定邮箱成功 |
|
1103 |
*/ |
|
1104 |
function action_mobile_binding_success () |
|
1105 |
{ |
|
1106 |
// 获取全局变量 |
|
1107 |
$_LANG = $GLOBALS['_LANG']; |
|
1108 |
$smarty = $GLOBALS['smarty']; |
|
1109 |
$db = $GLOBALS['db']; |
|
1110 |
$ecs = $GLOBALS['ecs']; |
|
1111 |
$user_id = $GLOBALS['user_id']; |
|
1112 |
|
|
1113 |
// 检查是否通过安全验证 |
|
1114 |
if($_SESSION['security_validate'] != true) |
|
1115 |
{ |
|
1116 |
header('Location: security.php'); |
|
1117 |
} |
|
1118 |
|
|
1119 |
$smarty->assign('action', 'mobile_binding'); |
|
1120 |
$smarty->assign('step', 'step_3'); |
|
1121 |
|
|
1122 |
// 释放变量 |
|
1123 |
$_SESSION['security_validate'] = false; |
|
1124 |
|
|
1125 |
$smarty->display('user_security.dwt'); |
|
1126 |
} |
|
1127 |
|
|
1128 |
/** |
|
1129 |
* 验证手机 |
|
1130 |
*/ |
|
1131 |
function action_mobile_validate () |
|
1132 |
{ |
|
1133 |
// 获取全局变量 |
|
1134 |
$_LANG = $GLOBALS['_LANG']; |
|
1135 |
$smarty = $GLOBALS['smarty']; |
|
1136 |
$db = $GLOBALS['db']; |
|
1137 |
$ecs = $GLOBALS['ecs']; |
|
1138 |
$user_id = $GLOBALS['user_id']; |
|
1139 |
|
|
1140 |
$sql = "select mobile_phone from " . $ecs->table('users') . " where user_name = '" . $_SESSION['user_name'] . "'"; |
|
1141 |
|
|
1142 |
$mobile = $db->getOne($sql); |
|
1143 |
|
|
1144 |
if(empty($mobile)) |
|
1145 |
{ |
|
1146 |
show_message('您还未绑定手机号,请先绑定!', '绑定手机号', 'security.php?act=mobile_binding', 'info'); |
|
1147 |
} |
|
1148 |
|
|
1149 |
$_SESSION[VT_MOBILE_VALIDATE] = $mobile; |
|
1150 |
|
|
1151 |
// 释放变量 |
|
1152 |
$_SESSION['security_validate'] = false; |
|
1153 |
|
|
1154 |
$smarty->assign('action', 'mobile_validate'); |
|
1155 |
$smarty->assign('step', 'step_1'); |
|
1156 |
$smarty->assign('mobile', encrypt_mobile($mobile)); |
|
1157 |
|
|
1158 |
$smarty->display('user_security.dwt'); |
|
1159 |
} |
|
1160 |
|
|
1161 |
/** |
|
1162 |
* 验证手机 |
|
1163 |
*/ |
|
1164 |
function action_do_mobile_validate () |
|
1165 |
{ |
|
1166 |
// 获取全局变量 |
|
1167 |
$_LANG = $GLOBALS['_LANG']; |
|
1168 |
$smarty = $GLOBALS['smarty']; |
|
1169 |
$db = $GLOBALS['db']; |
|
1170 |
$ecs = $GLOBALS['ecs']; |
|
1171 |
|
|
1172 |
// // 检查是否通过安全验证 |
|
1173 |
// if($_SESSION['security_validate'] != true) |
|
1174 |
// { |
|
1175 |
// exit(json_encode(array('error' => 1, 'content' => '非法操作', 'url' => ''))); |
|
1176 |
// } |
|
1177 |
|
|
1178 |
/* 开启验证码检查 */ |
|
1179 |
if(((intval($_CFG['captcha']) & CAPTCHA_REGISTER) && gd_version() > 0) || TRUE) |
|
1180 |
{ |
|
1181 |
if(empty($_POST['captcha'])) |
|
1182 |
{ |
|
1183 |
exit(json_encode(array( |
|
1184 |
'error' => 1, 'content' => $_LANG['invalid_captcha'], 'url' => '' |
|
1185 |
))); |
|
1186 |
} |
|
1187 |
|
|
1188 |
/* 检查验证码 */ |
|
1189 |
include_once ('includes/cls_captcha.php'); |
|
1190 |
|
|
1191 |
$captcha = new captcha(); |
|
1192 |
|
|
1193 |
if(! $captcha->check_word(trim($_POST['captcha']))) |
|
1194 |
{ |
|
1195 |
exit(json_encode(array( |
|
1196 |
'error' => 1, 'content' => $_LANG['invalid_captcha'], 'url' => '' |
|
1197 |
))); |
|
1198 |
} |
|
1199 |
} |
|
1200 |
|
|
1201 |
require_once (ROOT_PATH . 'includes/lib_passport.php'); |
|
1202 |
|
|
1203 |
$mobile_phone = $_SESSION[VT_MOBILE_VALIDATE]; |
|
1204 |
$mobile_code = ! empty($_POST['mobile_code']) ? trim($_POST['mobile_code']) : ''; |
|
1205 |
|
|
1206 |
$result = validate_mobile_code($mobile_phone, $mobile_code); |
|
1207 |
|
|
1208 |
if($result == 1) |
|
1209 |
{ |
|
1210 |
exit(json_encode(array( |
|
1211 |
'error' => 1, 'content' => $_LANG['msg_mobile_phone_blank'], 'url' => '' |
|
1212 |
))); |
|
1213 |
} |
|
1214 |
else if($result == 2) |
|
1215 |
{ |
|
1216 |
exit(json_encode(array( |
|
1217 |
'error' => 1, 'content' => $_LANG['msg_mobile_phone_format'], 'url' => '' |
|
1218 |
))); |
|
1219 |
} |
|
1220 |
else if($result == 3) |
|
1221 |
{ |
|
1222 |
exit(json_encode(array( |
|
1223 |
'error' => 1, 'content' => $_LANG['msg_mobile_phone_code_blank'], 'url' => '' |
|
1224 |
))); |
|
1225 |
} |
|
1226 |
else if($result == 4) |
|
1227 |
{ |
|
1228 |
exit(json_encode(array( |
|
1229 |
'error' => 1, 'content' => $_LANG['invalid_mobile_phone_code'], 'url' => '' |
|
1230 |
))); |
|
1231 |
} |
|
1232 |
else if($result == 5) |
|
1233 |
{ |
|
1234 |
exit(json_encode(array( |
|
1235 |
'error' => 1, 'content' => $_LANG['invalid_mobile_phone_code'], 'url' => '' |
|
1236 |
))); |
|
1237 |
} |
|
1238 |
|
|
1239 |
$user_name = $_SESSION['user_name']; |
|
1240 |
|
|
1241 |
$result = $GLOBALS['user']->edit_user(array( |
|
1242 |
'username' => $user_name, 'mobile_phone' => $mobile_phone, 'mobile_validated' => 1 |
|
1243 |
)); |
|
1244 |
|
|
1245 |
if($result == false) |
|
1246 |
{ |
|
1247 |
exit(json_encode(array( |
|
1248 |
'error' => 1, 'content' => '手机号码验证失败,请重新尝试', 'url' => '' |
|
1249 |
))); |
|
1250 |
} |
|
1251 |
else |
|
1252 |
{ |
|
1253 |
// 验证完成 |
|
1254 |
$_SESSION['security_validate'] = false; |
|
1255 |
|
|
1256 |
exit(json_encode(array( |
|
1257 |
'error' => 0, 'content' => '', 'url' => '' |
|
1258 |
))); |
|
1259 |
} |
|
1260 |
} |
|
1261 |
|
|
1262 |
/** |
|
1263 |
* 验证邮箱完成 |
|
1264 |
*/ |
|
1265 |
function action_mobile_validate_success () |
|
1266 |
{ |
|
1267 |
// 获取全局变量 |
|
1268 |
$_LANG = $GLOBALS['_LANG']; |
|
1269 |
$smarty = $GLOBALS['smarty']; |
|
1270 |
$db = $GLOBALS['db']; |
|
1271 |
$ecs = $GLOBALS['ecs']; |
|
1272 |
$user_id = $GLOBALS['user_id']; |
|
1273 |
|
|
1274 |
// 检查是否通过安全验证 |
|
1275 |
if($_SESSION['security_validate'] != true) |
|
1276 |
{ |
|
1277 |
header('Location: security.php'); |
|
1278 |
} |
|
1279 |
|
|
1280 |
$smarty->assign('action', 'mobile_validate'); |
|
1281 |
$smarty->assign('step', 'step_2'); |
|
1282 |
|
|
1283 |
// 释放变量 |
|
1284 |
$_SESSION['security_validate'] = false; |
|
1285 |
|
|
1286 |
$smarty->display('user_security.dwt'); |
|
1287 |
} |
|
1288 |
|
|
1289 |
/** |
|
1290 |
* 修改手机号,重新绑定 |
|
1291 |
*/ |
|
1292 |
function action_mobile_reset () |
|
1293 |
{ |
|
1294 |
// 获取全局变量 |
|
1295 |
$_LANG = $GLOBALS['_LANG']; |
|
1296 |
$smarty = $GLOBALS['smarty']; |
|
1297 |
$db = $GLOBALS['db']; |
|
1298 |
$ecs = $GLOBALS['ecs']; |
|
1299 |
$user_id = $GLOBALS['user_id']; |
|
1300 |
|
|
1301 |
// 获取验证方式 |
|
1302 |
$validate_types = get_validate_types($user_id); |
|
1303 |
$smarty->assign('validate_types', $validate_types); |
|
1304 |
|
|
1305 |
$smarty->assign('step', 'step_1'); |
|
1306 |
|
|
1307 |
$smarty->display('user_security.dwt'); |
|
1308 |
} |
|
1309 |
|
|
1310 |
/** |
|
1311 |
* 取消绑定手机号 |
|
1312 |
*/ |
|
1313 |
function action_mobile_unbinding () |
|
1314 |
{ |
|
1315 |
} |
|
1316 |
|
|
1317 |
/** |
|
1318 |
* 开启、修改、忘记支付密码 |
|
1319 |
*/ |
|
1320 |
function action_payment_password_reset () |
|
1321 |
{ |
|
1322 |
// 获取全局变量 |
|
1323 |
$_LANG = $GLOBALS['_LANG']; |
|
1324 |
$smarty = $GLOBALS['smarty']; |
|
1325 |
$db = $GLOBALS['db']; |
|
1326 |
$ecs = $GLOBALS['ecs']; |
|
1327 |
$user_id = $GLOBALS['user_id']; |
|
1328 |
|
|
1329 |
$sql = "SELECT is_surplus_open FROM " . $ecs->table("users") . " WHERE user_id = '" . $user_id . "' LIMIT 1"; |
|
1330 |
$is_surplus_open = $GLOBALS['db']->getOne($sql); |
|
1331 |
|
|
1332 |
// 获取验证方式 |
|
1333 |
$smarty->assign('is_surplus_open', $is_surplus_open); |
|
1334 |
|
|
1335 |
$smarty->assign('action', 'payment_password_reset'); |
|
1336 |
$smarty->assign('step', 'step_1'); |
|
1337 |
|
|
1338 |
// 获取验证方式 |
|
1339 |
$validate_types = get_validate_types($user_id); |
|
1340 |
$smarty->assign('validate_types', $validate_types); |
|
1341 |
|
|
1342 |
$smarty->display('user_security.dwt'); |
|
1343 |
} |
|
1344 |
|
|
1345 |
/** |
|
1346 |
* 开启、修改、忘记支付密码 |
|
1347 |
*/ |
|
1348 |
function action_to_payment_password_reset () |
|
1349 |
{ |
|
1350 |
// 获取全局变量 |
|
1351 |
$_LANG = $GLOBALS['_LANG']; |
|
1352 |
$smarty = $GLOBALS['smarty']; |
|
1353 |
$db = $GLOBALS['db']; |
|
1354 |
$ecs = $GLOBALS['ecs']; |
|
1355 |
$user_id = $GLOBALS['user_id']; |
|
1356 |
|
|
1357 |
if($_SESSION['security_validate'] != true) |
|
1358 |
{ |
|
1359 |
show_message('非法操作!', '返回上一页', 'security.php?act=payment_password_reset', 'info'); |
|
1360 |
} |
|
1361 |
|
|
1362 |
// 获取验证方式 |
|
1363 |
$smarty->assign('step', 'step_2'); |
|
1364 |
$smarty->assign('action', 'payment_password_reset'); |
|
1365 |
|
|
1366 |
$smarty->display('user_security.dwt'); |
|
1367 |
} |
|
1368 |
|
|
1369 |
/** |
|
1370 |
* 开启、修改、忘记支付密码 |
|
1371 |
*/ |
|
1372 |
function action_do_payment_password_reset () |
|
1373 |
{ |
|
1374 |
// 获取全局变量 |
|
1375 |
$user = $GLOBALS['user']; |
|
1376 |
$_CFG = $GLOBALS['_CFG']; |
|
1377 |
$_LANG = $GLOBALS['_LANG']; |
|
1378 |
$smarty = $GLOBALS['smarty']; |
|
1379 |
$db = $GLOBALS['db']; |
|
1380 |
$ecs = $GLOBALS['ecs']; |
|
1381 |
$user_id = $GLOBALS['user_id']; |
|
1382 |
|
|
1383 |
// 检查是否通过安全验证 |
|
1384 |
if($_SESSION['security_validate'] != true) |
|
1385 |
{ |
|
1386 |
exit(json_encode(array( |
|
1387 |
'error' => 1, 'content' => '非法操作', 'url' => '' |
|
1388 |
))); |
|
1389 |
} |
|
1390 |
|
|
1391 |
$surplus_password = empty($_POST['password']) ? '' : $_POST['password']; |
|
1392 |
|
|
1393 |
if(! empty($surplus_password)) |
|
1394 |
{ |
|
1395 |
$surplus_password = md5($surplus_password); |
|
1396 |
$sql = 'UPDATE ' . $ecs->table('users') . ' SET `surplus_password`=\'' . $surplus_password . '\',`is_surplus_open`=\'1\' WHERE `user_id`=\'' . $user_id . '\''; |
|
1397 |
$db->query($sql); |
|
1398 |
$affected_rows = $db->affected_rows(); |
|
1399 |
if($affected_rows == 1) |
|
1400 |
{ |
|
1401 |
exit(json_encode(array( |
|
1402 |
'error' => 0, 'content' => '', 'url' => '' |
|
1403 |
))); |
|
1404 |
} |
|
1405 |
else |
|
1406 |
{ |
|
1407 |
exit(json_encode(array( |
|
1408 |
'error' => 1, 'content' => '设置支付密码失败,请重新尝试', 'url' => '' |
|
1409 |
))); |
|
1410 |
} |
|
1411 |
} |
|
1412 |
else |
|
1413 |
{ |
|
1414 |
exit(json_encode(array( |
|
1415 |
'error' => 1, 'content' => '支付密码不能为空', 'url' => '' |
|
1416 |
))); |
|
1417 |
} |
|
1418 |
} |
|
1419 |
|
|
1420 |
/** |
|
1421 |
* 开启、修改、忘记支付密码 |
|
1422 |
*/ |
|
1423 |
function action_payment_password_reset_success () |
|
1424 |
{ |
|
1425 |
// 获取全局变量 |
|
1426 |
$_LANG = $GLOBALS['_LANG']; |
|
1427 |
$smarty = $GLOBALS['smarty']; |
|
1428 |
$db = $GLOBALS['db']; |
|
1429 |
$ecs = $GLOBALS['ecs']; |
|
1430 |
$user_id = $GLOBALS['user_id']; |
|
1431 |
|
|
1432 |
// 检查是否通过安全验证 |
|
1433 |
if($_SESSION['security_validate'] != true) |
|
1434 |
{ |
|
1435 |
header('Location: security.php'); |
|
1436 |
} |
|
1437 |
|
|
1438 |
$smarty->assign('action', 'payment_password_reset'); |
|
1439 |
$smarty->assign('step', 'step_3'); |
|
1440 |
|
|
1441 |
// 释放变量 |
|
1442 |
$_SESSION['security_validate'] = false; |
|
1443 |
|
|
1444 |
$smarty->display('user_security.dwt'); |
|
1445 |
} |
|
1446 |
|
|
1447 |
/** |
|
1448 |
* 关闭支付密码 |
|
1449 |
*/ |
|
1450 |
function action_payment_password_close () |
|
1451 |
{ |
|
1452 |
// 获取全局变量 |
|
1453 |
$_LANG = $GLOBALS['_LANG']; |
|
1454 |
$smarty = $GLOBALS['smarty']; |
|
1455 |
$db = $GLOBALS['db']; |
|
1456 |
$ecs = $GLOBALS['ecs']; |
|
1457 |
$user_id = $GLOBALS['user_id']; |
|
1458 |
|
|
1459 |
$sql = "SELECT is_surplus_open FROM " . $ecs->table("users") . " WHERE user_id = '" . $user_id . "' LIMIT 1"; |
|
1460 |
$is_surplus_open = $GLOBALS['db']->getOne($sql); |
|
1461 |
|
|
1462 |
$smarty->assign('is_surplus_open', $is_surplus_open); |
|
1463 |
|
|
1464 |
$smarty->assign('action', 'payment_password_close'); |
|
1465 |
$smarty->assign('step', 'step_1'); |
|
1466 |
|
|
1467 |
// 获取验证方式 |
|
1468 |
$validate_types = get_validate_types($user_id); |
|
1469 |
$smarty->assign('validate_types', $validate_types); |
|
1470 |
|
|
1471 |
$smarty->display('user_security.dwt'); |
|
1472 |
} |
|
1473 |
|
|
1474 |
function action_do_payment_password_close () |
|
1475 |
{ |
|
1476 |
$user = $GLOBALS['user']; |
|
1477 |
$_CFG = $GLOBALS['_CFG']; |
|
1478 |
$_LANG = $GLOBALS['_LANG']; |
|
1479 |
$smarty = $GLOBALS['smarty']; |
|
1480 |
$db = $GLOBALS['db']; |
|
1481 |
$ecs = $GLOBALS['ecs']; |
|
1482 |
$user_id = $GLOBALS['user_id']; |
|
1483 |
|
|
1484 |
// 检查是否通过安全验证 |
|
1485 |
if($_SESSION['security_validate'] != true) |
|
1486 |
{ |
|
1487 |
show_message('非法操作!', '返回上账户安全中心', 'security.php', 'info'); |
|
1488 |
} |
|
1489 |
|
|
1490 |
$sql = "UPDATE " . $ecs->table('users') . " SET is_surplus_open = 0, surplus_password = '' WHERE user_id = '" . $user_id . "'"; |
|
1491 |
$db->query($sql); |
|
1492 |
$affected_rows = $db->affected_rows(); |
|
1493 |
|
|
1494 |
if($affected_rows == 1) |
|
1495 |
{ |
|
1496 |
$smarty->assign('action', 'payment_password_close'); |
|
1497 |
$smarty->assign('step', 'step_2'); |
|
1498 |
|
|
1499 |
// 释放变量 |
|
1500 |
$_SESSION['security_validate'] = false; |
|
1501 |
|
|
1502 |
$smarty->display('user_security.dwt'); |
|
1503 |
} |
|
1504 |
else |
|
1505 |
{ |
|
1506 |
// 释放变量 |
|
1507 |
$_SESSION['security_validate'] = false; |
|
1508 |
show_message('关闭支付密码失败,请重新尝试', '返回上账户安全中心', 'security.php', 'info'); |
|
1509 |
} |
|
1510 |
} |
|
1511 |
|
|
1512 |
/** |
|
1513 |
* 同步会员信息到入驻商管理员表 |
|
1514 |
*/ |
|
1515 |
function action_sync_supplier () |
|
1516 |
{ |
|
1517 |
// 获取全局变量 |
|
1518 |
$_LANG = $GLOBALS['_LANG']; |
|
1519 |
$smarty = $GLOBALS['smarty']; |
|
1520 |
$db = $GLOBALS['db']; |
|
1521 |
$ecs = $GLOBALS['ecs']; |
|
1522 |
$user_id = $GLOBALS['user_id']; |
|
1523 |
|
|
1524 |
// 判断是否为商家 |
|
1525 |
$is_supplier = is_supplier($user_id); |
|
1526 |
|
|
1527 |
if(! $is_supplier) |
|
1528 |
{ |
|
1529 |
show_message('非法操作', '返回上账户安全中心', 'security.php', 'info'); |
|
1530 |
} |
|
1531 |
|
|
1532 |
// 获取验证方式 |
|
1533 |
$validate_types = get_validate_types($user_id); |
|
1534 |
$smarty->assign('validate_types', $validate_types); |
|
1535 |
|
|
1536 |
$smarty->assign('step', 'step_1'); |
|
1537 |
|
|
1538 |
$smarty->display('user_security.dwt'); |
|
1539 |
} |
|
1540 |
|
|
1541 |
function action_to_sync_supplier () |
|
1542 |
{ |
|
1543 |
// 获取全局变量 |
|
1544 |
$user = $GLOBALS['user']; |
|
1545 |
$_LANG = $GLOBALS['_LANG']; |
|
1546 |
$smarty = $GLOBALS['smarty']; |
|
1547 |
$db = $GLOBALS['db']; |
|
1548 |
$ecs = $GLOBALS['ecs']; |
|
1549 |
$user_id = $GLOBALS['user_id']; |
|
1550 |
|
|
1551 |
if($_SESSION['security_validate'] != true) |
|
1552 |
{ |
|
1553 |
show_message('非法操作!', '返回上一页', 'security.php?act=sync_supplier', 'info'); |
|
1554 |
} |
|
1555 |
|
|
1556 |
$user_info = $user->get_profile_by_id($user_id); |
|
1557 |
$user_name = $user_info['user_name']; |
|
1558 |
$email = $user_info['email']; |
|
1559 |
$mobile_phone = $user_info['mobile_phone']; |
|
1560 |
|
|
1561 |
$smarty->assign('user_name', $user_name); |
|
1562 |
$smarty->assign('email', encrypt_email($email)); |
|
1563 |
$smarty->assign('mobile_phone', encrypt_mobile($mobile_phone)); |
|
1564 |
|
|
1565 |
// 获取验证方式 |
|
1566 |
$smarty->assign('step', 'step_2'); |
|
1567 |
$smarty->assign('action', 'sync_supplier'); |
|
1568 |
|
|
1569 |
$smarty->display('user_security.dwt'); |
|
1570 |
} |
|
1571 |
|
|
1572 |
function action_do_sync_supplier () |
|
1573 |
{ |
|
1574 |
$user = $GLOBALS['user']; |
|
1575 |
$_CFG = $GLOBALS['_CFG']; |
|
1576 |
$_LANG = $GLOBALS['_LANG']; |
|
1577 |
$smarty = $GLOBALS['smarty']; |
|
1578 |
$db = $GLOBALS['db']; |
|
1579 |
$ecs = $GLOBALS['ecs']; |
|
1580 |
$user_id = $GLOBALS['user_id']; |
|
1581 |
|
|
1582 |
// 判断是否为商家 |
|
1583 |
$is_supplier = is_supplier($user_id); |
|
1584 |
|
|
1585 |
if(! $is_supplier) |
|
1586 |
{ |
|
1587 |
exit(json_encode(array( |
|
1588 |
'error' => 1, 'content' => '非法操作!', 'url' => 'security.php' |
|
1589 |
))); |
|
1590 |
} |
|
1591 |
|
|
1592 |
// 检查是否通过安全验证 |
|
1593 |
if($_SESSION['security_validate'] != true) |
|
1594 |
{ |
|
1595 |
exit(json_encode(array( |
|
1596 |
'error' => 1, 'content' => '非法操作!', 'url' => 'security.php' |
|
1597 |
))); |
|
1598 |
} |
|
1599 |
|
|
1600 |
$user_info = $user->get_profile_by_id($user_id); |
|
1601 |
$user_name = $user_info['user_name']; |
|
1602 |
$email = $user_info['email']; |
|
1603 |
$mobile_phone = $user_info['mobile_phone']; |
|
1604 |
$password = $user_info['password']; |
|
1605 |
$ec_salt = $user_info['ec_salt']; |
|
1606 |
|
|
1607 |
$values = array(); |
|
1608 |
$values[] = "user_name = '" . $user_name . "'"; |
|
1609 |
$values[] = "email = '" . $email . "'"; |
|
1610 |
$values[] = "mobile_phone = '" . $mobile_phone . "'"; |
|
1611 |
$values[] = "password = '" . $password . "'"; |
|
1612 |
$values[] = "ec_salt = '" . $ec_salt . "'"; |
|
1613 |
|
|
1614 |
$sql = "UPDATE " . $ecs->table('supplier_admin_user') . " SET " . implode(', ', $values) . " WHERE uid = '" . $user_id . "' LIMIT 1"; |
|
1615 |
|
|
1616 |
$result = $db->query($sql); |
|
1617 |
|
|
1618 |
if($result == false) |
|
1619 |
{ |
|
1620 |
$_SESSION['security_validate'] = false; |
|
1621 |
exit(json_encode(array( |
|
1622 |
'error' => 1, 'content' => '同步商家信息失败,请稍后重试!', 'url' => 'security.php' |
|
1623 |
))); |
|
1624 |
} |
|
1625 |
else |
|
1626 |
{ |
|
1627 |
exit(json_encode(array( |
|
1628 |
'error' => 0, 'content' => '', 'url' => '' |
|
1629 |
))); |
|
1630 |
} |
|
1631 |
} |
|
1632 |
|
|
1633 |
function action_sync_supplier_success () |
|
1634 |
{ |
|
1635 |
// 获取全局变量 |
|
1636 |
$_LANG = $GLOBALS['_LANG']; |
|
1637 |
$smarty = $GLOBALS['smarty']; |
|
1638 |
$db = $GLOBALS['db']; |
|
1639 |
$ecs = $GLOBALS['ecs']; |
|
1640 |
$user_id = $GLOBALS['user_id']; |
|
1641 |
|
|
1642 |
// 检查是否通过安全验证 |
|
1643 |
if($_SESSION['security_validate'] != true) |
|
1644 |
{ |
|
1645 |
header('Location: security.php'); |
|
1646 |
} |
|
1647 |
|
|
1648 |
$smarty->assign('action', 'sync_supplier'); |
|
1649 |
$smarty->assign('step', 'step_3'); |
|
1650 |
|
|
1651 |
// 释放变量 |
|
1652 |
$_SESSION['security_validate'] = false; |
|
1653 |
|
|
1654 |
$smarty->display('user_security.dwt'); |
|
1655 |
} |
|
1656 |
|
|
1657 |
/* 余额额支付密码_添加_END_ */ |
|
1658 |
function get_takegoods_orders ($user_id, $num = 10, $start = 0) |
|
1659 |
{ |
|
1660 |
$order_status = array( |
|
1661 |
'0' => '提货成功,等待发货', '1' => '确认收货', '2' => '完成' |
|
1662 |
); |
|
1663 |
/* 取得订单列表 */ |
|
1664 |
$arr = array(); |
|
1665 |
|
|
1666 |
$sql = "SELECT * " . " FROM " . $GLOBALS['ecs']->table('takegoods_order') . " WHERE user_id = '$user_id' ORDER BY rec_id DESC"; |
|
1667 |
$res = $GLOBALS['db']->SelectLimit($sql, $num, $start); |
|
1668 |
|
|
1669 |
while($row = $GLOBALS['db']->fetchRow($res)) |
|
1670 |
{ |
|
1671 |
$row['country_name'] = $GLOBALS['db']->getOne("select region_name from " . $GLOBALS['ecs']->table('region') . " where region_id='$row[country]' "); |
|
1672 |
$row['province_name'] = $GLOBALS['db']->getOne("select region_name from " . $GLOBALS['ecs']->table('region') . " where region_id='$row[province]' "); |
|
1673 |
$row['city_name'] = $GLOBALS['db']->getOne("select region_name from " . $GLOBALS['ecs']->table('region') . " where region_id='$row[city]' "); |
|
1674 |
$row['district_name'] = $GLOBALS['db']->getOne("select region_name from " . $GLOBALS['ecs']->table('region') . " where region_id='$row[district]' "); |
|
1675 |
$row['goods_url'] = build_uri('goods', array( |
|
1676 |
'gid' => $row['goods_id'] |
|
1677 |
), $row['goods_name']); |
|
1678 |
$arr[] = array( |
|
1679 |
'rec_id' => $row['rec_id'], 'tg_sn' => $row['tg_sn'], 'goods_name' => $row['goods_name'], 'address' => $row['country_name'] . $row['province_name'] . $row['city_name'] . $row['district_name'] . $row['address'], 'add_time' => local_date($GLOBALS['_CFG']['time_format'], $row['add_time']), 'order_status' => $row['order_status'], 'order_status_name' => $order_status[$row['order_status']], 'goods_url' => $row['goods_url'], 'handler' => $row['handler'] |
|
1680 |
); |
|
1681 |
} |
|
1682 |
|
|
1683 |
return $arr; |
|
1684 |
} |
|
1685 |
|
|
1686 |
/* 代码增加_end */ |
|
1687 |
/* 代码增加_start */ |
|
1688 |
function get_user_backorders ($user_id, $num = 10, $start = 0) |
|
1689 |
{ |
|
1690 |
/* 取得订单列表 */ |
|
1691 |
$arr = array(); |
|
1692 |
|
|
1693 |
$sql = "SELECT bo.*, g.goods_name " . " FROM " . $GLOBALS['ecs']->table('back_order') . " AS bo left join " . $GLOBALS['ecs']->table('goods') . " AS g " . " on bo.goods_id=g.goods_id " . " WHERE user_id = '$user_id' ORDER BY add_time DESC"; |
|
1694 |
$res = $GLOBALS['db']->SelectLimit($sql, $num, $start); |
|
1695 |
|
|
1696 |
while($row = $GLOBALS['db']->fetchRow($res)) |
|
1697 |
{ |
|
1698 |
|
|
1699 |
$row['order_time'] = local_date($GLOBALS['_CFG']['time_format'], $row['add_time']); |
|
1700 |
$row['refund_money_1'] = price_format($row['refund_money_1'], false); |
|
1701 |
|
|
1702 |
$row['goods_url'] = build_uri('goods', array( |
|
1703 |
'gid' => $row['goods_id'] |
|
1704 |
), $row['goods_name']); |
|
1705 |
$row['status_back_1'] = $row['status_back']; |
|
1706 |
$row['status_back'] = $GLOBALS['_LANG']['bos'][(($row['back_type'] == 4 && $row['status_back'] != 8) ? $row['back_type'] : $row['status_back'])] . ' - ' . $GLOBALS['_LANG']['bps'][$row['status_refund']]; |
|
1707 |
|
|
1708 |
$arr[] = $row; |
|
1709 |
} |
|
1710 |
|
|
1711 |
return $arr; |
|
1712 |
} |
|
1713 |
|
|
1714 |
function mc_random ($length, $char_str = 'abcdefghijklmnopqrstuvwxyz0123456789') |
|
1715 |
{ |
|
1716 |
$hash = ''; |
|
1717 |
$chars = $char_str; |
|
1718 |
$max = strlen($chars); |
|
1719 |
for($i = 0; $i < $length; $i ++) |
|
1720 |
{ |
|
1721 |
$hash .= substr($chars, (rand(0, 1000) % $max), 1); |
|
1722 |
} |
|
1723 |
return $hash; |
|
1724 |
} |
|
1725 |
|
|
1726 |
/* 代码增加2014-12-23 by _end */ |
|
1727 |
function get_user_yue ($user_id) |
|
1728 |
{ |
|
1729 |
$sql = "SELECT user_money FROM " . $GLOBALS['ecs']->table('users') . "WHERE user_id = '$user_id'"; |
|
1730 |
$res = $GLOBALS['db']->getOne($sql); |
|
1731 |
return $res; |
|
1732 |
} |
|
1733 |
|
|
1734 |
function get_inv_complete_address ($order) |
|
1735 |
{ |
|
1736 |
if($order['inv_type'] == 'normal_invoice') |
|
1737 |
{ |
|
1738 |
$address = trim(get_inv_complete_region($order['order_id'], $order['inv_type'])); |
|
1739 |
if(empty($address)) |
|
1740 |
{ |
|
1741 |
return $order['address']; |
|
1742 |
} |
|
1743 |
else |
|
1744 |
{ |
|
1745 |
return '[' . $address . '] ' . $order['address']; |
|
1746 |
} |
|
1747 |
} |
|
1748 |
elseif($order['inv_type'] == 'vat_invoice') |
|
1749 |
{ |
|
1750 |
$address = trim(get_inv_complete_region($order['order_id'], $order['inv_type'])); |
|
1751 |
if(empty($address)) |
|
1752 |
{ |
|
1753 |
return $order['inv_consignee_address']; |
|
1754 |
} |
|
1755 |
else |
|
1756 |
{ |
|
1757 |
return '[' . $address . '] ' . $order['inv_consignee_address']; |
|
1758 |
} |
|
1759 |
} |
|
1760 |
else |
|
1761 |
{ |
|
1762 |
return ''; |
|
1763 |
} |
|
1764 |
} |
|
1765 |
|
|
1766 |
function get_inv_complete_region ($order_id, $inv_type) |
|
1767 |
{ |
|
1768 |
if(! empty($order_id)) |
|
1769 |
{ |
|
1770 |
if($inv_type == 'normal_invoice') |
|
1771 |
{ |
|
1772 |
$sql = "SELECT concat(IFNULL(c.region_name, ''), ' ', IFNULL(p.region_name, ''), " . "' ', IFNULL(t.region_name, ''), ' ', IFNULL(d.region_name, '')) AS region " . "FROM " . $GLOBALS['ecs']->table('order_info') . " AS o " . "LEFT JOIN " . $GLOBALS['ecs']->table('region') . " AS c ON o.country = c.region_id " . "LEFT JOIN " . $GLOBALS['ecs']->table('region') . " AS p ON o.province = p.region_id " . "LEFT JOIN " . $GLOBALS['ecs']->table('region') . " AS t ON o.city = t.region_id " . "LEFT JOIN " . $GLOBALS['ecs']->table('region') . " AS d ON o.district = d.region_id " . "WHERE o.order_id = '$order_id'"; |
|
1773 |
return $GLOBALS['db']->getOne($sql); |
|
1774 |
} |
|
1775 |
elseif($inv_type == 'vat_invoice') |
|
1776 |
{ |
|
1777 |
$sql = "SELECT concat(IFNULL(p.region_name, ''), " . "' ', IFNULL(t.region_name, ''), ' ', IFNULL(d.region_name, '')) AS region " . "FROM " . $GLOBALS['ecs']->table('order_info') . " AS o " . "LEFT JOIN " . $GLOBALS['ecs']->table('region') . " AS p ON o.inv_consignee_province = p.region_id " . "LEFT JOIN " . $GLOBALS['ecs']->table('region') . " AS t ON o.inv_consignee_city = t.region_id " . "LEFT JOIN " . $GLOBALS['ecs']->table('region') . " AS d ON o.inv_consignee_district = d.region_id " . "WHERE o.order_id = '$order_id'"; |
|
1778 |
return $GLOBALS['db']->getOne($sql); |
|
1779 |
} |
|
1780 |
else |
|
1781 |
{ |
|
1782 |
return ' '; |
|
1783 |
} |
|
1784 |
} |
|
1785 |
else |
|
1786 |
{ |
|
1787 |
return ' '; |
|
1788 |
} |
|
1789 |
} |
|
1790 |
|
|
1791 |
/** |
|
1792 |
* 随机生成指定长度的数字 |
|
1793 |
* |
|
1794 |
* @param number $length |
|
1795 |
* @return number |
|
1796 |
*/ |
|
1797 |
function rand_number ($length = 6) |
|
1798 |
{ |
|
1799 |
if($length < 1) |
|
1800 |
{ |
|
1801 |
$length = 6; |
|
1802 |
} |
|
1803 |
|
|
1804 |
$min = 1; |
|
1805 |
for($i = 0; $i < $length - 1; $i ++) |
|
1806 |
{ |
|
1807 |
$min = $min * 10; |
|
1808 |
} |
|
1809 |
$max = $min * 10 - 1; |
|
1810 |
|
|
1811 |
return rand($min, $max); |
|
1812 |
} |
|
1813 |
|
|
1814 |
/** |
|
1815 |
* 获取身份验证方式 |
|
1816 |
* |
|
1817 |
* @param unknown $user_id |
|
1818 |
* @return array |
|
1819 |
*/ |
|
1820 |
function get_validate_types ($user_id) |
|
1821 |
{ |
|
1822 |
$smarty = $GLOBALS['smarty']; |
|
1823 |
$action = isset($_REQUEST['act']) ? trim($_REQUEST['act']) : ''; |
|
1824 |
|
|
1825 |
// 获取用户信息,判断用户是否验证了手机、邮箱 |
|
1826 |
// $sql = "select user_id, user_name, email, mobile_phone from " . |
|
1827 |
// $GLOBALS['ecs']->table('users') . " where user_id = '" . $user_id . "'"; |
|
1828 |
// $row = $GLOBALS['db']->getRow($sql); |
|
1829 |
$user = $GLOBALS['user']; |
|
1830 |
|
|
1831 |
$user_info = $user->get_profile_by_id($user_id); |
|
1832 |
|
|
1833 |
if($user_info == false) |
|
1834 |
{ |
|
1835 |
show_message('您输入的账户名不存在,请核对后重新输入。', $_LANG['relogin_lnk'], 'findPwd.php', 'error'); |
|
1836 |
} |
|
1837 |
|
|
1838 |
$email = $user_info['email']; |
|
1839 |
$mobile_phone = $user_info['mobile_phone']; |
|
1840 |
$email_validate = $user_info['email_validated']; |
|
1841 |
$mobile_validate = $user_info['mobile_validated']; |
|
1842 |
|
|
1843 |
$validate_types = array(); |
|
1844 |
|
|
1845 |
if(isset($mobile_phone) && ! empty($mobile_phone) && $mobile_validate == 1) |
|
1846 |
{ |
|
1847 |
|
|
1848 |
$_SESSION[VT_MOBILE_VALIDATE] = $mobile_phone; |
|
1849 |
|
|
1850 |
// 处理手机号,不让前台显示 |
|
1851 |
$mobile_phone = encrypt_mobile($mobile_phone); |
|
1852 |
|
|
1853 |
$validate_types[] = array( |
|
1854 |
'type' => 'mobile_phone', 'name' => '已验证的手机号码', 'value' => $mobile_phone |
|
1855 |
); |
|
1856 |
} |
|
1857 |
if(isset($email) && ! empty($email) && $email_validate == 1) |
|
1858 |
{ |
|
1859 |
|
|
1860 |
$_SESSION[VT_EMAIL_VALIDATE] = $email; |
|
1861 |
|
|
1862 |
$email = encrypt_email($email); |
|
1863 |
|
|
1864 |
$validate_types[] = array( |
|
1865 |
'type' => 'email', 'name' => '邮箱', 'value' => $email |
|
1866 |
); |
|
1867 |
} |
|
1868 |
if(count($validate_types) == 0) |
|
1869 |
{ |
|
1870 |
if($action == 'password_reset') |
|
1871 |
{ |
|
1872 |
if(empty($mobile_phone) && empty($email) ){ |
|
1873 |
show_message('系统检测发现您还绑定任何手机号码或者邮箱,账户安装存在风险,建议您先绑定手机号码或者邮箱以提高您的账户安全级别!', array('绑定手机号码', '绑定邮箱'), array('security.php?act=mobile_binding', 'security.php?act=email_binding'), 'error'); |
|
1874 |
}else{ |
|
1875 |
if($mobile_validate == 0 && $email_validate == 0){ |
|
1876 |
if(!empty($mobile_phone) && empty($email)){ |
|
1877 |
show_message('系统检测发现您的账户安装存在风险,建议您先验证手机号码或者绑定邮箱以提高您的账户安全级别!', array('验证手机号码', '绑定邮箱'), array('security.php?act=mobile_validate', 'security.php?act=email_binding'), 'error'); |
|
1878 |
}else if(empty($mobile_phone) && !empty($email)){ |
|
1879 |
show_message('系统检测发现您的账户安装存在风险,建议您先绑定手机号码或者验证邮箱以提高您的账户安全级别!', array('绑定手机号码', '验证邮箱'), array('security.php?act=mobile_binding', 'security.php?act=email_validate'), 'error'); |
|
1880 |
}else{ |
|
1881 |
show_message('系统检测发现您的账户安装存在风险,建议您先验证手机号码或者邮箱以提高您的账户安全级别!', array('验证手机号码', '验证邮箱'), array('security.php?act=mobile_validate', 'security.php?act=email_validate'), 'error'); |
|
1882 |
} |
|
1883 |
} |
|
1884 |
} |
|
1885 |
} |
|
1886 |
else if($action == 'mobile_binding' && empty($mobile_phone)) |
|
1887 |
{ |
|
1888 |
$smarty->assign('first_binding', '1'); |
|
1889 |
$_SESSION['security_validate'] = true; |
|
1890 |
action_to_mobile_binding(); |
|
1891 |
exit; |
|
1892 |
} |
|
1893 |
else if($action == 'email_binding' && empty($email)) |
|
1894 |
{ |
|
1895 |
$smarty->assign('first_binding', '1'); |
|
1896 |
$_SESSION['security_validate'] = true; |
|
1897 |
action_to_email_binding(); |
|
1898 |
exit; |
|
1899 |
} |
|
1900 |
} |
|
1901 |
|
|
1902 |
if(count($validate_types) == 0) |
|
1903 |
{ |
|
1904 |
$validate_types[] = array( |
|
1905 |
'type' => 'password', 'name' => '登录密码验证', 'value' => $_SESSION['user_name'] |
|
1906 |
); |
|
1907 |
} |
|
1908 |
|
|
1909 |
return $validate_types; |
|
1910 |
} |
|
1911 |
|
|
1912 |
function encrypt_email ($email) |
|
1913 |
{ |
|
1914 |
if(empty($email)) |
|
1915 |
{ |
|
1916 |
return $email; |
|
1917 |
} |
|
1918 |
|
|
1919 |
// 处理手机号,不让前台显示 |
|
1920 |
$email_head = substr($email, 0, strpos($email, '@')); |
|
1921 |
$email_domain = substr($email, strpos($email, '@')); |
|
1922 |
|
|
1923 |
if(strlen($email_head) == 1) |
|
1924 |
{ |
|
1925 |
$email = substr($email_head, 0, 1) . '*****' . $email_domain; |
|
1926 |
} |
|
1927 |
else if(strlen($email_head) <= 4) |
|
1928 |
{ |
|
1929 |
$email = substr($email_head, 0, 1) . '*****' . substr($email_head, - 1) . $email_domain; |
|
1930 |
} |
|
1931 |
else if(strlen($email_head) <= 7) |
|
1932 |
{ |
|
1933 |
$email = substr($email_head, 0, 2) . '*****' . substr($email_head, - 2) . $email_domain; |
|
1934 |
} |
|
1935 |
else |
|
1936 |
{ |
|
1937 |
$email = substr($email_head, 0, 3) . '*****' . substr($email_head, - 3) . $email_domain; |
|
1938 |
} |
|
1939 |
return $email; |
|
1940 |
} |
|
1941 |
|
|
1942 |
function encrypt_mobile ($mobile) |
|
1943 |
{ |
|
1944 |
if(empty($mobile)) |
|
1945 |
{ |
|
1946 |
return $mobile; |
|
1947 |
} |
|
1948 |
// 处理手机号,不让前台显示 |
|
1949 |
$mobile = substr($mobile, 0, 3) . '*****' . substr($mobile, - 3); |
|
1950 |
return $mobile; |
|
1951 |
} |
|
1952 |
|
|
1953 |
// 判断当前用户是否为商家用户 |
|
1954 |
function is_supplier ($user_id) |
|
1955 |
{ |
|
1956 |
$db = $GLOBALS['db']; |
|
1957 |
$ecs = $GLOBALS['ecs']; |
|
1958 |
|
|
1959 |
$db_name = $GLOBALS['user']->db_name; |
|
1960 |
$prefix = $GLOBALS['user']->prefix; |
|
1961 |
|
|
1962 |
$sql = "SELECT count(*) FROM information_schema.TABLES WHERE table_name = '" . $prefix . "supplier_admin_user' AND TABLE_SCHEMA = '" . $db_name . "'"; |
|
1963 |
|
|
1964 |
$count = $db->getOne($sql); |
|
1965 |
|
|
1966 |
if($count > 0) |
|
1967 |
{ |
|
1968 |
$sql = "select count(*) from " . $ecs->table('supplier_admin_user') . " where uid = " . $user_id; |
|
1969 |
$count = $db->getOne($sql); |
|
1970 |
if($count > 0) |
|
1971 |
{ |
|
1972 |
return true; |
|
1973 |
} |
|
1974 |
} |
|
1975 |
|
|
1976 |
return false; |
|
1977 |
} |
|
1978 |
|
|
1979 |
?> |