#!/usr/local/bin/perl # Script: post_newsletter.cgi # # Written by Scot Marburger starting 20Feb2000 # # Copywrite 1997 by Scot J. Marburger # BEGIN { unshift(@INC, '/www/bmwnorcal/html/cgi'); } require "CGI.pm"; require "sjm_lib.cgi"; require "home_def.cgi"; $| = 1; # no buffering, please # set up storage for form input $query = new CGI; # a hash for digits to month names $month{"01"} = "January"; $month{"02"} = "February"; $month{"03"} = "March"; $month{"04"} = "April"; $month{"05"} = "May"; $month{"06"} = "June"; $month{"07"} = "July"; $month{"08"} = "August"; $month{"09"} = "September"; $month{"10"} = "October"; $month{"11"} = "November"; $month{"12"} = "December"; # files $filestashdir = $htmlHOME."/norcal/newsletters/"; # don't forget to give $finishfile world write permissions! print $query->header; print $query->start_html( -title=>'The Newsletters of Norcal', -author=>'scot@gunsmoke.com', -BACKGROUND=>'http://www.bmwnorcal.org/norcal/images/norcal_logo_embos.gif', -BGCOLOR=>"#FFFFFF" ); $logo = "http://www.bmwnorcal.org/norcal/images/norcal_logo.gif"; print "

\n"; print "

Welcome to NorCal's Newsletter Archive

\n"; print "

Every month our endlessly toiling Editor compiles the best NorCal has to offer into a newsletter and posts it to the membership. Now, through the marvels of modern electronics and the latest in high tech software, we bring you an archive of electronic newsletters. But these aren't just any old electronic documents. No, they're Adobe PDF format files, viewable with Adobe's Acrobat Reader, which Adobe gives away to good people like you. We hope you'll enjoy the fruits of our labor, and will stop back monthly to view new issues.

"; # first we build a 3 dimentional array to hold the urls of the newsletters # dimensions are: # year # row # column # the idea is to have a 2D array for each year with 3 rows and 4 columns # representing Jan - Apr in row 0 # May - Aug in row 1 # Sep - Dec in row 3 $year_start = 5000; # !!!!Danger! Y5K problem! while ( $filename = <$filestashdir/*> ) { $filename =~ s|.*/(.*)|$1|; $filename = lc $filename; if ( $filename =~ /\d\d\d\d\-\d\d\.pdf/ ) { ( $year, $month ) = $filename =~ /(\d\d\d\d)\-(\d\d)/; # correct format or else! if ( $year_end < $year ) { $year_end = $year; # save highest year } if ( $year_start > $year ) { $year_start = $year; # save lowest year } $row = int( ( $month - 1 ) / 4 ); $col = ( $month - 1 ) % 4; $files[$year][$row][$col] = " $month{$month}"; } } # now print out the 3D array print "\n"; for ( $y = $year_start; $y <= $year_end; $y++ ) { print "\n"; # new year, so year row for ( $r = 0; $r < 3; $r++ ) { print ""; for ( $c = 0; $c < 4; $c++ ) { print ""; } print "\n"; } print "\n"; # a little space please... } print "
$y
$files[$y][$r][$c] 
 

"; print $query->end_html;