<?php
if (!defined('BB_ROOT')) die(basename(__FILE__));
array_deep($_POST, 'trim');
set_die_append_msg();
if (IS_ADMIN)
{
$bb_cfg['reg_email_activation'] = false;
$new_user = (int) request_var('admin', '');
if ($new_user) $gen_simple_header = true;
$template->assign_vars(array(
'NEW_USER' => $new_user,
));
}
$can_register = (IS_GUEST || IS_ADMIN);
$submit = !empty($_POST['submit']);
$errors = array();
$adm_edit = false; // редактирование админом чужого профиля
require(INC_DIR .'bbcode.php');
require(INC_DIR .'functions_validate.php');
require(INC_DIR .'functions_selects.php');
$pr_data = array(); // данные редактируемого либо регистрационного профиля
$db_data = array(); // данные для базы: регистрационные либо измененные данные юзера
$tp_data = array(); // данные для tpl
// Данные профиля
switch ($mode)
{
/**
* Регистрация
*/
case 'register':
if (!$can_register) redirect('index.php');
if (!IS_ADMIN)
{
// Ограничение по ip
if($bb_cfg['unique_ip'])
{
if($users = DB()->fetch_row("SELECT user_id, username FROM ". BB_USERS ." WHERE user_reg_ip = '". USER_IP ."' LIMIT 1"))
{
bb_die(sprintf($lang['ALREADY_REG_IP'], '<a href="'. PROFILE_URL . $users['user_id'] .'"><b>'. $users['username'] .'</b></a>', $bb_cfg['tech_admin_email']));
}
}
// Отключение регистрации
if ($bb_cfg['new_user_reg_disabled'] || ($bb_cfg['reg_email_activation'] && $bb_cfg['emailer_disabled']))
{
bb_die($lang['NEW_USER_REG_DISABLED']);
}
// Ограничение по времени
else if ($bb_cfg['new_user_reg_restricted'])
{
if (in_array(date('G'), array(0,/*1,2,3,4,5,6,7,8,11,12,13,14,15,16,*/17,18,19,20,21,22,23)))
{
bb_die($lang['REGISTERED_IN_TIME']);
}
}
}
// field => can_edit
$profile_fields = array(
'username' => true,
'user_password' => true,
'user_email' => true,
'user_timezone' => true,
'user_lang' => true,
'user_opt' => true,
);
$pr_data = array(
'user_id' => GUEST_UID,
'username' => '',
'user_password' => '',
'user_email' => '',
'user_timezone' => $bb_cfg['board_timezone'],
'user_lang' => $bb_cfg['default_lang'],
'user_opt' => 0,
'avatar_ext_id' => 0,
);
break;
/**
* Редактирование профиля
*/
case 'editprofile':
if (IS_GUEST) login_redirect();
// field => can_edit
$profile_fields = array(
'user_active' => IS_ADMIN,
'username' => (IS_ADMIN || $bb_cfg['allow_namechange']),
'user_password' => true,
'user_email' => true, // должен быть после user_password
'user_lang' => true,
'user_gender' => true,
'user_birthday' => true,
'user_timezone' => true,
'user_opt' => true,
'avatar_ext_id' => true,
'user_icq' => true,
'user_skype' => true,
'user_twitter' => true,
'user_website' => true,
'user_from' => true,
'user_sig' => true,
'user_occ' => true,
'user_interests' => true,
'tpl_name' => true,
);
// Выбор профиля: для юзера свой, для админа любой
if (IS_ADMIN && !empty($_REQUEST['u']))
{
$pr_user_id = (int) $_REQUEST['u'];
$adm_edit = ($pr_user_id != $userdata['user_id']);
}
else
{
$pr_user_id = $userdata['user_id'];
}
$profile_fields_sql = join(', ', array_keys($profile_fields));
$sql = "
SELECT
user_id,
user_rank,
user_level,
$profile_fields_sql
FROM ". BB_USERS ."
WHERE user_id = $pr_user_id
LIMIT 1
";
if (!$pr_data = DB()->fetch_row($sql))
{
bb_die($lang['PROFILE_NOT_FOUND']);
}
break;
default:
trigger_error("invalid mode: $mode", E_USER_ERROR);
}
// CAPTCHA
$need_captcha = ($mode == 'register' && !IS_ADMIN);
if ($submit)
{
if ($need_captcha && !CAPTCHA()->verify_code())
{
$errors[] = $lang['CONFIRM_CODE_WRONG'];
}
}
// Валидация данных
$cur_pass_valid = $adm_edit;
foreach ($profile_fields as $field => $can_edit)
{
switch ($field)
{
/**
* Активация (edit, reg)
*/
case 'user_active':
$active = isset($_POST['user_active']) ? (int) $_POST['user_active'] : $pr_data['user_active'];
if ($submit && $adm_edit)
{
$pr_data['user_active'] = $active;
$db_data['user_active'] = $active;
}
break;
/**
* Имя (edit, reg)
*/
case 'username':
$username = !empty($_POST['username']) ? clean_username($_POST['username']) : $pr_data['username'];
if ($submit)
{
$err = validate_username($username);
if (!$errors AND $err && $mode == 'register')
{
$errors[] = $err;
}
if ($can_edit && $username != $pr_data['username'] || $mode == 'register')
{
$pr_data['username'] = $username;
$db_data['username'] = $username;
}
}
$tp_data['CAN_EDIT_USERNAME'] = $can_edit;
$tp_data['USERNAME'] = $pr_data['username'];
break;
/**
* Пароль (edit, reg)
*/
case 'user_password':
if ($submit)
{
$cur_pass = (string) @$_POST['cur_pass'];
$new_pass = (string) @$_POST['new_pass'];
$cfm_pass = (string) @$_POST['cfm_pass'];
// пароль для гостя и при смене пароля юзером
if (!empty($new_pass))
{
if (mb_strlen($new_pass, 'UTF-8') > 20)
{
$errors[] = sprintf($lang['CHOOSE_PASS_ERR_MAX'], 20);
}
elseif (mb_strlen($new_pass, 'UTF-8') < 4)
{
$errors[] = sprintf($lang['CHOOSE_PASS_ERR_MIN'], 4);
}
elseif ($new_pass != $cfm_pass)
{
$errors[] = $lang['CHOOSE_PASS_ERR'];
}
$db_data['user_password'] = md5(md5($new_pass));
}
if ($mode == 'register')
{
if (empty($new_pass))
{
$errors[] = $lang['CHOOSE_PASS'];
}
}
else
{
if (!empty($cur_pass))
{
$cur_pass_valid = ($pr_data['user_password'] === md5(md5($cur_pass)));
}
if (!empty($new_pass) && !$cur_pass_valid)
{
$errors[] = $lang['CHOOSE_PASS_FAILED'];
}
}
}
break;
/**
* E-mail (edit, reg)
*/
case 'user_email':
$email = !empty($_POST['user_email']) ? (string) $_POST['user_email'] : $pr_data['user_email'];
if ($submit)
{
if ($mode == 'register')
{
if (empty($email))
{
$errors[] = $lang['CHOOSE_E_MAIL'];
}
if (!$errors AND $err = validate_email($email))
{
$errors[] = $err;
}
$db_data['user_email'] = $email;
}
else if ($email != $pr_data['user_email']) // если смена мейла юзером
{
if (!$cur_pass_valid)
{
$errors[] = $lang['CONFIRM_PASSWORD_EXPLAIN'];
}
if (!$errors AND $err = validate_email($email))
{
$errors[] = $err;
}
if ($bb_cfg['reg_email_activation'])
{
$pr_data['user_active'] = 0;
$db_data['user_active'] = 0;
}
$db_data['user_email'] = $email;
}
}
$tp_data['USER_EMAIL'] = htmlCHR($email);
break;
/**
* Язык (edit, reg)
*/
case 'user_lang':
$user_lang = isset($_POST['user_lang']) ? (string) $_POST['user_lang'] : $pr_data['user_lang'];
if ($submit && ($user_lang != $pr_data['user_lang'] || $mode == 'register'))
{
$pr_data['user_lang'] = $user_lang;
$db_data['user_lang'] = $user_lang;
}
break;
/**
* Часовой пояс (edit, reg)
*/
case 'user_timezone':
$user_timezone = isset($_POST['user_timezone']) ? (int) $_POST['user_timezone'] : $pr_data['user_timezone'];
if ($submit && ($user_timezone != $pr_data['user_timezone'] || $mode == 'register'))
{
if (isset($lang['TZ'][$user_timezone]))
{
$pr_data['user_timezone'] = $user_timezone;
$db_data['user_timezone'] = $user_timezone;
}
}
break;
/**
* Пол (edit, reg)
*/
case 'user_gender':
$user_gender = isset($_POST['user_gender']) ? (int) $_POST['user_gender'] : $pr_data['user_gender'];
if ($submit && $user_gender != $pr_data['user_gender'])
{
$pr_data['user_gender'] = $user_gender;
$db_data['user_gender'] = $user_gender;
}
$tp_data['USER_GENDER'] = build_select('user_gender', array_flip($lang['GENDER_SELECT']), $pr_data['user_gender']);
break;
/**
* Возраст (edit)
*/
case 'user_birthday':
$user_birthday = isset($_POST['user_birthday']) ? (string) $_POST['user_birthday'] : $pr_data['user_birthday'];
if ($submit && $user_birthday != $pr_data['user_birthday'])
{
$birthday_date = date_parse($user_birthday);
if (!empty($birthday_date['year']))
{
if (strtotime($user_birthday) >= TIMENOW)
{
$errors[] = $lang['WRONG_BIRTHDAY_FORMAT'];
}
elseif (bb_date(TIMENOW, 'Y', false) - $birthday_date['year'] > $bb_cfg['birthday_max_age'])
{
$errors[] = sprintf($lang['BIRTHDAY_TO_HIGH'], $bb_cfg['birthday_max_age']);
}
elseif (bb_date(TIMENOW, 'Y', false) - $birthday_date['year'] < $bb_cfg['birthday_min_age'])
{
$errors[] = sprintf($lang['BIRTHDAY_TO_LOW'], $bb_cfg['birthday_min_age']);
}
}
$pr_data['user_birthday'] = $user_birthday;
$db_data['user_birthday'] = $user_birthday;
}
$tp_data['USER_BIRTHDAY'] = $pr_data['user_birthday'];
break;
/**
* opt (edit)
*/
case 'user_opt':
$user_opt = $pr_data['user_opt'];
$reg_mode = ($mode == 'register');
$update_user_opt = array(
# 'user_opt_name' => ($reg_mode) ? #reg_value : #in_login_change
'user_viewemail' => ($reg_mode) ? false : true,
'user_viewonline' => ($reg_mode) ? false : true,
'user_notify' => ($reg_mode) ? true : true,
'user_notify_pm' => ($reg_mode) ? true : true,
'user_porn_forums' => ($reg_mode) ? false : true,
'user_dls' => ($reg_mode) ? false : true,
'user_callseed' => ($reg_mode) ? true : true,
'user_retracker' => ($reg_mode) ? true : true,
);
foreach ($update_user_opt as $opt => $can_change_opt)
{
if ($submit && (isset($_POST[$opt]) && $can_change_opt || $reg_mode))
{
$change_opt = ($reg_mode) ? $can_change_opt : !empty($_POST[$opt]);
setbit($user_opt, $bf['user_opt'][$opt], $change_opt);
}
$tp_data[strtoupper($opt)] = bf($user_opt, 'user_opt', $opt);
}
if ($submit && ($user_opt != $pr_data['user_opt'] || $reg_mode))
{
$pr_data['user_opt'] = $user_opt;
$db_data['user_opt'] = (int) $user_opt;
}
break;
/**
* Avatar (edit)
*/
case 'avatar_ext_id':
if ($submit && !bf($pr_data['user_opt'], 'user_opt', 'dis_avatar'))
{
if (isset($_POST['delete_avatar']))
{
delete_avatar($pr_data['user_id'], $pr_data['avatar_ext_id']);
$pr_data['avatar_ext_id'] = 0;
$db_data['avatar_ext_id'] = 0;
}
else if (!empty($_FILES['avatar']['name']) && $bb_cfg['avatars']['up_allowed'])
{
require(INC_DIR .'functions_upload.php');
$upload = new upload_common();
if ($upload->init($bb_cfg['avatars'], $_FILES['avatar']) AND $upload->store('avatar', $pr_data))
{
$pr_data['avatar_ext_id'] = $upload->file_ext_id;
$db_data['avatar_ext_id'] = (int) $upload->file_ext_id;
}
else
{
$errors = array_merge($errors, $upload->errors);
}
}
}
$tp_data['AVATARS_MAX_SIZE'] = humn_size($bb_cfg['avatars']['max_size']);
break;
/**
* ICQ (edit)
*/
case 'user_icq':
$icq = isset($_POST['user_icq']) ? (string) $_POST['user_icq'] : $pr_data['user_icq'];
if ($submit && $icq != $pr_data['user_icq'])
{
if ($icq == '' || preg_match('#^\d{6,15}$#', $icq))
{
$pr_data['user_icq'] = $icq;
$db_data['user_icq'] = (string) $icq;
}
else
{
$pr_data['user_icq'] = '';
$errors[] = htmlCHR($lang['ICQ_ERROR']);
}
}
$tp_data['USER_ICQ'] = $pr_data['user_icq'];
break;
/**
* Сайт (edit)
*/
case 'user_website':
$website = isset($_POST['user_website']) ? (string) $_POST['user_website'] : $pr_data['user_website'];
$website = htmlCHR($website);
if ($submit && $website != $pr_data['user_website'])
{
if ($website == '' || preg_match('#^https?://[\w\#!$%&~/.\-;:=,?@а-яА-Я\[\]+]+$#iu', $website))
{
$pr_data['user_website'] = $website;
$db_data['user_website'] = (string) $website;
}
else
{
$pr_data['user_website'] = '';
$errors[] = htmlCHR($lang['WEBSITE_ERROR']);
}
}
$tp_data['USER_WEBSITE'] = $pr_data['user_website'];
break;
/**
* Откуда (edit)
*/
case 'user_from':
$from = isset($_POST['user_from']) ? (string) $_POST['user_from'] : $pr_data['user_from'];
$from = htmlCHR($from);
if ($submit && $from != $pr_data['user_from'])
{
$pr_data['user_from'] = $from;
$db_data['user_from'] = (string) $from;
}
$tp_data['USER_FROM'] = $pr_data['user_from'];
break;
/**
* Подпись (edit)
*/
case 'user_sig':
$sig = isset($_POST['user_sig']) ? (string) $_POST['user_sig'] : $pr_data['user_sig'];
if ($submit && $sig != $pr_data['user_sig'])
{
$sig = prepare_message($sig);
if (mb_strlen($sig, 'UTF-8') > $bb_cfg['max_sig_chars'])
{
$errors[] = $lang['SIGNATURE_TOO_LONG'];
}
else if (preg_match('#<(a|b|i|u|table|tr|td|img) #i', $sig) || preg_match('#(href|src|target|title)=#i', $sig))
{
$errors[] = $lang['SIGNATURE_ERROR_HTML'];
}
$pr_data['user_sig'] = $sig;
$db_data['user_sig'] = (string) $sig;
}
$tp_data['USER_SIG'] = $pr_data['user_sig'];
break;
/**
* Род занятий (edit)
*/
case 'user_occ':
$occ = isset($_POST['user_occ']) ? (string) $_POST['user_occ'] : $pr_data['user_occ'];
$occ = htmlCHR($occ);
if ($submit && $occ != $pr_data['user_occ'])
{
$pr_data['user_occ'] = $occ;
$db_data['user_occ'] = (string) $occ;
}
$tp_data['USER_OCC'] = $pr_data['user_occ'];
break;
/**
* Интересы
*/
case 'user_interests':
$interests = isset($_POST['user_interests']) ? (string) $_POST['user_interests'] : $pr_data['user_interests'];
$interests = htmlCHR($interests);
if ($submit && $interests != $pr_data['user_interests'])
{
$pr_data['user_interests'] = $interests;
$db_data['user_interests'] = (string) $interests;
}
$tp_data['USER_INTERESTS'] = $pr_data['user_interests'];
break;
/**
* Skype
*/
case 'user_skype':
$skype = isset($_POST['user_skype']) ? (string) $_POST['user_skype'] : $pr_data['user_skype'];
if ($submit && $skype != $pr_data['user_skype'])
{
if ($skype != '' && !preg_match("#^[a-zA-Z0-9_.\-@,]{6,32}$#", $skype))
{
$errors[] = $lang['SKYPE_ERROR'];
}
$pr_data['user_skype'] = $skype;
$db_data['user_skype'] = (string) $skype;
}
$tp_data['USER_SKYPE'] = $pr_data['user_skype'];
break;
/**
* Twitter
*/
case 'user_twitter':
$twitter = isset($_POST['user_twitter']) ? (string) $_POST['user_twitter'] : $pr_data['user_twitter'];
if ($submit && $twitter != $pr_data['user_twitter'])
{
if ($twitter != '' && !preg_match("#^[a-zA-Z0-9_]{1,15}$#", $twitter))
{
$errors[] = $lang['TWITTER_ERROR'];
}
$pr_data['user_twitter'] = $twitter;
$db_data['user_twitter'] = (string) $twitter;
}
$tp_data['USER_TWITTER'] = $pr_data['user_twitter'];
break;
/**
* Выбор шаблона (edit)
*/
case 'tpl_name':
$templates = isset($_POST['tpl_name']) ? (string) $_POST['tpl_name'] : $pr_data['tpl_name'];
$templates = htmlCHR($templates);
if ($submit && $templates != $pr_data['tpl_name'])
{
$pr_data['tpl_name'] = $bb_cfg['tpl_name'];
$db_data['tpl_name'] = (string) $bb_cfg['tpl_name'];
foreach ($bb_cfg['templates'] as $folder => $name)
{
if ($templates == $folder)
{
$pr_data['tpl_name'] = $templates;
$db_data['tpl_name'] = (string) $templates;
}
}
}
$tp_data['TEMPLATES_SELECT'] = templates_select($pr_data['tpl_name'], 'tpl_name');
break;
/**
* default
*/
default:
trigger_error("invalid profile field: $field", E_USER_ERROR);
}
}
$tp_data['ULOGIN'] = 0;
if (!empty($_POST['token']))
{
require_once (INC_DIR .'class.ulogin.php');
$uLogin = new uLogin();
if ($row = $uLogin->auth())
{
$user->session_create($row);
$redirect_url = (defined('FIRST_LOGON')) ? $bb_cfg['first_logon_redirect_url'] : $_SERVER['QUERY_STRING'];
if ($redirect_url == '/login.php' || $redirect_url == 'login.php') $redirect_url = 'index.php';
redirect($redirect_url);
}
$db_data = array(
'username' => clean_username($uLogin->name()),
'user_password' => $uLogin->password(6),
'user_email' => strtolower($uLogin->email()),
'user_from' => $uLogin->from(),
);
$tp_data = array(
'CAN_EDIT_USERNAME' => true,
'USERNAME' => clean_username($uLogin->name()),
'USER_PASSWORD' => $uLogin->password(6),
'USER_EMAIL' => strtolower($uLogin->email()),
'ULOGIN' => $uLogin->identity(),
);
}
else
{
if(!empty($_POST['ulogin']))
{
$tp_data['ULOGIN'] = $_POST['ulogin'];
}
}
// submit
if ($submit && !$errors)
{
/**
* Создание нового профиля
*/
if ($mode == 'register')
{
if ($bb_cfg['reg_email_activation'])
{
$user_actkey = make_rand_str(12);
$db_data['user_active'] = 0;
$db_data['user_actkey'] = $user_actkey;
}
else
{
$db_data['user_active'] = 1;
$db_data['user_actkey'] = '';
}
$db_data['user_regdate'] = TIMENOW;
$db_data['user_rank'] = 2; //сразу user после реги
if (!IS_ADMIN) $db_data['user_reg_ip'] = USER_IP;
if (!isset($db_data['tpl_name'])) $db_data['tpl_name'] = (string) $bb_cfg['tpl_name'];
$sql_args = DB()->build_array('INSERT', $db_data);
DB()->query("INSERT INTO ". BB_USERS . $sql_args);
$new_user_id = DB()->sql_nextid();
if(!empty($_POST['ulogin'])) DB()->query("INSERT INTO bb_ulogin VALUES (NULL, $new_user_id, '" . DB()->escape($_POST['ulogin']) . "')");
if (IS_ADMIN)
{
set_pr_die_append_msg($new_user_id);
$message = $lang['ACCOUNT_ADDED'];
}
else
{
if ($bb_cfg['reg_email_activation'])
{
$message = $lang['ACCOUNT_INACTIVE'];
$email_template = 'user_welcome_inactive';
}
else
{
$message = $lang['ACCOUNT_ADDED'];
$email_template = 'user_welcome';
}
require(INC_DIR .'emailer.class.php');
$emailer = new emailer($bb_cfg['smtp_delivery']);
$emailer->from($bb_cfg['sitename'] ." <{$bb_cfg['board_email']}>");
$emailer->email_address("$username <$email>");
$emailer->use_template($email_template, $user_lang);
$emailer->assign_vars(array(
'SITENAME' => $bb_cfg['sitename'],
'WELCOME_MSG' => sprintf($lang['WELCOME_SUBJECT'], $bb_cfg['sitename']),
'USERNAME' => html_entity_decode($username),
'PASSWORD' => $new_pass,
'U_ACTIVATE' => make_url('profile.php?mode=activate&' . POST_USERS_URL . '=' . $new_user_id . '&act_key=' . $db_data['user_actkey'])
));
$emailer->send();
$emailer->reset();
}
bb_die($message);
}
/**
* Редактирование
*/
else
{
set_pr_die_append_msg($pr_data['user_id']);
// если что-то было изменено
if ($db_data)
{
if (!$pr_data['user_active'])
{
$user_actkey = make_rand_str(12);
$pr_data['user_actkey'] = $user_actkey;
$db_data['user_actkey'] = $user_actkey;
require(INC_DIR .'emailer.class.php');
$emailer = new emailer($bb_cfg['smtp_delivery']);
$emailer->from($bb_cfg['sitename'] ." <{$bb_cfg['board_email']}>");
$emailer->use_template('user_activate', $pr_data['user_lang']);
$emailer->email_address("$username <$email>");
$emailer->assign_vars(array(
'SITENAME' => $bb_cfg['sitename'],
'USERNAME' => html_entity_decode($username),
'U_ACTIVATE' => make_url("profile.php?mode=activate&u={$pr_data['user_id']}&act_key=$user_actkey"),
));
$emailer->send();
$emailer->reset();
$message = $lang['PROFILE_UPDATED_INACTIVE'];
$user->session_end();
}
else
{
meta_refresh('index.php' , 10);
$message = $lang['PROFILE_UPDATED'];
}
$sql_args = DB()->build_array('UPDATE', $db_data);
DB()->query("UPDATE ". BB_USERS ." SET $sql_args WHERE user_id = {$pr_data['user_id']} LIMIT 1");
if ($pr_data['user_id'] != $userdata['user_id'])
{
if ($pr_data['user_level'] == MOD && !empty($db_data['username']))
{
$datastore->update('moderators');
}
}
cache_rm_user_sessions ($pr_data['user_id']);
if($adm_edit)
{
bb_die($lang['PROFILE_USER'] . ' <b>'. profile_url($pr_data) .'</b> '. $lang['GOOD_UPDATE']);
}
elseif(!$pr_data['user_active'])
{
bb_die($lang['PROFILE_UPDATED_INACTIVE']);
}
else
{
meta_refresh('index.php' , 10);
bb_die($lang['PROFILE_UPDATED']);
}
}
else
{
bb_die($lang['NOTHING_HAS_CHANGED']);
}
}
}
$template->assign_vars($tp_data);
$template->assign_vars(array(
'PAGE_TITLE' => ($mode == 'editprofile') ? $lang['EDIT_PROFILE'] . ($adm_edit ? " :: {$pr_data['username']}" : '') : $lang['REGISTER'],
'SHOW_REG_AGREEMENT' => ($mode == 'register' && !IS_ADMIN),
'ERROR_MESSAGE' => ($errors) ? join('<br />', array_unique($errors)) : '',
'MODE' => $mode,
'EDIT_PROFILE' => ($mode == 'editprofile'),
'ADM_EDIT' => $adm_edit,
'SHOW_PASS' => ($adm_edit || ($mode == 'register' && IS_ADMIN)),
'CAPTCHA_HTML' => ($need_captcha) ? CAPTCHA()->get_html() : '',
'LANGUAGE_SELECT' => language_select($pr_data['user_lang'], 'user_lang'),
'TIMEZONE_SELECT' => tz_select($pr_data['user_timezone'], 'user_timezone'),
'USER_TIMEZONE' => $pr_data['user_timezone'],
'AVATAR_EXPLAIN' => sprintf($lang['AVATAR_EXPLAIN'], $bb_cfg['avatars']['max_width'], $bb_cfg['avatars']['max_height'], (round($bb_cfg['avatars']['max_size'] / 1024))),
'AVATAR_DISALLOWED' => bf($pr_data['user_opt'], 'user_opt', 'dis_avatar'),
'AVATAR_DIS_EXPLAIN' => sprintf($lang['AVATAR_DISABLE'], $bb_cfg['terms_and_conditions_url']),
'SIGNATURE_EXPLAIN' => sprintf($lang['SIGNATURE_EXPLAIN'], $bb_cfg['max_sig_chars']),
'SIG_DISALLOWED' => bf($pr_data['user_opt'], 'user_opt', 'dis_sig'),
'PR_USER_ID' => $pr_data['user_id'],
'U_RESET_AUTOLOGIN' => LOGIN_URL . "?logout=1&reset_autologin=1&sid={$userdata['session_id']}",
'AVATAR_URL_PATH' => ($pr_data['avatar_ext_id']) ? get_avatar_path($pr_data['user_id'], $pr_data['avatar_ext_id']) : '',
));
print_page('usercp_register.tpl');