[2] | 1 | <?php |
---|
[354] | 2 | // +-----------------------------------------------------------------------+ |
---|
[8728] | 3 | // | Piwigo - a PHP based photo gallery | |
---|
[2297] | 4 | // +-----------------------------------------------------------------------+ |
---|
[12922] | 5 | // | Copyright(C) 2008-2012 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 | |
---|
[18063] | 40 | trigger_action('loc_begin_register'); |
---|
| 41 | |
---|
[661] | 42 | if (isset($_POST['submit'])) |
---|
[2] | 43 | { |
---|
[7495] | 44 | if (!verify_ephemeral_key(@$_POST['key'])) |
---|
| 45 | { |
---|
| 46 | set_status_header(403); |
---|
[12764] | 47 | array_push($page['errors'], 'Invalid/expired form key'); |
---|
[7495] | 48 | } |
---|
| 49 | |
---|
[808] | 50 | if ($_POST['password'] != $_POST['password_conf']) |
---|
| 51 | { |
---|
[12764] | 52 | array_push($page['errors'], l10n('please enter your password again')); |
---|
[808] | 53 | } |
---|
[1068] | 54 | |
---|
[12764] | 55 | $page['errors'] = |
---|
[7495] | 56 | register_user($_POST['login'], |
---|
[808] | 57 | $_POST['password'], |
---|
[1985] | 58 | $_POST['mail_address'], |
---|
[2178] | 59 | true, |
---|
[12764] | 60 | $page['errors']); |
---|
[1068] | 61 | |
---|
[12764] | 62 | if (count($page['errors']) == 0) |
---|
[2] | 63 | { |
---|
[12883] | 64 | // email notification |
---|
[12885] | 65 | if (isset($_POST['send_password_by_mail']) and isset($_POST['mail_address'])) |
---|
| 66 | { |
---|
| 67 | include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php'); |
---|
| 68 | |
---|
| 69 | $keyargs_content = array( |
---|
| 70 | get_l10n_args('Hello %s,', $_POST['login']), |
---|
| 71 | get_l10n_args('Thank you for registering at %s!', $conf['gallery_title']), |
---|
| 72 | get_l10n_args('', ''), |
---|
[12886] | 73 | get_l10n_args('Here are your connection settings', ''), |
---|
| 74 | get_l10n_args('Username: %s', $_POST['login']), |
---|
| 75 | get_l10n_args('Password: %s', $_POST['password']), |
---|
| 76 | get_l10n_args('Email: %s', $_POST['mail_address']), |
---|
[12885] | 77 | get_l10n_args('', ''), |
---|
| 78 | get_l10n_args('If you think you\'ve received this email in error, please contact us at %s', get_webmaster_mail_address()), |
---|
| 79 | ); |
---|
| 80 | |
---|
| 81 | pwg_mail( |
---|
| 82 | $_POST['mail_address'], |
---|
| 83 | array( |
---|
| 84 | 'subject' => '['.$conf['gallery_title'].'] '.l10n('Registration'), |
---|
| 85 | 'content' => l10n_args($keyargs_content), |
---|
| 86 | 'content_format' => 'text/plain', |
---|
| 87 | ) |
---|
| 88 | ); |
---|
| 89 | |
---|
[12886] | 90 | $_SESSION['page_infos'][] = l10n('Successfully registered, you will soon receive an email with your connection settings. Welcome!'); |
---|
[12885] | 91 | } |
---|
[12883] | 92 | |
---|
| 93 | // log user and redirect |
---|
[902] | 94 | $user_id = get_userid($_POST['login']); |
---|
[2178] | 95 | log_user($user_id, false); |
---|
[1082] | 96 | redirect(make_index_url()); |
---|
[2] | 97 | } |
---|
[7495] | 98 | $registration_post_key = get_ephemeral_key(2); |
---|
[2] | 99 | } |
---|
[7495] | 100 | else |
---|
| 101 | { |
---|
| 102 | $registration_post_key = get_ephemeral_key(6); |
---|
| 103 | } |
---|
[365] | 104 | |
---|
[7495] | 105 | $login = !empty($_POST['login'])?htmlspecialchars(stripslashes($_POST['login'])):''; |
---|
| 106 | $email = !empty($_POST['mail_address'])?htmlspecialchars(stripslashes($_POST['mail_address'])):''; |
---|
[365] | 107 | |
---|
[2] | 108 | //----------------------------------------------------- template initialization |
---|
[345] | 109 | // |
---|
| 110 | // Start output of page |
---|
| 111 | // |
---|
[2268] | 112 | $title= l10n('Registration'); |
---|
[850] | 113 | $page['body_id'] = 'theRegisterPage'; |
---|
[345] | 114 | |
---|
[365] | 115 | $template->set_filenames( array('register'=>'register.tpl') ); |
---|
[2247] | 116 | $template->assign(array( |
---|
[1082] | 117 | 'U_HOME' => make_index_url(), |
---|
[7495] | 118 | 'F_KEY' => $registration_post_key, |
---|
[1004] | 119 | 'F_ACTION' => 'register.php', |
---|
[7495] | 120 | 'F_LOGIN' => $login, |
---|
[12610] | 121 | 'F_EMAIL' => $email, |
---|
| 122 | 'obligatory_user_mail_address' => $conf['obligatory_user_mail_address'], |
---|
[365] | 123 | )); |
---|
| 124 | |
---|
[10812] | 125 | // include menubar |
---|
| 126 | $themeconf = $template->get_template_vars('themeconf'); |
---|
[10824] | 127 | if (!isset($themeconf['hide_menu_on']) OR !in_array('theRegisterPage', $themeconf['hide_menu_on'])) |
---|
[10812] | 128 | { |
---|
| 129 | include( PHPWG_ROOT_PATH.'include/menubar.inc.php'); |
---|
| 130 | } |
---|
| 131 | |
---|
| 132 | include(PHPWG_ROOT_PATH.'include/page_header.php'); |
---|
[18063] | 133 | trigger_action('loc_end_register'); |
---|
[15578] | 134 | include(PHPWG_ROOT_PATH.'include/page_messages.php'); |
---|
[688] | 135 | $template->parse('register'); |
---|
[369] | 136 | include(PHPWG_ROOT_PATH.'include/page_tail.php'); |
---|
[362] | 137 | ?> |
---|