logo       

cvs: pearweb /public_html/bugs report.php /public_html/bugs/include functi: msg#00032

php.pear.core

Subject: cvs: pearweb /public_html/bugs report.php /public_html/bugs/include functions.inc

arnaud Mon Oct 16 20:48:18 2006 UTC

Modified files:
/pearweb/public_html/bugs report.php
/pearweb/public_html/bugs/include functions.inc
Log:
add a captcha when submit a new bug in an effort to reduce spam (patch by
David Coallier)


http://cvs.php.net/viewvc.cgi/pearweb/public_html/bugs/report.php?r1=1.64&r2=1.65&diff_format=u
Index: pearweb/public_html/bugs/report.php
diff -u pearweb/public_html/bugs/report.php:1.64
pearweb/public_html/bugs/report.php:1.65
--- pearweb/public_html/bugs/report.php:1.64 Wed Sep 27 04:27:21 2006
+++ pearweb/public_html/bugs/report.php Mon Oct 16 20:48:18 2006
@@ -1,5 +1,5 @@
<?php /* vim: set noet ts=4 sw=4: : */
-
+session_start();
/**
* Procedures for reporting bugs
*
@@ -17,7 +17,7 @@
* @package Bugs
* @copyright Copyright (c) 1997-2005 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License
- * @version $Id: report.php,v 1.64 2006/09/27 04:27:21 cellog Exp $
+ * @version $Id: report.php,v 1.65 2006/10/16 20:48:18 arnaud Exp $
*/

/**
@@ -30,10 +30,20 @@
*/
require_once './include/cvs-auth.inc';

+/**
+ * Numeral Captcha Class
+ */
+require_once './include/NumeralCaptcha.php';
+
error_reporting(E_ALL ^ E_NOTICE);
$errors = array();
$ok_to_submit_report = false;

+/**
+ * Instantiate the numeral captcha object.
+ */
+$numeralCaptcha = new NumeralCaptcha();
+
if (isset($_POST['save']) && isset($_POST['pw'])) {
// non-developers don't have $user set
setcookie('MAGIC_COOKIE', base64_encode(':' . $_POST['pw']),
@@ -41,8 +51,21 @@
}

if (isset($_POST['in'])) {
- $errors = incoming_details_are_valid($_POST['in'], 1, ($auth_user &&
$auth_user->registered));
+ $errors = incoming_details_are_valid($_POST['in'], 1, ($auth_user &&
$auth_user->registered));
+
+ /**
+ * Check if session answer is set, then compare
+ * it with the post captcha value. If it's not
+ * the same, then it's an incorrect password.
+ */
+ if (isset($_SESSION['answer'])) {
+ if ($_POST['captcha'] != $_SESSION['answer']) {
+ $errors[] = 'Incorrect Captcha';
+ }
+ }
+
if (!$errors) {
+
/*
* When user submits a report, do a search and display
* the results before allowing them to continue.
@@ -550,6 +573,13 @@
wrap="physical"><?php echo clean($_POST['in']['actres']); ?></textarea>
</td>
</tr>
+ <?php if (!$auth_user) { ?>
+ <tr>
+ <th>What is the answer to this? : <?php print
$numeralCaptcha->getOperation(); ?></th>
+ <td><input type="text" name="captcha" /></td>
+ </tr>
+ <?php $_SESSION['answer'] = $numeralCaptcha->getAnswer(); ?>
+ <?php } ?>
<tr>
<th class="form-label_left">
Submit:
http://cvs.php.net/viewvc.cgi/pearweb/public_html/bugs/include/functions.inc?r1=1.113&r2=1.114&diff_format=u
Index: pearweb/public_html/bugs/include/functions.inc
diff -u pearweb/public_html/bugs/include/functions.inc:1.113
pearweb/public_html/bugs/include/functions.inc:1.114
--- pearweb/public_html/bugs/include/functions.inc:1.113 Mon Sep 18
16:08:38 2006
+++ pearweb/public_html/bugs/include/functions.inc Mon Oct 16 20:48:18 2006
@@ -15,7 +15,7 @@
* @package Bugs
* @copyright Copyright (c) 1997-2005 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License
- * @version $Id: functions.inc,v 1.113 2006/09/18 16:08:38 cellog Exp $
+ * @version $Id: functions.inc,v 1.114 2006/10/16 20:48:18 arnaud Exp $
*/


@@ -44,6 +44,7 @@
'Verified' => 'Ver',
'Suspended' => 'Sus',
'Closed' => 'Csd',
+ 'Spam' => 'Spm',
);

$types = array(
@@ -70,6 +71,7 @@
'Stale' => 0,
'Fresh' => 0,
'Bogus' => 2,
+ 'Spam' => 2,
'All' => 0
);

@@ -447,6 +449,11 @@
echo '<select name="in[package_version]">' . "\n";
echo '<option value="">--Please Select--</option>' . "\n";
$use = 0;
+
+ if (count($versions) == 0) {
+ $versions = array(1 => 1);
+ }
+
while (list(,$v) = each($versions)) {
echo '<option';
if ($current == $v[0]) {
@@ -1257,3 +1264,4 @@
$dbh->query($query);
return true;
}
+

--
PEAR CVS Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise