From 2448361f373423d5be9c7964b28cfb47422b6d2b Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sun, 30 Apr 2006 08:10:51 +0000 Subject: [PATCH] r787: Implement the user API --- register.php | 75 ++++++++++++++-------------------------------------- 1 file changed, 20 insertions(+), 55 deletions(-) diff --git a/register.php b/register.php index 653a2f0..54521b6 100755 --- a/register.php +++ b/register.php @@ -28,6 +28,7 @@ define('SVN', '$Id$'); $focus['user'] = 'focus'; require_once('./global.php'); +require_once('./includes/api_user.php'); // ################################################################### @@ -48,41 +49,11 @@ if ($_POST['do'] == 'insert') $message->items[] = $lang->string('The emails you entered do not match.'); } - if (!$bugsys->in['email']) - { - $message->items[] = $lang->string('The email you specified was blank.'); - } - if ($bugsys->in['password'] != $bugsys->in['confirmpassword']) { $message->items[] = $lang->string('The passwords you entered did not match.'); } - - if (!$bugsys->in['password']) - { - $message->items[] = $lang->string('The password you specified was blank.'); - } - - if (!$bugsys->in['displayname']) - { - $message->items[] = $lang->string('The display name you specified was blank.'); - } - - if (!$funct->is_valid_email($bugsys->in['email'])) - { - $message->items[] = $lang->string('The specified email is invalid.'); - } - - if (is_array($db->query_first("SELECT * FROM " . TABLE_PREFIX . "user WHERE email = '" . $bugsys->in['email'] . "'"))) - { - $message->items[] = $lang->string('The specified email is already in use.'); - } - - if (is_array($db->query_first("SELECT * FROM " . TABLE_PREFIX . "user WHERE displayname = '" . $bugsys->in['displayname'] . "'"))) - { - $message->items[] = $lang->string('That display name is already in use by another user.'); - } - + if (!$message->items) { $salt = $funct->rand(15); @@ -103,23 +74,17 @@ if ($_POST['do'] == 'insert') } } - $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 - )" - ); + $user = new UserAPI($bugsys); + $user->set('email', $bugsys->in['email']); + $user->set('displayname', $bugsys->in['displayname']); + $user->set('password', $bugsys->in['password']); + $user->set('showemail', $bugsys->in['showemail']); + $user->set('showcolours', 1); + $user->set('languageid', $bugsys->in['languageid']); + $user->set('usergroupid', $usergroupid); + $user->insert(); - $userid = $db->insert_id(); + $userid = $user->insertid; // Verify email address if ($usergroupid == 3) @@ -131,10 +96,10 @@ if ($_POST['do'] == 'insert') $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'), + +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'], @@ -154,10 +119,10 @@ if ($_POST['do'] == 'insert') $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.'), + +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'] ); -- 2.22.5