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