[2] | 1 | <?php |
---|
[354] | 2 | // +-----------------------------------------------------------------------+ |
---|
[8728] | 3 | // | Piwigo - a PHP based photo gallery | |
---|
[2297] | 4 | // +-----------------------------------------------------------------------+ |
---|
[26461] | 5 | // | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org | |
---|
[2297] | 6 | // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net | |
---|
| 7 | // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick | |
---|
| 8 | // +-----------------------------------------------------------------------+ |
---|
| 9 | // | This program is free software; you can redistribute it and/or modify | |
---|
| 10 | // | it under the terms of the GNU General Public License as published by | |
---|
| 11 | // | the Free Software Foundation | |
---|
| 12 | // | | |
---|
| 13 | // | This program is distributed in the hope that it will be useful, but | |
---|
| 14 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
| 15 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
| 16 | // | General Public License for more details. | |
---|
| 17 | // | | |
---|
| 18 | // | You should have received a copy of the GNU General Public License | |
---|
| 19 | // | along with this program; if not, write to the Free Software | |
---|
| 20 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
| 21 | // | USA. | |
---|
| 22 | // +-----------------------------------------------------------------------+ |
---|
[2] | 23 | |
---|
[345] | 24 | //----------------------------------------------------------- include |
---|
[364] | 25 | define('PHPWG_ROOT_PATH','./'); |
---|
[365] | 26 | include_once( PHPWG_ROOT_PATH.'include/common.inc.php' ); |
---|
[1851] | 27 | |
---|
| 28 | // +-----------------------------------------------------------------------+ |
---|
| 29 | // | Check Access and exit when user status is not ok | |
---|
| 30 | // +-----------------------------------------------------------------------+ |
---|
[2325] | 31 | check_status(ACCESS_FREE); |
---|
[1851] | 32 | |
---|
[2] | 33 | //----------------------------------------------------------- user registration |
---|
[1652] | 34 | |
---|
| 35 | if (!$conf['allow_user_registration']) |
---|
| 36 | { |
---|
| 37 | page_forbidden('User registration closed'); |
---|
| 38 | } |
---|
| 39 | |
---|
[28587] | 40 | trigger_notify('loc_begin_register'); |
---|
[18063] | 41 | |
---|
[661] | 42 | if (isset($_POST['submit'])) |
---|
[2] | 43 | { |
---|
[7495] | 44 | if (!verify_ephemeral_key(@$_POST['key'])) |
---|
| 45 | { |
---|
| 46 | set_status_header(403); |
---|
[25018] | 47 | $page['errors'][] = l10n('Invalid/expired form key'); |
---|
[7495] | 48 | } |
---|
| 49 | |
---|
[25121] | 50 | if(empty($_POST['password'])) |
---|
[808] | 51 | { |
---|
[25121] | 52 | $page['errors'][] = l10n('Password is missing. Please enter the password.'); |
---|
[808] | 53 | } |
---|
[25121] | 54 | else if(empty($_POST['password_conf'])) |
---|
| 55 | { |
---|
| 56 | $page['errors'][] = l10n('Password confirmation is missing. Please confirm the chosen password.'); |
---|
| 57 | } |
---|
| 58 | else if ($_POST['password'] != $_POST['password_conf']) |
---|
| 59 | { |
---|
| 60 | $page['errors'][] = l10n('The passwords do not match'); |
---|
| 61 | } |
---|
[1068] | 62 | |
---|
[25237] | 63 | register_user( |
---|
| 64 | $_POST['login'], |
---|
| 65 | $_POST['password'], |
---|
| 66 | $_POST['mail_address'], |
---|
| 67 | true, |
---|
| 68 | $page['errors'], |
---|
| 69 | isset($_POST['send_password_by_mail']) |
---|
| 70 | ); |
---|
[1068] | 71 | |
---|
[12764] | 72 | if (count($page['errors']) == 0) |
---|
[2] | 73 | { |
---|
[12883] | 74 | // email notification |
---|
[25237] | 75 | if (isset($_POST['send_password_by_mail']) and email_check_format($_POST['mail_address'])) |
---|
[12885] | 76 | { |
---|
[12886] | 77 | $_SESSION['page_infos'][] = l10n('Successfully registered, you will soon receive an email with your connection settings. Welcome!'); |
---|
[12885] | 78 | } |
---|
[12883] | 79 | |
---|
| 80 | // log user and redirect |
---|
[902] | 81 | $user_id = get_userid($_POST['login']); |
---|
[2178] | 82 | log_user($user_id, false); |
---|
[1082] | 83 | redirect(make_index_url()); |
---|
[2] | 84 | } |
---|
[7495] | 85 | $registration_post_key = get_ephemeral_key(2); |
---|
[2] | 86 | } |
---|
[7495] | 87 | else |
---|
| 88 | { |
---|
| 89 | $registration_post_key = get_ephemeral_key(6); |
---|
| 90 | } |
---|
[365] | 91 | |
---|
[7495] | 92 | $login = !empty($_POST['login'])?htmlspecialchars(stripslashes($_POST['login'])):''; |
---|
| 93 | $email = !empty($_POST['mail_address'])?htmlspecialchars(stripslashes($_POST['mail_address'])):''; |
---|
[365] | 94 | |
---|
[2] | 95 | //----------------------------------------------------- template initialization |
---|
[345] | 96 | // |
---|
| 97 | // Start output of page |
---|
| 98 | // |
---|
[2268] | 99 | $title= l10n('Registration'); |
---|
[850] | 100 | $page['body_id'] = 'theRegisterPage'; |
---|
[345] | 101 | |
---|
[365] | 102 | $template->set_filenames( array('register'=>'register.tpl') ); |
---|
[2247] | 103 | $template->assign(array( |
---|
[1082] | 104 | 'U_HOME' => make_index_url(), |
---|
[7495] | 105 | 'F_KEY' => $registration_post_key, |
---|
[1004] | 106 | 'F_ACTION' => 'register.php', |
---|
[7495] | 107 | 'F_LOGIN' => $login, |
---|
[12610] | 108 | 'F_EMAIL' => $email, |
---|
| 109 | 'obligatory_user_mail_address' => $conf['obligatory_user_mail_address'], |
---|
[365] | 110 | )); |
---|
| 111 | |
---|
[10812] | 112 | // include menubar |
---|
| 113 | $themeconf = $template->get_template_vars('themeconf'); |
---|
[10824] | 114 | if (!isset($themeconf['hide_menu_on']) OR !in_array('theRegisterPage', $themeconf['hide_menu_on'])) |
---|
[10812] | 115 | { |
---|
| 116 | include( PHPWG_ROOT_PATH.'include/menubar.inc.php'); |
---|
| 117 | } |
---|
| 118 | |
---|
| 119 | include(PHPWG_ROOT_PATH.'include/page_header.php'); |
---|
[28587] | 120 | trigger_notify('loc_end_register'); |
---|
[20609] | 121 | flush_page_messages(); |
---|
[688] | 122 | $template->parse('register'); |
---|
[369] | 123 | include(PHPWG_ROOT_PATH.'include/page_tail.php'); |
---|
[362] | 124 | ?> |
---|