source: temp/test-xoops.ec-cube.net/html/modules/newbb/index.php @ 405

Revision 405, 9.2 KB checked in by root, 20 years ago (diff)
Line 
1<?php
2// $Id: index.php,v 1.8 2006/05/01 02:37:28 onokazu Exp $
3//  ------------------------------------------------------------------------ //
4//                XOOPS - PHP Content Management System                      //
5//                    Copyright (c) 2000 XOOPS.org                           //
6//                       <http://www.xoops.org/>                             //
7//  ------------------------------------------------------------------------ //
8//  This program is free software; you can redistribute it and/or modify     //
9//  it under the terms of the GNU General Public License as published by     //
10//  the Free Software Foundation; either version 2 of the License, or        //
11//  (at your option) any later version.                                      //
12//                                                                           //
13//  You may not change or alter any portion of this comment or credits       //
14//  of supporting developers from this source code or any supporting         //
15//  source code which is considered copyrighted (c) material of the          //
16//  original comment or credit authors.                                      //
17//                                                                           //
18//  This program is distributed in the hope that it will be useful,          //
19//  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
20//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
21//  GNU General Public License for more details.                             //
22//                                                                           //
23//  You should have received a copy of the GNU General Public License        //
24//  along with this program; if not, write to the Free Software              //
25//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
26//  ------------------------------------------------------------------------ //
27// Author: Kazumi Ono (AKA onokazu)                                          //
28// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ //
29// Project: The XOOPS Project                                                //
30// ------------------------------------------------------------------------- //
31
32include "header.php";
33// this page uses smarty template
34// this must be set before including main header.php
35$xoopsOption['template_main']= 'newbb_index.html';
36include XOOPS_ROOT_PATH."/header.php";
37
38$myts =& MyTextSanitizer::getInstance();
39
40$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';
41if ( !$result = $xoopsDB->query($sql) ) {
42    redirect_header(XOOPS_URL.'/',1,_MD_ERROROCCURED);
43    exit();
44}
45
46$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));
47
48$viewcat = (!empty($_GET['cat'])) ? intval($_GET['cat']) : 0;
49$categories = array();
50while ( $cat_row = $xoopsDB->fetchArray($result) ) {
51    $categories[] = $cat_row;
52}
53
54$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';
55if ( $viewcat != 0 ) {
56    $sql .= ' WHERE f.cat_id = '.$viewcat;
57    $xoopsTpl->assign('forum_index_title', sprintf(_MD_FORUMINDEX,htmlspecialchars($xoopsConfig['sitename'], ENT_QUOTES)));
58} else {
59    $xoopsTpl->assign('forum_index_title', '');
60}
61$sql .= ' ORDER BY f.cat_id, f.forum_id desc';
62if ( !$result = $xoopsDB->query($sql) ) {
63    exit("Error");
64}
65$forums = array(); // RMV-FIX
66while ( $forum_data = $xoopsDB->fetchArray($result) ) {
67    $forums[] = $forum_data;
68}
69$cat_count = count($categories);
70if ($cat_count > 0) {
71    for ( $i = 0; $i < $cat_count; $i++ ) {
72        $categories[$i]['cat_title'] = $myts->makeTboxData4Show($categories[$i]['cat_title']);
73        if ( $viewcat != 0 && $categories[$i]['cat_id'] != $viewcat ) {
74            $xoopsTpl->append("categories", $categories[$i]);
75            continue;
76        }
77        $topic_lastread = newbb_get_topics_viewed();
78        foreach ( $forums as $forum_row ) {
79            unset($last_post);
80            if ( $forum_row['cat_id'] == $categories[$i]['cat_id'] ) {
81                if ($forum_row['post_time']) {
82                    //$forum_row['subject'] = $myts->makeTboxData4Show($forum_row['subject']);
83                    $categories[$i]['forums']['forum_lastpost_time'][] = formatTimestamp($forum_row['post_time']);
84                    $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'].'">';
85                    if ( $forum_row['icon'] ) {
86                        $last_post_icon .= '<img src="'.XOOPS_URL.'/images/subject/'.htmlspecialchars($forum_row['icon']).'" border="0" alt="" />';
87                    } else {
88                        $last_post_icon .= '<img src="'.XOOPS_URL.'/images/subject/icon1.gif" width="15" height="15" border="0" alt="" />';
89                    }
90                    $last_post_icon .= '</a>';
91                    $categories[$i]['forums']['forum_lastpost_icon'][] = $last_post_icon;
92                    if ( $forum_row['uid'] != 0 && $forum_row['uname'] ){
93                        $categories[$i]['forums']['forum_lastpost_user'][] = '<a href="'.XOOPS_URL.'/userinfo.php?uid='.$forum_row['uid'].'">' . $myts->makeTboxData4Show($forum_row['uname']).'</a>';
94                    } else {
95                        $categories[$i]['forums']['forum_lastpost_user'][] = $xoopsConfig['anonymous'];
96                    }
97                    $forum_lastread = !empty($topic_lastread[$forum_row['topic_id']]) ? $topic_lastread[$forum_row['topic_id']] : false;
98                    if ( $forum_row['forum_type'] == 1 ) {
99                        $categories[$i]['forums']['forum_folder'][] = $bbImage['locked_forum'];
100                    } elseif ( $forum_row['post_time'] > $forum_lastread && !empty($forum_row['topic_id'])) {
101                        $categories[$i]['forums']['forum_folder'][] = $bbImage['newposts_forum'];
102                    } else {
103                        $categories[$i]['forums']['forum_folder'][] = $bbImage['folder_forum'];
104                    }
105                } else {
106                    // no forums, so put empty values
107                    $categories[$i]['forums']['forum_lastpost_time'][] = "";
108                    $categories[$i]['forums']['forum_lastpost_icon'][] = "";
109                    $categories[$i]['forums']['forum_lastpost_user'][] = "";
110                    if ( $forum_row['forum_type'] == 1 ) {
111                        $categories[$i]['forums']['forum_folder'][] = $bbImage['locked_forum'];
112                    } else {
113                        $categories[$i]['forums']['forum_folder'][] = $bbImage['folder_forum'];
114                    }
115                }
116                $categories[$i]['forums']['forum_id'][] = $forum_row['forum_id'];
117                $categories[$i]['forums']['forum_name'][] = $myts->makeTboxData4Show($forum_row['forum_name']);
118                $categories[$i]['forums']['forum_desc'][] = $myts->makeTareaData4Show($forum_row['forum_desc']);
119                $categories[$i]['forums']['forum_topics'][] = $forum_row['forum_topics'];
120                $categories[$i]['forums']['forum_posts'][] = $forum_row['forum_posts'];
121                $all_moderators = get_moderators($forum_row['forum_id']);
122                $count = 0;
123                $forum_moderators = '';
124                foreach ( $all_moderators as $mods) {
125                    foreach ( $mods as $mod_id => $mod_name) {
126                        if ( $count > 0 ) {
127                            $forum_moderators .= ', ';
128                        }
129                        $forum_moderators .= '<a href="'.XOOPS_URL.'/userinfo.php?uid='.$mod_id.'">'.$myts->makeTboxData4Show($mod_name).'</a>';
130                        $count = 1;
131                    }
132                }
133                $categories[$i]['forums']['forum_moderators'][] = $forum_moderators;
134            }
135        }
136        $xoopsTpl->append("categories", $categories[$i]);
137    }
138} else {
139    $xoopsTpl->append("categories", array());
140}
141$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));
142include_once XOOPS_ROOT_PATH.'/footer.php';
143?>
Note: See TracBrowser for help on using the repository browser.