aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Atkinson <thefinn@users.sourceforge.net>2003-03-04 18:14:36 +0000
committerJames Atkinson <thefinn@users.sourceforge.net>2003-03-04 18:14:36 +0000
commite6c31a8787410d218e23a24b1c652bb31d96da9f (patch)
tree1f58e083e879193a8f0e089b5fe7c990d4b5f263
parent77c9d2c275838a54053094b856ac2d2c61ecac3f (diff)
downloadforums-e6c31a8787410d218e23a24b1c652bb31d96da9f.tar
forums-e6c31a8787410d218e23a24b1c652bb31d96da9f.tar.gz
forums-e6c31a8787410d218e23a24b1c652bb31d96da9f.tar.bz2
forums-e6c31a8787410d218e23a24b1c652bb31d96da9f.tar.xz
forums-e6c31a8787410d218e23a24b1c652bb31d96da9f.zip
Ok, this should be the right version...I've got too many windows open...
git-svn-id: file:///svn/phpbb/trunk@3594 89ea8834-ac86-4346-8a33-228a782c2dd0
-rwxr-xr-xphpBB/ucp/usercp_register.php347
1 files changed, 2 insertions, 345 deletions
diff --git a/phpBB/ucp/usercp_register.php b/phpBB/ucp/usercp_register.php
index fad0d2ba8a..e726304bc3 100755
--- a/phpBB/ucp/usercp_register.php
+++ b/phpBB/ucp/usercp_register.php
@@ -38,7 +38,7 @@ $error = FALSE;
$page_title = $user->lang['Register'];
-// class for handling the manipulation of user data
+// Class for handling the manipulation of user data
$userdata = new userdata();
if ($mode == 'register')
@@ -72,350 +72,7 @@ $coppa = (empty($_POST['coppa_under_13']) && empty($_GET['coppa_under_13'])) ? 0
if (isset($_POST['submit']))
{
-/*
- $strip_var_list = array('username' => 'username', 'email' => 'email');
-
- foreach ($strip_var_list as $var => $param)
- {
- if (!empty($_POST[$param]))
- {
- $$var = trim(strip_tags($_POST[$param]));
- }
- }
-
- $trim_var_list = array('password_current' => 'cur_password', 'password' => 'new_password', 'password_confirm' => 'password_confirm');
-
- foreach ($trim_var_list as $var => $param)
- {
- if (!empty($_POST[$param]))
- {
- $$var = trim($_POST[$param]);
- }
- }
-
- $username = str_replace('&nbsp;', '', $username);
- $email = htmlspecialchars($email);
-
- // Run some validation on the optional fields. These are pass-by-ref, so they'll be changed to
- // empty strings if they fail.
- //validate_optional_fields($icq, $aim, $msn, $yim, $website, $location, $occupation, $interests, $signature);
-
- $viewemail = (isset($_POST['viewemail'])) ? (($_POST['viewemail']) ? TRUE : 0) : 0;
- $allowviewonline = (isset($_POST['hideonline'])) ? (($_POST['hideonline']) ? 0 : TRUE) : TRUE;
- $notifyreply = (isset($_POST['notifyreply'])) ? (($_POST['notifyreply']) ? TRUE : 0) : 0;
- $notifypm = (isset($_POST['notifypm'])) ? (($_POST['notifypm']) ? TRUE : 0) : TRUE;
- $popuppm = (isset($_POST['popup_pm'])) ? (($_POST['popup_pm']) ? TRUE : 0) : TRUE;
-
- $attachsig = (isset($_POST['attachsig'])) ? (($_POST['attachsig']) ? TRUE : 0) : $config['allow_sig'];
-
- $allowhtml = (isset($_POST['allowhtml'])) ? (($_POST['allowhtml']) ? TRUE : 0) : $config['allow_html'];
- $allowbbcode = (isset($_POST['allowbbcode'])) ? (($_POST['allowbbcode']) ? TRUE : 0) : $config['allow_bbcode'];
- $allowsmilies = (isset($_POST['allowsmilies'])) ? (($_POST['allowsmilies']) ? TRUE : 0) : $config['allow_smilies'];
-
- $user_style = (isset($_POST['style'])) ? intval($_POST['style']) : $config['default_style'];
-
- if (!empty($_POST['language']))
- {
- if (preg_match('/^[a-z_]+$/i', $_POST['language']))
- {
- $user_lang = $_POST['language'];
- }
- else
- {
- $error = true;
- $error_msg = $user->lang['Fields_empty'];
- }
- }
- else
- {
- $user_lang = $config['default_lang'];
- }
-
- $user_timezone = (isset($_POST['timezone'])) ? doubleval($_POST['timezone']) : $config['board_timezone'];
- $user_dateformat = (!empty($_POST['dateformat'])) ? trim($_POST['dateformat']) : $config['default_dateformat'];
-
-}
-
-
-// Did the user submit? In this case build a query to update the users profile in the DB
-if (isset($_POST['submit']))
-{
- $passwd_sql = '';
-
- if (empty($username) || empty($password) || empty($password_confirm) || empty($email))
- {
- $error = TRUE;
- $error_msg .= ((isset($error_msg)) ? '<br />' : '') . $user->lang['Fields_empty'];
- }
-
- $passwd_sql = '';
- if (!empty($password) && !empty($password_confirm))
- {
- if ($password != $password_confirm)
- {
- $error = TRUE;
- $error_msg .= ((isset($error_msg)) ? '<br />' : '') . $user->lang['Password_mismatch'];
- }
- else if (strlen($password) > 32)
- {
- $error = TRUE;
- $error_msg .= ((isset($error_msg)) ? '<br />' : '') . $user->lang['Password_long'];
- }
- else
- {
- if (!$error)
- {
- $password = md5($password);
- $passwd_sql = "user_password = '$password', ";
- }
- }
- }
- else if ((empty($password) && !empty($password_confirm)) || (!empty($password) && empty($password_confirm)))
- {
- $error = TRUE;
- $error_msg .= ((isset($error_msg)) ? '<br />' : '') . $user->lang['Password_mismatch'];
- }
- else
- {
- $password = $user->data['user_password'];
- }
-
- // Do a ban check on this email address
- if ($email != $user->data['user_email'] || $mode == 'register')
- {
- if (($result = validate_email($email)) != false)
- {
- $email = $user->data['user_email'];
-
- $error = TRUE;
- $error_msg .= ((isset($error_msg)) ? '<br />' : '') . $result;
- }
- }
-
- $username_sql = '';
-
- if (empty($username))
- {
- $error = TRUE;
- $error_msg .= ((isset($error_msg)) ? '<br />' : '') . $user->lang['Username_disallowed'];
- }
- else
- {
- if (($result = validate_username($username)) != false)
- {
- $error = TRUE;
- $error_msg .= ((isset($error_msg)) ? '<br />' : '') . $result;
- }
- else
- {
- $username_sql = "username = '" . $username . "', ";
- }
- }
-
- // Visual Confirmation handling
- if ($config['enable_confirm'])
- {
- if (empty($_POST['confirm_id']))
- {
- $error = TRUE;
- $error_msg .= ((isset($error_msg)) ? '<br />' : '') . $lang['Confirm_code_wrong'];
- }
- else
- {
- $sql = "SELECT code
- FROM " . CONFIRM_TABLE . "
- WHERE confirm_id = '" . $_POST['confirm_id'] . "'
- AND session_id = '" . $user->data['session_id'] . "'";
- $result = $db->sql_query($sql);
-
- if ($row = $db->sql_fetchrow($result))
- {
- if ($row['code'] != $_POST['confirm_code'])
- {
- $error = TRUE;
- $error_msg .= ((isset($error_msg)) ? '<br />' : '') . $lang['Confirm_code_wrong'];
- }
- }
- else
- {
- $error = TRUE;
- $error_msg .= ((isset($error_msg)) ? '<br />' : '') . $lang['Confirm_code_wrong'];
- }
-
- $sql = "DELETE FROM " . CONFIRM_TABLE . "
- WHERE confirm_id = '" . $_POST['confirm_id'] . "'
- AND session_id = '" . $userdata['session_id'] . "'";
- $db->sql_query($sql);
- }
- }
-
- if (!$error)
- {
- if ((($mode == 'register' || $coppa)) && ($config['require_activation'] == USER_ACTIVATION_SELF || $config['require_activation'] == USER_ACTIVATION_ADMIN))
- {
- $user_actkey = gen_png_string(10);
- $key_len = 54 - (strlen($server_url));
- $key_len = ($key_len > 6) ? $key_len : 6;
-
- $user_actkey = substr($user_actkey, 0, $key_len);
- $user_active = 0;
-
- if ($user->data['user_id'] != ANONYMOUS)
- {
- $user->destroy();
- }
- }
- else
- {
- $user_active = 1;
- $user_actkey = '';
- }
-
- // Begin transaction ... should this screw up we can rollback
- $db->sql_transaction();
-
- $sql_ary = array(
- 'user_ip' => $user->ip,
- 'user_regdate' => time(),
- 'username' => $username,
- 'user_password' => $password,
- 'user_email' => $email,
- 'user_viewemail' => $viewemail,
- 'user_attachsig' => $attachsig,
- 'user_allowsmile' => $allowsmilies,
- 'user_allowhtml' => $allowhtml,
- 'user_allowbbcode' => $allowbbcode,
- 'user_allow_viewonline' => $allowviewonline,
- 'user_allow_pm' => 1,
- 'user_notify' => $notifyreply,
- 'user_notify_pm'=> $notifypm,
- 'user_popup_pm' => $popuppm,
- 'user_timezone' => (float) $user_timezone,
- 'user_dateformat' => $user_dateformat,
- 'user_lang' => $user_lang,
- 'user_style' => $user_style,
- 'user_active' => $user_active,
- 'user_actkey' => $user_actkey
- );
-// 'user_avatar' => $avatar_sql['data'],
-// 'user_avatar_type' => $avatar_sql['type'],
-
- $sql = 'INSERT INTO ' . USERS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
- $db->sql_query($sql);
-
- $user_id = $db->sql_nextid();
-
- // Place into appropriate group, either REGISTERED or INACTIVE depending on config
- $group_name = ($config['require_activation'] == USER_ACTIVATION_NONE) ? 'REGISTERED' : 'INACTIVE';
- $sql = "INSERT INTO " . USER_GROUP_TABLE . " (user_id, group_id, user_pending)
- SELECT $user_id, group_id, 0
- FROM " . GROUPS_TABLE . "
- WHERE group_name = '$group_name'
- AND group_type = " . GROUP_SPECIAL;
- $result = $db->sql_query($sql);
-
- if ($config['require_activation'] == USER_ACTIVATION_NONE)
- {
- set_config('newest_user_id', $user_id, TRUE);
- set_config('newest_username', $username, TRUE);
- set_config('num_users', $config['num_users'] + 1, TRUE);
- }
-
- $db->sql_transaction('commit');
-
-
- if ($coppa)
- {
- $message = $user->lang['COPPA'];
- $email_template = 'coppa_welcome_inactive';
- }
- else if ($config['require_activation'] == USER_ACTIVATION_SELF)
- {
- $message = $user->lang['Account_inactive'];
- $email_template = 'user_welcome_inactive';
- }
- else if ($config['require_activation'] == USER_ACTIVATION_ADMIN)
- {
- $message = $user->lang['Account_inactive_admin'];
- $email_template = 'admin_welcome_inactive';
- }
- else
- {
- $message = $user->lang['Account_added'];
- $email_template = 'user_welcome';
- }
-
-/*
- include($phpbb_root_path . 'includes/emailer.'.$phpEx);
- $emailer = new emailer($config['smtp_delivery']);
-
- // Should we just define this within the email class?
- $email_headers = "From: " . $config['board_email'] . "\nReturn-Path: " . $config['board_email'] . "\r\n";
-
- $emailer->use_template($email_template, $user->data['user_lang']);
- $emailer->email_address($email);
- $emailer->set_subject();//sprintf($user->lang['Welcome_subject'], $config['sitename'])
- $emailer->extra_headers($email_headers);
-
- if ($coppa)
- {
- $emailer->assign_vars(array(
- 'SITENAME' => $config['sitename'],
- 'WELCOME_MSG' => sprintf($user->lang['Welcome_subject'], $config['sitename']),
- 'USERNAME' => $username,
- 'PASSWORD' => $password_confirm,
- 'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']),
-
- 'U_ACTIVATE' => $server_url . '?mode=activate&act_key=' . $user_actkey,
- 'FAX_INFO' => $config['coppa_fax'],
- 'MAIL_INFO' => $config['coppa_mail'],
- 'EMAIL_ADDRESS' => $email,
- 'SITENAME' => $config['sitename']));
- }
- else
- {
- $emailer->assign_vars(array(
- 'SITENAME' => $config['sitename'],
- 'WELCOME_MSG' => sprintf($user->lang['Welcome_subject'], $config['sitename']),
- 'USERNAME' => $username,
- 'PASSWORD' => $password_confirm,
- 'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']),
- 'U_ACTIVATE' => $server_url . '?mode=activate&act_key=' . $user_actkey)
- );
- }
-
- $emailer->send();
- $emailer->reset();
-
- if ($config['require_activation'] == USER_ACTIVATION_ADMIN)
- {
- $emailer->use_template('admin_activate', stripslashes($user_lang));
- $emailer->email_address($config['board_email']);
- $emailer->set_subject(); //$user->lang['New_account_subject']
- $emailer->extra_headers($email_headers);
-
- $emailer->assign_vars(array(
- 'USERNAME' => $username,
- 'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']),
-
- 'U_ACTIVATE' => $server_url . '?mode=activate&act_key=' . $user_actkey)
- );
- $emailer->send();
- $emailer->reset();
- }
-*/
-/*
- $message = $message . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . "index.$phpEx$SID" . '">', '</a>');
-
- trigger_error($message);
-
- }
- else
- {
- trigger_error($error_msg);
- }
-*/
-
+ // User registration is now handled by the userdata class which is in sessions.php.
$new_user_data = $userdata->add_new_user($_POST, $coppa);
if($new_user_data['user_id'])
{