1 |
238
|
stefan
|
<?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 |
282
|
stefan
|
if(!file_exists(WB_PATH.MEDIA_DIRECTORY.$directory)) {
|
52 |
238
|
stefan
|
$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 |
286
|
stefan
|
exit(0);
|
61 |
238
|
stefan
|
}
|
62 |
|
|
|
63 |
|
|
// Workout the parent dir link
|
64 |
|
|
$parent_dir_link = ADMIN_URL.'/media/browse.php?dir='.$directory.'&up=1';
|
65 |
|
|
// Workout if the up arrow should be shown
|
66 |
|
|
if($directory == '') {
|
67 |
|
|
$display_up_arrow = 'hide';
|
68 |
|
|
} else {
|
69 |
|
|
$display_up_arrow = '';
|
70 |
|
|
}
|
71 |
|
|
|
72 |
|
|
// Insert values
|
73 |
|
|
$template->set_var(array(
|
74 |
|
|
'CURRENT_DIR' => $directory,
|
75 |
|
|
'PARENT_DIR_LINK' => $parent_dir_link,
|
76 |
|
|
'DISPLAY_UP_ARROW' => $display_up_arrow
|
77 |
|
|
)
|
78 |
|
|
);
|
79 |
|
|
|
80 |
|
|
// Get home folder not to show
|
81 |
|
|
$home_folders = get_home_folders();
|
82 |
|
|
|
83 |
|
|
// Generate list
|
84 |
|
|
$template->set_block('main_block', 'list_block', 'list');
|
85 |
|
|
if($handle = opendir(WB_PATH.MEDIA_DIRECTORY.'/'.$directory)) {
|
86 |
|
|
// Loop through the files and dirs an add to list
|
87 |
|
|
while(false !== ($file = readdir($handle))) {
|
88 |
|
|
if(substr($file, 0, 1) != '.' AND $file != '.svn' AND $file != 'index.php') {
|
89 |
|
|
if(is_dir(WB_PATH.MEDIA_DIRECTORY.$directory.'/'.$file)) {
|
90 |
|
|
if(!isset($home_folders[$directory.'/'.$file])) {
|
91 |
|
|
$DIR[] = $file;
|
92 |
|
|
}
|
93 |
|
|
} else {
|
94 |
|
|
$FILE[] = $file;
|
95 |
|
|
}
|
96 |
|
|
}
|
97 |
|
|
}
|
98 |
|
|
// Now parse these values to the template
|
99 |
|
|
$temp_id = 0;
|
100 |
|
|
$row_bg_color = 'EEEEEE';
|
101 |
|
|
if(isset($DIR)) {
|
102 |
|
|
foreach($DIR AS $name) {
|
103 |
|
|
$link_name = str_replace(' ', '%20', $name);
|
104 |
|
|
$temp_id++;
|
105 |
|
|
$template->set_var(array(
|
106 |
|
|
'NAME' => $name,
|
107 |
|
|
'NAME_SLASHED' => addslashes($name),
|
108 |
|
|
'TEMP_ID' => $temp_id,
|
109 |
|
|
'LINK' => "browse.php?dir=$directory/$link_name",
|
110 |
|
|
'LINK_TARGET' => '',
|
111 |
|
|
'ROW_BG_COLOR' => $row_bg_color,
|
112 |
|
|
'FILETYPE_ICON' => ADMIN_URL.'/images/folder_16.png'
|
113 |
|
|
)
|
114 |
|
|
);
|
115 |
|
|
$template->parse('list', 'list_block', true);
|
116 |
|
|
// Code to alternate row colors
|
117 |
|
|
if($row_bg_color == 'DEDEDE') {
|
118 |
|
|
$row_bg_color = 'EEEEEE';
|
119 |
|
|
} else {
|
120 |
|
|
$row_bg_color = 'DEDEDE';
|
121 |
|
|
}
|
122 |
|
|
}
|
123 |
|
|
}
|
124 |
|
|
if(isset($FILE)) {
|
125 |
|
|
foreach($FILE AS $name) {
|
126 |
|
|
$temp_id++;
|
127 |
|
|
$template->set_var(array(
|
128 |
|
|
'NAME' => $name,
|
129 |
|
|
'NAME_SLASHED' => addslashes($name),
|
130 |
|
|
'TEMP_ID' => $temp_id,
|
131 |
|
|
'LINK' => WB_URL.MEDIA_DIRECTORY.$directory.'/'.$name,
|
132 |
|
|
'LINK_TARGET' => '_blank',
|
133 |
|
|
'ROW_BG_COLOR' => $row_bg_color,
|
134 |
|
|
'FILETYPE_ICON' => ADMIN_URL.'/images/blank.gif'
|
135 |
|
|
)
|
136 |
|
|
);
|
137 |
|
|
$template->parse('list', 'list_block', true);
|
138 |
|
|
// Code to alternate row colors
|
139 |
|
|
if($row_bg_color == 'DEDEDE') {
|
140 |
|
|
$row_bg_color = 'EEEEEE';
|
141 |
|
|
} else {
|
142 |
|
|
$row_bg_color = 'DEDEDE';
|
143 |
|
|
}
|
144 |
|
|
}
|
145 |
|
|
}
|
146 |
|
|
}
|
147 |
|
|
|
148 |
|
|
// If no files are in the media folder say so
|
149 |
|
|
if($temp_id == 0) {
|
150 |
|
|
$template->set_var('DISPLAY_LIST_TABLE', 'hide');
|
151 |
|
|
} else {
|
152 |
|
|
$template->set_var('DISPLAY_NONE_FOUND', 'hide');
|
153 |
|
|
}
|
154 |
|
|
|
155 |
|
|
// Insert permissions values
|
156 |
|
|
if($admin->get_permission('media_rename') != true) {
|
157 |
|
|
$template->set_var('DISPLAY_RENAME', 'hide');
|
158 |
|
|
}
|
159 |
|
|
if($admin->get_permission('media_delete') != true) {
|
160 |
|
|
$template->set_var('DISPLAY_DELETE', 'hide');
|
161 |
|
|
}
|
162 |
|
|
|
163 |
|
|
// Insert language text and messages
|
164 |
|
|
$template->set_var(array(
|
165 |
|
|
'MEDIA_DIRECTORY' => MEDIA_DIRECTORY,
|
166 |
|
|
'TEXT_CURRENT_FOLDER' => $TEXT['CURRENT_FOLDER'],
|
167 |
|
|
'TEXT_RELOAD' => $TEXT['RELOAD'],
|
168 |
|
|
'TEXT_RENAME' => $TEXT['RENAME'],
|
169 |
|
|
'TEXT_DELETE' => $TEXT['DELETE'],
|
170 |
|
|
'TEXT_UP' => $TEXT['UP'],
|
171 |
|
|
'NONE_FOUND' => $MESSAGE['MEDIA']['NONE_FOUND'],
|
172 |
|
|
'CONFIRM_DELETE' => $MESSAGE['MEDIA']['CONFIRM_DELETE']
|
173 |
|
|
)
|
174 |
|
|
);
|
175 |
|
|
|
176 |
|
|
// Parse template object
|
177 |
|
|
$template->parse('main', 'main_block', false);
|
178 |
|
|
$template->pparse('output', 'page');
|
179 |
|
|
|
180 |
239
|
stefan
|
?>
|