Ignore:
Timestamp:
Oct 20, 2006, 4:17:53 AM (18 years ago)
Author:
rvelices
Message:

used in the code (generates mysql errors on session garbage collector)

  • fix auto_login (die mysql when session timed out, but user has remember)
  • when a user reconnects from identification.php, the remember cookie was not

deleted

  • fix all redirect warnings/errors (many changes - mainly in common.inc.php

and user.inc.php)

login the 60 days countdown restarts

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/user.inc.php

    r1524 r1568  
    2626// +-----------------------------------------------------------------------+
    2727
     28// by default we start with guest
     29$user['id'] = $conf['guest_id'];
     30
    2831if (isset($_COOKIE[session_name()]))
    2932{
    3033  session_start();
    3134  if (isset($_GET['act']) and $_GET['act'] == 'logout')
    32   {
    33     // logout
     35  { // logout
    3436    $_SESSION = array();
    3537    session_unset();
    3638    session_destroy();
    3739    setcookie(session_name(),'',0,
    38               ini_get('session.cookie_path'),
    39               ini_get('session.cookie_domain')
    40               );
     40        ini_get('session.cookie_path'),
     41        ini_get('session.cookie_domain')
     42      );
    4143    setcookie($conf['remember_me_name'], '', 0, cookie_path());
    4244    redirect(make_index_url());
    43   }
    44   elseif (empty($_SESSION['pwg_uid']))
    45   {
    46     // timeout
     45  }
     46  elseif (empty($_SESSION['pwg_uid']))
     47  { // timeout
    4748    setcookie(session_name(),'',0,
    48               ini_get('session.cookie_path'),
    49               ini_get('session.cookie_domain')
    50               );
     49        ini_get('session.cookie_path'),
     50        ini_get('session.cookie_domain')
     51      );
    5152  }
    5253  else
    5354  {
    5455    $user['id'] = $_SESSION['pwg_uid'];
    55     $user['is_the_guest'] = false;
    5656  }
    5757}
    58 elseif (!empty($_COOKIE[$conf['remember_me_name']]))
     58
     59
     60// Now check the auto-login
     61if ( $user['id']==$conf['guest_id'] )
    5962{
    6063  auto_login();
    61 }
    62 else
    63 {
    64   $user['id'] = $conf['guest_id'];
    65   $user['is_the_guest'] = true;
    6664}
    6765
    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');
    74 }
    7566
    7667// using Apache authentication override the above user search
     
    8273    $user['id'] = get_userid($_SERVER['REMOTE_USER']);
    8374  }
     75}
     76$user = build_user( $user['id'],
     77          ( defined('IN_ADMIN') and IN_ADMIN ) ? false : true // use cache ?
     78         );
    8479
    85   $user['is_the_guest'] = false;
    86 }
    87 
    88 $user = array_merge(
    89   $user,
    90   getuserdata(
    91     $user['id'],
    92     ( defined('IN_ADMIN') and IN_ADMIN ) ? false : true // use cache ?
    93     )
    94   );
    95 
    96 // properties of user guest are found in the configuration
    97 if ($user['is_the_guest'])
    98 {
    99   $user['template'] = $conf['default_template'];
    100   $user['nb_image_line'] = $conf['nb_image_line'];
    101   $user['nb_line_page'] = $conf['nb_line_page'];
    102   $user['language'] = $conf['default_language'];
    103   $user['maxwidth'] = $conf['default_maxwidth'];
    104   $user['maxheight'] = $conf['default_maxheight'];
    105   $user['recent_period'] = $conf['recent_period'];
    106   $user['expand'] = $conf['auto_expand'];
    107   $user['show_nb_comments'] = $conf['show_nb_comments'];
    108   $user['enabled_high'] = $conf['newuser_default_enabled_high'];
    109 }
    110 
    111 // calculation of the number of picture to display per page
    112 $user['nb_image_page'] = $user['nb_image_line'] * $user['nb_line_page'];
    11380?>
Note: See TracChangeset for help on using the changeset viewer.