2 /*=====================================================================*\
3 || ################################################################### ||
4 || # Bugdar [#]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 ($_POST['do'] == 'insert')
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 if ($bugsys->in
['email'] != $bugsys->in
['confirmemail'])
39 $message->items
[] = $lang->string('The emails you entered do not match.');
42 if (!$bugsys->in
['email'])
44 $message->items
[] = $lang->string('The email you specified was blank.');
47 if ($bugsys->in
['password'] != $bugsys->in
['confirmpassword'])
49 $message->items
[] = $lang->string('The passwords you entered did not match.');
52 if (!$bugsys->in
['password'])
54 $message->items
[] = $lang->string('The password you specified was blank.');
57 if (!$bugsys->in
['displayname'])
59 $message->items
[] = $lang->string('The display name you specified was blank.');
62 if (!$funct->is_valid_email($bugsys->in
['email']))
64 $message->items
[] = $lang->string('The specified email is invalid.');
67 if (is_array($db->query_first("SELECT * FROM " . TABLE_PREFIX
. "user WHERE email = '" . $bugsys->in
['email'] . "'")))
69 $message->items
[] = $lang->string('The specified email is already in use.');
72 if (is_array($db->query_first("SELECT * FROM " . TABLE_PREFIX
. "user WHERE displayname = '" . $bugsys->in
['displayname'] . "'")))
74 $message->items
[] = $lang->string('That display name is already in use by another user.');
79 $salt = $funct->rand(15);
81 if ($bugsys->options
['verifyemail'])
87 if ($bugsys->options
['moderatenewusers'])
98 INSERT INTO " . TABLE_PREFIX
. "user
99 (email, displayname, password, salt, authkey, showemail, showcolours, languageid, usergroupid)
101 ('" . $bugsys->in
['email'] . "',
102 '" . $bugsys->in
['displayname'] . "',
103 '" . md5(md5($bugsys->in
['password']) . md5($salt)) . "',
105 '" . $funct->rand() . "',
106 " . intval($bugsys->in
['showemail']) . ",
108 " . intval($bugsys->in
['languageid']) . ",
113 $userid = $db->insert_id();
115 // Verify email address
116 if ($usergroupid == 3)
118 $activationid = $funct->rand(25);
120 $db->query("INSERT INTO " . TABLE_PREFIX
. "useractivation (userid, activator, dateline, usergroupid) VALUES ($userid, '$activationid', " . TIMENOW
. ", 2)");
122 $mail->to
= $bugsys->in
['email'];
123 $mail->subject
= sprintf($lang->string('Welcome to %1$s'), $bugsys->options
['trackertitle']);
124 $mail->body
= sprintf($lang->string('Hi %1$s,
126 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:
128 %3$s/register.php?do=activate&userid=%4$s&activator=%5$s'),
130 $bugsys->in
['displayname'],
131 $bugsys->options
['trackertitle'],
132 $bugsys->options
['trackerurl'],
139 $message->message($lang->string('You now need to activate your account via email.'));
141 else if ($usergroupid == 4 OR $usergroupid == 2)
143 if ($bugsys->options
['sendwelcomemail'])
145 $mail->to
= $bugsys->in
['email'];
146 $mail->subject
= sprintf($lang->string('Welcome to %1$s'), $bugsys->options
['trackertitle']);
147 $mail->body
= sprintf($lang->string('Hi %1$s,
149 Thank you for taking the time to register at %2$s. We look forward to your contributations to making our products better.
151 If you have any questions, please don\'t hesitate to contact the webmaster.'),
152 $bugsys->in
['displayname'],
153 $bugsys->options
['trackertitle']
159 if ($usergroupid == 4)
161 $message->message($lang->string('Your account is pending approval.'));
165 $message->message($lang->string('Thank you for registering. You may now use your account.'));
171 $_REQUEST['do'] = '';
172 $show['errors'] = true
;
173 $message->error_list_process();
177 // ###################################################################
179 if (empty($_REQUEST['do']))
181 if ($bugsys->userinfo
['userid'])
183 $message->error($lang->string('Sorry, you are already registered.'));
186 if (!$bugsys->options
['allownewreg'])
188 $message->error($lang->string('Sorry, we don\'t allow new registrations.'));
191 foreach ($bugsys->datastore
['language'] AS $value => $temp)
193 $label = $temp['title'];
194 $selected = ($value == $bugsys->in
['languageid']);
195 eval('$opts .= "' . $template->fetch('selectoption') . '";');
198 eval('$template->flush("' . $template->fetch('register') . '");');
201 // ###################################################################
203 if ($_REQUEST['do'] == 'activate')
205 if ($useractivation = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "useractivation WHERE userid = " . intval($bugsys->in
['userid']) . " AND activator = '" . $bugsys->in
['activator'] . "'"))
207 $user = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "user WHERE userid = " . intval($bugsys->in
['userid']));
208 $db->query("UPDATE " . TABLE_PREFIX
. "user SET usergroupid = $useractivation[usergroupid] WHERE userid = " . intval($bugsys->in
['userid']));
209 $db->query("DELETE FROM " . TABLE_PREFIX
. "useractivation WHERE userid = " . intval($bugsys->in
['userid']));
211 if ($bugsys->options
['sendwelcomemail'])
213 $mail->to
= $user['email'];
214 $mail->subject
= sprintf($lang->string('Welcome to %1$s'), $bugsys->options
['trackertitle']);
215 $mail->body
= sprintf($lang->string('Hi %1$s,
217 Thank you for taking the time to register at %2$s. We look forward to your contributations to making our products better.
219 If you have any questions, please don\'t hesitate to contact the webmaster.'),
220 $user['displayname'],
221 $bugsys->options
['trackertitle']
226 $message->message($lang->string('Your account is now activated and you can now login.'));
230 $message->error($lang->string('Sorry, we could not match your registration string. Please make sure you entered the correct URL.'));
234 /*=====================================================================*\
235 || ###################################################################
238 || ###################################################################
239 \*=====================================================================*/