1. <?
  2. ////////////////////////////////////////////////////////////////////////////////////////////////////////
  3. //
  4. // Configuration Variables
  5. // ======================
  6. //
  7. //    scale      : weather or not to scale the large img to the max height/width if it
  8. //                 does not exceed the max height/width limits
  9. //                 0=don't scale    1=scale
  10. //    maxwidth   : the maximum allowed width of the large picture
  11. //    maxheight  : the maximum allowed height of the large picture
  12. //    thumbmaxw  : the maximum allowed width of the thumbnail
  13. //    thumbmaxh  : the maximum allowed height of the thumbnail
  14. //    imgperpage : the number of thumbnail images displayed
  15. //                 its best to give this a value that is a multiple of imgperrow
  16. //    imgperrow  : the number of thumbnail images per row
  17. //    pgperrow   : the number of page links per row
  18. //    typelist   : array that contains the imagetypes shown by the browser
  19. //    currentdir : default the directory where this php file resides,
  20. //                 can be replaced by any directory of your choice
  21. //    title      : enter the title of your page here
  22. //    home       : enter path to your home directory or any other desired director
    y
  23. //                    (where the home link goes to)
  24. //      this_page     : the name of this file, $_SERVER['PHP_SELF'] should work, but if it dosen't
  25. //                    just use the file name; this is where all the links to this 
  26. age go
  27. //    captionext : filename extension placed on caption file with same name
  28. //                    as image. (ie - <image>.<ext>.<captionext>)
  29. //                    example: image file sunrise.jpg would use the caption
  30. //                    file sunrise.jpg.txt with the default captionext
  31. //    caption    : default caption to place under files if no caption file
  32. //                 exists
  33. //    stylesheet : enter the path to your stylesheet here
  34. //                    you may enter just '' to use the default(will embed it in the html)
  35. //                    you may also enter 'none' to have no style sheet
  36. //                 the stylesheet should have these classes:
  37. //
  38. //                 .imag { border-style : solid;
  39. //                         border-color: blue;
  40. //                         border-width : 1px;}
  41. //                 .thumb { border-style : solid;
  42. //                          border-color: #999999;
  43. //                          border-width : 2px;}
  44. //                  A:link { color: #999999;
  45. //                           text-decoration : none; }
  46. //                  A:visited { color: #999999;
  47. //                              text-decoration : none; }
  48. //                  A:hover { color:blue; }
  49. //                  any of these classses can be adjusted to your needs
  50. //
  51. //
  52. // USAGE:
  53. // to browse through the images use the back and forward images
  54. // click on one of the thumbnails
  55. // or use one of the pagelinks to go directly to another set of images
  56. // clicking on the large image will give you the full image
  57. /////////////////////////////////////////////////////////////////////////////////////////////////////////
  58.  
  59.  
  60. //---Variables---
  61.  
  62. $scale      = 1;
  63. $maxwidth   = 320;
  64. $maxheight  = 240;
  65. $thumbmaxw  = 50;
  66. $thumbmaxh  = 50;
  67. $imgperpage = 10;
  68. $imgperrow  = 5;
  69. $pgperrow   = 10;
  70. $currentdir = getcwd();
  71. $typelist   = array(&#092;"jpg\",\"jpeg\",\"gif\",\"png\",\"JPG\");
  72. $imagelist  = array();
  73. $stylesheet = &#092;"slavo.css\";
  74. $home       = &#092;"{$_SERVER['PHP_SELF']}\";
  75. $this_page  = &#092;"{$_SERVER['PHP_SELF']}\";
  76. $caption    = &#092;"\";
  77. $captionext = &#092;"txt\";
  78.  
  79. //--- ind is put to zero when the script is first called uppon---
  80.  
  81. if(!isset($_GET['ind'])) 
  82.     $_GET['ind'] = 0;
  83. $index = $_GET['ind'];
  84.  
  85. //---the following code iterates through the directory and puts any image found in th
  86.  imagelist array---
  87.  
  88. $dp=opendir($currentdir);
  89. while ( false != ( $file=readdir($dp) ) ) {
  90.         if (is_file($file) && $file!=&#092;".\" && $file!=\"..\"){
  91.  
  92.             $extention = explode(&#092;".\",$file);
  93.             $extfield = count($extention)-1;
  94.             $extention = $extention[$extfield];
  95.  
  96.             if( in_array($extention,$typelist) ){
  97.                 array_push ($imagelist,$file);
  98.             }
  99.         }
  100. }
  101. ?>
  102.  
  103. <table align=\"center\" border=\"0\">
  104.  <tr>
  105.   <td>
  106. <?       if($index-1 >= 0) {?>
  107.    <a href='<?= $this_page ?>?ind=<?= $index-1 ?>'>[ prev ]</a>
  108. <?       } ?>
  109.   </td>
  110.   <td>
  111.       <?
  112.  
  113. //--- This is where the large pictures are resized so that they maintain ratio---
  114.  
  115.         $sizeee = getimagesize (&#092;"$imagelist[$index]\");
  116.         $imgwidth = $sizeee[0];
  117.         $imgheight = $sizeee[1];
  118.         
  119. if ($scale == 1 || $imgwidth > $maxwidth || $imgheight > $maxheight) {   // decide if img needs to be scaled    
  120.         $newwidth = $imgwidth/($imgheight/$maxheight);
  121.         $newheight = $imgheight/($imgwidth/$maxwidth);
  122.         if ($imgwidth < $imgheight) {
  123.         
  124.             
  125.             
  126.             
  127.             if ($newwidth > $maxwidth)
  128.             
  129.                 {
  130.                 
  131.                 ?>
  132.                 <a href=\"<?= $imagelist[$index] ?>\" target=\"_blank\">
  133.                     <img src=\"<?= $imagelist[$index] ?>\" width=\"<?= $maxwidth ?>\" height=\"<?= $newheight ?>\" alt=\"\" />
  134.                 </a>
  135.                 <?
  136.                 } else {
  137.                 
  138.                 ?>
  139.                 <a href=\"<?= $imagelist[$index] ?>\" target=\"_blank\">
  140.                     <img src=\"<?= $imagelist[$index] ?>\" width=\"<?= $newwidth ?>\" height=\"<?= $maxheight ?>\" alt=\"\" />
  141.                 </a>
  142.                 <?
  143.                  }
  144.             } else { 
  145.         
  146.             
  147.             if ($newhight > $maxheight)
  148.                 
  149.                 {
  150.                 
  151.                 ?>
  152.                 <a href=\"<?= $imagelist[$index] ?>\" target=\"_blank\">
  153.                     <img src=\"<?= $imagelist[$index] ?>\" width=\"<?= $newwidth ?>\" height=\"<?= $maxheight ?>\" alt=\"\" />
  154.                 </a>
  155.                 <?
  156.                 } else {
  157.                 
  158.                 
  159.                 ?>
  160.                 
  161.                 <a href=\"<?= $imagelist[$index] ?>\" target=\"_blank\">
  162.                     <img src=\"<?= $imagelist[$index] ?>\" width=\"<?= $maxwidth ?>\" height=\"<?= $newheight ?>\" alt=\"\" />
  163.                 </a>
  164.                 
  165.                 <?
  166.         
  167.     
  168.        
  169.         }
  170.         }
  171.                 } else { ?>
  172.     <a href=\"<?= $imagelist[$index] ?>\" target=\"_blank\">
  173.         <img src=\"<?= $imagelist[$index] ?>\" width=\"<?= $imgwidth  ?>\" height=\"<?= $imgheight ?>\" alt=\"\" />
  174.     </a>
  175.     <?    }
  176.       ?>
  177.   </td>
  178.   <td>
  179. <?       if($index+< count($imagelist) ) {?>
  180.    <a href=\"<?= $this_page ?>?ind=<?= $index+1 ?>\">[ next ]</a>
  181. <?       } ?>
  182.   </td>
  183.  </tr>
  184.  <tr>
  185.   <td>
  186.   </td>
  187.   <td>
  188.    <center><?
  189.          if (file_exists ($imagelist[$index]. &#092;".\" . $captionext) &&
  190.              is_file ($imagelist[$index]. &#092;".\" . $captionext) &&
  191.              !is_dir ($imagelist[$index]. &#092;".\" . $captionext)) 
  192.            include $imagelist[$index]. &#092;".\" . $captionext;
  193.          else
  194.            echo $caption; ?>
  195.    </center>
  196.   </td>
  197.   <td>
  198.   </td>
  199.  </tr>
  200. </table>


Znalazlem taki oto gotowy skrypcik.. jest spoko.. problem w tym ze dziala poprawnie tylko wowczas kiedy pliki graficzne umieszczone sa w tym samym katalogu co on.. ja natomiast includuje go sobie na stronie z innego katalogu i chcialem zeby czytal zdiecia z katalogu podanego w $currentdir. Jednak tak sie nie dzieje.. zglasza tylko blad, ktory znika w momencie kiedy wgra sie pliki do katalogu ze skryptem..



NA PRAWDE NIKT NIE MA ZADNEJ KONCEPCJI? ;/