2 /*=====================================================================*\
3 || ################################################################### ||
4 || # BugStrike [#]version[#]
5 || # --------------------------------------------------------------- # ||
6 || # Copyright ©2002-[#]year[#] by Iris Studios, Inc. All Rights Reserved. # ||
7 || # This file may not be reproduced in any way without permission. # ||
8 || # --------------------------------------------------------------- # ||
9 || # User License Agreement at http://www.iris-studios.com/license/ # ||
10 || ################################################################### ||
11 \*=====================================================================*/
13 $fetchtemplates = array(
17 define('SVN', '$Id$');
19 $focus['user'] = 'focus';
21 require_once('./global.php');
23 // ###################################################################
25 if (empty($_REQUEST['do']))
27 if ($bugsys->userinfo
['userid'])
29 $message->error(lang
::r('Sorry, you are already registered!'));
32 if (!$bugsys->options
['allownewreg'])
34 $message->error(lang
::r('Sorry, we don\'t allow new registrations!'));
37 foreach ($bugsys->datastore
['language'] AS $value => $temp)
39 $label = $temp['title'];
40 eval('$opts .= "' . $template->fetch('selectoption') . '";');
43 eval('$template->flush("' . $template->fetch('register') . '");');
46 // ###################################################################
48 if ($_POST['do'] == 'insert')
50 if ($bugsys->userinfo
['userid'])
52 $message->error(lang
::r('Sorry, you are already registered!'));
55 if (!$bugsys->options
['allownewreg'])
57 $message->error(lang
::r('Sorry, we don\'t allow new registrations!'));
60 if ($bugsys->in
['email'] != $bugsys->in
['confirmemail'])
62 $message->phrase
[] = 'register_emails_no_match';
65 if (!$bugsys->in
['email'])
67 $message->phrase
[] = 'register_blank_email';
70 if ($bugsys->in
['password'] != $bugsys->in
['confirmpassword'])
72 $message->phrase
[] = 'register_passwords_no_match';
75 if (!$bugsys->in
['password'])
77 $message->phrase
[] = 'register_blank_password';
80 if (!$funct->is_valid_email($bugsys->in
['email']))
82 $message->phrase
[] = 'register_invalid_email';
85 if (is_array($db->query_first("SELECT * FROM " . TABLE_PREFIX
. "user WHERE email = '" . $bugsys->in
['email'] . "'")))
87 $message->phrase
[] = 'register_email_in_use';
92 $message->error_list_process();
96 $salt = $funct->rand(15);
98 if ($bugsys->options
['verifyemail'])
104 if ($bugsys->options
['moderatenewusers'])
115 INSERT INTO " . TABLE_PREFIX
. "user
116 (email, displayname, password, salt, authkey, showemail, languageid, usergroupid)
118 ('" . $bugsys->in
['email'] . "',
119 '" . $bugsys->in
['displayname'] . "',
120 '" . md5(md5($bugsys->in
['password']) . md5($salt)) . "',
122 '" . $funct->rand() . "',
123 " . intval($bugsys->in
['showemail']) . ",
124 " . intval($bugsys->in
['languageid']) . ",
129 $userid = $db->insert_id();
131 // Verify email address
132 if ($usergroupid == 3)
134 $activationid = $funct->rand(25);
136 $db->query("INSERT INTO " . TABLE_PREFIX
. "useractivation (userid, activator, dateline, usergroupid) VALUES ($userid, '$activationid', " . TIMENOW
. ", 2)");
138 $mail->to
= $bugsys->in
['email'];
139 $mail->subject
= lang
::r('Welcome to ' . $bugsys->options
['trackertitle']);
140 $mail->body
= lang
::r("Hi " . $bugsys->in
['displayname'] . " you need to activate your account: http://devbox/bugtraq/register.php?do=activate&userid=" . $userid . "&activator=" . $activationid);
143 $message->message(lang
::r('You now need to activate your account via email.'));
145 else if ($usergroupid == 4 OR $usergroupid == 2)
147 if ($bugsys->options
['sendwelcomemail'])
149 $mail->to
= $bugsys->in
['email'];
150 $mail->subject
= lang
::r('Welcome to ' . $bugsys->options
['trackertitle']);
151 $mail->body
= lang
::r("Hi " . $bugsys->in
['displayname'] . " and welcome to the " . $bugsys->options
['trackertitle'] . " bug tracker! Thanks for registering.");
155 if ($usergroupid == 4)
157 $message->message(lang
::r('Your account is pending approval.'));
161 $message->message(lang
::r('Registration complete!'));
166 // ###################################################################
168 if ($_REQUEST['do'] == 'activate')
170 if ($useractivation = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "useractivation WHERE userid = " . intval($bugsys->in
['userid']) . " AND activator = '" . $bugsys->in
['activator'] . "'"))
172 $user = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "user WHERE userid = " . intval($bugsys->in
['userid']));
173 $db->query("UPDATE " . TABLE_PREFIX
. "user SET usergroupid = $useractivation[usergroupid] WHERE userid = " . intval($bugsys->in
['userid']));
174 $db->query("DELETE FROM " . TABLE_PREFIX
. "useractivation WHERE userid = " . intval($bugsys->in
['userid']));
176 if ($bugsys->options
['sendwelcomemail'])
178 $mail->to
= $user['email'];
179 $mail->subject
= lang
::r('Welcome to ' . $bugsys->options
['trackertitle']);
180 $mail->body
= lang
::r("Hi " . $user['displayname'] . " and welcome to the " . $bugsys->options
['trackertitle'] . " bug tracker! Thanks for registering.");
184 $message->message(lang
::r('your account is now activated and you can now login'));
188 $message->error(lang
::r('we could not match your registration string. please make sure you entered the correct url'));
192 /*=====================================================================*\
193 || ###################################################################
196 || ###################################################################
197 \*=====================================================================*/