Projet

Général

Profil

Paste
Statistiques
| Branche: | Révision:

ryxeo-webphotoalbum-git / data / www / index.php @ 278d2613

Historique | Voir | Annoter | Télécharger (15,1 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&nbsp;" . $galerieauthor[$foldername];
220
      print "</span>\n";
221
    }
222
    if (@$galerieday[$foldername]) {
223
      print "<span class=\"date\">";
224
      print "$monthname&nbsp;" . $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 &gt; ";
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

    
294
       if($galerievideo) {
295
         print "   <a href=\"$ThisScript?galerie=$galerie&amp;video=${x[1]}\"";
296
       }
297
       else {
298
         print "   <a href=\"$ThisScript?galerie=$galerie&amp;photo=${x[1]}\"";
299
       }
300
       print " title=\"$title, $NumOfComments\"";
301
       if ($class) print " class=\"$class\"";
302
       print ">";
303
       print "<img ";
304
       if (isset($thumbsize)) {
305
         print "width=\"120\" height=\"80\" ";
306
       } else {
307
         // scale portraits to 80 height
308
         if ($portrait) {
309
           //portrait
310
           print "width=\"";
311
           $scaled = round($imgsize[0] / 1.5);
312
           print $scaled;
313
           print "\" height=\"${imgsize[0]}\"";
314
         } else {
315
           //landscape
316
           print $imgsize[3]; 
317
         }
318
       }
319
       print " src=\"$thumb\" ";
320
       print "alt=\"photo No. ${x[1]}\" />";
321
       print "</a>\n";
322
     }
323
   }
324
   print "</p>\n";
325

    
326
   //info
327
   print "<div id=\"info\">\n";
328
   if ($galeriedesc[$galerie]) {
329
     print "<p>";
330
     print "<span class=\"value\">";
331
     print $galeriedesc[$galerie] . "</span></p>\n";
332
   }
333
   if ($galerieauthor[$galerie]) {
334
     print "<p><span class=\"key\">Author: </span>";
335
     print "<span class=\"value\">";
336
     print $galerieauthor[$galerie] . "</span></p>\n";
337
   }
338
   print "</div>\n";
339

    
340
   //and links to archived images:
341
   print "\n<p class=\"archives\">\n";
342
   if (file_exists("$gallery_dir/$galerie/zip/mq.zip")) {
343
     print "[ <a href=\"$gallery_dir/$galerie/zip/mq.zip\">" . __('zipped MQ images') . "</a> ] ";
344
   }
345
   if (file_exists("$gallery_dir/$galerie/zip/mq.tar.bz2")) {
346
     print "[ <a href=\"$gallery_dir/$galerie/zip/mq.tar.bz2\">" . __('MQ images tarball') . "</a> ] ";
347
   }
348
   if (file_exists("$gallery_dir/$galerie/zip/hq.zip")) {
349
     print "[ <a href=\"$gallery_dir/$galerie/zip/hq.zip\">" . __('zipped HQ images') . "</a> ]";
350
   }
351
   if (file_exists("$gallery_dir/$galerie/zip/hq.tar.bz2")) {
352
     print "[ <a href=\"$gallery_dir/$galerie/zip/hq.tar.bz2\">" . __('HQ images tarball') . "</a> ]";
353
   }
354
   print "</p>";
355

    
356
   //######################
357
   //         Individual Image
358
   //######################
359
   } else { //low-res image
360

    
361
  // finish off header
362
  print "\n &gt; <a href=\"$ThisScript?galerie=$galerie\">";
363
  if ($galeriename[$galerie]) {
364
    print $galeriename[$galerie];
365
  } else {
366
    print $galerie;
367
  }
368
  print "</a>\n &gt; Photo";
369
  print " $snimek</div>";
370
  $path = "$gallery_dir/$galerie/thumbs";
371

    
372
  if(isset($_GET['video'])) {
373
    print "<br /><video controls>
374
  <source src=\"$gallery_dir/$galerie/webm/img-$snimek.webm\" type=\"video/webm\">
375
</video>\n";
376
    $page->user_comments($picture->number);
377
    $page->navigation($galerie, $snimek, null);
378

    
379
    require("inc/footer.inc.php");
380
    $page->footer();
381
    //Un exit histoire de ne pas se casser la tete avec le end (dev en cours)
382
    exit;
383
  }
384

    
385

    
386
  $imgfiles = new SortDir("$path");
387
  check($galerie);
388
  $path = "$gallery_dir/$galerie/lq";
389
  $file = "$path/img-$snimek.jpg";
390
  if (!file_exists($file)) {
391
    print __('No such image');
392
    $page->footer();
393
    exit;
394
  }
395
         
396
  if (!$picture) { //picture may have been created if commentform submitted
397
    require_once("$root/inc/photo.class.inc.php");
398
    $picture = new C_photo($file, $snimek);
399
  }
400

    
401
  // mini thumbnail roll
402

    
403
  if ($show_thumbs) {
404
    print "\n<!--mini thumbnail roll-->\n<div id=\"thumbs\" class=\"navigation\" style=\"visibility: hidden\"><ul class=\"thumbs noscript\" style=\"display:none\">";
405
    if($galerievideo) {
406
      print "<a id=\"minus\" href=\"$ThisScript?galerie=$galerie&amp;video=$snimek";
407
    }
408
    else {
409
      print "<a id=\"minus\" href=\"$ThisScript?galerie=$galerie&amp;photo=$snimek";
410
    }
411
    print "\">";
412
    print "</a>\n";
413
    print " : \n";
414
    while ($thumbfile = $imgfiles->read()) {
415
      if ( eregi("^img-([0-9]+)\.(png|jpe?g)",
416
                 $thumbfile, $x)) {
417
        $thumb = "$gallery_dir/$galerie/thumbs/img-${x[1]}.${x[2]}";
418
        print "   <li><a class=\"thumb\" href=\"$ThisScript?galerie=$galerie&amp;photo=${x[1]}&amp;directdownload=true\"";
419
        print " name=\"" . get_photo_title($galerie, $x[1]) . "\" title=\"" . get_photo_title($galerie, $x[1]) . "\">";
420
        print "</a></li> \n";
421
      }
422
    }
423
    if (file_exists("$gallery_dir/$galerie/zip/hq.zip")) {
424
      print "<a id=\"zip\" href=\"$gallery_dir/$galerie/zip/hq.zip\">";
425
      print "zip<span /></a>";
426
    }
427
    if (file_exists("$gallery_dir/$galerie/zip/hq.tar.bz2")) {
428
      print "<a id=\"zip\" href=\"$gallery_dir/$galerie/zip/hq.tar.bz2\">";
429
      print "zip<span /></a>";
430
    }
431
    print "</ul></div>\n";
432
  } else {
433
    // show the popup button
434
    print "\n<!--mini thumbnail popup-->\n<div class=\"thumbroll\">";
435
    print "<a id=\"plus\" href=\"$ThisScript?galerie=$galerie&amp;photo=$snimek";
436
    print "&amp;show_thumbs=yes\"";
437
    print " title=\"" . __('Show Thumbnail Navigation') . "\">";
438
    print "</a>\n";
439
    print "</div>\n";
440
  }
441

    
442
  /* main image + thumbnail navigation (prev/next) */
443

    
444
  if($slideshow) {
445
    print "
446
<div id=\"gallery\" class=\"content\">
447
  <div class=\"slideshow-container\">
448
   <div id=\"loading\" class=\"loader\"></div>
449
   <div id=\"slideshow\" class=\"slideshow\" style=\"height:480;\"></div>
450
  </div>
451
</div>\n";
452
  }
453
  else {
454
    $picture->renderPreview();
455
    $page->navigation($galerie, $snimek, "prev");
456
    $page->navigation($galerie, $snimek, "next");
457
  }
458
  print "</div>\n"; //end image div
459

    
460

    
461
  if(!$slideshow) {
462
    if (function_exists(exif_read_data)) require("$root/inc/exif.inc.php"); 
463
    /* Image comment
464
       really poor naming here, it is caption.
465
    */
466
    $picture->renderCaption();
467
     
468
     
469
    //show page counter
470
    if ($log_access) {
471
      $picture->renderCounter();
472
    }
473
     
474
    $picture->renderBigSize();
475
     
476
    $page->user_comments($picture->number);
477
    $page->navigation($galerie, $snimek, null);
478
  }
479
 }
480

    
481
require("inc/footer.inc.php");
482

    
483

    
484
if($slideshow) {
485
  print "
486
<div id=\"controls\" class=\"controls\"></div>
487
<script type=\"text/javascript\">
488
$(document).ready(function() {
489
  $('#thumbs').galleriffic({
490
     autoStart:              true,
491
     imageContainerSel:      '#slideshow',
492
     renderNavControls:      false,
493
     renderSSControls:       false
494
  });
495
});
496
</script>\n";
497
 }
498

    
499
$page->footer();
500
?>
Redmine Appliance - Powered by TurnKey Linux