Example #1
0
function validate_signup($enteredName, $enteredEmail, $enteredClass, $enteredReferral, $enteredPass)
{
    $successful = false;
    $sql = $GLOBALS['sql'];
    assert($sql);
    $send_name = $enteredName;
    $send_pass = $enteredPass;
    $send_class = $enteredClass;
    $send_email = $enteredEmail;
    $referred_by = $enteredReferral;
    echo "Your responses:<br> Name - {$send_name},<br>\n\t\t Password - " . (isset($send_pass) ? "***yourpassword***" : "NO PASSWORD") . ",<br>\n\t\t Class - {$send_class},<br>\n\t\t Email - {$send_email},<br>\n\t\t Site Referred By - {$referred_by}<br><br>\n";
    //  *** Requirement checking Section  ***
    if ($send_name != "" && $send_pass != "" && $send_email != "" && $send_class != "") {
        //When everything is non-blank.
        $check_name = 0;
        $check_email = 0;
        $sql->QueryItem("SELECT uname FROM players WHERE uname = '{$send_name}'");
        $check_name = $sql->getRowCount();
        $sql->QueryItem("SELECT email FROM players WHERE email = '{$send_email}'");
        $check_email = $sql->getRowCount();
        // Validate the username symbols!
        $username_error = validate_username($send_name);
        if ($username_error) {
            echo $username_error;
        } else {
            //when all the name requirement errors didn't trigger.
            $send_name = trim($send_name);
            // Just cuts off any white space at the end.
            $filter = new Filter();
            $send_name = $filter->toUsername($send_name);
            // Filter any un-whitelisted characters.
            echo "Phase 1 Complete: Name passes requirements.<hr>\n";
            // Validate the password!
            $password_error = validate_password($send_pass);
            if ($password_error) {
                echo $password_error;
            } else {
                $send_pass = trim($send_pass);
                // *** Trims any extra space off of the password.
                $send_pass = $filter->toPassword($send_pass);
                // Filter any un-whitelisted characters.
                echo "Phase 2 Complete: Password passes requirements.<hr>\n";
                if (FALSE) {
                    // CURRENTLY NO BLOCKED EMAIL SERVICES strstr($send_email, "@") == "@aol.com" || strstr($send_email, "@") == "@netscape.com" || strstr($send_email, "@") == "@aim.com"
                    //Throws error if email from blocked domain.
                    echo "Phase 3 Incomplete: We cannot currently accept @aol.com, @netscape.com, or @aim.com email addresses.";
                } elseif (!eregi("^[[:alnum:]][a-z0-9_.-]*@[a-z0-9.-]+\\.[a-z]{2,4}\$", trim($send_email))) {
                    echo "Phase 3 Incomplete: The email address (" . htmlentities($send_email) . ") \n\t\t\t\t\t    must contain an @ symbol and a domain name to be valid.";
                } else {
                    if ($check_name == 0 && $check_email == 0 && $send_name != "SysMsg" && $send_name != "NewUserList") {
                        //Uses previous query to make sure name and email aren't duplicates.
                        echo "Phase 3 Complete: Username and Email are unique.<br><hr>\n";
                        if ($send_class != 'Red' && $send_class != 'Blue' && $send_class != 'White' && $send_class != 'Black') {
                            echo "Phase 4 Incomplete: No proper class was specified.<br>";
                        } else {
                            echo "Phase 4 Complete: Class was specified.<br><hr>";
                            // *** Signup is successful at this point  ***
                            $preconfirm = 0;
                            $preconfirm = preconfirm_some_emails($send_email);
                            if (!$preconfirm) {
                                /* not blacklisted by, so require a normal email confirmation */
                                echo "Phase 5: When you receive an email from SysMsg,\n\t\t\t\t\t\t\t it will describe how to activate your account.<br><br>\n";
                            }
                            // The preconfirmation message occurs later.
                            $confirm = rand(1000, 9999);
                            //generate confirmation code
                            // Use the function from lib_player
                            $player_params = array('send_email' => $send_email, 'send_pass' => $send_pass, 'send_class' => $send_class, 'preconfirm' => $preconfirm, 'confirm' => $confirm, 'referred_by' => $referred_by);
                            $successful = create_player($send_name, $player_params);
                            // Create the player.
                            if (!$successful) {
                                echo "There was a problem with creating a player account.  Please contact us as below: ";
                            } else {
                                if (!$preconfirm) {
                                    //  *** Continues the page display ***
                                    echo "Confirmation email has been sent to <b>" . $send_email . "</b>.  <br>\n    \t\t\t\t  \t\t\t\t\tBe sure to also check for the email in any \"Junk Mail\" or \"Spam\" folders.\n    \t\t\t\t  \t\t\t\t\tDelivery typically takes less than 15 minutes.";
                                } else {
                                    // Use the confirm function from lib_player.
                                    confirm_player($send_name, false, true);
                                    // name, no confirm #, just autoconfirm.
                                    echo "<p>Account with the login name \"" . $send_name . "\" is now confirmed!  Please login on the login bar of the ninjawars.net page.</p>";
                                }
                                echo "<p>Only one account per person is allowed.</p>";
                            }
                            echo "If you require help use the forums at <a href='" . WEB_ROOT . "forum/'>" . WEB_ROOT . "forum/</a> or email: " . SUPPORT_EMAIL;
                        }
                        // *** End of class checking.
                    } else {
                        // Default, displays when the username or email are not unique.
                        $what = $check_email != 0 ? "Email" : "Username";
                        echo "Phase 3 Incomplete: That {$what} is already in use. Please choose a different one.\n";
                    }
                }
            }
        }
    } else {
        //  ***  Response for when nothing was submitted.  ***
        echo "Phase 1 Incomplete: You did not correctly fill out all the necessary information.\n";
    }
    //This is the final signup return section, which only shows if a successful
    //insert and confirmation number has -not- been acheived.
    echo "<br><br>";
    return $successful;
}
Example #2
0
 /**
  * group accountconf
  **/
 function testPreconfirmEmailsReturnRightResultForGmailHotmailAndWildcardEmails()
 {
     $preconfirm_emails = array('*****@*****.**', '*****@*****.**', '*****@*****.**');
     $no_preconfirm_emails = array('*****@*****.**', "O'*****@*****.**");
     foreach ($preconfirm_emails as $email) {
         $this->assertTrue((bool) preconfirm_some_emails($email));
     }
     foreach ($no_preconfirm_emails as $email) {
         $this->assertFalse((bool) preconfirm_some_emails($email));
     }
 }
Example #3
0
 $completedPhase = 1;
 $phase2 = validate_password($enteredPass);
 if ($phase2) {
     $error = $phase2;
 } else {
     $completedPhase = 2;
     $phase3 = validate_signup_phase3($enteredName, $enteredEmail);
     if ($phase3) {
         $error = $phase3;
     } else {
         $completedPhase = 3;
         if (!validate_signup_phase4($enteredClass)) {
             $error = 'Phase 4 Incomplete: No proper class was specified.';
         } else {
             $completedPhase = 4;
             $preconfirm = preconfirm_some_emails($enteredEmail);
             $confirm = rand(1000, 9999);
             //generate confirmation code
             Request::setTrustedProxies(Constants::$trusted_proxies);
             $request = Request::createFromGlobals();
             $ip = $request->getClientIp();
             $player_params = array('send_email' => $enteredEmail, 'send_pass' => $enteredPass, 'send_class' => $enteredClass, 'preconfirm' => $preconfirm, 'confirm' => $confirm, 'referred_by' => $enteredReferral, 'ip' => $ip);
             if ($error = create_account_and_ninja($enteredName, $player_params)) {
                 // Create the player.
                 if (!$error) {
                     $error = 'There was a problem with creating a player account. Please contact us as mentioned below: ';
                 }
             } else {
                 $submit_successful = true;
                 if ($preconfirm) {
                     // Use the confirm function from lib_player.