Pomoc - Szukaj - U¿ytkownicy - Kalendarz
Pe³na wersja: [php] galeria zdjec - dokladny adres zdjecia pod zdjeciem
Forum PHP.pl > Forum > PHP
kamilian
Mam taki problem. Korzystam ze skryptu FhImage ale nie spelnia on moich oczekiwañ w 100% mianowicie nie wiem z ktorej strony ugryzc problem zeby po kliknieciu w zdjecie pod miniaturka pojawial sie dokladny adres danego zdjêcia

kod do galerii ktorej uzywam: gentumbs.php - generowanie miniaturek

  1. <?php 
  2.  
  3. /****************************************************** 
  4.  
  5.   FhImage 
  6.  
  7.   Copyright (c) 2003 Flash-here.com (support@flash-here.com) 
  8.  
  9. *******************************************************/ 
  10.  
  11.  
  12. function resizejpg($imagefile,$w) 
  13. { 
  14. // check path to prevent illegal access to other files 
  15. if(substr($imagefile, 0, 1) != '.' || strstr($imagefile, "..")) { 
  16. echo "Illegal access!";exit; 
  17. } 
  18.  
  19. // seems gif not supported by GD now 
  20. $ext = substr($imagefile, -3); 
  21. if(strtolower($ext) == "GIF") { 
  22. if (!$src_img = imagecreatefromgif($imagefile)) { 
  23. echo "Error opening Image file!";exit; 
  24. } 
  25. } else if(strtolower($ext) == "jpg") { 
  26. if (!$src_img = imagecreatefromjpeg($imagefile)) { 
  27. echo "Error opening Image file!";exit; 
  28. } 
  29. } else { 
  30. echo "Error file type not supported!";exit; 
  31. } 
  32.  
  33. $hw = getimagesize($imagefile); 
  34. $new_w = $w; 
  35. $new_h = $hw["1"]/($hw["0"]/$w); 
  36. // truecolor supported only in GD 2.0 or later 
  37. $dst_img = @imagecreatetruecolor($new_w, $new_h); 
  38. if(!$dst_img) { 
  39. $dst_img = imageCreate($new_w, $new_h); 
  40. } 
  41.  
  42. imagecopyresized($dst_img,$src_img,0,0,0,0,$new_w,$new_h,imagesx($src_img),imagesy($src_img)); 
  43. imagejpeg($dst_img); 
  44. ImageDestroy($src_img); 
  45. ImageDestroy($dst_img); 
  46. } 
  47.  
  48. header("Content-type: image/jpeg"); 
  49.  
  50. // in case register global is off 
  51. foreach($HTTP_GET_VARS as $key => $val) { 
  52.  $$key = $val; 
  53.  global $$key; 
  54. } 
  55.  
  56. if ($w == ""){$w = "100";} 
  57. resizejpg("./".$image,$w); 
  58.  
  59.  
  60. ?>



plik settings.php

  1. <html> 
  2. <p align="center"><?php include ('reklama.php'); ?> </p> 
  3. <div align="center"> 
  4. </html> 
  5. <?php 
  6. // description 
  7. $g_desc=''; 
  8. // number of columns per page 
  9. $g_cols='4'; 
  10. // number of rows per page 
  11. $g_rows='4'; 
  12. // whether thumb width or height is specified 
  13. $g_thumb_worh='w'; 
  14. // thumbnail width/height 
  15. $g_twidth='120'; 
  16. // spacing between thumbs 
  17. $g_spacing='2'; 
  18. // background color 
  19. $g_bgcolor='#101010'; 
  20. // title text color 
  21. $g_titlecolor='#DCDCDC'; 
  22. // description text color 
  23. $g_desccolor='#2E8B57'; 
  24. // other text color 
  25. $g_textcolor='#DCDCDC'; 
  26. // link color 
  27. $g_linkcolor='#C2DCA8'; 
  28. // vlink color 
  29. $g_vlinkcolor='#808080'; 
  30. // display file name? 
  31. $g_dispFn='0'; 
  32. // sort by filename 
  33. $g_sortByFn='0'; 
  34. // case insensitive sort 
  35. $g_insensitive_sort='check'; 
  36. // what to be used as folder image 
  37. $g_folderImg='4'; 
  38. // show full sized image in pop up window? 
  39. $g_showInPopup='1'; 
  40. // pop up window default width 
  41. $g_popupWidth='400'; 
  42. // pop up window default height 
  43. $g_popupHeight='400'; 
  44. // shrink popup window size if image is smaller than default size 
  45. $g_shrinkPopup=''; 
  46. global $g_title, $g_desc, $g_cols, $g_rows, $g_thumb_worth, 
  47.  $g_twidth, $g_spacing, $g_bgcolor, $g_titlecolor, $g_desccolor, 
  48.  $g_textcolor, $g_linkcolor, $g_vlinkcolor, $g_dispFn, 
  49.  $g_sortByFn, $g_insensitive_sort, 
  50.  $g_folderImg, $g_showInPopup, $g_popupWidth, $g_popupHeight, 
  51.  $g_shrinkPopup; 
  52. ?>


plik index.php

  1. <head> 
  2. <META HTTP-EQUIV="Pragma" CONTENT="no-cache"> 
  3. <title>FhImage</title> 
  4.  
  5. <?php 
  6.  
  7. /****************************************************** 
  8.  
  9.  
  10.  
  11. *******************************************************/ 
  12.  
  13. if (is_file("./settings.php")) { 
  14. include("settings.php"); 
  15. } 
  16. if (is_file("./styles.php")) { 
  17. include("styles.php"); 
  18. } 
  19.  
  20. global $g_bgcolor, $g_titlecolor, $g_desccolor; 
  21.  
  22. ?> 
  23.  
  24. </head> 
  25.  
  26. <?php 
  27.  
  28. // in case register global is off 
  29. foreach($HTTP_GET_VARS as $key => $val) { 
  30.  $$key = $val; 
  31.  global $$key; 
  32. } 
  33.  
  34. global $files, $isDir, $g_twidth, $g_cols, $g_rows, $g_title, $g_desc, $g_dispFn, $g_sortByFn, $g_folderImg, $g_showInPopup, $g_popupWidth, $g_popupHeight; 
  35.  
  36. include("func.php"); 
  37. $path = adjustPath($path); 
  38. if(!$page) 
  39. $page = 0; 
  40.  
  41.  
  42. if(!$g_cols) 
  43. $g_cols = 4; 
  44. if(!$g_rows) 
  45. $g_rows = 1; 
  46. if(!$g_title) 
  47. $g_title = ""; 
  48. if(!$g_twidth) 
  49. $g_twidth = 100; 
  50.  
  51. $files = array(); 
  52. $isDir = array("." => false); 
  53. @readFiles($path, $files, $isDir); 
  54. ?> 
  55.  
  56. <html> 
  57.  
  58. <body <?php if($g_textcolor != "") echo "text="$g_textcolor" "; 
  59. if($g_linkcolor != "") echo "link="$g_linkcolor" "; 
  60. if($g_vlinkcolor != "") echo "vlink="$g_vlinkcolor" "; ?> > 
  61.  
  62. <div align="center"> 
  63. <table border="0" cellspacing="0" cellpadding="10"> 
  64.  <tr> 
  65. <td> 
  66. <div align="center" class="headline"><?php echo $g_title; ?></div> 
  67. </td> 
  68.  <tr> 
  69. <td> 
  70.  
  71. <div align="center" class="desc"><?php echo $g_desc; ?></div> 
  72. <p> 
  73. <div align="center"> 
  74. <?php 
  75.  @showPageLinks($path, count($files), $page, $idx, 
  76. $g_cols, $g_rows); 
  77. ?> 
  78. </div> 
  79. </td> 
  80.  </tr> 
  81.  <tr> 
  82. <td> 
  83. <?php 
  84.  if ($idx == "") { 
  85.  @showImgTable($path, $files, $isDir, $page, 
  86. $g_cols, $g_rows); 
  87.  } else { 
  88.  @showBigImg($path, $idx); 
  89.  } 
  90. ?> 
  91. </td> 
  92.  </tr> 
  93.  <tr> 
  94. <td> 
  95. <?php 
  96.  @showFooter(); 
  97. ?> 
  98. </td> 
  99.  </tr> 
  100.  
  101. </table> 
  102.  
  103. </div> 
  104.  
  105. </body> 
  106.  
  107. </html>


plik func.php

Kod PHP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
<?php 
function showImg($aPath$aFn$aIdx$aThisPage$aSubDir=""

global 
$g_twidth$g_dispFn$g_thumb_worh$g_showInPopup$g_popupWidth$g_popupHeight$g_shrinkPopup

$fullpath $aPath.$aFn

// find the width and height of the thumbnail 
$imgsize GetImageSize($fullpath); 
if(
$g_thumb_worh == 'w') { 
$twidth $g_twidth
$theight $imgsize[1] / ($imgsize[0]/$twidth); 
} else { 
$theight $g_twidth
$twidth $imgsize[0] / ($imgsize[1]/$theight); 


// generate the html 
echo "<td>"
if(
$aSubDir != "") { 
echo 
"<center><a href="$PHP_SELF?path=$aPath"><img border="1" width="$twidth" height="$theight" src="genthumbs.php?image=$fullpath&w=$twidth"></img></a></center>"
} else { 
// need scrollbar? 
$sb "1"
if(
$g_showInPopup == 'check') { 
$w $g_popupWidth
$h $g_popupHeight
if(
$g_shrinkPopup == 'check') { 
$picsize GetImageSize($aPath.$aFn); 
if(
$picsize[0]+10 $w && $picsize[1]+10 $h) { 
$w $picsize[0]+10
$h $picsize[1]+10
$sb "no"

 

echo 
"<center><a href=# onclick="java script:window.open('$aPath$aFn', '_blank', 'width=$w, height=$h, scrollbars=$sb');return false"><img border="0" width="$twidth" height="$theight" src="genthumbs.php?image=$fullpath&w=$twidth"></img></a></center>"

} else 
echo 
"<center><a href="$PHP_SELF?path=$aPath&page=$aThisPage&img=$aFn&idx=$aIdx"><img border="1" width="$twidth" height="$theight" src="genthumbs.php?image=$fullpath&w=$twidth"></img></a></center>"


// display filename? 
if($g_dispFn) { 
echo 
"<br><center>"
if(
$aSubDir == "0") { 
$l strlen($aFn) - 4
echo 
substr($aFn0$l); 
} else { 
echo 
$aSubDir.""

echo 
"</center>"

echo 
"</td>"



/* 
 * show the image in real size 
 */ 
function showBigImg($aPath$aIdx

global 
$files$isDir

echo 
"<center>"
echo 
"<table border="0" cellspacing="10" cellpadding="0">"

if(
$isDir[$files[$aIdx]]) { 
showDir($aPath$files[$aIdx]); 
} else { 
// generate the html 
echo "<td>"
echo 
"<center><img border="0" src="".$aPath.$files[$aIdx].""></img></center>"
echo 
"</td>"

echo 
"</table>"
echo 
"</center>"



/* 
 * get the filename of the first image from a folder 
 */ 
function getFirstImgFn($aPath$aExt

$dir_handle = @opendir($aPath) or die("Unable to open $aPath"); 

while(
$file readdir($dir_handle)) { 
$fullpath $aPath.$file

if(
is_dir($fullpath) == false) { 
$ext substr($file, -4); 
if(
strtolower($ext) == $aExt) { 
return 
$file



/* 
 * return empty if no img exists. 
 */ 
return ""


/* 
 * get the filename of a random image from a folder 
 */ 
function getRandomImgFn($aPath$aExt

$dir_handle = @opendir($aPath) or die("Unable to open $aPath"); 

$imgfiles = array(); 
while(
$file readdir($dir_handle)) { 
$fullpath $aPath.$file

if(
is_dir($fullpath) == false) { 
$ext substr($file, -4); 
if(
strtolower($ext) == $aExt) { 
$imgfiles[] = $file




$num count($imgfiles); 
if(
$num <= 0) { 
/* 
 * return empty if no img exists. 
 */ 
return ""


/* 
 * randomly pick one 
 */ 
$idx rand(0$num-1); 
return 
$imgfiles[$idx];




function 
showDir($a
Athlan
http://pl.php.net/manual/pl/function.basename.php



Kombinuj smile.gif
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-2025 Invision Power Services, Inc.