Pomoc - Szukaj - U¿ytkownicy - Kalendarz
Pe³na wersja: Instalacja Photodir
Forum PHP.pl > Forum > Gotowe rozwi±zania
ciszex
Witam smile.gif

Mam problem z konfiguracj± pomózcie mi co mama wpisac w zmiennych konfiguracyjnych. Jak uruchamiam ten skrypt to nic mi nie wy¶wietla... z³e ustawienia katalogów??
Za³ó¿my ¿e chce uruchomiæ to na stronie
www.domena.pl/galeria

link do skryptu... http://www.rossp.org/stuff/photodir-1.1.tar.gz

  1. <?
  2. /*
  3.  * PHOTODIR
  4.  * photodir.php - Main program
  5.  * Version 1.1, 20-Jan-04
  6.  * Copyright 2004 Ross W. Poulton
  7.  * ross@rossp.org
  8.  * <a href=\"http://www.rossp.org/\" target=\"_blank\">http://www.rossp.org/</a>
  9.  * 
  10.  * This file is part of PhotoDir.
  11.  *
  12.  * PhotoDir is free software; you can redistribute it and/or modify
  13.  * it under the terms of the GNU General Public License as published by
  14.  * the Free Software Foundation; either version 2 of the License, or
  15.  * (at your option) any later version.
  16.  *
  17.  * PhotoDir is distributed in the hope that it will be useful,
  18.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20.  * GNU General Public License for more details.
  21.  *
  22.  * You should have received a copy of the GNU General Public License
  23.  * along with PhotoDir; if not, write to the Free Software
  24.  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  25.  * 
  26.  */
  27. // Define some basic variables:
  28.  
  29. /* Directory where photos are stored */
  30. $photo_dir = "/var/httpd/rossp.org/photos";
  31.  
  32. /* Directory for cached thumbnails */
  33. $cache_dir = "/var/httpd/rossp.org/photos-cache";
  34.  
  35. /* URI to where photos are stored */
  36. $photo_url = "/photos";
  37.  
  38. /* 'Frame' picture - thumbnails will be centred on top of this image */
  39. $frame_pic = "outline.jpg";
  40.  
  41. /* 'Folder' picture */
  42. $folder_pic = "folder.jpg";
  43.  
  44. /* 'Parent' picture */
  45. $parent_pic = "folder.jpg";
  46.  
  47. /* Maximum dimensions for a thumbnail will be $thumb_max * $thumb_max. Thumbs
  48.    are made proportionatly, eg a 200x100 image with thumb_max of 100 will be 
  49.    resized to 100x50. */
  50. $thumb_max = 100;
  51.  
  52. /* *********************************************** */
  53. /* END CONFIGURATION */
  54. /* *********************************************** */
  55.  
  56. if ($_GET['photofile']) {
  57. /* If we're just displaying a photo, send it out to the user. */
  58.  
  59. $photo = $photo_dir . "/" . stripslashes($_GET['photofile']);
  60.  
  61. if (realpath($photo) != $photo) {
  62. /* Use realpath to find out if someone has tried spoofing us with
  63.  ../../../../etc/passwd or similar. */
  64. }
  65.  
  66. header("Content-type: image/jpeg");
  67. readfile($photo);
  68.  
  69. } elseif ($_GET['thumbfile']) {
  70.  
  71. /* Display a thumbnail. This will be a resized version of the full file, 
  72.  but superimposed on your outline image. */
  73.  
  74. $photo = $photo_dir . "/" . stripslashes($_GET['thumbfile']);
  75. if (realpath($photo) != $photo) {
  76. }
  77. header("Content-type: image/jpeg");
  78.  
  79. $md5sum = md5("$photo");
  80. $cache_file = $cache_dir . "/$md5sum";
  81.  
  82. if ((!file_exists($cache_file)) ||
  83. (filemtime($cache_file) < filemtime($photo))) {
  84.  
  85. $outline_img = imagecreatefromjpeg($photo_dir . "/" . $frame_pic);
  86. $outline_width = imagesx($outline_img);
  87. $outline_height = imagesy($outline_img);
  88.  
  89. $src_img = imagecreatefromjpeg($photo);
  90.  
  91. $size = getimagesize($photo);
  92. $origw = $size[0];
  93. $origh = $size[1];
  94.  
  95. if ($origw > $origh) {
  96. $neww = $thumb_max;
  97. $diff = $origw / $neww;
  98. $newh = $origh / $diff;
  99. } else {
  100. $newh = $thumb_max;
  101. $diff = $origh / $newh;
  102. $neww = $origw / $diff;
  103. }
  104.  
  105. $dst_img = imagecreatetruecolor($neww, $newh);
  106.  
  107. if (function_exists('imagecopyresampled')) {
  108. imagecopyresampled($dst_img,$src_img,0,0,0,0,$neww,$newh,
  109. $origw,$origh);
  110. } else {
  111. imagecopyresized($dst_img, $src_img,0,0,0,0,$neww,$newh,$origw,
  112. $origh);
  113. }
  114.  
  115. imagealphablending($outline_img, true);
  116.  
  117. /* The following block makes up our co-ordinates for placing the
  118. thumbnail on the frame. We always start at least 2 pixels from 
  119. each edge, and from there the image is centered both horizontally
  120. and vertically. */
  121.  
  122. if ($neww > $newh) {
  123. $startx = 2;
  124. $starty = ((100 - $newh) / 2) + 2;
  125. } else {
  126. $startx = ((100 - $neww) / 2) + 2;
  127. $starty = 2;
  128. }
  129.  
  130. imagecopy($outline_img, $dst_img, $startx, $starty, 0, 0, $neww, $newh);
  131.  
  132. imagejpeg($outline_img, $cache_file);
  133. }
  134.  
  135. readfile ($cache_file);
  136.  
  137. }
  138.  
  139. include "header.html";
  140.  
  141. /* $dir is the full filesystem directory that we're looking at, eg 
  142.    /var/httpd/photos/Holidays/NewYork2003
  143.    $path is everything AFTER the 'standard' photo directory, eg
  144.    Holidays/NewYork2003 */
  145.  
  146. if ($_GET['dir'] != "") {
  147. $dir = $photo_dir . "/" . stripslashes($_GET['dir']);
  148. $path = $_GET['dir'];
  149. } else {
  150. $dir = $photo_dir;
  151. $path = "";
  152. }
  153.  
  154. if (substr($dir, -1, 1) == "/") {
  155. /* Remove the trailing slash if there is one */
  156. $dir = substr($dir, 0, -1);
  157. }
  158.  
  159. if (substr($path, -1, 1) == "/") {
  160. /* Remove the trailing slash if there is one */
  161. $path = substr($path, 0, -1);
  162. }
  163.  
  164. if ($dir != realpath($dir)) {
  165. /* Quick check to make sure our path hasn't been 
  166.  poisened, eg ../../../../etc/passwd or similar. */
  167. }
  168.  
  169. /* Initialise basic variables */
  170. $i = 1;
  171. $first = "y";
  172.  
  173. if ((is_dir($dir)) && ($dir != "") && ($_GET['image'] == "")) {
  174. if ($dh = opendir($dir)) {
  175. echo "<table border=0 width=100%>";
  176.  
  177. echo "<tr>";
  178.  
  179. while (($file = readdir($dh)) !== false) {
  180. if (($file != ".") && ($file != "..") &&
  181. !(($file == $folder_pic) && ($path != "/")) &&
  182. !(($file == $frame_pic) && ($path != "/"))) {
  183.  
  184. if (($first == "y") && ($path != "")) {
  185. /* If this is the first entry to be displayed on this
  186.  page, then put in a 'Parent' link to back up a 
  187.  level. */
  188. $first = "n";
  189. $parts = explode("/", $path);
  190.  
  191. if (count($parts) == 0) {
  192. $parent = "";
  193. } else {
  194. for ($j=0; $j<count($parts)-1; $j++) {
  195. $parent .= $parts[$j] . "/";
  196. }
  197. }
  198.  
  199. echo "<td width=25% align=center valign=top>";
  200. echo "<a href='$PHP_SELF?dir=$parent'>";
  201. echo "<img src='$photo_url/" . $folder_pic . "'>";
  202. echo "<br>Parent Directory";
  203. echo "</a><br>";
  204. echo "</td>\n";
  205. }
  206.  
  207. if (filetype($dir . "/" . $file) == "dir") {
  208. /* This is a directory, display our folder icon */
  209. echo "<td width=25% align=center valign=top>";
  210.  
  211. echo "<a href='$PHP_SELF?dir=";
  212. if ($path == "") {
  213. echo $file;
  214. } else {
  215. echo $path . "/" . $file;
  216. }
  217. echo "'>";
  218. echo "<img src='$photo_url/" . $folder_pic;
  219. echo "'><br>$file</a><br>";
  220.  
  221. echo "</td>\n";
  222.  
  223. $i++;
  224.  
  225. } elseif (eregi("jpg", $file)) {
  226. /* This is an image, display its thumbnail and a link 
  227.  to the full image. */
  228. echo "<td width=25% align=center valign=top>";
  229.  
  230. echo "<a href='$PHP_SELF?image=$path/$file'>";
  231. echo "<img src='$PHP_SELF?thumbfile=";
  232. echo $path . "/" . $file;
  233. echo "'><br>";
  234. echo eregi_replace(".jpg", "", $file) . "</a><br>";
  235.  
  236. echo "</td>\n";
  237.  
  238. $i++;
  239.  
  240. }
  241.  
  242.  
  243. if ($i == 4) {
  244. echo "</tr>\n<tr>\n";
  245. $i = 0;
  246. }
  247. }
  248. }
  249. closedir($dh);
  250. echo "</tr></table>";
  251. } else {
  252. echo "That directory can't be opened! :(<br>";
  253. echo "Maybe try checking permissions.<br>";
  254. }
  255. } else {
  256. /* Display large photo and information */
  257.  
  258. echo "<h2 align=center>";
  259. echo eregi_replace(".jpg", "", basename($photo_dir . $_GET['image']));
  260. echo "</h2>";
  261.  
  262. echo "<p align=center>";
  263.  
  264. echo "<img src='$PHP_SELF?photofile=" . stripslashes($_GET['image']) . "'>";
  265. echo "<br>";
  266.  
  267. $size = getimagesize($photo_dir . "/" . $_GET['image']);
  268. $origw = $size[0];
  269. $origh = $size[1];
  270.  
  271. echo "<b>Photo Size</b>: $origw x $origh pixels<br>";
  272.  
  273. echo "<b>Filesize</b>: ";
  274. echo format_file_size(filesize($photo_dir . "/" . $_GET['image']));
  275. echo "<br>";
  276.  
  277. echo "<b>Last Modified</b>: ";
  278. echo date("d-m-y", filemtime($photo_dir . "/" . $_GET['image']));
  279. echo "<br>";
  280.  
  281. $parts = explode("/", stripslashes($_GET['image']));
  282. if (count($parts) == 0) {
  283. $parent = "";
  284. } else {
  285. for ($j=0; $j<count($parts)-1; $j++) {
  286. $parent .= $parts[$j] . "/";
  287. }
  288. $parent = substr($parent, 0, -1);
  289. }
  290. echo "<br>";
  291. echo "<a href='$PHP_SELF?dir=$parent'>Back</a>";
  292. echo "</p>";
  293. }
  294.  
  295. include "footer.html";
  296.  
  297. function format_file_size($size) {
  298. if ($size <= 1024) {
  299. return $size . "Mb";
  300. } elseif (($size > 1024) && ($size <= 1024000)) {
  301. $size = $size / 1024;
  302. $size = round($size, 2);
  303. return $size . "Kb";
  304. } elseif (($size > 1024000) && ($size <= 1024000000)) {
  305. $size = $size / 1024000;
  306. $size = round($size, 2);
  307. return $size . "Mb";
  308. } else {
  309. $size = $size / 1024000000;
  310. $size = round($size, 2);
  311. return $size . "Gb";
  312. }
  313. }
  314.  
  315. ?>
ciszex
Problem rozwi±zany smile.gif

w zmiennych $photo_dir, $cache_dir trzeba by³o podaæ ¶cie¿ke absolutna - $_SERVER['DOCUMENT_ROOT']

Pozdrawiam
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.