Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [php] szblon + galeria, nie moge tego zgrac!
tomorek
post 5.08.2006, 09:17:46
Post #1





Grupa: Zarejestrowani
Postów: 1
Pomógł: 0
Dołączył: 2.08.2006

Ostrzeżenie: (0%)
-----


Po nacisnięciu na miniaturke, skrypt nie odnajduje obrazka, sama galeria napewno dziala ale ja używam na stronie szblobu php zeby wszystko wyświetlało sie w odpowiedniej komórce, no i miniaturki i wszystko inne dziala, ale gdy klikam na miniaturke aby powiekszyc fotke nic sie nie wyswietla! zmienna $go z szablonu jest pusta nic nie pobiera, jestem poczatkujacym w php wiec prosz o pomoc, z gory dziekuje. Zeby dokladniej zrozumiec w czym problem tutaj -> http://republika.pl/zdjecia_praca/problem.rar jest spakowana, prymitywna stronka pokazująca ten błąd.

podam jeszcze trsc plików bo może ktoś z "lotu" potrafi mi odpowiedzieć na pytanie.
Plik galeri->
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html>
  3. <head>
  4. <title>Image Galleria</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  6. <style type="text/css">
  7.  
  8. </style>
  9. <!--link rel="stylesheet" href="../style.css" type="text/css"-->
  10. </head>
  11.  
  12. <body>
  13.  
  14. <div align="center">
  15. <h2>Image Gallery</h2>
  16.  
  17. <p>My most favorite pictures ever.</p>
  18.  
  19. <?
  20.  
  21.  
  22. /********** editable variables **********/
  23.  
  24. // thumbnails title
  25. $thumb_title = 1; // set to 1 if you want the image filename below the thumb, 0 otherwise
  26.  
  27. // full size images title
  28. $full_title = 1; // set to 1 if you want the image filename below the the full size image, 0 otherw
    ise
  29.  
  30. // how many thumbnails should appear per row?
  31. $cols = 3; // 3 looks the best, but you may want more or less, depending on the size of your 
    thumbnails
  32.  
  33. // how many thumbnails per page?
  34. $max_thumbs = 0; // a multiple of $cols looks the best, or 0 for all thumbnails on one page
  35.  
  36. // thumbnail directory name
  37. $thumbs_dir = "thumbs"; // just make sure your directory name is inside double quotes
  38.  
  39. // full size image directory name
  40. $full_dir = "images"; // just make sure your directory name is inside double quotes
  41.  
  42. // captions directory name
  43. $captions_dir = "captions"; // if you don't want captions at all, don't worry about this
  44.  
  45. // extension name
  46. $ext = "php"; // just incase you are using a different extension name for your script; if your s
    erver is not set for "index.$ext to be the index page, put "0".
  47.  
  48. // captions extension
  49. $cext = "inc"; // use whatever you're comfortable with
  50.  
  51. // show random option for single page view
  52. $showrand = 0; // to turn it off, switch 1 to 0
  53.  
  54. // print footer options
  55. $print_footer = "print_footer"; // put in the name of the function you use to print the footer of your page. if you don't use one, just leave it as it is.
  56.  
  57. /********** end editable variables **********/
  58.  
  59. // figure out this script's name
  60. $self = $HTTP_SERVER_VARS['PHP_SELF'];
  61.  
  62. if (basename($self) == "index.$ext") {
  63. $self = str_replace(basename($self), "", $self);
  64. }
  65.  
  66. // do you have an existing function to close your page? if not, use this default...
  67. if (!function_exists($print_footer)) {
  68. function print_gallery_footer() {
  69. ?>
  70.  
  71. </body>
  72. </html>
  73. <?
  74. }
  75. $print_footer = 'print_gallery_footer';
  76. }
  77.  
  78. // our error function, cleanly exits the script on user errors
  79. function imgerror($error) {
  80. global $print_footer;
  81. print "<p><b>$error</b></p>nn";
  82. $print_footer();
  83. exit();
  84. }
  85.  
  86. // get image size function
  87. function gallery_imgsize($image) {
  88. $size = GetImageSize($image);
  89. return "width=$size[0] height=$size[1]";
  90. }
  91.  
  92. // check for directories
  93. if(!is_dir($thumbs_dir)) {
  94. imgerror('Directory "'.$thumbs_dir.'" does not exist.');
  95. }
  96. if(!is_dir($full_dir)) {
  97. imgerror('Directory "'.$full_dir.'" does not exist.');
  98. }
  99.  
  100. // get contents of $thumbs_dir
  101. $dir = @opendir($thumbs_dir) or imgerror('Can't open ' . $thumbs_dir . ' directory');
  102. $thumbs = array();
  103. while($thumb = readdir($dir)) {
  104. if(preg_match('/(jpg$|jpeg$|gif$|tif$|bmp$|png$)/', $thumb))
  105. array_push($thumbs, $thumb);
  106. }
  107.  
  108. sort($thumbs);
  109.  
  110. // lowest displayed image in the array
  111. // use http_get_vars incase register_globals is off in php.ini
  112. if (!isset($HTTP_GET_VARS['i'])) {
  113. $i = 0;
  114. }
  115. else {
  116. $i = $HTTP_GET_VARS['i'];
  117. }
  118.  
  119. // check to see if all thumbs are meant to be displayed on one page
  120. if ($max_thumbs == 0) {
  121. $max_thumbs = sizeof($thumbs);
  122. $mt_check = 1;
  123. }
  124. else {
  125. $mt_check = 0;
  126. }
  127.  
  128. // thumbnail view
  129. if (is_numeric($i)) {
  130. // check to see which thumbnail to start with
  131. if (!$mt_check && $i > 0) {
  132. $start = $max_thumbs * ($i - 1);
  133. }
  134. else {
  135. $start = 0;
  136. }
  137. // are they looking for thumbs pages that don't exist?
  138. if ($start > sizeof($thumbs)) {
  139. print '<a href="' . $self . '">index</a>' . "nn";
  140. imgerror('Sorry, there are no images to display on this page');
  141. }
  142. ?>
  143. <table width="80%" cellspacing=0 cellpadding=10 border=0>
  144.  
  145. <tr>
  146. <?
  147. // loop through $thumbs and display $max_thumbs per page
  148. for($count = 1; $count <= $max_thumbs; $start++) {
  149. // break if past max_thumbs
  150. if ($start >= sizeof($thumbs)) {
  151. break;
  152. }
  153.  
  154. // print new row after predefined number of thumbnails
  155.  if(($count % $cols == 1) && $count != 1 && $cols > 1) {
  156. print "</tr>nn<tr>n";
  157. }
  158. else if ($cols == 1) {
  159. print "</tr>nn<tr>n";
  160. }
  161.  
  162.  // open cell
  163. print '<td align="center" width="' . (floor(100 / $cols)) . '%">';
  164.  
  165.  // insert thumb
  166. print '<a href="' . $self . '?i=' . rawurlencode("$thumbs[$start]") . '"><img src="' . $thumbs_dir . '/' . rawurlencode("$thumbs[$start]") . '" ';
  167. print gallery_imgsize("$thumbs_dir/$thumbs[$start]");
  168.  
  169. // alt information
  170. print ' alt="Link to full sized version of ' . $thumbs[$start] . '"></a>';
  171.  
  172. // image title
  173.  if($thumb_title) {
  174. $title = explode(".", str_replace("_", " ", ucfirst($thumbs[$start])));
  175. print "n" . '<br>' . $title[0];
  176. }
  177.  
  178. // close cell
  179. // supress line break for screen readers, but force a line break for lynx
  180. print '<br style="visibility: hidden; volume: silent"></td>' . "n";
  181. $count++;
  182. }
  183. ?>
  184. </tr>
  185.  
  186. </table>
  187. <?
  188. // thumbs page nav
  189. if (!$mt_check) {
  190. print "n<p>";
  191. // how many total thumbs pages, including a "remainder" page if needed
  192. $pages = ceil(sizeof($thumbs) / $max_thumbs);
  193. for ($count = 1; $count <= $pages; $count++) {
  194. if ($count == 1) {
  195. if ($count == $i || $i == 0) {
  196. print $count;
  197. }
  198. else {
  199. print "<a href="$self">$count</a>";
  200. }
  201. }
  202. else {
  203. if ($count == $i) {
  204. print " | $count</a>";
  205. }
  206. else {
  207. print " | <a href="$self?i=$count">$count</a>";
  208. }
  209. }
  210. }
  211. print '</p>';
  212. }
  213. }
  214.  
  215. // single image view
  216. else if (file_exists("$full_dir/$i")) {
  217. // find where it is in the array
  218. $key = array_search($i, $thumbs);
  219. if (is_null($key)) {
  220. $key = -1;
  221. }
  222.  
  223. // navigation
  224. print '<p>';
  225. // previous
  226. if($key >= 1) {
  227. print '<a href="' . $self . '?i=' . rawurlencode($thumbs[$key - 1]) . '">Ť previous</a> | ';
  228. }
  229. else {
  230. print 'Ť previous | ';
  231. }
  232. // index
  233. print '<a href="' . $self . '">index</a>';
  234. // random
  235. if ($showrand != 0) {
  236. $random = array_rand($thumbs, 2);
  237. print ' | <a href="' . $self . '?i=' . rawurlencode($thumbs[$random[0]]) . '">random</a>';
  238. }
  239. // next
  240. if($key != (sizeof($thumbs) - 1)) {
  241. print ' | <a href="' . $self . '?i=' . rawurlencode($thumbs[$key + 1]) . '">next ť</a>';
  242. }
  243. else {
  244. print ' | next ť';
  245. }
  246. print "</p>nn";
  247. // image
  248. print '<img src="' . $full_dir . '/' . rawurlencode($i) . '" ';
  249. print gallery_imgsize("$full_dir/$i");
  250.  
  251. // alt information
  252. print ' alt="';
  253. if(!$full_title) {
  254. print $i;
  255. }
  256. print "" border=0>nn";
  257.  
  258. if($full_title) {
  259. $title = explode(".", str_replace("_", " ", ucfirst($i)));
  260. print "<div class="fulltitle">$title[0]</div>nn";
  261. }
  262.  
  263. // numerically show what image it is in the series; hide this if image isn't in the series
  264. if ($key >= 0) {
  265. // add 1 so that the first image is image 1 in the series, not 0
  266. print '<div class="series">' . ($key + 1) . ' of ' . sizeof($thumbs) . "</div>nn";
  267. }
  268.  
  269. // caption (optional)
  270. if (file_exists("$captions_dir/$i.$cext")) {
  271. print '<div class="caption">';
  272. require("$captions_dir/$i.$cext");
  273. print '</div>';
  274. }
  275. }
  276.  
  277. // no image found
  278. else {
  279. ?><p><a href="<?=$self?>">index</a></p>
  280.  
  281. <?
  282. imgerror('Sorry, that image does not exist...');
  283. }
  284. ?>
  285.  
  286. <p><a href="../">Back to main image gallery</a></p>
  287. </div>
  288.  
  289. </body>
  290. </html>
  291. </body>
  292. </html>


Treśc szablonu ->
  1. <?php 
  2. // zmienna $go przekazana metoda GET
  3. $go = $_GET['go'];
  4.  
  5. // sprawdzamy czy zmienna $go nie jest pusta
  6. if(!empty($go)) {
  7. // sprawdzamy czy plik o danej nazwie istnieje
  8. if(is_file("./include/$go.php")) include "./include/$go.php";
  9. // jezeli plik nie istnieje wyswietla się komunikat
  10. else echo "<br />Nie ma takiej strony :-(";
  11. }
  12. // jezeli zmienna $go jest pusta wyswietla się strona glowna
  13. else include "start.php";
  14.  
  15. ?>


i pytanie to samo dlaczego po nacisnięciu na miniaturke skrypt nie znajduje pełnej fotki chociaż fizycznie ona jest, gdy do galeri odwołam sie bezpośrednio bez szblonu strony wszystko jest ok.

Ten post edytował tomorek 2.08.2006, 12:54:02
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 15.07.2025 - 08:18