Changeset 541 for trunk/include/user.inc.php
- Timestamp:
- Oct 3, 2004, 1:12:50 AM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/user.inc.php
r532 r541 31 31 // Example : 32 32 // status --> $user['status'] 33 $infos = array( 'id', 'username', 'mail_address', 'nb_image_line',34 'nb_line_page', 'status', 'language', 'maxwidth',35 'maxheight', 'expand', 'show_nb_comments', 'recent_period',36 'template', 'forbidden_categories');33 $infos = array('id','username','mail_address','nb_image_line','nb_line_page', 34 'status','language','maxwidth','maxheight','expand', 35 'show_nb_comments','recent_period','template', 36 'forbidden_categories'); 37 37 38 38 $query_user = 'SELECT * FROM '.USERS_TABLE; … … 41 41 42 42 // cookie deletion if administrator don't authorize them anymore 43 if ( !$conf['authorize_cookies'] and isset( $_COOKIE['id'] ))43 if (!$conf['authorize_remembering'] and isset($_COOKIE['id'])) 44 44 { 45 setcookie( 'id', '', 0, cookie_path());45 setcookie('id', '', 0, cookie_path()); 46 46 $url = 'category.php'; 47 redirect( $url);47 redirect($url); 48 48 } 49 49 50 $user['has_cookie'] = false; 51 if ( isset( $_GET['id'] ) ) $session_id = $_GET['id']; 52 elseif ( isset( $_COOKIE['id'] ) ) 50 if (isset($_GET['id'])) 51 { 52 $session_id = $_GET['id']; 53 $user['has_cookie'] = false; 54 $session_id_size = $conf['session_id_size_URI']; 55 } 56 elseif (isset($_COOKIE['id'])) 53 57 { 54 58 $session_id = $_COOKIE['id']; 55 59 $user['has_cookie'] = true; 60 $session_id_size = $conf['session_id_size_cookie']; 61 } 62 else 63 { 64 $user['has_cookie'] = false; 56 65 } 57 66 58 if ( isset( $session_id)59 and ereg( "^[0-9a-zA-Z]{".$conf['session_id_size']."}$", $session_id ))67 if (isset($session_id) 68 and ereg("^[0-9a-zA-Z]{".$session_id_size."}$", $session_id)) 60 69 { 61 70 $page['session_id'] = $session_id; 62 $query = 'SELECT user_id,expiration,ip'; 63 $query.= ' FROM '.SESSIONS_TABLE; 64 $query.= " WHERE id = '".$page['session_id']."'"; 65 $query.= ';'; 66 $result = mysql_query( $query ); 67 if ( mysql_num_rows( $result ) > 0 ) 71 $query = ' 72 SELECT user_id,expiration,ip 73 FROM '.SESSIONS_TABLE.' 74 WHERE id = \''.$page['session_id'].'\' 75 ;'; 76 $result = mysql_query($query); 77 if (mysql_num_rows($result) > 0) 68 78 { 69 $row = mysql_fetch_array( $result);70 if ( !$user['has_cookie'])79 $row = mysql_fetch_array($result); 80 if (!$user['has_cookie']) 71 81 { 72 if ( $row['expiration'] < time())82 if ($row['expiration'] < time()) 73 83 { 74 84 // deletion of the session from the database, … … 77 87 $delete_query.= " WHERE id = '".$page['session_id']."'"; 78 88 $delete_query.= ';'; 79 mysql_query( $delete_query);89 mysql_query($delete_query); 80 90 } 81 else if ( $_SERVER['REMOTE_ADDR'] == $row['ip'])91 else if ($_SERVER['REMOTE_ADDR'] == $row['ip']) 82 92 { 83 93 $query_user .= ' WHERE id = '.$row['user_id']; … … 92 102 } 93 103 } 94 if ( !$query_done)104 if (!$query_done) 95 105 { 96 106 $query_user .= ' WHERE id = 2'; … … 98 108 } 99 109 $query_user .= ';'; 100 $row = mysql_fetch_array( mysql_query( $query_user ));110 $row = mysql_fetch_array(mysql_query($query_user)); 101 111 102 112 // affectation of each value retrieved in the users table into a variable 103 113 // of the array $user. 104 foreach ( $infos as $info) {105 if ( isset( $row[$info] ))114 foreach ($infos as $info) { 115 if (isset($row[$info])) 106 116 { 107 117 // If the field is true or false, the variable is transformed into a 108 118 // boolean value. 109 if ( $row[$info] == 'true' or $row[$info] == 'false')110 $user[$info] = get_boolean( $row[$info]);119 if ($row[$info] == 'true' or $row[$info] == 'false') 120 $user[$info] = get_boolean($row[$info]); 111 121 else 112 122 $user[$info] = $row[$info]; … … 119 129 120 130 // special for $user['restrictions'] array 121 $user['restrictions'] = explode( ',', $user['forbidden_categories']);122 if ( $user['restrictions'][0] == '')131 $user['restrictions'] = explode(',', $user['forbidden_categories']); 132 if ($user['restrictions'][0] == '') 123 133 { 124 134 $user['restrictions'] = array(); … … 126 136 127 137 $isadmin = false; 128 if ( $user['status'] == 'admin')138 if ($user['status'] == 'admin') 129 139 { 130 140 $isadmin =true;
Note: See TracChangeset
for help on using the changeset viewer.