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