<?php

/*

GENERIC PAGE TEMPLATE

*/


// All important root and globals.  Do not edit the next 3 lines
$DOCROOT = $_SERVER['DOCUMENT_ROOT'];
include($DOCROOT.'/includes/globals.inc');
global $GLOB;

/*************************
 Configure this part
*************************/

// This is the date of this page's last update.  Change it when you update.

$lastupdate = '03/13/2007';


// The title of the page that will display at the top of the browser

$pagetitle = 'Contact us';


// The image for the top banner

$topbanner = '/images/web-rustbanner01.jpg';


// The alternate text for the top banner

$topbanneralt = 'Contact us';


// Breadcrumbs (the trail of links that tells you where you are)

$bcstyle = 'LEVEL1';			// This should be 'HOME', 'LEVEL1' or 'LEVEL2'


// If you set $bcstyle to LEVEL1 or LEVEL2, you need this part

$bclocation  = 'Contact Us';		// The is the text that will print for your current location. 


// If you set $bcstyle to LEVEL2, you also need these two

$bcparentname = 'Some Name';		// The name of the parent page to display
$bcparentlink = '/somepage.php';	// The link to the parent page (so they can click it to get back)

/*************************
STOP CONFIGURING
The rest of the page is your content.  Enjoy. 
*************************/

$posted = 'no';

if(isset($_REQUEST['submit']))
{
	$subject = 'Message from DTC site.';
	//$to = 'matt@popmartian.com, matt@darktwincities.com, devil@gothling.com';
	$to = 'matt@popmartian.com';
	// Filter bad things

	$message = $_REQUEST['message'];

	if(isset($_REQUEST['name']))
	{
		if(preg_match("/(%0A|%0D|\n+|\r+)/i", $_REQUEST['name']))
		{
			die('Your name contains invalid characters.  This looks like spam to me.  Please click your back button and try again.');
		}
		if(preg_match("/(%0A|%0D|\n+|\r+)(content-type:|to:|cc:|bcc:)/i", $_REQUEST['name']))
		{
			die('Your name contains invalid characters.  This looks like spam to me.  Please click your back button and try again.');
		}

		$fromname = $_REQUEST['name'];
	}
	else
	{
		$fromname = 'anonymous';
	}

	if(isset($_REQUEST['botkill']) && isset($_REQUEST['botkill2']))
	{
		if(($_REQUEST['botkill'] != 7) || ($_REQUEST['botkill2'] != 1))
		{
			die('Either you are bad at math or you are a spammer.');
		}
	}
	else
	{
		die('Either you are bad at math or you are a spammer.');
	}

	if(preg_match("/(%0A|%0D|\n+|\r+)/i", $_REQUEST['email']))
	{
		die('Your email address contains invalid characters.  This looks like spam to me.  Please click your back button and try again.');
	}


	if(preg_match("/(%0A|%0D|\n+|\r+)(content-type:|to:|cc:|bcc:)/i", $_REQUEST['email']))
	{
		die('Your email address contains invalid characters.  This looks like spam to me.  Please click your back button and try again.');
	}

	if(!preg_match("/^[A-Z0-9._%-]+@[A-Z0-9.-]+.[A-Z]{2,4}$/i",$_REQUEST['email']))
	{
		die('Invalid email.  Click your back button and enter a valid email address.');
	}

	$from = "From: ".strip_tags($_REQUEST['email']);

	// Send the message
//        mail($to, $subject, $message, $from, '-t');

	if(!mail($to, $subject, $message, $from, '-t'))
	{
		print_r($to);
		echo '<br>';
		print_r($subject);
		echo '<br>';
		print_r($message);
		echo '<br>';
		print_r($from);
		echo '<br>';
		die('failed');
	}
	else
	{
		$posted = 1;
	}
}
else
{
}
?>

<?php
	// Start the HTML with whatever you want the page to be called.
	html_start($pagetitle);
	// html_start(<title>) will print the starting HTML along with whatever you want in the title
?>

<?php
	// Print a banner across the top
	html_banner($topbanner, $topbanneralt);
	// html_banner(<image>, <text>) will print a banner with an image and alternate text
?>


<table width="700" align="center" cellpadding="0" cellspacing="0" border="0">
<tr>
	<td colspan="3" class="breadcrumb">
<?php
	/*******************
	This breadcrumb section will print the right trail depending on your configuration at the top of the template.
	If you know what you want, you don't need the whole thin of course, but it is easier if you leave it.
	******************/

	if($bcstyle == 'HOME')
	{
		html_breadcrumbs($bcstyle);
	}
	elseif($bcstyle == 'LEVEL1')
	{
		html_breadcrumbs($bclocation);
	}
	elseif($bcstyle == 'LEVEL2')
	{
		$bcpage = array('name' => $bcparentname, 'link' => $bcparentlink);
		html_breadcrumbs($bclocation, $bcpage);
	}
	else
	{
		html_breadcrumbs('NONE');
	}

	/*******************
	END BREADCRUMB TRAIL
	******************/
?>

	</td>
</tr>
<tr>
	<td colspan="3">
		&nbsp;
	</td>
</tr>
<tr>
	<td valign="top" width="160" class="leftnavcolumn">

<?php
	// Print the navigation bar
	include($DOCROOT.'/includes/navbar.inc');
?>
	</td>
	<td class="bodytitle" width="15">
		&nbsp;
	</td>
	<td valign="top" id="bodycell">
	<!-- START BODY CONTENT SECTION -->
		<table width="100%" align="center" cellpadding="3" cellspacing="0" border="0">
		<tr>
			<td colspan="2" class="bodytitle">
				<span class="heading">Contact Us!</span>
			</td>
		</tr>
<?php
if($posted == 1)
{
	echo'
		<tr>
			<td colspan="2">
				Thank you for contacting us.  Through the magic of the internet, little bits of data are streaming to us at the speed of light.  We will respond shortly.
			</td>
		<tr>
			<td colspan="2">
				&nbsp;
			</td>
		</tr>';
}
?>
		<tr>
			<td colspan="2">
				<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
					<table border="0">
					<tr>
						<td colspan="2">
							<strong>Who are you?</strong>
						</td>
					</tr>
					<tr>
						<td>
							Your name:
						</td>
						<td>
							<input name="name" type="text">
						</td>
					</tr>
					<tr>
						<td>
							Your email:
						</td>
						<td>
							<input name="email" type="text"> (required)
						</td>
					</tr>
					<tr>
						<td colspan="2">
							<strong>What do you want?</strong>
						</td>
					</tr>
					<tr>
						<td colspan="2">
							<textarea name="message" cols="70" rows="10"></textarea>
						</td>
					</tr>
					<tr>
						<td align="right">
							Prove you aren't a spam bot:
						</td>
						<td align="left">
							3 + 4 = <input type="text" name="botkill">
						</td>
					</tr>
					<tr>
						<td align="right">
							Prove you aren't a spam bot:
						</td>
						<td align="left">
							3 - 2 = <input type="text" name="botkill2">
						</td>
					</tr>
					<tr>
						<td colspan="2">
							<input type="submit" value="Talk" name="submit">
						</td>
					</tr>
					</table>
				</form>
			</td> 
		</tr> 
		<tr>

			<td colspan="2">
				&nbsp;
			</td>
		</tr>
		</table>
	<!-- STOP BODY CONTENT SECTION -->
	</td> 
</tr> 
<tr>
	<td colspan="3" class="bodytitle">
		&nbsp;
	</td>
</tr>
<tr>
	<td colspan="3" class="footer">
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
		<tr>
			<td>
				<?php html_footer(); ?>
			</td>
			<td width="150" class="lastupdate">
				Last update: <?php echo $lastupdate; ?>
			</td>
		</tr>
		</table>
	</td>
        <!-- end of main body subtable -->
</tr>
</table>

<?
include($DOCROOT.'/includes/foot.inc');
?>

</body>
</html>
