#!/usr/local/bin/perl $sitetitle = 'Your Search Engine Name'; # Change this to the url of your seach engine index page $searchurl = 'http://www.blabla.com/search/index.html'; # Change this to your e-mail address # Depending on your version of PERL you may have to escape # the @ sign like this \@ # At first try just entering your straight e-mail address $searchemail = 'you@youremail.com'; # You may not need to change the $mailprogram variable. # Try it as is first. If it doesn't work try putting a # in # front of the first line below and remove the # on the # second line. If that fails, try the removing the # on # the third line and put a # in front of the other two. # If that fails, ask your administrator where the sendmail # program is on your system. $mailprogram = '/usr/sbin/sendmail'; # $mailprogram = '/usr/lib/sendmail'; # $mailprogram = '/usr/bin/sendmail'; # Change this to the PATH (not the URL) of the base.txt file # (include the filename) $base = '/home/bla/public_html/search/base.txt'; # Change this to the PATH (not the URL) of the head.txt file # (include the filename) $headfile = '/home/bla/public_html/search/head.txt'; # Change this to the PATH (not the URL) of the foot.txt file # (include the filename) $footfile = '/home/bla/public_html/search/foot.txt'; # Change this to the PATH (not the URL) of the respond.txt file # (include the filename) $respondfile = '/home/bla/public_html/search/respond.txt'; # Change this to the PATH (not the URL) of the smut.txt file # Any word found in smut.txt is assumed to be adult material # therefore you can control what is censored and what isn't # (include the filename) $smutfile = '/home/bla/public_html/search/smut.txt'; # Change this to the URL of this script # (include the filename) $scripturl = 'http://www.blabla.com/cgi-bin/easysearch.cgi'; # Edit this one to choose the font for the search results # DO NOT use " or any special characters # Use below for an example of what is allowed # Also do not set a font size as the script does this automatically $font = 'FACE=arial,helvetica COLOR=000000'; # Change this to the minimum search word length # This is to exclude searches for "the", "and", "a", etc. $minword = '3'; # Enter the maximum number of characters you want to allow for # the 'title' field for new site submissions $maxtitle = '50'; # Enter the maximum number of characters you want to allow for # the 'description' field for new site submissions $maxdescription = '150'; # Enter the maximum number of characters you want to allow for # the 'keywords' field for new site submissions $maxkeywords = '50'; # How many URLs do you want displayed on the New URLs page $numnew = '3'; # If you want to use flock to avoid corrupt files by double access # leave this line as is...if you don't then change the 1 to a 0 $uselock = '1'; # If you want to automatically send an autorespond e-mail to visitors # who submit their URL to the database then leave this line as is # If you don't, then change the 1 to a 0 $userespond = '1'; # Get the form variables if ($ENV{'REQUEST_METHOD'} eq 'GET') { $buffer = $ENV{'QUERY_STRING'}; } else { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); } # Break em up into a format the script can read @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; } # Get the heading information unless (open (DATA,"$headfile")) {die (&error);} if ($uselock eq '1') { flock DATA, 2; seek DATA, 0, 0; } @headinfo = ; if ($uselock eq '1') { flock DATA, 8; } close (DATA); foreach $headline (@headinfo){ $heading = $heading.$headline; } # Get the footer information unless (open (DATA,"$footfile")) {die (&error);} if ($uselock eq '1') { flock DATA, 2; seek DATA, 0, 0; } @footinfo = ; if ($uselock eq '1') { flock DATA, 8; } close (DATA); foreach $footline (@footinfo){ $footer = $footer.$footline; } # Get the smut filter information unless (open (DATA,"$smutfile")) {die (&error);} if ($uselock eq '1') { flock DATA, 2; seek DATA, 0, 0; } @smutinfo = ; if ($uselock eq '1') { flock DATA, 8; } close (DATA); foreach $smutline (@smutinfo){ $smutfilter = $smutfilter.$smutline; @smutwords = split (/::/,$smutfilter); } # Determine what part of the script we need if ($FORM{'action'} eq "showadd") { &showadd; } if ($FORM{'action'} eq "addurl") { &addurl; } if ($FORM{'action'} eq "newurls"){ &newurls; } if ($FORM{'action'} eq "randomurl"){ &randomurl; } # Assign shorter variable names # (Laziness on my part - but I find the longer # a script gets the more work typing long # variable names becomes.) $position = $FORM{'code'}; $addshow = 0; $noshow = 0; $match = 0; if ($FORM{'safe'} ne "on") { $safekey = "off"; } else { $safekey = "on"; } # Begin the search process and output the results unless (open (DATA,"$base")) {die (&error);} if ($uselock eq '1') { flock DATA, 2; seek DATA, 0, 0; } @input = ; if ($uselock eq '1') { flock DATA, 8; } close (DATA); # Routine for 'words' search if ($FORM{'mode'} eq "words") { $searchstring=$FORM{'keywords'}; @words = split (/ /,$searchstring); foreach $word (@words) { $wordlength = length($word); if ($wordlength < $minword) { &stringshort; } } &heading; $entries = @input; if ($position == 0) { $currentline = $entries; } else { $currentline = $position; } $found="0"; print "
Search Results : '$FORM{'keywords'}'

"; print "
"; print ""; until ($found > 9 || $currentline == 0) { foreach $word (@words) { if ($input[$currentline] =~ /$word/i) { @data = split (/::/,$input[$currentline]); if ($data[4] ne "") { if ($safekey eq "on" && $match == 0) { foreach $smutword (@smutwords) { if ($input[$currentline] =~ /$smutword/i) { $smut = 1; } } unless ($smut == 1) { print "$data[1]
"; print "$data[4]
"; print "$data[0]

"; ++$found; ++$match; } $smut = 0; } if ($safekey eq "off" && $match == 0) { print "$data[1]
"; print "$data[4]
"; print "$data[0]

"; ++$found; ++$match; } } } } --$currentline; $match = 0; } } # Routine for 'phrases' search if ($FORM{'mode'} eq "phrases") { $searchstring=$FORM{'keywords'}; $wordlength = length($FORM{'keywords'}); if ($wordlength < $minword) { &phrase; } &heading; $entries = @input; if ($position == 0) { $currentline=$entries; } else { $currentline = $position; } print "

Search Results : '$FORM{'keywords'}'

"; print "
"; print ""; until ($found > 9 || $currentline == 0) { if ($input[$currentline] =~ /$FORM{'keywords'}/i) { @data = split (/::/,$input[$currentline]); if ($data[4] ne "") { if ($safekey eq "on") { foreach $smutword (@smutwords) { if ($input[$currentline] =~ /$smutword/i) { $smut = 1; } } unless ($smut == 1) { print "$data[1]
"; print "$data[4]
"; print "$data[0]

"; ++$found; } $smut = 0; } if ($safekey eq "off") { print "$data[1]
"; print "$data[4]
"; print "$data[0]

"; ++$found; } } } --$currentline; } } print ""; &footer; ################# SUBROUTINES ###################### sub heading { print "Content-type: text/html\n\n"; print "$heading"; } sub footer { $keyencode=$FORM{'keywords'}; $keyencode =~ tr/ /+/; if ($found > 9) { $position=$currentline; print "

More Results

"; } else { unless ($addshow == 1) { print "
End of Results.

\n"; } } unless ($noshow == 1) { unless ($addshow == 1) { print "

Search For :
Mode :WordsPhrase
Safe : Omit Offensive Slang

\n"; } if ($FORM{'keywords'} ne "") { print "
Search for \"$FORM{'keywords'}\" in these search engines...
AltaVista DejaNews Excite GO Network HotBot Lycos WebCrawler Yahoo!

\n"; } } &generate; print "$footer"; exit; } sub error { $noshow = 1; &heading; print "

File Access Error

You have an error in your PATH configuration variables in the $ENV{'SCRIPT_NAME'} file.

Your server reports that your BASE path is : $ENV{'DOCUMENT_ROOT'}
Note that this is reported as your BASE path, not the FULL path to your files.

If you require help installing this script please consider purchasing the professional version of this script. Your purchase includes full tech support and installation.

Get it at : http://www.getperl.com/easysearch/

\n"; &footer; } sub stringshort { $noshow = 1; print "Content-type: text/html\n\n"; &heading; print "

Word Too Short

Sorry...each word must be at least $minword characters long.

\n"; &footer; } sub phrase { $noshow = 1; print "Content-type: text/html\n\n"; &heading; print "

Phrase Too Short

Sorry...your phrase must be at least $minword characters long.

\n"; &footer; } sub generate { print "


\n"; print "

Powered by : EasySearch - Copyright 1999 by Thomas J. Delorme

\n"; print "


\n"; } sub showadd { &heading; $addshow = 1; print "
Add URL
\n"; print "Please fill out the following information and press the SUBMIT button.
\n"; print "Please note that all fields are required.

\n"; print "

\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
E-mail :
Site Title :
Url :
Description :
Keywords :
(Commas, no spaces)

\n"; print " I would like to receive occassional news from $sitetitle.

\n"; print "\n"; print "

\n"; &footer; } sub addurl { &heading; $noshow = 1; unless ($FORM{'url'} =~ /http:\/\//) { &submiterror; } if ($FORM{'url'} eq "" || $FORM{'title'} eq "" || $FORM{'email'} eq "" || $FORM{'description'} eq "" || $FORM{'keywords'} eq "") { ∅ } unless (open (DATA,"$base")) {die (&error);} if ($uselock eq '1') { flock DATA, 2; seek DATA, 0, 0; } @input = ; if ($uselock eq '1') { flock DATA, 8; } close (DATA); $entries = @input; $urlsearch = "$FORM{'url'}"."::"; $urltemp = $FORM{'url'}; chomp($urltemp); chop($urltemp); $urlsearchtwo = "$urltemp"."::"; $urlsearchthree = "$FORM{'url'}"."/::"; $currentline = 0; until ($currentline == $entries) { if ($input[$currentline] =~ /$urlsearch/i) { &exists; } if ($input[$currentline] =~ /$urlsearchtwo/i) { &exists; } if ($input[$currentline] =~ /$urlsearchthree/i) { &exists; } ++$currentline; } $testline = $input[$currentline-1]; $testline2 = $input[$currentline-2]; $testline3 = $input[$currentline-3]; $testline4 = $input[$currentline-4]; $testline5 = $input[$currentline-5]; $testline6 = $input[$currentline-6]; $testline7 = $input[$currentline-7]; $testline8 = $input[$currentline-8]; $testline9 = $input[$currentline-9]; $testline10 = $input[$currentline-10]; if ($testline =~ /$FORM{'description'}/) { &samestuff; } if ($testline =~ /$FORM{'title'}/) { &samestuff; } if ($testline =~ /$FORM{'keywords'}/) { &samestuff; } if ($testline =~ /$FORM{'email'}/i || $testline2 =~ /$FORM{'email'}/i || $testline3 =~ /$FORM{'email'}/i || $testline4 =~ /$FORM{'email'}/i || $testline5 =~ /$FORM{'email'}/i || $testline6 =~ /$FORM{'email'}/i || $testline7 =~ /$FORM{'email'}/i || $testline8 =~ /$FORM{'email'}/i || $testline9 =~ /$FORM{'email'}/i || $testline10 =~ /$FORM{'email'}/i) { &justsubmitted; } $newemail = $FORM{'email'}; if ($FORM{'send'} ne "on") { $newemail = "X"."$newemail"."X"; } $newtitle = substr($FORM{'title'},0,$maxtitle); $newdesc = substr($FORM{'description'},0,$maxdescription); $newkeywords = substr($FORM{'keywords'},0,$maxkeywords); $line = join ("::","$FORM{'url'}","$newtitle","$newkeywords","$newemail","$newdesc"); unless (open (DATA,">>$base")) {die (&error);} if ($uselock eq '1') { flock DATA, 2; seek DATA, 0, 2; } print DATA "$line\n"; if ($uselock eq '1') { flock DATA, 8; } close (DATA); print "

Submission Received

\n"; print "The following submission has been received by $sitetitle :
\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
URL :$FORM{'url'}
Title : $FORM{'title'}
Keywords : $FORM{'keywords'}
Description : $FORM{'description'}
E-mail : $FORM{'email'}

\n"; if ($userespond eq '1') { unless (open (DATA,"$respondfile")) {die (&error);} if ($uselock eq '1') { flock DATA, 2; seek DATA, 0, 0; } @respondinfo = ; if ($uselock eq '1') { flock DATA, 8; } close (DATA); foreach $respondline (@respondinfo){ $respondmessage = $respondmessage.$respondline; } open (MAIL, "|$mailprogram -t"); print MAIL "To: $FORM{'email'}\n"; print MAIL "From: $searchemail\n"; print MAIL "Subject: Got it!\n\n"; print MAIL "Welcome to $sitetitle!\n"; print MAIL "We are located at $searchurl\n\n"; print MAIL "YOUR SUBMISSION:\n"; print MAIL "------------------------------------------------------------------\n"; print MAIL "URL : $FORM{'url'}\n"; print MAIL "Title : $FORM{'title'}\n"; print MAIL "Description : $FORM{'description'}\n"; print MAIL "Keywords : $FORM{'keywords'}\n"; print MAIL "E-mail : $FORM{'email'}\n"; print MAIL "------------------------------------------------------------------\n\n"; print MAIL "$respondmessage"; print MAIL "------------------------------------------------------------------\n\n"; print MAIL "Thanks again,\n"; print MAIL "---------------------------------------------\n"; print MAIL "$sitetitle\n"; print MAIL "$searchemail\n"; print MAIL "$searchurl\n"; print MAIL "---------------------------------------------\n"; print MAIL "Powered by :\n"; print MAIL "EasySearch - Copyright 1999\n"; print MAIL "http://www.getperl.com\n"; print MAIL "---------------------------------------------\n"; close (MAIL); } &footer; } sub exists { $noshow = 1; print "

URL Already Exists


$FORM{'url'}
Sorry...Each URL is only allowed one entry.

\n"; &footer; } sub samestuff { $noshow = 1; print "

Recent URL Submission


You have recently submitted an URL with either the exact same title, description, or keywords. Since this is a different URL, please change your title, description and keywords to match this new page.

\n"; &footer; } sub justsubmitted { $noshow = 1; print "

Recent URL Submission


In order to avoid domain name overflow on the Newest URLs page,
we ask that you try your submission again later.

\n"; &footer; } sub empty { $noshow = 1; print "

Field Empty


Please make sure that you have filled in all fields on the form.

\n"; &footer; } sub submiterror { $noshow = 1; print "

Invalid URL


Please make sure that your URL contains http:// and is correct.

\n"; &footer; } sub newurls { &heading; unless (open (DATA,"$base")) {die (&error);} if ($uselock eq '1') { flock DATA, 2; seek DATA, 0, 0; } @input = ; if ($uselock eq '1') { flock DATA, 8; } close (DATA); $entries = @input; print "

Newest URLs :
"; $currentline = $entries; print ""; $count = 0; until ($count == $numnew) { @data = split (/::/,$input[$currentline]); if ($data[4] ne "") { foreach $smutword (@smutwords) { if ($input[$currentline] =~ /$smutword/i) { $smut = 1; } } unless ($smut == 1) { print ("$data[1]
"); print ("$data[4]
"); print ("$data[0]

"); ++$count; } $smut = 0; } --$currentline; } print ""; &footer; } sub randomurl { &heading; unless (open (DATA,"$base")) {die (&error);} if ($uselock eq '1') { flock DATA, 2; seek DATA, 0, 0; } @input = ; if ($uselock eq '1') { flock DATA, 8; } close (DATA); $entries = @input; print "

Random URL :
"; $count=0; while ($count != 1) { srand (time + $$); $currentline = int( rand ($entries)); print ""; @data = split (/::/,$input[$currentline]); foreach $smutword (@smutwords) { if ($input[$currentline] =~ /$smutword/i) { $smut = 1; } } unless ($smut == 1) { if ($data[4] ne "") { print "$data[1]
"; print "$data[4]
"; print "$data[0]

"; $count=1; } } $smut = 0; } &footer; }