Verzeichnisstruktur phpBB-2.0.0


Veröffentlicht
03.04.2002

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

      (Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

page_header.php

Zuletzt modifiziert: 09.10.2024, 12:51 - Dateigröße: 15.16 KiB


 001  <?php
 002  /***************************************************************************
 003   *                              page_header.php
 004   *                            -------------------
 005   *   begin                : Saturday, Feb 13, 2001
 006   *   copyright            : (C) 2001 The phpBB Group
 007   *   email                : support@phpbb.com
 008   *
 009   *   $Id$
 010   *
 011   *
 012   ***************************************************************************/
 013   
 014  /***************************************************************************
 015   *
 016   *   This program is free software; you can redistribute it and/or modify
 017   *   it under the terms of the GNU General Public License as published by
 018   *   the Free Software Foundation; either version 2 of the License, or
 019   *   (at your option) any later version.
 020   *
 021   ***************************************************************************/
 022   
 023  if ( !defined('IN_PHPBB') )
 024  {
 025      die("Hacking attempt");
 026  }
 027   
 028  define('HEADER_INC', TRUE);
 029   
 030  //
 031  // gzip_compression
 032  //
 033  $do_gzip_compress = FALSE;
 034  if ( $board_config['gzip_compress'] )
 035  {
 036      $phpver = phpversion();
 037   
 038      $useragent = (isset($HTTP_SERVER_VARS['HTTP_USER_AGENT'])) ? $HTTP_SERVER_VARS['HTTP_USER_AGENT'] : getenv('HTTP_USER_AGENT');
 039   
 040      if ( $phpver >= '4.0.4pl1' && ( strstr($useragent,'compatible') || strstr($useragent,'Gecko') ) )
 041      {
 042          if ( extension_loaded('zlib') )
 043          {
 044              ob_start('ob_gzhandler');
 045          }
 046      }
 047      else if ( $phpver > '4.0' )
 048      {
 049          if ( strstr($HTTP_SERVER_VARS['HTTP_ACCEPT_ENCODING'], 'gzip') )
 050          {
 051              if ( extension_loaded('zlib') )
 052              {
 053                  $do_gzip_compress = TRUE;
 054                  ob_start();
 055                  ob_implicit_flush(0);
 056   
 057                  header('Content-Encoding: gzip');
 058              }
 059          }
 060      }
 061  }
 062   
 063  //
 064  // Parse and show the overall header.
 065  //
 066  $template->set_filenames(array(
 067      'overall_header' => ( empty($gen_simple_header) ) ? 'overall_header.tpl' : 'simple_header.tpl')
 068  );
 069   
 070  //
 071  // Generate logged in/logged out status
 072  //
 073  if ( $userdata['session_logged_in'] )
 074  {
 075      $u_login_logout = 'login.'.$phpEx.'?logout=true&amp;sid=' . $userdata['session_id'];
 076      $l_login_logout = $lang['Logout'] . ' [ ' . $userdata['username'] . ' ]';
 077  }
 078  else
 079  {
 080      $u_login_logout = 'login.'.$phpEx;
 081      $l_login_logout = $lang['Login'];
 082  }
 083   
 084  $s_last_visit = ( $userdata['session_logged_in'] ) ? create_date($board_config['default_dateformat'], $userdata['user_lastvisit'], $board_config['board_timezone']) : '';
 085   
 086  //
 087  // Get basic (usernames + totals) online
 088  // situation
 089  //
 090  $logged_visible_online = 0;
 091  $logged_hidden_online = 0;
 092  $guests_online = 0;
 093  $online_userlist = '';
 094  $l_online_users = '';
 095   
 096  if (defined('SHOW_ONLINE'))
 097  {
 098   
 099      $user_forum_sql = ( !empty($forum_id) ) ? "AND s.session_page = " . intval($forum_id) : '';
 100      $sql = "SELECT u.username, u.user_id, u.user_allow_viewonline, u.user_level, s.session_logged_in, s.session_ip
 101          FROM ".USERS_TABLE." u, ".SESSIONS_TABLE." s
 102          WHERE u.user_id = s.session_user_id
 103              AND s.session_time >= ".( time() - 300 ) . "
 104              $user_forum_sql
 105          ORDER BY u.username ASC, s.session_ip ASC";
 106      if( !($result = $db->sql_query($sql)) )
 107      {
 108          message_die(GENERAL_ERROR, 'Could not obtain user/online information', '', __LINE__, __FILE__, $sql);
 109      }
 110   
 111      $userlist_ary = array();
 112      $userlist_visible = array();
 113   
 114      $prev_user_id = 0;
 115      $prev_user_ip = $prev_session_ip = '';
 116   
 117      while( $row = $db->sql_fetchrow($result) )
 118      {
 119          // User is logged in and therefor not a guest
 120          if ( $row['session_logged_in'] )
 121          {
 122              // Skip multiple sessions for one user
 123              if ( $row['user_id'] != $prev_user_id )
 124              {
 125                  $style_color = '';
 126                  if ( $row['user_level'] == ADMIN )
 127                  {
 128                      $row['username'] = '<b>' . $row['username'] . '</b>';
 129                      $style_color = 'style="color:#' . $theme['fontcolor3'] . '"';
 130                  }
 131                  else if ( $row['user_level'] == MOD )
 132                  {
 133                      $row['username'] = '<b>' . $row['username'] . '</b>';
 134                      $style_color = 'style="color:#' . $theme['fontcolor2'] . '"';
 135                  }
 136   
 137                  if ( $row['user_allow_viewonline'] )
 138                  {
 139                      $user_online_link = '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=" . $row['user_id']) . '"' . $style_color .'>' . $row['username'] . '</a>';
 140                      $logged_visible_online++;
 141                  }
 142                  else
 143                  {
 144                      $user_online_link = '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=" . $row['user_id']) . '"' . $style_color .'><i>' . $row['username'] . '</i></a>';
 145                      $logged_hidden_online++;
 146                  }
 147   
 148                  if ( $row['user_allow_viewonline'] || $userdata['user_level'] == ADMIN )
 149                  {
 150                      $online_userlist .= ( $online_userlist != '' ) ? ', ' . $user_online_link : $user_online_link;
 151                  }
 152              }
 153   
 154              $prev_user_id = $row['user_id'];
 155          }
 156          else
 157          {
 158              // Skip multiple sessions for one user
 159              if ( $row['session_ip'] != $prev_session_ip )
 160              {
 161                  $guests_online++;
 162              }
 163          }
 164   
 165          $prev_session_ip = $row['session_ip'];
 166      }
 167      $db->sql_freeresult($result);
 168   
 169      if ( empty($online_userlist) )
 170      {
 171          $online_userlist = $lang['None'];
 172      }
 173      $online_userlist = ( ( isset($forum_id) ) ? $lang['Browsing_forum'] : $lang['Registered_users'] ) . ' ' . $online_userlist;
 174   
 175      $total_online_users = $logged_visible_online + $logged_hidden_online + $guests_online;
 176   
 177      if ( $total_online_users > $board_config['record_online_users'])
 178      {
 179          $board_config['record_online_users'] = $total_online_users;
 180          $board_config['record_online_date'] = time();
 181   
 182          $sql = "UPDATE " . CONFIG_TABLE . "
 183              SET config_value = '$total_online_users'
 184              WHERE config_name = 'record_online_users'";
 185          if ( !$db->sql_query($sql) )
 186          {
 187              message_die(GENERAL_ERROR, 'Could not update online user record (nr of users)', '', __LINE__, __FILE__, $sql);
 188          }
 189   
 190          $sql = "UPDATE " . CONFIG_TABLE . "
 191              SET config_value = '" . $board_config['record_online_date'] . "'
 192              WHERE config_name = 'record_online_date'";
 193          if ( !$db->sql_query($sql) )
 194          {
 195              message_die(GENERAL_ERROR, 'Could not update online user record (date)', '', __LINE__, __FILE__, $sql);
 196          }
 197      }
 198   
 199      if ( $total_online_users == 0 )
 200      {
 201          $l_t_user_s = $lang['Online_users_zero_total'];
 202      }
 203      else if ( $total_online_users == 1 )
 204      {
 205          $l_t_user_s = $lang['Online_user_total'];
 206      }
 207      else
 208      {
 209          $l_t_user_s = $lang['Online_users_total'];
 210      }
 211   
 212      if ( $logged_visible_online == 0 )
 213      {
 214          $l_r_user_s = $lang['Reg_users_zero_total'];
 215      }
 216      else if ( $logged_visible_online == 1 )
 217      {
 218          $l_r_user_s = $lang['Reg_user_total'];
 219      }
 220      else
 221      {
 222          $l_r_user_s = $lang['Reg_users_total'];
 223      }
 224   
 225      if ( $logged_hidden_online == 0 )
 226      {
 227          $l_h_user_s = $lang['Hidden_users_zero_total'];
 228      }
 229      else if ( $logged_hidden_online == 1 )
 230      {
 231          $l_h_user_s = $lang['Hidden_user_total'];
 232      }
 233      else
 234      {
 235          $l_h_user_s = $lang['Hidden_users_total'];
 236      }
 237   
 238      if ( $guests_online == 0 )
 239      {
 240          $l_g_user_s = $lang['Guest_users_zero_total'];
 241      }
 242      else if ( $guests_online == 1 )
 243      {
 244          $l_g_user_s = $lang['Guest_user_total'];
 245      }
 246      else
 247      {
 248          $l_g_user_s = $lang['Guest_users_total'];
 249      }
 250   
 251      $l_online_users = sprintf($l_t_user_s, $total_online_users);
 252      $l_online_users .= sprintf($l_r_user_s, $logged_visible_online);
 253      $l_online_users .= sprintf($l_h_user_s, $logged_hidden_online);
 254      $l_online_users .= sprintf($l_g_user_s, $guests_online);
 255  }
 256   
 257  //
 258  // Obtain number of new private messages
 259  // if user is logged in
 260  //
 261  if ( ($userdata['session_logged_in']) && (empty($gen_simple_header)) )
 262  {
 263      if ( $userdata['user_new_privmsg'] )
 264      {
 265          $l_message_new = ( $userdata['user_new_privmsg'] == 1 ) ? $lang['New_pm'] : $lang['New_pms'];
 266          $l_privmsgs_text = sprintf($l_message_new, $userdata['user_new_privmsg']);
 267   
 268          if ( $userdata['user_last_privmsg'] > $userdata['user_lastvisit'] )
 269          {
 270              $sql = "UPDATE " . USERS_TABLE . "
 271                  SET user_last_privmsg = " . $userdata['user_lastvisit'] . "
 272                  WHERE user_id = " . $userdata['user_id'];
 273              if ( !$db->sql_query($sql) )
 274              {
 275                  message_die(GENERAL_ERROR, 'Could not update private message new/read time for user', '', __LINE__, __FILE__, $sql);
 276              }
 277   
 278              $s_privmsg_new = 1;
 279              $icon_pm = $images['pm_new_msg'];
 280          }
 281          else
 282          {
 283              $s_privmsg_new = 0;
 284              $icon_pm = $images['pm_new_msg'];
 285          }
 286      }
 287      else
 288      {
 289          $l_privmsgs_text = $lang['No_new_pm'];
 290   
 291          $s_privmsg_new = 0;
 292          $icon_pm = $images['pm_no_new_msg'];
 293      }
 294   
 295      if ( $userdata['user_unread_privmsg'] )
 296      {
 297          $l_message_unread = ( $userdata['user_unread_privmsg'] == 1 ) ? $lang['Unread_pm'] : $lang['Unread_pms'];
 298          $l_privmsgs_text_unread = sprintf($l_message_unread, $userdata['user_unread_privmsg']);
 299      }
 300      else
 301      {
 302          $l_privmsgs_text_unread = $lang['No_unread_pm'];
 303      }
 304  }
 305  else
 306  {
 307      $icon_pm = $images['pm_no_new_msg'];
 308      $l_privmsgs_text = $lang['Login_check_pm'];
 309      $l_privmsgs_text_unread = '';
 310      $s_privmsg_new = 0;
 311  }
 312   
 313  //
 314  // Generate HTML required for Mozilla Navigation bar
 315  //
 316  if (!isset($nav_links))
 317  {
 318      $nav_links = array();
 319  }
 320   
 321  $nav_links_html = '';
 322  $nav_link_proto = '<link rel="%s" href="%s" title="%s" />' . "\n";
 323  while( list($nav_item, $nav_array) = @each($nav_links) )
 324  {
 325      if ( !empty($nav_array['url']) )
 326      {
 327          $nav_links_html .= sprintf($nav_link_proto, $nav_item, append_sid($nav_array['url']), $nav_array['title']);
 328      }
 329      else
 330      {
 331          // We have a nested array, used for items like <link rel='chapter'> that can occur more than once.
 332          while( list(,$nested_array) = each($nav_array) )
 333          {
 334              $nav_links_html .= sprintf($nav_link_proto, $nav_item, $nested_array['url'], $nested_array['title']);
 335          }
 336      }
 337  }
 338   
 339  // Format Timezone. We are unable to use array_pop here, because of PHP3 compatibility
 340  $l_timezone = explode('.', $board_config['board_timezone']);
 341  $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'])];
 342  //
 343  // The following assigns all _common_ variables that may be used at any point
 344  // in a template.
 345  //
 346  $template->assign_vars(array(
 347      'SITENAME' => $board_config['sitename'],
 348      'SITE_DESCRIPTION' => $board_config['site_desc'],
 349      'PAGE_TITLE' => $page_title,
 350      'LAST_VISIT_DATE' => sprintf($lang['You_last_visit'], $s_last_visit),
 351      'CURRENT_TIME' => sprintf($lang['Current_time'], create_date($board_config['default_dateformat'], time(), $board_config['board_timezone'])),
 352      'TOTAL_USERS_ONLINE' => $l_online_users,
 353      'LOGGED_IN_USER_LIST' => $online_userlist,
 354      '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'])),
 355      'PRIVATE_MESSAGE_INFO' => $l_privmsgs_text,
 356      'PRIVATE_MESSAGE_INFO_UNREAD' => $l_privmsgs_text_unread,
 357      'PRIVATE_MESSAGE_NEW_FLAG' => $s_privmsg_new,
 358   
 359      'PRIVMSG_IMG' => $icon_pm,
 360   
 361      'L_USERNAME' => $lang['Username'],
 362      'L_PASSWORD' => $lang['Password'],
 363      'L_LOGIN_LOGOUT' => $l_login_logout,
 364      'L_LOGIN' => $lang['Login'],
 365      'L_LOG_ME_IN' => $lang['Log_me_in'],
 366      'L_AUTO_LOGIN' => $lang['Log_me_in'],
 367      'L_INDEX' => sprintf($lang['Forum_Index'], $board_config['sitename']),
 368      'L_REGISTER' => $lang['Register'],
 369      'L_PROFILE' => $lang['Profile'],
 370      'L_SEARCH' => $lang['Search'],
 371      'L_PRIVATEMSGS' => $lang['Private_Messages'],
 372      'L_WHO_IS_ONLINE' => $lang['Who_is_Online'],
 373      'L_MEMBERLIST' => $lang['Memberlist'],
 374      'L_FAQ' => $lang['FAQ'],
 375      'L_USERGROUPS' => $lang['Usergroups'],
 376      'L_SEARCH_NEW' => $lang['Search_new'],
 377      'L_SEARCH_UNANSWERED' => $lang['Search_unanswered'],
 378      'L_SEARCH_SELF' => $lang['Search_your_posts'],
 379      'L_WHOSONLINE_ADMIN' => sprintf($lang['Admin_online_color'], '<span style="color:#' . $theme['fontcolor3'] . '">', '</span>'),
 380      'L_WHOSONLINE_MOD' => sprintf($lang['Mod_online_color'], '<span style="color:#' . $theme['fontcolor2'] . '">', '</span>'),
 381   
 382      'U_SEARCH_UNANSWERED' => append_sid('search.'.$phpEx.'?search_id=unanswered'),
 383      'U_SEARCH_SELF' => append_sid('search.'.$phpEx.'?search_id=egosearch'),
 384      'U_SEARCH_NEW' => append_sid('search.'.$phpEx.'?search_id=newposts'),
 385      'U_INDEX' => append_sid('index.'.$phpEx),
 386      'U_REGISTER' => append_sid('profile.'.$phpEx.'?mode=register'),
 387      'U_PROFILE' => append_sid('profile.'.$phpEx.'?mode=editprofile'),
 388      'U_PRIVATEMSGS' => append_sid('privmsg.'.$phpEx.'?folder=inbox'),
 389      'U_PRIVATEMSGS_POPUP' => append_sid('privmsg.'.$phpEx.'?mode=newpm'),
 390      'U_SEARCH' => append_sid('search.'.$phpEx),
 391      'U_MEMBERLIST' => append_sid('memberlist.'.$phpEx),
 392      'U_MODCP' => append_sid('modcp.'.$phpEx),
 393      'U_FAQ' => append_sid('faq.'.$phpEx),
 394      'U_VIEWONLINE' => append_sid('viewonline.'.$phpEx),
 395      'U_LOGIN_LOGOUT' => append_sid($u_login_logout),
 396      'U_GROUP_CP' => append_sid('groupcp.'.$phpEx),
 397   
 398      'S_CONTENT_DIRECTION' => $lang['DIRECTION'],
 399      'S_CONTENT_ENCODING' => $lang['ENCODING'],
 400      'S_CONTENT_DIR_LEFT' => $lang['LEFT'],
 401      'S_CONTENT_DIR_RIGHT' => $lang['RIGHT'],
 402      'S_TIMEZONE' => sprintf($lang['All_times'], $l_timezone),
 403      'S_LOGIN_ACTION' => append_sid('login.'.$phpEx),
 404   
 405      'T_HEAD_STYLESHEET' => $theme['head_stylesheet'],
 406      'T_BODY_BACKGROUND' => $theme['body_background'],
 407      'T_BODY_BGCOLOR' => '#'.$theme['body_bgcolor'],
 408      'T_BODY_TEXT' => '#'.$theme['body_text'],
 409      'T_BODY_LINK' => '#'.$theme['body_link'],
 410      'T_BODY_VLINK' => '#'.$theme['body_vlink'],
 411      'T_BODY_ALINK' => '#'.$theme['body_alink'],
 412      'T_BODY_HLINK' => '#'.$theme['body_hlink'],
 413      'T_TR_COLOR1' => '#'.$theme['tr_color1'],
 414      'T_TR_COLOR2' => '#'.$theme['tr_color2'],
 415      'T_TR_COLOR3' => '#'.$theme['tr_color3'],
 416      'T_TR_CLASS1' => $theme['tr_class1'],
 417      'T_TR_CLASS2' => $theme['tr_class2'],
 418      'T_TR_CLASS3' => $theme['tr_class3'],
 419      'T_TH_COLOR1' => '#'.$theme['th_color1'],
 420      'T_TH_COLOR2' => '#'.$theme['th_color2'],
 421      'T_TH_COLOR3' => '#'.$theme['th_color3'],
 422      'T_TH_CLASS1' => $theme['th_class1'],
 423      'T_TH_CLASS2' => $theme['th_class2'],
 424      'T_TH_CLASS3' => $theme['th_class3'],
 425      'T_TD_COLOR1' => '#'.$theme['td_color1'],
 426      'T_TD_COLOR2' => '#'.$theme['td_color2'],
 427      'T_TD_COLOR3' => '#'.$theme['td_color3'],
 428      'T_TD_CLASS1' => $theme['td_class1'],
 429      'T_TD_CLASS2' => $theme['td_class2'],
 430      'T_TD_CLASS3' => $theme['td_class3'],
 431      'T_FONTFACE1' => $theme['fontface1'],
 432      'T_FONTFACE2' => $theme['fontface2'],
 433      'T_FONTFACE3' => $theme['fontface3'],
 434      'T_FONTSIZE1' => $theme['fontsize1'],
 435      'T_FONTSIZE2' => $theme['fontsize2'],
 436      'T_FONTSIZE3' => $theme['fontsize3'],
 437      'T_FONTCOLOR1' => '#'.$theme['fontcolor1'],
 438      'T_FONTCOLOR2' => '#'.$theme['fontcolor2'],
 439      'T_FONTCOLOR3' => '#'.$theme['fontcolor3'],
 440      'T_SPAN_CLASS1' => $theme['span_class1'],
 441      'T_SPAN_CLASS2' => $theme['span_class2'],
 442      'T_SPAN_CLASS3' => $theme['span_class3'],
 443   
 444      'NAV_LINKS' => $nav_links_html)
 445  );
 446   
 447  //
 448  // Login box?
 449  //
 450  if ( !$userdata['session_logged_in'] )
 451  {
 452      $template->assign_block_vars('switch_user_logged_out', array());
 453      //
 454      // Allow autologin?
 455      //
 456      if (!isset($board_config['allow_autologin']) || $board_config['allow_autologin'] )
 457      {
 458          $template->assign_block_vars('switch_allow_autologin', array());
 459          $template->assign_block_vars('switch_user_logged_out.switch_allow_autologin', array());
 460      }
 461  }
 462  else
 463  {
 464      $template->assign_block_vars('switch_user_logged_in', array());
 465   
 466      if ( !empty($userdata['user_popup_pm']) )
 467      {
 468          $template->assign_block_vars('switch_enable_pm_popup', array());
 469      }
 470  }
 471   
 472  // Add no-cache control for cookies if they are set
 473  //$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", ' : '';
 474   
 475  // Work around for "current" Apache 2 + PHP module which seems to not
 476  // cope with private cache control setting
 477  if (!empty($HTTP_SERVER_VARS['SERVER_SOFTWARE']) && strstr($HTTP_SERVER_VARS['SERVER_SOFTWARE'], 'Apache/2'))
 478  {
 479      header ('Cache-Control: no-cache, pre-check=0, post-check=0');
 480  }
 481  else
 482  {
 483      header ('Cache-Control: private, pre-check=0, post-check=0, max-age=0');
 484  }
 485  header ('Expires: 0');
 486  header ('Pragma: no-cache');
 487   
 488  $template->pparse('overall_header');
 489   
 490  ?>