# The name of this script may not be changed
# l1a = "SOFTWARE DISTIBUTION AGREEMENT"
# l1 = "This software may be distributed freely on online services, bulletin boards, or other electronic media as long as the files are distributed in their entirety.  This software may not be distributed on CD-ROM, disk, or other physical media for a fee without the permission of Andrew Computers, Inc and Ephraim Andrew.  You may not alter this software in any way, including changing or removing any messages or windows. You may not decompile, reverse engineer, disassemble or otherwise reduce this software to a human perceivable form.  You may not modify, rent for profit this software, or create derivative works based upon this software."
# l2 = "A registered end-user who has purchased the SmartIEbot Spider may sign up, for an Affilate Account with Andrew Computers, Inc. by hitting the [Make Money Selling This Software] button within the SmartIEbot Spider Program itself.  If an end-user becomes an affilate they will have to sign a longer paper version of a distrubtion agreement, to offically enroll in the Andrew Computers, Inc affilate program.  Once accepted the affilate will get 30% commision on all his or her sales.  Such affliates also have permission to submit the SmartIEbot Spider to download distrobution sites.  Such affiates do not have permission to re-submit the SmartIEbot Spider to a web site that it has already been listing the SmartIEbot Spider." & Chr$(13) & Chr$(13)

# sen0 = "SOFTWARE LICENSE AGREEMENT" & Chr$(13)
# sen1 = "*** Please read this entire agreement ***" & Chr$(13)
# sen2 = "LICENSE:" & Chr$(13)
# sen3 = "This Limited Use Software License Agreement (the" & Chr$(34) & "Agreement" & Chr$(34) & ") is a legal agreement between you(" & Chr$(34) & "Licensee" & Chr$(34) & "), the end-user, and Andrew Computers, Inc for the use of the SmartIEbot Spider software product (" & Chr$(34) & "Software" & Chr$(34) & ")." & Chr$(13)
# sen4 = "By using this software or storing this program on a computer hard drive (or other media), you are agreeing to be bound by the terms of this Agreement." & Chr$(13)
# sen5 = "If you do not agree to the terms of this Agreement, promptly delete the software from all storage media." & Chr$(13)
# sen6 = "You may install this program to test and evaluate it.  If the program suits your needs you can purchase it.  However, there is a set limit for the evaluation time." & Chr$(13)
# sen7 = "Some functions of the program may be limited in the evaluation version." & Chr$(13)
# sen8 = "This software may be distributed freely on online services, bulletin boards, or other electronic media as long as the files are distributed in their entirety.  This software may not be distributed on CD-ROM, disk, or other physical media for a fee without the permission of Andrew Computers, Inc" & Chr$(13)
# sen9 = "You may not alter this software in any way, including changing or removing any messages or windows." & Chr$(13)
# sen10 = "You may not decompile, reverse engineer, disassemble or otherwise reduce this software to a human perceivable form.  You may not modify, rent or resell for profit this software, or create derivative works based upon this software." & Chr$(13)
# sen11 = "You may not publicize or distribute any registration code algorithms, information, or registration codes used by this software without permission of Andrew Computers, Inc." & Chr$(13)
# sen12 = "You may not use any registration codes for the Software that have not been purchased from Andrew Computers, Inc or an authorized representative of Andrew Computers, Inc." & Chr$(13)
# sen14 = "You accept responsibility for any network usage costs or any other costs incurred by using this software." & Chr$(13)
# sen15 = "This software may be used to download materials.  It is licensed to you only for download of non-copyrighted materials, materials in which you own the copyright, or materials you are authorized or legally permitted to download.  If you are uncertain about your right to download any material, contact your legal advisor." & Chr$(13)
# sen16 = "" & Chr$(13)
# sen17 = "NO WARRANTIES.  - Andrew Computers, Inc EXPRESSLY DISCLAIMS ANY WARRANTY for the SOFTWARE. The SOFTWARE and any related documentation is provided & Chr$(34) & as is & Chr$(34) & without warranty of any kind, either express or implied, including, without limitation, the implied warranties or merchantability, fitness for a particular purpose, or noninfringement." & Chr$(13)
# sen18 = "The entire risk arising out of use or performance of the SOFTWARE remains with you." & Chr$(13)
# sen19 = "" & Chr$(13)
# sen20 = "THIS SOFTWARE IS NOT FAULT TOLERANT AND SHOULD NOT BE USED IN ANY ENVIRONMENT WHICH REQUIRES THIS." & Chr$(13)
# sen21 = "" & Chr$(13)
# sen22 = "NO LIABILITY FOR DAMAGES. In no event shall Andrew Computers, Inc or its suppliers be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or any other pecuniary loss) arising out of the use of or inability to use this SOFTWARE, EVEN IF Andrew Computers, Inc HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES." & Chr$(13)
# sen23 = "" & Chr$(13)
# sen23a = "By putting your name in the name field below and your email address in the email address field below, checking the i agree box, and hitting the continue button on this form means you agree to and will abide by this software license agreement."
# sen23b = "" & Chr$(13)
# sen24 = "COPYRIGHT" & Chr$(13)
# sen25 = "SmartIEbot Spider is Copyright Andrew Computers, Inc.  You must treat the Software like any other copyrighted material." & Chr$(13)
# sen26 = "© SmartIEbot Spider, Andrew Computers Inc., and Ephraim Andrew, 1999 - 2020" & Chr$(13)
# sen27 = "TM"
# By using this script you agree to the afforementioned above statements.



# Directions
# Change the line below to your perl directory but leave the # in front of the perl line below 


#!C:/perl5/bin/perl.exe



use DBI;
use CGI;


print "Content-type: text/html\n\n";


$addy = "localhost";
# $addy = $ENV{'SERVER_ADDR'};

# put your user name below
$user = "";

# put your password below
$password = "";

# put your database name below
$dbase = "";


$driver = "dbi:mysql:" . $dbase . ":$addy";

# connect to database
$dbh = DBI->connect($driver, $user, $password) or die "\nError
($DBI::err):$DBI::errstr\n";


my $cgi = CGI->new();
print $cgi->header();

print $cgi->start_form (-method => "GET");

print $cgi->textfield (-name=> "interest",
                       -value => $interest,
                       -size => 40);

print $cgi->submit (-name => "button", -value => "search again");
print $cgi->end_form();

  if (my $interest = $cgi->param("interest")) {
                                     # ...30 lines of code to run a search
                                     # and print the results as HTML
                                      search_members ($interest);
                                } else {
                                     die
                                     # ...15 lines of code to display
                                     # the search form
                                }

# run the search if a keyword is specified
# search_members ($interest) if $interest;


sub search_members
{
my ($interest) = shift;
my ($sth, $count);

printf "Search results for keyword: %s<BR><BR>\n",
				$cgi->escapeHTML ($interest);


# perform the query
$sth = $dbh->prepare (qq{SELECT * FROM findoldnew WHERE siteDescription like ?}) or die "\nError;
($DBI::err):$DBI::errstr\n";

$sth->execute("%" . $interest . "%") or die "\nError
($DBI::err):$DBI::errstr\n";
$count = 0;
# $hash_tupla_ref= $sth->fetchrow_hashref();
while (my $hash_ref = $sth->fetchrow_hashref ())
  {
  #do {
  $link = $hash_ref->{siteURL};
   #print "<b>$hash_ref->{sitetitle}</b>";
   #print "<BR>";
   #print "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp";;
   #}
  print "<P>";


  ++$count;
  print "_______________________________________________________________________________________________________________________________________";
  print "<BR>";
  print "<B>Record number</B>";

  print "&nbsp;&nbsp;$hash_ref->{webID}";
  print "&nbsp;&nbsp;&nbsp;$hash_ref->{sitetitle}";
  print "<BR>";
  print "<A HREF=$link>$link</a>";
  print "<BR>";
  print "$hash_ref->{siteDescription}";
  print "<BR><p>";
  print "<B>Keywords:</B>&nbsp;&nbsp;";
  print "$hash_ref->{siteKeywords}";
  print "...";
  #print "$hash_ref->{score}";
  #print "<P>";
  #print "$hash_ref->{org_name}";
  #print "<BR>";
  #print "$hash_ref->{address1}";
  #print "<BR>";
  if (!$hash_ref->{address2})
   {
  #print "<BR>";
  print "$hash_ref->{city}";
  #print ",";
  print "$hash_ref->{state_prov}";
  print "&nbsp;&nbsp;$hash_ref->{country}";
  print "<BR>";
  }
  if ($hash_ref->{address2})
  {
  #print "$hash_ref->{address2}";
  #print "<BR>";
  #print "$hash_ref->{city}";
  #print ",";
  #print "$hash_ref->{state_prov}";
  #print "&nbsp;&nbsp;$hash_ref->{country}";
  #print "<BR>";
  }
  }
print $cgi->p ("$count enteries found");
}

