owls

diff Includes/Loginsys.class.php @ 7:a3a651f0cac6

added doxygen-comments to Loginsys.class.php
author Meillo r e t u r n s <meillo@marmaro.de>
date Wed, 13 Dec 2006 22:16:59 +0100
parents 3021ce32ee14
children eb5bff360deb
line diff
     1.1 --- a/Includes/Loginsys.class.php	Wed Dec 13 20:02:56 2006 +0100
     1.2 +++ b/Includes/Loginsys.class.php	Wed Dec 13 22:16:59 2006 +0100
     1.3 @@ -1,12 +1,27 @@
     1.4  <?php
     1.5 -
     1.6 -define('TIME_SESSION_EXPIRES', 1800);
     1.7 -
     1.8 -
     1.9 +/**
    1.10 + * simple loginsystem for owls
    1.11 + *
    1.12 + * @brief simple loginsystem for owls
    1.13 + * @author Meillo  r e t u r n s <meillo@marmaro.de>
    1.14 + */
    1.15  class Loginsys {
    1.16  
    1.17 -  // Constructors
    1.18 +  /// Consts
    1.19  
    1.20 +  /**
    1.21 +   * time in seconds till the session expires
    1.22 +   */
    1.23 +  define('TIME_SESSION_EXPIRES', 1800);
    1.24 +
    1.25 +
    1.26 +
    1.27 +  /// Constructors
    1.28 +
    1.29 +  /**
    1.30 +   * starts the session
    1.31 +   * and puts an activity timestamp in it
    1.32 +   */
    1.33    public function __construct() {
    1.34      session_start();
    1.35      $this->heartbeat();
    1.36 @@ -15,8 +30,15 @@
    1.37  
    1.38  
    1.39  
    1.40 -  // Methods
    1.41 +  /// Methods
    1.42  
    1.43 +
    1.44 +  /**
    1.45 +   * trys to log in with the given login data
    1.46 +   *
    1.47 +   * @param $loginname username
    1.48 +   * @param $password_md5 md5 password hash
    1.49 +   */
    1.50    public function login($loginname, $password_md5) {    // login ------------------------------------
    1.51      $rowuser = mysql_fetch_array(mysql_query("select * from ". DB_PREFIX ."User where loginname='$loginname' and password='$password_md5' "));
    1.52      if (mysql_affected_rows() == 1) {  // valid login
    1.53 @@ -27,19 +49,28 @@
    1.54    }
    1.55  
    1.56  
    1.57 -
    1.58 +  /**
    1.59 +   * logs the user out
    1.60 +   */
    1.61    public function logout() {    // logout ------------------------------------------------------------
    1.62      unset($_SESSION[login]);
    1.63    }
    1.64  
    1.65  
    1.66 -
    1.67 +  /**
    1.68 +   * proves if the user is logged in and if he wan't to long inactive
    1.69 +   *
    1.70 +   * @return bool 'true' if user is logged in, else 'false'
    1.71 +   */
    1.72    public function loggedIn() {    // return login-status ---------------------------------------------
    1.73      return (isset($_SESSION[login][id]) && $_SESSION[login][logintime] > time()-TIME_SESSION_EXPIRES);
    1.74    }
    1.75  
    1.76  
    1.77 -
    1.78 +  /**
    1.79 +   * writes the current timestamp into the session
    1.80 +   * this is relevant for the time of inactivity
    1.81 +   */
    1.82    public function heartbeat() {
    1.83      if ($this->loggedIn()) {
    1.84        $_SESSION[login][logintime] = time();
    1.85 @@ -48,13 +79,19 @@
    1.86  
    1.87  
    1.88  
    1.89 -  // Getter and Setter
    1.90 +  /// Getter and Setter
    1.91  
    1.92 +
    1.93 +  /**
    1.94 +   * @return user id
    1.95 +   */
    1.96    public function getUserId() {
    1.97      return $_SESSION[login][id];
    1.98    }
    1.99  
   1.100 -
   1.101 +  /**
   1.102 +   * @return user name
   1.103 +   */
   1.104    public function getLoginname() {
   1.105      return $_SESSION[login][loginname];
   1.106    }