#!/usr/bin/perl -w
# http://sandiegogeologists.org/cgi-bin/newslist.cgi: reports meeting reservations and food choice totals
# Carolyn Glockhoff  19 January 2007   this program lists all past newsletters in the directory as links for users to download

use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);

print <<END_TOP;
Content-type: text/html

<HTML>
<HEAD>
<TITLE>SDAG Newsletter Archive</TITLE>
<STYLE type="text/css">
<!--
BODY, TD, H3 { font-family: Palatino, Times New Roman, Times, serif; color:#000000}
H1 {  font-family: Palatino, Times New Roman, Times, serif}
-->
</STYLE>
</HEAD>
<BODY BGCOLOR="#CCCCCC" background="../images/Granite.gif" TEXT="#000000" LINK="#0033FF"> 
<H1><A HREF="../Newsletter.pdf"><IMG SRC="../images/NewsButton.gif" alt="newsletters"></A> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SDAG Newsletter Archive</H1>
END_TOP

no strict;

opendir(NEWSLETTERS, "../newsletters") || dienice ("Can't open newsletters directory for reading: $!");
foreach $name (sort readdir(NEWSLETTERS)) {# list file names of newsletters as links
	if (-d $name) { #don't set up links to directory level
		print "\n";}
	else {
		print "<A HREF='../newsletters/".$name."'>$name</A><BR>\n"; 
	} 
}
closedir(NEWSLETTERS);
print "<BR> \n";

print <<END_BOTTOM;
<H3>
<A HREF="../index.html">SDAG home</A>
</H3>
</BODY>
</HTML>
END_BOTTOM

sub dienice {
	my ($msg) = @_;
	print "<H2>Error</H2>\n";
	print "$msg";
	exit;
}