#!/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++] = "

"; $headerlinks[$hl++] = "

"; } &foreign_search; }else{ #print "not ok ($id): $SEARCHTERMSI{$id}
"; SKIP: @grab = (); %grabq = (); $grab[0] = $searchterm; $grabq{"$searchterm"} = $quantity; $myUA::grabq{"$searchterm"} = $quantity; &foreign_search; } &foutput; sub foutput { #print "$results2
"; $head = ""; $headerlinks = ""; $results = ""; $bannercode = ""; $head = join (' ', @head); $headerlinks = join (' ', @headerlinks); $results = join (' ', @results); foreach (keys %bannercode) { @bannercode[$bc++] = $_ . "|^|" . $bannercode{$_}; } $bannercode = join ('||', @bannercode); #@ovalues = ($dbh,$heading,$domain,$pdescription,$itrue,$keywords,$bannerzone,$testnew,$testlinks,$otitle,$noresults_header,$template,$stylesheet,$results2,$results,$head,$headerlinks,$ID,$rootfrompage,$bannercode); #$output = output->output(@ovalues); &output; #print "dbh: $dbh
heading: $heading
domain: $domain
pdescription: $pdescription
itrue: $itrue
keywords: $keywords
bannerzone: $bannerzone
testnew: $testnew
testlinks: $testlinks
otitle: $otitle
noresults_header: $noresults_header
template: $template
stylesheet: $stylesheet
results: $results
head: $head
headerlinks: $headerlinks
id: $ID
rootfrompage: $rootfrompage
bannercode: $bannercode
"; print "$output"; &cleanup; exit; } sub output { #my (%oreturn,%bannercode,@links,@canlinks,@testlinks,@bc,@template); #my ($n,$c,$domain2,$domain3,$adomain,$output,$sth,$stp,$tl,$l,$tid,$link,$address,$inc,$htmllink,$tdisp,$cl,$url,$sitetitle,$testrootfrompage,$testdomain); # my ($name,$dbh,$heading,$domain,$pdescription,$itrue,$keywords,$bannerzone,$testnew,$testlinks,$otitle,$noresults_header,$template,$stylesheet,$results2,$results,$head,$headerlinks,$ID,$rootfrompage,$bannercode) = @_; #my ($dbh,$heading,$domain,$pdescription,$itrue,$keywords,$bannerzone,$testnew,$testlinks,$otitle,$noresults_header,$template,$stylesheet,$results2,$results,$head,$headerlinks,$ID,$rootfrompage,$bannercode) = @_; @bc = split (/\|\^\|/, $bannercode); foreach (@bc) { ($n,$c) = split (/\|\|/, $_); $bannercode{$n} = $c; } $oreturn{js} = q[ ]; chomp $pdescription; $pdescription =~ s/\n/ /g; $pdescription =~ s/\r/ /g; $pdescription =~ s/&/&/g; if ($itrue == 1) {$template = "blank";} if ($itrue == 2) {$template = "blank";} $keywords =~ s/,$//; $keywords =~ s/, $//; #print "template: $template
"; if ($template eq 'bare') { #$oreturn{output} .= "bare
"; $stylesheet =~ s/&/&/g; $oreturn{output} = ""; $oreturn{output} .= "$otitle"; $oreturn{output} .= ""; $oreturn{output} .= ""; $oreturn{output} .= ""; $oreturn{output} .= ""; $oreturn{output} .= "$heading

$results $results2"; $oreturn{output} .= ""; }elsif ($template eq 'blank') { #$oreturn{output} .= "blank
"; $oreturn{output} = "$results $results2"; }elsif ($template eq 'blank_noheader') { #$oreturn{output} .= "blank_noheader
"; $results =~ s'''igo; $results2 =~ s'''igo; $oreturn{output} .= "$results $results2"; }elsif ($template ne '') { #$oreturn{output} .= "/home/sites/site6/cgi-bin/disp_templates/$template
"; open (TEMP, "/home/sites/site6/cgi-bin/disp_templates/$template"); @template = ; close (TEMP); $domain =~ /http:\/\/www\.(.*?)\//io; $domain2 = $1; $domain =~ /http:\/\/(.*?)\//gio; $domain3 = $1; $domainname = $domain3; unless ($domain2) { $domain2 = $domain3; } unless ($domain2) { $domain2 = $domain; } if ($domain2 eq "/") {$domain2 = $domainroot;} #print "domain2: $domain2
domain: $domain dr: $domainroot
"; $adomain = $domain; $adomain =~ /http\:\/\/(.*?)\//gio; $adomain = $1; # if ($domain eq "http://www.freefanatic.com/ssi.html") { # # $testnew = "click here to advertise on this page."; # $testnew = "click here to advertise on this page."; # }else{ # $testnew = ""; #} #print "id: $ID
"; #print "SELECT * FROM searchlinks WHERE id='$ID' ORDER BY inc ASC
"; $sth = $dbh->prepare("SELECT * FROM searchlinks WHERE id='$ID' ORDER BY inc ASC"); $sth->execute(); $stp = $dbh->prepare("SELECT searchlinktitle FROM searchlinktitles WHERE domain='$ID' "); $stp->execute(); my ($searchlinktitle) = $stp->fetchrow_array(); $links[$l++] = "$searchlinktitle
"; while (($tid,$link,$address,$inc,$htmllink) = $sth->fetchrow_array()) { if ($htmllink eq "Y") { $links[$l++] = " $link
"; }else{ $address =~ s/&/&/go; $links[$l++] = " $link
"; } } $tdisp = "$heading

"; $stp = $dbh->prepare("SELECT showaplinks FROM sitedata WHERE id='$ID' "); $stp->execute(); my ($showaplinks) = $stp->fetchrow_array(); if ($showaplinks eq "on") { $sth = $dbh->prepare("SELECT * FROM searchaplinktitle"); $sth->execute(); my ($aptitle) = $sth->fetchrow_array(); $links[$l++] = "
$aptitle
"; $sth = $dbh->prepare("SELECT * FROM searchaplinks"); $sth->execute(); while (($link,$address,$inc,$htmllink) = $sth->fetchrow_array()) { if ($htmllink eq "Y") { $links[$l++] = " $link
"; }else{ $address =~ s/&/&/go; $links[$l++] = " $link
"; } } } $sth = $dbh->prepare("SELECT domain,sitetitle FROM sitedata WHERE domain LIKE '%$rootfrompage%' AND (sitetitle != NULL OR sitetitle != '') ORDER BY domain ASC"); $sth->execute(); my $rows = $sth->rows(); if ($rows > 0) { $canlinks[$cl++] = "
Related Links:
"; while (($url,$sitetitle) = $sth->fetchrow_array()) { if ($sitetitle eq "") {next;} if ($url eq $domain) {next;} $url =~ s/&/&/go; $canlinks[$cl++] = " $sitetitle
"; } } if ($template eq 'testlinks.html') { $sth = $dbh->prepare("SELECT domain FROM sitedata ORDER BY domain ASC"); $sth->execute(); while (($testdomain) = $sth->fetchrow_array()) { my $stupid = 0; my $frompage2 = $testdomain; $frompage2 =~ s/\//\|/go; while ($frompage2 =~ m/\|/go) {$stupid += 1;} if ($stupid >= 3) { $testdomain =~ m/.*?\/\/(.*?)\//go; $testrootfrompage = $1; }else{ $testdomain =~ m/.*?\/\/(.*?)$/go; $testrootfrompage = $1; } if ($testdomain eq "default") {next;} my $dotcount = 0; while ($testrootfrompage =~ m/\./go) {$dotcount += 1;} if ($dotcount > 2) { $testrootfrompage =~ m/.*?\.(.*?)$/go; $testrootfrompage = $1; } $testdomain =~ s/&/&/go; $testlinks[$tl++] = "$testrootfrompage"; } $testlinks = join (' || ', @testlinks); } if ($template eq "christmas.html") { $asl_bgcolor = "EEEEEE"; }elsif ($template eq "designerhandbag.html") { $asl_bgcolor = "008ECB"; }elsif ($template eq "electricglobe.html") { $asl_bgcolor = "008ECB"; } use LWP::Simple; $allsitelinks = get("http://www.freesearch.com/cgi-bin/allsitelinks.pl?background_color=$asl_bgcolor&how_many=6&width=100&height=72&orientation=v&per_row=1"); $keywords =~ s/,$//o; $keywords =~ s/, $//o; $bannerzone =~ s/\s/+/go; if ($blurb ne "") {$blurb = "
" . $blurb . "

";} #print "\n\n\n\n"; foreach (@template) { $_ =~ s//$bannercode{1}/go; $_ =~ s/\%allsitelinks\%/$allsitelinks/go; $_ =~ s/\%testnew\%/$testnew/go; $_ =~ s/\%testlinks\%/$testlinks/go; $_ =~ s/\%title\%/$otitle/go; $_ =~ s/\%description\%/$pdescription/go; $_ =~ s/\%keywords\%/$keywords/go; $_ =~ s/\%output\%/$results $results2/go; $_ =~ s/\%domainfull\%/$domain/go; $_ =~ s/\%domain\%/$domain3/go; $_ =~ s/\%adomain\%/$adomain/go; $_ =~ s/\%domain3\%/$domain3/go; $_ =~ s/\%domainname\%/$domainname/go; # $_ =~ s/\%domain2\%/$domain2/go; $_ =~ s/\%domain2\%/$domain2

$headerlinks/go; $_ =~ s/\%headerlinks\%/$headerlinks/go; $_ =~ s/\%bannerzone\%/$bannerzone/g; $_ =~ s/\%links\%/$tdisp$head@links@canlinks/go; $_ =~ s/\%stylesheet\%/$stylesheet/go; $_ =~ s/\%noresults_header\%/$noresults_header/go; $_ =~ s/\%blurb\%/$blurb/go; $oreturn{output} .= $_; } } $heading = ""; $headerlinks = ""; $output .= $oreturn{output}; %oreturn = (); return $output; } sub cleanup { %F = (); %results = (); %return = (); %myUA::grabq = (); %grabq = (); %grab = (); $output = ""; @values = (); @ovalues = (); @pvalues = (); @bannercode = (); $id = ""; $odomain = ""; $searchterm = ""; $stylesheet = ""; $template = ""; $otitle = ""; $heading = ""; $bannerzone = ""; $quantity = ""; $itemnumbers = ""; $itembullets = ""; $itemspace = ""; $pdescription = ""; $keywords = ""; $htmllink = ""; $sitetitle = ""; $frompage = ""; $domain = ""; @headerlinks = (); $headerlinks = ""; $domain2 = ""; $domain3 = ""; $first = ""; } sub more { $oquantity = $quantity; $quantity = 20; $q2 = $F{'q'} + $quantity; $q3 = $F{'q'} - $quantity; $searchterm = ""; $searchterm = $F{'search'}; $searchterm =~ s/\_/ /go; $domain = $F{'domain'}; if ($itrue == 1) {$domain = "http://www.4freequotes.com";} if ($itrue == 2) {$domain = "http://www.find-health-insurance.com";} $urlsearch = $F{'search'}; $urlsearch =~ s/\s/\%20/go; $urlsearch =~ s/\_/\%20/go; $frompage = $F{'frompage'}; $ua = ""; $ua = LWP::UserAgent->new(); $ua->agent("MultiSearch/0.1"); $ua->timeout(10); # change the timeout value as necessary #print "\n"; warn "more \n"; $turl = "http://us01.xmlsearch.findwhat.com/bin/findwhat.dll?getresults&Base=$F{'q'}&MT=$urlsearch&dc=20&aff_id=47114&ip_addr=$F{'ip'}&at=Q9JOCP72R7"; $req = HTTP::Request->new('GET' => $turl); #change as appropriate $res = $ua->request($req); $page = $res->content(); #&findwhat($page); # alter &set_values; $pro = process->new(); $results[$r++] = $pro->process(@pvalues,$turl,$searchterm,$quantity,$page); # $page =~ /records=\"(.*?)\"/g; $totalresults = $1; if ($q2 <= $totalresults) { $next = "
"; } if ($q3 <= 0) { $previous = "
"; }else{ $previous = "
"; } $results[$r++] = "\n
$next$previous
\n"; &foutput; } sub set_values { @pvalues = ($domain,$IP,$F{action},$rows,$itemnumbers,$itembullets,$itemspace,$live,$frompage,$barcolor,$dbh,$first); #print "pvalues
domain: $domain
IP: $IP
action: $F{action}
rows: $rows
itemnumbers: $itemnumbers
itembullets: $itembullets
itemspace: $itemspace
live: $live
frompage: $frompage
barcolor: $barcolor
dbh: $dbh"; } sub foreign_search { $counter = 0; $ua = ""; $ua = myUA->new("InnovativeAdvertising", "www.innovativeadvertising.net"); $ua->from("admin\@innovativeadvertising.net"); $ua->max_hosts(40); $ua->max_req(25); #$ua->delay(0); $ua->redirect(0); $ua->env_proxy; #print "-"; $| = 1; $sterm= "";$term = ""; foreach $sterm(@grab){ next unless ($sterm); unless ($first) {$first = $sterm;} $term = $sterm; $term =~ s/\s/\%20/g; $term =~ s/\_/\%20/g; if (($IP eq "67.175.8.192") || ($IP eq "67.190.122.169") || ($IP eq "76.167.70.155") || ($IP eq "98.206.64.72")){ #warn "Calling req_leadsandfeeds ($IP) \n"; #&req_leadsandfeeds; #&req_ask; &req_myxmlsource; #&req_findwhat; }else{ #warn "regular user ($IP): calling req_myxmlsource \n"; # only one of the following can be active at a time at the moment. #&req_leadsandfeeds; #&req_ask; # uncomment this to activate ask &req_myxmlsource; #&req_findwhat; # uncomment this to activate findwhat } #&req_kanoodle; } #print "-"; $howmany += $howmany; &set_values; $entries = $ua->wait(); # responses will be caught by on_return, etc #print "-"; $st = ""; $results2 = ""; #print "grab: @grab
"; foreach $st(@grab) { #warn "results $st: $results{\"$st\"} \n\n"; $results2 .= $results{"$st"}; $results2 .= "$spacer"; } %OUTPUT = (); %results = (); } sub req_myxmlsource { # myxmlsource request $useragentstring = $F{useragentstring}; $useragentstring =~ s/ /\%20/g; $useragentstring =~ s/;/\%3B/g; #warn "http://xml.myxmlsource.com/cgi-bin/feed?par=2568&query=$term&count=10&start=1&ip=$IP&useragent=$useragentstring \n"; $req = new HTTP::Request 'GET' => "http://xml.myxmlsource.com/cgi-bin/feed?par=2568&query=$term&count=10&start=1&ip=$IP&useragent=$useragentstring"; $req->header('Accept' => 'text/html'); $ua->register($req); } sub req_ask { # Ask request $useragentstring =~ s/ /\%20/g; #warn "http://frazoo.syndication.ask.com/frazoo?userip=$IP&q=$term&useragent=$useragentstring&o=10583 \n"; $req = new HTTP::Request 'GET' => "http://frazoo.syndication.ask.com/frazoo?userip=$IP&q=$term&useragent=$useragentstring&o=10583"; $req->header('Accept' => 'text/html'); $ua->register($req); } sub req_findwhat { # FindWhat request #warn "http://us01.xmlsearch.findwhat.com/bin/findwhat.dll?getresults&Base=0&MT=$term&dc=25&aff_id=47114&ip_addr=$IP \n"; $req = new HTTP::Request 'GET' => "http://us01.xmlsearch.findwhat.com/bin/findwhat.dll?getresults&Base=0&MT=$term&dc=25&aff_id=47114&ip_addr=$IP&at=Q9JOCP72R7"; $req->header('Accept' => 'text/html'); $ua->register($req); } sub req_leadsandfeeds { # leadsandfeeds request $useragentstring = $F{useragentstring}; $useragentstring =~ s/ /\%20/g; $useragentstring =~ s/;/\%3B/g; $useragentstring =~ s/:/%3A/g; $useragentstring =~ s/\?/%3F/g; $useragentstring =~ s/=/%3D/g; $useragentstring =~ s/&/%26/g; $enc_domain = $domain; $enc_domain =~ s/:/%3A/g; $enc_domain =~ s/\?/%3F/g; $enc_domain =~ s/=/%3D/g; $enc_domain =~ s/&/%26/g; #warn "http://xml.leadsandfeeds.com/ppc?aid=1200&cid=686&remoteaddr=$IP&key=$term&bp=1&count=10&ua=$useragentstring&ref=$enc_domain \n"; $req = new HTTP::Request 'GET' => "http://xml.leadsandfeeds.com/ppc?aid=1200&cid=686&remoteaddr=$IP&key=$term&bp=1&count=10&ua=$useragentstring&ref=$enc_domain"; $req->header('Accept' => 'text/html'); $ua->register($req); } sub req_kanoodle { # Kanoodle Request # print "http://partner1.kanoodle.com/cgi-bin/partner.cgi?noros=1&id=54720110&format=xml5&adultfilter=1&lowbid=.02&query=$term
"; $req = new HTTP::Request 'GET' => "http://partner1.kanoodle.com/cgi-bin/partner.cgi?noros=1&id=54720110&format=xml5&adultfilter=1&lowbid=.02&query=$term"; $req->header('Accept' => 'text/html'); $ua->register($req); } sub freesearch { $page = shift @_; $counter = 0; while ($page =~ m,(.*?),sg) { $link = $1; $counter += 1; ($title,$redirect,$description) = $link =~ m`.*?(.*?).*?(.*?).*?(.*?)`sx; $foreign{$redirect} = "$title||$description||$redirect"; $uforeign{$redirect} = $counter; } } sub myxmlsource { $page = shift @_; $link = ""; while ($page =~ m,(.*?),sg) { $link = $1; $counter += 1; #warn "\n\n$counter: $link\n"; ($bid, $description, $url, $rank, $title, $redirect) = $link =~ m'(.*?).*?(.*?).*?(.*?).*?(.*?).*?(.*?).*?(.*?)'sx; #print "redirect: $redirect
\n"; #warn "redirect: $redirect\n"; $title =~ s/\&/\&/g; $description =~ s/\&/\&/g; $redirect =~ s/\&/^/g; $foreign{$redirect} = "$title||$description||$redirect||$bid||$url"; $uforeign{$redirect} = $counter; } } sub ask { $page = shift @_; $link = ""; #$counter = 0; warn "sub ask\n"; while ($page =~ m,(.*?),sg) { $link = $1; $counter += 1; warn "\n\n$counter: $link\n"; ($title, $url, $redirect, $description, $bid) = $link =~ m,(.*?)(.*?)(.*?)(.*?),sx; $foreign{$redirect} = "$title||$description||$redirect||$bid||$url"; $uforeign{$redirect} = $counter; } } sub findwhat { $page = shift @_; $link = ""; #$counter = 0; while ($page =~ m,(.*?),sg) { $link = $1; $counter += 1; ($title, $url, $description, $bid, $redirect) = $link =~ m,.*?CDATA\[\s*(.*?)\s*]]>\s*(.*?).*?CDATA\[\s*(.*?)\s*]]>\s*(.*?)(.*?),sx; $foreign{$redirect} = "$title||$description||$redirect||$bid||$url"; $uforeign{$redirect} = $counter; } } sub leadsandfeeds { $page = shift @_; $link = ""; #$counter = 0; #warn "\n$page \n\n"; while ($page =~ m,(.*?),sg) { $link = $1; $counter += 1; ($url, $redirect, $description, $title, $bid) = $link =~ m,<\!\[CDATA\[(.*?)\]\]>.*?<\!\[CDATA\[(.*?)\]\]>.*?<\!\[CDATA\[(.*?)\]\]>.*?<\!\[CDATA\[(.*?)\]\]>.*?<\!\[CDATA\[(.*?)\]\]>,sxo; #($title, $url, $description, $bid, $redirect) = $link =~ m,.*?CDATA\[\s*(.*?)\s*]]>\s*(.*?).*?CDATA\[\s*(.*?)\s*]]>\s*(.*?)(.*?),sx; $title =~ s/\&/\&/g; $description =~ s/\&/\&/g; $redirect =~ s/\&/^/g; $foreign{$redirect} = "$title||$description||$redirect||$bid||$url"; $uforeign{$redirect} = $counter; } } sub kanoodle { $page = shift @_; $link = ""; #$counter = 0; while ($page =~ m,(.*?),sg) { $link = $1; $counter += 1; ($title, $url, $description, $bid, $redirect) = $link =~ m'.*?\[CDATA\[(.*?)\].*?\[CDATA\[(.*?)\]\].*?\[CDATA\[(.*?)\]\].*?\[CDATA\[(.*?)\]\].*?\[CDATA\[(.*?)\]\].*?'gism; $foreign{$redirect} = "$title||$description||$redirect||$bid||$url"; $uforeign{$redirect} = $counter; } } sub input { $in = new CGI; @variables = (); @variables = $in->param(); foreach (@variables){ $F{$_} = $in->param($_); $F{$_} =~ s/<\!--.*-->//g; $F{$_} =~ s/`//g; } } }