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
 
@@ -17,14 +17,20 @@
 
 * You should have received a copy of the GNU Affero General Public License
 
 * along with SlatePermutate.  If not, see <http://www.gnu.org/licenses/>.
 
 */
 

	
 
  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>
 

	
 
<?php
 
Page::session_start();
 
@@ -51,22 +57,21 @@ if (empty($visitormail) || !preg_match('
 
}
 
if(empty($nameis) || empty($feedback) || empty($visitormail)) {
 
  echo '<p>Please click "back" and fill in all fields.</p>';
 
  $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)
 
  {
 
    $feedback = stripcslashes($feedback);
 

	
 
    $message = date('l, F j, Y, g:i a') ."
 
@@ -85,10 +90,10 @@ Deployment = $fromdom
 
    /* $feedback_emails has its default set in inc/class.page.inc, can be set in config.inc */
 
    foreach($feedback_emails as $toaddr)
 
      {
 
	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
 
@@ -15,18 +15,21 @@
 
 * 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/>.
 
 */
 

	
 
  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">
 
<input type="hidden" name="ip" value="<?php echo $ipi ?>" />
 
<input type="hidden" name="fromdom" value="<?php echo $fromdom ?>" />
 
<input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" />
 
@@ -42,16 +45,20 @@
 
<h3>General Comments</h3>
 
<p>
 
<textarea name="feedback" rows="6" cols="40"></textarea>
 
</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;
 
    }
 
?>
 

	
 
<input class="gray" type="submit" value="Submit Feedback" />
 
</form>
 

	
inc/class.page.php
Show inline comments
 
@@ -24,14 +24,14 @@
 
define('SP_PACKAGE_NAME', 'slate_permutate');
 
define('SP_PACKAGE_VERSION', '0.1_pre');
 
define('SP_PACKAGE_STRING', SP_PACKAGE_NAME . '-' . SP_PACKAGE_VERSION);
 

	
 
/*
 
 * 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 . '..'.
 
 */
 
set_include_path(get_include_path() . PATH_SEPARATOR . dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'libs');
 

	
 
@@ -41,12 +41,13 @@ set_include_path(get_include_path() . PA
 
 * sense soon.
 
 */
 
/* defaults */
 
$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)) {
 
  require_once($config_inc);
 
}
 

	
inc/config.inc.example
Show inline comments
 
@@ -57,19 +57,20 @@
 
 */ 
 
/* $feedback_emails = array('ethanzonca@gmail.com, ngelderloos7@gmail.com, ohnobinki@ohnopublishing.net'); */
 
/* $feedback_emails = array('user@example.org'); */
 

	
 
/**
 
 * \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
 
 *   Password to be used for administration page (admin.php)
 
 *
 
 */
project.php
Show inline comments
 
@@ -34,14 +34,18 @@
 

	
 
<h3>Source Code</h3>
 
<p>A beta version of SlatePermutate will be released in the near future. For now, an alpha snapshot is available for download: <br /><a href="http://mirror.calvin.edu/~binki/slate_permutate-0.1_pre20101110.tar.bz2">slate_permutate-0.1_pre20101110.tar.bz2</a></p>
 
<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>
 

	
 
<h3>Contact</h3>
 
<p>You may contact the developers via the <a href="feedback.php">feedback form</a> (preferred), or you can email individual developers as listed in the <a href="http://protofusion.org/hg/SlatePermutate">repository</a>.</p>
 

	
0 comments (0 inline, 0 general)