$uid,
		'username' => $username,
		'password' => $password,
		'email' => $email,
		'adminid' => 0,
		'groupid' => $groupinfo['groupid'],
		'regdate' => TIMESTAMP,
		'credits' => $init_arr[0],
		'timeoffset' => 9999
		);
	DB::insert('common_member', $userdata);  //用户表
	$status_data = array(
		'uid' => $uid,
		'regip' => $_G['clientip'],
		'lastip' => $_G['clientip'],
		'lastvisit' => TIMESTAMP,
		'lastactivity' => TIMESTAMP,
		'lastpost' => 0,
		'lastsendmail' => 0,
		);
	DB::insert('common_member_status', $status_data); //用户状态信息表
	$profile['uid'] = $uid;
	DB::insert('common_member_profile', $profile); //用户属性
	DB::insert('common_member_field_forum', array('uid' => $uid)); //bbs用户信息字段
	DB::insert('common_member_field_home', array('uid' => $uid)); //家园用户信息字段
	if($verifyarr) {
		$setverify = array(
				'uid' => $uid,
				'username' => $username,
				'verifytype' => '0',
				'field' => daddslashes(serialize($verifyarr)),
				'dateline' => TIMESTAMP,
			);
		DB::insert('common_member_verify_info', $setverify); //未知
		DB::insert('common_member_verify', array('uid' => $uid)); //未知
	}

	$count_data = array(
		'uid' => $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' => $username), false, true); //配置
	manyoulog('user', $uid, 'add');

	$totalmembers = DB::result_first("SELECT COUNT(*) FROM ".DB::table('common_member'));
	$userstats = array('totalmembers' => $totalmembers, 'newsetuser' => $username);

	save_syscache('userstats', $userstats);

	if($_G['setting']['regctrl'] || $_G['setting']['regfloodctrl']) {
		DB::query("DELETE FROM ".DB::table('common_regip')." WHERE dateline<='$_G[timestamp]'-".($_G['setting']['regctrl'] > 72 ? $_G['setting']['regctrl'] : 72)."*3600", 'UNBUFFERED');
		if($_G['setting']['regctrl']) {
			DB::query("INSERT INTO ".DB::table('common_regip')." (ip, count, dateline)
				VALUES ('$_G[clientip]', '-1', '$_G[timestamp]')");
		}
	}

	$regmessage = dhtmlspecialchars($_G['gp_regmessage']);
	if($_G['setting']['regverify'] == 2) {
		DB::query("REPLACE INTO ".DB::table('common_member_validate')." (uid, submitdate, moddate, admin, submittimes, status, message, remark)
			VALUES ('$uid', '$_G[timestamp]', '0', '', '1', '0', '$regmessage', '')");
	}

	$_G['uid'] = $uid;
	$_G['username'] = $username;
	$_G['member']['username'] = dstripslashes($_G['username']);
	$_G['member']['password'] = $password;
	$_G['groupid'] = $groupinfo['groupid'];
	include_once libfile('function/stat');
	updatestat('register');

	$_CORE = & discuz_core::instance();
	$_CORE->session->set('uid', $uid);
	$_CORE->session->set('username', $username);

	dsetcookie('auth', authcode("{$_G['member']['password']}t$_G[uid]", 'ENCODE'), 2592000, 1, true);

	if($invite['id']) {
		DB::update("common_invite", array('fuid'=>$uid, 'fusername'=>$username, 'regdateline' => $_G['timestamp'], 'status' => 2), array('id'=>$invite['id'])); //更新邀请
		updatestat('invite');
	}
	if($invite['uid']) {
		if($_G['setting']['inviteconfig']['inviteaddcredit']) {
			updatemembercount($uid,
				array($_G['setting']['inviteconfig']['inviterewardcredit'] => $_G['setting']['inviteconfig']['inviteaddcredit']));
		}
		if($_G['setting']['inviteconfig']['invitedaddcredit']) {
			updatemembercount($invite['uid'],
				array($_G['setting']['inviteconfig']['inviterewardcredit'] => $_G['setting']['inviteconfig']['invitedaddcredit']));
		}
		require_once libfile('function/friend');
		friend_make($invite['uid'], $invite['username'], false);
		notification_add($invite['uid'], 'friend', 'invite_friend', array('actor' => ''.$invite['username'].''), 1);

		space_merge($invite, 'field_home');
		if(!empty($invite['privacy']['feed']['invite'])) {
			require_once libfile('function/feed');
			$tite_data = array('username' => ''.$_G['username'].'');
			feed_add('friend', 'feed_invite', $tite_data, '', array(), '', array(), array(), '', '', '', 0, 0, '', $invite['uid'], $invite['username']); //更新feed
		}
		if($invite['appid']) {
			updatestat('appinvite');
		}
	}

	if($welcomemsg && !empty($welcomemsgtxt)) {
		$welcomtitle = !empty($_G['setting']['welcomemsgtitle']) ? $_G['setting']['welcomemsgtitle'] : "Welcome to ".$_G['setting']['bbname']."!";
		$welcomtitle = addslashes(replacesitevar($welcomtitle));
		$welcomemsgtxt = addslashes(replacesitevar($welcomemsgtxt));
		if($welcomemsg == 1) {
			sendpm($uid, $welcomtitle, $welcomemsgtxt, 0);
		} elseif($welcomemsg == 2) {
			sendmail_cron($email, $welcomtitle, $welcomemsgtxt);
		}
	}

	if($fromuid) {
		updatecreditbyaction('promotion_register', $fromuid);
		dsetcookie('promotion', '');
	}

	dsetcookie('loginuser', '');
	dsetcookie('activationauth', '');
	dsetcookie('invite_auth', '');
?>

Comments are closed.

Post Navigation