Example #1
0
/**
 *
 * 判断手机号码运营商
 * @param int $mobile
 */
function hg_checkOperators($_mobile)
{
    if (hg_verify_mobile($_mobile)) {
        $special = array('134', '170');
        $segment = substr($_mobile, 0, 3);
        in_array($segment, $special) && ($segment = substr($_mobile, 0, 4));
        $telecom = array(133, 153, 177, 180, 181, 189, 1700);
        $mobile = array(135, 136, 137, 138, 139, 150, 151, 152, 158, 159, 182, 183, 184, 157, 187, 188, 147, 178, 1340, 1341, 1342, 1343, 1344, 1345, 1346, 1347, 1348, 1705);
        $unicom = array(130, 131, 132, 155, 156, 145, 185, 186, 176, 1709);
        $Satellite = array(1349);
        if (in_array($segment, $mobile)) {
            return 1;
            //移动(含向虚拟运营商专收号段170)
        } elseif (in_array($segment, $telecom)) {
            return 2;
            //电信(含向虚拟运营商专收号段170)
        } elseif (in_array($segment, $unicom)) {
            return 3;
            //联通(含向虚拟运营商专收号段170)
        } elseif (in_array($segment, $Satellite)) {
            return 4;
            //卫星通讯
        } else {
            return -1;
            //未知
        }
    }
    return 0;
    //手机号码不正确
}
Example #2
0
/**
 *
 * 隐藏手机号中间部分
 * @param string $mobile
 */
function hg_hide_mobile($mobile)
{
    if (hg_verify_mobile($mobile)) {
        $pattern = "/(1\\d{1,2})\\d\\d(\\d{0,3})/";
        $replacement = "\$1****\$3";
        return preg_replace($pattern, $replacement, $mobile);
    }
    return $mobile;
}
Example #3
0
 /**
  * 生成发送手机验证码(未采用任何验证),历史版本方法,等待私有化
  * $mobile 手机号
  *
  * 返回
  * success
  */
 public function send_sms()
 {
     $app_id = intval($this->input['app_id']);
     $appName = $this->input['app_name'];
     if ($this->settings['closesms']) {
         $this->errorOutput($this->settings['error_text']['closesms']);
     }
     $mobile = trim($this->input['mobile']);
     if (!$mobile) {
         $this->errorOutput(MOBILE_NOT_NUMBER);
     }
     if ($this->mSmslog->check_max_limits($mobile)) {
         $this->errorOutput($this->settings['error_text']['sms_max_limits']);
     }
     //简单验证手机号格式
     if (!hg_verify_mobile($mobile)) {
         $this->errorOutput(MOBILE_NUMBER_FORMAT_ERROR);
     }
     /*******************************增加可以指定短信配置进行发短信*************************************/
     if ($this->input['m_server_id']) {
         $condition = " AND status = 1 AND id = '" . $this->input['m_server_id'] . "' ";
     } else {
         $condition = " AND status = 1 ORDER BY over DESC LIMIT 1";
     }
     /*******************************增加可以指定短信配置进行发短信*************************************/
     //限制应用的发送短信条数
     if ($app_id) {
         $app_sms_record = $this->app_sms_count->detail($app_id);
         if ($app_sms_record) {
             //判断时间是否是上个月  如果是,把total清零
             $last_sms_time = $app_sms_record['last_send_time'];
             if (date('Y-m', TIMENOW) > date('Y-m', $last_sms_time)) {
                 $this->app_sms_count->update($app_id, array('total' => 0, 'last_send_time' => TIMENOW));
                 //重新获取计数
                 $app_sms_record = $this->app_sms_count->detail($app_id);
             }
             $balance = $app_sms_record['total'];
             $limit_count = MAX_SENDSMS_COUNT_LIMITS + $app_sms_record['recharge'];
             if ($balance >= $limit_count) {
                 $this->errorOutput(SMS_BALANCE_NOT_ENOUGH);
             }
         }
     }
     $sms_server = $this->mSmsServer->get_sms_server_info($condition);
     $sms_server = $sms_server[0];
     if (empty($sms_server)) {
         $this->errorOutput(SMS_NOT);
     }
     $verifycode_length = $sms_server['verifycode_length'];
     $verifycode_content = $sms_server['verifycode_content'];
     $content = $sms_server['content'];
     if ($verifycode = $this->db->query_first("SELECT * FROM " . DB_PREFIX . "mobile_verifycode WHERE mobile='" . $mobile . "' AND create_time >= " . intval(TIMENOW - VERIFYCODE_EXPIRED_TIME) . " ORDER BY create_time DESC")) {
         $verifycode = $verifycode['verifycode'];
     } else {
         $verifycode = hg_set_verifycode($verifycode_length, $verifycode_content);
     }
     if (!$verifycode) {
         $this->errorOutput(VERIFY_MAKE_FAILED);
     }
     if (strstr($content, '{$c}')) {
         $content = str_replace('{$c}', $verifycode, $content);
     } else {
         if (strstr($content, ''{$c}'')) {
             $content = str_replace(''{$c}'', $verifycode, $content);
         }
     }
     //为应用名称处理短信发送接口
     if (strstr($content, '{$app}')) {
         if (strstr($content, '{$app}')) {
             $content = str_replace('{$app}', $appName, $content);
         } else {
             if (strstr($content, ''{$app}'')) {
                 $content = str_replace(''{$app}'', $appName, $content);
             }
         }
     }
     if ($sms_server['charset'] != 'UTF-8') {
         $content = iconv('UTF-8', $sms_server['charset'], $content);
     }
     //替换相关变量
     $url = $sms_server['send_url'];
     if (strstr($url, '{$mobile}')) {
         $url = str_replace('{$mobile}', $mobile, $url);
     }
     if (strstr($url, '{$content}')) {
         $url = str_replace('{$content}', $content, $url);
     }
     /*
     $data = array(
     'mobile'		=> $mobile,
     'verifycode'	=> $verifycode,
     'create_time'	=> TIMENOW,
     );
     if ($this->settings['closesms'])
     {
     $ret = $this->mSmsServer->mobile_verifycode_create($data);
     $this->addItem($data);
     $this->output();
     }
     */
     if (!$sms_server['return_type']) {
         $type = 'json';
     } else {
         $type = $sms_server['return_type'];
     }
     $return = $this->mSmsServer->curl_get($url, $type);
     if (isset($return['return']) && $return['return'] || $return['result'] == '01' || isset($return['result']['err_code']) && $return['result']['err_code'] == '0') {
         //入手机验证码库
         $data = array('mobile' => $mobile, 'verifycode' => $verifycode, 'create_time' => TIMENOW);
         $ret = $this->mSmsServer->mobile_verifycode_create($data);
         //纪录发送记录和次数
         $this->mSmslog->replace($mobile);
         //记录app发送的次数和最后的时间
         if ($app_id) {
             $this->record_app_count($app_id);
         }
         if (!$ret) {
             $this->errorOutput(VERIFY_ADD_FAILED);
         }
         $this->addItem('success');
         $this->output();
     } else {
         $this->errorOutput(VERIFY_SEND_FAILED);
     }
 }
Example #4
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);
         }
     }
 }
Example #5
0
    public function mobiletypem2otoshouji()
    {
        $updatetotalPath = CACHE_DIR . 'mtosupdatetotal.txt';
        $progressPath = CACHE_DIR . 'mtosprogress.txt';
        $totalPath = CACHE_DIR . 'mtostotal.txt';
        $is_next = true;
        if (file_exists($progressPath) && file_exists($totalPath)) {
            $progress = file_get_contents($progressPath);
            $total = file_get_contents($totalPath);
            $newlegth = intval($progress + LENGTH);
            if ($newlegth > intval($total)) {
                $newlegth = $total;
                $is_next = false;
            }
        } else {
            file_put_contents($progressPath, 0);
            $sql = 'SELECT count(member_id) as total FROM ' . DB_PREFIX . 'member WHERE 1 AND member_name >= 10000000000 AND member_name <= 99999999999 AND type =  \'m2o\'';
            $count = $this->db->query_first($sql);
            file_put_contents($totalPath, $count['total']);
            $newlegth = 0;
            $total = $count['total'];
        }
        $sql = 'SELECT member_id,member_name FROM ' . DB_PREFIX . 'member WHERE 1 AND member_name >= 10000000000 AND member_name <= 99999999999 AND type =  \'m2o\' LIMIT ' . $newlegth . ',' . LENGTH;
        $query = $this->db->query($sql);
        $member_id = array();
        while ($row = $this->db->fetch_array($query)) {
            if (hg_verify_mobile($row['member_name'])) {
                $member_id[$row['member_id']] = array('member_name' => $row['member_name']);
            }
        }
        if ($member_id) {
            foreach ($member_id as $key => $val) {
                if ($key) {
                    $sql = 'UPDATE ' . DB_PREFIX . 'member SET mobile = ' . $val['member_name'] . ',type=\'shouji\',type_name = \'手机快速注册\' WHERE member_id = ' . $key;
                    $this->db->query($sql);
                    $membercount = array();
                    $sql = 'SELECT count(*) as total FROM ' . DB_PREFIX . 'member_bind WHERE member_id = ' . $key . ' AND type = \'shouji\' AND is_primary = 0';
                    $membercount = $this->db->query_first($sql);
                    if ($membercount['total']) {
                        $sql = 'DELETE FROM ' . DB_PREFIX . 'member_bind WHERE member_id = ' . $key . ' AND type = \'shouji\' AND is_primary = 0';
                        $this->db->query($sql);
                    }
                    $membercount = array();
                    $sql = 'SELECT count(*) as total FROM ' . DB_PREFIX . 'member_bind WHERE is_primary = 1 AND member_id = ' . $key;
                    $membercount = $this->db->query_first($sql);
                    if ($membercount['total']) {
                        $sql = 'UPDATE ' . DB_PREFIX . 'member_bind SET
					 platform_id = \'' . $val['member_name'] . '\',type=\'shouji\',type_name = \'手机快速注册\' WHERE is_primary = 1 AND member_id = ' . $key;
                        $this->db->query($sql);
                    }
                    if (!$membercount['total']) {
                        $sql = 'UPDATE ' . DB_PREFIX . 'member_bind SET
					      platform_id = \'' . $val['member_name'] . '\',type=\'shouji\',type_name = \'手机快速注册\',is_primary = 1  WHERE type = \'m2o\' AND member_id = ' . $key;
                        $this->db->query($sql);
                    }
                    $sql = 'UPDATE ' . DB_PREFIX . 'member_bind SET inuc = 0 WHERE member_id = ' . $key;
                    $this->db->query($sql);
                    $updatetotal = 0;
                    file_exists($updatetotalPath) && ($updatetotal = file_get_contents($updatetotalPath));
                    file_put_contents($updatetotalPath, $updatetotal + 1);
                } else {
                    echo "数据修复出错";
                    exit;
                }
            }
            file_put_contents($progressPath, $newlegth);
            if ($is_next) {
                $percent = round(intval($newlegth) / intval($total) * 100, 2) . "%";
                echo $message = '系统正在修复数据,别打扰唉...' . $percent;
                $this->redirect('membersDataRecovery.php?a=mobiletypem2otoshouji');
            }
            echo "数据修复完成";
            exit;
        } else {
            if ($newlegth < intval($total)) {
                file_put_contents($progressPath, $newlegth);
                $percent = round(intval($newlegth) / intval($total) * 100, 2) . "%";
                echo $message = '系统正在修复数据,别打扰唉...' . $percent;
                $this->redirect('membersDataRecovery.php?a=mobiletypem2otoshouji');
            } else {
                echo "已经修复完成,请勿重复修复数据";
            }
        }
        exit;
    }
Example #6
0
 /**
  *
  * 检测手机号是否在主表mobile字段存在 ...
  * @param int $mobile 检测的手机号
  * @param int $member_id 检测的用户
  * @return int -1为如果
  */
 public function checkMobile($mobile, $member_id = 0)
 {
     if (!hg_verify_mobile($mobile)) {
         return -1;
         //手机号格式不正确
     }
     $reMember = array();
     if ($mobile) {
         $sql = 'SELECT member_id FROM ' . DB_PREFIX . 'member WHERE mobile = \'' . $mobile . '\'';
         $reMember = $this->db->query_first($sql);
     }
     if ($reMember) {
         if ($member_id && $member_id == $reMember[member_id]) {
             return 2;
             //已存在,但是属于自己
         }
         return 1;
         //已存在
     }
     return 0;
     //未绑定
 }
Example #7
0
 /**
  *  检查手机号 格式 是否被注册
  */
 public function checkmobile()
 {
     try {
         $identifierUserSystem = new identifierUserSystem();
         $mobile = $this->input['mobile'] ? $this->input['mobile'] : 0;
         $identifier = $identifierUserSystem->setIdentifier((int) $this->input['identifier'])->checkIdentifier();
         //多用户系统
         if ($mobile && !hg_verify_mobile($mobile)) {
             $this->errorOutput(MOBILE_NUMBER_FORMAT_ERROR);
         } else {
             if ($mobile || defined('NO_VERIFY_MOBILEBIND') && NO_VERIFY_MOBILEBIND) {
                 $check_bind = new check_Bind();
                 if ($check_bind->checkmembernamereg($mobile, $identifier)) {
                     $this->errorOutput(MOBILE_REG_BIND);
                 }
             }
         }
     } catch (Exception $e) {
         $this->errorOutput($e->getMessage(), $e->getCode());
     }
 }
Example #8
0
 /**
  * 生成发送手机验证码
  * $mobile 手机号
  *
  * 返回
  * success
  */
 private function send_sms()
 {
     if ($this->settings['closesms']) {
         $this->errorOutput($this->settings['error_text']['closesms']);
     }
     $mobile = trim($this->input['mobile']);
     if (!$mobile) {
         $this->errorOutput(MOBILE_NOT_NUMBER);
     }
     if ($this->mSmslog->check_max_limits($mobile)) {
         $this->errorOutput($this->settings['error_text']['sms_max_limits']);
     }
     //简单验证手机号格式
     if (!hg_verify_mobile($mobile)) {
         $this->errorOutput(MOBILE_NUMBER_FORMAT_ERROR);
     }
     $condition = " AND id = 2 AND status = 1 ORDER BY over DESC LIMIT 1";
     $sms_server = $this->mSmsServer->get_sms_server_info($condition);
     $sms_server = $sms_server[0];
     if (empty($sms_server)) {
         $this->errorOutput(SMS_NOT);
     }
     $content = $sms_server['content'];
     if (strstr($content, '{&#036;c}')) {
         $content = str_replace('{&#036;c}', $this->user['user_name'], $content);
     } else {
         if (strstr($content, '&#39;{&#036;c}&#39;')) {
             $content = str_replace('&#39;{&#036;c}&#39;', $this->user['user_name'], $content);
         }
     }
     if ($sms_server['charset'] != 'UTF-8') {
         $content = iconv('UTF-8', $sms_server['charset'], $content);
     }
     //替换相关变量
     $url = $sms_server['send_url'];
     if (strstr($url, '{&#036;mobile}')) {
         $url = str_replace('{&#036;mobile}', $mobile, $url);
     }
     if (strstr($url, '{&#036;content}')) {
         $url = str_replace('{&#036;content}', $content, $url);
     }
     if (!$sms_server['return_type']) {
         $type = 'json';
     } else {
         $type = $sms_server['return_type'];
     }
     $return = $this->mSmsServer->curl_get($url, $type);
     if (isset($return['return']) && $return['return'] || $return['result'] == '01' || isset($return['result']['err_code']) && $return['result']['err_code'] == '0') {
         //纪录发送次数
         $this->mSmslog->replace($mobile);
         return true;
     } else {
         return false;
     }
 }
Example #9
0
 /**
  * 
  * 补充新浪绑定,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());
     }
 }
Example #10
0
 private function checkUserName($memberName, $isEnforce = 0)
 {
     !$this->oldtype && ($this->oldtype = $this->input['type'] = trimall($this->input['type']));
     if (!$this->oldtype || $this->settings['autoLoginReviseType'] || $isEnforce) {
         if (hg_verify_mobile($memberName)) {
             $this->input['type'] = 'shouji';
         } else {
             if (hg_check_email_format($memberName)) {
                 $this->input['type'] = 'email';
             } else {
                 if (!$this->oldtype || $isEnforce) {
                     $this->input['type'] = 'm2o';
                 }
             }
         }
     }
     return $memberName;
 }
Example #11
0
 public function update()
 {
     //guid 会员唯一标示
     if ($guid = $this->input['guid']) {
         $condition = ' AND guid="' . $guid . '"';
         $memberInfo = $this->mMember->get_member_info($condition);
         if ($memberInfo) {
             $member_id = $memberInfo[0]['member_id'];
         }
     } else {
         $member_id = intval($this->input['member_id']);
     }
     $member_name = trim($this->input['member_name']);
     $nick_name = trim($this->input['nick_name']);
     $password = trim($this->input['password']);
     $mobile = $this->input['mobile'] ? intval($this->input['mobile']) : '';
     $email = $this->input['email'] ? trim($this->input['email']) : '';
     $im_token = $this->input['im_token'] ? trim($this->input['im_token']) : '';
     $signature = $this->input['signature'] ? trim(urldecode($this->input['signature'])) : '';
     if (!$member_id) {
         $this->errorOutput(NO_MEMBER_ID);
     }
     $identifier = $this->mMember->getIdentifierForMemberId($member_id);
     if (!empty($member_name) && !$this->mMember->isMemberNameUpdate($member_id, 1)) {
         $this->errorOutput(NOT_EDIT_MEMBERNAME);
     }
     if (!$nick_name) {
         $nick_name = $member_name ? $member_name : $this->Members->get_member_name($member_id, false);
     }
     if (!hg_verify_mobile($mobile) && !empty($mobile)) {
         $this->errorOutput(MOBILE_NUMBER_FORMAT_ERROR);
     }
     $reg_mail = $this->Members->check_reg_mail($email, $member_id, $identifier);
     if ($reg_mail == -4) {
         $this->errorOutput(EMAIL_FORMAT_ERROR);
     } elseif ($reg_mail == -6) {
         $this->errorOutput(EMAIL_HAS_BINDED);
     }
     //头像
     $avatar = array();
     if ($_FILES['avatar']['tmp_name']) {
         $avatar = $_FILES['avatar'];
     }
     $data = array('member_id' => $member_id, 'update_time' => TIMENOW);
     if ($im_token) {
         $data['im_token'] = $im_token;
     }
     if ($mobile) {
         $data['mobile'] = $mobile;
     }
     if ($email) {
         $data['email'] = $email;
     }
     if ($signature) {
         $data['signature'] = $signature;
     }
     //验证会员名
     if ($member_name) {
         switch ($this->mMember->verify_member_name($member_name, $member_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;
         }
         $data['member_name'] = $member_name;
     }
     $member_name = $this->Members->get_member_name($member_id);
     if ($this->settings['ucenter']['open'] && !$identifier) {
         $is_password = $this->mMember->uc_user_edit($member_name[$member_id], $oldpw, $password, $email, 1);
         if ($is_password < 0) {
             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
         $md5_password = md5(md5($password) . $salt);
         $data['password'] = $md5_password;
         $data['salt'] = $salt;
     }
     //更新积分
     if ($this->input['credit'] && is_array($this->input['credit'])) {
         $credit_log = array('app_uniqueid' => APP_UNIQUEID, 'mod_uniqueid' => MOD_UNIQUEID, 'action' => $this->input['a'], 'method' => 'admin_update_members', 'relatedid' => $this->user['user_id'], 'title' => '积分变更', 'remark' => '管理员操作');
         if ($grade_credits_type = $this->Members->get_grade_credits_type(1)) {
             if ($this->input['credit'][$grade_credits_type['db_field']] < 0) {
                 $this->errorOutput($grade_credits_type['title'] . '不允许为负数');
             }
         }
         $this->Members->credits($this->input['credit'], $member_id, $coef = 1, false, false, true, null, array(), $credit_log);
     }
     //更新用户组
     $gid = intval($this->input['groupid']);
     $groupexpiry = $this->input['groupexpiry'] ? trim($this->input['groupexpiry']) : 0;
     $this->Members->updategroup($member_id, $gid, $groupexpiry);
     //更新黑名单
     $deadline = !empty($this->input['blacklist']) ? !empty($this->input['isblack']) ? $this->input['isblack'] : -1 : 0;
     if (!empty($this->input['blacklist'])) {
         $this->Members->blacklist_set($member_id, $deadline);
     }
     //更新勋章
     $medalid = !empty($this->input['medal_id']) ? $this->input['medal_id'] : '';
     $this->member_medal->edit_member_medal($member_id, $medalid);
     //会员数据入库
     $ret = $this->mMember->update($data);
     if (!$ret['member_id']) {
         $this->errorOutput(MEMBER_DATA_UPDATE_FAILED);
     }
     $data['member_id'] = $member_id;
     $this->mMemberInfo->extension_edit($member_id, $this->input['member_info'], $_FILES);
     //扩展信息编辑
     //头像入库
     if (!empty($avatar)) {
         $avatar = $this->mMember->add_material($avatar, $member_id);
         if (!empty($avatar)) {
             $update_data = array('member_id' => $member_id, 'avatar' => maybe_serialize($avatar));
             $ret_updata = $this->mMember->update($update_data);
             if (!$ret_updata['member_id']) {
                 $this->errorOutput(AVATAR_ADD_FAILED);
             }
         }
     }
     $bind_info = array();
     if ($nick_name) {
         $bind_info = array('nick_name' => $nick_name);
     }
     if ($bind_info) {
         $this->mMember->bind_update($bind_info, 'WHERE member_id = \'' . $member_id . '\'');
     }
     //会员痕迹
     $member_trace_data = array('member_id' => $this->user['user_id'], 'member_name' => $this->user['user_name'], 'content_id' => $member_id, 'title' => $member_name[$member_id], 'type' => 'adminedit', 'op_type' => '管理员更新会员资料', 'appid' => $this->user['appid'], 'appname' => $this->user['display_name'], 'create_time' => TIMENOW, 'ip' => hg_getip(), 'device_token' => 'admin', 'udid' => 'admin');
     $this->mMember->member_trace_create($member_trace_data);
     $this->addItem($member_id);
     $this->output();
 }
Example #12
0
 /**
  *
  * 获取找回密码邮箱验证码接口...
  */
 public function getResetPasswordlinkMail()
 {
     $memberId = 0;
     $link_url = $this->input['link_url'];
     $identifierUserSystem = new identifierUserSystem();
     $identifier = $identifierUserSystem->setIdentifier((int) $this->input['identifier'])->checkIdentifier();
     //多用户系统
     if ($memberName = trimall($this->input['member_name'])) {
         $this->email = $memberName;
         $nick_name = '用户';
         if (hg_check_email_format($memberName)) {
             $condition = " AND platform_id='" . $memberName . "' AND mb.type='email' AND mb.identifier=" . $identifier . "";
             $leftjoin = " LEFT JOIN " . DB_PREFIX . "member_bind as mb ON m.member_id=mb.member_id ";
             $memberInfo = $this->Members->get_member_info($condition, $field = ' mb.* ', $leftjoin, '', false);
             $nick_name = $memberInfo['nick_name'];
         }
         $this->type = 'resetpassword';
         $this->appuniqueid = 'resetpassword_link';
         $this->tspace = array(hg_verify_mobile($memberName) ? hg_hide_mobile($memberName) : $memberName);
         $this->verify_email();
         $this->_expire_time = $this->settings['email_token_limit']['time_limit'] ? TIMENOW + $this->settings['email_token_limit']['time_limit'] : TIMENOW + 1000;
         $condition = " AND email='" . $memberName . "' AND status=0";
         $email_token_info = $this->email_token->show($condition, ' ORDER BY id DESC ', 'limit 1');
         if (!$email_token_info) {
             $this->token = $this->makeToken(16);
         } else {
             $this->token = $email_token_info[0]['token'];
             //如果该验证码已经过期就重新生成验证码
             if ($email_token_info[0]['expire_time'] < TIMENOW) {
                 $this->token = $this->makeToken(16);
             } else {
                 //如果没有过期,过期时间还是原来的
                 $this->_expire_time = $email_token_info[0]['expire_time'];
             }
         }
         $url = $link_url . '&email=' . $memberName . '&token=' . $this->token;
         $this->bspace = array($memberName, $nick_name, $url);
         $sendInfo = $this->generate_link_email();
         if ($sendInfo) {
             $output = array('email' => $sendInfo['email']);
             $this->addItem($output);
         }
         $this->output();
     } else {
         $this->errorOutput(NO_MEMBER_NAME);
     }
 }