Pomoc - Szukaj - U¿ytkownicy - Kalendarz
Pe³na wersja: Nie laduje zdiec.. z podanej lokalizacji..
Forum PHP.pl > Forum > Gotowe rozwi±zania
slavo
  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 directory
  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 page go
  26. // captionext : filename extension placed on caption file with same name
  27. // as image. (ie - <image>.<ext>.<captionext>)
  28. // example: image file sunrise.jpg would use the caption
  29. // file sunrise.jpg.txt with the default captionext
  30. // caption : default caption to place under files if no caption file
  31. //  exists
  32. // stylesheet : enter the path to your stylesheet here
  33. // you may enter just '' to use the default(will embed it in the html)
  34. // you may also enter 'none' to have no style sheet
  35. //  the stylesheet should have these classes:
  36. //
  37. //  .imag { border-style : solid;
  38. //  border-color: blue;
  39. //  border-width : 1px;}
  40. //  .thumb { border-style : solid;
  41. // border-color: #999999;
  42. // border-width : 2px;}
  43. // A:link { color: #999999;
  44. //  text-decoration : none; }
  45. // A:visited { color: #999999;
  46. // text-decoration : none; }
  47. // A:hover { color:blue; }
  48. // any of these classses can be adjusted to your needs
  49. //
  50. //
  51. // USAGE:
  52. // to browse through the images use the back and forward images
  53. // click on one of the thumbnails
  54. // or use one of the pagelinks to go directly to another set of images
  55. // clicking on the large image will give you the full image
  56. /////////////////////////////////////////////////////////////////////////////////////////////////////////
  57.  
  58.  
  59. //---Variables---
  60.  
  61. $scale = 1;
  62. $maxwidth  = 320;
  63. $maxheight = 240;
  64. $thumbmaxw = 50;
  65. $thumbmaxh = 50;
  66. $imgperpage = 10;
  67. $imgperrow = 5;
  68. $pgperrow  = 10;
  69. $currentdir = getcwd();
  70. $typelist  = array(&#092;"jpg\",\"jpeg\",\"gif\",\"png\",\"JPG\");
  71. $imagelist = array();
  72. $stylesheet = &#092;"slavo.css\";
  73. $home  = &#092;"{$_SERVER['PHP_SELF']}\";
  74. $this_page = &#092;"{$_SERVER['PHP_SELF']}\";
  75. $caption = &#092;"\";
  76. $captionext = &#092;"txt\";
  77.  
  78. //--- ind is put to zero when the script is first called uppon---
  79.  
  80. if(!isset($_GET['ind'])) 
  81. $_GET['ind'] = 0;
  82. $index = $_GET['ind'];
  83.  
  84. //---the following code iterates through the directory and puts any image found in th
  85.  imagelist array---
  86.  
  87. $dp=opendir($currentdir);
  88. while ( false != ( $file=readdir($dp) ) ) {
  89. if (is_file($file) && $file!=&#092;".\" && $file!=\"..\"){
  90.  
  91. $extention = explode(&#092;".\",$file);
  92. $extfield = count($extention)-1;
  93. $extention = $extention[$extfield];
  94.  
  95. if( in_array($extention,$typelist) ){
  96. array_push ($imagelist,$file);
  97. }
  98. }
  99. }
  100. ?>
  101.  
  102. <table align=\"center\" border=\"0\">
  103.  <tr>
  104. <td>
  105. <?  if($index-1 >= 0) {?>
  106.  <a href='<?= $this_page ?>?ind=<?= $index-1 ?>'>[ prev ]</a>
  107. <?  } ?>
  108. </td>
  109. <td>
  110. <?
  111.  
  112. //--- This is where the large pictures are resized so that they maintain ratio---
  113.  
  114. $sizeee = getimagesize (&#092;"$imagelist[$index]\");
  115. $imgwidth = $sizeee[0];
  116. $imgheight = $sizeee[1];
  117.  
  118. if ($scale == 1 || $imgwidth > $maxwidth || $imgheight > $maxheight) {  // decide if img needs to be scaled
  119. $newwidth = $imgwidth/($imgheight/$maxheight);
  120. $newheight = $imgheight/($imgwidth/$maxwidth);
  121. if ($imgwidth < $imgheight) {
  122.  
  123.  
  124.  
  125.  
  126. if ($newwidth > $maxwidth)
  127.  
  128. {
  129.  
  130. ?>
  131. <a href=\"<?= $imagelist[$index] ?>\" target=\"_blank\">
  132. <img src=\"<?= $imagelist[$index] ?>\" width=\"<?= $maxwidth ?>\" height=\"<?= $newheight ?>\" alt=\"\" />
  133. </a>
  134. <?
  135. } else {
  136.  
  137. ?>
  138. <a href=\"<?= $imagelist[$index] ?>\" target=\"_blank\">
  139. <img src=\"<?= $imagelist[$index] ?>\" width=\"<?= $newwidth ?>\" height=\"<?= $maxheight ?>\" alt=\"\" />
  140. </a>
  141. <?
  142.  }
  143. } else { 
  144.  
  145.  
  146. if ($newhight > $maxheight)
  147.  
  148. {
  149.  
  150. ?>
  151. <a href=\"<?= $imagelist[$index] ?>\" target=\"_blank\">
  152. <img src=\"<?= $imagelist[$index] ?>\" width=\"<?= $newwidth ?>\" height=\"<?= $maxheight ?>\" alt=\"\" />
  153. </a>
  154. <?
  155. } else {
  156.  
  157.  
  158. ?>
  159.  
  160. <a href=\"<?= $imagelist[$index] ?>\" target=\"_blank\">
  161. <img src=\"<?= $imagelist[$index] ?>\" width=\"<?= $maxwidth ?>\" height=\"<?= $newheight ?>\" alt=\"\" />
  162. </a>
  163.  
  164. <?
  165.  
  166.  
  167.  
  168. }
  169. }
  170. } else { ?>
  171. <a href=\"<?= $imagelist[$index] ?>\" target=\"_blank\">
  172. <img src=\"<?= $imagelist[$index] ?>\" width=\"<?= $imgwidth ?>\" height=\"<?= $imgheight ?>\" alt=\"\" />
  173. </a>
  174. <? }
  175. ?>
  176. </td>
  177. <td>
  178. <?  if($index+< count($imagelist) ) {?>
  179.  <a href=\"<?= $this_page ?>?ind=<?= $index+1 ?>\">[ next ]</a>
  180. <?  } ?>
  181. </td>
  182.  </tr>
  183.  <tr>
  184. <td>
  185. </td>
  186. <td>
  187.  <center><?
  188.  if (file_exists ($imagelist[$index]. &#092;".\" . $captionext) &&
  189.  is_file ($imagelist[$index]. &#092;".\" . $captionext) &&
  190.  !is_dir ($imagelist[$index]. &#092;".\" . $captionext)) 
  191.  include $imagelist[$index]. &#092;".\" . $captionext;
  192.  else
  193.  echo $caption; ?>
  194.  </center>
  195. </td>
  196. <td>
  197. </td>
  198.  </tr>
  199. </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..
invx
podaj tresc bledu.
slavo
Blad to: DIvision By zero.. tam w dalaszej czesci..
To jest wersja lo-fi g³ównej zawarto¶ci. Aby zobaczyæ pe³n± wersjê z wiêksz± zawarto¶ci±, obrazkami i formatowaniem proszê kliknij tutaj.
Invision Power Board © 2001-2024 Invision Power Services, Inc.