Files
d-t-n.org/archive/version_01/resources.pl
2017-03-02 21:36:05 -06:00

618 lines
19 KiB
Perl
Executable File

#! /usr/bin/perl -w
#
########################################
#
# displays resources page for DTN site
# written by benjamin ramey
# bsr@rameydesign.net
# april, 2004
#
########################################
$data_file = "./data/resources_data.txt";
print "Content-type: text/html\n\n";
&Print_Top_HTML;
&Articles;
&Books_And_Other;
&On_Leadership;
&Teaching_Outlines;
&Tools_For_Min;
&Tools_For_Personal;
&Links;
&Print_Bottom_HTML;
exit;
################################################################################################################################################
# SUB ROUTINES FOR DYNAMIC HTML
################################################################################################################################################
sub Articles
{
my $in_section = 0;
print<<"HTML";
<table class="section_table" cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="corner">\&nbsp\;</td>
<td class="header" align="left">Articles\&nbsp\;\&nbsp\;\&nbsp\;<span class="top_anchor"><a name="articles" href="#top">\&nbsp\;</a></span></td>
<td>\&nbsp\;</td>
</tr>
<tr>
<td align="left" valign="top">\&nbsp\;</td>
<td colspan="2" class="content_column">
<b>Click on "view article", next to each article to open it up in a new window.</b>
<ul>
HTML
open( INFILE, $data_file ) or print "<span style='font-weight: bold; color: red'>ERROR: Could not open $data_file.</span>";
while( my $file_line = <INFILE> )
{
if( $file_line =~ m/<articlesection>/ ) { $in_section = 1; }
if( $file_line =~ m/<\/articlesection>/ ) { $in_section = 0; }
if( ($file_line =~ m/<title>(.*)<\/title>/) && $in_section ) { print "<li>$1 | \n\t"; }
if( ($file_line =~ m/<link>(.*)<\/link>/) && $in_section )
{
my $link = $1;
$link =~ s/([ ,',",\\,\/,-])/sprintf( "%%%lx", (unpack( "C", $1 )) )/eg;
print "<a href=\"javascript:void(0)\" onclick=\"window.open( './resources_pages/articles/$link', '_blank', 'width=750, height=500, scrollbars=yes, resizeable=yes' )\">view article</a></li>\n";
}
}
close( INFILE );
print<<"HTML";
</ul>
</td>
</tr>
</table>
HTML
}
sub Books_And_Other
{
my $in_section = 0;
print<<"HTML";
<table class="section_table" cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="corner">\&nbsp\;</td>
<td class="header" align="left">Books & Other Information\&nbsp\;\&nbsp\;\&nbsp\;<span class="top_anchor">/ <a name="books_other_info" href="#top">top</a> /</span></td>
<td>\&nbsp\;</td>
</tr>
<tr>
<td align="left" valign="top">\&nbsp\;</td>
<td colspan="2" class="content_column">
HTML
open( INFILE, $data_file ) or print "<span style='font-weight: bold; color: red'>ERROR: Could not open $data_file.</span>";
while( my $file_line = <INFILE> )
{
if( $file_line =~ m/<books_otherinfo>/ ) { $in_section = 1; }
if( $file_line =~ m/<\/books_otherinfo>/ ) { $in_section = 0; }
if( ($file_line =~ m/<name>(.*)<\/name>/) && $in_section )
{
my $section_name = $1;
print<<"HTML";
<b style="text-decoration: underline">$section_name:</b>
<blockquote>
HTML
$file_line = <INFILE>;
chomp( $file_line );
$file_line =~ s/.*<files>(.*)<\/files>.*/$1/;
my @files = split( /,/, $file_line );
foreach my $file ( @files )
{
my $display_name = $file;
$display_name =~ s/\.htm//;
$file =~ s/([ ,',",\\,\/,-])/sprintf( "%%%lx", (unpack( "C", $1 )) )/eg;
print "<a href=\"javascript:void(0)\" onclick=\"window.open( './resources_pages/books/$section_name/$file', '_blank', 'width=750, height=500, scrollbars=yes, resizeable=yes' )\">$display_name</a><br />\n";
}
print "\t\t\t</blockquote>\n";
}
}
close( INFILE );
print<<"HTML";
</td>
</tr>
</table>
HTML
}
sub On_Leadership
{
my $in_section = 0;
print<<"HTML";
<table class="section_table" cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="corner">\&nbsp\;</td>
<td class="header" align="left">On Leadership\&nbsp\;\&nbsp\;\&nbsp\;<span class="top_anchor">/ <a name="on_leadership" href="#top">top</a> /</span></td>
<td>\&nbsp\;</td>
</tr>
<tr>
<td align="left" valign="top">\&nbsp\;</td>
<td colspan="2" class="content_column">
<b>Click on each link to open a window with the subject material in it.</b>
<ul>
HTML
open( INFILE, $data_file ) or print "<span style='font-weight: bold; color: red'>ERROR: Could not open $data_file.</span>";
while( my $file_line = <INFILE> )
{
if( $file_line =~ m/<onleadership>/ ) { $in_section = 1; }
if( $file_line =~ m/<\/onleadership>/ ) { $in_section = 0; }
if( ($file_line =~ m/<file>(.*)<\/file>/) && $in_section )
{
my $file = $1;
my $display_name = $file;
$display_name =~ s/\.htm//;
$file =~ s/([ ,',",\\,\/,-])/sprintf( "%%%lx", (unpack( "C", $1 )) )/eg;
print "<li><a href=\"javascript:void(0)\" onclick=\"window.open( './resources_pages/onleadership/$file', '_blank', 'width=750, height=500, scrollbars=yes, resizeable=yes' )\">$display_name</a></li>\n";
}
}
close( INFILE );
print<<"HTML";
</ul>
</td>
</tr>
</table>
HTML
}
sub Teaching_Outlines
{
my $in_section = 0;
print<<"HTML";
<table class="section_table" cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="corner">\&nbsp\;</td>
<td class="header" align="left">Teaching Outlines\&nbsp\;\&nbsp\;\&nbsp\;<span class="top_anchor">/ <a name="teaching_outlines" href="#top">top</a> /</span></td>
<td>\&nbsp\;</td>
</tr>
<tr>
<td align="left" valign="top">\&nbsp\;</td>
<td colspan="2" class="content_column">
<b>Click on each link to open a window with the subject material in it.</b>
<ul>
HTML
open( INFILE, $data_file ) or print "<span style='font-weight: bold; color: red'>ERROR: Could not open $data_file.</span>";
while( my $file_line = <INFILE> )
{
if( $file_line =~ m/<teachingoutlines>/ ) { $in_section = 1; }
if( $file_line =~ m/<\/teachingoutlines>/ ) { $in_section = 0; }
if( ($file_line =~ m/<file>(.*)<\/file>/) && $in_section )
{
my $file = $1;
my $display_name = $file;
$display_name =~ s/\.htm//;
$file =~ s/([ ,',",\\,\/,-])/sprintf( "%%%lx", (unpack( "C", $1 )) )/eg;
print "<li><a href=\"javascript:void(0)\" onclick=\"window.open( './resources_pages/teachingoutlines/$file', '_blank', 'width=750, height=500, scrollbars=yes, resizeable=yes' )\">$display_name</a></li>\n";
}
}
close( INFILE );
print<<"HTML";
</ul>
</td>
</tr>
</table>
HTML
}
sub Tools_For_Min
{
my $in_section = 0;
print<<"HTML";
<table class="section_table" cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="corner">\&nbsp\;</td>
<td class="header" align="left">Tools For Ministry: Local Church\&nbsp\;\&nbsp\;\&nbsp\;<span class="top_anchor">/ <a name="tools_for_min" href="#top">top</a> /</span></td>
<td>\&nbsp\;</td>
</tr>
<tr>
<td align="left" valign="top">\&nbsp\;</td>
<td colspan="2" class="content_column">
<b>Click on each link to open a window with the subject material in it.</b>
HTML
open( INFILE, $data_file ) or print "<span style='font-weight: bold; color: red'>ERROR: Could not open $data_file.</span>";
my $in_top = 0;
while( my $file_line = <INFILE> )
{
if( $file_line =~ m/<toolsforministry>/ ) { $in_section = 1; }
if( $file_line =~ m/<\/toolsforministry>/ ) { $in_section = 0; }
if( ($file_line =~ m/<top>/) && $in_section )
{
print "\t\t<ul>\n";
$in_top = 1;
while( ($file_line = <INFILE>) && $in_top )
{
if( $file_line =~ m/<\/top>/ ) { $in_top = 0; }
elsif( $file_line =~ m/<file>(.*)<\/file>/ )
{
my $file = $1;
my $display_name = $file;
$display_name =~ s/\.\w{3}$//;
$file =~ s/([ ,',",\\,\/,-])/sprintf( "%%%lx", (unpack( "C", $1 )) )/eg;
print "<li><a href=\"javascript:void(0)\" onclick=\"window.open( './resources_pages/toolsforministry/$file', '_blank', 'width=750, height=500, scrollbars=yes, resizeable=yes' )\">$display_name</a></li>\n";
}
}
print "\t\t</ul>\n";
}
if( ($file_line =~ m/<subsection>/) && $in_section ) { &Do_Subsection( \*INFILE, "toolsforministry" ); }
}
close( INFILE );
print<<"HTML";
</td>
</tr>
</table>
HTML
}
sub Tools_For_Personal
{
my $in_section = 0;
print<<"HTML";
<table class="section_table" cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="corner">\&nbsp\;</td>
<td class="header" align="left">Tools For Personal\&nbsp\;\&nbsp\;\&nbsp\;<span class="top_anchor">/ <a name="tools_for_personal" href="#top">top</a> /</span></td>
<td>\&nbsp\;</td>
</tr>
<tr>
<td align="left" valign="top">\&nbsp\;</td>
<td colspan="2" class="content_column">
<b>Click on each link to open a window with the subject material in it.</b>
HTML
open( INFILE, $data_file ) or print "<span style='font-weight: bold; color: red'>ERROR: Could not open $data_file.</span>";
my $in_top = 0;
while( my $file_line = <INFILE> )
{
if( $file_line =~ m/<toolsforpersonal>/ ) { $in_section = 1; }
if( $file_line =~ m/<\/toolsforpersonal>/ ) { $in_section = 0; }
if( ($file_line =~ m/<top>/) && $in_section )
{
print "\t\t<ul>\n";
$in_top = 1;
while( ($file_line = <INFILE>) && $in_top )
{
if( $file_line =~ m/<\/top>/ ) { $in_top = 0; }
elsif( $file_line =~ m/<file>(.*)<\/file>/ )
{
my $file = $1;
my $display_name = $file;
$display_name =~ s/\.\w{3}$//;
$file =~ s/([ ,',",\\,\/,-])/sprintf( "%%%lx", (unpack( "C", $1 )) )/eg;
print "<li><a href=\"javascript:void(0)\" onclick=\"window.open( './resources_pages/toolsforpersonal/$file', '_blank', 'width=750, height=500, scrollbars=yes, resizeable=yes' )\">$display_name</a></li>\n";
}
}
print "\t\t</ul>\n";
}
if( ($file_line =~ m/<subsection>/) && $in_section ) { &Do_Subsection( \*INFILE, "toolsforpersonal" ); }
}
close( INFILE );
print<<"HTML";
</td>
</tr>
</table>
HTML
}
sub Links
{
print<<"HTML";
<table class="section_table" cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="corner">\&nbsp\;</td>
<td class="header" align="left">Links\&nbsp\;\&nbsp\;\&nbsp\;<span class="top_anchor">/ <a name="links" href="#top">top</a> /</span></td>
<td>\&nbsp\;</td>
</tr>
<tr>
<td align="left" valign="top">\&nbsp\;</td>
<td colspan="2" class="content_column">
This section displays all the links throughout the DtN site. This includes all e-mail addresses and web addresses being linked to from here.
The links are arranged according to which page they are found on.<br />&nbsp;<br />
HTML
open( INFILE, "./data/links_data.txt" ) or print "<span style='font-weight: bold; color: red'>ERROR: Could not open links_data.txt file.</span>";
my $col_count = 0;
print "<table cellpadding='15' cellspacing='0' style=\"font-size: 12px;\">\n\t<tr>\n";
while( my $fl = <INFILE> )
{
my @links = splice( @links );
if( $fl =~ m/<page name="(.*)">/ )
{
my $page_name = $1;
my $path = $1;
$page_name =~ s/(.*)\.\w{2,3}/$1/;
$in_page = 1;
if( $page_name eq 'whoweare' ) { $page_name = "Who We Are"; }
elsif( $page_name eq 'resources' ) { $page_name = "Resources"; }
elsif( $page_name eq 'prayer' ) { $page_name = "Prayer Requests"; }
elsif( $page_name eq 'travel' ) { $page_name = "Mission & Travel"; }
elsif( $page_name eq 'media' ) { $page_name = "Photos / Videos"; }
if( $col_count == 2 )
{
print "\t</tr>\n\t<tr>\n";
$col_count = 0;
}
if( $col_count == 0 ) { print "\t\t<td align='left' valign='top' width='50%' style='border: #000000 solid; border-width: 0px 1px 0px 0px;'><b style='text-decoration: underline'>$page_name page:</b><br />\n"; }
else { print "\t\t<td align='left' valign='top' width='50%'><b style='text-decoration: underline'>$page_name page:</b><br />\n"; }
while( $in_page )
{
$fl = <INFILE>;
if( $fl =~ m/<\/page>/ ) { $in_page = 0; }
else
{
$fl =~ s/.*<(.*)>(.*)<\/.*>.*/$2/;
my $link = $2;
$link =~ s/\\@/@/g;
push( @links, $link );
}
}
foreach my $pair ( sort @links )
{
my ($name, $link) = split( /=/, $pair );
if( $link =~ m/@/ ) { print "<a href=\"mailto:$link\">$name</a><br />\n"; }
elsif( $link =~ m/#/ ) { print "<a href=\"./$path$link\">$name</a><br />\n"; }
else { print "<a href=\"$link\">$name</a><br />\n"; }
}
print "\t\t</td>\n";
$col_count++;
}
}
print "\t</tr>\n</table>\n";
close( INFILE );
print<<"HTML";
</td>
</tr>
</table>
HTML
}
###############processes subsections for both "tools" sections####################
sub Do_Subsection
{
my $fh = shift;
my $line = 0;
my $in_sub = 1;
my $main_folder = shift;
my $file_path = shift;
while( $in_sub )
{
$line = <$fh>;
if( $line =~ m/<subsection>/ ) { &Do_Subsection( \*$fh, $main_folder, $file_path ); }
if( $line =~ m/<\/subsection>/ ) { $in_sub = 0; }
if( $line =~ m/<name>(.*)<\/name>/ )
{
print "<blockquote>\n<b style='text-decoration: underline'>$1:</b>\n";
print "\t\t<ul>\n";
$file_path .= $1 . '/';
}
elsif( $line =~ m/<file>(.*)<\/file>/ )
{
my $file = $1;
my $display_name = $file;
$display_name =~ s/\.\w{3}$//;
$file =~ s/([ ,',",\\,\/,-])/sprintf( "%%%lx", (unpack( "C", $1 )) )/eg;
print "<li><a href=\"javascript:void(0)\" onclick=\"window.open( './resources_pages/$main_folder/$file_path$file', '_blank', 'width=750, height=500, scrollbars=yes, resizeable=yes' )\">$display_name</a></li>\n";
}
}
print "\t\t</ul>\n";
print "</blockquote>\n";
}
################################################################################################################################################
# SUB ROUTINES FOR PRINTING GENERIC HTML
################################################################################################################################################
##############displays top of media page##############
sub Print_Top_HTML
{
print <<"HTML";
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Disciple the Nations - Resources</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="dtn.css" />
<link rel="stylesheet" type="text/css" href="dtn_resources.css" />
<SCRIPT SRC="ssm.js" language="JavaScript1.2">
//Dynamic-FX slide in menu v6.5 (By maXimus, maximus\@nsimail.com)
//Site: http://maximus.ravecore.com/
//For full source, and 100's more DHTML scripts, visit http://www.dynamicdrive.com
</SCRIPT>
<SCRIPT SRC="ssmItems_resources.js" language="JavaScript1.2"></SCRIPT>
<script language="javascript" type="text/javascript" src="random_verse.js"></script>
</head>
<body>
<a name="top"></a>
<div align="left">
<table cellpadding="0" cellspacing="0" width="100%">
<tr>
<td class="first_strip" colspan="3"><a name="#top"><img src="graphics/spacer.gif" border="0" width="1" height="10" /></a></td>
</tr>
<tr>
<td class="second_strip_top" colspan="3"><img src="graphics/spacer.gif" border="0" width="1" height="10" /></td>
</tr>
<tr>
<td align="left" colspan="2">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td>\&nbsp\;</td>
<td align="right">
<span style="font-size: 12px; margin-right: 10px" align="center">
<a href="home.htm" class="location">home</a> |
<a href="whoweare.pl" class="location">who we are</a> |
<a href="resources.pl" class="location">resources</a> |
<a href="prayer.pl" class="location">prayer requests</a> |
<a href="travel.pl" class="location">mission & travel</a> |
<a href="media.pl" class="location">photos/videos</a>
</span>
</td>
</tr>
</table>
</td>
<td><img src="graphics/spacer.gif" border="0" width="1" height="20" /></td>
</tr>
<tr>
<td valign="top" style="background-image: url( graphics/resources/sidebar_bg.gif );" width="195">
<img src="graphics/resources/sidebar_dtn_logo.gif" /><br />
<img src="graphics/resources/sidebar_resources.gif" />
</td>
<td width="100%" valign="top" class="content_table" align="left">
<table cellpadding="0" cellspacing="0" style="margin-top: 2px" width="100%">
<tr>
<td valign="bottom" align="left">
<img src="graphics/resources/resources_title.gif" /><br />
<span class="location" style="margin-left: 15px;">
<script language="javascript" type="text/javascript">
<!--
Random_Verse();
//-->
</script>
</span>
</td>
</tr>
<tr>
<td align="center">
<table cellpadding="0" cellspacing="0" width="100%" class="sub_link_div">
<tr>
<td align="center">
<a href="#articles" class="sub_link_table">articles</a> |
<a href="#books_other_info" class="sub_link_table">books & other info</a> |
<a href="#on_leadership" class="sub_link_table">on leadership</a> |
<a href="#teaching_outlines" class="sub_link_table">teaching outlines</a> |
<a href="#tools_for_min" class="sub_link_table">tools for min.: local church</a> |
<a href="#tools_for_personal" class="sub_link_table">tools for personal</a> |
<a href="#links" class="sub_link_table">links</a>
</td>
</tr>
</table>
</td>
</tr>
</table>
HTML
}
##############displays bottom of media page##############
sub Print_Bottom_HTML
{
print <<"HTML";
</td>
<td><img src="graphics/spacer.gif" width="15" height="1" /></td>
</tr>
<tr>
<td><img src="graphics/spacer.gif" border="0" width="1" height="20" /></td>
<td align="center" style="padding: 5px 0px 5px 0px">
<span style="font-size: 12px" align="center">
<a href="whoweare.pl">who we are</a> |
<a href="resources.pl">resources</a> |
<a href="prayer.pl">prayer requests</a> |
<a href="travel.pl">mission & travel</a> |
<a href="media.pl">photos/videos</a>
</span>
</td>
<td>\&nbsp\;</td>
</tr>
<tr>
<td class="second_strip_bottom" colspan="3"><img src="graphics/spacer.gif" border="0" width="1" height="10" /></td>
</tr>
<tr>
<td class="first_strip" colspan="3">all site content copyright of Disciple the Nations, all rights reserved | site designed by <a href="http://www.rameydesign.net" target="_blank" class="first_strip">ramey design</a></td>
</tr>
</table>
</div>
</body>
</html>
HTML
}