/**
  * 在UC和DZX进行用户初始化注册
  * @access protected
  * @return boolen
  */
 function _regToUCDZX()
 {
     global $_G;
     $this->uid = (int) uc_user_register($this->username, $this->password, $this->email, $this->questionid, $this->answer);
     //----------------add by zh--------------------------
     $passp = new passport();
     $pass = $passp->useradd($this->uid, $this->username, $this->password, $this->email, $this->ip, $this->groupid, $this->nickname);
     //add
     if (is_array($pass)) {
         $psptuser = $passp->passport_setsession($pass, 2592000, $this->ip);
         //add
     } else {
         if ($pass == "userisexist") {
             uc_user_delete($this->uid);
             $this->uid = -3;
         } else {
             if ($pass == "nicknameexist") {
                 uc_user_delete($this->uid);
                 $this->uid = -7;
             } else {
                 uc_user_delete($this->uid);
                 $this->uid = -8;
             }
         }
     }
     //-------------add end-------------------------------
     if ($this->uid > 0) {
         //在有UC的情况下,附属论坛的members表password列并不存储真实密码,只是用于cookies登陆状态校样。
         $init_arr = explode(',', $_G['setting']['initcredits']);
         $userdata = array('uid' => $this->uid, 'username' => $this->username, 'password' => md5(rand(100000, 999999)), 'email' => $this->email, 'adminid' => 0, 'groupid' => $this->groupid, 'regdate' => $this->timestamp, 'credits' => $init_arr[0], 'timeoffset' => 9999);
         DB::insert('common_member', $userdata);
         $status_data = array('uid' => $this->uid, 'regip' => $this->ip, 'lastip' => $this->ip, 'lastvisit' => $this->timestamp, 'lastactivity' => $this->timestamp, 'lastpost' => 0, 'lastsendmail' => 0);
         DB::insert('common_member_status', $status_data);
         $profile['uid'] = $this->uid;
         $profile['field1'] = $this->nickname;
         //add by zh
         DB::insert('common_member_profile', $profile);
         DB::insert('common_member_field_forum', array('uid' => $this->uid));
         DB::insert('common_member_field_home', array('uid' => $this->uid));
         //初始化积分
         $count_data = array('uid' => $this->uid, 'extcredits1' => $init_arr[1], 'extcredits2' => $init_arr[2], 'extcredits3' => $init_arr[3], 'extcredits4' => $init_arr[4], 'extcredits5' => $init_arr[5], 'extcredits6' => $init_arr[6], 'extcredits7' => $init_arr[7], 'extcredits8' => $init_arr[8]);
         DB::insert('common_member_count', $count_data);
         DB::insert('common_setting', array('skey' => 'lastmember', 'svalue' => $this->username), false, true);
         manyoulog('user', $this->uid, 'add');
         return true;
     } else {
         return false;
     }
 }
Esempio n. 2
0
 /**
  * 配置会员整合插件
  */
 public function setting()
 {
     if (IS_POST) {
         $code = $this->_post('code', 'trim');
         $mod = passport::uc($code);
         $info = $mod->get_info();
         foreach ($info['config'] as $key => $val) {
             $config[$key] = $this->_post($key);
         }
         $config = serialize($config);
         //保存到配置表
         D('setting')->where(array('name' => 'integrate_code'))->setField('data', $code);
         D('setting')->where(array('name' => 'integrate_config'))->setField('data', $config);
         $this->success(L('operation_success'), U('integrate/index'));
     } else {
         $code = $this->_get('code', 'trim');
         $mod = passport::uc($code);
         //获取配置项
         $info = $mod->get_info();
         $this->assign('info', $info);
         //获取配置值
         $this->assign('icv', C('pin_integrate_config'));
         $this->display();
     }
 }
Esempio n. 3
0
 /**
  * 登陆回调
  */
 public function callbackLogin($request_args)
 {
     $user = $this->_om->getUserInfo($request_args);
     $bind_user = $this->_checkBind($this->_type, $user['keyid']);
     if ($bind_user) {
         //已经绑定过则更新绑定信息 自动登陆
         $this->_updateBindInfo($user);
         $user_info = M('user')->field('id,username,sign_time,score,status')->where(array('id' => $bind_user['uid']))->find();
         if ($this->isOnline($user_info['id'])) {
             if ($user_info['status']) {
                 //检测是否有同一IP的记录,有更新,否则 添加
                 $online = M('Online');
                 $map = array();
                 $map['ip'] = get_client_ip();
                 $online_id = $online->where($map)->getField('id');
                 if (empty($online_id)) {
                     //插入在线用户表
                     $data = array();
                     $data['uid'] = $user_info['id'];
                     $data['account'] = $user_info['username'];
                     $data['username'] = $user_info['username'];
                     $data['lasttime'] = time();
                     $data['ip'] = get_client_ip();
                     $online->add($data);
                 } else {
                     //更新在线用户表
                     $data = array();
                     $data['uid'] = $user_info['id'];
                     $data['account'] = $user_info['username'];
                     $data['username'] = $user_info['username'];
                     $data['lasttime'] = time();
                     $online->where($map)->save($data);
                 }
             } else {
                 $is_error = true;
                 //帐号已经被锁定
                 session('user_info', null);
                 cookie('user_info', null);
             }
         }
         //登陆
         $this->_oauth_visitor()->assign_info($user_info);
         return U('index/index');
     } else {
         //处理用户名
         if (M('user')->where(array('username' => $user['keyname']))->count()) {
             $user['ftx_user_name'] = $user['keyname'] . '_' . mt_rand(99, 9999);
         } else {
             $user['ftx_user_name'] = $user['keyname'];
         }
         $username = $user['ftx_user_name'];
         $user['ftx_user_name'] = urlencode($user['ftx_user_name']);
         $user['keyname'] = urlencode($user['keyname']);
         if ($user['keyavatar_big']) {
             //下载原始头像到本地临时储存  用日期文件夹分类  方便清理
             $user['temp_avatar'] = '';
             $avatar_temp_root = C('ftx_attach_path') . 'avatar/temp/';
             $temp_dir = date('ymd', time()) . '/';
             $file_name = date('ymdhis' . mt_rand(1000, 9999)) . '.jpg';
             mkdir($avatar_temp_root . $temp_dir);
             $image_content = Http::fsockopenDownload($user['keyavatar_big']);
             file_put_contents($avatar_temp_root . $temp_dir . $file_name, $image_content);
             $user['temp_avatar'] = $temp_dir . $file_name;
         }
         $user['type'] = $this->_type;
         //连接用户中心
         $passport = new passport(C('ftx_integrate_code'));
         // $passport = $this->_user_server();
         //注册
         $passw = mt_rand(111111, 999999);
         $uid = $passport->register($username, $passw);
         !$uid && exit($passport->get_error());
         $bind_info = array('ftx_uid' => $uid, 'ftx_username' => $username, 'keyid' => $user['keyid'], 'bind_info' => $user['bind_info']);
         $this->bindByData($bind_info);
         $tag_arg = array('uid' => $uid, 'uname' => $username, 'action' => 'register');
         tag('register_end', $tag_arg);
         //邀请注册奖励
         $union_date = array('uid' => $uid, 'username' => $username);
         D('user')->union_reg($union_date);
         //登陆
         $this->visitor = new user_visitor();
         $this->visitor->login($uid);
         //登陆完成
         $tag_arg = array('uid' => $uid, 'uname' => $username, 'action' => 'login');
         tag('login_end', $tag_arg);
         //同步登陆
         $synlogin = $passport->synlogin($uid);
         //$this->success(L('register_successe').$synlogin.'您的密码为 '.$passw.'  ', U('user/index'));
         return U('index/index');
     }
 }
Esempio n. 4
0
        } else {
            if ($strTime == 0) {
                $result = array('status' => 3);
                #缺少参数
            } else {
                if ($strUserAccount == "") {
                    $result = array('status' => 3);
                    #缺少参数
                } else {
                    if (time() - $strTime > $timeExpire) {
                        $result = array('status' => 2);
                        //时间过期
                    }
                }
            }
        }
        if ($result > 0) {
            echo json_encode($result);
            exit;
        }
        $arrData['nologin'] = $iNologin;
        if ($strTocken) {
            $arrData['tocken'] = $strTocken;
        }
        $this->_action = ucfirst($strAction) . 'Action';
        $this->_command = $strCommand;
        $this->_parseData = $arrData;
    }
}
$objPassport = new passport();
$objPassport->dispatch();
 function on_register()
 {
     global $_G;
     // For ios registe add by heavenK
     if (!$_GET['phone_reg']) {
         $_GET['username'] = $_GET['' . $this->setting['reginput']['username']];
         $_GET['password'] = $_GET['' . $this->setting['reginput']['password']];
         $_GET['password2'] = $_GET['' . $this->setting['reginput']['password2']];
         $_GET['email'] = $_GET['' . $this->setting['reginput']['email']];
     }
     // end
     /*		$_GET['username'] = $_GET[''.$this->setting['reginput']['username']];
     		$_GET['password'] = $_GET[''.$this->setting['reginput']['password']];
     		$_GET['password2'] = $_GET[''.$this->setting['reginput']['password2']];
     		$_GET['email'] = $_GET[''.$this->setting['reginput']['email']];*/
     if ($_G['uid']) {
         $ucsynlogin = $this->setting['allowsynlogin'] ? uc_user_synlogin($_G['uid']) : '';
         $url_forward = dreferer();
         if (strpos($url_forward, $this->setting['regname']) !== false) {
             $url_forward = 'forum.php';
         }
         showmessage('login_succeed', $url_forward ? $url_forward : './', array('username' => $_G['member']['username'], 'usergroup' => $_G['group']['grouptitle'], 'uid' => $_G['uid']), array('extrajs' => $ucsynlogin));
     } elseif (!$this->setting['regclosed'] && (!$this->setting['regstatus'] || !$this->setting['ucactivation'])) {
         if ($_GET['action'] == 'activation' || $_GET['activationauth']) {
             if (!$this->setting['ucactivation'] && !$this->setting['closedallowactivation']) {
                 showmessage('register_disable_activation');
             }
         } elseif (!$this->setting['regstatus']) {
             showmessage(!$this->setting['regclosemessage'] ? 'register_disable' : str_replace(array("\r", "\n"), '', $this->setting['regclosemessage']));
         }
     }
     $bbrules =& $this->setting['bbrules'];
     $bbrulesforce =& $this->setting['bbrulesforce'];
     $bbrulestxt =& $this->setting['bbrulestxt'];
     $welcomemsg =& $this->setting['welcomemsg'];
     $welcomemsgtitle =& $this->setting['welcomemsgtitle'];
     $welcomemsgtxt =& $this->setting['welcomemsgtxt'];
     $regname = $this->setting['regname'];
     if ($this->setting['regverify']) {
         if ($this->setting['areaverifywhite']) {
             $location = $whitearea = '';
             $location = trim(convertip($_G['clientip'], "./"));
             if ($location) {
                 $whitearea = preg_quote(trim($this->setting['areaverifywhite']), '/');
                 $whitearea = str_replace(array("\\*"), array('.*'), $whitearea);
                 $whitearea = '.*' . $whitearea . '.*';
                 $whitearea = '/^(' . str_replace(array("\r\n", ' '), array('.*|.*', ''), $whitearea) . ')$/i';
                 if (@preg_match($whitearea, $location)) {
                     $this->setting['regverify'] = 0;
                 }
             }
         }
         if ($_G['cache']['ipctrl']['ipverifywhite']) {
             foreach (explode("\n", $_G['cache']['ipctrl']['ipverifywhite']) as $ctrlip) {
                 if (preg_match("/^(" . preg_quote($ctrlip = trim($ctrlip), '/') . ")/", $_G['clientip'])) {
                     $this->setting['regverify'] = 0;
                     break;
                 }
             }
         }
     }
     $invitestatus = false;
     if ($this->setting['regstatus'] == 2) {
         if ($this->setting['inviteconfig']['inviteareawhite']) {
             $location = $whitearea = '';
             $location = trim(convertip($_G['clientip'], "./"));
             if ($location) {
                 $whitearea = preg_quote(trim($this->setting['inviteconfig']['inviteareawhite']), '/');
                 $whitearea = str_replace(array("\\*"), array('.*'), $whitearea);
                 $whitearea = '.*' . $whitearea . '.*';
                 $whitearea = '/^(' . str_replace(array("\r\n", ' '), array('.*|.*', ''), $whitearea) . ')$/i';
                 if (@preg_match($whitearea, $location)) {
                     $invitestatus = true;
                 }
             }
         }
         if ($this->setting['inviteconfig']['inviteipwhite']) {
             foreach (explode("\n", $this->setting['inviteconfig']['inviteipwhite']) as $ctrlip) {
                 if (preg_match("/^(" . preg_quote($ctrlip = trim($ctrlip), '/') . ")/", $_G['clientip'])) {
                     $invitestatus = true;
                     break;
                 }
             }
         }
     }
     $groupinfo = array();
     if ($this->setting['regverify']) {
         $groupinfo['groupid'] = 8;
     } else {
         $groupinfo['groupid'] = $this->setting['newusergroupid'];
     }
     $seccodecheck = $this->setting['seccodestatus'] & 1;
     $secqaacheck = $this->setting['secqaa']['status'] & 1;
     $fromuid = !empty($_G['cookie']['promotion']) && $this->setting['creditspolicy']['promotion_register'] ? intval($_G['cookie']['promotion']) : 0;
     $username = isset($_GET['username']) ? $_GET['username'] : '';
     $bbrulehash = $bbrules ? substr(md5(FORMHASH), 0, 8) : '';
     $auth = $_GET['auth'];
     if (!$invitestatus) {
         $invite = getinvite();
     }
     $sendurl = $this->setting['sendregisterurl'] ? true : false;
     if ($sendurl) {
         if (!empty($_GET['hash'])) {
             $hash = explode("\t", authcode($_GET['hash'], 'DECODE', $_G['config']['security']['authkey']));
             if (is_array($hash) && isemail($hash[0]) && TIMESTAMP - $hash[1] < 259200) {
                 $sendurl = false;
             }
         }
     }
     if (!submitcheck('regsubmit', 0, $seccodecheck, $secqaacheck)) {
         if (!$sendurl) {
             if ($_GET['action'] == 'activation') {
                 $auth = explode("\t", authcode($auth, 'DECODE'));
                 if (FORMHASH != $auth[1]) {
                     showmessage('register_activation_invalid', 'member.php?mod=logging&action=login');
                 }
                 $username = $auth[0];
                 $activationauth = authcode("{$auth['0']}\t" . FORMHASH, 'ENCODE');
             }
             if ($fromuid) {
                 $member = getuserbyuid($fromuid);
                 if (!empty($member)) {
                     $fromuser = dhtmlspecialchars($member['username']);
                 } else {
                     dsetcookie('promotion');
                 }
             }
             if ($_GET['action'] == 'activation') {
                 $auth = dhtmlspecialchars($auth);
             }
             if ($seccodecheck) {
                 $seccode = random(6, 1);
             }
             $username = dhtmlspecialchars($username);
             $htmls = $settings = array();
             foreach ($_G['cache']['fields_register'] as $field) {
                 $fieldid = $field['fieldid'];
                 $html = profile_setting($fieldid, array(), false, false, true);
                 if ($html) {
                     $settings[$fieldid] = $_G['cache']['profilesetting'][$fieldid];
                     $htmls[$fieldid] = $html;
                 }
             }
             $navtitle = $this->setting['reglinkname'];
             if ($this->extrafile && file_exists($this->extrafile)) {
                 require_once $this->extrafile;
             }
         }
         $bbrulestxt = nl2br("\n{$bbrulestxt}\n\n");
         $dreferer = dreferer();
         include template($this->template);
     } else {
         if ($sendurl) {
             checkemail($_GET['email']);
             $hashstr = urlencode(authcode("{$_GET['email']}\t{$_G['timestamp']}", 'ENCODE', $_G['config']['security']['authkey']));
             $registerurl = "{$_G[siteurl]}member.php?mod=" . $this->setting['regname'] . "&amp;hash={$hashstr}&amp;email={$_GET[email]}";
             $email_register_message = lang('email', 'email_register_message', array('bbname' => $this->setting['bbname'], 'siteurl' => $_G['siteurl'], 'url' => $registerurl));
             if (!sendmail("{$_GET['email']} <{$_GET['email']}>", lang('email', 'email_register_subject'), $email_register_message)) {
                 runlog('sendmail', "{$_GET['email']} sendmail failed.");
             }
             showmessage('register_email_send_succeed', dreferer(), array('bbname' => $this->setting['bbname']), array('showdialog' => true, 'msgtype' => 3, 'closetime' => 10));
         }
         $emailstatus = 0;
         if ($this->setting['sendregisterurl'] && !$sendurl) {
             $_GET['email'] = strtolower($hash[0]);
             $this->setting['regverify'] = $this->setting['regverify'] == 1 ? 0 : $this->setting['regverify'];
             if (!$this->setting['regverify']) {
                 $groupinfo['groupid'] = $this->setting['newusergroupid'];
             }
             $emailstatus = 1;
         }
         if ($this->setting['regstatus'] == 2 && empty($invite) && !$invitestatus) {
             showmessage('not_open_registration_invite');
         }
         // For ios registe add by heavenK
         if (!$_GET['phone_reg']) {
             if ($bbrules && $bbrulehash != $_POST['agreebbrule']) {
                 showmessage('register_rules_agree');
             }
         }
         // end
         /*if($bbrules && $bbrulehash != $_POST['agreebbrule']) {
         			showmessage('register_rules_agree');
         		}*/
         $activation = array();
         if (isset($_GET['activationauth'])) {
             $activationauth = explode("\t", authcode($_GET['activationauth'], 'DECODE'));
             if ($activationauth[1] == FORMHASH && !($activation = uc_get_user($activationauth[0]))) {
                 showmessage('register_activation_invalid', 'member.php?mod=logging&action=login');
             }
         }
         if (!$activation) {
             $usernamelen = dstrlen($username);
             if ($usernamelen < 3) {
                 showmessage('profile_username_tooshort');
             } elseif ($usernamelen > 15) {
                 showmessage('profile_username_toolong');
             }
             if (uc_get_user(addslashes($username)) && !C::t('common_member')->fetch_uid_by_username($username) && !C::t('common_member_archive')->fetch_uid_by_username($username)) {
                 if ($_G['inajax']) {
                     showmessage('profile_username_duplicate');
                 } else {
                     showmessage('register_activation_message', 'member.php?mod=logging&action=login', array('username' => $username));
                 }
             }
             if ($this->setting['pwlength']) {
                 if (strlen($_GET['password']) < $this->setting['pwlength']) {
                     showmessage('profile_password_tooshort', '', array('pwlength' => $this->setting['pwlength']));
                 }
             }
             if ($this->setting['strongpw']) {
                 $strongpw_str = array();
                 if (in_array(1, $this->setting['strongpw']) && !preg_match("/\\d+/", $_GET['password'])) {
                     $strongpw_str[] = lang('member/template', 'strongpw_1');
                 }
                 if (in_array(2, $this->setting['strongpw']) && !preg_match("/[a-z]+/", $_GET['password'])) {
                     $strongpw_str[] = lang('member/template', 'strongpw_2');
                 }
                 if (in_array(3, $this->setting['strongpw']) && !preg_match("/[A-Z]+/", $_GET['password'])) {
                     $strongpw_str[] = lang('member/template', 'strongpw_3');
                 }
                 if (in_array(4, $this->setting['strongpw']) && !preg_match("/[^a-zA-z0-9]+/", $_GET['password'])) {
                     $strongpw_str[] = lang('member/template', 'strongpw_4');
                 }
                 if ($strongpw_str) {
                     showmessage(lang('member/template', 'password_weak') . implode(',', $strongpw_str));
                 }
             }
             $email = strtolower(trim($_GET['email']));
             if (empty($this->setting['ignorepassword'])) {
                 if ($_GET['password'] !== $_GET['password2']) {
                     showmessage('profile_passwd_notmatch');
                 }
                 if (!$_GET['password'] || $_GET['password'] != addslashes($_GET['password'])) {
                     showmessage('profile_passwd_illegal');
                 }
                 $password = $_GET['password'];
             } else {
                 $password = md5(random(10));
             }
         }
         $censorexp = '/^(' . str_replace(array('\\*', "\r\n", ' '), array('.*', '|', ''), preg_quote($this->setting['censoruser'] = trim($this->setting['censoruser']), '/')) . ')$/i';
         if ($this->setting['censoruser'] && @preg_match($censorexp, $username)) {
             showmessage('profile_username_protect');
         }
         if ($this->setting['regverify'] == 2 && !trim($_GET['regmessage'])) {
             showmessage('profile_required_info_invalid');
         }
         if ($_G['cache']['ipctrl']['ipregctrl']) {
             foreach (explode("\n", $_G['cache']['ipctrl']['ipregctrl']) as $ctrlip) {
                 if (preg_match("/^(" . preg_quote($ctrlip = trim($ctrlip), '/') . ")/", $_G['clientip'])) {
                     $ctrlip = $ctrlip . '%';
                     $this->setting['regctrl'] = $this->setting['ipregctrltime'];
                     break;
                 } else {
                     $ctrlip = $_G['clientip'];
                 }
             }
         } else {
             $ctrlip = $_G['clientip'];
         }
         if ($this->setting['regctrl']) {
             if (C::t('common_regip')->count_by_ip_dateline($ctrlip, $_G['timestamp'] - $this->setting['regctrl'] * 3600)) {
                 showmessage('register_ctrl', NULL, array('regctrl' => $this->setting['regctrl']));
             }
         }
         $setregip = null;
         if ($this->setting['regfloodctrl']) {
             $regip = C::t('common_regip')->fetch_by_ip_dateline($_G['clientip'], $_G['timestamp'] - 86400);
             if ($regip) {
                 if ($regip['count'] >= $this->setting['regfloodctrl']) {
                     showmessage('register_flood_ctrl', NULL, array('regfloodctrl' => $this->setting['regfloodctrl']));
                 } else {
                     $setregip = 1;
                 }
             } else {
                 $setregip = 2;
             }
         }
         $profile = $verifyarr = array();
         foreach ($_G['cache']['fields_register'] as $field) {
             if (defined('IN_MOBILE')) {
                 break;
             }
             $field_key = $field['fieldid'];
             $field_val = $_GET['' . $field_key];
             if ($field['formtype'] == 'file' && !empty($_FILES[$field_key]) && $_FILES[$field_key]['error'] == 0) {
                 $field_val = true;
             }
             if (!profile_check($field_key, $field_val)) {
                 $showid = !in_array($field['fieldid'], array('birthyear', 'birthmonth')) ? $field['fieldid'] : 'birthday';
                 showmessage($field['title'] . lang('message', 'profile_illegal'), '', array(), array('showid' => 'chk_' . $showid, 'extrajs' => $field['title'] . lang('message', 'profile_illegal') . ($field['formtype'] == 'text' ? '<script type="text/javascript">' . '$(\'registerform\').' . $field['fieldid'] . '.className = \'px er\';' . '$(\'registerform\').' . $field['fieldid'] . '.onblur = function () { if(this.value != \'\') {this.className = \'px\';$(\'chk_' . $showid . '\').innerHTML = \'\';}}' . '</script>' : '')));
             }
             if ($field['needverify']) {
                 $verifyarr[$field_key] = $field_val;
             } else {
                 $profile[$field_key] = $field_val;
             }
         }
         if (!$activation) {
             $uid = uc_user_register(addslashes($username), $password, $email, $questionid, $answer, $_G['clientip']);
             if ($uid <= 0) {
                 if ($uid == -1) {
                     if ($_GET['phone_reg']) {
                         $res['registerCheck'] = -1;
                         echo json_encode($res);
                         exit;
                     }
                     showmessage('profile_username_illegal');
                 } elseif ($uid == -2) {
                     if ($_GET['phone_reg']) {
                         $res['registerCheck'] = -2;
                         echo json_encode($res);
                         exit;
                     }
                     showmessage('profile_username_protect');
                 } elseif ($uid == -3) {
                     if ($_GET['phone_reg']) {
                         $res['registerCheck'] = -3;
                         echo json_encode($res);
                         exit;
                     }
                     showmessage('profile_username_duplicate');
                 } elseif ($uid == -4) {
                     showmessage('profile_email_illegal');
                 } elseif ($uid == -5) {
                     showmessage('profile_email_domain_illegal');
                 } elseif ($uid == -6) {
                     showmessage('profile_email_duplicate');
                 } else {
                     if ($_GET['phone_reg']) {
                         $res['registerCheck'] = -4;
                         echo json_encode($res);
                         exit;
                     }
                     showmessage('undefined_action');
                 }
             }
         } else {
             list($uid, $username, $email) = $activation;
         }
         $_G['username'] = $username;
         if (getuserbyuid($uid, 1)) {
             if (!$activation) {
                 uc_user_delete($uid);
             }
             showmessage('profile_uid_duplicate', '', array('uid' => $uid));
         }
         $passportpwd = $password;
         $password = md5(random(10));
         $secques = $questionid > 0 ? random(8) : '';
         if (isset($_POST['birthmonth']) && isset($_POST['birthday'])) {
             $profile['constellation'] = get_constellation($_POST['birthmonth'], $_POST['birthday']);
         }
         if (isset($_POST['birthyear'])) {
             $profile['zodiac'] = get_zodiac($_POST['birthyear']);
         }
         if ($_FILES) {
             $upload = new discuz_upload();
             foreach ($_FILES as $key => $file) {
                 $field_key = 'field_' . $key;
                 if (!empty($_G['cache']['fields_register'][$field_key]) && $_G['cache']['fields_register'][$field_key]['formtype'] == 'file') {
                     $upload->init($file, 'profile');
                     $attach = $upload->attach;
                     if (!$upload->error()) {
                         $upload->save();
                         if (!$upload->get_image_info($attach['target'])) {
                             @unlink($attach['target']);
                             continue;
                         }
                         $attach['attachment'] = dhtmlspecialchars(trim($attach['attachment']));
                         if ($_G['cache']['fields_register'][$field_key]['needverify']) {
                             $verifyarr[$key] = $attach['attachment'];
                         } else {
                             $profile[$key] = $attach['attachment'];
                         }
                     }
                 }
             }
         }
         if ($setregip !== null) {
             if ($setregip == 1) {
                 C::t('common_regip')->update_count_by_ip($_G['clientip']);
             } else {
                 C::t('common_regip')->insert(array('ip' => $_G['clientip'], 'count' => 1, 'dateline' => $_G['timestamp']));
             }
         }
         if ($invite && $this->setting['inviteconfig']['invitegroupid']) {
             $groupinfo['groupid'] = $this->setting['inviteconfig']['invitegroupid'];
         }
         $init_arr = array('credits' => explode(',', $this->setting['initcredits']), 'profile' => $profile, 'emailstatus' => $emailstatus);
         C::t('common_member')->insert($uid, $username, $password, $email, $_G['clientip'], $groupinfo['groupid'], $init_arr);
         //----------------add--------------------------
         $passp = new passport();
         $pass = $passp->useradd($uid, $username, $passportpwd, $email, $_G['clientip'], $groupinfo['groupid'], $init_arr);
         //add
         if (is_array($pass)) {
             $psptuser = $passp->passport_setsession($pass, $_GET['cookietime'] ? 2592000 : 14400, $_G['clientip']);
             //add
         } else {
             if ($pass == "userisexist") {
                 uc_user_delete($uid);
                 C::t('common_member')->delete_no_validate($uid);
                 showmessage('profile_username_duplicate');
             } else {
                 if ($pass == "nicknameexist") {
                     uc_user_delete($uid);
                     C::t('common_member')->delete_no_validate($uid);
                     if ($_GET['phone_reg']) {
                         $res['registerCheck'] = -5;
                         echo json_encode($res);
                         exit;
                     }
                     showmessage('nickname_exists');
                 } else {
                     uc_user_delete($uid);
                     C::t('common_member')->delete_no_validate($uid);
                     showmessage('system_error_action');
                 }
             }
         }
         if (!empty($profile['mobile'])) {
             C::t('common_member')->update_extgroupids_by_uid($uid, 22);
         }
         //--------------add end-------------------------
         if ($emailstatus) {
             updatecreditbyaction('realemail', $uid);
         }
         if ($verifyarr) {
             $setverify = array('uid' => $uid, 'username' => $username, 'verifytype' => '0', 'field' => serialize($verifyarr), 'dateline' => TIMESTAMP);
             C::t('common_member_verify_info')->insert($setverify);
             C::t('common_member_verify')->insert(array('uid' => $uid));
         }
         require_once libfile('cache/userstats', 'function');
         build_cache_userstats();
         if ($this->extrafile && file_exists($this->extrafile)) {
             require_once $this->extrafile;
         }
         if ($this->setting['regctrl'] || $this->setting['regfloodctrl']) {
             C::t('common_regip')->delete_by_dateline($_G['timestamp'] - ($this->setting['regctrl'] > 72 ? $this->setting['regctrl'] : 72) * 3600);
             if ($this->setting['regctrl']) {
                 C::t('common_regip')->insert(array('ip' => $_G['clientip'], 'count' => -1, 'dateline' => $_G['timestamp']));
             }
         }
         $regmessage = dhtmlspecialchars($_GET['regmessage']);
         if ($this->setting['regverify'] == 2) {
             C::t('common_member_validate')->insert(array('uid' => $uid, 'submitdate' => $_G['timestamp'], 'moddate' => 0, 'admin' => '', 'submittimes' => 1, 'status' => 0, 'message' => $regmessage, 'remark' => ''), false, true);
             manage_addnotify('verifyuser');
         }
         setloginstatus(array('uid' => $uid, 'username' => $_G['username'], 'password' => $password, 'groupid' => $groupinfo['groupid']), 0);
         include_once libfile('function/stat');
         updatestat('register');
         if ($invite['id']) {
             $result = C::t('common_invite')->count_by_uid_fuid($invite['uid'], $uid);
             if (!$result) {
                 C::t('common_invite')->update($invite['id'], array('fuid' => $uid, 'fusername' => $_G['username'], 'regdateline' => $_G['timestamp'], 'status' => 2));
                 updatestat('invite');
             } else {
                 $invite = array();
             }
         }
         if ($invite['uid']) {
             if ($this->setting['inviteconfig']['inviteaddcredit']) {
                 updatemembercount($uid, array($this->setting['inviteconfig']['inviterewardcredit'] => $this->setting['inviteconfig']['inviteaddcredit']));
             }
             if ($this->setting['inviteconfig']['invitedaddcredit']) {
                 updatemembercount($invite['uid'], array($this->setting['inviteconfig']['inviterewardcredit'] => $this->setting['inviteconfig']['invitedaddcredit']));
             }
             require_once libfile('function/friend');
             friend_make($invite['uid'], $invite['username'], false);
             notification_add($invite['uid'], 'friend', 'invite_friend', array('actor' => '<a href="home.php?mod=space&uid=' . $invite['uid'] . '" target="_blank">' . $invite['username'] . '</a>'), 1);
             space_merge($invite, 'field_home');
             if (!empty($invite['privacy']['feed']['invite'])) {
                 require_once libfile('function/feed');
                 $tite_data = array('username' => '<a href="home.php?mod=space&uid=' . $_G['uid'] . '">' . $_G['username'] . '</a>');
                 feed_add('friend', 'feed_invite', $tite_data, '', array(), '', array(), array(), '', '', '', 0, 0, '', $invite['uid'], $invite['username']);
             }
             if ($invite['appid']) {
                 updatestat('appinvite');
             }
         }
         if ($welcomemsg && !empty($welcomemsgtxt)) {
             $welcomemsgtitle = replacesitevar($welcomemsgtitle);
             $welcomemsgtxt = replacesitevar($welcomemsgtxt);
             if ($welcomemsg == 1) {
                 $welcomemsgtxt = nl2br(str_replace(':', '&#58;', $welcomemsgtxt));
                 notification_add($uid, 'system', $welcomemsgtxt, array('from_id' => 0, 'from_idtype' => 'welcomemsg'), 1);
             } elseif ($welcomemsg == 2) {
                 sendmail_cron($email, $welcomemsgtitle, $welcomemsgtxt);
             } elseif ($welcomemsg == 3) {
                 sendmail_cron($email, $welcomemsgtitle, $welcomemsgtxt);
                 $welcomemsgtxt = nl2br(str_replace(':', '&#58;', $welcomemsgtxt));
                 notification_add($uid, 'system', $welcomemsgtxt, array('from_id' => 0, 'from_idtype' => 'welcomemsg'), 1);
             }
         }
         if ($fromuid) {
             updatecreditbyaction('promotion_register', $fromuid);
             dsetcookie('promotion', '');
         }
         dsetcookie('loginuser', '');
         dsetcookie('activationauth', '');
         dsetcookie('invite_auth', '');
         $url_forward = dreferer();
         //-------------------add-------------------------------------&& passport::p_allowverify()
         //	if($_G['setting']['verify']['enabled']  || $_G['setting']['my_app_status'] && $_G['setting']['videophoto']){
         $url_forward = passport::url_sms();
         //	}
         //-----------------------------------------------------------
         $refreshtime = 2000;
         switch ($this->setting['regverify']) {
             case 1:
                 $idstring = random(6);
                 $authstr = $this->setting['regverify'] == 1 ? "{$_G['timestamp']}\t2\t{$idstring}" : '';
                 C::t('common_member_field_forum')->update($_G['uid'], array('authstr' => $authstr));
                 $verifyurl = "{$_G[siteurl]}member.php?mod=activate&amp;uid={$_G[uid]}&amp;id={$idstring}";
                 $email_verify_message = lang('email', 'email_verify_message', array('username' => $_G['member']['username'], 'bbname' => $this->setting['bbname'], 'siteurl' => $_G['siteurl'], 'url' => $verifyurl));
                 if (!sendmail("{$username} <{$email}>", lang('email', 'email_verify_subject'), $email_verify_message)) {
                     runlog('sendmail', "{$email} sendmail failed.");
                 }
                 $message = 'register_email_verify';
                 $locationmessage = 'register_email_verify_location';
                 $refreshtime = 10000;
                 break;
             case 2:
                 $message = 'register_manual_verify';
                 $locationmessage = 'register_manual_verify_location';
                 break;
             default:
                 $message = 'register_succeed';
                 $locationmessage = 'register_succeed_location';
                 break;
         }
         $url_referer = dreferer();
         $param = array('bbname' => $this->setting['bbname'], 'username' => $_G['username'], 'usergroup' => $_G['group']['grouptitle'], 'uid' => $_G['uid'], 'referrer' => $url_referer);
         if (strpos($url_forward, $this->setting['regname']) !== false || strpos($url_forward, 'buyinvitecode') !== false) {
             $url_forward = 'forum.php';
         }
         $url_forward .= '&o=' . urlencode($url_referer);
         $href = str_replace("'", "\\'", $url_forward);
         $extra = array('showid' => 'succeedmessage', 'extrajs' => '<script type="text/javascript">' . 'setTimeout("window.location.href =\'' . $href . '\';", ' . $refreshtime . ');' . '$(\'succeedmessage_href\').href = \'' . $href . '\';' . '$(\'main_message\').style.display = \'none\';' . '$(\'main_succeed\').style.display = \'\';' . '$(\'succeedlocation\').innerHTML = \'' . lang('message', $locationmessage) . '\';' . '</script>', 'striptags' => false);
         if ($_GET['phone_reg']) {
             $res['registerCheck'] = 1;
             echo json_encode($res);
             exit;
         }
         showmessage($message, $url_forward, $param, $extra);
     }
 }
<?php

/**
 *      [Discuz!] (C)2001-2099 Comsenz Inc.
 *      This is NOT a freeware, use is subject to license terms
 *
 *      $Id: new_ajax.php 30465 2012-05-30 04:10:03Z zh $
 */
if (!defined('IN_DISCUZ')) {
    exit('Access Denied');
}
define('NOROBOT', TRUE);
if ($_GET['action'] == 'chknickname') {
    $nickname = trim($_GET['nickname']);
    $pap = new passport();
    $status = $pap->nickname_check($nickname);
    if ($status == false) {
        showmessage('nickname_exist', '', array(), array('handle' => false));
    }
}
showmessage('succeed', '', array(), array('handle' => false));