svn: /pear/packages/Bugtracker/trunk/www/ bug-pwd-finder.php robots.txt

From: Date: Wed, 03 Mar 2010 20:14:17 +0000
Subject: svn: /pear/packages/Bugtracker/trunk/www/ bug-pwd-finder.php robots.txt
Groups: php.pear.cvs php.pear.core 
Request: Send a blank email to pear-core+get-9257@lists.php.net to get a copy of this message
jani Wed, 03 Mar 2010 20:14:17 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=295807 Log: - Prevent accidental and robots from sending people their passwords Changed paths: U pear/packages/Bugtracker/trunk/www/bug-pwd-finder.php U pear/packages/Bugtracker/trunk/www/robots.txt Modified: pear/packages/Bugtracker/trunk/www/bug-pwd-finder.php =================================================================== --- pear/packages/Bugtracker/trunk/www/bug-pwd-finder.php 2010-03-03 19:44:05 UTC (rev 295806) +++ pear/packages/Bugtracker/trunk/www/bug-pwd-finder.php 2010-03-03 20:14:17 UTC (rev 295807) @@ -2,40 +2,57 @@ /* Procedure for emailing a password reminder to a user */ +// Start session (for captcha!) +session_start(); + +require_once 'Text/CAPTCHA/Numeral.php'; +$numeralCaptcha = new Text_CAPTCHA_Numeral(); + // Obtain common includes require_once '../include/prepend.php'; $errors = array(); $success = false; -$bug_id = isset($_GET['id']) ? (int) $_GET['id'] : 0; +$bug_id = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0; +$bug_id = $bug_id ? $bug_id : ''; -if (!empty($bug_id)) { +if (isset($_POST['captcha']) && $bug_id != '') { + // 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']) && strlen(trim($_SESSION['answer'])) > 0) { + if ($_POST['captcha'] != $_SESSION['answer']) { + $errors[] = 'Incorrect Captcha'; + } + } else { + exit; + } + // Try to find the email and the password - $query = "SELECT email, passwd FROM bugdb WHERE id = '{$bug_id}'"; + if (empty($errors)) { + $query = "SELECT email, passwd FROM bugdb WHERE id = '{$bug_id}'"; - // Run the query - $row = $dbh->prepare($query)->execute()->fetchRow(MDB2_FETCHMODE_ASSOC); + // Run the query + $row = $dbh->prepare($query)->execute()->fetchRow(MDB2_FETCHMODE_ASSOC); - if (is_null($row)) { - $errors[] = "Invalid bug id provided: #{$bug_id}"; - } else { - if (empty($row['passwd'])) { - $errors[] = "No password found for #$bug_id bug report, sorry."; + if (is_null($row)) { + $errors[] = "Invalid bug id provided: #{$bug_id}"; } else { - $resp = mail($row['email'], + if (empty($row['passwd'])) { + $errors[] = "No password found for #$bug_id bug report, sorry."; + } else { + $resp = mail($row['email'], "Password for {$siteBig} bug report #{$bug_id}", "The password for {$siteBig} bug report #{$bug_id} is {$row['passwd']}", 'From: noreply@php.net'); - if ($resp) { - $success = "The password for bug report #{$bug_id} has been sent to " . spam_protect($row['email'], 'text'); - } else { - $errors[] = 'Sorry. Mail can not be sent at this time, please try again later.'; + if ($resp) { + $success = "The password for bug report #{$bug_id} has been sent to " . spam_protect($row['email'], 'text'); + } else { + $errors[] = 'Sorry. Mail can not be sent at this time, please try again later.'; + } } } } -} else { - $errors[] = 'Invalid bug id provided.'; } response_header('Bug Report Password Finder'); @@ -47,6 +64,10 @@ if ($success) { display_bug_success($success); } + +$captcha = $numeralCaptcha->getOperation(); +$_SESSION['answer'] = $numeralCaptcha->getAnswer(); + ?> <p> @@ -60,8 +81,10 @@ in the bug report. </p> -<form method="get" action="bug-pwd-finder.php"> -<p><b>Bug Report ID:</b> #<input type="text" size="20" name="id"> +<form method="post" action="bug-pwd-finder.php"> +<p><b>Bug Report ID:</b> #<input type="text" size="20" name="id" value="<?php echo $bug_id; ?>"> +<p><b>Solve the problem:<br /><?php echo $captcha; ?> = ? <input type="text" name="captcha" /></p> + <input type="submit" value="Send"></p> </form> Modified: pear/packages/Bugtracker/trunk/www/robots.txt =================================================================== --- pear/packages/Bugtracker/trunk/www/robots.txt 2010-03-03 19:44:05 UTC (rev 295806) +++ pear/packages/Bugtracker/trunk/www/robots.txt 2010-03-03 20:14:17 UTC (rev 295807) @@ -1,3 +1,5 @@ User-agent: msnbot Disallow: * +User-agent: * +Disallow: /bug-pwd-finder.php

« previous php.pear.core (#9257) next »