# HG changeset patch # User Meillo r e t u r n s # Date 1166044619 -3600 # Node ID a3a651f0cac6c0ea588e12544f84de4a2867b0c6 # Parent f79096d1d0ed6eeaa7f8c81908138a39dae8a97b added doxygen-comments to Loginsys.class.php diff -r f79096d1d0ed -r a3a651f0cac6 .hgignore --- a/.hgignore Wed Dec 13 20:02:56 2006 +0100 +++ b/.hgignore Wed Dec 13 22:16:59 2006 +0100 @@ -7,3 +7,5 @@ _Dev Smilies + +Doxyfile diff -r f79096d1d0ed -r a3a651f0cac6 Includes/Loginsys.class.php --- a/Includes/Loginsys.class.php Wed Dec 13 20:02:56 2006 +0100 +++ b/Includes/Loginsys.class.php Wed Dec 13 22:16:59 2006 +0100 @@ -1,12 +1,27 @@ + */ class Loginsys { - // Constructors + /// Consts + /** + * time in seconds till the session expires + */ + define('TIME_SESSION_EXPIRES', 1800); + + + + /// Constructors + + /** + * starts the session + * and puts an activity timestamp in it + */ public function __construct() { session_start(); $this->heartbeat(); @@ -15,8 +30,15 @@ - // Methods + /// Methods + + /** + * trys to log in with the given login data + * + * @param $loginname username + * @param $password_md5 md5 password hash + */ public function login($loginname, $password_md5) { // login ------------------------------------ $rowuser = mysql_fetch_array(mysql_query("select * from ". DB_PREFIX ."User where loginname='$loginname' and password='$password_md5' ")); if (mysql_affected_rows() == 1) { // valid login @@ -27,19 +49,28 @@ } - + /** + * logs the user out + */ public function logout() { // logout ------------------------------------------------------------ unset($_SESSION[login]); } - + /** + * proves if the user is logged in and if he wan't to long inactive + * + * @return bool 'true' if user is logged in, else 'false' + */ public function loggedIn() { // return login-status --------------------------------------------- return (isset($_SESSION[login][id]) && $_SESSION[login][logintime] > time()-TIME_SESSION_EXPIRES); } - + /** + * writes the current timestamp into the session + * this is relevant for the time of inactivity + */ public function heartbeat() { if ($this->loggedIn()) { $_SESSION[login][logintime] = time(); @@ -48,13 +79,19 @@ - // Getter and Setter + /// Getter and Setter + + /** + * @return user id + */ public function getUserId() { return $_SESSION[login][id]; } - + /** + * @return user name + */ public function getLoginname() { return $_SESSION[login][loginname]; }