3 * Register new account page
5 * Copyright 1999-2001 (c) VA Linux Systems
6 * Copyright 2010 (c) FusionForge Team
7 * Copyright (C) 2011 Alain Peyrat - Alcatel-Lucent
8 * Copyright 2013, Franck Villaume - TrivialDev
10 * This file is part of FusionForge. FusionForge is free software;
11 * you can redistribute it and/or modify it under the terms of the
12 * GNU General Public License as published by the Free Software
13 * Foundation; either version 2 of the Licence, or (at your option)
16 * FusionForge is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License along
22 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 require_once '../env.inc.php';
27 require_once $gfcommon.'include/pre.php';
28 require_once $gfcommon.'include/account.php';
29 require_once $gfcommon.'include/timezones.php';
31 if (forge_get_config ('user_registration_restricted')) {
32 session_require_global_perm ('forge_admin');
35 $unix_name = getStringFromRequest('unix_name');
36 $firstname = getStringFromRequest('firstname');
37 $lastname = getStringFromRequest('lastname');
38 $password1 = getStringFromRequest('password1');
39 $password2 = getStringFromRequest('password2');
40 $email = getStringFromRequest('email');
41 $mail_site = getIntFromRequest('mail_site');
42 $mail_va = getIntFromRequest('mail_va');
44 $language_id = getIntFromRequest('language_id');
45 $timezone = getStringFromRequest('timezone');
46 $theme_id = getIntFromRequest('theme_id');
47 $address = getStringFromRequest('address');
48 $address2 = getStringFromRequest('address2');
49 $phone = getStringFromRequest('phone');
50 $fax = getStringFromRequest('fax');
51 $title = getStringFromRequest('title');
52 $ccode = getStringFromRequest('ccode');
53 $accept_conditions = getIntFromRequest ('accept_conditions');
55 if (forge_get_config('use_ssl') && !session_issecure()) {
56 //force use of SSL for login
57 header('Location: https://'.getStringFromServer('HTTP_HOST').getStringFromServer('REQUEST_URI'));
60 if (!$theme_id || !is_numeric($theme_id)) {
61 $theme_id=$HTML->getThemeIdFromName(forge_get_config('default_theme'));
64 if (getStringFromRequest('submit')) {
66 Adding call to library rather than
67 logic that used to be coded in this page
69 if (!form_key_is_valid(getStringFromRequest('form_key'))) {
70 exit_form_double_submit('my');
74 if (forge_get_config('user_registration_accept_conditions') && ! $accept_conditions) {
75 $warning_msg = _("You can't register an account unless you accept the terms of use.");
78 if (!forge_check_global_perm('forge_admin')) {
79 $params['valide'] =& $valide;
80 $params['warning_msg'] =& $warning_msg;
81 plugin_hook('captcha_check', $params);
85 $activate_immediately = getIntFromRequest('activate_immediately');
86 if (($activate_immediately == 1) &&
87 forge_check_global_perm ('forge_admin')) {
89 $activate_immediately = true;
92 $activate_immediately = false;
95 $new_user = new GFUser();
96 $register = $new_user->create($unix_name,$firstname,$lastname,$password1,$password2,
97 $email,$mail_site,$mail_va,$language_id,$timezone,'',0,$theme_id,'',
98 $address,$address2,$phone,$fax,$title,$ccode,$send_mail);
100 site_header(array('title'=>_('Register Confirmation')));
102 if ($activate_immediately) {
103 if (!$new_user->setStatus('A')) {
104 print '<span class="error">' .
105 _('Error during user activation but after user registration (user is now in pending state and will not get a notification eMail!)') .
107 print '<p>' . sprintf(_("Could not activate newly registered user's forge account: %s"), htmlspecialchars($new_user->getErrorMessage())) . '</p>';
108 $HTML->footer(array());
114 printf(_('You have registered the %1$s account on %2$s.'),
115 $new_user->getUnixName(),
116 forge_get_config ('forge_name'));
118 print '<p>' . _('A confirmation email is being sent to verify the submitted email address. Visiting the link sent in this email will activate the account.') . '</p>';
121 printf (_('You have registered and activated user %1$s on %2$s. They will not receive an eMail about this fact.'), $unix_name, forge_get_config('forge_name'));
124 site_footer(array());
127 $error_msg = $new_user->getErrorMessage();
128 if (isset($register_error)) {
129 $error_msg .= ' '.$register_error;
135 if (!isset($timezone) || empty($timezone) || !preg_match('/^[-a-zA-Z0-9_\/\.+]+$/', $timezone)) {
136 $timezone = forge_get_config('default_timezone') ? forge_get_config('default_timezone') : 'GMT' ;
138 if (!isset($ccode) || empty($ccode) || !preg_match('/^[a-zA-Z]{2}$/', $ccode)) {
139 $ccode = forge_get_config('default_country_code');
142 site_header(array('title'=>_('User Account Registration')));
145 <form action="<?php echo util_make_url('/account/register.php'); ?>" method="post">
146 <input type="hidden" name="form_key" value="<?php echo form_generate_key(); ?>"/>
149 if (forge_get_config('require_unique_email')) {
150 echo _('Login Name (no uppercase letters; leave empty to have it generated automatically):');
152 echo _('Login Name (do not use uppercase letters):'); echo utils_requiredField();
154 <label for="unix_name">
155 <input id="unix_name" type="text" required="required" name="unix_name" value="<?php print(htmlspecialchars($unix_name)); ?>"/>
159 <?php echo _('Password (min. 6 chars):'); echo utils_requiredField(); ?><br />
160 <label for="password1">
161 <input id="password1" type="password" required="required" name="password1"/>
165 <?php echo _('Password (repeat):'); echo utils_requiredField(); ?><br />
166 <label for="password2">
167 <input id="password2" type="password" required="required" name="password2"/>
171 <?php echo _('Title')._(':'); ?><br />
173 <input id="title" type="text" name="title" value="<?php echo htmlspecialchars($title); ?>" size="10"/>
177 <?php echo _('First Name:'); echo utils_requiredField(); ?><br />
178 <label for="firstname">
179 <input id="firstname" required="required" size="30" type="text" name="firstname"
180 value="<?php print(htmlspecialchars($firstname)); ?>"/>
184 <?php echo _('Last Name:'); echo utils_requiredField(); ?><br />
185 <label for="lastname">
186 <input id="lastname" required="required" size="30" type="text" name="lastname"
187 value="<?php print(htmlspecialchars($lastname)); ?>"/>
191 <?php echo _('Language Choice:'); ?><br />
192 <?php echo html_get_language_popup ('language_id', language_name_to_lang_id (choose_language_from_context ())); ?>
195 <?php echo _('Timezone:'); ?><br />
196 <?php echo html_get_timezone_popup('timezone', $timezone); ?>
199 $toDisplay = html_get_theme_popup('theme_id', $theme_id);
200 if($toDisplay != "") {
203 <?php echo _('Theme'); ?><br />
204 <?php echo $toDisplay; ?>
208 <?php echo _('Country:'); ?><br />
209 <?php echo html_get_ccode_popup('ccode', $ccode); ?>
213 echo _('Email Address') . _(': ') . utils_requiredField() . "<br />\n<em>";
214 printf(_('This email address will be verified before account activation. You will receive a mail forward account at <loginname@%1$s> that will forward to this address.'), forge_get_config('users_host')); ?></em>
215 <br /><label for="email">
216 <input id="email" size="40" type="text" name="email" required="required" value="<?php print(htmlspecialchars($email)); ?>"/>
220 <?php echo _('Address')._(':'); ?><br />
221 <label for="address">
222 <input id="address" type="text" name="address" value="<?php echo htmlspecialchars($address); ?>" size="80"/>
226 <?php echo _('Address (continued)')._(':'); ?><br />
227 <label for="address2">
228 <input id="address2" type="text" name="address2" value="<?php echo htmlspecialchars($address2); ?>" size="80"/>
232 <?php echo _('Phone')._(':'); ?><br />
234 <input id="phone" type="text" name="phone" value="<?php echo htmlspecialchars($phone); ?>" size="20"/>
238 <?php echo _('Fax')._(':'); ?><br />
240 <input id="fax" type="text" name="fax" value="<?php echo htmlspecialchars($fax); ?>" size="20"/>
244 <label for="mail_site">
245 <input id="mail_site" type="checkbox" name="mail_site" value="1" checked="checked"/>
247 <?php echo _('Receive Email about Site Updates <em>(Very low traffic and includes security notices. Highly Recommended.)</em>'); ?>
250 <label for="mail_va">
251 <input id="mail_va" type="checkbox" name="mail_va" value="1"/>
253 <?php echo _('Receive additional community mailings. <em>(Low traffic.)</em>'); ?>
255 <?php if (forge_get_config('user_registration_accept_conditions')) { ?>
257 <input type="checkbox" name="accept_conditions" value="1" />
258 <?php printf (_('Do you accept the <a href="%1$s">terms of use</a> for this site?'),
259 util_make_url ('/terms.php')); ?>
262 <?php if (forge_check_global_perm('forge_admin')) { ?>
263 <p><input type="checkbox" name="activate_immediately" value="1" />
264 <?php print _('Activate this user immediately') ; ?>
267 plugin_hook('captcha_form');
272 <?php printf(_('Fields marked with %s are mandatory.'), utils_requiredField()); ?>
275 <input type="submit" name="submit" value="<?php echo _('Register'); ?>" />
278 <p><a href="pending-resend.php"><?php echo _('Resend confirmation email to a pending account'); ?></a></p>
280 <?php site_footer(array());
284 // c-file-style: "bsd"