[ Index ]
 

Code source de PHP NUKE 7.9

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/modules/Forums/ -> viewonline.php (source)

   1  <?php
   2  /***************************************************************************

   3   *                              viewonline.php

   4   *                            -------------------

   5   *   begin                : Saturday, Feb 13, 2001

   6   *   copyright            : (C) 2001 The phpBB Group

   7   *   email                : support@phpbb.com

   8   *

   9   *   Id: viewonline.php,v 1.54.2.4 2005/05/06 20:50:10 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  if ( !defined('MODULE_FILE') )
  23  {
  24      die("You can't access this file directly...");
  25  }
  26  $module_name = basename(dirname(__FILE__));
  27  require("modules/".$module_name."/nukebb.php");
  28  
  29  define('IN_PHPBB', true);
  30  include ($phpbb_root_path . 'extension.inc');
  31  include($phpbb_root_path . 'common.'.$phpEx);
  32  
  33  //

  34  // Start session management

  35  //

  36  $userdata = session_pagestart($user_ip, PAGE_VIEWONLINE, $nukeuser);
  37  init_userprefs($userdata);
  38  //

  39  // End session management

  40  //

  41  
  42  //

  43  // Output page header and load viewonline template

  44  //

  45  $page_title = $lang['Who_is_online'];
  46  include ("includes/page_header.php");
  47  
  48  $template->set_filenames(array(
  49          'body' => 'viewonline_body.tpl')
  50  );
  51  make_jumpbox('viewforum.'.$phpEx);
  52  
  53  $template->assign_vars(array(
  54          'L_WHOSONLINE' => $lang['Who_is_Online'],
  55          'L_ONLINE_EXPLAIN' => $lang['Online_explain'],
  56          'L_USERNAME' => $lang['Username'],
  57          'L_FORUM_LOCATION' => $lang['Forum_Location'],
  58          'L_LAST_UPDATE' => $lang['Last_updated'])
  59  );
  60  
  61  //

  62  // Forum info

  63  //

  64  $sql = "SELECT forum_name, forum_id
  65          FROM " . FORUMS_TABLE;
  66  if ( $result = $db->sql_query($sql) )
  67  {
  68          while( $row = $db->sql_fetchrow($result) )
  69          {
  70                  $forum_data[$row['forum_id']] = $row['forum_name'];
  71          }
  72  }
  73  else
  74  {
  75          message_die(GENERAL_ERROR, 'Could not obtain user/online forums information', '', __LINE__, __FILE__, $sql);
  76  }
  77  
  78  //

  79  // Get auth data

  80  //

  81  $is_auth_ary = array();
  82  $is_auth_ary = auth(AUTH_VIEW, AUTH_LIST_ALL, $userdata);
  83  
  84  //

  85  // Get user list

  86  //

  87  $sql = "SELECT u.user_id, u.username, u.user_allow_viewonline, u.user_level, s.session_logged_in, s.session_time, s.session_page, s.session_ip
  88          FROM ".USERS_TABLE." u, ".SESSIONS_TABLE." s
  89          WHERE u.user_id = s.session_user_id
  90                  AND s.session_time >= ".( time() - 300 ) . "
  91          ORDER BY u.username ASC, s.session_ip ASC";
  92  if ( !($result = $db->sql_query($sql)) )
  93  {
  94          message_die(GENERAL_ERROR, 'Could not obtain regd user/online information', '', __LINE__, __FILE__, $sql);
  95  }
  96  
  97  $guest_users = 0;
  98  $registered_users = 0;
  99  $hidden_users = 0;
 100  
 101  $reg_counter = 0;
 102  $guest_counter = 0;
 103  $prev_user = 0;
 104  $prev_ip = '';
 105  
 106  while ( $row = $db->sql_fetchrow($result) )
 107  {
 108          $view_online = false;
 109  
 110          if ( $row['session_logged_in'] )
 111          {
 112                  $user_id = $row['user_id'];
 113  
 114                  if ( $user_id != $prev_user )
 115                  {
 116                          $username = $row['username'];
 117  
 118                          $style_color = '';
 119                          if ( $row['user_level'] == ADMIN )
 120                          {
 121                                  $username = '<b style="color:#' . $theme['fontcolor3'] . '">' . $username . '</b>';
 122                          }
 123                          else if ( $row['user_level'] == MOD )
 124                          {
 125                                  $username = '<b style="color:#' . $theme['fontcolor2'] . '">' . $username . '</b>';
 126                          }
 127  
 128                          if ( !$row['user_allow_viewonline'] )
 129                          {
 130                                  $view_online = ( $userdata['user_level'] == ADMIN ) ? true : false;
 131                                  $hidden_users++;
 132  
 133                                  $username = '<i>' . $username . '</i>';
 134                          }
 135                          else
 136                          {
 137                                  $view_online = true;
 138                                  $registered_users++;
 139                          }
 140  
 141                          $which_counter = 'reg_counter';
 142                          $which_row = 'reg_user_row';
 143                          $prev_user = $user_id;
 144                  }
 145          }
 146          else
 147          {
 148                  if ( $row['session_ip'] != $prev_ip )
 149                  {
 150                          $username = $lang['Guest'];
 151                          $view_online = true;
 152                          $guest_users++;
 153  
 154                          $which_counter = 'guest_counter';
 155                          $which_row = 'guest_user_row';
 156                  }
 157          }
 158  
 159          $prev_ip = $row['session_ip'];
 160  
 161          if ( $view_online )
 162          {
 163                  if ( $row['session_page'] < 1 || !$is_auth_ary[$row['session_page']]['auth_view'] )
 164                  {
 165                          switch( $row['session_page'] )
 166                          {
 167                                  case PAGE_INDEX:
 168                                          $location = $lang['Forum_index'];
 169                                          $location_url = "index.$phpEx";
 170                                          break;
 171                                  case PAGE_POSTING:
 172                                          $location = $lang['Posting_message'];
 173                                          $location_url = "index.$phpEx";
 174                                          break;
 175                                  case PAGE_LOGIN:
 176                                          $location = $lang['Logging_on'];
 177                                          $location_url = "index.$phpEx";
 178                                          break;
 179                                  case PAGE_SEARCH:
 180                                          $location = $lang['Searching_forums'];
 181                                          $location_url = "search.$phpEx";
 182                                          break;
 183                                  case PAGE_PROFILE:
 184                                          $location = $lang['Viewing_profile'];
 185                                          $location_url = "index.$phpEx";
 186                                          break;
 187                                  case PAGE_VIEWONLINE:
 188                                          $location = $lang['Viewing_online'];
 189                                          $location_url = "viewonline.$phpEx";
 190                                          break;
 191                                  case PAGE_VIEWMEMBERS:
 192                                          $location = $lang['Viewing_member_list'];
 193                                          $location_url = "memberlist.$phpEx";
 194                                          break;
 195                                  case PAGE_PRIVMSGS:
 196                                          $location = $lang['Viewing_priv_msgs'];
 197                                          $location_url = "privmsg.$phpEx";
 198                                          break;
 199                                  case PAGE_FAQ:
 200                                          $location = $lang['Viewing_FAQ'];
 201                                          $location_url = "faq.$phpEx";
 202                                          break;
 203                                  default:
 204                                          $location = $lang['Forum_index'];
 205                                          $location_url = "index.$phpEx";
 206                          }
 207                  }
 208                  else
 209                  {
 210              $location_url = append_sid("viewforum.$phpEx?" . POST_FORUM_URL . '=' . $row['session_page']);
 211                          $location = $forum_data[$row['session_page']];
 212                  }
 213  
 214                  $row_color = ( $$which_counter % 2 ) ? $theme['td_color1'] : $theme['td_color2'];
 215                  $row_class = ( $$which_counter % 2 ) ? $theme['td_class1'] : $theme['td_class2'];
 216  
 217                  $template->assign_block_vars("$which_row", array(
 218                          'ROW_COLOR' => '#' . $row_color,
 219                          'ROW_CLASS' => $row_class,
 220                          'USERNAME' => $username,
 221                          'LASTUPDATE' => create_date($board_config['default_dateformat'], $row['session_time'], $board_config['board_timezone']),
 222                          'FORUM_LOCATION' => $location,
 223  
 224                          'U_USER_PROFILE' => append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . '=' . $user_id),
 225                          'U_FORUM_LOCATION' => append_sid($location_url))
 226                  );
 227  
 228                  $$which_counter++;
 229          }
 230  }
 231  
 232  if( $registered_users == 0 )
 233  {
 234          $l_r_user_s = $lang['Reg_users_zero_online'];
 235  }
 236  else if( $registered_users == 1 )
 237  {
 238          $l_r_user_s = $lang['Reg_user_online'];
 239  }
 240  else
 241  {
 242          $l_r_user_s = $lang['Reg_users_online'];
 243  }
 244  
 245  if( $hidden_users == 0 )
 246  {
 247          $l_h_user_s = $lang['Hidden_users_zero_online'];
 248  }
 249  else if( $hidden_users == 1 )
 250  {
 251          $l_h_user_s = $lang['Hidden_user_online'];
 252  }
 253  else
 254  {
 255          $l_h_user_s = $lang['Hidden_users_online'];
 256  }
 257  
 258  if( $guest_users == 0 )
 259  {
 260          $l_g_user_s = $lang['Guest_users_zero_online'];
 261  }
 262  else if( $guest_users == 1 )
 263  {
 264          $l_g_user_s = $lang['Guest_user_online'];
 265  }
 266  else
 267  {
 268          $l_g_user_s = $lang['Guest_users_online'];
 269  }
 270  
 271  $template->assign_vars(array(
 272          'TOTAL_REGISTERED_USERS_ONLINE' => sprintf($l_r_user_s, $registered_users) . sprintf($l_h_user_s, $hidden_users),
 273          'TOTAL_GUEST_USERS_ONLINE' => sprintf($l_g_user_s, $guest_users))
 274  );
 275  
 276  if ( $registered_users + $hidden_users == 0 )
 277  {
 278          $template->assign_vars(array(
 279                  'L_NO_REGISTERED_USERS_BROWSING' => $lang['No_users_browsing'])
 280          );
 281  }
 282  
 283  if ( $guest_users == 0 )
 284  {
 285          $template->assign_vars(array(
 286                  'L_NO_GUESTS_BROWSING' => $lang['No_users_browsing'])
 287          );
 288  }
 289  
 290  $template->pparse('body');
 291  
 292  include ("includes/page_tail.php");
 293  
 294  ?>


Généré le : Sun Apr 1 11:11:59 2007 par Balluche grâce à PHPXref 0.7