private function _saveInfo($res, $username, $email, $oauthToken, $openId, $gender, $platformId) { $username = WebUtils::t(rawurldecode($username)); $email = WebUtils::t(rawurldecode($email)); $password = MOBCENT_HACKER_PASSWORD; $regInfo = UserUtils::register($username, $password, $email, 'qq'); if ($regInfo['errcode']) { return $this->makeErrorInfo($res, $regInfo['message']); } $uid = $regInfo['info']['uid']; $userInfo = UserUtils::getUserInfo($uid); $userAccess = AppbymeUserAccess::registerProcess($uid, $password); if (!empty($platformId) && $platformId == 20) { $qqdata = array('uid' => $uid, 'conuin' => $oauthToken, 'conuinsecret' => '', 'conopenid' => $openId, 'conisfeed' => 1, 'conispublishfeed' => 1, 'conispublisht' => 1, 'conisregister' => 1, 'conisqzoneavatar' => 1, 'conisqqshow' => 1); $qqbind = array('mblid' => '', 'uid' => $uid, 'uin' => $openId, 'type' => 1, 'dateline' => time()); $this->_inserBindlog($qqbind); $this->_inserConnect($qqdata); $updateInfo = array('avatarstatus' => 1, 'conisbind' => 1); // 用户是否绑定QQ DzCommonMember::updateMember($updateInfo, array('uid' => $uid)); $setarr['gender'] = intval($gender); C::t('common_member_profile')->update($uid, $setarr); $ipArray = explode('.', $_G['clientip']); $sid = FileUtils::getRandomFileName('', 6); $data = array('sid' => $sid, 'ip1' => $ipArray[0], 'ip2' => $ipArray[1], 'ip3' => $ipArray[2], 'ip4' => $ipArray[3], 'uid' => $userInfo['uid'], 'username' => $userInfo['username'], 'groupid' => $userInfo['groupid'], 'invisible' => '0', 'action' => '', 'lastactivity' => time(), 'fid' => '0', 'tid' => '0', 'lastolupdate' => '0'); DzCommonSession::insertComSess($data); require_once libfile('cache/userstats', 'function'); build_cache_userstats(); $res['token'] = (string) $userAccess['token']; $res['secret'] = (string) $userAccess['secret']; $res['uid'] = (int) $regInfo['info']['uid']; return $res; } // 客户端参数不正确 return $this->makeErrorInfo($res, 'mobcent_error_params'); }
C::t('#qqconnect#common_member_connect')->insert(array('uid' => $uid, 'conuin' => $conuin, 'conuinsecret' => $conuinsecret, 'conopenid' => $conopenid, 'conispublishfeed' => $conispublishfeed, 'conispublisht' => $conispublisht, 'conisregister' => '1', 'conisqzoneavatar' => $is_qzone_avatar, 'conisfeed' => '1', 'conisqqshow' => $is_use_qqshow)); dsetcookie('connect_js_name', 'user_bind', 86400); dsetcookie('connect_js_params', base64_encode(serialize(array('type' => 'register'))), 86400); dsetcookie('connect_login', 1, 31536000); dsetcookie('connect_is_bind', '1', 31536000); dsetcookie('connect_uin', $conopenid, 31536000); dsetcookie('stats_qc_reg', 1, 86400); if ($_GET['is_feed']) { dsetcookie('connect_synpost_tip', 1, 31536000); } C::t('#qqconnect#connect_memberbindlog')->insert(array('uid' => $uid, 'uin' => $conopenid, 'type' => '1', 'dateline' => $_G['timestamp'])); dsetcookie('con_auth_hash'); C::t('#qqconnect#common_connect_guest')->delete($conopenid); if (!function_exists('build_cache_userstats')) { require_once libfile('cache/userstats', 'function'); } build_cache_userstats(); if ($_G['setting']['connect']['register_groupid']) { $userdata['groupid'] = $groupinfo['groupid'] = $_G['setting']['connect']['register_groupid']; } C::t('common_member')->update($uid, $userdata); if ($_G['setting']['connect']['register_addcredit']) { $addcredit = array('extcredits' . $_G['setting']['connect']['register_rewardcredit'] => $_G['setting']['connect']['register_addcredit']); } C::t('common_member_count')->increase($uid, $addcredit); } function connect_filter_username($username) { $username = str_replace(' ', '_', trim($username)); return cutstr($username, 15, ''); }
function register() { /*{{{*/ require_once dirname(dirname(dirname(__FILE__))) . '/bigappjson.class.php'; require_once libfile('function/misc'); require_once libfile('function/member'); require_once libfile('class/member'); $userName = isset($_REQUEST["username"]) ? $_REQUEST["username"] : ""; $password = isset($_REQUEST["password"]) ? $_REQUEST["password"] : ""; $email = isset($_REQUEST["email"]) ? strtolower($_REQUEST["email"]) : ""; global $_G; if (function_exists('iconv')) { $userName = iconv('UTF-8', CHARSET . '//ignore', $userName); } else { $userName = mb_convert_encoding($userName, CHARSET, 'UTF-8'); } if (empty($userName) || empty($password) || empty($email)) { echo BIGAPPJSON::encode(array('error_code' => 2, 'error_msg' => lang('plugin/bigapp', 'empty_params'), 'Variables' => array('auth' => null), 'Message' => array('messageval' => 'for comaptible', 'messagestr' => lang('plugin/bigapp', 'empty_params')))); die(0); } $userNamelen = dstrlen($userName); if ($userNamelen < 3) { echo BIGAPPJSON::encode(array('error_code' => 3, 'error_msg' => lang('plugin/bigapp', 'username_short'), 'Variables' => array('auth' => null), 'Message' => array('messageval' => 'for comaptible', 'messagestr' => lang('plugin/bigapp', 'username_short')))); die(0); } if ($userNamelen > 15) { echo BIGAPPJSON::encode(array('error_code' => 4, 'error_msg' => lang('plugin/bigapp', 'username_long'), 'Variables' => array('auth' => null), 'Message' => array('messageval' => 'for comaptible', 'messagestr' => lang('plugin/bigapp', 'username_long')))); die(0); } $ctlObj = new register_ctl(); $ctlObj->setting = $_G['setting']; if (isset($ctlObj->setting['pwlength']) && $ctlObj->setting['pwlength']) { if (strlen($password) < $ctlObj->setting['pwlength']) { echo BIGAPPJSON::encode(array('error_code' => 5, 'error_msg' => lang('plugin/bigapp', 'password_length') . ' [ >= ' . $ctlObj->setting['pwlength'] . ' ]', 'Variables' => array('auth' => null), 'Message' => array('messageval' => 'for comaptible', 'messagestr' => lang('plugin/bigapp', 'password_not_equal') . ' [ >= ' . $ctlObj->setting['pwlength'] . ' ]'))); die(0); } } if (isset($ctlObj->setting['strongpw']) && $ctlObj->setting['strongpw']) { $strongpw_str = array(); if (in_array(1, $ctlObj->setting['strongpw']) && !preg_match("/\\d+/", $password)) { $strongpw_str[] = lang('plugin/bigapp', 'password_number'); } if (in_array(2, $ctlObj->setting['strongpw']) && !preg_match("/[a-z]+/", $password)) { $strongpw_str[] = lang('plugin/bigapp', 'password_lowercase_char'); } if (in_array(3, $ctlObj->setting['strongpw']) && !preg_match("/[A-Z]+/", $password)) { $strongpw_str[] = lang('plugin/bigapp', 'password_uppercase_char'); } if (in_array(4, $ctlObj->setting['strongpw']) && !preg_match("/[^a-zA-Z0-9]+/", $password)) { $strongpw_str[] = lang('plugin/bigapp', 'password_charset'); } if ($strongpw_str) { echo BIGAPPJSON::encode(array('error_code' => 6, 'error_msg' => lang('plugin/bigapp', 'password_invalid') . ' [ ' . implode(', ', $strongpw_str) . ' ]', 'Variables' => array('auth' => null), 'Message' => array('messageval' => 'for comaptible', 'messagestr' => lang('plugin/bigapp', 'password_invalid') . ' [ ' . implode(', ', $strongpw_str) . ' ]'))); die(0); } } /* if(!isset($_G['setting']['mobile']['mobileregister']) || !$_G['setting']['mobile']['mobileregister']){ echo BIGAPPJSON::encode(array('error_code' => 7, 'error_msg' => lang('plugin/bigapp', 'forbid_mobreg'), 'Variables' => array('auth' => null), 'Message' => array('messageval' => 'for comaptible', 'messagestr' => lang('plugin/bigapp', 'forbid_mobreg')))); die(0); } */ loaducenter(); if (!$ctlObj->setting['regclosed'] && (!$ctlObj->setting['regstatus'] || !$ctlObj->setting['ucactivation'])) { if (!$ctlObj->setting['regstatus']) { echo BIGAPPJSON::encode(array('error_code' => 8, 'error_msg' => lang('plugin/bigapp', 'forbid_registration'), 'Variables' => array('auth' => null), 'Message' => array('messageval' => 'for comaptible', 'messagestr' => lang('plugin/bigapp', 'forbid_registration')))); die(0); } } if ($ctlObj->setting['regverify']) { if ($ctlObj->setting['areaverifywhite']) { $location = $whitearea = ''; $location = trim(convertip($_G['clientip'], "./")); if ($location) { $whitearea = preg_quote(trim($ctlObj->setting['areaverifywhite']), '/'); $whitearea = str_replace(array("\\*"), array('.*'), $whitearea); $whitearea = '.*' . $whitearea . '.*'; $whitearea = '/^(' . str_replace(array("\r\n", ' '), array('.*|.*', ''), $whitearea) . ')$/i'; if (@preg_match($whitearea, $location)) { $ctlObj->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'])) { $ctlObj->setting['regverify'] = 0; break; } } } } if ($ctlObj->setting['regverify']) { $groupinfo['groupid'] = 8; } else { $groupinfo['groupid'] = $ctlObj->setting['newusergroupid']; } if (!$password || $password != addslashes($password)) { echo BIGAPPJSON::encode(array('error_code' => 9, 'error_msg' => lang('plugin/bigapp', 'password_invalid_char'), 'Variables' => array('auth' => null), 'Message' => array('messageval' => 'for comaptible', 'messagestr' => lang('plugin/bigapp', 'password_invalid_char')))); die(0); } $censorexp = '/^(' . str_replace(array('\\*', "\r\n", ' '), array('.*', '|', ''), preg_quote($ctlObj->setting['censoruser'] = trim($ctlObj->setting['censoruser']), '/')) . ')$/i'; if ($ctlObj->setting['censoruser'] && @preg_match($censorexp, $userName)) { echo BIGAPPJSON::encode(array('error_code' => 10, 'error_msg' => lang('plugin/bigapp', 'forbid_username'), 'Variables' => array('auth' => null), 'Message' => array('messageval' => 'for comaptible', 'messagestr' => lang('plugin/bigapp', 'forbid_username')))); die(0); } 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 . '%'; $ctlObj->setting['regctrl'] = $ctlObj->setting['ipregctrltime']; break; } else { $ctrlip = $_G['clientip']; } } } else { $ctrlip = $_G['clientip']; } if ($ctlObj->setting['regctrl']) { if (C::t('common_regip')->count_by_ip_dateline($ctrlip, $_G['timestamp'] - $ctlObj->setting['regctrl'] * 3600)) { echo BIGAPPJSON::encode(array('error_code' => 11, 'error_msg' => lang('plugin/bigapp', 'forbid_ip'), 'Variables' => array('auth' => null), 'Message' => array('messageval' => 'for comaptible', 'messagestr' => lang('plugin/bigapp', 'forbid_ip')))); die(0); } } $setregip = null; if ($ctlObj->setting['regfloodctrl']) { $regip = C::t('common_regip')->fetch_by_ip_dateline($_G['clientip'], $_G['timestamp'] - 86400); if ($regip) { if ($regip['count'] >= $ctlObj->setting['regfloodctrl']) { echo BIGAPPJSON::encode(array('error_code' => 12, 'error_msg' => lang('plugin/bigapp', 'forbid_ip_today'), 'Variables' => array('auth' => null), 'Message' => array('messageval' => 'for comaptible', 'messagestr' => lang('plugin/bigapp', 'forbid_ip_today')))); die(0); } else { $setregip = 1; } } else { $setregip = 2; } } $uid = uc_user_register($userName, $password, $email, '', '', $_G['clientip']); if ($uid <= 0) { if ($uid == -1) { echo BIGAPPJSON::encode(array('error_code' => 13, 'error_msg' => lang('plugin/bigapp', 'username_invalid_char'), 'Variables' => array('auth' => null), 'Message' => array('messageval' => 'for comaptible', 'messagestr' => lang('plugin/bigapp', 'username_invalid_char')))); } elseif ($uid == -2) { echo BIGAPPJSON::encode(array('error_code' => 13, 'error_msg' => lang('plugin/bigapp', 'username_invalid_char'), 'Variables' => array('auth' => null), 'Message' => array('messageval' => 'for comaptible', 'messagestr' => lang('plugin/bigapp', 'username_invalid_char')))); } elseif ($uid == -3) { echo BIGAPPJSON::encode(array('error_code' => 13, 'error_msg' => lang('plugin/bigapp', 'username_used'), 'Variables' => array('auth' => null), 'Message' => array('messageval' => 'for comaptible', 'messagestr' => lang('plugin/bigapp', 'username_used')))); } elseif ($uid == -4) { echo BIGAPPJSON::encode(array('error_code' => 13, 'error_msg' => lang('plugin/bigapp', 'invalid_email'), 'Variables' => array('auth' => null), 'Message' => array('messageval' => 'for comaptible', 'messagestr' => lang('plugin/bigapp', 'invalid_email')))); } elseif ($uid == -5) { echo BIGAPPJSON::encode(array('error_code' => 13, 'error_msg' => lang('plugin/bigapp', 'invalid_email'), 'Variables' => array('auth' => null), 'Message' => array('messageval' => 'for comaptible', 'messagestr' => lang('plugin/bigapp', 'invalid_email')))); } elseif ($uid == -6) { echo BIGAPPJSON::encode(array('error_code' => 13, 'error_msg' => lang('plugin/bigapp', 'email_used'), 'Variables' => array('auth' => null), 'Message' => array('messageval' => 'for comaptible', 'messagestr' => lang('plugin/bigapp', 'email_used')))); } die(0); } $_G['username'] = $userName; $password = md5(random(10)); 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'])); } } $profile = $verifyarr = array(); $emailstatus = 0; $init_arr = array('credits' => explode(',', $ctlObj->setting['initcredits']), 'profile' => $profile, 'emailstatus' => $emailstatus); C::t('common_member')->insert($uid, $userName, $password, $email, $_G['clientip'], $groupinfo['groupid'], $init_arr); if ($ctlObj->setting['regctrl'] || $ctlObj->setting['regfloodctrl']) { C::t('common_regip')->delete_by_dateline($_G['timestamp'] - ($ctlObj->setting['regctrl'] > 72 ? $ctlObj->setting['regctrl'] : 72) * 3600); if ($ctlObj->setting['regctrl']) { C::t('common_regip')->insert(array('ip' => $_G['clientip'], 'count' => -1, 'dateline' => $_G['timestamp'])); } } if ($ctlObj->setting['regverify'] == 1) { $idstring = random(6); $authstr = $ctlObj->setting['regverify'] == 1 ? "{$_G['timestamp']}\t2\t{$idstring}" : ''; C::t('common_member_field_forum')->update($uid, array('authstr' => $authstr)); $verifyurl = "{$_G[siteurl]}member.php?mod=activate&uid={$uid}&id={$idstring}"; $email_verify_message = lang('email', 'email_verify_message', array('username' => $username, 'bbname' => $ctlObj->setting['bbname'], 'siteurl' => $_G['siteurl'], 'url' => $verifyurl)); if (!sendmail("{$username} <{$email}>", lang('email', 'email_verify_subject'), $email_verify_message)) { runlog('sendmail', "{$email} sendmail failed."); } } require_once libfile('cache/userstats', 'function'); build_cache_userstats(); $_GET['regmessage'] = 'from bigapp client'; $regmessage = dhtmlspecialchars($_GET['regmessage']); if ($ctlObj->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'); checkfollowfeed(); C::t('common_member_status')->update($_G['uid'], array('lastip' => $_G['clientip'], 'lastvisit' => TIMESTAMP, 'lastactivity' => TIMESTAMP)); //////////////////////////////////////////////// // 注册成功,绑定第三方openid $plat = $_GET["platform"]; if ($plat == "qq") { include_once CUR_PATH . "/../qqconnect/bind.php"; } else { if ($plat == "wechat") { include_once CUR_PATH . "/../wechatconnect/bind.php"; } } //////////////////////////////////////////////// echo BIGAPPJSON::encode(array('error_code' => 0, 'error_msg' => lang('plugin/bigapp', 'regist_succ'), 'Message' => array('messageval' => 'register_succeed', 'messagestr' => lang('plugin/bigapp', 'regist_succ')), 'Variables' => array('auth' => 'in order to be comapatible'))); die(0); }
function on_register() { global $_G; $_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']) { if ($this->setting['regconnect']) { dheader('location:connect.php?mod=login&op=init&referer=forum.php&statfrom=login_simple'); } 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'])) { $_GET['hash'] = preg_replace("/[^\\[A-Za-z0-9_\\]%]/", '', $_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 ($_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'); $sendurl = false; } if (!$sendurl) { 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 { $activationauth = array(); if (isset($_GET['activationauth']) && $_GET['activationauth']) { $activationauth = explode("\t", authcode($_GET['activationauth'], 'DECODE')); if ($activationauth[1] != FORMHASH) { showmessage('register_activation_invalid', 'member.php?mod=logging&action=login'); } $sendurl = false; } if (!$activationauth && ($sendurl || !$_G['setting']['forgeemail'])) { checkemail($_GET['email']); } if ($sendurl) { $hashstr = urlencode(authcode("{$_GET['email']}\t{$_G['timestamp']}", 'ENCODE', $_G['config']['security']['authkey'])); $registerurl = "{$_G[siteurl]}member.php?mod=" . $this->setting['regname'] . "&hash={$hashstr}&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' => false, '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'); } if ($bbrules && $bbrulehash != $_POST['agreebbrule']) { showmessage('register_rules_agree'); } $activation = array(); if (isset($_GET['activationauth']) && $activationauth && is_array($activationauth)) { 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($email) && $_G['setting']['forgeemail']) { $_GET['email'] = $email = strtolower(random(6)) . '@' . $_SERVER['HTTP_HOST']; } 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) { showmessage('profile_username_illegal'); } elseif ($uid == -2) { showmessage('profile_username_protect'); } elseif ($uid == -3) { 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 { 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)); } $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); 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(':', ':', $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(':', ':', $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(); $refreshtime = 3000; 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&uid={$_G[uid]}&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; } $param = array('bbname' => $this->setting['bbname'], 'username' => $_G['username'], 'usergroup' => $_G['group']['grouptitle'], 'uid' => $_G['uid']); if (strpos($url_forward, $this->setting['regname']) !== false || strpos($url_forward, 'buyinvitecode') !== false) { $url_forward = 'forum.php'; } $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); showmessage($message, $url_forward, $param, $extra); } }
public function setloginstatus($act, $ask_front_name = "") { //echo "act:".$act."<br>"; loaducenter(); if ($act == "login") { //echo "ask_front_name:".$ask_front_name."<br>"; $user = uc_user_login($ask_front_name, $ask_front_name); if ($user['0'] == -1) { //echo "无此用户,需要注册<br>"; $uid = uc_user_register($ask_front_name, $ask_front_name, $ask_front_name); if ($uid > 0) { $url = "member.php?mod=logging&action=login&loginsubmit=yes&infloat=yes&lssubmit=yes&fastloginfield=username&handlekey=ls&password="******"&quickforward=yes&username="******"location: {$url}"); require_once libfile('cache/userstats', 'function'); build_cache_userstats(); //echo "自动注册成功<br>"; } } else { //echo "已有用户,无需注册"; $uid = $user['0']; } //echo "uid:".$uid; $sync = uc_user_synlogin($uid); echo $sync; echo "<script>location.reload();</script>"; } elseif ($act == "logout") { $sync = uc_user_synlogout(); echo $sync; } return; }
/** * 用户注册 * * @author HanPengyu * @param string $username 用户名. * @param string $password 用户密码. * @param string $email 用户邮件. * @param string $type 注册类型,默认general. * @return array . */ public static function register($username, $password, $email, $type = 'general') { global $_G; require_once libfile('function/member'); require libfile('class/member'); require_once libfile('function/misc'); loaducenter(); $ctlObj = new register_ctl(); $ctlObj->setting = $_G['setting']; // 客户端是否开启注册功能 $mobAllowReg = WebUtils::getDzPluginAppbymeAppConfig('mobile_allow_register'); if ($mobAllowReg === '0') { return self::errorInfo(Webutils::t('客户端不允许注册')); } // 客户端是否开启跳转web页注册 // 系统是否允许注册 if (!$ctlObj->setting['regclosed'] && (!$ctlObj->setting['regstatus'] || !$ctlObj->setting['ucactivation'])) { if (!$ctlObj->setting['regstatus']) { $message = !$ctlObj->setting['regclosemessage'] ? 'register_disable' : str_replace(array("\r", "\n"), '', $ctlObj->setting['regclosemessage']); return self::errorInfo(lang('message', $message)); } } // $username = isset($username) ? trim(WebUtils::t($username)) : ''; $password = isset($password) ? $password : ''; // $password2 = isset($password2) ? $password2 : ''; $email = strtolower(trim($email)); if ($ctlObj->setting['regverify']) { // 对注册 IP 的限制 if ($ctlObj->setting['areaverifywhite']) { $location = $whitearea = ''; $location = trim(convertip($_G['clientip'], "./")); if ($location) { $whitearea = preg_quote(trim($ctlObj->setting['areaverifywhite']), '/'); $whitearea = str_replace(array("\\*"), array('.*'), $whitearea); $whitearea = '.*' . $whitearea . '.*'; $whitearea = '/^(' . str_replace(array("\r\n", ' '), array('.*|.*', ''), $whitearea) . ')$/i'; if (@preg_match($whitearea, $location)) { $ctlObj->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'])) { $ctlObj->setting['regverify'] = 0; break; } } } } if ($ctlObj->setting['regverify'] && $type == 'general') { $groupinfo['groupid'] = 8; } else { $groupinfo['groupid'] = $ctlObj->setting['newusergroupid']; } // 在插件中设置的用户组 date:2015.01.15 $registerGroup = WebUtils::getDzPluginAppbymeAppConfig('mobile_register_group'); if ($registerGroup) { $groupinfo['groupid'] = $registerGroup; } $usernamelen = dstrlen($username); if ($usernamelen < 3) { return self::errorInfo(lang('message', 'profile_username_tooshort')); } elseif ($usernamelen > 15) { return self::errorInfo(lang('message', 'profile_username_toolong')); } if ($ctlObj->setting['pwlength']) { if (strlen($password) < $ctlObj->setting['pwlength']) { // 密码最小的长度 return self::errorInfo(lang('message', 'profile_password_tooshort', array('pwlength' => $ctlObj->setting['pwlength']))); } } // 密码复杂度的限制 if ($ctlObj->setting['strongpw']) { $strongpw_str = array(); if (in_array(1, $ctlObj->setting['strongpw']) && !preg_match("/\\d+/", $password)) { $strongpw_str[] = lang('member/template', 'strongpw_1'); } if (in_array(2, $ctlObj->setting['strongpw']) && !preg_match("/[a-z]+/", $password)) { $strongpw_str[] = lang('member/template', 'strongpw_2'); } if (in_array(3, $ctlObj->setting['strongpw']) && !preg_match("/[A-Z]+/", $password)) { $strongpw_str[] = lang('member/template', 'strongpw_3'); } if (in_array(4, $ctlObj->setting['strongpw']) && !preg_match("/[^a-zA-z0-9]+/", $password)) { $strongpw_str[] = lang('member/template', 'strongpw_4'); } if ($strongpw_str) { // 密码太弱,密码中必须包含什么 return self::errorInfo(lang('member/template', 'password_weak') . implode(',', $strongpw_str)); } } // if($password !== $password2) { // // 两次输入的密码不同 // return WebUtils::makeErrorInfo_oldVersion($res, lang('message', 'profile_passwd_notmatch')); // } if (!$password || $password != addslashes($password)) { // 密码有特殊的字符 return self::errorInfo(lang('message', 'profile_passwd_illegal')); } $censorexp = '/^(' . str_replace(array('\\*', "\r\n", ' '), array('.*', '|', ''), preg_quote($ctlObj->setting['censoruser'] = trim($ctlObj->setting['censoruser']), '/')) . ')$/i'; if ($ctlObj->setting['censoruser'] && @preg_match($censorexp, $username)) { // 用户名包含被系统屏蔽的字符 return self::errorInfo(lang('message', 'profile_username_protect')); } // 这里是对ip注册的限制 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 . '%'; $ctlObj->setting['regctrl'] = $ctlObj->setting['ipregctrltime']; break; } else { $ctrlip = $_G['clientip']; } } } else { $ctrlip = $_G['clientip']; } // ip在一定时间内不能注册 if ($ctlObj->setting['regctrl']) { if (C::t('common_regip')->count_by_ip_dateline($ctrlip, $_G['timestamp'] - $ctlObj->setting['regctrl'] * 3600)) { return self::errorInfo(lang('message', 'register_ctrl', array('regctrl' => $ctlObj->setting['regctrl']))); } } // IP 地址在 24 小时内只能注册几次 $setregip = null; if ($ctlObj->setting['regfloodctrl']) { $regip = C::t('common_regip')->fetch_by_ip_dateline($_G['clientip'], $_G['timestamp'] - 86400); if ($regip) { if ($regip['count'] >= $ctlObj->setting['regfloodctrl']) { return self::errorInfo(lang('message', 'register_flood_ctrl', array('regfloodctrl' => $ctlObj->setting['regfloodctrl']))); } else { $setregip = 1; } } else { $setregip = 2; } } $uid = uc_user_register(addslashes($username), $password, $email, '', '', $_G['clientip']); if ($uid <= 0) { if ($uid == -1) { // 用户名包含敏感字符 return self::errorInfo(lang('message', 'profile_username_illegal')); } elseif ($uid == -2) { // 用户名包含被系统屏蔽的字符 return self::errorInfo(lang('message', 'profile_username_protect')); } elseif ($uid == -3) { // 该用户名已被注册 return self::errorInfo(lang('message', 'profile_username_duplicate')); } elseif ($uid == -4) { // Email 地址无效 return self::errorInfo(lang('message', 'profile_email_illegal')); } elseif ($uid == -5) { // 抱歉,Email 包含不可使用的邮箱域名 return self::errorInfo(lang('message', 'profile_email_domain_illegal')); } elseif ($uid == -6) { // 该 Email 地址已被注册 return self::errorInfo(lang('message', 'profile_email_duplicate')); } } $_G['username'] = $username; $password = md5(random(10)); 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'])); } } $profile = $verifyarr = array(); $emailstatus = 0; $init_arr = array('credits' => explode(',', $ctlObj->setting['initcredits']), 'profile' => $profile, 'emailstatus' => $emailstatus); C::t('common_member')->insert($uid, $username, $password, $email, $_G['clientip'], $groupinfo['groupid'], $init_arr); if ($ctlObj->setting['regctrl'] || $ctlObj->setting['regfloodctrl']) { C::t('common_regip')->delete_by_dateline($_G['timestamp'] - ($ctlObj->setting['regctrl'] > 72 ? $ctlObj->setting['regctrl'] : 72) * 3600); if ($ctlObj->setting['regctrl']) { C::t('common_regip')->insert(array('ip' => $_G['clientip'], 'count' => -1, 'dateline' => $_G['timestamp'])); } } if ($ctlObj->setting['regverify'] == 1) { $idstring = random(6); $authstr = $ctlObj->setting['regverify'] == 1 ? "{$_G['timestamp']}\t2\t{$idstring}" : ''; C::t('common_member_field_forum')->update($uid, array('authstr' => $authstr)); $verifyurl = "{$_G[siteurl]}member.php?mod=activate&uid={$uid}&id={$idstring}"; $email_verify_message = lang('email', 'email_verify_message', array('username' => $username, 'bbname' => $ctlObj->setting['bbname'], 'siteurl' => $_G['siteurl'], 'url' => $verifyurl)); if (!sendmail("{$username} <{$email}>", lang('email', 'email_verify_subject'), $email_verify_message)) { runlog('sendmail', "{$email} sendmail failed."); } } // [add]更新欢迎注册等 data:2015.01.04 require_once libfile('cache/userstats', 'function'); build_cache_userstats(); $_GET['regmessage'] = Webutils::t('来自手机客户端注册'); $regmessage = dhtmlspecialchars($_GET['regmessage']); if ($ctlObj->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'); return self::errorInfo('', 0, array('uid' => $uid)); }
function on_register() { global $_G; $_GET['username'] = $_GET['username']; $_GET['nickname'] = $_GET['nickname']; $_GET['password'] = $_GET['password']; $_GET['password2'] = $_GET['password2']; $_GET['email'] = $_GET['email']; if ($_G['uid']) { $url_forward = dreferer(); if (strpos($url_forward, 'reg') !== false) { $url_forward = 'index.php'; } showmessage('login_succeed', $url_forward ? $url_forward : './', array('username' => $_G['member']['username'], 'usergroup' => $_G['group']['grouptitle'], 'uid' => $_G['uid']), array()); } elseif (!$this->setting['regclosed']) { 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']; $username = isset($_GET['username']) ? $_GET['username'] : ''; $invitestatus = false; $seccodecheck = $this->setting['seccodestatus'] & 1; $secqaacheck = 0; $bbrulehash = $bbrules ? substr(md5(FORMHASH), 0, 8) : ''; $auth = $_GET['auth']; if (!$invitestatus) { $invite = getinvite(); } if (!submitcheck('regsubmit', 0, $seccodecheck)) { 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 { $emailstatus = 0; if ($this->setting['regstatus'] == 2 && empty($invite) && !$invitestatus) { showmessage('not_open_registration_invite'); } //验证同意协议 if ($bbrules && $bbrulehash != $_POST['agreebbrule']) { showmessage('register_rules_agree'); } //验证用户姓名 $usernamelen = dstrlen($username); if ($usernamelen < 3) { showmessage('profile_username_tooshort'); } if ($usernamelen > 30) { showmessage('profile_username_toolong'); } //验证用户名 if ($nickname = trim($_GET['nickname'])) { $nicknamelen = dstrlen($nickname); if ($nicknamelen < 3) { showmessage('profile_nickname_tooshort'); } if ($nicknamelen > 30) { showmessage('profile_nickname_toolong'); } } else { $nickname = ''; } //验证邮箱 $email = strtolower(trim($_GET['email'])); checkemail($email); //验证密码长度 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('user/template', 'strongpw_1'); } if (in_array(2, $this->setting['strongpw']) && !preg_match("/[a-z]+/", $_GET['password'])) { $strongpw_str[] = lang('user/template', 'strongpw_2'); } if (in_array(3, $this->setting['strongpw']) && !preg_match("/[A-Z]+/", $_GET['password'])) { $strongpw_str[] = lang('user/template', 'strongpw_3'); } if (in_array(4, $this->setting['strongpw']) && !preg_match("/[^a-zA-z0-9]+/", $_GET['password'])) { $strongpw_str[] = lang('user/template', 'strongpw_4'); } if ($strongpw_str) { showmessage(lang('user/template', 'password_weak') . implode(',', $strongpw_str)); } } //验证两次密码一致性 if ($_GET['password'] !== $_GET['password2']) { showmessage('两次密码不匹配'); } if (!$_GET['password'] || $_GET['password'] != addslashes($_GET['password'])) { showmessage('profile_passwd_illegal'); } $password = $_GET['password']; $ctrlip = $_G['clientip']; $setregip = null; $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'] . '.parentNode.parentNode.className = \'form-group warning\';' . '$(\'registerform\').' . $field['fieldid'] . '.onblur = function () { if(this.value != \'\') {this.parentNode.parentNode.className = \'form-group\';$(\'chk_' . $showid . '\').innerHTML = \'\';}}' . '</script>' : ''))); } if ($field['needverify']) { $verifyarr[$field_key] = $field_val; } else { $profile[$field_key] = $field_val; } } $groupinfo = array(); $addorg = 0; if ($this->setting['regverify']) { $groupinfo['groupid'] = 8; } else { $groupinfo['groupid'] = $this->setting['newusergroupid']; $addorg = 1; } $result = uc_user_register(addslashes($username), $password, $email, addslashes($nickname), $questionid, $answer, $_G['clientip'], $addorg); if (is_array($result)) { $uid = $result['uid']; $password = $result['password']; } else { $uid = $result; } if ($uid <= 0) { if ($uid == -1) { showmessage('profile_nickname_illegal'); } elseif ($uid == -2) { showmessage('profile_nickname_protect'); } elseif ($uid == -3) { showmessage('profile_nickname_duplicate'); } elseif ($uid == -4) { showmessage('profile_email_illegal'); } elseif ($uid == -5) { showmessage('profile_email_domain_illegal'); } elseif ($uid == -6) { showmessage('profile_email_duplicate'); } elseif ($uid == -7) { showmessage('profile_username_illegal'); } else { showmessage('undefined_action'); } } $_G['username'] = $username; 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) { 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') { if ($attachment = uploadtolocal($file, 'profile', '')) { if (@getimagesize($_G['setting']['attachdir'] . $attachment)) { //判断是否为图片文件 @unlink($_G['setting']['attachdir'] . $attachment); continue; } if ($_G['cache']['fields_register'][$field_key]['needverify']) { $verifyarr[$key] = $attachment; } else { $profile[$key] = $attachment; } } } } } $init_arr = array('profile' => $profile, 'emailstatus' => $emailstatus); C::t('user')->insert($uid, $_G['clientip'], $groupinfo['groupid'], $init_arr); if ($verifyarr) { $setverify = array('uid' => $uid, 'username' => $username, 'verifytype' => '0', 'field' => serialize($verifyarr), 'dateline' => TIMESTAMP); C::t('user_verify_info')->insert($setverify); C::t('user_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; } setloginstatus(array('uid' => $uid, 'username' => $_G['username'], 'password' => $password, 'groupid' => $groupinfo['groupid']), 0); include_once libfile('function/stat'); if ($welcomemsg && !empty($welcomemsgtxt)) { $welcomemsgtitle = replacesitevar($welcomemsgtitle); $welcomemsgtxt = replacesitevar($welcomemsgtxt); if ($welcomemsg == 1) { $welcomemsgtxt = nl2br(str_replace(':', ':', $welcomemsgtxt)); } elseif ($welcomemsg == 2) { sendmail_cron($email, $welcomemsgtitle, $welcomemsgtxt); } elseif ($welcomemsg == 3) { sendmail_cron($email, $welcomemsgtitle, $welcomemsgtxt); $welcomemsgtxt = nl2br(str_replace(':', ':', $welcomemsgtxt)); } } dsetcookie('loginuser', ''); dsetcookie('invite_auth', ''); $url_forward = dreferer(); $refreshtime = 3000; switch ($this->setting['regverify']) { case 1: $idstring = random(6); $authstr = $this->setting['regverify'] == 1 ? "{$_G['timestamp']}\t2\t{$idstring}" : ''; C::t('user')->update($_G['uid'], array('authstr' => $authstr)); $verifyurl = "{$_G[siteurl]}user.php?mod=activate&uid={$_G[uid]}&id={$idstring}"; $email_verify_message = lang('email', 'email_verify_message', array('username' => $_G['member']['username'], 'sitename' => $this->setting['sitename'], '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; } $param = daddslashes(array('sitename' => $this->setting['sitename'], 'username' => $_G['username'], 'usergroup' => $_G['group']['grouptitle'], 'uid' => $_G['uid'])); if (strpos($url_forward, $this->setting['regname']) !== false || strpos($url_forward, 'buyinvitecode') !== false) { $url_forward = 'index.php'; } $extra = array('showdialog' => true, 'locationtime' => false, 'extrajs' => ''); showmessage('', $url_forward, array(), array('showid' => 'succeedmessage', 'extrajs' => '<script type="text/javascript">' . 'setTimeout("window.location.href =\'' . $url_forward . '\';", 3000);' . '$(\'succeedmessage_href\').href = \'' . $url_forward . '\';' . '$(\'register_form\').style.display = \'none\';' . '$(\'main_succeed\').style.display = \'\';' . '$(\'succeedlocation\').innerHTML = \'' . lang('message', $message, $param) . '\';</script>', 'striptags' => false, 'showdialog' => false)); //showmessage($message, $url_forward, $param, $extra); } }
private function _updateQqMember($uid, $oauthToken, $openId, $gender) { global $_G; $qqdata = array('uid' => $uid, 'conuin' => $oauthToken, 'conuinsecret' => '', 'conopenid' => $openId, 'conisfeed' => 1, 'conispublishfeed' => 1, 'conispublisht' => 1, 'conisregister' => 1, 'conisqqshow' => 1); $qqbind = array('mblid' => '', 'uid' => $uid, 'uin' => $openId, 'type' => 1, 'dateline' => time()); $this->_inserBindlog($qqbind); $this->_inserConnect($qqdata); $updateInfo = array('avatarstatus' => 1, 'conisbind' => 1); // 用户是否绑定QQ DzCommonMember::updateMember($updateInfo, array('uid' => $uid)); $setarr['gender'] = intval($gender); C::t('common_member_profile')->update($uid, $setarr); $ipArray = explode('.', $_G['clientip']); $sid = FileUtils::getRandomFileName('', 6); $data = array('sid' => $sid, 'ip1' => $ipArray[0], 'ip2' => $ipArray[1], 'ip3' => $ipArray[2], 'ip4' => $ipArray[3], 'uid' => $userInfo['uid'], 'username' => $userInfo['username'], 'groupid' => $userInfo['groupid'], 'invisible' => '0', 'action' => '', 'lastactivity' => time(), 'fid' => '0', 'tid' => '0', 'lastolupdate' => '0'); DzCommonSession::insertComSess($data); require_once libfile('cache/userstats', 'function'); build_cache_userstats(); }