2 /*=====================================================================*\
3 || ###################################################################
4 || # Bugdar [#]version[#]
5 || # Copyright ©2002-[#]year[#] Blue Static
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
');
31 require_once('./includes
/api_user
.php
');
33 require_once('./includes
/class_api_error
.php
');
34 APIError(array(new API_Error_Handler($message), 'user_cumulative
'));
36 // ###################################################################
38 if ($_POST['do'] == 'insert
')
40 if ($bugsys->userinfo['userid
'])
42 $message->error($lang->string('Sorry
, you are already registered
.'));
45 if (!$bugsys->options['allownewreg
'])
47 $message->error($lang->string('Sorry
, we don\'t allow
new registrations
.'));
50 if ($bugsys->in['email
'] != $bugsys->in['confirmemail
'])
52 $message->add_error($lang->string('The emails you entered
do not match
.'));
55 if ($bugsys->in['password
'] != $bugsys->in['confirmpassword
'])
57 $message->add_error($lang->string('The passwords you entered did not match
.'));
62 $salt = $funct->rand(15);
64 if ($bugsys->options['verifyemail
'])
70 if ($bugsys->options['moderatenewusers
'])
80 $user = new UserAPI($bugsys);
81 $user->set('email
', $bugsys->in['email
']);
82 $user->set('displayname
', $bugsys->in['displayname
']);
83 $user->set('password
', $bugsys->in['password
']);
84 $user->set('showemail
', $bugsys->in['showemail
']);
85 $user->set('showcolours
', 1);
86 $user->set('languageid
', $bugsys->in['languageid
']);
87 $user->set('usergroupid
', $usergroupid);
90 $userid = $user->insertid;
92 // Verify email address
93 if ($usergroupid == 3)
95 $activationid = $funct->rand(25);
97 $db->query("INSERT INTO " . TABLE_PREFIX . "useractivation (userid, activator, dateline, usergroupid) VALUES ($userid, '$activationid', " . TIMENOW . ", 2)");
99 $mail->to = $bugsys->in['email'];
100 $mail->subject = sprintf($lang->string('Welcome to %1$s'), $bugsys->options['trackertitle']);
101 $mail->body = sprintf($lang->string('Hi %1$s,
103 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:
105 %3$s/register.php?do=activate&userid=%4$s&activator=%5$s'),
107 $bugsys->in['displayname'],
108 $bugsys->options['trackertitle'],
109 $bugsys->options['trackerurl'],
116 $message->message($lang->string('You now need to activate your account via email.'));
118 else if ($usergroupid == 4 OR $usergroupid == 2)
120 if ($bugsys->options['sendwelcomemail'])
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 Thank you for taking the time to register at %2$s. We look forward to your contributations to making our products better.
128 If you have any questions, please don\'t hesitate to contact the webmaster.'),
129 $bugsys->in['displayname'],
130 $bugsys->options['trackertitle']
136 if ($usergroupid == 4)
138 $message->message($lang->string('Your account is pending approval.'));
142 $message->message($lang->string('Thank you for registering. You may now use your account.'));
148 $_REQUEST['do'] = '';
149 $show['errors'] = true;
150 $message->error_list_process();
154 // ###################################################################
156 if (empty($_REQUEST['do']))
158 if ($bugsys->userinfo['userid'])
160 $message->error($lang->string('Sorry, you are already registered.'));
163 if (!$bugsys->options['allownewreg'])
165 $message->error($lang->string('Sorry, we don\'t allow new registrations.'));
168 foreach ($bugsys->datastore['language'] AS $value => $temp)
170 $label = $temp['title'];
171 $selected = ($value == $bugsys->in['languageid']);
172 eval('$opts .= "' . $template->fetch('selectoption
') . '";');
175 eval('$template->flush("' . $template->fetch('register
') . '");');
178 // ###################################################################
180 if ($_REQUEST['do'] == 'activate')
182 $bugsys->input_clean('userid', TYPE_UINT);
183 if ($useractivation = $db->query_first("SELECT
* FROM
" . TABLE_PREFIX . "useractivation WHERE userid
= " . $bugsys->in['userid'] . " AND activator
= '" . $bugsys->in['activator
'] . "'"))
185 $user = $db->query_first("SELECT
* FROM
" . TABLE_PREFIX . "user WHERE userid
= " . $bugsys->in['userid']);
186 $db->query("UPDATE
" . TABLE_PREFIX . "user SET usergroupid
= $useractivation[usergroupid
] WHERE userid
= " . $bugsys->in['userid']);
187 $db->query("DELETE FROM
" . TABLE_PREFIX . "useractivation WHERE userid
= " . $bugsys->in['userid']);
189 if ($bugsys->options['sendwelcomemail'])
191 $mail->to = $user['email'];
192 $mail->subject = sprintf($lang->string('Welcome to %1$s'), $bugsys->options['trackertitle']);
193 $mail->body = sprintf($lang->string('Hi %1$s,
195 Thank you for taking the time to register at %2$s. We look forward to your contributations to making our products better.
197 If you have any questions, please don\'t hesitate to contact the webmaster.'),
198 $user['displayname'],
199 $bugsys->options['trackertitle']
204 $message->message($lang->string('Your account is now activated and you can now login.'));
208 $message->error($lang->string('Sorry, we could not match your registration string. Please make sure you entered the correct URL.'));
212 /*=====================================================================*\
213 || ###################################################################
216 || ###################################################################
217 \*=====================================================================*/