uc.ctrl.php 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. $dos = array('home', 'profile', 'uc');
  8. $do = in_array($do, $dos) ? $do : 'home';
  9. $foo = ($_GPC['foo'] == 'bind' || $_GPC['foo'] == '') ? 'bind' : 'unbind';
  10. $setting = uni_setting($_W['uniacid'], array('uc'));
  11. if($foo == 'bind') {
  12. if($setting['uc']['status'] == '1') {
  13. $uc = $setting['uc'];
  14. $sql = 'SELECT * FROM ' . tablename('mc_mapping_ucenter') . ' WHERE `uniacid`=:uniacid AND `uid`=:uid';
  15. $pars = array();
  16. $pars[':uniacid'] = $_W['uniacid'];
  17. $pars[':uid'] = $_W['member']['uid'];
  18. $mapping = pdo_fetch($sql, $pars);
  19. if(empty($mapping)) {
  20. $op = trim($_GPC['op']);
  21. if($op == 'yes') {
  22. if(checksubmit('submit')) {
  23. $username = trim($_GPC['username']) ? trim($_GPC['username']) : message('请填写用户名!', '', 'error');
  24. $password = trim($_GPC['password']) ? trim($_GPC['password']) : message('请填写密码!', '', 'error');
  25. mc_init_uc();
  26. $data = uc_user_login($username, $password);
  27. if($data[0] < 0) {
  28. if($data[0] == -1) message('用户不存在,或者被删除!', '', 'error');
  29. elseif ($data[0] == -2) message('密码错误!', '', 'error');
  30. elseif ($data[0] == -3) message('安全提问错误!', '', 'error');
  31. }
  32. $exist = pdo_fetch('SELECT * FROM ' . tablename('mc_mapping_ucenter') . ' WHERE `uniacid`=:uniacid AND `centeruid`=:centeruid', array(':uniacid' => $_W['uniacid'], 'centeruid' => $data[0]));
  33. if(empty($exist)) {
  34. pdo_insert('mc_mapping_ucenter', array('uniacid' => $_W['uniacid'], 'uid' => $_W['member']['uid'], 'centeruid' => $data[0]));
  35. message('绑定UC账号成功!', url('mc/mc/home'), 'success');
  36. } else {
  37. message('该UC账号已绑定过,请使用其他账号绑定!', '', 'error');
  38. }
  39. }
  40. } elseif($op == 'no') {
  41. if(checksubmit('submit')) {
  42. $username = trim($_GPC['username']) ? trim($_GPC['username']) : message('请填写用户名!', '', 'error');
  43. $password = trim($_GPC['password']) ? trim($_GPC['password']) : message('请填写密码!', '', 'error');
  44. $repassword = trim($_GPC['repassword']) ? trim($_GPC['repassword']) : message('请填写确认密码!', '', 'error');
  45. if($password != $repassword) {message('两次密码输入不一致!', '', 'error');}
  46. $email = trim($_GPC['email']) ? trim($_GPC['email']) : message('请填写邮箱!', '', 'error');
  47. mc_init_uc();
  48. $uid = uc_user_register($username, $password, $email);
  49. if($uid < 0) {
  50. if($uid == -1) message('用户名不合法!', '', 'error');
  51. elseif ($uid == -2) message('包含不允许注册的词语!', '', 'error');
  52. elseif ($uid == -3) message('用户名已经存在!', '', 'error');
  53. elseif ($uid == -4) message('邮箱格式错误!', '', 'error');
  54. elseif ($uid == -5) message('邮箱不允许注册!', '', 'error');
  55. elseif ($uid == -6) message('邮箱已经被注册!', '', 'error');
  56. } else {
  57. if($_W['member']['email'] == '') {
  58. mc_update($_W['member']['uid'],array('email' => $email));
  59. }
  60. pdo_insert('mc_mapping_ucenter', array('uniacid' => $_W['uniacid'], 'uid' => $_W['member']['uid'], 'centeruid' => $uid));
  61. message('绑定UC账号成功!', url('mc/mc/home'), 'success');
  62. }
  63. }
  64. }
  65. template('mc/bind');
  66. exit;
  67. } else {
  68. message('已绑定UC账号,您可以尝试解绑定后重新绑定UC账号!', '', 'error');
  69. }
  70. } else {
  71. message('系统尚未开启UC!', '', 'success');
  72. }
  73. } else {
  74. $result = pdo_delete('mc_mapping_ucenter', array('uid' => $_W['member']['uid'], 'uniacid' => $_W['uniacid']), ' AND ');
  75. if($result === false) {
  76. message('解绑定UC账号失败!', referer(), 'error');
  77. } else {
  78. message('解绑定UC账号成功!', referer(), 'success');
  79. }
  80. }
  81. exit('Error: -1');