root / tags / release_3_0_1 / phpBB / includes / ucp / ucp_register.php @ 8499
History | View | Annotate | Download (17 kB)
| 1 | 4018 | psotfx | <?php
|
|---|---|---|---|
| 2 | 7408 | kellanved | /**
|
| 3 | 5114 | acydburn | * |
| 4 | 5114 | acydburn | * @package ucp |
| 5 | 5114 | acydburn | * @version $Id$ |
| 6 | 7408 | kellanved | * @copyright (c) 2005 phpBB Group |
| 7 | 7408 | kellanved | * @license http://opensource.org/licenses/gpl-license.php GNU Public License |
| 8 | 5114 | acydburn | * |
| 9 | 5114 | acydburn | */ |
| 10 | 4018 | psotfx | |
| 11 | 5114 | acydburn | /**
|
| 12 | 8147 | acydburn | * @ignore |
| 13 | 8147 | acydburn | */ |
| 14 | 8147 | acydburn | if (!defined('IN_PHPBB')) |
| 15 | 8147 | acydburn | {
|
| 16 | 8147 | acydburn | exit;
|
| 17 | 8147 | acydburn | } |
| 18 | 8147 | acydburn | |
| 19 | 8147 | acydburn | /**
|
| 20 | 5114 | acydburn | * ucp_register |
| 21 | 5114 | acydburn | * Board registration |
| 22 | 6058 | acydburn | * @package ucp |
| 23 | 5114 | acydburn | */ |
| 24 | 5254 | acydburn | class ucp_register |
| 25 | 4018 | psotfx | {
|
| 26 | 6015 | acydburn | var $u_action; |
| 27 | 6015 | acydburn | |
| 28 | 5254 | acydburn | function main($id, $mode) |
| 29 | 4018 | psotfx | {
|
| 30 | 6015 | acydburn | global $config, $db, $user, $auth, $template, $phpbb_root_path, $phpEx; |
| 31 | 4018 | psotfx | |
| 32 | 4018 | psotfx | //
|
| 33 | 4018 | psotfx | if ($config['require_activation'] == USER_ACTIVATION_DISABLE) |
| 34 | 4018 | psotfx | {
|
| 35 | 6048 | acydburn | trigger_error('UCP_REGISTER_DISABLE'); |
| 36 | 4018 | psotfx | } |
| 37 | 5916 | acydburn | |
| 38 | 4798 | psotfx | include($phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx); |
| 39 | 4798 | psotfx | |
| 40 | 6048 | acydburn | $confirm_id = request_var('confirm_id', ''); |
| 41 | 6048 | acydburn | $coppa = (isset($_REQUEST['coppa'])) ? ((!empty($_REQUEST['coppa'])) ? 1 : 0) : false; |
| 42 | 6048 | acydburn | $agreed = (!empty($_POST['agreed'])) ? 1 : 0; |
| 43 | 6048 | acydburn | $submit = (isset($_POST['submit'])) ? true : false; |
| 44 | 6048 | acydburn | $change_lang = request_var('change_lang', ''); |
| 45 | 7737 | acydburn | $user_lang = request_var('lang', $user->lang_name); |
| 46 | 8156 | kellanved | |
| 47 | 8156 | kellanved | if ($agreed) |
| 48 | 8156 | kellanved | {
|
| 49 | 8156 | kellanved | add_form_key('ucp_register');
|
| 50 | 8156 | kellanved | } |
| 51 | 8156 | kellanved | else
|
| 52 | 8156 | kellanved | {
|
| 53 | 8156 | kellanved | add_form_key('ucp_register_terms');
|
| 54 | 8156 | kellanved | } |
| 55 | 8120 | kellanved | |
| 56 | 8120 | kellanved | |
| 57 | 7737 | acydburn | if ($change_lang || $user_lang != $config['default_lang']) |
| 58 | 5074 | acydburn | {
|
| 59 | 7737 | acydburn | $use_lang = ($change_lang) ? basename($change_lang) : basename($user_lang); |
| 60 | 6366 | acydburn | |
| 61 | 7737 | acydburn | if (file_exists($phpbb_root_path . 'language/' . $use_lang . '/')) |
| 62 | 6366 | acydburn | {
|
| 63 | 7737 | acydburn | if ($change_lang) |
| 64 | 7737 | acydburn | {
|
| 65 | 7737 | acydburn | $submit = false; |
| 66 | 6366 | acydburn | |
| 67 | 7737 | acydburn | // Setting back agreed to let the user view the agreement in his/her language
|
| 68 | 7737 | acydburn | $agreed = (empty($_GET['change_lang'])) ? 0 : $agreed; |
| 69 | 7737 | acydburn | } |
| 70 | 7737 | acydburn | |
| 71 | 7737 | acydburn | $user->lang_name = $lang = $use_lang; |
| 72 | 6366 | acydburn | $user->lang_path = $phpbb_root_path . 'language/' . $lang . '/'; |
| 73 | 6366 | acydburn | $user->lang = array(); |
| 74 | 6366 | acydburn | $user->add_lang(array('common', 'ucp')); |
| 75 | 6366 | acydburn | } |
| 76 | 6366 | acydburn | else
|
| 77 | 6366 | acydburn | {
|
| 78 | 6366 | acydburn | $change_lang = ''; |
| 79 | 7737 | acydburn | $user_lang = $user->lang_name; |
| 80 | 6366 | acydburn | } |
| 81 | 5074 | acydburn | } |
| 82 | 5074 | acydburn | |
| 83 | 4798 | psotfx | $cp = new custom_profile(); |
| 84 | 4018 | psotfx | |
| 85 | 6552 | acydburn | $error = $cp_data = $cp_error = array(); |
| 86 | 4798 | psotfx | |
| 87 | 8408 | Kellanved | |
| 88 | 7116 | acydburn | if (!$agreed || ($coppa === false && $config['coppa_enable']) || ($coppa && !$config['coppa_enable'])) |
| 89 | 4018 | psotfx | {
|
| 90 | 6511 | acydburn | $add_lang = ($change_lang) ? '&change_lang=' . urlencode($change_lang) : ''; |
| 91 | 7162 | acydburn | $add_coppa = ($coppa !== false) ? '&coppa=' . $coppa : ''; |
| 92 | 6511 | acydburn | |
| 93 | 7118 | acydburn | $s_hidden_fields = ($confirm_id) ? array('confirm_id' => $confirm_id) : array(); |
| 94 | 7118 | acydburn | |
| 95 | 7118 | acydburn | // If we change the language, we want to pass on some more possible parameter.
|
| 96 | 7118 | acydburn | if ($change_lang) |
| 97 | 7118 | acydburn | {
|
| 98 | 8292 | kellanved | // We do not include the password
|
| 99 | 7118 | acydburn | $s_hidden_fields = array_merge($s_hidden_fields, array( |
| 100 | 7920 | acydburn | 'username' => utf8_normalize_nfc(request_var('username', '', true)), |
| 101 | 7118 | acydburn | 'email' => strtolower(request_var('email', '')), |
| 102 | 7118 | acydburn | 'email_confirm' => strtolower(request_var('email_confirm', '')), |
| 103 | 7118 | acydburn | 'confirm_code' => request_var('confirm_code', ''), |
| 104 | 8291 | kellanved | 'confirm_id' => request_var('confirm_id', ''), |
| 105 | 7118 | acydburn | 'lang' => $user->lang_name, |
| 106 | 7118 | acydburn | 'tz' => request_var('tz', (float) $config['board_timezone']), |
| 107 | 7118 | acydburn | )); |
| 108 | 7118 | acydburn | } |
| 109 | 7118 | acydburn | |
| 110 | 4018 | psotfx | if ($coppa === false && $config['coppa_enable']) |
| 111 | 4018 | psotfx | {
|
| 112 | 4018 | psotfx | $now = getdate(); |
| 113 | 4954 | psotfx | $coppa_birthday = $user->format_date(mktime($now['hours'] + $user->data['user_dst'], $now['minutes'], $now['seconds'], $now['mon'], $now['mday'] - 1, $now['year'] - 13), $user->lang['DATE_FORMAT']); |
| 114 | 4018 | psotfx | unset($now); |
| 115 | 4018 | psotfx | |
| 116 | 4018 | psotfx | $template->assign_vars(array( |
| 117 | 4018 | psotfx | 'L_COPPA_NO' => sprintf($user->lang['UCP_COPPA_BEFORE'], $coppa_birthday), |
| 118 | 4018 | psotfx | 'L_COPPA_YES' => sprintf($user->lang['UCP_COPPA_ON_AFTER'], $coppa_birthday), |
| 119 | 4018 | psotfx | |
| 120 | 6511 | acydburn | 'U_COPPA_NO' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=register&coppa=0' . $add_lang), |
| 121 | 6511 | acydburn | 'U_COPPA_YES' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=register&coppa=1' . $add_lang), |
| 122 | 4018 | psotfx | |
| 123 | 4954 | psotfx | 'S_SHOW_COPPA' => true, |
| 124 | 7118 | acydburn | 'S_HIDDEN_FIELDS' => build_hidden_fields($s_hidden_fields), |
| 125 | 8156 | kellanved | 'S_UCP_ACTION' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=register' . $add_lang), |
| 126 | 8156 | kellanved | )); |
| 127 | 4018 | psotfx | } |
| 128 | 4018 | psotfx | else
|
| 129 | 4018 | psotfx | {
|
| 130 | 4018 | psotfx | $template->assign_vars(array( |
| 131 | 5662 | acydburn | 'L_TERMS_OF_USE' => sprintf($user->lang['TERMS_OF_USE_CONTENT'], $config['sitename'], generate_board_url()), |
| 132 | 4018 | psotfx | |
| 133 | 4954 | psotfx | 'S_SHOW_COPPA' => false, |
| 134 | 5650 | acydburn | 'S_REGISTRATION' => true, |
| 135 | 7118 | acydburn | 'S_HIDDEN_FIELDS' => build_hidden_fields($s_hidden_fields), |
| 136 | 8156 | kellanved | 'S_UCP_ACTION' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=register' . $add_lang . $add_coppa), |
| 137 | 8156 | kellanved | ) |
| 138 | 4018 | psotfx | ); |
| 139 | 4018 | psotfx | } |
| 140 | 4018 | psotfx | |
| 141 | 5254 | acydburn | $this->tpl_name = 'ucp_agreement'; |
| 142 | 5254 | acydburn | return;
|
| 143 | 4018 | psotfx | } |
| 144 | 4018 | psotfx | |
| 145 | 8120 | kellanved | |
| 146 | 6650 | acydburn | // Try to manually determine the timezone and adjust the dst if the server date/time complies with the default setting +/- 1
|
| 147 | 6511 | acydburn | $timezone = date('Z') / 3600; |
| 148 | 6511 | acydburn | $is_dst = date('I'); |
| 149 | 6511 | acydburn | |
| 150 | 6650 | acydburn | if ($config['board_timezone'] == $timezone || $config['board_timezone'] == ($timezone - 1)) |
| 151 | 6511 | acydburn | {
|
| 152 | 6650 | acydburn | $timezone = ($is_dst) ? $timezone - 1 : $timezone; |
| 153 | 6650 | acydburn | |
| 154 | 6650 | acydburn | if (!isset($user->lang['tz_zones'][(string) $timezone])) |
| 155 | 6650 | acydburn | {
|
| 156 | 6650 | acydburn | $timezone = $config['board_timezone']; |
| 157 | 6650 | acydburn | } |
| 158 | 6650 | acydburn | } |
| 159 | 6650 | acydburn | else
|
| 160 | 6650 | acydburn | {
|
| 161 | 6650 | acydburn | $is_dst = $config['board_dst']; |
| 162 | 6511 | acydburn | $timezone = $config['board_timezone']; |
| 163 | 6511 | acydburn | } |
| 164 | 6511 | acydburn | |
| 165 | 6552 | acydburn | $data = array( |
| 166 | 7890 | naderman | 'username' => utf8_normalize_nfc(request_var('username', '', true)), |
| 167 | 6552 | acydburn | 'new_password' => request_var('new_password', '', true), |
| 168 | 6943 | acydburn | 'password_confirm' => request_var('password_confirm', '', true), |
| 169 | 6628 | acydburn | 'email' => strtolower(request_var('email', '')), |
| 170 | 6628 | acydburn | 'email_confirm' => strtolower(request_var('email_confirm', '')), |
| 171 | 6552 | acydburn | 'confirm_code' => request_var('confirm_code', ''), |
| 172 | 7789 | acydburn | 'lang' => basename(request_var('lang', $user->lang_name)), |
| 173 | 6552 | acydburn | 'tz' => request_var('tz', (float) $timezone), |
| 174 | 5086 | acydburn | ); |
| 175 | 5086 | acydburn | |
| 176 | 4018 | psotfx | // Check and initialize some variables if needed
|
| 177 | 4487 | psotfx | if ($submit) |
| 178 | 4018 | psotfx | {
|
| 179 | 6552 | acydburn | $error = validate_data($data, array( |
| 180 | 4487 | psotfx | 'username' => array( |
| 181 | 4487 | psotfx | array('string', false, $config['min_name_chars'], $config['max_name_chars']), |
| 182 | 7408 | kellanved | array('username', '')), |
| 183 | 6317 | acydburn | 'new_password' => array( |
| 184 | 6317 | acydburn | array('string', false, $config['min_pass_chars'], $config['max_pass_chars']), |
| 185 | 6317 | acydburn | array('password')), |
| 186 | 4954 | psotfx | 'password_confirm' => array('string', false, $config['min_pass_chars'], $config['max_pass_chars']), |
| 187 | 4487 | psotfx | 'email' => array( |
| 188 | 4954 | psotfx | array('string', false, 6, 60), |
| 189 | 4489 | psotfx | array('email')), |
| 190 | 4954 | psotfx | 'email_confirm' => array('string', false, 6, 60), |
| 191 | 5537 | davidmj | 'confirm_code' => array('string', !$config['enable_confirm'], 5, 8), |
| 192 | 5779 | naderman | 'tz' => array('num', false, -14, 14), |
| 193 | 6198 | acydburn | 'lang' => array('match', false, '#^[a-z_\-]{2,}$#i'), |
| 194 | 6552 | acydburn | )); |
| 195 | 8408 | Kellanved | if (!check_form_key('ucp_register')) |
| 196 | 8408 | Kellanved | {
|
| 197 | 8408 | Kellanved | $error[] = $user->lang['FORM_INVALID']; |
| 198 | 8408 | Kellanved | } |
| 199 | 4798 | psotfx | // Replace "error" strings with their real, localised form
|
| 200 | 4798 | psotfx | $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error); |
| 201 | 4798 | psotfx | |
| 202 | 6414 | acydburn | // DNSBL check
|
| 203 | 6414 | acydburn | if ($config['check_dnsbl']) |
| 204 | 6414 | acydburn | {
|
| 205 | 6698 | acydburn | if (($dnsbl = $user->check_dnsbl('register')) !== false) |
| 206 | 6414 | acydburn | {
|
| 207 | 6414 | acydburn | $error[] = sprintf($user->lang['IP_BLACKLISTED'], $user->ip, $dnsbl[1]); |
| 208 | 6414 | acydburn | } |
| 209 | 6414 | acydburn | } |
| 210 | 6414 | acydburn | |
| 211 | 4739 | acydburn | // validate custom profile fields
|
| 212 | 4984 | acydburn | $cp->submit_cp_field('register', $user->get_iso_lang_id(), $cp_data, $error); |
| 213 | 4739 | acydburn | |
| 214 | 4018 | psotfx | // Visual Confirmation handling
|
| 215 | 4798 | psotfx | $wrong_confirm = false; |
| 216 | 4018 | psotfx | if ($config['enable_confirm']) |
| 217 | 4018 | psotfx | {
|
| 218 | 4487 | psotfx | if (!$confirm_id) |
| 219 | 4018 | psotfx | {
|
| 220 | 4487 | psotfx | $error[] = $user->lang['CONFIRM_CODE_WRONG']; |
| 221 | 4798 | psotfx | $wrong_confirm = true; |
| 222 | 4018 | psotfx | } |
| 223 | 4018 | psotfx | else
|
| 224 | 4018 | psotfx | {
|
| 225 | 4954 | psotfx | $sql = 'SELECT code |
| 226 | 4954 | psotfx | FROM ' . CONFIRM_TABLE . " |
| 227 | 4954 | psotfx | WHERE confirm_id = '" . $db->sql_escape($confirm_id) . "' |
| 228 | 5622 | acydburn | AND session_id = '" . $db->sql_escape($user->session_id) . "' |
| 229 | 5622 | acydburn | AND confirm_type = " . CONFIRM_REG; |
| 230 | 4018 | psotfx | $result = $db->sql_query($sql); |
| 231 | 6048 | acydburn | $row = $db->sql_fetchrow($result); |
| 232 | 6048 | acydburn | $db->sql_freeresult($result); |
| 233 | 4954 | psotfx | |
| 234 | 6048 | acydburn | if ($row) |
| 235 | 4018 | psotfx | {
|
| 236 | 6517 | acydburn | if (strcasecmp($row['code'], $data['confirm_code']) === 0) |
| 237 | 4798 | psotfx | {
|
| 238 | 4954 | psotfx | $sql = 'DELETE FROM ' . CONFIRM_TABLE . " |
| 239 | 4954 | psotfx | WHERE confirm_id = '" . $db->sql_escape($confirm_id) . "' |
| 240 | 5622 | acydburn | AND session_id = '" . $db->sql_escape($user->session_id) . "' |
| 241 | 5622 | acydburn | AND confirm_type = " . CONFIRM_REG; |
| 242 | 4018 | psotfx | $db->sql_query($sql); |
| 243 | 4018 | psotfx | } |
| 244 | 5934 | davidmj | else
|
| 245 | 5934 | davidmj | {
|
| 246 | 5934 | davidmj | $error[] = $user->lang['CONFIRM_CODE_WRONG']; |
| 247 | 5934 | davidmj | $wrong_confirm = true; |
| 248 | 5934 | davidmj | } |
| 249 | 4018 | psotfx | } |
| 250 | 4018 | psotfx | else
|
| 251 | 4954 | psotfx | {
|
| 252 | 4487 | psotfx | $error[] = $user->lang['CONFIRM_CODE_WRONG']; |
| 253 | 4798 | psotfx | $wrong_confirm = true; |
| 254 | 4018 | psotfx | } |
| 255 | 4018 | psotfx | } |
| 256 | 4018 | psotfx | } |
| 257 | 4018 | psotfx | |
| 258 | 4798 | psotfx | if (!sizeof($error)) |
| 259 | 4018 | psotfx | {
|
| 260 | 6517 | acydburn | if ($data['new_password'] != $data['password_confirm']) |
| 261 | 5001 | acydburn | {
|
| 262 | 5967 | acydburn | $error[] = $user->lang['NEW_PASSWORD_ERROR']; |
| 263 | 5001 | acydburn | } |
| 264 | 5001 | acydburn | |
| 265 | 6517 | acydburn | if ($data['email'] != $data['email_confirm']) |
| 266 | 5001 | acydburn | {
|
| 267 | 5967 | acydburn | $error[] = $user->lang['NEW_EMAIL_ERROR']; |
| 268 | 5001 | acydburn | } |
| 269 | 5001 | acydburn | } |
| 270 | 6048 | acydburn | |
| 271 | 5001 | acydburn | if (!sizeof($error)) |
| 272 | 5001 | acydburn | {
|
| 273 | 4018 | psotfx | $server_url = generate_board_url();
|
| 274 | 4018 | psotfx | |
| 275 | 4913 | psotfx | // Which group by default?
|
| 276 | 6436 | acydburn | $group_name = ($coppa) ? 'REGISTERED_COPPA' : 'REGISTERED'; |
| 277 | 4913 | psotfx | |
| 278 | 4913 | psotfx | $sql = 'SELECT group_id |
| 279 | 4954 | psotfx | FROM ' . GROUPS_TABLE . " |
| 280 | 5744 | acydburn | WHERE group_name = '" . $db->sql_escape($group_name) . "' |
| 281 | 4913 | psotfx | AND group_type = " . GROUP_SPECIAL; |
| 282 | 4913 | psotfx | $result = $db->sql_query($sql); |
| 283 | 6048 | acydburn | $row = $db->sql_fetchrow($result); |
| 284 | 6048 | acydburn | $db->sql_freeresult($result); |
| 285 | 4913 | psotfx | |
| 286 | 6048 | acydburn | if (!$row) |
| 287 | 4913 | psotfx | {
|
| 288 | 6048 | acydburn | trigger_error('NO_GROUP'); |
| 289 | 4913 | psotfx | } |
| 290 | 4913 | psotfx | |
| 291 | 4913 | psotfx | $group_id = $row['group_id']; |
| 292 | 4913 | psotfx | |
| 293 | 4954 | psotfx | if (($coppa || |
| 294 | 4954 | psotfx | $config['require_activation'] == USER_ACTIVATION_SELF || |
| 295 | 4062 | psotfx | $config['require_activation'] == USER_ACTIVATION_ADMIN) && $config['email_enable']) |
| 296 | 4018 | psotfx | {
|
| 297 | 4213 | psotfx | $user_actkey = gen_rand_string(10); |
| 298 | 4018 | psotfx | $key_len = 54 - (strlen($server_url)); |
| 299 | 6048 | acydburn | $key_len = ($key_len < 6) ? 6 : $key_len; |
| 300 | 4018 | psotfx | $user_actkey = substr($user_actkey, 0, $key_len); |
| 301 | 6517 | acydburn | |
| 302 | 4603 | psotfx | $user_type = USER_INACTIVE; |
| 303 | 6394 | grahamje | $user_inactive_reason = INACTIVE_REGISTER; |
| 304 | 6394 | grahamje | $user_inactive_time = time(); |
| 305 | 4018 | psotfx | } |
| 306 | 4018 | psotfx | else
|
| 307 | 4018 | psotfx | {
|
| 308 | 4603 | psotfx | $user_type = USER_NORMAL; |
| 309 | 4018 | psotfx | $user_actkey = ''; |
| 310 | 6394 | grahamje | $user_inactive_reason = 0; |
| 311 | 6394 | grahamje | $user_inactive_time = 0; |
| 312 | 4018 | psotfx | } |
| 313 | 4954 | psotfx | |
| 314 | 6048 | acydburn | $user_row = array( |
| 315 | 6517 | acydburn | 'username' => $data['username'], |
| 316 | 8139 | acydburn | 'user_password' => phpbb_hash($data['new_password']), |
| 317 | 6517 | acydburn | 'user_email' => $data['email'], |
| 318 | 6394 | grahamje | 'group_id' => (int) $group_id, |
| 319 | 6517 | acydburn | 'user_timezone' => (float) $data['tz'], |
| 320 | 6511 | acydburn | 'user_dst' => $is_dst, |
| 321 | 6517 | acydburn | 'user_lang' => $data['lang'], |
| 322 | 6394 | grahamje | 'user_type' => $user_type, |
| 323 | 6394 | grahamje | 'user_actkey' => $user_actkey, |
| 324 | 6394 | grahamje | 'user_ip' => $user->ip, |
| 325 | 6394 | grahamje | 'user_regdate' => time(), |
| 326 | 6394 | grahamje | 'user_inactive_reason' => $user_inactive_reason, |
| 327 | 6394 | grahamje | 'user_inactive_time' => $user_inactive_time, |
| 328 | 4913 | psotfx | ); |
| 329 | 4018 | psotfx | |
| 330 | 6048 | acydburn | // Register user...
|
| 331 | 6048 | acydburn | $user_id = user_add($user_row, $cp_data); |
| 332 | 4018 | psotfx | |
| 333 | 6051 | acydburn | // This should not happen, because the required variables are listed above...
|
| 334 | 6051 | acydburn | if ($user_id === false) |
| 335 | 6051 | acydburn | {
|
| 336 | 7919 | kellanved | trigger_error('NO_USER', E_USER_ERROR); |
| 337 | 6051 | acydburn | } |
| 338 | 6051 | acydburn | |
| 339 | 4062 | psotfx | if ($coppa && $config['email_enable']) |
| 340 | 4018 | psotfx | {
|
| 341 | 4018 | psotfx | $message = $user->lang['ACCOUNT_COPPA']; |
| 342 | 4018 | psotfx | $email_template = 'coppa_welcome_inactive'; |
| 343 | 4018 | psotfx | } |
| 344 | 4062 | psotfx | else if ($config['require_activation'] == USER_ACTIVATION_SELF && $config['email_enable']) |
| 345 | 4018 | psotfx | {
|
| 346 | 4018 | psotfx | $message = $user->lang['ACCOUNT_INACTIVE']; |
| 347 | 4018 | psotfx | $email_template = 'user_welcome_inactive'; |
| 348 | 4018 | psotfx | } |
| 349 | 4062 | psotfx | else if ($config['require_activation'] == USER_ACTIVATION_ADMIN && $config['email_enable']) |
| 350 | 4018 | psotfx | {
|
| 351 | 4018 | psotfx | $message = $user->lang['ACCOUNT_INACTIVE_ADMIN']; |
| 352 | 4018 | psotfx | $email_template = 'admin_welcome_inactive'; |
| 353 | 4018 | psotfx | } |
| 354 | 4018 | psotfx | else
|
| 355 | 4018 | psotfx | {
|
| 356 | 4018 | psotfx | $message = $user->lang['ACCOUNT_ADDED']; |
| 357 | 4018 | psotfx | $email_template = 'user_welcome'; |
| 358 | 4018 | psotfx | } |
| 359 | 4018 | psotfx | |
| 360 | 4018 | psotfx | if ($config['email_enable']) |
| 361 | 4018 | psotfx | {
|
| 362 | 6048 | acydburn | include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); |
| 363 | 4018 | psotfx | |
| 364 | 5074 | acydburn | $messenger = new messenger(false); |
| 365 | 4583 | psotfx | |
| 366 | 6517 | acydburn | $messenger->template($email_template, $data['lang']); |
| 367 | 4583 | psotfx | |
| 368 | 6517 | acydburn | $messenger->to($data['email'], $data['username']); |
| 369 | 4583 | psotfx | |
| 370 | 4583 | psotfx | $messenger->headers('X-AntiAbuse: Board servername - ' . $config['server_name']); |
| 371 | 4583 | psotfx | $messenger->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']); |
| 372 | 4583 | psotfx | $messenger->headers('X-AntiAbuse: Username - ' . $user->data['username']); |
| 373 | 4583 | psotfx | $messenger->headers('X-AntiAbuse: User IP - ' . $user->ip); |
| 374 | 4583 | psotfx | |
| 375 | 4583 | psotfx | $messenger->assign_vars(array( |
| 376 | 6548 | acydburn | 'WELCOME_MSG' => htmlspecialchars_decode(sprintf($user->lang['WELCOME_SUBJECT'], $config['sitename'])), |
| 377 | 6548 | acydburn | 'USERNAME' => htmlspecialchars_decode($data['username']), |
| 378 | 6548 | acydburn | 'PASSWORD' => htmlspecialchars_decode($data['new_password']), |
| 379 | 4732 | bartvb | 'U_ACTIVATE' => "$server_url/ucp.$phpEx?mode=activate&u=$user_id&k=$user_actkey") |
| 380 | 4018 | psotfx | ); |
| 381 | 4018 | psotfx | |
| 382 | 4018 | psotfx | if ($coppa) |
| 383 | 4018 | psotfx | {
|
| 384 | 4583 | psotfx | $messenger->assign_vars(array( |
| 385 | 4487 | psotfx | 'FAX_INFO' => $config['coppa_fax'], |
| 386 | 4487 | psotfx | 'MAIL_INFO' => $config['coppa_mail'], |
| 387 | 6546 | acydburn | 'EMAIL_ADDRESS' => $data['email']) |
| 388 | 4018 | psotfx | ); |
| 389 | 4018 | psotfx | } |
| 390 | 4062 | psotfx | |
| 391 | 4583 | psotfx | $messenger->send(NOTIFY_EMAIL); |
| 392 | 4018 | psotfx | |
| 393 | 4018 | psotfx | if ($config['require_activation'] == USER_ACTIVATION_ADMIN) |
| 394 | 4018 | psotfx | {
|
| 395 | 6048 | acydburn | // Grab an array of user_id's with a_user permissions ... these users can activate a user
|
| 396 | 4883 | acydburn | $admin_ary = $auth->acl_get_list(false, 'a_user', false); |
| 397 | 6327 | acydburn | $admin_ary = (!empty($admin_ary[0]['a_user'])) ? $admin_ary[0]['a_user'] : array(); |
| 398 | 4018 | psotfx | |
| 399 | 6327 | acydburn | // Also include founders
|
| 400 | 6327 | acydburn | $where_sql = ' WHERE user_type = ' . USER_FOUNDER; |
| 401 | 6327 | acydburn | |
| 402 | 6327 | acydburn | if (sizeof($admin_ary)) |
| 403 | 6327 | acydburn | {
|
| 404 | 6511 | acydburn | $where_sql .= ' OR ' . $db->sql_in_set('user_id', $admin_ary); |
| 405 | 6327 | acydburn | } |
| 406 | 6327 | acydburn | |
| 407 | 5001 | acydburn | $sql = 'SELECT user_id, username, user_email, user_lang, user_jabber, user_notify_type |
| 408 | 6327 | acydburn | FROM ' . USERS_TABLE . ' ' . |
| 409 | 6327 | acydburn | $where_sql;
|
| 410 | 4657 | psotfx | $result = $db->sql_query($sql); |
| 411 | 4018 | psotfx | |
| 412 | 4657 | psotfx | while ($row = $db->sql_fetchrow($result)) |
| 413 | 4657 | psotfx | {
|
| 414 | 4967 | acydburn | $messenger->template('admin_activate', $row['user_lang']); |
| 415 | 4657 | psotfx | $messenger->to($row['user_email'], $row['username']); |
| 416 | 4657 | psotfx | $messenger->im($row['user_jabber'], $row['username']); |
| 417 | 4657 | psotfx | |
| 418 | 4657 | psotfx | $messenger->assign_vars(array( |
| 419 | 6628 | acydburn | 'USERNAME' => htmlspecialchars_decode($data['username']), |
| 420 | 6956 | acydburn | 'U_USER_DETAILS' => "$server_url/memberlist.$phpEx?mode=viewprofile&u=$user_id", |
| 421 | 6628 | acydburn | 'U_ACTIVATE' => "$server_url/ucp.$phpEx?mode=activate&u=$user_id&k=$user_actkey") |
| 422 | 4657 | psotfx | ); |
| 423 | 4657 | psotfx | |
| 424 | 4657 | psotfx | $messenger->send($row['user_notify_type']); |
| 425 | 4657 | psotfx | } |
| 426 | 4657 | psotfx | $db->sql_freeresult($result); |
| 427 | 4018 | psotfx | } |
| 428 | 4018 | psotfx | } |
| 429 | 4018 | psotfx | |
| 430 | 6930 | acydburn | $message = $message . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.$phpEx") . '">', '</a>'); |
| 431 | 4018 | psotfx | trigger_error($message); |
| 432 | 4018 | psotfx | } |
| 433 | 4018 | psotfx | } |
| 434 | 4018 | psotfx | |
| 435 | 7116 | acydburn | $s_hidden_fields = array( |
| 436 | 7408 | kellanved | 'agreed' => 'true', |
| 437 | 7116 | acydburn | 'change_lang' => 0, |
| 438 | 5202 | acydburn | ); |
| 439 | 4018 | psotfx | |
| 440 | 7116 | acydburn | if ($config['coppa_enable']) |
| 441 | 7116 | acydburn | {
|
| 442 | 7116 | acydburn | $s_hidden_fields['coppa'] = $coppa; |
| 443 | 7116 | acydburn | } |
| 444 | 7116 | acydburn | $s_hidden_fields = build_hidden_fields($s_hidden_fields); |
| 445 | 7116 | acydburn | |
| 446 | 4489 | psotfx | $confirm_image = ''; |
| 447 | 6048 | acydburn | |
| 448 | 4018 | psotfx | // Visual Confirmation - Show images
|
| 449 | 8291 | kellanved | |
| 450 | 4489 | psotfx | if ($config['enable_confirm']) |
| 451 | 4018 | psotfx | {
|
| 452 | 8291 | kellanved | if ($change_lang) |
| 453 | 5074 | acydburn | {
|
| 454 | 8291 | kellanved | $str = '&change_lang=' . $change_lang; |
| 455 | 8291 | kellanved | $sql = 'SELECT code |
| 456 | 8291 | kellanved | FROM ' . CONFIRM_TABLE . " |
| 457 | 8291 | kellanved | WHERE confirm_id = '" . $db->sql_escape($confirm_id) . "' |
| 458 | 8291 | kellanved | AND session_id = '" . $db->sql_escape($user->session_id) . "' |
| 459 | 8291 | kellanved | AND confirm_type = " . CONFIRM_REG; |
| 460 | 8291 | kellanved | $result = $db->sql_query($sql); |
| 461 | 8291 | kellanved | if (!$row = $db->sql_fetchrow($result)) |
| 462 | 8291 | kellanved | {
|
| 463 | 8291 | kellanved | $confirm_id = ''; |
| 464 | 8291 | kellanved | } |
| 465 | 8291 | kellanved | $db->sql_freeresult($result); |
| 466 | 8291 | kellanved | } |
| 467 | 8291 | kellanved | else
|
| 468 | 8291 | kellanved | {
|
| 469 | 8291 | kellanved | $str = ''; |
| 470 | 8291 | kellanved | } |
| 471 | 8291 | kellanved | if (!$change_lang || !$confirm_id) |
| 472 | 8291 | kellanved | {
|
| 473 | 8089 | kellanved | $user->confirm_gc(CONFIRM_REG); |
| 474 | 8291 | kellanved | |
| 475 | 5074 | acydburn | $sql = 'SELECT COUNT(session_id) AS attempts |
| 476 | 5074 | acydburn | FROM ' . CONFIRM_TABLE . " |
| 477 | 5622 | acydburn | WHERE session_id = '" . $db->sql_escape($user->session_id) . "' |
| 478 | 5622 | acydburn | AND confirm_type = " . CONFIRM_REG; |
| 479 | 5074 | acydburn | $result = $db->sql_query($sql); |
| 480 | 6048 | acydburn | $attempts = (int) $db->sql_fetchfield('attempts'); |
| 481 | 6048 | acydburn | $db->sql_freeresult($result); |
| 482 | 4018 | psotfx | |
| 483 | 6048 | acydburn | if ($config['max_reg_attempts'] && $attempts > $config['max_reg_attempts']) |
| 484 | 4018 | psotfx | {
|
| 485 | 7919 | kellanved | trigger_error('TOO_MANY_REGISTERS'); |
| 486 | 4018 | psotfx | } |
| 487 | 6048 | acydburn | |
| 488 | 5496 | davidmj | $code = gen_rand_string(mt_rand(5, 8)); |
| 489 | 5813 | grahamje | $confirm_id = md5(unique_id($user->ip)); |
| 490 | 6705 | davidmj | $seed = hexdec(substr(unique_id(), 4, 10)); |
| 491 | 5496 | davidmj | |
| 492 | 6731 | davidmj | // compute $seed % 0x7fffffff
|
| 493 | 6731 | davidmj | $seed -= 0x7fffffff * floor($seed / 0x7fffffff); |
| 494 | 6729 | davidmj | |
| 495 | 5074 | acydburn | $sql = 'INSERT INTO ' . CONFIRM_TABLE . ' ' . $db->sql_build_array('INSERT', array( |
| 496 | 5074 | acydburn | 'confirm_id' => (string) $confirm_id, |
| 497 | 5074 | acydburn | 'session_id' => (string) $user->session_id, |
| 498 | 5622 | acydburn | 'confirm_type' => (int) CONFIRM_REG, |
| 499 | 6705 | davidmj | 'code' => (string) $code, |
| 500 | 6729 | davidmj | 'seed' => (int) $seed) |
| 501 | 5074 | acydburn | ); |
| 502 | 5074 | acydburn | $db->sql_query($sql); |
| 503 | 4018 | psotfx | } |
| 504 | 6243 | davidmj | $confirm_image = '<img src="' . append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=confirm&id=' . $confirm_id . '&type=' . CONFIRM_REG . $str) . '" alt="" title="" />'; |
| 505 | 5537 | davidmj | $s_hidden_fields .= '<input type="hidden" name="confirm_id" value="' . $confirm_id . '" />'; |
| 506 | 4018 | psotfx | } |
| 507 | 4018 | psotfx | |
| 508 | 4954 | psotfx | //
|
| 509 | 4018 | psotfx | $l_reg_cond = ''; |
| 510 | 4018 | psotfx | switch ($config['require_activation']) |
| 511 | 4018 | psotfx | {
|
| 512 | 4018 | psotfx | case USER_ACTIVATION_SELF: |
| 513 | 4018 | psotfx | $l_reg_cond = $user->lang['UCP_EMAIL_ACTIVATE']; |
| 514 | 6048 | acydburn | break;
|
| 515 | 4018 | psotfx | |
| 516 | 4018 | psotfx | case USER_ACTIVATION_ADMIN: |
| 517 | 4018 | psotfx | $l_reg_cond = $user->lang['UCP_ADMIN_ACTIVATE']; |
| 518 | 6048 | acydburn | break;
|
| 519 | 4018 | psotfx | } |
| 520 | 4018 | psotfx | |
| 521 | 4018 | psotfx | $template->assign_vars(array( |
| 522 | 4954 | psotfx | 'ERROR' => (sizeof($error)) ? implode('<br />', $error) : '', |
| 523 | 6553 | acydburn | 'USERNAME' => $data['username'], |
| 524 | 6553 | acydburn | 'PASSWORD' => $data['new_password'], |
| 525 | 6553 | acydburn | 'PASSWORD_CONFIRM' => $data['password_confirm'], |
| 526 | 6553 | acydburn | 'EMAIL' => $data['email'], |
| 527 | 6553 | acydburn | 'EMAIL_CONFIRM' => $data['email_confirm'], |
| 528 | 4954 | psotfx | 'CONFIRM_IMG' => $confirm_image, |
| 529 | 4018 | psotfx | |
| 530 | 6548 | acydburn | 'L_CONFIRM_EXPLAIN' => sprintf($user->lang['CONFIRM_EXPLAIN'], '<a href="mailto:' . htmlspecialchars($config['board_contact']) . '">', '</a>'), |
| 531 | 6228 | acydburn | 'L_REG_COND' => $l_reg_cond, |
| 532 | 7375 | davidmj | 'L_USERNAME_EXPLAIN' => sprintf($user->lang[$config['allow_name_chars'] . '_EXPLAIN'], $config['min_name_chars'], $config['max_name_chars']), |
| 533 | 6814 | naderman | 'L_PASSWORD_EXPLAIN' => sprintf($user->lang[$config['pass_complex'] . '_EXPLAIN'], $config['min_pass_chars'], $config['max_pass_chars']), |
| 534 | 4018 | psotfx | |
| 535 | 6517 | acydburn | 'S_LANG_OPTIONS' => language_select($data['lang']), |
| 536 | 6517 | acydburn | 'S_TZ_OPTIONS' => tz_select($data['tz']), |
| 537 | 4018 | psotfx | 'S_CONFIRM_CODE' => ($config['enable_confirm']) ? true : false, |
| 538 | 4954 | psotfx | 'S_COPPA' => $coppa, |
| 539 | 4018 | psotfx | 'S_HIDDEN_FIELDS' => $s_hidden_fields, |
| 540 | 8156 | kellanved | 'S_UCP_ACTION' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=register'), |
| 541 | 8156 | kellanved | ) |
| 542 | 4018 | psotfx | ); |
| 543 | 4018 | psotfx | |
| 544 | 4018 | psotfx | //
|
| 545 | 4739 | acydburn | $user->profile_fields = array(); |
| 546 | 4739 | acydburn | |
| 547 | 4739 | acydburn | // Generate profile fields -> Template Block Variable profile_fields
|
| 548 | 4984 | acydburn | $cp->generate_profile_fields('register', $user->get_iso_lang_id()); |
| 549 | 4954 | psotfx | |
| 550 | 4739 | acydburn | //
|
| 551 | 5254 | acydburn | $this->tpl_name = 'ucp_register'; |
| 552 | 6054 | acydburn | $this->page_title = 'UCP_REGISTRATION'; |
| 553 | 4018 | psotfx | } |
| 554 | 4018 | psotfx | } |
| 555 | 4018 | psotfx | |
| 556 | 4018 | psotfx | ?> |

