From 65a36f942d2149a366690551b9958afed959beee Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sun, 15 Jan 2006 08:29:22 +0000 Subject: [PATCH] r724: Error box model for register.php --- register.php | 200 +++++++++++++++++++++-------------------- templates/register.tpl | 15 +++- 2 files changed, 113 insertions(+), 102 deletions(-) diff --git a/register.php b/register.php index 1d10eae..4e2dd12 100755 --- a/register.php +++ b/register.php @@ -22,29 +22,6 @@ require_once('./global.php'); // ################################################################### -if (empty($_REQUEST['do'])) -{ - if ($bugsys->userinfo['userid']) - { - $message->error($lang->string('Sorry, you are already registered.')); - } - - if (!$bugsys->options['allownewreg']) - { - $message->error($lang->string('Sorry, we don\'t allow new registrations.')); - } - - foreach ($bugsys->datastore['language'] AS $value => $temp) - { - $label = $temp['title']; - eval('$opts .= "' . $template->fetch('selectoption') . '";'); - } - - eval('$template->flush("' . $template->fetch('register') . '");'); -} - -// ################################################################### - if ($_POST['do'] == 'insert') { if ($bugsys->userinfo['userid']) @@ -97,101 +74,128 @@ if ($_POST['do'] == 'insert') $message->items[] = $lang->string('That display name is already in use by another user.'); } - if ($message->items) - { - $message->error_list_process(); - $message->error(); - } - - $salt = $funct->rand(15); - - if ($bugsys->options['verifyemail']) + if (!$message->items) { - $usergroupid = 3; - } - else - { - if ($bugsys->options['moderatenewusers']) + $salt = $funct->rand(15); + + if ($bugsys->options['verifyemail']) { - $usergroupid = 4; + $usergroupid = 3; } else { - $usergroupid = 2; + if ($bugsys->options['moderatenewusers']) + { + $usergroupid = 4; + } + else + { + $usergroupid = 2; + } } - } - - $db->query(" - INSERT INTO " . TABLE_PREFIX . "user - (email, displayname, password, salt, authkey, showemail, showcolours, languageid, usergroupid) - VALUES - ('" . $bugsys->in['email'] . "', - '" . $bugsys->in['displayname'] . "', - '" . md5(md5($bugsys->in['password']) . md5($salt)) . "', - '$salt', - '" . $funct->rand() . "', - " . intval($bugsys->in['showemail']) . ", - 1, - " . intval($bugsys->in['languageid']) . ", - $usergroupid - )" - ); - - $userid = $db->insert_id(); - - // Verify email address - if ($usergroupid == 3) - { - $activationid = $funct->rand(25); - - $db->query("INSERT INTO " . TABLE_PREFIX . "useractivation (userid, activator, dateline, usergroupid) VALUES ($userid, '$activationid', " . TIMENOW . ", 2)"); - $mail->to = $bugsys->in['email']; - $mail->subject = sprintf($lang->string('Welcome to %1$s'), $bugsys->options['trackertitle']); - $mail->body = sprintf($lang->string('Hi %1$s, - -Welcome to the %2$s tracker. Before you can begin posting bug reports, you\'ll need to activae your account. To do this, please click this link: - -%3$s/register.php?do=activate&userid=%4$s&activator=%5$s'), - - $bugsys->in['displayname'], - $bugsys->options['trackertitle'], - $bugsys->options['trackerurl'], - $userid, - $activationid + $db->query(" + INSERT INTO " . TABLE_PREFIX . "user + (email, displayname, password, salt, authkey, showemail, showcolours, languageid, usergroupid) + VALUES + ('" . $bugsys->in['email'] . "', + '" . $bugsys->in['displayname'] . "', + '" . md5(md5($bugsys->in['password']) . md5($salt)) . "', + '$salt', + '" . $funct->rand() . "', + " . intval($bugsys->in['showemail']) . ", + 1, + " . intval($bugsys->in['languageid']) . ", + $usergroupid + )" ); - $mail->send(); - - $message->message($lang->string('You now need to activate your account via email.')); - } - else if ($usergroupid == 4 OR $usergroupid == 2) - { - if ($bugsys->options['sendwelcomemail']) + $userid = $db->insert_id(); + + // Verify email address + if ($usergroupid == 3) { + $activationid = $funct->rand(25); + + $db->query("INSERT INTO " . TABLE_PREFIX . "useractivation (userid, activator, dateline, usergroupid) VALUES ($userid, '$activationid', " . TIMENOW . ", 2)"); + $mail->to = $bugsys->in['email']; - $mail->subject = sprintf($lang->string('Welcome to %1$s'), $bugsys->options['trackertitle']); + $mail->subject = sprintf($lang->string('Welcome to %1$s'), $bugsys->options['trackertitle']); $mail->body = sprintf($lang->string('Hi %1$s, - -Thank you for taking the time to register at %2$s. We look forward to your contributations to making our products better. - -If you have any questions, please don\'t hesitate to contact the webmaster.'), - $bugsys->in['displayname'], - $bugsys->options['trackertitle'] + + Welcome to the %2$s tracker. Before you can begin posting bug reports, you\'ll need to activae your account. To do this, please click this link: + + %3$s/register.php?do=activate&userid=%4$s&activator=%5$s'), + + $bugsys->in['displayname'], + $bugsys->options['trackertitle'], + $bugsys->options['trackerurl'], + $userid, + $activationid ); $mail->send(); - } - if ($usergroupid == 4) - { - $message->message($lang->string('Your account is pending approval.')); + $message->message($lang->string('You now need to activate your account via email.')); } - else + else if ($usergroupid == 4 OR $usergroupid == 2) { - $message->message($lang->string('Thank you for registering. You may now use your account.')); + if ($bugsys->options['sendwelcomemail']) + { + $mail->to = $bugsys->in['email']; + $mail->subject = sprintf($lang->string('Welcome to %1$s'), $bugsys->options['trackertitle']); + $mail->body = sprintf($lang->string('Hi %1$s, + + Thank you for taking the time to register at %2$s. We look forward to your contributations to making our products better. + + If you have any questions, please don\'t hesitate to contact the webmaster.'), + $bugsys->in['displayname'], + $bugsys->options['trackertitle'] + ); + + $mail->send(); + } + + if ($usergroupid == 4) + { + $message->message($lang->string('Your account is pending approval.')); + } + else + { + $message->message($lang->string('Thank you for registering. You may now use your account.')); + } } } + else + { + $_REQUEST['do'] = ''; + $show['errors'] = true; + $message->error_list_process(); + } +} + +// ################################################################### + +if (empty($_REQUEST['do'])) +{ + if ($bugsys->userinfo['userid']) + { + $message->error($lang->string('Sorry, you are already registered.')); + } + + if (!$bugsys->options['allownewreg']) + { + $message->error($lang->string('Sorry, we don\'t allow new registrations.')); + } + + foreach ($bugsys->datastore['language'] AS $value => $temp) + { + $label = $temp['title']; + $selected = ($value == $bugsys->in['languageid']); + eval('$opts .= "' . $template->fetch('selectoption') . '";'); + } + + eval('$template->flush("' . $template->fetch('register') . '");'); } // ################################################################### diff --git a/templates/register.tpl b/templates/register.tpl index 17bd382..22234d2 100644 --- a/templates/register.tpl +++ b/templates/register.tpl @@ -10,6 +10,13 @@ $headinclude $header + +
+ {@"The following errors occurred"}: + {$message->process} +
+
+
@@ -18,12 +25,12 @@ $header
{@"Register"}
-
{@"Email"}:
-
{@"Confirm Email"}:
-
{@"Display Name"}:
+
{@"Email"}:
+
{@"Confirm Email"}:
+
{@"Display Name"}:
{@"Password"}:
{@"Confirm Password"}:
-
{@"Show My Email Publicly"}: {@"Yes"}
+
{@"Show My Email Publicly"}: checked="checked" /> {@"Yes"}
{@"Language"}:
-- 2.22.5