Server IP : 184.154.167.98 / Your IP : 3.135.247.24 Web Server : Apache System : Linux pink.dnsnetservice.com 4.18.0-553.22.1.lve.1.el8.x86_64 #1 SMP Tue Oct 8 15:52:54 UTC 2024 x86_64 User : puertode ( 1767) PHP Version : 7.2.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/puertode/public_html/oficios/classes/ |
Upload File : |
<?php include('password.php'); class User extends Password{ private $_db; function __construct($db){ parent::__construct(); $this->_db = $db; } private function get_user_hash($username){ try { $stmt = $this->_db->prepare('SELECT password, username, memberID, nombre, ap_pat, ap_mat FROM members WHERE username = :username AND active="Yes" '); $stmt->execute(array('username' => $username)); return $stmt->fetch(); } catch(PDOException $e) { echo '<p class="bg-danger">'.$e->getMessage().'</p>'; } } public function isValidUsername($username){ if (strlen($username) < 3) return false; if (strlen($username) > 17) return false; if (!ctype_alnum($username)) return false; return true; } public function login($username,$password){ if (!$this->isValidUsername($username)) return false; if (strlen($password) < 3) return false; $row = $this->get_user_hash($username); if($this->password_verify($password,$row['password']) == 1){ $_SESSION['loggedin'] = true; $_SESSION['username'] = $row['username']; $_SESSION['memberID'] = $row['memberID']; $_SESSION['nombre'] = $row['nombre']; return true; } } public function logout(){ session_destroy(); } public function is_logged_in(){ if(isset($_SESSION['loggedin']) && $_SESSION['loggedin'] == true){ return true; } } } ?>