r303: Added SVN constant to user files; now ISSO debug information shows SVN details.
[bugdar.git] / register.php
1 <?php
2 /*=====================================================================*\
3 || ################################################################### ||
4 || # BugStrike [#]version[#]
5 || # --------------------------------------------------------------- # ||
6 || # Copyright ©2002-[#]year[#] by Iris Studios, Inc. All Rights Reserved. # ||
7 || # This file may not be reproduced in any way without permission. # ||
8 || # --------------------------------------------------------------- # ||
9 || # User License Agreement at http://www.iris-studios.com/license/ # ||
10 || ################################################################### ||
11 \*=====================================================================*/
12
13 $fetchtemplates = array(
14 'register'
15 );
16
17 define('SVN', '$Id$');
18
19 require_once('./global.php');
20
21 // ###################################################################
22
23 if ($bugsys->userinfo['userid'])
24 {
25 $message->error('Sorry, you are already registered!');
26 }
27
28 if (!$bugsys->options['allownewreg'])
29 {
30 $message->error('Sorry, we don\'t allow new registrations!');
31 }
32
33 // ###################################################################
34
35 if (empty($_REQUEST['do']))
36 {
37 foreach ($bugsys->datastore['language'] AS $value => $temp)
38 {
39 $label = $temp['title'];
40 eval('$opts .= "' . $template->fetch('selectoption') . '";');
41 }
42
43 eval('$template->flush("' . $template->fetch('register') . '");');
44 }
45
46 // ###################################################################
47
48 if ($_POST['do'] == 'insert')
49 {
50 if ($bugsys->in['email'] != $bugsys->in['confirmemail'])
51 {
52 $error->phrase[] = 'The emails you entered do not match.';
53 }
54
55 if (!$bugsys->in['email'])
56 {
57 $error->phrase[] = 'The password you specified was blank.';
58 }
59
60 if ($bugsys->in['password'] != $bugsys->in['confirmpassword'])
61 {
62 $error->phrase[] = 'The passwords you entered did not match.';
63 }
64
65 if (!$bugsys->in['password'])
66 {
67 $error->phrase[] = 'The password you specified was blank.';
68 }
69
70 if (!$funct->is_valid_email($bugsys->in['email']))
71 {
72 $error->phrase[] = 'The specified email is invalid.';
73 }
74
75 if (is_array($db->query_first("SELECT * FROM " . TABLE_PREFIX . "user WHERE email = '" . $bugsys->in['email'] . "'")))
76 {
77 $error->phrase[] = 'The specified email is already in use.';
78 }
79
80 $message->error_list_process();
81 $message->error();
82
83 $salt = $funct->rand(15);
84
85 if ($bugsys->options['verifyemail'])
86 {
87 $usergroupid = 3;
88 }
89 else
90 {
91 if ($bugsys->options['moderatenewusers'])
92 {
93 $usergroupid = 4;
94 }
95 else
96 {
97 $usergroupid = 2;
98 }
99 }
100
101 $db->query("
102 INSERT INTO " . TABLE_PREFIX . "user
103 (email, displayname, password, salt, authkey, showemail, languageid, usergroupid)
104 VALUES
105 ('" . $bugsys->in['email'] . "',
106 '" . $bugsys->in['displayname'] . "',
107 '" . md5(md5($bugsys->in['password']) . md5($salt)) . "',
108 '$salt',
109 '" . $funct->rand() . "',
110 " . intval($bugsys->in['showemail']) . ",
111 " . intval($bugsys->in['languageid']) . ",
112 $usergroupid
113 )"
114 );
115
116 $userid = $db->insert_id();
117
118 // Verify email address
119 if ($usergroupid == 3)
120 {
121 $activationid = $funct->rand(25);
122
123 $db->query("INSERT INTO " . TABLE_PREFIX . "useractivation (userid, activator, dateline, usergroupid) VALUES ($userid, '$activationid', " . NOW . ", 2)");
124
125 $mail->to = $bugsys->in['email'];
126 $mail->subject = 'Welcome to ' . $bugsys->options['trackertitle'];
127 $mail->body = "Hi " . $bugsys->in['displayname'] . " you need to activate your account: http://devbox/bugtraq/register.php?do=activate&userid=" . $userid . "&activator=" . $activationid;
128 $mail->send();
129
130 $message->message('You now need to activate your account via email.');
131 }
132 else if ($usergroupid == 4 OR $usergroupid == 2)
133 {
134 if ($bugsys->options['sendwelcomemail'])
135 {
136 $mail->to = $bugsys->in['email'];
137 $mail->subject = 'Welcome to ' . $bugsys->options['trackertitle'];
138 $mail->body = "Hi " . $bugsys->in['displayname'] . " and welcome to the " . $bugsys->options['trackertitle'] . " bug tracker! Thanks for registering.";
139 $mail->send();
140 }
141
142 if ($usergroupid == 4)
143 {
144 $message->message('Your account is pending approval.');
145 }
146 else
147 {
148 $message->message('Registration complete!');
149 }
150 }
151 }
152
153 // ###################################################################
154
155 if ($_REQUEST['do'] == 'activate')
156 {
157 if ($useractivation = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "useractivation WHERE userid = " . intval($bugsys->in['userid']) . " AND activator = '" . $bugsys->in['activator'] . "'"))
158 {
159 $db->query("UPDATE " . TABLE_PREFIX . "user SET usergroupid = $useractivation[usergroupid] WHERE userid = " . intval($bugsys->in['userid']));
160 $db->query("DELETE FROM " . TABLE_PREFIX . "useractivation WHERE userid = " . intval($bugsys->in['userid']));
161 $message->message('your account is now activated and you can now login');
162 }
163 else
164 {
165 $message->error('we could not match your registration string. please make sure you entered the correct url');
166 }
167 }
168
169 /*=====================================================================*\
170 || ###################################################################
171 || # $HeadURL$
172 || # $Id$
173 || ###################################################################
174 \*=====================================================================*/
175 ?>