isLoggedIn = false; $this->isLoggedInCliente = false; $this->isLoggedInSocieta = false; $this->dbconn = new dbconn(); $this->user = false; framework::$inst = $this; //$this->cliente = new cliente(); $this->societa = new societa(); if (isset($_SESSION['user']) && isset($_SESSION['usertype'])){ if($_SESSION['usertype'] == '0' || $_SESSION['usertype'] == '1' || $_SESSION['usertype'] == '2' || $_SESSION['usertype'] == '3'){ $this->user = new utenti(); $this->user->getUtentiByEmail($_SESSION['user']); //$this->user->userByName($_SESSION['user']); $this->isLoggedIn = true; } } // if (isset($_SESSION['cliente'])){ // //$this->cliente = new cliente; // $this->cliente->getClienteByEmail($_SESSION['cliente']); // //$this->user->userByName($_SESSION['user']); // $this->isLoggedInCliente = true; // } if (isset($_SESSION['user']) && isset($_SESSION['usertype']) ){ //$this->cliente = new cliente; } } public static function getDbconn(){ if (framework::$inst===NULL){ framework::$inst = new framework(); return framework::$inst->dbconn; } else{ return framework::$inst->dbconn; } } function isLogged(){ return $this->isLoggedIn; } function isLoggedCliente(){ return $this->isLoggedInCliente; } function isLoggedSocieta(){ return $this->isLoggedInSocieta; } function getCurrentUser(){ return $this->user; } function getCurrentCliente(){ return $this->cliente; } function getCurrentScieta(){ return $this->Societa; } function logIn($username,$pass){ if ($this->user = user::userByName($username)){ if ($this->user->verifyPassword($pass)){ $this->isLoggedIn = true; return true; } else{ $this->user = false; $this->isLoggedIn = false; return false; } } else{ $this->user = false; $this->isLoggedIn = false; return false; } } // function logIn($username,$pass){ // $utente = new utenti(); // $utente->getUtentiByEmail($username); // // if (!is_null($utente->getId())){ // $this->user = $utente; // if ($this->user->autenticato($pass)){ // $this->isLoggedIn = true; // return true; // } // else{ // $this->user = false; // $this->isLoggedIn = false; // return false; // } // } // else{ // $this->user = false; // $this->isLoggedIn = false; // return false; // } // // // } function logInCliente($username,$pass){ $this->cliente->getClienteByEmail($username); if (!is_null($this->cliente->getId())){ if ($this->cliente->verifyPassword($pass)){ $this->isLoggedInCliente = true; return true; } else{ $this->cliente = false; $this->isLoggedInCliente = false; return false; } } else{ $this->cliente = false; $this->isLoggedInCliente = false; return false; } } function logInSocieta($username,$pass){ $this->societa->getSocietaByEmail($username); if (!is_null($this->societa->getId())){ if ($this->societa->verifyPassword($pass)){ $this->isLoggedInSocieta = true; return true; } else{ $this->societa = false; $this->isLoggedInSocieta = false; return false; } } else{ $this->societa = false; $this->isLoggedInSocieta = false; return false; } } } ?>