setConstants(array('recip' => 'abarrera@princeton.edu', 'sub_pre' => 'Comments: ')); // Set defaults for the form elements // Add some elements to the form $form->addElement('header', null, 'Send your comments about a Database or E-Journal'); $form->addElement('text', 'name', 'Enter your name:', array('size' => 50, 'maxlength' => 255)); $form->addElement('text', 'email', 'Enter your email address:', array('size' => 50, 'maxlength' => 255)); $form->addElement('text','subject','Name of Resource:', array('size'=>50)); $form->addElement('textarea','comment','Details of your comment or suggestion:', array('cols'=>50, 'rows'=>3)); #Captcha if (ereg("128\.112\.[0-9]+\.[0-9]+",getip())||ereg("140\.180\.[0-9]+\.[0-9]+",getip())) { $nonpu = false; } else { $nonpu = true; $form->addElement('static','s1','',""); $form->addElement('text','phrase',"Enter the text from the image above"); } #End Captcha $form->addElement('submit', null, 'Send'); // Define filters and validation rules $form->applyFilter('name', 'trim'); $form->addRule('name', 'Please enter your name.', 'required', null, 'server'); $form->addRule('email', 'Please enter your complete valid email address.', 'required'); $form->addRule('email', 'Please enter your complete valid email address.', 'email'); $form->addRule('subject', 'Please enter the name of the resource.', 'required'); $form->addRule('comment', 'Please enter your comment or question.', 'required'); #Captcha Rules if ($nonpu) { $form->addRule('phrase','Please enter the phrase from the image.','required'); } # End Captcha Rules // Try to validate a form if ($form->validate()) { $email = htmlspecialchars($form->exportValue('email')); $name = htmlspecialchars($form->exportValue('name')); $subject = htmlspecialchars($form->exportValue('subject')); $comment = htmlspecialchars($form->exportValue('comment')); # Validate Captcha if (isset($_POST['phrase']) && isset($_SESSION['phrase']) && strlen($_POST['phrase']) > 0 && strlen($_SESSION['phrase']) > 0 && $_POST['phrase'] == $_SESSION['phrase']) { $msg = 'OK!'; $ok = true; unset($_SESSION['phrase']); } else { $msg = 'Please try again!'; } #End Captcha Validate $headers .= "From: $email\n"; $headers .= "Reply-to: $email \n"; $omsg = "Requestor: $name - $email\n"; $omsg .= "Database or E-Journal: $subject\n"; $omsg .= "Comment: $comment\n"; # Send Email if Captcha Successful if ($nonpu) { if($ok) { #mail('esupport@princeton.edu,abarrera@princeton.edu',"Database or E-Journal Feedback Form: ".$subject, $omsg, $headers); send_mail('esupport@princeton.edu,abarrera@princeton.edu',$email,"Database or E-Journal Feedback Form: ".$subject, $omsg); unlink("../about/dynimages/".md5(session_id()) . '.png'); echo "

Thank You, $name

Your comments have been successfully submitted. Thank you for contacting the Princeton University Library.

"; } else { echo "

The phrase submitted was incorrect, please press back to try again.

"; spam_attempts('esupport@princeton.edu,abarrera@princeton.edu', $subject, $omsg, $email, $headers); $fp = fopen("logging/comments.log", "a"); fwrite($fp, "========\n"); fwrite($fp,date("m/d/Y H:m")."\n"); fwrite($fp,"$_SERVER[HTTP_REFERER]==$_SERVER[REQUEST_URI]\n"); fwrite($fp,"Subject: $subject\n"); fwrite($fp,"Message: $omsg\n"); fwrite($fp,"Headers: $headers\n"); fwrite($fp,"IP: ".$_SERVER["REMOTE_ADDR"]."\n"); fclose($fp); send_mail('abarrera@princeton.edu',$email,"Database or E-Journal Feedback Form Spam: ".$subject, $omsg); } } else { #mail('esupport@princeton.edu,abarrera@princeton.edu',"Articles and Databases Feedback Form: ".$subject, $omsg, $headers); send_mail('esupport@princeton.edu,abarrera@princeton.edu',$email,"Database or E-Journal Feedback Form: ".$subject, $omsg); echo "

Thank You, $name

Your comments have been successfully submitted. Thank you for contacting the Princeton University Library.

"; } } else { ?>

Please use this form to report a problem with any of our databases or electronic journals. Your message will be acknowledged promptly. To contact the library about other issues, please see our general contacts page.

Required fields are marked with an asterisk (*).

\n\t\t{header}\n\t"; $form_tpl = "\n\n\n{content}\n
\n"; $renderer->setFormTemplate($form_tpl); $renderer->setHeaderTemplate($head_tpl); $form->accept($renderer); echo $renderer->toHtml(); #$form->display(); } ?>