/** * Возвращает данные пользователя, если он авторизирован.<br/> * Иначе перенаправляет на страницу входа * @return string <p>Идентификатор пользователя</p> */ public static function checkLogged() { $dbh = Db::getConnection(); $config = new PHPAuth\Config($dbh); $auth = new PHPAuth\Auth($dbh, $config); if (!$auth->isLogged()) { header("Location: /user/login"); } $userHash = $auth->getSessionHash(); $userId = $auth->getSessionUID($userHash); return $user = $auth->getUser($userId); }
<?php require "../../models/DB/Db.class.php"; $db = new Db(); $dbh = $db->getPurePodo(); include "../../models/PHPAuth/Config.php"; include "../../models/PHPAuth/Auth.php"; $config = new PHPAuth\Config($dbh); $auth = new PHPAuth\Auth($dbh, $config); $uid = filter_var($_POST["uid"], FILTER_SANITIZE_STRING); //$userhash = $auth->getSessionHash(); //$uid= $auth->getSessionUID($userhash); $result = $auth->getUser($uid); $email = $result['email']; $firstname = $result['firstName']; $lastname = $result['Lastname']; $username = $result['username']; ?> <div class= "container-fluid"> <h3 class="text3">GENERAL ACCOUNT SETTINGS</h3> <div class="col-sm-4 col-md-2 col-sm-offset-1 col-md-offset-1" style="padding-bottom: 10px"> <img src="../../../assets/images/user.png" class="img-rounded img-responsive" /> </div> <div class="col-sm-6 col-md-8"> <div class="alert alert-info"> <h2>User Bio : </h2>
<?php require "../../models/DB/Db.class.php"; $db = new Db(); $dbh = $db->getPurePodo(); include "../../models/PHPAuth/Config.php"; include "../../models/PHPAuth/Auth.php"; $config = new PHPAuth\Config($dbh); $auth = new PHPAuth\Auth($dbh, $config); var_dump($auth->getUser(5)); $email = "*****@*****.**"; $password = "******"; $password2 = "ucsc@123!@#AB"; //var_dump($auth->resendActivation($email,1)); //var_dump($auth->logout($auth->getSessionHash())); //var_dump($auth->changePassword(5,$password,$password2,$password2)); if (!$auth->isLogged()) { header('HTTP/1.0 403 Forbidden'); echo "Forbidden"; exit; } else { echo "youhaveloginchamath SIlva"; }