third-bind.ctrl.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * [WeEngine System] Copyright (c) 2014 WE7.CC
  4. * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
  5. */
  6. defined('IN_IA') or exit('Access Denied');
  7. load()->model('user');
  8. $do = safe_gpc_string($_GPC['do']);
  9. $dos = array('display', 'validate_mobile', 'bind_mobile');
  10. $do = in_array($do, $dos) ? $do : 'display';
  11. if (in_array($do, array('validate_mobile', 'bind_mobile'))) {
  12. $user_table = table('users');
  13. $user_profile = $user_table->userProfile($_W['uid']);
  14. $mobile = trim($_GPC['mobile']);
  15. $mobile_exists = $user_table->userProfileMobile($mobile);
  16. if (empty($mobile)) {
  17. iajax(-1, '手机号不能为空');
  18. }
  19. if (!preg_match(REGULAR_MOBILE, $mobile)) {
  20. iajax(-1, '手机号格式不正确');
  21. }
  22. if (empty($type) && !empty($mobile_exists)) {
  23. iajax(-1, '手机号已存在');
  24. }
  25. }
  26. if ($do == 'validate_mobile') {
  27. iajax(0, '本地校验成功');
  28. }
  29. if ($do == 'bind_mobile') {
  30. if ($_W['isajax'] && $_W['ispost']) {
  31. $bind_info = OAuth2Client::create('mobile')->bind();
  32. if (is_error($bind_info)) {
  33. iajax(-1, $bind_info['message']);
  34. }
  35. iajax(0, '绑定成功', url('user/profile/bind'));
  36. } else {
  37. iajax(-1, '非法请求');
  38. }
  39. }
  40. if ($do == 'display') {
  41. $support_bind_urls = user_support_urls();
  42. $setting_sms_sign = setting_load('site_sms_sign');
  43. $bind_sign = !empty($setting_sms_sign['site_sms_sign']['register']) ? $setting_sms_sign['site_sms_sign']['register'] : '';
  44. }
  45. template('user/third-bind');