1 | <?php |
---|
2 | // +-----------------------------------------------------------------------+ |
---|
3 | // | PhpWebGallery - a PHP based picture gallery | |
---|
4 | // | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | |
---|
5 | // | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net | |
---|
6 | // +-----------------------------------------------------------------------+ |
---|
7 | // | file : $Id: register.php 1985 2007-04-27 05:22:17Z rub $ |
---|
8 | // | last update : $Date: 2007-04-27 05:22:17 +0000 (Fri, 27 Apr 2007) $ |
---|
9 | // | last modifier : $Author: rub $ |
---|
10 | // | revision : $Revision: 1985 $ |
---|
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 | // +-----------------------------------------------------------------------+ |
---|
26 | |
---|
27 | //----------------------------------------------------------- include |
---|
28 | define('PHPWG_ROOT_PATH','./'); |
---|
29 | include_once( PHPWG_ROOT_PATH.'include/common.inc.php' ); |
---|
30 | |
---|
31 | // +-----------------------------------------------------------------------+ |
---|
32 | // | Check Access and exit when user status is not ok | |
---|
33 | // +-----------------------------------------------------------------------+ |
---|
34 | check_status(ACCESS_NONE); |
---|
35 | |
---|
36 | //----------------------------------------------------------- user registration |
---|
37 | |
---|
38 | if (!$conf['allow_user_registration']) |
---|
39 | { |
---|
40 | page_forbidden('User registration closed'); |
---|
41 | } |
---|
42 | |
---|
43 | $errors = array(); |
---|
44 | if (isset($_POST['submit'])) |
---|
45 | { |
---|
46 | if ($_POST['password'] != $_POST['password_conf']) |
---|
47 | { |
---|
48 | array_push($errors, $lang['reg_err_pass']); |
---|
49 | } |
---|
50 | |
---|
51 | $errors = |
---|
52 | register_user($_POST['login'], |
---|
53 | $_POST['password'], |
---|
54 | $_POST['mail_address'], |
---|
55 | $errors); |
---|
56 | |
---|
57 | if (count($errors) == 0) |
---|
58 | { |
---|
59 | $user_id = get_userid($_POST['login']); |
---|
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']; |
---|
66 | $admin_url = get_absolute_root_url() |
---|
67 | .'admin.php?page=user_list&username='.$username; |
---|
68 | |
---|
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 | ); |
---|
76 | |
---|
77 | pwg_mail_notification_admins |
---|
78 | ( |
---|
79 | get_l10n_args('Registration of %s', $username), |
---|
80 | $keyargs_content |
---|
81 | ); |
---|
82 | } |
---|
83 | redirect(make_index_url()); |
---|
84 | } |
---|
85 | } |
---|
86 | |
---|
87 | $login = !empty($_POST['login'])?$_POST['login']:''; |
---|
88 | $email = !empty($_POST['mail_address'])?$_POST['mail_address']:''; |
---|
89 | |
---|
90 | //----------------------------------------------------- template initialization |
---|
91 | // |
---|
92 | // Start output of page |
---|
93 | // |
---|
94 | $title= $lang['register_page_title']; |
---|
95 | $page['body_id'] = 'theRegisterPage'; |
---|
96 | include(PHPWG_ROOT_PATH.'include/page_header.php'); |
---|
97 | |
---|
98 | $template->set_filenames( array('register'=>'register.tpl') ); |
---|
99 | $template->assign_vars(array( |
---|
100 | 'U_HOME' => make_index_url(), |
---|
101 | |
---|
102 | 'F_ACTION' => 'register.php', |
---|
103 | 'F_LOGIN' => $login, |
---|
104 | 'F_EMAIL' => $email |
---|
105 | )); |
---|
106 | |
---|
107 | //-------------------------------------------------------------- errors display |
---|
108 | if ( sizeof( $errors ) != 0 ) |
---|
109 | { |
---|
110 | $template->assign_block_vars('errors',array()); |
---|
111 | for ( $i = 0; $i < sizeof( $errors ); $i++ ) |
---|
112 | { |
---|
113 | $template->assign_block_vars('errors.error',array('ERROR'=>$errors[$i])); |
---|
114 | } |
---|
115 | } |
---|
116 | |
---|
117 | $template->parse('register'); |
---|
118 | include(PHPWG_ROOT_PATH.'include/page_tail.php'); |
---|
119 | ?> |
---|