2 /*=====================================================================*\
3 || ###################################################################
4 || # Bugdar [#]version[#]
5 || # Copyright ©2002-[#]year[#] Iris Studios, Inc.
7 || # This program is free software; you can redistribute it and/or modify
8 || # it under the terms of the GNU General Public License as published by
9 || # the Free Software Foundation; version [#]gpl[#] of the License.
11 || # This program is distributed in the hope that it will be useful, but
12 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 || # You should have received a copy of the GNU General Public License along
17 || # with this program; if not, write to the Free Software Foundation, Inc.,
18 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 || ###################################################################
20 \*=====================================================================*/
22 $fetchtemplates = array(
26 define('SVN', '$Id$');
28 $focus['user'] = 'focus';
30 require_once('./global.php');
32 // ###################################################################
34 if ($_POST['do'] == 'insert')
36 if ($bugsys->userinfo
['userid'])
38 $message->error($lang->string('Sorry, you are already registered.'));
41 if (!$bugsys->options
['allownewreg'])
43 $message->error($lang->string('Sorry, we don\'t allow new registrations.'));
46 if ($bugsys->in
['email'] != $bugsys->in
['confirmemail'])
48 $message->items
[] = $lang->string('The emails you entered do not match.');
51 if (!$bugsys->in
['email'])
53 $message->items
[] = $lang->string('The email you specified was blank.');
56 if ($bugsys->in
['password'] != $bugsys->in
['confirmpassword'])
58 $message->items
[] = $lang->string('The passwords you entered did not match.');
61 if (!$bugsys->in
['password'])
63 $message->items
[] = $lang->string('The password you specified was blank.');
66 if (!$bugsys->in
['displayname'])
68 $message->items
[] = $lang->string('The display name you specified was blank.');
71 if (!$funct->is_valid_email($bugsys->in
['email']))
73 $message->items
[] = $lang->string('The specified email is invalid.');
76 if (is_array($db->query_first("SELECT * FROM " . TABLE_PREFIX
. "user WHERE email = '" . $bugsys->in
['email'] . "'")))
78 $message->items
[] = $lang->string('The specified email is already in use.');
81 if (is_array($db->query_first("SELECT * FROM " . TABLE_PREFIX
. "user WHERE displayname = '" . $bugsys->in
['displayname'] . "'")))
83 $message->items
[] = $lang->string('That display name is already in use by another user.');
88 $salt = $funct->rand(15);
90 if ($bugsys->options
['verifyemail'])
96 if ($bugsys->options
['moderatenewusers'])
107 INSERT INTO " . TABLE_PREFIX
. "user
108 (email, displayname, password, salt, authkey, showemail, showcolours, languageid, usergroupid)
110 ('" . $bugsys->in
['email'] . "',
111 '" . $bugsys->in
['displayname'] . "',
112 '" . md5(md5($bugsys->in
['password']) . md5($salt)) . "',
114 '" . $funct->rand() . "',
115 " . intval($bugsys->in
['showemail']) . ",
117 " . intval($bugsys->in
['languageid']) . ",
122 $userid = $db->insert_id();
124 // Verify email address
125 if ($usergroupid == 3)
127 $activationid = $funct->rand(25);
129 $db->query("INSERT INTO " . TABLE_PREFIX
. "useractivation (userid, activator, dateline, usergroupid) VALUES ($userid, '$activationid', " . TIMENOW
. ", 2)");
131 $mail->to
= $bugsys->in
['email'];
132 $mail->subject
= sprintf($lang->string('Welcome to %1$s'), $bugsys->options
['trackertitle']);
133 $mail->body
= sprintf($lang->string('Hi %1$s,
135 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:
137 %3$s/register.php?do=activate&userid=%4$s&activator=%5$s'),
139 $bugsys->in
['displayname'],
140 $bugsys->options
['trackertitle'],
141 $bugsys->options
['trackerurl'],
148 $message->message($lang->string('You now need to activate your account via email.'));
150 else if ($usergroupid == 4 OR $usergroupid == 2)
152 if ($bugsys->options
['sendwelcomemail'])
154 $mail->to
= $bugsys->in
['email'];
155 $mail->subject
= sprintf($lang->string('Welcome to %1$s'), $bugsys->options
['trackertitle']);
156 $mail->body
= sprintf($lang->string('Hi %1$s,
158 Thank you for taking the time to register at %2$s. We look forward to your contributations to making our products better.
160 If you have any questions, please don\'t hesitate to contact the webmaster.'),
161 $bugsys->in
['displayname'],
162 $bugsys->options
['trackertitle']
168 if ($usergroupid == 4)
170 $message->message($lang->string('Your account is pending approval.'));
174 $message->message($lang->string('Thank you for registering. You may now use your account.'));
180 $_REQUEST['do'] = '';
181 $show['errors'] = true
;
182 $message->error_list_process();
186 // ###################################################################
188 if (empty($_REQUEST['do']))
190 if ($bugsys->userinfo
['userid'])
192 $message->error($lang->string('Sorry, you are already registered.'));
195 if (!$bugsys->options
['allownewreg'])
197 $message->error($lang->string('Sorry, we don\'t allow new registrations.'));
200 foreach ($bugsys->datastore
['language'] AS $value => $temp)
202 $label = $temp['title'];
203 $selected = ($value == $bugsys->in
['languageid']);
204 eval('$opts .= "' . $template->fetch('selectoption') . '";');
207 eval('$template->flush("' . $template->fetch('register') . '");');
210 // ###################################################################
212 if ($_REQUEST['do'] == 'activate')
214 if ($useractivation = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "useractivation WHERE userid = " . intval($bugsys->in
['userid']) . " AND activator = '" . $bugsys->in
['activator'] . "'"))
216 $user = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "user WHERE userid = " . intval($bugsys->in
['userid']));
217 $db->query("UPDATE " . TABLE_PREFIX
. "user SET usergroupid = $useractivation[usergroupid] WHERE userid = " . intval($bugsys->in
['userid']));
218 $db->query("DELETE FROM " . TABLE_PREFIX
. "useractivation WHERE userid = " . intval($bugsys->in
['userid']));
220 if ($bugsys->options
['sendwelcomemail'])
222 $mail->to
= $user['email'];
223 $mail->subject
= sprintf($lang->string('Welcome to %1$s'), $bugsys->options
['trackertitle']);
224 $mail->body
= sprintf($lang->string('Hi %1$s,
226 Thank you for taking the time to register at %2$s. We look forward to your contributations to making our products better.
228 If you have any questions, please don\'t hesitate to contact the webmaster.'),
229 $user['displayname'],
230 $bugsys->options
['trackertitle']
235 $message->message($lang->string('Your account is now activated and you can now login.'));
239 $message->error($lang->string('Sorry, we could not match your registration string. Please make sure you entered the correct URL.'));
243 /*=====================================================================*\
244 || ###################################################################
247 || ###################################################################
248 \*=====================================================================*/