login  Naam:   Wachtwoord: 
Registreer je!
 Forum

3 naar 1 samenvoegen

Offline lau - 15/01/2005 21:52
Avatar van lauHTML interesse Hallo,

Heb uiteindelijk een gallery gevonden die thumbs on the fly weergeeft. Maar ik heb een probleem met dit. De 3 bestanden: "index.php", "config.cfg.php" en "picture.php" kunnen slecht worden samengevoegd (of ik heb iets over het hoofd gekeken). Picture.php zorgt ervoor dat de thumbs on the fly wordt weergeven en zorgt ook dat de originele foto wordt weergegeven.
Nu wil ik het intereren in mijn site en dit aanroepen dmv http://site/fotos.php?pid=01 (waarbij 01 eerste album is, 02 is volgende album). Ik heb ?pic=01 gelinkt naar de map foto/zooi/index.php (index.php is bestand waarbij ik ze samen heb gevoegd, maar deze niet wil wrken).

Ik heb tot zover alles geprobeerd, maar de foto's willen alsmaar niet tonen.
Hieronder de 3 bestanden die zo (stand-alone zonder site) zijn. En helemaal daaronder wat ik heb gedaan om ze samen te voegen. Maar het wilt niet helemaal werken, wie kan mij helpen om te laten werken.

"config.cfg.php"
  1. <?
  2. // image directory
  3. $_images_dir_ = 'fotos/zooi/';
  4.  
  5. // pad van 1e album naar index.php van foto
  6. $_link = '?pid=01';
  7.  
  8. // minimale breedte van image
  9. $_width_min_ = 150 ;
  10. // verticaal space
  11. $_vspace_ = 10 ;
  12. // horizontaal space
  13. $_hspace_ = 10 ;
  14. // border van image
  15. $_border_ = 0;
  16.  
  17. // sorteren: SORT_ASC, SORT_DESC
  18. $_sort_ = SORT_ASC;
  19.  
  20. // breedte van image: 0 voor originele breedte
  21. $_width_max_ = 640 ;
  22.  
  23. // filename weergven: 1 = Ja, 0 = Nee
  24. $_filename_ = 0;
  25.  
  26. // aantal kolommen
  27. $_no_cols_ = 3;
  28.  
  29. // aantal images op een site: aantal kolommen x aantal rijen
  30. $_no_pics_per_page_ = 9;
  31. ?>


"index.php"
  1. <?
  2. // checken of config.cfg.php file bestaat
  3. if(is_file('config.cfg.php'))
  4. require 'config.cfg.php';
  5. else
  6. die('Error, no config file');
  7.  
  8. // checken of er een image directorie bestaat
  9. if(!is_dir($_images_dir_))
  10. die('Error, no image directory');
  11.  
  12. ?>
  13. <html>
  14. <head>
  15. <meta http-equiv="content-type" content="text/html; charset=ISO-8859-2">
  16. <title>fotos</title>
  17.  
  18. </head>
  19. <body>
  20.  
  21. <?
  22. $time_start = microtime(true);
  23.  
  24.  
  25. // weergave thumb (jpg of gif)
  26. $noimage = 0;
  27.  
  28. if ($dh = opendir($_images_dir_)) {
  29. while (($f = readdir($dh)) !== false) {
  30. if((substr(strtolower($f),-3) == 'jpg') || (substr(strtolower($f),-3) == 'jpg'))
  31. {
  32. $imageinfo = getimagesize($_images_dir_.$f);
  33. $width = $imageinfo[0];
  34. $height = $imageinfo[1];
  35. $size = round(filesize($_images_dir_.$f)/1024,1).' KB';
  36. $noimage++;
  37. $images[] = array('filename' => $f, 'width' => $width, 'height' => $height, 'size' => $size);
  38. array_multisort($images, $_sort_, SORT_REGULAR);
  39. }
  40. }
  41. closedir($dh);
  42. }
  43.  
  44.  
  45. if($noimage)
  46. {
  47.  
  48. if($_GET["img"] != '')
  49. {
  50. echo '<p class="title">'.$images[$_GET["img"]][filename].'</p>';
  51. if($images[$_GET["img"]][filename] != '')
  52. {
  53.  
  54. if($_GET["img"])
  55. $_no_ = ceil(($_GET["img"]+1)/$_no_pics_per_page_);
  56. else
  57. $_no_ = 1;
  58.  
  59. if($_GET["img"] == 0)
  60. $side = '<p class="link"><a href="'.$_SERVER["PHP_SELF"].'?no='.$_no_.'" class="link">up</a>&nbsp;<a href="'.$_SERVER["PHP_SELF"].'?img='.($_GET["img"]+1).'" class="link">next >></a></p>';
  61. elseif($_GET["img"] == ($noimage-1))
  62. $side = '<p class="link"><a href="'.$_SERVER["PHP_SELF"].'?img='.($_GET["img"]-1).'" class="link"><< prev</a>&nbsp;<a href="'.$_SERVER["PHP_SELF"].'?no='.$_no_.'" class="link">up</a></p>';
  63. else
  64. $side = '<p class="link"><a href="'.$_SERVER["PHP_SELF"].'?img='.($_GET["img"]-1).'" class="link"><< prev</a>&nbsp;<a href="'.$_SERVER["PHP_SELF"].'?no='.$_no_.'" class="link">up</a>&nbsp;<a href="'.$_SERVER["PHP_SELF"].'?img='.($_GET["img"]+1).'" class="link">next >></a></p>';
  65. echo $side.'<p align="center"><img class= "link" src="picture.php?img='.$images[$_GET["img"]][filename].'&show=full" border="'.$_border_.'" hspace="'.$_hspace_.'" vspace="'.$_vspace_.'" alt="'.$images[$_GET["img"]][filename].'" title="'.$images[$_GET["img"]][filename].', '.$images[$_GET["img"]][width].'x'.$images[$_GET["img"]][height].', '.$images[$_GET["img"]][size].'" ></p>'.$side;
  66. }
  67. }
  68. else
  69. {
  70. echo '<p class="title">'.$_page_title_.'</p>';
  71.  
  72. // echo $noimage.'<br>'.print_r($images);
  73. if($noimage > $_no_pics_per_page_)
  74. $norows = ceil($_no_pics_per_page_/$_no_cols_);
  75. else
  76. $norows = ceil($noimage/$_no_cols_);
  77.  
  78. $nopos = ceil($noimage/$_no_pics_per_page_);
  79.  
  80. // echo $nopos;
  81. echo '<table border="0" align="center" cellpadding="0" cellspacing="0">
  82. ';
  83.  
  84. if($_GET["no"] == "")
  85. $no = 1;
  86. else
  87. $no = $_GET["no"];
  88.  
  89.  
  90. $index=abs($no-1)*$_no_pics_per_page_;
  91. if(($noimage-$index)<$_no_pics_per_page_)
  92. $norows= ceil(($noimage-$index)/$_no_cols_);
  93.  
  94. for($a = 1;$a<=$norows;$a++)
  95. {
  96. echo '
  97. <tr>
  98. ';
  99. for($b = 1;$b<=$_no_cols_;$b++)
  100. {
  101. if($images[$index][filename] != '')
  102. {
  103. echo '<td width="'.(2*$_vspace_+$_width_min_).'" valign="top" align="center"><a href="'.$_SERVER["PHP_SELF"].'?img='.$index.'" ><img class="link"src="picture.php?img='.$images[$index][filename].'" border="'.$_border_.'" hspace="'.$_hspace_.'" vspace="'.$_vspace_.'" alt="'.$images[$index][filename].'" title="'.$images[$index][filename].', '.$images[$index][width].'x'.$images[$index][height].', '.$images[$index][size].'"></a>
  104. ';
  105. if($_filename_)
  106. echo '<span class="name">'.$images[$index][filename].'</span><br><br>';
  107.  
  108. echo '</td>';
  109. $index++;
  110. }
  111. else
  112. echo '<td width="'.(2*$_vspace_+$_width_min_).'">&nbsp;</td>';
  113. }
  114. echo '</tr>
  115. ';
  116. }
  117.  
  118. echo '
  119. </table>
  120. ';
  121.  
  122. if($nopos>1)
  123. {
  124. echo '<p class="stopka">';
  125. for($i=1;$i<=$nopos;$i++)
  126. {
  127. if($i == $no)
  128. echo '<font class="stopka_select">'.$i.'</font>&nbsp;';
  129. else
  130. echo '<a href="'.$_SERVER["PHP_SELF"].'?no='.$i.'" class="stopka">'.$i.'</a>&nbsp;';
  131. }
  132. echo '</p>';
  133. }
  134.  
  135. }
  136.  
  137.  
  138.  
  139. }
  140. else
  141. die('No images in directory');
  142.  
  143.  
  144. $time_end = microtime(true);
  145. $time = $time_end - $time_start;
  146. echo '<p class="exe"><br>All images in gallery : '.count($images).'</p>';
  147. ?>
  148. </body>
  149. </html>


"picture.php"
  1. <?
  2. // checken of config.cfg.php file bestaat
  3. if(is_file('config.cfg.php'))
  4. require 'config.cfg.php';
  5. else
  6. die('Error, no config file');
  7.  
  8. if($_GET[img] == "")
  9.  
  10. if (!ereg('^[^./][^/]*$', $_GET[img]))
  11.  
  12. $_image_ = $_images_dir_.$_GET[img];
  13. $new_w = $_width_min_;
  14. $imagedata = getimagesize($_image_);
  15.  
  16. // echo $_image_;
  17. if(!$imagedata[0])
  18. exit();
  19.  
  20.  
  21. $new_h = (int)($imagedata[1]*($new_w/$imagedata[0]));
  22.  
  23. // weergeven van volledige image
  24. if($_GET["show"] == "full")
  25. {
  26. if($_width_max_)
  27. {
  28. if($imagedata[0]<$_width_max_)
  29. {
  30. $new_w = $imagedata[0];
  31. $new_h = $imagedata[1];
  32. }
  33. else
  34. {
  35. $new_w = $_width_max_;
  36. $new_h = (int)($imagedata[1]*($new_w/$imagedata[0]));
  37. }
  38. }
  39. else
  40. {
  41. $new_w = $imagedata[0];
  42. $new_h = $imagedata[1];
  43. }
  44. }
  45.  
  46. // gegevens voor *.jpg
  47. if(strtolower(substr($_GET[img],-3)) == "jpg")
  48. {
  49. header("Content-type: image/jpg");
  50. $dst_img=ImageCreate($new_w,$new_h);
  51. $src_img=ImageCreateFromJpeg($_image_);
  52. $dst_img = imagecreatetruecolor($new_w, $new_h);
  53. imagecopyresampled($dst_img,$src_img,0,0,0,0,$new_w,$new_h,ImageSX($src_img),ImageSY($src_img));
  54. $img = Imagejpeg($dst_img);
  55. }
  56.  
  57. // gegevens voor *.gif
  58. if(substr($_GET[img],-3) == "gif")
  59. {
  60. header("Content-type: image/gif");
  61. $dst_img=ImageCreate($new_w,$new_h);
  62. $src_img=ImageCreateFromGif($_image_);
  63. ImagePaletteCopy($dst_img,$src_img);
  64. ImageCopyResized($dst_img,$src_img,0,0,0,0,$new_w,$new_h,ImageSX($src_img),ImageSY($src_img));
  65. $img = Imagegif($dst_img);
  66. }
  67. ?>


En nu wat ik heb gedaan om dit in 1 file te laten werken (wat ie dus niet doet).
nieuwe "index.php"
  1. <?
  2. // image directory
  3. $_images_dir_ = 'fotos/zooi/';
  4. // checken of er een image directorie bestaat
  5. if(!is_dir($_images_dir_))
  6. die('Error, no image directory');
  7.  
  8. // pad van 1e album naar index.php van foto
  9. $_link = '?pid=01';
  10.  
  11. // minimale breedte van image
  12. $_width_min_ = 150 ;
  13. // verticaal space
  14. $_vspace_ = 10 ;
  15. // horizontaal space
  16. $_hspace_ = 10 ;
  17. // border van image
  18. $_border_ = 0;
  19.  
  20. // sorteren: SORT_ASC, SORT_DESC
  21. $_sort_ = SORT_ASC;
  22.  
  23. // breedte van image: 0 voor originele breedte
  24. $_width_max_ = 640 ;
  25.  
  26. // filename weergven: 1 = Ja, 0 = Nee
  27. $_filename_ = 0;
  28.  
  29. // aantal kolommen
  30. $_no_cols_ = 3;
  31.  
  32. // aantal images op een site: aantal kolommen x aantal rijen
  33. $_no_pics_per_page_ = 9;
  34. ?>
  35. <html>
  36. <head>
  37. <meta http-equiv="content-type" content="text/html; charset=ISO-8859-2">
  38. <title>QuickGallery</title>
  39. <meta NAME="Author" CONTENT="Marcin Chmielecki">
  40.  
  41. <link href="<?echo $_style_?>" rel="stylesheet" type="text/css">
  42. </head>
  43. <body>
  44.  
  45. <?
  46. $time_start = microtime(true);
  47.  
  48.  
  49. // weergave thumb (jpg of gif)
  50. $noimage = 0;
  51.  
  52. if ($dh = opendir($_images_dir_)) {
  53. while (($f = readdir($dh)) !== false) {
  54. if((substr(strtolower($f),-3) == 'jpg') || (substr(strtolower($f),-3) == 'jpg'))
  55. {
  56. $imageinfo = getimagesize($_images_dir_.$f);
  57. $width = $imageinfo[0];
  58. $height = $imageinfo[1];
  59. $size = round(filesize($_images_dir_.$f)/1024,1).' KB';
  60. $noimage++;
  61. $images[] = array('filename' => $f, 'width' => $width, 'height' => $height, 'size' => $size);
  62. array_multisort($images, $_sort_, SORT_REGULAR);
  63. }
  64. }
  65. closedir($dh);
  66. }
  67.  
  68.  
  69. if($noimage)
  70. {
  71.  
  72. if($_GET["img"] != '')
  73. {
  74. echo '<p class="title">'.$images[$_GET["img"]][filename].'</p>';
  75. if($images[$_GET["img"]][filename] != '')
  76. {
  77.  
  78. if($_GET["img"])
  79. $_no_ = ceil(($_GET["img"]+1)/$_no_pics_per_page_);
  80. else
  81. $_no_ = 1;
  82.  
  83. if($_GET["img"] == 0)
  84. $side = '<p class="link"><a href="'.$_link.'&no='.$_no_.'" class="link">up</a>&nbsp;<a href="'.$_link.'&img='.($_GET["img"]+1).'" class="link">next >></a></p>';
  85. elseif($_GET["img"] == ($noimage-1))
  86. $side = '<p class="link"><a href="'.$_link.'&img='.($_GET["img"]-1).'" class="link"><< prev</a>&nbsp;<a href="'.$_link.'&no='.$_no_.'" class="link">up</a></p>';
  87. else
  88. $side = '<p class="link"><a href="'.$_link.'&img='.($_GET["img"]-1).'" class="link"><< prev</a>&nbsp;<a href="'.$_link.'&no='.$_no_.'" class="link">up</a>&nbsp;<a href="'.$_link.'&img='.($_GET["img"]+1).'" class="link">next >></a></p>';
  89. echo $side.'<p align="center"><img class="link" src="'.$_link.'&img='.$images[$_GET["img"]][filename].'&show=full" border="'.$_border_.'" hspace="'.$_hspace_.'" vspace="'.$_vspace_.'" alt="'.$images[$_GET["img"]][filename].'" title="'.$images[$_GET["img"]][filename].', '.$images[$_GET["img"]][width].'x'.$images[$_GET["img"]][height].', '.$images[$_GET["img"]][size].'" ></p>'.$side;
  90. }
  91. }
  92. else
  93. {
  94. echo '<p class="title">'.$_page_title_.'</p>';
  95.  
  96. // echo $noimage.'<br>'.print_r($images);
  97. if($noimage > $_no_pics_per_page_)
  98. $norows = ceil($_no_pics_per_page_/$_no_cols_);
  99. else
  100. $norows = ceil($noimage/$_no_cols_);
  101.  
  102. $nopos = ceil($noimage/$_no_pics_per_page_);
  103.  
  104. // echo $nopos;
  105. echo '<table border="0" align="center" cellpadding="0" cellspacing="0">
  106. ';
  107.  
  108. if($_GET["no"] == "")
  109. $no = 1;
  110. else
  111. $no = $_GET["no"];
  112.  
  113.  
  114. $index=abs($no-1)*$_no_pics_per_page_;
  115. if(($noimage-$index)<$_no_pics_per_page_)
  116. $norows= ceil(($noimage-$index)/$_no_cols_);
  117.  
  118. for($a = 1;$a<=$norows;$a++)
  119. {
  120. echo '
  121. <tr>
  122. ';
  123. for($b = 1;$b<=$_no_cols_;$b++)
  124. {
  125. if($images[$index][filename] != '')
  126. {
  127. echo '<td width="'.(2*$_vspace_+$_width_min_).'" valign="top" align="center"><a href="'.$_link.'&img='.$index.'" ><img class="link"src="'.$_link.'&img='.$images[$index][filename].'" border="'.$_border_.'" hspace="'.$_hspace_.'" vspace="'.$_vspace_.'" alt="'.$images[$index][filename].'" title="'.$images[$index][filename].', '.$images[$index][width].'x'.$images[$index][height].', '.$images[$index][size].'"></a>
  128. ';
  129. if($_filename_)
  130. echo '<span class="name">'.$images[$index][filename].'</span><br><br>';
  131.  
  132. echo '</td>';
  133. $index++;
  134. }
  135. else
  136. echo '<td width="'.(2*$_vspace_+$_width_min_).'">&nbsp;</td>';
  137. }
  138. echo '</tr>
  139. ';
  140. }
  141.  
  142. echo '
  143. </table>
  144. ';
  145.  
  146. if($nopos>1)
  147. {
  148. echo '<p class="stopka">';
  149. for($i=1;$i<=$nopos;$i++)
  150. {
  151. if($i == $no)
  152. echo '<font class="stopka_select">'.$i.'</font>&nbsp;';
  153. else
  154. echo '<a href="'.$_link.'&no='.$i.'" class="stopka">'.$i.'</a>&nbsp;';
  155. }
  156. echo '</p>';
  157. }
  158.  
  159. }
  160.  
  161.  
  162.  
  163. }
  164. else
  165. die('No images in directory');
  166.  
  167.  
  168. $time_end = microtime(true);
  169. $time = $time_end - $time_start;
  170. echo '<p class="exe"><br>All images in gallery : '.count($images).'</p>';
  171. ?>
  172. </body>
  173. </html>
  174.  
  175. <?
  176. if($_GET[img] == "")
  177.  
  178. if (!ereg('^[^./][^/]*$', $_GET[img]))
  179.  
  180. $_image_ = $_images_dir_.$_GET[img];
  181. $new_w = $_width_min_;
  182. $imagedata = getimagesize($_image_);
  183.  
  184. // echo $_image_;
  185. if(!$imagedata[0])
  186. exit();
  187.  
  188.  
  189. $new_h = (int)($imagedata[1]*($new_w/$imagedata[0]));
  190.  
  191. // weergeven van volledige image
  192. if($_GET["show"] == "full")
  193. {
  194. if($_width_max_)
  195. {
  196. if($imagedata[0]<$_width_max_)
  197. {
  198. $new_w = $imagedata[0];
  199. $new_h = $imagedata[1];
  200. }
  201. else
  202. {
  203. $new_w = $_width_max_;
  204. $new_h = (int)($imagedata[1]*($new_w/$imagedata[0]));
  205. }
  206. }
  207. else
  208. {
  209. $new_w = $imagedata[0];
  210. $new_h = $imagedata[1];
  211. }
  212. }
  213.  
  214. // gegevens voor *.jpg
  215. if(strtolower(substr($_GET[img],-3)) == "jpg")
  216. {
  217. header("Content-type: image/jpg");
  218. $dst_img=ImageCreate($new_w,$new_h);
  219. $src_img=ImageCreateFromJpeg($_image_);
  220. $dst_img = imagecreatetruecolor($new_w, $new_h);
  221. imagecopyresampled($dst_img,$src_img,0,0,0,0,$new_w,$new_h,ImageSX($src_img),ImageSY($src_img));
  222. $img = Imagejpeg($dst_img);
  223. }
  224.  
  225. // gegevens voor *.gif
  226. if(substr($_GET[img],-3) == "gif")
  227. {
  228. header("Content-type: image/gif");
  229. $dst_img=ImageCreate($new_w,$new_h);
  230. $src_img=ImageCreateFromGif($_image_);
  231. ImagePaletteCopy($dst_img,$src_img);
  232. ImageCopyResized($dst_img,$src_img,0,0,0,0,$new_w,$new_h,ImageSX($src_img),ImageSY($src_img));
  233. $img = Imagegif($dst_img);
  234. }
  235. ?>


Ik hoop dat jullie mij (verder) willen helpen en dat het duidelijk is.
het enige probleem is dat ie geen plaatje zowel bij thumb als origineel niet wilt tonen.

Alvast bedankt.

1 antwoord

Gesponsorde links
Offline Zerato - 16/01/2005 08:32
Avatar van Zerato Onbekend wie gaat deze code nou bekijken LEES DE F.A.Q. daar in staat geen lappen tekst neer te zetten
Gesponsorde links
Dit onderwerp is gesloten.
Actieve forumberichten
© 2002-2024 Sitemasters.be - Regels - Laadtijd: 0.256s