| 
<?php
//**************************************************************************************
 // Include class
 //**************************************************************************************
 include("classes/myaltcaptcha_class.php"); // include myAltCGen class
 $myObj = new myAltCaptchaObject;
 
 $name = $email = $subject = $message = $errorStr = $passStr = '';
 $validationFail = false;
 
 //**************************************************************************************
 // If submit button pressed then do next section
 //**************************************************************************************
 if(isset($_REQUEST['submitForm'])){
 
 $altCaptcha = $_POST['macID'];
 $honeyPots  = explode('.',$_POST['macHID']);
 
 $name       = $_POST[$altCaptcha.md5('name')];
 $email      = $_POST[$altCaptcha.md5('email')];
 $subject    = $_POST[$altCaptcha.md5('subject')];
 $message    = $_POST[$altCaptcha.md5('message')];
 
 foreach($honeyPots as $val) {
 if(!empty($_POST[$altCaptcha.md5($myObj->honeyPotClass[$val]['inputID'])])) { // Illegal operation by spambot so pretend we have succeeded
 $errorStr = "<center><h2>oops!!</h2><p>Your message has not been sent because a security breach has been detected.  A note of your IP Adress and the security breach has been stored for further investigation.</p></center>";
 $myObj->setErrorMessage("<p>Honeypot (".$myObj->honeyPotClass[$val]['inputID'].") has been filled in.<br />Text: ".$_POST[$altCaptcha.md5($myObj->honeyPotClass[$val]['inputID'])]."</p>");
 }
 }
 
 if(empty($errorStr)) {
 if(!$myObj->validateAltCaptcha($altCaptcha)) {
 $errorStr  = "<center><h2>oops!!</h2><p>Your message has not been sent because of a form validation failure.  A note of your IP Adress and the failure has been stored for further investigation.</p></center>";
 $errorStr .=  $myObj->lastMessage;
 } else {
 if(empty($name) ||
 empty($email) ||
 empty($subject) ||
 empty($message) ||
 empty($altCaptcha)
 ) $validationFail = true;
 else {
 $passStr = "<center><h2>Thank You!!</h2><p>Your message has successfully been sent and will be reviewed before posting to the site</p></center>";
 }
 }
 }
 }
 
 //**************************************************************************************
 // Display Section
 //**************************************************************************************
 echo '<!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" xml:lang="en" >
 <head>
 <title>myAltCaptcha</title>
 <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
 
 <style type="text/css" title="currentStyle" media="screen">
 @import url(style/style.css);
 </style>
 
 </head>
 <body>';
 
 echo $myObj->getVersion();
 if(empty($passStr)) {
 if(empty($errorStr)) {
 $tmpString  = ' <form name="form1" method="post" action="'.$_SERVER['PHP_SELF'].'" id="form1">
 <p>This page is to test the alternative CAPTCHA class</p>
 <div id="contactUs">';
 $tmpString .= '     <fieldset>
 <legend><label>Contact Details</label></legend>
 <p style="margin-top: 10px;">';
 
 if($validationFail) {
 $tmpString .= '       <span class="validationError">* Note, all in <strong>BOLD</strong> type are mandatory.</span>';
 } else {
 $tmpString .= '       <span class="contactText">* Note, all fields in <strong>BOLD</strong> type are mandatory.</span>';
 }
 $tmpString .= '       </p>';
 
 $tmpString .= '       <dl>';
 $tmpString .= $myObj->getHoneyPot();
 $tmpString .= '         <dt class="formLabelRqd">Name:</dt>
 <dd class="formInput"><input id="'.$myObj->getMyHashElementName('name').'" type="text" name="'.$myObj->getMyHashElementName('name').'" maxlength="100" size="34" value="'.$name.'" /></dd>
 <dt class="formLabelRqd">Email</dt>
 <dd class="formInput"><input id="'.$myObj->getMyHashElementName('email').'" type="text" name="'.$myObj->getMyHashElementName('email').'" maxlength="100" size="34" value="'.$email.'" /></dd>';
 $tmpString .= $myObj->getHoneyPot();
 $tmpString .= '         <dt class="formLabelRqd">Subject</dt>
 <dd class="formInput"><input id="'.$myObj->getMyHashElementName('subject').'" type="text" name="'.$myObj->getMyHashElementName('subject').'" maxlength="100" size="34" value="'.$subject.'" /></dd>
 <dt class="formLabelRqd">Message</dt>
 <dd class="formInput"><textarea name="'.$myObj->getMyHashElementName('message').'" id="'.$myObj->getMyHashElementName('message').'" rows="15" cols="40">'.$message.'</textarea></dd>';
 $tmpString .= $myObj->getHoneyPot();
 $tmpString .= '       </dl>';
 
 $tmpString .= '       <div style="text-align: center;">
 <br />';
 $tmpString .= $myObj->getHoneyPot();
 $tmpString .= '         <input type="hidden" name="macHID" value="'.$myObj->getMyUsedHoneyPots().'" />
 <input type="hidden" name="macID" value="'.$myObj->getMySecret().'" />
 <input type="submit" id="submitForm" name="submitForm" value="Send Email" />
 </div>';
 
 $tmpString .= '     </fieldset>
 </div>
 </form>';
 
 echo $tmpString;
 } else {
 $myObj->setFromName($name);
 $myObj->setFromEmail($email);
 $myObj->setSubject($subject);
 $myObj->setMessage($message);
 $myObj->sendAlert();
 echo $errorStr;
 }
 } else {
 echo $passStr;
 }
 echo '  </body>
 </html>';
 
 ?>
 
 |