Ignore:
Timestamp:
Jul 27, 2003, 10:24:10 AM (21 years ago)
Author:
z0rglub
Message:

optional cookie identification

File:
1 edited

Legend:

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

    r26 r45  
    3333$query_done = false;
    3434$user['is_the_guest'] = false;
    35 if ( isset( $_GET['id'] )
    36      && ereg( "^[0-9a-zA-Z]{".$conf['session_id_size']."}$", $_GET['id'] ) )
     35
     36// cookie deletion if administrator don't authorize them anymore
     37if ( !$conf['authorize_cookies'] and isset( $_COOKIE['id'] ) )
    3738{
    38   $page['session_id'] = $_GET['id'];
     39  setcookie( 'id', '', 0, cookie_path() );
     40  $url = 'category.php';
     41  header( 'Request-URI: '.$url ); 
     42  header( 'Content-Location: '.$url ); 
     43  header( 'Location: '.$url );
     44  exit();
     45}
     46
     47$user['has_cookie'] = false;
     48if     ( isset( $_GET['id']    ) ) $session_id = $_GET['id'];
     49elseif ( isset( $_COOKIE['id'] ) )
     50{
     51  $session_id = $_COOKIE['id'];
     52  $user['has_cookie'] = true;
     53}
     54
     55if ( isset( $session_id )
     56     and ereg( "^[0-9a-zA-Z]{".$conf['session_id_size']."}$", $session_id ) )
     57{
     58  $page['session_id'] = $session_id;
    3959  $query = 'SELECT user_id,expiration,ip';
    4060  $query.= ' FROM '.PREFIX_TABLE.'sessions';
    41   $query.= " WHERE id = '".$_GET['id']."'";
     61  $query.= " WHERE id = '".$page['session_id']."'";
    4262  $query.= ';';
    4363  $result = mysql_query( $query );
     
    4565  {
    4666    $row = mysql_fetch_array( $result );
    47     if ( $row['expiration'] < time() )
     67    if ( !$user['has_cookie'] )
    4868    {
    49       // deletion of the session from the database,
    50       // because it is out-of-date
    51       $delete_query = 'DELETE FROM '.PREFIX_TABLE.'sessions';
    52       $delete_query.= " WHERE id = '".$page['session_id']."'";
    53       $delete_query.= ';';
    54       mysql_query( $delete_query );
    55     }
    56     else
    57     {
     69      if ( $row['expiration'] < time() )
     70      {
     71        // deletion of the session from the database,
     72        // because it is out-of-date
     73        $delete_query = 'DELETE FROM '.PREFIX_TABLE.'sessions';
     74        $delete_query.= " WHERE id = '".$page['session_id']."'";
     75        $delete_query.= ';';
     76        mysql_query( $delete_query );
     77      }
    5878      if ( $_SERVER['REMOTE_ADDR'] == $row['ip'] )
    5979      {
     
    6181        $query_done = true;
    6282      }
     83    }
     84    else
     85    {
     86      $query_user .= ' WHERE id = '.$row['user_id'];
     87      $query_done = true;
    6388    }
    6489  }
Note: See TracChangeset for help on using the changeset viewer.