Exemple #1
0
 /**
  * 
  * 重置密码发送验证码接口 ...
  */
 public function rePasswordSendSms()
 {
     $memberId = 0;
     if ($memberName = trimall($this->input['member_name'])) {
         if (hg_check_email_format($memberName)) {
             $this->errorOutput('请填写正确的用户名');
         }
         if (hg_verify_mobile($memberName)) {
             $memberId = $this->Members->get_member_id($memberName, false, false, 'shouji');
             if ($memberId) {
                 $isMobile = 1;
                 $platform_id = $memberName;
             }
         }
         if (!$memberId) {
             $memberId = $this->Members->get_member_id($memberName, false, false, 'm2o');
         }
         if (!$memberId) {
             $memberId = $this->Members->get_member_id($memberName, false, false, 'uc');
         }
         if (!$memberId) {
             $this->errorOutput(NO_MEMBER);
         }
         if (!$isMobile) {
             if ($mobile = trimall($this->input['mobile'])) {
                 $checkBind = new check_Bind();
                 $platform_id = $checkBind->check_Bind($memberId, 'shouji');
                 if ($platform_id && $platform_id != $mobile) {
                     $this->errorOutput('对不起,您填写的手机号不正确,请重新输入!');
                 } elseif (empty($platform_id)) {
                     $this->errorOutput('对不起,您需找回的帐号未绑定手机号!');
                 }
             } else {
                 $this->errorOutput('请输入正确的手机号,并获取验证码!');
             }
         }
         $this->send_sms();
     } else {
         $this->errorOutput(NO_MEMBER_NAME);
     }
 }
Exemple #2
0
 public function reset_password()
 {
     $this->check_verifycode();
     $verifycode = trim($this->input['verifycode']);
     $member_name = trim($this->input['member_name']);
     $password = trim($this->input['password']);
     $type = isset($this->input['type']) ? intval($this->input['type']) : -1;
     //验证码类型
     $identifierUserSystem = new identifierUserSystem();
     $identifier = $identifierUserSystem->setIdentifier((int) $this->input['identifier'])->checkIdentifier();
     //多用户系统
     if (!$verifycode) {
         $this->errorOutput(VERIFY_NULL);
     }
     if (!$password) {
         $this->errorOutput(NO_NEW_PASSWORD);
     }
     if ($type == '-1' && hg_check_email_format($member_name)) {
         $member_type = 'email';
         $type = 1;
     } elseif ($type == '-1' && hg_verify_mobile($member_name)) {
         $member_type = 'shouji';
         $type = 0;
     } else {
         if ($type == 0) {
             $member_type = 'shouji';
         } else {
             if ($type == 1) {
                 $member_type = 'email';
             }
         }
     }
     $condition = " AND platform_id = '" . $member_name . "' AND mb.type='{$member_type}' AND mb.identifier=" . $identifier . "";
     $field = 'mb.member_id,platform_id,mb.type';
     $bind_info = $this->mMember->get_bind_info($condition, $field);
     $bind_info = $bind_info[0];
     if (empty($bind_info)) {
         $this->errorOutput(NO_MEMBER);
     }
     $data = array();
     $data['member_id'] = $bind_info['member_id'];
     //根据验证码修改密码、
     if (!$type) {
         if ($this->mSmsServer->get_verifycode_info($member_name, $verifycode)) {
             //验证成功之后删除
             $this->mSmsServer->mobile_verifycode_delete($member_name, $verifycode);
             if ($this->settings['ucenter']['open']) {
                 $_member_name = $member_name;
                 $is_password = $this->mMember->uc_user_edit($_member_name, '', $password, '', 1);
             }
             if ($password && ($is_password >= 0 || !$this->settings['ucenter']['open'])) {
                 $salt = hg_generate_salt();
                 $data['salt'] = $salt;
                 $md5_password = md5(md5($password) . $salt);
                 $data['password'] = $md5_password;
             } elseif ($password && ($is_password < 0 && $this->settings['ucenter']['open'])) {
                 $this->errorOutput('UC密码同步失败');
             }
             if ($this->mMember->update($data)) {
                 $bind_info['status'] = 1;
                 $this->addItem($bind_info);
                 $this->output();
             }
         } else {
             $this->errorOutput(MOBILE_VERIFY_FAILED);
         }
     } else {
         if ($this->memberverifycode->get_verifycode_info($member_name, $verifycode, $type, $action = 1)) {
             //验证成功之后删除
             $this->memberverifycode->verifycode_delete($member_name, $verifycode, $type, $action = 1);
             if ($this->settings['ucenter']['open']) {
                 $_member_name = $member_name;
                 $is_password = $this->mMember->uc_user_edit($_member_name, '', $password, '', 1);
             }
             if ($password && ($is_password > 0 || !$this->settings['ucenter']['open'])) {
                 $salt = hg_generate_salt();
                 $data['salt'] = $salt;
                 $md5_password = md5(md5($password) . $salt);
                 $data['password'] = $md5_password;
             } elseif ($password && ($is_password < 0 && $this->settings['ucenter']['open'])) {
                 $this->errorOutput('UC密码同步失败');
             }
             if ($this->mMember->update($data)) {
                 $bind_info['status'] = 1;
                 $this->addItem($bind_info);
                 $this->output();
             }
         } else {
             $this->errorOutput(EMAIL_VERIFY_FAILED);
         }
     }
 }
Exemple #3
0
 public function uc_user_edit($username, $oldpw, $newpw, $email, $ignoreoldpw = 0, $questionid = '', $answer = '')
 {
     if (empty($this->input['member_name'])) {
         $this->input['member_name'] = $username;
     }
     $check_Bind = new check_Bind();
     if (hg_check_email_format($username)) {
         $type = 'email';
         $member_id = $check_Bind->bind_to_memberid($username, $type, true);
         //如果用户名为邮箱则检测邮箱类型
         if ($member_id) {
             $sql = 'SELECT member_name FROM ' . DB_PREFIX . 'member AS m WHERE member_id = \'' . $member_id . '\'';
             $row = $this->db->query_first($sql);
             $this->input['member_name'] = $username = $row['member_name'];
         }
     } else {
         if (hg_verify_mobile($username)) {
             $type = 'shouji';
             $member_id = $check_Bind->bind_to_memberid($username, $type, true);
             //如果用户名为邮箱则检测邮箱类型
             if ($member_id) {
                 $sql = 'SELECT member_name FROM ' . DB_PREFIX . 'member AS m WHERE member_id = \'' . $member_id . '\'';
                 $row = $this->db->query_first($sql);
                 $this->input['member_name'] = $username = $row['member_name'];
             }
         }
     }
     if (empty($member_id)) {
         $member_id = $check_Bind->bind_to_memberid($username, 'uc');
         //优先检测uc类型
         $type = 'uc';
     }
     if (empty($member_id)) {
         $member_id = $check_Bind->bind_to_memberid($username, 'm2o');
         $type = 'm2o';
     }
     $is_ucid = 0;
     if ($member_id) {
         $is_ucid = $check_Bind->check_uc($member_id, $type);
     }
     include_once CUR_CONF_PATH . 'uc_client/client.php';
     $uc_userinfo = uc_get_user($this->input['member_name']);
     if ($is_ucid && $is_ucid == $uc_userinfo[0]) {
         return uc_user_edit($username, $oldpw, $newpw, $email, $ignoreoldpw, $questionid, $answer);
     }
     return 0;
     //UC信息未修改
 }
Exemple #4
0
 /**
  * 检查必填等限制项
  * @param unknown_type $forms 提交的表单
  * @param unknown_type $value
  */
 private function check_limit($forms, $value, $id)
 {
     $nums = 0;
     if ($value['is_required'] && !$forms[$value['type'] . '_' . $value['id']]) {
         if ($value['type'] == 'standard' && $value['form_type'] == 5 && $_FILES['file_' . $value['id']] || $value['type'] == 'standard' && $value['form_type'] == 6) {
         } else {
             $this->errorOutput($value['name'] . '不能为空!');
         }
     }
     if ($value['is_unique'] && $forms[$value['type'] . '_' . $value['id']]) {
         if ($this->check_exist($forms[$value['type'] . '_' . $value['id']], $id, $value['id'])) {
             $this->errorOutput($value['name'] . ' ' . $forms[$value['type'] . '_' . $value['id']] . ' 已经存在!');
         }
     }
     if (is_array($forms[$value['type'] . '_' . $value['id']]) && !array_filter($forms[$value['type'] . '_' . $value['id']]) && $value['is_required']) {
         $this->errorOutput($value['name'] . '不能为空!');
     }
     if ($value['char_num']) {
         $num = $this->get_char_num(trim($forms[$value['type'] . '_' . $value['id']]));
         if ($num > $value['char_num']) {
             $this->errorOutput($value['name'] . '字符数不能超过' . $value['char_num'] . '个!');
         }
     }
     if ($forms[$value['type'] . '_' . $value['id']] && ($value['fixed_id'] == 3 && $value['type'] == 'fixed') || $value['member_field'] == 'mobile') {
         $check_mobile = hg_verify_mobile_fb($forms[$value['type'] . '_' . $value['id']]);
         if (!$check_mobile && $forms[$value['type'] . '_' . $value['id']]) {
             $this->errorOutput(MOBILE_ERROR);
         }
     }
     if ($forms[$value['type'] . '_' . $value['id']] && ($value['fixed_id'] == 2 && $value['type'] == 'fixed') || $value['member_field'] == 'email') {
         $check_email = hg_check_email_format($forms[$value['type'] . '_' . $value['id']]);
         if (!$check_email) {
             $this->errorOutput(EMAIL_ERROR);
         }
     }
     if ($value['form_type'] == 3 && $value['type'] == 'standard') {
         if (is_array($forms[$value['type'] . '_' . $value['id']])) {
             $nums = count(array_filter($forms[$value['type'] . '_' . $value['id']]));
         } else {
             $nums = count(array_filter(explode(',', $forms[$value['type'] . '_' . $value['id']])));
         }
         if ($nums) {
             if ($value['limit_type'] == 1 && $nums < $value['op_num'] && $nums > 0) {
                 $this->errorOutput($value['name'] . '至少要选' . $value['op_num'] . '项!');
             }
             if ($value['limit_type'] == 2 && $nums > $value['op_num']) {
                 $this->errorOutput($value['name'] . '至多只能选' . $value['op_num'] . '项!');
             }
             if ($value['limit_type'] == 3 && $nums != $value['op_num']) {
                 $this->errorOutput($value['name'] . '只能且必须选' . $value['op_num'] . '项!');
             }
             if ($value['min'] && $nums < $value['min'] && $nums > 0) {
                 $this->errorOutput($value['name'] . '至少要选' . $value['min'] . '项!');
             }
             if ($value['max'] && $nums > $value['max']) {
                 $this->errorOutput($value['name'] . '至多只能选' . $value['max'] . '项!');
             }
         }
     }
     if ($value['fixed_id'] == 5 && $forms[$value['type'] . '_' . $value['id']]) {
         if (!($input_time = strtotime($forms[$value['type'] . '_' . $value['id']]))) {
             $this->errorOutput($value['name'] . '不是合法的日期格式');
         }
         $_start_time = strtotime($value['start_time'] . '-01-01 00:00:00');
         $_end_time = strtotime($value['end_time'] . '-12-31 23:59:59');
         if ($_start_time && $input_time < $_start_time or $_end_time && $input_time > $_end_time) {
             $this->errorOutput($value['name'] . '超出时间范围!');
         }
     }
 }
Exemple #5
0
 private function checkRegMemberNameError()
 {
     !$this->memberName && $this->errorOutput(NO_MEMBER_NAME);
     $identifierUserSystem = new identifierUserSystem();
     $identifier = $identifierUserSystem->setIdentifier((int) $this->input['identifier'])->checkIdentifier();
     //多用户系统
     if ($this->memberName && $this->type == 'm2o' && is_numeric($this->memberName)) {
         $this->errorOutput(MEMBER_NO_NUM);
     } else {
         if ($this->memberName && $this->type == 'm2o' && ($memberNameStatus = $this->mMember->member_name_auth($this->memberName)) != 1) {
             $ret_verify = $this->mMember->verify_member_name($this->memberName, 0, $identifier);
             switch ($ret_verify) {
                 case -4:
                     $this->errorOutput(MEMBER_NAME_EXCEEDS_MAX);
                     break;
                 case -5:
                     $this->errorOutput(USERNAME_BELOW_MINIMUM);
                     break;
                 case -6:
                     $this->errorOutput(MEMBER_NAME_ERROR);
                     break;
                 default:
                     break;
             }
         }
     }
     if ($this->memberName && $this->type == 'shouji' && !hg_verify_mobile($this->memberName)) {
         $this->errorOutput(MOBILE_NUMBER_FORMAT_ERROR);
     }
     if ($this->memberName && $this->type == 'email' && !hg_check_email_format($this->memberName)) {
         $this->errorOutput(EMAIL_FORMAT_ERROR);
     }
 }
Exemple #6
0
 /**
  *
  * 检测邮箱状态 ...
  * @param string $email
  */
 public function check_reg_mail($email, $member_id = 0, $identifier = 0)
 {
     $checkemail = 0;
     //邮箱未传值,未检测
     if ($email) {
         $checkemail = 1;
         //开始检测
         if (!hg_check_email_format($email)) {
             $checkemail = -4;
         }
         if ($checkemail > 0 && $this->settings['ucenter']['open'] && !$identifier) {
             $mMember = new member();
             $ucid = $mMember->checkUc($member_id);
             include_once CUR_CONF_PATH . 'uc_client/client.php';
             if ($ucid) {
                 $ucInfo = uc_get_user($ucid, 1);
                 if ($ucInfo && $ucInfo[2] == $email) {
                     return 1;
                 }
             }
             $checkemail = uc_user_checkemail($email);
         }
         if ($checkemail > 0) {
             if ($member_id) {
                 $where = ' AND member_id!=' . $member_id;
             }
             $sql = 'SELECT count(*) as total FROM ' . DB_PREFIX . 'member_bind WHERE 1 ' . $where . ' AND platform_id=\'' . $email . '\' AND identifier = ' . $identifier;
             $result = $this->db->query_first($sql);
             if ($result['total']) {
                 $checkemail = -6;
             }
         }
     }
     return $checkemail;
 }
Exemple #7
0
 /**
 *  member_id 会员id
 		platform_id 第三方平台会员id char
 		nick_name 昵称
 		type 会员类型
 		type_name 会员类型名称
 		avatar_url 头像地址
 		bind_time 绑定时间
 		bind_ip 绑定ip
 * Enter description here ...
 */
 public function bind()
 {
     $memberUpdataField = array();
     //主表修改字段
     $member_id = intval($this->user['user_id']);
     if (!$member_id) {
         $this->errorOutput(USER_NO_LOGIN);
     }
     $platform_id = trim($this->input['platform_id']);
     $password = $this->input['password'] ? trim($this->input['password']) : '';
     $type = trim($this->input['type']);
     $platformInfo = $this->Members->get_platform_name($type);
     $identifierUserSystem = new identifierUserSystem();
     $identifier = $identifierUserSystem->setIdentifier((int) $this->input['identifier'])->checkIdentifier();
     //多用户系统
     if (in_array($type, array('m2o', 'uc')) || empty($platformInfo)) {
         $this->errorOutput(BIND_MEMBER_TYPE_ERROR);
     } else {
         if (!$platformInfo['status']) {
             $this->errorOutput(BIND_MEMBER_TYPE_CLOSE);
         }
     }
     $type_name = $platformInfo['name'];
     $device_token = $this->Members->check_device_token(trim($this->input['device_token']));
     $udid = $this->Members->check_udid(trim($this->input['uuid']));
     //唯一设备号
     if ($device_token === 0) {
         $this->errorOutput(ERROR_DEVICE_TOKEN);
     }
     if ($udid === 0) {
         $this->errorOutput(ERROR_UDID);
     }
     $avatar_url = trim($this->input['avatar_url']);
     $ip = hg_getip();
     //验证会员是否存在
     $condition = " AND m.member_id=" . $member_id;
     $left_join = 'LEFT JOIN ' . DB_PREFIX . 'member_bind as mb ON m.member_id=mb.member_id AND m.type=mb.type';
     $ret_member = $this->mMember->get_member_info($condition, 'm.*,mb.nick_name', $left_join, 0);
     $ret_member = $ret_member[0];
     if (empty($ret_member)) {
         $this->errorOutput(NO_MEMBER);
     }
     $callback_sql = '';
     if (!empty($ret_member['nick_name'])) {
         $nick_name = $ret_member['nick_name'];
     } else {
         $nick_name = $platform_id;
     }
     if (empty($avatar_url)) {
         $avatar = array('host' => '', 'dir' => '', 'filepath' => '', 'filename' => '');
         if (is_serialized_string($ret_member['avatar'])) {
             $avatar = unserialize($ret_member['avatar']);
         }
         $avatar_url = $avatar['host'] . $avatar['dir'] . $avatar['filepath'] . $avatar['filename'];
     } else {
         $avatar_url = trim($this->input['avatar_url']);
     }
     if (hg_check_email_format($platform_id)) {
         $sql = 'SELECT platform_id FROM ' . DB_PREFIX . 'member_bind WHERE platform_id="' . $platform_id . '" AND identifier=' . $identifier;
         $result = $this->db->query_first($sql);
         if ($result) {
             $this->errorOutput(EMAIL_HAS_BINDED);
         }
         if (defined(BIND_EMAIL_NEED_VERIFYCODE)) {
             $email_verifycode = trim($this->input['email_verifycode']);
             if (!$email_verifycode) {
                 $this->errorOutput(VERIFY_NULL);
             }
             if ($this->memberverifycode->get_verifycode_info($platform_id, $email_verifycode, 1, $action = 1)) {
                 //验证成功之后删除
                 $this->memberverifycode->verifycode_delete($platform_id, $email_verifycode, 1, $action = 1);
             } else {
                 $this->errorOutput(VERIFY_FAILED);
             }
         }
         $type = 'email';
         $type_name = '邮箱';
     } elseif (hg_verify_mobile($platform_id)) {
         $type = 'shouji';
         $type_name = '手机';
     }
     $need_password_type = array('shouji', 'm2o', 'email');
     if (in_array($type, $need_password_type) && $password) {
         //随机串
         $salt = hg_generate_salt();
         //密码md5
         $md5_password = md5(md5($password) . $salt);
         $memberUpdataField['password'] = $md5_password;
         $memberUpdataField['salt'] = $salt;
     } elseif (in_array($type, $need_password_type) && empty($ret_member['password'])) {
         $this->errorOutput(NO_PASSWORD);
         //如果绑定类型为手机,M2O,email,但是主表未设置密码,则需要设置密码
     }
     if (!$member_id) {
         $this->errorOutput(NO_MEMBER_ID);
     }
     if (!$platform_id) {
         $this->errorOutput(NO_EXTERNAL_MEMBER_ID);
     }
     if (!$nick_name) {
         $this->errorOutput(NO_NICKNAME);
     }
     if (!$type) {
         $this->errorOutput(NO_EXTERNAL_TYPE);
     }
     //验证手机验证码
     if ($type == 'shouji') {
         $mobile_verifycode = trim($this->input['mobile_verifycode']);
         if (!$mobile_verifycode) {
             $this->errorOutput(MOBILE_NOT_VERIFY);
         }
         $mobile = $platform_id;
         //简单验证手机号格式
         if (!hg_verify_mobile($mobile)) {
             $this->errorOutput(MOBILE_NUMBER_FORMAT_ERROR);
         }
         //验证码
         $verifycode = $this->mSmsServer->get_verifycode_info($mobile, $mobile_verifycode);
         if (empty($verifycode)) {
             $this->errorOutput(VERIFY_FAILED);
         }
         //删除验证码
         $this->mSmsServer->mobile_verifycode_delete($mobile, $mobile_verifycode);
         if (TIMENOW > $verifycode['create_time'] + VERIFYCODE_EXPIRED_TIME) {
             $this->errorOutput(VERIFY_EXPIRED);
         }
     }
     $condition = " AND mb.platform_id = '" . $platform_id . "' AND mb.type = '" . $type . "' AND mb.identifier=" . $identifier;
     $_bind = $this->mMember->get_bind_info($condition);
     if ($_bind[0] && $member_id != $_bind[0]['member_id']) {
         $this->errorOutput(ACCOUNT_BIND);
         //验证此账户类型是否已被其他用户绑定
     }
     $condition = " AND mb.member_id = '" . $member_id . "' AND mb.type = '" . $type . "' AND mb.identifier=" . $identifier;
     $bind = $this->mMember->get_bind_info($condition);
     $bind = $bind[0];
     if ($bind) {
         $this->errorOutput(BIND_TYPE_EXISTS);
         //强制用户解除已有该类型绑定,防止原先绑定信息未经验证被串改!
     }
     $avatar_array = $this->mMember->update_avatar($avatar_url, $bind, $member_id);
     if ($avatar_array && is_array($avatar_array)) {
         $sql = 'UPDATE ' . DB_PREFIX . 'member SET avatar =\'' . daddslashes(serialize($avatar_array)) . '\' WHERE member_id=' . intval($member_id);
         $this->db->query($sql);
     }
     $bind_data = array('member_id' => $member_id, 'platform_id' => $platform_id, 'nick_name' => $nick_name, 'type' => $type, 'type_name' => $type_name, 'avatar_url' => $avatar_url, 'identifier' => $identifier, 'reg_device_token' => $device_token, 'reg_udid' => $udid);
     if (empty($bind)) {
         $checkBind = new check_Bind();
         $isUc = 0;
         $isUc = $checkBind->check_Bind($member_id, 'uc');
         if (empty($isUc)) {
             $isUc = $checkBind->check_uc($member_id);
             if ($isUc) {
                 $bind_data['inuc'] = $isUc;
             }
         }
         //新增绑定表
         $bind_data['bind_time'] = TIMENOW;
         $bind_data['bind_ip'] = $ip;
         $ret_bind = $this->mMember->bind_create($bind_data);
         if (empty($ret_bind)) {
             $this->errorOutput(BIND_DATA_ADD_FAILED);
         }
     } else {
         //更新绑定表
         $ret_bind = $this->mMember->bind_update($bind_data);
         if (empty($ret_bind)) {
             $this->errorOutput(BIND_DATA_UPDATE_FAILED);
         }
     }
     if ($type == 'shouji') {
         $memberUpdataField['mobile'] = $platform_id;
     } elseif ($type == 'email') {
         $memberUpdataField['email'] = $platform_id;
     }
     if ($ret_member['type'] == 'email' || $ret_member['type'] == 'shouji') {
         $memberUpdataField['member_name'] = $platform_id;
     }
     $return = array('member_id' => $member_id, 'member_name' => in_array($ret_member['member_name'], array('m2o', 'uc')) ? $ret_member['member_name'] : $platform_id, 'type' => $type, 'nick_name' => $nick_name, 'is_exist_password' => $ret_member['password'] ? 1 : 0);
     if ($memberUpdataField && $this->mMember->update($memberUpdataField, array('member_id' => $member_id))) {
         if ($this->settings['ucenter']['open']) {
             if ($ret_member['type'] == 'm2o' && $type == 'email') {
                 $this->mMember->uc_user_edit($ret_member['member_name'], '', $password, $platform_id, 1);
             }
         }
     }
     $this->addItem($return);
     $this->output();
 }
Exemple #8
0
 protected function verify_email_format($email)
 {
     return hg_check_email_format($email);
 }
Exemple #9
0
 /**
  * 生成邮箱验证码并发送接口
  * $mail 邮箱
  *
  * 返回
  * success
  */
 private function generate_link_email()
 {
     if (!$this->settings['App_email']) {
         $this->errorOutput('邮箱验证码发送失败!请联系管理员');
     }
     if (empty($this->email)) {
         $this->errorOutput(NO_EMAIL);
     } else {
         if (!hg_check_email_format($this->email)) {
             $this->errorOutput(EMAIL_FORMAT_ERROR);
         }
     }
     if (!$this->appuniqueid) {
         $this->errorOutput('发送配置标识不能为空');
     }
     include ROOT_PATH . 'lib/class/email.class.php';
     $Oemail = new email();
     $params = array('to' => $this->email, 'appuniqueid' => $this->appuniqueid);
     if ($this->subject) {
         $params['subject'] = $this->subject;
     } elseif ($this->tspace) {
         $params['tspace'] = $this->tspace;
     }
     if ($this->body) {
         $params['body'] = $this->body;
     } elseif ($this->bspace) {
         $params['bspace'] = $this->bspace;
     }
     $sendInfo = $Oemail->addEmailQueue($params);
     $data = array('email' => $this->email, 'type' => $this->type, 'status' => 0, 'token' => $this->token, 'create_time' => TIMENOW, 'expire_time' => $this->_expire_time);
     $res = $this->email_token->create($data);
     return $data;
 }