owls
view Includes/Loginsys.class.php @ 0:3021ce32ee14
begin of using hg for owls
author | "Meillo r e t u r n s <meillo@marmaro.de>" |
---|---|
date | Sun, 03 Dec 2006 22:32:13 +0100 |
parents | |
children | a3a651f0cac6 |
line source
1 <?php
3 define('TIME_SESSION_EXPIRES', 1800);
6 class Loginsys {
8 // Constructors
10 public function __construct() {
11 session_start();
12 $this->heartbeat();
13 }
18 // Methods
20 public function login($loginname, $password_md5) { // login ------------------------------------
21 $rowuser = mysql_fetch_array(mysql_query("select * from ". DB_PREFIX ."User where loginname='$loginname' and password='$password_md5' "));
22 if (mysql_affected_rows() == 1) { // valid login
23 $_SESSION[login][id] = $rowuser[id];
24 $_SESSION[login][loginname] = $loginname;
25 $_SESSION[login][logintime] = time();
26 }
27 }
31 public function logout() { // logout ------------------------------------------------------------
32 unset($_SESSION[login]);
33 }
37 public function loggedIn() { // return login-status ---------------------------------------------
38 return (isset($_SESSION[login][id]) && $_SESSION[login][logintime] > time()-TIME_SESSION_EXPIRES);
39 }
43 public function heartbeat() {
44 if ($this->loggedIn()) {
45 $_SESSION[login][logintime] = time();
46 }
47 }
51 // Getter and Setter
53 public function getUserId() {
54 return $_SESSION[login][id];
55 }
58 public function getLoginname() {
59 return $_SESSION[login][loginname];
60 }
62 }
65 ?>