![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
|
![]() |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Letzter Eintrag im Gästebuch: Helmuth FRIEDL - 20.11.2018
Das neueste Bild: CIMG3260a.jpg - 15.11.2012 in der Test-Bildergalerie |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
![]() |
![]() |
![]() |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ![]() |
PERL Skript von meiner Bildergalerie
#!/usr/bin/perl -w
use strict; use CGI::Carp qw(fatalsToBrowser); use Image::Size 'html_imgsize'; { package main; #################################################### # Put thumbnails and pictures in your directory # # Thumbs and pictures in jpg format # # Call "/cgi-bin/gallery.pl?dir=yourdirectory" # # All pictures will be displayed in a gallery # # This script is freeware. You use this program at # # your own risk. No warranty and support is given. # #################################################### print "Content-type: text/html\n\n"; print <<END_OF; <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <!-- gallery.pl version 1 from Dobsak Jun 2006 --> <head> <meta http-equiv="content-type" content="text/html;charset=iso-8859-1"> <meta name="description" content="Die automatische Bildergalerie"> <title>Bildergalerie</title> END_OF # *** nice color mixer *** my $red = 127; my $blue = 127; my $green = 127; my $mostbright = sprintf("%x", $red+(255-$red)/8*7); my $mostbright .= sprintf("%x", $blue+(255-$blue)/8*7); my $mostbright .= sprintf("%x", $green+(255-$green)/8*7); my $morebright = sprintf("%x", $red+(255-$red)/4*3); my $morebright .= sprintf("%x", $blue+(255-$blue)/4*3); my $morebright .= sprintf("%x", $green+(255-$green)/4*3); my $bright = sprintf("%x", $red+(255-$red)/2); my $bright .= sprintf("%x", $blue+(255-$blue)/2); my $bright .= sprintf("%x", $green+(255-$green)/2); my $r = sprintf("%x", $red); if (length($r) < 2) { $r = "0" . $r; } my $b = sprintf("%x", $blue); if (length($b) < 2) { $b = "0" . $b; } my $g = sprintf("%x", $green); if (length($g) < 2) { $g = "0" . $g; } my $medium = $r . $b . $g; $r = sprintf("%x", $red/2); if (length($r) < 2) { $r = "0" . $r; } $b = sprintf("%x", $blue/2); if (length($b) < 2) { $b = "0" . $b; } $g = sprintf("%x", $green/2); if (length($g) < 2) { $g = "0" . $g; } my $dark = $r . $b . $g; $r = sprintf("%x", $red/4); if (length($r) < 2) { $r = "0" . $r; } $b = sprintf("%x", $blue/4); if (length($b) < 2) { $b = "0" . $b; } $g = sprintf("%x", $green/4); if (length($g) < 2) { $g = "0" . $g; } my $moredark = $r . $b . $g; $r = sprintf("%x", $red/8); if (length($r) < 2) { $r = "0" . $r; } $b = sprintf("%x", $blue/8); if (length($b) < 2) { $b = "0" . $b; } $g = sprintf("%x", $green/8); if (length($g) < 2) { $g = "0" . $g; } my $mostdark = $r . $b . $g; # *** CSS definitions *** print "<style type=\"text/css\"><!--\n"; print "body {\n"; print "font-family: Verdana,Arial,Helvetica,sans-serif;\n"; print "color: #000000;\n"; print "background-color: #$medium;\n"; print "font-size: 0.9em;\n"; print "}\n"; print ".outset {\n"; print "padding:7px; \n"; print "background-color: #$bright;\n"; print "border-collapse:collapse;\n"; print "border-left: 2px solid #$mostbright;\n"; print "border-top: 2px solid #$mostbright;\n"; print "border-right: 2px solid #$mostdark;\n"; print "border-bottom: 2px solid #$mostdark;\n"; print "}\n"; print "td {\n"; print "font-size: 0.8em;\n"; print "vertical-align: bottom;\n"; print "text-align: center;\n"; print "}\n"; print "--></style>\n"; print "</head><body>\n"; my %in, my $picpath, my $picsize, my $pstart, my $pic, my $nofilextension; # *** read query string *** if ($ENV{'QUERY_STRING'}) { my $buffer = $ENV{'QUERY_STRING'}; my @pairs = split(/&/, $buffer); foreach my $pair (@pairs) { (my $name, my $value) = split(/=/, $pair); $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $in{$name} = $value; } } my $dir; if ($in{'dir'}) { $dir = $in{'dir'}; } else { $dir = ""; } my $cols; if ($in{'c'}) { $cols = $in{'c'}; } else { $cols = 4; } my $rows; if ($in{'r'}) { $rows = $in{'r'}; } else { $rows = 3; } # *** define dirname, columns and rows from gallery *** # *** name of this file *** my $fname = "gallery.pl?"."dir=".$dir."&c=".$cols."&r=".$rows; # *** thumbnail prefix *** my $tn = "tn_"; my $c = 0; my $r = 0; my $step = $cols * $rows; my $start; if ($in{'start'}) { $start = $in{'start'}; } else { $start = 0; } if ($start < 0) { $start = 0; } # flag for showing one selected picture my $show; if ($in{'show'}) { $show = $in{'show'}; } else { $show = 0; } my $stop = $start + $step - 1; my $i = 0; my $s = 0; my $j = 0; my $top = ""; # *** Open directory and read all jpg's *** my $prev; my $next; my @myarr; if (opendir DIR, $ENV{'DOCUMENT_ROOT'} . "/" . $dir . "/") { while ( my $file = readdir(DIR) ) { # ** is there a top picture? *** if ($file eq "top.jpg") { $top = $file; } else { if (index(lc($file), ".jpg") > 0 && index(lc($file), "tn_") ne 0) { if ($s < $start) { # *** do not grep *** if (($start - $step) == $s) { $prev = $s; } $s++; } else { # *** grep picture filename until end *** $myarr[$r][$c] = $file; $i++; if ($j == ($stop+1)) { $next = $j; } $c++; if ($c >= $cols) { $c = 0; $r++; } } $j++; } } } closedir DIR; } # *** print gallery *** print "<table class=\"outset\" "; print "style=\"margin:auto;width:640px;padding:10px;\">\n"; # *** print nice header *** print " <tr><th colspan=\"3\">\n"; if (($show == 0) && $top) { $picpath = "/" . $dir . "/" . $top; $picsize = html_imgsize($ENV{'DOCUMENT_ROOT'}."/" . $dir . "/" . $top); print " <img src=\"$picpath\" $picsize><br>"; } print "$dir<hr noshade style=\"height:1px;\">\n"; print " </th></tr>\n"; if ($show == 1) { # we are in picture mode # *** detect current page *** $i = 0; $s = 0; while ($s <= $start) { $s = $i * $step; $i++; } my $page = int($s+1) / $step; $page = int($page); $pstart = ($page - 1) * $step; # *** print prev pic/back2page/next pic *** $prev = $start - 1; print " <tr>\n"; if ($prev < 0) { print " <th >[<< vorher]</th>\n"; } else { print " <th>[<a href=\"$fname&start=$prev&show=1\"><< vorher</a>]</th>\n"; } print " <th><a href=\"$fname&start=$pstart\">"; print "Zurück zur Seite $page</a></th>\n"; $next = $start + 1; if ($start >= ($j - 1)) { print " <th>[nächstes >>]</th>\n"; } else { print " <th>[<a href=\"$fname&start=$next&show=1\">nächstes >></a>]</th>\n"; } # *** show one selected picture *** print " </tr>\n <tr><td colspan=\"3\">\n"; $pic = $start + 1; $nofilextension = substr($myarr[0][0],0,index($myarr[0][0],".")); $picpath = "/" . $dir . "/" . $myarr[0][0]; my $descriptpath = $ENV{'DOCUMENT_ROOT'}; my $descriptpath .= "/" . $dir . "/" . $nofilextension . ".txt"; $picsize = html_imgsize($ENV{'DOCUMENT_ROOT'} . "/" . $picpath); print " <br><img src=\"$picpath\" $picsize><br>"; print "Bild $pic ($nofilextension) von $j<br>\n"; if (-e $descriptpath) { open(FILE, $descriptpath) or die("Unable to open $descriptpath"); while (<FILE>) { chomp; print " ", $_, "\n"; } } print " </td></tr>\n"; } else { # we are in thumbnail mode # *** print prev page *** print " <tr>\n"; if (defined $prev) { print " <th>[<a href=\"$fname&start=$prev\"><< vorher</a>]</th>\n"; } else { print " <th>[<< vorher]</th>\n"; } # *** print pages *** print " <th>"; print " Seite:"; for ($i = 0;$i < ($j / $step);$i++) { $s = $i * $step; $pstart = $i + 1; if ($s == $start) { print " <b>$pstart</b>"; } else { print " <a href=\"$fname&start=$s\">$pstart</a>"; } } print " </th>\n"; # *** print next page *** if ($next) { print " <th>[<a href=\"$fname&start=$next\">nächste >></a>]</th>\n"; } else { print " <th>[nächste >>]</th>\n"; } print " </tr>\n"; # *** print thumbnails from this page *** print " <tr><td colspan=\"3\"><br>"; print " <table style=\"background-color:white;margin:auto;\">\n"; $pic = $start; for ($r=0;$r <= ($rows - 1);$r++) { print " <tr>\n"; for ($c=0;$c <= ($cols - 1);$c++) { print " <td>\n"; if ($myarr[$r][$c]) { $nofilextension = substr($myarr[$r][$c],0,index($myarr[$r][$c],".")); $picpath = "/" . $dir . "/" . $tn . $myarr[$r][$c]; $picsize = html_imgsize($ENV{'DOCUMENT_ROOT'}."/".$picpath); print " <a href=\"$fname&start=$pic&show=1\">"; print "<img src=\"$picpath\" $picsize><br>\n"; print " $nofilextension</a>\n"; $pic++; } else { print " <img src=\"space.gif\" width=\"80\" height=\"60\"><br> \n"; } print " </td>\n"; } print " </tr>\n"; } print " </table>\n"; print " </td></tr>\n"; } # *** print link to my homepage *** print " <tr><td colspan=\"3\" style=\"text-align:center;\">\n"; print " <hr noshade style=\"height:1px;\">"; print "PERL-Programm von EDV Dienstleistungen Dobsak<br>\n"; print " </td></tr>\n"; print "</table>\n"; print <<END_OF; </body> </html> END_OF } |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|