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->string('Sorry, you are already registered.'));
32 if (!$bugsys->options
['allownewreg'])
34 $message->error($lang->string('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->string('Sorry, you are already registered.'));
55 if (!$bugsys->options
['allownewreg'])
57 $message->error($lang->string('Sorry, we don\'t allow new registrations.'));
60 if ($bugsys->in
['email'] != $bugsys->in
['confirmemail'])
62 $message->phrase
[] = $lang->string('The emails you entered do not match.');
65 if (!$bugsys->in
['email'])
67 $message->phrase
[] = $lang->string('The email you specified was blank.');
70 if ($bugsys->in
['password'] != $bugsys->in
['confirmpassword'])
72 $message->phrase
[] = $lang->string('The passwords you entered did not match.');
75 if (!$bugsys->in
['password'])
77 $message->phrase
[] = $lang->string('The password you specified was blank.');
80 if (!$funct->is_valid_email($bugsys->in
['email']))
82 $message->phrase
[] = $lang->string('The specified email is invalid.');
85 if (is_array($db->query_first("SELECT * FROM " . TABLE_PREFIX
. "user WHERE email = '" . $bugsys->in
['email'] . "'")))
87 $message->phrase
[] = $lang->string('The specified email is already in use.');
90 if (is_array($db->query_first("SELECT * FROM " . TABLE_PREFIX
. "user WHERE displayname = '" . $bugsys->in
['displayname'] . "'")))
92 $message->phrase
[] = $lang->string('That display name is already in use by another user');
97 $message->error_list_process();
101 $salt = $funct->rand(15);
103 if ($bugsys->options
['verifyemail'])
109 if ($bugsys->options
['moderatenewusers'])
120 INSERT INTO " . TABLE_PREFIX
. "user
121 (email, displayname, password, salt, authkey, showemail, showcolours, languageid, usergroupid)
123 ('" . $bugsys->in
['email'] . "',
124 '" . $bugsys->in
['displayname'] . "',
125 '" . md5(md5($bugsys->in
['password']) . md5($salt)) . "',
127 '" . $funct->rand() . "',
128 " . intval($bugsys->in
['showemail']) . ",
130 " . intval($bugsys->in
['languageid']) . ",
135 $userid = $db->insert_id();
137 // Verify email address
138 if ($usergroupid == 3)
140 $activationid = $funct->rand(25);
142 $db->query("INSERT INTO " . TABLE_PREFIX
. "useractivation (userid, activator, dateline, usergroupid) VALUES ($userid, '$activationid', " . TIMENOW
. ", 2)");
144 $mail->to
= $bugsys->in
['email'];
145 $mail->subject
= sprintf($lang->string('Welcome to %1$s'), $bugsys->options
['trackertitle']);
146 $mail->body
= sprintf($lang->string('Hi %1$s,
148 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:
150 %3$s/register.php?do=activate&userid=%4$s&activator=%5$s'),
152 $bugsys->in
['displayname'],
153 $bugsys->options
['trackertitle'],
154 $bugsys->options
['trackerurl'],
161 $message->message($lang->string('You now need to activate your account via email.'));
163 else if ($usergroupid == 4 OR $usergroupid == 2)
165 if ($bugsys->options
['sendwelcomemail'])
167 $mail->to
= $bugsys->in
['email'];
168 $mail->subject
= sprintf($lang->string('Welcome to %1$s'), $bugsys->options
['trackertitle']);
169 $mail->body
= sprintf($lang->string('Hi %1$s,
171 Thank you for taking the time to register at %2$s. We look forward to your contributations to making our products better.
173 If you have any questions, please don\'t hesitate to contact the webmaster.'),
174 $bugsys->in
['displayname'],
175 $bugsys->options
['trackertitle']
181 if ($usergroupid == 4)
183 $message->message($lang->string('Your account is pending approval.'));
187 $message->message($lang->string('Thank you for registering. You may now use your account.'));
192 // ###################################################################
194 if ($_REQUEST['do'] == 'activate')
196 if ($useractivation = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "useractivation WHERE userid = " . intval($bugsys->in
['userid']) . " AND activator = '" . $bugsys->in
['activator'] . "'"))
198 $user = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "user WHERE userid = " . intval($bugsys->in
['userid']));
199 $db->query("UPDATE " . TABLE_PREFIX
. "user SET usergroupid = $useractivation[usergroupid] WHERE userid = " . intval($bugsys->in
['userid']));
200 $db->query("DELETE FROM " . TABLE_PREFIX
. "useractivation WHERE userid = " . intval($bugsys->in
['userid']));
202 if ($bugsys->options
['sendwelcomemail'])
204 $mail->to
= $user['email'];
205 $mail->subject
= sprintf($lang->string('Welcome to %1$s'), $bugsys->options
['trackertitle']);
206 $mail->body
= sprintf($lang->string('Hi %1$s,
208 Thank you for taking the time to register at %2$s. We look forward to your contributations to making our products better.
210 If you have any questions, please don\'t hesitate to contact the webmaster.'),
211 $user['displayname'],
212 $bugsys->options
['trackertitle']
217 $message->message($lang->string('Your account is now activated and you can now login.'));
221 $message->error($lang->string('Sorry, we could not match your registration string. Please make sure you entered the correct URL.'));
225 /*=====================================================================*\
226 || ###################################################################
229 || ###################################################################
230 \*=====================================================================*/