<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head profile="http://gmpg.org/xfn/11">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Tomasino Blog Comments</title>
<meta name="description" content="The personal, hand-coded RSS Weblog of Tomasino" />
<meta name="copyright" content="Copyright © 2007 James Tomasino, All rights reserved." />
<meta name="robots" content="ALL" />
<meta name="distribution" content="Global" />
<meta name="language" content="English" />
<meta name="doc-type" content="Web Page" />
<meta name="doc-class" content="Living Document" />
<meta name="doc-rights" content="Copywritten Work" />
<link href="comments.css" media="all" rel="stylesheet" title="Simple Styles" type="text/css" />
</head>
<body id="www-tomasinoblog-com">
<div id="wrapper">
<?php
$posttitle = $_REQUEST['title'];
$name = $_REQUEST['name'];
$email = $_REQUEST['email'];
$comment = $_REQUEST['comment'];
$emailRegX = "/[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}/i";
$entry_id = $_REQUEST['id'];
$botcheck = $_REQUEST['website'];
function SendMail ($t,$n,$c,$e)
{
$emailaddress = "XXXXXXXX";
$subject = "Blog Comment - " . $t;
$headers = 'From: "'.$n.'" <'.$e.'>';
$body = $c;
if (mail($emailaddress, $subject, $body, $headers))
{
echo("<p id='title'>Comment Submitted!</p>");
} else {
echo("<p id='title'>Comment Failed.</p>");
}
}
if (isset($posttitle) && isset($name) && isset($comment) && preg_match($emailRegX, $email))
{
if (isset($botcheck) && ($botcheck != ""))
{
echo("<p id='title'>Comment Not Submitted. I think you're a bot.</p>");
}
else
{
SendMail($posttitle,$name,$comment,$email);
}
}
else
{
if (isSet($entry_id)) {
$xml = simplexml_load_file("blog.xml");
$itemCount = count($xml->xpath('/rss/channel/item'));
$index = intval($entry_id);
$itemIndex = $itemCount - $index;
if ( ($itemIndex <= $itemCount) and ($itemIndex > 0) ) {
$xpathQuery = '/rss/channel/item['.$itemIndex.']';
$item = $xml->xpath($xpathQuery);
$title = $item[0]->xpath('./title');
}
?>
<p id="title"> Comment On - <?php echo $title[0]; ?> </p>
<form id="contactform" class="contactform" method="post" action="comments.php">
<p>
<label for="name">Name:</label>
<input type="text" class="txt" name="name" id="name" size="20" value="<?=$name?>" />
</p>
<p>
<label for="email">Email:</label>
<input type="text" class="txt" name="email" id="email" size="20" value="<?=$email?>" />
</p>
<p>
<label for="comment">Comment:</label>
<textarea type="text" class="comment" name="comment" id="comment" size="20" value="<?=$comment?>"></textarea>
</p>
<p style="display:none;">
<label for="website">Website:</label>
<input type="text" class="txt" name="website" id="website" size="20" value="" />
</p>
<p>
<input type="hidden" name="id" value="<?=$entry_id?>" />
<input type="hidden" name="title" value="<?=$title[0]?>" />
<input type="submit" name="Submit" value="Submit" />
</p>
</form>
<?php
if (isset($posttitle))
{
?>
<p class="error">Please try again. Something is wrong.</p>
<?php
}
}
}
?>
</div>
</body>
</html>