Beispiel #1
0
 public function testPasswordEncrypt()
 {
     // each password encryption is unique, ensure that each is 60 characters long
     $this->assertEquals(60, strlen(passwordEncrypt("password")));
     $this->assertEquals(60, strlen(passwordEncrypt("hello")));
     $this->assertEquals(60, strlen(passwordEncrypt("1234")));
     $this->assertEquals(60, strlen(passwordEncrypt("sljkf8j9p4fjw3oj")));
     $this->assertEquals(60, strlen(passwordEncrypt("")));
     // test that no two encryptions are identical
     $this->assertFalse(passwordEncrypt("hello") == passwordEncrypt("hello"));
     $this->assertFalse(passwordEncrypt("password123") == passwordEncrypt("password123"));
 }
 public function checkNewUser($username, $name, $surname, $email, $password)
 {
     switch (FALSE) {
         case check_valid_input($username, 6):
             throw new InvalidInputException("false Username Input = input needs to be minimum 6 long, only numbers, letters, capital letters and # @ . - or _");
         case check_valid_input($name, 1):
         case check_no_numbers($name):
             throw new InvalidInputException("false name Input = input needs to be minimum 1 long, only letters, capital letters and # @ . - or _");
         case check_valid_input($surname, 1):
         case check_no_numbers($surname):
             throw new InvalidInputException("false surname Input = input needs to be minimum 1 long, only letters, capital letters and # @ . - or _");
         case check_valid_input($email, 6):
         case check_at($email):
             throw new InvalidInputException("false email Input = input needs to be minimum 6 long, only numbers, letters, capital letters and # @ . - or _");
         case check_password($password):
             throw new InvalidInputException("false password Input = input needs to be minimum 6 long, only numbers, letters, capital letters and # @ . - or _");
     }
     $hashedpwd = passwordEncrypt($username, $password);
     $userDAO = new UserDAO();
     $userDAO->createUser($username, $name, $surname, $email, $hashedpwd);
 }
Beispiel #3
0
<?php

if (!session_id()) {
    session_start();
}
include "connect.php";
include "functions.php";
$firstName = $_POST['firstName'];
$lastName = $_POST['lastName'];
$username = $_POST['username'];
$password1 = $_POST['password1'];
$password2 = $_POST['password2'];
if (!($password1 === $password2)) {
    $_SESSION['newuser_error'] = True;
    header("Location: ../public/newuser.php");
} else {
    $sql = "INSERT INTO users (username, hashed_password, first_name, last_name) VALUES (:username, :password, :firstName, :lastName);";
    $statement = $db->prepare($sql);
    $statement->bindParam(':username', $_POST['username']);
    $statement->bindParam(':password', passwordEncrypt($_POST['password1']));
    $statement->bindParam(':firstName', $firstName);
    $statement->bindParam(':lastName', $lastName);
    $statement->execute();
    $db = null;
    $_SESSION['username'] = $username;
    $_SESSION['first_name'] = $firstName;
    $_SESSION['last_name'] = $lastName;
    $_SESSION['newuser_error'] = False;
    header("Location: ../public/dashboard.php");
}
var_dump(check_valid_input($string, 6));
$fox = $userDAO->getByUsername("foxbarrelinc");
var_dump($fox);
//        $userSvc = new UserService();
//        $service = $userSvc->checkLogin("foxbarrelinc", "adminpwd");
//        var_dump($service);
$par1 = $_SERVER['REMOTE_ADDR'];
var_dump($par1);
$par2 = gethostbyaddr($par1);
var_dump($par2);
var_dump(redirect_arrayName());
var_dump(redirect_par());
$_SESSION[redirect_arrayName()] = redirect_par();
var_dump($_SESSION[redirect_arrayName()]);
var_dump($_SERVER['HTTP_USER_AGENT']);
$hashValue = passwordEncrypt("fifafo", "schildp@d");
var_dump($hashValue);
$color = randomColor();
echo "<span style='color:" . $color . "'>" . $color . "</span>";
$cDAO = new ChallengeDAO();
$temp_var = $cDAO->getByUsername("foxbarrelinc");
var_dump($temp_var);
$challengeSvc = new ChallengeService();
$service = $challengeSvc->getChallegeby("foxbarrelinc");
var_dump($service);
$bool_temp = $challengeSvc->checkChallenge($service->getUser()->getUsername());
var_dump($bool_temp);
$wDAO = new WeighpointDAO();
$points = $wDAO->getPointsByChallengeId($service->getChallengeId());
?>
    </body>