Witam,
siedze nad tym skryptem, kombinuje i nic, a sprawa jest taka:

mam fajny skrypt galerii, ktory polega na tym ze generuje galerie z folderow ktore sa w katalogu ze skryptem, a ja chcialbym zeby zdjecia byly w katalogu "galeria/", czyli:

nazwa skryptu galeria.php
zdjecia w katalogu galeria/

nie wiem czy dobrze wytlumaczylem, poni¿ej skrypt i z gory dziekuje za pomoc winksmiley.jpg

  1. <?
  2.  
  3. /*
  4.  * mmgallery v1.55  
  5.  * ===============
  6.  *
  7.  * Copyright (c) 2004 by madmaz <madmaz@netfriends.it>
  8.  *
  9.  * This program is free stware; you can redistribute it and/or
  10.  * modify it under the terms of the GNU General Public License
  11.  * as published by the Free Software Foundation; either version 2
  12.  * of the License, or (at your option) any later version.
  13.  *
  14.  * This program is distributed in the hope that it will be useful,
  15.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17.  * GNU General Public License for more details.
  18.  * 
  19.  * You should have received a copy of the GNU General Public License
  20.  * along with this program; if not, write to the Free Software
  21.  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  22.  *
  23.  */
  24.  
  25. // OPTIONS
  26.  
  27. // If you want to skip some directory rename them with the prefix specified in 
  28. // $filterprefix (for example use "__");
  29. $filterprefix = "";
  30.  
  31. // Set to true if you want to show filename below thumbs.
  32. $showfilename = false;
  33.  
  34. // Set to true if you want to hide extension in filename.
  35. $hidefilenameext = false;
  36.  
  37. /*********************************************************/
  38. /* Counts the number of file in the specified directory. */
  39. /*********************************************************/
  40. global $basedir = "galeria/";
  41.  
  42. function count_files($basedir)
  43. {
  44. $handle = opendir($basedir);
  45. $i = 0;
  46.  
  47. while ($file = readdir($handle))
  48. {
  49. if ((strstr(strtolower($file), '.bmp') || 
  50.  strstr(strtolower($file), '.gif') || 
  51.  strstr(strtolower($file), '.jpg') || 
  52.  strstr(strtolower($file), '.png')) && 
  53.  $file != "thumb.jpg")
  54. {
  55. $i++;
  56. }
  57. }
  58.  
  59. closedir($handle);
  60.  
  61. return $i;
  62. }
  63.  
  64.  
  65. /*********************************************************/
  66. /* Gets the name of the file number '$index' in the */
  67. /* '$basedir' directory.  */
  68. /*********************************************************/
  69.  
  70. function search_file($basedir, $index)
  71. {
  72. $handle = opendir($basedir);
  73.  
  74. while ($file = readdir($handle)) 
  75. {
  76. if ((strstr(strtolower($file), '.bmp') || 
  77.  strstr(strtolower($file), '.gif') || 
  78.  strstr(strtolower($file), '.jpg') || 
  79.  strstr(strtolower($file), '.png')) &&
  80.  $file != "thumb.jpg")
  81. {
  82. $filelist[] = "$file";
  83. }
  84. }
  85.  
  86. sort($filelist);
  87. closedir($handle);
  88.  
  89. return $filelist[$index - 1];
  90. }
  91.  
  92.  
  93. /*********************************************************/
  94. /* Gets the names of the files in the '$basedir'  */
  95. /* directory. */
  96. /*********************************************************/
  97.  
  98.  
  99. function list_files($basedir)
  100. {
  101. $handle = opendir($basedir);
  102.  
  103. while ($file = readdir($handle)) 
  104. {
  105. if ((strstr(strtolower($file), '.bmp') || 
  106.  strstr(strtolower($file), '.gif') || 
  107.  strstr(strtolower($file), '.jpg') || 
  108.  strstr(strtolower($file), '.png')))
  109. {
  110. $filelist[] = "$file";
  111. }
  112. }
  113.  
  114. sort($filelist);
  115. closedir($handle);
  116.  
  117. return $filelist;
  118. }
  119.  
  120.  
  121. /*********************************************************/
  122. /* Gets the directory list in the '$basedir'  */
  123. /* directory. */
  124. /*********************************************************/
  125.  
  126.  
  127. function search_dir($basedir)
  128. {
  129. global $filterprefix;
  130. $handle = opendir($basedir);
  131.  
  132. while ($file = readdir($handle)) 
  133. {
  134. if (!($file == "." || $file == ".." ) && is_dir($file) && 
  135.  (strstr($file, $filterprefix) != $file))
  136. {
  137. $filelisting[] = "$file";
  138. }
  139. }
  140.  
  141. closedir($handle);
  142.  
  143. return $filelisting;
  144. }
  145.  
  146.  
  147. /**************************************************************/
  148. /* Shows one thumb of each gallery in a table with */
  149. /* with '$cols' columns. */
  150. /* '$th_width' and '$th_height' are the dimensions */
  151. /* of the thumbnails.  */
  152. /* The thumbnails are picked from each directory and must  */
  153. /* be named 'thumb.jpg'  */
  154. /* '$cellpadding', '$cellspacing' refer to the table */
  155. /* properties.  */
  156. /**************************************************************/
  157.  
  158. function show_galleries($cols, $th_width, $th_height, 
  159. $cellpadding, $cellspacing)
  160. {
  161. echo "<table border='0' cellpadding='$cellpadding' 
  162. cellspacing='$cellspacing' 
  163. align='center'>n";
  164. echo "<tr>n";
  165.  
  166. $dirlist = search_dir("./"); 
  167. sort($dirlist);
  168. $n = 1;
  169.  
  170. for ($i = 0; $i < sizeof($dirlist); $i++) 
  171. {
  172. $dir = $dirlist[$i];
  173. $tot = count_files($dir);
  174. $gallery_name = str_replace("_", " ", $dirlist[$i]);
  175.  
  176. echo "<td align='center'>n";
  177. echo "<table border='0' cellspacing='1' cellpadding='0' 
  178. bgcolor='#000000'>n";
  179. echo "<tr><td>n";
  180. echo "<a href='thumbs.php?dir=$dir&page=1'>n";
  181. echo "<img src='$dir/thumb.jpg' width=$th_width 
  182. height=$th_height border=0><br>n";
  183. echo "</a></td></tr>n";
  184. echo "</table>n";
  185. echo "<a href='thumbs.php?dir=$dir&page=1'>";
  186. echo "<font size='1' face='verdana'><b>$gallery_name</b>&nbsp;<small>($tot)</small></font>n";
  187. echo "</a>";
  188. echo "</td>n";
  189.  
  190. if (($n % $cols) == 0 && ($n != sizeof($dirlist))) 
  191. {
  192. echo "</tr>n";
  193. echo "<tr align=center>";
  194. }
  195.  
  196. $n++;
  197. }
  198.  
  199. echo "</tr>n";
  200. echo "</table>n";
  201.  
  202. // Powered by mmgallery
  203. echo "<br>";
  204. echo "<div align="center"><small></a></small></div>";
  205. }
  206.  
  207.  
  208. /**************************************************************/
  209. /* Shows all thumbs of a gallery in a table with */
  210. /* '$cols' columns.  */
  211. /* '$th_width' and '$th_height' are the dimensions */
  212. /* of the thumbnails.  */
  213. /* The thumbnails are picked from each directory and must  */
  214. /* be named 'thumb.jpg'  */
  215. /* '$cellpadding', '$cellspacing' refer to the table */
  216. /* properties.  */
  217. /**************************************************************/
  218.  
  219.  
  220. function show_thumbs($cols, $th_width, $th_height, $cellpadding, 
  221.  $cellspacing, $perpage)
  222. {
  223. $dir = $_GET["dir"];
  224. $tot = count_files($dir);
  225. if (isset($_GET["page"])) {
  226. $page = $_GET["page"];
  227. }
  228. if (isset($_GET["img"])) {
  229. $img = $_GET["img"];
  230. }
  231. global $showfilename;
  232. global $hidefilenameext;
  233.  
  234. if ($page == NULL) {
  235. $page = ceil($img / $perpage);
  236. }
  237.  
  238. echo "<div style='text-align: center'>";
  239. echo "<table border='0' cellpadding='$cellpadding' 
  240. cellspacing='$cellspacing' align='center'>n";
  241. echo "<tr>n";
  242.  
  243. $filelist = list_files("./$dir/thumbs");
  244. $n = 1;
  245.  
  246. $end = min(($page * $perpage), sizeof($filelist));
  247.  
  248. for ($i = (($page - 1) * $perpage); $i < $end; $i++) 
  249. {
  250. echo "<td align='center'>n";
  251. echo "<table border='0' cellspacing='1' cellpadding='0' 
  252. bgcolor='#000000'>n";
  253. echo "<tr><td>n";
  254. echo "<a href='show.php?dir=$dir&tot=$tot&img=".($i + 1).
  255.  "&page=$page'>n";
  256. echo "<img src='$dir/thumbs/$filelist[$i]' width='$th_width' 
  257.  height='$th_height' border='0'><br>n";
  258. echo "</a>n";
  259. echo "</td></tr>n";
  260. echo "</table>n";
  261.  
  262. if ($showfilename) 
  263. {
  264. if ($hidefilenameext) {
  265. echo "<small>".substr($filelist[$i], 0, strrpos($filelist[$i], '.'))."</small>";
  266. }
  267. else
  268. {
  269. echo "<small>$filelist[$i]</small>";
  270. }  
  271. }
  272.  
  273. echo "</td>n"; 
  274.  
  275. if (($n % $cols) == 0 && ($n != $perpage)) 
  276. {
  277. echo "</tr>";
  278. echo "<tr align='center'>";
  279. }
  280.  
  281. $n++;
  282. }
  283. echo "</tr>n";
  284. echo "</table>";
  285.  
  286. // We need to show thumbs in more than one page
  287. if (sizeof($filelist) > $perpage) {
  288. echo ("<font face='verdana' size='1'>Strona:&nbsp;");
  289.  
  290. for ($j = 1; $j <= ceil(sizeof($filelist) / $perpage); $j++) {
  291.  echo ("<a href='thumbs.php?dir=$dir&page=".$j."'>");
  292.  
  293.  // Current page  
  294.  if ($page == $j) {
  295.  echo "<b>".$j."</b>";
  296.  }
  297.  else 
  298.  {
  299.  echo $j;
  300.  } 
  301.  
  302.  echo "</a>";
  303.  echo ("&nbsp;&nbsp;");
  304. }
  305.  
  306. echo "<br><br>";
  307. }
  308.  
  309. echo "<a href='show.php?dir=$dir&tot=$tot&img=".
  310. ((($page - 1) * $perpage) + 1)."'><font face='verdana' size='1'>start</a>&nbsp;::&nbsp;"; 
  311. echo "<a href='index.php'>menu galerii</a>&nbsp;"; 
  312.  
  313. // Powered by mmgallery
  314. echo "<br><br><br>";
  315. echo "</u></a></small>";
  316.  
  317. echo "</div>";
  318.  }
  319.  
  320.  
  321. /***********************************************************/
  322. /* Shows the picture and the links related to the position */
  323. /* in the slideshow.  */
  324. /***********************************************************/
  325.  
  326. function show_picture()
  327. {
  328. $dir = $_GET["dir"];
  329. $tot = $_GET["tot"];
  330. $img = $_GET["img"];
  331.  
  332. echo "<div style='text-align: center'>";
  333. echo "<big>n";
  334.  
  335. if ($img > 1)
  336. {
  337. echo "<a href='show.php?dir=$dir&tot=$tot&img=".($img - 1)."'>&lt;&lt;</a>"; 
  338. }
  339.  
  340. echo "&nbsp;&nbsp;&nbspn";
  341. echo "</big>n";
  342. echo "<b>".$img."</b> of ".$tot; 
  343. echo "&nbsp;&nbsp;&nbspn";
  344. echo "<big>n";
  345.  
  346. if ($img < $tot)
  347. {
  348. echo "<a href='show.php?dir=$dir&tot=$tot&img=".($img + 1)."'>&gt;&gt;</a>"; 
  349. }
  350.  
  351. echo "</big>n";
  352. echo "<br><br>n"; 
  353.  
  354. echo "<table border='0' cellspacing='1' cellpadding='0' 
  355.  bgcolor='#000000' align='center'>n";
  356. echo "<tr><td>n";
  357. echo "<a href='thumbs.php?dir=$dir&img=$img'>"; 
  358. echo "<img src='$dir/".search_file("./$dir", $img)."' border=0 
  359. onLoad='resize(this);' name=foto 
  360. alt='Click to go to thumbnails page.'>";
  361. echo "</a>";
  362. echo "</td></tr>n";
  363. echo "</table>n";
  364.  
  365.  
  366. echo "<br><br>n"; 
  367. echo "<big>n";
  368.  
  369. if ($img > 1)
  370. {
  371. echo "<a href='show.php?dir=$dir&tot=$tot&img=".($img - 1)."'>&lt;&lt;</a>"; 
  372. }
  373.  
  374. echo "&nbsp;&nbsp;&nbspn";
  375.  
  376. if ($img < $tot)
  377. {
  378. echo "<a href='show.php?dir=$dir&tot=$tot&img=".($img + 1)."'>&gt;&gt;</a>"; 
  379. }
  380.  
  381. echo "</big>n";
  382. echo "<br><br>n"; 
  383.  
  384. echo "<a href='show.php?dir=$dir&tot=$tot&img=1'>pierwsze</a>&nbsp;::&nbsp;"; 
  385. echo "<a href='index.php'>menu galerii</a>&nbsp;::&nbsp;"; 
  386. echo "<a href='thumbs.php?dir=$dir&img=$img'>miniaturki</a>&nbsp;::&nbsp;"; 
  387. echo "<a href='show.php?dir=$dir&tot=$tot&img=$tot'>ostatnie</a>"; 
  388.  
  389. echo "<br><br>n"; 
  390.  
  391. echo "<form name='jump'>n";
  392. echo "id¼ do zdjêcia nr: <select name=go onChange="document.location = 
  393. 'show.php?dir=$dir&tot=$tot&img=' + document.jump.go.value">";
  394. echo "<option value='' selected>";
  395.  
  396. for ($i = 1; $i <= $tot; $i++)
  397. {
  398. echo "<option value='$i'>$i";
  399. }
  400.  
  401. echo "</select>n";
  402. echo "</form>n";
  403.  
  404. // Powered by mmgallery
  405. echo "<br>";
  406. echo "<small></u></a></small>";
  407.  
  408. echo "</div>"; 
  409. }
  410.  
  411. ?>