public function run() { require_once $this->sysRoot . '/Model/appModel.php'; require_once $this->sysRoot . '/Model/loginModel.php'; $loginModel = new loginModel($this->sysRoot, $_POST); $loginData = $loginModel->run(); if (!empty($loginData)) { // success to login $_SESSION['name'] = $loginData['name']; header('Location: /'); } else { // faild to login header('Location: /login'); } }
public function startLogin() { $login = new loginModel(); $login->email = $_POST['email']; $login->password = $_POST['password']; #this follows our system sequence diagram # call processLogin which returns a bool val $validLogin = $login->processLogin(); if ($validLogin == true) { //self::showHomePage(); header('Location:survey.php'); } else { return; } }
public function login_user() { $email = Input::get('email'); $password = Input::get('password'); $ObjLogin = new loginModel(); $login = $ObjLogin->validate_login($email, $password); if ($login['contact_id']) { return Redirect::to($this->default_login_page)->with('message', $login['message']); } else { if ($login['contact_status'] == 'Contact Not Exist') { return Redirect::to('register')->with('message', $login['message']); } else { return Redirect::to('login')->with('message', $login['message']); } } }
public function logout($parameters = array()) { $currentuser = myauth::getCurrentuser(); if ($currentuser->getId() == $parameters['userid']) { // The user himself wants to logout // Get it of the server $loginModel = new loginModel(); $loginModel->deletebyUserid($parameters['userid']); // Get it of the client setcookie('userid', '', time() - 60 * 60 * 24 * 356); setcookie('challenge', '', time() - 60 * 60 * 24 * 356); // No auto-login after a logout setcookie('noremoteuser', 'TRUE'); // Refresh the page $this->response->redirect(); } else { // Someone wants to logout someone else, that's not allowed throw new securityException(); } }
public function check() { if (isset($_POST['nome'])) { $usuario = $_POST['nome']; } else { $usuario = null; } if (isset($_POST['senha'])) { $senha = $_POST['senha']; } else { $senha = null; } //list all records $model_login = new loginModel(); $login_res = $model_login->getLogin("nome='" . $usuario . "' and senha='" . $senha . "'"); //Full table Scan :( or :) if (sizeof($login_res) > 0) { $usuario_res = $login_res[0]['nome']; $senha_res = $login_res[0]['senha']; if ($usuario == $usuario_res) { if ($senha == $senha_res) { $this->sessao_grava($usuario_res); $this->smarty->display('home/home.tpl'); } else { $msg_login = '******'; $this->smarty->display('index/index.tpl'); } } else { $msg_login = '******'; $this->smarty->display('index/index.tpl'); } } else { $msg_login = '******'; $this->smarty->display('index/index.tpl'); } }
public function getUsers($user_id) { if (empty(self::$conn)) { self::$conn = $this->connect_pdo(); } $sql = "SELECT username,CONCAT_WS(' ',firstname,lastname) AS name,email FROM users WHERE user_id=?"; $stmt = self::$conn->prepare($sql); $stmt->bindParam(1, $user_id); $stmt->execute(); $stmt->setFetchMode(PDO::FETCH_ASSOC); $users = array(array()); $i = 0; while ($row = $stmt->fetch()) { $users[$i++] = $row; } $i--; return $users; }
public static function setCurrentuser($user) { $challenge = uniqid(); $userid = $user->getId(); $loginModel = new loginModel(); $login = new loginObject(); $login->setUserid($userid); $login->setChallenge($challenge); $login->setTime(time()); // Save it on the server $loginModel->save($login); // And save it on the client setcookie('userid', $userid); setcookie('challenge', $challenge); // Clean out stale logins for this user (older than 24h) $idCond['id'] = array('mode' => '!=', 'value' => $login->getId()); $useridCond['userid'] = array('mode' => '=', 'value' => $userid); $timeCond['time'] = array('mode' => '<', 'value' => time() - 60 * 60 * 24); $condition['AND'] = array($idCond, $useridCond, $timeCond); $loginModel->delete($condition); self::$currentuser = $user; }
<?php require_once 'loginModel.class.php'; @($actionType = $_POST['actionType']); $email = addslashes(trim($_POST['email'])); if ($actionType == 'email_ajax' && !empty($email)) { $loginModel = new loginModel(); $res = $loginModel->email_exists($email); if ($res) { $valid = true; } else { $valid = false; } echo json_encode(array('valid' => $valid)); } else { $password = md5(addslashes(trim($_POST['password']))); $loginModel = new loginModel(); if (!empty($email) && !empty($password) && $loginModel->loginAction($email, $password)) { ob_start(); @Header("Location: index.php"); ob_end_flush(); } else { ob_start(); @Header("Location: /sign.html"); ob_end_flush(); } }
<?php class loginModel extends baseModel { public function __construct() { parent::__construct(); } public function veritabaniBasla($kadi, $sifre) { $db = $this->_db; $say = $db->prepare("SELECT count(*) FROM t_kul_kullanici\n WHERE kul_adi = :kadi AND kul_sifre = :sifre"); $say->bindValue(':kadi', $kadi, PDO::PARAM_STR); $say->bindValue(':sifre', $sifre, PDO::PARAM_STR); $say->execute(); return $say->fetchColumn(); } public function veritabaniKontrol() { $db = DB::getInstance(); $say = $db->prepare("SELECT * FROM t_kul_kullanici\n WHERE kul_kadi = :kadi AND kul_yenisifre = :sifre\n "); $say->bindValue(':kadi', $_SESSION['_kadi'], PDO::PARAM_STR); $say->bindValue(':sifre', $_SESSION['_sifre'], PDO::PARAM_STR); $say->execute(); return $say->fetchColumn(); } } $a = new loginModel(); $a->veritabaniBasla('admin', 'e10adc3949ba59abbe56e057f20f883e');