Changeset 282

Show
Ignore:
Timestamp:
06/02/07 12:37:47
Author:
grahack
Message:

minor: refactored the comments of FreakAuth-light lib

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • FreakAuth/trunk/www/system/application/libraries/Freakauth_light.php

    r273 r282  
    22/** 
    33 * FreakAuth_light Class 
    4  * Security handler that provides functionality to handle login, logout, registration, 
    5  * and reset password requests.   
     4 * Security handler that provides functionality to handle login, logout, 
     5 * registration, and reset password requests. 
    66 * It also can verify the logged in status of 3 user classes 
    7  *  
     7 * 
    88 * => superadmin (has permissions on everything and can also create other admin) 
    9  * => admin            (you can choose what to let him manage) 
    10  * => user              (it is a registered user, and you can decide to give in rights to acces
    11  *                               some specific areas (controllers) of your application 
     9 * => admin      (you can choose what to let him manage) 
     10 * => user       (it is a registered user, and you can decide to give in right
     11 *               to access some specific areas (controllers) of your application 
    1212 * 
    1313 * The class requires the use of 
    14  *  
     14 * 
    1515 * => Database CI official library 
    1616 * => Db_session, FAL_validation and the FAL_front library (included in the download) 
    1717 * => URL, FORM and FreakAuth_light (included in the download) helpers 
    18  *  
     18 * 
    1919 * The FreakAuth_light library should be auto loaded in the core classes section 
    2020 * of the autoloader. 
    21  *  
     21 * 
    2222 * Passwords are encripted with md5 algorithm by the method _encode($password) 
    23  *  
    24  * --------------------------------------------------------------------------------- 
     23 * 
     24 * ----------------------------------------------------------------------------- 
    2525 * Copyright (C) 2007  Daniel Vecchiato (4webby.com) 
    26  * --------------------------------------------------------------------------------- 
     26 * ----------------------------------------------------------------------------- 
    2727 *This library is free software; you can redistribute it and/or 
    2828 *modify it under the terms of the GNU Lesser General Public 
     
    3838 *License along with this library; if not, write to the Free Software 
    3939 *Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA 
    40  *----------------------------------------------------------------------------------- 
     40 *------------------------------------------------------------------------------ 
    4141 * @package     FreakAuth_light 
    4242 * @subpackage  Libraries 
     
    5959 * library.  The Auth library should be auto loaded in the core classes section 
    6060 * of the autoloader. 
    61  *  
     61 * 
    6262 * Passwords are encripted with md5 algorithm. 
    6363 */ 
    6464class Freakauth_light 
    65 {        
    66         // -------------------------------------------------------------------- 
    67          
    68         /** 
    69         * Function FreakAuth inizialises the class loading the right libraries, helpers and models 
    70         *  
    71         * @uses libraries (encrypt, db_session), helpers (form, url, FreakAuth), modules (usermodel) 
    72         * */ 
     65
     66    // -------------------------------------------------------------------- 
     67     
     68    /** 
     69    * Function FreakAuth inizialises the class loading the right libraries, 
     70    * helpers and models 
     71    * 
     72    * @uses libraries (encrypt, db_session) 
     73    * @uses helpers (form, url, FreakAuth) 
     74    * @uses modules (usermodel) 
     75    */ 
    7376    function Freakauth_light() 
    7477    { 
     
    8891        $this->_init(); 
    8992    } 
    90          
     93 
    9194    // -------------------------------------------------------------------- 
    9295     
     
    98101    function _init() 
    99102    { 
    100         //checks if the Freakauth system is turned on 
     103        // checks if the Freakauth system is turned on 
    101104        if (!$this->CI->config->item('FAL')) 
    102105        { 
     
    119122        
    120123    /** 
    121      * Method used to restrict acess to controllers or methods of controllers to the specified category of users 
    122      * it requires 2 optional parameters 
    123      * The first parameterspecifies the user group i.e. ('admin') 
    124      * The second parameter specifies whether the area is reserved ONLY to that group (true) or if it is accessible by groups higher in the hierarchy 
    125      *  
     124     * Method used to restrict acess to controllers or methods of controllers 
     125         * to the specified category of users. 
     126     * It requires 2 optional parameters: 
     127     *  - the first parameterspecifies the user group i.e. ('admin') 
     128     *  - the second parameter specifies whether the area is reserved ONLY to 
     129         *    that group (true) or if it is accessible by groups higher in the 
     130         *    hierarchy 
     131     * 
    126132     * example usage in a controller 
    127      *  
    128      * 1) $this->freakauth_light->check()  //this restricts acess to registered users and user-groups higher in the hierarchy (i.e. admin, superadmin) 
    129      * 2) $this->freakauth_light->check('admin')  //this restricts acess to 'admin' and user-groups higher in the hierarchy (i.e. superadmin) 
    130      * 3) $this->freakauth_light->check('admin', true)  //this restricts acess to 'admin' ONLY 
    131      *  
    132      * @param string (to specify the role to whom the area is restricted to) $lock_to_role 
     133     * 
     134     * 1) $this->freakauth_light->check() 
     135         *    this restricts access to registered users and user-groups higher in 
     136         *    the hierarchy (i.e. admin, superadmin) 
     137     * 2) $this->freakauth_light->check('admin') 
     138         *    this restricts access to 'admin' users and users who belong to roles 
     139         *    higher in the hierarchy (i.e. 'superadmin') 
     140     * 3) $this->freakauth_light->check('admin', true) 
     141         *    this restricts access to 'admin' users ONLY 
     142     * 
     143     * @param string (the role to whom the area is restricted to) $lock_to_role 
    133144     * @param boolean (true/false) $only 
    134145     */ 
     
    136147    { 
    137148 
    138                 //check who did the request and build role hierarchy 
     149                // check who did the request and build role hierarchy 
    139150                $_who_is = $this->CI->db_session->userdata('role'); 
    140151                 
    141                 //if we have a role stored in DB session for this user 
     152                // if we have a role stored in DB session for this user 
    142153                if ($this->CI->db_session AND $this->CI->config->item('FAL') AND !empty($_who_is)) 
    143                 {       
     154                { 
    144155                     
    145                     //gets the locked role hierarchy value 
     156                    // gets the locked role hierarchy value 
    146157                    $_hierarchy = $this->CI->config->item('FAL_roles'); 
    147158                     
    148                     //if we didn't specify to who we will reserve the action 
    149                                //let's restrict it to registered users 
     159                    // if we didn't specify to who we will reserve the action 
     160                // let's restrict it to registered users 
    150161                    if ($_lock_to_role==null){$_lock_to_role='user';} 
    151162                     
    152                     //let's see who did we reserve the area to 
     163                    // let's see who did we reserve the area to 
    153164                    $_lock_hierarchy = $_hierarchy[$_lock_to_role]; 
    154                     //let's see who requested to access this area 
     165                    // let's see who requested to access this area 
    155166                    $_request_hierarchy = $_hierarchy[$_who_is]; 
    156                                  
    157                                //let's see if we decided to restrict access ONLY to a given category 
     167 
     168                // let's see if we decided to restrict access ONLY to a given category 
    158169                    switch ($_only) 
    159170                    { 
     
    162173                                break; 
    163174                         
    164                         //only false or not specified  
     175                        // only false or not specified         
    165176                        default: 
    166177                                $_request_hierarchy <= $_lock_hierarchy ? $_condition = true : $_condition = false; 
     
    169180                    } 
    170181                     
    171                     //if who did the request doesn't have enough credentials 
     182                    // if who did the request doesn't have enough credentials 
    172183                    if ($_condition==false) 
    173184                    { 
     
    175186                    } 
    176187                } 
    177                 //it means it is a guest because it has no role stored in DB_session  
     188                // it means it is a guest because it has no role stored in DB_session 
    178189                else 
    179190                { 
     
    196207     * ------------------------------- 
    197208     * $this->freakauth_light->denyAccess('user') 
    198      *  
     209     * 
    199210     * @param string the role of the one we are denying the access 
    200211     */ 
     
    263274     * Returns false if FreakAuth system is not activated 
    264275     * Returns true if admin or superadmin, otherwise false 
    265      *  
     276     * 
    266277     * @return true if admin/superadmin or false otherwise 
    267278     */ 
     
    280291        } 
    281292                 
    282         //if user_id not activated or not existent 
     293        // if user_id not activated or not existent 
    283294        return false; 
    284     }  
     295    } 
    285296 
    286297    // -------------------------------------------------------------------- 
     
    291302     * Returns false if FreakAuth system is not activated 
    292303     * Returns true if superadmin, otherwise false 
    293      *  
     304     * 
    294305     * @return boolean 
    295306     */ 
     
    306317                return true; 
    307318        } 
    308                  
     319 
    309320        return false; 
    310     }  
     321    } 
    311322    // -------------------------------------------------------------------- 
    312323     
     
    315326     * Returns false if FreakAuth system is not activated 
    316327     * Returns true if a valid user is logged, false otherwise 
    317      *  
     328     * 
    318329     * @return boolean 
    319330     */ 
     
    326337                return true; 
    327338        } 
    328                  
    329         //if user not activated or not existent 
     339 
     340        // if user not activated or not existent 
    330341        return false; 
    331     }  
    332      
    333     // -------------------------------------------------------------------- 
    334      
    335     /** 
    336      * Method used to used to check if a logged in members belongs to the custom role (group) specified in the first parameter 
    337      * it requires 2 optional parameters 
    338      * The first parameter specifies the user groups as a comma separated string (NB: just comma separated WITHOUT SPACES->'user,admin'<--RIGHT 'user,admin'<--WRONG) 
    339      * The second parameter specifies whether we want to check to the specified groups ONLY or for AT LEAST those group membership in the hierarchy 
    340      * (returns true also if the logged user belongs to a group higher in the hierarchy) 
    341      *  
    342      * example usage in a controller (see the relative helper belongsToGroup() to use it in views) 
    343      *  
    344      * 1) $this->freakauth_light->belongsToGroup()  //returns true if the visitor is logged in and he is AT LEAST an user 
    345      * 2) $this->freakauth_light->belongsToGroup('user,editor')  //returns true if the visitor is logged in and he is AT LEAST an user or an editor (therefore it returns true also if he belongs to user-groups higher in the hierarchy (i.e. superadmin) 
    346      * 3) $this->freakauth_light->belongsToGroup('admin', true)  //this true if the visitor is logged in and is an 'admin' ONLY  
    347      *  
    348      * @param string containing comma separated user groups i.e. "user,editor,moderator" 
     342    } 
     343     
     344    // -------------------------------------------------------------------- 
     345     
     346    /** 
     347     * Method used to used to check if a logged in members belongs to the custom 
     348     * role (group) specified in the first parameter. 
     349     * It requires 2 optional parameters: 
     350     *  - the first specifies the user roles as a comma separated string 
     351     *  - the second specifies whether we want to check to the specified roles 
     352     *    ONLY or for AT LEAST those group membership in the hierarchy 
     353     *    (returns true also if the logged user belongs to a group higher 
     354     *     in the hierarchy) 
     355     * 
     356     * example usage in a controller 
     357     * (see the relative helper belongsToGroup() to use it in views) 
     358     * 
     359     * 1) $this->freakauth_light->belongsToGroup() 
     360     *    returns true if the visitor is logged in and he is AT LEAST an user 
     361     * 2) $this->freakauth_light->belongsToGroup('user,editor') 
     362     *    returns true if the visitor is logged in and he is AT LEAST an user 
     363     *    or an editor (therefore it returns true also if he belongs to 
     364     *    user-groups higher in the hierarchy (i.e. superadmin) 
     365     * 3) $this->freakauth_light->belongsToGroup('admin', true) 
     366     *    this true if the visitor is logged in and is an 'admin' ONLY 
     367     * 
     368     * @param string with comma separated user roles: "user,editor,moderator" $_group 
    349369     * @param boolean $_only 
    350370     * @return true/false 
     
    359379            if ($_username != false AND $_who_is != false) 
    360380            { 
    361                     //if we didn't specify who we are looking for  
    362                                //let's look if the request comes from an 'user' 
     381                // if we didn't specify who we are looking for 
     382                // let's look if the request comes from an 'user' 
    363383                    if ($_group==null){$_group='user';} 
    364384  
    365385                    $_groups = explode(",", $_group); 
    366                                 
     386         
    367387                    $_group = array(); 
    368                     //eliminate possible whitespaces at the beginning and end of groups names 
    369                    //passed as parameters to this function 
     388                // eliminate possible whitespaces at the beginning and end 
     389                // of groups names passed as parameters to this function 
    370390                    foreach($_groups as $_grp) 
    371391                    { 
    372392                        $_group[] = trim($_grp); 
    373393                    } 
    374                                  
    375                                 //let's see if we decided to check if it belongs ONLY to a given group 
     394 
     395                // let's see if we decided to check if 
     396                // it belongs ONLY to a given group 
    376397                    switch ($_only) 
    377398                    {    
    378                         //$_only = true 
     399                        // $_only = true 
    379400                        case true: //we decided to check if it belongs ONLY to a given group 
    380401                                in_array($_who_is, $_group) ? $_condition = true : $_condition = false; 
    381402                                break; 
    382403                         
    383                         //$_only false or not specified 
    384                         //we decided to check if it belongs AT LEAST to a given group  
     404                        // $_only false or not specified 
     405                        // we decided to check if it belongs AT LEAST to a given group         
    385406                        default: 
    386                                 //gets the locked role hierarchy value 
     407                                // gets the locked role hierarchy value 
    387408                                    $_hierarchy = $this->CI->config->item('FAL_roles'); 
    388                                     //let's see who we are looking for 
     409                                    // let's see who we are looking for 
    389410                                     
    390411 
     
    396417                                            $_group_hierarchy = max($_group_hierarchy); 
    397418                                     
    398                                     //let's see who accessed 
    399                                     $_who_hierarchy = $_hierarchy[$_who_is];//gets the role-hierarchy-value of the subject that did the request 
     419                                    // let's see who accessed. we need to get the 
     420                        // role-hierarchy-value of the visitor that did the request 
     421                                    $_who_hierarchy = $_hierarchy[$_who_is]; 
    400422 
    401423                                $_who_hierarchy <= $_group_hierarchy ? $_condition = true : $_condition = false; 
     
    404426                    } 
    405427                     
    406                     //if who did the request doesn't have enough credentials 
     428                    // if who did the request doesn't have enough credentials 
    407429                    if ($_condition==true) 
    408430                    { 
     
    411433                } 
    412434        } 
    413         //if condition==false, db_session turner off or user not found (namely not logged in) in ci_session 
    414     return false;         
    415     }  
     435        // if condition==false, db_session turner off or user not found (namely not logged in) in ci_session 
     436    return false; 
     437    } 
    416438        
    417        // -------------------------------------------------------------------- 
    418  
    419        /** 
    420          * Performs the login procedure both for user login 
    421          * and form administrators login 
    422          * 
    423          * @return unknown 
    424          */ 
     439    // -------------------------------------------------------------------- 
     440 
     441    /** 
     442     * Performs the login procedure both for user login 
     443     * and form administrators login 
     444     * 
     445     * @return unknown 
     446     */ 
    425447    function login() 
    426     {             
     448    { 
    427449        if (!$this->CI->config->item('FAL'))  
    428450        { 
     
    442464                $password = $this->_encode($password); 
    443465 
    444                         //Use the input username and password and check against 'user' table 
    445                        //to check if user banned 
     466                        // Use the input username and password and check against 
     467                    // 'user' table to check if user banned 
    446468                        $query = $this->CI->usermodel->getUserForLogin($username, $password); 
    447469 
     
    454476                    foreach($fields as $field) $userdata[$field] = $row->{$field}; 
    455477 
    456                     //verifies if an user has not been banned from the site (i.e. user table, banned=1) 
     478                    // verifies if a user has not been banned from the site 
     479                    // (i.e. user table, banned=1) 
    457480                    if ($row->{'banned'} == 0) 
    458481                    { 
     
    486509    function logout() 
    487510    {            
    488         //checks if a session exists 
     511        // checks if a session exists 
    489512        if ($this->CI->db_session) 
    490513        { 
     
    492515 
    493516            if ($_username != false) 
    494                 //deletes the userdata stored in DB for the user that logged out 
     517                // deletes the userdata stored in DB for the user that logged out 
    495518                $this->_unset_user($_username); 
    496519        } 
    497520        
    498         //set FLASH MESSAGE 
     521        // set FLASH MESSAGE 
    499522       $msg = $this->CI->lang->line('FAL_logout_message'); 
    500523       flashMsg($msg); 
     
    503526    } 
    504527     
    505     // --------------------------------------------------------------------    
     528    // -------------------------------------------------------------------- 
    506529    /** 
    507530     * Performs the registration procedure 
    508531     * Returns true if successful registration, false if unsucessful 
    509      *  
     532     * 
    510533     * @return boolean 
    511534     */ 
    512535    function register() 
    513536    { 
    514         //let's clean the user_temp table 
    515         //if we use registration with e-mail verification 
     537        // let's clean the user_temp table 
     538        // if we use registration with e-mail verification 
    516539        if (!$this->CI->config->item('FAL_register_direct')) 
    517540        { 
     
    519542        } 
    520543         
    521         //let's check if the system is turned on and if we allow users to register 
     544        // let's check if the system is turned on and if we allow users to register 
    522545        if (!$this->CI->config->item('FAL') OR $this->CI->config->item('FAL_allow_user_registration')!=TRUE) 
    523546            return false; 
     
    536559                $password = $this->_encode($password); 
    537560                 
    538                 //reassignement to the encoded password 
     561                // reassignement to the encoded password 
    539562                $values['password'] = $password; 
    540563                 
    541                 //if we go for standard activation with e-mail verification 
    542                 //namely i.e. $config['FAL_register_direct'] = FALSE 
     564                // if we go for standard activation with e-mail verification 
     565                // namely i.e. $config['FAL_register_direct'] = FALSE 
    543566                if (!$this->CI->config->item('FAL_register_direct')) 
    544567                { 
    545                     //generates the activation code 
     568                    // generates the activation code 
    546569                    $activation_code = $this->_generateRandomString(); 
    547570                    $values['activation_code'] = $activation_code; 
    548571                    $query = $this->CI->UserTemp->insertUserForRegistration($values); 
    549572                     
    550                     //Use the input username and password and check against 'user_temp' table 
    551                     //needed to find the user_temp ID for the activation link 
     573                    // Use the input username and password and check against 'user_temp' table 
     574                    // needed to find the user_temp ID for the activation link 
    552575                    $query = $this->CI->UserTemp->getUserLoginData($username, $password); 
    553576 
     
    563586                    } 
    564587                } 
    565                 //do we skipp e-mail verification? 
    566                 //namely if we go for direct activation i.e. $config['FAL_register_direct'] = TRUE 
    567                 else  
     588                // do we skipp e-mail verification? 
     589                // namely if we go for direct activation 
     590                // i.e. $config['FAL_register_direct'] = TRUE 
     591                else 
    568592                { 
    569                     //let's insert the values in the user table 
     593                    // let's insert the values in the user table 
    570594                    $query = $this->CI->usermodel->insertUser($values); 
    571595                     
    572                     //if affected rows ==1 set a flash message and redirect to login 
     596                    // if affected rows ==1 set a flash message and redirect to login 
    573597                    if ($this->CI->db->affected_rows() == 1) 
    574598                    { 
    575                         //if we want the user profile as well 
     599                        // if we want the user profile as well 
    576600                        if($this->CI->config->item('FAL_create_user_profile')) 
    577601                        {        
    578                                 //let's get the last insert id 
     602                                // let's get the last insert id 
    579603                                $data_profile['id'] = $this->CI->db->insert_id(); 
    580604                                $this->CI->userprofile->insertUserProfile($data_profile); 
     
    582606                         
    583607                        flashMsg( $this->CI->lang->line('FAL_activation_success_message') ); 
    584                         return true;  
     608                        return true; 
    585609                    } 
    586610                     
     
    588612                } 
    589613            } 
    590             else  
     614            else 
    591615            { 
    592                 //set FLASH MESSAGE 
     616                // set FLASH MESSAGE 
    593617                flashMsg( $this->CI->lang->line('FAL_invalid_register_message') ); 
    594618                // FIXME : if false is returned, no redirection is done in FAL_front 
     
    610634    function activation($id, $activation_code) 
    611635    {    
    612         //let's clean the user_temp table 
    613         //if we use registration with e-mail verification 
     636        // let's clean the user_temp table 
     637        // if we use registration with e-mail verification 
    614638        if (!$this->CI->config->item('FAL_register_direct')) 
    615639        { 
     
    619643        if (($id > 0) && ($activation_code != '')) 
    620644        { 
    621             //gets userdata from USER_TEMP table 
     645            // gets userdata from USER_TEMP table 
    622646                $query = $this->CI->UserTemp->getUserForActivation($id, $activation_code); 
    623647                         
    624                //deletes the record from USER_TEMP 
     648            // deletes the record from USER_TEMP 
    625649            $this->CI->UserTemp->deleteUserAfterActivation($id); 
    626650             
     
    635659                                        } 
    636660                                         
    637                                    //let's insert the new data                                 
    638                                        //inserts the new user data in USER table 
     661                    // let's insert the new data                               
     662                    // inserts the new user data in USER table 
    639663                        $this->CI->usermodel->insertUser($data); 
    640664                         
    641                         //if we want the user profile as well 
     665                        // if we want the user profile as well 
    642666                        if($this->CI->config->item('FAL_create_user_profile')) 
    643667                        {        
     
    667691            $email = $this->CI->input->post('email'); 
    668692                         
    669             //if $email not false checks the relative password for that user querying the DB 
     693            // if $email not false 
     694            // checks the relative password for that user querying the DB 
    670695            if (($email != false)) 
    671696            { 
     
    702727     
    703728    /** 
    704      * Handles the user forgotten password reset requests, when the user clicks on the e-mail link 
     729     * Handles the user forgotten password reset requests, 
     730     * when the user clicks on the e-mail link. 
    705731     * Returns true if the process has been successful, false otherwise 
    706732     * 
     
    711737    function forgotten_password_reset($id, $activation_code) 
    712738    {    
    713         //checks if $id>0 and if $activation_code not null 
     739        // checks if $id>0 and if $activation_code not null 
    714740        if (($id > 0) && ($activation_code != '')) 
    715741        {        
    716                /** 
    717                 * recalls the function getUserForForgottenPasswordReset($id, $activation_code) 
    718                 * from the class usermodel 
    719                 * it queries the database looking for the user's $id and $activation_code 
    720                 */ 
     742            /** 
     743            * recalls the function getUserForForgottenPasswordReset($id, $activation_code) 
     744            * from the class usermodel 
     745            * it queries the database looking for the user's $id and $activation_code 
     746            */ 
    721747            $query = $this->CI->usermodel->getUserForForgottenPasswordReset($id, $activation_code); 
    722748                         
    723             //if the query returns at least a result namely num_rows() > 0 
     749            // if the query returns at least a result namely num_rows() > 0 
    724750            if ($query->num_rows() > 0) 
    725751            { 
     
    728754                $user = $row->{'user_name'}; 
    729755                $email = $row->{'email'}; 
    730                                  
    731                 //generates a random password 
     756 
     757                // generates a random password 
    732758                $password = $this->_generateRandomString($this->CI->config->item('FAL_user_password_min'), $this->CI->config->item('FAL_user_password_max')); 
    733759                 
    734                 //encrypts the random password using the md5 encryption 
     760                // encrypts the random password using the md5 encryption 
    735761                $encrypted_password = $this->_encode($password); 
    736                                  
    737                 //sends the new generated password to the user 
     762 
     763                // sends the new generated password to the user 
    738764                $this->_sendForgottenPasswordResetEmail($user_id, $user, $email, $password); 
    739                                  
    740                 //updates the password in the database 
     765 
     766                // updates the password in the database 
    741767                $this->CI->usermodel->updateUserForForgottenPasswordReset($user_id, $encrypted_password); 
    742768 
     
    763789            $new_password = $this->CI->input->post('password'); 
    764790 
    765             //if $email not false checks the relative password for that user querying the DB 
     791            // if $email not false checks the relative password for that user querying the DB 
    766792            if ($username != false AND $old_password != false AND $new_password != false) 
    767793            { 
     
    774800                    $user = $row->{'user_name'}; 
    775801                    $email = $row->{'email'}; 
    776                                          
    777                     //clear text password for e-mail 
     802 
     803                    // clear text password for e-mail 
    778804                    $password_email = $new_password; 
    779805                     
    780                     //encrypts the password for DB update 
     806                    // encrypts the password for DB update 
    781807                    $new_password = $this->_encode($new_password); 
    782808                     
    783                     //updates the user table 
     809                    // updates the user table 
    784810                    $this->CI->usermodel->updateUserForForgottenPasswordReset($user_id, $new_password); 
    785                                          
    786                     //sends e-mail to user 
     811 
     812                    // sends e-mail to user 
    787813                    $this->_sendChangePasswordEmail($user_id, $user, $email, $password_email); 
    788814                     
     
    791817            } 
    792818             
    793             //set unsuccess FLASH MESSAGE 
     819            // set unsuccess FLASH MESSAGE 
    794820            $msg = $this->CI->lang->line('FAL_change_password_failed_message'); 
    795821            flashMsg($msg); 
     
    797823            redirect($this->CI->config->item('FAL_changePassword_uri'), 'location'); 
    798824        } 
    799     }   
     825    } 
    800826     
    801827    // -------------------------------------------------------------------- 
     
    808834     */ 
    809835    function _set_logindata($userdata) 
    810     {                 
     836    { 
    811837        //updates the Last_visit field in the user table 
    812838        $this->CI->usermodel->updateUserForLogin($userdata['id']); 
    813         $this->CI->db_session->set_userdata($userdata);            
    814     } 
    815          
    816          
     839        $this->CI->db_session->set_userdata($userdata); 
     840    } 
     841 
     842 
    817843    // -------------------------------------------------------------------- 
    818844     
     
    829855        { 
    830856            unset($users); 
    831             //is better to do a 1 call to unset_userdata passing an array? 
     857            // is better to do a 1 call to unset_userdata passing an array? 
    832858            $this->CI->db_session->unset_userdata('id'); 
    833859            $this->CI->db_session->unset_userdata('user_name'); 
     
    837863    } 
    838864 
    839          
     865 
    840866    // -------------------------------------------------------------------- 
    841867    /** 
    842868     * Needed to clean the UserTemp table from not completed registration 
    843      * The records get removed if older than what you set in the configuration file 
    844      * $config['FreakAuthL_temporary_users_expiration'] 
     869     * The records get removed if older than what you set in the configuration 
     870     * file $config['FreakAuthL_temporary_users_expiration'] 
    845871     * Cleaning get performed after activation and on new registrations 
    846872     * 
     
    870896     * Returns an empty string if no user is logged in 
    871897     * uses Class db_session method "userdata". 
    872      *  
     898     * 
    873899     * @return username string of currently logged in user 
    874900     * @return empty string if user not logged in 
     
    954980                return; 
    955981         
    956         //ELSE unsets userdata from session table          
     982        //ELSE unsets userdata from session table 
    957983        $this->CI->db_session->unset_userdata('FreakAuth_captcha'); 
    958984         
     
    972998    /** 
    973999     * Deletes the captcha images generated 
    974      * it deletes them if they "expired". The "expiration" (in seconds) signifies how long an image will 
    975      * remain in the root/tmp folder before it will be deleted.  The default is 10 minutes. Change the value of $expiration 
    976      * if you want them to be deleted more or less often 
     1000     * it deletes them if they "expired". The "expiration" (in seconds) 
     1001     * signifies how long an image will remain in the root/tmp folder before it 
     1002     * will be deleted.  The default is 10 minutes. Change the value 
     1003     * of $expiration if you want them to be deleted more or less often 
    9771004     * 
    9781005     * @param float $now 
     
    9831010        list($usec, $sec) = explode(" ", microtime()); 
    9841011                 
    985         //sets the expiration time of the captcha image 
     1012        // sets the expiration time of the captcha image 
    9861013        $expiration=60*10; //10 min 
    9871014                         
     
    11281155     
    11291156    /** 
    1130      * Sends an email from the system to the user that has forgotten the password 
    1131      * the e-mail contains the link to make the reset password start 
    1132      *  
     1157     * Sends an email from the system to the user that has forgotten the 
     1158     * password the e-mail contains the link to make the reset password start. 
     1159     * 
    11331160     * @access private 
    11341161     * @param unknown_type $id 
     
    11701197                       
    11711198                 
    1172         //displays message to the user on screen 
     1199        // displays message to the user on screen 
    11731200        $message = $this->CI->load->view($this->CI->config->item('FAL_forgotten_password_reset_email'), $data, true); 
    11741201                 
    11751202        $subject= '['.$this->CI->config->item('FAL_website_name').'] '.$this->CI->lang->line('FAL_forgotten_password_email_reset_subject'); 
    1176         //sends e-mail to the user to reset password 
     1203        // sends e-mail to the user to reset password 
    11771204        $this->_sendEmail($email, $subject, $message); 
    11781205    } 
     
    11821209    /** 
    11831210     * Sends an email from the system to the user that has changed the password 
    1184      * the e-mail has the newly generated password 
     1211     * the e-mail has the newly generated password. 
    11851212     * @access private 
    11861213     * @param unknown_type $id 
     
    12491276                $majorsalt=null; 
    12501277                 
    1251                 //if you set your encryption key let's use it 
     1278                // if you set your encryption key let's use it 
    12521279                if ($this->CI->config->item('encryption_key')!='') 
    12531280                { 
    1254                         //conctenates the encryption key and the password 
     1281                        // conctenates the encryption key and the password 
    12551282                        $_password = $this->CI->config->item('encryption_key').$password; 
    12561283                } 
    12571284                else {$_password=$password;} 
    12581285                 
    1259                 //if PHP5 
     1286                // if PHP5 
    12601287                if (function_exists('str_split')) 
    12611288                { 
    12621289                    $_pass = str_split($_password);        
    12631290                } 
    1264                 //if PHP4 
     1291                // if PHP4 
    12651292                else 
    12661293                { 
     
    12751302                } 
    12761303                 
    1277                 //encrypts every single letter of the password 
     1304                // encrypts every single letter of the password 
    12781305                foreach ($_pass as $_hashpass)  
    12791306                { 
     
    12811308                } 
    12821309                 
    1283                //encrypts the string combinations of every single encrypted letter 
    1284                 //and finally returns the encrypted password  
     1310        // encrypts the string combinations of every single encrypted letter 
     1311        // and finally returns the encrypted password 
    12851312                return $password=md5($majorsalt); 
    12861313                 
     
    13541381         
    13551382        /** 
    1356          * Needed to dynamically build rules and fields from config array for add and edit custom user profile 
     1383         * Needed to dynamically build rules and fields from config array for add 
     1384     * and edit custom user profile. 
    13571385         * 
    13581386         * @return array of data['rules'] and data['fields'] 
     
    13601388        function _buildUserProfileFieldsRules() 
    13611389        { 
    1362                 //lets get fields names from config 
     1390                // lets get fields names from config 
    13631391                $field_name=$this->CI->config->item('FAL_user_profile_fields_names'); 
    13641392                 
    1365                 //lets get fields validation rules from config 
     1393                // lets get fields validation rules from config 
    13661394                $field_rule=$this->CI->config->item('FAL_user_profile_fields_validation_rules'); 
    13671395         
    13681396                 
    1369                 //array of fields 
     1397                // array of fields 
    13701398        &