Changeset 808 for trunk/include/user.inc.php
- Timestamp:
- Aug 8, 2005, 10:52:19 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/user.inc.php
r804 r808 38 38 // pwg_query($query); 39 39 // } 40 41 40 42 41 // retrieving connected user informations … … 88 87 if (!isset($user['id'])) 89 88 { 90 $user['id'] = 2;89 $user['id'] = $conf['guest_id']; 91 90 $user['is_the_guest'] = true; 92 91 } … … 95 94 if ($conf['apache_authentication'] and isset($_SERVER['REMOTE_USER'])) 96 95 { 97 $query = ' 98 SELECT id 99 FROM '.USERS_TABLE.' 100 WHERE username = \''.mysql_escape_string($_SERVER['REMOTE_USER']).'\' 101 ;'; 102 $result = pwg_query($query); 103 104 if (mysql_num_rows($result) == 0) 96 if (!($user['id'] = get_userid($_SERVER['REMOTE_USER']))) 105 97 { 106 register_user($_SERVER['REMOTE_USER'], '', '', ''); 107 108 $query = ' 109 SELECT id 110 FROM '.USERS_TABLE.' 111 WHERE username = \''.mysql_escape_string($_SERVER['REMOTE_USER']).'\' 112 ;'; 113 list($user['id']) = mysql_fetch_row(pwg_query($query)); 98 register_user($_SERVER['REMOTE_USER'], '', ''); 99 $user['id'] = get_userid($_SERVER['REMOTE_USER']); 114 100 } 115 else 116 { 117 list($user['id']) = mysql_fetch_row($result); 118 } 119 101 120 102 $user['is_the_guest'] = false; 121 103 } 122 104 123 $query = ' 124 SELECT u.*, uf.* 125 FROM '.USERS_TABLE.' AS u LEFT JOIN '.USER_FORBIDDEN_TABLE.' AS uf 126 ON id = user_id 127 WHERE u.id = '.$user['id'].' 128 ;'; 129 $row = mysql_fetch_array(pwg_query($query)); 130 131 // affectation of each value retrieved in the users table into a variable of 132 // the array $user. 133 foreach ($row as $key => $value) 134 { 135 if (!is_numeric($key)) 136 { 137 // If the field is true or false, the variable is transformed into a 138 // boolean value. 139 if ($value == 'true' or $value == 'false') 140 { 141 $user[$key] = get_boolean($value); 142 } 143 else 144 { 145 $user[$key] = $value; 146 } 147 } 148 } 105 $use_cache = (defined('IN_ADMIN') and IN_ADMIN) ? false : true; 106 $user = array_merge($user, getuserdata($user['id'], $use_cache)); 149 107 150 108 // properties of user guest are found in the configuration … … 162 120 } 163 121 164 // if no information were found about user in user_forbidden table OR the165 // forbidden categories must be updated : only if current user is in public166 // part167 if (!defined('IN_ADMIN') or !IN_ADMIN)168 {169 if (!isset($user['need_update'])170 or !is_bool($user['need_update'])171 or $user['need_update'] == true)172 {173 $user['forbidden_categories'] = calculate_permissions($user['id'],174 $user['status']);175 }176 }177 178 // forbidden_categories is a must be empty, at least179 if (!isset($user['forbidden_categories']))180 {181 $user['forbidden_categories'] = '';182 }183 184 // special for $user['restrictions'] array185 $user['restrictions'] = explode(',', $user['forbidden_categories']);186 if ($user['restrictions'][0] == '')187 {188 $user['restrictions'] = array();189 }190 191 122 // calculation of the number of picture to display per page 192 123 $user['nb_image_page'] = $user['nb_image_line'] * $user['nb_line_page']; 193 194 if (empty($user['language'])195 or !file_exists(PHPWG_ROOT_PATH.'language/'.196 $user['language'].'/common.lang.php'))197 {198 $user['language'] = $conf['default_language'];199 }200 include_once(PHPWG_ROOT_PATH.'language/'.$user['language'].'/common.lang.php');201 202 // displaying the username in the language of the connected user, instead of203 // "guest" as you can find in the database204 if ($user['is_the_guest'])205 {206 $user['username'] = $lang['guest'];207 }208 209 // only if we are in the administration section210 if (defined('IN_ADMIN') and IN_ADMIN)211 {212 $langdir = PHPWG_ROOT_PATH.'language/'.$user['language'];213 if (!file_exists($langdir.'/admin.lang.php'))214 {215 $langdir = PHPWG_ROOT_PATH.'language/'.$conf['default_language'];216 }217 include_once($langdir.'/admin.lang.php');218 include_once($langdir.'/faq.lang.php');219 }220 221 if (empty($user['template']))222 {223 $user['template'] = $conf['default_template'];224 }225 $template = setup_style($user['template']);226 124 ?>
Note: See TracChangeset
for help on using the changeset viewer.