public function checkUc($member_id) { $ucid = 0; $checkBind = new check_Bind(); $ucid = $checkBind->check_uc($member_id); if (!$ucid) { $ucid = $checkBind->check_uc($member_id, 'uc'); } return $ucid; }
public function detail() { $this->verify_content_prms(array('_action' => 'show')); $member_id = trim($this->input['id']); if (!$member_id) { $this->errorOutput(NO_MEMBER_ID); } $member = $this->mMember->detail($member_id); if (empty($member)) { $this->errorOutput(NO_MEMBER); } $member_medal = $this->Members->get_member_medal(array($member_id)); $member['medal_id'] = @array_keys($member_medal[$member_id]); $member['medal_id'] = $member['medal_id'] ? $member['medal_id'] : array(); if (empty($member['graname'])) { $grade_info = $this->Members->updategrade($member_id); if ($grade_info && is_array($grade_info)) { foreach ($grade_info as $key => $val) { $member[$key] = $val; } } } if (empty($member['groupname'])) { $group_info = $this->Members->updategroup($member_id, 0); if ($group_info && is_array($group_info)) { foreach ($group_info as $key => $val) { $member[$key] = $val; } } } if (!empty($member) && $member_id) { unset($member['password'], $member['salt']); // 积分信息 $credits = $this->Members->membercredit($member_id, $is_on = 1); // 黑名单信息 $blacklist = $this->Members->blacklist($member_id); //绑定信息 $bind = $this->mMember->get_bind_info(" AND mb.member_id = " . $member_id); //获取邀请人 $invite_user = $this->get_invite_user($member_id); //扩展信息 $member_info = $this->mMemberInfo->show(" AND member_id = " . $member_id); } //扩展字段表信息处理 if (intval($this->input['app_id'])) { $extension = $this->mMemberInfo->extendDataProcessByApp($member_info, 1, $this->input['app_id']); } else { $extension = $this->mMemberInfo->extendDataProcess($member_info); } $return = $member; if ($bind && is_array($bind)) { $is_flag = true; foreach ($bind as $bin) { if ($is_flag) { $return['nick_name'] = $bin['nick_name']; $return['nick_name'] && ($is_flag = false); } } } if (!$return['nick_name']) { $return['nick_name'] = $return['member_name']; } $check_bind = new check_Bind(); $inuc = $check_bind->check_uc($member['member_id'], $member['type']); $tmp_return = $this->mMember->getIdentifierName(array($return)); //获取会员加入的群组 if ($this->input['need_group_count']) { $groupCount = $this->im->getGroupCountBymemberId($member_id); } //获取好友粉丝数量 if ($this->input['need_friend_count']) { //好友的 $condition = " AND (member_id=" . $member_id . " AND relation_type=3) or (friend_id=" . $member_id . " AND relation_type=3)"; $friend_num = $this->friend->count($condition); //获取粉丝数 $condition = " AND (member_id=" . $member_id . " AND relation_type<>1) or (friend_id=" . $member_id . " AND relation_type<>2)"; $fans_num = $this->friend->count($condition); } $return = $tmp_return[0]; $return['inuc'] = $inuc; $return['isNameUpdate'] = $this->mMember->isMemberNameUpdate($member['member_id'], 1); $return['inviteuser'] = $invite_user ? $invite_user : array(); $return['credit'] = $credits[$member['member_id']]; $return['blacklist'] = $blacklist[$member['member_id']]; $return['bind'] = $bind; $return['extension'] = $extension; $return['groupCount'] = $groupCount['total'] ? $groupCount['total'] : 0; $return['friendCount'] = $friend_num['total'] ? $friend_num['total'] : 0; $return['fansCount'] = $fans_num['total'] ? $fans_num['total'] : 0; $this->addItem($return); $this->output(); }
/** * 验证会员 * $member_name 会员名 * $password 密码 * $type 登陆类型 * $appid * $appkey */ public function verify_member() { try { $encrypt = $this->input['encrypt'] ? intval($this->input['encrypt']) : 0; $platform_id = trim($this->input['platform_id']); $password = $encrypt ? passport_decrypt(trim($this->input['password']), CUSTOM_APPKEY) : trim($this->input['password']); $type = trim($this->input['type']); $_type = trim($this->input['_type']); //防止本地M2O同步至UC后,再次验证本地密码BUG。 $identifierUserSystem = new identifierUserSystem(); $identifier = $identifierUserSystem->setIdentifier((int) $this->input['identifier'])->checkIdentifier(); //多用户系统 $ip = hg_getip(); $need_password_type = array('shouji', 'm2o', 'email'); $appid = intval($this->input['appid']); $appkey = trim($this->input['appkey']); //会员名 if (!$platform_id) { $this->errorOutput(NO_MEMBER_NAME); } //密码 if (!$password && in_array($type, $need_password_type)) { $this->errorOutput(NO_PASSWORD); } $condition = " AND mb.platform_id = '" . $platform_id . "' AND mb.type = '" . $type . "' AND mb.identifier = '" . $identifier . '\''; $_bind = $this->mMember->get_bind_info($condition); $bind = array(); if (is_array($_bind) && count($_bind) > 1) { foreach ($_bind as $v) { if ($v['inuc'] > 0) { $bind = $v; break; } } } elseif (is_array($_bind)) { $bind = $_bind[0]; } $member_id = intval($bind['member_id']); $platform_id = $bind['platform_id']; $condition = " AND m.member_id = " . $member_id; $fileds_array = array('member_id', 'member_name', 'password', 'salt', 'avatar', 'type', 'type_name', 'gid', 'gradeid', 'guid', 'signature', 'mobile', 'email', 'isVerify', 'identifier', 'last_login_device'); $fields = implode(',', $fileds_array); $member_info = $this->mMember->get_member_info($condition, $fields); $member_info = $member_info[0]; if (empty($member_info)) { $this->errorOutput(LOGIN_NOMEMBER_ERROR); } $isComplete = isUserComplete($member_info['type']); if (in_array($type, $need_password_type) && $_type != 'uc') { $encrypt_num = intval($this->input['encrypt_num']); if ($encrypt_num == 1) { $md5_password = md5($password . $member_info['salt']); } else { $md5_password = md5(md5($password) . $member_info['salt']); } if ($md5_password != $member_info['password']) { $this->errorOutput(PASSWORD_ERROR); } } else { //验证新浪微博、腾讯微博、QQ、人人、豆瓣 等 用户信息 //暂时不作处理 } //积分规则调用 $credit_rules = $this->Members->credits_rule('members_login_login', $member_info['member_id'], $coef = 1, $update = 1, APP_UNIQUEID); $copywriting_credit = copywriting_credit(array($credit_rules)); $check_Bind = new check_Bind(); $inuc = $check_Bind->check_uc($member_id, $type); if (!$inuc && ($_type == 'm2o' || $type == 'm2o') && $member_info['email']) { if ($inuc = $this->mMember->syncUcRegister($member_id, $member_info['member_name'], $password, $member_info['email'])) { $platform_id = $inuc; } } $return = array('user_id' => $member_info['member_id'], 'platform_id' => (string) $platform_id, 'inuc' => $inuc, 'user_name' => $member_info['member_name'], 'nick_name' => $bind['nick_name'], 'type' => $member_info['type'], 'avatar' => $member_info['avatar'], 'copywriting' => '登录成功', 'copywriting_credit' => $copywriting_credit, 'isVerify' => $member_info['isVerify'], 'identifier' => $member_info['identifier'], 'isComplete' => $isComplete); $return = array_merge($return, $member_info); $this->addItem($return); $this->output(); } catch (Exception $e) { $this->errorOutput($e->getMessage(), $e->getCode()); } }
/** * 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(); }
public function checkUc() { try { $identifierUserSystem = new identifierUserSystem(); $identifier = $identifierUserSystem->setIdentifier((int) $this->input['identifier'])->checkIdentifier(); //多用户系统 $check_Bind = new check_Bind(); if ($this->input['platform_id']) { $platform_id = $this->input['platform_id']; $type = $this->input['type']; } elseif ($this->input['member_name']) { $user_name = trim($this->input['member_name']); $member_id = $check_Bind->bind_to_memberid($user_name, 'uc', false, $identifier); //优先检测uc类型 $type = 'uc'; if (empty($member_id)) { $member_id = $check_Bind->bind_to_memberid($user_name, 'm2o', false, $identifier); $type = 'm2o'; } if (empty($member_id)) { $member_id = $check_Bind->bind_to_memberid($user_name, 'shouji', false, $identifier); $type = 'shouji'; } if (empty($member_id)) { $platform_id = $this->input['member_name']; $type = $this->input['type']; } } $is_bind = 0; if (empty($member_id)) { $member_id = $check_Bind->bind_to_memberid($platform_id, $type, true, $identifier); } $is_bind = $check_Bind->check_uc($member_id, $type); $this->addItem_withkey('is_bind', $is_bind); $this->output(); } catch (Exception $e) { $this->errorOutput($e->getMessage(), $e->getCode()); } }