[xoops-cvslog 2949] CVS update: xoops2jp/html/modules/newbb

Back to archive index

onokazu onoka****@users*****
2006年 5月 1日 (月) 11:37:29 JST


Index: xoops2jp/html/modules/newbb/index.php
diff -u xoops2jp/html/modules/newbb/index.php:1.7 xoops2jp/html/modules/newbb/index.php:1.8
--- xoops2jp/html/modules/newbb/index.php:1.7	Tue Oct 25 12:07:38 2005
+++ xoops2jp/html/modules/newbb/index.php	Mon May  1 11:37:28 2006
@@ -1,143 +1,143 @@
-<?php
-// $Id: index.php,v 1.7 2005/10/25 03:07:38 onokazu Exp $
-//  ------------------------------------------------------------------------ //
-//                XOOPS - PHP Content Management System                      //
-//                    Copyright (c) 2000 XOOPS.org                           //
-//                       <http://www.xoops.org/>                             //
-//  ------------------------------------------------------------------------ //
-//  This program is free software; you can redistribute it and/or modify     //
-//  it under the terms of the GNU General Public License as published by     //
-//  the Free Software Foundation; either version 2 of the License, or        //
-//  (at your option) any later version.                                      //
-//                                                                           //
-//  You may not change or alter any portion of this comment or credits       //
-//  of supporting developers from this source code or any supporting         //
-//  source code which is considered copyrighted (c) material of the          //
-//  original comment or credit authors.                                      //
-//                                                                           //
-//  This program is distributed in the hope that it will be useful,          //
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
-//  GNU General Public License for more details.                             //
-//                                                                           //
-//  You should have received a copy of the GNU General Public License        //
-//  along with this program; if not, write to the Free Software              //
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
-//  ------------------------------------------------------------------------ //
-// Author: Kazumi Ono (AKA onokazu)                                          //
-// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ //
-// Project: The XOOPS Project                                                //
-// ------------------------------------------------------------------------- //
-
-include "header.php";
-// this page uses smarty template
-// this must be set before including main header.php
-$xoopsOption['template_main']= 'newbb_index.html';
-include XOOPS_ROOT_PATH."/header.php";
-
-$myts =& MyTextSanitizer::getInstance();
-
-$sql = 'SELECT c.* FROM '.$xoopsDB->prefix('bb_categories').' c, '.$xoopsDB->prefix("bb_forums").' f WHERE f.cat_id=c.cat_id GROUP BY c.cat_id, c.cat_title, c.cat_order ORDER BY c.cat_order';
-if ( !$result = $xoopsDB->query($sql) ) {
-    redirect_header(XOOPS_URL.'/',1,_MD_ERROROCCURED);
-    exit();
-}
-
-$xoopsTpl->assign(array("lang_welcomemsg" => sprintf(_MD_WELCOME,htmlspecialchars($xoopsConfig['sitename'], ENT_QUOTES)), "lang_tostart" => _MD_TOSTART, "lang_totaltopics" => _MD_TOTALTOPICSC, "lang_totalposts" => _MD_TOTALPOSTSC, "total_topics" => get_total_topics(), "total_posts" => get_total_posts(0, 'all'), "lang_lastvisit" => sprintf(_MD_LASTVISIT,formatTimestamp($last_visit)), "lang_currenttime" => sprintf(_MD_TIMENOW,formatTimestamp(time(),"m")), "lang_forum" => _MD_FORUM, "lang_topics" => _MD_TOPICS, "lang_posts" => _MD_POSTS, "lang_lastpost" => _MD_LASTPOST, "lang_moderators" => _MD_MODERATOR));
-
-$viewcat = (!empty($_GET['cat'])) ? intval($_GET['cat']) : 0;
-$categories = array();
-while ( $cat_row = $xoopsDB->fetchArray($result) ) {
-    $categories[] = $cat_row;
-}
-
-$sql = 'SELECT f.*, u.uname, u.uid, p.topic_id, p.post_time, p.subject, p.icon FROM '.$xoopsDB->prefix('bb_forums').' f LEFT JOIN '.$xoopsDB->prefix('bb_posts').' p ON p.post_id = f.forum_last_post_id LEFT JOIN '.$xoopsDB->prefix('users').' u ON u.uid = p.uid';
-if ( $viewcat != 0 ) {
-    $sql .= ' WHERE f.cat_id = '.$viewcat;
-    $xoopsTpl->assign('forum_index_title', sprintf(_MD_FORUMINDEX,htmlspecialchars($xoopsConfig['sitename'], ENT_QUOTES)));
-} else {
-    $xoopsTpl->assign('forum_index_title', '');
-}
-$sql .= ' ORDER BY f.cat_id, f.forum_id';
-if ( !$result = $xoopsDB->query($sql) ) {
-    exit("Error");
-}
-$forums = array(); // RMV-FIX
-while ( $forum_data = $xoopsDB->fetchArray($result) ) {
-    $forums[] = $forum_data;
-}
-$cat_count = count($categories);
-if ($cat_count > 0) {
-    for ( $i = 0; $i < $cat_count; $i++ ) {
-        $categories[$i]['cat_title'] = $myts->makeTboxData4Show($categories[$i]['cat_title']);
-        if ( $viewcat != 0 && $categories[$i]['cat_id'] != $viewcat ) {
-            $xoopsTpl->append("categories", $categories[$i]);
-            continue;
-        }
-        $topic_lastread = newbb_get_topics_viewed();
-        foreach ( $forums as $forum_row ) {
-            unset($last_post);
-            if ( $forum_row['cat_id'] == $categories[$i]['cat_id'] ) {
-                if ($forum_row['post_time']) {
-                    //$forum_row['subject'] = $myts->makeTboxData4Show($forum_row['subject']);
-                    $categories[$i]['forums']['forum_lastpost_time'][] = formatTimestamp($forum_row['post_time']);
-                    $last_post_icon = '<a href="'.XOOPS_URL.'/modules/newbb/viewtopic.php?post_id='.$forum_row['forum_last_post_id'].'&amp;topic_id='.$forum_row['topic_id'].'&amp;forum='.$forum_row['forum_id'].'#forumpost'.$forum_row['forum_last_post_id'].'">';
-                    if ( $forum_row['icon'] ) {
-                        $last_post_icon .= '<img src="'.XOOPS_URL.'/images/subject/'.htmlspecialchars($forum_row['icon']).'" border="0" alt="" />';
-                    } else {
-                        $last_post_icon .= '<img src="'.XOOPS_URL.'/images/subject/icon1.gif" width="15" height="15" border="0" alt="" />';
-                    }
-                    $last_post_icon .= '</a>';
-                    $categories[$i]['forums']['forum_lastpost_icon'][] = $last_post_icon;
-                    if ( $forum_row['uid'] != 0 && $forum_row['uname'] ){
-                        $categories[$i]['forums']['forum_lastpost_user'][] = '<a href="'.XOOPS_URL.'/userinfo.php?uid='.$forum_row['uid'].'">' . $myts->makeTboxData4Show($forum_row['uname']).'</a>';
-                    } else {
-                        $categories[$i]['forums']['forum_lastpost_user'][] = $xoopsConfig['anonymous'];
-                    }
-                    $forum_lastread = !empty($topic_lastread[$forum_row['topic_id']]) ? $topic_lastread[$forum_row['topic_id']] : false;
-                    if ( $forum_row['forum_type'] == 1 ) {
-                        $categories[$i]['forums']['forum_folder'][] = $bbImage['locked_forum'];
-                    } elseif ( $forum_row['post_time'] > $forum_lastread && !empty($forum_row['topic_id'])) {
-                        $categories[$i]['forums']['forum_folder'][] = $bbImage['newposts_forum'];
-                    } else {
-                        $categories[$i]['forums']['forum_folder'][] = $bbImage['folder_forum'];
-                    }
-                } else {
-                    // no forums, so put empty values
-                    $categories[$i]['forums']['forum_lastpost_time'][] = "";
-                    $categories[$i]['forums']['forum_lastpost_icon'][] = "";
-                    $categories[$i]['forums']['forum_lastpost_user'][] = "";
-                    if ( $forum_row['forum_type'] == 1 ) {
-                        $categories[$i]['forums']['forum_folder'][] = $bbImage['locked_forum'];
-                    } else {
-                        $categories[$i]['forums']['forum_folder'][] = $bbImage['folder_forum'];
-                    }
-                }
-                $categories[$i]['forums']['forum_id'][] = $forum_row['forum_id'];
-                $categories[$i]['forums']['forum_name'][] = $myts->makeTboxData4Show($forum_row['forum_name']);
-                $categories[$i]['forums']['forum_desc'][] = $myts->makeTareaData4Show($forum_row['forum_desc']);
-                $categories[$i]['forums']['forum_topics'][] = $forum_row['forum_topics'];
-                $categories[$i]['forums']['forum_posts'][] = $forum_row['forum_posts'];
-                $all_moderators = get_moderators($forum_row['forum_id']);
-                $count = 0;
-                $forum_moderators = '';
-                foreach ( $all_moderators as $mods) {
-                    foreach ( $mods as $mod_id => $mod_name) {
-                        if ( $count > 0 ) {
-                            $forum_moderators .= ', ';
-                        }
-                        $forum_moderators .= '<a href="'.XOOPS_URL.'/userinfo.php?uid='.$mod_id.'">'.$myts->makeTboxData4Show($mod_name).'</a>';
-                        $count = 1;
-                    }
-                }
-                $categories[$i]['forums']['forum_moderators'][] = $forum_moderators;
-            }
-        }
-        $xoopsTpl->append("categories", $categories[$i]);
-    }
-} else {
-    $xoopsTpl->append("categories", array());
-}
-$xoopsTpl->assign(array("img_hotfolder" => $bbImage['newposts_forum'], "img_folder" => $bbImage['folder_forum'], "img_locked" => $bbImage['locked_forum'], "lang_newposts" => _MD_NEWPOSTS, "lang_private" => _MD_PRIVATEFORUM, "lang_nonewposts" => _MD_NONEWPOSTS, "lang_search" => _MD_SEARCH, "lang_advsearch" => _MD_ADVSEARCH));
-include_once XOOPS_ROOT_PATH.'/footer.php';
-?>
+<?php
+// $Id: index.php,v 1.8 2006/05/01 02:37:28 onokazu Exp $
+//  ------------------------------------------------------------------------ //
+//                XOOPS - PHP Content Management System                      //
+//                    Copyright (c) 2000 XOOPS.org                           //
+//                       <http://www.xoops.org/>                             //
+//  ------------------------------------------------------------------------ //
+//  This program is free software; you can redistribute it and/or modify     //
+//  it under the terms of the GNU General Public License as published by     //
+//  the Free Software Foundation; either version 2 of the License, or        //
+//  (at your option) any later version.                                      //
+//                                                                           //
+//  You may not change or alter any portion of this comment or credits       //
+//  of supporting developers from this source code or any supporting         //
+//  source code which is considered copyrighted (c) material of the          //
+//  original comment or credit authors.                                      //
+//                                                                           //
+//  This program is distributed in the hope that it will be useful,          //
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
+//  GNU General Public License for more details.                             //
+//                                                                           //
+//  You should have received a copy of the GNU General Public License        //
+//  along with this program; if not, write to the Free Software              //
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
+//  ------------------------------------------------------------------------ //
+// Author: Kazumi Ono (AKA onokazu)                                          //
+// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ //
+// Project: The XOOPS Project                                                //
+// ------------------------------------------------------------------------- //
+
+include "header.php";
+// this page uses smarty template
+// this must be set before including main header.php
+$xoopsOption['template_main']= 'newbb_index.html';
+include XOOPS_ROOT_PATH."/header.php";
+
+$myts =& MyTextSanitizer::getInstance();
+
+$sql = 'SELECT c.* FROM '.$xoopsDB->prefix('bb_categories').' c, '.$xoopsDB->prefix("bb_forums").' f WHERE f.cat_id=c.cat_id GROUP BY c.cat_id, c.cat_title, c.cat_order ORDER BY c.cat_order';
+if ( !$result = $xoopsDB->query($sql) ) {
+    redirect_header(XOOPS_URL.'/',1,_MD_ERROROCCURED);
+    exit();
+}
+
+$xoopsTpl->assign(array("lang_welcomemsg" => sprintf(_MD_WELCOME,htmlspecialchars($xoopsConfig['sitename'], ENT_QUOTES)), "lang_tostart" => _MD_TOSTART, "lang_totaltopics" => _MD_TOTALTOPICSC, "lang_totalposts" => _MD_TOTALPOSTSC, "total_topics" => get_total_topics(), "total_posts" => get_total_posts(0, 'all'), "lang_lastvisit" => sprintf(_MD_LASTVISIT,formatTimestamp($last_visit)), "lang_currenttime" => sprintf(_MD_TIMENOW,formatTimestamp(time(),"m")), "lang_forum" => _MD_FORUM, "lang_topics" => _MD_TOPICS, "lang_posts" => _MD_POSTS, "lang_lastpost" => _MD_LASTPOST, "lang_moderators" => _MD_MODERATOR));
+
+$viewcat = (!empty($_GET['cat'])) ? intval($_GET['cat']) : 0;
+$categories = array();
+while ( $cat_row = $xoopsDB->fetchArray($result) ) {
+    $categories[] = $cat_row;
+}
+
+$sql = 'SELECT f.*, u.uname, u.uid, p.topic_id, p.post_time, p.subject, p.icon FROM '.$xoopsDB->prefix('bb_forums').' f LEFT JOIN '.$xoopsDB->prefix('bb_posts').' p ON p.post_id = f.forum_last_post_id LEFT JOIN '.$xoopsDB->prefix('users').' u ON u.uid = p.uid';
+if ( $viewcat != 0 ) {
+    $sql .= ' WHERE f.cat_id = '.$viewcat;
+    $xoopsTpl->assign('forum_index_title', sprintf(_MD_FORUMINDEX,htmlspecialchars($xoopsConfig['sitename'], ENT_QUOTES)));
+} else {
+    $xoopsTpl->assign('forum_index_title', '');
+}
+$sql .= ' ORDER BY f.cat_id, f.forum_id';
+if ( !$result = $xoopsDB->query($sql) ) {
+    exit("Error");
+}
+$forums = array(); // RMV-FIX
+while ( $forum_data = $xoopsDB->fetchArray($result) ) {
+    $forums[] = $forum_data;
+}
+$cat_count = count($categories);
+if ($cat_count > 0) {
+    for ( $i = 0; $i < $cat_count; $i++ ) {
+        $categories[$i]['cat_title'] = $myts->makeTboxData4Show($categories[$i]['cat_title']);
+        if ( $viewcat != 0 && $categories[$i]['cat_id'] != $viewcat ) {
+            $xoopsTpl->append("categories", $categories[$i]);
+            continue;
+        }
+        $topic_lastread = newbb_get_topics_viewed();
+        foreach ( $forums as $forum_row ) {
+            unset($last_post);
+            if ( $forum_row['cat_id'] == $categories[$i]['cat_id'] ) {
+                if ($forum_row['post_time']) {
+                    //$forum_row['subject'] = $myts->makeTboxData4Show($forum_row['subject']);
+                    $categories[$i]['forums']['forum_lastpost_time'][] = formatTimestamp($forum_row['post_time']);
+                    $last_post_icon = '<a href="'.XOOPS_URL.'/modules/newbb/viewtopic.php?post_id='.$forum_row['forum_last_post_id'].'&amp;topic_id='.$forum_row['topic_id'].'&amp;forum='.$forum_row['forum_id'].'#forumpost'.$forum_row['forum_last_post_id'].'">';
+                    if ( $forum_row['icon'] ) {
+                        $last_post_icon .= '<img src="'.XOOPS_URL.'/images/subject/'.htmlspecialchars($forum_row['icon']).'" border="0" alt="" />';
+                    } else {
+                        $last_post_icon .= '<img src="'.XOOPS_URL.'/images/subject/icon1.gif" width="15" height="15" border="0" alt="" />';
+                    }
+                    $last_post_icon .= '</a>';
+                    $categories[$i]['forums']['forum_lastpost_icon'][] = $last_post_icon;
+                    if ( $forum_row['uid'] != 0 && $forum_row['uname'] ){
+                        $categories[$i]['forums']['forum_lastpost_user'][] = '<a href="'.XOOPS_URL.'/userinfo.php?uid='.$forum_row['uid'].'">' . $myts->makeTboxData4Show($forum_row['uname']).'</a>';
+                    } else {
+                        $categories[$i]['forums']['forum_lastpost_user'][] = $xoopsConfig['anonymous'];
+                    }
+                    $forum_lastread = !empty($topic_lastread[$forum_row['topic_id']]) ? $topic_lastread[$forum_row['topic_id']] : false;
+                    if ( $forum_row['forum_type'] == 1 ) {
+                        $categories[$i]['forums']['forum_folder'][] = $bbImage['locked_forum'];
+                    } elseif ( $forum_row['post_time'] > $forum_lastread && !empty($forum_row['topic_id'])) {
+                        $categories[$i]['forums']['forum_folder'][] = $bbImage['newposts_forum'];
+                    } else {
+                        $categories[$i]['forums']['forum_folder'][] = $bbImage['folder_forum'];
+                    }
+                } else {
+                    // no forums, so put empty values
+                    $categories[$i]['forums']['forum_lastpost_time'][] = "";
+                    $categories[$i]['forums']['forum_lastpost_icon'][] = "";
+                    $categories[$i]['forums']['forum_lastpost_user'][] = "";
+                    if ( $forum_row['forum_type'] == 1 ) {
+                        $categories[$i]['forums']['forum_folder'][] = $bbImage['locked_forum'];
+                    } else {
+                        $categories[$i]['forums']['forum_folder'][] = $bbImage['folder_forum'];
+                    }
+                }
+                $categories[$i]['forums']['forum_id'][] = $forum_row['forum_id'];
+                $categories[$i]['forums']['forum_name'][] = $myts->makeTboxData4Show($forum_row['forum_name']);
+                $categories[$i]['forums']['forum_desc'][] = $myts->makeTareaData4Show($forum_row['forum_desc']);
+                $categories[$i]['forums']['forum_topics'][] = $forum_row['forum_topics'];
+                $categories[$i]['forums']['forum_posts'][] = $forum_row['forum_posts'];
+                $all_moderators = get_moderators($forum_row['forum_id']);
+                $count = 0;
+                $forum_moderators = '';
+                foreach ( $all_moderators as $mods) {
+                    foreach ( $mods as $mod_id => $mod_name) {
+                        if ( $count > 0 ) {
+                            $forum_moderators .= ', ';
+                        }
+                        $forum_moderators .= '<a href="'.XOOPS_URL.'/userinfo.php?uid='.$mod_id.'">'.$myts->makeTboxData4Show($mod_name).'</a>';
+                        $count = 1;
+                    }
+                }
+                $categories[$i]['forums']['forum_moderators'][] = $forum_moderators;
+            }
+        }
+        $xoopsTpl->append("categories", $categories[$i]);
+    }
+} else {
+    $xoopsTpl->append("categories", array());
+}
+$xoopsTpl->assign(array("img_hotfolder" => $bbImage['newposts_forum'], "img_folder" => $bbImage['folder_forum'], "img_locked" => $bbImage['locked_forum'], "lang_newposts" => _MD_NEWPOSTS, "lang_private" => _MD_PRIVATEFORUM, "lang_nonewposts" => _MD_NONEWPOSTS, "lang_search" => _MD_SEARCH, "lang_advsearch" => _MD_ADVSEARCH));
+include_once XOOPS_ROOT_PATH.'/footer.php';
+?>
Index: xoops2jp/html/modules/newbb/viewforum.php
diff -u xoops2jp/html/modules/newbb/viewforum.php:1.6 xoops2jp/html/modules/newbb/viewforum.php:1.7
--- xoops2jp/html/modules/newbb/viewforum.php:1.6	Tue Oct 25 12:07:38 2005
+++ xoops2jp/html/modules/newbb/viewforum.php	Mon May  1 11:37:28 2006
@@ -1,282 +1,282 @@
-<?php
-// $Id: viewforum.php,v 1.6 2005/10/25 03:07:38 onokazu Exp $
-//  ------------------------------------------------------------------------ //
-//                XOOPS - PHP Content Management System                      //
-//                    Copyright (c) 2000 XOOPS.org                           //
-//                       <http://www.xoops.org/>                             //
-//  ------------------------------------------------------------------------ //
-//  This program is free software; you can redistribute it and/or modify     //
-//  it under the terms of the GNU General Public License as published by     //
-//  the Free Software Foundation; either version 2 of the License, or        //
-//  (at your option) any later version.                                      //
-//                                                                           //
-//  You may not change or alter any portion of this comment or credits       //
-//  of supporting developers from this source code or any supporting         //
-//  source code which is considered copyrighted (c) material of the          //
-//  original comment or credit authors.                                      //
-//                                                                           //
-//  This program is distributed in the hope that it will be useful,          //
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
-//  GNU General Public License for more details.                             //
-//                                                                           //
-//  You should have received a copy of the GNU General Public License        //
-//  along with this program; if not, write to the Free Software              //
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
-//  ------------------------------------------------------------------------ //
-// Author: Kazumi Ono (AKA onokazu)                                          //
-// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ //
-// Project: The XOOPS Project                                                //
-// ------------------------------------------------------------------------- //
-
-include "header.php";
-
-$forum = intval($_GET['forum']);
-if ( $forum < 1 ) {
-    redirect_header("index.php", 2, _MD_ERRORFORUM);
-    exit();
-}
-$sql = 'SELECT forum_type, forum_name, forum_access, allow_html, allow_sig, posts_per_page, hot_threshold, topics_per_page FROM '.$xoopsDB->prefix('bb_forums').' WHERE forum_id = '.$forum;
-if ( !$result = $xoopsDB->query($sql) ) {
-    redirect_header("index.php", 2, _MD_ERRORCONNECT);
-    exit();
-}
-if ( !$forumdata = $xoopsDB->fetchArray($result) ) {
-    redirect_header("index.php", 2, _MD_ERROREXIST);
-    exit();
-}
-// this page uses smarty template
-// this must be set before including main header.php
-$xoopsOption['template_main'] = 'newbb_viewforum.html';
-include XOOPS_ROOT_PATH."/header.php";
-$can_post = 0;
-$show_reg = 0;
-if ( $forumdata['forum_type'] == 1 ) {
-    // this is a private forum.
-    $xoopsTpl->assign('is_private_forum', true);
-    $accesserror = 0;
-    if ( $xoopsUser ) {
-        if ( !$xoopsUser->isAdmin($xoopsModule->mid()) ) {
-            if ( !check_priv_forum_auth($xoopsUser->getVar("uid"), $forum, false) ) {
-                $accesserror = 1;
-            }
-        }
-    } else {
-        $accesserror = 1;
-    }
-    if ( $accesserror == 1 ) {
-        redirect_header("index.php",2,_MD_NORIGHTTOACCESS);
-        exit();
-    }
-    $can_post = 1;
-    $show_reg = 1;
-} else {
-    // this is not a priv forum
-    $xoopsTpl->assign('is_private_forum', false);
-    if ( $forumdata['forum_access'] == 1 ) {
-        // this is a reg user only forum
-        if ( $xoopsUser ) {
-            $can_post = 1;
-        } else {
-            $show_reg = 1;
-        }
-    } elseif ( $forumdata['forum_access'] == 2 ) {
-        // this is an open forum
-        $can_post = 1;
-    } else {
-        // this is an admin/moderator only forum
-        if ( $xoopsUser ) {
-            if ( $xoopsUserIsAdmin || is_moderator($forum, $xoopsUser->uid()) ) {
-                $can_post = 1;
-            }
-        }
-    }
-}
-
-$xoopsTpl->assign("forum_id", $forum);
-if ( $can_post == 1 ) {
-    $xoopsTpl->assign('viewer_can_post', true);
-    $xoopsTpl->assign('forum_post_or_register', "<a href=\"newtopic.php?forum=".$forum."\"><img src=\"".$bbImage['post']."\" alt=\""._MD_POSTNEW."\" /></a>");
-} else {
-    $xoopsTpl->assign('viewer_can_post', false);
-    if ( $show_reg == 1 ) {
-        $xoopsTpl->assign('forum_post_or_register', '<a href="'.XOOPS_URL.'/user.php?xoops_redirect='.htmlspecialchars($xoopsRequestUri).'">'._MD_REGTOPOST.'</a>');
-    } else {
-        $xoopsTpl->assign('forum_post_or_register', "");
-    }
-}
-$xoopsTpl->assign('forum_index_title', sprintf(_MD_FORUMINDEX,$xoopsConfig['sitename']));
-$xoopsTpl->assign('forum_image_folder', $bbImage['folder_topic']);
-$myts =& MyTextSanitizer::getInstance();
-$xoopsTpl->assign('forum_name', $myts->makeTboxData4Show($forumdata['forum_name']));
-$xoopsTpl->assign('lang_moderatedby', _MD_MODERATEDBY);
-
-$forum_moderators = "";
-$count = 0;
-$moderators = get_moderators($forum);
-foreach ( $moderators as $mods ) {
-    foreach ( $mods as $mod_id => $mod_name ) {
-        if ( $count > 0 ) {
-            $forum_moderators .= ", ";
-        }
-        $forum_moderators .=  '<a href="'.XOOPS_URL.'/userinfo.php?uid='.$mod_id.'">'.$myts->makeTboxData4Show($mod_name).'</a>';
-        $count = 1;
-    }
-}
-$xoopsTpl->assign('forum_moderators', $forum_moderators);
-
-
-$sel_sort_array = array("t.topic_title"=>_MD_TOPICTITLE, "t.topic_replies"=>_MD_NUMBERREPLIES, "u.uname"=>_MD_TOPICPOSTER, "t.topic_views"=>_MD_VIEWS, "p.post_time"=>_MD_LASTPOSTTIME);
-if ( !isset($_GET['sortname']) || !in_array($_GET['sortname'], array_keys($sel_sort_array)) ) {
-    $sortname = "p.post_time";
-} else {
-    $sortname = $_GET['sortname'];
-}
-
-$xoopsTpl->assign('lang_sortby', _MD_SORTEDBY);
-
-$forum_selection_sort = '<select name="sortname">';
-foreach ( $sel_sort_array as $sort_k => $sort_v ) {
-    $forum_selection_sort .= '<option value="'.$sort_k.'"'.(($sortname == $sort_k) ? ' selected="selected"' : '').'>'.$sort_v.'</option>';
-}
-$forum_selection_sort .= '</select>';
-
-// assign to template
-$xoopsTpl->assign('forum_selection_sort', $forum_selection_sort);
-
-$sortorder = (!isset($_GET['sortorder']) || $_GET['sortorder'] != "ASC") ? "DESC" : "ASC";
-$forum_selection_order = '<select name="sortorder">';
-$forum_selection_order .= '<option value="ASC"'.(($sortorder == "ASC") ? ' selected="selected"' : '').'>'._MD_ASCENDING.'</option>';
-$forum_selection_order .= '<option value="DESC"'.(($sortorder == "DESC") ? ' selected="selected"' : '').'>'._MD_DESCENDING.'</option>';
-$forum_selection_order .= '</select>';
-
-// assign to template
-$xoopsTpl->assign('forum_selection_order', $forum_selection_order);
-
-$sortsince = !empty($_GET['sortsince']) ? intval($_GET['sortsince']) : 100;
-$sel_since_array = array(1, 2, 5, 10, 20, 30, 40, 60, 75, 100);
-$forum_selection_since = '<select name="sortsince">';
-foreach ($sel_since_array as $sort_since_v) {
-    $forum_selection_since .= '<option value="'.$sort_since_v.'"'.(($sortsince == $sort_since_v) ? ' selected="selected"' : '').'>'.sprintf(_MD_FROMLASTDAYS,$sort_since_v).'</option>';
-}
-$forum_selection_since .= '<option value="365"'.(($sortsince == 365) ? ' selected="selected"' : '').'>'.sprintf(_MD_THELASTYEAR,365).'</option>';
-$forum_selection_since .= '<option value="1000"'.(($sortsince == 1000) ? ' selected="selected"' : '').'>'.sprintf(_MD_BEGINNING,1000).'</option>';
-$forum_selection_since .= '</select>';
-
-// assign to template
-$xoopsTpl->assign('forum_selection_since', $forum_selection_since);
-$xoopsTpl->assign('lang_go', _MD_GO);
-
-$xoopsTpl->assign('h_topic_link', "viewforum.php?forum=$forum&amp;sortname=t.topic_title&amp;sortsince=$sortsince&amp;sortorder=". (($sortname == "t.topic_title" && $sortorder == "DESC") ? "ASC" : "DESC"));
-$xoopsTpl->assign('lang_topic', _MD_TOPIC);
-
-$xoopsTpl->assign('h_reply_link', "viewforum.php?forum=$forum&amp;sortname=t.topic_replies&amp;sortsince=$sortsince&amp;sortorder=". (($sortname == "t.topic_replies" && $sortorder == "DESC") ? "ASC" : "DESC"));
-$xoopsTpl->assign('lang_replies', _MD_REPLIES);
-
-$xoopsTpl->assign('h_poster_link', "viewforum.php?forum=$forum&amp;sortname=u.uname&amp;sortsince=$sortsince&amp;sortorder=". (($sortname == "u.uname" && $sortorder == "DESC") ? "ASC" : "DESC"));
-$xoopsTpl->assign('lang_poster', _MD_POSTER);
-
-$xoopsTpl->assign('h_views_link', "viewforum.php?forum=$forum&amp;sortname=t.topic_views&amp;sortsince=$sortsince&amp;sortorder=". (($sortname == "t.topic_views" && $sortorder == "DESC") ? "ASC" : "DESC"));
-$xoopsTpl->assign('lang_views', _MD_VIEWS);
-
-$xoopsTpl->assign('h_date_link', "viewforum.php?forum=$forum&amp;sortname=p.post_time&amp;sortsince=$sortsince&amp;sortorder=". (($sortname == "p.post_time" && $sortorder == "DESC") ? "ASC" : "DESC"));
-$xoopsTpl->assign('lang_date', _MD_DATE);
-
-$startdate = time() - (86400* $sortsince);
-$start = !empty($_GET['start']) ? intval($_GET['start']) : 0;
-
-$sql = 'SELECT t.*, u.uname, u2.uname as last_poster, p.post_time as last_post_time, p.icon FROM '.$xoopsDB->prefix("bb_topics").' t LEFT JOIN '.$xoopsDB->prefix('users').' u ON u.uid = t.topic_poster LEFT JOIN '.$xoopsDB->prefix('bb_posts').' p ON p.post_id = t.topic_last_post_id LEFT JOIN '.$xoopsDB->prefix('users').' u2 ON  u2.uid = p.uid WHERE t.forum_id = '.$forum.' AND (p.post_time > '.$startdate.' OR t.topic_sticky=1) ORDER BY topic_sticky DESC, '.$sortname.' '.$sortorder;
-if ( !$result = $xoopsDB->query($sql,$forumdata['topics_per_page'],$start) ) {
-    redirect_header('index.php',2,_MD_ERROROCCURED);
-    exit();
-}
-
-// Read topic 'lastread' times from cookie, if exists
-$topic_lastread = newbb_get_topics_viewed();
-while ( $myrow = $xoopsDB->fetchArray($result) ) {
-
-    if ( empty($myrow['last_poster']) ) {
-        $myrow['last_poster'] = $xoopsConfig['anonymous'];
-    }
-    if ( $myrow['topic_sticky'] == 1 ) {
-        $image = $bbImage['folder_sticky'];
-    } elseif ( $myrow['topic_status'] == 1 ) {
-        $image = $bbImage['locked_topic'];
-    } else {
-        if ( $myrow['topic_replies'] >= $forumdata['hot_threshold'] ) {
-            if ( empty($topic_lastread[$myrow['topic_id']]) || ($topic_lastread[$myrow['topic_id']] < $myrow['last_post_time'] )) {
-                $image = $bbImage['hot_newposts_topic'];
-            } else {
-                $image = $bbImage['hot_folder_topic'];
-            }
-        } else {
-            if ( empty($topic_lastread[$myrow['topic_id']]) || ($topic_lastread[$myrow['topic_id']] < $myrow['last_post_time'] )) {
-                $image = $bbImage['newposts_topic'];
-            } else {
-                $image = $bbImage['folder_topic'];
-            }
-        }
-    }
-    $pagination = '';
-    $addlink = '';
-    $topiclink = 'viewtopic.php?topic_id='.$myrow['topic_id'].'&amp;forum='.$forum;
-    $totalpages = ceil(($myrow['topic_replies'] + 1) / $forumdata['posts_per_page']);
-    if ( $totalpages > 1 ) {
-        $pagination .= '&nbsp;&nbsp;&nbsp;<img src="'.XOOPS_URL.'/images/icons/posticon.gif" /> ';
-        for ( $i = 1; $i <= $totalpages; $i++ ) {
-
-            if ( $i > 3 && $i < $totalpages ) {
-                $pagination .= "...";
-            } else {
-                $addlink = '&amp;start='.(($i - 1) * $forumdata['posts_per_page']);
-                $pagination .= '[<a href="'.$topiclink.$addlink.'">'.$i.'</a>]';
-            }
-        }
-    }
-    if ( $myrow['icon'] ) {
-        $topic_icon = '<img src="'.XOOPS_URL.'/images/subject/'.htmlspecialchars($myrow['icon']).'" alt="" />';
-    } else {
-        $topic_icon = '<img src="'.XOOPS_URL.'/images/icons/no_posticon.gif" alt="" />';
-    }
-    if ( $myrow['topic_poster'] != 0 && $myrow['uname'] ) {
-        $topic_poster = '<a href="'.XOOPS_URL.'/userinfo.php?uid='.$myrow['topic_poster'].'">'.$myrow['uname'].'</a>';
-    } else {
-        $topic_poster = $xoopsConfig['anonymous'];
-    }
-    $xoopsTpl->append('topics', array('topic_icon'=>$topic_icon, 'topic_folder'=>$image, 'topic_title'=>$myts->makeTboxData4Show($myrow['topic_title']), 'topic_link'=>$topiclink, 'topic_page_jump'=>$pagination, 'topic_replies'=>$myrow['topic_replies'], 'topic_poster'=>$topic_poster, 'topic_views'=>$myrow['topic_views'], 'topic_last_posttime'=>formatTimestamp($myrow['last_post_time']), 'topic_last_poster'=>$myts->makeTboxData4Show($myrow['last_poster'])));
-}
-
-$xoopsTpl->assign('lang_by', _MD_BY);
-
-$xoopsTpl->assign('img_newposts', $bbImage['newposts_topic']);
-$xoopsTpl->assign('img_hotnewposts', $bbImage['hot_newposts_topic']);
-$xoopsTpl->assign('img_folder', $bbImage['folder_topic']);
-$xoopsTpl->assign('img_hotfolder', $bbImage['hot_folder_topic']);
-$xoopsTpl->assign('img_locked', $bbImage['locked_topic']);
-$xoopsTpl->assign('img_sticky', $bbImage['folder_sticky']);
-$xoopsTpl->assign('lang_newposts', _MD_NEWPOSTS);
-$xoopsTpl->assign('lang_hotnewposts', _MD_MORETHAN);
-$xoopsTpl->assign('lang_hotnonewposts', _MD_MORETHAN2);
-$xoopsTpl->assign('lang_nonewposts', _MD_NONEWPOSTS);
-$xoopsTpl->assign('lang_legend', _MD_LEGEND);
-$xoopsTpl->assign('lang_topiclocked', _MD_TOPICLOCKED);
-$xoopsTpl->assign('lang_topicsticky', _MD_TOPICSTICKY);
-$xoopsTpl->assign("lang_search", _MD_SEARCH);
-$xoopsTpl->assign("lang_advsearch", _MD_ADVSEARCH);
-
-$sql = 'SELECT COUNT(*) FROM '.$xoopsDB->prefix('bb_topics').' WHERE forum_id = '.$forum.' AND (topic_time > '.$startdate.' OR topic_sticky = 1)';
-if ( !$r = $xoopsDB->query($sql) ) {
-    //redirect_header('index.php',2,_MD_ERROROCCURED);
-    //exit();
-}
-list($all_topics) = $xoopsDB->fetchRow($r);
-if ( $all_topics > $forumdata['topics_per_page'] ) {
-    include XOOPS_ROOT_PATH.'/class/pagenav.php';
-    $nav = new XoopsPageNav($all_topics, $forumdata['topics_per_page'], $start, "start", 'forum='.$forum.'&amp;sortname='.$sortname.'&amp;sortorder='.$sortorder.'&amp;sortsince='.$sortsince);
-    $xoopsTpl->assign('forum_pagenav', $nav->renderNav(4));
-} else {
-    $xoopsTpl->assign('forum_pagenav', '');
-}
-$xoopsTpl->assign('forum_jumpbox', make_jumpbox($forum));
-include XOOPS_ROOT_PATH."/footer.php";
-?>
+<?php
+// $Id: viewforum.php,v 1.7 2006/05/01 02:37:28 onokazu Exp $
+//  ------------------------------------------------------------------------ //
+//                XOOPS - PHP Content Management System                      //
+//                    Copyright (c) 2000 XOOPS.org                           //
+//                       <http://www.xoops.org/>                             //
+//  ------------------------------------------------------------------------ //
+//  This program is free software; you can redistribute it and/or modify     //
+//  it under the terms of the GNU General Public License as published by     //
+//  the Free Software Foundation; either version 2 of the License, or        //
+//  (at your option) any later version.                                      //
+//                                                                           //
+//  You may not change or alter any portion of this comment or credits       //
+//  of supporting developers from this source code or any supporting         //
+//  source code which is considered copyrighted (c) material of the          //
+//  original comment or credit authors.                                      //
+//                                                                           //
+//  This program is distributed in the hope that it will be useful,          //
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
+//  GNU General Public License for more details.                             //
+//                                                                           //
+//  You should have received a copy of the GNU General Public License        //
+//  along with this program; if not, write to the Free Software              //
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
+//  ------------------------------------------------------------------------ //
+// Author: Kazumi Ono (AKA onokazu)                                          //
+// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ //
+// Project: The XOOPS Project                                                //
+// ------------------------------------------------------------------------- //
+
+include "header.php";
+
+$forum = intval($_GET['forum']);
+if ( $forum < 1 ) {
+    redirect_header("index.php", 2, _MD_ERRORFORUM);
+    exit();
+}
+$sql = 'SELECT forum_type, forum_name, forum_access, allow_html, allow_sig, posts_per_page, hot_threshold, topics_per_page FROM '.$xoopsDB->prefix('bb_forums').' WHERE forum_id = '.$forum;
+if ( !$result = $xoopsDB->query($sql) ) {
+    redirect_header("index.php", 2, _MD_ERRORCONNECT);
+    exit();
+}
+if ( !$forumdata = $xoopsDB->fetchArray($result) ) {
+    redirect_header("index.php", 2, _MD_ERROREXIST);
+    exit();
+}
+// this page uses smarty template
+// this must be set before including main header.php
+$xoopsOption['template_main'] = 'newbb_viewforum.html';
+include XOOPS_ROOT_PATH."/header.php";
+$can_post = 0;
+$show_reg = 0;
+if ( $forumdata['forum_type'] == 1 ) {
+    // this is a private forum.
+    $xoopsTpl->assign('is_private_forum', true);
+    $accesserror = 0;
+    if ( $xoopsUser ) {
+        if ( !$xoopsUser->isAdmin($xoopsModule->mid()) ) {
+            if ( !check_priv_forum_auth($xoopsUser->getVar("uid"), $forum, false) ) {
+                $accesserror = 1;
+            }
+        }
+    } else {
+        $accesserror = 1;
+    }
+    if ( $accesserror == 1 ) {
+        redirect_header("index.php",2,_MD_NORIGHTTOACCESS);
+        exit();
+    }
+    $can_post = 1;
+    $show_reg = 1;
+} else {
+    // this is not a priv forum
+    $xoopsTpl->assign('is_private_forum', false);
+    if ( $forumdata['forum_access'] == 1 ) {
+        // this is a reg user only forum
+        if ( $xoopsUser ) {
+            $can_post = 1;
+        } else {
+            $show_reg = 1;
+        }
+    } elseif ( $forumdata['forum_access'] == 2 ) {
+        // this is an open forum
+        $can_post = 1;
+    } else {
+        // this is an admin/moderator only forum
+        if ( $xoopsUser ) {
+            if ( $xoopsUserIsAdmin || is_moderator($forum, $xoopsUser->uid()) ) {
+                $can_post = 1;
+            }
+        }
+    }
+}
+
+$xoopsTpl->assign("forum_id", $forum);
+if ( $can_post == 1 ) {
+    $xoopsTpl->assign('viewer_can_post', true);
+    $xoopsTpl->assign('forum_post_or_register', "<a href=\"newtopic.php?forum=".$forum."\"><img src=\"".$bbImage['post']."\" alt=\""._MD_POSTNEW."\" /></a>");
+} else {
+    $xoopsTpl->assign('viewer_can_post', false);
+    if ( $show_reg == 1 ) {
+        $xoopsTpl->assign('forum_post_or_register', '<a href="'.XOOPS_URL.'/user.php?xoops_redirect='.htmlspecialchars($xoopsRequestUri).'">'._MD_REGTOPOST.'</a>');
+    } else {
+        $xoopsTpl->assign('forum_post_or_register', "");
+    }
+}
+$xoopsTpl->assign('forum_index_title', sprintf(_MD_FORUMINDEX,$xoopsConfig['sitename']));
+$xoopsTpl->assign('forum_image_folder', $bbImage['folder_topic']);
+$myts =& MyTextSanitizer::getInstance();
+$xoopsTpl->assign('forum_name', $myts->makeTboxData4Show($forumdata['forum_name']));
+$xoopsTpl->assign('lang_moderatedby', _MD_MODERATEDBY);
+
+$forum_moderators = "";
+$count = 0;
+$moderators = get_moderators($forum);
+foreach ( $moderators as $mods ) {
+    foreach ( $mods as $mod_id => $mod_name ) {
+        if ( $count > 0 ) {
+            $forum_moderators .= ", ";
+        }
+        $forum_moderators .=  '<a href="'.XOOPS_URL.'/userinfo.php?uid='.$mod_id.'">'.$myts->makeTboxData4Show($mod_name).'</a>';
+        $count = 1;
+    }
+}
+$xoopsTpl->assign('forum_moderators', $forum_moderators);
+
+
+$sel_sort_array = array("t.topic_title"=>_MD_TOPICTITLE, "t.topic_replies"=>_MD_NUMBERREPLIES, "u.uname"=>_MD_TOPICPOSTER, "t.topic_views"=>_MD_VIEWS, "p.post_time"=>_MD_LASTPOSTTIME);
+if ( !isset($_GET['sortname']) || !in_array($_GET['sortname'], array_keys($sel_sort_array)) ) {
+    $sortname = "p.post_time";
+} else {
+    $sortname = $_GET['sortname'];
+}
+
+$xoopsTpl->assign('lang_sortby', _MD_SORTEDBY);
+
+$forum_selection_sort = '<select name="sortname">';
+foreach ( $sel_sort_array as $sort_k => $sort_v ) {
+    $forum_selection_sort .= '<option value="'.$sort_k.'"'.(($sortname == $sort_k) ? ' selected="selected"' : '').'>'.$sort_v.'</option>';
+}
+$forum_selection_sort .= '</select>';
+
+// assign to template
+$xoopsTpl->assign('forum_selection_sort', $forum_selection_sort);
+
+$sortorder = (!isset($_GET['sortorder']) || $_GET['sortorder'] != "ASC") ? "DESC" : "ASC";
+$forum_selection_order = '<select name="sortorder">';
+$forum_selection_order .= '<option value="ASC"'.(($sortorder == "ASC") ? ' selected="selected"' : '').'>'._MD_ASCENDING.'</option>';
+$forum_selection_order .= '<option value="DESC"'.(($sortorder == "DESC") ? ' selected="selected"' : '').'>'._MD_DESCENDING.'</option>';
+$forum_selection_order .= '</select>';
+
+// assign to template
+$xoopsTpl->assign('forum_selection_order', $forum_selection_order);
+
+$sortsince = !empty($_GET['sortsince']) ? intval($_GET['sortsince']) : 100;
+$sel_since_array = array(1, 2, 5, 10, 20, 30, 40, 60, 75, 100);
+$forum_selection_since = '<select name="sortsince">';
+foreach ($sel_since_array as $sort_since_v) {
+    $forum_selection_since .= '<option value="'.$sort_since_v.'"'.(($sortsince == $sort_since_v) ? ' selected="selected"' : '').'>'.sprintf(_MD_FROMLASTDAYS,$sort_since_v).'</option>';
+}
+$forum_selection_since .= '<option value="365"'.(($sortsince == 365) ? ' selected="selected"' : '').'>'.sprintf(_MD_THELASTYEAR,365).'</option>';
+$forum_selection_since .= '<option value="1000"'.(($sortsince == 1000) ? ' selected="selected"' : '').'>'.sprintf(_MD_BEGINNING,1000).'</option>';
+$forum_selection_since .= '</select>';
+
+// assign to template
+$xoopsTpl->assign('forum_selection_since', $forum_selection_since);
+$xoopsTpl->assign('lang_go', _MD_GO);
+
+$xoopsTpl->assign('h_topic_link', "viewforum.php?forum=$forum&amp;sortname=t.topic_title&amp;sortsince=$sortsince&amp;sortorder=". (($sortname == "t.topic_title" && $sortorder == "DESC") ? "ASC" : "DESC"));
+$xoopsTpl->assign('lang_topic', _MD_TOPIC);
+
+$xoopsTpl->assign('h_reply_link', "viewforum.php?forum=$forum&amp;sortname=t.topic_replies&amp;sortsince=$sortsince&amp;sortorder=". (($sortname == "t.topic_replies" && $sortorder == "DESC") ? "ASC" : "DESC"));
+$xoopsTpl->assign('lang_replies', _MD_REPLIES);
+
+$xoopsTpl->assign('h_poster_link', "viewforum.php?forum=$forum&amp;sortname=u.uname&amp;sortsince=$sortsince&amp;sortorder=". (($sortname == "u.uname" && $sortorder == "DESC") ? "ASC" : "DESC"));
+$xoopsTpl->assign('lang_poster', _MD_POSTER);
+
+$xoopsTpl->assign('h_views_link', "viewforum.php?forum=$forum&amp;sortname=t.topic_views&amp;sortsince=$sortsince&amp;sortorder=". (($sortname == "t.topic_views" && $sortorder == "DESC") ? "ASC" : "DESC"));
+$xoopsTpl->assign('lang_views', _MD_VIEWS);
+
+$xoopsTpl->assign('h_date_link', "viewforum.php?forum=$forum&amp;sortname=p.post_time&amp;sortsince=$sortsince&amp;sortorder=". (($sortname == "p.post_time" && $sortorder == "DESC") ? "ASC" : "DESC"));
+$xoopsTpl->assign('lang_date', _MD_DATE);
+
+$startdate = time() - (86400* $sortsince);
+$start = !empty($_GET['start']) ? intval($_GET['start']) : 0;
+
+$sql = 'SELECT t.*, u.uname, u2.uname as last_poster, p.post_time as last_post_time, p.icon FROM '.$xoopsDB->prefix("bb_topics").' t LEFT JOIN '.$xoopsDB->prefix('users').' u ON u.uid = t.topic_poster LEFT JOIN '.$xoopsDB->prefix('bb_posts').' p ON p.post_id = t.topic_last_post_id LEFT JOIN '.$xoopsDB->prefix('users').' u2 ON  u2.uid = p.uid WHERE t.forum_id = '.$forum.' AND (p.post_time > '.$startdate.' OR t.topic_sticky=1) ORDER BY topic_sticky DESC, '.$sortname.' '.$sortorder;
+if ( !$result = $xoopsDB->query($sql,$forumdata['topics_per_page'],$start) ) {
+    redirect_header('index.php',2,_MD_ERROROCCURED);
+    exit();
+}
+
+// Read topic 'lastread' times from cookie, if exists
+$topic_lastread = newbb_get_topics_viewed();
+while ( $myrow = $xoopsDB->fetchArray($result) ) {
+
+    if ( empty($myrow['last_poster']) ) {
+        $myrow['last_poster'] = $xoopsConfig['anonymous'];
+    }
+    if ( $myrow['topic_sticky'] == 1 ) {
+        $image = $bbImage['folder_sticky'];
+    } elseif ( $myrow['topic_status'] == 1 ) {
+        $image = $bbImage['locked_topic'];
+    } else {
+        if ( $myrow['topic_replies'] >= $forumdata['hot_threshold'] ) {
+            if ( empty($topic_lastread[$myrow['topic_id']]) || ($topic_lastread[$myrow['topic_id']] < $myrow['last_post_time'] )) {
+                $image = $bbImage['hot_newposts_topic'];
+            } else {
+                $image = $bbImage['hot_folder_topic'];
+            }
+        } else {
+            if ( empty($topic_lastread[$myrow['topic_id']]) || ($topic_lastread[$myrow['topic_id']] < $myrow['last_post_time'] )) {
+                $image = $bbImage['newposts_topic'];
+            } else {
+                $image = $bbImage['folder_topic'];
+            }
+        }
+    }
+    $pagination = '';
+    $addlink = '';
+    $topiclink = 'viewtopic.php?topic_id='.$myrow['topic_id'].'&amp;forum='.$forum;
+    $totalpages = ceil(($myrow['topic_replies'] + 1) / $forumdata['posts_per_page']);
+    if ( $totalpages > 1 ) {
+        $pagination .= '&nbsp;&nbsp;&nbsp;<img src="'.XOOPS_URL.'/images/icons/posticon.gif" /> ';
+        for ( $i = 1; $i <= $totalpages; $i++ ) {
+
+            if ( $i > 3 && $i < $totalpages ) {
+                $pagination .= "...";
+            } else {
+                $addlink = '&amp;start='.(($i - 1) * $forumdata['posts_per_page']);
+                $pagination .= '[<a href="'.$topiclink.$addlink.'">'.$i.'</a>]';
+            }
+        }
+    }
+    if ( $myrow['icon'] ) {
+        $topic_icon = '<img src="'.XOOPS_URL.'/images/subject/'.htmlspecialchars($myrow['icon']).'" alt="" />';
+    } else {
+        $topic_icon = '<img src="'.XOOPS_URL.'/images/icons/no_posticon.gif" alt="" />';
+    }
+    if ( $myrow['topic_poster'] != 0 && $myrow['uname'] ) {
+        $topic_poster = '<a href="'.XOOPS_URL.'/userinfo.php?uid='.$myrow['topic_poster'].'">'.$myrow['uname'].'</a>';
+    } else {
+        $topic_poster = $xoopsConfig['anonymous'];
+    }
+    $xoopsTpl->append('topics', array('topic_icon'=>$topic_icon, 'topic_folder'=>$image, 'topic_title'=>$myts->makeTboxData4Show($myrow['topic_title']), 'topic_link'=>$topiclink, 'topic_page_jump'=>$pagination, 'topic_replies'=>$myrow['topic_replies'], 'topic_poster'=>$topic_poster, 'topic_views'=>$myrow['topic_views'], 'topic_last_posttime'=>formatTimestamp($myrow['last_post_time']), 'topic_last_poster'=>$myts->makeTboxData4Show($myrow['last_poster'])));
+}
+
+$xoopsTpl->assign('lang_by', _MD_BY);
+
+$xoopsTpl->assign('img_newposts', $bbImage['newposts_topic']);
+$xoopsTpl->assign('img_hotnewposts', $bbImage['hot_newposts_topic']);
+$xoopsTpl->assign('img_folder', $bbImage['folder_topic']);
+$xoopsTpl->assign('img_hotfolder', $bbImage['hot_folder_topic']);
+$xoopsTpl->assign('img_locked', $bbImage['locked_topic']);
+$xoopsTpl->assign('img_sticky', $bbImage['folder_sticky']);
+$xoopsTpl->assign('lang_newposts', _MD_NEWPOSTS);
+$xoopsTpl->assign('lang_hotnewposts', _MD_MORETHAN);
+$xoopsTpl->assign('lang_hotnonewposts', _MD_MORETHAN2);
+$xoopsTpl->assign('lang_nonewposts', _MD_NONEWPOSTS);
+$xoopsTpl->assign('lang_legend', _MD_LEGEND);
+$xoopsTpl->assign('lang_topiclocked', _MD_TOPICLOCKED);
+$xoopsTpl->assign('lang_topicsticky', _MD_TOPICSTICKY);
+$xoopsTpl->assign("lang_search", _MD_SEARCH);
+$xoopsTpl->assign("lang_advsearch", _MD_ADVSEARCH);
+
+$sql = 'SELECT COUNT(*) FROM '.$xoopsDB->prefix('bb_topics').' WHERE forum_id = '.$forum.' AND (topic_time > '.$startdate.' OR topic_sticky = 1)';
+if ( !$r = $xoopsDB->query($sql) ) {
+    //redirect_header('index.php',2,_MD_ERROROCCURED);
+    //exit();
+}
+list($all_topics) = $xoopsDB->fetchRow($r);
+if ( $all_topics > $forumdata['topics_per_page'] ) {
+    include XOOPS_ROOT_PATH.'/class/pagenav.php';
+    $nav = new XoopsPageNav($all_topics, $forumdata['topics_per_page'], $start, "start", 'forum='.$forum.'&amp;sortname='.$sortname.'&amp;sortorder='.$sortorder.'&amp;sortsince='.$sortsince);
+    $xoopsTpl->assign('forum_pagenav', $nav->renderNav(4));
+} else {
+    $xoopsTpl->assign('forum_pagenav', '');
+}
+$xoopsTpl->assign('forum_jumpbox', make_jumpbox($forum));
+include XOOPS_ROOT_PATH."/footer.php";
+?>
Index: xoops2jp/html/modules/newbb/viewtopic.php
diff -u xoops2jp/html/modules/newbb/viewtopic.php:1.5 xoops2jp/html/modules/newbb/viewtopic.php:1.6
--- xoops2jp/html/modules/newbb/viewtopic.php:1.5	Tue Oct 25 12:07:38 2005
+++ xoops2jp/html/modules/newbb/viewtopic.php	Mon May  1 11:37:28 2006
@@ -1,360 +1,360 @@
-<?php
-// $Id: viewtopic.php,v 1.5 2005/10/25 03:07:38 onokazu Exp $
-//  ------------------------------------------------------------------------ //
-//                XOOPS - PHP Content Management System                      //
-//                    Copyright (c) 2000 XOOPS.org                           //
-//                       <http://www.xoops.org/>                             //
-//  ------------------------------------------------------------------------ //
-//  This program is free software; you can redistribute it and/or modify     //
-//  it under the terms of the GNU General Public License as published by     //
-//  the Free Software Foundation; either version 2 of the License, or        //
-//  (at your option) any later version.                                      //
-//                                                                           //
-//  You may not change or alter any portion of this comment or credits       //
-//  of supporting developers from this source code or any supporting         //
-//  source code which is considered copyrighted (c) material of the          //
-//  original comment or credit authors.                                      //
-//                                                                           //
-//  This program is distributed in the hope that it will be useful,          //
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
-//  GNU General Public License for more details.                             //
-//                                                                           //
-//  You should have received a copy of the GNU General Public License        //
-//  along with this program; if not, write to the Free Software              //
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
-//  ------------------------------------------------------------------------ //
-// Author: Kazumi Ono (AKA onokazu)                                          //
-// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ //
-// Project: The XOOPS Project                                                //
-// ------------------------------------------------------------------------- //
-
-include 'header.php';
-$forum = isset($_GET['forum']) ? intval($_GET['forum']) : 0;
-$topic_id = isset($_GET['topic_id']) ? intval($_GET['topic_id']) : 0;
-if ( empty($forum) ) {
-    redirect_header(XOOPS_URL."/modules/".$xoopsModule->getVar('dirname')."/index.php",2,_MD_ERRORFORUM);
-    exit();
-} elseif ( empty($topic_id) ) {
-    redirect_header('viewforum.php?forum='.$forum,2,_MD_ERRORTOPIC);
-    exit();
-}
-$topic_time = (isset($_GET['topic_time'])) ? intval($_GET['topic_time']) : 0;
-$post_id = !empty($_GET['post_id']) ? intval($_GET['post_id']) : 0;
-
-//use users preferences
-if (is_object($xoopsUser)) {
-    $viewmode = $xoopsUser->getVar('umode');
-    $order = ($xoopsUser->getVar('uorder') == 1) ? 'DESC' : 'ASC';
-} else {
-    $viewmode = 'flat';
-    $order = 'ASC';
-}
-
-// newbb does not have nested mode
-if ($viewmode == 'nest') {
-    $viewmode = 'thread';
-}
-
-// override mode/order if any requested
-if (isset($_GET['viewmode']) && ($_GET['viewmode'] == 'flat' || $_GET['viewmode'] == 'thread')) {
-    $viewmode = $_GET['viewmode'];
-}
-if (isset($_GET['order']) && ($_GET['order'] == 'ASC' || $_GET['order'] == 'DESC')) {
-    $order = $_GET['order'];
-}
-
-if ($viewmode != 'flat') {
-    $xoopsOption['template_main'] =  'newbb_viewtopic_thread.html';
-} else {
-    $xoopsOption['template_main'] =  'newbb_viewtopic_flat.html';
-}
-
-include XOOPS_ROOT_PATH.'/header.php';
-include_once 'class/class.forumposts.php';
-
-if ( isset($_GET['move']) && 'next' == $_GET['move'] ) {
-    $sql = 'SELECT t.topic_id, t.topic_title, t.topic_time, t.topic_status, t.topic_sticky, t.topic_last_post_id, f.forum_id, f.forum_name, f.forum_access, f.forum_type, f.allow_html, f.allow_sig, f.posts_per_page, f.hot_threshold, f.topics_per_page FROM '.$xoopsDB->prefix('bb_topics').' t LEFT JOIN '.$xoopsDB->prefix('bb_forums').' f ON f.forum_id = t.forum_id WHERE t.topic_time > '.$topic_time.' AND t.forum_id = '.$forum.' ORDER BY t.topic_time ASC LIMIT 1';
-} elseif ( isset($_GET['move']) && 'prev' == $_GET['move']) {
-    $sql = 'SELECT t.topic_id, t.topic_title, t.topic_time, t.topic_status, t.topic_sticky, t.topic_last_post_id, f.forum_id, f.forum_name, f.forum_access, f.forum_type, f.allow_html, f.allow_sig, f.posts_per_page, f.hot_threshold, f.topics_per_page FROM '.$xoopsDB->prefix('bb_topics').' t LEFT JOIN '.$xoopsDB->prefix('bb_forums').' f ON f.forum_id = t.forum_id WHERE t.topic_time < '.$topic_time.' AND t.forum_id = '.$forum.' ORDER BY t.topic_time DESC LIMIT 1';
-} else {
-    $sql = 'SELECT t.topic_id, t.topic_title, t.topic_time, t.topic_status, t.topic_sticky, t.topic_last_post_id, f.forum_id, f.forum_name, f.forum_access, f.forum_type, f.allow_html, f.allow_sig, f.posts_per_page, f.hot_threshold, f.topics_per_page FROM '.$xoopsDB->prefix('bb_topics').' t LEFT JOIN '.$xoopsDB->prefix('bb_forums').' f ON f.forum_id = t.forum_id WHERE t.topic_id = '.$topic_id.' AND t.forum_id = '.$forum;
-}
-
-if ( !$result = $xoopsDB->query($sql) ) {
-    redirect_header('viewforum.php?forum='.$forum,2,_MD_ERROROCCURED);
-    exit();
-}
-
-if ( !$forumdata = $xoopsDB->fetchArray($result) ) {
-    redirect_header('viewforum.php?forum='.$forum,2,_MD_FORUMNOEXIST);
-    exit();
-}
-$xoopsTpl->assign('topic_id', $forumdata['topic_id']);
-$topic_id = $forumdata['topic_id'];
-$xoopsTpl->assign('forum_id', $forumdata['forum_id']);
-$forum = $forumdata['forum_id'];
-$can_post = 0;
-$show_reg = 0;
-if ( $forumdata['forum_type'] == 1 ) {
-    // this is a private forum.
-    $accesserror = 0;
-    if ( $xoopsUser ) {
-        if ( !$xoopsUser->isAdmin($xoopsModule->mid()) ) {
-            if ( !check_priv_forum_auth($xoopsUser->getVar('uid'), $forum, false) ) {
-                $accesserror = 1;
-            }
-        } else {
-            $isadminormod = 1;
-        }
-    } else {
-        $accesserror = 1;
-    }
-    if ( $accesserror == 1 ) {
-        redirect_header(XOOPS_URL."/modules/".$xoopsModule->getVar('dirname')."/index.php",2,_MD_NORIGHTTOACCESS);
-        exit();
-    }
-    $can_post = 1;
-    $show_reg = 1;
-} else {
-    // this is not a priv forum
-    if ( $forumdata['forum_access'] == 1 ) {
-        // this is a reg user only forum
-        if ( $xoopsUser ) {
-            $can_post = 1;
-        } else {
-            $show_reg = 1;
-        }
-    } elseif ( $forumdata['forum_access'] == 2 ) {
-        // this is an open forum
-        $can_post = 1;
-    } else {
-        // this is an admin/moderator only forum
-        if ( $xoopsUser ) {
-            if ( $xoopsUser->isAdmin($xoopsModule->mid()) || is_moderator($forum, $xoopsUser->getVar('uid')) ) {
-                $can_post = 1;
-                $isadminormod = 1;
-            }
-        }
-    }
-}
-$myts =& MyTextSanitizer::getInstance();
-$forumdata['topic_title'] = $myts->makeTboxData4Show($forumdata['topic_title']);$forumdata['forum_name'] = $myts->makeTboxData4Show($forumdata['forum_name']);
-$xoopsTpl->assign(array('topic_title' => '<a href="'.$bbUrl['root'].'viewtopic.php?viewmode='.$viewmode.'&amp;topic_id='.$topic_id.'&amp;forum='.$forum.'">'.$forumdata['topic_title'].'</a>', 'forum_name' => $forumdata['forum_name'], 'topic_time' => $forumdata['topic_time'], 'lang_nexttopic' => _MD_NEXTTOPIC, 'lang_prevtopic' => _MD_PREVTOPIC));
-
-// add image links to admin page if the user viewing this page is a forum admin
-if ( $xoopsUser ) {
-    $xoopsTpl->assign('viewer_userid', $xoopsUser->getVar('uid'));
-    if ( !empty($isadminormod) || $xoopsUser->isAdmin($xoopsModule->mid()) || is_moderator( $forum, $xoopsUser->getVar('uid')) ) {
-        // yup, the user is admin
-        // the forum is locked?
-        if ( $forumdata['topic_status'] != 1 ) {
-            // nope
-            $xoopsTpl->assign('topic_lock_image', '<a href="'.$bbUrl['root'].'topicmanager.php?mode=lock&amp;topic_id='.$topic_id.'&amp;forum='.$forum.'"><img src="'.$bbImage['locktopic'].'" alt="'._MD_LOCKTOPIC.'" /></a>');
-        } else {
-            // yup, it is..
-            $xoopsTpl->assign('topic_lock_image', '<a href="'.$bbUrl['root'].'topicmanager.php?mode=unlock&amp;topic_id='.$topic_id.'&amp;forum='.$forum.'"><img src="'.$bbImage['unlocktopic'].'" alt="'._MD_UNLOCKTOPIC.'" /></a>');
-        }
-        $xoopsTpl->assign('topic_move_image', '<a href="'.$bbUrl['root'].'topicmanager.php?mode=move&amp;topic_id='.$topic_id.'&amp;forum='.$forum.'"><img src="'.$bbImage['movetopic'].'" alt="'._MD_MOVETOPIC.'" /></a>');
-        $xoopsTpl->assign('topic_delete_image', '<a href="'.$bbUrl['root'].'topicmanager.php?mode=del&amp;topic_id='.$topic_id.'&amp;forum='.$forum.'"><img src="'.$bbImage['deltopic'].'" alt="'._MD_DELETETOPIC.'" /></a>');
-        // is the topic sticky?
-        if ( $forumdata['topic_sticky'] != 1 ) {
-            // nope, not yet..
-            $xoopsTpl->assign('topic_sticky_image', '<a href="'.$bbUrl['root'].'topicmanager.php?mode=sticky&amp;topic_id='.$topic_id.'&amp;forum='.$forum.'"><img src="'.$bbImage['sticky'].'" alt="'._MD_STICKYTOPIC.'" /></a>');
-        } else {
-            // yup it is sticking..
-            $xoopsTpl->assign('topic_sticky_image', '<a href="'.$bbUrl['root'].'topicmanager.php?mode=unsticky&amp;topic_id='.$topic_id.'&amp;forum='.$forum.'"><img src="'.$bbImage['unsticky'].'" alt="'._MD_UNSTICKYTOPIC.'" /></a>');
-        }
-        // need to set this also
-        $xoopsTpl->assign('viewer_is_admin', true);
-    } else {
-        // nope, the user is not a forum admin..
-        $xoopsTpl->assign('viewer_is_admin', false);
-    }
-} else {
-    // nope, the user is not a forum admin, not even registered
-    $xoopsTpl->assign(array('viewer_is_admin' => false, 'viewer_userid' => 0));
-}
-
-function showTree(&$arr, $current=0, $key=0, $prefix='', $foundusers=array()){
-    global $xoopsConfig;
-    if ($key != 0) {
-        if ( 0 != $arr[$key]['obj']->uid() ) {
-            if (!isset($foundusers[$arr[$key]['obj']->uid()])) {
-                $eachposter = new XoopsUser($arr[$key]['obj']->uid());
-                $foundusers[$arr[$key]['obj']->uid()] =& $eachposter;
-            } else {
-                $eachposter =& $foundusers[$arr[$key]['obj']->uid()];
-            }
-            $poster_rank = $eachposter->rank();
-            if ( $poster_rank['image'] != '' ) {
-                $poster_rank['image'] = '<img src="'.XOOPS_UPLOAD_URL.'/'.$poster_rank['image'].'" alt="" />';
-            }
-            if ( $eachposter->isActive() ) {
-                $posterarr =  array('poster_uid' => $eachposter->getVar('uid'), 'poster_uname' => '<a href="'.XOOPS_URL.'/userinfo.php?uid='.$eachposter->getVar('uid').'">'.$eachposter->getVar('uname').'</a>');
-            } else {
-                $posterarr = array('poster_uid' =>0, 'poster_uname' => $xoopsConfig['anonymous']);
-            }
-        } else {
-            $posterarr = array('poster_uid' =>0, 'poster_uname' => $xoopsConfig['anonymous']);
-        }
-        $posticon = $arr[$key]['obj']->icon();
-        if ( isset($posticon) && $posticon != '' ) {
-            $post_image = '<img src="'.XOOPS_URL.'/images/subject/'.htmlspecialchars($posticon).'" alt="" />';
-        } else {
-            $post_image =  '<img src="'.XOOPS_URL.'/images/icons/no_posticon.gif" alt="" />';
-        }
-        if ($current != $key) {
-            $subject = '<a href="viewtopic.php?viewmode=thread&amp;topic_id='.$arr[$key]['obj']->topic().'&amp;forum='.$arr[$key]['obj']->forum().'&amp;post_id='.$arr[$key]['obj']->postid().'#'.$arr[$key]['obj']->postid().'">'.$arr[$key]['obj']->subject().'</a>';
-            $GLOBALS['xoopsTpl']->append("topic_trees", array_merge($posterarr, array("post_id" => $arr[$key]['obj']->postid(), "post_parent_id" => $arr[$key]['obj']->parent(), "post_date" => formatTimestamp($arr[$key]['obj']->posttime(), "m"), "post_image" => $post_image, "post_title" => $subject, "post_prefix" => $prefix)));
-        } else {
-            $subject = '<b>'.$arr[$key]['obj']->subject().'</b>';
-            $thisprefix = substr($prefix, 0, -6)."<b>&raquo;</b>";
-            $GLOBALS['xoopsTpl']->append("topic_trees", array_merge($posterarr, array("post_id" => $arr[$key]['obj']->postid(), "post_parent_id" => $arr[$key]['obj']->parent(), "post_date" => formatTimestamp($arr[$key]['obj']->posttime(), "m"), "post_image" => $post_image, "post_title" => $subject, "post_prefix" => $thisprefix)));
-        }
-    }
-    if ( isset($arr[$key]['replies']) && !empty($arr[$key]['replies']) ){
-        $prefix .= "&nbsp;&nbsp;";
-        foreach($arr[$key]['replies'] as $replykey) {
-            $current = ( $current == 0 ) ? $replykey : $current;
-            showTree($arr, $current, $replykey, $prefix, $foundusers);
-        }
-    }
-}
-
-if ($order == 'DESC') {
-    $xoopsTpl->assign(array('order_current' => 'DESC', 'order_other' => 'ASC', 'lang_order_other' => _OLDESTFIRST));
-} else {
-    $xoopsTpl->assign(array('order_current' => 'ASC', 'order_other' => 'DESC', 'lang_order_other' => _NEWESTFIRST));
-}
-
-// initialize the start number of select query
-$start = !empty($_GET['start']) ? intval($_GET['start']) : 0;
-
-$total_posts = get_total_posts($topic_id, 'topic');
-if ($total_posts > 50) {
-    $viewmode ="flat";
-    // hide link to theaded view
-    $xoopsTpl->assign('lang_threaded', "" );
-    $xoopsTpl->assign('lang_flat', _FLAT );
-} else {
-    $xoopsTpl->assign(array('lang_threaded' => _THREADED, 'lang_flat' => _FLAT));
-}
-
-if ( $can_post == 1 ) {
-    $xoopsTpl->assign(array('viewer_can_post' => true, 'forum_post_or_register' => "<a href=\"newtopic.php?forum=".$forum."\"><img src=\"".$bbImage['post']."\" alt=\""._MD_POSTNEW."\" /></a>"));
-} else {
-    $xoopsTpl->assign('viewer_can_post', false);
-    if ( $show_reg == 1 ) {
-        $xoopsTpl->assign('forum_post_or_register', '<a href="'.XOOPS_URL.'/user.php?xoops_redirect='.htmlspecialchars($xoopsRequestUri).'">'._MD_REGTOPOST.'</a>');
-    } else {
-        $xoopsTpl->assign('forum_post_or_register', '');
-    }
-}
-
-if ( $viewmode == "thread" ) {
-    $start = 0;
-    $postsArray = ForumPosts::getAllPosts($topic_id, "ASC", $total_posts, $start);
-    $xoopsTpl->assign('topic_viewmode', 'thread');
-
-    $newObjArr = array();
-    foreach ( $postsArray as $eachpost ) {
-        $key1 = $eachpost->postid();
-        if ( (!empty($post_id) && $post_id == $key1) || ( empty($post_id) && $eachpost->parent() == 0 ) ) {
-            $post_text = $eachpost->text();
-            if ( 0 != $eachpost->uid() ) {
-                $eachposter = new XoopsUser($eachpost->uid());
-                $poster_rank = $eachposter->rank();
-                if ( $poster_rank['image'] != "" ) {
-                    $poster_rank['image'] = "<img src='".XOOPS_UPLOAD_URL."/".$poster_rank['image']."' alt='' />";
-                }
-                if ( $eachposter->isActive() ) {
-                    $poster_status = $eachposter->isOnline() ? _MD_ONLINE : '';
-                    $posterarr =  array('poster_uid' => $eachposter->getVar('uid'), 'poster_uname' => '<a href="'.XOOPS_URL.'/userinfo.php?uid='.$eachposter->getVar('uid').'">'.$eachposter->getVar('uname').'</a>', 'poster_avatar' => $eachposter->getVar('user_avatar'), 'poster_from' => $eachposter->getVar('user_from'), 'poster_regdate' => formatTimestamp($eachposter->getVar('user_regdate'), 's'), 'poster_postnum' => $eachposter->getVar('posts'), 'poster_sendpmtext' => sprintf(_SENDPMTO,$eachposter->getVar('uname')), 'poster_rank_title' => $poster_rank['title'], 'poster_rank_image' => $poster_rank['image'], 'poster_status' => $poster_status);
-                    if ( 1 == $forumdata['allow_sig'] && $eachpost->attachsig() == 1 && $eachposter->attachsig() == 1 ) {
-                        $myts =& MytextSanitizer::getInstance();
-                        $post_text .= "<p><br />----------------<br />". $myts->makeTareaData4Show($eachposter->getVar("user_sig", "N"), 0, 1, 1)."</p>";
-                    }
-                } else {
-                    $posterarr = array('poster_uid' =>0, 'poster_uname' => $xoopsConfig['anonymous'], 'poster_avatar' => '', 'poster_from' => '', 'poster_regdate' => '', 'poster_postnum' => '', 'poster_sendpmtext' => '', 'poster_rank_title' => '', 'poster_rank_image' => '');
-                }
-            } else {
-                $posterarr = array('poster_uid' =>0, 'poster_uname' => $xoopsConfig['anonymous'], 'poster_avatar' => '', 'poster_from' => '', 'poster_regdate' => '', 'poster_postnum' => '', 'poster_sendpmtext' => '', 'poster_rank_title' => '', 'poster_rank_image' => '');
-            }
-            $posticon = $eachpost->icon();
-            if ( isset($posticon) && $posticon != '' ) {
-                $post_image = '<a name="'.$eachpost->postid().'"><img src="'.XOOPS_URL.'/images/subject/'.htmlspecialchars($eachpost->icon()).'" alt="" /></a>';
-            } else {
-                $post_image =  '<a name="'.$eachpost->postid().'"><img src="'.XOOPS_URL.'/images/icons/posticon.gif" alt="" /></a>';
-            }
-            $xoopsTpl->append('topic_posts', array_merge($posterarr, array('post_id' => $eachpost->postid(), 'post_parent_id' => $eachpost->parent(), 'post_date' => formatTimestamp($eachpost->posttime(), 'm'), 'post_poster_ip'=> $eachpost->posterip(), 'post_image' => $post_image, 'post_title' => $eachpost->subject(), 'post_text' => $post_text)));
-        }
-        $newObjArr[$key1]['obj'] = $eachpost;
-        $key2 = $eachpost->parent();
-        $newObjArr[$key2]['replies'][] = $key1;
-        $newObjArr[$key2]['leaf'] = $key1;
-    }
-    showTree($newObjArr, $post_id);
-    $xoopsTpl->assign(array('lang_subject' => _MD_SUBJECT, 'lang_date' => _MD_DATE));
-} else {
-    $xoopsTpl->assign(array('topic_viewmode' => 'flat', 'lang_top' => _MD_TOP, 'lang_subject' => _MD_SUBJECT, 'lang_bottom' => _MD_BOTTOM));
-    $postsArray = ForumPosts::getAllPosts($topic_id, $order, $forumdata['posts_per_page'], $start, $post_id);
-    $foundusers = array();
-    foreach ( $postsArray as $eachpost ) {
-        $post_text = $eachpost->text();
-        if ( 0 != $eachpost->uid() ) {
-            if (!isset($foundusers['user'.$eachpost->uid()])) {
-                $eachposter = new XoopsUser($eachpost->uid());
-                $foundusers['user'.$eachpost->uid()] =& $eachposter;
-            } else {
-                $eachposter =& $foundusers['user'.$eachpost->uid()];
-            }
-            $poster_rank = $eachposter->rank();
-            if ( $poster_rank['image'] != '' ) {
-                $poster_rank['image'] = '<img src="'.XOOPS_UPLOAD_URL.'/'.$poster_rank['image'].'" alt="" />';
-            }
-            if ( $eachposter->isActive() ) {
-                $poster_status = $eachposter->isOnline() ? _MD_ONLINE : '';
-                $posterarr =  array('poster_uid' => $eachposter->getVar('uid'), 'poster_uname' => '<a href="'.XOOPS_URL.'/userinfo.php?uid='.$eachposter->getVar('uid').'">'.$eachposter->getVar('uname').'</a>', 'poster_avatar' => $eachposter->getVar('user_avatar'), 'poster_from' => $eachposter->getVar('user_from'), 'poster_regdate' => formatTimestamp($eachposter->getVar('user_regdate'), 's'), 'poster_postnum' => $eachposter->getVar('posts'), 'poster_sendpmtext' => sprintf(_SENDPMTO,$eachposter->getVar('uname')), 'poster_rank_title' => $poster_rank['title'], 'poster_rank_image' => $poster_rank['image'], 'poster_status' => $poster_status);
-                if ( 1 == $forumdata['allow_sig'] && $eachpost->attachsig() == 1 && $eachposter->attachsig() == 1 ) {
-                    $myts =& MytextSanitizer::getInstance();
-                    $post_text .= '<p><br />----------------<br />'. $myts->makeTareaData4Show($eachposter->getVar('user_sig', 'N'), 0, 1, 1).'</p>';
-                }
-            } else {
-                $posterarr = array('poster_uid' =>0, 'poster_uname' => $xoopsConfig['anonymous'], 'poster_avatar' => '', 'poster_from' => '', 'poster_regdate' => '', 'poster_postnum' => '', 'poster_sendpmtext' => '', 'poster_rank_title' => '', 'poster_rank_image' => '');
-            }
-        } else {
-            $posterarr = array('poster_uid' =>0, 'poster_uname' => $xoopsConfig['anonymous'], 'poster_avatar' => '', 'poster_from' => '', 'poster_regdate' => '', 'poster_postnum' => '', 'poster_sendpmtext' => '', 'poster_rank_title' => '', 'poster_rank_image' => '');
-        }
-        $posticon = $eachpost->icon();
-        if ( isset($posticon) && $posticon != '' ) {
-            $post_image = '<a name="'.$eachpost->postid().'"><img src="'.XOOPS_URL.'/images/subject/'.htmlspecialchars($eachpost->icon()).'" alt="" /></a>';
-        } else {
-            $post_image =  '<a name="'.$eachpost->postid().'"><img src="'.XOOPS_URL.'/images/icons/no_posticon.gif" alt="" /></a>';
-        }
-        $xoopsTpl->append('topic_posts', array_merge($posterarr, array('post_id' => $eachpost->postid(), 'post_parent_id' => $eachpost->parent(), 'post_date' => formatTimestamp($eachpost->posttime(), 'm'), 'post_poster_ip'=> $eachpost->posterip(), 'post_image' => $post_image, 'post_title' => $eachpost->subject(), 'post_text' => $post_text)));
-        unset($eachposter);
-    }
-    if ( $total_posts > $forumdata['posts_per_page'] ) {
-        include XOOPS_ROOT_PATH.'/class/pagenav.php';
-        $nav = new XoopsPageNav($total_posts, $forumdata['posts_per_page'], $start, "start", 'topic_id='.$topic_id.'&amp;forum='.$forum.'&amp;viewmode='.$viewmode.'&amp;order='.$order);
-        $xoopsTpl->assign('forum_page_nav', $nav->renderNav(4));
-    } else {
-        $xoopsTpl->assign('forum_page_nav', '');
-    }
-}
-
-// create jump box
-$xoopsTpl->assign(array('forum_jumpbox' => make_jumpbox($forum), 'lang_forum_index' => sprintf(_MD_FORUMINDEX,$xoopsConfig['sitename']), 'lang_from' => _MD_FROM, 'lang_joined' => _MD_JOINED, 'lang_posts' => _MD_POSTS, 'lang_poster' => _MD_POSTER, 'lang_thread' => _MD_THREAD, 'lang_edit' => _EDIT, 'lang_delete' => _DELETE, 'lang_reply' => _REPLY, 'lang_postedon' => _MD_POSTEDON));
-
-// Read in cookie of 'lastread' times
-$topic_lastread = newbb_get_topics_viewed();
-// if cookie is not set for this topic, update view count and set cookie
-if ( empty($topic_lastread[$topic_id]) ) {
-    $sql = 'UPDATE '.$xoopsDB->prefix('bb_topics').' SET topic_views = topic_views + 1 WHERE topic_id ='. $topic_id;
-    $xoopsDB->queryF($sql);
-}
-// Update cookie
-newbb_add_topics_viewed($topic_lastread, $topic_id, time(), $bbCookie['path'], $bbCookie['domain'], $bbCookie['secure']);
-include XOOPS_ROOT_PATH.'/footer.php';
-?>
+<?php
+// $Id: viewtopic.php,v 1.6 2006/05/01 02:37:28 onokazu Exp $
+//  ------------------------------------------------------------------------ //
+//                XOOPS - PHP Content Management System                      //
+//                    Copyright (c) 2000 XOOPS.org                           //
+//                       <http://www.xoops.org/>                             //
+//  ------------------------------------------------------------------------ //
+//  This program is free software; you can redistribute it and/or modify     //
+//  it under the terms of the GNU General Public License as published by     //
+//  the Free Software Foundation; either version 2 of the License, or        //
+//  (at your option) any later version.                                      //
+//                                                                           //
+//  You may not change or alter any portion of this comment or credits       //
+//  of supporting developers from this source code or any supporting         //
+//  source code which is considered copyrighted (c) material of the          //
+//  original comment or credit authors.                                      //
+//                                                                           //
+//  This program is distributed in the hope that it will be useful,          //
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
+//  GNU General Public License for more details.                             //
+//                                                                           //
+//  You should have received a copy of the GNU General Public License        //
+//  along with this program; if not, write to the Free Software              //
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
+//  ------------------------------------------------------------------------ //
+// Author: Kazumi Ono (AKA onokazu)                                          //
+// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ //
+// Project: The XOOPS Project                                                //
+// ------------------------------------------------------------------------- //
+
+include 'header.php';
+$forum = isset($_GET['forum']) ? intval($_GET['forum']) : 0;
+$topic_id = isset($_GET['topic_id']) ? intval($_GET['topic_id']) : 0;
+if ( empty($forum) ) {
+    redirect_header(XOOPS_URL."/modules/".$xoopsModule->getVar('dirname')."/index.php",2,_MD_ERRORFORUM);
+    exit();
+} elseif ( empty($topic_id) ) {
+    redirect_header('viewforum.php?forum='.$forum,2,_MD_ERRORTOPIC);
+    exit();
+}
+$topic_time = (isset($_GET['topic_time'])) ? intval($_GET['topic_time']) : 0;
+$post_id = !empty($_GET['post_id']) ? intval($_GET['post_id']) : 0;
+
+//use users preferences
+if (is_object($xoopsUser)) {
+    $viewmode = $xoopsUser->getVar('umode');
+    $order = ($xoopsUser->getVar('uorder') == 1) ? 'DESC' : 'ASC';
+} else {
+    $viewmode = 'flat';
+    $order = 'ASC';
+}
+
+// newbb does not have nested mode
+if ($viewmode == 'nest') {
+    $viewmode = 'thread';
+}
+
+// override mode/order if any requested
+if (isset($_GET['viewmode']) && ($_GET['viewmode'] == 'flat' || $_GET['viewmode'] == 'thread')) {
+    $viewmode = $_GET['viewmode'];
+}
+if (isset($_GET['order']) && ($_GET['order'] == 'ASC' || $_GET['order'] == 'DESC')) {
+    $order = $_GET['order'];
+}
+
+if ($viewmode != 'flat') {
+    $xoopsOption['template_main'] =  'newbb_viewtopic_thread.html';
+} else {
+    $xoopsOption['template_main'] =  'newbb_viewtopic_flat.html';
+}
+
+include XOOPS_ROOT_PATH.'/header.php';
+include_once 'class/class.forumposts.php';
+
+if ( isset($_GET['move']) && 'next' == $_GET['move'] ) {
+    $sql = 'SELECT t.topic_id, t.topic_title, t.topic_time, t.topic_status, t.topic_sticky, t.topic_last_post_id, f.forum_id, f.forum_name, f.forum_access, f.forum_type, f.allow_html, f.allow_sig, f.posts_per_page, f.hot_threshold, f.topics_per_page FROM '.$xoopsDB->prefix('bb_topics').' t LEFT JOIN '.$xoopsDB->prefix('bb_forums').' f ON f.forum_id = t.forum_id WHERE t.topic_time > '.$topic_time.' AND t.forum_id = '.$forum.' ORDER BY t.topic_time ASC LIMIT 1';
+} elseif ( isset($_GET['move']) && 'prev' == $_GET['move']) {
+    $sql = 'SELECT t.topic_id, t.topic_title, t.topic_time, t.topic_status, t.topic_sticky, t.topic_last_post_id, f.forum_id, f.forum_name, f.forum_access, f.forum_type, f.allow_html, f.allow_sig, f.posts_per_page, f.hot_threshold, f.topics_per_page FROM '.$xoopsDB->prefix('bb_topics').' t LEFT JOIN '.$xoopsDB->prefix('bb_forums').' f ON f.forum_id = t.forum_id WHERE t.topic_time < '.$topic_time.' AND t.forum_id = '.$forum.' ORDER BY t.topic_time DESC LIMIT 1';
+} else {
+    $sql = 'SELECT t.topic_id, t.topic_title, t.topic_time, t.topic_status, t.topic_sticky, t.topic_last_post_id, f.forum_id, f.forum_name, f.forum_access, f.forum_type, f.allow_html, f.allow_sig, f.posts_per_page, f.hot_threshold, f.topics_per_page FROM '.$xoopsDB->prefix('bb_topics').' t LEFT JOIN '.$xoopsDB->prefix('bb_forums').' f ON f.forum_id = t.forum_id WHERE t.topic_id = '.$topic_id.' AND t.forum_id = '.$forum;
+}
+
+if ( !$result = $xoopsDB->query($sql) ) {
+    redirect_header('viewforum.php?forum='.$forum,2,_MD_ERROROCCURED);
+    exit();
+}
+
+if ( !$forumdata = $xoopsDB->fetchArray($result) ) {
+    redirect_header('viewforum.php?forum='.$forum,2,_MD_FORUMNOEXIST);
+    exit();
+}
+$xoopsTpl->assign('topic_id', $forumdata['topic_id']);
+$topic_id = $forumdata['topic_id'];
+$xoopsTpl->assign('forum_id', $forumdata['forum_id']);
+$forum = $forumdata['forum_id'];
+$can_post = 0;
+$show_reg = 0;
+if ( $forumdata['forum_type'] == 1 ) {
+    // this is a private forum.
+    $accesserror = 0;
+    if ( $xoopsUser ) {
+        if ( !$xoopsUser->isAdmin($xoopsModule->mid()) ) {
+            if ( !check_priv_forum_auth($xoopsUser->getVar('uid'), $forum, false) ) {
+                $accesserror = 1;
+            }
+        } else {
+            $isadminormod = 1;
+        }
+    } else {
+        $accesserror = 1;
+    }
+    if ( $accesserror == 1 ) {
+        redirect_header(XOOPS_URL."/modules/".$xoopsModule->getVar('dirname')."/index.php",2,_MD_NORIGHTTOACCESS);
+        exit();
+    }
+    $can_post = 1;
+    $show_reg = 1;
+} else {
+    // this is not a priv forum
+    if ( $forumdata['forum_access'] == 1 ) {
+        // this is a reg user only forum
+        if ( $xoopsUser ) {
+            $can_post = 1;
+        } else {
+            $show_reg = 1;
+        }
+    } elseif ( $forumdata['forum_access'] == 2 ) {
+        // this is an open forum
+        $can_post = 1;
+    } else {
+        // this is an admin/moderator only forum
+        if ( $xoopsUser ) {
+            if ( $xoopsUser->isAdmin($xoopsModule->mid()) || is_moderator($forum, $xoopsUser->getVar('uid')) ) {
+                $can_post = 1;
+                $isadminormod = 1;
+            }
+        }
+    }
+}
+$myts =& MyTextSanitizer::getInstance();
+$forumdata['topic_title'] = $myts->makeTboxData4Show($forumdata['topic_title']);$forumdata['forum_name'] = $myts->makeTboxData4Show($forumdata['forum_name']);
+$xoopsTpl->assign(array('topic_title' => '<a href="'.$bbUrl['root'].'viewtopic.php?viewmode='.$viewmode.'&amp;topic_id='.$topic_id.'&amp;forum='.$forum.'">'.$forumdata['topic_title'].'</a>', 'forum_name' => $forumdata['forum_name'], 'topic_time' => $forumdata['topic_time'], 'lang_nexttopic' => _MD_NEXTTOPIC, 'lang_prevtopic' => _MD_PREVTOPIC));
+
+// add image links to admin page if the user viewing this page is a forum admin
+if ( $xoopsUser ) {
+    $xoopsTpl->assign('viewer_userid', $xoopsUser->getVar('uid'));
+    if ( !empty($isadminormod) || $xoopsUser->isAdmin($xoopsModule->mid()) || is_moderator( $forum, $xoopsUser->getVar('uid')) ) {
+        // yup, the user is admin
+        // the forum is locked?
+        if ( $forumdata['topic_status'] != 1 ) {
+            // nope
+            $xoopsTpl->assign('topic_lock_image', '<a href="'.$bbUrl['root'].'topicmanager.php?mode=lock&amp;topic_id='.$topic_id.'&amp;forum='.$forum.'"><img src="'.$bbImage['locktopic'].'" alt="'._MD_LOCKTOPIC.'" /></a>');
+        } else {
+            // yup, it is..
+            $xoopsTpl->assign('topic_lock_image', '<a href="'.$bbUrl['root'].'topicmanager.php?mode=unlock&amp;topic_id='.$topic_id.'&amp;forum='.$forum.'"><img src="'.$bbImage['unlocktopic'].'" alt="'._MD_UNLOCKTOPIC.'" /></a>');
+        }
+        $xoopsTpl->assign('topic_move_image', '<a href="'.$bbUrl['root'].'topicmanager.php?mode=move&amp;topic_id='.$topic_id.'&amp;forum='.$forum.'"><img src="'.$bbImage['movetopic'].'" alt="'._MD_MOVETOPIC.'" /></a>');
+        $xoopsTpl->assign('topic_delete_image', '<a href="'.$bbUrl['root'].'topicmanager.php?mode=del&amp;topic_id='.$topic_id.'&amp;forum='.$forum.'"><img src="'.$bbImage['deltopic'].'" alt="'._MD_DELETETOPIC.'" /></a>');
+        // is the topic sticky?
+        if ( $forumdata['topic_sticky'] != 1 ) {
+            // nope, not yet..
+            $xoopsTpl->assign('topic_sticky_image', '<a href="'.$bbUrl['root'].'topicmanager.php?mode=sticky&amp;topic_id='.$topic_id.'&amp;forum='.$forum.'"><img src="'.$bbImage['sticky'].'" alt="'._MD_STICKYTOPIC.'" /></a>');
+        } else {
+            // yup it is sticking..
+            $xoopsTpl->assign('topic_sticky_image', '<a href="'.$bbUrl['root'].'topicmanager.php?mode=unsticky&amp;topic_id='.$topic_id.'&amp;forum='.$forum.'"><img src="'.$bbImage['unsticky'].'" alt="'._MD_UNSTICKYTOPIC.'" /></a>');
+        }
+        // need to set this also
+        $xoopsTpl->assign('viewer_is_admin', true);
+    } else {
+        // nope, the user is not a forum admin..
+        $xoopsTpl->assign('viewer_is_admin', false);
+    }
+} else {
+    // nope, the user is not a forum admin, not even registered
+    $xoopsTpl->assign(array('viewer_is_admin' => false, 'viewer_userid' => 0));
+}
+
+function showTree(&$arr, $current=0, $key=0, $prefix='', $foundusers=array()){
+    global $xoopsConfig;
+    if ($key != 0) {
+        if ( 0 != $arr[$key]['obj']->uid() ) {
+            if (!isset($foundusers[$arr[$key]['obj']->uid()])) {
+                $eachposter = new XoopsUser($arr[$key]['obj']->uid());
+                $foundusers[$arr[$key]['obj']->uid()] =& $eachposter;
+            } else {
+                $eachposter =& $foundusers[$arr[$key]['obj']->uid()];
+            }
+            $poster_rank = $eachposter->rank();
+            if ( $poster_rank['image'] != '' ) {
+                $poster_rank['image'] = '<img src="'.XOOPS_UPLOAD_URL.'/'.$poster_rank['image'].'" alt="" />';
+            }
+            if ( $eachposter->isActive() ) {
+                $posterarr =  array('poster_uid' => $eachposter->getVar('uid'), 'poster_uname' => '<a href="'.XOOPS_URL.'/userinfo.php?uid='.$eachposter->getVar('uid').'">'.$eachposter->getVar('uname').'</a>');
+            } else {
+                $posterarr = array('poster_uid' =>0, 'poster_uname' => $xoopsConfig['anonymous']);
+            }
+        } else {
+            $posterarr = array('poster_uid' =>0, 'poster_uname' => $xoopsConfig['anonymous']);
+        }
+        $posticon = $arr[$key]['obj']->icon();
+        if ( isset($posticon) && $posticon != '' ) {
+            $post_image = '<img src="'.XOOPS_URL.'/images/subject/'.htmlspecialchars($posticon).'" alt="" />';
+        } else {
+            $post_image =  '<img src="'.XOOPS_URL.'/images/icons/no_posticon.gif" alt="" />';
+        }
+        if ($current != $key) {
+            $subject = '<a href="viewtopic.php?viewmode=thread&amp;topic_id='.$arr[$key]['obj']->topic().'&amp;forum='.$arr[$key]['obj']->forum().'&amp;post_id='.$arr[$key]['obj']->postid().'#forumpost'.$arr[$key]['obj']->postid().'">'.$arr[$key]['obj']->subject().'</a>';
+            $GLOBALS['xoopsTpl']->append("topic_trees", array_merge($posterarr, array("post_id" => $arr[$key]['obj']->postid(), "post_parent_id" => $arr[$key]['obj']->parent(), "post_date" => formatTimestamp($arr[$key]['obj']->posttime(), "m"), "post_image" => $post_image, "post_title" => $subject, "post_prefix" => $prefix)));
+        } else {
+            $subject = '<b>'.$arr[$key]['obj']->subject().'</b>';
+            $thisprefix = substr($prefix, 0, -6)."<b>&raquo;</b>";
+            $GLOBALS['xoopsTpl']->append("topic_trees", array_merge($posterarr, array("post_id" => $arr[$key]['obj']->postid(), "post_parent_id" => $arr[$key]['obj']->parent(), "post_date" => formatTimestamp($arr[$key]['obj']->posttime(), "m"), "post_image" => $post_image, "post_title" => $subject, "post_prefix" => $thisprefix)));
+        }
+    }
+    if ( isset($arr[$key]['replies']) && !empty($arr[$key]['replies']) ){
+        $prefix .= "&nbsp;&nbsp;";
+        foreach($arr[$key]['replies'] as $replykey) {
+            $current = ( $current == 0 ) ? $replykey : $current;
+            showTree($arr, $current, $replykey, $prefix, $foundusers);
+        }
+    }
+}
+
+if ($order == 'DESC') {
+    $xoopsTpl->assign(array('order_current' => 'DESC', 'order_other' => 'ASC', 'lang_order_other' => _OLDESTFIRST));
+} else {
+    $xoopsTpl->assign(array('order_current' => 'ASC', 'order_other' => 'DESC', 'lang_order_other' => _NEWESTFIRST));
+}
+
+// initialize the start number of select query
+$start = !empty($_GET['start']) ? intval($_GET['start']) : 0;
+
+$total_posts = get_total_posts($topic_id, 'topic');
+if ($total_posts > 50) {
+    $viewmode ="flat";
+    // hide link to theaded view
+    $xoopsTpl->assign('lang_threaded', "" );
+    $xoopsTpl->assign('lang_flat', _FLAT );
+} else {
+    $xoopsTpl->assign(array('lang_threaded' => _THREADED, 'lang_flat' => _FLAT));
+}
+
+if ( $can_post == 1 ) {
+    $xoopsTpl->assign(array('viewer_can_post' => true, 'forum_post_or_register' => "<a href=\"newtopic.php?forum=".$forum."\"><img src=\"".$bbImage['post']."\" alt=\""._MD_POSTNEW."\" /></a>"));
+} else {
+    $xoopsTpl->assign('viewer_can_post', false);
+    if ( $show_reg == 1 ) {
+        $xoopsTpl->assign('forum_post_or_register', '<a href="'.XOOPS_URL.'/user.php?xoops_redirect='.htmlspecialchars($xoopsRequestUri).'">'._MD_REGTOPOST.'</a>');
+    } else {
+        $xoopsTpl->assign('forum_post_or_register', '');
+    }
+}
+
+if ( $viewmode == "thread" ) {
+    $start = 0;
+    $postsArray = ForumPosts::getAllPosts($topic_id, "ASC", $total_posts, $start);
+    $xoopsTpl->assign('topic_viewmode', 'thread');
+
+    $newObjArr = array();
+    foreach ( $postsArray as $eachpost ) {
+        $key1 = $eachpost->postid();
+        if ( (!empty($post_id) && $post_id == $key1) || ( empty($post_id) && $eachpost->parent() == 0 ) ) {
+            $post_text = $eachpost->text();
+            if ( 0 != $eachpost->uid() ) {
+                $eachposter = new XoopsUser($eachpost->uid());
+                $poster_rank = $eachposter->rank();
+                if ( $poster_rank['image'] != "" ) {
+                    $poster_rank['image'] = "<img src='".XOOPS_UPLOAD_URL."/".$poster_rank['image']."' alt='' />";
+                }
+                if ( $eachposter->isActive() ) {
+                    $poster_status = $eachposter->isOnline() ? _MD_ONLINE : '';
+                    $posterarr =  array('poster_uid' => $eachposter->getVar('uid'), 'poster_uname' => '<a href="'.XOOPS_URL.'/userinfo.php?uid='.$eachposter->getVar('uid').'">'.$eachposter->getVar('uname').'</a>', 'poster_avatar' => $eachposter->getVar('user_avatar'), 'poster_from' => $eachposter->getVar('user_from'), 'poster_regdate' => formatTimestamp($eachposter->getVar('user_regdate'), 's'), 'poster_postnum' => $eachposter->getVar('posts'), 'poster_sendpmtext' => sprintf(_SENDPMTO,$eachposter->getVar('uname')), 'poster_rank_title' => $poster_rank['title'], 'poster_rank_image' => $poster_rank['image'], 'poster_status' => $poster_status);
+                    if ( 1 == $forumdata['allow_sig'] && $eachpost->attachsig() == 1 && $eachposter->attachsig() == 1 ) {
+                        $myts =& MytextSanitizer::getInstance();
+                        $post_text .= "<p><br />----------------<br />". $myts->makeTareaData4Show($eachposter->getVar("user_sig", "N"), 0, 1, 1)."</p>";
+                    }
+                } else {
+                    $posterarr = array('poster_uid' =>0, 'poster_uname' => $xoopsConfig['anonymous'], 'poster_avatar' => '', 'poster_from' => '', 'poster_regdate' => '', 'poster_postnum' => '', 'poster_sendpmtext' => '', 'poster_rank_title' => '', 'poster_rank_image' => '');
+                }
+            } else {
+                $posterarr = array('poster_uid' =>0, 'poster_uname' => $xoopsConfig['anonymous'], 'poster_avatar' => '', 'poster_from' => '', 'poster_regdate' => '', 'poster_postnum' => '', 'poster_sendpmtext' => '', 'poster_rank_title' => '', 'poster_rank_image' => '');
+            }
+            $posticon = $eachpost->icon();
+            if ( isset($posticon) && $posticon != '' ) {
+                $post_image = '<a name="'.$eachpost->postid().'"><img src="'.XOOPS_URL.'/images/subject/'.htmlspecialchars($eachpost->icon()).'" alt="" /></a>';
+            } else {
+                $post_image =  '<a name="'.$eachpost->postid().'"><img src="'.XOOPS_URL.'/images/icons/posticon.gif" alt="" /></a>';
+            }
+            $xoopsTpl->append('topic_posts', array_merge($posterarr, array('post_id' => $eachpost->postid(), 'post_parent_id' => $eachpost->parent(), 'post_date' => formatTimestamp($eachpost->posttime(), 'm'), 'post_poster_ip'=> $eachpost->posterip(), 'post_image' => $post_image, 'post_title' => $eachpost->subject(), 'post_text' => $post_text)));
+        }
+        $newObjArr[$key1]['obj'] = $eachpost;
+        $key2 = $eachpost->parent();
+        $newObjArr[$key2]['replies'][] = $key1;
+        $newObjArr[$key2]['leaf'] = $key1;
+    }
+    showTree($newObjArr, $post_id);
+    $xoopsTpl->assign(array('lang_subject' => _MD_SUBJECT, 'lang_date' => _MD_DATE));
+} else {
+    $xoopsTpl->assign(array('topic_viewmode' => 'flat', 'lang_top' => _MD_TOP, 'lang_subject' => _MD_SUBJECT, 'lang_bottom' => _MD_BOTTOM));
+    $postsArray = ForumPosts::getAllPosts($topic_id, $order, $forumdata['posts_per_page'], $start, $post_id);
+    $foundusers = array();
+    foreach ( $postsArray as $eachpost ) {
+        $post_text = $eachpost->text();
+        if ( 0 != $eachpost->uid() ) {
+            if (!isset($foundusers['user'.$eachpost->uid()])) {
+                $eachposter = new XoopsUser($eachpost->uid());
+                $foundusers['user'.$eachpost->uid()] =& $eachposter;
+            } else {
+                $eachposter =& $foundusers['user'.$eachpost->uid()];
+            }
+            $poster_rank = $eachposter->rank();
+            if ( $poster_rank['image'] != '' ) {
+                $poster_rank['image'] = '<img src="'.XOOPS_UPLOAD_URL.'/'.$poster_rank['image'].'" alt="" />';
+            }
+            if ( $eachposter->isActive() ) {
+                $poster_status = $eachposter->isOnline() ? _MD_ONLINE : '';
+                $posterarr =  array('poster_uid' => $eachposter->getVar('uid'), 'poster_uname' => '<a href="'.XOOPS_URL.'/userinfo.php?uid='.$eachposter->getVar('uid').'">'.$eachposter->getVar('uname').'</a>', 'poster_avatar' => $eachposter->getVar('user_avatar'), 'poster_from' => $eachposter->getVar('user_from'), 'poster_regdate' => formatTimestamp($eachposter->getVar('user_regdate'), 's'), 'poster_postnum' => $eachposter->getVar('posts'), 'poster_sendpmtext' => sprintf(_SENDPMTO,$eachposter->getVar('uname')), 'poster_rank_title' => $poster_rank['title'], 'poster_rank_image' => $poster_rank['image'], 'poster_status' => $poster_status);
+                if ( 1 == $forumdata['allow_sig'] && $eachpost->attachsig() == 1 && $eachposter->attachsig() == 1 ) {
+                    $myts =& MytextSanitizer::getInstance();
+                    $post_text .= '<p><br />----------------<br />'. $myts->makeTareaData4Show($eachposter->getVar('user_sig', 'N'), 0, 1, 1).'</p>';
+                }
+            } else {
+                $posterarr = array('poster_uid' =>0, 'poster_uname' => $xoopsConfig['anonymous'], 'poster_avatar' => '', 'poster_from' => '', 'poster_regdate' => '', 'poster_postnum' => '', 'poster_sendpmtext' => '', 'poster_rank_title' => '', 'poster_rank_image' => '');
+            }
+        } else {
+            $posterarr = array('poster_uid' =>0, 'poster_uname' => $xoopsConfig['anonymous'], 'poster_avatar' => '', 'poster_from' => '', 'poster_regdate' => '', 'poster_postnum' => '', 'poster_sendpmtext' => '', 'poster_rank_title' => '', 'poster_rank_image' => '');
+        }
+        $posticon = $eachpost->icon();
+        if ( isset($posticon) && $posticon != '' ) {
+            $post_image = '<a name="'.$eachpost->postid().'"><img src="'.XOOPS_URL.'/images/subject/'.htmlspecialchars($eachpost->icon()).'" alt="" /></a>';
+        } else {
+            $post_image =  '<a name="'.$eachpost->postid().'"><img src="'.XOOPS_URL.'/images/icons/no_posticon.gif" alt="" /></a>';
+        }
+        $xoopsTpl->append('topic_posts', array_merge($posterarr, array('post_id' => $eachpost->postid(), 'post_parent_id' => $eachpost->parent(), 'post_date' => formatTimestamp($eachpost->posttime(), 'm'), 'post_poster_ip'=> $eachpost->posterip(), 'post_image' => $post_image, 'post_title' => $eachpost->subject(), 'post_text' => $post_text)));
+        unset($eachposter);
+    }
+    if ( $total_posts > $forumdata['posts_per_page'] ) {
+        include XOOPS_ROOT_PATH.'/class/pagenav.php';
+        $nav = new XoopsPageNav($total_posts, $forumdata['posts_per_page'], $start, "start", 'topic_id='.$topic_id.'&amp;forum='.$forum.'&amp;viewmode='.$viewmode.'&amp;order='.$order);
+        $xoopsTpl->assign('forum_page_nav', $nav->renderNav(4));
+    } else {
+        $xoopsTpl->assign('forum_page_nav', '');
+    }
+}
+
+// create jump box
+$xoopsTpl->assign(array('forum_jumpbox' => make_jumpbox($forum), 'lang_forum_index' => sprintf(_MD_FORUMINDEX,$xoopsConfig['sitename']), 'lang_from' => _MD_FROM, 'lang_joined' => _MD_JOINED, 'lang_posts' => _MD_POSTS, 'lang_poster' => _MD_POSTER, 'lang_thread' => _MD_THREAD, 'lang_edit' => _EDIT, 'lang_delete' => _DELETE, 'lang_reply' => _REPLY, 'lang_postedon' => _MD_POSTEDON));
+
+// Read in cookie of 'lastread' times
+$topic_lastread = newbb_get_topics_viewed();
+// if cookie is not set for this topic, update view count and set cookie
+if ( empty($topic_lastread[$topic_id]) ) {
+    $sql = 'UPDATE '.$xoopsDB->prefix('bb_topics').' SET topic_views = topic_views + 1 WHERE topic_id ='. $topic_id;
+    $xoopsDB->queryF($sql);
+}
+// Update cookie
+newbb_add_topics_viewed($topic_lastread, $topic_id, time(), $bbCookie['path'], $bbCookie['domain'], $bbCookie['secure']);
+include XOOPS_ROOT_PATH.'/footer.php';
+?>


xoops-cvslog メーリングリストの案内
Back to archive index