1
|
<?php
|
2
|
|
3
|
// $Id: index.php 10 2005-09-04 08:59:31Z ryan $
|
4
|
|
5
|
/*
|
6
|
|
7
|
Website Baker Project <http://www.websitebaker.org/>
|
8
|
Copyright (C) 2004-2005, 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
|
require('../../config.php');
|
27
|
require_once(WB_PATH.'/framework/class.admin.php');
|
28
|
$admin = new admin('Access', 'users');
|
29
|
|
30
|
// Create new template object for the modify/remove menu
|
31
|
$template = new Template(ADMIN_PATH.'/users');
|
32
|
$template->set_file('page', 'template.html');
|
33
|
$template->set_block('page', 'main_block', 'main');
|
34
|
$template->set_var('ADMIN_URL', ADMIN_URL);
|
35
|
|
36
|
// Get existing value from database
|
37
|
$database = new database();
|
38
|
$query = "SELECT user_id, username, display_name FROM ".TABLE_PREFIX."users WHERE user_id != '1' ORDER BY username";
|
39
|
$results = $database->query($query);
|
40
|
if($database->is_error()) {
|
41
|
$admin->print_error($database->get_error(), 'index.php');
|
42
|
}
|
43
|
|
44
|
// Insert values into the modify/remove menu
|
45
|
$template->set_block('main_block', 'list_block', 'list');
|
46
|
if($results->numRows() > 0) {
|
47
|
// Insert first value to say please select
|
48
|
$template->set_var('VALUE', '');
|
49
|
$template->set_var('NAME', $TEXT['PLEASE_SELECT'].'...');
|
50
|
$template->parse('list', 'list_block', true);
|
51
|
// Loop through users
|
52
|
while($user = $results->fetchRow()) {
|
53
|
$template->set_var('VALUE', $user['user_id']);
|
54
|
$template->set_var('NAME', $user['display_name'].' ('.$user['username'].')');
|
55
|
$template->parse('list', 'list_block', true);
|
56
|
}
|
57
|
} else {
|
58
|
// Insert single value to say no users were found
|
59
|
$template->set_var('NAME', $TEXT['NONE_FOUND']);
|
60
|
$template->parse('list', 'list_block', true);
|
61
|
}
|
62
|
|
63
|
// Insert permissions values
|
64
|
if($admin->get_permission('users_add') != true) {
|
65
|
$template->set_var('DISPLAY_ADD', 'hide');
|
66
|
}
|
67
|
if($admin->get_permission('users_modify') != true) {
|
68
|
$template->set_var('DISPLAY_MODIFY', 'hide');
|
69
|
}
|
70
|
if($admin->get_permission('users_delete') != true) {
|
71
|
$template->set_var('DISPLAY_DELETE', 'hide');
|
72
|
}
|
73
|
|
74
|
// Insert language headings
|
75
|
$template->set_var(array(
|
76
|
'HEADING_MODIFY_DELETE_USER' => $HEADING['MODIFY_DELETE_USER'],
|
77
|
'HEADING_ADD_USER' => $HEADING['ADD_USER']
|
78
|
)
|
79
|
);
|
80
|
// Insert language text and messages
|
81
|
$template->set_var(array(
|
82
|
'TEXT_MODIFY' => $TEXT['MODIFY'],
|
83
|
'TEXT_DELETE' => $TEXT['DELETE'],
|
84
|
'TEXT_MANAGE_GROUPS' => $TEXT['MANAGE_GROUPS'],
|
85
|
'CONFIRM_DELETE' => $MESSAGE['USERS']['CONFIRM_DELETE']
|
86
|
)
|
87
|
);
|
88
|
|
89
|
// Parse template object
|
90
|
$template->parse('main', 'main_block', false);
|
91
|
$template->pparse('output', 'page');
|
92
|
|
93
|
// Setup template for add user form
|
94
|
$template = new Template(ADMIN_PATH.'/users');
|
95
|
$template->set_file('page', 'user_form.html');
|
96
|
$template->set_block('page', 'main_block', 'main');
|
97
|
$template->set_var('DISPLAY_EXTRA', 'none');
|
98
|
$template->set_var('ACTIVE_CHECKED', 'checked');
|
99
|
$template->set_var('ACTION_URL', ADMIN_URL.'/users/add.php');
|
100
|
$template->set_var('SUBMIT_TITLE', $TEXT['ADD']);
|
101
|
|
102
|
// Add groups to list
|
103
|
$template->set_block('main_block', 'group_list_block', 'group_list');
|
104
|
$results = $database->query("SELECT group_id, name FROM ".TABLE_PREFIX."groups WHERE group_id != '1'");
|
105
|
if($results->numRows() > 0) {
|
106
|
$template->set_var('ID', '');
|
107
|
$template->set_var('NAME', $TEXT['PLEASE_SELECT'].'...');
|
108
|
$template->set_var('SELECTED', 'selected');
|
109
|
$template->parse('group_list', 'group_list_block', true);
|
110
|
while($group = $results->fetchRow()) {
|
111
|
$template->set_var('ID', $group['group_id']);
|
112
|
$template->set_var('NAME', $group['name']);
|
113
|
$template->set_var('SELECTED', '');
|
114
|
$template->parse('group_list', 'group_list_block', true);
|
115
|
}
|
116
|
}
|
117
|
// Only allow the user to add a user to the Administrators group if they belong to it
|
118
|
if($admin->get_group_id() == 1) {
|
119
|
$template->set_var('ID', '1');
|
120
|
$template->set_var('NAME', $admin->get_group_name());
|
121
|
$template->set_var('SELECTED', '');
|
122
|
$template->parse('group_list', 'group_list_block', true);
|
123
|
} else {
|
124
|
if($results->numRows() == 0) {
|
125
|
$template->set_var('ID', '');
|
126
|
$template->set_var('NAME', $TEXT['NONE_FOUND']);
|
127
|
$template->parse('group_list', 'group_list_block', true);
|
128
|
}
|
129
|
}
|
130
|
|
131
|
// Insert permissions values
|
132
|
if($admin->get_permission('users_add') != true) {
|
133
|
$template->set_var('DISPLAY_ADD', 'hide');
|
134
|
}
|
135
|
|
136
|
// Generate username field name
|
137
|
$username_fieldname = 'username_';
|
138
|
$salt = "abchefghjkmnpqrstuvwxyz0123456789";
|
139
|
srand((double)microtime()*1000000);
|
140
|
$i = 0;
|
141
|
while ($i <= 7) {
|
142
|
$num = rand() % 33;
|
143
|
$tmp = substr($salt, $num, 1);
|
144
|
$username_fieldname = $username_fieldname . $tmp;
|
145
|
$i++;
|
146
|
}
|
147
|
|
148
|
// Work-out if home folder should be shown
|
149
|
if(!HOME_FOLDERS) {
|
150
|
$template->set_var('DISPLAY_HOME_FOLDERS', 'none');
|
151
|
}
|
152
|
|
153
|
// Include the WB functions file
|
154
|
require_once(WB_PATH.'/framework/functions.php');
|
155
|
|
156
|
// Add media folders to home folder list
|
157
|
$template->set_block('main_block', 'folder_list_block', 'folder_list');
|
158
|
foreach(directory_list(WB_PATH.MEDIA_DIRECTORY) AS $name) {
|
159
|
$template->set_var('NAME', str_replace(WB_PATH, '', $name));
|
160
|
$template->set_var('FOLDER', str_replace(WB_PATH.MEDIA_DIRECTORY, '', $name));
|
161
|
$template->set_var('SELECTED', ' ');
|
162
|
$template->parse('folder_list', 'folder_list_block', true);
|
163
|
}
|
164
|
|
165
|
// Insert language text and messages
|
166
|
$template->set_var(array(
|
167
|
'TEXT_RESET' => $TEXT['RESET'],
|
168
|
'TEXT_ACTIVE' => $TEXT['ACTIVE'],
|
169
|
'TEXT_DISABLED' => $TEXT['DISABLED'],
|
170
|
'TEXT_PLEASE_SELECT' => $TEXT['PLEASE_SELECT'],
|
171
|
'TEXT_USERNAME' => $TEXT['USERNAME'],
|
172
|
'TEXT_PASSWORD' => $TEXT['PASSWORD'],
|
173
|
'TEXT_RETYPE_PASSWORD' => $TEXT['RETYPE_PASSWORD'],
|
174
|
'TEXT_DISPLAY_NAME' => $TEXT['DISPLAY_NAME'],
|
175
|
'TEXT_EMAIL' => $TEXT['EMAIL'],
|
176
|
'TEXT_GROUP' => $TEXT['GROUP'],
|
177
|
'TEXT_NONE' => $TEXT['NONE'],
|
178
|
'TEXT_HOME_FOLDER' => $TEXT['HOME_FOLDER'],
|
179
|
'USERNAME_FIELDNAME' => $username_fieldname,
|
180
|
'CHANGING_PASSWORD' => $MESSAGE['USERS']['CHANGING_PASSWORD']
|
181
|
)
|
182
|
);
|
183
|
|
184
|
// Parse template for add user form
|
185
|
$template->parse('main', 'main_block', false);
|
186
|
$template->pparse('output', 'page');
|
187
|
|
188
|
$admin->print_footer();
|
189
|
|
190
|
?>
|