public static function createUserLoginDetails($id) { $userObject = new self(); $query = "SELECT * FROM TUSERS U WHERE U.`User ID` = {$id}"; $user = db_select($query); $userObject->setUserId($id); $userObject->setEmail($user[0]['Email']); $userObject->setRole($user[0]['Role']); $userObject->setLocked($user[0]['Locked']); $userObject->setLockedTime($user[0]['Locked Time']); $userObject->setLastFailedLogin($user[0]['Last Failed Login']); $userObject->setLoginAttempts($user[0]['Login Attempts']); $userObject->setPassword($user[0]['Password']); $userObject->setSalt($user[0]['Salt']); $userObject->setValidation($user[0]['Validation']); return $userObject; }
/** * Hashes an object using salt provided * * @param string $object hash an object * @param string $salt Salt to be used with object * @param integer $rounds The number of rounds to hash it by * @param string $algo Algorythm to use when hashing * @return StdClass */ public static function hash($object, $salt = null, $rounds = 0, $algo = null) { $ret = new self(); $ret->setSalt($salt)->setRounds($rounds); // First mix password and salt $data = serialize($object) . $salt; if (!is_null($algo)) { $ret->setAlgo($algo); } for ($i = 0; $i <= $ret->getRounds(); $i++) { $data = hash($ret->getAlgo(), $data); } $ret->setHash($data); return $ret; }