Example #1
0
 public function fetchByUsername($username)
 {
     $user = null;
     if (is_file($this->_filename)) {
         $fopen = fopen($this->_filename, "r");
         while (false !== ($value = fgets($fopen))) {
             $value = trim($value);
             if (substr($value, 40) == $username) {
                 $user = new \App\User\User();
                 $user->setPassword(substr($value, 0, 40))->setUsername($username);
                 $this->_loadUserOptions($user);
                 break;
             }
         }
         fclose($fopen);
     }
     return $user;
 }
Example #2
0
<?php

$user = new \App\User\User();
$errors = array();
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    if (!isset($_POST["username"]) || !trim($_POST["username"])) {
        $errors["username"] = "******";
    } else {
        $user->setUsername(trim($_POST["username"]));
    }
    if (empty($_POST["password"])) {
        $errors["password"] = "******";
    } elseif (empty($_POST["password"]) || $_POST["password"] != $_POST["confirmPassword"]) {
        $errors["confirmPassword"] = "******";
    }
    if (empty($errors)) {
        $user->setPassword(sha1($_POST["password"]));
        $userStorage->save($user);
        header("LOCATION: ?mod=admin&a=users");
        exit;
    }
}