www.pudn.com > madengine.zip > madengine.cgi


#!/usr/bin/perl 
require './config.pl'; 
##################################################################### 
##guestpost.cgi v1.0 Copyright  1998, Tom and Linda Myro, 
##all rights reserved.  Permission granted to use and modify 
##for any good use, as long as you agree to hold Tom and Linda  
##Myro and cyber-nurse.com harmless, in the event of any disaster 
##either real or imagined, resulting from the use of this software. 
##Modification and/or installation of this software shall be  
##considered agreement of you, the user with the above conditions. 
#####################################################################  
 
##################################################################### 
##The Configuration 
##################################################################### 
$numoffilters = 4; 
$title = $madenginetitle; 
$thisscripturl = $madengineurl; 
##Fabrication 
$urllist = $datadirectorypath . "/" . "urlbase\.dat"; 
 
#This business here was borrowed from Dave Palmer  
 
read(STDIN, $input, $ENV{'CONTENT_LENGTH'}); 
 
	# split the input 
	@pairs = split(/&/, $input); 
 
	# split the name/value pairs 
	foreach $pair (@pairs) { 
 
	($name, $value) = split(/=/, $pair); 
 
	$name =~ tr/+/ /; 
	$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; 
	$value =~ tr/+/ /; 
	$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; 
	$value =~ s/<([^>]|\n)*>//g; 
 
  $FORM{$name} = $value; 
    } 
################Translation 
$url = $FORM{ 'url' }; 
$action = $FORM{ 'action' }; 
$pass = $FORM{ 'pass' }; 
$deletethis = $FORM{ 'deletethis' }; 
$userfilterchoice = $FORM{ 'userfilterchoice' }; 
$surchstring = $FORM{ 'surchstring' }; 
 
 
 
 
if($action eq ""){ 
	&starthtml; 
	print "

$title Search


\n"; print "

This search uses a fairly literal search routine\. It is case insensitive\, but matches patterns directly\, so \"beanie baby\" will return BEANIE BABY only\, whereas \"beanie bab\" will return both BEANIE BABY and BEANIE BABIES\.

\n"; &formstarter; print "\n"; print "Type Search String Here\:
\n"; print "\n"; &endhtml; exit; } if($action eq "searchresults"){ $surchstring =~ tr/A-Z/a-z/; opendir(DATADIRECTORY, "$datadirectorypath"); @files = readdir(DATADIRECTORY); &starthtml; print "

$title Search Results


\n"; print "\n"; $searchcount = 0; foreach $file(@files){ if($file =~ /indexfile/){ $whichfile = $file; $whichfile =~ s/indexfile//; $whichfile =~ s/\.dat//; open(URLBASE, "$urllist"); $line = ; while($line ne ""){ if($line =~ /^$whichfile/){ @urlmatch = split(/\|/, $line); $page = $urlmatch[1]; } $line = ; } close(URLBASE); $searchfile = $datadirectorypath . "/" . $file; open(INDEXFILE, "$searchfile"); @searchlines = ; foreach $searchline(@searchlines){ if($searchline =~ /$surchstring/i){ ++$searchcount; print "\n"; } } close(INDEXFILE); } } if($searchcount == 0){ print "\n"; } closedir(DATADIRECTORY); print "
URLLINE CONTAINING SEARCH STRING
$page$searchline
\n"; &formstarter; print "Sorry, No Matches
\n"; print "Type Search String Here\:
\n"; print "\n"; print "
\n"; &endhtml; exit; } #here's the subroutines sub formstarter { print "
\n"; } sub starthtml { if ($colororimage eq "0"){ $backgroundtag = "BACKGROUND\=$bgimageurl"; $bgcolortag = ""; } else { $backgroundtag = ""; $bgcolortag = "BGCOLOR\=$bgcolor"; } print "Content-type: text/html\n\n"; print "$title\n"; print "\n"; } #here's another sub endhtml { print ""; }