#!/usr/bin/perl
#############################################################
# Copyright (C) 1999 Anaconda Partners
#
# CONFIGURATION
#
# ANACONDA MAIN SCRIPT
#
# Make sure to set the first line to point to your perl5 binary!
#
$AP_aversion="Anaconda Version: [1.12] [SEARCH AMAZON.COM] [1/28/00]";
#
#
# Amazon.com Affiliate Site Code
$AP_sitecode = "blackbookshelfin";
#
#
# HTML template file for the search results.
# Pass a "template" field in a get or post to override this.
$AP_defaulttemplatefile = "atemplate.html";
#
#
# Template file directory
# If this is left commented out, the template files are assumed to be in the same directory 
# as the anaconda.pl file.  Under unix it is something like: "/home/mysite/cgi-bin/"
# and under NT it is something like "c:\\inetpub\\wwwroot\cgi-bin\\"
#$AP_templatedir = "d:\\inetpub\\wwwroot\\cgi-bin\\";
#
#
# web server platform
$AP_http_os = "UNIX"; # UNIX or NT
#
#
# Color substitutions
# Override for Amazon Headings (normally orange).  Set to whatever html color setting you would like.
#$AP_newheadingcolor = "#00007d";
# Override for Amazon shipping/price notes (normally red).  Set to whatever html color setting you would like.
#$AP_newshippingcolor = "#00FF00";
#
# This allows you to have your own images in place of the Amazon.com ones, since the Amazon
# ones assume a white background...some people wanted to alter them.  You will need to create
# the same directory structure as Amazon beyond this settable root (ie. /g/detail/xxxx.gif)
#$AP_imageroot = "http://www.anaconda.net/images";
#
# Log file name (for logging search terms).
# This is useful for learning what your visitors are interested in.  It allows you to target
# them with better choices of recommended books, etc.  Uncomment the line to turn it on.
# NOTE: some server require you to pre-create the file, and verify the permissions are writable by all
$AP_logfile = "anacondalog.txt";
#
#
# Uncomment this line to allow viewing of sorted logfile through browser (url = anaconda.pl?command=sortlog)
#$AP_allowsortlog = 1;
#
#
# Uncomment this to have hyperlinks to Amazon open a new browser window
$AP_newbrowserwindow=1;
#
#
# maximum time to wait for host site
$AP_maxtime=20;
#
# address of host site (for Amazon UK change to "www.amazon.co.uk", for German Amazon change to "www.amazon.de")
$AP_siteaddress="www.amazon.com";
#
#
# Final link to Amazon setting..."<ASIN>" will be replaced with the ASIN/ISBN code...and "<SITECODE>" will get 
# replaced with your sitecode.  Change only if you want the final link to go somewhere else.
$AP_finallink = "http://$AP_siteaddress/exec/obidos/ASIN/<ASIN>/<SITECODE>";
#
#
# These setting should be used when there is a timeout problem with the host site. 
# First try the AP_use_original line, then try the AP_use_LWP line.  Remove the #
# sign to try out each setting.
#$AP_use_LWP = 1;
#$AP_use_original = 1;
#
#
###### PLEASE CHANGE NOTHING BELOW THIS LINE! ##################################
 use Socket; setstdstuff(); InitStuff(); if($I11I111I1I1I1I1I)
{ $I1II1I1I1I1IIIII=qq| target="_blank" |; } $| = 1; $I11111II11111III = ""; $I1II11I1II11I111 = $ENV{SCRIPT_NAME};
unless($I1II11I1II11I111 =~ /^\//){ $I1II11I1II11I111 = "/$I1II11I1II11I111"; }
if($I111I11I11I1I11I) {	$I1I1I1I11111III1 = "color[ =\"#]+CC6600";
$I11II11IIIIIII1I = "color=\"$I111I11I11I1I11I\""; } if($I11II1I11II11I11)
{	$I1IIII1IIIIIIIII = "color[ =\"#]+990033";  $I11I1III111I1I11 = "color=\"$I11II1I11II11I11\""; }
$I1III11I1I11IIII = $ENV{'CONTENT_TYPE'}; $I11II1111II1I11I  = $ENV{'CONTENT_LENGTH'};
$I11II111I11III11 = $ENV{'REQUEST_METHOD'}; if (!defined $I11II111I11III11 || $I11II111I11III11 eq '') 
{ $I1II11111I1IIIII = $ENV{'QUERY_STRING'}; }  elsif($I11II111I11III11 eq 'GET' || $I11II111I11III11 eq 'HEAD') 
{ $I1II11111I1IIIII = $ENV{'QUERY_STRING'}; }  else  { read(STDIN, $I1II11111I1IIIII, $I11II1111II1I11I);
}  $I11II11I1I1111II = URLDecodeString("$I1II11111I1IIIII&");
print "Content-type: text/html\n\n"; $_=$I11II11I1I1111II; if(!($I111IIII1I1I1I11 =~ m|\w:\s*\[.*?\]\s*\[.*?\]\s*\[.*?\]|i))
{ print "INVALID ANACONDA INSTALLATION!\n"; exit; } $I1I1II11IIIIIIII=0; 
if($I11II111I11III11 eq 'POST') { if(m/post=(.*?)\&/i) { $I1IIII1I11111II1=URLDecodeString($1); s/post=(.*?)\&//i; }
$I1III1I11III111I = $_; } if(m/siteaddress=(.*?)\&/i) { $I1II1I11III111I1=URLDecodeString($1); s/siteaddress=(.*?)\&//i; }
if(m/command=(.*?)\&/i) { $I111IIII1III1I1I=URLDecodeString($1); s/command=(.*?)\&//i; }
if($I111IIII1III1I1I =~ m|version|i) { print "$I111IIII1I1I1I11\n";
exit; } m/keyword=(.*?)\&/i; $I1I1II11II1III1I=$1;  m/keyword(.*?)\&/i; $I1II1III11III1II=$1; 
$I11IIII11111III1 = $I1I1II11II1III1I; $I11IIII11111III1 =~ s/\+/ /g;
$I1II1111III11II1 = URLEncodeString($I11IIII11111III1); if(m|morelink|i)
{ s/keyword=(.*?)\&//i;  if(m/morelink=(.*?)$/i) { $I11I1IIII1III11I=$1; s/morelink=(.*?)$//i; }
} $I1IIII1I1IIII111 = ""; if(m/template=(.*?)\&/i) { $I1I111I111II11II=$1; s/template=(.*?)\&//i; }
if(m/postkey=(.*?)\&/i) { $I1II1III1I11I1I1=URLDecodeString($1); s/postkey=(.*?)\&//i; }
if(m/prekey=(.*?)\&/i) { $I1II1II1II11II1I=URLDecodeString($1); s/prekey=(.*?)\&//i; }
if(m/f1=(.*?)\&/i) { $f1=URLDecodeString($1); s/f1=(.*?)\&//i; }
if(m/f2=(.*?)\&/i) { $f2=URLDecodeString($1); s/f2=(.*?)\&//i; }
if(m/f3=(.*?)\&/i) { $f3=URLDecodeString($1); s/f3=(.*?)\&//i; }
if(m/f4=(.*?)\&/i) { $f4=URLDecodeString($1); s/f4=(.*?)\&//i; }
if(m/f5=(.*?)\&/i) { $f5=URLDecodeString($1); s/f5=(.*?)\&//i; }
if(m/f6=(.*?)\&/i) { $f6=URLDecodeString($1); s/f6=(.*?)\&//i; }
if(m/f7=(.*?)\&/i) { $f7=URLDecodeString($1); s/f7=(.*?)\&//i; }
if(m/f8=(.*?)\&/i) { $f8=URLDecodeString($1); s/f8=(.*?)\&//i; }
if(m/f9=(.*?)\&/i) { $f9=URLDecodeString($1); s/f9=(.*?)\&//i; }
if(m/siteaddress=(.*?)\&/i) { $I1II1I11III111I1=URLDecodeString($1); s/siteaddress=(.*?)\&//i; }
if(m/c1=(.*?)\&/i) { $I111I11I11I1I11I=URLDecodeString($1); s/c1=(.*?)\&//i; }
if(m/c2=(.*?)\&/i) { $I11II1I11II11I11=URLDecodeString($1); s/c2=(.*?)\&//i; }
if(m/tag=(.*?)\&/i) { $I111I1III1II11II=$1; }  if(m/mode=(.*?)\&/i) { $I1I111I1IIIIIII1=$1; } else { $I1I111I1IIIIIII1="books"; }
$I11II11I1I1111II=$_; if($I111IIII1III1I1I =~ /sortlog/) { DoSortLog();
} else { if($I1IIII1I11111II1) { $I1I111I111II11I1=$I1IIII1I11111II1;
if($I1I111I111II11I1 =~ s|http://([^/]*)$|/|i) { $I1II1I11III111I1 = $1;
} if($I1I111I111II11I1 =~ s|http://([^/]*?)/|/|i) { $I1II1I11III111I1 = $1;
} $I1I111I111II11I1 =~ s|\?(.*?)$||; $I1111II1III1I11I = $1; if($I11II111I11III11 eq 'GET')
{ $I1I1IIII11III11I = &HTTPGet("$I1I111I111II11I1", "$I1II1I11III111I1", 80, "$I1111II1III1I11I");
} else { $I1I1IIII11III11I = &HTTPPost("$I1I111I111II11I1", "$I1II1I11III111I1", 80, "$I1III1I11III111I");
} if($I1I111I111II11I1 =~ m|^(.*?)/[^/]*$|i) { $I111I1IIIIIII1II = $1;
} } elsif (/subsequent-query/)  { $I11II11I1I1111II =~ s/tag=(.*?)\&//; 
$I11II11I1I1111II =~ s|&$||i; @I11I11IIII111111=split(/&subsequent-query/, $I11II11I1I1111II);
$I1I1III111III111=substr($I11I11IIII111111[0],4); $I1I1IIII11III11I = &HTTPPost("/exec/obidos/subsequent-query/$I1I1III111III111", "$I1II1I11III111I1", 80, "subsequent-query$I11I11IIII111111[1]"); 
if(length($I1I1IIII11III11I)==0)	 {  print "Anaconda Error - $I1II1I11III111I1 failed to respond in $I11I1IIII1I11II1 seconds.\n";	
exit;  }		 } elsif ($I11I1IIII1III11I)  { $I1I1IIII11III11I = &HTTPGet("/exec/obidos/search-handle-url/$I11I1IIII1III11I", "$I1II1I11III111I1", 80, ""); 
if(length($I1I1IIII11III11I)==0)	 {  print "Anaconda Error - $I1II1I11III111I1 failed to respond in $I11I1IIII1I11II1 seconds.\n";	
exit;  } if ($I1I1IIII11III11I =~ m#Location: http://(.+?)/(.+)\?(.+)$#m)	
{  $I1I1IIII11III11I=&HTTPGet("/$2", "$1", 80, $3);  if(length($I1I1IIII11III11I)==0)	{ print "Anaconda Error - $I1II1I11III111I1 failed to respond in $I11I1IIII1I11II1 seconds.\n";	exit; }
}  elsif ($I1I1IIII11III11I =~ m|Location: http://(.+?)/(.+)$|im)	
{  $I1I1IIII11III11I=&HTTPGet("/$2", "$1", 80, "");  if(length($I1I1IIII11III11I)==0)	{ print "Anaconda Error - $I1II1I11III111I1 failed to respond in $I11I1IIII1I11II1 seconds.\n";	exit; }
}	 } else { if($I11II1I1II1I1II1) { open(logfile1,">>$I11II1I1II1I1II1");
$I1I1I1II11111III = $I1II1III11III1II; $I1I1I1II11111III =~ s/^[=\+]+//; 
while ($I1I1I1II11111III =~ s/\+/ /) { }; print logfile1 "$I1I1I1II11111III\n"; close logfile1; 
} if($I1II1II1II11II1I) { $I11II11I1I1111II =~ s/keyword=(.*?)\&/keyword=$I1II1II1II11II1I $1\&/i; }
if($I1II1III1I11I1I1) { $I11II11I1I1111II =~ s/keyword=(.*?)\&/keyword=$1 $I1II1III1I11I1I1\&/i; }
$I11II11I1I1111II =~ s/\+/%20/g; $I1I1IIII11III11I = &HTTPGet("/exec/obidos/external-search", "$I1II1I11III111I1", 80, $I11II11I1I1111II);
$_=$I1I1IIII11III11I; if(length($I1I1IIII11III11I)==0)	{ print "Anaconda Error - $I1II1I11III111I1 failed to respond in $I11I1IIII1I11II1 seconds.\n";	exit; }
if (m#Location: http://(.+?)/(.+)\?(.+)$#m)	 {  $I1I1IIII11III11I=&HTTPGet("/$2", "$1", 80, $3); 
if(length($I1I1IIII11III11I)==0)	{ print "Anaconda Error - $I1II1I11III111I1 failed to respond in $I11I1IIII1I11II1 seconds.\n";	exit; }
} } $I11111I1I1II1II1=0; $I1111I1I1II1111I=0; if($I1I111I1IIIIIII1 =~ /toys/i)
{ $I1I1IIII11III11I =~ s|^.*?(<table width="100%">\s*<tr><td valign="top">\d+\.<)|$1|is;
if($I1I1IIII11III11I =~ s|(<form.*?subsequent-query.*?</form>)||is)
{ $I1I11III1III1II1 = $1; } $I1I1IIII11III11I =~ s|</table>.*$|</table>|is;
$I11111II11111III = ""; foreach $I111II11111I11II (split(/\n/, $I1I1IIII11III11I))
{ $_ = $I111II11111I11II; s/img src=\"/img src=\"http:\/\/$I1II1I11III111I1/i;
s/<img([^<>]*?)src="\/(.*?)"/<img \1 src="http:\/\/$I1II1I11III111I1\/\2"/i;
if(s|\"/exec/obidos/ASIN/([^/]*?)/(.*?)\"|\"$I1I111I1111IIII1\"$I1II1I1I1I1IIIII|i)
{ $I11II1I1I1III1I1=1; $I11I1II11I11I1I1=$1; s/<ASIN>/$I11I1II11I11I1I1/i;
s/<SITECODE>/$I111I1III1II11II/i; } else { s/<a href=\"\/exec\/obidos/<a href=\"http:\/\/$I1II1I11III111I1\/exec\/obidos/;
} $I11111II11111III .= "$_\n"; } } else { $I1I1IIII11III11I =~ s|<hr noshade size=1>\n<hr noshade size=1>|<hr noshade size=1>|igm;
$I1I1IIII11III11I =~ s|Your Book.Search Results|Your Book Search Results|igs;
$I1I1IIII11III11I =~ s|<b>Related Areas:.*?<br>||igs; $I1I1IIII11III11I =~ s|<input type=\"image\" value=\"Add to Shopping Basket\"[^<>]*?>||igs;
$I1I1IIII11III11I =~ s|<input type=\"?image\"? value=\"In den Einkaufswagen legen\"[^<>]*?>||igs;
$I1I1IIII11III11I =~ s|^.*</head>||igs; $I1I1IIII11III11I =~ s|<b>See results for your search in</b>:.*?/obidos/query/.*?/video/.*?</a>||igs;
$I1I1IIII11III11I =~ s|<a href=\"/exec/obidos/query/[^<>]*>([^<>]*)</a>|<a href="$I1II11I1II11I111?f1=$f1&f2=$f2&f3=$f3&f4=$f4&f5=$f5&f6=$f6&f7=$f7&f8=$f8&f9=$f9&c1=$I111I11I11I1I11I&c2=$I11II1I11II11I11&template=$I1I111I111II11II&mode=$I1I111I1IIIIIII1&keyword=$1">$1</a>|igs;
$I1I1IIII11III11I =~ s/img src=\"/img src=\"$I1I11I1II11IIIII/igs;
$I1I1IIII11III11I =~ s/<img([^<>]*?)src=\"\/(.*?)\"/<img $1 src="$I1I11I1II11IIIII\/\2"/igs;
if($I1I1IIII11III11I =~ m|</DL>(.*?search-handle-url.*?)</td>|is)
{ $I11II1II1II1I111 = qq|$1<BR><BR>|; $I11II1II1II1I111 =~ s|/exec/obidos/search-handle-url/|$I1II11I1II11I111?keyword=$I1I1II11II1III1I&morelink=|igs;
} $I1I1IIII11III11I =~ s|>|>\n|igs; foreach $I1I1I1IIII11I11I (split(/\n/, $I1I1IIII11III11I)) 
{  $_=$I1I1I1IIII11I11I;  if (m#Location:(.+)ASIN/(.+?)/#m)  {
$I111I1I1III1III1="http://$I1II1I11III111I1/exec/obidos/ASIN/$2/$I111I1III1II11II";
print "<HTML><HEAD><TITLE></TITLE><META HTTP-EQUIV=\"REFRESH\" CONTENT=\"0;URL=$I111I1I1III1III1\"></HEAD></BODY></HTML>\n"; 
exit;  } if (/^You searched for/ || /Search Results:?</ || /We were unable to find exact matches for your search/ || /^Suchergebnisse/ || /Wir haben keine genauen Treffer für Ihre Suche gefunden/) 
{  $I11111II11I1II11=1;  $I1I1II11IIIIIIII=1;  } if (($I1I1II11IIIIIIII==1) && ( /subsequent-query/ || m|</DL>|i || /Would you like to search again?/ || /Möchten Sie noch einmal suchen?/ )) 
{  $I1I1II11IIIIIIII=0;  $I11111I1I1II1II1=1;  }  if ($I1I1II11IIIIIIII==1) 
{ 	 if($I111I11I11I1I11I) { s/$I1I1I1I11111III1/$I11II11IIIIIII1I/ig;	
} if($I11II1I11II11I11) { s/$I1IIII1IIIIIIIII/$I11I1III111I1I11/ig;   
}	 $I11I1111IIIII1I1=0; while(!$I11I1111IIIII1I1) { if(s|\"/exec/obidos/ASIN/([^/]*?)/(.*?)\"|\"$I1I111I1111IIII1\"$I1II1I1I1I1IIIII|i)
{ $I11II1I1I1III1I1=1; $I11I1II11I11I1I1=$1; s/<ASIN>/$I11I1II11I11I1I1/gi;
s/<SITECODE>/$I111I1III1II11II/gi; } else { s/<a href=\"\/exec\/obidos/<a href=\"http:\/\/$I1II1I11III111I1\/exec\/obidos/ig;
$I11I1111IIIII1I1=1; } }	 $I111I1I1III1III1 = $_; if(/<form.*quicksearch-query/i)
{ } else {  $I11111II11111III .= "$I111I1I1III1III1\n"; } }  if (($I11111I1I1II1II1==1) && /subsequent-query/)
{	 $I11111I1I1II1II1=0;	 $I1111I1I1II1111I=1;  } if ($I1111I1I1II1111I==1) 
{ 	 $I1III11II11I1III="<input type=\"hidden\" name=\"tag\" value=\"$I111I1III1II11II\">\n";
if($siteaddress ne $I1II1I11III111I1) { $I1III11II11I1III .= "<input type=\"hidden\" name=\"siteaddress\" value=\"$I1II1I11III111I1\">\n";
} $I1III11II11I1III .= "<input type=\"hidden\" name=\"f1\" value=\"$f1\">\n";
$I1III11II11I1III .= "<input type=\"hidden\" name=\"keyword\" value=\"$I1I1II11II1III1I\">\n";
$I1III11II11I1III .= "<input type=\"hidden\" name=\"f2\" value=\"$f2\">\n";
$I1III11II11I1III .= "<input type=\"hidden\" name=\"f3\" value=\"$f3\">\n";
$I1III11II11I1III .= "<input type=\"hidden\" name=\"f4\" value=\"$f4\">\n";
$I1III11II11I1III .= "<input type=\"hidden\" name=\"f5\" value=\"$f5\">\n";
$I1III11II11I1III .= "<input type=\"hidden\" name=\"f6\" value=\"$f6\">\n";
$I1III11II11I1III .= "<input type=\"hidden\" name=\"f7\" value=\"$f7\">\n";
$I1III11II11I1III .= "<input type=\"hidden\" name=\"f8\" value=\"$f8\">\n";
$I1III11II11I1III .= "<input type=\"hidden\" name=\"f9\" value=\"$f9\">\n";
$I1III11II11I1III .= "<input type=\"hidden\" name=\"c1\" value=\"$I111I11I11I1I11I\">\n";
$I1III11II11I1III .= "<input type=\"hidden\" name=\"c2\" value=\"$I11II1I11II11I11\">\n";
$I1III11II11I1III .= "<input type=\"hidden\" name=\"template\" value=\"$I1I111I111II11II\">\n";
s/action="\/exec\/obidos\/subsequent-query\//action="$I1II11I1II11I111">\n$I1III11II11I1III<input type="hidden" name="klp" value="/;
s/POST/GET/;  $I11111II11111III .= "$_\n";  }   if (($I1111I1I1II1111I==1) && /form>/i)
{	 $I1111I1I1II1111I=0;  }  } if($I11111II11I1II11!=1) {  $I1I1II11IIIIIIII=1; 
}  }	 if($I11II1I1I1III1I1!=1) {  if(($I1II1III11III1II eq "=+") || ($I1II1III11III1II eq "=")) 
{  $I11111II11111III .= "You must enter one or more keywords to search on.<BR>\n"; 
} else {  $I11111II11111III .= "We were unable to find exact matches for your search.<BR>\n"; 
}  } } $I11111II11111III .= "$I11II1II1II1I111<CENTER><font face=\"Arial\" size=\"-2\" color=\"#aaaaaa\">powered by <A HREF=\"http://www.anaconda.net\">Anaconda!</A></FONT></CENTER><BR>\n";
$I11II1III11II11I = $I1I1111I11I1I1I1; $I11II1III11II11I .= $I1I111I111II11II?$I1I111I111II11II:$I11I1I1I1111I11I;
if(-s $I11II1III11II11I) { open(TEMPLATEFILE,$I11II1III11II11I);
while($I1I1I111I1II1I11=<TEMPLATEFILE>) {		while($I1I1I111I1II1I11 =~ m/\<\!\-\-\s*\#INCLUDE\s+VIRTUAL=\"(.+)\"\s*\-\-\>/i)
{ open(INCFILE, $1); $I111I11II1I11I1I = ""; while($I1II11111I11I11I=<INCFILE>) { $I111I11II1I11I1I .= "$I1II11111I11I11I\n"; }
close INCFILE; $I1I1I111I1II1I11 =~ s/\<\!\-\-\s*\#INCLUDE\s+VIRTUAL=\"(.+)\"\s*\-\-\>/$I111I11II1I11I1I/ig; }
$I1I1I111I1II1I11 =~ s/\<\!\-\-\s*ANACONDARESULTS\s*\-\-\>/$I11111II11111III/;
$I1I1I111I1II1I11 =~ s/\<\!\-\-\s*ANACONDATIME\s*\-\-\>/$I11II111I1II1111/;
$I1I1I111I1II1I11 =~ s/\<\!\-\-\s*ANACONDAKEYWORD\s*\-\-\>/$I11IIII11111III1/gm;
$I1I1I111I1II1I11 =~ s/\<\!\-\-\s*ANACONDAKEYWORDX\s*\-\-\>/$I1II1111III11II1/gm;
$I1I1I111I1II1I11 =~ s/\<\!\-\-\s*ANACONDAF1\s*\-\-\>/$f1/; $I1I1I111I1II1I11 =~ s/\<\!\-\-\s*ANACONDAF2\s*\-\-\>/$f2/;
$I1I1I111I1II1I11 =~ s/\<\!\-\-\s*ANACONDAF3\s*\-\-\>/$f3/; $I1I1I111I1II1I11 =~ s/\<\!\-\-\s*ANACONDAF4\s*\-\-\>/$f4/;
$I1I1I111I1II1I11 =~ s/\<\!\-\-\s*ANACONDAF5\s*\-\-\>/$f5/; $I1I1I111I1II1I11 =~ s/\<\!\-\-\s*ANACONDAF6\s*\-\-\>/$f6/;
$I1I1I111I1II1I11 =~ s/\<\!\-\-\s*ANACONDAF7\s*\-\-\>/$f7/; $I1I1I111I1II1I11 =~ s/\<\!\-\-\s*ANACONDAF8\s*\-\-\>/$f8/;
$I1I1I111I1II1I11 =~ s/\<\!\-\-\s*ANACONDAF9\s*\-\-\>/$f9/; $I1I1I111I1II1I11 =~ s/\<\!\-\-\s*ANACONDASITECODE\s*\-\-\>/$I111I1III1II11II/;
$I1I1I111I1II1I11 =~ s/\<\!\-\-\s*TEMPLATE\s*\-\-\>/$I1I111I111II11II/;
$I11III1III11I111 .= "$I1I1I111I1II1I11\n"; } close TEMPLATEFILE; print "$I11III1III11I111\n";
} else { print "Anaconda Error - template file \"$I11II1III11II11I\" not found!\n";
} exit; sub setstdstuff { $I111I1III1II11II=$AP_sitecode; $I11I1I1I1111I11I=$AP_defaulttemplatefile;
$I1I1111I11I1I1I1=$AP_templatedir; $I1IIII1I11II1III=$AP_http_os;
$I111I11I11I1I11I=$AP_newheadingcolor; $I11II1I11II11I11=$AP_newshippingcolor;
$I11II1I1II1I1II1=$AP_logfile; $I1II1I11III111I1=$AP_siteaddress;
$I11I1IIII1I11II1=$AP_maxtime; $I1IIII111IIII11I=$AP_allowsortlog;
$I1I111I1111IIII1=$AP_finallink; $I111IIII1I1I1I11=$AP_aversion;
$I11I111I1I1I1I1I=$AP_newbrowserwindow; $I1III1I11I1I11II=$AP_alternate_sockets;
$I1I11I1II11IIIII = $AP_imageroot; if(!$I1I11I1II11IIIII) { $I1I11I1II11IIIII = "http://$I1II1I11III111I1";
} } sub InitStuff { $I11II111I1II1111 = time(); $I111I1I1I1111I1I = "\015\012";
$I1II11II1I11II1I=0; $I11I111I1I1111II=""; if($AP_use_LWP) { require LWP::UserAgent;
$useLWP=1; } elsif($AP_use_original) {	 } else { require IO::Socket;
} } sub HTTPGet  { local($I1I1IIII1111II1I, $I1I1I1111III11II, $I1I1I1III11IIIII, $I1II11111I1IIIII) = @_;
local ($I1II111IIII111IIet); $I1II111IIII111IIet = HTTPPreFetch($I1I1IIII1111II1I, $I1I1I1111III11II, $I1I1I1III11IIIII, $I1II11111I1IIIII, "GET");
return HTTPPostFetch($I1II111IIII111IIet, $I1I1IIII1111II1I, $I1I1I1111III11II, $I1I1I1III11IIIII, $I1II11111I1IIIII, "GET");
}	 sub HTTPPost  { local($I1I1IIII1111II1I, $I1I1I1111III11II, $I1I1I1III11IIIII, $I1II11111I1IIIII) = @_;
local ($I1II111IIII111IIet); $I1II111IIII111IIet = HTTPPreFetch($I1I1IIII1111II1I, $I1I1I1111III11II, $I1I1I1III11IIIII, $I1II11111I1IIIII, "POST");
return HTTPPostFetch($I1II111IIII111IIet, $I1I1IIII1111II1I, $I1I1I1111III11II, $I1I1I1III11IIIII, $I1II11111I1IIIII, "POST");
}	 sub HTTPPreFetch  { local($I1I1IIII1111II1I, $I1I1I1111III11II, $I1I1I1III11IIIII, $I1II11111I1IIIII, $I11II111I11III11) = @_;
local($I1II111IIII111IIet, $I1I1111I111III11); if($useLWP) { return 0;
} else { $I1II111IIII111IIet = &new_socket($I1I1I1111III11II, $I1I1I1III11IIIII, $I11I1IIII1I11II1);
$I1I1111I111III11 = &FormatFormVars($I1II11111I1IIIII); if($I11II111I11III11 eq 'GET')
{ $I1I1IIII1111II1I .= "?" . $I1I1111I111III11; print  $I1II111IIII111IIet "GET $I1I1IIII1111II1I HTTP/1.0$I111I1I1I1111I1I";
print  $I1II111IIII111IIet "Accept: text/html$I111I1I1I1111I1I";
print  $I1II111IIII111IIet "Accept: text/plain$I111I1I1I1111I1I";
print  $I1II111IIII111IIet "User-Agent: Mozilla/4.0$I111I1I1I1111I1I";
print  $I1II111IIII111IIet "$I111I1I1I1111I1I"; print  $I1II111IIII111IIet "$I111I1I1I1111I1I";
} else { $I11II1II11I1I1I1 = length($I1I1111I111III11); print  $I1II111IIII111IIet "POST $I1I1IIII1111II1I HTTP/1.0$I111I1I1I1111I1I";
print  $I1II111IIII111IIet "Accept: text/html$I111I1I1I1111I1I";
print  $I1II111IIII111IIet "Accept: text/plain$I111I1I1I1111I1I";
print  $I1II111IIII111IIet "User-Agent: Mozilla/4.0$I111I1I1I1111I1I";
print  $I1II111IIII111IIet "Content-type: application/x-www-form-urlencoded$I111I1I1I1111I1I";
print  $I1II111IIII111IIet "Content-length: $I11II1II11I1I1I1$I111I1I1I1111I1I";
print  $I1II111IIII111IIet "$I111I1I1I1111I1I"; print  $I1II111IIII111IIet "$I1I1111I111III11$I111I1I1I1111I1I";
} } return $I1II111IIII111IIet; } sub HTTPPostFetch  { local($I1II111IIII111IIet, $I1I1IIII1111II1I, $I1I1I1111III11II, $I1I1I1III11IIIII, $I1II11111I1IIIII, $I11II111I11III11) = @_;
local($I1I1111I111III11, $I1II1I1I111I1III); local ($I1III1I1I11IIII1);
if($useLWP) { if($I11II111I11III11 eq 'GET') { $I1I1111I1I1I11II = new LWP::UserAgent;
$I1I1111I1I1I11II->agent('Mozilla/4.0'); $I1I1IIII1111II1I =~ s|^/||;
my $I1I1I11II111IIII = new HTTP::Request 'GET',"http://$I1I1I1111III11II/$I1I1IIII1111II1I?$I1II11111I1IIIII";
my $I1111111111111II = $I1I1111I1I1I11II->request($I1I1I11II111IIII);
$I1III1I1I11IIII1=$I1111111111111II->as_string; } else { $I1I1111I1I1I11II = new LWP::UserAgent;
$I1I1111I1I1I11II->agent('Mozilla/4.0'); my $I1I1I11II111IIII = new HTTP::Request 'POST',"http://$I1I1I1111III11II$I1I1IIII1111II1I";
$I1I1I11II111IIII->content_type('application/x-www-form-urlencoded');
$I1I1I11II111IIII->content("$I1II11111I1IIIII"); my $I1111111111111II = $I1I1111I1I1I11II->request($I1I1I11II111IIII);
$I1III1I1I11IIII1=$I1111111111111II->as_string; } } else { $I1III1I1I11IIII1 = &RetrieveHTTP($I1II111IIII111IIet);
} if(length($I1III1I1I11IIII1)==0)	 {  $I1II1I1I1I1II1I1++;  }
$I1III1I1I11IIII1; } sub FormatFormVars { local ($I1II11111I1IIIII) = @_; 
$I1II11111I1IIIII =~ s/ /%20/g; $I1II11111I1IIIII; }  sub RetrieveHTTP 
{ local ($I1II111IIII111IIet) = @_; local ($I1III1I1I11IIII1,$I1II1I1I111I1III, $I1111II11I111111);
$I1III1I1I11IIII1 = read_sock($I1II111IIII111IIet, $I11I1IIII1I11II1);
while(<$I1II111IIII111IIet>)  { $I1III1I1I11IIII1 .= $_; } close $I1II111IIII111IIet;
$I1III1I1I11IIII1; } sub read_sock  { local($I1II11II11II11II, $I111II11II111II1) = @_;
local($I11II1I11111I111,$I1III1I1I11IIII1); local($I1I11I1111I111II,$I1I111I11I11I1I1,$I111I11II11II111);
$I111II11II111II1 += time; $I1III1I1I11IIII1 = ""; $I1I11I1111I111II = '';
vec($I1I11I1111I111II, fileno($I1II11II11II11II), 1) = 1; $I111I11II11II111 = 0;
read_socket:  while (($I111II11II111II1 > time) && ($I111I11II11II111 <= 0)) 
{ $I1111IIIII111I11 = 1024; $I11II1I11111I111 = " " x 1025; $I111I11II11II111 = 1;
if ($I1IIII1I11II1III ne "NT")  { $I111I11II11II111 = select($I1I111I11I11I1I1=$I1I11I1111I111II, undef, undef,.2);
} } if ($I111I11II11II111 > 0)  { $I1111IIIII111I11 = sysread($I1II11II11II11II, $I11II1I11111I111, 1024);
if ($I1111IIIII111I11 > 0)  { $I1III1I1I11IIII1 .= $I11II1I11111I111;
} } $I1III1I1I11IIII1; } sub URLDecodeString { my($I111111I11I111II) = shift;
$I111111I11I111II =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
return $I111111I11I111II; } sub new_socket { my($I1IIII11II111111, $I1I1I1III11IIIII, $I1II1I1I1I1II1I1) = @_;
my($I1II111IIII111II); if($AP_use_original) { my $I1I1I1I1IIIII111 = gethostbyname('localhost');
my $PROTOCOL = getprotobyname('tcp'); my $SOCK_STREAM = SOCK_STREAM;
my $AF_INET = AF_INET; my $I1IIIII1I11III11 = sockaddr_in(0, $I1I1I1I1IIIII111);
my $I11III1111IIIII1 = inet_aton($I1IIII11II111111)     || die "unknown host";
my $I11I1I11I1111II1 = sockaddr_in($I1I1I1III11IIIII, $I11III1111IIIII1);
$I1II11II1I11II1I++; if($I1II11II1I11II1I == 1) { $t = socket (S1, $AF_INET, $SOCK_STREAM, $PROTOCOL) || &web_error( "$t Can't make socket:$!\n"); $I1I1II111I11I1II = S1; }
elsif ($I1II11II1I11II1I == 2) { socket (S2, $AF_INET, $SOCK_STREAM, $PROTOCOL) || &web_error( "Can't make socket:$!\n"); $I1I1II111I11I1II = S2; }
elsif ($I1II11II1I11II1I == 3) { socket (S3, $AF_INET, $SOCK_STREAM, $PROTOCOL) || &web_error( "Can't make socket:$!\n"); $I1I1II111I11I1II = S3; }
elsif ($I1II11II1I11II1I == 4) { socket (S4, $AF_INET, $SOCK_STREAM, $PROTOCOL) || &web_error( "Can't make socket:$!\n"); $I1I1II111I11I1II = S4; }
elsif ($I1II11II1I11II1I == 5) { socket (S5, $AF_INET, $SOCK_STREAM, $PROTOCOL) || &web_error( "Can't make socket:$!\n"); $I1I1II111I11I1II = S5; }
elsif ($I1II11II1I11II1I == 6) { socket (S6, $AF_INET, $SOCK_STREAM, $PROTOCOL) || &web_error( "Can't make socket:$!\n"); $I1I1II111I11I1II = S6; }
elsif ($I1II11II1I11II1I == 7) { socket (S7, $AF_INET, $SOCK_STREAM, $PROTOCOL) || &web_error( "Can't make socket:$!\n"); $I1I1II111I11I1II = S7; }
elsif ($I1II11II1I11II1I == 8) { socket (S8, $AF_INET, $SOCK_STREAM, $PROTOCOL) || &web_error( "Can't make socket:$!\n"); $I1I1II111I11I1II = S8; }
elsif ($I1II11II1I11II1I == 9) { socket (S9, $AF_INET, $SOCK_STREAM, $PROTOCOL) || &web_error( "Can't make socket:$!\n"); $I1I1II111I11I1II = S9; }
elsif ($I1II11II1I11II1I == 10) { socket (S10, $AF_INET, $SOCK_STREAM, $PROTOCOL) || &web_error( "Can't make socket:$!\n"); $I1I1II111I11I1II = S10; }
elsif ($I1II11II1I11II1I == 11) { socket (S11, $AF_INET, $SOCK_STREAM, $PROTOCOL) || &web_error( "Can't make socket:$!\n"); $I1I1II111I11I1II = S11; }
elsif ($I1II11II1I11II1I == 12) { socket (S12, $AF_INET, $SOCK_STREAM, $PROTOCOL) || &web_error( "Can't make socket:$!\n"); $I1I1II111I11I1II = S12; }
elsif ($I1II11II1I11II1I == 13) { socket (S13, $AF_INET, $SOCK_STREAM, $PROTOCOL) || &web_error( "Can't make socket:$!\n"); $I1I1II111I11I1II = S13; }
elsif ($I1II11II1I11II1I == 14) { socket (S14, $AF_INET, $SOCK_STREAM, $PROTOCOL) || &web_error( "Can't make socket:$!\n"); $I1I1II111I11I1II = S14; }
elsif ($I1II11II1I11II1I == 15) { socket (S15, $AF_INET, $SOCK_STREAM, $PROTOCOL) || &web_error( "Can't make socket:$!\n"); $I1I1II111I11I1II = S15; }
elsif ($I1II11II1I11II1I == 16) { socket (S16, $AF_INET, $SOCK_STREAM, $PROTOCOL) || &web_error( "Can't make socket:$!\n"); $I1I1II111I11I1II = S16; }
elsif ($I1II11II1I11II1I == 17) { socket (S17, $AF_INET, $SOCK_STREAM, $PROTOCOL) || &web_error( "Can't make socket:$!\n"); $I1I1II111I11I1II = S17; }
elsif ($I1II11II1I11II1I == 18) { socket (S18, $AF_INET, $SOCK_STREAM, $PROTOCOL) || &web_error( "Can't make socket:$!\n"); $I1I1II111I11I1II = S18; }
elsif ($I1II11II1I11II1I == 19) { socket (S19, $AF_INET, $SOCK_STREAM, $PROTOCOL) || &web_error( "Can't make socket:$!\n"); $I1I1II111I11I1II = S19; }
else { die "Can't create another socket!"; } connect($I1I1II111I11I1II, $I11I1I11I1111II1) || die( "Can't connect socket:$!\n");
$I1II111IIII111II=$I1I1II111I11I1II; } else { local($^W) = 0;
$I1II111IIII111II = IO::Socket::INET->new(PeerAddr => $I1IIII11II111111,
PeerPort => 'http(80)', Proto    => 'tcp', Timeout  => $I1II1I1I1I1II1I1,
); unless ($I1II111IIII111II) { die "Can't connect to $I1IIII11II111111:$I1I1I1III11IIIII ($@)";
} } my $I11III1II11I1I1I = select($I1II111IIII111II); $| = 1;
select ($I11III1II11I1I1I); $I1II111IIII111II; } sub URLEncodeString 
{ my $I1I1III111I11111 = shift; $I1I1III111I11111 =~ s/([^a-zA-Z0-9_\-.])/uc sprintf("%%%02x",ord($1))/eg;
return $I1I1III111I11111; } sub ExtractSnippetsFromTemplate {
my($I11I1I1I11II1I11,@I1II1I111II1III1) = @_; my(@I111I11II111I111);
$I111I1II11III11I = 1; foreach $I1IIIIII1I11I11I (@I1II1I111II1III1)
{ if($I11I1I1I11II1I11 =~  s/ANACONDASNIP\($I1IIIIII1I11I11I\)(.+)ANACONDAENDSNIP\($I1IIIIII1I11I11I\)//si)
{ push(@I111I11II111I111,$1); } } $I111I1II11III11I = 0; return @I111I11II111I111;
} sub DoSortLog { if(!$I1IIII111IIII11I) { print "Anaconda Error - log viewing not allowed.\n";	exit; }
open(LOGFILE, $I11II1I1II1I1II1); while($I11I1IIIIII1I1II=<LOGFILE>)
{	 $I1II1I11I1I111II .= $I11I1IIIIII1I1II; } close LOGFILE; @I1I1111I1I11II11 = split(/\n/, $I1II1I11I1I111II);
@I1II1I11I1I111II = sort @I1I1111I1I11II11; $I111I1I1IIII1111=1;
$I1II1I11I1I111II = "<TABLE>\n"; foreach $I11I1I1II1IIII1I (@I1II1I11I1I111II)
{ if($I1I1I11I1I1I11II eq $I11I1I1II1IIII1I) { $I111I1I1IIII1111 += 1;
} else { $I1II1I11I1I111II .= "<TR><TD>$I111I1I1IIII1111</td><TD>$I1I1I11I1I1I11II</td></tr>\n";
$I111I1I1IIII1111 = 1; $I1I1I11I1I1I11II=$I11I1I1II1IIII1I; }
} $I1II1I11I1I111II .= "<TR><TD>$I111I1I1IIII1111</td><TD>$I1I1I11I1I1I11II</td></tr>\n";
$I1II1I11I1I111II .= "</table>\n"; print "$I1II1I11I1I111II\n";
exit;  } 1;
