Flash Gallery Galerie für die Webseite

SimpleViewer ist ein kostenloser Flash-Image-Viewer. Die Einstellungen zum Wiedergeben von Fotos werden in einer XML Datei gespeichert. Damit es richtig funktioniert, benötiggt der Viewer nicht nur einen Ordner mit Bildern, sondern auch einen mit Thumbs / Vorschaubildern. Um die zwei Sachen, XML Datei und Thumbs,  zu sparen, habe ich einen Script geschrieben, der sie ersetzt.

Code:

<?php
/** File: gallery.php
* created by Freeware Eugen -> http://eugens-web.com
* 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.
* http://www.gnu.org/licenses/gpl.html
*
**/

/** example code for html file
 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>SimpleViewer</title>
<script type="text/javascript" src="swfobject.js"></script>
</head>
<body>
 
 <script type="text/javascript">
   
        var fo = new SWFObject("viewer.swf", "viewer", "100%", "100%", "8", "#181818");
       
        // SIMPLEVIEWER CONFIGURATION OPTIONS
        // To use an option, uncomment it by removing the "//" at the start of the line
        // For a description of config options, go to:
        // http://www.airtightinteractive.com/simpleviewer/options.html
       
        fo.addVariable("xmlDataPath", "gallery.php?url=Z2FsbGVyeS5waHA/aW1ncGF0aD1maWxlcy9iZWxsLyZ3PTYwM
CZoPTc1MCZ0aHJvdz0yJnRoY29sPTUmbmF2cG9zPWJvdHRvbSZmcm13PTIwJnN0Z
3A9MTAmZXJjbz10cnVlJnR4dGM9ZmZmZmZmJmZybWM9ZmZmZmZm");
        //fo.addVariable("firstImageIndex", "5");   
        //fo.addVariable("langOpenImage", "Open Image in New Window");
        //fo.addVariable("langAbout", "About");   
        //fo.addVariable("preloaderColor", "0xFFFFFF");
        fo.write("flashcontent");   
    </script>
    </body>
  </html>
*/
 
 

/* Redirect */
$redirurl = $_GET["url"];
if ($redirurl){
 header('Location: '.base64_decode($redirurl)); /* redir url must be base64 encoded */
}

/* Options images*/
$width = $_GET["w"];
$height = $_GET["h"];
$textcolor = $_GET["txtc"];
$framecolor = $_GET["frmc"];
$framewidth = $_GET["frmw"];
$stagepadding = $_GET["stgp"];
$thumbsnailcolumns = $_GET["thcol"]; /* columns of thumbs */
$thumbnailrows = $_GET["throw"]; /* rows of thumbs */
$navposition = $_GET["navpos"]; /* navigation position - right, bottom, left, top */
$title = $_GET["t"]; /* gallery title */
$enablerightclickopen = $_GET["erco"]; /* true or false */
$bgimage = $_GET["bgimg"]; /* background image */
$imgpath = $_GET["imgpath"]; /* Path to image dir --> for example: files/images/gallery1/  --> gallery.php?imgpath=files/images/gallery1/ */

/*Options thumbs */
$thumb = $_GET["thumb"]; /* thumb folder */
$thumbwidth = $_GET["thumbw"];
if ($thumbwidth){} else{$thumbwidth = "100";}

/* PHP Thumb Function
* Author: Simon Jarvis
* Copyright: 2006 Simon Jarvis
* Date: 08/11/06
* Link: http://www.white-hat-web-design.co.uk/articles/php-image-resizing.php
*
* 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:
* http://www.gnu.org/licenses/gpl.html
*
*/
 
class SimpleImage {
  
   var $image;
   var $image_type;
 
   function load($filename) {
      $image_info = getimagesize($filename);
      $this->image_type = $image_info[2];
      if( $this->image_type == IMAGETYPE_JPEG ) {
         $this->image = imagecreatefromjpeg($filename);
      } elseif( $this->image_type == IMAGETYPE_GIF ) {
         $this->image = imagecreatefromgif($filename);
      } elseif( $this->image_type == IMAGETYPE_PNG ) {
         $this->image = imagecreatefrompng($filename);
      }
   }
   function save($filename, $image_type=IMAGETYPE_JPEG, $compression=75, $permissions=null) {
      if( $image_type == IMAGETYPE_JPEG ) {
         imagejpeg($this->image,$filename,$compression);
      } elseif( $image_type == IMAGETYPE_GIF ) {
         imagegif($this->image,$filename);        
      } elseif( $image_type == IMAGETYPE_PNG ) {
         imagepng($this->image,$filename);
      }  
      if( $permissions != null) {
         chmod($filename,$permissions);
      }
   }
   function output($image_type=IMAGETYPE_JPEG) {
      if( $image_type == IMAGETYPE_JPEG ) {
         imagejpeg($this->image);
      } elseif( $image_type == IMAGETYPE_GIF ) {
         imagegif($this->image);        
      } elseif( $image_type == IMAGETYPE_PNG ) {
         imagepng($this->image);
      }  
   }
   function getWidth() {
      return imagesx($this->image);
   }
   function getHeight() {
      return imagesy($this->image);
   }
   function resizeToHeight($height) {
      $ratio = $height / $this->getHeight();
      $width = $this->getWidth() * $ratio;
      $this->resize($width,$height);
   }
   function resizeToWidth($width) {
      $ratio = $width / $this->getWidth();
      $height = $this->getheight() * $ratio;
      $this->resize($width,$height);
   }
   function scale($scale) {
      $width = $this->getWidth() * $scale/100;
      $height = $this->getheight() * $scale/100;
      $this->resize($width,$height);
   }
   function resize($width,$height) {
      $new_image = imagecreatetruecolor($width, $height);
      imagecopyresampled($new_image, $this->image, 0, 0, 0, 0, $width, $height, $this->getWidth(), $this->getHeight());
      $this->image = $new_image;  
   }     
}

if ($thumb){
  header('Content-Type: image/jpeg');
  $image = new SimpleImage();
  $image->load($thumb);
  $image->resizeToWidth($thumbwidth);
  $image->output();}

/* create XML File */
if ($imgpath){
header ("content-type: text/xml");
header("Cache-Control: no-cache");
header("Pragma: no-cache");
print "\n".'<?xml version="1.0" encoding="UTF-8" ?>'."\n".'<simpleviewerGallery maxImageWidth = "'.$width.'" maxImageHeight = "'.$height.'" textColor = "0x'.$textcolor.'" frameColor = "0x'.$framecolor.'" frameWidth = "'.$framewidth.'" stagePadding = "'.$stagepadding.'" thumbnailColumns = "'.$thumbsnailcolumns.'" thumbnailRows = "'.$thumbnailrows.'" navPosition = "'.$navposition.'" title = "'.$title.'" enableRightClickOpen = "'.$enablerightclickopen.'" backgroundImagePath = "'.$bgimage.'" imagePath = "'.dirname($_SERVER["PHP_SELF"]).'/'.$imgpath.'" thumbPath = "'.$_SERVER["PHP_SELF"].'?thumb='.$imgpath.'">';
if ($handle = opendir("$imgpath")) {
  // List all the files
    while (false !== ($img = readdir($handle))) {
       if (is_dir("$imgpath.$img")){} else{print "
\n<image>
<filename>$img</filename>
<caption></caption>
</image>";
    } }

    closedir($handle);
}
print "\n</simpleviewerGallery>";

} ?>

Der Code sollte in der Datei gallery.php abgespeichert werden.

Den Flash-Viewer kann man hier downloaden.