Beispiel #1
0
 public function loginAccount($username, $password)
 {
     $this->dbConnect();
     //Encrypt the password
     $password = Operations::encryptPassword($username, $password);
     //Query to get the user's details
     $sql = "SELECT * FROM users WHERE username = ? AND password = ?";
     $stmt = $this->con->prepare($sql);
     $stmt->bindParam(1, $username);
     $stmt->bindParam(2, $password);
     $stmt->execute();
     $stmt->setFetchMode(PDO::FETCH_ASSOC);
     $results = $stmt->fetchAll();
     //For each of the results (only one) *This will only happen if there is a result, so return inside the foreach*
     foreach ($results as $row) {
         //Instantiate a new account object
         $account = new Account();
         //Set the account details
         $account->setUsername($row["username"]);
         $account->setPassword($row["password"]);
         $account->setFirstname($row["firstname"]);
         $account->setLastname($row["lastname"]);
         $account->setEmail($row["email"]);
         $this->dbDisconnect();
         //Return the account object
         return $account;
     }
     $this->dbDisconnect();
     return null;
 }
Beispiel #2
0
 public function addAccount($username, $password, $firstname)
 {
     // Loop through the current accounts to see if the username already exists
     // If the username does not exist, we will push the new account in to the array & return true
     // Else, return false
     $accountExists = false;
     foreach ($this::$data as $account) {
         if ($account->getUsername() == $username) {
             $accountExists = true;
             break;
         }
     }
     if ($accountExists) {
         return false;
     } else {
         $account = new Account();
         $account->setUsername($username);
         $account->setPassword($password);
         $account->setFirstname($firstname);
         echo "adding to data..";
         array_push(InMemoryDatabase::$data, $account);
         var_dump($this::$data);
         return true;
     }
 }
 public function doSignUp($request, $dbConnection)
 {
     $account = new Account($dbConnection);
     $account->setPassword($request['password']);
     $account->setUsername($request['username']);
     $account->setEmail($request['email']);
     $account->insert();
 }
 public function createAccount(Account $account)
 {
     $params = array('package_type' => $account->getType(), 'period' => $account->getPeriod(), 'method' => 'create');
     $result = $this->_request($params);
     $account->setStatus('enabled');
     $account->setUsername($result['user']);
     $account->setPassword($result['vpn_password']);
     return $account;
 }
Beispiel #5
0
 public function LoadAcc($id)
 {
     $acc = new Account();
     $allaccs = file('storage/account.txt');
     foreach ($allaccs as $allacc) {
         $accarr = explode(':', $allacc);
         if ($id == $accarr['0']) {
             $acc->setId($accarr['0']);
             $acc->setUsername($accarr['1']);
             $acc->setPassword($accarr['2']);
             $pro = new ProfilController();
             $acc->setProfil($pro->GetById($accarr['3']));
             $lan = new SpracheController();
             $acc->setSprache($lan->GetById($accarr['4']));
             return $acc;
         }
     }
     return false;
 }
    if ($_POST['submit'] && recaptchaCheck()) {
        extract($_POST);
        //CALL CHECKPASSWORD
        $database = connectToDatabase();
        $new_account = new Account();
        $new_account->setFirstName($first_name);
        $new_account->setLastName($last_name);
        $new_account->setMiddleInitial($middle_initial);
        $new_account->setStreetAddress($street_address);
        $new_account->setCity($city);
        $new_account->setState($state);
        $new_account->setZipCode($zip_code);
        $new_account->setEmailAddress($email_address);
        $new_account->setAreaCode($area_code);
        $new_account->setPhoneNumber($phone_number);
        $new_account->setUsername($username, $database);
        if ($password === $password2) {
            $new_account->setPassword($password);
        }
        if ($new_account->updateDatabase($database) == 0) {
            displayForm();
        } else {
            echo "Account created successfully!<br/>";
        }
    } else {
        displayForm();
    }
}
function displayForm()
{
    echo "<form method='post'>";
Beispiel #7
0
 public function getFriends($currentUser)
 {
     $this->dbConnect();
     $sql = "SELECT * FROM accounts WHERE username <> ?";
     $statement = $this->con->prepare($sql);
     $statement->bindParam(1, $currentUser);
     $statement->execute();
     $statement->setFetchMode(PDO::FETCH_ASSOC);
     $results = $statement->fetchAll();
     $users = array();
     foreach ($results as $row) {
         $account = new Account();
         $account->setUsername($row["username"]);
         $account->setPassword($row["password"]);
         $account->setFirstname($row["firstname"]);
         array_push($users, $account);
     }
     $this->dbClose();
     return $users;
 }