mam galerie zdjęć, ale brakuje w niej porządku tzn wyświetlania zdjęć np tak jak są ponumerowane 1, 2, 3...

o to kod

  1. <?
  2. $folder = zdjecia;
  3. $scale = 0;
  4. $maxwidth = 440;
  5. $maxheight = 500;
  6. $thumbmaxw = 50;
  7. $thumbmaxh = 50;
  8. $imgperpage = 5;
  9. $imgperrow = 5;
  10. $pgperrow = 10;
  11. $cursign = '';
  12. $currentdir = 'zdjecia';
  13. $typelist = array("jpg","jpeg","gif","png","JPG");
  14. $imagelist = array();
  15. $title = "Pics";
  16. $stylesheet = '' ;
  17. $home = "{$_SERVER['PHP_SELF']}";
  18. $this_page = "{$_SERVER['PHP_SELF']}";
  19. $caption = "";
  20. $captionext = "txt";
  21.  
  22. //--- ind is put to zero when the script is first called uppon---
  23.  
  24. if(!isset($_GET['ind']))
  25. $_GET['ind'] = 0;
  26. $index = $_GET['ind'];
  27.  
  28. //---the following code iterates through the directory and puts any image found in the imagelist array---
  29.  
  30. $dp=opendir($cursign.$currentdir);
  31. while ( false !== ( $file=readdir($dp) ) ) {
  32. if (is_file($cursign.$currentdir.DIRECTORY_SEPARATOR.$file) && $file!="." && $file!=".."){
  33.  
  34. $extention = explode(".",$file);
  35. $extfield = count($extention)-1;
  36. $extention = $extention[$extfield];
  37.  
  38. if( in_array($extention,$typelist) ){
  39. array_push ($imagelist,$currentdir.DIRECTORY_SEPARATOR.$file);
  40. }
  41. }
  42. }
  43. ?>
  44. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  45. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  46.  
  47.  
  48.  
  49.  
  50. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  51. <head>
  52.  
  53.  
  54. <title><?= $title ?></title>
  55. <?
  56. if ($stylesheet == ''){
  57. //--insert the default style sheet into html if none specified
  58. echo '<style type="text/css">'
  59. .'.imag { border-style : solid;'
  60. .'border-color: blue;'
  61. .'border-width : 1px;}'
  62. .'.thumb { border-style : solid;'
  63. .'border-color: #999999;'
  64. .'border-width : 2px;}'
  65. .'A:link { color: #999999;'
  66. .'text-decoration : none; }'
  67. .'A:visited { color: #999999;'
  68. .'text-decoration : none; }'
  69. .'A:hover { color:blue; }'
  70. .'</style>';
  71. } elseif ($stylesheet == 'none') {
  72. //--no style sheet if that is what you want
  73. } else {
  74. echo "<link rel=\"STYLESHEET\" href=\"$stylesheet\" />";
  75. }
  76. ?>
  77. </head>
  78. <body>
  79.  
  80. <table align="center" border="0">
  81. <tr>
  82. <td>
  83. <? if($index-1 >= 0) {?>
  84. <? } ?>
  85. </td>
  86. <td>
  87. <?
  88.  
  89. //--- This is where the large pictures are resized so that they maintain ratio---
  90.  
  91. $sizeee = getimagesize ("$imagelist[$index]");
  92. $imgwidth = $sizeee[0];
  93. $imgheight = $sizeee[1];
  94.  
  95. if ($scale == 1 || $imgwidth > $maxwidth || $imgheight > $maxheight) { // decide if img needs to be scaled
  96. $newwidth = $imgwidth/($imgheight/$maxheight);
  97. $newheight = $imgheight/($imgwidth/$maxwidth);
  98. if ($imgwidth < $imgheight) {
  99.  
  100.  
  101.  
  102.  
  103. if ($newwidth > $maxwidth)
  104.  
  105. {
  106.  
  107. ?>
  108. <a href="<?= $imagelist[$index] ?>" target="_blank">
  109. <img src="<?= $imagelist[$index] ?>" width="<?= $maxwidth ?>" height="<?= $newheight ?>" alt="" />
  110. </a>
  111. <?
  112. } else {
  113.  
  114. ?>
  115. <a href="<?= $imagelist[$index] ?>" target="_blank">
  116. <img src="<?= $imagelist[$index] ?>" width="<?= $newwidth ?>" height="<?= $maxheight ?>" alt="" />
  117. </a>
  118. <?
  119. }
  120. } else {
  121.  
  122.  
  123. if ($newhight > $maxheight)
  124.  
  125. {
  126.  
  127. ?>
  128. <a href="<?= $imagelist[$index] ?>" target="_blank">
  129. <img src="<?= $imagelist[$index] ?>" width="<?= $newwidth ?>" height="<?= $maxheight ?>" alt="" />
  130. </a>
  131. <?
  132. } else {
  133.  
  134.  
  135. ?>
  136.  
  137. <a href="<?= $imagelist[$index] ?>" target="_blank">
  138. <img src="<?= $imagelist[$index] ?>" width="<?= $maxwidth ?>" height="<?= $newheight ?>" alt="" />
  139. </a>
  140.  
  141. <?
  142.  
  143.  
  144.  
  145. }
  146. }
  147. } else { ?>
  148. <a href="<?= $imagelist[$index] ?>" target="_blank">
  149. <img src="<?= $imagelist[$index] ?>" width="<?= $imgwidth ?>" height="<?= $imgheight ?>" alt="" />
  150. </a>
  151. <? }
  152. ?>
  153. </td>
  154. <td>
  155. <? if($index+1 < count($imagelist) ) {?>
  156. <? } ?>
  157. </td>
  158. </tr>
  159. <tr>
  160. <td>
  161. </td>
  162. <td>
  163. <center><?
  164. if (file_exists ($imagelist[$index]. "." . $captionext) &&
  165. is_file ($imagelist[$index]. "." . $captionext) &&
  166. !is_dir ($imagelist[$index]. "." . $captionext))
  167. include $imagelist[$index]. "." . $captionext;
  168. else
  169. echo $caption; ?>
  170. </center>
  171. </td>
  172. <td>
  173. </td>
  174. </tr>
  175. </table>
  176.  
  177. <table align="center">
  178. <tr><td></td>
  179. <?
  180.  
  181. //---this code generates the thumbnails based on the configuration settings---
  182.  
  183. $nrpages = ceil( count($imagelist)/$imgperpage );
  184.  
  185. for($j=0;$j<$nrpages;$j++)
  186. {
  187. if( $index >= ($j*$imgperpage) && ($index < (($j+1) * $imgperpage)) ) {
  188. for($i=($j*$imgperpage);$i<(($j+1) * $imgperpage);$i++) {
  189. if(($i%$imgperrow == 0) && ($i > 0)) { ?>
  190. </tr>
  191. <tr>
  192. <? }
  193. if($i <count($imagelist) ) {
  194. $path = "$this_page?ind=".$i; ?>
  195. <td>
  196.  
  197. <?
  198.  
  199.  
  200.  
  201. //--- This is where the thumbnails are resized so that they maintain ratio---
  202.  
  203.  
  204. $sizeee = getimagesize ("$imagelist[$i]");
  205. $imgwidth = $sizeee[0];
  206. $imgheight = $sizeee[1];
  207.  
  208. $newthumbw = $imgwidth/($imgheight/$thumbmaxh);
  209. $newthumbh = $imgheight/($imgwidth/$thumbmaxw);
  210. if ($imgwidth < $imgheight) {
  211.  
  212.  
  213.  
  214.  
  215. if ($newthumbw > $thumbmaxw)
  216.  
  217. {
  218.  
  219. ?>
  220. <a href="<?= $path ?>">
  221. <img src="<?= $imagelist[$i] ?>" width="<?= $thumbmaxw ?>" height="<?= $newthumbh ?>" alt="" />
  222. </a>
  223. <?
  224. } else {
  225.  
  226.  
  227. ?>
  228. <a href="<?= $path ?>">
  229. <img src="<?= $imagelist[$i] ?>" width="<?= $newthumbw ?>" height="<?= $thumbmaxh ?>" alt="" />
  230. </a>
  231. <?
  232. }
  233. } else {
  234.  
  235.  
  236. if ($newthumbh > $thumbmaxh)
  237.  
  238. {
  239.  
  240. ?>
  241. <a href="<?= $path ?>">
  242. <img src="<?= $imagelist[$i] ?>" width="<?= $newthumbw ?>" height="<?= $thumbmaxh ?>" />
  243. </a>
  244. <?
  245. } else {
  246.  
  247.  
  248. ?>
  249.  
  250. <a href="<?= $path ?>">
  251. <img src="<?= $imagelist[$i] ?>" width="<?= $thumbmaxw ?>" height="<?= $newthumbh ?>" alt="" />
  252. </a>
  253.  
  254. <?
  255.  
  256.  
  257.  
  258. }
  259. }
  260. ?>
  261. </td>
  262. <? }
  263. }
  264. }
  265. }
  266. ?>
  267. </tr>
  268. </table>
  269. <? if($index-1 >= 0) {?>
  270. <a href='<?= $this_page ?>?ind=<?= $index-1 ?>'><img src="images/strzalka_lewo.gif" alt="Poprzednie" /></a>
  271. <? } ?>
  272. <a href="<?= $this_page ?>?ind=<?= $index+1 ?>"><img src="images/strzalka_prawo.gif" alt="Następne" /></a>
  273. <center>
  274. <?
  275. //---this code generates links based on the configuration settings---
  276. //---only puts $pgperrow page links per row to make cleaner---
  277. for($j=0;$j<$nrpages;$j++) {
  278. if(($j%$pgperrow == 0) && ($j > 0)) { ?>
  279. <? } ?>
  280. <a href="<?= $this_page ?>?ind=<?= ($j*$imgperpage) ?>">[ <strong> Strona <?= ($j+1) ?></strong> ]</a>
  281. <? } ?>
  282. </center>
  283. </body>
  284. </html>
  285. </body>
  286. </html>



za każdą odp daje +