| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- Class User {
- private $username = "";
- private $password = "";
- private $email = "";
- public function __construct($username) {
- if($username != NULL) {
- $this->username = $username;
- }
- }
- public function login($username, $password) {
- global $db;
- $this->username = $username;
- $this->password = $password;
- $user = $db->query("SELECT * FROM `users` WHERE `username` = '" . $username . "'");
- if($user->password === md5($password)) {
- $_SESSION['loggedIn'] = true;
- $_SESSION['username'] = $this->username;
- header("Location: http://vpn.mmnx.de/index.php?action=profile");
- } else {
- return false;
- }
- }
- public function logout() {
- $this->username = "";
- $this->password = "";
- $this->email = "";
- $_SESSION['loggedIn'] = false;
- unset($_SESSION['username']);
- session_destroy();
- header("Location: http://vpn.mmnx.de/index.php");
- }
- public function getClients() {
- global $db;
- //$clients = $db->query("SELECT * FROM `clients` WHERE `owned_by` = '" . $this->username . "'");
- //sizeof($clients);
- //return $clients->name;
- return $this->username;
- }
- }
- ?>
|