'; // Überschrift Start $gallery['titleend'] = ''; // Überschrift Ende $gallery['displaystart'] = '
'; // Start der Ausgabe $gallery['displayend'] = '
'; // Ende der Ausgabe $gallery['exif'] = TRUE; // EXIF-Unterstützung $gallery['iptc'] = TRUE; // IPTC-Unterstützung $gallery['savethumbs'] = FALSE; // Thumbnails erstellen und abspeichern $gallery['thumbwidth'] = 100; // Breite der Thumbnails $gallery['randomwidth'] = 150; // Breiter der Thumbails der Zufallbilder $gallery['index'] = 'index.txt'; // Liste mit den Zufallsbildern // Eigene Einstellungen vornehmen @require_once('config.php'); // Pfad zum Datenverzeichnis $dir = trim($conf['savedir']); if ($dir{0} == '.') $dir = substr($dir, 1); if ($dir{0} == '/') $dir = substr($dir, 1); if ($dir{strlen($dir)-1} == '/') $dir = substr($dir, 0, strlen($dir)-1); $gallery['datadir'] = $dir; return $gallery; } /** * Hauptroutine - Galerie starten * * Funktion wird im Template "main.php" aufgerufen */ function tpl_gallery() { global $ID; global $ACT; global $conf; global $INFO; // Werte einstellen $gallery = gallery_init(); // Galerie nur anzeigen wenn Seite nicht bearbeitet wird und Seite vorhanden ist if ($ACT != 'show' or $INFO['exists'] != 1) return; // Galerie nur anzeigen wenn man sich im korrekten Namespace befindet $array_id = split(':', $ID); if (strtolower($array_id[0]) != strtolower($gallery['namespace'])) return; // Parameter einlesen $gallery['pic'] = $_GET['pic']; // Name der Seite ermitteln $gallery['name'] = $array_id[count($array_id)-1]; // Galerie nicht anzeigen wenn eine "Startseite" aktiv ist if (strtolower($gallery['name']) == strtolower($conf['start'])) return; // Namespaces ermitteln $gallery['space'] = str_replace(':', '/', str_replace(':'.$gallery['name'], '', $ID)); // Suffix für Dateinamen der Bilder erstellen $gallery['suffix'] = strtolower($gallery['name']).'_'; // Pfad zu den Bildern $gallery['dir'] = $gallery['datadir'].'/media/'.$gallery['space']; $gallery['media'] = 'media/'.$gallery['space']; // Prüfen ob Verzeichnis vorhanden ist if (!is_dir($gallery['dir'])) { echo '

'.$gallery['nopicture']."

\n"; return; } // Verzeichnis einlesen $array = gallery_readdir($gallery); $gallery['image'] = $array[1]; $gallery['thumbnail'] = $array[2]; $gallery['imagename'] = $array[3]; $gallery['thumbname'] = $array[4]; // Anzahl der Bilder ermitteln $gallery['max'] = count($gallery['image']); // Prüfen ob Bilder vorhanden sind if ($gallery['max'] == 0) { echo '

'.$gallery['nopicture']."

\n"; return; } // Parameter prüfen if (isset($gallery['pic'])) { if ($gallery['pic'] > $gallery['max']) $gallery['pic'] = $gallery['max']; if ($gallery['pic'] < 1) $gallery['pic'] = 1; } // Gallerie oder einzelnes Bild anzeigen if (!isset($gallery['pic'])) gallery_displaythumbnails($gallery); else gallery_displayimage($gallery); return; } /** * Zufallsbild anzeigen */ function tpl_gallery_random() { global $conf; global $ACT; global $INFO; global $ID; // Werte einstellen $gallery = gallery_init(); $namespace = strtolower($gallery['namespace']); // Galerie nur anzeigen wenn Seite nicht bearbeitet wird und Seite vorhanden ist if ($ACT != 'show' or $INFO['exists'] != 1) return; // Galerie nur anzeigen wenn "Startseite" aktiv ist if (strtolower($ID) != strtolower($conf['start'])) return; // Pfad+Dateiname der Index-Datei $file = $gallery['datadir'].'/media/'.$namespace.'/'.$gallery['index']; // Inhalt der Index-Datei einlesen if (file_exists($file)) { $index = file($file); $max = count($index); // Einträge in der Index-Datei sind vorhanden if ($max > 0) { $nr = rand(0, $max); // Zufallsbild auswählen $picture = $namespace.'/'.trim($index[$nr]); // Dateiname des Bildes $sizeimage = getimagesize($gallery['datadir'].'/media/'.$picture, $info); $height = $sizeimage[1]/($sizeimage[0]/$gallery['randomwidth']); $media = ml(str_replace('/', ':', $picture), 'w='.$gallery['randomwidth'].'&h='.$height.'&cache=cache', TRUE); if (isset($info["APP13"]) and $gallery['iptc']) { $iptc = iptcparse ($info['APP13']); $alt = htmlentities($iptc['2#120'][0]); $iptc_caption = str_ireplace("\r\n", '
', $alt); $iptc_caption = str_ireplace("\r", '
', $iptc_caption); $iptc_caption = str_ireplace("\n", '
', $iptc_caption); $alt = htmlentities($iptc['2#090'][0]); $iptc_city = str_ireplace("\r\n", '
', $alt); $iptc_city = str_ireplace("\r", '
', $iptc_city); $iptc_city = str_ireplace("\n", '
', $iptc_city); } else { unset($iptc_caption); unset($iptc_city); } // Bild anzeigen $script = wl($gallery['namespace'].':'.$conf['start']); echo '
'."\n"; echo ''.$alt.''."\n"; echo "
\n$iptc_caption\n"; if ($iptc_city != '') echo "
\n($iptc_city)\n"; echo '
'."\n"; } } } /** * Thumbnails anzeigen * * @param array $gallery Daten-Array */ function gallery_displaythumbnails($gallery) { global $ID; $script = wl($ID); // Trenner für Parameter in URL $trenner = '?'; if (stristr($script, '?')) { $trenner = '&'; } echo $gallery['titlestart'].$gallery['content'].$gallery['titleend']."\n"; echo $gallery['displaystart']."\n"; echo $gallery['count'].' '.$gallery['max']."\n"; echo '
'."\n"; for ($i = 0; $i < $gallery['max']; $i++): // Thumbnail erzeugen falls nicht vorhanden ist if ($gallery['savethumbs']) { if (!file_exists($gallery['thumbnail'][$i])) gallery_createthumbnail($gallery, $i); $sizethumb = getimagesize($gallery['thumbnail'][$i]); } $sizeimage = getimagesize($gallery['image'][$i], $info); // IPTC-Daten ermitteln if ($gallery['iptc'] and isset($info["APP13"])) { $iptc = iptcparse($info['APP13']); $iptc_caption = htmlentities($iptc['2#120'][0]); if ($iptc_caption != '') $iptc_caption = ' - '.$iptc_caption; } else unset($iptc_caption); // Thumbnail anzeigen if ($gallery['savethumbs']) { $media = ml(getNS($ID).':'.$gallery['thumbname'][$i], 'w=&h=&cache=cache', TRUE); echo ''.$gallery['picturename'].($i+1).$iptc_caption.''."\n"; } else { $media = ml(getNS($ID).':'.$gallery['imagename'][$i], 'w='.$gallery['thumbwidth'].'&h=&cache=cache', TRUE); $height = $sizeimage[1]/($sizeimage[0]/$gallery['thumbwidth']); echo ''.$gallery['picturename'].($i+1).$iptc_caption.''."\n"; } flush(); endfor; echo '
'."\n"; echo $gallery['displayend']."\n"; flush(); } /** * Bild anzeigen * * @param array $gallery Daten-Array */ function gallery_displayimage($gallery) { global $ID; $size = getimagesize($gallery['image'][$gallery['pic']-1], $info); // EXIF-Daten ermitteln if ($gallery['exif']) { $exif = exif_read_data($gallery['image'][$gallery['pic']-1],'',true,false); $exif_date = htmlentities($exif['DateTime']); $exif_make = htmlentities($exif['Make']); $exif_camera = htmlentities($exif['Model']); } // IPTC-Daten ermitteln if (isset($info["APP13"]) and $gallery['iptc']) { $iptc = iptcparse ($info['APP13']); $iptc_program = htmlentities($iptc['2#065'][0]); $iptc_jobid = htmlentities($iptc['2#022'][0]); $iptc_status = htmlentities($iptc['2#007'][0]); $iptc_copyright = htmlentities($iptc['2#116'][0]); $iptc_specialinstructions = htmlentities($iptc['2#040'][0]); $iptc_headline = htmlentities($iptc['2#105'][0]); $iptc_captionwriter = htmlentities($iptc['2#122'][0]); $iptc_caption = htmlentities($iptc['2#120'][0]); $iptc_caption = str_ireplace("\r\n", '
', $iptc_caption); $iptc_caption = str_ireplace("\r", '
', $iptc_caption); $iptc_caption = str_ireplace("\n", '
', $iptc_caption); $iptc_originaltransmissionreference = htmlentities($iptc['2#103'][0]); $iptc_countrycode = htmlentities($iptc['2#100'][0]); $iptc_country = htmlentities($iptc['2#101'][0]); $iptc_state = htmlentities($iptc['2#095'][0]); $iptc_sublocation = htmlentities($iptc['2#092'][0]); $iptc_city = htmlentities($iptc['2#090'][0]); $iptc_objectname = htmlentities($iptc['2#005'][0]); $iptc_source = htmlentities($iptc['2#115'][0]); $iptc_credit = htmlentities($iptc['2#110'][0]); $iptc_bylinetitle = htmlentities($iptc['2#085'][0]); $iptc_byline = htmlentities($iptc['2#080'][0]); } else { unset($iptc_program); unset($iptc_jobid); unset($iptc_status); unset($iptc_copyright); unset($iptc_specialinstructions); unset($iptc_headline); unset($iptc_captionwriter); unset($iptc_caption); unset($iptc_originaltransmissionreference); unset($iptc_countrycode); unset($iptc_country); unset($iptc_state); unset($iptc_sublocation); unset($iptc_city); unset($iptc_objectname); unset($iptc_source); unset($iptc_credit); unset($iptc_bylinetitle); unset($iptc_byline); } echo $gallery['titlestart'].$gallery['picturename'].$gallery['pic'].' '.$gallery['of'].' '.$gallery['max'].$gallery['titleend']."\n"; echo $gallery['displaystart']."\n"; // Bild anzeigen $detail = ml(getNS($ID).':'.$gallery['imagename'][$gallery['pic']-1], 'id='.$ID.'&cache=cache', FALSE); $media = ml(getNS($ID).':'.$gallery['imagename'][$gallery['pic']-1], 'w=&h=&cache=cache', TRUE); $alt = getNS($ID).':'.$gallery['imagename'][$gallery['pic']-1]; echo '
'."\n"; echo ''; echo ''.$gallery['picturename'].$gallery['pic'].' '.$gallery['of'].' '.$gallery['max'].''; echo ''."\n"; echo '
'."\n"; // Beschreibung anzeigen if ($exif_date != '' and $gallery['exif']) { echo $exif_date."\n"; echo '
'."\n"; } if ($gallery['iptc']) { if ($iptc_caption != '') { echo $iptc_caption."\n"; echo '
'."\n"; } if ($iptc_city != '') { echo $gallery['city'].': '.$iptc_city; if ($iptc_country != '') echo ', '.$iptc_country; echo '
'."\n"; } elseif ($iptc_country != '') { echo $gallery['country'].': '.$iptc_country."\n"; echo '
'."\n"; } if ($iptc_sublocation != '') { echo $iptc_sublocation."\n"; echo '
'."\n"; } } echo '
'."\n"; // Navigation anzeigen gallery_navigation($gallery); echo '
'."\n"; echo $gallery['displayend']."\n"; flush(); } /** * Verzeichnis einlesen * * @param array $gallery Daten-Array * @return array */ function gallery_readdir($gallery) { $path = $gallery['dir'].'/'; $suffix = strtolower($gallery['suffix']); $len = strlen($suffix); $dir = dir($path); while ($file = $dir->read()) { $filename = strtolower($file); if (substr($filename,0,6) != 'thumb_' and substr($filename,0,$len) == $suffix) { if (stristr($filename, '.jpg')) { $image[] = $path.$filename; $thumbnail[] = $path.'thumb_'.$filename; $imagename[] = $filename; $thumbname[] = 'thumb_'.$filename; } if (stristr($filename, '.jpeg')) { $image[] = $path.$filename; $thumbnail[] = $path.'thumb_'.$filename; $imagename[] = $filename; $thumbname[] = 'thumb_'.$filename; } if (stristr($filename, '.png')) { $image[] = $path.$filename; $thumbnail[] = $path.'thumb_'.$filename; $imagename[] = $filename; $thumbname[] = 'thumb_'.$filename; } if (stristr($filename, '.gif')) { $image[] = $path.$filename; $thumbnail[] = $path.'thumb_'.$filename; $imagename[] = $filename; $thumbname[] = 'thumb_'.$filename; } } } $dir->close(); // Inhaltsverzeichnis sortieren if (count($image) > 0) { sort($image); sort($thumbnail); sort($imagename); sort($thumbname); } $array[1] = $image; $array[2] = $thumbnail; $array[3] = $imagename; $array[4] = $thumbname; return $array; } /** * Thumbnail erzeugen * * @param array $gallery Daten-Array * @param integer $nr Nummer des Bildes */ function gallery_createthumbnail($gallery, $nr) { $image = $gallery['image'][$nr]; $thumbnail = $gallery['thumbnail'][$nr]; // Infos über Bild holen $info = getimagesize($image); $width = $info[0]; $height = $info[1]; $type = $info[2]; // Thumbnail erstellen if ($type == 1) $new = imagecreatefromgif($image); elseif ($type == 2) $new = imagecreatefromjpeg($image); elseif ($type == 3) $new = imagecreatefrompng($image); $newwidth = $gallery['thumbwidth']; $newheight = $height/($width/$newwidth); $newimage = imagecreatetruecolor($newwidth, $newheight); imagecopyresampled($newimage, $new, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); // Thumbnail speichern if ($type == 1) imagegif($newimage, $thumbnail); elseif ($type == 2) imagejpeg($newimage, $thumbnail); elseif ($type == 3) imagepng($newimage, $thumbnail); } /** * Navigation anzeigen * * @param array $gallery Daten-Array */ function gallery_navigation($gallery) { global $ID; $script = wl($ID); // Trenner für Parameter in URL $trenner = '?'; if (stristr($script, '?')) { $trenner = '&'; } echo "

\n"; // Thumbnails $start = $gallery['pic']-2; if ($start < 1) $start = 1; $ende = $start+5; if ($ende > $gallery['max']+1) { $ende = $gallery['max']+1; if ($ende-5 < $start) $start = $ende-5; if ($start < 1) $start = 1; } for ($i = $start-1; $i < $ende-1; $i++) { if ($gallery['savethumbs']) $sizethumb = getimagesize($gallery['thumbnail'][$i]); $sizeimage = getimagesize($gallery['image'][$i], $info); // IPTC-Daten ermitteln if (isset($info["APP13"]) and $gallery['iptc']) { $iptc = iptcparse($info['APP13']); $iptc_caption = htmlentities($iptc['2#120'][0]); if ($iptc_caption != '') $iptc_caption = ' - '.$iptc_caption; } else unset($iptc_caption); // Thumbnail anzeigen if ($gallery['savethumbs']) { $media = ml(getNS($ID).':'.$gallery['thumbname'][$i], 'w=&h=&cache=cache', TRUE); } else { $media = ml(getNS($ID).':'.$gallery['imagename'][$i], 'w='.$gallery['thumbwidth'].'&h=&cache=cache', TRUE); $height = $sizeimage[1]/($sizeimage[0]/$gallery['thumbwidth']); } $thumb = str_replace('/', '%3A', $thumb); if ($i+1 == $gallery['pic']) { if ($gallery['savethumbs']) echo ''.$gallery['picturename'].($i+1).$iptc_caption.''."\n"; else echo ''.$gallery['picturename'].($i+1).$iptc_caption.''."\n"; } else { if ($gallery['savethumbs']) echo ''.$gallery['picturename'].($i+1).$iptc_caption.''."\n"; else echo ''.$gallery['picturename'].($i+1).$iptc_caption.''."\n"; } flush(); } flush(); echo "
\n"; // Textlinks if ($gallery['pic'] > 1) { echo '<< '."\n"; echo '< '."\n"; } else { echo '<< '."\n"; echo '< '."\n"; } echo ''.$gallery['content'].' '."\n"; if ($gallery['pic'] < $gallery['max']) { echo '> '."\n"; echo '>>'."\n"; } else { echo '> '."\n"; echo '>>'."\n"; } echo "

\n"; flush(); return; } ?>