#!/usr/bin/perl

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

$d_name = "muncieml_db1";
$d_username = "muncieml_db1";
$d_pass = "\@rockdb1";

use DBI;
my $dsn = "DBI:mysql:database=$d_name;host=localhost";
my $dbh = DBI->connect($dsn, $d_username, $d_pass, {RaiseError => 1}) || die $DBI::errstr;

$ipadd = $ENV{REMOTE_ADDR};
$browser = $ENV{HTTP_USER_AGENT};
$referer = $ENV{HTTP_REFERER};


print qq~
<html>
<head>
<title>Visit Laurel Meadows Grand Opening Saturday & Sunday from 1pm - 5pm!</title>
<style>
	a:link			{ font-size: 14px; color: #ffff99; font-weight: bold;text-decoration: none; background-color: transparent; }
	a:visited 		{ font-size: 14px; color: #ffff99; font-weight: bold; text-decoration: none; background-color: transparent; }
	a:active		{ font-size: 14px; color: #ffff99; font-weight: bold; text-decoration: none; background-color: transparent; }
	a:hover 		{ font-size: 14px; color: #ffffff; font-weight: bold; text-decoration: underline; background-color: transparent; }

	td				{ font-family: verdana; font-size: 14px; font-weight: bold; color: #000000; text-decoration: none; }
	table			{ font-family: verdana; font-size: 14px; font-weight: bold; color: #000000; text-decoration: none; }
	body 			{ font-family: verdana; font-size: 14px; font-weight: bold; color: #000000; text-decoration: none; }
</style>
</head>
<body bgcolor="white" leftMargin="0" topMargin="0" marginwidth="0" marginheight="0">
<center>
<table border="0" width="800" bgcolor="#000066">
<tr>
<td valign="top" width="800" align="center">
<font size="3" color="white">Search MLS Listings Online at: <a href="www.muncieMLS.com">Click Here To Visit MuncieMLS.com</a></font><br>
<a href="http://www.ideal-builders.com"><img src="laurel_meadows_flyer.gif" alt="Click Here to Visit IDEAL-Builders.com" border="0" height="1035" width="800"></a>
</td>
</tr>
</table>
<font color="white">$ipadd</font>
</center>
</body>
</html>
~;

	@variables = ($ipadd,$referer,$browser);
	$sql_query = "INSERT INTO starpress_ideal_ad values ('',now(),?,?,?)";
	my $aasth = $dbh->do($sql_query, undef, @variables);

open(MAIL,"|/usr/sbin/sendmail -t");
print MAIL "To: Ryan\@ORRHomes.com\n";
print MAIL "From: Notify\@MuncieMLS.com\n";
print MAIL "Subject: NEW Visit to Laurel Meadows AD Campaign!\n";
print MAIL "Content-type: text/html\n\n";
print MAIL qq~
<html>
<head>
<title>E-Mailer</title>
<link rel="stylesheet" TYPE="text/css" href="http://www.ORRHomes.com/includes/style.css">
</head>
<body bgcolor="white" leftMargin="0" topMargin="0" marginwidth="0" marginheight="0">
<br><br>
New Visitor to Laurel Meadows Campaign!<Br>
IP Address: $ipadd<br>
Refering Site: $referer<Br>
Broswer: $browser<br>
</body>
</html>
~;
close(MAIL);