1 |
238
|
stefan
|
<?php
|
2 |
1400
|
FrankH
|
/**
|
3 |
|
|
*
|
4 |
|
|
* @category admin
|
5 |
|
|
* @package media
|
6 |
|
|
* @author WebsiteBaker Project
|
7 |
|
|
* @copyright 2004-2009, Ryan Djurovich
|
8 |
|
|
* @copyright 2009-2011, 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 5.2.2 and higher
|
13 |
|
|
* @version $Id$
|
14 |
|
|
* @filesource $HeadURL: $
|
15 |
|
|
* @lastmodified $Date: $
|
16 |
|
|
*
|
17 |
|
|
*/
|
18 |
238
|
stefan
|
|
19 |
|
|
// Create admin object
|
20 |
|
|
require('../../config.php');
|
21 |
|
|
require_once(WB_PATH.'/framework/class.admin.php');
|
22 |
|
|
$admin = new admin('Media', 'media', false);
|
23 |
|
|
|
24 |
1457
|
Luisehahne
|
$starttime = explode(" ", microtime());
|
25 |
|
|
$starttime = $starttime[0]+$starttime[1];
|
26 |
|
|
|
27 |
238
|
stefan
|
// Include the WB functions file
|
28 |
|
|
require_once(WB_PATH.'/framework/functions.php');
|
29 |
1041
|
Ruebenwurz
|
include ('parameters.php');
|
30 |
238
|
stefan
|
|
31 |
1082
|
Ruebenwurz
|
// check if theme language file exists for the language set by the user (e.g. DE, EN)
|
32 |
|
|
if(!file_exists(THEME_PATH .'/languages/'.LANGUAGE .'.php')) {
|
33 |
|
|
// no theme language file exists for the language set by the user, include default theme language file EN.php
|
34 |
|
|
require_once(THEME_PATH .'/languages/EN.php');
|
35 |
|
|
} else {
|
36 |
|
|
// a theme language file exists for the language defined by the user, load it
|
37 |
|
|
require_once(THEME_PATH .'/languages/'.LANGUAGE .'.php');
|
38 |
|
|
}
|
39 |
|
|
|
40 |
1023
|
Ruebenwurz
|
// Byte convert for filesize
|
41 |
|
|
function byte_convert($bytes) {
|
42 |
1041
|
Ruebenwurz
|
$symbol = array(' bytes', ' KB', ' MB', ' GB', ' TB');
|
43 |
1035
|
Ruebenwurz
|
$exp = 0;
|
44 |
|
|
$converted_value = 0;
|
45 |
|
|
if( $bytes > 0 ) {
|
46 |
|
|
$exp = floor( log($bytes)/log(1024) );
|
47 |
|
|
$converted_value = ( $bytes/pow(1024,floor($exp)) );
|
48 |
|
|
}
|
49 |
|
|
return sprintf( '%.2f '.$symbol[$exp], $converted_value );
|
50 |
1023
|
Ruebenwurz
|
}
|
51 |
|
|
|
52 |
|
|
// Get file extension
|
53 |
|
|
function get_filetype($fname) {
|
54 |
|
|
$pathinfo = pathinfo($fname);
|
55 |
1407
|
FrankH
|
$extension = (isset($pathinfo['extension'])) ? strtolower($pathinfo['extension']) : '';
|
56 |
1023
|
Ruebenwurz
|
return $extension;
|
57 |
|
|
}
|
58 |
|
|
|
59 |
|
|
// Get file extension for icons
|
60 |
|
|
function get_filetype_icon($fname) {
|
61 |
|
|
$pathinfo = pathinfo($fname);
|
62 |
1407
|
FrankH
|
$extension = (isset($pathinfo['extension'])) ? strtolower($pathinfo['extension']) : '';
|
63 |
1023
|
Ruebenwurz
|
if (file_exists(THEME_PATH.'/images/files/'.$extension.'.png')) {
|
64 |
|
|
return $extension;
|
65 |
|
|
} else {
|
66 |
1457
|
Luisehahne
|
return 'blank_16';
|
67 |
1023
|
Ruebenwurz
|
}
|
68 |
|
|
}
|
69 |
|
|
|
70 |
1457
|
Luisehahne
|
function ShowTip($name,$detail='') {
|
71 |
|
|
$parts = explode(".", $name);
|
72 |
|
|
$ext = strtolower(end($parts));
|
73 |
|
|
if (strpos('.gif.jpg.jpeg.png.bmp.',$ext) )
|
74 |
|
|
return 'onmouseover="overlib(\'<img src=\\\''.$name.'\\\' maxwidth=\\\'200\\\' maxheight=\\\'200\\\'>\',VAUTO, WIDTH)" onmouseout="nd()" ' ;
|
75 |
|
|
else
|
76 |
|
|
return '';
|
77 |
|
|
}
|
78 |
|
|
|
79 |
|
|
function fsize($size) {
|
80 |
|
|
if($size == 0) return("0 Bytes");
|
81 |
|
|
$filesizename = array(" bytes", " kB", " MB", " GB", " TB");
|
82 |
|
|
return round($size/pow(1024, ($i = floor(log($size, 1024)))), 1) . $filesizename[$i];
|
83 |
|
|
}
|
84 |
|
|
|
85 |
238
|
stefan
|
// Setup template object
|
86 |
944
|
Ruebenwurz
|
$template = new Template(THEME_PATH.'/templates');
|
87 |
|
|
$template->set_file('page', 'media_browse.htt');
|
88 |
238
|
stefan
|
$template->set_block('page', 'main_block', 'main');
|
89 |
|
|
|
90 |
|
|
// Get the current dir
|
91 |
1087
|
Ruebenwurz
|
$currentHome = $admin->get_home_folder();
|
92 |
|
|
$directory = (($currentHome) AND (!array_key_exists('dir',$_GET)))
|
93 |
1457
|
Luisehahne
|
?
|
94 |
1087
|
Ruebenwurz
|
$currentHome
|
95 |
|
|
:
|
96 |
|
|
$admin->strip_slashes($admin->get_get('dir')) ;
|
97 |
327
|
stefan
|
if($directory == '/' OR $directory == '\\') {
|
98 |
238
|
stefan
|
$directory = '';
|
99 |
|
|
}
|
100 |
|
|
|
101 |
|
|
// Check to see if it contains ../
|
102 |
1400
|
FrankH
|
if (!check_media_path($directory)) {
|
103 |
1425
|
Luisehahne
|
// $admin->print_header();
|
104 |
238
|
stefan
|
$admin->print_error($MESSAGE['MEDIA']['DIR_DOT_DOT_SLASH']);
|
105 |
|
|
}
|
106 |
|
|
|
107 |
282
|
stefan
|
if(!file_exists(WB_PATH.MEDIA_DIRECTORY.$directory)) {
|
108 |
1425
|
Luisehahne
|
// $admin->print_header();
|
109 |
238
|
stefan
|
$admin->print_error($MESSAGE['MEDIA']['DIR_DOES_NOT_EXIST']);
|
110 |
|
|
}
|
111 |
|
|
|
112 |
|
|
// Check to see if the user wanted to go up a directory into the parent folder
|
113 |
|
|
if($admin->get_get('up') == 1) {
|
114 |
|
|
$parent_directory = dirname($directory);
|
115 |
1427
|
Luisehahne
|
header("Location: browse.php?dir=$parent_directory");
|
116 |
286
|
stefan
|
exit(0);
|
117 |
238
|
stefan
|
}
|
118 |
|
|
|
119 |
1041
|
Ruebenwurz
|
if ($_SESSION['GROUP_ID'] != 1 && $pathsettings['global']['admin_only']) { // Only show admin the settings link
|
120 |
|
|
$template->set_var('DISPLAY_SETTINGS', 'hide');
|
121 |
|
|
}
|
122 |
|
|
|
123 |
238
|
stefan
|
// Workout the parent dir link
|
124 |
1427
|
Luisehahne
|
$parent_dir_link = ADMIN_URL.'/media/browse.php?dir='.$directory.'&up=1';
|
125 |
238
|
stefan
|
// Workout if the up arrow should be shown
|
126 |
1087
|
Ruebenwurz
|
if(($directory == '') or ($directory==$currentHome)) {
|
127 |
238
|
stefan
|
$display_up_arrow = 'hide';
|
128 |
|
|
} else {
|
129 |
|
|
$display_up_arrow = '';
|
130 |
|
|
}
|
131 |
|
|
|
132 |
|
|
// Insert values
|
133 |
|
|
$template->set_var(array(
|
134 |
1457
|
Luisehahne
|
'THEME_URL' => THEME_URL,
|
135 |
|
|
// 'THEME_URL' => '',
|
136 |
|
|
'CURRENT_DIR' => $directory,
|
137 |
|
|
'PARENT_DIR_LINK' => $parent_dir_link,
|
138 |
|
|
'DISPLAY_UP_ARROW' => $display_up_arrow,
|
139 |
|
|
'INCLUDE_PATH' => WB_URL.'/include'
|
140 |
|
|
)
|
141 |
|
|
);
|
142 |
238
|
stefan
|
|
143 |
|
|
// Get home folder not to show
|
144 |
|
|
$home_folders = get_home_folders();
|
145 |
|
|
|
146 |
|
|
// Generate list
|
147 |
|
|
$template->set_block('main_block', 'list_block', 'list');
|
148 |
1457
|
Luisehahne
|
|
149 |
|
|
$usedFiles = array();
|
150 |
|
|
// require_once(ADMIN_PATH.'/media/dse.php');
|
151 |
|
|
// $filename = $currentdir;
|
152 |
|
|
if(!empty($currentdir)) {
|
153 |
|
|
$usedFiles = $Dse->getMatchesFromDir( $currentdir, DseTwo::RETURN_USED);
|
154 |
|
|
}
|
155 |
|
|
|
156 |
1468
|
Luisehahne
|
$rename_file_types = str_replace(',','|',RENAME_FILES_ON_UPLOAD);
|
157 |
|
|
// hardcodet forbidden filetypes
|
158 |
|
|
$forbidden_file_types = 'phtml|php5|php4|php|cgi|pl|exe|com|bat|src|'.$rename_file_types;
|
159 |
|
|
|
160 |
238
|
stefan
|
if($handle = opendir(WB_PATH.MEDIA_DIRECTORY.'/'.$directory)) {
|
161 |
|
|
// Loop through the files and dirs an add to list
|
162 |
1035
|
Ruebenwurz
|
while(false !== ($file = readdir($handle))) {
|
163 |
238
|
stefan
|
if(substr($file, 0, 1) != '.' AND $file != '.svn' AND $file != 'index.php') {
|
164 |
|
|
if(is_dir(WB_PATH.MEDIA_DIRECTORY.$directory.'/'.$file)) {
|
165 |
|
|
if(!isset($home_folders[$directory.'/'.$file])) {
|
166 |
|
|
$DIR[] = $file;
|
167 |
|
|
}
|
168 |
|
|
} else {
|
169 |
1468
|
Luisehahne
|
$info = pathinfo($file);
|
170 |
|
|
$ext = isset($info['extension']) ? $info['extension'] : '';
|
171 |
|
|
if( !preg_match('/'.$forbidden_file_types.'$/i', $ext) ) {
|
172 |
|
|
$FILE[] = $file;
|
173 |
|
|
}
|
174 |
238
|
stefan
|
}
|
175 |
|
|
}
|
176 |
|
|
}
|
177 |
|
|
// Now parse these values to the template
|
178 |
|
|
$temp_id = 0;
|
179 |
686
|
doc
|
$row_bg_color = 'FFF';
|
180 |
238
|
stefan
|
if(isset($DIR)) {
|
181 |
384
|
Ruebenwurz
|
sort($DIR);
|
182 |
238
|
stefan
|
foreach($DIR AS $name) {
|
183 |
|
|
$link_name = str_replace(' ', '%20', $name);
|
184 |
|
|
$temp_id++;
|
185 |
|
|
$template->set_var(array(
|
186 |
1457
|
Luisehahne
|
'NAME' => $name,
|
187 |
|
|
'NAME_SLASHED' => addslashes($name),
|
188 |
|
|
'TEMP_ID' => $admin->getIDKEY($temp_id),
|
189 |
|
|
'LINK' => "browse.php?dir=$directory/$link_name",
|
190 |
|
|
'LINK_TARGET' => '_self',
|
191 |
|
|
'ROW_BG_COLOR' => $row_bg_color,
|
192 |
|
|
'FT_ICON' => THEME_URL.'/images/folder_16.png',
|
193 |
|
|
'FILETYPE_ICON' => THEME_URL.'/images/folder_16.png',
|
194 |
|
|
'MOUSEOVER' => '',
|
195 |
|
|
'IMAGEDETAIL' => '',
|
196 |
|
|
'SIZE' => '',
|
197 |
|
|
'DATE' => '',
|
198 |
|
|
'PREVIEW' => '',
|
199 |
|
|
'IMAGE_TITLE' => $name,
|
200 |
|
|
'IMAGE_EXIST' => 'blank_16.gif'
|
201 |
|
|
)
|
202 |
|
|
);
|
203 |
238
|
stefan
|
$template->parse('list', 'list_block', true);
|
204 |
|
|
// Code to alternate row colors
|
205 |
686
|
doc
|
if($row_bg_color == 'FFF') {
|
206 |
|
|
$row_bg_color = 'ECF1F3';
|
207 |
238
|
stefan
|
} else {
|
208 |
686
|
doc
|
$row_bg_color = 'FFF';
|
209 |
238
|
stefan
|
}
|
210 |
|
|
}
|
211 |
|
|
}
|
212 |
|
|
if(isset($FILE)) {
|
213 |
384
|
Ruebenwurz
|
sort($FILE);
|
214 |
1457
|
Luisehahne
|
$filepreview = array('jpg','gif','tif','tiff','png','txt','css','js','cfg','conf','pdf','zip','gz','doc');
|
215 |
238
|
stefan
|
foreach($FILE AS $name) {
|
216 |
1023
|
Ruebenwurz
|
$size = filesize('../../'.MEDIA_DIRECTORY.$directory.'/'.$name);
|
217 |
|
|
$bytes = byte_convert($size);
|
218 |
|
|
$fdate = filemtime('../../'.MEDIA_DIRECTORY.$directory.'/'.$name);
|
219 |
|
|
$date = gmdate(DATE_FORMAT.' '.TIME_FORMAT, $fdate);
|
220 |
|
|
$filetypeicon = get_filetype_icon(WB_URL.MEDIA_DIRECTORY.$directory.'/'.$name);
|
221 |
|
|
$filetype = get_filetype(WB_URL.MEDIA_DIRECTORY.$directory.'/'.$name);
|
222 |
1427
|
Luisehahne
|
|
223 |
1023
|
Ruebenwurz
|
if (in_array($filetype, $filepreview)) {
|
224 |
|
|
$preview = 'preview';
|
225 |
|
|
} else {
|
226 |
|
|
$preview = '';
|
227 |
|
|
}
|
228 |
238
|
stefan
|
$temp_id++;
|
229 |
1035
|
Ruebenwurz
|
$imgdetail = '';
|
230 |
1457
|
Luisehahne
|
// $icon = THEME_URL.'/images/blank_16.gif';
|
231 |
|
|
$icon = '';
|
232 |
1035
|
Ruebenwurz
|
$tooltip = '';
|
233 |
1457
|
Luisehahne
|
|
234 |
|
|
|
235 |
1035
|
Ruebenwurz
|
if (!$pathsettings['global']['show_thumbs']) {
|
236 |
|
|
$info = getimagesize(WB_PATH.MEDIA_DIRECTORY.$directory.'/'.$name);
|
237 |
|
|
if ($info[0]) {
|
238 |
1041
|
Ruebenwurz
|
$imgdetail = fsize(filesize(WB_PATH.MEDIA_DIRECTORY.$directory.'/'.$name)).'<br /> '.$info[0].' x '.$info[1].' px';
|
239 |
1427
|
Luisehahne
|
$icon = 'thumb.php?t=1&img='.$directory.'/'.$name;
|
240 |
|
|
$tooltip = ShowTip('thumb.php?t=2&img='.$directory.'/'.$name);
|
241 |
1035
|
Ruebenwurz
|
}
|
242 |
|
|
}
|
243 |
1457
|
Luisehahne
|
|
244 |
|
|
$filetype_url = THEME_URL.'/images/files/'.$filetypeicon.'.png';
|
245 |
238
|
stefan
|
$template->set_var(array(
|
246 |
1457
|
Luisehahne
|
'NAME' => $name,
|
247 |
|
|
'NAME_SLASHED' => addslashes($name),
|
248 |
|
|
'TEMP_ID' => $admin->getIDKEY($temp_id),
|
249 |
|
|
'LINK' => WB_URL.MEDIA_DIRECTORY.$directory.'/'.$name,
|
250 |
|
|
'LINK_TARGET' => '_blank',
|
251 |
|
|
'ROW_BG_COLOR' => $row_bg_color,
|
252 |
|
|
'FT_ICON' => empty($icon) ? $filetype_url : $icon,
|
253 |
|
|
'FILETYPE_ICON' => $filetype_url,
|
254 |
|
|
'MOUSEOVER' => $tooltip,
|
255 |
|
|
'IMAGEDETAIL' => $imgdetail,
|
256 |
|
|
'SIZE' => $bytes,
|
257 |
|
|
'DATE' => $date,
|
258 |
|
|
'PREVIEW' => $preview,
|
259 |
|
|
'IMAGE_TITLE' => $name,
|
260 |
1460
|
Luisehahne
|
'IMAGE_EXIST' => 'blank_16.gif'
|
261 |
1457
|
Luisehahne
|
)
|
262 |
|
|
);
|
263 |
238
|
stefan
|
$template->parse('list', 'list_block', true);
|
264 |
|
|
// Code to alternate row colors
|
265 |
686
|
doc
|
if($row_bg_color == 'FFF') {
|
266 |
|
|
$row_bg_color = 'ECF1F3';
|
267 |
238
|
stefan
|
} else {
|
268 |
686
|
doc
|
$row_bg_color = 'FFF';
|
269 |
238
|
stefan
|
}
|
270 |
|
|
}
|
271 |
|
|
}
|
272 |
|
|
}
|
273 |
|
|
|
274 |
|
|
// If no files are in the media folder say so
|
275 |
|
|
if($temp_id == 0) {
|
276 |
|
|
$template->set_var('DISPLAY_LIST_TABLE', 'hide');
|
277 |
|
|
} else {
|
278 |
|
|
$template->set_var('DISPLAY_NONE_FOUND', 'hide');
|
279 |
|
|
}
|
280 |
|
|
|
281 |
|
|
// Insert permissions values
|
282 |
|
|
if($admin->get_permission('media_rename') != true) {
|
283 |
|
|
$template->set_var('DISPLAY_RENAME', 'hide');
|
284 |
|
|
}
|
285 |
|
|
if($admin->get_permission('media_delete') != true) {
|
286 |
|
|
$template->set_var('DISPLAY_DELETE', 'hide');
|
287 |
|
|
}
|
288 |
|
|
|
289 |
|
|
// Insert language text and messages
|
290 |
|
|
$template->set_var(array(
|
291 |
1457
|
Luisehahne
|
'MEDIA_DIRECTORY' => MEDIA_DIRECTORY,
|
292 |
|
|
'TEXT_CURRENT_FOLDER' => $TEXT['CURRENT_FOLDER'],
|
293 |
|
|
'TEXT_RELOAD' => $TEXT['RELOAD'],
|
294 |
|
|
'TEXT_RENAME' => $TEXT['RENAME'],
|
295 |
|
|
'TEXT_DELETE' => $TEXT['DELETE'],
|
296 |
|
|
'TEXT_SIZE' => $TEXT['SIZE'],
|
297 |
|
|
'TEXT_DATE' => $TEXT['DATE'],
|
298 |
|
|
'TEXT_NAME' => $TEXT['NAME'],
|
299 |
|
|
'TEXT_TYPE' => $TEXT['TYPE'],
|
300 |
|
|
'TEXT_UP' => $TEXT['UP'],
|
301 |
|
|
'NONE_FOUND' => $MESSAGE['MEDIA']['NONE_FOUND'],
|
302 |
|
|
'CHANGE_SETTINGS' => $TEXT['MODIFY_SETTINGS'],
|
303 |
|
|
'CONFIRM_DELETE' => $MESSAGE['MEDIA']['CONFIRM_DELETE']
|
304 |
|
|
)
|
305 |
|
|
);
|
306 |
238
|
stefan
|
|
307 |
|
|
// Parse template object
|
308 |
|
|
$template->parse('main', 'main_block', false);
|
309 |
|
|
$template->pparse('output', 'page');
|
310 |
1457
|
Luisehahne
|
/*
|
311 |
|
|
$endtime=explode(" ", microtime());
|
312 |
|
|
$endtime=$endtime[0]+$endtime[1];
|
313 |
|
|
$debugVMsg = '';
|
314 |
|
|
if($admin->ami_group_member('1') ) {
|
315 |
|
|
$debugVMsg = "<p>Mask loaded in ".round($endtime - $starttime,6)." Sec, ";
|
316 |
|
|
$debugVMsg .= "Memory in use ".number_format(memory_get_usage(true), 0, ',', '.')." Byte, ";
|
317 |
|
|
$debugVMsg .= sizeof(get_included_files())." included files</p>";
|
318 |
|
|
// $debugVMsg = print_message($debugVMsg,'#','debug',-1,false);
|
319 |
|
|
print $debugVMsg.'<br />';
|
320 |
|
|
}
|
321 |
|
|
*/
|