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 (!$bugsys->in['displayname
'])
82 $message->phrase[] = $lang->string('The display name you specified was blank
.');
85 if (!$funct->is_valid_email($bugsys->in['email
']))
87 $message->phrase[] = $lang->string('The specified email is invalid
.');
90 if (is_array($db->query_first("SELECT * FROM " . TABLE_PREFIX . "user WHERE email = '" . $bugsys->in['email'] . "'")))
92 $message->phrase[] = $lang->string('The specified email is already in
use.');
95 if (is_array($db->query_first("SELECT * FROM " . TABLE_PREFIX . "user WHERE displayname = '" . $bugsys->in['displayname'] . "'")))
97 $message->phrase[] = $lang->string('That display name is already in
use by another user
.');
100 if ($message->phrase)
102 $message->error_list_process();
106 $salt = $funct->rand(15);
108 if ($bugsys->options['verifyemail
'])
114 if ($bugsys->options['moderatenewusers
'])
125 INSERT INTO " . TABLE_PREFIX . "user
126 (email, displayname, password, salt, authkey, showemail, showcolours, languageid, usergroupid)
128 ('" . $bugsys->in['email'] . "',
129 '" . $bugsys->in['displayname'] . "',
130 '" . md5(md5($bugsys->in['password']) . md5($salt)) . "',
132 '" . $funct->rand() . "',
133 " . intval($bugsys->in['showemail']) . ",
135 " . intval($bugsys->in['languageid']) . ",
140 $userid = $db->insert_id();
142 // Verify email address
143 if ($usergroupid == 3)
145 $activationid = $funct->rand(25);
147 $db->query("INSERT INTO
" . TABLE_PREFIX . "useractivation (userid
, activator
, dateline
, usergroupid
) VALUES ($userid, '$activationid', " . TIMENOW . ", 2)");
149 $mail->to = $bugsys->in['email
'];
150 $mail->subject = sprintf($lang->string('Welcome to %
1$s'), $bugsys->options
['trackertitle']);
151 $mail->body
= sprintf($lang->string('Hi %1$s,
153 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:
155 %3$s/register.php?do=activate&userid=%4$s&activator=%5$s'),
157 $bugsys->in['displayname
'],
158 $bugsys->options['trackertitle
'],
159 $bugsys->options['trackerurl
'],
166 $message->message($lang->string('You now need to activate your account via email
.'));
168 else if ($usergroupid == 4 OR $usergroupid == 2)
170 if ($bugsys->options['sendwelcomemail
'])
172 $mail->to = $bugsys->in['email
'];
173 $mail->subject = sprintf($lang->string('Welcome to %
1$s'), $bugsys->options
['trackertitle']);
174 $mail->body
= sprintf($lang->string('Hi %1$s,
176 Thank you for taking the time to register at %2$s. We look forward to your contributations to making our products better.
178 If you have any questions, please don\'t hesitate to contact the webmaster.'),
179 $bugsys->in
['displayname'],
180 $bugsys->options
['trackertitle']
186 if ($usergroupid == 4)
188 $message->message($lang->string('Your account is pending approval.'));
192 $message->message($lang->string('Thank you for registering. You may now use your account.'));
197 // ###################################################################
199 if ($_REQUEST['do'] == 'activate')
201 if ($useractivation = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "useractivation WHERE userid = " . intval($bugsys->in
['userid']) . " AND activator = '" . $bugsys->in
['activator'] . "'"))
203 $user = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "user WHERE userid = " . intval($bugsys->in
['userid']));
204 $db->query("UPDATE " . TABLE_PREFIX
. "user SET usergroupid = $useractivation[usergroupid] WHERE userid = " . intval($bugsys->in
['userid']));
205 $db->query("DELETE FROM " . TABLE_PREFIX
. "useractivation WHERE userid = " . intval($bugsys->in
['userid']));
207 if ($bugsys->options
['sendwelcomemail'])
209 $mail->to
= $user['email'];
210 $mail->subject
= sprintf($lang->string('Welcome to %1$s'), $bugsys->options['trackertitle
']);
211 $mail->body = sprintf($lang->string('Hi %
1$s,
213 Thank you
for taking the time to register at %
2$s. We look forward to your contributations to making our products better
.
215 If you have any questions
, please don\'t hesitate to contact the webmaster
.'),
216 $user['displayname
'],
217 $bugsys->options['trackertitle
']
222 $message->message($lang->string('Your account is now activated
and you can now login
.'));
226 $message->error($lang->string('Sorry
, we could not match your registration
string. Please make sure you entered the correct URL
.'));
230 /*=====================================================================*\
231 || ###################################################################
234 || ###################################################################
235 \*=====================================================================*/