#!/usr/bin/perl # Title : picindex # Function : automaticly create webpage's showing pics in selected DIR # Author : P.Schiks (C)2002 GNU / GPL # Version : v3.1 # Platform : PERL 5 # use strict; # # Customise default variables # # picture files path my $DIRPATH = "."; # full path of global index my $ROOTPATH = "../index.html"; # page title my $TITLE = "Picture index"; # name of index file my $INDEXNAME = "index.html"; my $INDEXTITLE = "Picture main index"; # name of the description file my $DESCRIPTIONFILENAME = "description.txt"; # name of preview file my $PAGENAME = "page_"; # max pictures / page , preview picture size and nr pic's / line my $MAXPICS = 32; my $HEIGHT = 120; my $WIDTH = 160; my $COUNT = 4; # my $INDEXMSG="Index"; my $PREVMSG="Prev"; my $NEXTMSG="Next"; # If you like Prev/Next buttons iso just text, define here your button image. my $INDEXPIC="/home/pascal/pics/index.gif"; my $NEXTPIC="/home/pascal/pics/next.gif"; my $PREVPIC="/home/pascal/pics/prev.gif"; my $INDEXLOGO="../index.jpg"; # # Program variables # my $FILENAME; my $DESCRIPTION; my $page; my $pagenr = 0; my $prevpagenr; my $nextpagenr; my $pagename; my $count; my $piccount; my $totalpics; # # Program start # print "Picindex v2.4 Pascal (C) 2002 GNU/GPL\n\n"; print "Page Title = $TITLE\n"; print "Index filename = $INDEXNAME\n"; print "Previewname = $PAGENAME\n\n"; # if(opendir DIRECTORY, $DIRPATH) { $totalpics=0; $piccount=0; $count=0; # if(open INDEX,">$INDEXNAME") { print INDEX "\n\n$INDEXTITLE\n\n\n"; print INDEX "

$INDEXTITLE

\n"; if($ROOTPATH) { if($INDEXLOGO) { print INDEX "
\n"; } else { print INDEX "
  • Total Index\n

    \n"; } } # while($FILENAME=readdir(DIRECTORY)) { # Filter for .jpg .JPG .gif .GIF $_ = $FILENAME; if((m/.jpg$/)||(m/.JPG$/)||(m/.gif$/)||(m/.GIF$/)||(m/.png$/)||(m/.PNG$/)) { # Figure out description if not available, just use filename $DESCRIPTION=$FILENAME; if(open(DESCRIPTIONFILE,$DESCRIPTIONFILENAME)) { while() { if(m/$FILENAME/) { s/$FILENAME //; $DESCRIPTION=$_; } } close(DESCRIPTIONFILE); } # Go on with the regulair stuff if($piccount==0) { $prevpagenr=$pagenr; $pagenr++; $nextpagenr=$pagenr+1; $pagename = "$PAGENAME$pagenr.html"; print "\n\nNew file $pagename\n"; print INDEX "
  • $pagename\n"; $page = open(PAGE,">$pagename"); if($page) { print "Creating file $pagename\n"; print PAGE "\n\n$TITLE\n\n"; print PAGE "\n"; print PAGE "

    $TITLE

    \n"; print PAGE "
    "; if($pagenr>1) { print PAGE ""; if($PREVPIC) { print PAGE "\"$PREVMSG\""; } else { print PAGE "$PREVMSG"; } print PAGE " "; } print PAGE ""; if($INDEXPIC) { print PAGE "\"$INDEXMSG\""; } else { print PAGE "$INDEXMSG "; } if($nextpagenr) { print PAGE " "; if($NEXTPIC) { print PAGE "\"$NEXTMSG\""; } else { print PAGE "$NEXTMSG"; } print PAGE ""; } print PAGE "
    "; print PAGE "\n
    \n"; print PAGE "\n"; } else { print "File $pagename could not be created\n"; } } # print $FILENAME," "; if($page) { if(!$count) { printf(PAGE " \n"); } $piccount++; $totalpics++; $count++; printf(PAGE " \n",$FILENAME,$FILENAME,$DESCRIPTION); if($count>=$COUNT) { printf(PAGE " \n"); $count = 0; } } # end preview } # end Filter # if($piccount>=$MAXPICS) { if($page) { if($count) { printf(PAGE " \n"); } print PAGE "
    ",$FILENAME); printf(PAGE "\"%s\"
    $DESCRIPTION
    \n"; print PAGE "
    \n"; print PAGE "
    "; if($pagenr>1) { print PAGE ""; if($NEXTPIC) { print PAGE "\"$NEXTMSG\""; } else { print PAGE "$NEXTMSG"; } print PAGE ""; } print PAGE " "; if($INDEXPIC) { print PAGE "\"$INDEXMSG\""; } else { print PAGE "$INDEXMSG "; } print PAGE ""; print PAGE " "; if($NEXTPIC) { print PAGE "\"$NEXTMSG\""; } else { print PAGE "$NEXTMSG"; } print PAGE "\n"; print PAGE "

    \n"; print PAGE "\n\n"; close(PAGE); } $piccount = 0; $count = 0; } } # end while $FILENAME # if($totalpics==0) { print INDEX "

    No pictures indexed

    \n"; } # if($page) { print PAGE ""; print PAGE "
    \n
    \n"; if($pagenr>1) { print PAGE "
    \n"; print PAGE ""; if($PREVPIC) { print PAGE "\"$PREVMSG\""; } else { print PAGE "$PREVMSG"; } print PAGE ""; print PAGE " "; if($INDEXPIC) { print PAGE "\"$INDEXMSG\""; } else { print PAGE "$INDEXMSG "; } print PAGE "
    \n"; } print PAGE "\n\n"; close(PREVIEW); } # print "\n\n$totalpics Pictures indexed\n"; print INDEX "
    \n"; close(INDEX); closedir(DIRECTORY); } # end if open INDEX else { print "Error, could not create $INDEXNAME\n"; } } # end if opendir else { print "Error, could not open directory $DIRPATH\n"; }