} /** * 获取评论总数 */ public function count() { $info = $this->api->count(array(), true); echo json_encode($info); } /** * 发表评论 */ public function create() { $id = intval($this->input['id']); if ($id <= 0) { $this->errorOutput(PARAM_WRONG); } $photo_info = $this->api->detail('photos', array('id' => $id, 'state' => 1), 'albums_id'); if (!$photo_info) { $this->errorOutput(OBJECT_NULL); } $content = trim(urldecode($this->input['comment_con'])); if (empty($content)) { $this->errorOutput(PARAM_WRONG); } //屏蔽字判断 include_once ROOT_PATH . 'lib/class/banword.class.php'; $banword = new banword(); $words = $banword->exists($content); if ($words) { $keywords = array(); foreach ($words as $v) { $keywords[] = $v['banname']; } $keywords = implode(',', $keywords); } $insertData = array('albums_id' => $photo_info['albums_id'], 'photo_id' => $id, 'content' => $content, 'user_id' => $this->user['user_id'], 'user_name' => $this->user['user_name'], 'org_id' => $this->user['org_id'], 'appid' => $this->user['appid'], 'appname' => $this->user['display_name'], 'create_time' => TIMENOW, 'ip' => hg_getip()); if ($keywords) { $insertData['banwords'] = $keywords; $insertData['isbanword'] = 1; } if (INIT_AUDIT) { $insertData['state'] = 1; } $result = $this->api->create($insertData); if ($result) {
/** * 会员编辑 * $member_id * $member_name * $password * $old_password * $signature * $avatar file * $member_info json */ public function edit() { $this->input = hg_mermber2members_compatible(array('new_password' => 'password'), $this->input, false); $member_id = intval($this->user['user_id']); $app_id = $this->input['app_id']; //应用id if (!$member_id) { $this->errorOutput(NO_MEMBER_ID); } //检测该会员是否存在 $condition = " AND m.member_id = '" . $member_id . "' "; $field = 'm.member_id , m.member_name, m.password, m.salt, m.avatar, m.type,mb.nick_name'; $_member_info = $this->mMember->get_member_info($condition, $field, ' LEFT JOIN ' . DB_PREFIX . 'member_bind as mb ON mb.member_id = m.member_id'); $member_info = array(); $member_info = $_member_info[0]; if (empty($member_info)) { $this->errorOutput(NO_MEMBER); } $this->ReplaceCheck($member_info); //判定是否有值不更新 $member_name = trim($this->input['member_name']); if ($this->input['nick_name']) { $nick_name = trim($this->input['nick_name']); } if (!$nick_name && $this->settings['memberNameToNickName']) { $nick_name = $member_name; unset($member_name, $this->input['member_name']); } $password = trim($this->input['password']) ? trim($this->input['password']) : ''; $old_password = trim($this->input['old_password']); $signature = trim($this->input['signature']); $mobile = trim($this->input['mobile']); $email = trim($this->input['email']) ? trim($this->input['email']) : ''; $verifycode = trim($this->input['verifycode']); $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); } //会员名、更新时间 $data = array('member_id' => $member_id, 'update_time' => TIMENOW); $check_bind = new check_Bind(); if ($mobile) { if (!hg_verify_mobile($mobile)) { $this->errorOutput(MOBILE_NUMBER_FORMAT_ERROR); } else { if ($check_bind->checkMobileBind($member_id) != $mobile) { $this->errorOutput(MOBILE_BIND_NOT_UPDATE); } } $data['mobile'] = $mobile; } if ($email) { if (!hg_check_email_format($email)) { $this->errorOutput(EMAIL_FORMAT_ERROR); } elseif ($check_bind->checkEmailBind($member_id) == $email) { $this->errorOutput(EMAIL_BIND_NOT_UPDATE); } $data['email'] = $email; } if ($member_name && !$this->mMember->isMemberNameUpdate($member_id)) { $this->errorOutput(NOT_EDIT_MEMBERNAME); } else { if ($member_name) { $member_name_exists = $this->mMember->member_name_exists($member_name, $member_id); if (!empty($member_name_exists)) { $this->errorOutput(MEMBER_NAME_EXISTS); } $data['member_name'] = $member_name; } } if ($this->settings['App_banword']) { include ROOT_PATH . 'lib/class/banword.class.php'; $banword = new banword(); $signature_banword = $banword->exists($signature); //个性签名检测 if ($signature_banword && is_array($signature_banword)) { $this->errorOutput(SIGNATURE_INVALID); } $nick_name_banword = $banword->exists($nick_name); //个性签名检测 if ($nick_name_banword && is_array($nick_name_banword)) { $this->errorOutput(NICKNAME_ILLEGAL); } } //如果是m2o注册类型屏蔽字检测 if (in_array($member_info['type'], array('m2o', 'uc')) && $this->settings['App_banword']) { $member_name_banword = $banword->exists($member_name); if ($member_name_banword && is_array($member_name_banword)) { //$this->errorOutput(var_export($banword,1)); $this->errorOutput(MEMBER_NAME_INVALID); } } $_old_password = ''; //用户原始密码 $is_no_old_password = 1; //是否需要旧密码修改资料,不涉及用户密码操作直接修改 //密码、随机串 if (isset($this->input['password']) && $password || isset($this->input['verifycode']) && $verifycode) { if (!$old_password && !$verifycode) { $this->errorOutput(OLD_PASSWORD_ERROR); } //根据原始密码修改密码 if ($old_password) { $is_no_old_password = 0; $_old_password = $old_password; //用作uc更改密码 $old_password = md5(md5($old_password) . $member_info['salt']); if ($old_password != $member_info['password']) { $this->errorOutput(OLD_PASSWORD_ERROR); } } //根据验证码修改密码 if ($verifycode) { if ($this->mSmsServer->get_verifycode_info($member_name, $verifycode)) { //验证成功之后删除 $this->mSmsServer->mobile_verifycode_delete($member_name, $verifycode); } else { $this->errorOutput(VERIFY_FAILED); } } } /** * 同步UC信息 */ if ($this->settings['ucenter']['open'] && in_array($member_info['type'], array('m2o', 'uc'))) { $_member_name = $this->user['user_name']; $is_password = $this->mMember->uc_user_edit($_member_name, $_old_password, $password, $email, $is_no_old_password); if ($is_password < 0) { if ($is_password == -1) { $this->errorOutput(OLD_PASSWORD_ERROR); } else { if ($is_password == -4) { $this->errorOutput(EMAIL_FORMAT_ERROR); } elseif ($is_password == -5) { $this->errorOutput(EMAIL_NO_REGISTER); } elseif ($is_password == -6) { $this->errorOutput(EMAIL_HAS_BINDED); } } } } if ($password) { $salt = hg_generate_salt(); $md5_password = md5(md5($password) . $salt); $data['password'] = $md5_password; $data['salt'] = $salt; } //个性签名 if (isset($this->input['signature'])) { $data['signature'] = $signature; } //头像 if ($_FILES['avatar']['tmp_name']) { $avatar = $_FILES['avatar']; } elseif ($this->input['avatar']) { $avatar = $this->input['avatar']; } //背景图 if ($_FILES['background']['tmp_name']) { $background = $_FILES['background']; } elseif ($this->input['background']) { $background = $this->input['background']; } $_avatar = array(); $_background = array(); //编辑头像 if (!empty($avatar) && is_array($avatar)) { if ($this->input['version'] == CLIENT_VERSION) { $avatar['name'] .= '.png'; } $_avatar = $this->mMember->add_material($avatar, $member_id); } elseif ($avatar && is_string($avatar) && is_url($avatar)) { $_avatar = $this->mMember->update_avatar($avatar, array(), $member_id, true); } //叮当更换头像时刷新im用户信息 if ($_avatar && $this->input['platformMark'] && $this->input['platformMark'] == 'dingdone' && $app_id) { $param = array('app_id' => $app_id, 'member_id' => $member_id, 'member_name' => $member_info['member_name']); $param['avatar_url'] = $_avatar['host'] . $_avatar['dir'] . $_avatar['filepath'] . $_avatar['filename']; $imInfo = $this->refreshImInfo($param); } //编辑背景图 if (!empty($background) && is_array($background)) { $_background = $this->mMember->add_material($background, $member_id); } if (!empty($_avatar)) { $data['avatar'] = serialize($_avatar); } $bind_info = array(); if ($nick_name) { $bind_info = array('nick_name' => $nick_name); } if ($_background) { $bind_info['background'] = serialize($_background); } $copywriting_credit = $this->editCreditRules($member_id, $data, $bind_info); //判断积分规则 //会员数据入库 $ret = $this->mMember->update($data); if ($bind_info) { $this->mMember->bind_update($bind_info, 'WHERE member_id = \'' . $member_id . '\''); } if (!$ret['member_id']) { $this->errorOutput(EDIT_FAILED); } //编辑扩展信息 if ($this->input['platformMark'] && $this->input['platformMark'] == 'dingdone' && $app_id) { //为叮当注册根据app配置不同的扩展信息 $extension = $this->mMemberInfo->extension_editByApp($member_id, $this->input['member_info'], $app_id, $_FILES); } else { $extension = $this->mMemberInfo->extension_edit($member_id, $this->input['member_info'], $_FILES); } //会员痕迹 $member_trace_data = array('member_id' => $member_id, 'member_name' => $member_name ? $member_name : $member_info['member_name'], 'content_id' => $member_id, 'title' => $member_name ? $member_name : $member_info['member_name'], 'type' => 'editmember', 'op_type' => '修改会员资料', 'appid' => $this->user['appid'], 'appname' => $this->user['display_name'], 'create_time' => TIMENOW, 'ip' => hg_getip(), 'device_token' => $device_token, 'udid' => $udid); $this->mMember->member_trace_create($member_trace_data); $return = array('member_id' => $member_id, 'member_name' => !$member_name ? $member_info['member_name'] : $member_name, 'nick_name' => !$nick_name ? $member_info['nick_name'] : $nick_name, 'type' => $member_info['type'], 'avatar' => !$_avatar ? $member_info['avatar'] : $_avatar, 'access_token' => $this->user['token'], 'update_avatar' => $avatar ? 1 : 0, 'copywriting_credit' => $copywriting_credit, 'background' => $_background ? $_background : array(), 'email' => $email ? $email : ''); if (isset($this->input['signature'])) { $return['signature'] = $signature; } //获取扩展信息 if ($app_id) { $extension = $this->getExtensionInfo($member_id, $app_id); $return['extension'] = $extension; } //获取会员基本信息返回 $condition = ''; $condition = " AND m.member_id = '" . $member_id . "' AND mb.is_primary=1"; $field = 'm.member_id , m.member_name, m.signature, m.email,m.mobile, mb.background, m.salt, m.avatar, m.type,mb.nick_name'; $memberBaseInfo = $this->mMember->get_member_info($condition, $field, ' LEFT JOIN ' . DB_PREFIX . 'member_bind as mb ON mb.member_id = m.member_id'); if (!empty($memberBaseInfo[0])) { foreach ($memberBaseInfo[0] as $k => $v) { $return[$k] = $v; } } if ($this->input['version'] == CLIENT_VERSION) { //头像 if ($this->input['m_avatar']) { $return = $return['avatar']; } //昵称 if ($this->input['m_name']) { if ($this->input['appid'] == 7 && $this->input['appkey'] == 'upnKAycZKVw4D7QSXH7D8uFrFOpRQyXb') { $return = 'success'; } else { $return = array('nick_name' => $return['member_name'], 'update_time' => '', 'member_name' => $return['member_name'], 'member_id' => $return['member_id']); } } //密码 if ($this->input['m_password']) { $return = array('member_id' => $return['member_id']); } //邮箱 if ($this->input['m_mail'] || $this->input['m_mobile']) { $return = "success"; } } $this->addItem($return); $this->output(); }
/** * 会员注册 * member_id 会员id member_name 会员名 password 密码 salt 随机数 type 会员类型 type_name 会员类型名 avatar 头像 signature 个性签名 appid 应用id appname 应用名 create_time 注册时间 update_time 更新时间 ip 注册ip * * $appid * $appkey * $callback * * $mobile_verifycode * * 绑定表 * member_id 会员id platform_id 第三方平台会员id char nick_name 昵称 type 会员类型 type_name 会员类型名称 avatar_url 头像地址 bind_time 绑定时间 bind_ip 绑定ip * * 返回 * member_id * member_name * type * avatar * access_token */ public function register() { try { $this->check_verifycode(); //验证码 $this->oldtype = $this->type = trim($this->input['type']); $member_name = $this->checkRegMemberName(); $this->checkRegType(); $this->checkRegMemberNameError(); $password = trim($this->input['password']); $identifierUserSystem = new identifierUserSystem(); $identifier = $identifierUserSystem->setIdentifier((int) $this->input['identifier'])->checkIdentifier(); //多用户系统 if (empty($this->type)) { $this->errorOutput(NO_MEMBER_TYPE); } $platformInfo = $this->Members->get_platform_name($this->type); if (empty($platformInfo)) { $this->errorOutput(REG_MEMBER_TYPE_ERROR); } else { if (!$platformInfo['status']) { $this->errorOutput(REG_MEMBER_TYPE_CLOSE); } } $type_name = $platformInfo['name']; $signature = trim($this->input['signature']); $ip = hg_getip(); $appid = intval($this->input['appid']); $appkey = trim($this->input['appkey']); $platform_id = ''; $mobile_verifycode = trim($this->input['mobile_verifycode']); $email = trim($this->input['email']); $reg_mail = $this->Members->check_reg_mail($email, 0, $identifier); if ($reg_mail == -4) { $this->errorOutput(EMAIL_FORMAT_ERROR); } elseif ($reg_mail == -5) { $this->errorOutput(EMAIL_NO_REGISTER); } elseif ($reg_mail == -6) { $this->errorOutput(EMAIL_HAS_BINDED); } $this->type == 'email' && $this->checkEmailVerifyCode($member_name); $this->type != 'email' && $email && $this->checkEmailVerifyCode($email); $_mobile = trim($this->input['mobile']); //简单验证手机号格式 if ($_mobile && !hg_verify_mobile($_mobile)) { $this->errorOutput(MOBILE_NUMBER_FORMAT_ERROR); } else { if ($_mobile && (isset($this->input['mobile_verifycode']) || defined('NO_VERIFY_MOBILEBIND') && NO_VERIFY_MOBILEBIND)) { $check_bind = new check_Bind(); if ($check_bind->checkmembernamereg($_mobile, $identifier)) { $this->errorOutput(MOBILE_REG_BIND); } } } if ($this->type != 'shouji' && $_mobile && isset($this->input['mobile_verifycode'])) { //验证码 $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); } $this->ismobileverify = 1; } else { if ($this->type != 'shouji' && $_mobile && defined('NO_VERIFY_MOBILEBIND') && NO_VERIFY_MOBILEBIND) { $this->ismobileverify = 1; } } $device_token = $this->Members->check_device_token(trim($this->input['device_token'])); if ($device_token === 0) { $this->errorOutput(ERROR_DEVICE_TOKEN); } $udid = $this->Members->check_udid(trim($this->input['uuid'])); if ($udid === 0) { $this->errorOutput(ERROR_UDID); } //验证设备号和ip是否在黑名单 if ($udid) { $device_res = $this->Blacklist->detailDeviceBlacklist(array('device_token' => $udid, 'identifier' => $identifier)); if ($device_res[0]['deadline'] == -1 && $device_res[0]['type'] == 2) { $this->errorOutput(DEVICE_BLACKLIST_FOREVER); } elseif ($device_res[0]['deadline'] == -1) { $this->errorOutput(DEVICE_BLACKLIST); } } if ($ip) { $ip_res = $this->Blacklist->detailIpBlacklist(array('ip' => ip2long($ip), 'identifier' => $identifier)); if ($ip_res[0]['deadline'] == -1 && $ip_res[0]['type'] == 2) { $this->errorOutput(IP_BLACKLIST_FOREVER); } elseif ($ip_res[0]['deadline'] == -1) { $this->errorOutput(IP_BLACKLIST); } } //密码 if (!$password) { $this->errorOutput(NO_PASSWORD); } //验证手机验证码 if ($this->type == 'shouji') { $check_bind = new check_Bind(); if ($check_bind->checkmembernamereg($member_name, $identifier)) { $this->errorOutput(MOBILE_REG_BIND); } $platform_id = $mobile = $member_name; $_mobile = $mobile ? $mobile : $_mobile; //简单验证手机号格式 if (!hg_verify_mobile($mobile)) { $this->errorOutput(MOBILE_NUMBER_FORMAT_ERROR); } if (!$mobile_verifycode) { $this->errorOutput(MOBILE_NOT_VERIFY); } //验证码 $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); } } //如果是m2o注册类型屏蔽字检测 if ($this->settings['App_banword']) { include ROOT_PATH . 'lib/class/banword.class.php'; $banword = new banword(); $signature_banword = $banword->exists($signature); if ($signature_banword && is_array($signature_banword)) { $this->errorOutput(SIGNATURE_INVALID); } } if ($this->type == 'm2o' && $this->settings['App_banword']) { $member_name_banword = $banword->exists($member_name); if ($member_name_banword && is_array($member_name_banword)) { $this->errorOutput(MEMBER_NAME_INVALID); } } //头像 $avatar = array(); if (isset($this->input['avatar']) && $_FILES['avatar']['tmp_name']) { $avatar = $_FILES['avatar']; } //验证会员名 $ret_verify = $this->mMember->verify_member_name($member_name, 0, $identifier, $type); switch ($ret_verify) { case -1: $this->errorOutput(MEMBER_NAME_ILLEGAL); break; case -2: $this->errorOutput(PROHIBITED_WORDS); break; case -3: $this->errorOutput(UC_MEMBER_NAME_REGISTER); break; 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; case -7: $this->errorOutput(MEMBER_NAME_REGISTER); break; default: break; } //随机串 $salt = hg_generate_salt(); //密码md5 $md5_password = md5(md5($password) . $salt); $groupInfo = $this->Members->checkgroup_credits(0); $gradeInfo = $this->Members->checkgrade_credits(0); $data = array('member_name' => $member_name, 'password' => $md5_password, 'salt' => $salt, 'type' => $this->type, 'type_name' => $type_name, 'gid' => $groupInfo['gid'], 'gradeid' => $gradeInfo['gradeid'], 'signature' => $signature, 'mobile' => $_mobile, 'email' => $email, 'status' => $this->settings['member_status'], 'identifier' => $identifier, 'appid' => $this->user['appid'], 'appname' => $this->user['display_name'], 'create_time' => TIMENOW, 'update_time' => TIMENOW, 'ip' => $ip, 'guid' => guid(), 'reg_device_token' => $device_token, 'reg_udid' => $udid); //入ucenter $inuc = 0; if ($this->type == 'm2o' && $this->settings['ucenter']['open'] && !$identifier) { //邮箱 m2o类型必须传入email if (!$email) { $this->errorOutput(NO_EMAIL); } $virtual_email = $email; //忽略返回值 $reinfo = $this->uc_register(array('member_name' => $data['member_name'], 'password' => $password, 'email' => $virtual_email)); $inuc = $reinfo['member_id']; } //会员数据入库 $ret = $this->mMember->create($data); if (!$ret['member_id']) { $this->errorOutput(MEMBER_DATA_ADD_FAILED); } $member_id = $ret['member_id']; //编辑扩展信息 #@param platformMark 平台标示 if ($this->input['platformMark'] && $this->input['platformMark'] == 'dingdone' && $this->input['identifier']) { //为叮当注册根据app配置不同的扩展信息 $this->mMemberInfo->extension_editByApp($member_id, $this->input['member_info'], $this->input['identifier'], $_FILES); } else { $this->mMemberInfo->extension_edit($member_id, $this->input['member_info'], $_FILES); } //获取扩展信息 $extension = $this->getExtensionInfo($member_id, $identifier); if (!$identifier) { $invite_user = new invite(); $id = $this->input['invite_id'] ? $this->input['invite_id'] : 0; //邀请码id $invite_code = $this->input['invite_code'] ? $this->input['invite_code'] : $member_name; //如果未传邀请码则已用户名为邀请码去邀请数据库查询是否存在邀请信息,目前仅支持手机注册类型用户名; $invite = $invite_user->invite_rules($member_id, $invite_code, $id); //邀请用户处理 $this->invite_error($invite); } //uc打开平台id为uc 否则为自身id if ($this->type == 'm2o') { $platform_id = $this->settings['ucenter']['open'] && $reinfo['member_id'] > 0 && !$identifier ? $reinfo['member_id'] : $member_id; } elseif ($this->type == 'email') { $platform_id = $member_name; } $data['member_id'] = $member_id; //绑定表 $bind_data = array('member_id' => $member_id, 'platform_id' => $platform_id, 'nick_name' => $member_name, 'type' => $this->type, 'type_name' => $type_name, 'bind_time' => TIMENOW, 'bind_ip' => $ip, 'inuc' => $inuc, 'is_primary' => 1, 'identifier' => $identifier, 'reg_device_token' => $device_token, 'reg_udid' => $udid); $ret_bind = $this->mMember->bind_create($bind_data); if (empty($ret_bind)) { $this->errorOutput(BIND_DATA_ADD_FAILED); } $this->registerCreditRules($member_id); //注册相关积分规则 //如果注册时填写邮箱则可以同时入绑定表 if ($data['email']) { if ($this->type != 'email' && $this->isemailverify) { $_bind_data = $bind_data; $_bind_data['platform_id'] = $data['email']; $_bind_data['is_primary'] = 0; $_bind_data['type'] = 'email'; $_bind_data['type_name'] = '邮箱'; $_ret_bind = $this->mMember->bind_create($_bind_data); if (empty($_ret_bind)) { $this->errorOutput(BIND_DATA_ADD_FAILED); } unset($_bind_data, $_ret_bind); } } if ($data['mobile']) { if ($this->type != 'shouji' && $this->ismobileverify) { $_bind_data = $bind_data; $_bind_data['platform_id'] = $data['mobile']; $_bind_data['is_primary'] = 0; $_bind_data['type'] = 'shouji'; $_bind_data['type_name'] = '手机'; $_ret_bind = $this->mMember->bind_create($_bind_data); if (empty($_ret_bind)) { $this->errorOutput(BIND_DATA_ADD_FAILED); } unset($_bind_data, $_ret_bind); } } //头像入库 if (!empty($avatar)) { $avatar = $this->mMember->add_material($avatar, $member_id); if (!empty($avatar)) { $update_data = array('member_id' => $member_id, 'avatar' => daddslashes(serialize($avatar))); $ret_updata = $this->mMember->update($update_data); if (!$ret_updata['member_id']) { $this->errorOutput(AVATAR_ADD_FAILED); } } } else { $avatar_url = $this->input['avatar_url'] ? trim($this->input['avatar_url']) : ''; if ($avatar_url) { $avatar = $this->mMember->local_material($avatar_url, $member_id); if (!empty($avatar)) { $update_data = array('member_id' => $member_id, 'avatar' => daddslashes(serialize($avatar))); $ret_updata = $this->mMember->update($update_data); if (!$ret_updata['member_id']) { $this->errorOutput(AVATAR_ADD_FAILED); } } } } //到auth接口取access_token $callback = 'http://' . $this->settings['App_members']['host'] . '/' . $this->settings['App_members']['dir'] . 'login.php?a=verify_member&appid=' . $appid . '&appkey=' . $appkey; $encryptPassword = urlencode(passport_encrypt($password, CUSTOM_APPKEY)); $auth_data = array('user_name' => $member_name, 'appid' => $appid, 'appkey' => $appkey, 'ip' => $ip, 'verify_user_cb' => $callback, 'extend' => 'platform_id=' . $platform_id . '&password='******'&encrypt=1&type=' . $this->type . '&identifier=' . $identifier); $auth = $this->mMember->get_access_token($auth_data); if (!$auth['token']) { $this->errorOutput(MEMBERS_LOGIN_ERROR); } $return = array('member_id' => $member_id, 'member_name' => $ret['member_name'], 'nick_name' => $auth['nick_name'], 'platform_id' => $auth['platform_id'], 'inuc' => $auth['inuc'] ? $auth['inuc'] : 0, 'type' => $this->type, 'type_name' => $auth['type_name'], 'avatar' => $avatar, 'access_token' => $auth['token'], 'guid' => $auth['guid'], 'gid' => $auth['gid'], 'gradeid' => $auth['gradeid'], 'copywriting_credit' => $auth['copywriting_credit'], 'copywriting' => $auth['copywriting'], 'signature' => $auth['signature'], 'mobile' => $auth['mobile'], 'email' => $auth['email'], 'isVerify' => $auth['isVerify'], 'isComplete' => $auth['isComplete'], 'identifier' => $auth['identifier'], 'last_login_device' => $auth['last_login_device']); if ($extension) { $return['extension'] = $extension; } //会员痕迹 $member_trace_data = array('member_id' => $member_id, 'member_name' => $member_name, 'content_id' => $member_id, 'title' => $member_name, 'type' => 'register', 'op_type' => '注册', 'appid' => $this->user['appid'], 'appname' => $this->user['display_name'], 'create_time' => TIMENOW, 'ip' => hg_getip(), 'device_token' => $device_token, 'udid' => $udid); $this->mMember->member_trace_create($member_trace_data); //记录登陆信息 $loginInfoRecord = array('last_login_device' => $member_trace_data['device_token'], 'final_login_time' => $member_trace_data['create_time'], 'last_login_time' => $member_trace_data['create_time'], 'last_login_udid' => $member_trace_data['udid']); $this->mMember->loginInfoRecord($return['member_id'], $loginInfoRecord); $return = hg_mermber2members_compatible(array('member_name' => 'nick_name', 'access_token' => 'token'), $return, false); $this->addItem($return); $this->output(); } catch (Exception $e) { $this->errorOutput($e->getMessage(), $e->getCode()); } }
/** * * 补充新浪绑定,QQ绑定等第三方绑定信息为正常M2O账号 ... * 目的是为了解决 新浪、QQ等第三方平台首次直接登陆系统后,资料信息不完善问题 */ public function supplementaryBindInfo() { try { $identifierUserSystem = new identifierUserSystem(); $identifier = $identifierUserSystem->setIdentifier((int) $this->input['identifier'])->checkIdentifier(); //多用户系统 $member_name = $this->input['member_name']; $nick_name = $this->input['nick_name']; if (empty($member_name)) { $this->errorOutput(NO_MEMBER_NAME); } //如果是m2o注册类型屏蔽字检测 if ($this->settings['App_banword']) { include ROOT_PATH . 'lib/class/banword.class.php'; $banword = new banword(); $member_name_banword = $banword->exists($member_name); if ($member_name_banword && is_array($member_name_banword)) { $this->errorOutput(MEMBER_NAME_INVALID); } } switch ($this->mMember->verify_member_name($member_name, $user_id, $identifier)) { case -1: $this->errorOutput(MEMBER_NAME_ILLEGAL); break; case -2: $this->errorOutput(PROHIBITED_WORDS); break; case -3: $this->errorOutput(UC_MEMBER_NAME_REGISTER); break; 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; case -7: $this->errorOutput(MEMBER_NAME_REGISTER); break; default: break; } $mobile_verifycode = trim($this->input['mobile_verifycode']); $email_verifycode = trim($this->input['email_verifycode']); $email = $this->input['email']; if (empty($email)) { $this->errorOutput(NO_EMAIL); } $reg_mail = $this->Members->check_reg_mail($email, 0, $identifier); if ($reg_mail == -4) { $this->errorOutput(EMAIL_FORMAT_ERROR); } elseif ($reg_mail == -5) { $this->errorOutput(EMAIL_NO_REGISTER); } elseif ($reg_mail == -6) { $this->errorOutput(EMAIL_HAS_BINDED); } if ($email && isset($this->input['email_verifycode'])) { if ($this->memberverifycode->get_verifycode_info($email, $email_verifycode, 1, $action = 1)) { //验证成功之后删除 $this->memberverifycode->verifycode_delete($member_name, $email_verifycode, 1, $action = 1); } else { $this->errorOutput(VERIFY_FAILED); } $this->isemailverify = 1; } $mobile = $this->input['mobile']; //简单验证手机号格式 if ($mobile && !hg_verify_mobile($mobile)) { $this->errorOutput(MOBILE_NUMBER_FORMAT_ERROR); } else { if ($mobile && (isset($this->input['mobile_verifycode']) || defined('NO_VERIFY_MOBILEBIND') && NO_VERIFY_MOBILEBIND)) { $check_bind = new check_Bind(); if ($check_bind->checkmembernamereg($mobile, $identifier)) { $this->errorOutput(MOBILE_REG_BIND); } } } if ($mobile && isset($this->input['mobile_verifycode'])) { //验证码 $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); } $this->ismobileverify = 1; } $password = $this->input['password']; $user_id = $this->user['user_id']; if (!$user_id) { $this->errorOutput(NO_MEMBER_ID); } $cond = ' AND member_id = ' . $user_id; $memberInfo = $this->Members->get_member_info($cond); if (!$memberInfo) { $this->errorOutput(NO_MEMBER); } if ($memberInfo['type'] == 'm2o' || $memberInfo['type'] == 'uc') { $this->errorOutput(UPDATEM2O); } $updateMemberInfo['member_id'] = $user_id; $updateMemberInfo['type'] = 'm2o'; $updateMemberInfo['type_name'] = 'M2O'; $updateMemberInfo['member_name'] = $member_name; if (empty($password)) { $this->errorOutput(NO_PASSWORD); } $salt = hg_generate_salt(); $updateMemberInfo['salt'] = $salt; $md5_password = md5(md5($password) . $salt); $updateMemberInfo['password'] = $md5_password; $email && ($updateMemberInfo['email'] = $email); $mobile && ($updateMemberInfo['mobile'] = $mobile); $this->mMember->update($updateMemberInfo); $membersql = new membersql(); $this->mMember->bind_update(array('is_primary' => 0), $membersql->where(array('member_id' => $memberInfo['member_id'], 'type' => $memberInfo['type']))); $platform_id = $user_id; $inuc = 0; if (!$identifier && $this->settings['ucenter']['open']) { $register_data = array('member_name' => $member_name, 'password' => $password, 'email' => $email); $registerInfo = $this->mMember->uc_register($register_data); if ($registerInfo['member_id'] > 0) { $inuc = $platform_id = $registerInfo['member_id']; } } //M2O绑定关系 $bind_data = array('member_id' => $user_id, 'platform_id' => $platform_id, 'nick_name' => $nick_name, 'type' => 'm2o', 'type_name' => 'M2O', 'bind_time' => TIMENOW, 'bind_ip' => hg_getip(), 'inuc' => $inuc, 'is_primary' => 1, 'identifier' => $identifier, 'reg_device_token' => 'www', 'reg_udid' => $udid); $ret_bind = $this->mMember->bind_create($bind_data); //如果注册时填写邮箱则可以同时入绑定表 if ($email) { if ($this->isemailverify || defined('NO_VERIFY_EMAILBIND') && NO_VERIFY_EMAILBIND) { $_bind_data = $bind_data; $_bind_data['platform_id'] = $email; $_bind_data['is_primary'] = 0; $_bind_data['type'] = 'email'; $_bind_data['type_name'] = '邮箱'; $_ret_bind = $this->mMember->bind_create($_bind_data); if (empty($_ret_bind)) { $this->errorOutput(BIND_DATA_ADD_FAILED); } unset($_bind_data, $_ret_bind); } } if ($mobile) { if ($this->ismobileverify || defined('NO_VERIFY_MOBILEBIND') && NO_VERIFY_MOBILEBIND) { $_bind_data = $bind_data; $_bind_data['platform_id'] = $mobile; $_bind_data['is_primary'] = 0; $_bind_data['type'] = 'shouji'; $_bind_data['type_name'] = '手机'; $_ret_bind = $this->mMember->bind_create($_bind_data); if (empty($_ret_bind)) { $this->errorOutput(BIND_DATA_ADD_FAILED); } unset($_bind_data, $_ret_bind); } } if ($inuc) { $_updateBind = array('inuc' => $inuc); $this->mMember->bind_update($_updateBind, ' WHERE member_id = ' . $user_id); } $this->addItem($bind_data); $this->output(); } catch (Exception $e) { $this->errorOutput($e->getMessage(), $e->getCode()); } }
private function check_banword($text) { include_once ROOT_PATH . 'lib/class/banword.class.php'; $banword = new banword(); $banwords = $banword->exists($text); $ban = ''; if ($banwords) { foreach ($banwords as $v) { $ban .= $v['banname'] . '|'; } $ban = rtrim($ban, '|'); } return $ban; }
$this->addItem($data); } } $this->output(); } public function banwords($tmp_breif) { //屏蔽字判断 !$tmp_breif || class_exists('banword') or (include ROOT_PATH . 'lib/class/banword.class.php'); $tmp_breif && ($banword = new banword()); $words = $banword->exists(urlencode($tmp_breif)); $_keywords = ''; if ($words) { $keywords = array(); foreach ($words as $v) { $keywords[] = $v['banname']; } $keywords && ($_keywords = implode(',', $keywords)); } return $_keywords; } /** * 编辑图片 */ public function update_photo() { $id = intval($this->input['id']); if ($id <= 0) { $this->errorOutput(PARAM_WRONG); } $pic_info = $this->api->detail('photos', array('id' => $id)); if (!$pic_info) { $this->errorOutput(PARAM_WRONG); } $updateData = array(); $albums_id = intval($this->input['albums_id']); $photo_name = trim(urldecode($this->input['photo_name'])); $photo_brief = trim(urldecode($this->input['breif'])); $albums_info = $this->api->detail('albums', array('id' => $albums_id), 'id'); if ($albums_info && $albums_id != $pic_info['albums_id']) { $updateData['albums_id'] = $albums_id; } if ($photo_name && $photo_name != $pic_info['photo_name']) { $updateData['photo_name'] = $photo_name; } if ($photo_brief && $photo_brief != $pic_info['photos_brief']) { $updateData['photos_brief'] = $photo_brief; //屏蔽字判断 include_once ROOT_PATH . 'lib/class/banword.class.php'; $banword = new banword(); $words = $banword->exists(urlencode($photo_brief)); if ($words) { $keywords = array(); foreach ($words as $v) { $keywords[] = $v['banname']; } $keywords = implode(',', $keywords); $updateData['banwords'] = $keywords; if (!$pic_info['isbanword']) { $updateData['isbanword'] = 1; } } else { if ($pic_info['isbanword']) { $updateData['banwords'] = '';