#!/usr/bin/perl require "../cgi-lib.pl"; &ReadParse(); print &PrintHeader(); $anchor = $in{"anchor"}; if ($in{"show"} eq "") { $show = 20; } else {$show = $in{"show"};} print "\n"; print "Sermons Archive\n"; print "\n"; print "Welcome to our remodeled sermons archive! Soon, you will be "; print "able to list specific sets of sermons (eg. those within a "; print "range of dates, those from a certain book in the Bible, etc.) "; print "Please keep yourself posted!

"; print "The old sermons list can be accessed here.

\n"; print "Free reader for PDF format available from: Adobe Acrobat download site.

"; open (DATA, "sermons.dat"); #open (DATA, `cat sermons.dat`); # Eat and discard the first header line of 'sermons.dat' $line = ; # Read the rest of 'sermons.dat' into a hash while ($line = ) { chop $line; @lineArray = split("\t", $line); $sermons{$lineArray[0]} = $line; } # Order the hash by date: # if specified, ascending (least recent first) if ($in{"order"}) { @ordered = sort keys %sermons; } # otherwise, default case - descending (most recent first) else { @ordered = sort {$b<=>$a} keys %sermons; } if ($anchor > 0) { $prevnext .= "<< Prev | "; } $prevnext .= "Showing " . ($anchor+1) . "-" . ($anchor+$show) . " of " . ($#ordered+1) ; if ($anchor+$show<=$#ordered) { $prevnext .= " | Next >>"; } print "\n"; print "\n"; print ""; print ""; print ""; print ""; print ""; print ""; print "\n"; $i = 0; # even/odd row indicator $row = 0; # row number indicator $numPrinted = 0; # number of rows printed foreach $id (@ordered) { if ($row++ < $anchor) { next; } if ($numPrinted++ >= $show) { last; } @item = split("\t", $sermons{$id}); print ""; # Convert ID to a readable date format # In general, YYYYMMDD -> MM/DD/YY $itemdate = substr($id,4,2) . "/" . substr($id,6,2) . "/" . substr($id,2,2); print ""; # Date # Title print ""; # Scripture print ""; # Speaker print ""; # Event print ""; print "\n"; # Toggle row indicator $i = !$i; } close DATA; print "\n"; print "
$prevnext
Date "; print ""; print "\"ToggleTitleScriptureSpeakerEvent
$itemdate$item[1]
"; print "["; if (-e "/www/cfchome_org/resources/sermons/archives/$id.html") { print ""; } print "HTML|"; if (-e "/www/cfchome_org/pdf/$id.pdf") { print ""; } print "PDF]"; print "[RealAudio "; if (-e "/www/cfchome_org/realaudio/$id.ram") { print ""; } print "stream|"; if (-e "/www/cfchome_org/mp3s/$id.mp3") { print ""; } elsif (-e "/www/cfchome_org/realaudio/$id.rm") { print ""; } print "file]"; print "
$item[2]"; if ($item[3] eq "M") { print "Rev. Min Chung"; } else { print substr($item[3],1); } print ""; if ($item[4] eq "S") { print "Lord's Day Service"; } elsif ($item[4] eq "F") { print "Friday Large Group"; } else { print substr($item[4],1); } print "
$prevnext
"; print "\n\n"; sub ReplicateQueryStr { local (@omitlist, $formItem, $key, $val, $omit, $i, $result); foreach $formItem (@in) { ($key, $val) = split(/=/,$formItem,2); # splits on the first =. $omit = 0; foreach $i (0 .. $#_) { if ($key eq $_[$i]) { $omit = 1; last; } } if (!$omit) { $result .= $formItem . "&"; } } return $result; } sub Max { if ($_[0]>$_[1]) { return $_[0]; } else { return $_[1]; } } sub Ceiling { local (@splitted); @splitted = split('\.', $_[0]); if ($#splitted == 0) {return $_[0];} else { return $splitted[0]+1; } }