ryxeo-webphotoalbum-git / data / www / index.php @ f9a46a42
Historique | Voir | Annoter | Télécharger (15,5 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 |
if (isset($_GET["video"])) $snimek=$_GET["video"]; |
50 |
$snimek = intval($snimek); |
51 |
$y=''; |
52 |
if (isset($_GET['y'])) $y=$_GET["y"]; |
53 |
$cmnt=''; |
54 |
if (isset($_GET["cmnt"])) $cmnt=$_GET["cmnt"]; |
55 |
$show_thumbs=''; |
56 |
if (isset($_GET["show_thumbs"])) $show_thumbs=$_GET["show_thumbs"]; |
57 |
|
58 |
$page = new C_www; |
59 |
//default colors
|
60 |
|
61 |
if (!is_dir("$gallery_dir/$galerie/thumbs")) { |
62 |
$galerie = ""; |
63 |
} |
64 |
|
65 |
//read interesting stuff from info.txt
|
66 |
if ($galerie) { |
67 |
readInfo("$root/$gallery_dir/$galerie/info.txt", $galerie); |
68 |
//check for restricted access
|
69 |
if ($galerielogin[$galerie]) { |
70 |
access_check($galerielogin[$galerie],$galeriepw[$galerie],$galerie); |
71 |
} |
72 |
} |
73 |
|
74 |
$page->process_comment_form();
|
75 |
|
76 |
//START RENDERING
|
77 |
|
78 |
//ryxeo
|
79 |
if($_GET['slideshow'] == 'play') |
80 |
$slideshow = true; |
81 |
else
|
82 |
$slideshow = false; |
83 |
|
84 |
if($_GET['directdownload'] == "true") { |
85 |
require_once("$root/inc/photo.class.inc.php"); |
86 |
$picture = new C_photo($file, $snimek); |
87 |
// print_r($picture);
|
88 |
header('Content-Type: ' . $picture->mime); |
89 |
header('Content-Transfer-Encoding: binary'); |
90 |
header('Expires: 0'); |
91 |
header('Cache-Control: must-revalidate'); |
92 |
header('Pragma: public'); |
93 |
header('Content-Length: ' . filesize($picture->preview)); |
94 |
ob_clean(); |
95 |
flush();
|
96 |
readfile($picture->preview); |
97 |
//print_r($picture);
|
98 |
exit;
|
99 |
} |
100 |
|
101 |
//ryxeo
|
102 |
if(isset($_GET['video'])) { |
103 |
$page->header("Vidéo"); |
104 |
} |
105 |
else {
|
106 |
$page->header("Photos"); |
107 |
} |
108 |
require("inc/header.inc.php"); |
109 |
|
110 |
// folder > tree
|
111 |
//print "<div class=\"navigation\"><a href=\"$ThisScript\">" . $scnamegallery . "</a>";
|
112 |
print "<div class=\"navigation\"><a href=\"./\">" . $scnamegallery . "</a>"; |
113 |
|
114 |
/*
|
115 |
if(isset($_GET['video'])) {
|
116 |
print "<video controls>
|
117 |
<source src=\"$gallery_dir/$galerie/webm/img-$snimek.webm\" type=\"video/webm\">
|
118 |
</video>\n";
|
119 |
print "</body>
|
120 |
</html>\n";
|
121 |
//Un exit histoire de ne pas se casser la tete avec le end (dev en cours)
|
122 |
exit;
|
123 |
}
|
124 |
*/
|
125 |
|
126 |
//############################
|
127 |
// Overall Gallery Index
|
128 |
//############################
|
129 |
if (!$galerie) { |
130 |
// finish off navigation bar
|
131 |
print "</div>\n\n<!-- listing galleries-->\n\n"; |
132 |
// I've nuked date.txt to replace it with a more generic info.txt
|
133 |
// It optionally supplies i18n name, camera model, author and date
|
134 |
// TODO: imgconv script support
|
135 |
while ($file = $adr->Read()) { |
136 |
// checking for inc is only really needed when gallery_dir == $root
|
137 |
// hopefully not many galleries will be named inc ;)
|
138 |
if (is_dir("$gallery_dir/$file") && !ereg("\.", $file) && $file!="inc") { |
139 |
// Use date file for gallery date if avaliable
|
140 |
// info.txt format described in README
|
141 |
readInfo("$root/$gallery_dir/$file/info.txt", $file); |
142 |
|
143 |
} |
144 |
} |
145 |
|
146 |
if (!isset($galeriemonth)) $galeriemonth = array(); |
147 |
if (!isset($galerieday)) $galerieday = array(); |
148 |
//sort within month depending on $sortinmonth
|
149 |
if ($sortinmonth) { |
150 |
//alphabetically
|
151 |
ksort($galeriemonth); |
152 |
reset($galeriemonth); |
153 |
} else {//by date |
154 |
arsort($galerieday); |
155 |
reset($galerieday); |
156 |
} |
157 |
|
158 |
|
159 |
$thisyear = 0; |
160 |
if (!$yearto) $yearto = date("Y"); |
161 |
for ($i = $yearto; $i >= $yearsince; $i--) { |
162 |
for ($thismonth=12; $thismonth>0; $thismonth--) { // go year by year, month by month |
163 |
// down
|
164 |
foreach ($galerieday as $foldername => $day) { //using $galerieday (for when sorted) |
165 |
if ($galeriemonth["$foldername"] == $thismonth && |
166 |
$galerieyear["$foldername"] == $i) { //such Y/M exists |
167 |
|
168 |
$galerieyearordered["$foldername"]=$galerieyear["$foldername"]; |
169 |
$galeriemonthordered["$foldername"]=$galeriemonth["$foldername"]; |
170 |
} |
171 |
} |
172 |
} |
173 |
} |
174 |
|
175 |
|
176 |
$months = array(__('January'), __('February'), __('March'), __('April'), __('May'), __('June'), __('July'), __('August'), |
177 |
__('September'), __('October'), __('November'), __('December')); |
178 |
$one_out = false; |
179 |
foreach ($galerieyearordered as $foldername => $year) { |
180 |
$one_out = true; |
181 |
if (@$thisyear!=$year) { //if the year is not equal to the current year |
182 |
//This is the first year
|
183 |
if (@$thisyear) { print " </div>\n</div>\n";}// end last year if this is |
184 |
// not the first one
|
185 |
//This is a new year
|
186 |
unset($thismonth); |
187 |
print "<div class=\"year\"><h3>$year</h3>\n"; |
188 |
print ""; |
189 |
} |
190 |
$month=$galeriemonth["$foldername"]; |
191 |
// now months
|
192 |
if (@$thismonth!=$month) { |
193 |
//first one
|
194 |
if (@$thismonth) { print " </div>\n"; } // end of last month if |
195 |
// this is not the first one
|
196 |
//new month
|
197 |
$monthindex = $month - 1; |
198 |
$monthname = $months[$monthindex]; |
199 |
print " <div class=\"month\"><h4>$monthname</h4>\n"; |
200 |
} |
201 |
//galleries within month
|
202 |
if ($galerielogin[$foldername]) { |
203 |
print " <p class=\"restricted\"><a "; |
204 |
} else {
|
205 |
print " <p><a "; |
206 |
} |
207 |
if (@$galeriename[$foldername]) { |
208 |
print " href=\"$ThisScript?galerie=$foldername\">"; |
209 |
print $galeriename[$foldername]; |
210 |
print "</a>"; |
211 |
} else {
|
212 |
print " href=\"$ThisScript?galerie=$foldername\">$foldername</a>"; |
213 |
} |
214 |
if (@$galeriedesc[$foldername]) { |
215 |
print "<span class=\"desc\">" . $galeriedesc[$foldername]; |
216 |
print "</span>\n"; |
217 |
} |
218 |
if (@$galerieauthor[$foldername]) { |
219 |
print "<span class=\"author\">by " . $galerieauthor[$foldername]; |
220 |
print "</span>\n"; |
221 |
} |
222 |
if (@$galerieday[$foldername]) { |
223 |
print "<span class=\"date\">"; |
224 |
print "$monthname " . $galerieday[$foldername]; |
225 |
print "</span>\n"; |
226 |
} |
227 |
print "</p>\n"; |
228 |
$thisyear=$year; |
229 |
$thismonth=$month; |
230 |
} |
231 |
if ($one_out) print (" </div>\n</div>\n\n"); |
232 |
|
233 |
//#############################
|
234 |
// Individual Gallery Index #
|
235 |
//#############################
|
236 |
} elseif (!$snimek) { |
237 |
|
238 |
// finish off navigation header
|
239 |
|
240 |
print "\n > "; |
241 |
if ($galeriename[$galerie]) { |
242 |
print $galeriename[$galerie]; |
243 |
} else {
|
244 |
print $galerie; |
245 |
} |
246 |
print "</div>\n\n"; |
247 |
|
248 |
//thumbnails
|
249 |
print "<p class=\"bigthumbnails\">\n"; |
250 |
$path = "$gallery_dir/$galerie/thumbs"; |
251 |
$imgfiles = new SortDir($path); |
252 |
check($galerie); // check for nasty input |
253 |
while ($file = $imgfiles->read()) { |
254 |
if (is_file("$path/$file") && eregi("^img-([0-9]+)\.(png|jpe?g)", $file, $x)) { |
255 |
|
256 |
$thumb = "$gallery_dir/$galerie/thumbs/img-${x[1]}.${x[2]}"; |
257 |
$imgsize = getimagesize("$root/$thumb"); |
258 |
//check for portraits
|
259 |
$portrait = "false"; |
260 |
$class = ""; |
261 |
if($imgsize[0]<100) { |
262 |
//portraits need a special class for styling
|
263 |
$class = "portrait"; |
264 |
} |
265 |
//check for number of comments per photo
|
266 |
if ($comments) { //there probably won't be user comments if it's off |
267 |
$NumOfComments = 0; |
268 |
if (file_exists("$gallery_dir/$galerie/comments/user_${x[1]}.txt")) { |
269 |
if ($class) $class .= " "; |
270 |
$class .= "hascomments"; |
271 |
//now let's count'em
|
272 |
$fh = fopen("$gallery_dir/$galerie/comments/user_${x[1]}.txt","r"); |
273 |
while (!feof($fh)) { |
274 |
$line = fgets($fh); |
275 |
if (eregi("commententry",$line)) $NumOfComments++; |
276 |
} |
277 |
fclose($fh); |
278 |
} |
279 |
if ($NumOfComments==1) { |
280 |
$NumOfComments = $NumOfComments . " " . __('Comment'); |
281 |
} else {
|
282 |
$NumOfComments = $NumOfComments . " " . __('Comments'); |
283 |
} |
284 |
} |
285 |
if (file_exists("$gallery_dir/$galerie/comments/${x[1]}.txt") && |
286 |
$title = file_get_contents("$gallery_dir/$galerie/comments/${x[1]}.txt")) { |
287 |
$title = ereg_replace("(\"|\')","",trim(strip_tags($title))); |
288 |
$title = ereg_replace("(.{77}).*","\\1",$title); |
289 |
} else
|
290 |
$title = "Photo ${x[1]}"; |
291 |
|
292 |
//print "<p>On est ici : $galerievideo</p>";
|
293 |
//print "<p>On teste $gallery_dir/$galerie/webm/img-${x[1]}.webm</p>";
|
294 |
if (file_exists("$gallery_dir/$galerie/webm/img-${x[1]}.webm")) { |
295 |
print " <a href=\"$ThisScript?galerie=$galerie&video=${x[1]}\""; |
296 |
} |
297 |
else {
|
298 |
print " <a href=\"$ThisScript?galerie=$galerie&photo=${x[1]}\""; |
299 |
} |
300 |
print " title=\"$title, $NumOfComments\""; |
301 |
if ($class) print " class=\"$class\""; |
302 |
print ">"; |
303 |
if (file_exists("$gallery_dir/$galerie/webm/img-${x[1]}.webm")) { |
304 |
print "<img src=\"applications-multimedia.png\" width=\"32\" height=\"32\" style=\"width: 32px; height:32px; position: fixed;\">"; |
305 |
} |
306 |
print "<img "; |
307 |
if (isset($thumbsize)) { |
308 |
print "width=\"120\" height=\"80\" "; |
309 |
} else {
|
310 |
// scale portraits to 80 height
|
311 |
if ($portrait) { |
312 |
//portrait
|
313 |
print "width=\""; |
314 |
$scaled = round($imgsize[0] / 1.5); |
315 |
print $scaled; |
316 |
print "\" height=\"${imgsize[0]}\""; |
317 |
} else {
|
318 |
//landscape
|
319 |
print $imgsize[3]; |
320 |
} |
321 |
} |
322 |
print " src=\"$thumb\" "; |
323 |
print "alt=\"photo No. ${x[1]}\" />"; |
324 |
print "</a>\n"; |
325 |
} |
326 |
} |
327 |
print "</p>\n"; |
328 |
|
329 |
//info
|
330 |
print "<div id=\"info\">\n"; |
331 |
if ($galeriedesc[$galerie]) { |
332 |
print "<p>"; |
333 |
print "<span class=\"value\">"; |
334 |
print $galeriedesc[$galerie] . "</span></p>\n"; |
335 |
} |
336 |
if ($galerieauthor[$galerie]) { |
337 |
print "<p><span class=\"key\">Author: </span>"; |
338 |
print "<span class=\"value\">"; |
339 |
print $galerieauthor[$galerie] . "</span></p>\n"; |
340 |
} |
341 |
print "</div>\n"; |
342 |
|
343 |
//and links to archived images:
|
344 |
print "\n<p class=\"archives\">\n"; |
345 |
if (file_exists("$gallery_dir/$galerie/zip/mq.zip")) { |
346 |
print "[ <a href=\"$gallery_dir/$galerie/zip/mq.zip\">" . __('zipped MQ images') . "</a> ] "; |
347 |
} |
348 |
if (file_exists("$gallery_dir/$galerie/zip/mq.tar.bz2")) { |
349 |
print "[ <a href=\"$gallery_dir/$galerie/zip/mq.tar.bz2\">" . __('MQ images tarball') . "</a> ] "; |
350 |
} |
351 |
if (file_exists("$gallery_dir/$galerie/zip/hq.zip")) { |
352 |
print "[ <a href=\"$gallery_dir/$galerie/zip/hq.zip\">" . __('zipped HQ images') . "</a> ]"; |
353 |
} |
354 |
if (file_exists("$gallery_dir/$galerie/zip/hq.tar.bz2")) { |
355 |
print "[ <a href=\"$gallery_dir/$galerie/zip/hq.tar.bz2\">" . __('HQ images tarball') . "</a> ]"; |
356 |
} |
357 |
print "</p>"; |
358 |
|
359 |
//######################
|
360 |
// Individual Image
|
361 |
//######################
|
362 |
} else { //low-res image |
363 |
|
364 |
// finish off header
|
365 |
print "\n > <a href=\"$ThisScript?galerie=$galerie\">"; |
366 |
if ($galeriename[$galerie]) { |
367 |
print $galeriename[$galerie]; |
368 |
} else {
|
369 |
print $galerie; |
370 |
} |
371 |
print "</a>\n > Photo"; |
372 |
print " $snimek</div>"; |
373 |
$path = "$gallery_dir/$galerie/thumbs"; |
374 |
|
375 |
if(isset($_GET['video'])) { |
376 |
print "<br /><video controls> |
377 |
<source src=\"$gallery_dir/$galerie/webm/img-$snimek.webm\" type=\"video/webm\">
|
378 |
</video>\n";
|
379 |
$page->user_comments($picture->number); |
380 |
$page->navigation($galerie, $snimek, null); |
381 |
|
382 |
require("inc/footer.inc.php"); |
383 |
$page->footer();
|
384 |
//Un exit histoire de ne pas se casser la tete avec le end (dev en cours)
|
385 |
exit;
|
386 |
} |
387 |
|
388 |
|
389 |
$imgfiles = new SortDir("$path"); |
390 |
check($galerie);
|
391 |
$path = "$gallery_dir/$galerie/lq"; |
392 |
$file = "$path/img-$snimek.jpg"; |
393 |
if (!file_exists($file)) { |
394 |
print __('No such image'); |
395 |
$page->footer();
|
396 |
exit;
|
397 |
} |
398 |
|
399 |
if (!$picture) { //picture may have been created if commentform submitted |
400 |
require_once("$root/inc/photo.class.inc.php"); |
401 |
$picture = new C_photo($file, $snimek); |
402 |
} |
403 |
|
404 |
// mini thumbnail roll
|
405 |
|
406 |
if ($show_thumbs) { |
407 |
print "\n<!--mini thumbnail roll-->\n<div id=\"thumbs\" class=\"navigation\" style=\"visibility: hidden\"><ul class=\"thumbs noscript\" style=\"display:none\">"; |
408 |
if (file_exists("$gallery_dir/$galerie/webm/img-$snimek.webm")) { |
409 |
print "<a id=\"minus\" href=\"$ThisScript?galerie=$galerie&video=$snimek"; |
410 |
} |
411 |
else {
|
412 |
print "<a id=\"minus\" href=\"$ThisScript?galerie=$galerie&photo=$snimek"; |
413 |
} |
414 |
print "\">"; |
415 |
print "</a>\n"; |
416 |
print " : \n"; |
417 |
while ($thumbfile = $imgfiles->read()) { |
418 |
if ( eregi("^img-([0-9]+)\.(png|jpe?g)", |
419 |
$thumbfile, $x)) { |
420 |
$thumb = "$gallery_dir/$galerie/thumbs/img-${x[1]}.${x[2]}"; |
421 |
print " <li><a class=\"thumb\" href=\"$ThisScript?galerie=$galerie&photo=${x[1]}&directdownload=true\""; |
422 |
print " name=\"" . get_photo_title($galerie, $x[1]) . "\" title=\"" . get_photo_title($galerie, $x[1]) . "\">"; |
423 |
print "</a></li> \n"; |
424 |
} |
425 |
} |
426 |
if (file_exists("$gallery_dir/$galerie/zip/hq.zip")) { |
427 |
print "<a id=\"zip\" href=\"$gallery_dir/$galerie/zip/hq.zip\">"; |
428 |
print "zip<span /></a>"; |
429 |
} |
430 |
if (file_exists("$gallery_dir/$galerie/zip/hq.tar.bz2")) { |
431 |
print "<a id=\"zip\" href=\"$gallery_dir/$galerie/zip/hq.tar.bz2\">"; |
432 |
print "zip<span /></a>"; |
433 |
} |
434 |
print "</ul></div>\n"; |
435 |
} else {
|
436 |
// show the popup button
|
437 |
print "\n<!--mini thumbnail popup-->\n<div class=\"thumbroll\">"; |
438 |
print "<a id=\"plus\" href=\"$ThisScript?galerie=$galerie&photo=$snimek"; |
439 |
print "&show_thumbs=yes\""; |
440 |
print " title=\"" . __('Show Thumbnail Navigation') . "\">"; |
441 |
print "</a>\n"; |
442 |
print "</div>\n"; |
443 |
} |
444 |
|
445 |
/* main image + thumbnail navigation (prev/next) */
|
446 |
|
447 |
if($slideshow) { |
448 |
print " |
449 |
<div id=\"gallery\" class=\"content\">
|
450 |
<div class=\"slideshow-container\">
|
451 |
<div id=\"loading\" class=\"loader\"></div>
|
452 |
<div id=\"slideshow\" class=\"slideshow\" style=\"height:480;\"></div>
|
453 |
</div>
|
454 |
</div>\n";
|
455 |
} |
456 |
else {
|
457 |
$picture->renderPreview();
|
458 |
$page->navigation($galerie, $snimek, "prev"); |
459 |
$page->navigation($galerie, $snimek, "next"); |
460 |
} |
461 |
print "</div>\n"; //end image div |
462 |
|
463 |
|
464 |
if(!$slideshow) { |
465 |
if (function_exists(exif_read_data)) require("$root/inc/exif.inc.php"); |
466 |
/* Image comment
|
467 |
really poor naming here, it is caption.
|
468 |
*/
|
469 |
$picture->renderCaption();
|
470 |
|
471 |
|
472 |
//show page counter
|
473 |
if ($log_access) { |
474 |
$picture->renderCounter();
|
475 |
} |
476 |
|
477 |
$picture->renderBigSize();
|
478 |
|
479 |
$page->user_comments($picture->number); |
480 |
$page->navigation($galerie, $snimek, null); |
481 |
} |
482 |
} |
483 |
|
484 |
require("inc/footer.inc.php"); |
485 |
|
486 |
|
487 |
if($slideshow) { |
488 |
print " |
489 |
<div id=\"controls\" class=\"controls\"></div>
|
490 |
<script type=\"text/javascript\">
|
491 |
$(document).ready(function() {
|
492 |
$('#thumbs').galleriffic({
|
493 |
autoStart: true,
|
494 |
imageContainerSel: '#slideshow',
|
495 |
renderNavControls: false,
|
496 |
renderSSControls: false
|
497 |
});
|
498 |
});
|
499 |
</script>\n";
|
500 |
} |
501 |
|
502 |
$page->footer();
|
503 |
?>
|