// ############################### start add member ###############################
if ($_POST['do'] == 'addmember')
{
$vbulletin->input->clean_array_gpc('p', array(
'options' => TYPE_ARRAY_BOOL,
'username' => TYPE_STR,
'email' => TYPE_STR,
'emailconfirm' => TYPE_STR,
'parentemail' => TYPE_STR,
'password' => TYPE_STR,
'password_md5' => TYPE_STR,
'passwordconfirm' => TYPE_STR,
'passwordconfirm_md5' => TYPE_STR,
'referrername' => TYPE_NOHTML,
'coppauser' => TYPE_BOOL,
'day' => TYPE_UINT,
'month' => TYPE_UINT,
'year' => TYPE_UINT,
'timezoneoffset' => TYPE_NUM,
'dst' => TYPE_UINT,
'userfield' => TYPE_ARRAY,
'showbirthday' => TYPE_UINT,
'humanverify' => TYPE_ARRAY,
));
if (!$vbulletin->options['allowregistration'])
{
eval(standard_error(fetch_error('noregister')));
}
// check for multireg
if ($vbulletin->userinfo['userid'] AND !$vbulletin->options['allowmultiregs'])
{
eval(standard_error(fetch_error('alreadyregistered', $vbulletin->userinfo['username'], $vbulletin->session->vars['sessionurl'])));
}
// init user datamanager class
$userdata = datamanager_init('User', $vbulletin, ERRTYPE_ARRAY);
// coppa option
if ($vbulletin->options['usecoppa'])
{
$current['year'] = date('Y');
$current['month'] = date('m');
$current['day'] = date('d');
$month = $vbulletin->GPC['month'];
$year = $vbulletin->GPC['year'];
$day = $vbulletin->GPC['day'];
if ($year > 1970 AND mktime(0, 0, 0, $month, $day, $year) > mktime(0, 0, 0, $current['month'], $current['day'], $current['year'] - 13))
{
if ($vbulletin->options['checkcoppa'])
{
vbsetcookie('coppaage', $month . '-' . $day . '-' . $year, 1);
}
if ($vbulletin->options['usecoppa'] == 2)
{
standard_error(fetch_error('under_thirteen_registration_denied'));
}
$vbulletin->GPC['coppauser'] = true;
}
else
{
$vbulletin->GPC['coppauser'] = false;
}
}
else
{
$vbulletin->GPC['coppauser'] = false;
}
$userdata->set_info('coppauser', $vbulletin->GPC['coppauser']);
$userdata->set_info('coppapassword', $vbulletin->GPC['password']);
$userdata->set_bitfield('options', 'coppauser', $vbulletin->GPC['coppauser']);
$userdata->set('parentemail', $vbulletin->GPC['parentemail']);
// check for missing fields
if (empty($vbulletin->GPC['username'])
OR empty($vbulletin->GPC['email'])
OR empty($vbulletin->GPC['emailconfirm'])
OR ($vbulletin->GPC['coppauser'] AND empty($vbulletin->GPC['parentemail']))
OR (empty($vbulletin->GPC['password']) AND empty($vbulletin->GPC['password_md5']))
OR (empty($vbulletin->GPC['passwordconfirm']) AND empty($vbulletin->GPC['passwordconfirm_md5']))
)
{
$userdata->error('fieldmissing');
}
// check for matching passwords
if ($vbulletin->GPC['password'] != $vbulletin->GPC['passwordconfirm'] OR (strlen($vbulletin->GPC['password_md5']) == 32 AND $vbulletin->GPC['password_md5'] != $vbulletin->GPC['passwordconfirm_md5']))
{
$userdata->error('passwordmismatch');
}
// check for matching email addresses
if ($vbulletin->GPC['email'] != $vbulletin->GPC['emailconfirm'])
{
$userdata->error('emailmismatch');
}
$userdata->set('email', $vbulletin->GPC['email']);
$userdata->set('username', $vbulletin->GPC['username']);
// set password
$userdata->set('password', ($vbulletin->GPC['password_md5'] ? $vbulletin->GPC['password_md5'] : $vbulletin->GPC['password']));
// check referrer
if ($vbulletin->GPC['referrername'] AND !$vbulletin->userinfo['userid'])
{
$userdata->set('referrerid', $vbulletin->GPC['referrername']);
}
// Human Verification
if (fetch_require_hvcheck('register'))
{
require_once(DIR . '/includes/class_humanverify.php');
$verify = vB_HumanVerify::fetch_library($vbulletin);
if (!$verify->verify_token($vbulletin->GPC['humanverify']))
{
$userdata->error($verify->fetch_error());
}
}
// Set specified options
if (!empty($vbulletin->GPC['options']))
{
foreach ($vbulletin->GPC['options'] AS $optionname => $onoff)
{
$userdata->set_bitfield('options', $optionname, $onoff);
}
}
// assign user to usergroup 3 if email needs verification
if ($vbulletin->options['verifyemail'])
{
$newusergroupid = 3;
}
else if ($vbulletin->options['moderatenewmembers'] OR $vbulletin->GPC['coppauser'])
{
$newusergroupid = 4;
}
else
{
$newusergroupid = 2;
}
// set usergroupid
$userdata->set('usergroupid', $newusergroupid);
// set languageid
$userdata->set('languageid', $vbulletin->userinfo['languageid']);
// set user title
$userdata->set_usertitle('', false, $vbulletin->usergroupcache["$newusergroupid"], false, false);
// set profile fields
$customfields = $userdata->set_userfields($vbulletin->GPC['userfield'], true, 'register');
// set birthday
$userdata->set('showbirthday', $vbulletin->GPC['showbirthday']);
$userdata->set('birthday', array(
'day' => $vbulletin->GPC['day'],
'month' => $vbulletin->GPC['month'],
'year' => $vbulletin->GPC['year']
));
// set time options
$userdata->set_dst($vbulletin->GPC['dst']);
$userdata->set('timezoneoffset', $vbulletin->GPC['timezoneoffset']);
// register IP address
$userdata->set('ipaddress', IPADDRESS);
($hook = vBulletinHook::fetch_hook('register_addmember_process')) ? eval($hook) : false;
$userdata->pre_save();
// check for errors
if (!empty($userdata->errors))
{
$_REQUEST['do'] = 'register';
$errorlist = '';
foreach ($userdata->errors AS $index => $error)
{
$errorlist .= "<li>$error</li>";
}
$username = htmlspecialchars_uni($vbulletin->GPC['username']);
$email = htmlspecialchars_uni($vbulletin->GPC['email']);
$emailconfirm = htmlspecialchars_uni($vbulletin->GPC['emailconfirm']);
$parentemail = htmlspecialchars_uni($vbulletin->GPC['parentemail']);
$selectdst = array($vbulletin->GPC['dst'] => 'selected="selected"');
$sbselected = array($vbulletin->GPC['showbirthday'] => 'selected="selected"');
$show['errors'] = true;
}
else
{
$show['errors'] = false;
// save the data
$vbulletin->userinfo['userid']
= $userid
= $userdata->save();
if ($userid)
{
$userinfo = fetch_userinfo($userid,0,0,0,true); // Read Master
$userdata_rank = datamanager_init('User', $vbulletin, ERRTYPE_SILENT);
$userdata_rank->set_existing($userinfo);
$userdata_rank->set('posts', 0);
$userdata_rank->save();
// force a new session to prevent potential issues with guests from the same IP, see bug #2459
require_once(DIR . '/includes/functions_login.php');
$vbulletin->session->created = false;
process_new_login('', false, '');
// send new user email
if ($vbulletin->options['newuseremail'] != '')
{
$username = $vbulletin->GPC['username'];
$email = $vbulletin->GPC['email'];
if ($birthday = $userdata->fetch_field('birthday'))
{
$bday = explode('-', $birthday);
$year = vbdate('Y', TIMENOW, false, false);
$month = vbdate('n', TIMENOW, false, false);
$day = vbdate('j', TIMENOW, false, false);
if ($year > $bday[2] AND $bday[2] > 1901 AND $bday[2] != '0000')
{
require_once(DIR . '/includes/functions_misc.php');
$vbulletin->options['calformat1'] = mktimefix($vbulletin->options['calformat1'], $bday[2]);
if ($bday[2] >= 1970)
{
$yearpass = $bday[2];
}
else
{
// day of the week patterns repeat every 28 years, so
// find the first year >= 1970 that has this pattern
$yearpass = $bday[2] + 28 * ceil((1970 - $bday[2]) / 28);
}
$birthday = vbdate($vbulletin->options['calformat1'], mktime(0, 0, 0, $bday[0], $bday[1], $yearpass), false, true, false);
}
else
{
// lets send a valid year as some PHP3 don't like year to be 0
$birthday = vbdate($vbulletin->options['calformat2'], mktime(0, 0, 0, $bday[0], $bday[1], 1992), false, true, false);
}
if ($birthday == '')
{
// Should not happen; fallback for win32 bug regarding mktime and dates < 1970
if ($bday[2] == '0000')
{
$birthday = "$bday[0]-$bday[1]";
}
else
{
$birthday = "$bday[0]-$bday[1]-$bday[2]";
}
}
}
if ($userdata->fetch_field('referrerid') AND $vbulletin->GPC['referrername'])
{
$referrer = unhtmlspecialchars($vbulletin->GPC['referrername']);
}
else
{
$referrer = $vbphrase['n_a'];
}
$ipaddress = IPADDRESS;
eval(fetch_email_phrases('newuser', 0));
$newemails = explode(' ', $vbulletin->options['newuseremail']);
foreach ($newemails AS $toemail)
{
if (trim($toemail))
{
vbmail($toemail, $subject, $message);
}
}
}
$username = htmlspecialchars_uni($vbulletin->GPC['username']);
$email = htmlspecialchars_uni($vbulletin->GPC['email']);
// sort out emails and usergroups
if ($vbulletin->options['verifyemail'])
{
$activateid = build_user_activation_id($userid, (($vbulletin->options['moderatenewmembers'] OR $vbulletin->GPC['coppauser']) ? 4 : 2), 0);
eval(fetch_email_phrases('activateaccount'));
vbmail($email, $subject, $message, true);
}
else if ($newusergroupid == 2)
{
if ($vbulletin->options['welcomemail'])
{
eval(fetch_email_phrases('welcomemail'));
vbmail($email, $subject, $message);
}
}
($hook = vBulletinHook::fetch_hook('register_addmember_complete')) ? eval($hook) : false;
if ($vbulletin->GPC['coppauser'])
{
$_REQUEST['do'] = 'coppaform';
}
else
{
if ($vbulletin->options['verifyemail'])
{
eval(standard_error(fetch_error('registeremail', $username, $email, create_full_url($vbulletin->url . $vbulletin->session->vars['sessionurl_q'])), '', false));
}
else
{
$vbulletin->url = str_replace('"', '', $vbulletin->url);
if (!$vbulletin->url)
{
$vbulletin->url = $vbulletin->options['forumhome'] . '.php' . $vbulletin->session->vars['sessionurl_q'];
}
else
{
$vbulletin->url = iif(strpos($vbulletin->url, 'register.php') !== false, $vbulletin->options['forumhome'] . '.php' . $vbulletin->session->vars['sessionurl_q'], $vbulletin->url);
}
if ($vbulletin->options['moderatenewmembers'])
{
eval(standard_error(fetch_error('moderateuser', $username, $vbulletin->options['forumhome'], $vbulletin->session->vars['sessionurl_q']), '', false));
}
else
{
eval(standard_error(fetch_error('registration_complete', $username, $vbulletin->session->vars['sessionurl'], $vbulletin->options['bburl'] . '/' . $vbulletin->options['forumhome'] . '.php'), '', false));
}
}
}
}
}
}
else if ($_GET['do'] == 'addmember')
{
// hmm, this probably happened because of a template edit that put the login box in the header.
exec_header_redirect($vbulletin->options['forumhome'] . '.php');
}Add a code snippet to your website: www.paste.org