Projet

Général

Profil

Paste
Statistiques
| Branche: | Révision:

ryxeo-webphotoalbum-git / data / www / index.php @ eee84392

Historique | Voir | Annoter | Télécharger (14,2 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&nbsp;" . $galerieauthor[$foldername];
201
      print "</span>\n";
202
    }
203
    if (@$galerieday[$foldername]) {
204
      print "<span class=\"date\">";
205
      print "$monthname&nbsp;" . $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 &gt; ";
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
       if($galerievideo) {
274
         print "   <a href=\"$ThisScript?galerie=$galerie&amp;video=${x[1]}\"";
275
       }
276
       else {
277
         print "   <a href=\"$ThisScript?galerie=$galerie&amp;photo=${x[1]}\"";
278
       }
279
       print " title=\"$title, $NumOfComments\"";
280
       if ($class) print " class=\"$class\"";
281
       print ">";
282
       print "<img ";
283
       if (isset($thumbsize)) {
284
         print "width=\"120\" height=\"80\" ";
285
       } else {
286
         // scale portraits to 80 height
287
         if ($portrait) {
288
           //portrait
289
           print "width=\"";
290
           $scaled = round($imgsize[0] / 1.5);
291
           print $scaled;
292
           print "\" height=\"${imgsize[0]}\"";
293
         } else {
294
           //landscape
295
           print $imgsize[3]; 
296
         }
297
       }
298
       print " src=\"$thumb\" ";
299
       print "alt=\"photo No. ${x[1]}\" />";
300
       print "</a>\n";
301
     }
302
   }
303
   print "</p>\n";
304

    
305
   //info
306
   print "<div id=\"info\">\n";
307
   if ($galeriedesc[$galerie]) {
308
     print "<p>";
309
     print "<span class=\"value\">";
310
     print $galeriedesc[$galerie] . "</span></p>\n";
311
   }
312
   if ($galerieauthor[$galerie]) {
313
     print "<p><span class=\"key\">Author: </span>";
314
     print "<span class=\"value\">";
315
     print $galerieauthor[$galerie] . "</span></p>\n";
316
   }
317
   print "</div>\n";
318

    
319
   //and links to archived images:
320
   print "\n<p class=\"archives\">\n";
321
   if (file_exists("$gallery_dir/$galerie/zip/mq.zip")) {
322
     print "[ <a href=\"$gallery_dir/$galerie/zip/mq.zip\">" . __('zipped MQ images') . "</a> ] ";
323
   }
324
   if (file_exists("$gallery_dir/$galerie/zip/mq.tar.bz2")) {
325
     print "[ <a href=\"$gallery_dir/$galerie/zip/mq.tar.bz2\">" . __('MQ images tarball') . "</a> ] ";
326
   }
327
   if (file_exists("$gallery_dir/$galerie/zip/hq.zip")) {
328
     print "[ <a href=\"$gallery_dir/$galerie/zip/hq.zip\">" . __('zipped HQ images') . "</a> ]";
329
   }
330
   if (file_exists("$gallery_dir/$galerie/zip/hq.tar.bz2")) {
331
     print "[ <a href=\"$gallery_dir/$galerie/zip/hq.tar.bz2\">" . __('HQ images tarball') . "</a> ]";
332
   }
333
   print "</p>";
334

    
335
   //######################
336
   //         Individual Image
337
   //######################
338
   } else { //low-res image
339
  // finish off header
340
  print "\n &gt; <a href=\"$ThisScript?galerie=$galerie\">";
341
  if ($galeriename[$galerie]) {
342
    print $galeriename[$galerie];
343
  } else {
344
    print $galerie;
345
  }
346
  print "</a>\n &gt; Photo";
347
  print " $snimek</div>";
348
  $path = "$gallery_dir/$galerie/thumbs";
349
  $imgfiles = new SortDir("$path");
350
  check($galerie);
351
  $path = "$gallery_dir/$galerie/lq";
352
  $file = "$path/img-$snimek.jpg";
353
  if (!file_exists($file)) {
354
    print __('No such image');
355
    $page->footer();
356
    exit;
357
  }
358
         
359
  if (!$picture) { //picture may have been created if commentform submitted
360
    require_once("$root/inc/photo.class.inc.php");
361
    $picture = new C_photo($file, $snimek);
362
  }
363

    
364
  // mini thumbnail roll
365

    
366
  if ($show_thumbs) {
367
    print "\n<!--mini thumbnail roll-->\n<div id=\"thumbs\" class=\"navigation\" style=\"visibility: hidden\"><ul class=\"thumbs noscript\" style=\"display:none\">";
368
    if($galerievideo) {
369
      print "<a id=\"minus\" href=\"$ThisScript?galerie=$galerie&amp;video=$snimek";
370
    }
371
    else {
372
      print "<a id=\"minus\" href=\"$ThisScript?galerie=$galerie&amp;photo=$snimek";
373
    }
374
    print "\">";
375
    print "</a>\n";
376
    print " : \n";
377
    while ($thumbfile = $imgfiles->read()) {
378
      if ( eregi("^img-([0-9]+)\.(png|jpe?g)",
379
                 $thumbfile, $x)) {
380
        $thumb = "$gallery_dir/$galerie/thumbs/img-${x[1]}.${x[2]}";
381
        print "   <li><a class=\"thumb\" href=\"$ThisScript?galerie=$galerie&amp;photo=${x[1]}&amp;directdownload=true\"";
382
        print " name=\"" . get_photo_title($galerie, $x[1]) . "\" title=\"" . get_photo_title($galerie, $x[1]) . "\">";
383
        print "</a></li> \n";
384
      }
385
    }
386
    if (file_exists("$gallery_dir/$galerie/zip/hq.zip")) {
387
      print "<a id=\"zip\" href=\"$gallery_dir/$galerie/zip/hq.zip\">";
388
      print "zip<span /></a>";
389
    }
390
    if (file_exists("$gallery_dir/$galerie/zip/hq.tar.bz2")) {
391
      print "<a id=\"zip\" href=\"$gallery_dir/$galerie/zip/hq.tar.bz2\">";
392
      print "zip<span /></a>";
393
    }
394
    print "</ul></div>\n";
395
  } else {
396
    // show the popup button
397
    print "\n<!--mini thumbnail popup-->\n<div class=\"thumbroll\">";
398
    print "<a id=\"plus\" href=\"$ThisScript?galerie=$galerie&amp;photo=$snimek";
399
    print "&amp;show_thumbs=yes\"";
400
    print " title=\"" . __('Show Thumbnail Navigation') . "\">";
401
    print "</a>\n";
402
    print "</div>\n";
403
  }
404

    
405
  /* main image + thumbnail navigation (prev/next) */
406

    
407
  if($slideshow) {
408
    print "
409
<div id=\"gallery\" class=\"content\">
410
  <div class=\"slideshow-container\">
411
   <div id=\"loading\" class=\"loader\"></div>
412
   <div id=\"slideshow\" class=\"slideshow\" style=\"height:480;\"></div>
413
  </div>
414
</div>\n";
415
  }
416
  else {
417
    $picture->renderPreview();
418
    $page->navigation($galerie, $snimek, "prev");
419
    $page->navigation($galerie, $snimek, "next");
420
  }
421
  print "</div>\n"; //end image div
422

    
423

    
424
  if(!$slideshow) {
425
    if (function_exists(exif_read_data)) require("$root/inc/exif.inc.php"); 
426
    /* Image comment
427
       really poor naming here, it is caption.
428
    */
429
    $picture->renderCaption();
430
     
431
     
432
    //show page counter
433
    if ($log_access) {
434
      $picture->renderCounter();
435
    }
436
     
437
    $picture->renderBigSize();
438
     
439
    $page->user_comments($picture->number);
440
    $page->navigation($galerie, $snimek, null);
441
  }
442
 }
443

    
444
require("inc/footer.inc.php");
445

    
446

    
447
if($slideshow) {
448
  print "
449
<div id=\"controls\" class=\"controls\"></div>
450
<script type=\"text/javascript\">
451
$(document).ready(function() {
452
  $('#thumbs').galleriffic({
453
     autoStart:              true,
454
     imageContainerSel:      '#slideshow',
455
     renderNavControls:      false,
456
     renderSSControls:       false
457
  });
458
});
459
</script>\n";
460
 }
461

    
462
$page->footer();
463
?>
Redmine Appliance - Powered by TurnKey Linux