[csw-devel] SF.net SVN: opencsw:[621] web/wordpresscsw/wp-content/themes/opencsw
bdwalton at users.sourceforge.net
bdwalton at users.sourceforge.net
Thu May 31 01:04:02 CEST 2012
Revision: 621
http://opencsw.svn.sourceforge.net/opencsw/?rev=621&view=rev
Author: bdwalton
Date: 2012-05-30 23:04:01 +0000 (Wed, 30 May 2012)
Log Message:
-----------
add recaptcha support to the maintainer contact/package query form
Modified Paths:
--------------
web/wordpresscsw/wp-content/themes/opencsw/composeEmail.php
web/wordpresscsw/wp-content/themes/opencsw/sendEmail.php
Modified: web/wordpresscsw/wp-content/themes/opencsw/composeEmail.php
===================================================================
--- web/wordpresscsw/wp-content/themes/opencsw/composeEmail.php 2012-05-29 22:33:04 UTC (rev 620)
+++ web/wordpresscsw/wp-content/themes/opencsw/composeEmail.php 2012-05-30 23:04:01 UTC (rev 621)
@@ -7,6 +7,11 @@
<?php get_header(); ?>
<?php
+ // include captcha library
+ require_once("recaptchalib.php");
+?>
+
+<?php
// Retrieve the information from the database
$maintainerName = $wp_query->get('maintainerName');
$softwareName = $wp_query->get('softwareName');
@@ -37,6 +42,10 @@
<input type="hidden" name="maintainerName" value="<?php echo $maintainerName ?>" >
<input type="hidden" name="softwareName" value="<?php echo $softwareName ?>" >
<input type="hidden" name="maintainerFullName" value="<?php echo $maintainerFullName ?>" >
+ <?php
+ // Get the captcha
+ echo recaptcha_get_html(RECAPTCHA_PUBLIC_KEY);
+ ?>
<br>
<br>
<input type="submit" value="Send email" id="searchsubmit">
Modified: web/wordpresscsw/wp-content/themes/opencsw/sendEmail.php
===================================================================
--- web/wordpresscsw/wp-content/themes/opencsw/sendEmail.php 2012-05-29 22:33:04 UTC (rev 620)
+++ web/wordpresscsw/wp-content/themes/opencsw/sendEmail.php 2012-05-30 23:04:01 UTC (rev 621)
@@ -6,6 +6,11 @@
<?php get_header(); ?>
+<?php
+ // Include the captcha library
+ require_once('recaptchalib.php');
+?>
+
<div id="container">
<div id="content">
<div class="post hentry">
@@ -20,21 +25,45 @@
$emailBody = $wp_query->get('emailBody');
$emailAddress = $wp_query->get('emailAddress');
- $maintainerEmail = "$maintainerName at opencsw.org";
+ $hasError = false;
- if (! mail($maintainerEmail, $emailSubject, $emailBody, "From: $emailAddress ") ) {
- echo "<p>Server error :( Cannot submit form.</p>";
- echo "<p>Please try again later.</p>";
- } else {
- echo "<p>Thank you. Your message has been sent to $maintainerFullName.</p>" ;
- echo "<p/>";
- if ( strlen($softwareName) > 0 ) {
- echo "<p>Back to " . $softwareName . " software <a href=\"packages/" . $softwareName . "\">page</a>.</p>";
- }
- echo "<p/>";
- echo "<p>Back to " . $maintainerFullName . " maintainer <a href=\"maintainers/" . $maintainerName . "\">page</a>.</p>";
+ // Control that the text input in the captcha field is valid
+ if (!$_POST["recaptcha_response_field"]) {
+ // What happens when the CAPTCHA was entered incorrectly
+ echo "<p>The value entered in the captcha field is not valid</p>";
+ $hasError = true;
+ } else {
+ $resp = recaptcha_check_answer (RECAPTCHA_SECRET_KEY,
+ $_SERVER["REMOTE_ADDR"],
+ $_POST["recaptcha_challenge_field"],
+ $_POST["recaptcha_response_field"]);
+
+ if (!$resp->is_valid) {
+ // What happens when the CAPTCHA was entered incorrectly
+ echo "<p>The value entered in the captcha field is not correct</p>";
+ $hasError = true;
+ }
}
+
+
+ if ($hasError == false) {
+ $maintainerEmail = "$maintainerName at opencsw.org";
+
+ if (! mail($maintainerEmail, $emailSubject, $emailBody, "From: $emailAddress ") ) {
+ echo "<p>Server error :( Cannot submit form.</p>";
+ echo "<p>Please try again later.</p>";
+ } else {
+ echo "<p>Thank you. Your message has been sent to $maintainerFullName.</p>" ;
+ echo "<p/>";
+ if ( strlen($softwareName) > 0 ) {
+ echo "<p>Back to " . $softwareName . " software <a href=\"packages/" . $softwareName . "\">page</a>.</p>";
+ }
+ echo "<p/>";
+ echo "<p>Back to " . $maintainerFullName . " maintainer <a href=\"maintainers/" . $maintainerName . "\">page</a>.</p>";
+ }
+ }
+
?>
</div>
</div>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the devel
mailing list