Esempio n. 1
0
function printForm($data = array())
{
    foreach (array('name', 'email', 'copy_me', 'subject', 'text') as $value) {
        if (!isset($data[$value])) {
            $data[$value] = '';
        }
    }
    $form = new HTML_QuickForm2('contect', 'post', array('action' => '/account-mail.php?handle=' . htmlspecialchars($_GET['handle'])));
    $form->removeAttribute('name');
    // Set defaults for the form elements
    $form->addDataSource(new HTML_QuickForm2_DataSource_Array(array('name' => htmlspecialchars($data['name']), 'email' => htmlspecialchars($data['email']), 'copy_me' => htmlspecialchars($data['copy_me']), 'subject' => htmlspecialchars($data['subject']), 'text' => htmlspecialchars($data['text']))));
    $form->addElement('text', 'name', array('required' => 'required'))->setLabel('Y<span class="accesskey">o</span>ur Name:', 'size="40" accesskey="o"');
    $form->addElement('email', 'email', array('required' => 'required'))->setLabel('Email Address:');
    $form->addElement('checkbox', 'copy_me')->setLabel('CC me?:');
    $form->addElement('text', 'subject', array('required' => 'required', 'size' => '80'))->setLabel('Subject:');
    $form->addElement('textarea', 'text', array('cols' => 80, 'rows' => 10, 'required' => 'required'))->setLabel('Text:');
    if (!auth_check('pear.dev')) {
        $numeralCaptcha = new Text_CAPTCHA_Numeral();
        $form->addElement('number', 'captcha', array('maxlength' => 4, 'required' => 'required'))->setLabel("What is " . $numeralCaptcha->getOperation() . '?');
        $_SESSION['answer'] = $numeralCaptcha->getAnswer();
    }
    $form->addElement('submit', 'submit')->setLabel('Send Email');
    print $form;
}
Esempio n. 2
0
 * @package   Bugs
 * @copyright Copyright (c) 1997-2005 The PHP Group
 * @license   http://www.php.net/license/3_0.txt  PHP License
 * @version   $Id$
 */
// Obtain common includes
require_once './include/prepend.inc';
// Get user's CVS password
require_once './include/cvs-auth.inc';
// Numeral Captcha Class
require_once 'Text/CAPTCHA/Numeral.php';
require_once 'services/HoneyPot.php';
$errors = array();
$ok_to_submit_report = false;
// Instantiate the numeral captcha object.
$numeralCaptcha = new Text_CAPTCHA_Numeral();
if (isset($_POST['save']) && isset($_POST['pw'])) {
    // non-developers don't have $user set
    setcookie('MAGIC_COOKIE', base64_encode(':' . $_POST['pw']), time() + 3600 * 24 * 12, '/', '.php.net');
}
// captcha is not necessary if the user is logged in
if (isset($auth_user) && $auth_user->registered) {
    if (auth_check('pear.voter') && !auth_check('pear.dev') && !auth_check('pear.bug')) {
        // auto-grant bug tracker karma if it isn't present
        require_once 'Damblan/Karma.php';
        $karma = new Damblan_Karma($dbh);
        $karma->grant($auth_user->user, 'pear.bug');
    }
    if (isset($_SESSION['answer'])) {
        unset($_SESSION['answer']);
    }
Esempio n. 3
0
   | Authors:                                                             |
   +----------------------------------------------------------------------+
   $Id$
*/
redirect_to_https();
require_once 'HTML/QuickForm2.php';
require_once 'HTML/QuickForm2/Renderer/PEAR.php';
/** @todo Remove once in QF2 */
require_once 'HTML/QuickForm2/Element/InputNumber.php';
require_once 'HTML/QuickForm2/Element/InputEmail.php';
require_once 'HTML/QuickForm2/Element/InputUrl.php';
require_once 'Damblan/Mailer.php';
require_once 'election/pear-election-accountrequest.php';
require_once 'Text/CAPTCHA/Numeral.php';
require_once 'services/HoneyPot.php';
$numeralCaptcha = new Text_CAPTCHA_Numeral();
session_start();
$display_form = true;
$errors = array();
$jumpto = 'handle';
$stripped = @array_map('strip_tags', $_POST);
response_header('Request Account');
echo '<h1>Request Account</h1>';
do {
    if (isset($stripped['submit'])) {
        if (empty($stripped['handle']) || !preg_match('/^[0-9a-z_]{2,20}\\z/', $stripped['handle'])) {
            $errors[] = 'Username is invalid.';
            $display_form = true;
        }
        if (empty($_POST['read_everything']['comments_read'])) {
            $errors[] = 'Obviously you did not read all the comments' . ' concerning the need for an account. Please read ' . 'them again.';