Revision 238
Added by stefan about 19 years ago
trunk/wb/search/search.php | ||
---|---|---|
35 | 35 |
$items_listed = array(); |
36 | 36 |
|
37 | 37 |
// Get search string |
38 |
if(isset($_REQUEST['string'])) { |
|
39 |
if ($_REQUEST['match']!='exact') { |
|
40 |
$string=str_replace(',', '', $_REQUEST['string']); |
|
38 |
if(isset($_REQUEST['string'])) {
|
|
39 |
if ($_REQUEST['match']!='exact') {
|
|
40 |
$string=str_replace(',', '', $_REQUEST['string']);
|
|
41 | 41 |
} else { |
42 | 42 |
$string=$_REQUEST['string']; |
43 | 43 |
} |
44 |
// reverse potential magic_quotes action |
|
45 |
$original_string=$wb->strip_slashes($string); |
|
46 |
// Double backslashes (mySQL needs doubly escaped backslashes in LIKE comparisons) |
|
44 |
// reverse potential magic_quotes action
|
|
45 |
$original_string=$wb->strip_slashes($string);
|
|
46 |
// Double backslashes (mySQL needs doubly escaped backslashes in LIKE comparisons)
|
|
47 | 47 |
$string = addslashes($wb->escape_backslashes($original_string)); |
48 |
// then escape for mySQL query |
|
48 |
// then escape for mySQL query
|
|
49 | 49 |
$search_string = htmlspecialchars($original_string,ENT_QUOTES); |
50 | 50 |
} else { |
51 | 51 |
$string = ''; |
... | ... | |
55 | 55 |
// Work-out what to do (match all words, any words, or do exact match), and do relevant with query settings |
56 | 56 |
$all_checked = ''; |
57 | 57 |
$any_checked = ''; |
58 |
$exact_checked = ''; |
|
58 |
$exact_checked = '';
|
|
59 | 59 |
if($_REQUEST['match'] != 'exact') { |
60 | 60 |
// Split string into array with explode() function |
61 | 61 |
$exploded_string = explode(' ', $string); |
... | ... | |
66 | 66 |
$string[] = $each_exploded_string; |
67 | 67 |
} |
68 | 68 |
} |
69 |
if ($_REQUEST['match'] == 'any') { |
|
70 |
$any_checked = ' checked'; |
|
71 |
$logical_operator = ' OR'; |
|
72 |
} else { |
|
73 |
$all_checked = ' checked'; |
|
74 |
$logical_operator = ' AND'; |
|
75 |
} |
|
69 |
if ($_REQUEST['match'] == 'any') {
|
|
70 |
$any_checked = ' checked';
|
|
71 |
$logical_operator = ' OR';
|
|
72 |
} else {
|
|
73 |
$all_checked = ' checked';
|
|
74 |
$logical_operator = ' AND';
|
|
75 |
}
|
|
76 | 76 |
} else { |
77 | 77 |
$exact_checked = ' checked'; |
78 |
$exact_string=$string; |
|
79 |
$string=array(); |
|
80 |
$string[]=$exact_string; |
|
78 |
$exact_string=$string;
|
|
79 |
$string=array();
|
|
80 |
$string[]=$exact_string;
|
|
81 | 81 |
} |
82 | 82 |
// Get list of usernames and display names |
83 | 83 |
$query_users = $database->query("SELECT user_id,username,display_name FROM ".TABLE_PREFIX."users"); |
... | ... | |
208 | 208 |
if($count != 0) { $prepared_query .= $logical_operator; } |
209 | 209 |
$prepared_query .= str_replace('[STRING]', $each_string, $query_body); |
210 | 210 |
$count = $count+1; |
211 |
} |
|
211 |
}
|
|
212 | 212 |
$prepared_query .= $query_end; |
213 | 213 |
// Execute query |
214 | 214 |
$query = $database->query($prepared_query); |
trunk/wb/admin/groups/get_permissions.php | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
// $Id$ |
|
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 |
if(!defined('WB_PATH')) { exit('Direct access to this file is not allowed'); } |
|
27 |
|
|
28 |
// Get system permissions |
|
29 |
if($admin->get_post('advanced') != 'yes') { |
|
30 |
$system_permissions['pages'] = $admin->get_post('pages'); |
|
31 |
$system_permissions['pages_view'] = $system_permissions['pages']; |
|
32 |
$system_permissions['pages_add'] = $system_permissions['pages']; |
|
33 |
$system_permissions['pages_add_l0'] = $system_permissions['pages']; |
|
34 |
$system_permissions['pages_settings'] = $system_permissions['pages']; |
|
35 |
$system_permissions['pages_modify'] = $system_permissions['pages']; |
|
36 |
$system_permissions['pages_intro'] = $system_permissions['pages']; |
|
37 |
$system_permissions['pages_delete'] = $system_permissions['pages']; |
|
38 |
$system_permissions['media'] = $admin->get_post('media'); |
|
39 |
$system_permissions['media_view'] = $system_permissions['media']; |
|
40 |
$system_permissions['media_upload'] = $system_permissions['media']; |
|
41 |
$system_permissions['media_rename'] = $system_permissions['media']; |
|
42 |
$system_permissions['media_delete'] = $system_permissions['media']; |
|
43 |
$system_permissions['media_create'] = $system_permissions['media']; |
|
44 |
if($admin->get_post('modules') != '' OR $admin->get_post('templates') != '' OR $admin->get_post('languages') != '') { |
|
45 |
$system_permissions['addons'] = 1; |
|
46 |
} else { |
|
47 |
$system_permissions['addons'] = 0; |
|
48 |
} |
|
49 |
$system_permissions['modules'] = $admin->get_post('modules'); |
|
50 |
$system_permissions['modules_view'] = $system_permissions['modules']; |
|
51 |
$system_permissions['modules_install'] = $system_permissions['modules']; |
|
52 |
$system_permissions['modules_uninstall'] = $system_permissions['modules']; |
|
53 |
$system_permissions['templates'] = $admin->get_post('templates'); |
|
54 |
$system_permissions['templates_view'] = $system_permissions['templates']; |
|
55 |
$system_permissions['templates_install'] = $system_permissions['templates']; |
|
56 |
$system_permissions['templates_uninstall'] = $system_permissions['templates']; |
|
57 |
$system_permissions['languages'] = $admin->get_post('languages'); |
|
58 |
$system_permissions['languages_view'] = $system_permissions['languages']; |
|
59 |
$system_permissions['languages_install'] = $system_permissions['languages']; |
|
60 |
$system_permissions['languages_uninstall'] = $system_permissions['languages']; |
|
61 |
$system_permissions['settings'] = $admin->get_post('settings'); |
|
62 |
$system_permissions['settings_basic'] = $system_permissions['settings']; |
|
63 |
$system_permissions['settings_advanced'] = $system_permissions['settings']; |
|
64 |
if($admin->get_post('users') != '' AND $admin->get_post('groups') != '') { |
|
65 |
$system_permissions['access'] = 1; |
|
66 |
} else { |
|
67 |
$system_permissions['access'] = 0; |
|
68 |
} |
|
69 |
$system_permissions['users'] = $admin->get_post('users'); |
|
70 |
$system_permissions['users_view'] = $system_permissions['users']; |
|
71 |
$system_permissions['users_add'] = $system_permissions['users']; |
|
72 |
$system_permissions['users_modify'] = $system_permissions['users']; |
|
73 |
$system_permissions['users_delete'] = $system_permissions['users']; |
|
74 |
$system_permissions['groups'] = $admin->get_post('groups'); |
|
75 |
$system_permissions['groups_view'] = $system_permissions['groups']; |
|
76 |
$system_permissions['groups_add'] = $system_permissions['groups']; |
|
77 |
$system_permissions['groups_modify'] = $system_permissions['groups']; |
|
78 |
$system_permissions['groups_delete'] = $system_permissions['groups']; |
|
79 |
} else { |
|
80 |
// Pages |
|
81 |
$system_permissions['pages_view'] = $admin->get_post('pages_view'); |
|
82 |
$system_permissions['pages_add'] = $admin->get_post('pages_add'); |
|
83 |
if($admin->get_post('pages_add') != 1 AND $admin->get_post('pages_add_l0') == 1) { |
|
84 |
$system_permissions['pages_add'] = $admin->get_post('pages_add_l0'); |
|
85 |
} |
|
86 |
$system_permissions['pages_add_l0'] = $admin->get_post('pages_add_l0'); |
|
87 |
$system_permissions['pages_settings'] = $admin->get_post('pages_settings'); |
|
88 |
$system_permissions['pages_modify'] = $admin->get_post('pages_modify'); |
|
89 |
$system_permissions['pages_intro'] = $admin->get_post('pages_intro'); |
|
90 |
$system_permissions['pages_delete'] = $admin->get_post('pages_delete'); |
|
91 |
if($system_permissions['pages_view'] == 1 OR $system_permissions['pages_add'] == 1 OR $system_permissions['pages_settings'] == 1 OR $system_permissions['pages_modify'] == 1 OR $system_permissions['pages_intro'] == 1 OR $system_permissions['pages_delete'] == 1) { |
|
92 |
$system_permissions['pages'] = 1; |
|
93 |
} else { |
|
94 |
$system_permissions['pages'] = ''; |
|
95 |
} |
|
96 |
// Media |
|
97 |
$system_permissions['media_view'] = $admin->get_post('media_view'); |
|
98 |
$system_permissions['media_upload'] = $admin->get_post('media_upload'); |
|
99 |
$system_permissions['media_rename'] = $admin->get_post('media_rename'); |
|
100 |
$system_permissions['media_delete'] = $admin->get_post('media_delete'); |
|
101 |
$system_permissions['media_create'] = $admin->get_post('media_create'); |
|
102 |
if($system_permissions['media_view'] == 1 OR $system_permissions['media_upload'] == 1 OR $system_permissions['media_rename'] == 1 OR $system_permissions['media_delete'] == 1 OR $system_permissions['media_create'] == 1) { |
|
103 |
$system_permissions['media'] = 1; |
|
104 |
} else { |
|
105 |
$system_permissions['media'] = ''; |
|
106 |
} |
|
107 |
// Add-ons |
|
108 |
// Modules |
|
109 |
$system_permissions['modules_view'] = $admin->get_post('modules_view'); |
|
110 |
$system_permissions['modules_install'] = $admin->get_post('modules_install'); |
|
111 |
$system_permissions['modules_uninstall'] = $admin->get_post('modules_uninstall'); |
|
112 |
if($system_permissions['modules_view'] == 1 OR $system_permissions['modules_install'] == 1 OR $system_permissions['modules_uninstall'] == 1) { |
|
113 |
$system_permissions['modules'] = 1; |
|
114 |
} else { |
|
115 |
$system_permissions['modules'] = ''; |
|
116 |
} |
|
117 |
// Templates |
|
118 |
$system_permissions['templates_view'] = $admin->get_post('templates_view'); |
|
119 |
$system_permissions['templates_install'] = $admin->get_post('templates_install'); |
|
120 |
$system_permissions['templates_uninstall'] = $admin->get_post('templates_uninstall'); |
|
121 |
if($system_permissions['templates_view'] == 1 OR $system_permissions['templates_install'] == 1 OR $system_permissions['templates_uninstall'] == 1) { |
|
122 |
$system_permissions['templates'] = 1; |
|
123 |
} else { |
|
124 |
$system_permissions['templates'] = ''; |
|
125 |
} |
|
126 |
// Languages |
|
127 |
$system_permissions['languages_view'] = $admin->get_post('languages_view'); |
|
128 |
$system_permissions['languages_install'] = $admin->get_post('languages_install'); |
|
129 |
$system_permissions['languages_uninstall'] = $admin->get_post('languages_uninstall'); |
|
130 |
if($system_permissions['languages_install'] == 1 OR $system_permissions['languages_uninstall'] == 1) { |
|
131 |
$system_permissions['languages'] = 1; |
|
132 |
} else { |
|
133 |
$system_permissions['languages'] = ''; |
|
134 |
} |
|
135 |
if($system_permissions['modules'] == 1 OR $system_permissions['templates'] == 1 OR $system_permissions['languages'] == 1) { |
|
136 |
$system_permissions['addons'] = 1; |
|
137 |
} else { |
|
138 |
$system_permissions['addons'] = ''; |
|
139 |
} |
|
140 |
// Settings |
|
141 |
$system_permissions['settings_basic'] = $admin->get_post('settings_basic'); |
|
142 |
$system_permissions['settings_advanced'] = $admin->get_post('settings_advanced'); |
|
143 |
if($system_permissions['settings_basic'] == 1 OR $system_permissions['settings_advanced'] == 1) { |
|
144 |
$system_permissions['settings'] = 1; |
|
145 |
} else { |
|
146 |
$system_permissions['settings'] = ''; |
|
147 |
} |
|
148 |
// Access |
|
149 |
// Users |
|
150 |
$system_permissions['users_view'] = $admin->get_post('users_view'); |
|
151 |
$system_permissions['users_add'] = $admin->get_post('users_add'); |
|
152 |
$system_permissions['users_modify'] = $admin->get_post('users_modify'); |
|
153 |
$system_permissions['users_delete'] = $admin->get_post('users_delete'); |
|
154 |
if($system_permissions['users_view'] == 1 OR $system_permissions['users_add'] == 1 OR $system_permissions['users_modify'] == 1 OR $system_permissions['users_delete'] == 1) { |
|
155 |
$system_permissions['users'] = 1; |
|
156 |
} else { |
|
157 |
$system_permissions['users'] = ''; |
|
158 |
} |
|
159 |
// Groups |
|
160 |
$system_permissions['groups_view'] = $admin->get_post('groups_view'); |
|
161 |
$system_permissions['groups_add'] = $admin->get_post('groups_add'); |
|
162 |
$system_permissions['groups_modify'] = $admin->get_post('groups_modify'); |
|
163 |
$system_permissions['groups_delete'] = $admin->get_post('groups_delete'); |
|
164 |
if($system_permissions['groups_view'] == 1 OR $system_permissions['groups_add'] == 1 OR $system_permissions['groups_modify'] == 1 OR $system_permissions['groups_delete'] == 1) { |
|
165 |
$system_permissions['groups'] = 1; |
|
166 |
} else { |
|
167 |
$system_permissions['groups'] = ''; |
|
168 |
} |
|
169 |
if($system_permissions['users'] == 1 OR $system_permissions['groups'] == 1) { |
|
170 |
$system_permissions['access'] = 1; |
|
171 |
} else { |
|
172 |
$system_permissions['access'] = ''; |
|
173 |
} |
|
174 |
} |
|
175 |
|
|
176 |
// Implode system permissions |
|
177 |
$imploded_system_permissions = ''; |
|
178 |
foreach($system_permissions AS $name => $value) { |
|
179 |
if($value == true) { |
|
180 |
if($imploded_system_permissions == '') { |
|
181 |
$imploded_system_permissions = $name; |
|
182 |
} else { |
|
183 |
$imploded_system_permissions .= ','.$name; |
|
184 |
} |
|
185 |
} |
|
186 |
} |
|
187 |
|
|
188 |
$system_permissions = $imploded_system_permissions; |
|
189 |
|
|
190 |
// Get module permissions |
|
191 |
$module_permissions = ''; |
|
192 |
if($handle = opendir(WB_PATH.'/modules/')) { |
|
193 |
while (false !== ($file = readdir($handle))) { |
|
194 |
if($file != "." AND $file != ".." AND $file != ".svn" AND is_dir(WB_PATH."/modules/$file") AND file_exists(WB_PATH."/modules/$file/info.php")) { |
|
195 |
// Include the modules info file |
|
196 |
require(WB_PATH.'/modules/'.$file.'/info.php'); |
|
197 |
// Check if it was selected to be used or not |
|
198 |
$count = 0; |
|
199 |
if(is_array($admin->get_post('module_permissions'))) { |
|
200 |
foreach($admin->get_post('module_permissions') AS $selected_name) { |
|
201 |
if($file == $selected_name) { |
|
202 |
$count = $count+1; |
|
203 |
} |
|
204 |
} |
|
205 |
} |
|
206 |
if($count == 0) { |
|
207 |
// Add unselected modules to list |
|
208 |
if($module_permissions == '') { |
|
209 |
$module_permissions = $file; |
|
210 |
} else { |
|
211 |
$module_permissions .= ','.$file; |
|
212 |
} |
|
213 |
} |
|
214 |
} |
|
215 |
} |
|
216 |
} |
|
217 |
|
|
218 |
// Get template permissions |
|
219 |
$template_permissions = ''; |
|
220 |
if($handle = opendir(WB_PATH.'/templates/')) { |
|
221 |
while (false !== ($file = readdir($handle))) { |
|
222 |
if($file != "." AND $file != ".." AND $file != ".svn" AND is_dir(WB_PATH."/templates/$file") AND file_exists(WB_PATH."/templates/$file/info.php")) { |
|
223 |
// Include the modules info file |
|
224 |
require(WB_PATH.'/templates/'.$file.'/info.php'); |
|
225 |
// Check if it was selected to be used or not |
|
226 |
$count = 0; |
|
227 |
if(is_array($admin->get_post('template_permissions'))) { |
|
228 |
foreach($admin->get_post('template_permissions') AS $selected_name) { |
|
229 |
if($file == $selected_name) { |
|
230 |
$count = $count+1; |
|
231 |
} |
|
232 |
} |
|
233 |
} |
|
234 |
if($count == 0) { |
|
235 |
// Add unselected modules to list |
|
236 |
if($template_permissions == '') { |
|
237 |
$template_permissions = $file; |
|
238 |
} else { |
|
239 |
$template_permissions .= ','.$file; |
|
240 |
} |
|
241 |
} |
|
242 |
} |
|
243 |
} |
|
244 |
} |
|
245 |
|
|
246 |
?> |
|
1 |
<?php |
|
2 |
|
|
3 |
// $Id$ |
|
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 |
if(!defined('WB_PATH')) { exit('Direct access to this file is not allowed'); } |
|
27 |
|
|
28 |
// Get system permissions |
|
29 |
if($admin->get_post('advanced') != 'yes') { |
|
30 |
$system_permissions['pages'] = $admin->get_post('pages'); |
|
31 |
$system_permissions['pages_view'] = $system_permissions['pages']; |
|
32 |
$system_permissions['pages_add'] = $system_permissions['pages']; |
|
33 |
$system_permissions['pages_add_l0'] = $system_permissions['pages']; |
|
34 |
$system_permissions['pages_settings'] = $system_permissions['pages']; |
|
35 |
$system_permissions['pages_modify'] = $system_permissions['pages']; |
|
36 |
$system_permissions['pages_intro'] = $system_permissions['pages']; |
|
37 |
$system_permissions['pages_delete'] = $system_permissions['pages']; |
|
38 |
$system_permissions['media'] = $admin->get_post('media'); |
|
39 |
$system_permissions['media_view'] = $system_permissions['media']; |
|
40 |
$system_permissions['media_upload'] = $system_permissions['media']; |
|
41 |
$system_permissions['media_rename'] = $system_permissions['media']; |
|
42 |
$system_permissions['media_delete'] = $system_permissions['media']; |
|
43 |
$system_permissions['media_create'] = $system_permissions['media']; |
|
44 |
if($admin->get_post('modules') != '' OR $admin->get_post('templates') != '' OR $admin->get_post('languages') != '') { |
|
45 |
$system_permissions['addons'] = 1; |
|
46 |
} else { |
|
47 |
$system_permissions['addons'] = 0; |
|
48 |
} |
|
49 |
$system_permissions['modules'] = $admin->get_post('modules'); |
|
50 |
$system_permissions['modules_view'] = $system_permissions['modules']; |
|
51 |
$system_permissions['modules_install'] = $system_permissions['modules']; |
|
52 |
$system_permissions['modules_uninstall'] = $system_permissions['modules']; |
|
53 |
$system_permissions['templates'] = $admin->get_post('templates'); |
|
54 |
$system_permissions['templates_view'] = $system_permissions['templates']; |
|
55 |
$system_permissions['templates_install'] = $system_permissions['templates']; |
|
56 |
$system_permissions['templates_uninstall'] = $system_permissions['templates']; |
|
57 |
$system_permissions['languages'] = $admin->get_post('languages'); |
|
58 |
$system_permissions['languages_view'] = $system_permissions['languages']; |
|
59 |
$system_permissions['languages_install'] = $system_permissions['languages']; |
|
60 |
$system_permissions['languages_uninstall'] = $system_permissions['languages']; |
|
61 |
$system_permissions['settings'] = $admin->get_post('settings'); |
|
62 |
$system_permissions['settings_basic'] = $system_permissions['settings']; |
|
63 |
$system_permissions['settings_advanced'] = $system_permissions['settings']; |
|
64 |
if($admin->get_post('users') != '' AND $admin->get_post('groups') != '') { |
|
65 |
$system_permissions['access'] = 1; |
|
66 |
} else { |
|
67 |
$system_permissions['access'] = 0; |
|
68 |
} |
|
69 |
$system_permissions['users'] = $admin->get_post('users'); |
|
70 |
$system_permissions['users_view'] = $system_permissions['users']; |
|
71 |
$system_permissions['users_add'] = $system_permissions['users']; |
|
72 |
$system_permissions['users_modify'] = $system_permissions['users']; |
|
73 |
$system_permissions['users_delete'] = $system_permissions['users']; |
|
74 |
$system_permissions['groups'] = $admin->get_post('groups'); |
|
75 |
$system_permissions['groups_view'] = $system_permissions['groups']; |
|
76 |
$system_permissions['groups_add'] = $system_permissions['groups']; |
|
77 |
$system_permissions['groups_modify'] = $system_permissions['groups']; |
|
78 |
$system_permissions['groups_delete'] = $system_permissions['groups']; |
|
79 |
} else { |
|
80 |
// Pages |
|
81 |
$system_permissions['pages_view'] = $admin->get_post('pages_view'); |
|
82 |
$system_permissions['pages_add'] = $admin->get_post('pages_add'); |
|
83 |
if($admin->get_post('pages_add') != 1 AND $admin->get_post('pages_add_l0') == 1) { |
|
84 |
$system_permissions['pages_add'] = $admin->get_post('pages_add_l0'); |
|
85 |
} |
|
86 |
$system_permissions['pages_add_l0'] = $admin->get_post('pages_add_l0'); |
|
87 |
$system_permissions['pages_settings'] = $admin->get_post('pages_settings'); |
|
88 |
$system_permissions['pages_modify'] = $admin->get_post('pages_modify'); |
|
89 |
$system_permissions['pages_intro'] = $admin->get_post('pages_intro'); |
|
90 |
$system_permissions['pages_delete'] = $admin->get_post('pages_delete'); |
|
91 |
if($system_permissions['pages_view'] == 1 OR $system_permissions['pages_add'] == 1 OR $system_permissions['pages_settings'] == 1 OR $system_permissions['pages_modify'] == 1 OR $system_permissions['pages_intro'] == 1 OR $system_permissions['pages_delete'] == 1) { |
|
92 |
$system_permissions['pages'] = 1; |
|
93 |
} else { |
|
94 |
$system_permissions['pages'] = ''; |
|
95 |
} |
|
96 |
// Media |
|
97 |
$system_permissions['media_view'] = $admin->get_post('media_view'); |
|
98 |
$system_permissions['media_upload'] = $admin->get_post('media_upload'); |
|
99 |
$system_permissions['media_rename'] = $admin->get_post('media_rename'); |
|
100 |
$system_permissions['media_delete'] = $admin->get_post('media_delete'); |
|
101 |
$system_permissions['media_create'] = $admin->get_post('media_create'); |
|
102 |
if($system_permissions['media_view'] == 1 OR $system_permissions['media_upload'] == 1 OR $system_permissions['media_rename'] == 1 OR $system_permissions['media_delete'] == 1 OR $system_permissions['media_create'] == 1) { |
|
103 |
$system_permissions['media'] = 1; |
|
104 |
} else { |
|
105 |
$system_permissions['media'] = ''; |
|
106 |
} |
|
107 |
// Add-ons |
|
108 |
// Modules |
|
109 |
$system_permissions['modules_view'] = $admin->get_post('modules_view'); |
|
110 |
$system_permissions['modules_install'] = $admin->get_post('modules_install'); |
|
111 |
$system_permissions['modules_uninstall'] = $admin->get_post('modules_uninstall'); |
|
112 |
if($system_permissions['modules_view'] == 1 OR $system_permissions['modules_install'] == 1 OR $system_permissions['modules_uninstall'] == 1) { |
|
113 |
$system_permissions['modules'] = 1; |
|
114 |
} else { |
|
115 |
$system_permissions['modules'] = ''; |
|
116 |
} |
|
117 |
// Templates |
|
118 |
$system_permissions['templates_view'] = $admin->get_post('templates_view'); |
|
119 |
$system_permissions['templates_install'] = $admin->get_post('templates_install'); |
|
120 |
$system_permissions['templates_uninstall'] = $admin->get_post('templates_uninstall'); |
|
121 |
if($system_permissions['templates_view'] == 1 OR $system_permissions['templates_install'] == 1 OR $system_permissions['templates_uninstall'] == 1) { |
|
122 |
$system_permissions['templates'] = 1; |
|
123 |
} else { |
|
124 |
$system_permissions['templates'] = ''; |
|
125 |
} |
|
126 |
// Languages |
|
127 |
$system_permissions['languages_view'] = $admin->get_post('languages_view'); |
|
128 |
$system_permissions['languages_install'] = $admin->get_post('languages_install'); |
|
129 |
$system_permissions['languages_uninstall'] = $admin->get_post('languages_uninstall'); |
|
130 |
if($system_permissions['languages_install'] == 1 OR $system_permissions['languages_uninstall'] == 1) { |
|
131 |
$system_permissions['languages'] = 1; |
|
132 |
} else { |
|
133 |
$system_permissions['languages'] = ''; |
|
134 |
} |
|
135 |
if($system_permissions['modules'] == 1 OR $system_permissions['templates'] == 1 OR $system_permissions['languages'] == 1) { |
|
136 |
$system_permissions['addons'] = 1; |
|
137 |
} else { |
|
138 |
$system_permissions['addons'] = ''; |
|
139 |
} |
|
140 |
// Settings |
|
141 |
$system_permissions['settings_basic'] = $admin->get_post('settings_basic'); |
|
142 |
$system_permissions['settings_advanced'] = $admin->get_post('settings_advanced'); |
|
143 |
if($system_permissions['settings_basic'] == 1 OR $system_permissions['settings_advanced'] == 1) { |
|
144 |
$system_permissions['settings'] = 1; |
|
145 |
} else { |
|
146 |
$system_permissions['settings'] = ''; |
|
147 |
} |
|
148 |
// Access |
|
149 |
// Users |
|
150 |
$system_permissions['users_view'] = $admin->get_post('users_view'); |
|
151 |
$system_permissions['users_add'] = $admin->get_post('users_add'); |
|
152 |
$system_permissions['users_modify'] = $admin->get_post('users_modify'); |
|
153 |
$system_permissions['users_delete'] = $admin->get_post('users_delete'); |
|
154 |
if($system_permissions['users_view'] == 1 OR $system_permissions['users_add'] == 1 OR $system_permissions['users_modify'] == 1 OR $system_permissions['users_delete'] == 1) { |
|
155 |
$system_permissions['users'] = 1; |
|
156 |
} else { |
|
157 |
$system_permissions['users'] = ''; |
|
158 |
} |
|
159 |
// Groups |
|
160 |
$system_permissions['groups_view'] = $admin->get_post('groups_view'); |
|
161 |
$system_permissions['groups_add'] = $admin->get_post('groups_add'); |
|
162 |
$system_permissions['groups_modify'] = $admin->get_post('groups_modify'); |
|
163 |
$system_permissions['groups_delete'] = $admin->get_post('groups_delete'); |
|
164 |
if($system_permissions['groups_view'] == 1 OR $system_permissions['groups_add'] == 1 OR $system_permissions['groups_modify'] == 1 OR $system_permissions['groups_delete'] == 1) { |
|
165 |
$system_permissions['groups'] = 1; |
|
166 |
} else { |
|
167 |
$system_permissions['groups'] = ''; |
|
168 |
} |
|
169 |
if($system_permissions['users'] == 1 OR $system_permissions['groups'] == 1) { |
|
170 |
$system_permissions['access'] = 1; |
|
171 |
} else { |
|
172 |
$system_permissions['access'] = ''; |
|
173 |
} |
|
174 |
} |
|
175 |
|
|
176 |
// Implode system permissions |
|
177 |
$imploded_system_permissions = ''; |
|
178 |
foreach($system_permissions AS $name => $value) { |
|
179 |
if($value == true) { |
|
180 |
if($imploded_system_permissions == '') { |
|
181 |
$imploded_system_permissions = $name; |
|
182 |
} else { |
|
183 |
$imploded_system_permissions .= ','.$name; |
|
184 |
} |
|
185 |
} |
|
186 |
} |
|
187 |
|
|
188 |
$system_permissions = $imploded_system_permissions; |
|
189 |
|
|
190 |
// Get module permissions |
|
191 |
$module_permissions = ''; |
|
192 |
if($handle = opendir(WB_PATH.'/modules/')) { |
|
193 |
while (false !== ($file = readdir($handle))) { |
|
194 |
if($file != "." AND $file != ".." AND $file != ".svn" AND is_dir(WB_PATH."/modules/$file") AND file_exists(WB_PATH."/modules/$file/info.php")) { |
|
195 |
// Include the modules info file |
|
196 |
require(WB_PATH.'/modules/'.$file.'/info.php'); |
|
197 |
// Check if it was selected to be used or not |
|
198 |
$count = 0; |
|
199 |
if(is_array($admin->get_post('module_permissions'))) { |
|
200 |
foreach($admin->get_post('module_permissions') AS $selected_name) { |
|
201 |
if($file == $selected_name) { |
|
202 |
$count = $count+1; |
|
203 |
} |
|
204 |
} |
|
205 |
} |
|
206 |
if($count == 0) { |
|
207 |
// Add unselected modules to list |
|
208 |
if($module_permissions == '') { |
|
209 |
$module_permissions = $file; |
|
210 |
} else { |
|
211 |
$module_permissions .= ','.$file; |
|
212 |
} |
|
213 |
} |
|
214 |
} |
|
215 |
} |
|
216 |
} |
|
217 |
|
|
218 |
// Get template permissions |
|
219 |
$template_permissions = ''; |
|
220 |
if($handle = opendir(WB_PATH.'/templates/')) { |
|
221 |
while (false !== ($file = readdir($handle))) { |
|
222 |
if($file != "." AND $file != ".." AND $file != ".svn" AND is_dir(WB_PATH."/templates/$file") AND file_exists(WB_PATH."/templates/$file/info.php")) { |
|
223 |
// Include the modules info file |
|
224 |
require(WB_PATH.'/templates/'.$file.'/info.php'); |
|
225 |
// Check if it was selected to be used or not |
|
226 |
$count = 0; |
|
227 |
if(is_array($admin->get_post('template_permissions'))) { |
|
228 |
foreach($admin->get_post('template_permissions') AS $selected_name) { |
|
229 |
if($file == $selected_name) { |
|
230 |
$count = $count+1; |
|
231 |
} |
|
232 |
} |
|
233 |
} |
|
234 |
if($count == 0) { |
|
235 |
// Add unselected modules to list |
|
236 |
if($template_permissions == '') { |
|
237 |
$template_permissions = $file; |
|
238 |
} else { |
|
239 |
$template_permissions .= ','.$file; |
|
240 |
} |
|
241 |
} |
|
242 |
} |
|
243 |
} |
|
244 |
} |
|
245 |
|
|
246 |
?> |
trunk/wb/admin/groups/groups.php | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
// $Id$ |
|
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 |
// Include config file and admin class file |
|
27 |
require('../../config.php'); |
|
28 |
require_once(WB_PATH.'/framework/class.admin.php'); |
|
29 |
|
|
30 |
// Create new database object |
|
31 |
$database = new database(); |
|
32 |
|
|
33 |
if(!isset($_POST['action']) OR $_POST['action'] != "modify" AND $_POST['action'] != "delete") { |
|
34 |
header("Location: index.php"); |
|
35 |
} |
|
36 |
|
|
37 |
// Check if group group_id is a valid number and doesnt equal 1 |
|
38 |
if(!isset($_POST['group_id']) OR !is_numeric($_POST['group_id']) OR $_POST['group_id'] == 1) { |
|
39 |
header("Location: index.php"); |
|
40 |
} |
|
41 |
|
|
42 |
if($_POST['action'] == 'modify') { |
|
43 |
// Create new admin object |
|
44 |
$admin = new admin('Access', 'groups_modify', false); |
|
45 |
// Print header |
|
46 |
$admin->print_header(); |
|
47 |
// Get existing values |
|
48 |
$results = $database->query("SELECT * FROM ".TABLE_PREFIX."groups WHERE group_id = '".$_POST['group_id']."'"); |
|
49 |
$group = $results->fetchRow(); |
|
50 |
// Setup template object |
|
51 |
$template = new Template(ADMIN_PATH.'/groups'); |
|
52 |
$template->set_file('page', 'group_form.html'); |
|
53 |
$template->set_block('page', 'main_block', 'main'); |
|
54 |
$template->set_var( array( |
|
55 |
'ACTION_URL' => ADMIN_URL.'/groups/save.php', |
|
56 |
'SUBMIT_TITLE' => $TEXT['SAVE'], |
|
57 |
'GROUP_ID' => $group['group_id'], |
|
58 |
'GROUP_NAME' => $group['name'], |
|
59 |
'ADVANCED_ACTION' => 'groups.php' |
|
60 |
) |
|
61 |
); |
|
62 |
// Tell the browser whether or not to show advanced options |
|
63 |
if(isset($_POST['advanced']) AND $_POST['advanced'] == $TEXT['SHOW_ADVANCED'].' >>') { |
|
64 |
$template->set_var('DISPLAY_ADVANCED', ''); |
|
65 |
$template->set_var('DISPLAY_BASIC', 'none'); |
|
66 |
$template->set_var('ADVANCED', 'yes'); |
|
67 |
$template->set_var('ADVANCED_BUTTON', '<< '.$TEXT['HIDE_ADVANCED']); |
|
68 |
} else { |
|
69 |
$template->set_var('DISPLAY_ADVANCED', 'none'); |
|
70 |
$template->set_var('DISPLAY_BASIC', ''); |
|
71 |
$template->set_var('ADVANCED', 'no'); |
|
72 |
$template->set_var('ADVANCED_BUTTON', $TEXT['SHOW_ADVANCED'].' >>'); |
|
73 |
} |
|
74 |
|
|
75 |
// Explode system permissions |
|
76 |
$system_permissions = explode(',', $group['system_permissions']); |
|
77 |
// Check system permissions boxes |
|
78 |
foreach($system_permissions AS $name) { |
|
79 |
$template->set_var($name.'_checked', 'checked'); |
|
80 |
} |
|
81 |
// Explode module permissions |
|
82 |
$module_permissions = explode(',', $group['module_permissions']); |
|
83 |
// Explode template permissions |
|
84 |
$template_permissions = explode(',', $group['template_permissions']); |
|
85 |
|
|
86 |
// Insert values into module list |
|
87 |
$template->set_block('main_block', 'module_list_block', 'module_list'); |
|
88 |
$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'module' AND function = 'page'"); |
|
89 |
if($result->numRows() > 0) { |
|
90 |
while($addon = $result->fetchRow()) { |
|
91 |
$template->set_var('VALUE', $addon['directory']); |
|
92 |
$template->set_var('NAME', $addon['name']); |
|
93 |
if(!is_numeric(array_search($addon['directory'], $module_permissions))) { |
|
94 |
$template->set_var('CHECKED', 'checked'); |
|
95 |
} else { |
|
96 |
$template->set_var('CHECKED', ''); |
|
97 |
} |
|
98 |
$template->parse('module_list', 'module_list_block', true); |
|
99 |
} |
|
100 |
} |
|
101 |
|
|
102 |
// Insert values into template list |
|
103 |
$template->set_block('main_block', 'template_list_block', 'template_list'); |
|
104 |
$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'template'"); |
|
105 |
if($result->numRows() > 0) { |
|
106 |
while($addon = $result->fetchRow()) { |
|
107 |
$template->set_var('VALUE', $addon['directory']); |
|
108 |
$template->set_var('NAME', $addon['name']); |
|
109 |
if(!is_numeric(array_search($addon['directory'], $template_permissions))) { |
|
110 |
$template->set_var('CHECKED', 'checked'); |
|
111 |
} else { |
|
112 |
$template->set_var('CHECKED', ''); |
|
113 |
} |
|
114 |
$template->parse('template_list', 'template_list_block', true); |
|
115 |
} |
|
116 |
} |
|
117 |
|
|
118 |
// Insert language text and messages |
|
119 |
$template->set_var(array( |
|
120 |
'TEXT_RESET' => $TEXT['RESET'], |
|
121 |
'TEXT_ACTIVE' => $TEXT['ACTIVE'], |
|
122 |
'TEXT_DISABLED' => $TEXT['DISABLED'], |
|
123 |
'TEXT_PLEASE_SELECT' => $TEXT['PLEASE_SELECT'], |
|
124 |
'TEXT_USERNAME' => $TEXT['USERNAME'], |
|
125 |
'TEXT_PASSWORD' => $TEXT['PASSWORD'], |
|
126 |
'TEXT_RETYPE_PASSWORD' => $TEXT['RETYPE_PASSWORD'], |
|
127 |
'TEXT_DISPLAY_NAME' => $TEXT['DISPLAY_NAME'], |
|
128 |
'TEXT_EMAIL' => $TEXT['EMAIL'], |
|
129 |
'TEXT_GROUP' => $TEXT['GROUP'], |
|
130 |
'TEXT_SYSTEM_PERMISSIONS' => $TEXT['SYSTEM_PERMISSIONS'], |
|
131 |
'TEXT_MODULE_PERMISSIONS' => $TEXT['MODULE_PERMISSIONS'], |
|
132 |
'TEXT_TEMPLATE_PERMISSIONS' => $TEXT['TEMPLATE_PERMISSIONS'], |
|
133 |
'TEXT_NAME' => $TEXT['NAME'], |
|
134 |
'SECTION_PAGES' => $MENU['PAGES'], |
|
135 |
'SECTION_MEDIA' => $MENU['MEDIA'], |
|
136 |
'SECTION_MODULES' => $MENU['MODULES'], |
|
137 |
'SECTION_TEMPLATES' => $MENU['TEMPLATES'], |
|
138 |
'SECTION_LANGUAGES' => $MENU['LANGUAGES'], |
|
139 |
'SECTION_SETTINGS' => $MENU['SETTINGS'], |
|
140 |
'SECTION_USERS' => $MENU['USERS'], |
|
141 |
'SECTION_GROUPS' => $MENU['GROUPS'], |
|
142 |
'TEXT_VIEW' => $TEXT['VIEW'], |
|
143 |
'TEXT_ADD' => $TEXT['ADD'], |
|
144 |
'TEXT_LEVEL' => $TEXT['LEVEL'], |
|
145 |
'TEXT_MODIFY' => $TEXT['MODIFY'], |
|
146 |
'TEXT_DELETE' => $TEXT['DELETE'], |
|
147 |
'TEXT_MODIFY_CONTENT' => $TEXT['MODIFY_CONTENT'], |
|
148 |
'TEXT_MODIFY_SETTINGS' => $TEXT['MODIFY_SETTINGS'], |
|
149 |
'HEADING_MODIFY_INTRO_PAGE' => $HEADING['MODIFY_INTRO_PAGE'], |
|
150 |
'TEXT_CREATE_FOLDER' => $TEXT['CREATE_FOLDER'], |
|
151 |
'TEXT_RENAME' => $TEXT['RENAME'], |
|
152 |
'TEXT_UPLOAD_FILES' => $TEXT['UPLOAD_FILES'], |
|
153 |
'TEXT_BASIC' => $TEXT['BASIC'], |
|
154 |
'TEXT_ADVANCED' => $TEXT['ADVANCED'], |
|
155 |
'CHANGING_PASSWORD' => $MESSAGE['USERS']['CHANGING_PASSWORD'] |
|
156 |
) |
|
157 |
); |
|
158 |
|
|
159 |
// Parse template object |
|
160 |
$template->parse('main', 'main_block', false); |
|
161 |
$template->pparse('output', 'page'); |
|
162 |
} elseif($_POST['action'] == 'delete') { |
|
163 |
// Create new admin object |
|
164 |
$admin = new admin('Access', 'groups_delete', false); |
|
165 |
// Print header |
|
166 |
$admin->print_header(); |
|
167 |
// Delete the group |
|
168 |
$database->query("DELETE FROM ".TABLE_PREFIX."groups WHERE group_id = '".$_POST['group_id']."' LIMIT 1"); |
|
169 |
if($database->is_error()) { |
|
170 |
$admin->print_error($database->get_error()); |
|
171 |
} else { |
|
172 |
// Delete users in the group |
|
173 |
$database->query("DELETE FROM ".TABLE_PREFIX."users WHERE group_id = '".$_POST['group_id']."'"); |
|
174 |
if($database->is_error()) { |
|
175 |
$admin->print_error($database->get_error()); |
|
176 |
} else { |
|
177 |
$admin->print_success($MESSAGE['GROUPS']['DELETED']); |
|
178 |
} |
|
179 |
} |
|
180 |
} |
|
181 |
|
|
182 |
// Print admin footer |
|
183 |
$admin->print_footer(); |
|
184 |
|
|
185 |
?> |
|
1 |
<?php |
|
2 |
|
|
3 |
// $Id$ |
|
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 |
// Include config file and admin class file |
|
27 |
require('../../config.php'); |
|
28 |
require_once(WB_PATH.'/framework/class.admin.php'); |
|
29 |
|
|
30 |
// Create new database object |
|
31 |
$database = new database(); |
|
32 |
|
|
33 |
if(!isset($_POST['action']) OR $_POST['action'] != "modify" AND $_POST['action'] != "delete") { |
|
34 |
header("Location: index.php"); |
|
35 |
} |
|
36 |
|
|
37 |
// Check if group group_id is a valid number and doesnt equal 1 |
|
38 |
if(!isset($_POST['group_id']) OR !is_numeric($_POST['group_id']) OR $_POST['group_id'] == 1) { |
|
39 |
header("Location: index.php"); |
|
40 |
} |
|
41 |
|
|
42 |
if($_POST['action'] == 'modify') { |
|
43 |
// Create new admin object |
|
44 |
$admin = new admin('Access', 'groups_modify', false); |
|
45 |
// Print header |
|
46 |
$admin->print_header(); |
|
47 |
// Get existing values |
|
48 |
$results = $database->query("SELECT * FROM ".TABLE_PREFIX."groups WHERE group_id = '".$_POST['group_id']."'"); |
|
49 |
$group = $results->fetchRow(); |
|
50 |
// Setup template object |
|
51 |
$template = new Template(ADMIN_PATH.'/groups'); |
|
52 |
$template->set_file('page', 'group_form.html'); |
|
53 |
$template->set_block('page', 'main_block', 'main'); |
|
54 |
$template->set_var( array( |
|
55 |
'ACTION_URL' => ADMIN_URL.'/groups/save.php', |
|
56 |
'SUBMIT_TITLE' => $TEXT['SAVE'], |
|
57 |
'GROUP_ID' => $group['group_id'], |
|
58 |
'GROUP_NAME' => $group['name'], |
|
59 |
'ADVANCED_ACTION' => 'groups.php' |
|
60 |
) |
|
61 |
); |
|
62 |
// Tell the browser whether or not to show advanced options |
|
63 |
if(isset($_POST['advanced']) AND $_POST['advanced'] == $TEXT['SHOW_ADVANCED'].' >>') { |
|
64 |
$template->set_var('DISPLAY_ADVANCED', ''); |
|
65 |
$template->set_var('DISPLAY_BASIC', 'none'); |
|
66 |
$template->set_var('ADVANCED', 'yes'); |
|
67 |
$template->set_var('ADVANCED_BUTTON', '<< '.$TEXT['HIDE_ADVANCED']); |
|
68 |
} else { |
|
69 |
$template->set_var('DISPLAY_ADVANCED', 'none'); |
|
70 |
$template->set_var('DISPLAY_BASIC', ''); |
|
71 |
$template->set_var('ADVANCED', 'no'); |
|
72 |
$template->set_var('ADVANCED_BUTTON', $TEXT['SHOW_ADVANCED'].' >>'); |
|
73 |
} |
|
74 |
|
|
75 |
// Explode system permissions |
|
76 |
$system_permissions = explode(',', $group['system_permissions']); |
|
77 |
// Check system permissions boxes |
|
78 |
foreach($system_permissions AS $name) { |
|
79 |
$template->set_var($name.'_checked', 'checked'); |
|
80 |
} |
|
81 |
// Explode module permissions |
|
82 |
$module_permissions = explode(',', $group['module_permissions']); |
|
83 |
// Explode template permissions |
|
84 |
$template_permissions = explode(',', $group['template_permissions']); |
|
85 |
|
|
86 |
// Insert values into module list |
|
87 |
$template->set_block('main_block', 'module_list_block', 'module_list'); |
|
88 |
$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'module' AND function = 'page'"); |
|
89 |
if($result->numRows() > 0) { |
|
90 |
while($addon = $result->fetchRow()) { |
|
91 |
$template->set_var('VALUE', $addon['directory']); |
|
92 |
$template->set_var('NAME', $addon['name']); |
|
93 |
if(!is_numeric(array_search($addon['directory'], $module_permissions))) { |
|
94 |
$template->set_var('CHECKED', 'checked'); |
|
95 |
} else { |
|
96 |
$template->set_var('CHECKED', ''); |
|
97 |
} |
|
98 |
$template->parse('module_list', 'module_list_block', true); |
|
99 |
} |
|
100 |
} |
|
101 |
|
|
102 |
// Insert values into template list |
|
103 |
$template->set_block('main_block', 'template_list_block', 'template_list'); |
|
104 |
$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'template'"); |
|
105 |
if($result->numRows() > 0) { |
|
106 |
while($addon = $result->fetchRow()) { |
|
107 |
$template->set_var('VALUE', $addon['directory']); |
|
108 |
$template->set_var('NAME', $addon['name']); |
|
109 |
if(!is_numeric(array_search($addon['directory'], $template_permissions))) { |
|
110 |
$template->set_var('CHECKED', 'checked'); |
|
111 |
} else { |
|
112 |
$template->set_var('CHECKED', ''); |
|
113 |
} |
|
114 |
$template->parse('template_list', 'template_list_block', true); |
|
115 |
} |
|
116 |
} |
|
117 |
|
|
118 |
// Insert language text and messages |
|
119 |
$template->set_var(array( |
|
120 |
'TEXT_RESET' => $TEXT['RESET'], |
|
121 |
'TEXT_ACTIVE' => $TEXT['ACTIVE'], |
|
122 |
'TEXT_DISABLED' => $TEXT['DISABLED'], |
|
123 |
'TEXT_PLEASE_SELECT' => $TEXT['PLEASE_SELECT'], |
|
124 |
'TEXT_USERNAME' => $TEXT['USERNAME'], |
|
125 |
'TEXT_PASSWORD' => $TEXT['PASSWORD'], |
|
126 |
'TEXT_RETYPE_PASSWORD' => $TEXT['RETYPE_PASSWORD'], |
|
127 |
'TEXT_DISPLAY_NAME' => $TEXT['DISPLAY_NAME'], |
|
128 |
'TEXT_EMAIL' => $TEXT['EMAIL'], |
|
129 |
'TEXT_GROUP' => $TEXT['GROUP'], |
|
130 |
'TEXT_SYSTEM_PERMISSIONS' => $TEXT['SYSTEM_PERMISSIONS'], |
|
131 |
'TEXT_MODULE_PERMISSIONS' => $TEXT['MODULE_PERMISSIONS'], |
|
132 |
'TEXT_TEMPLATE_PERMISSIONS' => $TEXT['TEMPLATE_PERMISSIONS'], |
|
133 |
'TEXT_NAME' => $TEXT['NAME'], |
|
134 |
'SECTION_PAGES' => $MENU['PAGES'], |
|
135 |
'SECTION_MEDIA' => $MENU['MEDIA'], |
|
136 |
'SECTION_MODULES' => $MENU['MODULES'], |
|
137 |
'SECTION_TEMPLATES' => $MENU['TEMPLATES'], |
|
138 |
'SECTION_LANGUAGES' => $MENU['LANGUAGES'], |
|
139 |
'SECTION_SETTINGS' => $MENU['SETTINGS'], |
|
140 |
'SECTION_USERS' => $MENU['USERS'], |
|
141 |
'SECTION_GROUPS' => $MENU['GROUPS'], |
|
142 |
'TEXT_VIEW' => $TEXT['VIEW'], |
|
143 |
'TEXT_ADD' => $TEXT['ADD'], |
|
144 |
'TEXT_LEVEL' => $TEXT['LEVEL'], |
|
145 |
'TEXT_MODIFY' => $TEXT['MODIFY'], |
|
146 |
'TEXT_DELETE' => $TEXT['DELETE'], |
|
147 |
'TEXT_MODIFY_CONTENT' => $TEXT['MODIFY_CONTENT'], |
|
148 |
'TEXT_MODIFY_SETTINGS' => $TEXT['MODIFY_SETTINGS'], |
|
149 |
'HEADING_MODIFY_INTRO_PAGE' => $HEADING['MODIFY_INTRO_PAGE'], |
|
150 |
'TEXT_CREATE_FOLDER' => $TEXT['CREATE_FOLDER'], |
|
151 |
'TEXT_RENAME' => $TEXT['RENAME'], |
|
152 |
'TEXT_UPLOAD_FILES' => $TEXT['UPLOAD_FILES'], |
|
153 |
'TEXT_BASIC' => $TEXT['BASIC'], |
|
154 |
'TEXT_ADVANCED' => $TEXT['ADVANCED'], |
|
155 |
'CHANGING_PASSWORD' => $MESSAGE['USERS']['CHANGING_PASSWORD'] |
|
156 |
) |
|
157 |
); |
|
158 |
|
|
159 |
// Parse template object |
|
160 |
$template->parse('main', 'main_block', false); |
|
161 |
$template->pparse('output', 'page'); |
|
162 |
} elseif($_POST['action'] == 'delete') { |
|
163 |
// Create new admin object |
|
164 |
$admin = new admin('Access', 'groups_delete', false); |
|
165 |
// Print header |
|
166 |
$admin->print_header(); |
|
167 |
// Delete the group |
|
168 |
$database->query("DELETE FROM ".TABLE_PREFIX."groups WHERE group_id = '".$_POST['group_id']."' LIMIT 1"); |
|
169 |
if($database->is_error()) { |
|
170 |
$admin->print_error($database->get_error()); |
|
171 |
} else { |
|
172 |
// Delete users in the group |
|
173 |
$database->query("DELETE FROM ".TABLE_PREFIX."users WHERE group_id = '".$_POST['group_id']."'"); |
|
174 |
if($database->is_error()) { |
|
175 |
$admin->print_error($database->get_error()); |
|
176 |
} else { |
|
177 |
$admin->print_success($MESSAGE['GROUPS']['DELETED']); |
|
178 |
} |
|
179 |
} |
|
180 |
} |
|
181 |
|
|
182 |
// Print admin footer |
|
183 |
$admin->print_footer(); |
|
184 |
|
|
185 |
?> |
trunk/wb/admin/media/rename2.php | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
/* |
|
4 |
|
|
5 |
Website Baker Project <http://www.websitebaker.org/> |
|
6 |
Copyright (C) 2004-2005, Ryan Djurovich |
|
7 |
|
|
8 |
Website Baker is free software; you can redistribute it and/or modify |
|
9 |
it under the terms of the GNU General Public License as published by |
|
10 |
the Free Software Foundation; either version 2 of the License, or |
|
11 |
(at your option) any later version. |
|
12 |
|
|
13 |
Website Baker is distributed in the hope that it will be useful, |
|
14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
GNU General Public License for more details. |
|
17 |
|
|
18 |
You should have received a copy of the GNU General Public License |
|
19 |
along with Website Baker; if not, write to the Free Software |
|
20 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
21 |
|
|
22 |
*/ |
|
23 |
|
|
24 |
// Create admin object |
|
25 |
require('../../config.php'); |
|
26 |
require_once(WB_PATH.'/framework/class.admin.php'); |
|
27 |
$admin = new admin('Media', 'media_rename', false); |
|
28 |
|
|
29 |
// Include the WB functions file |
|
30 |
require_once(WB_PATH.'/framework/functions.php'); |
|
31 |
|
|
32 |
// Include the basic header file |
|
33 |
require(ADMIN_PATH.'/media/basic_header.html'); |
|
34 |
|
|
35 |
// Get list of file types to which we're supposed to append 'txt' |
|
36 |
$get_result=$database->query("SELECT value FROM ".TABLE_PREFIX."settings WHERE name='rename_files_on_upload' LIMIT 1"); |
|
37 |
$file_extension_string=''; |
|
38 |
if ($get_result->numRows()>0) { |
|
39 |
$fetch_result=$get_result->fetchRow(); |
|
40 |
$file_extension_string=$fetch_result['value']; |
|
41 |
} |
|
42 |
$file_extensions=explode(",",$file_extension_string); |
|
43 |
|
|
44 |
|
|
45 |
// Get the current dir |
|
46 |
$directory = $admin->get_post('dir'); |
|
47 |
if($directory == '/') { |
|
48 |
$directory = ''; |
|
49 |
} |
|
50 |
// Check to see if it contains ../ |
|
51 |
if(strstr($directory, '../')) { |
|
52 |
$admin->print_header(); |
|
53 |
$admin->print_error($MESSAGE['MEDIA']['DIR_DOT_DOT_SLASH']); |
|
54 |
} |
|
55 |
|
|
56 |
// Get the temp id |
|
57 |
if(!is_numeric($admin->get_post('id'))) { |
|
58 |
header("Location: browse.php?dir=$directory"); |
|
59 |
} else { |
|
60 |
$file_id = $admin->get_post('id'); |
|
61 |
} |
|
62 |
|
|
63 |
// Get home folder not to show |
|
64 |
$home_folders = get_home_folders(); |
|
65 |
|
|
66 |
// Figure out what folder name the temp id is |
|
67 |
if($handle = opendir(WB_PATH.MEDIA_DIRECTORY.'/'.$directory)) { |
|
68 |
// Loop through the files and dirs an add to list |
|
69 |
while (false !== ($file = readdir($handle))) { |
|
70 |
if(substr($file, 0, 1) != '.' AND $file != '.svn' AND $file != 'index.php') { |
|
71 |
if(is_dir(WB_PATH.MEDIA_DIRECTORY.$directory.'/'.$file)) { |
|
72 |
if(!isset($home_folders[$directory.'/'.$file])) { |
|
73 |
$DIR[] = $file; |
|
74 |
} |
|
75 |
} else { |
|
76 |
$FILE[] = $file; |
|
77 |
} |
|
78 |
} |
|
79 |
} |
|
80 |
$temp_id = 0; |
|
81 |
if(isset($DIR)) { |
|
82 |
foreach($DIR AS $name) { |
|
83 |
$temp_id++; |
|
84 |
if($file_id == $temp_id) { |
|
85 |
$rename_file = $name; |
|
86 |
$type = 'folder'; |
|
87 |
} |
|
88 |
} |
|
89 |
} |
|
90 |
if(isset($FILE)) { |
|
91 |
foreach($FILE AS $name) { |
|
92 |
$temp_id++; |
|
93 |
if($file_id == $temp_id) { |
|
94 |
$rename_file = $name; |
|
95 |
$type = 'file'; |
|
96 |
} |
|
97 |
} |
|
98 |
} |
|
99 |
} |
|
100 |
|
|
101 |
if(!isset($rename_file)) { |
|
102 |
$admin->print_error($MESSAGE['MEDIA']['FILE_NOT_FOUND'], "browse.php?dir=$directory", false); |
|
103 |
} |
|
104 |
|
|
105 |
// Check if they entered a new name |
|
106 |
if(media_filename($admin->get_post('name')) == "") { |
|
107 |
$admin->print_error($MESSAGE['MEDIA']['BLANK_NAME'], "rename.php?dir=$directory&id=$file_id", false); |
|
108 |
} else { |
|
109 |
$old_name = $admin->get_post('old_name'); |
|
110 |
$new_name = media_filename($admin->get_post('name')); |
|
111 |
} |
|
112 |
|
|
113 |
// Check if they entered an extension |
|
114 |
if($type == 'file') { |
|
115 |
if(media_filename($admin->get_post('extension')) == "") { |
|
116 |
$admin->print_error($MESSAGE['MEDIA']['BLANK_EXTENSION'], "rename.php?dir=$directory&id=$file_id", false); |
|
117 |
} else { |
|
118 |
$extension = media_filename($admin->get_post('extension')); |
|
119 |
} |
|
120 |
} else { |
|
121 |
$extension = ''; |
|
122 |
} |
|
123 |
|
|
124 |
// Join new name and extension |
|
125 |
$name = $new_name.$extension; |
|
126 |
|
|
127 |
// Check if the name contains .. |
|
128 |
if(strstr($name, '..')) { |
|
129 |
$admin->print_error($MESSAGE['MEDIA']['NAME_DOT_DOT_SLASH'], "rename.php?dir=$directory&id=$file_id", false); |
|
130 |
} |
|
131 |
|
|
132 |
// Check if the name is index.php |
|
133 |
if($name == 'index.php') { |
|
134 |
$admin->print_error($MESSAGE['MEDIA']['NAME_INDEX_PHP'], "rename.php?dir=$directory&id=$file_id", false); |
|
135 |
} |
|
136 |
|
|
137 |
// Check that the name still has a value |
|
138 |
if($name == '') { |
|
139 |
$admin->print_error($MESSAGE['MEDIA']['BLANK_NAME'], "rename.php?dir=$directory&id=$file_id", false); |
|
140 |
} |
|
141 |
|
|
142 |
// Check for potentially malicious files and append 'txt' to their name |
|
143 |
foreach($file_extensions as $file_ext) { |
|
144 |
$file_ext_len=strlen($file_ext); |
|
145 |
if (substr($name,-$file_ext_len)==$file_ext) { |
|
146 |
$name.='.txt'; |
|
147 |
} |
|
148 |
} |
|
149 |
|
|
150 |
|
|
151 |
// Check if we should overwrite or not |
|
152 |
if($admin->get_post('overwrite') != 'yes' AND file_exists(WB_PATH.MEDIA_DIRECTORY.$directory.'/'.$name) == true) { |
|
153 |
if($type == 'folder') { |
|
154 |
$admin->print_error($MESSAGE['MEDIA']['DIR_EXISTS'], "rename.php?dir=$directory&id=$file_id", false); |
|
155 |
} else { |
|
156 |
$admin->print_error($MESSAGE['MEDIA']['FILE_EXISTS'], "rename.php?dir=$directory&id=$file_id", false); |
|
157 |
} |
|
158 |
} |
|
159 |
|
|
160 |
// Try and rename the file/folder |
|
161 |
if(rename(WB_PATH.MEDIA_DIRECTORY.$directory.'/'.$rename_file, WB_PATH.MEDIA_DIRECTORY.$directory.'/'.$name)) { |
|
162 |
$admin->print_success($MESSAGE['MEDIA']['RENAMED'], "browse.php?dir=$directory"); |
|
163 |
} else { |
|
164 |
$admin->print_error($MESSAGE['MEDIA']['CANNOT_RENAME'], "rename.php?dir=$directory&id=$file_id", false); |
|
165 |
} |
|
166 |
|
|
167 |
?> |
|
1 |
<?php |
|
2 |
|
|
3 |
/* |
|
4 |
|
|
5 |
Website Baker Project <http://www.websitebaker.org/> |
|
6 |
Copyright (C) 2004-2005, Ryan Djurovich |
|
7 |
|
|
8 |
Website Baker is free software; you can redistribute it and/or modify |
|
9 |
it under the terms of the GNU General Public License as published by |
|
10 |
the Free Software Foundation; either version 2 of the License, or |
|
11 |
(at your option) any later version. |
|
12 |
|
|
13 |
Website Baker is distributed in the hope that it will be useful, |
|
14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
GNU General Public License for more details. |
|
17 |
|
|
18 |
You should have received a copy of the GNU General Public License |
|
19 |
along with Website Baker; if not, write to the Free Software |
|
20 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
21 |
|
|
22 |
*/ |
|
23 |
|
|
24 |
// Create admin object |
|
25 |
require('../../config.php'); |
|
26 |
require_once(WB_PATH.'/framework/class.admin.php'); |
|
27 |
$admin = new admin('Media', 'media_rename', false); |
|
28 |
|
|
29 |
// Include the WB functions file |
|
30 |
require_once(WB_PATH.'/framework/functions.php'); |
|
31 |
|
|
32 |
// Include the basic header file |
|
33 |
require(ADMIN_PATH.'/media/basic_header.html'); |
|
34 |
|
|
35 |
// Get list of file types to which we're supposed to append 'txt' |
|
36 |
$get_result=$database->query("SELECT value FROM ".TABLE_PREFIX."settings WHERE name='rename_files_on_upload' LIMIT 1"); |
|
37 |
$file_extension_string=''; |
|
38 |
if ($get_result->numRows()>0) { |
|
39 |
$fetch_result=$get_result->fetchRow(); |
|
40 |
$file_extension_string=$fetch_result['value']; |
|
41 |
} |
|
42 |
$file_extensions=explode(",",$file_extension_string); |
|
43 |
|
|
44 |
|
|
45 |
// Get the current dir |
|
46 |
$directory = $admin->get_post('dir'); |
|
47 |
if($directory == '/') { |
|
48 |
$directory = ''; |
|
49 |
} |
|
50 |
// Check to see if it contains ../ |
|
51 |
if(strstr($directory, '../')) { |
|
52 |
$admin->print_header(); |
|
53 |
$admin->print_error($MESSAGE['MEDIA']['DIR_DOT_DOT_SLASH']); |
|
54 |
} |
|
55 |
|
|
56 |
// Get the temp id |
|
57 |
if(!is_numeric($admin->get_post('id'))) { |
|
58 |
header("Location: browse.php?dir=$directory"); |
|
59 |
} else { |
|
60 |
$file_id = $admin->get_post('id'); |
|
61 |
} |
|
62 |
|
|
63 |
// Get home folder not to show |
|
64 |
$home_folders = get_home_folders(); |
|
65 |
|
|
66 |
// Figure out what folder name the temp id is |
|
67 |
if($handle = opendir(WB_PATH.MEDIA_DIRECTORY.'/'.$directory)) { |
|
68 |
// Loop through the files and dirs an add to list |
|
69 |
while (false !== ($file = readdir($handle))) { |
|
70 |
if(substr($file, 0, 1) != '.' AND $file != '.svn' AND $file != 'index.php') { |
|
71 |
if(is_dir(WB_PATH.MEDIA_DIRECTORY.$directory.'/'.$file)) { |
|
72 |
if(!isset($home_folders[$directory.'/'.$file])) { |
|
73 |
$DIR[] = $file; |
|
74 |
} |
|
75 |
} else { |
|
76 |
$FILE[] = $file; |
|
77 |
} |
|
78 |
} |
|
79 |
} |
|
80 |
$temp_id = 0; |
|
81 |
if(isset($DIR)) { |
|
82 |
foreach($DIR AS $name) { |
|
83 |
$temp_id++; |
|
84 |
if($file_id == $temp_id) { |
|
85 |
$rename_file = $name; |
|
86 |
$type = 'folder'; |
|
87 |
} |
|
88 |
} |
|
89 |
} |
|
90 |
if(isset($FILE)) { |
|
91 |
foreach($FILE AS $name) { |
|
92 |
$temp_id++; |
|
93 |
if($file_id == $temp_id) { |
|
94 |
$rename_file = $name; |
|
95 |
$type = 'file'; |
|
96 |
} |
|
97 |
} |
|
98 |
} |
|
99 |
} |
|
100 |
|
|
101 |
if(!isset($rename_file)) { |
|
102 |
$admin->print_error($MESSAGE['MEDIA']['FILE_NOT_FOUND'], "browse.php?dir=$directory", false); |
|
103 |
} |
|
104 |
|
|
105 |
// Check if they entered a new name |
|
106 |
if(media_filename($admin->get_post('name')) == "") { |
|
107 |
$admin->print_error($MESSAGE['MEDIA']['BLANK_NAME'], "rename.php?dir=$directory&id=$file_id", false); |
|
108 |
} else { |
|
109 |
$old_name = $admin->get_post('old_name'); |
|
110 |
$new_name = media_filename($admin->get_post('name')); |
|
111 |
} |
|
112 |
|
|
113 |
// Check if they entered an extension |
|
114 |
if($type == 'file') { |
|
115 |
if(media_filename($admin->get_post('extension')) == "") { |
|
116 |
$admin->print_error($MESSAGE['MEDIA']['BLANK_EXTENSION'], "rename.php?dir=$directory&id=$file_id", false); |
|
117 |
} else { |
|
118 |
$extension = media_filename($admin->get_post('extension')); |
|
119 |
} |
|
120 |
} else { |
|
121 |
$extension = ''; |
|
122 |
} |
|
123 |
|
|
124 |
// Join new name and extension |
|
125 |
$name = $new_name.$extension; |
|
126 |
|
|
127 |
// Check if the name contains .. |
|
128 |
if(strstr($name, '..')) { |
|
129 |
$admin->print_error($MESSAGE['MEDIA']['NAME_DOT_DOT_SLASH'], "rename.php?dir=$directory&id=$file_id", false); |
|
130 |
} |
|
131 |
|
|
132 |
// Check if the name is index.php |
|
133 |
if($name == 'index.php') { |
|
134 |
$admin->print_error($MESSAGE['MEDIA']['NAME_INDEX_PHP'], "rename.php?dir=$directory&id=$file_id", false); |
|
135 |
} |
|
136 |
|
|
137 |
// Check that the name still has a value |
|
138 |
if($name == '') { |
|
139 |
$admin->print_error($MESSAGE['MEDIA']['BLANK_NAME'], "rename.php?dir=$directory&id=$file_id", false); |
|
140 |
} |
|
141 |
|
|
142 |
// Check for potentially malicious files and append 'txt' to their name |
|
143 |
foreach($file_extensions as $file_ext) { |
|
144 |
$file_ext_len=strlen($file_ext); |
|
145 |
if (substr($name,-$file_ext_len)==$file_ext) { |
|
146 |
$name.='.txt'; |
|
147 |
} |
|
148 |
} |
|
149 |
|
|
150 |
|
|
151 |
// Check if we should overwrite or not |
|
152 |
if($admin->get_post('overwrite') != 'yes' AND file_exists(WB_PATH.MEDIA_DIRECTORY.$directory.'/'.$name) == true) { |
|
153 |
if($type == 'folder') { |
|
154 |
$admin->print_error($MESSAGE['MEDIA']['DIR_EXISTS'], "rename.php?dir=$directory&id=$file_id", false); |
|
155 |
} else { |
|
156 |
$admin->print_error($MESSAGE['MEDIA']['FILE_EXISTS'], "rename.php?dir=$directory&id=$file_id", false); |
|
157 |
} |
|
158 |
} |
|
159 |
|
|
160 |
// Try and rename the file/folder |
|
161 |
if(rename(WB_PATH.MEDIA_DIRECTORY.$directory.'/'.$rename_file, WB_PATH.MEDIA_DIRECTORY.$directory.'/'.$name)) { |
|
162 |
$admin->print_success($MESSAGE['MEDIA']['RENAMED'], "browse.php?dir=$directory"); |
|
163 |
} else { |
|
164 |
$admin->print_error($MESSAGE['MEDIA']['CANNOT_RENAME'], "rename.php?dir=$directory&id=$file_id", false); |
|
165 |
} |
|
166 |
|
|
167 |
?> |
trunk/wb/admin/media/browse.php | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
// $Id$ |
|
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 |
// Create admin object |
|
27 |
require('../../config.php'); |
|
28 |
require_once(WB_PATH.'/framework/class.admin.php'); |
|
29 |
$admin = new admin('Media', 'media', false); |
|
30 |
|
|
31 |
// Include the WB functions file |
|
32 |
require_once(WB_PATH.'/framework/functions.php'); |
|
33 |
|
|
34 |
// Setup template object |
|
35 |
$template = new Template(ADMIN_PATH.'/media'); |
|
36 |
$template->set_file('page', 'browse.html'); |
|
37 |
$template->set_block('page', 'main_block', 'main'); |
|
38 |
|
|
39 |
// Get the current dir |
|
40 |
$directory = $admin->get_get('dir'); |
|
41 |
if($directory == '/') { |
|
42 |
$directory = ''; |
|
43 |
} |
|
44 |
|
|
45 |
// Check to see if it contains ../ |
|
46 |
if(strstr($directory, '../')) { |
|
47 |
$admin->print_header(); |
|
48 |
$admin->print_error($MESSAGE['MEDIA']['DIR_DOT_DOT_SLASH']); |
|
49 |
} |
|
50 |
|
|
51 |
if(!file_exists(WB_PATH.'/media'.$directory)) { |
|
52 |
$admin->print_header(); |
|
53 |
$admin->print_error($MESSAGE['MEDIA']['DIR_DOES_NOT_EXIST']); |
|
54 |
} |
|
55 |
|
|
56 |
// Check to see if the user wanted to go up a directory into the parent folder |
|
57 |
if($admin->get_get('up') == 1) { |
|
58 |
$parent_directory = dirname($directory); |
|
59 |
header("Location: browse.php?dir=$parent_directory"); |
|
60 |
} |
|
61 |
|
|
62 |
// Workout the parent dir link |
|
63 |
$parent_dir_link = ADMIN_URL.'/media/browse.php?dir='.$directory.'&up=1'; |
|
64 |
// Workout if the up arrow should be shown |
|
65 |
if($directory == '') { |
|
66 |
$display_up_arrow = 'hide'; |
|
67 |
} else { |
|
68 |
$display_up_arrow = ''; |
|
69 |
} |
|
70 |
|
|
71 |
// Insert values |
|
72 |
$template->set_var(array( |
|
73 |
'CURRENT_DIR' => $directory, |
|
74 |
'PARENT_DIR_LINK' => $parent_dir_link, |
|
75 |
'DISPLAY_UP_ARROW' => $display_up_arrow |
|
76 |
) |
|
77 |
); |
|
78 |
|
|
79 |
// Get home folder not to show |
|
80 |
$home_folders = get_home_folders(); |
|
81 |
|
|
82 |
// Generate list |
|
83 |
$template->set_block('main_block', 'list_block', 'list'); |
|
84 |
if($handle = opendir(WB_PATH.MEDIA_DIRECTORY.'/'.$directory)) { |
|
85 |
// Loop through the files and dirs an add to list |
|
86 |
while(false !== ($file = readdir($handle))) { |
|
87 |
if(substr($file, 0, 1) != '.' AND $file != '.svn' AND $file != 'index.php') { |
|
88 |
if(is_dir(WB_PATH.MEDIA_DIRECTORY.$directory.'/'.$file)) { |
|
89 |
if(!isset($home_folders[$directory.'/'.$file])) { |
|
90 |
$DIR[] = $file; |
|
91 |
} |
|
92 |
} else { |
|
93 |
$FILE[] = $file; |
|
94 |
} |
|
95 |
} |
|
96 |
} |
|
97 |
// Now parse these values to the template |
|
98 |
$temp_id = 0; |
|
99 |
$row_bg_color = 'EEEEEE'; |
|
100 |
if(isset($DIR)) { |
|
101 |
foreach($DIR AS $name) { |
|
102 |
$link_name = str_replace(' ', '%20', $name); |
|
103 |
$temp_id++; |
|
104 |
$template->set_var(array( |
|
105 |
'NAME' => $name, |
|
106 |
'NAME_SLASHED' => addslashes($name), |
|
107 |
'TEMP_ID' => $temp_id, |
|
108 |
'LINK' => "browse.php?dir=$directory/$link_name", |
|
109 |
'LINK_TARGET' => '', |
|
110 |
'ROW_BG_COLOR' => $row_bg_color, |
|
111 |
'FILETYPE_ICON' => ADMIN_URL.'/images/folder_16.png' |
|
112 |
) |
|
113 |
); |
|
114 |
$template->parse('list', 'list_block', true); |
|
115 |
// Code to alternate row colors |
|
116 |
if($row_bg_color == 'DEDEDE') { |
|
117 |
$row_bg_color = 'EEEEEE'; |
|
118 |
} else { |
|
119 |
$row_bg_color = 'DEDEDE'; |
|
120 |
} |
|
121 |
} |
|
122 |
} |
|
123 |
if(isset($FILE)) { |
|
124 |
foreach($FILE AS $name) { |
|
125 |
$temp_id++; |
|
126 |
$template->set_var(array( |
|
127 |
'NAME' => $name, |
|
128 |
'NAME_SLASHED' => addslashes($name), |
|
129 |
'TEMP_ID' => $temp_id, |
|
130 |
'LINK' => WB_URL.MEDIA_DIRECTORY.$directory.'/'.$name, |
|
131 |
'LINK_TARGET' => '_blank', |
|
132 |
'ROW_BG_COLOR' => $row_bg_color, |
|
133 |
'FILETYPE_ICON' => ADMIN_URL.'/images/blank.gif' |
|
134 |
) |
|
135 |
); |
|
136 |
$template->parse('list', 'list_block', true); |
|
137 |
// Code to alternate row colors |
|
138 |
if($row_bg_color == 'DEDEDE') { |
|
139 |
$row_bg_color = 'EEEEEE'; |
|
140 |
} else { |
|
141 |
$row_bg_color = 'DEDEDE'; |
|
142 |
} |
|
143 |
} |
|
144 |
} |
|
145 |
} |
|
146 |
|
|
147 |
// If no files are in the media folder say so |
|
148 |
if($temp_id == 0) { |
|
149 |
$template->set_var('DISPLAY_LIST_TABLE', 'hide'); |
|
150 |
} else { |
|
151 |
$template->set_var('DISPLAY_NONE_FOUND', 'hide'); |
|
152 |
} |
|
153 |
|
|
154 |
// Insert permissions values |
|
155 |
if($admin->get_permission('media_rename') != true) { |
|
156 |
$template->set_var('DISPLAY_RENAME', 'hide'); |
|
157 |
} |
|
158 |
if($admin->get_permission('media_delete') != true) { |
|
159 |
$template->set_var('DISPLAY_DELETE', 'hide'); |
|
160 |
} |
|
161 |
|
|
162 |
// Insert language text and messages |
|
163 |
$template->set_var(array( |
|
164 |
'MEDIA_DIRECTORY' => MEDIA_DIRECTORY, |
|
165 |
'TEXT_CURRENT_FOLDER' => $TEXT['CURRENT_FOLDER'], |
|
166 |
'TEXT_RELOAD' => $TEXT['RELOAD'], |
|
167 |
'TEXT_RENAME' => $TEXT['RENAME'], |
|
168 |
'TEXT_DELETE' => $TEXT['DELETE'], |
|
169 |
'TEXT_UP' => $TEXT['UP'], |
|
170 |
'NONE_FOUND' => $MESSAGE['MEDIA']['NONE_FOUND'], |
|
171 |
'CONFIRM_DELETE' => $MESSAGE['MEDIA']['CONFIRM_DELETE'] |
|
172 |
) |
|
173 |
); |
|
174 |
|
|
175 |
// Parse template object |
|
176 |
$template->parse('main', 'main_block', false); |
|
177 |
$template->pparse('output', 'page'); |
|
178 |
|
|
179 |
?> |
|
1 |
<?php |
|
2 |
|
|
3 |
// $Id$ |
|
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 |
// Create admin object |
|
27 |
require('../../config.php'); |
|
28 |
require_once(WB_PATH.'/framework/class.admin.php'); |
|
29 |
$admin = new admin('Media', 'media', false); |
|
30 |
|
Also available in: Unified diff
Fixed inconsistent line ending styles