#!/usr/bin/perl


#  PROJECT HONEY POT ADDRESS DISTRIBUTION SCRIPT
#  For more information visit: http://www.projecthoneypot.org/
#  Copyright (C) 2004, Unspam, LLC
#  
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.
#  
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#  
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
#  02111-1307  USA
#  
#  If you choose to modify or redistribute the software, you must
#  completely disconnect it from the Project Honey Pot Service, as
#  specified under the Terms of Service Use. These terms are available
#  here:
#  
#  http://www.projecthoneypot.org/terms_of_service_use.php
#  
#  The required modification to disconnect the software from the
#  Project Honey Pot Service is explained in the comments below. To find the
#  instructions, search for:  *** DISCONNECT INSTRUCTIONS ***
#  
#  Generated On: Thu, 28 Oct 2004 01:26:47 -0500
#  For Domain: www.drivingmontana.com
#  
#  
use strict;
use Digest::MD5 qw(md5_hex);



#  *** DISCONNECT INSTRUCTIONS ***
#  
#  You are free to modify or redistribute this software. However, if
#  you do so you must disconnect it from the Project Honey Pot Service.
#  To do this, you must delete the lines of code below located between the
#  *** START CUT HERE *** and *** FINISH CUT HERE *** comments. Under the
#  Terms of Service Use that you agreed to before downloading this software,
#  you may not recreate the deleted lines or modify this software to access
#  or otherwise connect to any Project Honey Pot server.
#  
#  *** START CUT HERE ***
#  
my $__REQUEST_HOST    = 'hpr4.projecthoneypot.org';
my $__REQUEST_PORT    = '80';
my $__REQUEST_SCRIPT  = '/cgi/serve.php';
#  
#  *** FINISH CUT HERE ***
#  

my $__HPOT_TAG1       = '40a183ec06f366fd844398484a3daa87';
my $__HPOT_TAG2       = 'bdabf4d8c6035123fd589bd06148b4d9';
my $__HPOT_TAG3       = '60eff423c208d7fdab40a0dd2d377e0b';

my $__CLASS_STYLE_1   = 'tustoteyu';
my $__CLASS_STYLE_2   = 'jubrugotuc';

my $__DIV1            = 'cl8v6wr3';

my $__VANITY_L1       = 'MEMBER OF PROJECT HONEY POT';
my $__VANITY_L2       = 'Spam Harvester Protection Network';
my $__VANITY_L3       = 'provided by Unspam';

my $__DOC_TYPE1       = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">\n';
my $__HEAD1           = '<html>\n<head>\n';
my $__HEAD2           = '<title>http://www.drivingmontana.com</title>\n</head>\n';
my $__ROBOT1          = '<meta name="robots" content="noindex">\n<meta name="robots" content="noarchive">\n<meta name="robots" content="follow">\n';
my $__NOCOLLECT1      = '<meta name="no-email-collection" content="/" />\n';
my $__TOP1            = '<body>\n<div id="colitis" align="center">\n';
my $__EMAIL1A         = '<a href="mailto:';
my $__EMAIL1B         = '" style="display: none;">';
my $__EMAIL1C         = '</a>';
my $__EMAIL2A         = '<a href="mailto:';
my $__EMAIL2B         = '" style="display:none;">';
my $__EMAIL2C         = '</a>';
my $__EMAIL3A         = '<a style="display: none;" href="mailto:';
my $__EMAIL3B         = '">';
my $__EMAIL3C         = '</a>';
my $__EMAIL4A         = '<a style="display:none;" href="mailto:';
my $__EMAIL4B         = '">';
my $__EMAIL4C         = '</a>';
my $__EMAIL5A         = '<a href="mailto:';
my $__EMAIL5B         = '"></a>';
my $__EMAIL5C         = '..';
my $__EMAIL6A         = '<span style="display: none;"><a href="mailto:';
my $__EMAIL6B         = '">';
my $__EMAIL6C         = '</a></span>';
my $__EMAIL7A         = '<span style="display:none;"><a href="mailto:';
my $__EMAIL7B         = '">';
my $__EMAIL7C         = '</a></span>';
my $__EMAIL8A         = '<!-- <a href="mailto:';
my $__EMAIL8B         = '">';
my $__EMAIL8C         = '</a> -->';
my $__EMAIL9A         = '<div id="'.$__DIV1.'"><a href="';
my $__EMAIL9B         = '">';
my $__EMAIL9C         = '</a></div><br><script language="JavaScript" type="text/javascript">document.getElementById(\''.$__DIV1.'\').innerHTML=\'\';</script>';
my $__EMAIL10A        = '<a href="mailto:';
my $__EMAIL10B        = '"><!-- ';
my $__EMAIL10C        = ' --></a>';
my $__LEGAL1          = '';
my $__LEGAL2          = '\n';
my $__STYLE1          = '\n<style>a.'.$__CLASS_STYLE_1.'{color:#FFF;font:bold 10px arial,sans-serif;text-decoration:none;}</style>';
my $__VANITY1         = '<table cellspacing="0"cellpadding="0"border="0"style="background:#999;width:230px;"><tr><td valign="top"style="padding: 1px 2px 5px 4px;border-right:solid 1px #CCC;"><span style="font:bold 30px arial,sans-serif;color:#666;top:0px;position:relative;">@</span></td><td valign="top" align="left" style="padding:3px 0 0 4px;"><a href="http://www.projecthoneypot.org/" class="'.$__CLASS_STYLE_1.'">'.$__VANITY_L1.'</a><br><a href="http://www.unspam.com"class="'.$__CLASS_STYLE_1.'">'.$__VANITY_L2.'<br>'.$__VANITY_L3.'</a></td></tr></table>\n';
my $__BOTTOM1         = '</div>\n</body>\n</html>\n';


sub getLegalContent() { return '<table cellpadding="0" cellspacing="0" border="0">\n<tr>\n<td><tt>&nbsp; &nbsp; <b><span style="color:#FFF;">h</span></b>&nbsp; <b><span style="color:#FFF;">p</span></b>&nbsp; <br>&nbsp;<br>The websi&#116;<br>t&#111; &#121;ou s&#117;b<br>other<span style="color:#FFF;">c</span>&#116;erm<!-- doloroso congress unassisted fungoid bride --><br>Website &#121;o<br>read t<!-- gusty doubtful nopar recluse -->hem <br>agents of <br>them. &#84;&#104;e <br>no&#110;-tr&#97;nsf<br>Website<!-- knight vast -->.<br><br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; <b><span style="color:#FFF;">t</span></b><br>&nbsp;<br>Spe&#99;ial &#114;e<br>Non-Human <br>spider&#115;, b<br>program&#115; d<br>automatica<br><br>Email addr<br>It is reco<br>alone. You<br>has a v&#97;l&#117;<br>storage<!-- polarbears scent -->&#44;<span style="color:#FFF;">a</span>a<br>va&#108;u&#101; of<span style="color:#FFF;">e</span>t<br>stor&#105;n&#103; th<br>&#97;gr&#101;eme&#110;t<!-- hackers unwilling surrogate -->&nbsp;<br><br><b><span style="color:#FFF;">i</span></b>&nbsp;<b><span style="color:#FFF;">d</span></b>&nbsp;<b><span style="color:#FFF;">k</span></b>&nbsp;<b><span style="color:#FFF;">p</span><span style="color:#FFF;">d</span><span style="color:#FFF;">a</span></b>&nbsp;<br>&nbsp;<br>&#69;ac<!-- step war imperial -->h party<br>agains&#116; &#116;h<br>("Ju&#100;ic<!-- strange planner -->i&#97;l<br>th&#101; regis&#116;<br>suc&#104; laws <br>and perfo&#114;<br>of feder&#97;l<br>a&#110;y action<br>Service. Y<br>the abov&#101; <br><br>&nbsp; &nbsp; &nbsp; <b><span style="color:#FFF;">f</span></b>&nbsp; <b><span style="color:#FFF;">k</span></b><br>&nbsp;<br>You &#99;on&#115;en<br>may appea<!-- sequent -->r<br>&#97;&#98;use. The<br>&#86;i&#115;&#105;t&#111;rs a<br><br>VISITORS A<br>PARTY OR S<br>SUBSEQUENT<br></tt></td>\n<td><tt>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br><br>e<span style="color:#FFF;">t</span>from whi<br>je&#99;&#116; t<!-- draw nanny stake -->o th<br>s governin<br>u<span style="color:#FFF;">d</span>accept t<br>&#99;a&#114;efully<!-- mould stone thigh royal valley -->&#46;<br>the &#105;ndivi<br>acces&#115; rig<br>erable w&#105;t<br><br><br><b><span style="color:#FFF;">t</span></b>&nbsp; &nbsp; <b>SPECI</b><br><br>strictions<br>Visi&#116;o&#114;s. <br>ots&#44; i&#110;dex<br>e<!-- scary royal effective -->&#115;igned &#116;&#111;<br>lly&#46;<br><br>e&#115;se&#115; on t<br>gnized tha<br>&nbsp;ac&#107;n&#111;w&#108;ed<br>e not l<!-- check -->ess<br>nd/or<span style="color:#FFF;">i</span>dist<br>&#104;&#101;s&#101; addre<br>is W&#101;&#98;site<br>and expres<br><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br><br>&nbsp;agrees th<br>e o&#116;he&#114;<span style="color:#FFF;">c</span>in<br>&nbsp;A&#99;tion") <br>ered &#65;dmin<br>are app&#108;ie<br>med ent&#105;re<br>&nbsp;a&#110;d s&#116;ate<br>&nbsp;&#98;r&#111;ught a<br>ou conse&#110;t<br>ag&#114;eement&#46;<br><br>&nbsp;<b><span style="color:#FFF;">c</span></b>&nbsp; &nbsp; &nbsp; &nbsp; <br><br>t<span style="color:#FFF;">e</span>to &#104;&#97;vin<br>&nbsp;somewhere<br>&nbsp;I&#100;entifie<br>g<!-- beefy abaft -->ree not t<br><br>GREE THAT <br>ENDING ANY<br>&nbsp;B<!-- tertian utopia tight liaison -->REACH OF<br></tt></td>\n<td><tt>&nbsp; &nbsp; &nbsp; <b><span style="color:#FFF;">c</span>TER</b><br><br>c&#104; you a<!-- idea remedy injured -->&#99;c<br>&#101; foll&#111;&#119;in<br>g access<!-- consumption -->&nbsp;t<br>h&#101;se<span style="color:#FFF;">a</span>terms<br>&nbsp;&#65;ny Non-H<br>dual(s&#41;<span style="color:#FFF;">p</span>wh<br>h&#116;s &#103;&#114;ant&#101;<br>&#104;&#111;&#117;t the e<br><br><br><b>&#65;L</b>&nbsp;<b>LICENS&#69;</b><br><br><span style="color:#FFF;">p</span>on a vis&#105;<br>Non-Hu&#109;an <br>er&#115;,<span style="color:#FFF;">e</span>rob&#111;t<br>&nbsp;access,<span style="color:#FFF;">c</span>r<br><br><br>h<!-- traveller substitute -->&#105;s<span style="color:#FFF;">f</span>sit&#101; a<br>&#116; &#116;h&#101;se em<br>ge and agr<br>&nbsp;than US<span style="color:#FFF;">e</span>$<br>&#114;i&#98;uti<!-- lactescent late tear -->on o<br>sses&#46; Inte<br>\'s ema&#105;l &#97;<br>sly prohib<br><br>&nbsp;&nbsp; <b><span style="color:#FFF;">i</span></b>&nbsp;<b>&#65;PPLI</b><br><br>at any sui<br>&nbsp;connectio<br>sha&#108;l &#98;e g<br>istrati&#118;e <br>d<span style="color:#FFF;">s</span>to agree<br>ly &#119;it&#104;i&#110; <br>&nbsp;cou&#114;ts &#119;i<br>g&#97;in&#115;t hi&#109;<br>&nbsp;&#116;o e&#108;ec&#116;r<br><br><br>&nbsp; &nbsp; <b>RECOR&#68;</b><br><br>g your I<!-- major hoary demandpull -->nt<br>&nbsp;on &#116;&#104;is<span style="color:#FFF;">t</span>p<br>r is u&#110;i&#113;u<br>o use<span style="color:#FFF;">g</span>th&#105;s<br><br>HARVE&#83;TING<br>&nbsp;MESS&#65;GE&#40;S<br><span style="color:#FFF;">e</span>THESE TE&#82;<br></tt></td>\n<td><tt><b>MS</b>&nbsp;<b>&#65;N&#68;</b>&nbsp;<b>CON</b><br><br>es&#115;ed this<br>g<span style="color:#FFF;">a</span>conditio<br>o<span style="color:#FFF;">e</span>the W&#101;bs<br>&nbsp;and c<!-- symbolic swanky camper sisterly gorgeous -->ond&#105;<br>um<!-- oddson perception thing doubleedged -->an Visit<br>o controls<!-- assorted --><br>d to<span style="color:#FFF;">e</span>you u<br>&#120;p&#114;ess wri<br><br><br>&nbsp;<b>&#82;ESTRICT&#73;</b><br><br>tor<!-- walkin landlord suchlike willing obligatory -->\'s li&#99;e<br>Vi&#115;i&#116;ors<span style="color:#FFF;">a</span>i<br>s, &#99;rawler<br>ead, compi<br><br><br>r&#101; conside<br>ai&#108; addre<!-- slashandburn adage moire jugglers pattern -->s<br>&#101;e that e<!-- rounded birth -->&#97;<br>&#53;0. Y&#111;u fu<br>f &#116;h&#101;se ad<br>ntional c&#111;<br>&#100;&#100;re&#115;ses &#105;<br>ited.<br><br><b>CA&#66;LE</b>&nbsp;<b>LA&#87;<span style="color:#FFF;">k</span></b><br><br>t,<span style="color:#FFF;">d</span>acti&#111;n <br>n wit&#104; or<!-- eloquent -->&nbsp;<br>overne<!-- lamented mercuric opposite -->d by<br>C<!-- incident orthodox edentate tank -->ontact (t<br>&#109;ent&#115;<span style="color:#FFF;">f</span>be&#116;w<br>the Admin <br>thin<span style="color:#FFF;">f</span>t&#104;e A<br>&nbsp;in connec<br>on<!-- organic -->ic servi<br><br><br><b>S</b>&nbsp;<b>O&#70;</b>&nbsp;<b>VISIT</b><br><br>ernet Pro&#116;<br>a&#103;e (the "<br>e&#108;y &#109;&#97;tc&#104;e<br>&nbsp;address f<br><br>,<span style="color:#FFF;">a</span>&#71;ATHE&#82;IN<br>&#41; TO T&#72;E I<br>MS OF SERV<br></tt></td>\n<td><tt><b>DITIONS</b>&nbsp;<b>OF</b><br><br>&nbsp;agreem<!-- pregnant unbiased -->e&#110;t<br>&#110;s&#46; Thes&#101; <br>ite. B&#121; vi<br>&#116;ions (the<br>ors &#116;o t&#104;e<br>, authors <br>nder<span style="color:#FFF;">f</span>th&#101; T<br>tt&#101;n p&#101;r&#109;i<br><br><br><b>O&#78;S</b>&nbsp;<b>FOR</b>&nbsp;<b>NO</b><br><br>nse to ac<!-- collectable -->c<br>ncl<!-- incandescent km -->u&#100;&#101;, &#98;u<br>s, harvest<br>le or ga&#116;h<br><br><br>red propri<!-- closedcaptioned sandpipers --><br>se<!-- reservation chinchillas dietetic moral -->s are &#112;r<br>ch email<span style="color:#FFF;">k</span>&#97;<br>rther agre<br>dr&#101;sses su<br>llection, <br>&#115; recogniz<br><br><br><b>AND</b>&nbsp;<b>JURISD</b><br><br>&#111;r procee&#100;<br>arising fr<br>&nbsp;the law o<br>&#104;e "Admin <br>een Admin <br>State&#46; You<br>d&#109;in State<br>tion with <br>ce of proc<br><br><br><b>OR</b>&nbsp;<b>USE</b>&nbsp;<b>AND</b><br><br>ocol addr&#101;<br>Id&#101;nt<!-- knee stereotyped indolent -->if&#105;e&#114;<br>d to your <br>or any rea<br><br>&#71;&#44; STORING<br>DENTIFIER <br>ICE&#46;<br></tt></td>\n<td><tt>&nbsp;<b>USE</b>&nbsp;<br><br>&nbsp;("&#116;he Web<br>&#116;erms<span style="color:#FFF;">h</span>ar&#101;<span style="color:#FFF;">k</span><br>siting (i&#110;<br>&nbsp;"Terms of<br>&nbsp;We<!-- permeable -->b&#115;ite s<br>or otherwi<br>erms<span style="color:#FFF;">t</span>&#111;&#102; Se<br>&#115;sion<span style="color:#FFF;">t</span>of t<!-- guidebook throne --><br><br><br><b>N-HUMAN<span style="color:#FFF;">d</span>VI</b><br><br>ess<span style="color:#FFF;">s</span>the We<br>t are &#110;ot <br>ers, or an<br>&#101;r &#99;&#111;ntent<br><br><br>e&#116;ary in&#116;&#101;<br>ovided fo&#114;<br>ddress &#116;he<br>e &#116;&#104;at t&#104;e<br>b&#115;tantiall<br>har&#118;esting<br>ed as a vi<br><br><br><b>I&#67;TION</b>&nbsp;<br><br>ing brough<br>om &#116;he Ter<br>f the stat<br>State")<!-- parcel -->&nbsp;fo<br>S&#116;ate r&#101;&#115;&#105;<br>&nbsp;consen&#116; t<br>. You<span style="color:#FFF;">a</span>cons<br>&#98;rea&#99;hes<span style="color:#FFF;">e</span>o<br>&#101;s&#115;<span style="color:#FFF;">k</span>&#114;eg&#97;r&#100;<br><br><br>&nbsp;<b>ABUS&#69;</b>&nbsp;<br><br>&#115;s &#114;ecord&#101;<br>")<span style="color:#FFF;">k</span>&#105;f w<!-- oxyacetylene separation undesirable -->e s<br>Internet &#80;<br>&#115;on.<br><br>, TRANSFER<br>CONST<!-- siren resonant -->ITUTE<br><br></tt></td>\n<td><tt><br><br>sit&#101;") is <br>i&#110; ad<!-- laryngeal examination babe couchant -->d&#105;ti<!-- ethical curlews endemic inkjet -->o<br>&nbsp;a&#110;y<span style="color:#FFF;">d</span>&#109;an&#110;e<br><span style="color:#FFF;">i</span>Service"&#41;<br>hal&#108;<span style="color:#FFF;">o</span>be co<br>s&#101; m&#97;ke&#115; u<br>rvice a&#114;&#101;<br>he ow&#110;er o<br><br><br><b>S&#73;TO&#82;S</b>&nbsp;<br><br>bsit&#101; appl<br>l&#105;mited t&#111;<br>y ot&#104;e&#114; co<br>&nbsp;f&#114;o&#109;<span style="color:#FFF;">a</span>the <br><br><br>ll&#101;c&#116;ua&#108; p<br>&nbsp;human vis<br>&nbsp;Web&#115;ite c<br>&nbsp;c&#111;mpilat&#105;<br>y diminish<br>, &#103;a&#116;he&#114;in<br>olation o&#102;<br><br><br><br><br>t by su&#99;h <br>ms of Se&#114;v<br>e o&#102;<span style="color:#FFF;">o</span>r&#101;sid<br>r<!-- academic drill lush --><span style="color:#FFF;">h</span>th&#101; W&#101;b&#115;<br>dents &#101;nte<br>&#111; the ju<!-- patch awake -->r<!-- violent -->i<br>ent<span style="color:#FFF;">d</span>to t&#104;e<br>f these Te<br>ing action<br><br><br><br><br>d. An e&#109;ai<br>uspe&#99;t pot<br>&#114;o&#116;ocol<span style="color:#FFF;">c</span>ad<br><br><br>RIN&#71;<span style="color:#FFF;">c</span>TO A <br>S<span style="color:#FFF;">s</span>AN ACC&#69;P<br><br></tt></td>\n<td><tt><br><br>prov&#105;d&#101;d<br>n to &#97;ny<br>r)<span style="color:#FFF;">t</span>&#116;he<br>. Pl&#101;ase<br>nside&#114;ed<br>&#115;&#101; of<br><br>f &#116;he<br><br><br><br><br>y<span style="color:#FFF;">d</span>to<br>,<span style="color:#FFF;">k</span>web<br>mpu&#116;&#101;r<br>W&#101;bsit&#101;<br><br><br>rop&#101;rty.<br>i&#116;o&#114;s<br>ontains<br>&#111;n,<br>es the<br>g&#44;<span style="color:#FFF;">h</span>and/or<br>&nbsp;th&#105;s<br><br><br><br><br>party<br>ice<br>en&#99;e of<br>ite as<br>red into<br>&#115;diction<br>&nbsp;ven&#117;e in<br>rms<!-- investigation adjunct fitness lavish technical -->&nbsp;of<br>s under<br><br><br><br><br>l a<!-- equinoctial chorus -->ddress<br>ential<br>dr&#101;s&#115;.<br><br><br>T&#72;IRD<br>&#84;AN&#67;E AND<br><br></tt></td>\n</tr>\n</table>\n<br>'; }




sub formatHTML		{
	my $s = $_[0];
	$s =~ s/\\n/\n/g;
	return $s;
}
sub getDocType			{ return formatHTML($__DOC_TYPE1); }
sub getHeadHTML			{ return formatHTML($__HEAD1); }
sub getRobotHTML		{ return formatHTML($__ROBOT1); }
sub getNoCollectHTML	{ return formatHTML($__NOCOLLECT1); }
sub getHeadHTML2		{ return formatHTML($__HEAD2); }
sub getTopHTML			{ return formatHTML($__TOP1); }
sub getEmailHTML		{
	my $method=$_[0];
	my $m=$_[1];
	if ($method eq "0" || !$method) {
		return "";
	} elsif ($method eq "1") {
		return formatHTML($__EMAIL1A.$m.$__EMAIL1B.$m.$__EMAIL1C);
	} elsif ($method eq "2") {
		return formatHTML($__EMAIL2A.$m.$__EMAIL2B.$m.$__EMAIL2C);
	} elsif ($method eq "3") {
		return formatHTML($__EMAIL3A.$m.$__EMAIL3B.$m.$__EMAIL3C);
	} elsif ($method eq "4") {
		return formatHTML($__EMAIL4A.$m.$__EMAIL4B.$m.$__EMAIL4C);
	} elsif ($method eq "5") {
		return formatHTML($__EMAIL5A.$m.$__EMAIL5B);
	} elsif ($method eq "6") {
		return formatHTML($__EMAIL6A.$m.$__EMAIL6B.$m.$__EMAIL6C);
	} elsif ($method eq "7") {
		return formatHTML($__EMAIL7A.$m.$__EMAIL7B.$m.$__EMAIL7C);
	} elsif ($method eq "8") {
		return formatHTML($__EMAIL8A.$m.$__EMAIL8B.$m.$__EMAIL8C);
	} elsif ($method eq "9") {
		return formatHTML($__EMAIL9A.$m.$__EMAIL9B.$m.$__EMAIL9C); 
	}
	return formatHTML($__EMAIL9A.$m.$__EMAIL9B.$m.$__EMAIL9C);
}
sub getLegalHTML	{
	my $legal_text = &getLegalContent;
	return formatHTML($__LEGAL1.($legal_text).$__LEGAL2);
}
sub getStyleHTML	{ return formatHTML($__STYLE1); }
sub getVanityHTML	{ return formatHTML($__VANITY1); }
sub getBottomHTML	{ return formatHTML($__BOTTOM1); }

sub performRequest {
	
	my $request = $_[0];
	my $response = "";
	my $head = "";
	
        $head  = "POST ".$__REQUEST_SCRIPT." HTTP/1.1\r\n";
        $head .= "Host: ".$__REQUEST_HOST."\r\n";
        $head .= "User-Agent: PHPot ".$__HPOT_TAG2."\r\n";
        $head .= "Content-Type: application/x-www-form-urlencoded\r\n";
        $head .= "Content-Length: ".length($request)."\r\n";
        $head .= "Connection: close\r\n\r\n";

	use Socket;

	socket(SH, PF_INET, SOCK_STREAM, getprotobyname('tcp')) || die $!;
	my $sin = sockaddr_in($__REQUEST_PORT,inet_aton($__REQUEST_HOST));
	connect(SH,$sin) || die "\n<br>Unable to contact the server...<br>\n";
	syswrite(SH, $head, length($head));	
	syswrite(SH, $request, length($request));	
	my $line;
	while ($line = <SH>) {
		$response .= $line;
	}
	
	close(SH);
	return $response;
}

sub prepareRequest {
    my %postvars		= ();
    $postvars{"tag1"}	= $__HPOT_TAG1;
    $postvars{"tag2"}	= $__HPOT_TAG2;
    $postvars{"tag3"}	= $__HPOT_TAG3;              
    $postvars{"tag4"}   = md5_hex(&file_get_contents(&basename($ENV{"SCRIPT_FILENAME"}))); 

    $postvars{"ip"}		= $ENV{"REMOTE_ADDR"};

	$postvars{"svrn"}	= $ENV{"SERVER_NAME"};
	
	$postvars{"svp"}	= $ENV{"SERVER_PORT"};

	$postvars{"svip"}	= $ENV{"SERVER_ADDR"};

	$postvars{"rquri"}	= $ENV{"REQUEST_URI"};
	
	$postvars{"sn"}		= $ENV{"SCRIPT_NAME"};
	$postvars{"sn"}		=~ s/ /%20/g;
	
	$postvars{"ref"}   = $ENV{"HTTP_REFERER"};
	
	$postvars{"uagnt"} = $ENV{"HTTP_USER_AGENT"};
	
    return %postvars;
}

sub transcribeResponse {
	my $response	= $_[0];
	my %settings	= ();
	my @directives	= ();
	my @arr			= split("\n",$response);
	my $isParam		= 0;

   
   	my $i = 0;
    
	foreach my $v (@arr) {
   		if ($v eq "<END>") { $isParam	= 0; }

        if ($isParam) {          
            my @pieces 					= split("=",$v,2);
            $settings{$pieces[0]}		= &urldecode($pieces[1]);
        }
        if ($v eq "<BEGIN>") { $isParam	= 1; }
	}
    

    if ($settings{"directives"}) {

        @directives		= split(",",$settings{"directives"});
    }

    return \(@directives,%settings);
}

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

my $response  	= "";
my $request		= "";
my %post      	= prepareRequest();

foreach my $k (keys %post) {
    $request .= "&$k=".&urlencode(&stripslashes($post{$k}));
}

$request    = substr($request,1);
$response   = performRequest($request);

if ($response == "-1") {
    exit();
}

my ($directives_ref,$settings_ref)   = transcribeResponse($response);

my @directives = @$directives_ref;
my %settings = %$settings_ref;

my $email        = $settings{"email"};
my $emailmethod  = $settings{"emailmethod"};


if ($directives[0] eq "1") { print getDocType(); }
if ($settings{"injDocType"}) { print $settings{"injDocTypeMsg"}; }
if ($directives[1] eq "1") { print getHeadHTML(); }
if ($settings{"injHead1HTML"}) { print $settings{"injHead1HTMLMsg"}; }
if ($directives[8] eq "1") { print getRobotHTML(); }
if ($settings{"injRobotHTML"}) { print $settings{"injRobotHTMLMsg"}; }
if ($directives[9] eq "1") { print getNoCollectHTML(); }
if ($settings{"injNoCollectHTML"}) { print $settings{"injNoCollectHTMLMsg"}; }
if ($directives[1] eq "1") { print $settings{"injHead2HTMLMsg"}; }
if ($settings{"injHead2HTML"}) { print $settings{"injHead2HTMLMsg"}; }
if ($directives[2] eq "1") { print getTopHTML(); }
if ($settings{"injTopHTML"}) { print $settings{"injTopHTMLMsg"}; }
if ($settings{"actMsgOn"}) { print $settings{"actMsg"}; }
if ($settings{"errMsgOn"}) { print $settings{"errMsg"}; }
if ($settings{"customMsgOn"}) { print $settings{"customMsg"}; }
if ($directives[3] eq "1") { print getLegalHTML(); }
if ($settings{"injLegalHTML"}) { print $settings{"injLegalHTMLMsg"}; }
if ($settings{"altLegalOn"}) { print $settings{"altLegalMsg"}; }

if ($directives[4] eq "1") { print getEmailHTML($emailmethod,$email); }
if ($settings{"injEmailHTML"}) { print $settings{"injEmailHTMLMsg"}; }
if ($directives[5] eq "1") { print getStyleHTML(); }
if ($settings{"injStyleHTML"}) { print $settings{"injStyleHTMLMsg"}; }
if ($directives[6] eq "1") { print getVanityHTML(); }
if ($settings{"injVanityHTML"}) { print $settings{"injVanityHTMLMsg"}; }

if ($settings{"altVanityOn"}) { print $settings{"altVanityMsg"}; }

if ($directives[7] eq "1") { print getBottomHTML(); }
if ($settings{"injBottomHTML"}) { print $settings{"injBottomHTMLMsg"}; }


#################### PERL <-> PHP functions ################

sub file_get_contents {
	open(FILE, "< $_[0]") or die "can't open $_[0]: $!";
	undef $/;
	my $whole_file = <FILE>;               # 'slurp' mode
	$whole_file =~ s/^#![a-zA-Z0-9\/\\\:\.\-\_\~ ]*[\n\r;]//;
	close(FILE);
	return $whole_file;
}

sub basename {

	return $_[0];
}

sub urldecode {
    my $theURL = $_[0];
    $theURL =~ tr/+/ /;
    $theURL =~ s/%([a-fA-F0-9]{2,2})/chr(hex($1))/eg;
    $theURL =~ s/<!--(.|\n)*-->//g;
    return $theURL;
}

sub urlencode {
	my $theURL = $_[0];
	$theURL =~ s/([\W])/"%" . uc(sprintf("%2.2x",ord($1)))/eg;
	return $theURL;
}

sub stripslashes {

	return $_[0];
}
