<?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); $email = "*****@*****.**"; $password = "******"; $repeatpassword = "******"; $remember = "0"; echo '<pre>'; $result = $auth->login($email, $password, $remember); //if login deatile correct create session if (!$result['error']) { setcookie('authIDD', $result["hash"], $result["expire"], '/'); } var_dump($result); echo '<br>';
/** * Возвращает данные пользователя, если он авторизирован.<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); }
session_start(); if (isset($_POST["username"]) && isset($_POST["password"])) { //check if its an ajax request, exit if not if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) and strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest') { //exit script outputting json data $output = json_encode(array("typee" => 1, "resultt" => 'Sorry Request must be Ajax POST')); die($output); } // Data base connetion and Auth class 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); //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']; //////////////////////////////////////
<?php require "../../config/config.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); if (!$auth->isLogged()) { header('HTTP/1.0 403 Forbidden'); echo "Forbidden"; exit; } else { echo "ok"; } // only work with vies/xx can't nested more than that ?> <html> <head></head> <body> <h1>GENARAL</h1> <?php $uid = $auth->getSessionUID($auth->getSessionHash()); $result = $auth->getUser($uid); echo '<pre>';
//$uid =61; $item_per_page = 4; //need to put this configuration file require "../../models/DB/Db.class.php"; $db = new Db(); $get_total_rows = 0; $lessons = $db->query("SELECT COUNT(*) FROM lesson"); $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">
<?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>';
<?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); $email = "*****@*****.**"; $password = "******"; $repeatpassword = "******"; $key = "03AHJ_VusDysdsdsldk6nNgaBFahjAIlwHyrxod-1WIyiqWjmUmxVTkNCGxkA8y21CZyDiu_03sS0qwNRgLU-8sjNIAYcANipvcjBuWFgOee_FwU7rOL36eQLxJovDXXyUGgvVpLI7aPthpN_GuF7d7-qRDMwqzfUbQnDhzx0Dmdxl4jjDEen7NbtJ4Rs5SiFxme_ujF05jGy2e1x5GCT1M5AnPzCY7P7-_BEsP_RQw-Ja1J07pRVADq3e7KwMZZ027nmc-7PB8ehgWDBcG6rENnBj_KjjGKftZ-z7B1zZh1grI_gYMidPXnpP9reEcnLhu4fveoVBwqSZ1RyR0qhjV3RZZ2OxBBUpB-rEeVDxDwPHT4hhmZ-ceo4hWfacaRtoMe7x3IJlZr5EoTZv1g9vSTs52q0fPUuuc2QEHLz-ZUkMWzgSwxyYrV9xhE5qplrlvKs_4mszM3b70ZiWFR2TIS4"; $params = array("A" => "apple", "B" => "orange", "C" => "how"); echo '<pre>'; $result = $auth->register($email, $password, $repeatpassword, $params); var_dump($result); echo '<br>';
<?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); $uid = $auth->getSessionUID($auth->getSessionHash()); $password = "******"; $password2 = "ucsc@123!@#AB"; $result = $auth->changePassword($uid, $password, $password2, $password2); echo '<pre>'; var_dump($result); echo '<br>';
<?php require "../DB/Db.class.php"; $db = new Db(); //var_dump($db->getPurePodo()); $dbh = $db->getPurePodo(); include "Config.php"; include "Auth.php"; //$dbh = new PDO("mysql:host=localhost;dbname=user_login", "root", "root") or Die("lolo"); $config = new PHPAuth\Config($dbh); $auth = new PHPAuth\Auth($dbh, $config); $email = "*****@*****.**"; $password = "******"; $repeatpassword = "******"; $params = array("A" => "apple", "B" => "orange", "C" => "how"); var_dump($params); //var_dump($auth->register($email,$password,$repeatpassword ,$params)); echo '<br>'; $temp = $auth->login($email, $password); var_dump($temp); echo '<br>'; //echo $temp; //setcookie("authID", "", time() - 360000000); setcookie('authID', $temp["hash"], $temp["expire"]);
public function actionReset() { $dbh = Db::getConnection(); $config = new PHPAuth\Config($dbh); $auth = new PHPAuth\Auth($dbh, $config, $language = "ru_RU"); $result = false; if (isset($_POST['submit'])) { $key = $_POST['key']; $password = $_POST['password']; $confirm_password = $_POST['confirm_password']; $result = $auth->resetPass($key, $password, $confirm_password); } return $this->render('user/reset', ['title' => 'Сброс пароля', 'result' => $result]); }
<?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); $userhash = $auth->getSessionHash(); $uid = $auth->getSessionUID($userhash); $result = $auth->getUser($uid); $email = $result['email']; $firstname = $result['firstName']; $lastname = $result['Lastname']; $username = $result['username']; ?> <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">
<?php if ($_POST) { //check if its an ajax request, exit if not if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) and strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest') { $output = json_encode(array('type' => 'error', 'text' => 'Sorry Request must be Ajax POST')); die($output); //exit script outputting json data } 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); $newemail = filter_var($_POST["newemail"], FILTER_SANITIZE_STRING); $currentPassword = filter_var($_POST["currentPassword"], FILTER_SANITIZE_STRING); $result = $auth->changeEmail($uid, $newemail, $currentPassword); if (!$result['error']) { $output = json_encode(array('type' => 'text', 'text' => "<div class='alert alert-success'><a href='#' class='close' data-dismiss='alert' aria-label='close'>×</a><strong>Success!</strong>" . $result['message'] . "</div>")); } else { $output = json_encode(array('type' => 'error', 'text' => "<div class='alert alert-danger'><a href='#' class='close' data-dismiss='alert' aria-label='close'>×</a><strong>Warning!</strong>" . $result['message'] . "</div>")); } die($output); }
<?php if (!isset($_SERVER['HTTP_X_REQUESTED_WITH'])) { die; } // Data base connetion and Auth class 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); if (isset($_FILES["FileInput1"]) && $_FILES["FileInput1"]["error"] == UPLOAD_ERR_OK) { //check if this is an ajax request if (!isset($_SERVER['HTTP_X_REQUESTED_WITH'])) { die; } //allowed file type Server side check switch (strtolower($_FILES['FileInput1']['type'])) { //allowed file types case 'text/plain': break; default: die('Unsupported File Please upload txt file!'); //output error } } else { die('Something wrong with upload! Is "upload_max_filesize" set correctly?'); } set_error_handler('exceptions_error_handler');
<?php include "Config.php"; include "Auth.php"; $dbh = new PDO("mysql:host=localhost;dbname=user_login", "root", "root") or die("lolo"); $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"; }
<?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); $email = "*****@*****.**"; //$password = "******"; //$repeatpassword = "******"; // //$key = "03AHJ_VusDysdsdsldk6nNgaBFahjAIlwHyrxod-1WIyiqWjmUmxVTkNCGxkA8y21CZyDiu_03sS0qwNRgLU-8sjNIAYcANipvcjBuWFgOee_FwU7rOL36eQLxJovDXXyUGgvVpLI7aPthpN_GuF7d7-qRDMwqzfUbQnDhzx0Dmdxl4jjDEen7NbtJ4Rs5SiFxme_ujF05jGy2e1x5GCT1M5AnPzCY7P7-_BEsP_RQw-Ja1J07pRVADq3e7KwMZZ027nmc-7PB8ehgWDBcG6rENnBj_KjjGKftZ-z7B1zZh1grI_gYMidPXnpP9reEcnLhu4fveoVBwqSZ1RyR0qhjV3RZZ2OxBBUpB-rEeVDxDwPHT4hhmZ-ceo4hWfacaRtoMe7x3IJlZr5EoTZv1g9vSTs52q0fPUuuc2QEHLz-ZUkMWzgSwxyYrV9xhE5qplrlvKs_4mszM3b70ZiWFR2TIS4"; // // //$params = array("firstName" => "chamath","Lastname" => "silva", "username" => "chamathsilva","type" => '1'); // // echo '<pre>'; // //$tets1 = "Hello world"; // // $result= $auth->register($email,$password,$password,$params,$tets1 ); // var_dump($result); // // echo '<br>'; //#activation Part // echo '<pre>'; // $result= $auth->activate('02CHi7Z2o8hBtf0w61At'); // var_dump($result); // echo '<br>';
<?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"; }
<?php require "../../config/config.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); if (!$auth->isLogged()) { header('HTTP/1.0 403 Forbidden'); echo "Forbidden"; exit; } else { echo "ok"; } // only work with vies/xx can't nested more than that
<?php if ($_POST) { //check if its an ajax request, exit if not if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) and strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest') { $output = json_encode(array('type' => 'error', 'text' => 'Sorry Request must be Ajax POST')); die($output); //exit script outputting json data } 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); $currentPassword = filter_var($_POST["currentPassword"], FILTER_SANITIZE_STRING); $newPassword = filter_var($_POST["newPassword"], FILTER_SANITIZE_STRING); $confirmPassword = filter_var($_POST["confirmPassword"], FILTER_SANITIZE_STRING); $result = $auth->changePassword($uid, $currentPassword, $newPassword, $confirmPassword); if (!$result['error']) { $output = json_encode(array('type' => 'text', 'text' => "<div class='alert alert-success'><a href='#' class='close' data-dismiss='alert' aria-label='close'>×</a><strong>Success!</strong>" . $result['message'] . "</div>")); } else { $output = json_encode(array('type' => 'error', 'text' => "<div class='alert alert-danger'><a href='#' class='close' data-dismiss='alert' aria-label='close'>×</a><strong>Warning!</strong>" . $result['message'] . "</div>")); } die($output); }
<?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); $email = "*****@*****.**"; $password = "******"; $repeatpassword = "******"; echo '<pre>'; $result = $auth->logout($auth->getSessionHash()); var_dump($result); //header('location: ../../../index.php'); echo '<br>';
<?php // Data base connetion and Auth class 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); $firstname = filter_var($_POST["First_Name"], FILTER_SANITIZE_STRING); $lastname = filter_var($_POST["Last_Name"], FILTER_SANITIZE_STRING); $username = filter_var($_POST["regUser_Name"], FILTER_SANITIZE_STRING); $email = filter_var($_POST["E_mail"], FILTER_SANITIZE_STRING); $password = filter_var($_POST["regPassword"], FILTER_SANITIZE_STRING); $passwordconform = filter_var($_POST["password_again"], FILTER_SANITIZE_STRING); $tems = filter_var(isset($_POST["terms"])); $key = $_POST['g-recaptcha-response']; $params = array("firstName" => "{$firstname}", "Lastname" => "{$lastname}", "username" => "{$username}", "type" => '1'); $result = $auth->register($email, $password, $passwordconform, $params, $sendmail = true); if ($result['error']) { // if registration not complete $output = json_encode(array("typee" => 1, "resultt" => $result['message'])); } else { $uid = $auth->getUID($email); $db->query("INSERT INTO recentlesson (user_id,lesson_id) VALUES (:uid, '0')", array("uid" => $uid)); $output = json_encode(array("typee" => 0, "resultt" => $result['message'])); } //$output = json_encode(array("typee" => 1, "resultt" => "$key--$firstname -- $lastname -- $username -- $email -- $password -- $passwordconform -- $tems ")); die($output);