1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
|
<?php
/***************************************************************************
* index.php
* -------------------
* begin : Saturday, Feb 13, 2001
* copyright : (C) 2001 The phpBB Group
* email : support@phpbb.com
*
* $Id$
*
***************************************************************************/
/***************************************************************************
*
* 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.
*
***************************************************************************/
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
// Get posted/get info
$cat_id = (!empty($_GET['c'])) ? intval($_GET['c']) : 0;
if (isset($_GET['mark']) || isset($_POST['mark']))
{
$mark_read = (isset($_POST['mark'])) ? $_POST['mark'] : $_GET['mark'];
}
else
{
$mark_read = '';
}
// Start session management
$userdata = $session->start();
$auth->acl($userdata);
// End session management
// Configure style, language, etc.
$session->configure($userdata);
// Handle marking posts
if ($mark_read == 'forums')
{
if ($userdata['user_id'])
{
setcookie($board_config['cookie_name'] . '_f_all', time(), 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']);
}
$template->assign_vars(array(
'META' => '<meta http-equiv="refresh" content="3;url=' . "index.$phpEx$SID" . '">')
);
$message = $lang['Forums_marked_read'] . '<br /><br />' . sprintf($lang['Click_return_index'], '<a href="' . "index.$phpEx$SID" . '">', '</a> ');
message_die(MESSAGE, $message);
}
// End handle marking posts
// Topic/forum marked read info
$mark_topics = (isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t'])) ? unserialize(stripslashes($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t'])) : array();
$mark_forums = (isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f'])) ? unserialize(stripslashes($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f'])) : array();
// Set some stats, get posts count from forums data if we... hum... retrieve all forums data
$total_users = $board_config['num_users'];
$newest_user = $board_config['newest_username'];
$newest_uid = $board_config['newest_user_id'];
if ($total_users == 0)
{
$l_total_user_s = $lang['Registered_users_zero_total'];
}
else if ($total_users == 1)
{
$l_total_user_s = $lang['Registered_user_total'];
}
else
{
$l_total_user_s = $lang['Registered_users_total'];
}
// Forum moderators ... a static template var could allow us
// to drop these queries ...
$forum_moderators = array();
get_moderators($forum_moderators);
// Set some vars
$root_id = $branch_root_id = $cat_id;
$forum_rows = $subforums = $nav_forums = array();
if ($cat_id == 0)
{
$is_nav = FALSE;
$total_posts = 0;
switch (SQL_LAYER)
{
case 'oracle':
$sql = 'SELECT f.*, u.username
FROM ' . FORUMS_TABLE . ' f, ' . USERS_TABLE . 'u
WHERE f.forum_last_poster_id = u.user_id(+)
ORDER BY f.left_id';
break;
default:
$sql = 'SELECT f.*, u.username
FROM ' . FORUMS_TABLE . ' f
LEFT JOIN ' . USERS_TABLE . ' u ON f.forum_last_poster_id = u.user_id
ORDER BY f.left_id';
}
}
else
{
$is_nav = TRUE;
if (!$auth->get_acl($cat_id, 'forum', 'list'))
{
// TODO: Deal with hidden categories
message_die(ERROR, $lang['Category_not_exist']);
}
// NOTE: make sure that categories post count is set to 0
$sql = 'SELECT SUM(forum_posts) AS total
FROM ' . FORUMS_TABLE . '
WHERE post_count_inc = 1';
$result = $db->sql_query($sql);
$total_posts = $db->sql_fetchfield('total', 0, $result);
$result = $db->sql_query('SELECT left_id, right_id, parent_id FROM ' . FORUMS_TABLE . ' WHERE forum_id = ' . $cat_id);
$catrow = $db->sql_fetchrow($result);
switch (SQL_LAYER)
{
case 'oracle':
$sql = 'SELECT f.*, u.username
FROM ' . FORUMS_TABLE . ' f, ' . USERS_TABLE . 'u
WHERE (f.left_id BETWEEN ' . $catrow['left_id'] . ' AND ' . $catrow['right_id'] . '
OR ' . $catrow['left_id'] . ' BETWEEN f.left_id AND f.right_id)
AND f.forum_last_poster_id = u.user_id(+)
ORDER BY left_id';
break;
default:
$sql = 'SELECT f.*, u.username
FROM ' . FORUMS_TABLE . ' f
LEFT JOIN ' . USERS_TABLE . ' u ON f.forum_last_poster_id = u.user_id
WHERE f.left_id BETWEEN ' . $catrow['left_id'] . ' AND ' . $catrow['right_id'] . '
OR ' . $catrow['left_id'] . ' BETWEEN f.left_id AND f.right_id
ORDER BY f.left_id';
}
}
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
if (!$cat_id && $row['post_count_inc'])
{
$total_posts += $row['forum_posts'];
}
if ($row['forum_id'] == $cat_id)
{
$nav_forums[] = $row;
$forum_rows[] = $row;
$is_nav = FALSE;
}
elseif ($is_nav)
{
$nav_forums[] = $row;
}
else
{
if ($row['parent_id'] == $cat_id)
{
// Root-level forum
$forum_rows[] = $row;
$parent_id = $row['forum_id'];
if (!$cat_id && $row['forum_status'] == ITEM_CATEGORY)
{
$branch_root_id = $row['forum_id'];
}
}
elseif ($row['parent_id'] == $branch_root_id)
{
// Forum directly under a category
$forum_rows[] = $row;
$parent_id = $row['forum_id'];
}
elseif ($row['display_on_index'] && $row['forum_status'] != ITEM_CATEGORY)
{
// Subforum, store it for direct linking
if ($auth->get_acl($row['forum_id'], 'forum', 'list'))
{
$subforums[$parent_id][] = $row;
}
}
}
}
$root_id = ($cat_id) ? $catrow['parent_id'] : 0;
include($phpbb_root_path . 'includes/forums_display.' . $phpEx);
if ($total_posts == 0)
{
$l_total_post_s = $lang['Posted_articles_zero_total'];
}
else if ($total_posts == 1)
{
$l_total_post_s = $lang['Posted_article_total'];
}
else
{
$l_total_post_s = $lang['Posted_articles_total'];
}
$template->assign_vars(array(
'TOTAL_POSTS' => sprintf($l_total_post_s, $total_posts),
'TOTAL_USERS' => sprintf($l_total_user_s, $total_users),
'NEWEST_USER' => sprintf($lang['Newest_user'], '<a href="profile.' . $phpEx . $SID . '&mode=viewprofile&u=' . $newest_uid . '">', $newest_user, '</a>'),
'FORUM_IMG' => create_img($theme['forum'], $lang['No_new_posts']),
'FORUM_NEW_IMG' => create_img($theme['forum_new'], $lang['New_posts']),
'FORUM_LOCKED_IMG' => create_img($theme['forum_locked'], $lang['No_new_posts_locked']),
'L_FORUM' => $lang['Forum'],
'L_TOPICS' => $lang['Topics'],
'L_REPLIES' => $lang['Replies'],
'L_VIEWS' => $lang['Views'],
'L_POSTS' => $lang['Posts'],
'L_LASTPOST' => $lang['Last_Post'],
'L_MODERATORS' => $lang['Moderators'],
'L_NO_NEW_POSTS' => $lang['No_new_posts'],
'L_NEW_POSTS' => $lang['New_posts'],
'L_NO_NEW_POSTS_LOCKED' => $lang['No_new_posts_locked'],
'L_NEW_POSTS_LOCKED' => $lang['New_posts_locked'],
'L_ONLINE_EXPLAIN' => $lang['Online_explain'],
'L_VIEW_MODERATORS' => $lang['View_moderators'],
'L_FORUM_LOCKED' => $lang['Forum_is_locked'],
'L_MARK_FORUMS_READ' => $lang['Mark_all_forums'],
'L_LEGEND' => $lang['Legend'],
'L_NO_FORUMS' => $lang['No_forums'],
'U_MARK_READ' => "index.$phpEx$SID&mark=forums")
);
foreach ($nav_forums as $row)
{
if ($row['forum_status'] == ITEM_CATEGORY)
{
$link = 'index.' . $phpEx . $SID . '&c=' . $row['forum_id'];
}
else
{
$link = 'viewforum.' . $phpEx . $SID . '&f=' . $row['forum_id'];
}
$template->assign_block_vars('navlinks', array(
'FORUM_NAME' => $row['forum_name'],
'U_VIEW_FORUM' => $link
));
}
// Start output of page
$page_title = $lang['Index'];
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
$template->set_filenames(array(
'body' => 'index_body.html'
));
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
?>
|