From 21ce5c483169c0959b49c6c90cfb596d9e93112e Mon Sep 17 00:00:00 2001 From: "Paul S. Owen" Date: Fri, 9 May 2003 00:14:57 +0000 Subject: [PATCH] Updates to various items ... note this won't "work" at present since I've not committed associated updates git-svn-id: file:///svn/phpbb/trunk@3995 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/ucp/ucp_register.php | 253 +++++++++++++++++++++++++++++++++++++ 1 file changed, 253 insertions(+) create mode 100644 phpBB/ucp/ucp_register.php diff --git a/phpBB/ucp/ucp_register.php b/phpBB/ucp/ucp_register.php new file mode 100644 index 0000000000..5d523c9561 --- /dev/null +++ b/phpBB/ucp/ucp_register.php @@ -0,0 +1,253 @@ +lang['UCP_REGISTER_DISABLE']); +} + + + + + + + +$coppa = (isset($_REQUEST['coppa'])) ? ((!empty($_REQUEST['coppa'])) ? 1 : 0) : false; +$agreed = (!empty($_POST['agreed'])) ? 1 : 0; +$lang = (isset($_POST['lang'])) ? htmlspecialchars($_POST['lang']) : ''; +$tz = (isset($_POST['tz'])) ? intval($_POST['tz']) : $config['board_timezone']; + +$error = array(); + + + + +if (!$agreed) +{ + if ($coppa === false && $config['coppa_enable']) + { + $now = getdate(); + $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']); + unset($now); + + $template->assign_vars(array( + 'L_COPPA_NO' => sprintf($user->lang['UCP_COPPA_BEFORE'], $coppa_birthday), + 'L_COPPA_YES' => sprintf($user->lang['UCP_COPPA_ON_AFTER'], $coppa_birthday), + + 'U_COPPA_NO' => "ucp.$phpEx$SID&mode=register&coppa=0", + 'U_COPPA_YES' => "ucp.$phpEx$SID&mode=register&coppa=1", + + 'S_SHOW_COPPA' => true, + 'S_REGISTER_ACTION' => "ucp.$phpEx$SID&mode=register") + ); + } + else + { + $l_reg_cond = ''; + switch ($config['require_activation']) + { + case USER_ACTIVATION_SELF: + $l_reg_cond = $user->lang['UCP_EMAIL_ACTIVATE']; + break; + + case USER_ACTIVATION_ADMIN: + $l_reg_cond = $user->lang['UCP_ADMIN_ACTIVATE']; + break; + } + + $template->assign_vars(array( + 'L_AGREEMENT' => $user->lang['UCP_AGREEMENT'], + 'L_REG_CONDITIONS' => $l_reg_cond, + + 'S_SHOW_COPPA' => false, + 'S_REGISTER_ACTION' => "ucp.$phpEx$SID&mode=register") + ); + } + + page_header($user->lang['REGISTER']); + + $template->set_filenames(array( + 'body' => 'ucp_agreement.html') + ); + make_jumpbox('viewforum.'.$phpEx); + + page_footer(); + +} +else +{ + $agreed = TRUE; +} + + + + + + +// Check and initialize some variables if needed +if (isset($_POST['submit'])) +{ + // Load the userdata manipulation methods + require($phpbb_root_path . 'includes/functions_user.'.$phpEx); + $userdata = new userdata(); + + if($message = $userdata->add_new_user($coppa)) + { + $message = $message . '

' . sprintf($user->lang['RETURN_INDEX'], "", ''); + trigger_error($message); + } +} +// End of submit + + + + + + +if (sizeof($userdata->error)) +{ + // If an error occured we need to stripslashes on returned data + $username = stripslashes($username); + $password = stripslashes($password); + $password_confirm = stripslashes($password_confirm); + $email = stripslashes($email); + $email_confirm = stripslashes($email_confirm); +} + + + + + + // Visual Confirmation - Show images + $confirm_image = ''; + if (!empty($config['enable_confirm'])) + { + $sql = "SELECT session_id + FROM " . SESSIONS_TABLE; + $result = $db->sql_query($sql); + + if ($row = $db->sql_fetchrow($result)) + { + $confirm_sql = ''; + do + { + $confirm_sql .= (($confirm_sql != '') ? ', ' : '') . "'" . $row['session_id'] . "'"; + } + while ($row = $db->sql_fetchrow($result)); + + $sql = "DELETE FROM " . CONFIRM_TABLE . " + WHERE session_id NOT IN ($confirm_sql)"; + $db->sql_query($sql); + } + $db->sql_freeresult($result); + + $sql = "SELECT COUNT(session_id) AS attempts + FROM " . CONFIRM_TABLE . " + WHERE session_id = '" . $userdata['session_id'] . "'"; + $result = $db->sql_query($sql); + + if ($row = $db->sql_fetchrow($result)) + { + if ($row['attempts'] > 5) + { + trigger_error($user->lang['Too_many_registers']); + } + } + $db->sql_freeresult($result); + + $code = gen_png_string(6); + $confirm_id = md5(uniqid($user_ip)); + + $sql = "INSERT INTO " . CONFIRM_TABLE . " (confirm_id, session_id, code) + VALUES ('$confirm_id', '" . $user->data['session_id'] . "', '$code')"; + $db->sql_query($sql); + + $confirm_image = (@extension_loaded('zlib')) ? '' : ''; + $s_hidden_fields .= ''; + } + // End visual confirmation + + + $template->assign_vars(array( + 'USERNAME' => $username, + 'PASSWORD' => $password, + 'PASSWORD_CONFIRM' => $password_confirm, + 'EMAIL' => $email, + 'EMAIL_CONFIRM' => $email, + 'CONFIRM_IMG' => $confirm_image, + 'ERROR' => (sizeof($userdata->error)) ? implode('
', $userdata->error) : '', + + 'L_CONFIRM_EXPLAIN' => sprintf($user->lang['CONFIRM_EXPLAIN'], '', ''), + + 'S_LANG_OPTIONS' => language_select($lang), + 'S_TZ_OPTIONS' => tz_select($tz), + 'S_CONFIRM_CODE' => ($config['enable_confirm']) ? 1 : 0, + 'S_COPPA' => $coppa, + 'S_HIDDEN_FIELDS' => '', + 'S_FORM_ENCTYPE' => $form_enctype, + 'S_PROFILE_ACTION' => "ucp.$phpEx$SID&mode=register") + ); + + + +// +page_header($user->lang['REGISTER']); + +$template->set_filenames(array( + 'body' => 'ucp_register.html') +); +make_jumpbox('viewforum.'.$phpEx); + +page_footer(); + + + + +function gen_png_string($num_chars) +{ + $chars = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '1', '2', '3', '4', '5', '6', '7', '8', '9'); + + list($usec, $sec) = explode(' ', microtime()); + mt_srand($sec * $usec); + + $max_chars = count($chars) - 1; + $rand_str = ''; + for ($i = 0; $i < $num_chars; $i++) + { + $rand_str .= $chars[mt_rand(0, $max_chars)]; + } + + return $rand_str; +} + + +?> \ No newline at end of file