#!/usr/bin/perl ############################################################################## # Simple Search Version 1.0 # # Copyright 1996 Matt Wright mattw@worldwidemart.com # # Created 12/16/95 Last Modified 12/16/95 # # Scripts Archive at: http://www.worldwidemart.com/scripts/ # ############################################################################## # COPYRIGHT NOTICE # # Copyright 1996 Matthew M. Wright All Rights Reserved. # # # # Simple Search may be used and modified free of charge by anyone so long as # # this copyright notice and the comments above remain intact. By using this # # code you agree to indemnify Matthew M. Wright from any liability that # # might arise from it's use. # # # # Selling the code for this program without prior written consent is # # expressly forbidden. In other words, please ask first before you try and # # make money off of my program. # # # # Obtain permission before redistributing this software over the Internet or # # in any other medium. In all cases copyright and header must remain intact.# ############################################################################## # Define Variables # $basedir = '/website/htdocs/pattayamail/'; $baseurl = 'http://www.pattayamail.com/'; @files = ('*.html','*.htm','275','276','277','278','279','280','281','282'); @filesyear = ('231','232','233','234','235','236','237','238','239','240','241','242','243','244','245','246','247','248','249','250','251','252','253','254','255','256','257','258','259','260','261','262','263','264','265','266','267','268','269','270','271','272','273','274'); $title = "Search www.pattayamail.com"; $title_url = 'http://www.pattayamail.com/'; $search_url = 'http://www.pattayamail.com/search/search.html'; # Done # ############################################################################## # Parse Form Search Information &parse_form; #Choose between months and whole year search &choose; print "Content-type: text/html\n\n"; print "\n \n Results of Search\n"; print "\n"; print "\n"; print "\n"; print "\n \n \n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
\n"; print "\n"; print "
\n
\n"; print "

\n"; print "

Index\n"; print "

Current Issue\n"; print "

  • News
  • \n"; print "
  • Business News
  • \n"; print "
  • Features
  • \n"; print "
  • Columns
  • \n"; print "
  • Letters
  • \n"; print "
  • Sports
  • \n"; print "
  • AutoMania
  • \n"; print "
  • Kids Corner
  • \n"; print "
  • Who's who
  • \n"; print "
  • Travel
  • \n"; print "
  • Shopping
  • \n"; print "
  • Our Community
  • \n"; print "
  • Dining Out & Entertainment
  • \n"; print "
  • Community Happenings
  • \n"; print "
  • Books-Movies-Music
  • \n"; print "

    Classifieds\n"; print "

  • View Classifieds
  • \n"; print "
  • Submit Classified
  • \n"; print "

    Search\n"; print "

  • Back Issues
  • \n"; print "

    Pattaya Mail \n"; print "
    About Us\n"; print "
    Subscribe\n"; print "

    \ \;

    \ \;

    \ \;

    \ \;

    \ \; \n"; print "

    \n"; print "

    Results of Search

    \n"; # Get Files To Search Through &get_files; # Search the files &search; # Print Results of Search &return_html; sub choose { if ($FORM{'searchoption'} eq "month") { # tests if you want months only @files; } else { # unites array files with array filesyear push (@files, @filesyear); } } sub parse_form { # Get the input read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); # Split the name-value pairs @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $FORM{$name} = $value; } } sub get_files { chdir($basedir); foreach $file (@files) { $ls = `dir /B $file`; # print "Files: $ls
    \n"; # print "$file
    \n"; @ls = split(/\n+/,$ls); foreach $temp_file (@ls) { # print "The File is $file
    \n"; if (-d $file) { # print "Directory Found $temp_file
    \n"; $filename = "$file/$temp_file"; if (-T $filename) { push(@FILES,$filename); } } elsif (-T $temp_file) { # print "Text File Found $temp_file
    \n"; push(@FILES,$temp_file); } } } } sub search { @terms = split(/\s+/, $FORM{'terms'}); foreach $FILE (@FILES) { # print "$FILE
    \n"; open(FILE,"$FILE"); @LINES = ; close(FILE); $string = join(' ',@LINES); $string =~ s/\n//g; if ($FORM{'boolean'} eq 'AND') { foreach $term (@terms) { if ($FORM{'case'} eq 'Insensitive') { if (!($string =~ /$term/i)) { $include{$FILE} = 'no'; last; } else { $include{$FILE} = 'yes'; } } elsif ($FORM{'case'} eq 'Sensitive') { if (!($string =~ /$term/)) { $include{$FILE} = 'no'; last; } else { $include{$FILE} = 'yes'; } } } } elsif ($FORM{'boolean'} eq 'OR') { foreach $term (@terms) { if ($FORM{'case'} eq 'Insensitive') { if ($string =~ /$term/i) { $include{$FILE} = 'yes'; last; } else { $include{$FILE} = 'no'; } } elsif ($FORM{'case'} eq 'Sensitive') { if ($string =~ /$term/) { $include{$FILE} = 'yes'; last; } else { $include{$FILE} = 'no'; } } } } if ($string =~ /(.*)<\/title>/i) { $titles{$FILE} = "$1"; } else { $titles{$FILE} = "$FILE"; } } } sub return_html { print "Below are the results of your Search in no particular order:<p><hr width=75%><p>\n"; print "<ul>\n"; foreach $key (keys %include) { if ($include{$key} eq 'yes') { print "<li><a href=\"$baseurl$key\">$titles{$key}</a>\n"; } } print "</ul>\n"; print "<hr width=75%>\n"; print "Search Information:<p>\n"; print "<ul>\n"; print "<li><b>Terms:</b> "; $i = 0; foreach $term (@terms) { print "$term"; $i++; if (!($i == @terms)) { print ", "; } } print "\n"; print "<li><b>Boolean Used:</b> $FORM{'boolean'}\n"; print "<li><b>Case $FORM{'case'}</b>\n"; print "</ul><br><hr width=75%><P>\n"; # print "<ul>\n<li><a href=\"$search_url\">Back to Search Page</a>\n"; print "<li><a href=\"$title_url\">$title</a>\n"; print "</ul>\n"; print "<hr width=75%>\n"; print "</td></tr></table>\n"; print "</body>\n</html>\n"; }