| [ Index ] |
|
Code source de eGroupWare 1.2.106-2 |
1 <?php 2 /**************************************************************************\ 3 * eGroupWare - Insert File Dialog, File Manager -plugin for tinymce * 4 * http://www.eGroupWare.org * 5 * Authors Al Rashid <alrashid@klokan.sk> * 6 * and Xiang Wei ZHUO <wei@zhuo.org> * 7 * Modified for eGW by Cornelius Weiss <egw@von-und-zu-weiss.de> * 8 * -------------------------------------------- * 9 * This program is free software; you can redistribute it and/or modify it * 10 * under the terms of the GNU General Public License as published by the * 11 * Free Software Foundation; version 2 of the License. * 12 \**************************************************************************/ 13 14 require ('config.inc.php'); 15 require ('functions.php'); 16 require ('view_text.php'); 17 18 //Reset auth variables 19 20 $refresh_dirs = false; 21 $clear_upload = false; 22 $err = false; 23 24 25 if (isset($_REQUEST['refresh'])) { 26 $refresh_dirs = true; 27 } 28 if (!isset($_REQUEST['view'])) { 29 $_REQUEST['view'] = 'text'; 30 } 31 if (isset($_REQUEST['path'])) { 32 //$path = $_REQUEST['path']; 33 $path = checkName($_REQUEST['path']); 34 $path = unsanitize($path); 35 $path = pathSlashes($path); 36 } else { 37 $path = '/'; 38 } 39 40 $MY_PATH = $path; 41 $MY_UP_PATH = substr($MY_PATH,0,@strrpos(substr($MY_PATH,0,strlen($MY_PATH)-1),'/'))."/"; 42 //echo "PATH:".$MY_PATH; 43 //echo "<br>UPP:".$MY_UP_PATH; 44 45 function createFolder() { 46 global $MY_ALLOW_CREATE, $MY_MESSAGES, $MY_DOCUMENT_ROOT, $refresh_dirs; 47 global $MY_PATH; 48 if (!$MY_ALLOW_CREATE) return ($MY_MESSAGES['nopermtocreatefolder']); 49 if (!(is_dir($MY_DOCUMENT_ROOT.$MY_PATH))) return ($MY_MESSAGES['pathnotfound']); 50 if ( !isset($_REQUEST['file'])) return ($MY_MESSAGES['foldernamemissing']); 51 $Folder = checkName($_REQUEST['file']); 52 //$Folder = utf8RawUrlDecode($Folder); 53 $newFolder = $MY_DOCUMENT_ROOT.$MY_PATH.$Folder; 54 if (is_dir($newFolder)) return ($MY_MESSAGES['folderalreadyexists']); 55 $newFolder = unsanitize($newFolder); 56 if (!(@mkdir($newFolder,0755))) return ($MY_MESSAGES['mkdirfailed']); 57 chmod($newFolder,0755); 58 $refresh_dirs = true; 59 return false; 60 } 61 62 function deleteFile() { 63 $error = false; 64 global $MY_ALLOW_DELETE, $MY_MESSAGES, $MY_DOCUMENT_ROOT, $MY_PATH ; 65 if (!$MY_ALLOW_DELETE) return ($MY_MESSAGES['nopermtodelete']); 66 if (isset($_REQUEST['folders']) && is_array($_REQUEST['folders'])) { 67 foreach ($_REQUEST['folders'] as $folder) { 68 $folder = unsanitize($folder); 69 deldir($MY_DOCUMENT_ROOT.$MY_PATH.$folder); 70 } 71 } 72 if (isset($_REQUEST['files']) && is_array($_REQUEST['files'])) { 73 foreach ($_REQUEST['files'] as $file) { 74 $file = unsanitize($file); 75 $delFile = $MY_DOCUMENT_ROOT.$MY_PATH.$file; 76 if (is_file($delFile)) { 77 if (!(unlink($delFile))) $error = $error.'\n'.alertSanitize($MY_MESSAGES['unlinkfailed'].' ('.$delFile.')'); 78 } else { 79 $error = $error.'\n'.alertSanitize($MY_MESSAGES['filenotfound'].' ('.$delFile.')'); 80 } 81 } 82 } 83 $refresh_dirs = true; 84 return $error; 85 } 86 87 function deldir($dir){ 88 $current_dir = opendir($dir); 89 while (false !== ($entryname = readdir($current_dir))) { 90 if(is_dir("$dir/$entryname") and ($entryname != "." and $entryname!="..")){ 91 deldir("$dir}/$entryname}"); 92 }elseif($entryname != "." and $entryname!=".."){ 93 unlink("$dir}/$entryname}"); 94 } 95 } 96 closedir($current_dir); 97 rmdir($dir); 98 } 99 100 function renameFile() { 101 global $MY_ALLOW_RENAME, $MY_MESSAGES, $MY_DOCUMENT_ROOT, $MY_PATH, $refresh_dirs; 102 global $MY_ALLOW_EXTENSIONS, $MY_DENY_EXTENSIONS ; 103 $error = false; 104 if (!$MY_ALLOW_RENAME) return ($MY_MESSAGES['nopermtorename']); 105 if (isset($_REQUEST['folders']) && is_array($_REQUEST['folders'])) { 106 foreach ($_REQUEST['folders'] as $file) { 107 $oldname = checkName(unsanitize($file['oldname'])); 108 $newname = checkName(unsanitize($file['newname'])); 109 $oldFile = $MY_DOCUMENT_ROOT.$MY_PATH.$oldname; 110 $newFile = $MY_DOCUMENT_ROOT.$MY_PATH.$newname; 111 if (is_dir($oldFile)) { 112 if (is_dir($newFile)) { 113 $error = $error.'\n'.alertSanitize($MY_MESSAGES['folderalreadyexists'].' ('.$oldFile.' -> '.$newFile.')'); 114 } else { 115 if (!rename($oldFile, $newFile)) $error = $error.'\n'.alertSanitize($MY_MESSAGES['renamefailed'].' ('.$oldFile.' -> '.$newFile.')'); 116 } 117 } else { 118 $error = $error.'\n'.alertSanitize($MY_MESSAGES['foldernotfound'].' ('.$oldFile.')'); 119 } 120 } 121 } 122 123 if (isset($_REQUEST['files']) && is_array($_REQUEST['files'])) { 124 foreach ($_REQUEST['files'] as $file) { 125 $oldname = checkName(unsanitize($file['oldname'])); 126 $newname = checkName(unsanitize($file['newname'])); 127 $parts = explode('.', $newname); 128 $ext = strtolower($parts[count($parts)-1]); 129 if (is_array($MY_DENY_EXTENSIONS )) { 130 if (in_array($ext, $MY_DENY_EXTENSIONS)) $error = $error.'\n'.$MY_MESSAGES['extnotallowed']; 131 } 132 if (is_array($MY_ALLOW_EXTENSIONS )) { 133 if (!in_array($ext, $MY_ALLOW_EXTENSIONS)) $error = $error.'\n'.$MY_MESSAGES['extnotallowed']; 134 } 135 $oldFile = $MY_DOCUMENT_ROOT.$MY_PATH.$oldname; 136 $newFile = $MY_DOCUMENT_ROOT.$MY_PATH.$newname; 137 if (is_file($oldFile)) { 138 if (is_file($newFile)) { 139 $error = $error.'\n'.alertSanitize($MY_MESSAGES['filealreadyexists'].' ('.$oldFile.' -> '.$newFile.')'); 140 } else { 141 if (!rename($oldFile, $newFile)) $error = $error.'\n'.alertSanitize($MY_MESSAGES['renamefailed'].' ('.$oldFile.' -> '.$newFile.')'); 142 } 143 } else { 144 $error = $error.'\n'.alertSanitize($MY_MESSAGES['filenotfound'].' ('.$oldFile.')'); 145 } 146 } 147 } 148 149 $refresh_dirs = true; 150 return $error; 151 } 152 153 function moveFile() { 154 global $MY_ALLOW_MOVE, $MY_MESSAGES, $MY_DOCUMENT_ROOT, $MY_PATH, $refresh_dirs; 155 global $MY_ALLOW_EXTENSIONS, $MY_DENY_EXTENSIONS ; 156 $error = false; 157 if (!$MY_ALLOW_MOVE) return ($MY_MESSAGES['nopermtomove']); 158 $newPath = pathSlashes(checkName($_REQUEST['newpath'])); 159 if (!(is_dir($MY_DOCUMENT_ROOT.$newPath))) return ($MY_MESSAGES['pathnotfound']); 160 if (isset($_REQUEST['folders']) && is_array($_REQUEST['folders'])) { 161 foreach ($_REQUEST['folders'] as $file) { 162 $name = checkName(unsanitize($file)); 163 $oldFile = $MY_DOCUMENT_ROOT.$MY_PATH.$name; 164 $newFile = $MY_DOCUMENT_ROOT.$newPath.$name; 165 if (is_dir($oldFile)) { 166 if (is_dir($newFile)) { 167 $error = $error.'\n'.alertSanitize($MY_MESSAGES['folderalreadyexists'].' ('.$oldFile.' -> '.$newFile.')'); 168 } else { 169 if (!rename($oldFile, $newFile)) $error = $error.'\n'.alertSanitize($MY_MESSAGES['renamefailed'].' ('.$oldFile.' -> '.$newFile.')'); 170 } 171 } else { 172 $error = $error.'\n'.alertSanitize($MY_MESSAGES['foldernotfound'].' ('.$oldFile.')'); 173 } 174 } 175 } 176 if (isset($_REQUEST['files']) && is_array($_REQUEST['files'])) { 177 foreach ($_REQUEST['files'] as $file) { 178 $name = checkName(unsanitize($file)); 179 $oldFile = $MY_DOCUMENT_ROOT.$MY_PATH.$name; 180 $newFile = $MY_DOCUMENT_ROOT.$newPath.$name; 181 if (is_file($oldFile)) { 182 if (is_file($newFile)) { 183 $error = $error.'\n'.alertSanitize($MY_MESSAGES['filealreadyexists'].' ('.$oldFile.' -> '.$newFile.')'); 184 } else { 185 if (!rename($oldFile, $newFile)) $error = $error.'\n'.alertSanitize($MY_MESSAGES['renamefailed'].' ('.$oldFile.' -> '.$newFile.')'); 186 } 187 } else { 188 $error = $error.'\n'.alertSanitize($MY_MESSAGES['filenotfound'].' ('.$oldFile.')'); 189 } 190 } 191 } 192 $refresh_dirs = true; 193 return $error; 194 } 195 196 function uploadFile() { 197 global $MY_ALLOW_UPLOAD, $MY_MESSAGES, $MY_DOCUMENT_ROOT, $MY_PATH, $clear_upload; 198 global $MY_ALLOW_EXTENSIONS, $MY_DENY_EXTENSIONS, $MY_MAX_FILE_SIZE ; 199 if (!$MY_ALLOW_UPLOAD) return ($MY_MESSAGES['nopermtoupload']); 200 if (!(is_dir($MY_DOCUMENT_ROOT.$MY_PATH))) return ($MY_MESSAGES['pathnotfound']); 201 $filename = checkName($_FILES['uploadFile']['name']); 202 $newFile = $MY_DOCUMENT_ROOT.$MY_PATH.$filename; 203 $parts = explode('.', $filename); 204 $ext = strtolower($parts[count($parts)-1]); 205 if (is_file($newFile)) return ($MY_MESSAGES['uploadfilealreadyexists']); 206 if (is_array($MY_DENY_EXTENSIONS )) { 207 if (in_array($ext, $MY_DENY_EXTENSIONS)) return ($MY_MESSAGES['extnotallowed']); 208 } 209 if (is_array($MY_ALLOW_EXTENSIONS )) { 210 if (!in_array($ext, $MY_ALLOW_EXTENSIONS)) return ($MY_MESSAGES['extnotallowed']); 211 } 212 if ($MY_MAX_FILE_SIZE) { 213 if ($_FILES['uploadFile']['size'] > $MY_MAX_FILE_SIZE) return ($MY_MESSAGES['filesizeexceedlimit'].' of '.($MY_MAX_FILE_SIZE/1024).'kB.'); 214 } 215 if (!is_file($_FILES['uploadFile']['tmp_name'])) return ($MY_MESSAGES['filenotuploaded']); 216 move_uploaded_file($_FILES['uploadFile']['tmp_name'], $newFile); 217 chmod($newFile, 0666); 218 $clear_upload = true; 219 return false; 220 } 221 222 if (isset($_REQUEST['action'])) { 223 if ('delete' == $_REQUEST['action']) $err = deleteFile(); 224 if ('rename' == $_REQUEST['action']) $err = renameFile(); 225 if ('move' == $_REQUEST['action']) $err = moveFile(); 226 if ('createFolder' == $_REQUEST['action']) $err = createFolder(); 227 } 228 if (isset($_FILES['uploadFile']) && is_array($_FILES['uploadFile'])) $err = uploadFile(); 229 230 231 function parse_size($size) { 232 if($size < 1024) 233 return $size.' bytes'; 234 else if($size >= 1024 && $size < 1024*1024) { 235 return sprintf('%01.2f',$size/1024.0).' KB'; 236 } else { 237 return sprintf('%01.2f',$size/(1024.0*1024)).' MB'; 238 } 239 } 240 241 function parse_time($timestamp) { 242 global $MY_DATETIME_FORMAT; 243 return date($MY_DATETIME_FORMAT, $timestamp); 244 } 245 246 247 function draw_no_results() { 248 global $MY_MESSAGES; 249 echo '<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0" style="background-color:Window;"> <tr> 250 <td><div align="center" style="font-size:large;font-weight:bold;color:#CCCCCC;font-family: Helvetica, sans-serif;">'; 251 echo $MY_MESSAGES['nofiles']; 252 echo '</div></td></tr></table>'; 253 } 254 255 function draw_no_dir() { 256 global $MY_MESSAGES; 257 global $MY_DOCUMENT_ROOT; 258 echo '<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0" style="background-color:Window;"><tr> 259 <td><div align="center" style="font-size:small;font-weight:bold;color:#CC0000;font-family: Helvetica, sans-serif;">'; 260 echo $MY_MESSAGES['configproblem']." ".$MY_DOCUMENT_ROOT; 261 echo '</div></td></tr></table>'; 262 } 263 264 ?> 265 <html> 266 <head> 267 <title>File Browser</title> 268 <?php 269 echo '<meta http-equiv="content-language" content="'.$MY_LANG.'" />'."\n"; 270 echo '<meta http-equiv="Content-Type" content="text/html; charset='.$MY_CHARSET.'" />'."\n"; 271 echo '<meta name="author" content="AlRashid, www: http://alrashid.klokan.sk; mailto:alrashid@klokan.sk" />'."\n"; 272 ?> 273 274 <style type="text/css"> 275 <!-- 276 body { 277 font-family: Verdana, Helvetica, Arial, Sans-Serif; 278 font: message-box; 279 background: ThreedFace; 280 } 281 code { 282 font-size: 1em; 283 } 284 285 a { 286 color: black; 287 } 288 289 a:visited { 290 color: black; 291 } 292 .selected a { 293 background: Highlight; 294 color: HighlightText; 295 } 296 .selected a:visited { 297 background: Highlight; 298 color: HighlightText; 299 } 300 301 302 .selected { 303 background: Highlight; 304 color: HighlightText; 305 } 306 307 td { 308 font: icon; 309 padding: 2px 5px; 310 cursor: default; 311 -moz-user-select: none; 312 } 313 --> 314 </style> 315 <link type="text/css" rel="StyleSheet" href="css/sortabletable.css" /> 316 <script type="text/javascript" src="js/sortabletable.js"></script> 317 <script type="text/javascript" src="js/selectableelements.js"></script> 318 <script type="text/javascript" src="js/selectabletablerows.js"></script> 319 320 321 <script language="JavaScript" type="text/JavaScript"> 322 /*<![CDATA[*/ 323 324 function MM_findObj(n, d) { //v4.01 325 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { 326 d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} 327 if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; 328 for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); 329 if(!x && d.getElementById) x=d.getElementById(n); return x; 330 } 331 332 function MM_showHideLayers() { //v6.0 333 var i,p,v,obj,args=MM_showHideLayers.arguments; 334 for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i],window.top.document))!=null) { v=args[i+2]; 335 if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; } 336 obj.visibility=v; } 337 } 338 339 function changeLoadingStatus(state) { 340 var statusText = null; 341 if(state == 'load') { 342 statusText = '<?php echo $MY_MESSAGES['loading']; ?>'; 343 } 344 else if(state == 'upload') { 345 statusText = '<?php echo $MY_MESSAGES['uploading']; ?>'; 346 } 347 if(statusText != null) { 348 var obj = MM_findObj('loadingStatus', window.top.document); 349 if (obj != null && obj.innerHTML != null) 350 obj.innerHTML = statusText; 351 MM_showHideLayers('loading','','show') 352 } 353 } 354 355 function changeDir(nb) { 356 changeLoadingStatus('load'); 357 var postForm2 = document.getElementById('form2'); 358 postForm2.elements["action"].value="changeDir"; 359 postForm2.elements["path"].value=postForm2.elements["path"].value+folderJSArray[nb][1]; 360 postForm2.submit(); 361 } 362 363 function setSortBy(column, noclick) { 364 switch (column) { 365 case 0: st2.sort(4); 366 if (noclick) st.sort(0); 367 break; 368 case 2: st2.sort(5); 369 if (noclick) st.sort(2); 370 break; 371 case 3: st1.sort(6); 372 st2.sort(6); 373 if (noclick) st.sort(3); 374 break; 375 default: st1.sort(1); 376 st2.sort(1); 377 if (noclick) st.sort(1); 378 } 379 var topDoc = window.top.document.forms[0]; 380 topDoc.sortby.value = column; 381 } 382 383 function getSortBy() { 384 var topDoc = window.top.document.forms[0]; 385 return (topDoc.sortby.value); 386 } 387 388 function fileSelected(filename, caption, ext, width, height) 389 { 390 var topDoc = window.top.document.forms[0]; 391 topDoc.f_url.value = filename; 392 topDoc.f_url2.value = filename; 393 topDoc.f_caption.value = caption; 394 topDoc.f_alt.value = caption; 395 topDoc.f_width.value = width; 396 topDoc.f_height.value = height; 397 topDoc.orginal_width.value = width; 398 topDoc.orginal_height.value = height; 399 topDoc.f_ext.value = ext; 400 } 401 402 function updateDir() { 403 var newPath = "<?php echo $MY_PATH; ?>"; 404 if(window.top.document.forms[0] != null) { 405 var allPaths = window.top.document.forms[0].path.options; 406 for(i=0; i<allPaths.length; i++) { 407 allPaths.item(i).selected = false; 408 if((allPaths.item(i).value)==newPath) { 409 allPaths.item(i).selected = true; 410 } 411 } 412 } 413 } 414 415 <?php 416 if($clear_upload) { 417 echo ' 418 var topDoc = window.top.document.forms[0]; 419 topDoc.uploadFile.value = null; 420 '; 421 } 422 if ($refresh_dirs) { ?> 423 function refreshDirs() { 424 var allPaths = window.top.document.forms[0].path.options; 425 var fields = ['/' <?php dirs($MY_DOCUMENT_ROOT,'');?>]; 426 var newPath = '<?php echo sanitize2($MY_PATH); ?>'; 427 for(i = allPaths.length; i > 0; i--) { 428 allPaths[i-1]=null; 429 } 430 431 for(i=0; i<fields.length; i++) { 432 var newElem = document.createElement("OPTION"); 433 var newValue = fields[i]; 434 newElem.text = newValue; 435 newElem.value = newValue; 436 if(newValue == newPath) 437 newElem.selected = true; 438 else 439 newElem.selected = false; 440 allPaths.add(newElem); 441 } 442 } 443 refreshDirs(); 444 <?php 445 } 446 if ($err) { 447 echo 'alert(\''.$err.'\');'; 448 } 449 ?> 450 451 452 /*]]>*/ 453 </script> 454 </head> 455 <body onload="updateDir();"> 456 <form action="files.php?dialogname=<?php echo $MY_NAME; ?>&refresh=1" id="form2" name="form2" method="post" enctype="multipart/form-data"> 457 <input type="hidden" name="action" id="action" value="" /> 458 <input type="hidden" name="path" id="path" value="<?php echo $MY_PATH; ?>" /> 459 <input type="hidden" name="uppath" id="uppath" value="<?php echo $MY_UP_PATH; ?>" /> 460 <input type="hidden" name="newpath" id="newpath" value="" /> 461 <input type="hidden" name="file" id="file" value="" /> 462 <input type="hidden" name="view" id="view" value="<?php echo $_REQUEST['view'] ?>" /> 463 </form> 464 465 <?php 466 $d = @dir($MY_DOCUMENT_ROOT.$MY_PATH); 467 if($d) { 468 469 $classname = 'view_'.$_REQUEST['view']; 470 include_once $classname.'.php'; 471 $view = new $classname; 472 473 $entries_cnt = 0; 474 $fileNb=0; 475 $folderNb=0; 476 $fileJSArray='var fileJSArray = ['; 477 $folderJSArray='var folderJSArray = ['; 478 $params['MY_MESSAGES'] = $MY_MESSAGES; 479 $params['MY_BASE_URL'] = $MY_BASE_URL; 480 while (false !== ($entry = $d->read())) { 481 if(substr($entry,0,1) != '.') { 482 $params['entry'] = $entry; 483 $params['relativePath'] = $relativePath = $MY_PATH.$entry; 484 $params['absolutePath'] = $absolutePath = $MY_DOCUMENT_ROOT.$relativePath; 485 if (is_dir($absolutePath)) { 486 $entries_cnt++; 487 $params['time'] = $time = filemtime($absolutePath); 488 $params['parsed_time'] = $parsed_time = parse_time($time); 489 $params['folderNb'] = $folderNb; 490 $folders_body .= $view->folder_item($params); 491 $folderJSArray .= "['". $GLOBALS['egw_info']['server']['webserver_url']. '/phpgwapi/templates/default/images/mime/folder_small.gif'. "', '".sanitize2($entry)."', '".$MY_MESSAGES['folder']."', '".$parsed_time."'],\n"; 492 $folderNb++; 493 } else { 494 $entries_cnt++; 495 $params['ext'] = $ext = substr(strrchr($entry, '.'), 1); 496 if (is_array($MY_LIST_EXTENSIONS)) { 497 if (!in_array(strtolower($ext), $MY_LIST_EXTENSIONS)) continue; 498 } 499 $params['info'] = array(800,600); 500 if(in_array(strtolower($ext),array('jpg','gif','png','jpeg'))) $params['info'] = @getimagesize($absolutePath); 501 $params['size'] = $size = filesize($absolutePath); 502 $params['time'] = $time = filemtime($absolutePath); 503 $params['parsed_size'] = $parsed_size = parse_size($size); 504 $params['parsed_time'] = $parsed_time = parse_time($time); 505 $params['parsed_icon'] = $parsed_icon = $GLOBALS['egw_info']['server']['webserver_url']. '/phpgwapi/templates/default/images/mime/'. parse_icon($ext); 506 $params['fileNb'] = $fileNb; 507 $files_body .= $view->files_item($params); 508 $fileJSArray .= "['".$parsed_icon."', '".sanitize2($entry)."', '".$parsed_size."', '".$parsed_time."', '".$ext."'],\n"; 509 $fileNb++; 510 } 511 } 512 } 513 $d->close(); 514 $folderJSArray .= "['', '', '', '']];\n"; 515 $fileJSArray .= "['', '', '', '', '']];\n"; 516 517 if ($entries_cnt) { 518 echo $view->table_header($params); 519 // echo "\n<div style=\"height:90%; overflow: auto; overflow-y: scroll; background-color:window;\">"; 520 echo $view->folders_header($params).$folders_body.$view->folders_footer($params)."\n"; 521 echo $view->files_header($params). $files_body. $view->files_footer($params)."\n"; 522 // echo "</div>"."\n"; 523 echo $view->table_footer($params); 524 525 echo '<script type="text/javascript">'; 526 echo '/*<![CDATA[*/'; 527 echo $folderJSArray; 528 echo $fileJSArray; 529 echo '/*]]>*/'; 530 echo '</script>'; 531 } 532 else { 533 draw_no_results(); 534 } 535 } 536 elseif($_REQUEST['view'] == 'icon' && $d){ 537 $images = array(); 538 $folders = array(); 539 while (false !== ($entry = $d->read())) 540 { 541 $img_file = $MY_PATH.$entry; 542 $BASE_DIR = $MY_DOCUMENT_ROOT; 543 $BASE_URL = $MY_BASE_URL; 544 // $img_file = $IMG_ROOT.$entry; 545 546 if(is_file($BASE_DIR.$img_file) && substr($entry,0,1) != '.') 547 { 548 $image_info = @getimagesize($BASE_DIR.$img_file); 549 if(is_array($image_info)) 550 { 551 $file_details['file'] = $img_file; 552 $file_details['img_info'] = $image_info; 553 $file_details['size'] = filesize($BASE_DIR.$img_file); 554 $images[$entry] = $file_details; 555 //show_image($img_file, $entry, $image_info); 556 } 557 } 558 else if(is_dir($BASE_DIR.$img_file) && substr($entry,0,1) != '.') 559 { 560 $folders[$entry] = $img_file; 561 //show_dir($img_file, $entry); 562 } 563 } 564 $d->close(); 565 566 if(count($images) > 0 || count($folders) > 0) 567 { 568 //now sort the folders and images by name. 569 ksort($images); 570 ksort($folders); 571 572 echo '<table border="0" cellpadding="0" cellspacing="2"><tr>'; 573 574 for($i=0; $i<count($folders); $i++) 575 { 576 $folder_name = key($folders); 577 // show_dir($folders[$folder_name], $folder_name); 578 next($folders); 579 } 580 foreach($images as $image => $info) 581 { 582 // $image_name = key($images); 583 show_image($info['file'], $image, $info['img_info'], $info['size']); 584 } 585 echo '</tr></table>'; 586 } 587 else 588 { 589 draw_no_results(); 590 } 591 } 592 else 593 { 594 draw_no_dir(); 595 } 596 597 ?> 598 599 <script language="JavaScript" type="text/JavaScript"> 600 /*<![CDATA[*/ 601 MM_showHideLayers('loading','','hide') 602 /*]]>*/ 603 </script> 604 </body> 605 </html>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Sun Feb 25 17:20:01 2007 | par Balluche grâce à PHPXref 0.7 |