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.');
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
= sprintf($lang->string('Welcome to %1$s'), $bugsys->options
['trackertitle']);
140 $mail->body
= sprintf($lang->string('Hi %1$s,
142 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:
144 %3$s/register.php?do=activate&userid=%4$s&activator=%5$s'),
146 $bugsys->in
['displayname'],
147 $bugsys->options
['trackertitle'],
148 $bugsys->options
['trackerurl'],
155 $message->message($lang->string('You now need to activate your account via email.'));
157 else if ($usergroupid == 4 OR $usergroupid == 2)
159 if ($bugsys->options
['sendwelcomemail'])
161 $mail->to
= $bugsys->in
['email'];
162 $mail->subject
= sprintf($lang->string('Welcome to %1$s'), $bugsys->options
['trackertitle']);
163 $mail->body
= sprintf($lang->string('Hi %1$s,
165 Thank you for taking the time to register at %2$s. We look forward to your contributations to making our products better.
167 If you have any questions, please don\'t hesitate to contact the webmaster.'),
168 $bugsys->in
['displayname'],
169 $bugsys->options
['trackertitle']
175 if ($usergroupid == 4)
177 $message->message($lang->string('Your account is pending approval.'));
181 $message->message($lang->string('Thank you for registering. You may now use your account.'));
186 // ###################################################################
188 if ($_REQUEST['do'] == 'activate')
190 if ($useractivation = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "useractivation WHERE userid = " . intval($bugsys->in
['userid']) . " AND activator = '" . $bugsys->in
['activator'] . "'"))
192 $user = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "user WHERE userid = " . intval($bugsys->in
['userid']));
193 $db->query("UPDATE " . TABLE_PREFIX
. "user SET usergroupid = $useractivation[usergroupid] WHERE userid = " . intval($bugsys->in
['userid']));
194 $db->query("DELETE FROM " . TABLE_PREFIX
. "useractivation WHERE userid = " . intval($bugsys->in
['userid']));
196 if ($bugsys->options
['sendwelcomemail'])
198 $mail->to
= $user['email'];
199 $mail->subject
= sprintf($lang->string('Welcome to %1$s'), $bugsys->options
['trackertitle']);
200 $mail->body
= sprintf($lang->string('Hi %1$s,
202 Thank you for taking the time to register at %2$s. We look forward to your contributations to making our products better.
204 If you have any questions, please don\'t hesitate to contact the webmaster.'),
205 $user['displayname'],
206 $bugsys->options
['trackertitle']
211 $message->message($lang->string('Your account is now activated and you can now login.'));
215 $message->error($lang->string('Sorry, we could not match your registration string. Please make sure you entered the correct URL.'));
219 /*=====================================================================*\
220 || ###################################################################
223 || ###################################################################
224 \*=====================================================================*/