ryxeo-webphotoalbum-git / data / www / index.php @ 6c207150
Historique | Voir | Annoter | Télécharger (14 ko)
1 |
<?php
|
---|---|
2 |
/** Album Photo -- RyXéo SARL
|
3 |
* @see https://redmine.ryxeo.com/projects/
|
4 |
* @author 2004 Jakub 'jimmac' Steiner
|
5 |
* @author 2012 Eric Seigne <eric.seigne@ryxeo.com>
|
6 |
* @see The GNU Public License (GNU/GPL) v2
|
7 |
*
|
8 |
* This program is free software; you can redistribute it and/or modify
|
9 |
* it under the terms of the GNU General Public License as published by
|
10 |
* the Free Software Foundation; either version 2 of the License, or
|
11 |
* (at your option) any later version.
|
12 |
*
|
13 |
* This program is distributed in the hope that it will be useful, but
|
14 |
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
15 |
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
16 |
* for more details.
|
17 |
*
|
18 |
* You should have received a copy of the GNU General Public License along
|
19 |
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
20 |
*/
|
21 |
|
22 |
// uncomment this to check for uninitialized variables etc.:
|
23 |
// error_reporting (E_ALL);
|
24 |
|
25 |
//language support
|
26 |
require_once ("lib/lib.l10n.php"); |
27 |
require_once("inc/config.inc.php"); |
28 |
require_once("inc/www.class.inc.php"); |
29 |
require_once("inc/funkce.inc.php"); |
30 |
//session_name("navstevnik");
|
31 |
//session_register("page");
|
32 |
|
33 |
//set the language translation
|
34 |
l10n::set("$root/l10n/".$sclang."/main.lang"); |
35 |
l10n::set("$root/l10n/".$sclang."/date.lang"); |
36 |
|
37 |
// always get sorted directory entries
|
38 |
$adr = new SortDir("$gallery_dir"); |
39 |
|
40 |
// get variables passed in from the URL:
|
41 |
$galerie=''; |
42 |
if (isset($_GET['galerie'])) $galerie=$_GET["galerie"]; |
43 |
if (isset($_GET['gallery'])) $galerie=$_GET["gallery"]; |
44 |
$galerie = preg_replace('/\//', '', $galerie); |
45 |
if (isset($_GET["thumbsize"])) $thumbsize=$_GET["thumbsize"]; |
46 |
$snimek = 0; |
47 |
if (isset($_GET["snimek"])) $snimek=$_GET["snimek"]; |
48 |
if (isset($_GET["photo"])) $snimek=$_GET["photo"]; |
49 |
$snimek = intval($snimek); |
50 |
$y=''; |
51 |
if (isset($_GET['y'])) $y=$_GET["y"]; |
52 |
$cmnt=''; |
53 |
if (isset($_GET["cmnt"])) $cmnt=$_GET["cmnt"]; |
54 |
$show_thumbs=''; |
55 |
if (isset($_GET["show_thumbs"])) $show_thumbs=$_GET["show_thumbs"]; |
56 |
|
57 |
$page = new C_www; |
58 |
//default colors
|
59 |
|
60 |
if (!is_dir("$gallery_dir/$galerie/thumbs")) { |
61 |
$galerie = ""; |
62 |
} |
63 |
|
64 |
//read interesting stuff from info.txt
|
65 |
if ($galerie) { |
66 |
readInfo("$root/$gallery_dir/$galerie/info.txt", $galerie); |
67 |
//check for restricted access
|
68 |
if ($galerielogin[$galerie]) { |
69 |
access_check($galerielogin[$galerie],$galeriepw[$galerie],$galerie); |
70 |
} |
71 |
} |
72 |
|
73 |
$page->process_comment_form();
|
74 |
|
75 |
//START RENDERING
|
76 |
|
77 |
//ryxeo
|
78 |
if($_GET['slideshow'] == 'play') |
79 |
$slideshow = true; |
80 |
else
|
81 |
$slideshow = false; |
82 |
|
83 |
if($_GET['directdownload'] == "true") { |
84 |
require_once("$root/inc/photo.class.inc.php"); |
85 |
$picture = new C_photo($file, $snimek); |
86 |
// print_r($picture);
|
87 |
header('Content-Type: ' . $picture->mime); |
88 |
header('Content-Transfer-Encoding: binary'); |
89 |
header('Expires: 0'); |
90 |
header('Cache-Control: must-revalidate'); |
91 |
header('Pragma: public'); |
92 |
header('Content-Length: ' . filesize($picture->preview)); |
93 |
ob_clean(); |
94 |
flush();
|
95 |
readfile($picture->preview); |
96 |
//print_r($picture);
|
97 |
exit;
|
98 |
} |
99 |
|
100 |
$page->header("Photos"); |
101 |
require("inc/header.inc.php"); |
102 |
|
103 |
// folder > tree
|
104 |
//print "<div class=\"navigation\"><a href=\"$ThisScript\">" . $scnamegallery . "</a>";
|
105 |
print "<div class=\"navigation\"><a href=\"./\">" . $scnamegallery . "</a>"; |
106 |
|
107 |
//############################
|
108 |
// Overall Gallery Index
|
109 |
//############################
|
110 |
if (!$galerie) { |
111 |
// finish off navigation bar
|
112 |
print "</div>\n\n<!-- listing galleries-->\n\n"; |
113 |
// I've nuked date.txt to replace it with a more generic info.txt
|
114 |
// It optionally supplies i18n name, camera model, author and date
|
115 |
// TODO: imgconv script support
|
116 |
while ($file = $adr->Read()) { |
117 |
// checking for inc is only really needed when gallery_dir == $root
|
118 |
// hopefully not many galleries will be named inc ;)
|
119 |
if (is_dir("$gallery_dir/$file") && !ereg("\.", $file) && $file!="inc") { |
120 |
// Use date file for gallery date if avaliable
|
121 |
// info.txt format described in README
|
122 |
readInfo("$root/$gallery_dir/$file/info.txt", $file); |
123 |
|
124 |
} |
125 |
} |
126 |
|
127 |
if (!isset($galeriemonth)) $galeriemonth = array(); |
128 |
if (!isset($galerieday)) $galerieday = array(); |
129 |
//sort within month depending on $sortinmonth
|
130 |
if ($sortinmonth) { |
131 |
//alphabetically
|
132 |
ksort($galeriemonth); |
133 |
reset($galeriemonth); |
134 |
} else {//by date |
135 |
arsort($galerieday); |
136 |
reset($galerieday); |
137 |
} |
138 |
|
139 |
|
140 |
$thisyear = 0; |
141 |
if (!$yearto) $yearto = date("Y"); |
142 |
for ($i = $yearto; $i >= $yearsince; $i--) { |
143 |
for ($thismonth=12; $thismonth>0; $thismonth--) { // go year by year, month by month |
144 |
// down
|
145 |
foreach ($galerieday as $foldername => $day) { //using $galerieday (for when sorted) |
146 |
if ($galeriemonth["$foldername"] == $thismonth && |
147 |
$galerieyear["$foldername"] == $i) { //such Y/M exists |
148 |
|
149 |
$galerieyearordered["$foldername"]=$galerieyear["$foldername"]; |
150 |
$galeriemonthordered["$foldername"]=$galeriemonth["$foldername"]; |
151 |
} |
152 |
} |
153 |
} |
154 |
} |
155 |
|
156 |
|
157 |
$months = array(__('January'), __('February'), __('March'), __('April'), __('May'), __('June'), __('July'), __('August'), |
158 |
__('September'), __('October'), __('November'), __('December')); |
159 |
$one_out = false; |
160 |
foreach ($galerieyearordered as $foldername => $year) { |
161 |
$one_out = true; |
162 |
if (@$thisyear!=$year) { //if the year is not equal to the current year |
163 |
//This is the first year
|
164 |
if (@$thisyear) { print " </div>\n</div>\n";}// end last year if this is |
165 |
// not the first one
|
166 |
//This is a new year
|
167 |
unset($thismonth); |
168 |
print "<div class=\"year\"><h3>$year</h3>\n"; |
169 |
print ""; |
170 |
} |
171 |
$month=$galeriemonth["$foldername"]; |
172 |
// now months
|
173 |
if (@$thismonth!=$month) { |
174 |
//first one
|
175 |
if (@$thismonth) { print " </div>\n"; } // end of last month if |
176 |
// this is not the first one
|
177 |
//new month
|
178 |
$monthindex = $month - 1; |
179 |
$monthname = $months[$monthindex]; |
180 |
print " <div class=\"month\"><h4>$monthname</h4>\n"; |
181 |
} |
182 |
//galleries within month
|
183 |
if ($galerielogin[$foldername]) { |
184 |
print " <p class=\"restricted\"><a "; |
185 |
} else {
|
186 |
print " <p><a "; |
187 |
} |
188 |
if (@$galeriename[$foldername]) { |
189 |
print " href=\"$ThisScript?galerie=$foldername\">"; |
190 |
print $galeriename[$foldername]; |
191 |
print "</a>"; |
192 |
} else {
|
193 |
print " href=\"$ThisScript?galerie=$foldername\">$foldername</a>"; |
194 |
} |
195 |
if (@$galeriedesc[$foldername]) { |
196 |
print "<span class=\"desc\">" . $galeriedesc[$foldername]; |
197 |
print "</span>\n"; |
198 |
} |
199 |
if (@$galerieauthor[$foldername]) { |
200 |
print "<span class=\"author\">by " . $galerieauthor[$foldername]; |
201 |
print "</span>\n"; |
202 |
} |
203 |
if (@$galerieday[$foldername]) { |
204 |
print "<span class=\"date\">"; |
205 |
print "$monthname " . $galerieday[$foldername]; |
206 |
print "</span>\n"; |
207 |
} |
208 |
print "</p>\n"; |
209 |
$thisyear=$year; |
210 |
$thismonth=$month; |
211 |
} |
212 |
if ($one_out) print (" </div>\n</div>\n\n"); |
213 |
|
214 |
//#############################
|
215 |
// Individual Gallery Index #
|
216 |
//#############################
|
217 |
} elseif (!$snimek) { |
218 |
|
219 |
// finish off navigation header
|
220 |
|
221 |
print "\n > "; |
222 |
if ($galeriename[$galerie]) { |
223 |
print $galeriename[$galerie]; |
224 |
} else {
|
225 |
print $galerie; |
226 |
} |
227 |
print "</div>\n\n"; |
228 |
|
229 |
//thumbnails
|
230 |
print "<p class=\"bigthumbnails\">\n"; |
231 |
$path = "$gallery_dir/$galerie/thumbs"; |
232 |
$imgfiles = new SortDir($path); |
233 |
check($galerie); // check for nasty input |
234 |
while ($file = $imgfiles->read()) { |
235 |
if (is_file("$path/$file") && eregi("^img-([0-9]+)\.(png|jpe?g)", $file, $x)) { |
236 |
|
237 |
$thumb = "$gallery_dir/$galerie/thumbs/img-${x[1]}.${x[2]}"; |
238 |
$imgsize = getimagesize("$root/$thumb"); |
239 |
//check for portraits
|
240 |
$portrait = "false"; |
241 |
$class = ""; |
242 |
if($imgsize[0]<100) { |
243 |
//portraits need a special class for styling
|
244 |
$class = "portrait"; |
245 |
} |
246 |
//check for number of comments per photo
|
247 |
if ($comments) { //there probably won't be user comments if it's off |
248 |
$NumOfComments = 0; |
249 |
if (file_exists("$gallery_dir/$galerie/comments/user_${x[1]}.txt")) { |
250 |
if ($class) $class .= " "; |
251 |
$class .= "hascomments"; |
252 |
//now let's count'em
|
253 |
$fh = fopen("$gallery_dir/$galerie/comments/user_${x[1]}.txt","r"); |
254 |
while (!feof($fh)) { |
255 |
$line = fgets($fh); |
256 |
if (eregi("commententry",$line)) $NumOfComments++; |
257 |
} |
258 |
fclose($fh); |
259 |
} |
260 |
if ($NumOfComments==1) { |
261 |
$NumOfComments = $NumOfComments . " " . __('Comment'); |
262 |
} else {
|
263 |
$NumOfComments = $NumOfComments . " " . __('Comments'); |
264 |
} |
265 |
} |
266 |
if (file_exists("$gallery_dir/$galerie/comments/${x[1]}.txt") && |
267 |
$title = file_get_contents("$gallery_dir/$galerie/comments/${x[1]}.txt")) { |
268 |
$title = ereg_replace("(\"|\')","",trim(strip_tags($title))); |
269 |
$title = ereg_replace("(.{77}).*","\\1",$title); |
270 |
} else
|
271 |
$title = "Photo ${x[1]}"; |
272 |
|
273 |
print " <a href=\"$ThisScript?galerie=$galerie&photo=${x[1]}\""; |
274 |
print " title=\"$title, $NumOfComments\""; |
275 |
if ($class) print " class=\"$class\""; |
276 |
print ">"; |
277 |
print "<img "; |
278 |
if (isset($thumbsize)) { |
279 |
print "width=\"120\" height=\"80\" "; |
280 |
} else {
|
281 |
// scale portraits to 80 height
|
282 |
if ($portrait) { |
283 |
//portrait
|
284 |
print "width=\""; |
285 |
$scaled = round($imgsize[0] / 1.5); |
286 |
print $scaled; |
287 |
print "\" height=\"${imgsize[0]}\""; |
288 |
} else {
|
289 |
//landscape
|
290 |
print $imgsize[3]; |
291 |
} |
292 |
} |
293 |
print " src=\"$thumb\" "; |
294 |
print "alt=\"photo No. ${x[1]}\" />"; |
295 |
print "</a>\n"; |
296 |
} |
297 |
} |
298 |
print "</p>\n"; |
299 |
|
300 |
//info
|
301 |
print "<div id=\"info\">\n"; |
302 |
if ($galeriedesc[$galerie]) { |
303 |
print "<p>"; |
304 |
print "<span class=\"value\">"; |
305 |
print $galeriedesc[$galerie] . "</span></p>\n"; |
306 |
} |
307 |
if ($galerieauthor[$galerie]) { |
308 |
print "<p><span class=\"key\">Author: </span>"; |
309 |
print "<span class=\"value\">"; |
310 |
print $galerieauthor[$galerie] . "</span></p>\n"; |
311 |
} |
312 |
print "</div>\n"; |
313 |
|
314 |
//and links to archived images:
|
315 |
print "\n<p class=\"archives\">\n"; |
316 |
if (file_exists("$gallery_dir/$galerie/zip/mq.zip")) { |
317 |
print "[ <a href=\"$gallery_dir/$galerie/zip/mq.zip\">" . __('zipped MQ images') . "</a> ] "; |
318 |
} |
319 |
if (file_exists("$gallery_dir/$galerie/zip/mq.tar.bz2")) { |
320 |
print "[ <a href=\"$gallery_dir/$galerie/zip/mq.tar.bz2\">" . __('MQ images tarball') . "</a> ] "; |
321 |
} |
322 |
if (file_exists("$gallery_dir/$galerie/zip/hq.zip")) { |
323 |
print "[ <a href=\"$gallery_dir/$galerie/zip/hq.zip\">" . __('zipped HQ images') . "</a> ]"; |
324 |
} |
325 |
if (file_exists("$gallery_dir/$galerie/zip/hq.tar.bz2")) { |
326 |
print "[ <a href=\"$gallery_dir/$galerie/zip/hq.tar.bz2\">" . __('HQ images tarball') . "</a> ]"; |
327 |
} |
328 |
print "</p>"; |
329 |
|
330 |
//######################
|
331 |
// Individual Image
|
332 |
//######################
|
333 |
} else { //low-res image |
334 |
// finish off header
|
335 |
print "\n > <a href=\"$ThisScript?galerie=$galerie\">"; |
336 |
if ($galeriename[$galerie]) { |
337 |
print $galeriename[$galerie]; |
338 |
} else {
|
339 |
print $galerie; |
340 |
} |
341 |
print "</a>\n > Photo"; |
342 |
print " $snimek</div>"; |
343 |
$path = "$gallery_dir/$galerie/thumbs"; |
344 |
$imgfiles = new SortDir("$path"); |
345 |
check($galerie);
|
346 |
$path = "$gallery_dir/$galerie/lq"; |
347 |
$file = "$path/img-$snimek.jpg"; |
348 |
if (!file_exists($file)) { |
349 |
print __('No such image'); |
350 |
$page->footer();
|
351 |
exit;
|
352 |
} |
353 |
|
354 |
if (!$picture) { //picture may have been created if commentform submitted |
355 |
require_once("$root/inc/photo.class.inc.php"); |
356 |
$picture = new C_photo($file, $snimek); |
357 |
} |
358 |
|
359 |
// mini thumbnail roll
|
360 |
|
361 |
if ($show_thumbs) { |
362 |
print "\n<!--mini thumbnail roll-->\n<div id=\"thumbs\" class=\"navigation\" style=\"visibility: hidden\"><ul class=\"thumbs noscript\" style=\"display:none\">"; |
363 |
print "<a id=\"minus\" href=\"$ThisScript?galerie=$galerie&photo=$snimek"; |
364 |
print "\">"; |
365 |
print "</a>\n"; |
366 |
print " : \n"; |
367 |
while ($thumbfile = $imgfiles->read()) { |
368 |
if ( eregi("^img-([0-9]+)\.(png|jpe?g)", |
369 |
$thumbfile, $x)) { |
370 |
$thumb = "$gallery_dir/$galerie/thumbs/img-${x[1]}.${x[2]}"; |
371 |
print " <li><a class=\"thumb\" href=\"$ThisScript?galerie=$galerie&photo=${x[1]}&directdownload=true\""; |
372 |
print " name=\"" . get_photo_title($galerie, $x[1]) . "\" title=\"" . get_photo_title($galerie, $x[1]) . "\">"; |
373 |
print "</a></li> \n"; |
374 |
} |
375 |
} |
376 |
if (file_exists("$gallery_dir/$galerie/zip/hq.zip")) { |
377 |
print "<a id=\"zip\" href=\"$gallery_dir/$galerie/zip/hq.zip\">"; |
378 |
print "zip<span /></a>"; |
379 |
} |
380 |
if (file_exists("$gallery_dir/$galerie/zip/hq.tar.bz2")) { |
381 |
print "<a id=\"zip\" href=\"$gallery_dir/$galerie/zip/hq.tar.bz2\">"; |
382 |
print "zip<span /></a>"; |
383 |
} |
384 |
print "</ul></div>\n"; |
385 |
} else {
|
386 |
// show the popup button
|
387 |
print "\n<!--mini thumbnail popup-->\n<div class=\"thumbroll\">"; |
388 |
print "<a id=\"plus\" href=\"$ThisScript?galerie=$galerie&photo=$snimek"; |
389 |
print "&show_thumbs=yes\""; |
390 |
print " title=\"" . __('Show Thumbnail Navigation') . "\">"; |
391 |
print "</a>\n"; |
392 |
print "</div>\n"; |
393 |
} |
394 |
|
395 |
/* main image + thumbnail navigation (prev/next) */
|
396 |
|
397 |
if($slideshow) { |
398 |
print " |
399 |
<div id=\"gallery\" class=\"content\">
|
400 |
<div class=\"slideshow-container\">
|
401 |
<div id=\"loading\" class=\"loader\"></div>
|
402 |
<div id=\"slideshow\" class=\"slideshow\" style=\"height:480;\"></div>
|
403 |
</div>
|
404 |
</div>\n";
|
405 |
} |
406 |
else {
|
407 |
$picture->renderPreview();
|
408 |
$page->navigation($galerie, $snimek, "prev"); |
409 |
$page->navigation($galerie, $snimek, "next"); |
410 |
} |
411 |
print "</div>\n"; //end image div |
412 |
|
413 |
|
414 |
if(!$slideshow) { |
415 |
if (function_exists(exif_read_data)) require("$root/inc/exif.inc.php"); |
416 |
/* Image comment
|
417 |
really poor naming here, it is caption.
|
418 |
*/
|
419 |
$picture->renderCaption();
|
420 |
|
421 |
|
422 |
//show page counter
|
423 |
if ($log_access) { |
424 |
$picture->renderCounter();
|
425 |
} |
426 |
|
427 |
$picture->renderBigSize();
|
428 |
|
429 |
$page->user_comments($picture->number); |
430 |
$page->navigation($galerie, $snimek, null); |
431 |
} |
432 |
} |
433 |
|
434 |
require("inc/footer.inc.php"); |
435 |
|
436 |
|
437 |
if($slideshow) { |
438 |
print " |
439 |
<div id=\"controls\" class=\"controls\"></div>
|
440 |
<script type=\"text/javascript\">
|
441 |
$(document).ready(function() {
|
442 |
$('#thumbs').galleriffic({
|
443 |
autoStart: true,
|
444 |
imageContainerSel: '#slideshow',
|
445 |
renderNavControls: false,
|
446 |
renderSSControls: false
|
447 |
});
|
448 |
});
|
449 |
</script>\n";
|
450 |
} |
451 |
|
452 |
$page->footer();
|
453 |
?>
|