[ Index ]
 

Code source de e107 0.7.8

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

title

Body

[fermer]

/e107_plugins/forum/ -> forum_viewforum.php (source)

   1  <?php
   2  /*
   3  + ----------------------------------------------------------------------------+
   4  |     e107 website system
   5  |
   6  |     ©Steve Dunstan 2001-2002
   7  |     http://e107.org
   8  |     jalist@e107.org
   9  |
  10  |     Released under the terms and conditions of the
  11  |     GNU General Public License (http://gnu.org).
  12  |
  13  |     $Source: /cvsroot/e107/e107_0.7/e107_plugins/forum/forum_viewforum.php,v $
  14  |     $Revision: 1.62 $
  15  |     $Date: 2006/12/24 13:44:26 $
  16  |     $Author: mrpete $
  17  +----------------------------------------------------------------------------+
  18  */
  19  
  20  require_once ("../../class2.php");
  21  $lan_file = e_PLUGIN.'forum/languages/'.e_LANGUAGE.'/lan_forum_viewforum.php';
  22  include_once(file_exists($lan_file) ? $lan_file : e_PLUGIN.'forum/languages/English/lan_forum_viewforum.php');
  23  
  24  if (isset($_POST['fjsubmit'])) {
  25      header("location:".e_PLUGIN."forum/forum_viewforum.php?".$_POST['forumjump']);
  26      exit;
  27  }
  28  
  29  if (!e_QUERY)
  30  {
  31      js_location(e_PLUGIN."forum/forum.php");
  32  }
  33  else
  34  {
  35      $tmp = explode(".", e_QUERY);
  36      $forum_id = intval($tmp[0]);
  37      $thread_from = (isset($tmp[1]) ? intval($tmp[1]) : 0);
  38  }
  39  $view = 25;
  40  
  41  if(is_numeric(e_MENU))
  42  {
  43      $thread_from = (intval(e_MENU)-1)*$view;
  44  }
  45  require_once(e_PLUGIN.'forum/forum_class.php');
  46  $forum = new e107forum;
  47  
  48  $STARTERTITLE = LAN_54;
  49  $THREADTITLE = LAN_53;
  50  $REPLYTITLE = LAN_55;
  51  $LASTPOSTITLE = LAN_57;
  52  $VIEWTITLE = LAN_56;
  53  
  54  global $forum_info, $FORUM_CRUMB;
  55  $forum_info = $forum->forum_get($forum_id);
  56  
  57  if (!check_class($forum_info['forum_class']) || !check_class($forum_info['parent_class']) || !$forum_info['forum_parent'])
  58  {
  59      header("Location:".e_PLUGIN."forum/forum.php");
  60      exit;
  61  }
  62  
  63  if (!$FORUM_VIEW_START) {
  64      if (file_exists(THEME."forum_viewforum_template.php"))
  65      {
  66          require_once(THEME."forum_viewforum_template.php");
  67      }
  68      else if (file_exists(THEME."forum_template.php"))
  69      {
  70          require_once(THEME."forum_template.php");
  71      }
  72      else
  73      {
  74          require_once(e_PLUGIN."forum/templates/forum_viewforum_template.php");
  75      }
  76  }
  77  
  78  
  79  $forum_info['forum_name'] = $tp->toHTML($forum_info['forum_name'], TRUE, 'no_hook, emotes_off');
  80  $forum_info['forum_description'] = $tp->toHTML($forum_info['forum_description'], TRUE, 'no_hook');
  81  
  82  $_forum_name = (substr($forum_info['forum_name'], 0, 1) == "*" ? substr($forum_info['forum_name'], 1) : $forum_info['forum_name']);
  83  define("e_PAGETITLE", LAN_01." / ".$_forum_name);
  84  define("MODERATOR", $forum_info['forum_moderators'] != "" && check_class($forum_info['forum_moderators']));
  85  $modArray = $forum->forum_getmods($forum_info['forum_moderators']);
  86  $message = "";
  87  if (MODERATOR)
  88  {
  89      if ($_POST)
  90      {
  91          require_once(e_PLUGIN."forum/forum_mod.php");
  92          $message = forum_thread_moderate($_POST);
  93      }
  94  }
  95  
  96  $member_users = $sql->db_Select("online", "*", "online_location REGEXP('forum_viewforum.php.$forum_id') AND online_user_id!='0' ");
  97  $guest_users = $sql->db_Select("online", "*", "online_location REGEXP('forum_viewforum.php.$forum_id') AND online_user_id='0' ");
  98  $users = $member_users+$guest_users;
  99  
 100  require_once(HEADERF);
 101  $text='';
 102  if ($message)
 103  {
 104      $ns->tablerender("", $message, array('forum_viewforum', 'msg'));
 105  }
 106  
 107  $topics = $forum->forum_get_topic_count($forum_id);
 108  
 109  if ($topics > $view)
 110  {
 111      $pages = ceil($topics/$view);
 112  }
 113  else
 114  {
 115      $pages = FALSE;
 116  }
 117  
 118  if ($pages)
 119  {
 120      if(strpos($FORUM_VIEW_START, 'THREADPAGES') !== FALSE || strpos($FORUM_VIEW_END, 'THREADPAGES') !== FALSE)
 121      {
 122          $parms = "{$topics},{$view},{$thread_from},".e_SELF.'?'.$forum_id.'.[FROM],off';
 123          $THREADPAGES = LAN_316." ".$tp->parseTemplate("{NEXTPREV={$parms}}");
 124      }
 125  }
 126  
 127  if (check_class($forum_info['forum_postclass']) && check_class($forum_info['parent_postclass']))
 128  {
 129      $NEWTHREADBUTTON = "<a href='".e_PLUGIN."forum/forum_post.php?nt.".$forum_id."'>".IMAGE_newthread."</a>";
 130  }
 131  
 132  if(substr($forum_info['forum_name'], 0, 1) == "*")
 133  {
 134      $forum_info['forum_name'] = substr($forum_info['forum_name'], 1);
 135      $container_only = true;
 136  }
 137  else
 138  {
 139      $container_only = false;
 140  }
 141  
 142  if(substr($forum_info['sub_parent'], 0, 1) == "*")
 143  {
 144      $forum_info['sub_parent'] = substr($forum_info['sub_parent'], 1);
 145  }
 146  
 147  $forum->set_crumb(); // set $BREADCRUMB (and $BACKLINK)
 148  
 149  $FORUMTITLE = $forum_info['forum_name'];
 150  //$MODERATORS = LAN_404.": ".$forum_info['forum_moderators'];
 151  $MODERATORS = LAN_404.": ".implode(", ", $modArray);
 152  $BROWSERS = $users." ".($users == 1 ? LAN_405 : LAN_406)." (".$member_users." ".($member_users == 1 ? LAN_407 : LAN_409).", ".$guest_users." ".($guest_users == 1 ? LAN_408 : LAN_410).")";
 153  
 154  $ICONKEY = "
 155      <table style='width:100%'>
 156      <tr>
 157      <td style='vertical-align:middle; text-align:center; width:2%'>".IMAGE_new_small."</td>
 158      <td style='width:10%' class='smallblacktext'>".LAN_79."</td>
 159      <td style='vertical-align:middle; text-align:center; width:2%'>".IMAGE_nonew_small."</td>
 160      <td style='width:10%' class='smallblacktext'>".LAN_80."</td>
 161      <td style='vertical-align:middle; text-align:center; width:2%'>".IMAGE_sticky_small."</td>
 162      <td style='width:10%' class='smallblacktext'>".LAN_202."</td>
 163      <td style='vertical-align:middle; text-align:center; width:2%'>".IMAGE_announce_small."</td>
 164      <td style='width:10%' class='smallblacktext'>".LAN_396."</td>
 165      </tr>
 166      <tr>
 167      <td style='vertical-align:middle; text-align:center; width:2%'>".IMAGE_new_popular_small."</td>
 168      <td style='width:2%' class='smallblacktext'>".LAN_79." ".LAN_395."</td>
 169      <td style='vertical-align:middle; text-align:center; width:2%'>".IMAGE_nonew_popular_small."</td>
 170      <td style='width:10%' class='smallblacktext'>".LAN_80." ".LAN_395."</td>
 171      <td style='vertical-align:middle; text-align:center; width:2%'>".IMAGE_stickyclosed_small."</td>
 172      <td style='width:10%' class='smallblacktext'>".LAN_203."</td>
 173      <td style='vertical-align:middle; text-align:center; width:2%'>".IMAGE_closed_small."</td>
 174      <td style='width:10%' class='smallblacktext'>".LAN_81."</td>
 175      </tr>
 176      </table>";
 177  
 178  $SEARCH = "
 179      <form method='get' action='".e_BASE."search.php'>
 180      <p>
 181      <input class='tbox' type='text' name='q' size='20' value='' maxlength='50' />
 182      <input type='hidden' name='r' value='0' />
 183      <input type='hidden' name='ref' value='forum' />
 184      <input class='button' type='submit' name='s' value='".LAN_180."' />
 185      </p>
 186      </form>";
 187  
 188  if(check_class($forum_info['forum_postclass']))
 189  {
 190      $PERMS = LAN_204." - ".LAN_206." - ".LAN_208;
 191  }
 192  else
 193  {
 194      $PERMS = LAN_205." - ".LAN_207." - ".LAN_209;
 195  }
 196  
 197  $sticky_threads = 0;
 198  $stuck = FALSE;
 199  $reg_threads = 0;
 200  $unstuck = FALSE;
 201  
 202  $thread_list = $forum->forum_get_topics($forum_id, $thread_from, $view);
 203  $sub_list = $forum->forum_getsubs($forum_id);
 204  //print_a($sub_list);
 205  $gen = new convert;
 206  
 207  $SUBFORUMS = "";
 208  if(is_array($sub_list))
 209  {
 210      $newflag_list = $forum->forum_newflag_list();
 211      $sub_info = "";
 212      foreach($sub_list as $sub)
 213      {
 214          $sub_info .= parse_sub($sub);
 215      }
 216      $SUBFORUMS = $FORUM_VIEW_SUB_START.$sub_info.$FORUM_VIEW_SUB_END;
 217  }
 218  
 219  
 220  if (count($thread_list) )
 221  {
 222      foreach($thread_list as $thread_info) {
 223          $idArray[] = $thread_info['thread_id'];
 224      }
 225      $inList = '('.implode(',', $idArray).')';
 226      foreach($thread_list as $thread_info) {
 227          if ($thread_info['thread_s']) {
 228              $sticky_threads ++;
 229          }
 230          if ($sticky_threads > 0 && !$stuck && $pref['forum_hilightsticky'])
 231          {
 232              if($FORUM_IMPORTANT_ROW)
 233              {
 234                  $forum_view_forum .= $FORUM_IMPORTANT_ROW;
 235              }
 236              else
 237              {
 238                  $forum_view_forum .= "<tr><td class='forumheader'>&nbsp;</td><td colspan='5'  class='forumheader'><span class='mediumtext'><b>".LAN_411."</b></span></td></tr>";
 239              }
 240              $stuck = TRUE;
 241          }
 242          if (!$thread_info['thread_s'])
 243          {
 244              $reg_threads ++;
 245          }
 246          if ($reg_threads == "1" && !$unstuck && $stuck)
 247          {
 248              if($FORUM_NORMAL_ROW)
 249              {
 250                  $forum_view_forum .= $FORUM_NORMAL_ROW;
 251              }
 252              else
 253              {
 254                  $forum_view_forum .= "<tr><td class='forumheader'>&nbsp;</td><td colspan='5'  class='forumheader'><span class='mediumtext'><b>".LAN_412."</b></span></td></tr>";
 255              }
 256              $unstuck = TRUE;
 257          }
 258          $forum_view_forum .= parse_thread($thread_info);
 259      }
 260  }
 261  else
 262  {
 263      $forum_view_forum .= "<tr><td class='forumheader' colspan='6'>".LAN_58."</td></tr>";
 264  }
 265  
 266  $sql->db_Select("forum", "*", "forum_parent !=0 AND forum_class!='255' ");
 267  $FORUMJUMP = forumjump();
 268  $TOPLINK = "<a href='".e_SELF."?".e_QUERY."#top' onclick=\"window.scrollTo(0,0);\">".LAN_02."</a>";
 269  
 270  if($container_only)
 271  {
 272      $FORUM_VIEW_START = ($FORUM_VIEW_START_CONTAINER ? $FORUM_VIEW_START_CONTAINER : $FORUM_VIEW_START);
 273      $FORUM_VIEW_END = ($FORUM_VIEW_END_CONTAINER ? $FORUM_VIEW_END_CONTAINER : $FORUM_VIEW_END);
 274      $forum_view_forum = "";
 275  }
 276  
 277  $forum_view_start = preg_replace("/\{(.*?)\}/e", '$\1', $FORUM_VIEW_START);
 278  $forum_view_end = preg_replace("/\{(.*?)\}/e", '$\1', $FORUM_VIEW_END);
 279  
 280  
 281  if ($pref['forum_enclose'])
 282  {
 283      $ns->tablerender($pref['forum_title'], $forum_view_start.$forum_view_subs.$forum_view_forum.$forum_view_end, array('forum_viewforum', 'main1'));
 284  }
 285  else
 286  {
 287      echo $forum_view_start.$forum_view_forum.$forum_view_end;
 288  }
 289  
 290  echo "<script type=\"text/javascript\">
 291  	function confirm_(thread_id)
 292      {
 293          return confirm(\"".$tp->toJS(LAN_434)."\");
 294      }
 295      </script>";
 296  
 297  require_once(FOOTERF);
 298  
 299  
 300  function parse_thread($thread_info)
 301  {
 302      global $forum, $tp, $FORUM_VIEW_FORUM, $gen, $pref, $forum_id, $menu_pref;
 303      $text = "";
 304      $VIEWS = $thread_info['thread_views'];
 305      $REPLIES = $thread_info['thread_total_replies'];
 306  
 307  
 308      if ($REPLIES)
 309      {
 310          $lastpost_datestamp = $gen->convert_date($thread_info['thread_lastpost'], 'forum');
 311          $tmp = explode(".", $thread_info['thread_lastuser'], 2);
 312          if($thread_info['lastpost_username'])
 313          {
 314              $LASTPOST = "<a href='".e_BASE."user.php?id.".$tmp[0]."'>".$thread_info['lastpost_username']."</a>";
 315          }
 316          else
 317          {
 318              if($tmp[1])
 319              {
 320                  $LASTPOST = $tp->toHTML($tmp[1]);
 321              }
 322              else
 323              {
 324                  $LASTPOST = FORLAN_19;
 325              }
 326          }
 327          $LASTPOST .= "<br />".$lastpost_datestamp;
 328      }
 329      else
 330      {
 331          $REPLIES = LAN_317;
 332          $LASTPOST = " - ";
 333      }
 334  
 335      $newflag = FALSE;
 336      if (USER)
 337      {
 338          if ($thread_info['thread_lastpost'] > USERLV && !preg_match("#\b".$thread_info['thread_id']."\b#", USERVIEWED))
 339          {
 340              $newflag = TRUE;
 341          }
 342      }
 343  
 344      $THREADDATE = $gen->convert_date($thread_info['thread_datestamp'], 'forum');
 345      $ICON = ($newflag ? IMAGE_new : IMAGE_nonew);
 346      if ($REPLIES >= $pref['forum_popular'] && $REPLIES != "None") {
 347          $ICON = ($newflag ? IMAGE_new_popular : IMAGE_nonew_popular);
 348      }
 349  
 350      $THREADTYPE = '';
 351      if ($thread_info['thread_s'] == 1)
 352      {
 353          $ICON = ($thread_info['thread_active'] ? IMAGE_sticky : IMAGE_stickyclosed);
 354          $THREADTYPE = '['.LAN_202.']<br />';
 355      }
 356      elseif($thread_info['thread_s'] == 2)
 357      {
 358          $ICON = IMAGE_announce;
 359          $THREADTYPE = '['.LAN_396.']<br />';
 360      }
 361      elseif(!$thread_info['thread_active'])
 362      {
 363          $ICON = IMAGE_closed;
 364      }
 365  
 366      $thread_name = strip_tags($tp->toHTML($thread_info['thread_name'], false, 'no_hook, emotes_off'));
 367      if (strtoupper($THREADTYPE) == strtoupper(substr($thread_name, 0, strlen($THREADTYPE)))) {
 368          $thread_name = substr($thread_name, strlen($THREADTYPE));
 369      }
 370      if ($pref['forum_tooltip']) {
 371          $thread_thread = strip_tags($tp->toHTML($thread_info['thread_thread'], true, 'no_hook'));
 372          $tip_length = ($pref['forum_tiplength'] ? $pref['forum_tiplength'] : 400);
 373          if (strlen($thread_thread) > $tip_length) {
 374              $thread_thread = substr($thread_thread, 0, $tip_length)." ".$menu_pref['newforumposts_postfix'];
 375          }
 376          $thread_thread = str_replace("'", "&#39;", $thread_thread);
 377          $title = "title='".$thread_thread."'";
 378      } else {
 379          $title = "";
 380      }
 381      $THREADNAME = "<a {$title} href='".e_PLUGIN."forum/forum_viewtopic.php?{$thread_info['thread_id']}'>{$thread_name}</a>";
 382  
 383      $pages = ceil(($REPLIES+1)/$pref['forum_postspage']);
 384      if ($pages > 1)
 385      {
 386          if($pages > 6)
 387          {
 388              for($a = 0; $a <= 2; $a++)
 389              {
 390                  $PAGES .= $PAGES ? " " : "";
 391                  $PAGES .= "<a href='".e_PLUGIN."forum/forum_viewtopic.php?".$thread_info['thread_id'].".".($a * $pref['forum_postspage'])."'>".($a+1)."</a>";
 392              }
 393              $PAGES .= " ... ";
 394              for($a = $pages-3; $a <= $pages-1; $a++)
 395              {
 396                  $PAGES .= $PAGES ? " " : "";
 397                  $PAGES .= "<a href='".e_PLUGIN."forum/forum_viewtopic.php?".$thread_info['thread_id'].".".($a * $pref['forum_postspage'])."'>".($a+1)."</a>";
 398              }
 399          }
 400          else
 401          {
 402              for($a = 0; $a <= ($pages-1); $a++)
 403              {
 404                  $PAGES .= $PAGES ? " " : "";
 405                  $PAGES .= "<a href='".e_PLUGIN."forum/forum_viewtopic.php?".$thread_info['thread_id'].".".($a * $pref['forum_postspage'])."'>".($a+1)."</a>";
 406              }
 407          }
 408          $PAGES = LAN_316." [&nbsp;".$PAGES."&nbsp;]";
 409      }
 410      else
 411      {
 412          $PAGES = "";
 413      }
 414  
 415      if (MODERATOR)
 416      {
 417          $thread_id = $thread_info['thread_id'];
 418          $ADMIN_ICONS = "
 419              <form method='post' action='".e_SELF."?{$forum_id}' id='frmMod_{$forum_id}_{$thread_id}' style='margin:0;'><div>
 420              ";
 421  
 422          $ADMIN_ICONS .= "<input type='image' ".IMAGE_admin_delete." name='delete_$thread_id' value='thread_action' onclick=\"return confirm_($thread_id)\" /> \n";
 423  
 424          $ADMIN_ICONS .= ($thread_info['thread_s'] == 1) ? "<input type='image' ".IMAGE_admin_unstick." name='unstick_{$thread_id}' value='thread_action' /> " :
 425           "<input type='image' ".IMAGE_admin_stick." name='stick_{$thread_id}' value='thread_action' /> ";
 426          $ADMIN_ICONS .= ($thread_info['thread_active']) ? "<input type='image' ".IMAGE_admin_lock." name='lock_{$thread_id}' value='thread_action' /> " :
 427           "<input type='image' ".IMAGE_admin_unlock." name='unlock_{$thread_id}' value='thread_action' /> ";
 428          $ADMIN_ICONS .= "<a href='".e_PLUGIN."forum/forum_conf.php?move.".$thread_id."'>".IMAGE_admin_move."</a>";
 429          $ADMIN_ICONS .= "
 430              </div></form>
 431              ";
 432      }
 433  
 434      $text .= "</td>
 435          <td style='vertical-align:top; text-align:center; width:20%' class='forumheader3'>".$THREADDATE."<br />
 436          ";
 437      $tmp = explode(".", $thread_info['thread_user'], 2);
 438      if($thread_info['user_name'])
 439      {
 440          $POSTER = "<a href='".e_BASE."user.php?id.".$tmp[0]."'>".$thread_info['user_name']."</a>";
 441      }
 442      else
 443      {
 444          if($tmp[1])
 445          {
 446              $x = explode(chr(1), $tmp[1]);
 447              $POSTER = $tp->toHTML($x[0]);
 448          }
 449          else
 450          {
 451              $POSTER = FORLAN_19;
 452          }
 453      }
 454  
 455      if ($thread_info['thread_s'] == 1 && $FORUM_VIEW_FORUM_STICKY)
 456      {
 457          return(preg_replace("/\{(.*?)\}/e", '$\1', $FORUM_VIEW_FORUM_STICKY));
 458      }
 459  
 460      if ($thread_info['thread_s'] == 2 && $FORUM_VIEW_FORUM_ANNOUNCE)
 461      {
 462          return(preg_replace("/\{(.*?)\}/e", '$\1', $FORUM_VIEW_FORUM_ANNOUNCE));
 463      }
 464  
 465      return(preg_replace("/\{(.*?)\}/e", '$\1', $FORUM_VIEW_FORUM));
 466  }
 467  
 468  function parse_sub($subInfo)
 469  {
 470      global $FORUM_VIEW_SUB, $gen, $tp, $newflag_list;
 471      $SUB_FORUMTITLE = "<a href='".e_PLUGIN."forum/forum_viewforum.php?{$subInfo['forum_id']}'>{$subInfo['forum_name']}</a>";
 472      $SUB_DESCRIPTION = $tp->toHTML($subInfo['forum_description'], false, 'no_hook');
 473      $SUB_THREADS = $subInfo['forum_threads'];
 474      $SUB_REPLIES = $subInfo['forum_replies'];
 475      if(USER && is_array($newflag_list) && in_array($subInfo['forum_id'], $newflag_list))
 476      {
 477          $NEWFLAG = "<a href='".e_SELF."?mfar.{$subInfo['forum_id']}'>".IMAGE_new."</a>";
 478      }
 479      else
 480      {
 481          $NEWFLAG = IMAGE_nonew;
 482      }
 483  
 484      if($subInfo['forum_lastpost_info'])
 485      {
 486          $tmp = explode(".", $subInfo['forum_lastpost_info']);
 487          $lp_thread = "<a href='".e_PLUGIN."forum/forum_viewtopic.php?{$tmp[1]}.last'>".IMAGE_post2."</a>";
 488          $lp_date = $gen->convert_date($tmp[0], 'forum');
 489          $tmp = explode(".", $subInfo['forum_lastpost_user']);
 490          if($subInfo['user_name'])
 491          {
 492              $lp_name = "<a href='".e_BASE."user.php?{$tmp[0]}'>{$subInfo['user_name']}</a>";
 493          }
 494          else
 495          {
 496              $lp_name = $tmp[1];
 497          }
 498          $SUB_LASTPOST = $lp_date."<br />".$lp_name." ".$lp_thread;
 499      }
 500      else
 501      {
 502          $SUB_LASTPOST = "-";
 503      }
 504      return  (preg_replace("/\{(.*?)\}/e", '$\1', $FORUM_VIEW_SUB));
 505  }
 506  
 507  function forumjump()
 508  {
 509      global $forum;
 510      $jumpList = $forum->forum_get_allowed();
 511      $text = "<form method='post' action='".e_SELF."'><p>".LAN_403.": <select name='forumjump' class='tbox'>";
 512      foreach($jumpList as $key => $val)
 513      {
 514          $text .= "\n<option value='".$key."'>".$val."</option>";
 515      }
 516      $text .= "</select> <input class='button' type='submit' name='fjsubmit' value='".LAN_03."' />&nbsp;&nbsp;&nbsp;&nbsp;<a href='".e_SELF."?".$_SERVER['QUERY_STRING']."#top'>".LAN_02."</a></p></form>";
 517      return $text;
 518  }
 519  
 520  ?>


Généré le : Sun Apr 1 01:23:32 2007 par Balluche grâce à PHPXref 0.7