| [ Index ] |
|
Code source de PHP NUKE 7.9 |
1 <?php 2 /*************************************************************************** 3 * page_header.php 4 * ------------------- 5 * begin : Saturday, Feb 13, 2001 6 * copyright : (C) 2001 The phpBB Group 7 * email : support@phpbb.com 8 * 9 * Id: page_header.php,v 1.106.2.24 2005/03/26 14:15:59 acydburn Exp 10 * 11 * 12 ***************************************************************************/ 13 14 /*************************************************************************** 15 * 16 * This program is free software; you can redistribute it and/or modify 17 * it under the terms of the GNU General Public License as published by 18 * the Free Software Foundation; either version 2 of the License, or 19 * (at your option) any later version. 20 * 21 ***************************************************************************/ 22 23 if ( !defined('IN_PHPBB') ) 24 { 25 die("Hacking attempt"); 26 } 27 define('HEADER_INC', TRUE); 28 29 global $name, $sitename, $is_inline_review, $prefix, $db; 30 31 OpenTable(); 32 33 // 34 // gzip_compression 35 // 36 $do_gzip_compress = FALSE; 37 if ( $board_config['gzip_compress'] ) 38 { 39 $phpver = phpversion(); 40 41 $useragent = (isset($HTTP_SERVER_VARS['HTTP_USER_AGENT'])) ? $HTTP_SERVER_VARS['HTTP_USER_AGENT'] : getenv('HTTP_USER_AGENT'); 42 43 if ( $phpver >= '4.0.4pl1' && ( strstr($useragent,'compatible') || strstr($useragent,'Gecko') ) ) 44 { 45 if ( extension_loaded('zlib') ) 46 { 47 ob_start('ob_gzhandler'); 48 } 49 } 50 else if ( $phpver > '4.0' ) 51 { 52 if ( strstr($HTTP_SERVER_VARS['HTTP_ACCEPT_ENCODING'], 'gzip') ) 53 { 54 if ( extension_loaded('zlib') ) 55 { 56 $do_gzip_compress = TRUE; 57 ob_start(); 58 ob_implicit_flush(0); 59 60 header('Content-Encoding: gzip'); 61 } 62 } 63 } 64 } 65 66 // 67 // Parse and show the overall header. 68 // 69 $template->set_filenames(array( 70 'overall_header' => ( empty($gen_simple_header) ) ? 'overall_header.tpl' : 'simple_header.tpl') 71 ); 72 73 // 74 // Generate logged in/logged out status 75 // 76 if ( $userdata['session_logged_in'] ) 77 { 78 $u_login_logout = 'modules.php?name=Your_Account&op=logout&redirect=Forums'; 79 $l_login_logout = $lang['Logout'] . ' [ ' . $userdata['username'] . ' ]'; 80 } 81 else 82 { 83 $u_login_logout = 'modules.php?name=Your_Account&redirect=index'; 84 $l_login_logout = $lang['Login']; 85 } 86 87 $s_last_visit = ( $userdata['session_logged_in'] ) ? create_date($board_config['default_dateformat'], $userdata['user_lastvisit'], $board_config['board_timezone']) : ''; 88 89 // 90 // Get basic (usernames + totals) online 91 // situation 92 // 93 $logged_visible_online = 0; 94 $logged_hidden_online = 0; 95 $guests_online = 0; 96 $online_userlist = ''; 97 $l_online_users = ''; 98 if (defined('SHOW_ONLINE')) 99 { 100 101 $user_forum_sql = ( !empty($forum_id) ) ? "AND s.session_page = " . intval($forum_id) : ''; 102 $sql = "SELECT u.username, u.user_id, u.user_allow_viewonline, u.user_level, s.session_logged_in, s.session_ip 103 FROM ".USERS_TABLE." u, ".SESSIONS_TABLE." s 104 WHERE u.user_id = s.session_user_id 105 AND s.session_time >= ".( time() - 300 ) . " 106 $user_forum_sql 107 ORDER BY u.username ASC, s.session_ip ASC"; 108 if( !($result = $db->sql_query($sql)) ) 109 { 110 message_die(GENERAL_ERROR, 'Could not obtain user/online information', '', __LINE__, __FILE__, $sql); 111 } 112 113 $userlist_ary = array(); 114 $userlist_visible = array(); 115 116 $prev_user_id = 0; 117 $prev_user_ip = $prev_session_ip = ''; 118 119 while( $row = $db->sql_fetchrow($result) ) 120 { 121 // User is logged in and therefor not a guest 122 if ( $row['session_logged_in'] ) 123 { 124 // Skip multiple sessions for one user 125 if ( $row['user_id'] != $prev_user_id ) 126 { 127 $style_color = ''; 128 if ( $row['user_level'] == ADMIN ) 129 { 130 $row['username'] = '<b>' . $row['username'] . '</b>'; 131 $style_color = 'style="color:#' . $theme['fontcolor3'] . '"'; 132 } 133 else if ( $row['user_level'] == MOD ) 134 { 135 $row['username'] = '<b>' . $row['username'] . '</b>'; 136 $style_color = 'style="color:#' . $theme['fontcolor2'] . '"'; 137 } 138 139 if ( $row['user_allow_viewonline'] ) 140 { 141 $user_online_link = '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $row['user_id']) . '"' . $style_color .'>' . $row['username'] . '</a>'; 142 $logged_visible_online++; 143 } 144 else 145 { 146 $user_online_link = '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $row['user_id']) . '"' . $style_color .'><i>' . $row['username'] . '</i></a>'; 147 $logged_hidden_online++; 148 } 149 150 if ( $row['user_allow_viewonline'] || $userdata['user_level'] == ADMIN ) 151 { 152 $online_userlist .= ( $online_userlist != '' ) ? ', ' . $user_online_link : $user_online_link; 153 } 154 } 155 156 $prev_user_id = $row['user_id']; 157 } 158 else 159 { 160 // Skip multiple sessions for one user 161 if ( $row['session_ip'] != $prev_session_ip ) 162 { 163 $guests_online++; 164 } 165 } 166 167 $prev_session_ip = $row['session_ip']; 168 } 169 $db->sql_freeresult($result); 170 171 if ( empty($online_userlist) ) 172 { 173 $online_userlist = $lang['None']; 174 } 175 $online_userlist = ( ( isset($forum_id) ) ? $lang['Browsing_forum'] : $lang['Registered_users'] ) . ' ' . $online_userlist; 176 177 $total_online_users = $logged_visible_online + $logged_hidden_online + $guests_online; 178 179 if ( $total_online_users > $board_config['record_online_users']) 180 { 181 $board_config['record_online_users'] = $total_online_users; 182 $board_config['record_online_date'] = time(); 183 184 $sql = "UPDATE " . CONFIG_TABLE . " 185 SET config_value = '$total_online_users' 186 WHERE config_name = 'record_online_users'"; 187 if ( !$db->sql_query($sql) ) 188 { 189 message_die(GENERAL_ERROR, 'Could not update online user record (nr of users)', '', __LINE__, __FILE__, $sql); 190 } 191 192 $sql = "UPDATE " . CONFIG_TABLE . " 193 SET config_value = '" . $board_config['record_online_date'] . "' 194 WHERE config_name = 'record_online_date'"; 195 if ( !$db->sql_query($sql) ) 196 { 197 message_die(GENERAL_ERROR, 'Could not update online user record (date)', '', __LINE__, __FILE__, $sql); 198 } 199 } 200 201 if ( $total_online_users == 0 ) 202 { 203 $l_t_user_s = $lang['Online_users_zero_total']; 204 } 205 else if ( $total_online_users == 1 ) 206 { 207 $l_t_user_s = $lang['Online_user_total']; 208 } 209 else 210 { 211 $l_t_user_s = $lang['Online_users_total']; 212 } 213 214 if ( $logged_visible_online == 0 ) 215 { 216 $l_r_user_s = $lang['Reg_users_zero_total']; 217 } 218 else if ( $logged_visible_online == 1 ) 219 { 220 $l_r_user_s = $lang['Reg_user_total']; 221 } 222 else 223 { 224 $l_r_user_s = $lang['Reg_users_total']; 225 } 226 227 if ( $logged_hidden_online == 0 ) 228 { 229 $l_h_user_s = $lang['Hidden_users_zero_total']; 230 } 231 else if ( $logged_hidden_online == 1 ) 232 { 233 $l_h_user_s = $lang['Hidden_user_total']; 234 } 235 else 236 { 237 $l_h_user_s = $lang['Hidden_users_total']; 238 } 239 240 if ( $guests_online == 0 ) 241 { 242 $l_g_user_s = $lang['Guest_users_zero_total']; 243 } 244 else if ( $guests_online == 1 ) 245 { 246 $l_g_user_s = $lang['Guest_user_total']; 247 } 248 else 249 { 250 $l_g_user_s = $lang['Guest_users_total']; 251 } 252 253 $l_online_users = sprintf($l_t_user_s, $total_online_users); 254 $l_online_users .= sprintf($l_r_user_s, $logged_visible_online); 255 $l_online_users .= sprintf($l_h_user_s, $logged_hidden_online); 256 $l_online_users .= sprintf($l_g_user_s, $guests_online); 257 } 258 259 // 260 // Obtain number of new private messages 261 // if user is logged in 262 // 263 if ( ($userdata['session_logged_in']) && (empty($gen_simple_header)) ) 264 { 265 if ( $userdata['user_new_privmsg'] ) 266 { 267 $l_message_new = ( $userdata['user_new_privmsg'] == 1 ) ? $lang['New_pm'] : $lang['New_pms']; 268 $l_privmsgs_text = sprintf($l_message_new, $userdata['user_new_privmsg']); 269 270 if ( $userdata['user_last_privmsg'] > $userdata['user_lastvisit'] ) 271 { 272 $sql = "UPDATE " . USERS_TABLE . " 273 SET user_last_privmsg = " . $userdata['user_lastvisit'] . " 274 WHERE user_id = " . $userdata['user_id']; 275 if ( !$db->sql_query($sql) ) 276 { 277 message_die(GENERAL_ERROR, 'Could not update private message new/read time for user', '', __LINE__, __FILE__, $sql); 278 } 279 280 $s_privmsg_new = 1; 281 $icon_pm = $images['pm_new_msg']; 282 } 283 else 284 { 285 $s_privmsg_new = 0; 286 $icon_pm = $images['pm_new_msg']; 287 } 288 } 289 else 290 { 291 $l_privmsgs_text = $lang['No_new_pm']; 292 293 $s_privmsg_new = 0; 294 $icon_pm = $images['pm_no_new_msg']; 295 } 296 297 if ( $userdata['user_unread_privmsg'] ) 298 { 299 $l_message_unread = ( $userdata['user_unread_privmsg'] == 1 ) ? $lang['Unread_pm'] : $lang['Unread_pms']; 300 $l_privmsgs_text_unread = sprintf($l_message_unread, $userdata['user_unread_privmsg']); 301 } 302 else 303 { 304 $l_privmsgs_text_unread = $lang['No_unread_pm']; 305 } 306 } 307 else 308 { 309 $icon_pm = $images['pm_no_new_msg']; 310 $l_privmsgs_text = $lang['Login_check_pm']; 311 $l_privmsgs_text_unread = ''; 312 $s_privmsg_new = 0; 313 } 314 315 // 316 // Generate HTML required for Mozilla Navigation bar 317 // 318 if (!isset($nav_links)) 319 { 320 $nav_links = array(); 321 } 322 323 $nav_links_html = ''; 324 $nav_link_proto = '<link rel="%s" href="%s" title="%s" />' . "\n"; 325 while( list($nav_item, $nav_array) = @each($nav_links) ) 326 { 327 if ( !empty($nav_array['url']) ) 328 { 329 $nav_links_html .= sprintf($nav_link_proto, $nav_item, append_sid($nav_array['url']), $nav_array['title']); 330 } 331 else 332 { 333 // We have a nested array, used for items like <link rel='chapter'> that can occur more than once. 334 while( list(,$nested_array) = each($nav_array) ) 335 { 336 $nav_links_html .= sprintf($nav_link_proto, $nav_item, $nested_array['url'], $nested_array['title']); 337 } 338 } 339 } 340 341 // Format Timezone. We are unable to use array_pop here, because of PHP3 compatibility 342 $l_timezone = explode('.', $board_config['board_timezone']); 343 $l_timezone = (count($l_timezone) > 1 && $l_timezone[count($l_timezone)-1] != 0) ? $lang[sprintf('%.1f', $board_config['board_timezone'])] : $lang[number_format($board_config['board_timezone'])]; 344 // 345 // The following assigns all _common_ variables that may be used at any point 346 // in a template. 347 // 348 $template->assign_vars(array( 349 'SITENAME' => $board_config['sitename'], 350 'SITE_DESCRIPTION' => $board_config['site_desc'], 351 'PAGE_TITLE' => $page_title, 352 'LAST_VISIT_DATE' => sprintf($lang['You_last_visit'], $s_last_visit), 353 'CURRENT_TIME' => sprintf($lang['Current_time'], create_date($board_config['default_dateformat'], time(), $board_config['board_timezone'])), 354 'TOTAL_USERS_ONLINE' => $l_online_users, 355 'LOGGED_IN_USER_LIST' => $online_userlist, 356 'RECORD_USERS' => sprintf($lang['Record_online_users'], $board_config['record_online_users'], create_date($board_config['default_dateformat'], $board_config['record_online_date'], $board_config['board_timezone'])), 357 'PRIVATE_MESSAGE_INFO' => $l_privmsgs_text, 358 'PRIVATE_MESSAGE_INFO_UNREAD' => $l_privmsgs_text_unread, 359 'PRIVATE_MESSAGE_NEW_FLAG' => $s_privmsg_new, 360 361 'PRIVMSG_IMG' => $icon_pm, 362 363 'L_USERNAME' => $lang['Username'], 364 'L_PASSWORD' => $lang['Password'], 365 'L_LOGIN_LOGOUT' => $l_login_logout, 366 'L_LOGIN' => $lang['Login'], 367 'L_LOG_ME_IN' => $lang['Log_me_in'], 368 'L_AUTO_LOGIN' => $lang['Log_me_in'], 369 'L_INDEX' => sprintf($lang['Forum_Index'], $board_config['sitename']), 370 'L_REGISTER' => $lang['Register'], 371 'L_PROFILE' => $lang['Profile'], 372 'L_SEARCH' => $lang['Search'], 373 'L_PRIVATEMSGS' => $lang['Private_Messages'], 374 'L_WHO_IS_ONLINE' => $lang['Who_is_Online'], 375 'L_MEMBERLIST' => $lang['Memberlist'], 376 'L_FAQ' => $lang['FAQ'], 377 'L_USERGROUPS' => $lang['Usergroups'], 378 'L_SEARCH_NEW' => $lang['Search_new'], 379 'L_SEARCH_UNANSWERED' => $lang['Search_unanswered'], 380 'L_SEARCH_SELF' => $lang['Search_your_posts'], 381 'L_WHOSONLINE_ADMIN' => sprintf($lang['Admin_online_color'], '<span style="color:#' . $theme['fontcolor3'] . '">', '</span>'), 382 'L_WHOSONLINE_MOD' => sprintf($lang['Mod_online_color'], '<span style="color:#' . $theme['fontcolor2'] . '">', '</span>'), 383 384 'U_SEARCH_UNANSWERED' => append_sid('search.'.$phpEx.'?search_id=unanswered'), 385 'U_SEARCH_SELF' => append_sid('search.'.$phpEx.'?search_id=egosearch'), 386 'U_SEARCH_NEW' => append_sid('search.'.$phpEx.'?search_id=newposts'), 387 'U_INDEX' => append_sid('index.'.$phpEx), 388 'U_REGISTER' => append_sid('profile.'.$phpEx.'?mode=register'), 389 'U_PROFILE' => append_sid('profile.'.$phpEx.'?mode=editprofile'), 390 'U_PRIVATEMSGS' => append_sid('privmsg.'.$phpEx.'?folder=inbox'), 391 'U_PRIVATEMSGS_POPUP' => append_sid('privmsg.'.$phpEx.'?mode=newpm&popup=1'), 392 'U_SEARCH' => append_sid('search.'.$phpEx), 393 'U_MEMBERLIST' => append_sid('memberlist.'.$phpEx), 394 'U_MODCP' => append_sid('modcp.'.$phpEx), 395 'U_FAQ' => append_sid('faq.'.$phpEx), 396 'U_VIEWONLINE' => append_sid('viewonline.'.$phpEx), 397 'U_LOGIN_LOGOUT' => append_sid($u_login_logout), 398 'U_MEMBERSLIST' => append_sid('memberlist.'.$phpEx), 399 'U_GROUP_CP' => append_sid('groupcp.'.$phpEx), 400 401 'S_CONTENT_DIRECTION' => $lang['DIRECTION'], 402 'S_CONTENT_ENCODING' => $lang['ENCODING'], 403 'S_CONTENT_DIR_LEFT' => $lang['LEFT'], 404 'S_CONTENT_DIR_RIGHT' => $lang['RIGHT'], 405 'S_TIMEZONE' => sprintf($lang['All_times'], $l_timezone), 406 'S_LOGIN_ACTION' => append_sid('login.'.$phpEx), 407 408 'T_HEAD_STYLESHEET' => $theme['head_stylesheet'], 409 /* 410 'T_BODY_BACKGROUND' => $theme['body_background'], 411 'T_BODY_BGCOLOR' => '#'.$theme['body_bgcolor'], 412 'T_BODY_TEXT' => '#'.$theme['body_text'], 413 'T_BODY_LINK' => '#'.$theme['body_link'], 414 'T_BODY_VLINK' => '#'.$theme['body_vlink'], 415 'T_BODY_ALINK' => '#'.$theme['body_alink'], 416 'T_BODY_HLINK' => '#'.$theme['body_hlink'], 417 */ 418 'T_TR_COLOR1' => '#'.$theme['tr_color1'], 419 'T_TR_COLOR2' => '#'.$theme['tr_color2'], 420 'T_TR_COLOR3' => '#'.$theme['tr_color3'], 421 'T_TR_CLASS1' => $theme['tr_class1'], 422 'T_TR_CLASS2' => $theme['tr_class2'], 423 'T_TR_CLASS3' => $theme['tr_class3'], 424 'T_TH_COLOR1' => '#'.$theme['th_color1'], 425 'T_TH_COLOR2' => '#'.$theme['th_color2'], 426 'T_TH_COLOR3' => '#'.$theme['th_color3'], 427 'T_TH_CLASS1' => $theme['th_class1'], 428 'T_TH_CLASS2' => $theme['th_class2'], 429 'T_TH_CLASS3' => $theme['th_class3'], 430 'T_TD_COLOR1' => '#'.$theme['td_color1'], 431 'T_TD_COLOR2' => '#'.$theme['td_color2'], 432 'T_TD_COLOR3' => '#'.$theme['td_color3'], 433 'T_TD_CLASS1' => $theme['td_class1'], 434 'T_TD_CLASS2' => $theme['td_class2'], 435 'T_TD_CLASS3' => $theme['td_class3'], 436 'T_FONTFACE1' => $theme['fontface1'], 437 'T_FONTFACE2' => $theme['fontface2'], 438 'T_FONTFACE3' => $theme['fontface3'], 439 'T_FONTSIZE1' => $theme['fontsize1'], 440 'T_FONTSIZE2' => $theme['fontsize2'], 441 'T_FONTSIZE3' => $theme['fontsize3'], 442 'T_FONTCOLOR1' => '#'.$theme['fontcolor1'], 443 'T_FONTCOLOR2' => '#'.$theme['fontcolor2'], 444 'T_FONTCOLOR3' => '#'.$theme['fontcolor3'], 445 'T_SPAN_CLASS1' => $theme['span_class1'], 446 'T_SPAN_CLASS2' => $theme['span_class2'], 447 'T_SPAN_CLASS3' => $theme['span_class3'], 448 449 'NAV_LINKS' => $nav_links_html) 450 ); 451 452 // 453 // Login box? 454 // 455 if ( !$userdata['session_logged_in'] ) 456 { 457 $template->assign_block_vars('switch_user_logged_out', array()); 458 } 459 else 460 { 461 $template->assign_block_vars('switch_user_logged_in', array()); 462 463 if ( !empty($userdata['user_popup_pm']) ) 464 { 465 $template->assign_block_vars('switch_enable_pm_popup', array()); 466 } 467 } 468 469 // Add no-cache control for cookies if they are set 470 //$c_no_cache = (isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_sid']) || isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_data'])) ? 'no-cache="set-cookie", ' : ''; 471 472 // Work around for "current" Apache 2 + PHP module which seems to not 473 // cope with private cache control setting 474 if (!empty($HTTP_SERVER_VARS['SERVER_SOFTWARE']) && strstr($HTTP_SERVER_VARS['SERVER_SOFTWARE'], 'Apache/2')) 475 { 476 header ('Cache-Control: no-cache, pre-check=0, post-check=0'); 477 } 478 else 479 { 480 header ('Cache-Control: private, pre-check=0, post-check=0, max-age=0'); 481 } 482 header ('Expires: 0'); 483 header ('Pragma: no-cache'); 484 485 $template->pparse('overall_header'); 486 487 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Sun Apr 1 11:11:59 2007 | par Balluche grâce à PHPXref 0.7 |