function _validate_fields($real_name, $username, $userpass, $userpass2, $email, $email2, $email_updates)
{
    global $testing;
    // Make sure that password and confirmed password are equal.
    if ($userpass != $userpass2) {
        return _("The passwords you entered were not equal.");
    }
    // Make sure that email and confirmed email are equal.
    if ($email != $email2) {
        return _("The e-mail addresses you entered were not equal.");
    }
    // Do some validity-checks on inputted username, password, e-mail and real name
    $err = check_username($username, TRUE);
    if ($err != '') {
        return $err;
    }
    // In testing mode, a fake email address is constructed using
    // 'localhost' as the domain. check_email_address() incorrectly
    // thinks the domain should end in a 2-4 character top level
    // domain, so disable the address check for testing.
    if (!$testing) {
        $err = check_email_address($email);
        if ($err != '') {
            return $err;
        }
    }
    if (empty($userpass) || empty($real_name)) {
        return _("You did not completely fill out the form.");
    }
    // Make sure that the requested username is not already taken.
    // Use non-strict validation, which will return TRUE if the username
    // is the same as an existing one, or differs only by case or trailing
    // whitespace.
    if (User::is_valid_user($username, FALSE)) {
        return _("That user name already exists, please try another.");
    }
    // TODO: The above check only validates against users in the DP database.
    // It's possible that there are usernames already registered with the
    // underlying forum software (like 'Anonymous') or are disallowed in the
    // forum software which, if used, will cause account creation to fail in
    // activate.php.
    return '';
}
Example #2
0
 public function testValidateInvalidUser()
 {
     $is_valid = User::is_valid_user($this->NONEXISTENT_USERNAME);
     $this->assertFalse($is_valid);
 }
$rounds = array_keys($Round_for_round_id_);
// defaults
$default_sampleLimit = 0;
$default_days = 100;
// load any data passed into the page
$username = @$_REQUEST["username"];
$work_round_id = @$_REQUEST["work_round_id"];
$review_round_id = @$_REQUEST["review_round_id"];
$sampleLimit = array_get($_REQUEST, "sample_limit", $default_sampleLimit);
$days = array_get($_REQUEST, "days", $default_days);
// if the user isn't a site manager or an access request reviewer
// they can only access their own pages
if (!(user_is_a_sitemanager() || user_is_an_access_request_reviewer())) {
    $username = $pguser;
}
if ($username && !User::is_valid_user($username)) {
    die("Invalid username");
}
// start the page
$title = _('Reviewing work');
output_header($title, NO_STATSBAR);
echo "<h1>{$title}</h1>\n";
// show form
echo "<form action='review_work.php' method='GET'>";
echo "<table>";
if (user_is_a_sitemanager() || user_is_an_access_request_reviewer()) {
    // only let site admins or reviewers to access non-self records
    echo "<tr>";
    echo "<td>" . _("Username") . "</td>";
    echo "<td><input name='username' type='text' size='26' value='{$username}'></td>";
    echo "</tr>";