Hallo alle zusammen!
Ich würde gerne die Bilder galleri in meine Seite einbauen.
Mich stört aber das unter den thumbnail immer der Name des Bildes ausgegeben wird.
Kann mir vielleicht einer von euch sagen wo ich das in dem Code auskommentieren kann?
Ich würde gerne die Bilder galleri in meine Seite einbauen.
Mich stört aber das unter den thumbnail immer der Name des Bildes ausgegeben wird.
Kann mir vielleicht einer von euch sagen wo ich das in dem Code auskommentieren kann?
Code:
<?php
/*//////////////////////////////////////////////////////////////////////////////
// Copyright N. Waldisphl, 2003-05
////////////////////////////////////////////////////////////////////////////////
// Project RetortePictureBrowser / Script for displaying images
//
// Read readme.txt for further infos
//
// Dateiname index.php
//
// Author Nico Waldisphl NW
// Contact nw at retorte dot ch
// Datum of creat. 27. July 2003
//
//This program is free software; you can redistribute it and/or modify it under
//the terms of the GNU General Public License as published by the Free Software
//Foundation; either version 2 of the License, or (at your option) any later
//version.
//
//This program is distributed in the hope that it will be useful, but WITHOUT
//ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
//FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License along with
//this program; if not, write to the Free Software Foundation, Inc., 59 Temple
//Place, Suite 330, Boston, MA 02111-1307, USA. (http://www.fsf.org/)
//////////////////////////////////////////////////////////////////////////////*/
////////////////////////////////////////////////////////////////////////////////
// Classdefinition and such
////////////////////////////////////////////////////////////////////////////////
class PICTURE_BROWSER
{
var $version;
var $aktId;
var $navArray;
var $pictures;
var $title;
var $cols;
var $thumb_width;
var $tn_mode;
var $sort;
var $thumbs_per_page;
var $description;
var $description_old;
var $link_vor;
var $link_zurueck;
var $link_up;
var $page_vor;
var $page_zurueck;
var $comments;
var $comments_old;
var $prev_width;
var $template_thumb;
var $template_pic;
var $show_nav;
var $header;
/*--------------------------------------------------------------------*/
/* Constructor */
/*--------------------------------------------------------------------*/
function Picture_Browser()
{
// Nice thingies to start
// Configuration
$this->doConfig();
// Check, if comment files available
$this->checkCommentFile();
// Return special HTTP Header to browser.
$this->putHTTPHeader();
}
/*--------------------------------------------------------------------*/
/* Configuration; read configfile */
/*--------------------------------------------------------------------*/
function doConfig()
{
$config_file = "pb.conf";
// Read configfiles.
if(file_exists($config_file))
{
$cf = @file($config_file);
while($config_abfrage = each($cf))
{
$config_abfrage = trim($config_abfrage[1]);
if( (strpos($config_abfrage, "#")==false) AND (!empty($config_abfrage)) )
{
$einzelteile = explode("=", $config_abfrage);
$varname = stripslashes(trim($einzelteile[0]));
$varvalue = stripslashes(trim($einzelteile[1]));
$$varname = $varvalue;
}
}
}
// Global preferences, fallback. Don't do anything here. Use pb.conf!
////////////////////////////////////////////////////////////////////////
$version = "2.4.1";
// Title
if(!isset($title)) {
$title = "Retorte Picture Browser V $version";
}
// Number of thumbnails per line
if(!isset($cols)) {
$cols = 8;
}
// Size (in pixels) of thumbnails (always square)
if(!isset($width)) {
$width = 80;
}
// Thumbnailmode
// 1: Don't scale, cut out little square
// 2: Scale proportional, cut only the rest
if(!isset($mode)) {
$mode = 2;
}
else
{
if($mode=="cut")
{
$mode = 1;
}
else
{
$mode = 2;
}
}
// Sortmode
if(!isset($sort)) {
$sort = "name";
}
// Number of thumbnails displayed per page
if(!isset($thumbs_per_page)) {
$thumbs_per_page = 0;
}
// Name of file with description
if(!isset($description)) {
$description = "pb_desc.txt";
}
// Name of (existing) file with description
if(!isset($description_old)) {
$description_old = "pb_desc.old";
}
// Text for various links
// next picture
if(!isset($forward)) {
$forward = "forward (next picture) »";
}
// previous picture
if(!isset($back)) {
$back = "« back (previous picture)";
}
// next page
if(!isset($next)) {
$next = "forward (next page) »";
}
// previous page
if(!isset($previous)) {
$previous = "« back (previous page)";
}
// back up
if(!isset($up)) {
$up = "up (back to thumbnails)";
}
// Name of file with comments
if(!isset($comments)) {
$comments = "comments.txt";
}
// Name of (existing) file with comments
if(!isset($comments_old)) {
$comments_old = "comments.old";
}
// Size of thumbnails in comment generator
if(!isset($prev_width)) {
$prev_width = 180;
}
// Template for thumbnail view
if(!isset($template_thumb)) {
$template_thumb = "template_thumb.inc.html";
}
// Template for image view
if(!isset($template_pic)) {
$template_pic = "template_pic.inc.html";
}
// Show navigation if not useful?
if(!isset($show_nav)) {
$show_nav = 1;
}
// HTML file header
$header = "<!--
Retorte Picture Browser V $version
http://www.retorte.ch/tools/picturebrowser
------------------------------------------------------
Funktion: Zeigt Bilder eines Verzeichnisses in einer
Gesamtvorschau und auch einzeln zum Navigieren an.
Erstellt dynamisch Thumbnails. Problemlos einzusetzen.
------------------------------------------------------
(c) 2003/04 Nico Waldispuehl (http://www.retorte.ch)
//-->
";
// Define variables with values from above
$this->version = $version;
$this->title = $title;
$this->thumb_cols = $cols;
$this->thumb_width = $width;
$this->tn_mode = $mode;
$this->sort = $sort;
$this->thumbs_per_page = $thumbs_per_page;
$this->description = $description;
$this->description_old = $description_old;
$this->link_vor = $forward;
$this->link_zurueck = $back;
$this->link_up = $up;
$this->page_vor = $next;
$this->page_zurueck = $previous;
$this->comments = $comments;
$this->comments_old = $comments_old;
$this->prev_width = $prev_width;
$this->template_thumb = $template_thumb;
$this->template_pic = $template_pic;
$this->show_nav = $show_nav;
$this->header = $header;
// PB reads these image formats
$this->supported_pf = array("gif",
"jpg",
"jpeg",
"png");
$this->check_integrity();
$this->readDirectory();
}
/*--------------------------------------------------------------------*/
/* Definition of errorcodes */
/*--------------------------------------------------------------------*/
function set_error_codes()
{
define("ERROR_TEMPLATE_MISSING", "Achtung: Ein HTML Template konnte nicht gefunden werden!");
define("ERROR_IMAGE_FILE_MISSING", "Achtung: Die Datei pb_img.php konnte nicht gefunden werden!");
}
/*--------------------------------------------------------------------*/
/* Check if all important data is available */
/*--------------------------------------------------------------------*/
function check_integrity()
{
$this->set_error_codes();
if(!file_exists($this->template_pic))
{
$this->show_error_message(ERROR_TEMPLATE_MISSING);
}
if(!file_exists($this->template_thumb))
{
$this->show_error_message(ERROR_TEMPLATE_MISSING);
}
if(!file_exists("./pb_img.php"))
{
$this->show_error_message(ERROR_IMAGE_FILE_MISSING);
}
}
/*--------------------------------------------------------------------*/
/* Reads current directory */
/*--------------------------------------------------------------------*/
function readDirectory()
{
// Read all elemets of current dir into array
$verzeichnis = "./";
$v = dir($verzeichnis);
$v->rewind();
while($dir_output = $v->read())
{
$dir_output_arr[] = $dir_output;
}
// Sort elements
natsort($dir_output_arr);
// Sort out useless things
while($dir_out_pre = each($dir_output_arr))
{
$dir_out = $dir_out_pre[1];
// Put away dirs
if(!@is_dir($dir_out))
{
$dir_out_arr = explode(".", $dir_out);
$dir_out_arr_rev = array_reverse($dir_out_arr);
$endung = strtolower($dir_out_arr_rev[0]);
$write_trig = 0;
// Put away not supported files
while($endung_ctrl = each($this->supported_pf))
{
if(strtolower($endung_ctrl[1])==$endung)
{
$write_trig = 1;
}
}
reset($this->supported_pf);
$file_cont = "$dir_out";
if($write_trig == 1)
{
$this->pictures[] = $file_cont;
}
}
}
// if images shall be sorted by data, rearrange array
if($this->sort == "date" AND @function_exists(read_exif_data) AND !empty($this->pictures))
{
// we need a second and a third array
$exif_images_array = array();
$non_exif_images_array = array();
while($eintrag = each($this->pictures))
{
$zeile = $eintrag[1];
$zeilen_arr = explode(";;;", $zeile);
$dateiname = $zeilen_arr[0];
$dateigroesse = round((filesize("./$dateiname")/1024),1)." KB";
$dateiname_arr = array_reverse(explode(".", $dateiname));
if((strtolower($dateiname_arr[0])=="jpg")OR(strtolower($dateiname_arr[0])=="jpeg"))
{
$exif_daten = @read_exif_data("./$dateiname");
if(isset($exif_daten["DateTimeOriginal"]))
{
$datum_zeit = explode(" ", $exif_daten["DateTimeOriginal"]);
$datum_roh = $datum_zeit[0];
$jahr = substr($datum_roh, 0, 4);
$monat = substr($datum_roh, 5, 2);
$tag = substr($datum_roh, 8, 2);
$datum = $jahr . $monat . $tag;
$stunden = substr($datum_zeit[1], 0, 2);
$minuten = substr($datum_zeit[1], 3, 2);
$sekunden = substr($datum_zeit[1], 6, 2);
$zeit = $stunden . $minuten . $sekunden;
$stamp = $datum . $zeit;
$exif_images_array[$stamp] = $eintrag[1];
}
else
{
$non_exif_images_array[] = $eintrag[1];
}
}
else
{
// ... if no jpeg...
$non_exif_images_array[] = $eintrag[1];
}
}
// Sort array with EXIF enables files by key (=timestamp)
ksort($exif_images_array);
// Sort array with non EXIF files by name
natsort($non_exif_images_array);
// Merge arrays
$this->pictures = array();
reset($exif_images_array);
reset($non_exif_images_array);
while($out = each($exif_images_array))
{
$this->pictures[] = $out[1];
}
while($out = each($non_exif_images_array))
{
$this->pictures[] = $out[1];
}
}
}
/*--------------------------------------------------------------------*/
/* Generate context sensitive forward link */
/*--------------------------------------------------------------------*/
function forward()
{
if(isset($_GET["pic"]))
{
$aktId = abs($_GET["pic"]);
$navArray = $this->pictures;
$nextId = $aktId + 1;
if(isset($navArray[$nextId]))
{
$output = "<a href='./?pic=$nextId' class='navlink'>".$this->link_vor."</a>";
}
else
{
$output = "<span class='navlink_inactive'>".$this->link_vor."</span>";
}
}
else
{
$totalpics = count($this->pictures);
if($totalpics > $thumbs_per_page AND $this->thumbs_per_page > 0)
{
$total_pages = ceil($totalpics / $this->thumbs_per_page);
if(isset($_GET["page"]))
{
$actual_page = abs($_GET["page"]);
if($actual_page < 1)
{
$actual_page = 1;
}
}
else
{
$actual_page = 1;
}
$next_page = $actual_page + 1;
if($actual_page < $total_pages)
{
$output = "<a href='./?page=$next_page' class='navlink'>".$this->page_vor."</a>";
}
else
{
$output = "<span class='navlink_inactive'>".$this->page_vor."</span>";
}
}
else
{
if($this->show_nav==1)
{
$output = "<span class='navlink_inactive'>".$this->page_vor."</span>";
}
else
{
$output = "";
}
}
}
return $output;
}
/*--------------------------------------------------------------------*/
/* Generate context sensitive backward link */
/*--------------------------------------------------------------------*/
function back()
{
if(isset($_GET["pic"]))
{
$aktId = abs($_GET["pic"]);
$navArray = $this->pictures;
$prevId = $aktId - 1;
if(isset($navArray[$prevId]))
{
$output = "<a href='./?pic=$prevId' class='navlink'>".$this->link_zurueck."</a>";
}
else
{
$output = "<span class='navlink_inactive'>".$this->link_zurueck."</span>";
}
}
else
{
$totalpics = count($this->pictures);
if($totalpics > $thumbs_per_page AND $this->thumbs_per_page > 0)
{
$total_pages = ceil($totalpics / $this->thumbs_per_page);
if(isset($_GET["page"]))
{
$actual_page = abs($_GET["page"]);
if($actual_page > ceil($totalpics / $this->thumbs_per_page))
{
$actual_page = ceil($totalpics / $this->thumbs_per_page);
}
}
else
{
$actual_page = 1;
}
$previous_page = $actual_page - 1;
if($actual_page > 1)
{
$output = "<a href='./?page=$previous_page' class='navlink'>".$this->page_zurueck."</a>";
}
else
{
$output = "<span class='navlink_inactive'>".$this->page_zurueck."</span>";
}
}
else
{
if($this->show_nav==1)
{
$output = "<span class='navlink_inactive'>".$this->page_zurueck."</span>";
}
else
{
$output = "";
}
}
}
return $output;
}
/*--------------------------------------------------------------------*/
/* Generate context sensitive up link */
/*--------------------------------------------------------------------*/
function up()
{
if(isset($_GET["pic"]))
{
$totalpics = count($this->pictures);
if($totalpics > $this->thumbs_per_page AND $this->thumbs_per_page > 0)
{
$current_pic = $_GET["pic"];
$current_page = ceil(($current_pic + 1) / $this->thumbs_per_page);
$output = "<a href='./?page=$current_page' class='navlink'>".$this->link_up."</a>";
}
else
{
$output = "<a href='./' class='navlink'>".$this->link_up."</a>";
}
}
else
{
if($this->show_nav==1)
{
$output = "<span class='navlink_inactive'>".$this->link_up."</span>";
}
else
{
$output = "";
}
}
return $output;
}
/*--------------------------------------------------------------------*/
/* Generate pages link series */
/*--------------------------------------------------------------------*/
function pages()
{
if(!isset($_GET["pic"]) AND $this->thumbs_per_page > 0)
{
$totalpics = count($this->pictures);
if($totalpics > $this->thumbs_per_page)
{
if(isset($_GET["page"]))
{
$actual_page = abs($_GET["page"]);
if($actual_page > ceil($totalpics / $this->thumbs_per_page))
{
$actual_page = ceil($totalpics / $this->thumbs_per_page);
}
elseif($actual_page == 0)
{
$actual_page = 1;
}
}
else
{
$actual_page = 1;
}
for($current_page = 1; $current_page <= ceil($totalpics / $this->thumbs_per_page) ;$current_page++)
{
if($current_page == $actual_page)
{
$output .= "<b>$current_page</b> ";
}
else
{
$output .= "<a href='?page=$current_page'>$current_page</a> ";
}
}
}
}
else
{
$output = "";
}
return $output;
}
/*--------------------------------------------------------------------*/
/* Generate EXIF Information */
/*--------------------------------------------------------------------*/
function showExif()
{
if(isset($_GET["pic"]))
{
$pic = abs($_GET["pic"]);
$totalpics = count($this->pictures);
$hoechster_index = (count($this->pictures)-1);
if($pic > $hoechster_index)
{
/* $output = "<span class='exif_inactive'>Filename:
none | Filesize: none | Date:
none | Time: none | Camera:
none</span>"; */
}
else
{
$zeile = $this->pictures[$pic];
$zeilen_arr = explode(";;;", $zeile);
$dateiname = $zeilen_arr[0];
$dateigroesse = round((filesize("./$dateiname")/1024),1)." KB";
$dateiname_arr = array_reverse(explode(".", $dateiname));
if((strtolower($dateiname_arr[0])=="jpg")OR(strtolower($dateiname_arr[0])=="jpeg"))
{
if(@function_exists(read_exif_data))
{
$exif_daten = @read_exif_data("./$dateiname");
if(isset($exif_daten["DateTimeOriginal"]))
{
$datum_zeit = explode(" ", $exif_daten["DateTimeOriginal"]);
$datum_roh = $datum_zeit[0];
$jahr = substr($datum_roh, 0, 4);
$monat = substr($datum_roh, 5, 2);
$tag = substr($datum_roh, 8, 2);
$datum = "$tag.$monat.$jahr";
$zeit = substr($datum_zeit[1], 0, 5);
$kamera = $exif_daten["Model"]. " (".$exif_daten["Make"].")";
$blende = $exif_daten["FNumber"];
$belichtungszeit = $exif_daten["ExposureTime"]." seconds";
$blitz_roh = $exif_daten["Flash"];
$blitz = "No";
if($blitz_roh%2==1)
{
$blitz = "Yes";
}
$no_exif_flag = 0;
}
else
{
$no_exif_flag = 1;
$datum = "-";
$kamera = "-";
$blende = "-";
$belichtungszeit = "-";
$zeit = "-";
}
}
elseif(@function_exists(exif_read_data))
{
// If 'wrong' routine is supported, do nothing
$datum = "-";
$kamera = "-";
$blende = "-";
$belichtungszeit = "-";
$zeit = "-";
$blitz = "-";
}
else
{
// If no EXIF routine is supported...
$datum = "-";
$kamera = "-";
$blende = "-";
$belichtungszeit = "-";
$zeit = "-";
$blitz = "-";
}
if($no_exif_flag == 1)
{
/* $output = "<span class='exif'><span class='exif_titel'>Filename:</span>
$dateiname | <span class='exif_titel'>Filesize:</span> $dateigroesse</span>"; */
}
else
{
$output = "<span class='exif'><span class='exif_titel'>Filename:</span>
$dateiname | <span class='exif_titel'>Filesize:</span> $dateigroesse | <span class='exif_titel'>Date:</span>
$datum | <span class='exif_titel'>Time:</span> $zeit | <span class='exif_titel'>Camera:</span>
$kamera | <span class='exif_titel'>Aperture:</span> $blende | <span class='exif_titel'>Exposure:</span> $belichtungszeit | <span class='exif_titel'>Flash:</span> $blitz</span>";
}
}
else
{
$output = "<span class='exif'><span class='exif_titel'>Filename:</span>
$dateiname | <span class='exif_titel'>Filesize:</span> $dateigroesse</span>";
}
}
}
else
{
if($this->show_nav==1)
{
/* Bilder beschreibung */
/* $output = "<span class='exif_inactive'>Filename:
none | Filesize: none | Date:
none | Time: none | Camera:
none</span>"; */
}
else
{
$output = "";
}
}
return $output;
}