Changeset - 7b489f5ccba0
[Not reviewed]
default
0 5 1
Nathan Brink (binki) - 15 years ago 2010-12-31 17:04:41
ohnobinki@ohnopublishing.net
Replace reCaptcha with phpcaptcha (a.k.a. securimage), which actually lets us use XHTML.
6 files changed with 75 insertions and 29 deletions:
0 comments (0 inline, 0 general)
captcha_img.php
Show inline comments
 
new file 100644
 
<?php
 
/*
 
 * Copyright 2010 Nathan Gelderloos, Ethan Zonca, Nathan Phillip Brink
 
 *
 
 * This file is part of SlatePermutate.
 
 *
 
 * SlatePermutate is free software: you can redistribute it and/or modify
 
 * it under the terms of the GNU Affero General Public License as published by
 
 * the Free Software Foundation, either version 3 of the License, or
 
 * (at your option) any later version.
 
 *
 
 * SlatePermutate is distributed in the hope that it will be useful,
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
 * GNU Affero General Public License for more details.
 
 *
 
 * You should have received a copy of the GNU Affero General Public License
 
 * along with SlatePermutate.  If not, see <http://www.gnu.org/licenses/>.
 
 */
 

	
 
require_once('inc/class.page.php');
 

	
 
if (!$use_captcha)
 
  page::show_404('Captchas are disabled.');
 

	
 
require('securimage/securimage.php');
 
$securimage = new Securimage();
 
echo $securimage->show();
feedback-submit.php
Show inline comments
 
@@ -20,8 +20,14 @@
 

	
 
  include_once 'inc/class.page.php';
 

	
 
  $feedbackpage = new page('Feedback');
 
  $subject = '[SlatePermutate] - Feedback';
 
if ($use_captcha)
 
  {
 
    require_once('securimage/securimage.php');
 
    $securimage = new Securimage();
 
  }
 

	
 
$feedbackpage = new page('Feedback');
 
$subject = '[SlatePermutate] - Feedback';
 
?>
 

	
 
<h3>Thanks!</h3>
 
@@ -54,16 +60,15 @@ if(empty($nameis) || empty($feedback) ||
 
  $reject = TRUE;
 
}
 

	
 
/** Try reCaptcha */
 
if(isset($reCaptcha_priv) && isset($reCaptcha_pub)) {
 
  require_once('inc/recaptchalib.php');
 
  $reCaptchaRes = recaptcha_check_answer($reCaptcha_priv, $_SERVER["REMOTE_ADDR"],$_POST["recaptcha_challenge_field"],$_POST["recaptcha_response_field"]);
 

	
 
  if(!$reCaptchaRes->is_valid) {
 
    echo '<p>Please click "back" and enter a valid reCaptcha response.</p>';
 
    $reject = TRUE;
 
/** Check the captcha */
 
if ($use_captcha)
 
  {
 
    if (!$securimage->check($_REQUEST['captcha_code']))
 
      {
 
	echo '<p>Your captcha response was incorrect, please try again.</p>';
 
	$reject = TRUE;
 
      }
 
  }
 
}
 

	
 
if (!$reject)
 
  {
 
@@ -88,7 +93,7 @@ Deployment = $fromdom
 
	mail($toaddr, $subject, $message, $from);
 
      }
 

	
 
    echo '<p>Thanks for helping make SlatePermutate better. Your feedback is greatly appreciated.</pi>';
 
    echo '<p>Thanks for helping make SlatePermutate better. Your feedback is greatly appreciated.</p>';
 
    echo '<p>We will attempt to respond via email if your feedback lends itself to a response.</p>';
 
  }
 
    $feedbackpage->foot();
feedback.php
Show inline comments
 
@@ -18,12 +18,15 @@
 
 * along with SlatePermutate.  If not, see <http://www.gnu.org/licenses/>.
 
 */
 

	
 
  include_once 'inc/class.page.php'; 
 
include_once 'inc/class.page.php'; 
 

	
 
  $feedbackpage = new page('Feedback');
 
  $ipi = $_SERVER['REMOTE_ADDR'];
 
  $fromdom = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
 
  $httpagenti = $_SERVER['HTTP_USER_AGENT'];
 
$feedbackpage = new page('Feedback');
 
$ipi = $_SERVER['REMOTE_ADDR'];
 
$fromdom = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
 
$httpagenti = $_SERVER['HTTP_USER_AGENT'];
 

	
 
$n = "\n";
 

	
 
?>
 

	
 
<form action="feedback-submit.php" method="post">
 
@@ -45,10 +48,14 @@
 
</p>
 

	
 
<?php
 
  if(isset($reCaptcha_pub) && isset($reCaptcha_priv))
 
    if ($use_captcha)
 
    {
 
      require_once('recaptchalib.php');
 
      echo recaptcha_get_html($reCaptcha_pub); 
 
      echo '<fieldset>' . $n
 
      . '  <legend>Captcha</legend>' . $n
 
      . '  <img id="captcha_img" src="captcha_img.php" alt="captcha image" style="display: block" />' . $n
 
      . '  <label for="captcha_code" style="display: block">Enter the obfuscated text in the above image:</label>' . $n
 
      . '  <input name="captcha_code" type="textbox" />' . $n
 
      . '</fieldset>' . $n;
 
    }
 
?>
 

	
inc/class.page.php
Show inline comments
 
@@ -27,8 +27,8 @@ define('SP_PACKAGE_STRING', SP_PACKAGE_N
 

	
 
/*
 
 * Set up include() path for user-supplied libs (in case if his system
 
 * doesn't have libs, such as recaptchalib.php). Users would store
 
 * such libs in /libs.
 
 * doesn't have libs, such as phpcaptcha
 
 * (securimage/securimage.php)). Users would store such libs in /libs.
 
 *
 
 * Coding note: dirname(dirname('a/b/c')) returns 'a'. This is a
 
 * similar effect to dirname('a/b/c') . DIRECTORY_SEPARATOR . '..'.
 
@@ -44,6 +44,7 @@ set_include_path(get_include_path() . PA
 
$clean_urls = FALSE;
 
$ga_trackers = array();
 
$feedback_emails = array('ez@ethanzonca.com, ngelderloos7@gmail.com, ohnobinki@ohnopublishing.net');
 
$use_captcha = FALSE;
 

	
 
$config_inc = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'config.inc';
 
if (file_exists($config_inc)) {
inc/config.inc.example
Show inline comments
 
@@ -60,13 +60,14 @@
 

	
 
/**
 
 * \brief
 
 *   Keys to use with reCaptcha for feedback form submissions
 
 *   Whether or not to use SecureImage phpcaptcha.
 
 *
 
 * Set to your public and private keys obtained from https://www.google.com/recaptcha/
 
 * Be sure to keep your private key secret.
 
 * Set to TRUE to use SecureImage captcha, FALSE to not use
 
 * it. Requires PHP library available from http://phpcaptcha.org/
 
 * which may be placed in slate_permutate's lib/ directory or into the
 
 * system PHP include path.
 
 */
 
/* $reCaptcha_priv = ''; */
 
/* $reCaptcha_pub = ''; */ 
 
$use_captcha = FALSE;
 

	
 
/**
 
 * \brief
project.php
Show inline comments
 
@@ -37,8 +37,12 @@
 
<p>Current development code can be retrieved via the Mercurial SCM at <em>https://protofusion.org/hg/SlatePermutate</em></p>
 

	
 
<h3>Requirements</h3>
 
<p>To run properly, SlatePermutate requires a modern PHP environment (5.0+) that includes libcurl, and a writable cache directory for school and schedule data. SlatePermutate <em>does not</em> require a backend database.</p><p>SlatePermutate has optional requirements of Google Analytics tracking and reCaptcha for feedback forms; these options are set in the config.inc file.</p>
 

	
 
<p>To run properly, SlatePermutate requires a modern PHP environment (5.0+) that includes libcurl, and a writable cache directory for school and schedule data. SlatePermutate <em>does not</em> require a backend database.</p>
 
<p>
 
  SlatePermutate has optional requirements of Google Analytics tracking
 
  and <a href="http://phpcaptcha.org/">phpcaptcha/securimage</a> for
 
  feedback forms; these options are set in the config.inc file.
 
</p>
 
<h3>About</h3>
 
<p>This program was created by <a href="http://www.calvin.edu" rel="external">Calvin College</a> and <a href="http://cedarville.edu/" rel="external">Cedarville University</a> students. SlatePermutate is written in PHP, with a valid XHTML frontend.</p>
 

	
0 comments (0 inline, 0 general)