]>
src.bluestatic.org Git - bugdar.git/blob - register.php
2 /*=====================================================================*\
3 || ###################################################################
5 || # Copyright (c)2004-2009 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(
27 $focus['user'] = 'focus';
29 require_once('./global.php');
30 require_once('./includes/api_user.php');
32 // ###################################################################
34 if ($_POST['do'] == 'insert')
36 if (bugdar
::$userinfo['userid'])
38 $message->error(T('Sorry, you are already registered.'));
41 if (!bugdar
::$options['allownewreg'])
43 $message->error(T('Sorry, we don\'t allow new registrations.'));
46 if ($input->in
['email'] != $input->in
['confirmemail'])
48 $message->addError(T('The emails you entered do not match.'));
51 if ($input->in
['password'] != $input->in
['confirmpassword'])
53 $message->addError(T('The passwords you entered did not match.'));
56 if (bugdar
::$options['verifyemail'])
62 if (bugdar
::$options['moderatenewusers'])
72 $user = new UserAPI();
73 $user->set('email', $input->in
['email']);
74 $user->set('displayname', $input->in
['displayname']);
75 $user->set('password', $input->in
['password']);
76 $user->set('showemail', $input->in
['showemail']);
77 $user->set('showcolors', 1);
78 $user->set('languageid', $input->in
['languageid']);
79 $user->set('timezone', bugdar
::$options['defaulttimezone']);
80 $user->set('usergroupid', $usergroupid);
82 if (!$message->hasErrors())
86 $userid = $user->insertid
;
88 // Verify email address
89 if ($usergroupid == 3)
91 $activationid = BSFunctions
::random(25);
93 $db->query("INSERT INTO " . TABLE_PREFIX
. "useractivation (userid, activator, dateline, usergroupid) VALUES ($userid, '$activationid', " . TIMENOW
. ", 2)");
95 $email = get_email_text('activate_account');
97 $mail->setSubject($email['subject']);
98 $mail->setBodyText(sprintf($email['bodyText'], $input->in
['displayname'], bugdar
::$options['trackertitle'], bugdar
::$options['trackerurl'], $userid, $activationid));
99 $mail->setFromAddress(MAIL_FROM_ADDRESS
);
100 $mail->setFromName(MAIL_FROM_NAME
);
101 $mail->send($input->in
['email'], $input->in
['displayname']);
103 $message->message(T('You now need to activate your account via email.'));
105 else if ($usergroupid == 4 OR $usergroupid == 2)
107 if (bugdar
::$options['sendwelcomemail'])
109 $displayName = $input->in
['displayname'];
111 $email = get_email_text('welcome');
112 $mail = new BSMail();
113 $mail->setSubject($email['subject']);
114 $mail->setBodyText(sprintf($email['bodyText'], $input->in
['displayname'], bugdar
::$options['trackertitle']));
115 $mail->setFromAddress(MAIL_FROM_ADDRESS
);
116 $mail->setFromName(MAIL_FROM_NAME
);
117 $mail->send($input->in
['email'], $input->in
['displayname']);
120 if ($usergroupid == 4)
122 $message->message(T('Your account is pending approval.'));
126 $message->message(T('Thank you for registering. You may now use your account.'));
132 $_REQUEST['do'] = '';
133 $show['errors'] = true;
137 // ###################################################################
139 if (empty($_REQUEST['do']))
141 if (bugdar
::$userinfo['userid'])
143 $message->error(T('Sorry, you are already registered.'));
146 if (!bugdar
::$options['allownewreg'])
148 $message->error(T('Sorry, we don\'t allow new registrations.'));
151 foreach (bugdar
::$datastore['language'] as $value => $temp)
153 $tpl = new BSTemplate('selectoption');
156 'label' => $temp['title'],
157 'selected' => ($value == $input->in
['languageid'])
159 $opts .= $tpl->evaluate()->getTemplate();
162 $tpl = new BSTemplate('register');
166 $tpl->evaluate()->flush();
169 // ###################################################################
171 if ($_REQUEST['do'] == 'activate')
173 $input->inputClean('userid', TYPE_UINT
);
174 if ($useractivation = $db->queryFirst("SELECT * FROM " . TABLE_PREFIX
. "useractivation WHERE userid = " . $input->in
['userid'] . " AND activator = '" . $input->inputEscape('activator') . "'"))
176 $user = $db->queryFirst("SELECT * FROM " . TABLE_PREFIX
. "user WHERE userid = " . $input->in
['userid']);
177 $db->query("UPDATE " . TABLE_PREFIX
. "user SET usergroupid = $useractivation[usergroupid] WHERE userid = " . $input->in
['userid']);
178 $db->query("DELETE FROM " . TABLE_PREFIX
. "useractivation WHERE userid = " . $input->in
['userid']);
180 if (bugdar
::$options['sendwelcomemail'])
182 $displayName = $user['displayname'];
184 $email = get_email_text('welcome');
185 $mail = new BSMail();
186 $mail->setSubject($email['subject']);
187 $mail->setBodyText(sprintf($email['bodyText'], $user['displayname'], bugdar
::$options['trackertitle']));
188 $mail->setFromAddress(MAIL_FROM_ADDRESS
);
189 $mail->setFromName(MAIL_FROM_NAME
);
190 $mail->send($user['email'], $user['displayname']);
193 $message->message(T('Your account is now activated and you can now login.'));
197 $message->error(T('Sorry, we could not match your registration string. Please make sure you entered the correct URL.'));