[2] | 1 | <?php |
---|
[354] | 2 | // +-----------------------------------------------------------------------+ |
---|
[8728] | 3 | // | Piwigo - a PHP based photo gallery | |
---|
[2297] | 4 | // +-----------------------------------------------------------------------+ |
---|
[8728] | 5 | // | Copyright(C) 2008-2011 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 | |
---|
[631] | 40 | $errors = array(); |
---|
[661] | 41 | if (isset($_POST['submit'])) |
---|
[2] | 42 | { |
---|
[7495] | 43 | if (!verify_ephemeral_key(@$_POST['key'])) |
---|
| 44 | { |
---|
| 45 | set_status_header(403); |
---|
| 46 | array_push($errors, 'Invalid/expired form key'); |
---|
| 47 | } |
---|
| 48 | |
---|
[808] | 49 | if ($_POST['password'] != $_POST['password_conf']) |
---|
| 50 | { |
---|
[5021] | 51 | array_push($errors, l10n('please enter your password again')); |
---|
[808] | 52 | } |
---|
[1068] | 53 | |
---|
[808] | 54 | $errors = |
---|
[7495] | 55 | register_user($_POST['login'], |
---|
[808] | 56 | $_POST['password'], |
---|
[1985] | 57 | $_POST['mail_address'], |
---|
[2178] | 58 | true, |
---|
[1985] | 59 | $errors); |
---|
[1068] | 60 | |
---|
[661] | 61 | if (count($errors) == 0) |
---|
[2] | 62 | { |
---|
[902] | 63 | $user_id = get_userid($_POST['login']); |
---|
[2178] | 64 | log_user($user_id, false); |
---|
[1082] | 65 | redirect(make_index_url()); |
---|
[2] | 66 | } |
---|
[7495] | 67 | $registration_post_key = get_ephemeral_key(2); |
---|
[2] | 68 | } |
---|
[7495] | 69 | else |
---|
| 70 | { |
---|
| 71 | $registration_post_key = get_ephemeral_key(6); |
---|
| 72 | } |
---|
[365] | 73 | |
---|
[7495] | 74 | $login = !empty($_POST['login'])?htmlspecialchars(stripslashes($_POST['login'])):''; |
---|
| 75 | $email = !empty($_POST['mail_address'])?htmlspecialchars(stripslashes($_POST['mail_address'])):''; |
---|
[365] | 76 | |
---|
[2] | 77 | //----------------------------------------------------- template initialization |
---|
[345] | 78 | // |
---|
| 79 | // Start output of page |
---|
| 80 | // |
---|
[2268] | 81 | $title= l10n('Registration'); |
---|
[850] | 82 | $page['body_id'] = 'theRegisterPage'; |
---|
[345] | 83 | |
---|
[365] | 84 | $template->set_filenames( array('register'=>'register.tpl') ); |
---|
[2247] | 85 | $template->assign(array( |
---|
[1082] | 86 | 'U_HOME' => make_index_url(), |
---|
[7495] | 87 | 'F_KEY' => $registration_post_key, |
---|
[1004] | 88 | 'F_ACTION' => 'register.php', |
---|
[7495] | 89 | 'F_LOGIN' => $login, |
---|
[12610] | 90 | 'F_EMAIL' => $email, |
---|
| 91 | 'obligatory_user_mail_address' => $conf['obligatory_user_mail_address'], |
---|
[365] | 92 | )); |
---|
| 93 | |
---|
[2] | 94 | //-------------------------------------------------------------- errors display |
---|
[2247] | 95 | if (count($errors) != 0) |
---|
[2] | 96 | { |
---|
[2247] | 97 | $template->assign('errors', $errors); |
---|
[2] | 98 | } |
---|
[365] | 99 | |
---|
[10812] | 100 | // include menubar |
---|
| 101 | $themeconf = $template->get_template_vars('themeconf'); |
---|
[10824] | 102 | if (!isset($themeconf['hide_menu_on']) OR !in_array('theRegisterPage', $themeconf['hide_menu_on'])) |
---|
[10812] | 103 | { |
---|
| 104 | include( PHPWG_ROOT_PATH.'include/menubar.inc.php'); |
---|
| 105 | } |
---|
| 106 | |
---|
| 107 | include(PHPWG_ROOT_PATH.'include/page_header.php'); |
---|
[688] | 108 | $template->parse('register'); |
---|
[369] | 109 | include(PHPWG_ROOT_PATH.'include/page_tail.php'); |
---|
[362] | 110 | ?> |
---|