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