[ Index ]
 

Code source de eGroupWare 1.2.106-2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageManager/ -> images.php (source)

   1  <?php
   2     /**************************************************************************\
   3     * eGroupWare - UploadImage-plugin for htmlArea                             *
   4     * http://www.eGroupWare.org                                                *
   5     * Written and (c) by Xiang Wei ZHUO <wei@zhuo.org>                         *
   6     * Modified for eGW by and (c) by Pim Snel <pim@lingewoud.nl>               *
   7     * --------------------------------------------                             *
   8     * This program is free software; you can redistribute it and/or modify it  *
   9     * under the terms of the GNU General Public License as published by the    *
  10     * Free Software Foundation; version 2 of the License.                      *
  11     * --------------------------------------------                             *
  12     * Title.........:    Image Manager, draws the thumbnails and directies     *
  13     * Version.......:    1.01                                                  *
  14     * Author........:    Xiang Wei ZHUO <wei@zhuo.org>                         *
  15     * Notes.........:    Configuration in config.inc.php                       *
  16     *                                                                          *
  17     * Functions                                                                *
  18     * - create a new folder,                                                   *
  19     * - delete folder,                                                         *
  20     * - upload new image                                                       *
  21     * - use cached thumbnail views                                             *
  22     \**************************************************************************/
  23  
  24     /* $id */
  25  
  26     // FIXME move all php functions to a main file
  27     // FIXME better directory-structure
  28  
  29     include  'config.inc.php';
  30     require_once  'std_functions.inc.php';
  31     require_once  '../ImageEditor/Transform.php';
  32  
  33     if(isset($_GET['dir'])) {
  34        $dirParam = $_GET['dir'];
  35  
  36        if(strlen($dirParam) > 0) 
  37        {
  38           if(substr($dirParam,0,1)=='/') 
  39           $IMG_ROOT .= $dirParam;        
  40           else
  41           $IMG_ROOT = $dirParam;            
  42        }    
  43     }
  44  
  45     $refresh_dirs = false;
  46     $clearUploads = false;
  47  
  48     if(strrpos($IMG_ROOT, '/')!= strlen($IMG_ROOT)-1) 
  49     $IMG_ROOT .= '/';
  50  
  51     if(isset($_GET['create']) && isset($_GET['dir']) && $SAFE_MODE == false) 
  52     {
  53        create_folder();    
  54     }
  55  
  56     if(isset($_GET['delFile']) && isset($_GET['dir'])) 
  57     {
  58        delete_file($_GET['delFile']);    
  59     }
  60  
  61     if(isset($_GET['delFolder']) && isset($_GET['dir'])) 
  62     {
  63        delete_folder($_GET['delFolder']);    
  64     }
  65  
  66     if(isset($_FILES['upload']) && is_array($_FILES['upload']) && isset($_POST['dirPath'])) 
  67     {
  68        $dirPathPost = $_POST['dirPath'];
  69  
  70        if(strlen($dirPathPost) > 0) 
  71        {
  72           if(substr($dirPathPost,0,1)=='/') 
  73           $IMG_ROOT .= $dirPathPost;        
  74           else
  75           $IMG_ROOT = $dirPathPost;            
  76        }
  77  
  78        if(strrpos($IMG_ROOT, '/')!= strlen($IMG_ROOT)-1) 
  79        $IMG_ROOT .= '/';
  80  
  81        //    do_upload($_FILES['upload'], $BASE_DIR.$BASE_ROOT.$dirPathPost.'/');
  82        do_upload($_FILES['upload'], $BASE_DIR.$dirPathPost.'/');
  83     }
  84  
  85     function do_upload($file, $dest_dir) 
  86     {
  87        global $clearUploads,$MAX_WIDTH,$MAX_HEIGHT;
  88  
  89        if(is_file($file['tmp_name'])) 
  90        {
  91           $img_info = getimagesize($file['tmp_name']);
  92  
  93           //_debug_array($img_info); 
  94           
  95           if(is_array($img_info))
  96           {
  97              $w = $img_info[0]; 
  98              $h = $img_info[1];
  99  
 100              if( $w > $MAX_WIDTH || $h > $MAX_HEIGHT )
 101              {
 102                 adapt_size($file['tmp_name'],$dest_dir.$file['name']);
 103              }
 104              else
 105              {
 106                 move_uploaded_file($file['tmp_name'], $dest_dir.$file['name']);    
 107              }
 108              chmod($dest_dir.$file['name'], 0666);
 109           }
 110        }
 111  
 112        $clearUploads = true;
 113     }
 114  
 115     
 116     function adapt_size($img,$dest_file) 
 117     {
 118        global $BASE_DIR, $BASE_URL,$MAX_WIDTH,$MAX_HEIGHT;
 119  
 120        $path_info = pathinfo($img);
 121        $path = $path_info['dirname']."/";
 122        $img_file = $path_info['basename'];
 123  
 124        $img_info = getimagesize($path.$img_file);
 125        $w = $img_info[0]; $h = $img_info[1];
 126  
 127        $nw = $MAX_WIDTH; $nh = $MAX_HEIGHT;
 128  
 129        $img_resize = Image_Transform::factory(IMAGE_CLASS);
 130        $img_resize->load($path.$img_file);
 131  
 132        if ($w > $h) 
 133        $nh = unpercent(percent($nw, $w), $h);          
 134        else if ($h > $w) 
 135        $nw = unpercent(percent($nh, $h), $w); 
 136  
 137        $img_resize->resize($nw, $nh);
 138  
 139        $img_resize->save($dest_file);
 140        $img_resize->free();
 141  
 142        chmod($dest_file, 0666);
 143     }
 144  
 145     
 146     
 147     function delete_folder($folder) 
 148     {
 149        global $BASE_DIR, $refresh_dirs;
 150        
 151        $del_folder = dir_name($BASE_DIR).$folder;
 152        
 153        if(is_dir($del_folder) && num_files($del_folder) <= 0) 
 154        {
 155           rm_all_dir($del_folder);
 156           $refresh_dirs = true;
 157        }
 158     }
 159  
 160     function rm_all_dir($dir) 
 161     {
 162        //$dir = dir_name($dir);
 163        //echo "OPEN:".$dir.'<Br>';
 164        if(is_dir($dir)) 
 165        {
 166           $d = @dir($dir);
 167  
 168           while (false !== ($entry = $d->read())) 
 169           {
 170              //echo "#".$entry.'<br>';
 171              if($entry != '.' && $entry != '..') 
 172              {
 173                 $node = $dir.'/'.$entry;
 174                 //echo "NODE:".$node;
 175                 if(is_file($node)) {
 176                    //echo " - is file<br>";
 177                    unlink($node);
 178                 }
 179                 else if(is_dir($node)) {
 180                    //echo " -    is Dir<br>";
 181                    rm_all_dir($node);
 182                 }
 183              }
 184           }
 185           $d->close();
 186  
 187           rmdir($dir);
 188        }
 189        //echo "RM: $dir <br>";
 190     }
 191  
 192     function delete_file($file) 
 193     {
 194        global $BASE_DIR,$IMG_ROOT;
 195  
 196        $del_image = dir_name($BASE_DIR).$IMG_ROOT.$file;
 197        $del_thumb = dir_name($BASE_DIR).$IMG_ROOT.$file;
 198  
 199        if(is_file($del_image)) 
 200        {
 201           unlink($del_image);    
 202        }
 203  
 204        if(is_file($del_thumb)) 
 205        {
 206           unlink($del_thumb);    
 207        }
 208     }
 209  
 210     function create_folder() 
 211     {
 212        global $BASE_DIR, $IMG_ROOT, $refresh_dirs;
 213  
 214        $folder_name = $_GET['foldername'];
 215  
 216        if(strlen($folder_name) >0) 
 217        {
 218           $folder = $BASE_DIR.$IMG_ROOT.$folder_name;
 219  
 220           if(!is_dir($folder) && !is_file($folder))
 221           {
 222              mkdir($folder,0777);    
 223              chmod($folder,0777);
 224              $refresh_dirs = true;
 225           }
 226        }
 227     }
 228  
 229     function num_files($dir) 
 230     {
 231        $total = 0;
 232  
 233        if(is_dir($dir)) 
 234        {
 235           $d = @dir($dir);
 236  
 237           while (false !== ($entry = $d->read())) 
 238           {
 239              //echo $entry."<br>";
 240              if(substr($entry,0,1) != '.') {
 241                 $total++;
 242              }
 243           }
 244           $d->close();
 245        }
 246        return $total;
 247     }
 248  
 249     function dirs($dir,$abs_path) 
 250     {
 251        $d = dir($dir);
 252        //echo "Handle: ".$d->handle."<br>\n";
 253        //echo "Path: ".$d->path."<br>\n";
 254        $dirs = array();
 255        while (false !== ($entry = $d->read())) {
 256           if(is_dir($dir.'/'.$entry) && substr($entry,0,1) != '.') 
 257           {
 258              //dirs($dir.'/'.$entry, $prefix.$prefix);
 259              //echo $prefix.$entry."<br>\n";
 260              $path['path'] = $dir.'/'.$entry;
 261              $path['name'] = $entry;
 262              $dirs[$entry] = $path;
 263           }
 264        }
 265        $d->close();
 266  
 267        ksort($dirs);
 268        for($i=0; $i<count($dirs); $i++) 
 269        {
 270           $name = key($dirs);
 271           $current_dir = $abs_path.'/'.$dirs[$name]['name'];
 272           echo ", \"$current_dir\"\n";
 273           dirs($dirs[$name]['path'],$current_dir);
 274           next($dirs);
 275        }
 276     }
 277  
 278     function parse_size($size) 
 279     {
 280        if($size < 1024) 
 281        return $size.' btyes';    
 282        else if($size >= 1024 && $size < 1024*1024) 
 283        {
 284           return sprintf('%01.2f',$size/1024.0).' Kb';    
 285        }
 286        else
 287        {
 288           return sprintf('%01.2f',$size/(1024.0*1024)).' Mb';    
 289        }
 290     }
 291  
 292     function show_image($img, $file, $info, $size) 
 293     {
 294        global $BASE_DIR, $BASE_URL, $newPath;
 295  
 296        $img_path = dir_name($img);
 297        $img_file = basename($img);
 298  
 299        $thumb_image = 'thumbs.php?img='.urlencode($img);
 300  
 301        $img_url = $BASE_URL.$img_path.'/'.$img_file;
 302  
 303        $filesize = parse_size($size);
 304  
 305     ?>
 306     <td>
 307        <table width="102" border="0" cellpadding="0" cellspacing="2">
 308           <tr> 
 309              <td align="center" class="imgBorder" onMouseOver="pviiClassNew(this,'imgBorderHover')" onMouseOut="pviiClassNew(this,'imgBorder')">
 310                 <a href="javascript:;" onClick="javascript:imageSelected('<? echo $img_url; ?>', <? echo $info[0];?>, <? echo $info[1]; ?>,'<? echo $file; ?>');"><img src="<? echo $thumb_image; ?>" alt="<? echo $file; ?> - <? echo $filesize; ?>" border="0"></a></td>
 311           </tr>
 312           <tr> 
 313              <td><table width="100%" border="0" cellspacing="0" cellpadding="2">
 314                    <tr> 
 315                       <td width="1%" class="buttonOut" onMouseOver="pviiClassNew(this,'buttonHover')" onMouseOut="pviiClassNew(this,'buttonOut')">
 316                          <a href="javascript:;" onClick="javascript:preview('<? echo $img_url; ?>', '<? echo $file; ?>', ' <? echo $filesize; ?>',<? echo $info[0].','.$info[1]; ?>);"><img src="edit_pencil.gif" width="15" height="15" border="0"></a></td>
 317                       <td width="1%" class="buttonOut" onMouseOver="pviiClassNew(this,'buttonHover')" onMouseOut="pviiClassNew(this,'buttonOut')">
 318                          <a href="images.php?delFile=<? echo $file; ?>&dir=<? echo $newPath; ?>" onClick="return deleteImage('<? echo $file; ?>');"><img src="edit_trash.gif" width="15" height="15" border="0"></a></td>
 319                       <td width="98%" class="imgCaption"><? echo $info[0].'x'.$info[1]; ?></td>
 320                    </tr>
 321              </table></td>
 322           </tr>
 323        </table>
 324     </td>
 325     <?php
 326  }
 327  
 328  function show_dir($path, $dir) 
 329  {
 330     global $newPath, $BASE_DIR, $BASE_URL;
 331  
 332     $num_files = num_files($BASE_DIR.$path);
 333  ?>
 334  <td>
 335     <table width="102" border="0" cellpadding="0" cellspacing="2">
 336        <tr> 
 337           <td align="center" class="imgBorder" onMouseOver="pviiClassNew(this,'imgBorderHover')" onMouseOut="pviiClassNew(this,'imgBorder')">
 338              <a href="images.php?dir=<? echo $path; ?>" onClick="changeLoadingStatus('load')">
 339                 <img src="folder.gif" width="80" height="80" border=0 alt="<? echo $dir; ?>">
 340              </a>
 341           </td>
 342        </tr>
 343        <tr> 
 344           <td><table width="100%" border="0" cellspacing="1" cellpadding="2">
 345                 <tr> 
 346                    <td width="1%" class="buttonOut" onMouseOver="pviiClassNew(this,'buttonHover')" onMouseOut="pviiClassNew(this,'buttonOut')">
 347                       <a href="images.php?delFolder=<? echo $BASE_URL.$path; ?>&dir=<? echo $newPath; ?>" onClick="return deleteFolder('<? echo $dir; ?>', <? echo $num_files; ?>);"><img src="edit_trash.gif" width="15" height="15" border="0"></a></td>
 348                    <td width="99%" class="imgCaption"><? echo $dir; ?></td>
 349                 </tr>
 350           </table></td>
 351        </tr>
 352     </table>
 353  </td>
 354  <?    
 355  }
 356  
 357  function draw_no_results() 
 358  {
 359  ?>
 360  <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
 361     <tr>
 362        <td><div align="center" style="font-size:large;font-weight:bold;color:#CCCCCC;font-family: Helvetica, sans-serif;">No Images Found</div></td>
 363     </tr>
 364  </table>
 365  <?    
 366  }
 367  
 368  function draw_no_dir() 
 369  {
 370     global $BASE_DIR;
 371  ?>
 372  <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
 373     <tr>
 374        <td><div align="center" style="font-size:small;font-weight:bold;color:#CC0000;font-family: Helvetica, sans-serif;">Configuration Problem: &quot;<? echo $BASE_DIR; ?>&quot; does not exist.</div></td>
 375     </tr>
 376  </table>
 377  <?    
 378  }
 379  
 380  
 381  function draw_table_header() 
 382  {
 383     echo '<table border="0" cellpadding="0" cellspacing="2">';
 384        echo '<tr>';
 385        }
 386  
 387  	  function draw_table_footer() 
 388        {
 389           echo '</tr>';
 390        echo '</table>';
 391  }
 392  
 393  ?>
 394  <html>
 395     <head>
 396        <title>Image Browser</title>
 397        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
 398        <style type="text/css">
 399           <!--
 400           .imgBorder {
 401                 height: 96px;
 402                 border: 1px solid threedface;
 403                 vertical-align: middle;
 404           }
 405           .imgBorderHover {
 406                 height: 96px;
 407                 border: 1px solid threedface;
 408                 vertical-align: middle;
 409                 background: #FFFFCC;
 410                 cursor: hand;
 411           }
 412  
 413           .buttonHover {
 414                 border: 1px solid;
 415                 border-color: ButtonHighlight ButtonShadow ButtonShadow ButtonHighlight;
 416                 cursor: hand;
 417                 background: #FFFFCC;
 418           }
 419           .buttonOut
 420           {
 421                 border: 1px solid;
 422                 border-color: white;
 423           }
 424  
 425           .imgCaption {
 426                 font-size: 9pt;
 427                 font-family: "MS Shell Dlg", Helvetica, sans-serif;
 428                 text-align: center;
 429           }
 430           .dirField {
 431                 font-size: 9pt;
 432                 font-family: "MS Shell Dlg", Helvetica, sans-serif;
 433                 width:110px;
 434           }
 435  
 436           -->
 437        </style>
 438        <?php
 439  //          $dirPath = eregi_replace($BASE_ROOT,'',$IMG_ROOT);
 440           $dirPath=$IMG_ROOT;
 441  
 442           $paths = explode('/', $dirPath);
 443           $upDirPath = '/';
 444           for($i=0; $i<count($paths)-2; $i++) 
 445           {
 446              $path = $paths[$i];
 447              if(strlen($path) > 0) 
 448              {
 449                 $upDirPath .= $path.'/';
 450              }
 451           }
 452  
 453           $slashIndex = strlen($dirPath);
 454           $newPath = $dirPath;
 455           if($slashIndex > 1 && substr($dirPath, $slashIndex-1, $slashIndex) == '/')
 456           {
 457              $newPath = substr($dirPath, 0,$slashIndex-1);
 458           }
 459        ?>
 460        <script type="text/javascript" src="../popup.js"></script>
 461        <script type="text/javascript" src="../../../../dialog.js"></script>
 462        <script language="JavaScript" type="text/JavaScript">
 463           <!--
 464  		 function pviiClassNew(obj, new_style) { //v2.6 by PVII
 465              obj.className=new_style;
 466        }
 467  
 468  	  function goUp() 
 469        {
 470              location.href = "ImageManager/images.php?dir=<? echo $upDirPath; ?>";
 471        }
 472  
 473  	  function changeDir(newDir) 
 474        {
 475              location.href = "ImageManager/images.php?dir="+newDir;
 476        }
 477  
 478  	  function newFolder(oldDir, newFolder) 
 479        {
 480              location.href = "ImageManager/images.php?dir="+oldDir+'&create=folder&foldername='+newFolder;
 481        }
 482  
 483  	  function updateDir() 
 484        {
 485              var newPath = "<?php echo $newPath; ?>";
 486  //            alert('<?php echo $newPath; ?>');
 487              if(window.top.document.forms[0] != null) {
 488  
 489                    var allPaths = window.top.document.forms[0].dirPath.options;
 490                    //alert("new:"+newPath);
 491                    for(i=0; i<allPaths.length; i++) 
 492                    {
 493                          //alert(allPaths.item(i).value);
 494                          allPaths.item(i).selected = false;
 495                          if((allPaths.item(i).value)==newPath) 
 496                          {
 497                                allPaths.item(i).selected = true;
 498                          }
 499                    }
 500  
 501                    <?
 502                    if($clearUploads) {
 503                    ?>
 504                    var topDoc = window.top.document.forms[0];
 505                    topDoc.upload.value = null;
 506                    //topDoc.upload.disabled = true;
 507                    <?
 508                 }
 509              ?>
 510  
 511        }
 512  
 513  }
 514  
 515  <? if ($refresh_dirs) { ?>
 516  function refreshDirs() 
 517  {
 518     var allPaths = window.top.document.forms[0].dirPath.options;
 519     var fields = ["/" <? dirs($BASE_DIR,'');?>];
 520  
 521     var newPath = "<? echo $newPath; ?>";
 522  
 523     while(allPaths.length > 0) 
 524     {
 525           for(i=0; i<allPaths.length; i++) 
 526           {
 527                 allPaths.remove(i);    
 528           }        
 529     }
 530  
 531     for(i=0; i<fields.length; i++) 
 532     {
 533           var newElem =    document.createElement("OPTION");
 534           var newValue = fields[i];
 535           newElem.text = newValue;
 536           newElem.value = newValue;
 537  
 538           if(newValue == newPath) 
 539           newElem.selected = true;    
 540           else
 541           newElem.selected = false;
 542  
 543           allPaths.add(newElem);
 544     }
 545                                      }
 546                                      refreshDirs();
 547                                      <? } ?>
 548  
 549  									function imageSelected(filename, width, height, alt) 
 550                                      {
 551                                            var topDoc = window.top.document.forms[0];
 552                                            topDoc.f_url.value = filename;
 553                                            topDoc.f_width.value= width;
 554                                            topDoc.f_height.value = height;
 555                                            topDoc.f_alt.value = alt;
 556                                            topDoc.orginal_width.value = width;
 557                                            topDoc.orginal_height.value = height;
 558  
 559                                      }
 560  
 561  									function preview(file, image, size, width, height) 
 562                                      {
 563                                         
 564                                         
 565                                         alert('Not implemented yet,sorry');
 566                                      return;    
 567                                         
 568                                         
 569                                         /*
 570                                            var predoc = '<img src="'+file+'" alt="'+image+' ('+width+'x'+height+', '+size+')">';
 571                                            var w = 450;
 572                                            var h = 400;
 573                                            var LeftPosition=(screen.width)?(screen.width-w)/2:100;
 574                                            var TopPosition=(screen.height)?(screen.height-h)/2:100;
 575  
 576                                            var win = window.open('','image_preview','toolbar=no,location=no,menubar=no,status=yes,scrollbars=yes,resizable=yes,width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition);
 577                                            var doc=win.document.open();
 578  
 579                                            doc.writeln('<html>\n<head>\n<title>Image Preview - '+image+' ('+width+'x'+height+', '+size+')</title>');
 580                                                  doc.writeln('</head>\n<body>');
 581                                                  doc.writeln(predoc);
 582                                                  doc.writeln('</body>\n</html>\n');
 583                                            doc=win.document.close();
 584                                            win.focus();*/
 585                                            //alert(file);
 586                                            Dialog("../ImageEditor/ImageEditor.php?img="+escape(file), function(param) {
 587                                                  if (!param) {    // user must have pressed Cancel
 588                                                     return false;
 589                                               }
 590                                         }, null);
 591                                         return;
 592                                   }
 593  
 594  								 function deleteImage(file) 
 595                                   {
 596                                         if(confirm("Delete image \""+file+"\"?")) 
 597                                         return true;
 598  
 599                                         return false;
 600                                   }
 601  
 602  								 function deleteFolder(folder, numFiles) 
 603                                   {
 604                                         if(numFiles > 0) {
 605                                               alert("There are "+numFiles+" files/folders in \""+folder+"\".\n\nPlease delete all files/folder in \""+folder+"\" first.");
 606                                               return false;
 607                                         }
 608  
 609                                         if(confirm("Delete folder \""+folder+"\"?")) 
 610                                         return true;
 611  
 612                                         return false;
 613                                   }
 614  
 615  								 function MM_findObj(n, d) { //v4.01
 616                                      var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
 617                                            d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
 618                                         if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
 619                                         for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
 620                                         if(!x && d.getElementById) x=d.getElementById(n); return x;
 621                                   }
 622  
 623  								 function MM_showHideLayers() { //v6.0
 624                                      var i,p,v,obj,args=MM_showHideLayers.arguments;
 625                                      for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i],window.top.document))!=null) { v=args[i+2];
 626                                         if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
 627                                         obj.visibility=v; }
 628                                }
 629  
 630  							  function changeLoadingStatus(state) 
 631                                {
 632                                      var statusText = null;
 633                                      if(state == 'load') {
 634                                            statusText = 'Loading Images';    
 635                                      }
 636                                      else if(state == 'upload') {
 637                                            statusText = 'Uploading Files';
 638                                      }
 639                                      if(statusText != null) {
 640                                            var obj = MM_findObj('loadingStatus', window.top.document);
 641                                            //alert(obj.innerHTML);
 642                                            if (obj != null && obj.innerHTML != null)
 643                                            obj.innerHTML = statusText;
 644                                            MM_showHideLayers('loading','','show')        
 645                                      }
 646                                }
 647  
 648                                //-->
 649                             </script>
 650                          </head>
 651                          <body onLoad="updateDir();" bgcolor="#FFFFFF">
 652  
 653                             <?
 654                             //var_dump($_GET);
 655                             //echo $dirParam.':'.$upDirPath;
 656                             //echo '<br>';
 657                             $d = @dir($BASE_DIR.$IMG_ROOT);
 658  
 659                             if($d) 
 660                             {
 661                                //var_dump($d);
 662                                $images = array();
 663                                $folders = array();
 664                                while (false !== ($entry = $d->read())) 
 665                                {
 666                                   $img_file = $IMG_ROOT.$entry; 
 667  
 668                                   if(is_file($BASE_DIR.$img_file) && substr($entry,0,1) != '.') 
 669                                   {
 670                                      $image_info = @getimagesize($BASE_DIR.$img_file);
 671                                      if(is_array($image_info)) 
 672                                      {
 673                                         $file_details['file'] = $img_file;
 674                                         $file_details['img_info'] = $image_info;
 675                                         $file_details['size'] = filesize($BASE_DIR.$img_file);
 676                                         $images[$entry] = $file_details;
 677                                         //show_image($img_file, $entry, $image_info);
 678                                      }
 679                                   }
 680                                   else if(is_dir($BASE_DIR.$img_file) && substr($entry,0,1) != '.') 
 681                                   {
 682                                      $folders[$entry] = $img_file;
 683                                      //show_dir($img_file, $entry);    
 684                                   }
 685                                }
 686                                $d->close();    
 687  
 688                                if(count($images) > 0 || count($folders) > 0) 
 689                                {    
 690                                   //now sort the folders and images by name.
 691                                   ksort($images);
 692                                   ksort($folders);
 693  
 694                                   draw_table_header();
 695  
 696                                   for($i=0; $i<count($folders); $i++) 
 697                                   {
 698                                      $folder_name = key($folders);        
 699                                      show_dir($folders[$folder_name], $folder_name);
 700                                      next($folders);
 701                                   }
 702                                   for($i=0; $i<count($images); $i++) 
 703                                   {
 704                                      $image_name = key($images);
 705                                      show_image($images[$image_name]['file'], $image_name, $images[$image_name]['img_info'], $images[$image_name]['size']);
 706                                      next($images);
 707                                   }
 708                                   draw_table_footer();
 709                                }
 710                                else
 711                                {
 712                                   draw_no_results();
 713                                }
 714                             }
 715                             else
 716                             {
 717                                draw_no_dir();
 718                             }
 719  
 720                          ?>
 721                          <script language="JavaScript" type="text/JavaScript">
 722                             MM_showHideLayers('loading','','hide')
 723                          </script>
 724                       </body>
 725                    </html>


Généré le : Sun Feb 25 17:20:01 2007 par Balluche grâce à PHPXref 0.7