From 06c64d8db2956526b8a718757d11986005d82f18 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sun, 21 Aug 2005 20:42:02 +0000 Subject: [PATCH] r354: - phrased registration error system - activation system now sends welcome emails, too --- register.php | 63 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 42 insertions(+), 21 deletions(-) diff --git a/register.php b/register.php index fa45d42..2e85e4d 100755 --- a/register.php +++ b/register.php @@ -22,20 +22,18 @@ require_once('./global.php'); // ################################################################### -if ($bugsys->userinfo['userid']) -{ - $message->error('Sorry, you are already registered!'); -} - -if (!$bugsys->options['allownewreg']) -{ - $message->error('Sorry, we don\'t allow new registrations!'); -} - -// ################################################################### - if (empty($_REQUEST['do'])) { + if ($bugsys->userinfo['userid']) + { + $message->error('Sorry, you are already registered!'); + } + + if (!$bugsys->options['allownewreg']) + { + $message->error('Sorry, we don\'t allow new registrations!'); + } + foreach ($bugsys->datastore['language'] AS $value => $temp) { $label = $temp['title']; @@ -49,38 +47,51 @@ if (empty($_REQUEST['do'])) if ($_POST['do'] == 'insert') { + if ($bugsys->userinfo['userid']) + { + $message->error('Sorry, you are already registered!'); + } + + if (!$bugsys->options['allownewreg']) + { + $message->error('Sorry, we don\'t allow new registrations!'); + } + if ($bugsys->in['email'] != $bugsys->in['confirmemail']) { - $error->phrase[] = 'The emails you entered do not match.'; + $message->phrase[] = 'register_emails_no_match'; } if (!$bugsys->in['email']) { - $error->phrase[] = 'The password you specified was blank.'; + $message->phrase[] = 'register_blank_email'; } if ($bugsys->in['password'] != $bugsys->in['confirmpassword']) { - $error->phrase[] = 'The passwords you entered did not match.'; + $message->phrase[] = 'register_passwords_no_match'; } if (!$bugsys->in['password']) { - $error->phrase[] = 'The password you specified was blank.'; + $message->phrase[] = 'register_blank_password'; } if (!$funct->is_valid_email($bugsys->in['email'])) { - $error->phrase[] = 'The specified email is invalid.'; + $message->phrase[] = 'register_invalid_email'; } if (is_array($db->query_first("SELECT * FROM " . TABLE_PREFIX . "user WHERE email = '" . $bugsys->in['email'] . "'"))) { - $error->phrase[] = 'The specified email is already in use.'; + $message->phrase[] = 'register_email_in_use'; } - $message->error_list_process(); - $message->error(); + if ($message->phrase) + { + $message->error_list_process(); + $message->error(); + } $salt = $funct->rand(15); @@ -122,7 +133,7 @@ if ($_POST['do'] == 'insert') { $activationid = $funct->rand(25); - $db->query("INSERT INTO " . TABLE_PREFIX . "useractivation (userid, activator, dateline, usergroupid) VALUES ($userid, '$activationid', " . NOW . ", 2)"); + $db->query("INSERT INTO " . TABLE_PREFIX . "useractivation (userid, activator, dateline, usergroupid) VALUES ($userid, '$activationid', " . TIMENOW . ", 2)"); $mail->to = $bugsys->in['email']; $mail->subject = 'Welcome to ' . $bugsys->options['trackertitle']; @@ -158,8 +169,18 @@ if ($_REQUEST['do'] == 'activate') { if ($useractivation = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "useractivation WHERE userid = " . intval($bugsys->in['userid']) . " AND activator = '" . $bugsys->in['activator'] . "'")) { + $user = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "user WHERE userid = " . intval($bugsys->in['userid'])); $db->query("UPDATE " . TABLE_PREFIX . "user SET usergroupid = $useractivation[usergroupid] WHERE userid = " . intval($bugsys->in['userid'])); $db->query("DELETE FROM " . TABLE_PREFIX . "useractivation WHERE userid = " . intval($bugsys->in['userid'])); + + if ($bugsys->options['sendwelcomemail']) + { + $mail->to = $user['email']; + $mail->subject = 'Welcome to ' . $bugsys->options['trackertitle']; + $mail->body = "Hi " . $user['displayname'] . " and welcome to the " . $bugsys->options['trackertitle'] . " bug tracker! Thanks for registering."; + $mail->send(); + } + $message->message('your account is now activated and you can now login'); } else -- 2.22.5