Näytetään sen sisältö showAlbum($album, $picno); } else { listAlbums(); } // -------------------------------------------------------------- function listAlbums() { PageHeader("Kuvia", "index.menu"); print "

Kuvia

\n"; $d = dir(ALBUMDIR); while($entry=$d->read()) { if (preg_match("/^([-_a-zåäö0-9]+)\.album$/i", $entry, $matches) && isPublic(ALBUMDIR . $entry)) { $album_name = $matches[1]; $content = file_get_contents(ALBUMDIR . $entry); if (preg_match("/^(.+)(?:\n((?:.+\n?)*))?\n\n/i", $content, $matches)) { $album_title = $matches[1]; $album_desc = $matches[2]; print "$album_title\n"; print "

$album_desc

\n"; } } } $d->close; PageFooter(); } function showAlbum($album_name, $picno) { $content = file(ALBUMDIR . $album_name . '.album'); $line = 0; $album_title = ""; $album_title = rtrim($content[$line++]); $album_desc = ""; while (rtrim($content[$line]) != "") { $album_desc .= $content[$line++]; } $album_desc = rtrim($album_desc); $line++; // Mahdollinen oletuspolku kuville // Tämä lisätään ALBUMDIR:n arvoon $album_path = ""; if (preg_match("/^path=(.*)\n$/i", $content[$line], $matches)) { $album_path = $matches[1]; $line++; } // Luetaan kuvien tiedot // Kuvat on erotetu toisistaan tyhjällä rivillä // 1. filename // 2. title // 3-n. description $album_images = array(); $album_imagetitles = array(); $album_imagedescs = array(); while ($line < count($content)) { if (rtrim($content[$line]) == "") { $line++; } else { array_push($album_images, rtrim($content[$line++])); $tmp_title = rtrim($content[$line++]); $tmp_desc = ""; if ($tmp_title != "") { while (rtrim($content[$line]) != "") { $tmp_desc .= $content[$line++]; } } array_push($album_imagetitles, $tmp_title); array_push($album_imagedescs, rtrim($tmp_desc)); } } // Tarkistetaan, että valittu kuva on kelvollinen if ($picno < 1 || $picno > count($album_images)) { $picno = 1; } // Tulostetaan otsikko PageHeader("Kuvia - $album_title", ""); print "

$album_title

\n"; print ""; print "\n"; // Previous print "\n"; // Valittu kuva if (substr($album_images[$picno-1],0,1) != '/') { $imagepath = WWWBASE . ALBUMDIR . $album_path; $imagefile = $album_images[$picno-1]; } else { $imagepath = WWWBASE . ALBUMDIR . substr(dirname($album_images[$picno-1]),1) . '/'; $imagefile = basename($album_images[$picno-1]); } print "\n"; // Next print "\n"; print "\n"; print "
\n"; if ($picno > 1) { print ''; print 'Edellinen'; print ''; } else { print " \n"; } print "\n"; print '' . $album_imagetitles[$picno-1]. ''; print "\n"; if ($picno < count($album_images)) { print ''; print 'Seuraava'; print ''; } else { print " \n"; } print "
\n"; // Kuvan otsikko ja kuvaus if ($album_imagetitles[$picno-1] != "") { print '

' . $album_imagetitles[$picno-1] . "

\n"; } if ($album_imagedescs[$picno-1] != "") { print '

' . $album_imagedescs[$picno-1] . "

\n"; } // Tyjä rivi print "
\n"; // Tulostetaan kuvien thumbnailit $i = 0; print ""; while ($i < count($album_images)) { if (($i % COLCOUNT) == 0) { print "\n"; } print '\n"; if ((++$i % COLCOUNT) == 0) { print "\n"; } } if (($i % COLCOUNT) != 0) { while (($i++ % COLCOUNT) != 0) { print "\n"; } print "\n"; } print "
'; // Linkki print ''; // Selvitellään polkuja if (substr($album_images[$i],0,1) != '/') { $origfile = ALBUMDIR . $album_path . $album_images[$i]; $systempath = ALBUMDIR . $album_path . 'thumbs/'; $thumbpath = WWWBASE . ALBUMDIR . $album_path . 'thumbs/'; $thumbfile = $album_images[$i]; } else { $origfile = ALBUMDIR . substr(dirname($album_images[$i]),1) . '/' . basename($album_images[$i]); $systempath = ALBUMDIR . substr(dirname($album_images[$i]),1) . '/thumbs/'; $thumbpath = WWWBASE . ALBUMDIR . substr(dirname($album_images[$i]),1) . '/thumbs/'; $thumbfile = basename($album_images[$i]); } // Katsotaan tarvitseeko luoda uusi thumbnail if (! file_exists($systempath . $thumbfile) && file_exists($systempath)) { exec('convert -sample 100x100 ' . $origfile . ' ' . $systempath . $thumbfile); chmod($systempath . $thumbfile, 0644); } // Katsotaan onko thumb olemassa if (file_exists($systempath . $thumbfile)) { if ($i == $picno-1) { $class = " class=\"selected\""; } else { $class = ""; } print '' . $album_imagetitles[$i] .  ''; } else if ($album_imagetitles[$i] != "") { print $album_imagetitles[$i]; } else { print basename($album_images[$i]); } print "
 
"; print "

[ Kuvien etusivulle ]

\n"; // Sivun loppu PageFooter(); } function isPublic($file) { $perms = fileperms($file); return ($perms & 4); } ?>