#!/usr/bin/perl ############################################ ## by John Tsangaris ## ## version: 1.01 ## ## last modified: 11/08/00 ## ## copyright (c) 2000 ## ## latest version is available ## ## by emailing gods-apollo@home.com ## ############################################ $version = "1.01"; # Specify path to files. File name by itself means current directory. $file = "jokes.txt"; $program = "hints.pl"; # Specify whether or not this file is to be called from SSI or whether the # program should display a full page. If you want a full page SSI = 0. # If you want it to be displayed as SSI then SSI = 1. $SSI = 0; $HeaderFile = "/home/sites/www.laugh-of-the-day.com/web/header.txt"; $FooterFile = "/home/sites/www.laugh-of-the-day.com/web/footer.txt"; $JokesTitle = "Laugh-Of-The-Day!"; #### Do not change the following text #### use DBI; use CGI; $query = new CGI; unless ($function1 = $query->param('function1')) { $function1 = 'none'; if ($ENV{'QUERY_STRING'}) { $date_string = $ENV{'QUERY_STRING'}; print_header(); print_joke(); exit(0); } } if ($function1 eq 'none') { print_header(); get_date(); print_joke(); exit(0); } elsif ($function1 eq 'search') { print_header(); complete_search(); exit(); } elsif ($function1 eq 'listall') { print_header(); listall(); exit(0); } else{} ################################ sub complete_search() sub complete_search() { unless ($search_string = $query->param('search')) { print_empty('Search'); exit(0); } print<<"ENDOFHTML"; $JokesTitle ENDOFHTML if ($HeaderFile) { open (HEADER,"$HeaderFile"); @header =
; close (HEADER); foreach $line (@header) { print "$line"; } } print<<"ENDOFHTML";

All Laughs

    ENDOFHTML open (FILE, "$file"); get_date(); $counter=0; while () { if ($_ =~ /$search_string/i) { @jokearray = split (/:::/); if ($date_string >= $jokearray[0]) { format_date($jokearray[0]); print<<"EndOfHTML";
  • $formatted_date: $jokearray[1] EndOfHTML $counter++; } else {next;} } } if ($counter == 0) { print "Sorry, there were no matches for your search."; } print "

"; print<<"ENDOFHTML";
ENDOFHTML if ($FooterFile) { open (FOOTER,"$FooterFile"); @footer =