source: branches/branch-1_7/register.php @ 2001

Last change on this file since 2001 was 1986, checked in by rub, 17 years ago

Issue 0000682: Error on user registration
On register page when the 2 passwords are not the same, an error occurs but user is also created.

=> Just error must be raised.

Merge BSF 1984:1985 into branch-1_7

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 4.2 KB
RevLine 
[2]1<?php
[354]2// +-----------------------------------------------------------------------+
[593]3// | PhpWebGallery - a PHP based picture gallery                           |
4// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
[1753]5// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
[354]6// +-----------------------------------------------------------------------+
[1753]7// | file          : $Id: register.php 1986 2007-04-27 05:24:01Z rub $
[354]8// | last update   : $Date: 2007-04-27 05:24:01 +0000 (Fri, 27 Apr 2007) $
9// | last modifier : $Author: rub $
10// | revision      : $Revision: 1986 $
11// +-----------------------------------------------------------------------+
12// | This program is free software; you can redistribute it and/or modify  |
13// | it under the terms of the GNU General Public License as published by  |
14// | the Free Software Foundation                                          |
15// |                                                                       |
16// | This program is distributed in the hope that it will be useful, but   |
17// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
18// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
19// | General Public License for more details.                              |
20// |                                                                       |
21// | You should have received a copy of the GNU General Public License     |
22// | along with this program; if not, write to the Free Software           |
23// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
24// | USA.                                                                  |
25// +-----------------------------------------------------------------------+
[2]26
[345]27//----------------------------------------------------------- include
[364]28define('PHPWG_ROOT_PATH','./');
[365]29include_once( PHPWG_ROOT_PATH.'include/common.inc.php' );
[1851]30
31// +-----------------------------------------------------------------------+
32// | Check Access and exit when user status is not ok                      |
33// +-----------------------------------------------------------------------+
34check_status(ACCESS_NONE);
35
[2]36//----------------------------------------------------------- user registration
[1652]37
38if (!$conf['allow_user_registration'])
39{
40  page_forbidden('User registration closed');
41}
42
[631]43$errors = array();
[661]44if (isset($_POST['submit']))
[2]45{
[808]46  if ($_POST['password'] != $_POST['password_conf'])
47  {
48    array_push($errors, $lang['reg_err_pass']);
49  }
[1068]50
[808]51  $errors =
52      register_user($_POST['login'],
53                    $_POST['password'],
[1986]54                    $_POST['mail_address'],
55                    $errors);
[1068]56
[661]57  if (count($errors) == 0)
[2]58  {
[902]59    $user_id = get_userid($_POST['login']);
[1566]60    log_user( $user_id, false);
61
62    if ($conf['email_admin_on_new_user'])
63    {
64      include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
65      $username = $_POST['login'];
[1753]66      $admin_url = get_absolute_root_url()
[1901]67                   .'admin.php?page=user_list&username='.$username;
[1566]68
[1908]69      $keyargs_content = array
70      (
71        get_l10n_args('User: %s', $username),
72        get_l10n_args('Email: %s', $_POST['mail_address']),
73        get_l10n_args('', ''),
74        get_l10n_args('Admin: %s', $admin_url)
75      );
[1566]76
[1908]77      pwg_mail_notification_admins
[1818]78      (
[1908]79        get_l10n_args('Registration of %s', $username),
80        $keyargs_content
[1809]81      );
[1566]82    }
[1082]83    redirect(make_index_url());
[2]84  }
85}
[365]86
[393]87$login = !empty($_POST['login'])?$_POST['login']:'';
[740]88$email = !empty($_POST['mail_address'])?$_POST['mail_address']:'';
[365]89
[2]90//----------------------------------------------------- template initialization
[345]91//
92// Start output of page
93//
94$title= $lang['register_page_title'];
[850]95$page['body_id'] = 'theRegisterPage';
[369]96include(PHPWG_ROOT_PATH.'include/page_header.php');
[345]97
[365]98$template->set_filenames( array('register'=>'register.tpl') );
99$template->assign_vars(array(
[1082]100  'U_HOME' => make_index_url(),
[1068]101
[1004]102  'F_ACTION' => 'register.php',
[365]103  'F_LOGIN' => $login,
[740]104  'F_EMAIL' => $email
[365]105  ));
106
[2]107//-------------------------------------------------------------- errors display
[631]108if ( sizeof( $errors ) != 0 )
[2]109{
[365]110  $template->assign_block_vars('errors',array());
[631]111  for ( $i = 0; $i < sizeof( $errors ); $i++ )
[2]112  {
[365]113    $template->assign_block_vars('errors.error',array('ERROR'=>$errors[$i]));
[2]114  }
115}
[365]116
[688]117$template->parse('register');
[369]118include(PHPWG_ROOT_PATH.'include/page_tail.php');
[362]119?>
Note: See TracBrowser for help on using the repository browser.