2 /*=====================================================================*\
3 || ###################################################################
5 || # Copyright ©2002-2007 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 2 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 // ###################################################################
35 if ($_POST['do'] == 'insert')
37 if (bugdar
::$userinfo['userid'])
39 $message->error(T('Sorry, you are already registered.'));
42 if (!bugdar
::$options['allownewreg'])
44 $message->error(T('Sorry, we don\'t allow new registrations.'));
47 if ($input->in
['email'] != $input->in
['confirmemail'])
49 $message->addError(T('The emails you entered do not match.'));
52 if ($input->in
['password'] != $input->in
['confirmpassword'])
54 $message->addError(T('The passwords you entered did not match.'));
57 if (bugdar
::$options['verifyemail'])
63 if (bugdar
::$options['moderatenewusers'])
73 $user = new UserAPI();
74 $user->set('email', $input->in
['email']);
75 $user->set('displayname', $input->in
['displayname']);
76 $user->set('password', $input->in
['password']);
77 $user->set('showemail', $input->in
['showemail']);
78 $user->set('showcolors', 1);
79 $user->set('languageid', $input->in
['languageid']);
80 $user->set('timezone', bugdar
::$options['defaulttimezone']);
81 $user->set('usergroupid', $usergroupid);
83 if (!$message->hasErrors())
87 $userid = $user->insertid
;
89 // Verify email address
90 if ($usergroupid == 3)
92 $activationid = BSFunctions
::random(25);
94 $db->query("INSERT INTO " . TABLE_PREFIX
. "useractivation (userid, activator, dateline, usergroupid) VALUES ($userid, '$activationid', " . TIMENOW
. ", 2)");
96 $email = get_email_text('activate_account');
98 $mail->setSubject($email['subject']);
99 $mail->setBodyText(sprintf($email['bodyText'], $input->in
['displayname'], bugdar
::$options['trackertitle'], bugdar
::$options['trackerurl'], $userid, $activationid));
100 $mail->setFromAddress(MAIL_FROM_ADDRESS
);
101 $mail->setFromName(MAIL_FROM_NAME
);
102 $mail->send($input->in
['email'], $input->in
['displayname']);
104 $message->message(T('You now need to activate your account via email.'));
106 else if ($usergroupid == 4 OR $usergroupid == 2)
108 if (bugdar
::$options['sendwelcomemail'])
110 $displayName = $input->in
['displayname'];
112 $email = get_email_text('welcome');
113 $mail = new BSMail();
114 $mail->setSubject($email['subject']);
115 $mail->setBodyText(sprintf($email['bodyText'], $input->in
['displayname'], bugdar
::$options['trackertitle']));
116 $mail->setFromAddress(MAIL_FROM_ADDRESS
);
117 $mail->setFromName(MAIL_FROM_NAME
);
118 $mail->send($input->in
['email'], $input->in
['displayname']);
121 if ($usergroupid == 4)
123 $message->message(T('Your account is pending approval.'));
127 $message->message(T('Thank you for registering. You may now use your account.'));
133 $_REQUEST['do'] = '';
134 $show['errors'] = true
;
138 // ###################################################################
140 if (empty($_REQUEST['do']))
142 if (bugdar
::$userinfo['userid'])
144 $message->error(T('Sorry, you are already registered.'));
147 if (!bugdar
::$options['allownewreg'])
149 $message->error(T('Sorry, we don\'t allow new registrations.'));
152 foreach (bugdar
::$datastore['language'] as $value => $temp)
154 $tpl = new BSTemplate('selectoption');
157 'label' => $temp['title'],
158 'selected' => ($value == $input->in
['languageid'])
160 $opts .= $tpl->evaluate()->getTemplate();
163 $tpl = new BSTemplate('register');
167 $tpl->evaluate()->flush();
170 // ###################################################################
172 if ($_REQUEST['do'] == 'activate')
174 $input->inputClean('userid', TYPE_UINT
);
175 if ($useractivation = $db->queryFirst("SELECT * FROM " . TABLE_PREFIX
. "useractivation WHERE userid = " . $input->in
['userid'] . " AND activator = '" . $input->inputEscape('activator') . "'"))
177 $user = $db->queryFirst("SELECT * FROM " . TABLE_PREFIX
. "user WHERE userid = " . $input->in
['userid']);
178 $db->query("UPDATE " . TABLE_PREFIX
. "user SET usergroupid = $useractivation[usergroupid] WHERE userid = " . $input->in
['userid']);
179 $db->query("DELETE FROM " . TABLE_PREFIX
. "useractivation WHERE userid = " . $input->in
['userid']);
181 if (bugdar
::$options['sendwelcomemail'])
183 $displayName = $user['displayname'];
185 $email = get_email_text('welcome');
186 $mail = new BSMail();
187 $mail->setSubject($email['subject']);
188 $mail->setBodyText(sprintf($email['bodyText'], $user['displayname'], bugdar
::$options['trackertitle']));
189 $mail->setFromAddress(MAIL_FROM_ADDRESS
);
190 $mail->setFromName(MAIL_FROM_NAME
);
191 $mail->send($user['email'], $user['displayname']);
194 $message->message(T('Your account is now activated and you can now login.'));
198 $message->error(T('Sorry, we could not match your registration string. Please make sure you entered the correct URL.'));
202 /*=====================================================================*\
203 || ###################################################################
206 || ###################################################################
207 \*=====================================================================*/