Projet

Général

Profil

Paste
Statistiques
| Branche: | Révision:

ryxeo-webphotoalbum-git / www / index.php @ 4fcec884

Historique | Voir | Annoter | Télécharger (13,1 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
// always get sorted directory entries
18
$adr = new SortDir("$gallery_dir");
19

    
20
// get variables passed in from the URL:
21
$galerie='';
22
if (isset($_GET['galerie'])) $galerie=$_GET["galerie"];
23
if (isset($_GET['gallery'])) $galerie=$_GET["gallery"];
24
$galerie = preg_replace('/\//', '', $galerie);
25
if (isset($_GET["thumbsize"])) $thumbsize=$_GET["thumbsize"];
26
$snimek = 0;
27
if (isset($_GET["snimek"])) $snimek=$_GET["snimek"];
28
if (isset($_GET["photo"])) $snimek=$_GET["photo"];
29
$snimek = intval($snimek);
30
$y='';
31
if (isset($_GET['y'])) $y=$_GET["y"];
32
$cmnt='';
33
if (isset($_GET["cmnt"])) $cmnt=$_GET["cmnt"];
34
$show_thumbs='';
35
if (isset($_GET["show_thumbs"])) $show_thumbs=$_GET["show_thumbs"];
36

    
37
$page = new C_www;
38
//default colors
39

    
40
if (!is_dir("$gallery_dir/$galerie/thumbs")) {
41
  $galerie = "";
42
 }
43

    
44
//read interesting stuff from info.txt
45
if ($galerie) { 
46
  readInfo("$root/$gallery_dir/$galerie/info.txt", $galerie);
47
  //check for restricted access
48
  if ($galerielogin[$galerie]) {
49
    access_check($galerielogin[$galerie],$galeriepw[$galerie],$galerie);
50
  }
51
 }
52

    
53
$page->process_comment_form();
54

    
55
//START RENDERING
56

    
57
//ryxeo
58
if($_GET['slideshow'] == 'play')
59
  $slideshow = true;
60
 else
61
   $slideshow = false;
62

    
63
if($_GET['directdownload'] == "true") {
64
  require_once("$root/inc/photo.class.inc.php");
65
  $picture = new C_photo($file, $snimek);
66
  //  print_r($picture);
67
  header('Content-Type: ' . $picture->mime);
68
  header('Content-Transfer-Encoding: binary');
69
  header('Expires: 0');
70
  header('Cache-Control: must-revalidate');
71
  header('Pragma: public');
72
  header('Content-Length: ' . filesize($picture->preview));
73
  ob_clean();
74
  flush();
75
  readfile($picture->preview);
76
  //print_r($picture);
77
  exit;
78
 }
79

    
80
$page->header("Photos");
81
require("inc/header.inc.php");
82

    
83
// folder > tree
84
//print "<div class=\"navigation\"><a href=\"$ThisScript\">" . $scnamegallery . "</a>";
85
print "<div class=\"navigation\"><a href=\"./\">" . $scnamegallery . "</a>";
86

    
87
//############################
88
//         Overall Gallery Index
89
//############################
90
if (!$galerie) {
91
  // finish off navigation bar
92
  print "</div>\n\n<!-- listing galleries-->\n\n";  
93
  // I've nuked date.txt to replace it with a more generic info.txt
94
  // It optionally supplies i18n name, camera model, author and date
95
  // TODO: imgconv script support
96
  while ($file = $adr->Read()) {
97
    // checking for inc is only really needed when gallery_dir == $root
98
    // hopefully not many galleries will be named inc ;)
99
    if (is_dir("$gallery_dir/$file") && !ereg("\.", $file) && $file!="inc") { 
100
      // Use date file for gallery date if avaliable
101
      // info.txt format described in README
102
      readInfo("$root/$gallery_dir/$file/info.txt", $file);
103
      
104
    }
105
  }
106
  
107
  if (!isset($galeriemonth)) $galeriemonth = array();
108
  if (!isset($galerieday)) $galerieday = array();
109
  //sort within month depending on $sortinmonth
110
  if ($sortinmonth) {
111
    //alphabetically
112
    ksort($galeriemonth);
113
    reset($galeriemonth);
114
  } else {//by date
115
    arsort($galerieday);
116
    reset($galerieday);
117
  }
118
  
119
  
120
  $thisyear = 0;
121
  if (!$yearto) $yearto = date("Y");
122
  for ($i = $yearto; $i >= $yearsince; $i--) {
123
    for ($thismonth=12; $thismonth>0; $thismonth--) { // go year by year, month by month
124
      // down
125
      foreach ($galerieday as $foldername => $day) { //using $galerieday (for when sorted)
126
        if ($galeriemonth["$foldername"] == $thismonth && 
127
            $galerieyear["$foldername"] == $i) { //such Y/M exists
128
          
129
          $galerieyearordered["$foldername"]=$galerieyear["$foldername"];
130
          $galeriemonthordered["$foldername"]=$galeriemonth["$foldername"];
131
        }
132
      }
133
    }
134
  }
135
  
136
  
137
  $months = array(__('January'), __('February'), __('March'), __('April'), __('May'), __('June'), __('July'), __('August'),
138
                  __('September'), __('October'), __('November'), __('December'));
139
  $one_out = false;
140
  foreach ($galerieyearordered as $foldername => $year) {
141
    $one_out = true;
142
    if (@$thisyear!=$year) { //if the year is not equal to the current year
143
      //This is the first year
144
      if (@$thisyear) { print "   </div>\n</div>\n";}// end last year if this is 
145
      // not the first one
146
      //This is a new year
147
      unset($thismonth);
148
      print "<div class=\"year\"><h3>$year</h3>\n";
149
      print "";
150
    }
151
    $month=$galeriemonth["$foldername"];
152
    // now months
153
    if (@$thismonth!=$month) {
154
      //first one
155
      if (@$thismonth) { print "   </div>\n"; } // end of last month if
156
      // this is not the first one
157
      //new month
158
      $monthindex = $month - 1;
159
      $monthname = $months[$monthindex];
160
      print "   <div class=\"month\"><h4>$monthname</h4>\n";
161
    }
162
    //galleries within month        
163
    if ($galerielogin[$foldername]) {
164
      print "      <p class=\"restricted\"><a ";
165
    } else {
166
      print "      <p><a ";
167
    }
168
    if (@$galeriename[$foldername]) {
169
      print " href=\"$ThisScript?galerie=$foldername\">";
170
      print $galeriename[$foldername];
171
      print "</a>";
172
    } else {
173
      print " href=\"$ThisScript?galerie=$foldername\">$foldername</a>";
174
    }
175
    if (@$galeriedesc[$foldername]) {
176
      print "<span class=\"desc\">" . $galeriedesc[$foldername];
177
      print "</span>\n";
178
    }
179
    if (@$galerieauthor[$foldername]) {
180
      print "<span class=\"author\">by&nbsp;" . $galerieauthor[$foldername];
181
      print "</span>\n";
182
    }
183
    if (@$galerieday[$foldername]) {
184
      print "<span class=\"date\">";
185
      print "$monthname&nbsp;" . $galerieday[$foldername];
186
      print "</span>\n";
187
    }
188
    print "</p>\n";
189
    $thisyear=$year;
190
    $thismonth=$month;
191
  }
192
  if ($one_out) print ("   </div>\n</div>\n\n");
193
   
194
  //#############################
195
  //  Individual Gallery Index  #
196
  //#############################
197
 } elseif (!$snimek) {
198
         
199
   // finish off navigation header
200
         
201
   print "\n &gt; ";
202
   if ($galeriename[$galerie]) {
203
     print $galeriename[$galerie];
204
   } else {
205
     print $galerie;
206
   }
207
   print "</div>\n\n";
208

    
209
   //thumbnails
210
   print "<p class=\"bigthumbnails\">\n";
211
   $path = "$gallery_dir/$galerie/thumbs";
212
   $imgfiles = new SortDir($path);
213
   check($galerie); // check for nasty input
214
   while ($file = $imgfiles->read()) {
215
     if (is_file("$path/$file") && eregi("^img-([0-9]+)\.(png|jpe?g)", $file, $x)) {
216
                                                                  
217
       $thumb = "$gallery_dir/$galerie/thumbs/img-${x[1]}.${x[2]}";
218
       $imgsize = getimagesize("$root/$thumb");
219
       //check for portraits
220
       $portrait = "false";
221
       $class = "";
222
       if($imgsize[0]<100) {
223
         //portraits need a special class for styling
224
         $class = "portrait";
225
       }
226
       //check for number of comments per photo
227
       if ($comments) { //there probably won't be user comments if it's off
228
         $NumOfComments = 0;
229
         if (file_exists("$gallery_dir/$galerie/comments/user_${x[1]}.txt")) {
230
           if ($class) $class .= " ";
231
           $class .= "hascomments";
232
           //now let's count'em
233
           $fh = fopen("$gallery_dir/$galerie/comments/user_${x[1]}.txt","r");
234
           while (!feof($fh)) {
235
             $line = fgets($fh);
236
             if (eregi("commententry",$line)) $NumOfComments++;
237
           }
238
           fclose($fh);
239
         }
240
         if ($NumOfComments==1) {
241
           $NumOfComments = $NumOfComments . " " . __('Comment');
242
         } else {
243
           $NumOfComments = $NumOfComments . " " . __('Comments');
244
         }
245
       }
246
       if (file_exists("$gallery_dir/$galerie/comments/${x[1]}.txt") &&
247
           $title = file_get_contents("$gallery_dir/$galerie/comments/${x[1]}.txt")) {
248
         $title = ereg_replace("(\"|\')","",trim(strip_tags($title)));
249
         $title = ereg_replace("(.{77}).*","\\1",$title);
250
       } else 
251
         $title = "Photo ${x[1]}";
252

    
253
       print "   <a href=\"$ThisScript?galerie=$galerie&amp;photo=${x[1]}\"";
254
       print " title=\"$title, $NumOfComments\"";
255
       if ($class) print " class=\"$class\"";
256
       print ">";
257
       print "<img ";
258
       if (isset($thumbsize)) {
259
         print "width=\"120\" height=\"80\" ";
260
       } else {
261
         // scale portraits to 80 height
262
         if ($portrait) {
263
           //portrait
264
           print "width=\"";
265
           $scaled = round($imgsize[0] / 1.5);
266
           print $scaled;
267
           print "\" height=\"${imgsize[0]}\"";
268
         } else {
269
           //landscape
270
           print $imgsize[3]; 
271
         }
272
       }
273
       print " src=\"$thumb\" ";
274
       print "alt=\"photo No. ${x[1]}\" />";
275
       print "</a>\n";
276
     }
277
   }
278
   print "</p>\n";
279

    
280
   //info
281
   print "<div id=\"info\">\n";
282
   if ($galeriedesc[$galerie]) {
283
     print "<p>";
284
     print "<span class=\"value\">";
285
     print $galeriedesc[$galerie] . "</span></p>\n";
286
   }
287
   if ($galerieauthor[$galerie]) {
288
     print "<p><span class=\"key\">Author: </span>";
289
     print "<span class=\"value\">";
290
     print $galerieauthor[$galerie] . "</span></p>\n";
291
   }
292
   print "</div>\n";
293

    
294
   //and links to archived images:
295
   print "\n<p class=\"archives\">\n";
296
   if (file_exists("$gallery_dir/$galerie/zip/mq.zip")) {
297
     print "[ <a href=\"$gallery_dir/$galerie/zip/mq.zip\">" . __('zipped MQ images') . "</a> ] ";
298
   }
299
   if (file_exists("$gallery_dir/$galerie/zip/mq.tar.bz2")) {
300
     print "[ <a href=\"$gallery_dir/$galerie/zip/mq.tar.bz2\">" . __('MQ images tarball') . "</a> ] ";
301
   }
302
   if (file_exists("$gallery_dir/$galerie/zip/hq.zip")) {
303
     print "[ <a href=\"$gallery_dir/$galerie/zip/hq.zip\">" . __('zipped HQ images') . "</a> ]";
304
   }
305
   if (file_exists("$gallery_dir/$galerie/zip/hq.tar.bz2")) {
306
     print "[ <a href=\"$gallery_dir/$galerie/zip/hq.tar.bz2\">" . __('HQ images tarball') . "</a> ]";
307
   }
308
   print "</p>";
309

    
310
   //######################
311
   //         Individual Image
312
   //######################
313
   } else { //low-res image
314
  // finish off header
315
  print "\n &gt; <a href=\"$ThisScript?galerie=$galerie\">";
316
  if ($galeriename[$galerie]) {
317
    print $galeriename[$galerie];
318
  } else {
319
    print $galerie;
320
  }
321
  print "</a>\n &gt; Photo";
322
  print " $snimek</div>";
323
  $path = "$gallery_dir/$galerie/thumbs";
324
  $imgfiles = new SortDir("$path");
325
  check($galerie);
326
  $path = "$gallery_dir/$galerie/lq";
327
  $file = "$path/img-$snimek.jpg";
328
  if (!file_exists($file)) {
329
    print __('No such image');
330
    $page->footer();
331
    exit;
332
  }
333
         
334
  if (!$picture) { //picture may have been created if commentform submitted
335
    require_once("$root/inc/photo.class.inc.php");
336
    $picture = new C_photo($file, $snimek);
337
  }
338

    
339
  // mini thumbnail roll
340

    
341
  if ($show_thumbs) {
342
    print "\n<!--mini thumbnail roll-->\n<div id=\"thumbs\" class=\"navigation\" style=\"visibility: hidden\"><ul class=\"thumbs noscript\" style=\"display:none\">";
343
    print "<a id=\"minus\" href=\"$ThisScript?galerie=$galerie&amp;photo=$snimek";
344
    print "\">";
345
    print "</a>\n";
346
    print " : \n";
347
    while ($thumbfile = $imgfiles->read()) {
348
      if ( eregi("^img-([0-9]+)\.(png|jpe?g)",
349
                 $thumbfile, $x)) {
350
        $thumb = "$gallery_dir/$galerie/thumbs/img-${x[1]}.${x[2]}";
351
        print "   <li><a class=\"thumb\" href=\"$ThisScript?galerie=$galerie&amp;photo=${x[1]}&amp;directdownload=true\"";
352
        print " name=\"" . get_photo_title($galerie, $x[1]) . "\" title=\"" . get_photo_title($galerie, $x[1]) . "\">";
353
        print "</a></li> \n";
354
      }
355
    }
356
    if (file_exists("$gallery_dir/$galerie/zip/hq.zip")) {
357
      print "<a id=\"zip\" href=\"$gallery_dir/$galerie/zip/hq.zip\">";
358
      print "zip<span /></a>";
359
    }
360
    if (file_exists("$gallery_dir/$galerie/zip/hq.tar.bz2")) {
361
      print "<a id=\"zip\" href=\"$gallery_dir/$galerie/zip/hq.tar.bz2\">";
362
      print "zip<span /></a>";
363
    }
364
    print "</ul></div>\n";
365
  } else {
366
    // show the popup button
367
    print "\n<!--mini thumbnail popup-->\n<div class=\"thumbroll\">";
368
    print "<a id=\"plus\" href=\"$ThisScript?galerie=$galerie&amp;photo=$snimek";
369
    print "&amp;show_thumbs=yes\"";
370
    print " title=\"" . __('Show Thumbnail Navigation') . "\">";
371
    print "</a>\n";
372
    print "</div>\n";
373
  }
374

    
375
  /* main image + thumbnail navigation (prev/next) */
376

    
377
  if($slideshow) {
378
    print "
379
<div id=\"gallery\" class=\"content\">
380
  <div class=\"slideshow-container\">
381
   <div id=\"loading\" class=\"loader\"></div>
382
   <div id=\"slideshow\" class=\"slideshow\" style=\"height:480;\"></div>
383
  </div>
384
</div>\n";
385
  }
386
  else {
387
    $picture->renderPreview();
388
    $page->navigation($galerie, $snimek, "prev");
389
    $page->navigation($galerie, $snimek, "next");
390
  }
391
  print "</div>\n"; //end image div
392

    
393

    
394
  if(!$slideshow) {
395
    if (function_exists(exif_read_data)) require("$root/inc/exif.inc.php"); 
396
    /* Image comment
397
       really poor naming here, it is caption.
398
    */
399
    $picture->renderCaption();
400
     
401
     
402
    //show page counter
403
    if ($log_access) {
404
      $picture->renderCounter();
405
    }
406
     
407
    $picture->renderBigSize();
408
     
409
    $page->user_comments($picture->number);
410
    $page->navigation($galerie, $snimek, null);
411
  }
412
 }
413

    
414
require("inc/footer.inc.php");
415

    
416

    
417
if($slideshow) {
418
  print "
419
<div id=\"controls\" class=\"controls\"></div>
420
<script type=\"text/javascript\">
421
$(document).ready(function() {
422
  $('#thumbs').galleriffic({
423
     autoStart:              true,
424
     imageContainerSel:      '#slideshow',
425
     renderNavControls:      false,
426
     renderSSControls:       false
427
  });
428
});
429
</script>\n";
430
 }
431

    
432
$page->footer();
433
?>
Redmine Appliance - Powered by TurnKey Linux