cvs: pearweb / package.xml /include/Damblan/Mail pearweb_account_request_bug.tpl.php /include/DataObject Bugdb.php Bugdb_comments.php /include/bugs
pear-bug-accountrequest.php pear.ini /include/election pear-election-accountrequest.php /public_html account-request-confirm.php /public_html/bugs
bug.php report.php /public_html/bugs/include functions.inc /sql bugs.sql pearweb_mdb2schema.xml
| From: | Greg Beaver | Date: | Sun, 25 Feb 2007 22:44:27 +0000 |
| Subject: | cvs: pearweb / package.xml /include/Damblan/Mail pearweb_account_request_bug.tpl.php /include/DataObject Bugdb.php Bugdb_comments.php /include/bugs pear-bug-accountrequest.php pear.ini /include/election pear-election-accountrequest.php /public_html account-request-confirm.php /public_html/bugs bug.php report.php /public_html/bugs/include functions.inc /sql bugs.sql pearweb_mdb2schema.xml |
||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-44878@lists.php.net to get a copy of this message | ||
cellog Sun Feb 25 22:44:27 2007 UTC
Added files:
/pearweb/include/Damblan/Mail pearweb_account_request_bug.tpl.php
/pearweb/include/bugs pear-bug-accountrequest.php
Modified files:
/pearweb package.xml
/pearweb/include/DataObject Bugdb.php Bugdb_comments.php
/pearweb/include/bugs pear.ini
/pearweb/include/election pear-election-accountrequest.php
/pearweb/public_html account-request-confirm.php
/pearweb/public_html/bugs bug.php report.php
/pearweb/public_html/bugs/include functions.inc
/pearweb/sql bugs.sql pearweb_mdb2schema.xml
Log:
initial work on auto-user registration (incomplete - comments not 100% working)
http://cvs.php.net/viewvc.cgi/pearweb/package.xml?r1=1.142&r2=1.143&diff_format=u Index: pearweb/package.xml diff -u pearweb/package.xml:1.142 pearweb/package.xml:1.143 --- pearweb/package.xml:1.142 Sun Feb 25 19:48:23 2007 +++ pearweb/package.xml Sun Feb 25 22:44:26 2007 @@ -93,6 +93,7 @@ <dir name="include"> <dir name="bugs"> <file name="pear-bugs.php" role="web" /> + <file name="pear-bug-accountrequest.php" role="web" /> <file name="pear.ini" role="web" /> <file name="pear.links.ini" role="web" /> </dir> <!-- /include/bugs --> http://cvs.php.net/viewvc.cgi/pearweb/include/DataObject/Bugdb.php?r1=1.1&r2=1.2&diff_format=u Index: pearweb/include/DataObject/Bugdb.php diff -u pearweb/include/DataObject/Bugdb.php:1.1 pearweb/include/DataObject/Bugdb.php:1.2 --- pearweb/include/DataObject/Bugdb.php:1.1 Sat Feb 17 23:22:37 2007 +++ pearweb/include/DataObject/Bugdb.php Sun Feb 25 22:44:26 2007 @@ -14,6 +14,7 @@ var $package_name; // string(80) not_null var $bug_type; // string(32) not_null var $email; // string(40) not_null + var $handle; // string(20) not_null var $sdesc; // string(80) not_null var $ldesc; // blob(65535) not_null blob var $package_version; // string(100) http://cvs.php.net/viewvc.cgi/pearweb/include/DataObject/Bugdb_comments.php?r1=1.1&r2=1.2&diff_format=u Index: pearweb/include/DataObject/Bugdb_comments.php diff -u pearweb/include/DataObject/Bugdb_comments.php:1.1 pearweb/include/DataObject/Bugdb_comments.php:1.2 --- pearweb/include/DataObject/Bugdb_comments.php:1.1 Sat Feb 17 23:22:37 2007 +++ pearweb/include/DataObject/Bugdb_comments.php Sun Feb 25 22:44:26 2007 @@ -13,6 +13,7 @@ var $id; // int(8) not_null primary_key var $bug; // int(8) not_null var $email; // string(40) not_null + var $handle; // string(20) not_null var $ts; // datetime(19) var $comment; // blob(65535) not_null blob http://cvs.php.net/viewvc.cgi/pearweb/include/bugs/pear.ini?r1=1.1&r2=1.2&diff_format=u Index: pearweb/include/bugs/pear.ini diff -u pearweb/include/bugs/pear.ini:1.1 pearweb/include/bugs/pear.ini:1.2 --- pearweb/include/bugs/pear.ini:1.1 Sat Feb 17 23:22:37 2007 +++ pearweb/include/bugs/pear.ini Sun Feb 25 22:44:26 2007 @@ -3,6 +3,7 @@ package_name = 130 bug_type = 130 email = 130 +handle = 130 sdesc = 130 ldesc = 194 package_version = 130 @@ -41,6 +42,7 @@ id = 129 bug = 129 email = 130 +handle = 130 ts = 142 comment = 194 reporter_name = 130 http://cvs.php.net/viewvc.cgi/pearweb/include/election/pear-election-accountrequest.php?r1=1.2&r2=1.3&diff_format=u Index: pearweb/include/election/pear-election-accountrequest.php diff -u pearweb/include/election/pear-election-accountrequest.php:1.2 pearweb/include/election/pear-election-accountrequest.php:1.3 --- pearweb/include/election/pear-election-accountrequest.php:1.2 Sun Dec 3 20:04:17 2006 +++ pearweb/include/election/pear-election-accountrequest.php Sun Feb 25 22:44:26 2007 @@ -146,6 +146,12 @@ $this->dbh->query(' DELETE FROM users WHERE handle=? ', array($data[0])); + $this->dbh->query(' + DELETE FROM bugdb WHERE handle=? + ', array($data[0])); + $this->dbh->query(' + DELETE FROM bugdb_comments WHERE handle=? + ', array($data[0])); } } $query = ' http://cvs.php.net/viewvc.cgi/pearweb/public_html/account-request-confirm.php?r1=1.1&r2=1.2&diff_format=u Index: pearweb/public_html/account-request-confirm.php diff -u pearweb/public_html/account-request-confirm.php:1.1 pearweb/public_html/account-request-confirm.php:1.2 --- pearweb/public_html/account-request-confirm.php:1.1 Sun Dec 3 06:14:48 2006 +++ pearweb/public_html/account-request-confirm.php Sun Feb 25 22:44:26 2007 @@ -1,5 +1,6 @@ <?php -require_once 'election/pear-election-accountrequest.php'; +require 'bugs/pear-bug-accountrequest.php'; +require 'election/pear-election-accountrequest.php'; $stripped = @array_map('strip_tags', $_GET); @@ -7,13 +8,24 @@ print '<h1>Confirm account</h1>'; -if (!empty($stripped['salt']) && strlen($salt = htmlspecialchars($stripped['salt'])) == 32) { - $request = new PEAR_Election_Accountrequest(); - $request->confirmRequest($salt); - report_success('Your account has been activated, you can now vote in -PEAR elections that are for the general PHP public'); +if (isset($_GET['type']) && $_GET['type'] == 'bug') { + if (!empty($stripped['salt']) && strlen($salt = htmlspecialchars($stripped['salt'])) == 32) { + $request = new PEAR_Bug_Accountrequest; + $request->confirmRequest($salt); + report_success('Your account has been activated, bugs you have opened and comments +you have made are now available to the public for viewing'); + } else { + report_error('Unknown salt'); + } } else { - report_error('Unknown salt'); + if (!empty($stripped['salt']) && strlen($salt = htmlspecialchars($stripped['salt'])) == 32) { + $request = new PEAR_Election_Accountrequest(); + $request->confirmRequest($salt); + report_success('Your account has been activated, you can now vote in + PEAR elections that are for the general PHP public'); + } else { + report_error('Unknown salt'); + } } response_footer(); ?> \ No newline at end of file http://cvs.php.net/viewvc.cgi/pearweb/public_html/bugs/bug.php?r1=1.115&r2=1.116&diff_format=u Index: pearweb/public_html/bugs/bug.php diff -u pearweb/public_html/bugs/bug.php:1.115 pearweb/public_html/bugs/bug.php:1.116 --- pearweb/public_html/bugs/bug.php:1.115 Sun Feb 25 19:14:11 2007 +++ pearweb/public_html/bugs/bug.php Sun Feb 25 22:44:26 2007 @@ -1,5 +1,5 @@ <?php /* vim: set noet ts=4 sw=4: : */ - +session_start(); /** * User interface for viewing and editing bug details * @@ -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: bug.php,v 1.115 2007/02/25 19:14:11 cellog Exp $ + * @version $Id: bug.php,v 1.116 2007/02/25 22:44:26 cellog Exp $ */ /* @@ -37,9 +37,19 @@ * Obtain a list of the trusted developers */ require_once './include/trusted-devs.inc'; + +/** + * Numeral Captcha Class + */ +require_once './include/NumeralCaptcha.php'; + +/** + * Instantiate the numeral captcha object. + */ +$numeralCaptcha = new NumeralCaptcha(); + Bug_DataObject::init(); -session_start(); error_reporting(E_ALL ^ E_NOTICE); @@ -70,6 +80,13 @@ $edit = (int)$_REQUEST['edit']; } +// captcha is not necessary if the user is logged in +if ($auth_user && $auth_user->registered) { + if (isset($_SESSION['answer'])) { + unset($_SESSION['answer']); + } +} + if ($auth_user && $auth_user->registered && isset($_GET['delete_comment'])) { $delete_comment = (int)$_GET['delete_comment']; } else { @@ -101,7 +118,7 @@ $pw = ''; } -// Subscribtion +// Subscription if (isset($_POST['subscribe_to_bug'])) { $email = $_POST['subscribe_email']; if (!preg_match("/[.\\w+-]+@[.\\w-]+\\.\\w{2,}/i", $email)) { @@ -119,9 +136,11 @@ $trytoforce = isset($_POST['trytoforce']) ? (int)$_POST['trytoforce'] : false; // fetch info about the bug into $bug -$query = 'SELECT b.id, b.package_name, b.bug_type, b.email, b.reporter_name, +if ($dbh->getOne('SELECT handle FROM bugdb WHERE id=?', array($id))) { + $query = 'SELECT b.id, b.package_name, b.bug_type, b.email, b.handle, b.reporter_name, b.passwd, b.sdesc, b.ldesc, b.php_version, b.package_version, b.php_os, b.status, b.ts1, b.ts2, b.assign, UNIX_TIMESTAMP(b.ts1) AS submitted, + users.registered, UNIX_TIMESTAMP(b.ts2) AS modified, COUNT(bug=b.id) AS votes, SUM(reproduced) AS reproduced,SUM(tried) AS tried, @@ -130,10 +149,28 @@ users.showemail, users.handle, p.package_type FROM bugdb b LEFT JOIN bugdb_votes ON b.id = bug + LEFT JOIN users ON users.handle = b.handle + LEFT JOIN packages p ON b.package_name = p.name + WHERE b.id = '.(int)$id.' + GROUP BY bug'; +} else { + $query = 'SELECT b.id, b.package_name, b.bug_type, b.email, b.handle, b.reporter_name, + b.passwd, b.sdesc, b.ldesc, b.php_version, b.package_version, b.php_os, + b.status, b.ts1, b.ts2, b.assign, UNIX_TIMESTAMP(b.ts1) AS submitted, + UNIX_TIMESTAMP(b.ts2) AS modified, + COUNT(bug=b.id) AS votes, + SUM(reproduced) AS reproduced,SUM(tried) AS tried, + SUM(sameos) AS sameos, SUM(samever) AS samever, + AVG(score)+3 AS average,STD(score) AS deviation, + users.showemail, users.handle, p.package_type, + 1 as registered + FROM bugdb b + LEFT JOIN bugdb_votes ON b.id = bug LEFT JOIN users ON users.email = b.email LEFT JOIN packages p ON b.package_name = p.name WHERE b.id = '.(int)$id.' GROUP BY bug'; +} $bug =& $dbh->getRow($query, array(), DB_FETCHMODE_ASSOC); @@ -165,6 +202,16 @@ exit(); } +// if the user is not registered, this might be spam, don't display +if (!$bug['registered']) { + response_header('User has not confirmed identity'); + display_bug_error('The user who submitted this bug has not yet confirmed ' . + 'their email address. If you submitted this bug, please check your email.' . + ' If you do not have a confirmation message, please write a message to' . + ' pear-dev@lists.php.net asking for manual approval of your account'); + response_footer(); + exit; +} // Delete comment if ($edit == 1 && isset($_GET['delete_comment'])) { $addon = ''; @@ -183,31 +230,34 @@ if ($_POST['in'] && !isset($_POST['preview']) && $edit == 3) { // Submission of additional comment by others - if (!validate_captcha()) { - $errors[] = 'Incorrect CAPTCHA'; - } - - $comment_name = isset($_POST['in']['comment_name']) ? htmlspecialchars(strip_tags($_POST['in']['comment_name'])) : ''; - - - if (!preg_match("/[.\\w+-]+@[.\\w-]+\\.\\w{2,}/i", $_POST['in']['commentemail'])) { - $errors[] = "You must provide a valid email address."; - } - - // Don't allow comments by the original report submitter - if (rinse($_POST['in']['commentemail']) == $bug['email']) { - localRedirect('bug.php' . "?id=$id&edit=2"); - exit(); + /** + * 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'; + } } - /* check that they aren't using a php.net mail address without - being authenticated (oh, the horror!) */ - if (preg_match('/^(.+)@php\.net/i', rinse($_POST['in']['commentemail']), $m)) { - if ($user != rinse($m[1]) || !verify_password($user, $pass)) { - $errors[] = 'You have to be logged in as a developer and be' - . ' editing the bug via the "Developer" tab in order' - . ' to use your php.net email address.'; + // try to verify the user + if (!$auth_user) { + if (!empty($_POST['isMD5'])) { + $password = @$_POST['PEAR_PW']; + } else { + $password = md5(@$_POST['PEAR_PW']); + } + if (user::exists($_POST['in']['PEAR_USER'])) { + if (auth_verify($_POST['in']['PEAR_USER'], $password)) { + $POST['in']['handle'] = $_POST['in']['PEAR_USER']; + } else { + $errors[] = 'User name "' . clean($_POST['in']['PEAR_USER']) . + '" already exists, please choose another user name'; + } } + } else { + $_POST['in']['handle'] = $auth_user->handle; } $ncomment = trim($_POST['ncomment']); @@ -216,15 +266,60 @@ } if (!$errors) { - $query = 'INSERT INTO bugdb_comments' . - ' (bug, email, ts, comment, reporter_name) VALUES (' . - " $id," . - " '" . escapeSQL($_POST['in']['commentemail']) . "'," . - ' NOW(),' . - " '" . escapeSQL($ncomment) . "'," . - " '" . escapeSQL($comment_name) . "')"; + do { + if (!$auth_user) { + // user doesn't exist yet + require 'bugs/pear-bug-accountrequest.php'; + $buggie = new PEAR_Bug_Accountrequest; + if (empty($_POST['isMD5'])) { + $_POST['PEAR_PW'] = md5($_POST['PEAR_PW']); + $_POST['PEAR_PW2'] = md5($_POST['PEAR_PW2']); + } + $salt = $buggie->addRequest($_POST['PEAR_USER'], + $_POST['in']['email'], $_POST['in']['reporter_name'], + $_POST['PEAR_PW'], $_POST['PEAR_PW2']); + if (is_array($salt)) { + $errors = $salt; + response_header('Report - Problems'); + break; // skip bug comment addition + } + if (PEAR::isError($salt)) { + $errors[] = $salt; + response_header('Report - Problems'); + break; + } + if ($salt === false) { + $errors[] = 'Your account cannot be added to the queue.' + . ' Please write a mail message to the ' + . ' <i>pear-dev</i> mailing list.'; + response_header('Report - Problems'); + break; + } - $dbh->query($query); + $_POST['in']['handle'] = $_POST['PEAR_USER']; + $mailData = array( + 'username' => $_POST['in']['handle'], + 'salt' => $salt, + ); + + if (!DEVBOX) { + $mailer = Damblan_Mailer::create('pearweb_account_request_bug', $mailData); + $additionalHeaders['To'] = $_POST['in']['email']; + $mailer->send($additionalHeaders); + } + } + + $query = 'INSERT INTO bugdb_comments' . + ' (bug, email, handle, ts, comment, reporter_name) VALUES (' . + " $id," . + " '" . escapeSQL($_POST['in']['commentemail']) . "', + '" . $_POST['in']['handle'] . "'," . + ' NOW(),' . + " '" . escapeSQL($ncomment) . "'," . + " '" . escapeSQL($comment_name) . "')"; + + $dbh->query($query); + } while (false); } $from = rinse($_POST['in']['commentemail']); } elseif ($_POST['in'] && isset($_POST['preview']) && $edit == 3) { @@ -545,7 +640,7 @@ if ($auth_user) { control(1, 'Developer'); } else { - control(2, 'Edit Submission'); + control(1, 'Edit Submission'); } ?> @@ -881,12 +976,47 @@ if ($edit == 3) { ?> - <div class="explain"> - If you're the original bug submitter, here's where you can edit the bug - or add additional notes. <a href="<?php - echo htmlspecialchars($_SERVER['PHP_SELF'])."?id=$id&edit=2" ?>">Edit my bug</a>. - </div> - <form id="comment" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']) ?>" method="post"> + <form<?php +$action = htmlspecialchars($_SERVER['PHP_SELF']); +if (!$auth_user && DEVBOX == false) { + $action = "https://" . $_SERVER['SERVER_NAME'] . '/' . $action; +} +if (!$auth_user) { + echo ' onsubmit="javascript:doMD5(document.forms[\'comment\'])" ' ; +} ?> name="comment" id="comment" action="<?php echo $action ?>" method="post"> +<?php if (!$auth_user): ?> + <div class="explain"> + Please choose a username/password or <a href="<?php echo '/login.php?redirect=' . + urlencode("{$self}?{$_SERVER['QUERY_STRING']}") ?>">Log in</a> +<script type="text/javascript" src="/javascript/md5.js"></script> +<script type="text/javascript"> +function doMD5(frm) { + frm.PEAR_PW.value = hex_md5(frm.PEAR_PW.value); + frm.PEAR_PW2.value = hex_md5(frm.PEAR_PW2.value); + frm.isMD5.value = 1; +} +</script> +<input type="hidden" name="isMD5" value="0" /> +<table class="form-holder" cellspacing="1"> + <tr> + <th class="form-label_left"> +Use<span class="accesskey">r</span>name:</th> + <td class="form-input"> +<input size="20" name="PEAR_USER" accesskey="r" /></td> + </tr> + <tr> + <th class="form-label_left">Password:</th> + <td class="form-input"> +<input size="20" name="PEAR_PW" type="password" /></td> + </tr> + <tr> + <th class="form-label_left">Confirm Password:</th> + <td class="form-input"> +<input size="20" name="PEAR_PW2" type="password" /></td> + </tr> +</table> +</div> +<?php endif; //if (!$auth_user) ?> <?php if (!$_POST['in']) { @@ -931,12 +1061,13 @@ <input type="hidden" name="edit" value="<?php echo $edit?>" /> </td> </tr> + <?php if (!$auth_user): ?> <tr> - <th class="details">CAPTCHA:</th> - <td> - <?php echo generate_captcha() ?> - </td> + <th>Solve the problem : <?php print $numeralCaptcha->getOperation(); ?> = ?</th> + <td class="form-input"><input type="text" name="captcha" /></td> </tr> + <?php $_SESSION['answer'] = $numeralCaptcha->getAnswer(); ?> + <?php endif; // if (!$auth_user): ?> </table> <div> @@ -1013,7 +1144,7 @@ // Display original report if ($bug['ldesc']) { - output_note(0, $bug['submitted'], $bug['email'], $bug['ldesc'], $bug['showemail'], $bug['handle'], $bug['reporter_name']); + output_note(0, $bug['submitted'], $bug['email'], $bug['ldesc'], $bug['showemail'], $bug['handle'], $bug['reporter_name'], 1); } // Display patches @@ -1031,28 +1162,44 @@ echo urlencode($name) ?>&revision=latest"><?php echo clean($name) ?></a> (last revision <?php echo date('Y-m-d H:i:s', $revisions[0][0]) ?> by <?php echo $revisions[0][1] ?>)<br /><?php } // Display comments -$query = 'SELECT c.id,c.email,c.comment,UNIX_TIMESTAMP(c.ts) AS added, c.reporter_name as comment_name, +if ($dbh->getOne('SELECT handle FROM bugdb WHERE id=?', array($id))) { + $query = 'SELECT c.id,c.email,c.comment,UNIX_TIMESTAMP(c.ts) AS added, c.reporter_name as comment_name, u.registered, u.showemail, u.handle FROM bugdb_comments c LEFT JOIN users u ON u.email = c.email WHERE c.bug = '.(int)$id.' GROUP BY c.id ORDER BY c.ts'; +} else { + $query = 'SELECT c.id,c.email,c.comment,UNIX_TIMESTAMP(c.ts) AS added, c.reporter_name as comment_name, 1 as registered, + u.showemail, u.handle + FROM bugdb_comments c + LEFT JOIN users u ON u.email = c.email + WHERE c.bug = '.(int)$id.' + GROUP BY c.id ORDER BY c.ts'; +} $res =& $dbh->query($query); if ($res) { while ($row =& $res->fetchRow(DB_FETCHMODE_ASSOC)) { - output_note($row['id'], $row['added'], $row['email'], $row['comment'], $row['showemail'], $row['handle'], $row['comment_name']); + output_note($row['id'], $row['added'], $row['email'], $row['comment'], $row['showemail'], $row['handle'], $row['comment_name'], $row['reigstered']); } } response_footer(); -function output_note($com_id, $ts, $email, $comment, $showemail = 1, $handle = NULL, $comment_name = NULL) +function output_note($com_id, $ts, $email, $comment, $showemail = 1, $handle = NULL, $comment_name = NULL, $registered) { global $edit, $id, $trusted_developers, $user, $dbh; echo '<div class="comment">'; echo "<strong>[",format_date($ts),"] "; + if (!$registered) { + echo 'User who submitted this comment has not confirmed identity</strong>'; + echo '<pre class="note">If you submitted this note, check your email.'; + echo ' If you do not have a message, write a mail to pear-dev@lists.php.net'; + echo ' asking for manual approval</pre></div>'; + return; + } if ($showemail == '0' && !is_null($handle)) { echo $handle."</strong>\n"; } else { http://cvs.php.net/viewvc.cgi/pearweb/public_html/bugs/report.php?r1=1.68&r2=1.69&diff_format=u Index: pearweb/public_html/bugs/report.php diff -u pearweb/public_html/bugs/report.php:1.68 pearweb/public_html/bugs/report.php:1.69 --- pearweb/public_html/bugs/report.php:1.68 Fri Feb 9 06:43:11 2007 +++ pearweb/public_html/bugs/report.php Sun Feb 25 22:44:26 2007 @@ -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.68 2007/02/09 06:43:11 cellog Exp $ + * @version $Id: report.php,v 1.69 2007/02/25 22:44:26 cellog Exp $ */ /** @@ -51,6 +51,15 @@ } if (isset($_POST['in'])) { + if (isset($_POST['PEAR_PW'])) { + $_POST['in']['PEAR_PW'] = $_POST['PEAR_PW']; + } + if (isset($_POST['PEAR_PW2'])) { + $_POST['in']['PEAR_PW2'] = $_POST['PEAR_PW2']; + } + if (isset($_POST['PEAR_USER'])) { + $_POST['in']['PEAR_USER'] = $_POST['PEAR_USER']; + } $errors = incoming_details_are_valid($_POST['in'], 1, ($auth_user && $auth_user->registered)); // captcha is not necessary if the user is logged in @@ -71,6 +80,25 @@ } } + // try to verify the user + if (!$auth_user) { + if (!empty($_POST['isMD5'])) { + $password = @$_POST['PEAR_PW']; + } else { + $password = md5(@$_POST['PEAR_PW']); + } + if (user::exists($_POST['in']['PEAR_USER'])) { + if (auth_verify($_POST['in']['PEAR_USER'], $password)) { + $POST['in']['handle'] = $_POST['in']['PEAR_USER']; + } else { + $errors[] = 'User name "' . clean($_POST['in']['PEAR_USER']) . + '" already exists, please choose another user name'; + } + } + } else { + $_POST['in']['handle'] = $auth_user->handle; + } + if (!$errors) { /* @@ -179,132 +207,177 @@ $ok_to_submit_report = true; } - if ($ok_to_submit_report) { - // Put all text areas together. - $fdesc = "Description:\n------------\n" . $_POST['in']['ldesc'] . "\n\n"; - if (!empty($_POST['in']['repcode'])) { - $fdesc .= "Test script:\n---------------\n"; - $fdesc .= $_POST['in']['repcode'] . "\n\n"; - } - if (!empty($_POST['in']['expres']) || - $_POST['in']['expres'] === '0') - { - $fdesc .= "Expected result:\n----------------\n"; - $fdesc .= $_POST['in']['expres'] . "\n\n"; - } - if (!empty($_POST['in']['actres']) || - $_POST['in']['actres'] === '0') - { - $fdesc .= "Actual result:\n--------------\n"; - $fdesc .= $_POST['in']['actres'] . "\n"; - } - - $reporter_name = isset($_POST['in']['reporter_name']) ? htmlspecialchars(strip_tags($_POST['in']['reporter_name'])) : ''; - - $query = 'INSERT INTO bugdb (' . - ' package_name,' . - ' bug_type,' . - ' email,' . - ' sdesc,' . - ' ldesc,' . - ' package_version,' . - ' php_version,' . - ' php_os,' . - ' status, ts1,' . - ' passwd,' . - ' reporter_name' . - ') VALUES (' . - " '" . escapeSQL($_POST['in']['package_name']) . "'," . - " '" . escapeSQL($_POST['in']['bug_type']) . "'," . - " '" . escapeSQL($_POST['in']['email']) . "'," . - " '" . escapeSQL($_POST['in']['sdesc']) . "'," . - " '" . escapeSQL($fdesc) . "'," . - " '" . escapeSQL($_POST['in']['package_version']) . "'," . - " '" . escapeSQL($_POST['in']['php_version']) . "'," . - " '" . escapeSQL($_POST['in']['php_os']) . "'," . - " 'Open', NOW(), " . - " '" . escapeSQL($_POST['in']['passwd']) . "'," . - " '" . escapeSQL($reporter_name) . "')"; - - - $dbh->query($query); - -/* - * Need to move the insert ID determination to DB eventually... - */ - if ($dbh->phptype == 'mysql') { - $cid = mysql_insert_id(); - } else { - $cid = mysqli_insert_id($dbh->connection); - } - - $report = ''; - $report .= 'From: ' . spam_protect(rinse($_POST['in']['email']), - 'text') . "\n"; - $report .= 'Operating system: ' . rinse($_POST['in']['php_os']) . "\n"; - $report .= 'Package version: ' . rinse($_POST['in']['package_version']) . "\n"; - $report .= 'PHP version: ' . rinse($_POST['in']['php_version']) . "\n"; - $report .= 'Package: ' . $_POST['in']['package_name'] . "\n"; - $report .= 'Bug Type: ' . $_POST['in']['bug_type'] . "\n"; - $report .= 'Bug description: '; - - $fdesc = rinse($fdesc); - $sdesc = rinse($_POST['in']['sdesc']); - - $ascii_report = "$report$sdesc\n\n" . wordwrap($fdesc); - $ascii_report .= "\n-- \nEdit bug report at "; - $ascii_report .= "http://$site.php.net/bugs/bug.php?id=$cid&edit="; - - list($mailto, $mailfrom) = get_package_mail($_POST['in']['package_name']); - - $email = rinse($_POST['in']['email']); - $protected_email = '"' . spam_protect($email, 'text') . '"'; - $protected_email .= '<' . $mailfrom . '>'; - - // provide shortcut URLS for "quick bug fixes" - // $dev_extra = ''; - // $maxkeysize = 0; - // foreach ($RESOLVE_REASONS as $v) { - // if (!$v['webonly']) { - // $actkeysize = strlen($v['desc']) + 1; - // $maxkeysize = (($maxkeysize < $actkeysize) ? $actkeysize : $maxkeysize); - // } - // } - // foreach ($RESOLVE_REASONS as $k => $v) { - // if (!$v['webonly']) - // $dev_extra .= str_pad($v['desc'] . ":", $maxkeysize) . - // " http://bugs.php.net/fix.php?id=$cid&r=$k\n"; - // } - - $extra_headers = 'From: ' . $protected_email . "\n"; - $extra_headers .= 'X-PHP-BugTracker: PEARbug' . "\n"; - $extra_headers .= 'X-PHP-Bug: ' . $cid . "\n"; - $extra_headers .= 'X-PHP-Type: ' . rinse($_POST['in']['bug_type']) . "\n"; - $extra_headers .= 'X-PHP-PackageVersion: ' . rinse($_POST['in']['package_version']) . "\n"; - $extra_headers .= 'X-PHP-Version: ' . rinse($_POST['in']['php_version']) . "\n"; - $extra_headers .= 'X-PHP-Category: ' . rinse($_POST['in']['package_name']) . "\n"; - $extra_headers .= 'X-PHP-OS: ' . rinse($_POST['in']['php_os']) . "\n"; - $extra_headers .= 'X-PHP-Status: Open' . "\n"; - $extra_headers .= 'Message-ID: <bug-' . $cid . '@'.$site.'.php.net>'; - - $type = @$types[$_POST['in']['bug_type']]; - - if (DEVBOX == false) { - // mail to package developers - @mail($mailto, "[$siteBig-BUG] $type #$cid [NEW]: $sdesc", - $ascii_report . "1\n-- \n$dev_extra", $extra_headers, - '-f bounce-no-user@php.net'); - // mail to reporter - @mail($email, "[$siteBig-BUG] $type #$cid: $sdesc", - $ascii_report . "2\n", - "From: $siteBig Bug Database <$mailfrom>\n" . - "X-PHP-Bug: $cid\n" . - "Message-ID: <bug-$cid@$site.php.net>", - '-f bounce-no-user@php.net'); + do { + if ($ok_to_submit_report) { + if (!$auth_user) { + // user doesn't exist yet + require 'bugs/pear-bug-accountrequest.php'; + $buggie = new PEAR_Bug_Accountrequest; + if (empty($_POST['isMD5'])) { + $_POST['PEAR_PW'] = md5($_POST['PEAR_PW']); + $_POST['PEAR_PW2'] = md5($_POST['PEAR_PW2']); + } + $salt = $buggie->addRequest($_POST['PEAR_USER'], + $_POST['in']['email'], $_POST['in']['reporter_name'], + $_POST['PEAR_PW'], $_POST['PEAR_PW2']); + if (is_array($salt)) { + $errors = $salt; + response_header('Report - Problems'); + break; // skip bug addition + } + if (PEAR::isError($salt)) { + $errors[] = $salt; + response_header('Report - Problems'); + break; + } + if ($salt === false) { + $errors[] = 'Your account cannot be added to the queue.' + . ' Please write a mail message to the ' + . ' <i>pear-dev</i> mailing list.'; + response_header('Report - Problems'); + break; + } + + $_POST['in']['handle'] = $_POST['PEAR_USER']; + $mailData = array( + 'username' => $_POST['in']['handle'], + 'salt' => $salt, + ); + + if (!DEVBOX) { + $mailer = Damblan_Mailer::create('pearweb_account_request_bug', $mailData); + $additionalHeaders['To'] = $_POST['in']['email']; + $mailer->send($additionalHeaders); + } + } + // Put all text areas together. + $fdesc = "Description:\n------------\n" . $_POST['in']['ldesc'] . "\n\n"; + if (!empty($_POST['in']['repcode'])) { + $fdesc .= "Test script:\n---------------\n"; + $fdesc .= $_POST['in']['repcode'] . "\n\n"; + } + if (!empty($_POST['in']['expres']) || + $_POST['in']['expres'] === '0') + { + $fdesc .= "Expected result:\n----------------\n"; + $fdesc .= $_POST['in']['expres'] . "\n\n"; + } + if (!empty($_POST['in']['actres']) || + $_POST['in']['actres'] === '0') + { + $fdesc .= "Actual result:\n--------------\n"; + $fdesc .= $_POST['in']['actres'] . "\n"; + } + + $reporter_name = isset($_POST['in']['reporter_name']) ? htmlspecialchars(strip_tags($_POST['in']['reporter_name'])) : ''; + + + $query = 'INSERT INTO bugdb ( + package_name, + bug_type, + email, + handle, + sdesc, + ldesc, + package_version, + php_version, + php_os, + status, ts1, + passwd, + reporter_name + ) VALUES (' . + " '" . escapeSQL($_POST['in']['package_name']) . "'," . + " '" . escapeSQL($_POST['in']['bug_type']) . "'," . + " '" . escapeSQL($_POST['in']['email']) . "'," . + " '" . escapeSQL($_POST['in']['handle']) . "'," . + " '" . escapeSQL($_POST['in']['sdesc']) . "'," . + " '" . escapeSQL($fdesc) . "'," . + " '" . escapeSQL($_POST['in']['package_version']) . "'," . + " '" . escapeSQL($_POST['in']['php_version']) . "'," . + " '" . escapeSQL($_POST['in']['php_os']) . "'," . + " 'Open', NOW(), " . + " '" . escapeSQL($_POST['in']['passwd']) . "'," . + " '" . escapeSQL($reporter_name) . "')"; + + + $dbh->query($query); + + /* + * Need to move the insert ID determination to DB eventually... + */ + if ($dbh->phptype == 'mysql') { + $cid = mysql_insert_id(); + } else { + $cid = mysqli_insert_id($dbh->connection); + } + + $report = ''; + $report .= 'From: ' . $_POST['in']['handle'] . "\n"; + $report .= 'Operating system: ' . rinse($_POST['in']['php_os']) . "\n"; + $report .= 'Package version: ' . rinse($_POST['in']['package_version']) . "\n"; + $report .= 'PHP version: ' . rinse($_POST['in']['php_version']) . "\n"; + $report .= 'Package: ' . $_POST['in']['package_name'] . "\n"; + $report .= 'Bug Type: ' . $_POST['in']['bug_type'] . "\n"; + $report .= 'Bug description: '; + + $fdesc = rinse($fdesc); + $sdesc = rinse($_POST['in']['sdesc']); + + $ascii_report = "$report$sdesc\n\n" . wordwrap($fdesc); + $ascii_report .= "\n-- \nEdit bug report at "; + $ascii_report .= "http://$site.php.net/bugs/bug.php?id=$cid&edit="; + + list($mailto, $mailfrom) = get_package_mail($_POST['in']['package_name']); + + $email = rinse($_POST['in']['email']); + $protected_email = '"' . spam_protect($email, 'text') . '"'; + $protected_email .= '<' . $mailfrom . '>'; + + // provide shortcut URLS for "quick bug fixes" + // $dev_extra = ''; + // $maxkeysize = 0; + // foreach ($RESOLVE_REASONS as $v) { + // if (!$v['webonly']) { + // $actkeysize = strlen($v['desc']) + 1; + // $maxkeysize = (($maxkeysize < $actkeysize) ? $actkeysize : $maxkeysize); + // } + // } + // foreach ($RESOLVE_REASONS as $k => $v) { + // if (!$v['webonly']) + // $dev_extra .= str_pad($v['desc'] . ":", $maxkeysize) . + // " http://bugs.php.net/fix.php?id=$cid&r=$k\n"; + // } + + $extra_headers = 'From: ' . $protected_email . "\n"; + $extra_headers .= 'X-PHP-BugTracker: PEARbug' . "\n"; + $extra_headers .= 'X-PHP-Bug: ' . $cid . "\n"; + $extra_headers .= 'X-PHP-Type: ' . rinse($_POST['in']['bug_type']) . "\n"; + $extra_headers .= 'X-PHP-PackageVersion: ' . rinse($_POST['in']['package_version']) . "\n"; + $extra_headers .= 'X-PHP-Version: ' . rinse($_POST['in']['php_version']) . "\n"; + $extra_headers .= 'X-PHP-Category: ' . rinse($_POST['in']['package_name']) . "\n"; + $extra_headers .= 'X-PHP-OS: ' . rinse($_POST['in']['php_os']) . "\n"; + $extra_headers .= 'X-PHP-Status: Open' . "\n"; + $extra_headers .= 'Message-ID: <bug-' . $cid . '@'.$site.'.php.net>'; + + $type = @$types[$_POST['in']['bug_type']]; + + if (DEVBOX == false) { + // mail to package developers + @mail($mailto, "[$siteBig-BUG] $type #$cid [NEW]: $sdesc", + $ascii_report . "1\n-- \n$dev_extra", $extra_headers, + '-f bounce-no-user@php.net'); + // mail to reporter + @mail($email, "[$siteBig-BUG] $type #$cid: $sdesc", + $ascii_report . "2\n", + "From: $siteBig Bug Database <$mailfrom>\n" . + "X-PHP-Bug: $cid\n" . + "Message-ID: <bug-$cid@$site.php.net>", + '-f bounce-no-user@php.net'); + } + localRedirect('bug.php?id=' . $cid . '&thanks=4'); + exit; } - localRedirect('bug.php?id=' . $cid . '&thanks=4'); - exit; - } + } while (false); } else { // had errors... response_header('Report - Problems'); @@ -357,9 +430,51 @@ ?> -<form method="post" - action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']) . '?package=' - . clean($_REQUEST['package']); ?>"> +<?php +$self = htmlspecialchars($_SERVER['PHP_SELF']); +$action = $self . '?package=' . clean($_REQUEST['package']); +if (!$auth_user && DEVBOX == false) { + $action = "https://" . $_SERVER['SERVER_NAME'] . '/' . $action; +} +?> +<form<?php +if (!$auth_user) { + echo ' onsubmit="javascript:doMD5(document.forms[\'bugreport\'])" ' ; +} ?>method="post" + action="<?php echo $action ?>" name="bugreport" id="bugreport"> +<?php if (!$auth_user): ?> + <div class="explain"> + Please choose a username/password or <a href="<?php echo '/login.php?redirect=' . + urlencode("{$self}?{$_SERVER['QUERY_STRING']}") ?>">Log in</a> +<script type="text/javascript" src="/javascript/md5.js"></script> +<script type="text/javascript"> +function doMD5(frm) { + frm.PEAR_PW.value = hex_md5(frm.PEAR_PW.value); + frm.PEAR_PW2.value = hex_md5(frm.PEAR_PW2.value); + frm.isMD5.value = 1; +} +</script> +<input type="hidden" name="isMD5" value="0" /> +<table class="form-holder" cellspacing="1"> + <tr> + <th class="form-label_left"> +Use<span class="accesskey">r</span>name:</th> + <td class="form-input"> +<input size="20" name="PEAR_USER" accesskey="r" /></td> + </tr> + <tr> + <th class="form-label_left">Password:</th> + <td class="form-input"> +<input size="20" name="PEAR_PW" type="password" /></td> + </tr> + <tr> + <th class="form-label_left">Confirm Password:</th> + <td class="form-input"> +<input size="20" name="PEAR_PW2" type="password" /></td> + </tr> +</table> +</div> +<?php endif; //if (!$auth_user) ?> <table class="form-holder" cellspacing="1"> <tr> <th class="form-label_left"> @@ -491,28 +606,6 @@ value="<?php echo clean($_POST['in']['sdesc']); ?>" /> </td> </tr> -<?php -if (!($auth_user && $auth_user->registered)) { -?> - <tr> - <th class="form-label_left"> - Password: - </th> - <td class="form-input"> - - <input type="password" size="20" maxlength="20" name="in[passwd]" - value="<?php echo clean($_POST['in']['passwd']); ?>" /> - - <p class="cell_note"> - You may enter any password here, which will be stored for this bug report. - This password allows you to come back and modify your submitted bug report - at a later date. - </p> - </td> - </tr> -<?php -} -?> <tr> <th class="form-label_left"> Note: http://cvs.php.net/viewvc.cgi/pearweb/public_html/bugs/include/functions.inc?r1=1.127&r2=1.128&diff_format=u Index: pearweb/public_html/bugs/include/functions.inc diff -u pearweb/public_html/bugs/include/functions.inc:1.127 pearweb/public_html/bugs/include/functions.inc:1.128 --- pearweb/public_html/bugs/include/functions.inc:1.127 Sat Feb 24 00:49:12 2007 +++ pearweb/public_html/bugs/include/functions.inc Sun Feb 25 22:44:26 2007 @@ -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.127 2007/02/24 00:49:12 cellog Exp $ + * @version $Id: functions.inc,v 1.128 2007/02/25 22:44:26 cellog Exp $ */ @@ -897,7 +897,7 @@ $max_comments = 5; $output = ""; $count = 0; - $res =& $dbh->query("SELECT ts, email, comment FROM bugdb_comments WHERE bug=$bug_id ORDER BY ts DESC"); + $res =& $dbh->query("SELECT ts, email, comment, handle FROM bugdb_comments WHERE bug=$bug_id ORDER BY ts DESC"); # skip the most recent unless the caller wanted all comments if (!$all) { @@ -908,11 +908,14 @@ } while (($row =& $res->fetchRow(DB_FETCHMODE_ORDERED)) && strlen($output) < $max_message_length && $count++ < $max_comments) { - $output .= "[$row[0]] ". spam_protect($row[1], 'text') ."\n\n$row[2]\n\n$divider\n\n"; + $email = $row[3] ? + $row[3] : + spam_protect($row[1], 'text'); + $output .= "[$row[0]] $email\n\n$row[2]\n\n$divider\n\n"; } if (strlen($output) < $max_message_length && $count < $max_comments) { - $res =& $dbh->query("SELECT ts1,email,ldesc FROM bugdb WHERE id=$bug_id"); + $res =& $dbh->query("SELECT ts1,email,ldesc,handle FROM bugdb WHERE id=$bug_id"); if (!$res) { return $output; } @@ -920,7 +923,10 @@ if (!$row) { return $output; } - return ("\n\nPrevious Comments:\n$divider\n\n" . $output . "[$row[0]] ". spam_protect($row[1], 'text') ."\n\n$row[2]\n\n$divider\n\n"); + $email = $row[3] ? + $row[3] : + spam_protect($row[1], 'text'); + return ("\n\nPrevious Comments:\n$divider\n\n" . $output . "[$row[0]] $email\n\n$row[2]\n\n$divider\n\n"); } else { return ("\n\nPrevious Comments:\n$divider\n\n" . $output . "The remainder of the comments for this report are too long. To view\nthe rest of the comments, please view the bug report online at\n http://$site.php.net/bugs/bug.php?id=$bug_id\n"); } @@ -974,7 +980,7 @@ */ function incoming_details_are_valid($in, $initial = 0, $logged = false) { - global $bug, $dbh, $types; + global $bug, $dbh, $types, $auth_user; $errors = array(); if (empty ($in['package_name']) || $in['package_name'] == 'none') { @@ -983,12 +989,31 @@ $errors[] = 'Please select an appropriate bug type.'; } - if ($initial || (!empty($in[email]) && $bug[email] != $in[email])) { + if ($initial || (!empty($in['email']) && $bug['email'] != $in['email'])) { if (!preg_match("/[.\\w+-]+@[.\\w-]+\\.\\w{2,}/i",$in['email'])) { $errors[] = 'Please provide a valid email address.'; } } + if (!$auth_user) { + if (empty($in['PEAR_USER'])) { + $errors[] = 'Please type a username'; + } elseif (!preg_match(PEAR_COMMON_USER_NAME_REGEX, $in['PEAR_USER'])) { + $errors[] = 'Username must start with a letter and contain' + . ' only letters and digits'; + } + + if (empty($in['PEAR_PW'])) { + $errors[] = 'Please type a password'; + } + if (empty($in['PEAR_PW2'])) { + $errors[] = 'Please confirm your password'; + } + if ($in['PEAR_PW'] !== $in['PEAR_PW2']) { + $errors[] = 'Passwords do not match'; + } + } + if (isset($in['php_version']) && $in['php_version'] == 'earlier') { $errors[] = 'Please select a valid PHP version. If your PHP version is too old, please upgrade first and see if the problem has not already been fixed.'; } @@ -1012,9 +1037,6 @@ if ($initial && empty($in['ldesc'])) { $errors[] = 'You must supply a long description of the bug you are reporting.'; } - if (!$logged && $initial && empty($in['passwd'])) { - $errors[] = 'You must supply a password for this bug report.'; - } return $errors; } @@ -1036,7 +1058,9 @@ case 'Bug System': case 'PEPr': case 'Web Site': - return array(PEAR_WEBMASTER_EMAIL, PEAR_WEBMASTER_EMAIL); + $arr = get_package_mail('pearweb'); + $arr[0][] = PEAR_WEBMASTER_EMAIL; + return array($arr[0], PEAR_WEBMASTER_EMAIL); case 'Documentation': return array(PEAR_DOC_EMAIL, PEAR_DOC_EMAIL); } http://cvs.php.net/viewvc.cgi/pearweb/sql/bugs.sql?r1=1.14&r2=1.15&diff_format=u Index: pearweb/sql/bugs.sql diff -u pearweb/sql/bugs.sql:1.14 pearweb/sql/bugs.sql:1.15 --- pearweb/sql/bugs.sql:1.14 Sun Feb 25 19:14:12 2007 +++ pearweb/sql/bugs.sql Sun Feb 25 22:44:26 2007 @@ -6,6 +6,7 @@ id int(8) NOT NULL auto_increment, package_name varchar(80) default NULL, bug_type varchar(32) NOT NULL default 'Bug', + handle varchar(20) NOT NULL default '', email varchar(40) NOT NULL default '', reporter_name varchar(80) default '', sdesc varchar(80) NOT NULL default '', @@ -31,6 +32,7 @@ id int(8) NOT NULL auto_increment, bug int(8) NOT NULL default '0', email varchar(40) NOT NULL default '', + handle varchar(20) NOT NULL default '', reporter_name varchar(80) default '', ts datetime NOT NULL default '0000-00-00 00:00:00', comment text NOT NULL, @@ -83,4 +85,13 @@ revision int(8) NOT NULL, developer varchar(20) NOT NULL, PRIMARY KEY (bugdb_id, patch, revision) -); \ No newline at end of file +); + +CREATE TABLE bug_account_request ( + id INT NOT NULL AUTO_INCREMENT, + created_on DATE NOT NULL, + handle VARCHAR(20) NOT NULL, + salt CHAR(32) NOT NULL, + email VARCHAR(65) NOT NULL, + PRIMARY KEY(id) +); http://cvs.php.net/viewvc.cgi/pearweb/sql/pearweb_mdb2schema.xml?r1=1.22&r2=1.23&diff_format=u Index: pearweb/sql/pearweb_mdb2schema.xml diff -u pearweb/sql/pearweb_mdb2schema.xml:1.22 pearweb/sql/pearweb_mdb2schema.xml:1.23 --- pearweb/sql/pearweb_mdb2schema.xml:1.22 Sun Feb 25 19:14:12 2007 +++ pearweb/sql/pearweb_mdb2schema.xml Sun Feb 25 22:44:26 2007 @@ -128,6 +128,14 @@ </field> <field> + <name>handle</name> + <type>text</type> + <length>20</length> + <notnull>true</notnull> + <default></default> + </field> + + <field> <name>reporter_name</name> <type>text</type> <length>80</length> @@ -289,6 +297,14 @@ </field> <field> + <name>handle</name> + <type>text</type> + <length>20</length> + <notnull>true</notnull> + <default></default> + </field> + + <field> <name>email</name> <type>text</type> <length>40</length> @@ -3096,5 +3112,58 @@ </declaration> </table> + <table> + + <name>bug_account_request</name> + + <declaration> + + <field> + <name>id</name> + <type>integer</type> + <length>11</length> + <notnull>true</notnull> + <autoincrement>true</autoincrement> + </field> + + <field> + <name>created_on</name> + <type>date</type> + <notnull>true</notnull> + </field> + + <field> + <name>handle</name> + <type>text</type> + <length>20</length> + <notnull>true</notnull> + </field> + + <field> + <name>salt</name> + <type>text</type> + <length>32</length> + <notnull>true</notnull> + </field> + + <field> + <name>email</name> + <type>text</type> + <length>65</length> + <notnull>true</notnull> + </field> + + <index> + <name>primary</name> + <primary>true</primary> + <field> + <name>id</name> + <sorting>ascending</sorting> + </field> + </index> + + </declaration> + + </table> </database> http://cvs.php.net/viewvc.cgi/pearweb/include/Damblan/Mail/pearweb_account_request_bug.tpl.php?view=markup&rev=1.1 Index: pearweb/include/Damblan/Mail/pearweb_account_request_bug.tpl.php +++ pearweb/include/Damblan/Mail/pearweb_account_request_bug.tpl.php <?php /** * Used variables in this template: * * %username% username of the requested account * %salt% salt for confirmation */ $tpl = array( 'Reply-To' => array('PEAR Webmaster <' . PEAR_WEBMASTER_EMAIL . '>'), 'Subject' => '[PEAR-ACCOUNT-REQUEST] Your bug tracker account request : %username%', 'Body' => 'You have requested an account to open bugs or comment on existing bugs. This account is only for use with the bug tracker, but can be updated to allow voting in general elections or other privileges later. To confirm please follow the link http://' . PEAR_CHANNELNAME . '/account-request-confirm.php?salt=%salt%&type=bug If you have received this email by mistake we apologize for any inconvenience. You do not need to reply to this email. PEAR Quality Assurance.'); ?> http://cvs.php.net/viewvc.cgi/pearweb/include/bugs/pear-bug-accountrequest.php?view=markup&rev=1.1 Index: pearweb/include/bugs/pear-bug-accountrequest.php +++ pearweb/include/bugs/pear-bug-accountrequest.php <?php class PEAR_Bug_Accountrequest { var $dbh; var $id; var $created_on; var $handle; var $salt; var $email; function PEAR_Bug_Accountrequest() { $this->dbh = &$GLOBALS['dbh']; $this->user = isset($GLOBALS['auth_user']) ? $GLOBALS['auth_user']->handle : false; $this->cleanOldRequests(); } function _makeSalt($handle) { list($usec, $sec) = explode(" ", microtime()); return md5($handle . ((float)$usec + (float)$sec)); } function find($salt) { $request = $this->dbh->getRow(' SELECT id, created_on, salt, handle FROM bug_account_request WHERE salt=? ', array($salt), DB_FETCHMODE_ASSOC); if (count($request) > 0) { foreach ($request as $field => $value) { $this->$field = $value; } return true; } return false; } /** * Adds a request in the DB * * @return string salt */ function addRequest($handle, $email, $name, $password, $password2) { if ($handle == $this->dbh->getOne('SELECT handle FROM users WHERE handle=?', array($handle))) { $id = $this->dbh->nextId("karma"); $query = "INSERT INTO karma VALUES (?, ?, ?, ?, NOW())"; $sth = $this->dbh->query($query, array($id, $this->handle, 'pear.bug', 'pearweb')); return true; } list($firstname, $lastname) = explode(' ', $name, 2); $data = array( 'handle' => $handle, 'firstname' => $firstname, 'lastname' => $lastname, 'email' => $email, 'purpose' => 'bug tracker', 'password' => $password, 'password2' => $password2, ); $useradd = user::add($data); if (is_array($useradd)) { return $useradd; } $salt = $this->_makeSalt($handle); $created_on = gmdate('Y-m-d H:i:s'); $query = ' insert into bug_account_request (created_on, handle, email, salt) values (?, ?, ?, ?)'; $res = $this->dbh->query($query, array($created_on, $handle, $email, $salt)); if (DB::isError($res)) { return $res; } //$this->find($salt); //$this->sendRequest(); return $salt; } function deleteRequest() { $query = 'delete from bug_account_request where salt=?'; return $this->dbh->query($query, array($this->salt)); } function confirmRequest($salt) { if (!$this->find($salt)) { return PEAR::raiseError('cannot find request'); } // activate the handle and grant karma // implicitly without human intervention // copied from the user class and Damblan_Karma $user =& new PEAR_User($this->dbh, $this->handle); if (@$user->registered) { return false; } @$arr = unserialize($user->userinfo); note::removeAll("uid", $this->handle); $user->set('registered', 1); if (is_array($arr)) { $user->set('userinfo', $arr[1]); } $user->set('created', gmdate('Y-m-d H:i')); $user->set('createdby', 'pearweb'); $user->store(); $id = $this->dbh->nextId("karma"); $query = "INSERT INTO karma VALUES (?, ?, ?, ?, NOW())"; $sth = $this->dbh->query($query, array($id, $this->handle, 'pear.bug', 'pearweb')); if (!DB::isError($sth)) { note::add("uid", $this->handle, "Account opened", 'pearweb'); $msg = "Your PEAR bug tracker account has been opened.\n" . "Bugs you have opened will now be displayed, and you can\n" . "add new comments to existing bugs"; $xhdr = "From: pear-webmaster@lists.php.net"; mail($user->email, "Your PEAR Bug Tracker Account Request", $msg, $xhdr, "-f bounce-no-user@php.net"); $this->deleteRequest(); return true; } return false; } function listRequests() { } function cleanOldRequests() { $old = gmdate('Y-m-d H:i:s', time() - 90000); $findquery = ' select handle from bug_account_request where created_on < ?'; $all = $this->dbh->getAll($findquery, array($old)); // purge reserved usernames as well as their account requests if (is_array($all)) { foreach ($all as $data) { $this->dbh->query(' DELETE FROM users WHERE handle=? ', array($data[0])); $this->dbh->query(' DELETE FROM bugdb WHERE handle=? ', array($data[0])); $this->dbh->query(' DELETE FROM bugdb_comments WHERE handle=? ', array($data[0])); } } $query = ' delete from bug_account_request where created_on < ?'; // purge out-of-date account requests return $this->dbh->query($query, array($old)); } } ?>
http://cvs.php.net/viewvc.cgi/pearweb/package.xml?r1=1.142&r2=1.143&diff_format=u Index: pearweb/package.xml diff -u pearweb/package.xml:1.142 pearweb/package.xml:1.143 --- pearweb/package.xml:1.142 Sun Feb 25 19:48:23 2007 +++ pearweb/package.xml Sun Feb 25 22:44:26 2007 @@ -93,6 +93,7 @@ <dir name="include"> <dir name="bugs"> <file name="pear-bugs.php" role="web" /> + <file name="pear-bug-accountrequest.php" role="web" /> <file name="pear.ini" role="web" /> <file name="pear.links.ini" role="web" /> </dir> <!-- /include/bugs --> http://cvs.php.net/viewvc.cgi/pearweb/include/DataObject/Bugdb.php?r1=1.1&r2=1.2&diff_format=u Index: pearweb/include/DataObject/Bugdb.php diff -u pearweb/include/DataObject/Bugdb.php:1.1 pearweb/include/DataObject/Bugdb.php:1.2 --- pearweb/include/DataObject/Bugdb.php:1.1 Sat Feb 17 23:22:37 2007 +++ pearweb/include/DataObject/Bugdb.php Sun Feb 25 22:44:26 2007 @@ -14,6 +14,7 @@ var $package_name; // string(80) not_null var $bug_type; // string(32) not_null var $email; // string(40) not_null + var $handle; // string(20) not_null var $sdesc; // string(80) not_null var $ldesc; // blob(65535) not_null blob var $package_version; // string(100) http://cvs.php.net/viewvc.cgi/pearweb/include/DataObject/Bugdb_comments.php?r1=1.1&r2=1.2&diff_format=u Index: pearweb/include/DataObject/Bugdb_comments.php diff -u pearweb/include/DataObject/Bugdb_comments.php:1.1 pearweb/include/DataObject/Bugdb_comments.php:1.2 --- pearweb/include/DataObject/Bugdb_comments.php:1.1 Sat Feb 17 23:22:37 2007 +++ pearweb/include/DataObject/Bugdb_comments.php Sun Feb 25 22:44:26 2007 @@ -13,6 +13,7 @@ var $id; // int(8) not_null primary_key var $bug; // int(8) not_null var $email; // string(40) not_null + var $handle; // string(20) not_null var $ts; // datetime(19) var $comment; // blob(65535) not_null blob http://cvs.php.net/viewvc.cgi/pearweb/include/bugs/pear.ini?r1=1.1&r2=1.2&diff_format=u Index: pearweb/include/bugs/pear.ini diff -u pearweb/include/bugs/pear.ini:1.1 pearweb/include/bugs/pear.ini:1.2 --- pearweb/include/bugs/pear.ini:1.1 Sat Feb 17 23:22:37 2007 +++ pearweb/include/bugs/pear.ini Sun Feb 25 22:44:26 2007 @@ -3,6 +3,7 @@ package_name = 130 bug_type = 130 email = 130 +handle = 130 sdesc = 130 ldesc = 194 package_version = 130 @@ -41,6 +42,7 @@ id = 129 bug = 129 email = 130 +handle = 130 ts = 142 comment = 194 reporter_name = 130 http://cvs.php.net/viewvc.cgi/pearweb/include/election/pear-election-accountrequest.php?r1=1.2&r2=1.3&diff_format=u Index: pearweb/include/election/pear-election-accountrequest.php diff -u pearweb/include/election/pear-election-accountrequest.php:1.2 pearweb/include/election/pear-election-accountrequest.php:1.3 --- pearweb/include/election/pear-election-accountrequest.php:1.2 Sun Dec 3 20:04:17 2006 +++ pearweb/include/election/pear-election-accountrequest.php Sun Feb 25 22:44:26 2007 @@ -146,6 +146,12 @@ $this->dbh->query(' DELETE FROM users WHERE handle=? ', array($data[0])); + $this->dbh->query(' + DELETE FROM bugdb WHERE handle=? + ', array($data[0])); + $this->dbh->query(' + DELETE FROM bugdb_comments WHERE handle=? + ', array($data[0])); } } $query = ' http://cvs.php.net/viewvc.cgi/pearweb/public_html/account-request-confirm.php?r1=1.1&r2=1.2&diff_format=u Index: pearweb/public_html/account-request-confirm.php diff -u pearweb/public_html/account-request-confirm.php:1.1 pearweb/public_html/account-request-confirm.php:1.2 --- pearweb/public_html/account-request-confirm.php:1.1 Sun Dec 3 06:14:48 2006 +++ pearweb/public_html/account-request-confirm.php Sun Feb 25 22:44:26 2007 @@ -1,5 +1,6 @@ <?php -require_once 'election/pear-election-accountrequest.php'; +require 'bugs/pear-bug-accountrequest.php'; +require 'election/pear-election-accountrequest.php'; $stripped = @array_map('strip_tags', $_GET); @@ -7,13 +8,24 @@ print '<h1>Confirm account</h1>'; -if (!empty($stripped['salt']) && strlen($salt = htmlspecialchars($stripped['salt'])) == 32) { - $request = new PEAR_Election_Accountrequest(); - $request->confirmRequest($salt); - report_success('Your account has been activated, you can now vote in -PEAR elections that are for the general PHP public'); +if (isset($_GET['type']) && $_GET['type'] == 'bug') { + if (!empty($stripped['salt']) && strlen($salt = htmlspecialchars($stripped['salt'])) == 32) { + $request = new PEAR_Bug_Accountrequest; + $request->confirmRequest($salt); + report_success('Your account has been activated, bugs you have opened and comments +you have made are now available to the public for viewing'); + } else { + report_error('Unknown salt'); + } } else { - report_error('Unknown salt'); + if (!empty($stripped['salt']) && strlen($salt = htmlspecialchars($stripped['salt'])) == 32) { + $request = new PEAR_Election_Accountrequest(); + $request->confirmRequest($salt); + report_success('Your account has been activated, you can now vote in + PEAR elections that are for the general PHP public'); + } else { + report_error('Unknown salt'); + } } response_footer(); ?> \ No newline at end of file http://cvs.php.net/viewvc.cgi/pearweb/public_html/bugs/bug.php?r1=1.115&r2=1.116&diff_format=u Index: pearweb/public_html/bugs/bug.php diff -u pearweb/public_html/bugs/bug.php:1.115 pearweb/public_html/bugs/bug.php:1.116 --- pearweb/public_html/bugs/bug.php:1.115 Sun Feb 25 19:14:11 2007 +++ pearweb/public_html/bugs/bug.php Sun Feb 25 22:44:26 2007 @@ -1,5 +1,5 @@ <?php /* vim: set noet ts=4 sw=4: : */ - +session_start(); /** * User interface for viewing and editing bug details * @@ -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: bug.php,v 1.115 2007/02/25 19:14:11 cellog Exp $ + * @version $Id: bug.php,v 1.116 2007/02/25 22:44:26 cellog Exp $ */ /* @@ -37,9 +37,19 @@ * Obtain a list of the trusted developers */ require_once './include/trusted-devs.inc'; + +/** + * Numeral Captcha Class + */ +require_once './include/NumeralCaptcha.php'; + +/** + * Instantiate the numeral captcha object. + */ +$numeralCaptcha = new NumeralCaptcha(); + Bug_DataObject::init(); -session_start(); error_reporting(E_ALL ^ E_NOTICE); @@ -70,6 +80,13 @@ $edit = (int)$_REQUEST['edit']; } +// captcha is not necessary if the user is logged in +if ($auth_user && $auth_user->registered) { + if (isset($_SESSION['answer'])) { + unset($_SESSION['answer']); + } +} + if ($auth_user && $auth_user->registered && isset($_GET['delete_comment'])) { $delete_comment = (int)$_GET['delete_comment']; } else { @@ -101,7 +118,7 @@ $pw = ''; } -// Subscribtion +// Subscription if (isset($_POST['subscribe_to_bug'])) { $email = $_POST['subscribe_email']; if (!preg_match("/[.\\w+-]+@[.\\w-]+\\.\\w{2,}/i", $email)) { @@ -119,9 +136,11 @@ $trytoforce = isset($_POST['trytoforce']) ? (int)$_POST['trytoforce'] : false; // fetch info about the bug into $bug -$query = 'SELECT b.id, b.package_name, b.bug_type, b.email, b.reporter_name, +if ($dbh->getOne('SELECT handle FROM bugdb WHERE id=?', array($id))) { + $query = 'SELECT b.id, b.package_name, b.bug_type, b.email, b.handle, b.reporter_name, b.passwd, b.sdesc, b.ldesc, b.php_version, b.package_version, b.php_os, b.status, b.ts1, b.ts2, b.assign, UNIX_TIMESTAMP(b.ts1) AS submitted, + users.registered, UNIX_TIMESTAMP(b.ts2) AS modified, COUNT(bug=b.id) AS votes, SUM(reproduced) AS reproduced,SUM(tried) AS tried, @@ -130,10 +149,28 @@ users.showemail, users.handle, p.package_type FROM bugdb b LEFT JOIN bugdb_votes ON b.id = bug + LEFT JOIN users ON users.handle = b.handle + LEFT JOIN packages p ON b.package_name = p.name + WHERE b.id = '.(int)$id.' + GROUP BY bug'; +} else { + $query = 'SELECT b.id, b.package_name, b.bug_type, b.email, b.handle, b.reporter_name, + b.passwd, b.sdesc, b.ldesc, b.php_version, b.package_version, b.php_os, + b.status, b.ts1, b.ts2, b.assign, UNIX_TIMESTAMP(b.ts1) AS submitted, + UNIX_TIMESTAMP(b.ts2) AS modified, + COUNT(bug=b.id) AS votes, + SUM(reproduced) AS reproduced,SUM(tried) AS tried, + SUM(sameos) AS sameos, SUM(samever) AS samever, + AVG(score)+3 AS average,STD(score) AS deviation, + users.showemail, users.handle, p.package_type, + 1 as registered + FROM bugdb b + LEFT JOIN bugdb_votes ON b.id = bug LEFT JOIN users ON users.email = b.email LEFT JOIN packages p ON b.package_name = p.name WHERE b.id = '.(int)$id.' GROUP BY bug'; +} $bug =& $dbh->getRow($query, array(), DB_FETCHMODE_ASSOC); @@ -165,6 +202,16 @@ exit(); } +// if the user is not registered, this might be spam, don't display +if (!$bug['registered']) { + response_header('User has not confirmed identity'); + display_bug_error('The user who submitted this bug has not yet confirmed ' . + 'their email address. If you submitted this bug, please check your email.' . + ' If you do not have a confirmation message, please write a message to' . + ' pear-dev@lists.php.net asking for manual approval of your account'); + response_footer(); + exit; +} // Delete comment if ($edit == 1 && isset($_GET['delete_comment'])) { $addon = ''; @@ -183,31 +230,34 @@ if ($_POST['in'] && !isset($_POST['preview']) && $edit == 3) { // Submission of additional comment by others - if (!validate_captcha()) { - $errors[] = 'Incorrect CAPTCHA'; - } - - $comment_name = isset($_POST['in']['comment_name']) ? htmlspecialchars(strip_tags($_POST['in']['comment_name'])) : ''; - - - if (!preg_match("/[.\\w+-]+@[.\\w-]+\\.\\w{2,}/i", $_POST['in']['commentemail'])) { - $errors[] = "You must provide a valid email address."; - } - - // Don't allow comments by the original report submitter - if (rinse($_POST['in']['commentemail']) == $bug['email']) { - localRedirect('bug.php' . "?id=$id&edit=2"); - exit(); + /** + * 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'; + } } - /* check that they aren't using a php.net mail address without - being authenticated (oh, the horror!) */ - if (preg_match('/^(.+)@php\.net/i', rinse($_POST['in']['commentemail']), $m)) { - if ($user != rinse($m[1]) || !verify_password($user, $pass)) { - $errors[] = 'You have to be logged in as a developer and be' - . ' editing the bug via the "Developer" tab in order' - . ' to use your php.net email address.'; + // try to verify the user + if (!$auth_user) { + if (!empty($_POST['isMD5'])) { + $password = @$_POST['PEAR_PW']; + } else { + $password = md5(@$_POST['PEAR_PW']); + } + if (user::exists($_POST['in']['PEAR_USER'])) { + if (auth_verify($_POST['in']['PEAR_USER'], $password)) { + $POST['in']['handle'] = $_POST['in']['PEAR_USER']; + } else { + $errors[] = 'User name "' . clean($_POST['in']['PEAR_USER']) . + '" already exists, please choose another user name'; + } } + } else { + $_POST['in']['handle'] = $auth_user->handle; } $ncomment = trim($_POST['ncomment']); @@ -216,15 +266,60 @@ } if (!$errors) { - $query = 'INSERT INTO bugdb_comments' . - ' (bug, email, ts, comment, reporter_name) VALUES (' . - " $id," . - " '" . escapeSQL($_POST['in']['commentemail']) . "'," . - ' NOW(),' . - " '" . escapeSQL($ncomment) . "'," . - " '" . escapeSQL($comment_name) . "')"; + do { + if (!$auth_user) { + // user doesn't exist yet + require 'bugs/pear-bug-accountrequest.php'; + $buggie = new PEAR_Bug_Accountrequest; + if (empty($_POST['isMD5'])) { + $_POST['PEAR_PW'] = md5($_POST['PEAR_PW']); + $_POST['PEAR_PW2'] = md5($_POST['PEAR_PW2']); + } + $salt = $buggie->addRequest($_POST['PEAR_USER'], + $_POST['in']['email'], $_POST['in']['reporter_name'], + $_POST['PEAR_PW'], $_POST['PEAR_PW2']); + if (is_array($salt)) { + $errors = $salt; + response_header('Report - Problems'); + break; // skip bug comment addition + } + if (PEAR::isError($salt)) { + $errors[] = $salt; + response_header('Report - Problems'); + break; + } + if ($salt === false) { + $errors[] = 'Your account cannot be added to the queue.' + . ' Please write a mail message to the ' + . ' <i>pear-dev</i> mailing list.'; + response_header('Report - Problems'); + break; + } - $dbh->query($query); + $_POST['in']['handle'] = $_POST['PEAR_USER']; + $mailData = array( + 'username' => $_POST['in']['handle'], + 'salt' => $salt, + ); + + if (!DEVBOX) { + $mailer = Damblan_Mailer::create('pearweb_account_request_bug', $mailData); + $additionalHeaders['To'] = $_POST['in']['email']; + $mailer->send($additionalHeaders); + } + } + + $query = 'INSERT INTO bugdb_comments' . + ' (bug, email, handle, ts, comment, reporter_name) VALUES (' . + " $id," . + " '" . escapeSQL($_POST['in']['commentemail']) . "', + '" . $_POST['in']['handle'] . "'," . + ' NOW(),' . + " '" . escapeSQL($ncomment) . "'," . + " '" . escapeSQL($comment_name) . "')"; + + $dbh->query($query); + } while (false); } $from = rinse($_POST['in']['commentemail']); } elseif ($_POST['in'] && isset($_POST['preview']) && $edit == 3) { @@ -545,7 +640,7 @@ if ($auth_user) { control(1, 'Developer'); } else { - control(2, 'Edit Submission'); + control(1, 'Edit Submission'); } ?> @@ -881,12 +976,47 @@ if ($edit == 3) { ?> - <div class="explain"> - If you're the original bug submitter, here's where you can edit the bug - or add additional notes. <a href="<?php - echo htmlspecialchars($_SERVER['PHP_SELF'])."?id=$id&edit=2" ?>">Edit my bug</a>. - </div> - <form id="comment" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']) ?>" method="post"> + <form<?php +$action = htmlspecialchars($_SERVER['PHP_SELF']); +if (!$auth_user && DEVBOX == false) { + $action = "https://" . $_SERVER['SERVER_NAME'] . '/' . $action; +} +if (!$auth_user) { + echo ' onsubmit="javascript:doMD5(document.forms[\'comment\'])" ' ; +} ?> name="comment" id="comment" action="<?php echo $action ?>" method="post"> +<?php if (!$auth_user): ?> + <div class="explain"> + Please choose a username/password or <a href="<?php echo '/login.php?redirect=' . + urlencode("{$self}?{$_SERVER['QUERY_STRING']}") ?>">Log in</a> +<script type="text/javascript" src="/javascript/md5.js"></script> +<script type="text/javascript"> +function doMD5(frm) { + frm.PEAR_PW.value = hex_md5(frm.PEAR_PW.value); + frm.PEAR_PW2.value = hex_md5(frm.PEAR_PW2.value); + frm.isMD5.value = 1; +} +</script> +<input type="hidden" name="isMD5" value="0" /> +<table class="form-holder" cellspacing="1"> + <tr> + <th class="form-label_left"> +Use<span class="accesskey">r</span>name:</th> + <td class="form-input"> +<input size="20" name="PEAR_USER" accesskey="r" /></td> + </tr> + <tr> + <th class="form-label_left">Password:</th> + <td class="form-input"> +<input size="20" name="PEAR_PW" type="password" /></td> + </tr> + <tr> + <th class="form-label_left">Confirm Password:</th> + <td class="form-input"> +<input size="20" name="PEAR_PW2" type="password" /></td> + </tr> +</table> +</div> +<?php endif; //if (!$auth_user) ?> <?php if (!$_POST['in']) { @@ -931,12 +1061,13 @@ <input type="hidden" name="edit" value="<?php echo $edit?>" /> </td> </tr> + <?php if (!$auth_user): ?> <tr> - <th class="details">CAPTCHA:</th> - <td> - <?php echo generate_captcha() ?> - </td> + <th>Solve the problem : <?php print $numeralCaptcha->getOperation(); ?> = ?</th> + <td class="form-input"><input type="text" name="captcha" /></td> </tr> + <?php $_SESSION['answer'] = $numeralCaptcha->getAnswer(); ?> + <?php endif; // if (!$auth_user): ?> </table> <div> @@ -1013,7 +1144,7 @@ // Display original report if ($bug['ldesc']) { - output_note(0, $bug['submitted'], $bug['email'], $bug['ldesc'], $bug['showemail'], $bug['handle'], $bug['reporter_name']); + output_note(0, $bug['submitted'], $bug['email'], $bug['ldesc'], $bug['showemail'], $bug['handle'], $bug['reporter_name'], 1); } // Display patches @@ -1031,28 +1162,44 @@ echo urlencode($name) ?>&revision=latest"><?php echo clean($name) ?></a> (last revision <?php echo date('Y-m-d H:i:s', $revisions[0][0]) ?> by <?php echo $revisions[0][1] ?>)<br /><?php } // Display comments -$query = 'SELECT c.id,c.email,c.comment,UNIX_TIMESTAMP(c.ts) AS added, c.reporter_name as comment_name, +if ($dbh->getOne('SELECT handle FROM bugdb WHERE id=?', array($id))) { + $query = 'SELECT c.id,c.email,c.comment,UNIX_TIMESTAMP(c.ts) AS added, c.reporter_name as comment_name, u.registered, u.showemail, u.handle FROM bugdb_comments c LEFT JOIN users u ON u.email = c.email WHERE c.bug = '.(int)$id.' GROUP BY c.id ORDER BY c.ts'; +} else { + $query = 'SELECT c.id,c.email,c.comment,UNIX_TIMESTAMP(c.ts) AS added, c.reporter_name as comment_name, 1 as registered, + u.showemail, u.handle + FROM bugdb_comments c + LEFT JOIN users u ON u.email = c.email + WHERE c.bug = '.(int)$id.' + GROUP BY c.id ORDER BY c.ts'; +} $res =& $dbh->query($query); if ($res) { while ($row =& $res->fetchRow(DB_FETCHMODE_ASSOC)) { - output_note($row['id'], $row['added'], $row['email'], $row['comment'], $row['showemail'], $row['handle'], $row['comment_name']); + output_note($row['id'], $row['added'], $row['email'], $row['comment'], $row['showemail'], $row['handle'], $row['comment_name'], $row['reigstered']); } } response_footer(); -function output_note($com_id, $ts, $email, $comment, $showemail = 1, $handle = NULL, $comment_name = NULL) +function output_note($com_id, $ts, $email, $comment, $showemail = 1, $handle = NULL, $comment_name = NULL, $registered) { global $edit, $id, $trusted_developers, $user, $dbh; echo '<div class="comment">'; echo "<strong>[",format_date($ts),"] "; + if (!$registered) { + echo 'User who submitted this comment has not confirmed identity</strong>'; + echo '<pre class="note">If you submitted this note, check your email.'; + echo ' If you do not have a message, write a mail to pear-dev@lists.php.net'; + echo ' asking for manual approval</pre></div>'; + return; + } if ($showemail == '0' && !is_null($handle)) { echo $handle."</strong>\n"; } else { http://cvs.php.net/viewvc.cgi/pearweb/public_html/bugs/report.php?r1=1.68&r2=1.69&diff_format=u Index: pearweb/public_html/bugs/report.php diff -u pearweb/public_html/bugs/report.php:1.68 pearweb/public_html/bugs/report.php:1.69 --- pearweb/public_html/bugs/report.php:1.68 Fri Feb 9 06:43:11 2007 +++ pearweb/public_html/bugs/report.php Sun Feb 25 22:44:26 2007 @@ -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.68 2007/02/09 06:43:11 cellog Exp $ + * @version $Id: report.php,v 1.69 2007/02/25 22:44:26 cellog Exp $ */ /** @@ -51,6 +51,15 @@ } if (isset($_POST['in'])) { + if (isset($_POST['PEAR_PW'])) { + $_POST['in']['PEAR_PW'] = $_POST['PEAR_PW']; + } + if (isset($_POST['PEAR_PW2'])) { + $_POST['in']['PEAR_PW2'] = $_POST['PEAR_PW2']; + } + if (isset($_POST['PEAR_USER'])) { + $_POST['in']['PEAR_USER'] = $_POST['PEAR_USER']; + } $errors = incoming_details_are_valid($_POST['in'], 1, ($auth_user && $auth_user->registered)); // captcha is not necessary if the user is logged in @@ -71,6 +80,25 @@ } } + // try to verify the user + if (!$auth_user) { + if (!empty($_POST['isMD5'])) { + $password = @$_POST['PEAR_PW']; + } else { + $password = md5(@$_POST['PEAR_PW']); + } + if (user::exists($_POST['in']['PEAR_USER'])) { + if (auth_verify($_POST['in']['PEAR_USER'], $password)) { + $POST['in']['handle'] = $_POST['in']['PEAR_USER']; + } else { + $errors[] = 'User name "' . clean($_POST['in']['PEAR_USER']) . + '" already exists, please choose another user name'; + } + } + } else { + $_POST['in']['handle'] = $auth_user->handle; + } + if (!$errors) { /* @@ -179,132 +207,177 @@ $ok_to_submit_report = true; } - if ($ok_to_submit_report) { - // Put all text areas together. - $fdesc = "Description:\n------------\n" . $_POST['in']['ldesc'] . "\n\n"; - if (!empty($_POST['in']['repcode'])) { - $fdesc .= "Test script:\n---------------\n"; - $fdesc .= $_POST['in']['repcode'] . "\n\n"; - } - if (!empty($_POST['in']['expres']) || - $_POST['in']['expres'] === '0') - { - $fdesc .= "Expected result:\n----------------\n"; - $fdesc .= $_POST['in']['expres'] . "\n\n"; - } - if (!empty($_POST['in']['actres']) || - $_POST['in']['actres'] === '0') - { - $fdesc .= "Actual result:\n--------------\n"; - $fdesc .= $_POST['in']['actres'] . "\n"; - } - - $reporter_name = isset($_POST['in']['reporter_name']) ? htmlspecialchars(strip_tags($_POST['in']['reporter_name'])) : ''; - - $query = 'INSERT INTO bugdb (' . - ' package_name,' . - ' bug_type,' . - ' email,' . - ' sdesc,' . - ' ldesc,' . - ' package_version,' . - ' php_version,' . - ' php_os,' . - ' status, ts1,' . - ' passwd,' . - ' reporter_name' . - ') VALUES (' . - " '" . escapeSQL($_POST['in']['package_name']) . "'," . - " '" . escapeSQL($_POST['in']['bug_type']) . "'," . - " '" . escapeSQL($_POST['in']['email']) . "'," . - " '" . escapeSQL($_POST['in']['sdesc']) . "'," . - " '" . escapeSQL($fdesc) . "'," . - " '" . escapeSQL($_POST['in']['package_version']) . "'," . - " '" . escapeSQL($_POST['in']['php_version']) . "'," . - " '" . escapeSQL($_POST['in']['php_os']) . "'," . - " 'Open', NOW(), " . - " '" . escapeSQL($_POST['in']['passwd']) . "'," . - " '" . escapeSQL($reporter_name) . "')"; - - - $dbh->query($query); - -/* - * Need to move the insert ID determination to DB eventually... - */ - if ($dbh->phptype == 'mysql') { - $cid = mysql_insert_id(); - } else { - $cid = mysqli_insert_id($dbh->connection); - } - - $report = ''; - $report .= 'From: ' . spam_protect(rinse($_POST['in']['email']), - 'text') . "\n"; - $report .= 'Operating system: ' . rinse($_POST['in']['php_os']) . "\n"; - $report .= 'Package version: ' . rinse($_POST['in']['package_version']) . "\n"; - $report .= 'PHP version: ' . rinse($_POST['in']['php_version']) . "\n"; - $report .= 'Package: ' . $_POST['in']['package_name'] . "\n"; - $report .= 'Bug Type: ' . $_POST['in']['bug_type'] . "\n"; - $report .= 'Bug description: '; - - $fdesc = rinse($fdesc); - $sdesc = rinse($_POST['in']['sdesc']); - - $ascii_report = "$report$sdesc\n\n" . wordwrap($fdesc); - $ascii_report .= "\n-- \nEdit bug report at "; - $ascii_report .= "http://$site.php.net/bugs/bug.php?id=$cid&edit="; - - list($mailto, $mailfrom) = get_package_mail($_POST['in']['package_name']); - - $email = rinse($_POST['in']['email']); - $protected_email = '"' . spam_protect($email, 'text') . '"'; - $protected_email .= '<' . $mailfrom . '>'; - - // provide shortcut URLS for "quick bug fixes" - // $dev_extra = ''; - // $maxkeysize = 0; - // foreach ($RESOLVE_REASONS as $v) { - // if (!$v['webonly']) { - // $actkeysize = strlen($v['desc']) + 1; - // $maxkeysize = (($maxkeysize < $actkeysize) ? $actkeysize : $maxkeysize); - // } - // } - // foreach ($RESOLVE_REASONS as $k => $v) { - // if (!$v['webonly']) - // $dev_extra .= str_pad($v['desc'] . ":", $maxkeysize) . - // " http://bugs.php.net/fix.php?id=$cid&r=$k\n"; - // } - - $extra_headers = 'From: ' . $protected_email . "\n"; - $extra_headers .= 'X-PHP-BugTracker: PEARbug' . "\n"; - $extra_headers .= 'X-PHP-Bug: ' . $cid . "\n"; - $extra_headers .= 'X-PHP-Type: ' . rinse($_POST['in']['bug_type']) . "\n"; - $extra_headers .= 'X-PHP-PackageVersion: ' . rinse($_POST['in']['package_version']) . "\n"; - $extra_headers .= 'X-PHP-Version: ' . rinse($_POST['in']['php_version']) . "\n"; - $extra_headers .= 'X-PHP-Category: ' . rinse($_POST['in']['package_name']) . "\n"; - $extra_headers .= 'X-PHP-OS: ' . rinse($_POST['in']['php_os']) . "\n"; - $extra_headers .= 'X-PHP-Status: Open' . "\n"; - $extra_headers .= 'Message-ID: <bug-' . $cid . '@'.$site.'.php.net>'; - - $type = @$types[$_POST['in']['bug_type']]; - - if (DEVBOX == false) { - // mail to package developers - @mail($mailto, "[$siteBig-BUG] $type #$cid [NEW]: $sdesc", - $ascii_report . "1\n-- \n$dev_extra", $extra_headers, - '-f bounce-no-user@php.net'); - // mail to reporter - @mail($email, "[$siteBig-BUG] $type #$cid: $sdesc", - $ascii_report . "2\n", - "From: $siteBig Bug Database <$mailfrom>\n" . - "X-PHP-Bug: $cid\n" . - "Message-ID: <bug-$cid@$site.php.net>", - '-f bounce-no-user@php.net'); + do { + if ($ok_to_submit_report) { + if (!$auth_user) { + // user doesn't exist yet + require 'bugs/pear-bug-accountrequest.php'; + $buggie = new PEAR_Bug_Accountrequest; + if (empty($_POST['isMD5'])) { + $_POST['PEAR_PW'] = md5($_POST['PEAR_PW']); + $_POST['PEAR_PW2'] = md5($_POST['PEAR_PW2']); + } + $salt = $buggie->addRequest($_POST['PEAR_USER'], + $_POST['in']['email'], $_POST['in']['reporter_name'], + $_POST['PEAR_PW'], $_POST['PEAR_PW2']); + if (is_array($salt)) { + $errors = $salt; + response_header('Report - Problems'); + break; // skip bug addition + } + if (PEAR::isError($salt)) { + $errors[] = $salt; + response_header('Report - Problems'); + break; + } + if ($salt === false) { + $errors[] = 'Your account cannot be added to the queue.' + . ' Please write a mail message to the ' + . ' <i>pear-dev</i> mailing list.'; + response_header('Report - Problems'); + break; + } + + $_POST['in']['handle'] = $_POST['PEAR_USER']; + $mailData = array( + 'username' => $_POST['in']['handle'], + 'salt' => $salt, + ); + + if (!DEVBOX) { + $mailer = Damblan_Mailer::create('pearweb_account_request_bug', $mailData); + $additionalHeaders['To'] = $_POST['in']['email']; + $mailer->send($additionalHeaders); + } + } + // Put all text areas together. + $fdesc = "Description:\n------------\n" . $_POST['in']['ldesc'] . "\n\n"; + if (!empty($_POST['in']['repcode'])) { + $fdesc .= "Test script:\n---------------\n"; + $fdesc .= $_POST['in']['repcode'] . "\n\n"; + } + if (!empty($_POST['in']['expres']) || + $_POST['in']['expres'] === '0') + { + $fdesc .= "Expected result:\n----------------\n"; + $fdesc .= $_POST['in']['expres'] . "\n\n"; + } + if (!empty($_POST['in']['actres']) || + $_POST['in']['actres'] === '0') + { + $fdesc .= "Actual result:\n--------------\n"; + $fdesc .= $_POST['in']['actres'] . "\n"; + } + + $reporter_name = isset($_POST['in']['reporter_name']) ? htmlspecialchars(strip_tags($_POST['in']['reporter_name'])) : ''; + + + $query = 'INSERT INTO bugdb ( + package_name, + bug_type, + email, + handle, + sdesc, + ldesc, + package_version, + php_version, + php_os, + status, ts1, + passwd, + reporter_name + ) VALUES (' . + " '" . escapeSQL($_POST['in']['package_name']) . "'," . + " '" . escapeSQL($_POST['in']['bug_type']) . "'," . + " '" . escapeSQL($_POST['in']['email']) . "'," . + " '" . escapeSQL($_POST['in']['handle']) . "'," . + " '" . escapeSQL($_POST['in']['sdesc']) . "'," . + " '" . escapeSQL($fdesc) . "'," . + " '" . escapeSQL($_POST['in']['package_version']) . "'," . + " '" . escapeSQL($_POST['in']['php_version']) . "'," . + " '" . escapeSQL($_POST['in']['php_os']) . "'," . + " 'Open', NOW(), " . + " '" . escapeSQL($_POST['in']['passwd']) . "'," . + " '" . escapeSQL($reporter_name) . "')"; + + + $dbh->query($query); + + /* + * Need to move the insert ID determination to DB eventually... + */ + if ($dbh->phptype == 'mysql') { + $cid = mysql_insert_id(); + } else { + $cid = mysqli_insert_id($dbh->connection); + } + + $report = ''; + $report .= 'From: ' . $_POST['in']['handle'] . "\n"; + $report .= 'Operating system: ' . rinse($_POST['in']['php_os']) . "\n"; + $report .= 'Package version: ' . rinse($_POST['in']['package_version']) . "\n"; + $report .= 'PHP version: ' . rinse($_POST['in']['php_version']) . "\n"; + $report .= 'Package: ' . $_POST['in']['package_name'] . "\n"; + $report .= 'Bug Type: ' . $_POST['in']['bug_type'] . "\n"; + $report .= 'Bug description: '; + + $fdesc = rinse($fdesc); + $sdesc = rinse($_POST['in']['sdesc']); + + $ascii_report = "$report$sdesc\n\n" . wordwrap($fdesc); + $ascii_report .= "\n-- \nEdit bug report at "; + $ascii_report .= "http://$site.php.net/bugs/bug.php?id=$cid&edit="; + + list($mailto, $mailfrom) = get_package_mail($_POST['in']['package_name']); + + $email = rinse($_POST['in']['email']); + $protected_email = '"' . spam_protect($email, 'text') . '"'; + $protected_email .= '<' . $mailfrom . '>'; + + // provide shortcut URLS for "quick bug fixes" + // $dev_extra = ''; + // $maxkeysize = 0; + // foreach ($RESOLVE_REASONS as $v) { + // if (!$v['webonly']) { + // $actkeysize = strlen($v['desc']) + 1; + // $maxkeysize = (($maxkeysize < $actkeysize) ? $actkeysize : $maxkeysize); + // } + // } + // foreach ($RESOLVE_REASONS as $k => $v) { + // if (!$v['webonly']) + // $dev_extra .= str_pad($v['desc'] . ":", $maxkeysize) . + // " http://bugs.php.net/fix.php?id=$cid&r=$k\n"; + // } + + $extra_headers = 'From: ' . $protected_email . "\n"; + $extra_headers .= 'X-PHP-BugTracker: PEARbug' . "\n"; + $extra_headers .= 'X-PHP-Bug: ' . $cid . "\n"; + $extra_headers .= 'X-PHP-Type: ' . rinse($_POST['in']['bug_type']) . "\n"; + $extra_headers .= 'X-PHP-PackageVersion: ' . rinse($_POST['in']['package_version']) . "\n"; + $extra_headers .= 'X-PHP-Version: ' . rinse($_POST['in']['php_version']) . "\n"; + $extra_headers .= 'X-PHP-Category: ' . rinse($_POST['in']['package_name']) . "\n"; + $extra_headers .= 'X-PHP-OS: ' . rinse($_POST['in']['php_os']) . "\n"; + $extra_headers .= 'X-PHP-Status: Open' . "\n"; + $extra_headers .= 'Message-ID: <bug-' . $cid . '@'.$site.'.php.net>'; + + $type = @$types[$_POST['in']['bug_type']]; + + if (DEVBOX == false) { + // mail to package developers + @mail($mailto, "[$siteBig-BUG] $type #$cid [NEW]: $sdesc", + $ascii_report . "1\n-- \n$dev_extra", $extra_headers, + '-f bounce-no-user@php.net'); + // mail to reporter + @mail($email, "[$siteBig-BUG] $type #$cid: $sdesc", + $ascii_report . "2\n", + "From: $siteBig Bug Database <$mailfrom>\n" . + "X-PHP-Bug: $cid\n" . + "Message-ID: <bug-$cid@$site.php.net>", + '-f bounce-no-user@php.net'); + } + localRedirect('bug.php?id=' . $cid . '&thanks=4'); + exit; } - localRedirect('bug.php?id=' . $cid . '&thanks=4'); - exit; - } + } while (false); } else { // had errors... response_header('Report - Problems'); @@ -357,9 +430,51 @@ ?> -<form method="post" - action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']) . '?package=' - . clean($_REQUEST['package']); ?>"> +<?php +$self = htmlspecialchars($_SERVER['PHP_SELF']); +$action = $self . '?package=' . clean($_REQUEST['package']); +if (!$auth_user && DEVBOX == false) { + $action = "https://" . $_SERVER['SERVER_NAME'] . '/' . $action; +} +?> +<form<?php +if (!$auth_user) { + echo ' onsubmit="javascript:doMD5(document.forms[\'bugreport\'])" ' ; +} ?>method="post" + action="<?php echo $action ?>" name="bugreport" id="bugreport"> +<?php if (!$auth_user): ?> + <div class="explain"> + Please choose a username/password or <a href="<?php echo '/login.php?redirect=' . + urlencode("{$self}?{$_SERVER['QUERY_STRING']}") ?>">Log in</a> +<script type="text/javascript" src="/javascript/md5.js"></script> +<script type="text/javascript"> +function doMD5(frm) { + frm.PEAR_PW.value = hex_md5(frm.PEAR_PW.value); + frm.PEAR_PW2.value = hex_md5(frm.PEAR_PW2.value); + frm.isMD5.value = 1; +} +</script> +<input type="hidden" name="isMD5" value="0" /> +<table class="form-holder" cellspacing="1"> + <tr> + <th class="form-label_left"> +Use<span class="accesskey">r</span>name:</th> + <td class="form-input"> +<input size="20" name="PEAR_USER" accesskey="r" /></td> + </tr> + <tr> + <th class="form-label_left">Password:</th> + <td class="form-input"> +<input size="20" name="PEAR_PW" type="password" /></td> + </tr> + <tr> + <th class="form-label_left">Confirm Password:</th> + <td class="form-input"> +<input size="20" name="PEAR_PW2" type="password" /></td> + </tr> +</table> +</div> +<?php endif; //if (!$auth_user) ?> <table class="form-holder" cellspacing="1"> <tr> <th class="form-label_left"> @@ -491,28 +606,6 @@ value="<?php echo clean($_POST['in']['sdesc']); ?>" /> </td> </tr> -<?php -if (!($auth_user && $auth_user->registered)) { -?> - <tr> - <th class="form-label_left"> - Password: - </th> - <td class="form-input"> - - <input type="password" size="20" maxlength="20" name="in[passwd]" - value="<?php echo clean($_POST['in']['passwd']); ?>" /> - - <p class="cell_note"> - You may enter any password here, which will be stored for this bug report. - This password allows you to come back and modify your submitted bug report - at a later date. - </p> - </td> - </tr> -<?php -} -?> <tr> <th class="form-label_left"> Note: http://cvs.php.net/viewvc.cgi/pearweb/public_html/bugs/include/functions.inc?r1=1.127&r2=1.128&diff_format=u Index: pearweb/public_html/bugs/include/functions.inc diff -u pearweb/public_html/bugs/include/functions.inc:1.127 pearweb/public_html/bugs/include/functions.inc:1.128 --- pearweb/public_html/bugs/include/functions.inc:1.127 Sat Feb 24 00:49:12 2007 +++ pearweb/public_html/bugs/include/functions.inc Sun Feb 25 22:44:26 2007 @@ -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.127 2007/02/24 00:49:12 cellog Exp $ + * @version $Id: functions.inc,v 1.128 2007/02/25 22:44:26 cellog Exp $ */ @@ -897,7 +897,7 @@ $max_comments = 5; $output = ""; $count = 0; - $res =& $dbh->query("SELECT ts, email, comment FROM bugdb_comments WHERE bug=$bug_id ORDER BY ts DESC"); + $res =& $dbh->query("SELECT ts, email, comment, handle FROM bugdb_comments WHERE bug=$bug_id ORDER BY ts DESC"); # skip the most recent unless the caller wanted all comments if (!$all) { @@ -908,11 +908,14 @@ } while (($row =& $res->fetchRow(DB_FETCHMODE_ORDERED)) && strlen($output) < $max_message_length && $count++ < $max_comments) { - $output .= "[$row[0]] ". spam_protect($row[1], 'text') ."\n\n$row[2]\n\n$divider\n\n"; + $email = $row[3] ? + $row[3] : + spam_protect($row[1], 'text'); + $output .= "[$row[0]] $email\n\n$row[2]\n\n$divider\n\n"; } if (strlen($output) < $max_message_length && $count < $max_comments) { - $res =& $dbh->query("SELECT ts1,email,ldesc FROM bugdb WHERE id=$bug_id"); + $res =& $dbh->query("SELECT ts1,email,ldesc,handle FROM bugdb WHERE id=$bug_id"); if (!$res) { return $output; } @@ -920,7 +923,10 @@ if (!$row) { return $output; } - return ("\n\nPrevious Comments:\n$divider\n\n" . $output . "[$row[0]] ". spam_protect($row[1], 'text') ."\n\n$row[2]\n\n$divider\n\n"); + $email = $row[3] ? + $row[3] : + spam_protect($row[1], 'text'); + return ("\n\nPrevious Comments:\n$divider\n\n" . $output . "[$row[0]] $email\n\n$row[2]\n\n$divider\n\n"); } else { return ("\n\nPrevious Comments:\n$divider\n\n" . $output . "The remainder of the comments for this report are too long. To view\nthe rest of the comments, please view the bug report online at\n http://$site.php.net/bugs/bug.php?id=$bug_id\n"); } @@ -974,7 +980,7 @@ */ function incoming_details_are_valid($in, $initial = 0, $logged = false) { - global $bug, $dbh, $types; + global $bug, $dbh, $types, $auth_user; $errors = array(); if (empty ($in['package_name']) || $in['package_name'] == 'none') { @@ -983,12 +989,31 @@ $errors[] = 'Please select an appropriate bug type.'; } - if ($initial || (!empty($in[email]) && $bug[email] != $in[email])) { + if ($initial || (!empty($in['email']) && $bug['email'] != $in['email'])) { if (!preg_match("/[.\\w+-]+@[.\\w-]+\\.\\w{2,}/i",$in['email'])) { $errors[] = 'Please provide a valid email address.'; } } + if (!$auth_user) { + if (empty($in['PEAR_USER'])) { + $errors[] = 'Please type a username'; + } elseif (!preg_match(PEAR_COMMON_USER_NAME_REGEX, $in['PEAR_USER'])) { + $errors[] = 'Username must start with a letter and contain' + . ' only letters and digits'; + } + + if (empty($in['PEAR_PW'])) { + $errors[] = 'Please type a password'; + } + if (empty($in['PEAR_PW2'])) { + $errors[] = 'Please confirm your password'; + } + if ($in['PEAR_PW'] !== $in['PEAR_PW2']) { + $errors[] = 'Passwords do not match'; + } + } + if (isset($in['php_version']) && $in['php_version'] == 'earlier') { $errors[] = 'Please select a valid PHP version. If your PHP version is too old, please upgrade first and see if the problem has not already been fixed.'; } @@ -1012,9 +1037,6 @@ if ($initial && empty($in['ldesc'])) { $errors[] = 'You must supply a long description of the bug you are reporting.'; } - if (!$logged && $initial && empty($in['passwd'])) { - $errors[] = 'You must supply a password for this bug report.'; - } return $errors; } @@ -1036,7 +1058,9 @@ case 'Bug System': case 'PEPr': case 'Web Site': - return array(PEAR_WEBMASTER_EMAIL, PEAR_WEBMASTER_EMAIL); + $arr = get_package_mail('pearweb'); + $arr[0][] = PEAR_WEBMASTER_EMAIL; + return array($arr[0], PEAR_WEBMASTER_EMAIL); case 'Documentation': return array(PEAR_DOC_EMAIL, PEAR_DOC_EMAIL); } http://cvs.php.net/viewvc.cgi/pearweb/sql/bugs.sql?r1=1.14&r2=1.15&diff_format=u Index: pearweb/sql/bugs.sql diff -u pearweb/sql/bugs.sql:1.14 pearweb/sql/bugs.sql:1.15 --- pearweb/sql/bugs.sql:1.14 Sun Feb 25 19:14:12 2007 +++ pearweb/sql/bugs.sql Sun Feb 25 22:44:26 2007 @@ -6,6 +6,7 @@ id int(8) NOT NULL auto_increment, package_name varchar(80) default NULL, bug_type varchar(32) NOT NULL default 'Bug', + handle varchar(20) NOT NULL default '', email varchar(40) NOT NULL default '', reporter_name varchar(80) default '', sdesc varchar(80) NOT NULL default '', @@ -31,6 +32,7 @@ id int(8) NOT NULL auto_increment, bug int(8) NOT NULL default '0', email varchar(40) NOT NULL default '', + handle varchar(20) NOT NULL default '', reporter_name varchar(80) default '', ts datetime NOT NULL default '0000-00-00 00:00:00', comment text NOT NULL, @@ -83,4 +85,13 @@ revision int(8) NOT NULL, developer varchar(20) NOT NULL, PRIMARY KEY (bugdb_id, patch, revision) -); \ No newline at end of file +); + +CREATE TABLE bug_account_request ( + id INT NOT NULL AUTO_INCREMENT, + created_on DATE NOT NULL, + handle VARCHAR(20) NOT NULL, + salt CHAR(32) NOT NULL, + email VARCHAR(65) NOT NULL, + PRIMARY KEY(id) +); http://cvs.php.net/viewvc.cgi/pearweb/sql/pearweb_mdb2schema.xml?r1=1.22&r2=1.23&diff_format=u Index: pearweb/sql/pearweb_mdb2schema.xml diff -u pearweb/sql/pearweb_mdb2schema.xml:1.22 pearweb/sql/pearweb_mdb2schema.xml:1.23 --- pearweb/sql/pearweb_mdb2schema.xml:1.22 Sun Feb 25 19:14:12 2007 +++ pearweb/sql/pearweb_mdb2schema.xml Sun Feb 25 22:44:26 2007 @@ -128,6 +128,14 @@ </field> <field> + <name>handle</name> + <type>text</type> + <length>20</length> + <notnull>true</notnull> + <default></default> + </field> + + <field> <name>reporter_name</name> <type>text</type> <length>80</length> @@ -289,6 +297,14 @@ </field> <field> + <name>handle</name> + <type>text</type> + <length>20</length> + <notnull>true</notnull> + <default></default> + </field> + + <field> <name>email</name> <type>text</type> <length>40</length> @@ -3096,5 +3112,58 @@ </declaration> </table> + <table> + + <name>bug_account_request</name> + + <declaration> + + <field> + <name>id</name> + <type>integer</type> + <length>11</length> + <notnull>true</notnull> + <autoincrement>true</autoincrement> + </field> + + <field> + <name>created_on</name> + <type>date</type> + <notnull>true</notnull> + </field> + + <field> + <name>handle</name> + <type>text</type> + <length>20</length> + <notnull>true</notnull> + </field> + + <field> + <name>salt</name> + <type>text</type> + <length>32</length> + <notnull>true</notnull> + </field> + + <field> + <name>email</name> + <type>text</type> + <length>65</length> + <notnull>true</notnull> + </field> + + <index> + <name>primary</name> + <primary>true</primary> + <field> + <name>id</name> + <sorting>ascending</sorting> + </field> + </index> + + </declaration> + + </table> </database> http://cvs.php.net/viewvc.cgi/pearweb/include/Damblan/Mail/pearweb_account_request_bug.tpl.php?view=markup&rev=1.1 Index: pearweb/include/Damblan/Mail/pearweb_account_request_bug.tpl.php +++ pearweb/include/Damblan/Mail/pearweb_account_request_bug.tpl.php <?php /** * Used variables in this template: * * %username% username of the requested account * %salt% salt for confirmation */ $tpl = array( 'Reply-To' => array('PEAR Webmaster <' . PEAR_WEBMASTER_EMAIL . '>'), 'Subject' => '[PEAR-ACCOUNT-REQUEST] Your bug tracker account request : %username%', 'Body' => 'You have requested an account to open bugs or comment on existing bugs. This account is only for use with the bug tracker, but can be updated to allow voting in general elections or other privileges later. To confirm please follow the link http://' . PEAR_CHANNELNAME . '/account-request-confirm.php?salt=%salt%&type=bug If you have received this email by mistake we apologize for any inconvenience. You do not need to reply to this email. PEAR Quality Assurance.'); ?> http://cvs.php.net/viewvc.cgi/pearweb/include/bugs/pear-bug-accountrequest.php?view=markup&rev=1.1 Index: pearweb/include/bugs/pear-bug-accountrequest.php +++ pearweb/include/bugs/pear-bug-accountrequest.php <?php class PEAR_Bug_Accountrequest { var $dbh; var $id; var $created_on; var $handle; var $salt; var $email; function PEAR_Bug_Accountrequest() { $this->dbh = &$GLOBALS['dbh']; $this->user = isset($GLOBALS['auth_user']) ? $GLOBALS['auth_user']->handle : false; $this->cleanOldRequests(); } function _makeSalt($handle) { list($usec, $sec) = explode(" ", microtime()); return md5($handle . ((float)$usec + (float)$sec)); } function find($salt) { $request = $this->dbh->getRow(' SELECT id, created_on, salt, handle FROM bug_account_request WHERE salt=? ', array($salt), DB_FETCHMODE_ASSOC); if (count($request) > 0) { foreach ($request as $field => $value) { $this->$field = $value; } return true; } return false; } /** * Adds a request in the DB * * @return string salt */ function addRequest($handle, $email, $name, $password, $password2) { if ($handle == $this->dbh->getOne('SELECT handle FROM users WHERE handle=?', array($handle))) { $id = $this->dbh->nextId("karma"); $query = "INSERT INTO karma VALUES (?, ?, ?, ?, NOW())"; $sth = $this->dbh->query($query, array($id, $this->handle, 'pear.bug', 'pearweb')); return true; } list($firstname, $lastname) = explode(' ', $name, 2); $data = array( 'handle' => $handle, 'firstname' => $firstname, 'lastname' => $lastname, 'email' => $email, 'purpose' => 'bug tracker', 'password' => $password, 'password2' => $password2, ); $useradd = user::add($data); if (is_array($useradd)) { return $useradd; } $salt = $this->_makeSalt($handle); $created_on = gmdate('Y-m-d H:i:s'); $query = ' insert into bug_account_request (created_on, handle, email, salt) values (?, ?, ?, ?)'; $res = $this->dbh->query($query, array($created_on, $handle, $email, $salt)); if (DB::isError($res)) { return $res; } //$this->find($salt); //$this->sendRequest(); return $salt; } function deleteRequest() { $query = 'delete from bug_account_request where salt=?'; return $this->dbh->query($query, array($this->salt)); } function confirmRequest($salt) { if (!$this->find($salt)) { return PEAR::raiseError('cannot find request'); } // activate the handle and grant karma // implicitly without human intervention // copied from the user class and Damblan_Karma $user =& new PEAR_User($this->dbh, $this->handle); if (@$user->registered) { return false; } @$arr = unserialize($user->userinfo); note::removeAll("uid", $this->handle); $user->set('registered', 1); if (is_array($arr)) { $user->set('userinfo', $arr[1]); } $user->set('created', gmdate('Y-m-d H:i')); $user->set('createdby', 'pearweb'); $user->store(); $id = $this->dbh->nextId("karma"); $query = "INSERT INTO karma VALUES (?, ?, ?, ?, NOW())"; $sth = $this->dbh->query($query, array($id, $this->handle, 'pear.bug', 'pearweb')); if (!DB::isError($sth)) { note::add("uid", $this->handle, "Account opened", 'pearweb'); $msg = "Your PEAR bug tracker account has been opened.\n" . "Bugs you have opened will now be displayed, and you can\n" . "add new comments to existing bugs"; $xhdr = "From: pear-webmaster@lists.php.net"; mail($user->email, "Your PEAR Bug Tracker Account Request", $msg, $xhdr, "-f bounce-no-user@php.net"); $this->deleteRequest(); return true; } return false; } function listRequests() { } function cleanOldRequests() { $old = gmdate('Y-m-d H:i:s', time() - 90000); $findquery = ' select handle from bug_account_request where created_on < ?'; $all = $this->dbh->getAll($findquery, array($old)); // purge reserved usernames as well as their account requests if (is_array($all)) { foreach ($all as $data) { $this->dbh->query(' DELETE FROM users WHERE handle=? ', array($data[0])); $this->dbh->query(' DELETE FROM bugdb WHERE handle=? ', array($data[0])); $this->dbh->query(' DELETE FROM bugdb_comments WHERE handle=? ', array($data[0])); } } $query = ' delete from bug_account_request where created_on < ?'; // purge out-of-date account requests return $this->dbh->query($query, array($old)); } } ?>