]> src.bluestatic.org Git - bugdar.git/blob - register.php
We were hitting an infinite loop with isso_pre_parse_hook
[bugdar.git] / register.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Bugdar
5 || # Copyright ©2002-2007 Blue Static
6 || #
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.
10 || #
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
14 || # more details.
15 || #
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 \*=====================================================================*/
21
22 $fetchtemplates = array(
23 'register'
24 );
25
26 define('SVN', '$Id$');
27
28 $focus['user'] = 'focus';
29
30 require_once('./global.php');
31 require_once('./includes/api_user.php');
32
33 require_once('./includes/class_api_error.php');
34 APIError(array(new API_Error_Handler($message), 'user_cumulative'));
35
36 // ###################################################################
37
38 if ($_POST['do'] == 'insert')
39 {
40 if (bugdar::$userinfo['userid'])
41 {
42 $message->error(T('Sorry, you are already registered.'));
43 }
44
45 if (!bugdar::$options['allownewreg'])
46 {
47 $message->error(T('Sorry, we don\'t allow new registrations.'));
48 }
49
50 if ($bugsys->in['email'] != $bugsys->in['confirmemail'])
51 {
52 $message->addError(T('The emails you entered do not match.'));
53 }
54
55 if ($bugsys->in['password'] != $bugsys->in['confirmpassword'])
56 {
57 $message->addError(T('The passwords you entered did not match.'));
58 }
59
60 if (bugdar::$options['verifyemail'])
61 {
62 $usergroupid = 3;
63 }
64 else
65 {
66 if (bugdar::$options['moderatenewusers'])
67 {
68 $usergroupid = 4;
69 }
70 else
71 {
72 $usergroupid = 2;
73 }
74 }
75
76 $user = new UserAPI($bugsys);
77 $user->set('email', $bugsys->in['email']);
78 $user->set('displayname', $bugsys->in['displayname']);
79 $user->set('password', $bugsys->in['password']);
80 $user->set('showemail', $bugsys->in['showemail']);
81 $user->set('showcolors', 1);
82 $user->set('languageid', $bugsys->in['languageid']);
83 $user->set('timezone', bugdar::$options['defaulttimezone']);
84 $user->set('usergroupid', $usergroupid);
85
86 if (!$message->hasErrors())
87 {
88 $user->insert();
89
90 $userid = $user->insertid;
91
92 // Verify email address
93 if ($usergroupid == 3)
94 {
95 $activationid = BSFunctions::random(25);
96
97 $db->query("INSERT INTO " . TABLE_PREFIX . "useractivation (userid, activator, dateline, usergroupid) VALUES ($userid, '$activationid', " . TIMENOW . ", 2)");
98
99 eval('$email = "' . $template->fetch(FetchEmailPath('activateaccount.xml', bugdar::$datastore['language'][$bugsys->in['languageid']]['langcode'])) . '";');
100 $email = $bugsys->xml->parse($email);
101 $mail->setSubject($email['email']['subject']['value']);
102 $mail->setBodyText($email['email']['bodyText']['value']);
103
104 $mail->send($bugsys->in['email'], $bugsys->in['displayname']);
105
106 $message->message(T('You now need to activate your account via email.'));
107 }
108 else if ($usergroupid == 4 OR $usergroupid == 2)
109 {
110 if (bugdar::$options['sendwelcomemail'])
111 {
112 $displayName = $bugsys->in['displayname'];
113 eval('$email = "' . $template->fetch(FetchEmailPath('welcome.xml', bugdar::$datastore['language'][$bugsys->in['languageid']]['langcode'])) . '";');
114 $email = $bugsys->xml->parse($email);
115 $mail->setSubject($email['email']['subject']['value']);
116 $mail->setBodyText($email['email']['bodyText']['value']);
117 $mail->send($bugsys->in['email'], $bugsys->in['displayname']);
118 }
119
120 if ($usergroupid == 4)
121 {
122 $message->message(T('Your account is pending approval.'));
123 }
124 else
125 {
126 $message->message(T('Thank you for registering. You may now use your account.'));
127 }
128 }
129 }
130 else
131 {
132 $_REQUEST['do'] = '';
133 $show['errors'] = true;
134 }
135 }
136
137 // ###################################################################
138
139 if (empty($_REQUEST['do']))
140 {
141 if (bugdar::$userinfo['userid'])
142 {
143 $message->error(T('Sorry, you are already registered.'));
144 }
145
146 if (!bugdar::$options['allownewreg'])
147 {
148 $message->error(T('Sorry, we don\'t allow new registrations.'));
149 }
150
151 foreach (bugdar::$datastore['language'] AS $value => $temp)
152 {
153 $label = $temp['title'];
154 $selected = ($value == $bugsys->in['languageid']);
155 eval('$opts .= "' . $template->fetch('selectoption') . '";');
156 }
157
158 eval('$template->flush("' . $template->fetch('register') . '");');
159 }
160
161 // ###################################################################
162
163 if ($_REQUEST['do'] == 'activate')
164 {
165 $bugsys->input_clean('userid', TYPE_UINT);
166 if ($useractivation = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "useractivation WHERE userid = " . $bugsys->in['userid'] . " AND activator = '" . $bugsys->input_escape('activator') . "'"))
167 {
168 $user = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "user WHERE userid = " . $bugsys->in['userid']);
169 $db->query("UPDATE " . TABLE_PREFIX . "user SET usergroupid = $useractivation[usergroupid] WHERE userid = " . $bugsys->in['userid']);
170 $db->query("DELETE FROM " . TABLE_PREFIX . "useractivation WHERE userid = " . $bugsys->in['userid']);
171
172 if (bugdar::$options['sendwelcomemail'])
173 {
174 $displayName = $user['displayname'];
175 eval('$email = "' . $template->fetch(FetchEmailPath('welcome.xml', bugdar::$datastore['language'][$user['languageid']]['langcode'])) . '";');
176 $email = $bugsys->xml->parse($email);
177 $mail->setSubject($email['email']['subject']['value']);
178 $mail->setBodyText($email['email']['bodyText']['value']);
179 $mail->send($user['email'], $user['displayname']);
180 }
181
182 $message->message(T('Your account is now activated and you can now login.'));
183 }
184 else
185 {
186 $message->error(T('Sorry, we could not match your registration string. Please make sure you entered the correct URL.'));
187 }
188 }
189
190 /*=====================================================================*\
191 || ###################################################################
192 || # $HeadURL$
193 || # $Id$
194 || ###################################################################
195 \*=====================================================================*/
196 ?>