[ Index ]
 

Code source de PHP NUKE 7.9

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

title

Body

[fermer]

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

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

   3   *                               viewforum.php

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

   5   *   begin                : Saturday, Feb 13, 2001

   6   *   copyright            : (C) 2001 The phpBB Group

   7   *   email                : support@phpbb.com

   8   *

   9   *   Id: viewforum.php,v 1.139.2.12 2004/03/13 15:08:23 acydburn Exp

  10   *

  11   *

  12   ***************************************************************************/
  13  
  14  /***************************************************************************

  15  * phpbb2 forums port version 2.0.5 (c) 2003 - Nuke Cops (http://nukecops.com)

  16  *

  17  * Ported by Nuke Cops to phpbb2 standalone 2.0.5 Test

  18  * and debugging completed by the Elite Nukers and site members.

  19  *

  20  * You run this package at your sole risk. Nuke Cops and affiliates cannot

  21  * be held liable if anything goes wrong. You are advised to test this

  22  * package on a development system. Backup everything before implementing

  23  * in a production environment. If something goes wrong, you can always

  24  * backout and restore your backups.

  25  *

  26  * Installing and running this also means you agree to the terms of the AUP

  27  * found at Nuke Cops.

  28  *

  29  * This is version 2.0.5 of the phpbb2 forum port for PHP-Nuke. Work is based

  30  * on Tom Nitzschner's forum port version 2.0.6. Tom's 2.0.6 port was based

  31  * on the phpbb2 standalone version 2.0.3. Our version 2.0.5 from Nuke Cops is

  32  * now reflecting phpbb2 standalone 2.0.5 that fixes some bugs and the

  33  * invalid_session error message.

  34  ***************************************************************************/
  35  /***************************************************************************

  36   *   This file is part of the phpBB2 port to Nuke 6.0 (c) copyright 2002

  37   *   by Tom Nitzschner (tom@toms-home.com)

  38   *   http://bbtonuke.sourceforge.net (or http://www.toms-home.com)

  39   *

  40   *   As always, make a backup before messing with anything. All code

  41   *   release by me is considered sample code only. It may be fully

  42   *   functual, but you use it at your own risk, if you break it,

  43   *   you get to fix it too. No waranty is given or implied.

  44   *

  45   *   Please post all questions/request about this port on http://bbtonuke.sourceforge.net first,

  46   *   then on my site. All original header code and copyright messages will be maintained

  47   *   to give credit where credit is due. If you modify this, the only requirement is

  48   *   that you also maintain all original copyright messages. All my work is released

  49   *   under the GNU GENERAL PUBLIC LICENSE. Please see the README for more information.

  50   *

  51   ***************************************************************************/
  52  
  53  /***************************************************************************

  54   *

  55   *   This program is free software; you can redistribute it and/or modify

  56   *   it under the terms of the GNU General Public License as published by

  57   *   the Free Software Foundation; either version 2 of the License, or

  58   *   (at your option) any later version.

  59   *

  60   ***************************************************************************/
  61  
  62  if ( !defined('MODULE_FILE') )
  63  {
  64      die("You can't access this file directly...");
  65  }
  66  if ($popup != "1"){
  67      $module_name = basename(dirname(__FILE__));
  68      require("modules/".$module_name."/nukebb.php");
  69  }
  70  else
  71  {
  72      $phpbb_root_path = 'modules/Forums/';
  73  }
  74  define('IN_PHPBB', true);
  75  //$phpbb_root_path = './';

  76  include ($phpbb_root_path . 'extension.inc');
  77  include($phpbb_root_path . 'common.'.$phpEx);
  78  
  79  //

  80  // Start initial var setup

  81  //

  82  if ( isset($HTTP_GET_VARS[POST_FORUM_URL]) || isset($HTTP_POST_VARS[POST_FORUM_URL]) )
  83  {
  84          $forum_id = ( isset($HTTP_GET_VARS[POST_FORUM_URL]) ) ? intval($HTTP_GET_VARS[POST_FORUM_URL]) : intval($HTTP_POST_VARS[POST_FORUM_URL]);
  85  }
  86  else if ( isset($HTTP_GET_VARS['forum']))
  87  {
  88          $forum_id = intval($HTTP_GET_VARS['forum']);
  89  }
  90  else
  91  {
  92          $forum_id = '';
  93  }
  94  
  95  $start = ( isset($HTTP_GET_VARS['start']) ) ? intval($HTTP_GET_VARS['start']) : 0;
  96  
  97  if ( isset($HTTP_GET_VARS['mark']) || isset($HTTP_POST_VARS['mark']) )
  98  {
  99          $mark_read = (isset($HTTP_POST_VARS['mark'])) ? $HTTP_POST_VARS['mark'] : $HTTP_GET_VARS['mark'];
 100  }
 101  else
 102  {
 103          $mark_read = '';
 104  }
 105  //

 106  // End initial var setup

 107  //

 108  
 109  //

 110  // Check if the user has actually sent a forum ID with his/her request

 111  // If not give them a nice error page.

 112  //

 113  if ( !empty($forum_id) )
 114  {
 115          $sql = "SELECT *
 116                  FROM " . FORUMS_TABLE . "
 117                  WHERE forum_id = '$forum_id'";
 118          if ( !($result = $db->sql_query($sql)) )
 119          {
 120                  message_die(GENERAL_ERROR, 'Could not obtain forums information', '', __LINE__, __FILE__, $sql);
 121          }
 122  }
 123  else
 124  {
 125          message_die(GENERAL_MESSAGE, 'Forum_not_exist');
 126  }
 127  
 128  //

 129  // If the query doesn't return any rows this isn't a valid forum. Inform

 130  // the user.

 131  //

 132  if ( !($forum_row = $db->sql_fetchrow($result)) )
 133  {
 134          message_die(GENERAL_MESSAGE, 'Forum_not_exist');
 135  }
 136  
 137  //

 138  // Start session management

 139  //

 140  $userdata = session_pagestart($user_ip, $forum_id, $nukeuser);
 141  init_userprefs($userdata);
 142  //

 143  // End session management

 144  //

 145  
 146  //

 147  // Start auth check

 148  //

 149  $is_auth = array();
 150  $is_auth = auth(AUTH_ALL, $forum_id, $userdata, $forum_row);
 151  
 152  if ( !$is_auth['auth_read'] || !$is_auth['auth_view'] )
 153  {
 154          if ( !$userdata['session_logged_in'] )
 155          {
 156                  $redirect = POST_FORUM_URL . "=$forum_id" . ( ( isset($start) ) ? "&start=$start" : '' );
 157                  $header_location = ( @preg_match("/Microsoft|WebSTAR|Xitami/", $_SERVER["SERVER_SOFTWARE"]) ) ? "Refresh: 0; URL=" : "Location: ";
 158                  header($header_location . append_sid("login.$phpEx?redirect=viewforum.$phpEx&$redirect", true));
 159                  exit;
 160          }
 161          //

 162          // The user is not authed to read this forum ...

 163          //

 164          $message = ( !$is_auth['auth_view'] ) ? $lang['Forum_not_exist'] : sprintf($lang['Sorry_auth_read'], $is_auth['auth_read_type']);
 165  
 166          message_die(GENERAL_MESSAGE, $message);
 167  }
 168  //

 169  // End of auth check

 170  //

 171  
 172  //

 173  // Handle marking posts

 174  //

 175  if ( $mark_read == 'topics' )
 176  {
 177          if ( $userdata['session_logged_in'] )
 178          {
 179                  $sql = "SELECT MAX(post_time) AS last_post
 180                          FROM " . POSTS_TABLE . "
 181                          WHERE forum_id = '$forum_id'";
 182                  if ( !($result = $db->sql_query($sql)) )
 183                  {
 184                          message_die(GENERAL_ERROR, 'Could not obtain forums information', '', __LINE__, __FILE__, $sql);
 185                  }
 186  
 187                  if ( $row = $db->sql_fetchrow($result) )
 188                  {
 189                          $tracking_forums = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) : array();
 190                          $tracking_topics = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) : array();
 191  
 192                          if ( ( count($tracking_forums) + count($tracking_topics) ) >= 150 && empty($tracking_forums[$forum_id]) )
 193                          {
 194                                  asort($tracking_forums);
 195                                  unset($tracking_forums[key($tracking_forums)]);
 196                          }
 197  
 198                          if ( $row['last_post'] > $userdata['user_lastvisit'] )
 199                          {
 200                                  $tracking_forums[$forum_id] = time();
 201  
 202                                  setcookie($board_config['cookie_name'] . '_f', serialize($tracking_forums), 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']);
 203                          }
 204                  }
 205  
 206                  $template->assign_vars(array(
 207                          'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id") . '">')
 208                  );
 209          }
 210  
 211          $message = $lang['Topics_marked_read'] . '<br /><br />' . sprintf($lang['Click_return_forum'], '<a href="' . append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id") . '">', '</a> ');
 212          message_die(GENERAL_MESSAGE, $message);
 213  }
 214  //

 215  // End handle marking posts

 216  //

 217  
 218  $tracking_topics = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) : '';
 219  $tracking_forums = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) : '';
 220  
 221  //

 222  // Do the forum Prune

 223  //

 224  if ( $is_auth['auth_mod'] && $board_config['prune_enable'] )
 225  {
 226          if ( $forum_row['prune_next'] < time() && $forum_row['prune_enable'] )
 227  
 228          {
 229  
 230                  include ("includes/prune.php");
 231  
 232                  require ("includes/functions_admin.php");
 233                  auto_prune($forum_id);
 234          }
 235  }
 236  //

 237  // End of forum prune

 238  //

 239  
 240  //

 241  // Obtain list of moderators of each forum

 242  // First users, then groups ... broken into two queries

 243  //

 244  $sql = "SELECT u.user_id, u.username
 245          FROM " . AUTH_ACCESS_TABLE . " aa, " . USER_GROUP_TABLE . " ug, " . GROUPS_TABLE . " g, " . USERS_TABLE . " u
 246          WHERE aa.forum_id = '$forum_id'
 247                  AND aa.auth_mod = " . TRUE . "
 248                  AND g.group_single_user = '1'
 249                  AND ug.group_id = aa.group_id
 250                  AND g.group_id = aa.group_id
 251                  AND u.user_id = ug.user_id
 252          GROUP BY u.user_id, u.username
 253          ORDER BY u.user_id";
 254  if ( !($result = $db->sql_query($sql)) )
 255  {
 256          message_die(GENERAL_ERROR, 'Could not query forum moderator information', '', __LINE__, __FILE__, $sql);
 257  }
 258  
 259  $moderators = array();
 260  while( $row = $db->sql_fetchrow($result) )
 261  {
 262          $moderators[] = '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=" . $row['user_id']) . '">' . $row['username'] . '</a>';
 263  }
 264  
 265  $sql = "SELECT g.group_id, g.group_name
 266          FROM " . AUTH_ACCESS_TABLE . " aa, " . USER_GROUP_TABLE . " ug, " . GROUPS_TABLE . " g
 267          WHERE aa.forum_id = '$forum_id'
 268                  AND aa.auth_mod = " . TRUE . "
 269                  AND g.group_single_user = '0'
 270                  AND g.group_type <> ". GROUP_HIDDEN ."
 271                  AND ug.group_id = aa.group_id
 272                  AND g.group_id = aa.group_id
 273          GROUP BY g.group_id, g.group_name
 274          ORDER BY g.group_id";
 275  if ( !($result = $db->sql_query($sql)) )
 276  {
 277          message_die(GENERAL_ERROR, 'Could not query forum moderator information', '', __LINE__, __FILE__, $sql);
 278  }
 279  
 280  while( $row = $db->sql_fetchrow($result) )
 281  {
 282          $moderators[] = '<a href="' . append_sid("groupcp.$phpEx?" . POST_GROUPS_URL . "=" . $row['group_id']) . '">' . $row['group_name'] . '</a>';
 283  }
 284  
 285  $l_moderators = ( count($moderators) == 1 ) ? $lang['Moderator'] : $lang['Moderators'];
 286  $forum_moderators = ( count($moderators) ) ? implode(', ', $moderators) : $lang['None'];
 287  unset($moderators);
 288  
 289  //

 290  // Generate a 'Show topics in previous x days' select box. If the topicsdays var is sent

 291  // then get it's value, find the number of topics with dates newer than it (to properly

 292  // handle pagination) and alter the main query

 293  //

 294  $previous_days = array(0, 1, 7, 14, 30, 90, 180, 364);
 295  $previous_days_text = array($lang['All_Topics'], $lang['1_Day'], $lang['7_Days'], $lang['2_Weeks'], $lang['1_Month'], $lang['3_Months'], $lang['6_Months'], $lang['1_Year']);
 296  
 297  if ( !empty($HTTP_POST_VARS['topicdays']) || !empty($HTTP_GET_VARS['topicdays']) )
 298  {
 299          $topic_days = ( !empty($HTTP_POST_VARS['topicdays']) ) ? intval($HTTP_POST_VARS['topicdays']) : intval($HTTP_GET_VARS['topicdays']);
 300          $min_topic_time = time() - ($topic_days * 86400);
 301  
 302          $sql = "SELECT COUNT(t.topic_id) AS forum_topics
 303                  FROM " . TOPICS_TABLE . " t, " . POSTS_TABLE . " p
 304                  WHERE t.forum_id = '$forum_id'
 305                          AND p.post_id = t.topic_last_post_id
 306                          AND p.post_time >= '$min_topic_time'";
 307  
 308          if ( !($result = $db->sql_query($sql)) )
 309          {
 310                  message_die(GENERAL_ERROR, 'Could not obtain limited topics count information', '', __LINE__, __FILE__, $sql);
 311          }
 312          $row = $db->sql_fetchrow($result);
 313  
 314          $topics_count = ( $row['forum_topics'] ) ? $row['forum_topics'] : 1;
 315          $limit_topics_time = "AND p.post_time >= $min_topic_time";
 316  
 317          if ( !empty($HTTP_POST_VARS['topicdays']) )
 318          {
 319                  $start = 0;
 320          }
 321  }
 322  else
 323  {
 324          $topics_count = ( $forum_row['forum_topics'] ) ? $forum_row['forum_topics'] : 1;
 325  
 326          $limit_topics_time = '';
 327          $topic_days = 0;
 328  }
 329  
 330  $select_topic_days = '<select name="topicdays">';
 331  for($i = 0; $i < count($previous_days); $i++)
 332  {
 333          $selected = ($topic_days == $previous_days[$i]) ? ' selected="selected"' : '';
 334          $select_topic_days .= '<option value="' . $previous_days[$i] . '"' . $selected . '>' . $previous_days_text[$i] . '</option>';
 335  }
 336  $select_topic_days .= '</select>';
 337  
 338  
 339  //

 340  // All announcement data, this keeps announcements

 341  // on each viewforum page ...

 342  //

 343  $sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_time, p.post_username
 344          FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . USERS_TABLE . " u2
 345          WHERE t.forum_id = '$forum_id'
 346                  AND t.topic_poster = u.user_id
 347                  AND p.post_id = t.topic_last_post_id
 348                  AND p.poster_id = u2.user_id
 349                  AND t.topic_type = " . POST_ANNOUNCE . "
 350          ORDER BY t.topic_last_post_id DESC ";
 351  if ( !($result = $db->sql_query($sql)) )
 352  {
 353     message_die(GENERAL_ERROR, 'Could not obtain topic information', '', __LINE__, __FILE__, $sql);
 354  }
 355  
 356  $topic_rowset = array();
 357  $total_announcements = 0;
 358  while( $row = $db->sql_fetchrow($result) )
 359  {
 360          $topic_rowset[] = $row;
 361          $total_announcements++;
 362  }
 363  
 364  $db->sql_freeresult($result);
 365  
 366  //

 367  // Grab all the basic data (all topics except announcements)

 368  // for this forum

 369  //

 370  $sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_username, p2.post_username AS post_username2, p2.post_time
 371          FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . POSTS_TABLE . " p2, " . USERS_TABLE . " u2
 372          WHERE t.forum_id = '$forum_id'
 373                  AND t.topic_poster = u.user_id
 374                  AND p.post_id = t.topic_first_post_id
 375                  AND p2.post_id = t.topic_last_post_id
 376                  AND u2.user_id = p2.poster_id
 377                  AND t.topic_type <> " . POST_ANNOUNCE . "
 378                  $limit_topics_time
 379          ORDER BY t.topic_type DESC, t.topic_last_post_id DESC
 380          LIMIT $start, ".$board_config['topics_per_page'];
 381  if ( !($result = $db->sql_query($sql)) )
 382  {
 383     message_die(GENERAL_ERROR, 'Could not obtain topic information', '', __LINE__, __FILE__, $sql);
 384  }
 385  
 386  $total_topics = 0;
 387  while( $row = $db->sql_fetchrow($result) )
 388  {
 389          $topic_rowset[] = $row;
 390          $total_topics++;
 391  }
 392  
 393  $db->sql_freeresult($result);
 394  
 395  //

 396  // Total topics ...

 397  //

 398  $total_topics += $total_announcements;
 399  
 400  //

 401  // Define censored word matches

 402  //

 403  $orig_word = array();
 404  $replacement_word = array();
 405  obtain_word_list($orig_word, $replacement_word);
 406  
 407  //

 408  // Post URL generation for templating vars

 409  //

 410  $template->assign_vars(array(
 411          'L_DISPLAY_TOPICS' => $lang['Display_topics'],
 412  
 413          'U_POST_NEW_TOPIC' => append_sid("posting.$phpEx?mode=newtopic&amp;" . POST_FORUM_URL . "=$forum_id"),
 414  
 415          'S_SELECT_TOPIC_DAYS' => $select_topic_days,
 416          'S_POST_DAYS_ACTION' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=" . $forum_id . "&amp;start=$start"))
 417  );
 418  
 419  //

 420  // User authorisation levels output

 421  //

 422  $s_auth_can = ( ( $is_auth['auth_post'] ) ? $lang['Rules_post_can'] : $lang['Rules_post_cannot'] ) . '<br />';
 423  $s_auth_can .= ( ( $is_auth['auth_reply'] ) ? $lang['Rules_reply_can'] : $lang['Rules_reply_cannot'] ) . '<br />';
 424  $s_auth_can .= ( ( $is_auth['auth_edit'] ) ? $lang['Rules_edit_can'] : $lang['Rules_edit_cannot'] ) . '<br />';
 425  $s_auth_can .= ( ( $is_auth['auth_delete'] ) ? $lang['Rules_delete_can'] : $lang['Rules_delete_cannot'] ) . '<br />';
 426  $s_auth_can .= ( ( $is_auth['auth_vote'] ) ? $lang['Rules_vote_can'] : $lang['Rules_vote_cannot'] ) . '<br />';
 427  
 428  if ( $is_auth['auth_mod'] )
 429  {
 430          $s_auth_can .= sprintf($lang['Rules_moderate'], '<a href="' . append_sid("modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id") . '">', '</a>');
 431  }
 432  
 433  //

 434  // Mozilla navigation bar

 435  //

 436  $nav_links['up'] = array(
 437          'url' => append_sid('index.'.$phpEx),
 438          'title' => sprintf($lang['Forum_Index'], $board_config['sitename'])
 439  );
 440  
 441  //

 442  // Dump out the page header and load viewforum template

 443  //

 444  define('SHOW_ONLINE', true);
 445  $page_title = $lang['View_forum'] . ' - ' . $forum_row['forum_name'];
 446  include ("includes/page_header.php");
 447  
 448  $template->set_filenames(array(
 449          'body' => 'viewforum_body.tpl')
 450  );
 451  make_jumpbox('viewforum.'.$phpEx);
 452  
 453  $template->assign_vars(array(
 454          'FORUM_ID' => $forum_id,
 455          'FORUM_NAME' => $forum_row['forum_name'],
 456          'MODERATORS' => $forum_moderators,
 457          'POST_IMG' => ( $forum_row['forum_status'] == FORUM_LOCKED ) ? $images['post_locked'] : $images['post_new'],
 458  
 459          'FOLDER_IMG' => $images['folder'],
 460          'FOLDER_NEW_IMG' => $images['folder_new'],
 461          'FOLDER_HOT_IMG' => $images['folder_hot'],
 462          'FOLDER_HOT_NEW_IMG' => $images['folder_hot_new'],
 463          'FOLDER_LOCKED_IMG' => $images['folder_locked'],
 464          'FOLDER_LOCKED_NEW_IMG' => $images['folder_locked_new'],
 465          'FOLDER_STICKY_IMG' => $images['folder_sticky'],
 466          'FOLDER_STICKY_NEW_IMG' => $images['folder_sticky_new'],
 467          'FOLDER_ANNOUNCE_IMG' => $images['folder_announce'],
 468          'FOLDER_ANNOUNCE_NEW_IMG' => $images['folder_announce_new'],
 469  
 470          'L_TOPICS' => $lang['Topics'],
 471          'L_REPLIES' => $lang['Replies'],
 472          'L_VIEWS' => $lang['Views'],
 473          'L_POSTS' => $lang['Posts'],
 474          'L_LASTPOST' => $lang['Last_Post'],
 475          'L_MODERATOR' => $l_moderators,
 476          'L_MARK_TOPICS_READ' => $lang['Mark_all_topics'],
 477          'L_POST_NEW_TOPIC' => ( $forum_row['forum_status'] == FORUM_LOCKED ) ? $lang['Forum_locked'] : $lang['Post_new_topic'],
 478          'L_NO_NEW_POSTS' => $lang['No_new_posts'],
 479          'L_NEW_POSTS' => $lang['New_posts'],
 480          'L_NO_NEW_POSTS_LOCKED' => $lang['No_new_posts_locked'],
 481          'L_NEW_POSTS_LOCKED' => $lang['New_posts_locked'],
 482          'L_NO_NEW_POSTS_HOT' => $lang['No_new_posts_hot'],
 483          'L_NEW_POSTS_HOT' => $lang['New_posts_hot'],
 484          'L_ANNOUNCEMENT' => $lang['Post_Announcement'],
 485          'L_STICKY' => $lang['Post_Sticky'],
 486          'L_POSTED' => $lang['Posted'],
 487          'L_JOINED' => $lang['Joined'],
 488          'L_AUTHOR' => $lang['Author'],
 489  
 490          'S_AUTH_LIST' => $s_auth_can,
 491  
 492          'U_VIEW_FORUM' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL ."=$forum_id"),
 493  
 494          'U_MARK_READ' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id&amp;mark=topics"))
 495  );
 496  //

 497  // End header

 498  //

 499  
 500  //

 501  // Okay, lets dump out the page ...

 502  //

 503  if( $total_topics )
 504  {
 505          for($i = 0; $i < $total_topics; $i++)
 506          {
 507                  $topic_id = $topic_rowset[$i]['topic_id'];
 508  
 509                  $topic_title = ( count($orig_word) ) ? preg_replace($orig_word, $replacement_word, $topic_rowset[$i]['topic_title']) : $topic_rowset[$i]['topic_title'];
 510  
 511                  $replies = $topic_rowset[$i]['topic_replies'];
 512  
 513                  $topic_type = $topic_rowset[$i]['topic_type'];
 514  
 515                  if( $topic_type == POST_ANNOUNCE )
 516                  {
 517                          $topic_type = $lang['Topic_Announcement'] . ' ';
 518                  }
 519                  else if( $topic_type == POST_STICKY )
 520                  {
 521                          $topic_type = $lang['Topic_Sticky'] . ' ';
 522                  }
 523                  else
 524                  {
 525                          $topic_type = '';
 526                  }
 527  
 528                  if( $topic_rowset[$i]['topic_vote'] )
 529                  {
 530                          $topic_type .= $lang['Topic_Poll'] . ' ';
 531                  }
 532  
 533                  if( $topic_rowset[$i]['topic_status'] == TOPIC_MOVED )
 534                  {
 535                          $topic_type = $lang['Topic_Moved'] . ' ';
 536                          $topic_id = $topic_rowset[$i]['topic_moved_id'];
 537  
 538                          $folder_image =  $images['folder'];
 539                          $folder_alt = $lang['Topics_Moved'];
 540                          $newest_post_img = '';
 541                  }
 542                  else
 543                  {
 544                          if( $topic_rowset[$i]['topic_type'] == POST_ANNOUNCE )
 545                          {
 546                                  $folder = $images['folder_announce'];
 547                                  $folder_new = $images['folder_announce_new'];
 548                          }
 549                          else if( $topic_rowset[$i]['topic_type'] == POST_STICKY )
 550                          {
 551                                  $folder = $images['folder_sticky'];
 552                                  $folder_new = $images['folder_sticky_new'];
 553                          }
 554                          else if( $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED )
 555                          {
 556                                  $folder = $images['folder_locked'];
 557                                  $folder_new = $images['folder_locked_new'];
 558                          }
 559                          else
 560                          {
 561                                  if($replies >= $board_config['hot_threshold'])
 562                                  {
 563                                          $folder = $images['folder_hot'];
 564                                          $folder_new = $images['folder_hot_new'];
 565                                  }
 566                                  else
 567                                  {
 568                                          $folder = $images['folder'];
 569                                          $folder_new = $images['folder_new'];
 570                                  }
 571                          }
 572  
 573                          $newest_post_img = '';
 574                          if( $userdata['session_logged_in'] )
 575                          {
 576                                  if( $topic_rowset[$i]['post_time'] > $userdata['user_lastvisit'] )
 577                                  {
 578                                          if( !empty($tracking_topics) || !empty($tracking_forums) || isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all']) )
 579                                          {
 580                                                  $unread_topics = true;
 581  
 582                                                  if( !empty($tracking_topics[$topic_id]) )
 583                                                  {
 584                                                          if( $tracking_topics[$topic_id] >= $topic_rowset[$i]['post_time'] )
 585                                                          {
 586                                                                  $unread_topics = false;
 587                                                          }
 588                                                  }
 589  
 590                                                  if( !empty($tracking_forums[$forum_id]) )
 591                                                  {
 592                                                          if( $tracking_forums[$forum_id] >= $topic_rowset[$i]['post_time'] )
 593                                                          {
 594                                                                  $unread_topics = false;
 595                                                          }
 596                                                  }
 597  
 598                                                  if( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all']) )
 599                                                  {
 600                                                          if( $HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all'] >= $topic_rowset[$i]['post_time'] )
 601                                                          {
 602                                                                  $unread_topics = false;
 603                                                          }
 604                                                  }
 605  
 606                                                  if( $unread_topics )
 607                                                  {
 608                                                          $folder_image = $folder_new;
 609                                                          $folder_alt = $lang['New_posts'];
 610  
 611                                                          $newest_post_img = '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;view=newest") . '"><img src="' . $images['icon_newest_reply'] . '" alt="' . $lang['View_newest_post'] . '" title="' . $lang['View_newest_post'] . '" border="0" /></a> ';
 612                                                  }
 613                                                  else
 614                                                  {
 615                                                          $folder_image = $folder;
 616                                                          $folder_alt = ( $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts'];
 617  
 618                                                          $newest_post_img = '';
 619                                                  }
 620                                          }
 621                                          else
 622                                          {
 623                                                  $folder_image = $folder_new;
 624                                                  $folder_alt = ( $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['New_posts'];
 625  
 626                                                  $newest_post_img = '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;view=newest") . '"><img src="' . $images['icon_newest_reply'] . '" alt="' . $lang['View_newest_post'] . '" title="' . $lang['View_newest_post'] . '" border="0" /></a> ';
 627                                          }
 628                                  }
 629                                  else
 630                                  {
 631                                          $folder_image = $folder;
 632                                          $folder_alt = ( $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts'];
 633  
 634                                          $newest_post_img = '';
 635                                  }
 636                          }
 637                          else
 638                          {
 639                                  $folder_image = $folder;
 640                                  $folder_alt = ( $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts'];
 641  
 642                                  $newest_post_img = '';
 643                          }
 644                  }
 645  
 646                  if( ( $replies + 1 ) > $board_config['posts_per_page'] )
 647                  {
 648                          $total_pages = ceil( ( $replies + 1 ) / $board_config['posts_per_page'] );
 649                          $goto_page = ' [ <img src="' . $images['icon_gotopost'] . '" alt="' . $lang['Goto_page'] . '" title="' . $lang['Goto_page'] . '" />' . $lang['Goto_page'] . ': ';
 650  
 651                          $times = 1;
 652                          for($j = 0; $j < $replies + 1; $j += $board_config['posts_per_page'])
 653                          {
 654                                  $goto_page .= '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=" . $topic_id . "&amp;start=$j") . '">' . $times . '</a>';
 655                                  if( $times == 1 && $total_pages > 4 )
 656                                  {
 657                                          $goto_page .= ' ... ';
 658                                          $times = $total_pages - 3;
 659                                          $j += ( $total_pages - 4 ) * $board_config['posts_per_page'];
 660                                  }
 661                                  else if ( $times < $total_pages )
 662                                  {
 663                                          $goto_page .= ', ';
 664                                  }
 665                                  $times++;
 666                          }
 667                          $goto_page .= ' ] ';
 668                  }
 669                  else
 670                  {
 671                          $goto_page = '';
 672                  }
 673  
 674                  $view_topic_url = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id");
 675  
 676                  $topic_author = ( $topic_rowset[$i]['user_id'] != ANONYMOUS ) ? '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . '=' . $topic_rowset[$i]['user_id']) . '">' : '';
 677                  $topic_author .= ( $topic_rowset[$i]['user_id'] != ANONYMOUS ) ? $topic_rowset[$i]['username'] : ( ( $topic_rowset[$i]['post_username'] != '' ) ? $topic_rowset[$i]['post_username'] : $lang['Guest'] );
 678  
 679                  $topic_author .= ( $topic_rowset[$i]['user_id'] != ANONYMOUS ) ? '</a>' : '';
 680  
 681                  $first_post_time = create_date($board_config['default_dateformat'], $topic_rowset[$i]['topic_time'], $board_config['board_timezone']);
 682  
 683                  $last_post_time = create_date($board_config['default_dateformat'], $topic_rowset[$i]['post_time'], $board_config['board_timezone']);
 684  
 685                  $last_post_author = ( $topic_rowset[$i]['id2'] == ANONYMOUS ) ? ( ($topic_rowset[$i]['post_username2'] != '' ) ? $topic_rowset[$i]['post_username2'] . ' ' : $lang['Guest'] . ' ' ) : '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . '='  . $topic_rowset[$i]['id2']) . '">' . $topic_rowset[$i]['user2'] . '</a>';
 686  
 687                  $last_post_url = '<a href="' . append_sid("viewtopic.$phpEx?"  . POST_POST_URL . '=' . $topic_rowset[$i]['topic_last_post_id']) . '#' . $topic_rowset[$i]['topic_last_post_id'] . '"><img src="' . $images['icon_latest_reply'] . '" alt="' . $lang['View_latest_post'] . '" title="' . $lang['View_latest_post'] . '" border="0" /></a>';
 688  
 689                  $views = $topic_rowset[$i]['topic_views'];
 690  
 691                  $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
 692                  $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
 693  
 694                  $template->assign_block_vars('topicrow', array(
 695                          'ROW_COLOR' => $row_color,
 696                          'ROW_CLASS' => $row_class,
 697                          'FORUM_ID' => $forum_id,
 698                          'TOPIC_ID' => $topic_id,
 699                          'TOPIC_FOLDER_IMG' => $folder_image,
 700                          'TOPIC_AUTHOR' => $topic_author,
 701                          'GOTO_PAGE' => $goto_page,
 702                          'REPLIES' => $replies,
 703                          'NEWEST_POST_IMG' => $newest_post_img,
 704                          'TOPIC_TITLE' => $topic_title,
 705                          'TOPIC_TYPE' => $topic_type,
 706                          'VIEWS' => $views,
 707                          'FIRST_POST_TIME' => $first_post_time,
 708                          'LAST_POST_TIME' => $last_post_time,
 709                          'LAST_POST_AUTHOR' => $last_post_author,
 710                          'LAST_POST_IMG' => $last_post_url,
 711  
 712                          'L_TOPIC_FOLDER_ALT' => $folder_alt,
 713  
 714                          'U_VIEW_TOPIC' => $view_topic_url)
 715                  );
 716          }
 717  
 718          $topics_count -= $total_announcements;
 719  
 720          $template->assign_vars(array(
 721                  'PAGINATION' => generate_pagination("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id&amp;topicdays=$topic_days", $topics_count, $board_config['topics_per_page'], $start),
 722                  'PAGE_NUMBER' => sprintf($lang['Page_of'], ( floor( $start / $board_config['topics_per_page'] ) + 1 ), ceil( $topics_count / $board_config['topics_per_page'] )),
 723  
 724                  'L_GOTO_PAGE' => $lang['Goto_page'])
 725          );
 726  }
 727  else
 728  {
 729          //

 730          // No topics

 731          //

 732          $no_topics_msg = ( $forum_row['forum_status'] == FORUM_LOCKED ) ? $lang['Forum_locked'] : $lang['No_topics_post_one'];
 733          $template->assign_vars(array(
 734                  'L_NO_TOPICS' => $no_topics_msg)
 735          );
 736  
 737          $template->assign_block_vars('switch_no_topics', array() );
 738  
 739  }
 740  
 741  //

 742  // Parse the page and print

 743  //

 744  $template->pparse('body');
 745  
 746  //

 747  // Page footer

 748  //

 749  include ("includes/page_tail.php");
 750  
 751  ?>


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