owls

changeset 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 f79096d1d0ed
children 2672cd855fa2
files .hgignore Includes/Loginsys.class.php
diffstat 2 files changed, 50 insertions(+), 11 deletions(-) [+]
line diff
     1.1 --- a/.hgignore	Wed Dec 13 20:02:56 2006 +0100
     1.2 +++ b/.hgignore	Wed Dec 13 22:16:59 2006 +0100
     1.3 @@ -7,3 +7,5 @@
     1.4  _Dev
     1.5  
     1.6  Smilies
     1.7 +
     1.8 +Doxyfile
     2.1 --- a/Includes/Loginsys.class.php	Wed Dec 13 20:02:56 2006 +0100
     2.2 +++ b/Includes/Loginsys.class.php	Wed Dec 13 22:16:59 2006 +0100
     2.3 @@ -1,12 +1,27 @@
     2.4  <?php
     2.5 -
     2.6 -define('TIME_SESSION_EXPIRES', 1800);
     2.7 -
     2.8 -
     2.9 +/**
    2.10 + * simple loginsystem for owls
    2.11 + *
    2.12 + * @brief simple loginsystem for owls
    2.13 + * @author Meillo  r e t u r n s <meillo@marmaro.de>
    2.14 + */
    2.15  class Loginsys {
    2.16  
    2.17 -  // Constructors
    2.18 +  /// Consts
    2.19  
    2.20 +  /**
    2.21 +   * time in seconds till the session expires
    2.22 +   */
    2.23 +  define('TIME_SESSION_EXPIRES', 1800);
    2.24 +
    2.25 +
    2.26 +
    2.27 +  /// Constructors
    2.28 +
    2.29 +  /**
    2.30 +   * starts the session
    2.31 +   * and puts an activity timestamp in it
    2.32 +   */
    2.33    public function __construct() {
    2.34      session_start();
    2.35      $this->heartbeat();
    2.36 @@ -15,8 +30,15 @@
    2.37  
    2.38  
    2.39  
    2.40 -  // Methods
    2.41 +  /// Methods
    2.42  
    2.43 +
    2.44 +  /**
    2.45 +   * trys to log in with the given login data
    2.46 +   *
    2.47 +   * @param $loginname username
    2.48 +   * @param $password_md5 md5 password hash
    2.49 +   */
    2.50    public function login($loginname, $password_md5) {    // login ------------------------------------
    2.51      $rowuser = mysql_fetch_array(mysql_query("select * from ". DB_PREFIX ."User where loginname='$loginname' and password='$password_md5' "));
    2.52      if (mysql_affected_rows() == 1) {  // valid login
    2.53 @@ -27,19 +49,28 @@
    2.54    }
    2.55  
    2.56  
    2.57 -
    2.58 +  /**
    2.59 +   * logs the user out
    2.60 +   */
    2.61    public function logout() {    // logout ------------------------------------------------------------
    2.62      unset($_SESSION[login]);
    2.63    }
    2.64  
    2.65  
    2.66 -
    2.67 +  /**
    2.68 +   * proves if the user is logged in and if he wan't to long inactive
    2.69 +   *
    2.70 +   * @return bool 'true' if user is logged in, else 'false'
    2.71 +   */
    2.72    public function loggedIn() {    // return login-status ---------------------------------------------
    2.73      return (isset($_SESSION[login][id]) && $_SESSION[login][logintime] > time()-TIME_SESSION_EXPIRES);
    2.74    }
    2.75  
    2.76  
    2.77 -
    2.78 +  /**
    2.79 +   * writes the current timestamp into the session
    2.80 +   * this is relevant for the time of inactivity
    2.81 +   */
    2.82    public function heartbeat() {
    2.83      if ($this->loggedIn()) {
    2.84        $_SESSION[login][logintime] = time();
    2.85 @@ -48,13 +79,19 @@
    2.86  
    2.87  
    2.88  
    2.89 -  // Getter and Setter
    2.90 +  /// Getter and Setter
    2.91  
    2.92 +
    2.93 +  /**
    2.94 +   * @return user id
    2.95 +   */
    2.96    public function getUserId() {
    2.97      return $_SESSION[login][id];
    2.98    }
    2.99  
   2.100 -
   2.101 +  /**
   2.102 +   * @return user name
   2.103 +   */
   2.104    public function getLoginname() {
   2.105      return $_SESSION[login][loginname];
   2.106    }