/** * Возвращает данные пользователя, если он авторизирован.<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 = $auth->getSessionUID($auth->getSessionHash()); $password = "******"; $email = "*****@*****.**"; $result = $auth->changeEmail($uid, $email, $password); echo '<pre>'; var_dump($result); echo '<br>';
$get_total_rows = $lessons[0]["COUNT(*)"]; //break total records into pages $total_pages = ceil($get_total_rows / $item_per_page); //login testing $dbh = $db->getPurePodo(); include "../../models/PHPAuth/Config.php"; include "../../models/PHPAuth/Auth.php"; $config = new PHPAuth\Config($dbh); $auth = new PHPAuth\Auth($dbh, $config); if (!$auth->isLogged()) { header('HTTP/1.0 403 Forbidden'); echo "Forbidden"; exit; } $userhash = $auth->getSessionHash(); $uid = $auth->getSessionUID($userhash); //Die($userhash."----".$uid); ?> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>UCSC VideoBay</title> <!-- CSS --> <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Roboto:400,100,300,500"> <!-- Latest compiled and minified CSS --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
include "../../models/PHPAuth/Config.php"; include "../../models/PHPAuth/Auth.php"; $config = new PHPAuth\Config($dbh); $auth = new PHPAuth\Auth($dbh, $config); //Sanitize input data using PHP filter_var(). $email = filter_var($_POST["username"], FILTER_SANITIZE_STRING); $password = filter_var($_POST["password"], FILTER_SANITIZE_STRING); $remember = isset($_POST["remember"]); $result = $auth->login($email, $password, $remember); // 1 - error // 0 - ok if ($result['error']) { $output = json_encode(array("typee" => 1, "resultt" => $result['message'])); } else { setcookie('authIDD', $result["hash"], $result["expire"], '/'); $uid = $auth->getSessionUID($result["hash"]); $result = $auth->getUser($uid); $type = $result['type']; ////////////////////////////////////// //Temporary use only //$_SESSION["user"] = $uid; ///////////////////////////////////// // 99 - admin // 1 - general user // 2 - ucsc user // 3 - bit user if ($type == 99) { $output = json_encode(array("typee" => 0, "resultt" => 'application/views/admin/adminHome.php')); } elseif ($type == 1) { $output = json_encode(array("typee" => 0, "resultt" => 'application/views/user/userhomeOld.php')); } elseif ($type == 2) {