Changeset 702 for trunk/forum/includes/ucp/ucp_register.php
- Timestamp:
- Mar 31, 2010, 6:32:40 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/forum/includes/ucp/ucp_register.php
r400 r702 3 3 * 4 4 * @package ucp 5 * @version $Id : ucp_register.php 8782 2008-08-23 17:20:55Z acydburn$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 38 38 include($phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx); 39 39 40 $confirm_id = request_var('confirm_id', '');41 40 $coppa = (isset($_REQUEST['coppa'])) ? ((!empty($_REQUEST['coppa'])) ? 1 : 0) : false; 42 41 $agreed = (!empty($_POST['agreed'])) ? 1 : 0; … … 54 53 } 55 54 56 57 55 if ($change_lang || $user_lang != $config['default_lang']) 58 56 { … … 69 67 } 70 68 71 $user->lang_name = $ lang = $use_lang;69 $user->lang_name = $user_lang = $use_lang; 72 70 $user->lang = array(); 71 $user->data['user_lang'] = $user->lang_name; 73 72 $user->add_lang(array('common', 'ucp')); 74 73 } … … 80 79 } 81 80 81 82 82 $cp = new custom_profile(); 83 83 84 84 $error = $cp_data = $cp_error = array(); 85 86 85 87 86 if (!$agreed || ($coppa === false && $config['coppa_enable']) || ($coppa && !$config['coppa_enable'])) … … 90 89 $add_coppa = ($coppa !== false) ? '&coppa=' . $coppa : ''; 91 90 92 $s_hidden_fields = ($confirm_id) ? array('confirm_id' => $confirm_id) : array(); 91 $s_hidden_fields = array( 92 'change_lang' => $change_lang, 93 ); 93 94 94 95 // If we change the language, we want to pass on some more possible parameter. … … 100 101 'email' => strtolower(request_var('email', '')), 101 102 'email_confirm' => strtolower(request_var('email_confirm', '')), 102 'confirm_code' => request_var('confirm_code', ''),103 'confirm_id' => request_var('confirm_id', ''),104 103 'lang' => $user->lang_name, 105 104 'tz' => request_var('tz', (float) $config['board_timezone']), 106 105 )); 107 } 106 107 } 108 109 // Checking amount of available languages 110 $sql = 'SELECT lang_id 111 FROM ' . LANG_TABLE; 112 $result = $db->sql_query($sql); 113 114 $lang_row = array(); 115 while ($row = $db->sql_fetchrow($result)) 116 { 117 $lang_row[] = $row; 118 } 119 $db->sql_freeresult($result); 108 120 109 121 if ($coppa === false && $config['coppa_enable']) … … 114 126 115 127 $template->assign_vars(array( 128 'S_LANG_OPTIONS' => (sizeof($lang_row) > 1) ? language_select($user_lang) : '', 116 129 'L_COPPA_NO' => sprintf($user->lang['UCP_COPPA_BEFORE'], $coppa_birthday), 117 130 'L_COPPA_YES' => sprintf($user->lang['UCP_COPPA_ON_AFTER'], $coppa_birthday), … … 128 141 { 129 142 $template->assign_vars(array( 143 'S_LANG_OPTIONS' => (sizeof($lang_row) > 1) ? language_select($user_lang) : '', 130 144 'L_TERMS_OF_USE' => sprintf($user->lang['TERMS_OF_USE_CONTENT'], $config['sitename'], generate_board_url()), 131 145 … … 137 151 ); 138 152 } 153 unset($lang_row); 139 154 140 155 $this->tpl_name = 'ucp_agreement'; 141 156 return; 142 157 } 143 158 159 160 // The CAPTCHA kicks in here. We can't help that the information gets lost on language change. 161 if ($config['enable_confirm']) 162 { 163 include($phpbb_root_path . 'includes/captcha/captcha_factory.' . $phpEx); 164 $captcha =& phpbb_captcha_factory::get_instance($config['captcha_plugin']); 165 $captcha->init(CONFIRM_REG); 166 } 144 167 145 168 // Try to manually determine the timezone and adjust the dst if the server date/time complies with the default setting +/- 1 … … 168 191 'email' => strtolower(request_var('email', '')), 169 192 'email_confirm' => strtolower(request_var('email_confirm', '')), 170 'confirm_code' => request_var('confirm_code', ''),171 193 'lang' => basename(request_var('lang', $user->lang_name)), 172 194 'tz' => request_var('tz', (float) $timezone), … … 188 210 array('email')), 189 211 'email_confirm' => array('string', false, 6, 60), 190 'confirm_code' => array('string', !$config['enable_confirm'], 5, 8),191 212 'tz' => array('num', false, -14, 14), 192 213 'lang' => array('match', false, '#^[a-z_\-]{2,}$#i'), 193 214 )); 215 194 216 if (!check_form_key('ucp_register')) 195 217 { 196 218 $error[] = $user->lang['FORM_INVALID']; 197 219 } 220 198 221 // Replace "error" strings with their real, localised form 199 222 $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error); 200 223 224 if ($config['enable_confirm']) 225 { 226 $vc_response = $captcha->validate($data); 227 if ($vc_response !== false) 228 { 229 $error[] = $vc_response; 230 } 231 232 if ($config['max_reg_attempts'] && $captcha->get_attempt_count() > $config['max_reg_attempts']) 233 { 234 $error[] = $user->lang['TOO_MANY_REGISTERS']; 235 } 236 } 237 201 238 // DNSBL check 202 239 if ($config['check_dnsbl']) … … 210 247 // validate custom profile fields 211 248 $cp->submit_cp_field('register', $user->get_iso_lang_id(), $cp_data, $error); 212 213 // Visual Confirmation handling214 $wrong_confirm = false;215 if ($config['enable_confirm'])216 {217 if (!$confirm_id)218 {219 $error[] = $user->lang['CONFIRM_CODE_WRONG'];220 $wrong_confirm = true;221 }222 else223 {224 $sql = 'SELECT code225 FROM ' . CONFIRM_TABLE . "226 WHERE confirm_id = '" . $db->sql_escape($confirm_id) . "'227 AND session_id = '" . $db->sql_escape($user->session_id) . "'228 AND confirm_type = " . CONFIRM_REG;229 $result = $db->sql_query($sql);230 $row = $db->sql_fetchrow($result);231 $db->sql_freeresult($result);232 233 if ($row)234 {235 if (strcasecmp($row['code'], $data['confirm_code']) === 0)236 {237 $sql = 'DELETE FROM ' . CONFIRM_TABLE . "238 WHERE confirm_id = '" . $db->sql_escape($confirm_id) . "'239 AND session_id = '" . $db->sql_escape($user->session_id) . "'240 AND confirm_type = " . CONFIRM_REG;241 $db->sql_query($sql);242 }243 else244 {245 $error[] = $user->lang['CONFIRM_CODE_WRONG'];246 $wrong_confirm = true;247 }248 }249 else250 {251 $error[] = $user->lang['CONFIRM_CODE_WRONG'];252 $wrong_confirm = true;253 }254 }255 }256 249 257 250 if (!sizeof($error)) … … 327 320 ); 328 321 322 if ($config['new_member_post_limit']) 323 { 324 $user_row['user_new'] = 1; 325 } 326 329 327 // Register user... 330 328 $user_id = user_add($user_row, $cp_data); … … 334 332 { 335 333 trigger_error('NO_USER', E_USER_ERROR); 334 } 335 336 // Okay, captcha, your job is done. 337 if ($config['enable_confirm'] && isset($captcha)) 338 { 339 $captcha->reset(); 336 340 } 337 341 … … 441 445 $s_hidden_fields['coppa'] = $coppa; 442 446 } 447 448 if ($config['enable_confirm']) 449 { 450 $s_hidden_fields = array_merge($s_hidden_fields, $captcha->get_hidden_fields()); 451 } 443 452 $s_hidden_fields = build_hidden_fields($s_hidden_fields); 444 445 453 $confirm_image = ''; 446 454 447 455 // Visual Confirmation - Show images 448 449 456 if ($config['enable_confirm']) 450 457 { 451 if ($change_lang) 452 { 453 $str = '&change_lang=' . $change_lang; 454 $sql = 'SELECT code 455 FROM ' . CONFIRM_TABLE . " 456 WHERE confirm_id = '" . $db->sql_escape($confirm_id) . "' 457 AND session_id = '" . $db->sql_escape($user->session_id) . "' 458 AND confirm_type = " . CONFIRM_REG; 459 $result = $db->sql_query($sql); 460 if (!$row = $db->sql_fetchrow($result)) 461 { 462 $confirm_id = ''; 463 } 464 $db->sql_freeresult($result); 465 } 466 else 467 { 468 $str = ''; 469 } 470 if (!$change_lang || !$confirm_id) 471 { 472 $user->confirm_gc(CONFIRM_REG); 473 474 $sql = 'SELECT COUNT(session_id) AS attempts 475 FROM ' . CONFIRM_TABLE . " 476 WHERE session_id = '" . $db->sql_escape($user->session_id) . "' 477 AND confirm_type = " . CONFIRM_REG; 478 $result = $db->sql_query($sql); 479 $attempts = (int) $db->sql_fetchfield('attempts'); 480 $db->sql_freeresult($result); 481 482 if ($config['max_reg_attempts'] && $attempts > $config['max_reg_attempts']) 483 { 484 trigger_error('TOO_MANY_REGISTERS'); 485 } 486 487 $code = gen_rand_string(mt_rand(5, 8)); 488 $confirm_id = md5(unique_id($user->ip)); 489 $seed = hexdec(substr(unique_id(), 4, 10)); 490 491 // compute $seed % 0x7fffffff 492 $seed -= 0x7fffffff * floor($seed / 0x7fffffff); 493 494 $sql = 'INSERT INTO ' . CONFIRM_TABLE . ' ' . $db->sql_build_array('INSERT', array( 495 'confirm_id' => (string) $confirm_id, 496 'session_id' => (string) $user->session_id, 497 'confirm_type' => (int) CONFIRM_REG, 498 'code' => (string) $code, 499 'seed' => (int) $seed) 500 ); 501 $db->sql_query($sql); 502 } 503 $confirm_image = '<img src="' . append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=confirm&id=' . $confirm_id . '&type=' . CONFIRM_REG . $str) . '" alt="" title="" />'; 504 $s_hidden_fields .= '<input type="hidden" name="confirm_id" value="' . $confirm_id . '" />'; 458 $template->assign_vars(array( 459 'CAPTCHA_TEMPLATE' => $captcha->get_template(), 460 )); 505 461 } 506 462 … … 525 481 'EMAIL' => $data['email'], 526 482 'EMAIL_CONFIRM' => $data['email_confirm'], 527 'CONFIRM_IMG' => $confirm_image, 528 529 'L_CONFIRM_EXPLAIN' => sprintf($user->lang['CONFIRM_EXPLAIN'], '<a href="mailto:' . htmlspecialchars($config['board_contact']) . '">', '</a>'), 483 530 484 'L_REG_COND' => $l_reg_cond, 531 485 'L_USERNAME_EXPLAIN' => sprintf($user->lang[$config['allow_name_chars'] . '_EXPLAIN'], $config['min_name_chars'], $config['max_name_chars']), … … 534 488 'S_LANG_OPTIONS' => language_select($data['lang']), 535 489 'S_TZ_OPTIONS' => tz_select($data['tz']), 536 'S_CONFIRM_CODE' => ($config['enable_confirm']) ? true : false, 490 'S_CONFIRM_REFRESH' => ($config['enable_confirm'] && $config['confirm_refresh']) ? true : false, 491 'S_REGISTRATION' => true, 537 492 'S_COPPA' => $coppa, 538 493 'S_HIDDEN_FIELDS' => $s_hidden_fields, 539 494 'S_UCP_ACTION' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=register'), 540 ) 541 ); 495 )); 542 496 543 497 //
Note:
See TracChangeset
for help on using the changeset viewer.