1 | <?php
|
---|
2 | /**
|
---|
3 | * ExtendedFileManager images.php file. Shows folders and files.
|
---|
4 | * Authors: Wei Zhuo, Afru, Krzysztof Kotowicz
|
---|
5 | * Version: Updated on 08-01-2005 by Afru
|
---|
6 | * Version: Updated on 21-06-2006 by Krzysztof Kotowicz
|
---|
7 | * Package: ExtendedFileManager (EFM 1.1.1)
|
---|
8 | * http://www.afrusoft.com/htmlarea
|
---|
9 | */
|
---|
10 |
|
---|
11 | if(isset($_REQUEST['mode'])) $insertMode=$_REQUEST['mode'];
|
---|
12 | if(!isset($insertMode)) $insertMode="image";
|
---|
13 |
|
---|
14 | require_once('config.inc.php');
|
---|
15 | require_once('Classes/ExtendedFileManager.php');
|
---|
16 |
|
---|
17 | //default path is /
|
---|
18 | $relative = '/';
|
---|
19 | $manager = new ExtendedFileManager($IMConfig, $insertMode);
|
---|
20 |
|
---|
21 | //process any file uploads
|
---|
22 | $uploadStatus=$manager->processUploads();
|
---|
23 |
|
---|
24 | if ($manager->deleteFiles())
|
---|
25 | $refreshFile = true;
|
---|
26 |
|
---|
27 | $refreshDir = false;
|
---|
28 | //process any directory functions
|
---|
29 | if($manager->deleteDirs() || $manager->processNewDir())
|
---|
30 | $refreshDir = true;
|
---|
31 |
|
---|
32 |
|
---|
33 | $diskInfo=$manager->getDiskInfo();
|
---|
34 |
|
---|
35 | //check for any sub-directory request
|
---|
36 | //check that the requested sub-directory exists
|
---|
37 | //and valid
|
---|
38 | if(isset($_REQUEST['dir']))
|
---|
39 | {
|
---|
40 | $path = rawurldecode($_REQUEST['dir']);
|
---|
41 | if($manager->validRelativePath($path))
|
---|
42 | $relative = $path;
|
---|
43 | }
|
---|
44 |
|
---|
45 |
|
---|
46 | $afruViewType="";
|
---|
47 | if(isset($_REQUEST['viewtype']))
|
---|
48 | {
|
---|
49 | $afruViewType=$_REQUEST['viewtype'];
|
---|
50 | }
|
---|
51 | if($afruViewType!="thumbview" && $afruViewType!="listview")
|
---|
52 |
|
---|
53 | $afruViewType=$IMConfig['view_type'];
|
---|
54 |
|
---|
55 | //get the list of files and directories
|
---|
56 | $list = $manager->getFiles($relative);
|
---|
57 |
|
---|
58 |
|
---|
59 | /* ================= OUTPUT/DRAW FUNCTIONS ======================= */
|
---|
60 |
|
---|
61 |
|
---|
62 | /**
|
---|
63 | * Draw folders and files. Changed by Afru
|
---|
64 | */
|
---|
65 | function drawDirs_Files($list, &$manager)
|
---|
66 | {
|
---|
67 | global $relative, $afruViewType, $IMConfig, $insertMode;
|
---|
68 |
|
---|
69 | switch ($afruViewType) {
|
---|
70 | case 'listview':
|
---|
71 | $maxNameLength = 30;
|
---|
72 | ?>
|
---|
73 | <table class="listview">
|
---|
74 | <thead>
|
---|
75 | <tr><th colspan="2">Name</th><th>Size</th><th>Image Size</th><th>Date Modified</th><th> </th></tr></thead>
|
---|
76 | <tbody>
|
---|
77 | <?php
|
---|
78 | // start of foreach for draw listview folders .
|
---|
79 | foreach($list[0] as $path => $dir)
|
---|
80 | { ?>
|
---|
81 | <tr>
|
---|
82 | <td><img src="<?php print $IMConfig['base_url'];?>icons/folder_small.gif" alt="" /></td>
|
---|
83 | <th nowrap><a href="<?php print $IMConfig['backend_url']; ?>__function=images&mode=<?php echo $insertMode;?>&dir=<?php echo rawurlencode($path); ?>&viewtype=<?php echo $afruViewType; ?>" onclick="updateDir('<?php echo $path; ?>')" title="<?php echo $dir['entry']; ?>">
|
---|
84 | <?php
|
---|
85 | if(strlen($dir['entry'])>$maxNameLength) echo substr($dir['entry'],0,$maxNameLength)."..."; else echo $dir['entry'];
|
---|
86 | ?>
|
---|
87 | </a></th>
|
---|
88 | <td colspan="2" nowrap>Folder</td>
|
---|
89 |
|
---|
90 | <td nowrap><?php echo date("d.m.y H:i",$dir['stat']['mtime']); ?></td>
|
---|
91 |
|
---|
92 | <td class="actions" nowrap>
|
---|
93 | <a href="<?php print $IMConfig['backend_url']; ?>__function=images&mode=<?php echo $insertMode;?>&dir=<?php echo $relative; ?>&deld=<?php echo rawurlencode($path); ?>&viewtype=<?php echo $afruViewType; ?>" title="Trash" onclick="return confirmDeleteDir('<?php echo $dir['entry']; ?>', <?php echo $dir['count']; ?>);" style="border:0px;"><img src="<?php print $IMConfig['base_url'];?>img/edit_trash.gif" height="15" width="15" alt="Trash" border="0" /></a>
|
---|
94 | </td>
|
---|
95 | </tr>
|
---|
96 | <?php
|
---|
97 | } // end of foreach for draw listview folders .
|
---|
98 |
|
---|
99 | clearstatcache();
|
---|
100 |
|
---|
101 | // start of foreach for draw listview files .
|
---|
102 | foreach($list[1] as $entry => $file)
|
---|
103 | {
|
---|
104 | ?>
|
---|
105 | <tr>
|
---|
106 | <td><img src="<?php print $IMConfig['base_url']; if(is_file('icons/'.$file['ext'].'_small.gif')) echo "icons/".$file['ext']."_small.gif"; else echo $IMConfig['default_listicon']; ?>" alt="" /></td>
|
---|
107 | <th><a href="#" class="thumb" style="cursor: pointer;" onclick="selectImage('<?php echo $file['relative'];?>', '<?php echo $entry; ?>', <?php echo $file['image'][0];?>, <?php echo $file['image'][1]; ?>);return false;" title="<?php echo $entry; ?> - <?php echo Files::formatSize($file['stat']['size']); ?>" <?php if ($insertMode == 'image') { ?> onmouseover="showPreview('<?php echo $file['relative'];?>')" onmouseout="showPreview(window.parent.document.getElementById('f_url').value)" <?php } ?> >
|
---|
108 | <?php
|
---|
109 | if(strlen($entry)>$maxNameLength) echo substr($entry,0,$maxNameLength)."..."; else echo $entry;
|
---|
110 | ?>
|
---|
111 | </a></th>
|
---|
112 | <td><?php echo Files::formatSize($file['stat']['size']); ?></td>
|
---|
113 | <td><?php if($file['image'][0] > 0){ echo $file['image'][0].'x'.$file['image'][1]; } ?></td>
|
---|
114 | <td nowrap><?php echo date("d.m.y H:i",$file['stat']['mtime']); ?></td>
|
---|
115 | <td class="actions">
|
---|
116 | <a href="<?php print $IMConfig['backend_url']; ?>__function=images&dir=<?php echo $relative; ?>&delf=<?php echo rawurlencode($file['relative']);?>&mode=<?php echo $insertMode;?>&viewtype=<?php echo $afruViewType; ?>" title="Trash" onclick="return confirmDeleteFile('<?php echo $entry; ?>');"><img src="<?php print $IMConfig['base_url'];?>img/edit_trash.gif" height="15" width="15" alt="Trash" border="0" /></a>
|
---|
117 | <?php if($IMConfig['img_library'] && $IMConfig['allow_edit_image'] && $file['image'][0] > 0) { ?>
|
---|
118 | <a href="javascript:;" title="Edit" onclick="editImage('<?php echo rawurlencode($file['relative']);?>');"><img src="<?php print $IMConfig['base_url'];?>img/edit_pencil.gif" height="15" width="15" alt="Edit" border="0" /></a>
|
---|
119 | <?php } ?>
|
---|
120 | </td>
|
---|
121 | </tr>
|
---|
122 | <?php
|
---|
123 | }//end of foreach of draw listview files
|
---|
124 | ?>
|
---|
125 | </tbody>
|
---|
126 | </table>
|
---|
127 | <?php
|
---|
128 | break;
|
---|
129 | case 'thumbview': // thumbview is default
|
---|
130 | default:
|
---|
131 | $maxFileNameLength=10;
|
---|
132 | $maxFolderNameLength=13;
|
---|
133 | // start of foreach for draw thumbview folders.
|
---|
134 | foreach($list[0] as $path => $dir)
|
---|
135 | { ?>
|
---|
136 | <div class="dir_holder">
|
---|
137 | <a class="dir" href="<?php print $IMConfig['backend_url'];?>__function=images&mode=<?php echo $insertMode;?>&dir=<?php echo rawurlencode($path); ?>&viewtype=<?php echo $afruViewType; ?>" onclick="updateDir('<?php echo $path; ?>')" title="<?php echo $dir['entry']; ?>"><img src="<?php print $IMConfig['base_url'];?>img/folder.gif" height="80" width="80" alt="<?php echo $dir['entry']; ?>" /></a>
|
---|
138 |
|
---|
139 | <div class="edit">
|
---|
140 | <a href="<?php print $IMConfig['backend_url'];?>__function=images&mode=<?php echo $insertMode;?>&dir=<?php echo $relative; ?>&deld=<?php echo rawurlencode($path); ?>&viewtype=<?php echo $afruViewType; ?>" title="Trash" onclick="return confirmDeleteDir('<?php echo $dir['entry']; ?>', <?php echo $dir['count']; ?>);"><img src="<?php print $IMConfig['base_url'];?>img/edit_trash.gif" height="15" width="15" alt="Trash" /></a>
|
---|
141 | <?php if(strlen($dir['entry']) > $maxFolderNameLength)
|
---|
142 | echo substr($dir['entry'], 0, $maxFolderNameLength) . "...";
|
---|
143 | else
|
---|
144 | echo $dir['entry']; ?>
|
---|
145 | </div>
|
---|
146 | </div>
|
---|
147 | <?php
|
---|
148 | } // end of foreach for draw thumbview folders.
|
---|
149 |
|
---|
150 |
|
---|
151 | // start of foreach for draw thumbview files.
|
---|
152 | foreach($list[1] as $entry => $file)
|
---|
153 | {
|
---|
154 | $afruimgdimensions=$manager->checkImageSize($file['relative']);
|
---|
155 | ?>
|
---|
156 | <div class="thumb_holder" id="holder_<?php echo asc2hex($entry) ?>">
|
---|
157 | <a href="#" class="thumb" style="cursor: pointer;" onclick="selectImage('<?php echo $file['relative'];?>', '<?php echo $entry; ?>', <?php echo $file['image'][0];?>, <?php echo $file['image'][1]; ?>);return false;" title="<?php echo $entry; ?> - <?php echo Files::formatSize($file['stat']['size']); ?>">
|
---|
158 | <img src="<?php print $manager->getThumbnail($file['relative']); ?>" alt="<?php echo $entry; ?> - <?php echo Files::formatSize($file['stat']['size']); ?>" />
|
---|
159 | </a>
|
---|
160 | <div class="edit">
|
---|
161 | <a href="<?php print $IMConfig['backend_url']; ?>__function=images&mode=<?php echo $insertMode;?>&dir=<?php echo $relative; ?>&delf=<?php echo rawurlencode($file['relative']);?>&viewtype=<?php echo $afruViewType; ?>" title="Trash" onclick="return confirmDeleteFile('<?php echo $entry; ?>');"><img src="<?php print $IMConfig['base_url'];?>img/edit_trash.gif" height="15" width="15" alt="Trash" /></a>
|
---|
162 |
|
---|
163 | <?php if($IMConfig['img_library'] && $IMConfig['allow_edit_image'] && $file['image'][0] > 0 )
|
---|
164 | { ?>
|
---|
165 | <a href="javascript:;" title="Edit" onclick="editImage('<?php echo rawurlencode($file['relative']);?>');"><img src="<?php print $IMConfig['base_url'];?>img/edit_pencil.gif" height="15" width="15" alt="Edit" /></a>
|
---|
166 | <?php $maxFileName2=$maxFileNameLength-3;}
|
---|
167 | else $maxFileName2=$maxFileNameLength; ?>
|
---|
168 |
|
---|
169 | <?php
|
---|
170 | if(strlen($entry)>$maxFileName2) echo strtolower(substr($entry,0,$maxFileName2))."..."; else echo $entry;
|
---|
171 | ?>
|
---|
172 | </div>
|
---|
173 | </div>
|
---|
174 | <?php
|
---|
175 | }//end of foreach of draw thumbview files
|
---|
176 |
|
---|
177 | }
|
---|
178 | }//end of function drawDirs_Files
|
---|
179 |
|
---|
180 |
|
---|
181 | /**
|
---|
182 | * No directories and no files.
|
---|
183 | */
|
---|
184 | function drawNoResults()
|
---|
185 | {
|
---|
186 | ?>
|
---|
187 | <div class="noResult">No Files Found</div>
|
---|
188 | <?php
|
---|
189 | }
|
---|
190 |
|
---|
191 | /**
|
---|
192 | * No directories and no files.
|
---|
193 | */
|
---|
194 | function drawErrorBase(&$manager)
|
---|
195 | {
|
---|
196 | ?>
|
---|
197 | <div class="error"><span>Invalid base directory:</span> <?php echo $manager->config['images_dir']; ?></div>
|
---|
198 | <?php
|
---|
199 | }
|
---|
200 |
|
---|
201 | /**
|
---|
202 | * Utility to convert ascii string to hex
|
---|
203 | */
|
---|
204 | function asc2hex ($temp)
|
---|
205 | {
|
---|
206 | $data = '';
|
---|
207 | $len = strlen($temp);
|
---|
208 | for ($i=0; $i<$len; $i++) $data.=sprintf("%02x",ord(substr($temp,$i,1)));
|
---|
209 | return $data;
|
---|
210 | }
|
---|
211 |
|
---|
212 | ?>
|
---|
213 | <html>
|
---|
214 | <head>
|
---|
215 | <title>File List</title>
|
---|
216 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
---|
217 | <link href="<?php print $IMConfig['base_url'];?>assets/imagelist.css" rel="stylesheet" type="text/css" />
|
---|
218 | <script type="text/javascript" src="<?php print $IMConfig['base_url'];?>assets/dialog.js"></script>
|
---|
219 | <script type="text/javascript">
|
---|
220 | /*<![CDATA[*/
|
---|
221 |
|
---|
222 | var _backend_url = "<?php print $IMConfig['backend_url']; ?>";
|
---|
223 |
|
---|
224 | if(window.top)
|
---|
225 | HTMLArea = window.top.HTMLArea;
|
---|
226 |
|
---|
227 | function hideMessage()
|
---|
228 | {
|
---|
229 | var topDoc = window.top.document;
|
---|
230 | var messages = topDoc.getElementById('messages');
|
---|
231 | if(messages)
|
---|
232 | messages.style.display = "none";
|
---|
233 | }
|
---|
234 |
|
---|
235 | init = function()
|
---|
236 | {
|
---|
237 | __dlg_translate('ExtendedFileManager');
|
---|
238 |
|
---|
239 | hideMessage();
|
---|
240 |
|
---|
241 | <?php
|
---|
242 | if(isset($uploadStatus) && !is_numeric($uploadStatus) && !is_bool($uploadStatus))
|
---|
243 | echo 'alert("'.$uploadStatus.'");';
|
---|
244 | else if(isset($uploadStatus) && $uploadStatus==false)
|
---|
245 | echo 'alert("Unable to upload File. \nEither Maximum file size ['.($insertMode == 'image' ? $IMConfig['max_filesize_kb_image'] : $IMConfig['max_filesize_kb_link'] ).'Kb] exceeded or\nFolder doesn\'t have write permission.");';
|
---|
246 | ?>
|
---|
247 |
|
---|
248 |
|
---|
249 | var topDoc = window.top.document;
|
---|
250 |
|
---|
251 | <?php
|
---|
252 | //we need to refesh the drop directory list
|
---|
253 | //save the current dir, delete all select options
|
---|
254 | //add the new list, re-select the saved dir.
|
---|
255 | if($refreshDir)
|
---|
256 | {
|
---|
257 | $dirs = $manager->getDirs();
|
---|
258 | ?>
|
---|
259 | var selection = topDoc.getElementById('dirPath');
|
---|
260 | var currentDir = selection.options[selection.selectedIndex].text;
|
---|
261 |
|
---|
262 | while(selection.length > 0)
|
---|
263 | { selection.remove(0); }
|
---|
264 |
|
---|
265 | selection.options[selection.length] = new Option("/","<?php echo rawurlencode('/'); ?>");
|
---|
266 | <?php foreach($dirs as $relative=>$fullpath) { ?>
|
---|
267 | selection.options[selection.length] = new Option("<?php echo $relative; ?>","<?php echo rawurlencode($relative); ?>");
|
---|
268 | <?php } ?>
|
---|
269 |
|
---|
270 | for(var i = 0; i < selection.length; i++)
|
---|
271 | {
|
---|
272 | var thisDir = selection.options[i].text;
|
---|
273 | if(thisDir == currentDir)
|
---|
274 | {
|
---|
275 | selection.selectedIndex = i;
|
---|
276 | break;
|
---|
277 | }
|
---|
278 | }
|
---|
279 | <?php } ?>
|
---|
280 | }
|
---|
281 |
|
---|
282 | function editImage(image)
|
---|
283 | {
|
---|
284 | var url = "<?php print $IMConfig['backend_url']; ?>__function=editor&img="+image;
|
---|
285 | Dialog(url, function(param)
|
---|
286 | {
|
---|
287 | if (!param) { // user must have pressed Cancel
|
---|
288 | return false;
|
---|
289 | } else
|
---|
290 | {
|
---|
291 | return true;
|
---|
292 | }
|
---|
293 | }, null);
|
---|
294 | }
|
---|
295 |
|
---|
296 | /*]]>*/
|
---|
297 | </script>
|
---|
298 | <script type="text/javascript" src="<?php print $IMConfig['base_url'];?>assets/images.js"></script>
|
---|
299 | <script type="text/javascript" src="<?php print $IMConfig['base_url'];?>assets/popup.js"></script>
|
---|
300 | <script type="text/javascript">
|
---|
301 | <!--
|
---|
302 | // Koto: why emptying? commented out
|
---|
303 | //if(window.top.document.getElementById('manager_mode').value=="image")
|
---|
304 | //emptyProperties();
|
---|
305 | <?php if(isset($diskInfo)) echo 'updateDiskMesg("'.$diskInfo.'");'; ?>
|
---|
306 | //-->
|
---|
307 | </script>
|
---|
308 |
|
---|
309 | </head>
|
---|
310 |
|
---|
311 | <body>
|
---|
312 | <?php if ($manager->isValidBase() == false) { drawErrorBase($manager); }
|
---|
313 | elseif(count($list[0]) > 0 || count($list[1]) > 0) { ?>
|
---|
314 | <?php drawDirs_Files($list, $manager); ?>
|
---|
315 | <?php } else { drawNoResults(); } ?>
|
---|
316 | </body>
|
---|
317 | </html>
|
---|