4freequotes.com - Request
insurance rates from up to 10 companies simultaneously at
4freequotes.com using one form! Hundreds of agents, brokers and
companies.
#!/usr/bin/perl
package main;
{
print "Content-type: text/html\n\n";
warn "mod_perl: $ENV{MOD_PERL} \n";
print "mod_perl: $ENV{MOD_PERL} \n";
#$Apache->warn("mod_perl: $ENV{MOD_PERL}");
#print "Test ";
#exit;
BEGIN
{
#use msearch_config;
use vars qw(%C %D $dbh %SITEDATA_EXT %SITEDATA %SITEDATA_CAN %SEARCHTERMSI %SEARCHTERMSQ %SEARCHTERMSLB %SEARCHTERMS);
# *D = \%msearch_config::D;
*C = \%msearch_config::C;
*dbh = \$msearch_config::dbh;
*SITEDATA_EXT = \%msearch_config::SITEDATA_EXT;
*SITEDATA = \%msearch_config::SITEDATA;
*SITEDATA_ID = \%msearch_config::SITEDATA_ID;
*SITEDATA_ALIASES = \%msearch_config::SITEDATA_ALIASES;
*SITEDATA_CAN = \%msearch_config::SITEDATA_CAN;
*SEARCHTERMSI = \%msearch_config::SEARCHTERMSI;
*SEARCHTERMSQ = \%msearch_config::SEARCHTERMSQ;
*SEARCHTERMSLB = \%msearch_config::SEARCHTERMSLB;
*SEARCHTERMS = \%msearch_config::SEARCHTERMS;
$barcolor = "#DDEEFF";
%results = ();
$testing = "This is a test";
#$frompage = "testing";
}
$touch_file = "/tmp/reload_modules";
reread_conf($touch_file);
sub reread_conf {
my $file = shift;
return unless $file;
return unless -e $file and -r _;
unless ($MODIFIED{$file} and $MODIFIED{$file} == -M _){
my $result;
#print "Modified ";
unless ($result = do "/home/sites/site6/cgi-bin/mp/msearch_config.pm") {
warn "couldn't parse msearch_config: $@" if $@;
warn "couldn't do msearch_config: $!" unless defined $result;
warn "couldn't run msearch_config" unless $result;
}
#print "INC: @INC ";
$MODIFIED{$file} = -M _; # Update the MODIFICATION times
}
} # end of reread_conf
{
{
# use strict;
{
# IP matching for testing:
my $aip1 = "98.206.64.72"; # Chris
my $aip2 = "4.62."; # Randall (mask)
my $aip3 = "24.185.1.153"; # Anthony
my $testip = "no";
if (($ENV{REMOTE_ADDR} =~ m/^$aip1/) || ($ENV{REMOTE_ADDR} =~ m/^$aip2/) || ($ENV{REMOTE_ADDR} eq "$aip3")) {
$testip = "yes";
}else{
$testip = "yes"; # (force to not use popups for everyone if "yes")
}
}
my $live = "live"; # set to "live" for links to be available. Set to anything else to not show links.
{
#use Apache::Reload;
#use CGI;
#use DBI;
#use LWP::Parallel::UserAgent;
#use LWP::Parallel::RobotUA qw(:CALLBACK);
#use LWP::Parallel::UserAgent qw(:CALLBACK);
#use process(); # qw(process);
#use output;
#use myUA;
}
&initvars();
sub initvars {
$first = "";
$domainname = "";
$headerlinks = "";
@headerlinks = ();
$frompage = "";
$use = "";
$domain = "";
$temp = "";
$end = "";
$ext = "";
$root = "";
$can = "";
$can2 = "";
@tempc = ();
$sitenum = "";
$junk = "";
$searchterm = "";
$quantity = "";
@results = ();
@links = ();
$l = 0;
@canlinks = ();
$cl = 0;
@testlinks = ();
$tl = 0;
%foreign = ();
%uforeign = ();
%F = ();
$counter = 0;
@results = ();
$r = 0;
@head = ();
@header = ();
$h = 0;
$hl = 0;
$tc = 0;
$id = "";
$odomain = "";
$searchterm = "";
$stylesheet = "";
$template = "";
$otitle = "";
$heading = "";
$bannerzone = "";
$quantity = 0;
$itemnumbers = "";
$itembullets = "";
$itemspace = "";
$pdescription = "";
$keywords = "";
$htmllink = "";
$sitetitle = ();
$itemnumstart = "";
$itemnumend = "";
$itembulstart = "";
$itembulend = "";
$ispace = "";
$q = 0;
$num = 0;
$disp_num = "";
$alt_title = "";
$description = "";
$oquantity = "";
$page = "";
%OUTPUT = ();
%KOUTPUT = ();
$IP = "";
$itrue = 0;
$blurb = "";
}
}
&input;
if (($F{ip} eq "67.175.8.192") || ($F{ip} eq "67.190.122.169")){
$useragentstring = $F{useragentstring};
warn "useragentstring: $useragentstring\n";
foreach (%ENV) {
#warn "$_: $ENV{$_}\n";
}
#warn "\n";
}
#@ext = qw(org net biz tv gov com); # extensions to look for
$IP = $F{ip};
unless ($IP) {$IP = $ENV{REMOTE_ADDR};}
#print "IP: $IP ";
$domain = $F{'domain'};
unless ($domain) {$domain = "http://$ENV{'SERVER_NAME'}$ENV{'DOCUMENT_URI'}";}
$domain2 = $domain;
if ($domain =~ m/tourism\.com/) {$domain = "http://www.tourismdepot.com";} # lump all tourism sites together
{
$temp = $domain;
$temp =~ s/http:\/\///; # remove http://
$temp =~ s/(\/.*?)$//; # remove and save all data after domain
$end = $1;
@tempc = split (/\./, $temp); # split domain at the .'s
$ext = pop @tempc; # pull the extension off the bottom of the stack
$root = pop @tempc; # pull the root off the bottom of the stack
$can = join ('.', @tempc); # join the rest (if more than one) into the canonical
$can2 = "http://" . $can;
}
if ($F{uri} ne "") { # is frompage forced by requesting url?
$frompage = $F{uri};
}else{ # check for exact domain in sites db
if (exists $SITEDATA{$domain}{domain}) { # exact match
#print "exact match ";
$frompage = $domain; # full path with domain
}else{
#print "\n";
#print "\n";
if (exists $SITEDATA_ALIASES{$can}{$root}{$ext}{$end}) {
$sitenum = $SITEDATA_ALIASES{$can}{$root}{$ext}{$end};
$frompage = $SITEDATA_ID{$sitenum};
}elsif (exists $SITEDATA_ALIASES{$can2}{$root}{$ext}{$end}) {
$sitenum = $SITEDATA_ALIASES{$can2}{$root}{$ext}{$end};
$frompage = $SITEDATA_ID{$sitenum};
}elsif (exists $SITEDATA_ALIASES{$can2}{$root}{$ext}{'/'}) {
$sitenum = $SITEDATA_ALIASES{$can2}{$root}{$ext}{'/'};
$frompage = $SITEDATA_ID{$sitenum};
}
}
$frompage = $domain unless $frompage;
}
#print "frompage: $frompage ";
#print "\n";
#print "\n";
$| = 1;
unless ($domain) {$domain = "default";}
#print "\n";
##### change for 4freequotes
if ($domain eq "insurance") {$itrue = 1;}
if ($frompage eq "insurance") {$itrue = 1;}
if ($domain eq "http://www.4freequotes.com") {
#$domain = "4fq";
#$frompage = "4fq";
$itrue = 1;
}
if ($frompage eq "http://www.4freequotes.com") {
#$domain = "4fq";
#$frompage = "4fq";
$itrue = 1;
}
if ($domain eq "http://www.find-health-insurance.com") {$domain = "insurance";$frompage = "insurance";$itrue = 2;}
if ($frompage eq "http://www.find-health-insurance.com") {$domain = "insurance";$frompage = "insurance";$itrue = 2;}
#####
#print "\n";
#print "\n";
$stupid = 0;
$frompage2 = $domain;
$frompage2 =~ s/\//\|/go;
while ($frompage2 =~ m/\|/go) {$stupid += 1;}
if ($stupid >= 3) {
$domain =~ m/.*?\.(.*?)\//go;
$rootfrompage = $1;
}else{
$domain =~ m/.*?\.(.*?)$/go;
$rootfrompage = $1;
}
if ($domain eq "default") {$rootfrompage = $domain;}
#if ($domain eq "http://www.freefanatic.com/ssi.html") {$live = "live";}else{$live = "";}
$dotcount = 0;
while ($rootfrompage =~ m/\./go) {$dotcount += 1;}
if ($dotcount >= 2) {
$rootfrompage =~ m/.*?\.(.*?)$/go;
$rootfrompage = $1;
}
#print "rf: $rootfrompage ";
#print "Frompage: $frompage " ;
$frompage = 'default' unless ($frompage);
if (exists $SITEDATA{$frompage}) {
#print "default exists! ";
$use = $frompage;
}else{
if (exists $SITEDATA{$domain}) {
$use = "$domain";
}else{
$hdomain = "http://" . $domain;
if (exists $SITEDATA{$hdomain}) {
$use = "$hdomain";
}else{
$use = 'default';
}
}
}
$frompage = $use;
#print "\n";
#print "\n";
$q_frompage = $dbh->quote($frompage);
$sth = $dbh->prepare("SELECT COUNT(id) FROM pagetrack WHERE page=$q_frompage AND DATE_FORMAT(whenviewed, \"%Y %M %D\")=DATE_FORMAT(NOW(), \"%Y %M %D\") "); # 12-9 change for passed-in frompage
$sth->execute();
($dcount) = $sth->fetchrow_array();
if ($dcount < 1) {
$sth = $dbh->prepare("INSERT INTO pagetrack VALUES (NULL,$q_frompage,'$F{ip}',NOW(),'0')"); # 12-9 change for passed-in frompage
$sth->execute();
}else{
$sth = $dbh->prepare("UPDATE pagetrack SET views=views+1 WHERE page=$q_frompage AND DATE_FORMAT(whenviewed, \"%Y %M %D\")=DATE_FORMAT(NOW(), \"%Y %M %D\") "); # 12-9 change for passed-in frompage
$sth->execute();
}
#print "use: $use ";
#($id,$odomain,$searchterm,$stylesheet,$template,$otitle,$heading,$bannerzone,$quantity,$itemnumbers,$itembullets,$itemspace,$pdescription,$keywords,$htmllink,$sitetitle,$blurb) = $sth->fetchrow_array();
$id = $SITEDATA{$frompage}{id};
$odomain = $SITEDATA{$frompage}{domain};
$searchterm = $SITEDATA{$frompage}{searchterm};
$stylesheet = $SITEDATA{$frompage}{stylesheet};
$template = $SITEDATA{$frompage}{template};
$otitle = $SITEDATA{$frompage}{title};
$heading = $SITEDATA{$frompage}{heading};
$bannerzone = $SITEDATA{$frompage}{bannerzone};
$quantity = $SITEDATA{$frompage}{quantity};
$itemnumbers = $SITEDATA{$frompage}{itemnumbers};
$itembullets = $SITEDATA{$frompage}{itembullets};
$itemspace = $SITEDATA{$frompage}{itemspace};
$pdescription = $SITEDATA{$frompage}{description};
$keywords = $SITEDATA{$frompage}{keywords};
$htmllink = $SITEDATA{$frompage}{htmllink};
$sitetitle = $SITEDATA{$frompage}{sitetitle};
$blurb = $SITEDATA{$frompage}{blurb};
#print "\n\n";
if ($bannerzone eq "") {$bannerzone = 'Shopping';}
if ($F{action} eq "more") {&more;}
#if ($domain =~ m/123-sites\.com/) {$F{search} = "";}
if ($F{search} ne "") {$searchterm = $F{search};goto SKIP;}
}
$ID = $id;
if (exists $SEARCHTERMSI{$id}) {
$rows = 0;
foreach (keys %{$SEARCHTERMS{$id}}) {$rows++;}
#print "rows: $rows ";
#print "ok ($id): $SEARCHTERMSI{$id} ";
$searchterm = "";
@grab = ();$g = "";
@head = ();$h = "";
@headerlinks = ();$hl = "";
%grabq = ();
(@starray) = sort { $SEARCHTERMS{$id}{$a} <=> $SEARCHTERMS{$id}{$b} } keys %{$SEARCHTERMS{$id}};
foreach $searchterm(@starray) {
#print "$searchterm ";
if ($rows > 1) {
#print "$searchterm ";
$a_searchterm = $searchterm;
$a_searchterm =~ s/\s/\%20/go;
$head[$h++] = " $searchterm \n";
$headerlinks[$hl++] = " $searchterm\n";
}
$grab[$g++] = $searchterm;
$grabq{"$searchterm"} = $SEARCHTERMSQ{$id}{$searchterm};
$myUA::grabq{"$searchterm"} = $SEARCHTERMSQ{$id}{$searchterm};
#print "g: $searchterm - $SEARCHTERMSQ{$id}{$searchterm} ";
}
if ($rows > 1) {
$head[$h++] = "