- Timestamp:
- 05/27/06 14:21:20 (2 years ago)
- Files:
-
- devel/lib/elgglib.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
devel/lib/elgglib.php
r367 r368 3344 3344 } 3345 3345 3346 // Fills user information 3347 function init_user_var($user) { 3348 3349 global $CFG; 3350 3351 $user->loggedin = true; 3352 $user->site = $CFG->wwwroot; // for added security, store the site in the session 3353 $user->sesskey = random_string(10); 3354 $user->sessionIP = md5(getremoteaddr()); // Store the current IP in the session 3355 // backwards compatibility (TODO this will have to go eventually) 3356 fill_legacy_user_session($user); 3357 return $user; 3358 3359 } 3360 3346 3361 3347 3362 // Authentication Function … … 3375 3390 3376 3391 // Set Persistent Cookie 3377 $rememberme = optional_param('remember',0 ,PARAM_INT);3392 $rememberme = optional_param('remember',0); 3378 3393 if (!empty($rememberme)) { 3379 3394 remember_login($user->ident); 3380 3395 } 3381 3396 3382 $user->loggedin = true; 3383 $user->site = $CFG->wwwroot; // for added security, store the site in the session 3384 $user->sesskey = random_string(10); 3385 $user->sessionIP = md5(getremoteaddr()); // Store the current IP in the session 3386 // backwards compatibility (TODO this will have to go eventually) 3387 fill_legacy_user_session($user); 3388 $USER = $user; 3397 3398 $USER = init_user_var($user); 3389 3399 return $ok; 3390 3400 } 3391 3401 3392 /** 3393 * elgg doesn't have a 'login' page yet, but it will so this can stay here for now 3394 */ 3395 function require_login() { 3396 global $USER, $SESSION,$FULLME; 3397 // Check to see if there's a persistent cookie 3402 // Attempts to get login from a cookie 3403 function cookied_login() { 3404 global $USER; 3398 3405 if($ticket = md5($_COOKIE[AUTH_COOKIE])) { 3399 3406 if ($user = get_record('users','code',$ticket)) { … … 3401 3408 3402 3409 /*** TODO: Create Proper Abstraction Interface - don't use file binding -- ugh ***/ 3403 if (!run("users:flags:get", array("banned",$ row->ident))) {3404 $USER = $user;3410 if (!run("users:flags:get", array("banned",$user->ident))) { 3411 $USER = init_user_var($user); 3405 3412 return true; 3406 3413 } else { 3407 3414 global $messages; 3408 3415 $messages[] = gettext("You have been banned from the system!"); 3416 return false; 3409 3417 } 3410 3418 } 3411 3419 } 3420 } 3421 3422 /** 3423 * elgg doesn't have a 'login' page yet, but it will so this can stay here for now 3424 */ 3425 function require_login() { 3426 global $USER, $SESSION,$FULLME; 3427 3428 // Check to see if there's a persistent cookie 3429 cookied_login(); 3412 3430 3413 3431 // First check that the user is logged in to the site. … … 3450 3468 3451 3469 setcookie(AUTH_COOKIE, $ticket, time()+AUTH_COOKIE_LENGTH, '/'); 3470 global $messages; 3471 $messages[] = gettext("The system will remember you and automatically log you in next time."); 3452 3472 3453 3473 return 1; 3454 3474 } 3455 3475 3476 // Returns whether the user is logged in or not; 3477 // if not logged in, checks for persistent cookie 3456 3478 function isloggedin() { 3457 3479 global $USER; 3480 if (empty($USER->ident) && empty($USER->loggedin)) { 3481 cookied_login(); 3482 } 3458 3483 return (!empty($USER->ident) && !empty($USER->loggedin)); 3459 3484 }
