Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
#!/usr/bin/perl -w ## Quick and Dirty Online Photo Album ## by John J Reiser (newrisedesigns) use strict; use CGI; use HTML::Template; my $cgi = "/cgi-bin/"; #CGI Location my $url = "/photoalbum/"; #IMG SRC - needs trailing +slash my $server = ''; #Server - NO trailing sla +sh my $root = "../../httpdocs/photoalbum/"; #Filesystem - needs + trailing slash my $template = "template.html"; #file (in photo director +y) my $q = CGI->new(); my $t = HTML::Template->new(filename => $root . $template); my $album = $q->param('album') || ''; if($album =~ /(\w+)/){ $album = $1; } else{ $album = ''; } if($album eq ''){ my @dir = finddir($root); my $form; $form = $q->start_form(-method=>"POST"); $form .= $q->p($q->popup_menu(-name=>"album", -value=>[@dir])); $form .= $q->p($q->submit()); $form .= $q->end_form; $t->param(DIR => "Choose an album to view"); $t->param(RLINK => $form); print $q->header(); print $t->output(); } else{ my $rlink = q[<a href="] . $cgi . q[?">click here to view a different +album</a>]; my $dlink = $server . $cgi . '?album=' . $album; $album .= '/'; $url .= $album; $t->param(DIR => $album); $t->param(SHOWLINK => 1); $t->param(RLINK => $rlink); $t->param(DLINK => $dlink); my $fh; opendir($fh, $root . $album) or die("Cannot open $root$album $!"); my @files = sort grep(/\.jpg$/, readdir($fh)); closedir($fh); my @tags; foreach(@files){ my $tag = q[<img src="] . $url . $_ . q[" alt="" border="0">]; push(@tags, {'TAG' => $tag}); } $t->param(PICTURES => \@tags); print $q->header(); print $t->output(); } sub finddir{ my $dir = shift; my $fh; chdir($dir); opendir($fh, '.'); my @files = sort grep((-d $_) && ($_ !~ /\./), readdir($fh)); closedir($fh); return @files; } __END__ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:/ +/"> <html> <head> <title>photo album</title> <style> <!-- .small { font-size: .75em; } --> </style> </head> <body bgcolor="#FFFFFF"> <h1><TMPL_VAR NAME="DIR"></h1> <TMPL_IF NAME="SHOWLINK"> <p class="small">Link directly to this album:<br /><TMPL_VAR NAME= +"DLINK"></p> </TMPL_IF> <div align="center" class="small"><TMPL_VAR NAME="RLINK"></div> <TMPL_LOOP NAME="PICTURES"> <p align="center"><TMPL_VAR NAME="TAG"></p> </TMPL_LOOP> </body> </html>

In reply to Quick-n-dirty Photo Album by newrisedesigns

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others cooling their heels in the Monastery: (8)
    As of 2020-04-02 20:00 GMT
    Find Nodes?
      Voting Booth?
      The most amusing oxymoron is:

      Results (26 votes). Check out past polls.