login  Naam:   Wachtwoord: 
Registreer je!
 Scripts:

Scripts > PHP > Foto gallerijen > Foto gallerij met overzicht

Foto gallerij met overzicht

Auteur: Stijn1 - 25 september 2004 - 21:14 - Gekeurd door: Dennisvb - Hits: 30877 - Aantal punten: 3.79 (17 stemmen)




Dit is een scriptje dat een dir uitleest naar foto's (de extenties kunnen zelf opgegeven worden)
Je kan vanboven nog wat aanpassen maar in het script ook nog wat...
Sorry maar ik was te lui om het echt helemaal perfect te maken (dat je alles kon invullen vanboven enz) maar het ziet er toch redelijk uit...

Code:
  1. <?php
  2. // change
  3. $map = '.'; // dir for images
  4. $col = 4; // collumns per page
  5. $row = 5; // rows per page
  6. $img = array('jpg'); // possible extentions
  7. $tab = array(); // empty
  8. if(isset($_GET['actie'])){
  9. $_GET['actie'] = $_GET['actie'];
  10. }
  11. else{
  12. $_GET['actie'] = '';
  13. }
  14. if(isset($_GET['dir'])){
  15. $_GET['dir'] = $_GET['dir'];
  16. }
  17. else{
  18. $_GET['dir'] = '';
  19. }
  20. $dir = $_GET['dir'];
  21. if(!isset($_GET['p'])){
  22. $p = 1;
  23. }
  24. else{
  25. $p = $_GET['p'];
  26. }
  27. function img_resize($a, $b = '', $c = ''){
  28. if(file_exists($a)){
  29. if($b == '' || !is_numeric($b)){
  30. $b = 100;
  31. }
  32. if($c == '' || !is_numeric($c)){
  33. $c = 100;
  34. }
  35. $f = getimagesize($a);
  36. $g = array();
  37. if($f[1] > $c || $f[0] > $b){
  38. if($f[0] > $c){
  39. $d = $f[0] - $b;
  40. $e = $d / $f[0];
  41. $g[0] = $b;
  42. $g[1] = $f[1] - ($f[1] * $e);
  43. }
  44. elseif($f[1] > $c){
  45. $d = $f[1] - $c;
  46. $e = $d / $f[1];
  47. $g[0] = $f[0] - ($f[0] * $e);
  48. $g[1] = $c;
  49. }
  50. else{
  51. $g[1] = $c;
  52. $g[0] = $b;
  53. }
  54. }
  55. else{
  56. $g[0] = $f[0];
  57. $g[2] = $f[1];
  58. }
  59. return 'src="'.$a.'" width="'.$g[0].'" height="'.$g[1].'"';
  60. }
  61. else{
  62. return false;
  63. }
  64. }
  65. function dir_array($a, $b){
  66. $g = array();
  67. if($c = opendir($a)){
  68. while(false !== ($d = readdir($c))){
  69. if($d != "." && $d != ".."){
  70. $e = explode('.', $d);
  71. $f = $e[count($e)-1];
  72. if(is_dir($a."/".$d)){
  73. $g = array_merge($g, dir_array($a."/".$d, $b));
  74. }
  75. elseif(in_array(strtolower($f), $b)){
  76. $g[] = $a."/".$d;
  77. }
  78. }
  79. }
  80. closedir($c);
  81. }
  82. return $g;
  83. }
  84. function map_array($a){
  85. $g = array();
  86. if($c = opendir($a)){
  87. while(false !== ($d = readdir($c))){
  88. if($d != "." && $d != ".."){
  89. if(is_dir($a."/".$d)){
  90. $g[$d] = $a."/".$d;
  91. }
  92. }
  93. }
  94. closedir($c);
  95. }
  96. return $g;
  97. }
  98. function sort_table($a, $b, $e){
  99. global $p;
  100. $f = $b*$e;
  101. $f = count($a)/$f;
  102. $f = ceil($f);
  103. if(isset($_GET['actie'])){
  104. $actie = '&actie='.$_GET['actie'];
  105. }
  106. else{
  107. $actie = '';
  108. }
  109. if($_GET['dir'] != ''){
  110. $actie .= '&dir='.$_GET['dir'];
  111. }
  112. if($b > count($a)){
  113. $b = count($a);
  114. }
  115. if($p < 1 || $p > $f){
  116. $p = 1;
  117. }
  118. $c = '<table border="1" width="'.(150*$b).'" style="border-collapse: collapse">';
  119. $d = 1;
  120. for($i = $b*$e*($p-1); $i < ($b*$e*$p); $i++){
  121. if($d == 1){
  122. $c .= '<tr align="center" valign="middle">';
  123. }
  124. $c .= '<td width="150" height="150">';
  125. if(isset($a[$i])){
  126. $c .= $a[$i];
  127. }
  128. // else{
  129. // $c .= '&nbsp;';
  130. // }
  131. $c .= '</td>';
  132. if($d == $b){
  133. $d = 1;
  134. $c .= '</tr>';
  135. }
  136. else{
  137. $d++;
  138. }
  139. }
  140. $c .= '<tr align="center" valign="middle"><td colspan="'.$b.'">';
  141. if($p > 1){
  142. $c .= '<a href="?p='.($p-1).$actie.'">< Vorige</a>';
  143. }
  144. else{
  145. $c .= '< Vorige';
  146. }
  147. $c .= ' | ';
  148. for($j = 1; $j <= $f; $j++){
  149. if($p != $j){
  150. $c .= '<a href="?p='.$j.$actie.'">'.$j.'</a>';
  151. }
  152. else{
  153. $c .= '<b>'.$j.'</b>';
  154. }
  155. $c .= ' | ';
  156. }
  157. if($p < $f){
  158. $c .= '<a href="?p='.($p+1).$actie.'">Volgende ></a>';
  159. }
  160. else{
  161. $c .= 'Volgende >';
  162. }
  163. if($_GET['actie'] == 2){
  164. $c .= '<br /><a href="?actie=1&dir='.$_GET['dir'].'">Overzicht</a>';
  165. }
  166. elseif($_GET['actie'] == 1){
  167. $c .= '<br /><a href="?dir=">Overzicht</a>';
  168. }
  169. $c .= '</td></tr>';
  170. $c .= '</table>';
  171. return $c;
  172. }
  173. ?>
  174. <html>
  175. <head>
  176. <title>Foto's Cm 2004 Schwarszee</title>
  177. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  178. </head>
  179. <body>
  180. <div align="center">
  181. <?php
  182. $i = 1;
  183. foreach(dir_array($dir, $img) as $a){
  184. if(file_exists($a) == true){
  185. if($_GET['actie'] == 1){
  186. $tab[] = '<a href="?p='.$i.'&actie=2&dir='.$_GET['dir'].'"><img '.img_resize($a).' border="0" /></a>';
  187. }
  188. else{
  189. $tab[] = '<a href="'.$a.'"><img '.img_resize($a, 700, 700).' border="0" /></a>';
  190. }
  191. $i++;
  192. }
  193. }
  194. if($_GET['actie'] == '' || $_GET['dir'] == '' || !is_dir($_GET['dir'])){
  195. echo '<b>Fotoalbums:</b><br />';
  196. if(count(map_array($map)) != 0){
  197. foreach(map_array($map) as $a => $b){
  198. echo '- <a href="?actie=1&dir='.$b.'">'.$a.'</a><br />';
  199. }
  200. }
  201. else{
  202. echo '- <a href="?actie=1&dir='.$map.'">'.$map.'</a><br />';
  203. }
  204. echo '- <a href="?actie=1&dir='.$map.'">Allemaal</a><br />';
  205. }
  206. elseif($_GET['actie'] == 1){
  207. echo sort_table($tab, $col, $row);
  208. }
  209. elseif($_GET['actie'] == 2){
  210. echo sort_table($tab, 1, 1);
  211. }
  212. ?>
  213. </div>
  214. </body>
  215. </html>
Download code! Download code (.txt)

 Stemmen
Niet ingelogd.

 Reacties
Post een reactie
Lees de reacties (17)
© 2002-2024 Sitemasters.be - Regels - Laadtijd: 0.039s