source: trunk/register.php @ 12764

Last change on this file since 12764 was 12764, checked in by mistic100, 9 years ago

feature:2538 Make a unified messages management
use only $pageinfos and $pageerrors vars and and necessary template to all main pages

  • Property svn:eol-style set to LF
File size: 3.9 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based photo gallery                                    |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2008-2011 Piwigo Team                  http://piwigo.org |
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// +-----------------------------------------------------------------------+
23
24//----------------------------------------------------------- include
25define('PHPWG_ROOT_PATH','./');
26include_once( PHPWG_ROOT_PATH.'include/common.inc.php' );
27
28// +-----------------------------------------------------------------------+
29// | Check Access and exit when user status is not ok                      |
30// +-----------------------------------------------------------------------+
31check_status(ACCESS_FREE);
32
33//----------------------------------------------------------- user registration
34
35if (!$conf['allow_user_registration'])
36{
37  page_forbidden('User registration closed');
38}
39
40if (isset($_POST['submit']))
41{
42  if (!verify_ephemeral_key(@$_POST['key']))
43  {
44                set_status_header(403);
45    array_push($page['errors'], 'Invalid/expired form key');
46  }
47
48  if ($_POST['password'] != $_POST['password_conf'])
49  {
50    array_push($page['errors'], l10n('please enter your password again'));
51  }
52
53  $page['errors'] =
54      register_user($_POST['login'],
55                    $_POST['password'],
56                    $_POST['mail_address'],
57                    true,
58                    $page['errors']);
59
60  if (count($page['errors']) == 0)
61  {
62    $user_id = get_userid($_POST['login']);
63    log_user($user_id, false);
64    redirect(make_index_url());
65  }
66        $registration_post_key = get_ephemeral_key(2);
67}
68else
69{
70        $registration_post_key = get_ephemeral_key(6);
71}
72
73$login = !empty($_POST['login'])?htmlspecialchars(stripslashes($_POST['login'])):'';
74$email = !empty($_POST['mail_address'])?htmlspecialchars(stripslashes($_POST['mail_address'])):'';
75
76//----------------------------------------------------- template initialization
77//
78// Start output of page
79//
80$title= l10n('Registration');
81$page['body_id'] = 'theRegisterPage';
82
83$template->set_filenames( array('register'=>'register.tpl') );
84$template->assign(array(
85  'U_HOME' => make_index_url(),
86        'F_KEY' => $registration_post_key,
87  'F_ACTION' => 'register.php',
88  'F_LOGIN' => $login,
89  'F_EMAIL' => $email,
90  'obligatory_user_mail_address' => $conf['obligatory_user_mail_address'],
91  ));
92
93// include menubar
94$themeconf = $template->get_template_vars('themeconf');
95if (!isset($themeconf['hide_menu_on']) OR !in_array('theRegisterPage', $themeconf['hide_menu_on']))
96{
97  include( PHPWG_ROOT_PATH.'include/menubar.inc.php');
98}
99
100include(PHPWG_ROOT_PATH.'include/page_header.php');
101$template->parse('register');
102include(PHPWG_ROOT_PATH.'include/page_tail.php');
103?>
Note: See TracBrowser for help on using the repository browser.