Revision 1304
Added by Dietmar over 14 years ago
branches/2.8.x/CHANGELOG | ||
---|---|---|
11 | 11 |
! = Update/Change |
12 | 12 |
|
13 | 13 |
------------------------------------- 2.8.1 ------------------------------------- |
14 |
07-Mar-2010 Dietmar Woellbrink (Luisehahne) |
|
14 |
17-Mar-2010 Dietmar Woellbrink (Luisehahne) |
|
15 |
# Ticket #956 Useraccounts, now e-mail is required |
|
16 |
09-Mar-2010 Dietmar Woellbrink (Luisehahne) |
|
15 | 17 |
# Fixed e-mail preg pattern, because issues with some php versions |
16 | 18 |
07-Mar-2010 Dietmar Woellbrink (Luisehahne) |
17 | 19 |
# fixed search_modext.php ( Tks to Thorn ) |
branches/2.8.x/wb/admin/interface/version.php | ||
---|---|---|
52 | 52 |
|
53 | 53 |
// check if defined to avoid errors during installation (redirect to admin panel fails if PHP error/warnings are enabled) |
54 | 54 |
if(!defined('VERSION')) define('VERSION', '2.8.x'); |
55 |
if(!defined('REVISION')) define('REVISION', '1303');
|
|
55 |
if(!defined('REVISION')) define('REVISION', '1304');
|
|
56 | 56 |
|
57 | 57 |
?> |
branches/2.8.x/wb/admin/users/save.php | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
// $Id$ |
|
4 |
|
|
5 |
/* |
|
6 |
|
|
7 |
Website Baker Project <http://www.websitebaker.org/> |
|
8 |
Copyright (C) 2004-2009, Ryan Djurovich |
|
9 |
|
|
10 |
Website Baker is free software; you can redistribute it and/or modify |
|
11 |
it under the terms of the GNU General Public License as published by |
|
12 |
the Free Software Foundation; either version 2 of the License, or |
|
13 |
(at your option) any later version. |
|
14 |
|
|
15 |
Website Baker is distributed in the hope that it will be useful, |
|
16 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
18 |
GNU General Public License for more details. |
|
19 |
|
|
20 |
You should have received a copy of the GNU General Public License |
|
21 |
along with Website Baker; if not, write to the Free Software |
|
22 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
23 |
|
|
24 |
*/ |
|
25 |
|
|
26 |
// Print admin header |
|
27 |
require('../../config.php'); |
|
28 |
require_once(WB_PATH.'/framework/class.admin.php'); |
|
29 |
$admin = new admin('Access', 'users_modify'); |
|
30 |
|
|
31 |
// Create new database object |
|
32 |
$database = new database(); |
|
33 |
|
|
34 |
// Check if user id is a valid number and doesnt equal 1 |
|
35 |
if(!isset($_POST['user_id']) OR !is_numeric($_POST['user_id']) OR $_POST['user_id'] == 1) { |
|
36 |
header("Location: index.php"); |
|
37 |
exit(0); |
|
38 |
} else { |
|
39 |
$user_id = $_POST['user_id']; |
|
40 |
} |
|
41 |
|
|
42 |
// Gather details entered |
|
43 |
$groups_id = (isset($_POST['groups'])) ? implode(",", $admin->add_slashes($_POST['groups'])) : ''; |
|
44 |
$active = $admin->add_slashes($_POST['active'][0]); |
|
45 |
$username_fieldname = $admin->get_post_escaped('username_fieldname'); |
|
46 |
$username = strtolower($admin->get_post_escaped($username_fieldname)); |
|
47 |
$password = $admin->get_post('password'); |
|
48 |
$password2 = $admin->get_post('password2'); |
|
49 |
$display_name = $admin->get_post_escaped('display_name'); |
|
50 |
$email = $admin->get_post_escaped('email'); |
|
51 |
$home_folder = $admin->get_post_escaped('home_folder'); |
|
52 |
|
|
53 |
// Create a javascript back link |
|
54 |
$js_back = "javascript: history.go(-1);"; |
|
55 |
|
|
56 |
// Check values |
|
57 |
if($groups_id == "") { |
|
58 |
$admin->print_error($MESSAGE['USERS']['NO_GROUP'], $js_back); |
|
59 |
} |
|
60 |
if(strlen($username) < 2) { |
|
61 |
$admin->print_error($MESSAGE['USERS']['USERNAME_TOO_SHORT'], $js_back); |
|
62 |
} |
|
63 |
if($password != "") { |
|
64 |
if(strlen($password) < 2) { |
|
65 |
$admin->print_error($MESSAGE['USERS']['PASSWORD_TOO_SHORT'], $js_back); |
|
66 |
} |
|
67 |
if($password != $password2) { |
|
68 |
$admin->print_error($MESSAGE['USERS']['PASSWORD_MISMATCH'], $js_back); |
|
69 |
} |
|
70 |
} |
|
71 |
if($email != "") { |
|
72 |
if($admin->validate_email($email) == false) { |
|
73 |
$admin->print_error($MESSAGE['USERS']['INVALID_EMAIL'], $js_back); |
|
74 |
} |
|
75 |
} |
|
76 |
|
|
77 |
// Prevent from renaming user to "admin" |
|
78 |
if($username != 'admin') { |
|
79 |
$username_code = ", username = '$username'"; |
|
80 |
} else { |
|
81 |
$username_code = ''; |
|
82 |
} |
|
83 |
|
|
84 |
// Update the database |
|
85 |
if($password == "") { |
|
86 |
$query = "UPDATE ".TABLE_PREFIX."users SET groups_id = '$groups_id', active = '$active'$username_code, display_name = '$display_name', home_folder = '$home_folder', email = '$email' WHERE user_id = '$user_id'"; |
|
87 |
} else { |
|
88 |
// MD5 supplied password |
|
89 |
$md5_password = md5($password); |
|
90 |
$query = "UPDATE ".TABLE_PREFIX."users SET groups_id = '$groups_id', active = '$active'$username_code, display_name = '$display_name', home_folder = '$home_folder', email = '$email', password = '$md5_password' WHERE user_id = '$user_id'"; |
|
91 |
} |
|
92 |
$database->query($query); |
|
93 |
if($database->is_error()) { |
|
94 |
$admin->print_error($database->get_error()); |
|
95 |
} else { |
|
96 |
$admin->print_success($MESSAGE['USERS']['SAVED']); |
|
97 |
} |
|
98 |
|
|
99 |
// Print admin footer |
|
100 |
$admin->print_footer(); |
|
101 |
|
|
1 |
<?php |
|
2 |
/** |
|
3 |
* |
|
4 |
* @category admin |
|
5 |
* @package users |
|
6 |
* @author WebsiteBaker Project |
|
7 |
* @copyright 2004-2009, Ryan Djurovich |
|
8 |
* @copyright 2009-2010, Website Baker Org. e.V. |
|
9 |
* @link http://www.websitebaker2.org/ |
|
10 |
* @license http://www.gnu.org/licenses/gpl.html |
|
11 |
* @platform WebsiteBaker 2.8.x |
|
12 |
* @requirements PHP 4.4.9 and higher |
|
13 |
* @version $Id$ |
|
14 |
* @filesource $HeadURL$ |
|
15 |
* @lastmodified $Date$ |
|
16 |
* |
|
17 |
*/ |
|
18 |
|
|
19 |
// Print admin header |
|
20 |
require('../../config.php'); |
|
21 |
require_once(WB_PATH.'/framework/class.admin.php'); |
|
22 |
$admin = new admin('Access', 'users_modify'); |
|
23 |
|
|
24 |
// Create new database object |
|
25 |
$database = new database(); |
|
26 |
|
|
27 |
// Check if user id is a valid number and doesnt equal 1 |
|
28 |
if(!isset($_POST['user_id']) OR !is_numeric($_POST['user_id']) OR $_POST['user_id'] == 1) { |
|
29 |
header("Location: index.php"); |
|
30 |
exit(0); |
|
31 |
} else { |
|
32 |
$user_id = $_POST['user_id']; |
|
33 |
} |
|
34 |
|
|
35 |
// Gather details entered |
|
36 |
$groups_id = (isset($_POST['groups'])) ? implode(",", $admin->add_slashes($_POST['groups'])) : ''; |
|
37 |
$active = $admin->add_slashes($_POST['active'][0]); |
|
38 |
$username_fieldname = $admin->get_post_escaped('username_fieldname'); |
|
39 |
$username = strtolower($admin->get_post_escaped($username_fieldname)); |
|
40 |
$password = $admin->get_post('password'); |
|
41 |
$password2 = $admin->get_post('password2'); |
|
42 |
$display_name = $admin->get_post_escaped('display_name'); |
|
43 |
$email = $admin->get_post_escaped('email'); |
|
44 |
$home_folder = $admin->get_post_escaped('home_folder'); |
|
45 |
|
|
46 |
// Create a javascript back link |
|
47 |
$js_back = "javascript: history.go(-1);"; |
|
48 |
|
|
49 |
// Check values |
|
50 |
if($groups_id == "") { |
|
51 |
$admin->print_error($MESSAGE['USERS']['NO_GROUP'], $js_back); |
|
52 |
} |
|
53 |
if(strlen($username) < 2) { |
|
54 |
$admin->print_error($MESSAGE['USERS']['USERNAME_TOO_SHORT'], $js_back); |
|
55 |
} |
|
56 |
if($password != "") { |
|
57 |
if(strlen($password) < 2) { |
|
58 |
$admin->print_error($MESSAGE['USERS']['PASSWORD_TOO_SHORT'], $js_back); |
|
59 |
} |
|
60 |
if($password != $password2) { |
|
61 |
$admin->print_error($MESSAGE['USERS']['PASSWORD_MISMATCH'], $js_back); |
|
62 |
} |
|
63 |
} |
|
64 |
|
|
65 |
if($email != "") |
|
66 |
{ |
|
67 |
if($admin->validate_email($email) == false) |
|
68 |
{ |
|
69 |
$admin->print_error($MESSAGE['USERS']['INVALID_EMAIL'], $js_back); |
|
70 |
} |
|
71 |
} else { // e-mail must be present |
|
72 |
$admin->print_error($MESSAGE['SIGNUP']['NO_EMAIL'], $js_back); |
|
73 |
} |
|
74 |
|
|
75 |
// Check if the email already exists |
|
76 |
$results = $database->query("SELECT user_id FROM ".TABLE_PREFIX."users WHERE email = '".$admin->add_slashes($_POST['email'])."'"); |
|
77 |
if($results->numRows() > 0) |
|
78 |
{ |
|
79 |
if(isset($MESSAGE['USERS']['EMAIL_TAKEN'])) |
|
80 |
{ |
|
81 |
$admin->print_error($MESSAGE['USERS']['EMAIL_TAKEN'], $js_back); |
|
82 |
} else { |
|
83 |
$admin->print_error($MESSAGE['USERS']['INVALID_EMAIL'], $js_back); |
|
84 |
} |
|
85 |
} |
|
86 |
|
|
87 |
// Prevent from renaming user to "admin" |
|
88 |
if($username != 'admin') { |
|
89 |
$username_code = ", username = '$username'"; |
|
90 |
} else { |
|
91 |
$username_code = ''; |
|
92 |
} |
|
93 |
|
|
94 |
// Update the database |
|
95 |
if($password == "") { |
|
96 |
$query = "UPDATE ".TABLE_PREFIX."users SET groups_id = '$groups_id', active = '$active'$username_code, display_name = '$display_name', home_folder = '$home_folder', email = '$email' WHERE user_id = '$user_id'"; |
|
97 |
} else { |
|
98 |
// MD5 supplied password |
|
99 |
$md5_password = md5($password); |
|
100 |
$query = "UPDATE ".TABLE_PREFIX."users SET groups_id = '$groups_id', active = '$active'$username_code, display_name = '$display_name', home_folder = '$home_folder', email = '$email', password = '$md5_password' WHERE user_id = '$user_id'"; |
|
101 |
} |
|
102 |
$database->query($query); |
|
103 |
if($database->is_error()) { |
|
104 |
$admin->print_error($database->get_error()); |
|
105 |
} else { |
|
106 |
$admin->print_success($MESSAGE['USERS']['SAVED']); |
|
107 |
} |
|
108 |
|
|
109 |
// Print admin footer |
|
110 |
$admin->print_footer(); |
|
111 |
|
|
102 | 112 |
?> |
103 | 113 |
branches/2.8.x/wb/admin/users/users.php | ||
---|---|---|
40 | 40 |
exit(0); |
41 | 41 |
} |
42 | 42 |
|
43 |
if($_POST['action'] == 'modify') { |
|
43 |
if($_POST['action'] == 'modify') |
|
44 |
{ |
|
44 | 45 |
// Print header |
45 | 46 |
$admin = new admin('Access', 'users_modify'); |
46 | 47 |
// Get existing values |
... | ... | |
71 | 72 |
} |
72 | 73 |
// Add groups to list |
73 | 74 |
$template->set_block('main_block', 'group_list_block', 'group_list'); |
74 |
$results = $database->query("SELECT group_id, name FROM ".TABLE_PREFIX."groups WHERE group_id != '1'"); |
|
75 |
$results = $database->query("SELECT group_id, name FROM ".TABLE_PREFIX."groups WHERE group_id != '1' ORDER BY name");
|
|
75 | 76 |
if($results->numRows() > 0) { |
76 | 77 |
$template->set_var('ID', ''); |
77 | 78 |
$template->set_var('NAME', $TEXT['PLEASE_SELECT'].'...'); |
... | ... | |
88 | 89 |
$template->parse('group_list', 'group_list_block', true); |
89 | 90 |
} |
90 | 91 |
} |
92 |
|
|
91 | 93 |
// Only allow the user to add a user to the Administrators group if they belong to it |
92 |
if(in_array(1, $admin->get_groups_id())) { |
|
94 |
if(in_array(1, $admin->get_groups_id())) |
|
95 |
{ |
|
93 | 96 |
$template->set_var('ID', '1'); |
94 | 97 |
$users_groups = $admin->get_groups_name(); |
95 | 98 |
$template->set_var('NAME', $users_groups[1]); |
96 |
|
|
99 |
|
|
97 | 100 |
$in_group = FALSE; |
98 | 101 |
foreach($admin->get_groups_id() as $cur_gid){ |
99 | 102 |
if (in_array($cur_gid, explode(",", $user['groups_id']))) { |
... | ... | |
115 | 118 |
$template->parse('group_list', 'group_list_block', true); |
116 | 119 |
} |
117 | 120 |
} |
118 |
|
|
121 |
|
|
119 | 122 |
// Generate username field name |
120 | 123 |
$username_fieldname = 'username_'; |
121 | 124 |
$salt = "abchefghjkmnpqrstuvwxyz0123456789"; |
branches/2.8.x/wb/admin/users/index.php | ||
---|---|---|
30 | 30 |
|
31 | 31 |
// Get existing value from database |
32 | 32 |
$database = new database(); |
33 |
$query = "SELECT user_id, username, display_name FROM ".TABLE_PREFIX."users WHERE user_id != '1' ORDER BY username"; |
|
33 |
$query = "SELECT user_id, username, display_name FROM ".TABLE_PREFIX."users WHERE user_id != '1' ORDER BY display_name,username";
|
|
34 | 34 |
$results = $database->query($query); |
35 | 35 |
if($database->is_error()) { |
36 | 36 |
$admin->print_error($database->get_error(), 'index.php'); |
branches/2.8.x/wb/admin/users/add.php | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
// $Id$ |
|
4 |
|
|
5 |
/* |
|
6 |
|
|
7 |
Website Baker Project <http://www.websitebaker.org/> |
|
8 |
Copyright (C) 2004-2009, Ryan Djurovich |
|
9 |
|
|
10 |
Website Baker is free software; you can redistribute it and/or modify |
|
11 |
it under the terms of the GNU General Public License as published by |
|
12 |
the Free Software Foundation; either version 2 of the License, or |
|
13 |
(at your option) any later version. |
|
14 |
|
|
15 |
Website Baker is distributed in the hope that it will be useful, |
|
16 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
18 |
GNU General Public License for more details. |
|
19 |
|
|
20 |
You should have received a copy of the GNU General Public License |
|
21 |
along with Website Baker; if not, write to the Free Software |
|
22 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
23 |
|
|
24 |
*/ |
|
25 |
|
|
26 |
// Print admin header |
|
27 |
require('../../config.php'); |
|
28 |
require_once(WB_PATH.'/framework/class.admin.php'); |
|
29 |
$admin = new admin('Access', 'users_add'); |
|
30 |
|
|
31 |
// Create new database object |
|
32 |
$database = new database(); |
|
33 |
|
|
34 |
// Get details entered |
|
35 |
$groups_id = implode(",", $admin->add_slashes($_POST['groups'])); //should check permissions |
|
36 |
$groups_id = trim($groups_id, ','); // there will be an additional ',' when "Please Choose" was selected, too |
|
37 |
$active = $admin->add_slashes($_POST['active'][0]); |
|
38 |
$username_fieldname = $admin->get_post_escaped('username_fieldname'); |
|
39 |
$username = strtolower($admin->get_post_escaped($username_fieldname)); |
|
40 |
$password = $admin->get_post('password'); |
|
41 |
$password2 = $admin->get_post('password2'); |
|
42 |
$display_name = $admin->get_post_escaped('display_name'); |
|
43 |
$email = $admin->get_post_escaped('email'); |
|
44 |
$home_folder = $admin->get_post_escaped('home_folder'); |
|
45 |
$default_language = DEFAULT_LANGUAGE; |
|
46 |
|
|
47 |
// Create a javascript back link |
|
48 |
$js_back = 'javascript: history.go(-1);'; |
|
49 |
|
|
50 |
// Check values |
|
51 |
if($groups_id == '') { |
|
52 |
$admin->print_error($MESSAGE['USERS']['NO_GROUP'], $js_back); |
|
53 |
} |
|
54 |
if(strlen($username) < 2) { |
|
55 |
$admin->print_error($MESSAGE['USERS']['USERNAME_TOO_SHORT'], $js_back); |
|
56 |
} |
|
57 |
if(strlen($password) < 2) { |
|
58 |
$admin->print_error($MESSAGE['USERS']['PASSWORD_TOO_SHORT'], $js_back); |
|
59 |
} |
|
60 |
if($password != $password2) { |
|
61 |
$admin->print_error($MESSAGE['USERS']['PASSWORD_MISMATCH'], $js_back); |
|
62 |
} |
|
63 |
if($email != '') { |
|
64 |
if($admin->validate_email($email) == false) { |
|
65 |
$admin->print_error($MESSAGE['USERS']['INVALID_EMAIL'], $js_back); |
|
66 |
} |
|
67 |
} |
|
68 |
|
|
69 |
// choose group_id from groups_id - workaround for still remaining calls to group_id (to be cleaned-up) |
|
70 |
$gid_tmp = explode(',', $groups_id); |
|
71 |
if(in_array('1', $gid_tmp)) $group_id = '1'; // if user is in administrator-group, get this group |
|
72 |
else $group_id = $gid_tmp[0]; // else just get the first one |
|
73 |
unset($gid_tmp); |
|
74 |
|
|
75 |
// Check if username already exists |
|
76 |
$results = $database->query("SELECT user_id FROM ".TABLE_PREFIX."users WHERE username = '$username'"); |
|
77 |
if($results->numRows() > 0) { |
|
78 |
$admin->print_error($MESSAGE['USERS']['USERNAME_TAKEN'], $js_back); |
|
79 |
} |
|
80 |
|
|
81 |
// Check if the email already exists |
|
82 |
$results = $database->query("SELECT user_id FROM ".TABLE_PREFIX."users WHERE email = '".$admin->add_slashes($_POST['email'])."'"); |
|
83 |
if($results->numRows() > 0) { |
|
84 |
if(isset($MESSAGE['USERS']['EMAIL_TAKEN'])) { |
|
85 |
$admin->print_error($MESSAGE['USERS']['EMAIL_TAKEN'], $js_back); |
|
86 |
} else { |
|
87 |
$admin->print_error($MESSAGE['USERS']['INVALID_EMAIL'], $js_back); |
|
88 |
} |
|
89 |
} |
|
90 |
|
|
91 |
// MD5 supplied password |
|
92 |
$md5_password = md5($password); |
|
93 |
|
|
94 |
// Inser the user into the database |
|
95 |
$query = "INSERT INTO ".TABLE_PREFIX."users (group_id,groups_id,active,username,password,display_name,home_folder,email,timezone, language) VALUES ('$group_id', '$groups_id', '$active', '$username','$md5_password','$display_name','$home_folder','$email','-72000', '$default_language')"; |
|
96 |
$database->query($query); |
|
97 |
if($database->is_error()) { |
|
98 |
$admin->print_error($database->get_error()); |
|
99 |
} else { |
|
100 |
$admin->print_success($MESSAGE['USERS']['ADDED']); |
|
101 |
} |
|
102 |
|
|
103 |
// Print admin footer |
|
104 |
$admin->print_footer(); |
|
105 |
|
|
1 |
<?php |
|
2 |
/** |
|
3 |
* |
|
4 |
* @category admin |
|
5 |
* @package users |
|
6 |
* @author WebsiteBaker Project |
|
7 |
* @copyright 2004-2009, Ryan Djurovich |
|
8 |
* @copyright 2009-2010, Website Baker Org. e.V. |
|
9 |
* @link http://www.websitebaker2.org/ |
|
10 |
* @license http://www.gnu.org/licenses/gpl.html |
|
11 |
* @platform WebsiteBaker 2.8.x |
|
12 |
* @requirements PHP 4.4.9 and higher |
|
13 |
* @version $Id$ |
|
14 |
* @filesource $HeadURL$ |
|
15 |
* @lastmodified $Date$ |
|
16 |
* |
|
17 |
*/ |
|
18 |
|
|
19 |
// Print admin header |
|
20 |
require('../../config.php'); |
|
21 |
require_once(WB_PATH.'/framework/class.admin.php'); |
|
22 |
$admin = new admin('Access', 'users_add'); |
|
23 |
|
|
24 |
// Create new database object |
|
25 |
$database = new database(); |
|
26 |
|
|
27 |
// Get details entered |
|
28 |
$groups_id = implode(",", $admin->add_slashes($_POST['groups'])); //should check permissions |
|
29 |
$groups_id = trim($groups_id, ','); // there will be an additional ',' when "Please Choose" was selected, too |
|
30 |
$active = $admin->add_slashes($_POST['active'][0]); |
|
31 |
$username_fieldname = $admin->get_post_escaped('username_fieldname'); |
|
32 |
$username = strtolower($admin->get_post_escaped($username_fieldname)); |
|
33 |
$password = $admin->get_post('password'); |
|
34 |
$password2 = $admin->get_post('password2'); |
|
35 |
$display_name = $admin->get_post_escaped('display_name'); |
|
36 |
$email = $admin->get_post_escaped('email'); |
|
37 |
$home_folder = $admin->get_post_escaped('home_folder'); |
|
38 |
$default_language = DEFAULT_LANGUAGE; |
|
39 |
|
|
40 |
// Create a javascript back link |
|
41 |
$js_back = 'javascript: history.go(-1);'; |
|
42 |
|
|
43 |
// Check values |
|
44 |
if($groups_id == '') { |
|
45 |
$admin->print_error($MESSAGE['USERS']['NO_GROUP'], $js_back); |
|
46 |
} |
|
47 |
if(strlen($username) < 2) { |
|
48 |
$admin->print_error($MESSAGE['USERS']['USERNAME_TOO_SHORT'], $js_back); |
|
49 |
} |
|
50 |
if(strlen($password) < 2) { |
|
51 |
$admin->print_error($MESSAGE['USERS']['PASSWORD_TOO_SHORT'], $js_back); |
|
52 |
} |
|
53 |
if($password != $password2) { |
|
54 |
$admin->print_error($MESSAGE['USERS']['PASSWORD_MISMATCH'], $js_back); |
|
55 |
} |
|
56 |
if($email != '') |
|
57 |
{ |
|
58 |
if($admin->validate_email($email) == false) |
|
59 |
{ |
|
60 |
$admin->print_error($MESSAGE['USERS']['INVALID_EMAIL'], $js_back); |
|
61 |
} |
|
62 |
} else { // e-mail must be present |
|
63 |
$admin->print_error($MESSAGE['SIGNUP']['NO_EMAIL'], $js_back); |
|
64 |
} |
|
65 |
|
|
66 |
// choose group_id from groups_id - workaround for still remaining calls to group_id (to be cleaned-up) |
|
67 |
$gid_tmp = explode(',', $groups_id); |
|
68 |
if(in_array('1', $gid_tmp)) $group_id = '1'; // if user is in administrator-group, get this group |
|
69 |
else $group_id = $gid_tmp[0]; // else just get the first one |
|
70 |
unset($gid_tmp); |
|
71 |
|
|
72 |
// Check if username already exists |
|
73 |
$results = $database->query("SELECT user_id FROM ".TABLE_PREFIX."users WHERE username = '$username'"); |
|
74 |
if($results->numRows() > 0) { |
|
75 |
$admin->print_error($MESSAGE['USERS']['USERNAME_TAKEN'], $js_back); |
|
76 |
} |
|
77 |
|
|
78 |
// Check if the email already exists |
|
79 |
$results = $database->query("SELECT user_id FROM ".TABLE_PREFIX."users WHERE email = '".$admin->add_slashes($_POST['email'])."'"); |
|
80 |
if($results->numRows() > 0) |
|
81 |
{ |
|
82 |
if(isset($MESSAGE['USERS']['EMAIL_TAKEN'])) |
|
83 |
{ |
|
84 |
$admin->print_error($MESSAGE['USERS']['EMAIL_TAKEN'], $js_back); |
|
85 |
} else { |
|
86 |
$admin->print_error($MESSAGE['USERS']['INVALID_EMAIL'], $js_back); |
|
87 |
} |
|
88 |
} |
|
89 |
|
|
90 |
// MD5 supplied password |
|
91 |
$md5_password = md5($password); |
|
92 |
|
|
93 |
// Inser the user into the database |
|
94 |
$query = "INSERT INTO ".TABLE_PREFIX."users (group_id,groups_id,active,username,password,display_name,home_folder,email,timezone, language) VALUES ('$group_id', '$groups_id', '$active', '$username','$md5_password','$display_name','$home_folder','$email','-72000', '$default_language')"; |
|
95 |
$database->query($query); |
|
96 |
if($database->is_error()) { |
|
97 |
$admin->print_error($database->get_error()); |
|
98 |
} else { |
|
99 |
$admin->print_success($MESSAGE['USERS']['ADDED']); |
|
100 |
} |
|
101 |
|
|
102 |
// Print admin footer |
|
103 |
$admin->print_footer(); |
|
104 |
|
|
106 | 105 |
?> |
107 | 106 |
Also available in: Unified diff
Ticket #956 Useraccounts, now e-mail is required