Ticket #258: 080227_check_banned_user.diff

File 080227_check_banned_user.diff, 2.3 kB (added by rho, 8 months ago)
  • a/lib/elgglib.php

    old new  
    34063406            } 
    34073407             
    34083408            /*** TODO: Create Proper Abstraction Interface - don't use file binding -- ugh ***/ 
    3409             if (!user_flag_get("banned",$USER->ident)) { 
     3409            if (!check_banned()) { 
    34103410                $USER = init_user_var($USER); 
    34113411                return true; 
    3412             } else { 
    3413                 global $CFG; 
    3414  
    3415                 // Seek and destroy user data!!! 
    3416                 $_SESSION = array(); 
    3417                 session_destroy(); 
    3418  
    3419                 // Destroy cookie! yummie yummie 
    3420                 setcookie(session_name(), '', time()-84600, $CFG->cookiepath); 
    3421  
    3422                 // Clear magic code 
    3423                 setcookie(AUTH_COOKIE, '', time()-84600, $CFG->cookiepath); 
    3424  
    3425                 // Now becomes into guest 
    3426                 $USER = fill_legacy_user_session(); 
    3427  
    3428                 // For human deception... :D 
    3429                 $_SESSION['messages'][] = __gettext('You have been banned from the system!'); 
    34303412            } 
    34313413        } 
    34323414    } 
     3415} 
     3416 
     3417/** 
     3418 * Check if current user is banned 
     3419 */ 
     3420function check_banned() { 
     3421    global $CFG, $USER; 
     3422 
     3423    static $banned; 
     3424 
     3425    if (!isset($banned) && user_flag_get("banned",$USER->ident)) { 
     3426        // Seek and destroy user data!!! 
     3427        $_SESSION = array(); 
     3428        session_destroy(); 
     3429 
     3430        // Destroy cookie! yummie yummie 
     3431        setcookie(session_name(), '', time()-84600, $CFG->cookiepath); 
     3432 
     3433        // Clear magic code 
     3434        setcookie(AUTH_COOKIE, '', time()-84600, $CFG->cookiepath); 
     3435 
     3436        // Now becomes into guest 
     3437        $USER = fill_legacy_user_session(); 
     3438 
     3439        // For human deception... :D 
     3440        $_SESSION['messages'][] = __gettext('You have been banned from the system!'); 
     3441 
     3442        $banned = true; 
     3443    } 
     3444 
     3445    return $banned; 
    34333446} 
    34343447 
    34353448/** 
     
    35493562    if (empty($USER->ident) && empty($USER->loggedin)) { 
    35503563        cookied_login(); 
    35513564    } 
    3552     return (!empty($USER->ident) && !empty($USER->loggedin)); 
     3565    $loggedin = (!empty($USER->ident) && !empty($USER->loggedin)); 
     3566 
     3567    // check if user is banned 
     3568    if ($loggedin && check_banned()) { 
     3569        $loggedin = false; 
     3570    } 
     3571 
     3572    return $loggedin; 
    35533573} 
    35543574 
    35553575/**