1
|
<?php
|
2
|
|
3
|
// $Id: list_media.php 10 2005-09-04 08:59:31Z ryan $
|
4
|
|
5
|
/*
|
6
|
|
7
|
Website Baker Project <http://www.websitebaker.org/>
|
8
|
Copyright (C) 2004-2005, Ryan Djurovich
|
9
|
|
10
|
Website Baker is free software; you can redistribute it and/or modify
|
11
|
it under the terms of the GNU General Public License as published by
|
12
|
the Free Software Foundation; either version 2 of the License, or
|
13
|
(at your option) any later version.
|
14
|
|
15
|
Website Baker is distributed in the hope that it will be useful,
|
16
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18
|
GNU General Public License for more details.
|
19
|
|
20
|
You should have received a copy of the GNU General Public License
|
21
|
along with Website Baker; if not, write to the Free Software
|
22
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
23
|
|
24
|
*/
|
25
|
|
26
|
// Include the config file
|
27
|
require('../../../../config.php');
|
28
|
|
29
|
// Create new admin object
|
30
|
require(WB_PATH.'/framework/class.admin.php');
|
31
|
$admin = new admin('Pages', 'pages_modify', false);
|
32
|
|
33
|
// Include the WB functions file
|
34
|
require_once(WB_PATH.'/framework/functions.php');
|
35
|
|
36
|
// Get popup type
|
37
|
$popup = $admin->get_get('popup');
|
38
|
if($popup == 'image') {
|
39
|
$popup = 'insert_image';
|
40
|
} elseif($popup != 'link') {
|
41
|
$popup = 'link';
|
42
|
}
|
43
|
|
44
|
// Get the directory to browse
|
45
|
$directory = $admin->get_get('folder');
|
46
|
if($directory == '') {
|
47
|
$directory = MEDIA_DIRECTORY;
|
48
|
}
|
49
|
// If the directory contains ../ then set it to /media
|
50
|
if(strstr($directory, '../')) {
|
51
|
$directory = MEDIA_DIRECTORY;
|
52
|
}
|
53
|
|
54
|
// Insert files into the file list
|
55
|
$file_list = array();
|
56
|
foreach(file_list(WB_PATH.$directory, array('index.php')) AS $name) {
|
57
|
$filename = str_replace(WB_PATH.$directory.'/', '', $name);
|
58
|
$file_list[] = array('name' => basename($name), 'url' => WB_URL.$directory.'/'.$filename);
|
59
|
}
|
60
|
|
61
|
?>
|
62
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
63
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
64
|
<head>
|
65
|
<title>Browse Media</title>
|
66
|
<style type="text/css">
|
67
|
body,td,th {
|
68
|
font-family: Verdana, Arial, Helvetica, sans-serif;
|
69
|
font-size: 12px;
|
70
|
color: #000000;
|
71
|
padding: 10px;
|
72
|
}
|
73
|
body {
|
74
|
background-color: #FFFFFF;
|
75
|
margin: 0px;
|
76
|
}
|
77
|
a:link, a:visited, a:active {
|
78
|
color: #0000FF;
|
79
|
text-decoration: none;
|
80
|
}
|
81
|
a:hover {
|
82
|
text-decoration: underline;
|
83
|
color: #0000FF;
|
84
|
}
|
85
|
ul, li {
|
86
|
margin: 0;
|
87
|
padding: 0;
|
88
|
display: block;
|
89
|
list-style-type: none;
|
90
|
}
|
91
|
li {
|
92
|
padding: 5px 0px 5px 0px;
|
93
|
}
|
94
|
</style>
|
95
|
</head>
|
96
|
<body>
|
97
|
<?php
|
98
|
|
99
|
// If list is an empty array, then say that no files are in the current dir
|
100
|
if($file_list == array()) {
|
101
|
echo 'The selected folder is empty';
|
102
|
} else {
|
103
|
echo '<ul>';
|
104
|
foreach($file_list AS $file) {
|
105
|
?>
|
106
|
<li><a href="#" onclick="javascript: window.parent.document.<?php echo $popup; ?>.url.value = '<?php echo $file['url']; ?>';"><?php echo $file['name']; ?></a></li>
|
107
|
<?php
|
108
|
}
|
109
|
echo '</ul>';
|
110
|
}
|
111
|
|
112
|
?>
|
113
|
</body>
|
114
|
</html>
|