Changeset 1554
- Timestamp:
- Oct 4, 2006, 10:50:20 PM (18 years ago)
- Location:
- branches/branch-1_6
- Files:
-
- 1 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/branch-1_6/identification.php
r1082 r1554 64 64 $remember_me = true; 65 65 } 66 log_user( 66 log_user($row['id'], $remember_me); 67 67 redirect(empty($redirect_to) ? make_index_url() : $redirect_to); 68 68 } … … 71 71 array_push( $errors, $lang['invalid_pwd'] ); 72 72 } 73 } 74 elseif (!empty($_COOKIE[$conf['remember_me_name']])) 75 { 76 auto_login(); 73 77 } 74 78 //----------------------------------------------------- template initialization -
branches/branch-1_6/include/config_default.inc.php
r1530 r1554 319 319 $conf['authorize_remembering'] = true; 320 320 321 // remember_me_name: specifies the name of the cookie used to stay logged 322 $conf['remember_me_name'] = 'pwg_remember'; 323 321 324 // remember_me_length : time of validity for "remember me" cookies, in 322 325 // seconds. 323 326 $conf['remember_me_length'] = 31536000; 324 325 // session_length : time of validity for normal session, in seconds.326 $conf['session_length'] = 3600;327 327 328 328 // +-----------------------------------------------------------------------+ -
branches/branch-1_6/include/functions_session.inc.php
r1443 r1554 72 72 ini_set('session.use_trans_sid', intval($conf['session_use_trans_sid'])); 73 73 } 74 session_name( $conf['session_name'] ); 75 session_set_cookie_params( 76 ini_get('session.cookie_lifetime'), 77 cookie_path() 78 ); 74 session_name($conf['session_name']); 75 session_set_cookie_params(0, cookie_path()); 79 76 } 80 77 -
branches/branch-1_6/include/functions_user.inc.php
r1463 r1554 551 551 function log_user($user_id, $remember_me) 552 552 { 553 global $conf ;554 $session_length = $conf['session_length']; 553 global $conf, $user; 554 555 555 if ($remember_me) 556 556 { 557 $session_length = $conf['remember_me_length']; 558 } 559 session_set_cookie_params($session_length); 557 // search for an existing auto_login_key 558 $query = ' 559 SELECT auto_login_key 560 FROM '.USERS_TABLE.' 561 WHERE '.$conf['user_fields']['id'].' = '.$user_id.' 562 ;'; 563 564 $auto_login_key = current(mysql_fetch_assoc(pwg_query($query))); 565 if (empty($auto_login_key)) 566 { 567 $auto_login_key = base64_encode(md5(uniqid(rand(), true))); 568 $query = ' 569 UPDATE '.USERS_TABLE.' 570 SET auto_login_key=\''.$auto_login_key.'\' 571 WHERE '.$conf['user_fields']['id'].' = '.$user_id.' 572 ;'; 573 pwg_query($query); 574 } 575 $cookie = array('id' => $user_id, 'key' => $auto_login_key); 576 setcookie($conf['remember_me_name'], 577 serialize($cookie), 578 time()+$conf['remember_me_length'], 579 cookie_path() 580 ); 581 } 560 582 session_start(); 561 583 $_SESSION['pwg_uid'] = $user_id; 584 585 $user['id'] = $_SESSION['pwg_uid']; 586 $user['is_the_guest'] = false; 587 } 588 589 /* 590 * Performs auto-connexion when cookie remember_me exists 591 * @return void 592 */ 593 function auto_login() { 594 global $conf; 595 596 // must remove slash added in include/common.inc.php 597 $cookie = unserialize(stripslashes($_COOKIE[$conf['remember_me_name']])); 598 599 $query = ' 600 SELECT auto_login_key 601 FROM '.USERS_TABLE.' 602 WHERE '.$conf['user_fields']['id'].' = '.$cookie['id'].' 603 ;'; 604 605 $auto_login_key = current(mysql_fetch_assoc(pwg_query($query))); 606 if ($auto_login_key == $cookie['key']) 607 { 608 log_user($cookie['id'], false); 609 redirect(make_index_url()); 610 } 611 else 612 { 613 setcookie($conf['remember_me_name'], '', 0, cookie_path()); 614 redirect(make_index_url()); 615 } 562 616 } 563 617 -
branches/branch-1_6/include/menubar.inc.php
r1504 r1554 45 45 'U_REGISTER' => get_root_url().'register.php', 46 46 'U_LOST_PASSWORD' => get_root_url().'password.php', 47 'U_LOGOUT' => add_url_params(make_index_url(), array('act'=>'logout') ),47 'U_LOGOUT' => get_root_url().'?act=logout', 48 48 'U_ADMIN'=> get_root_url().'admin.php', 49 49 'U_PROFILE'=> get_root_url().'profile.php', -
branches/branch-1_6/include/user.inc.php
r1230 r1554 26 26 // +-----------------------------------------------------------------------+ 27 27 28 // retrieving connected user informations29 28 if (isset($_COOKIE[session_name()])) 30 29 { 31 session_start(); 32 if (isset($_SESSION['pwg_uid'])) 33 { 34 $user['id'] = $_SESSION['pwg_uid']; 35 $user['is_the_guest'] = false; 36 } 37 else 38 { 39 // session timeout 40 $user['id'] = $conf['guest_id']; 41 $user['is_the_guest'] = true; 42 } 30 session_start(); 31 if (isset($_GET['act']) and $_GET['act'] == 'logout') 32 { 33 // logout 34 $_SESSION = array(); 35 session_unset(); 36 session_destroy(); 37 setcookie(session_name(),'',0, 38 ini_get('session.cookie_path'), 39 ini_get('session.cookie_domain') 40 ); 41 setcookie($conf['remember_me_name'], '', 0, cookie_path()); 42 redirect(make_index_url()); 43 } 44 elseif (empty($_SESSION['pwg_uid'])) 45 { 46 // timeout 47 setcookie(session_name(),'',0, 48 ini_get('session.cookie_path'), 49 ini_get('session.cookie_domain') 50 ); 51 } 52 else 53 { 54 $user['id'] = $_SESSION['pwg_uid']; 55 $user['is_the_guest'] = false; 56 } 57 } 58 elseif (!empty($_COOKIE[$conf['remember_me_name']])) 59 { 60 auto_login(); 43 61 } 44 else 62 else 45 63 { 46 $user['id'] = $conf['guest_id']; 47 $user['is_the_guest'] = true; 64 $user['id'] = $conf['guest_id']; 65 $user['is_the_guest'] = true; 66 } 67 68 if ($user['is_the_guest'] and !$conf['guest_access'] 69 and (basename($_SERVER['PHP_SELF'])!='identification.php') 70 and (basename($_SERVER['PHP_SELF'])!='password.php') 71 and (basename($_SERVER['PHP_SELF'])!='register.php')) 72 { 73 redirect (get_root_url().'identification.php'); 48 74 } 49 75 … … 59 85 $user['is_the_guest'] = false; 60 86 } 87 61 88 $user = array_merge( 62 89 $user, -
branches/branch-1_6/install/phpwebgallery_structure.sql
r1496 r1554 1 -- MySQL dump 9.111 1-- MySQL dump 9.11 2 2 -- 3 3 -- Host: localhost Database: pwg-1_6 … … 346 346 `password` varchar(32) default NULL, 347 347 `mail_address` varchar(255) default NULL, 348 `auto_login_key` varchar(64) default NULL, 348 349 PRIMARY KEY (`id`), 349 350 UNIQUE KEY `users_ui1` (`username`) -
branches/branch-1_6/install/upgrade_1.5.0.php
r1437 r1554 469 469 } 470 470 471 $query = ' 472 ALTER TABLE '.PREFIX_TABLE.'users 473 ADD auto_login_key varchar(64) NOT NULL 474 ;'; 475 pwg_query($query); 471 476 ?>
Note: See TracChangeset
for help on using the changeset viewer.