author | Dan |
Thu, 12 Jul 2007 15:00:35 -0400 | |
changeset 3 | c0c445d4a13e |
parent 2 | a8a21e1c7afa |
child 4 | eb9ed4c366d0 |
permissions | -rw-r--r-- |
0 | 1 |
<?php |
2 |
/*********************************************************************** |
|
3 |
||
4 |
Copyright (C) 2002-2005 Rickard Andersson (rickard@punbb.org) |
|
5 |
||
6 |
This file is part of PunBB. |
|
7 |
||
8 |
PunBB is free software; you can redistribute it and/or modify it |
|
9 |
under the terms of the GNU General Public License as published |
|
10 |
by the Free Software Foundation; either version 2 of the License, |
|
11 |
or (at your option) any later version. |
|
12 |
||
13 |
PunBB is distributed in the hope that it will be useful, but |
|
14 |
WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
GNU General Public License for more details. |
|
17 |
||
18 |
You should have received a copy of the GNU General Public License |
|
19 |
along with this program; if not, write to the Free Software |
|
20 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
|
21 |
MA 02111-1307 USA |
|
22 |
||
23 |
************************************************************************/ |
|
24 |
||
25 |
||
2
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
26 |
//define('PUN_ROOT', './'); |
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
27 |
//require PUN_ROOT.'include/common.php'; |
0 | 28 |
|
2
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
29 |
global $pun_db, $pun_user, $pun_config, $lang_common; |
0 | 30 |
|
31 |
if ($pun_user['g_read_board'] == '0') |
|
32 |
message($lang_common['No view']); |
|
33 |
||
34 |
// Load the index.php language file |
|
35 |
require PUN_ROOT.'lang/'.$pun_user['language'].'/index.php'; |
|
36 |
||
37 |
$page_title = pun_htmlspecialchars($pun_config['o_board_title']); |
|
38 |
define('PUN_ALLOW_INDEX', 1); |
|
39 |
require PUN_ROOT.'header.php'; |
|
40 |
||
41 |
// Print the categories and forums |
|
2
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
42 |
$result = $pun_db->query('SELECT c.id AS cid, c.cat_name, f.id AS fid, f.forum_name, f.forum_desc, f.redirect_url, f.moderators, f.num_topics, f.num_posts, f.last_post, f.last_post_id, f.last_poster FROM '.$pun_db->prefix.'categories AS c INNER JOIN '.$pun_db->prefix.'forums AS f ON c.id=f.cat_id LEFT JOIN '.$pun_db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE fp.read_forum IS NULL OR fp.read_forum=1 ORDER BY c.disp_position, c.id, f.disp_position', true) or error('Unable to fetch category/forum list', __FILE__, __LINE__, $pun_db->error()); |
0 | 43 |
|
44 |
$cur_category = 0; |
|
45 |
$cat_count = 0; |
|
2
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
46 |
while ($cur_forum = $pun_db->fetch_assoc($result)) |
0 | 47 |
{ |
48 |
$moderators = ''; |
|
49 |
||
50 |
if ($cur_forum['cid'] != $cur_category) // A new category since last iteration? |
|
51 |
{ |
|
52 |
if ($cur_category != 0) |
|
53 |
echo "\t\t\t".'</tbody>'."\n\t\t\t".'</table>'."\n\t\t".'</div>'."\n\t".'</div>'."\n".'</div>'."\n\n"; |
|
54 |
||
55 |
++$cat_count; |
|
56 |
||
57 |
?> |
|
58 |
<div id="idx<?php echo $cat_count ?>" class="blocktable"> |
|
59 |
<h2><span><?php echo pun_htmlspecialchars($cur_forum['cat_name']) ?></span></h2> |
|
60 |
<div class="box"> |
|
61 |
<div class="inbox"> |
|
62 |
<table cellspacing="0"> |
|
63 |
<thead> |
|
64 |
<tr> |
|
65 |
<th class="tcl" scope="col"><?php echo $lang_common['Forum'] ?></th> |
|
66 |
<th class="tc2" scope="col"><?php echo $lang_index['Topics'] ?></th> |
|
67 |
<th class="tc3" scope="col"><?php echo $lang_common['Posts'] ?></th> |
|
68 |
<th class="tcr" scope="col"><?php echo $lang_common['Last post'] ?></th> |
|
69 |
</tr> |
|
70 |
</thead> |
|
71 |
<tbody> |
|
72 |
<?php |
|
73 |
||
74 |
$cur_category = $cur_forum['cid']; |
|
75 |
} |
|
76 |
||
77 |
$item_status = ''; |
|
78 |
$icon_text = $lang_common['Normal icon']; |
|
79 |
$icon_type = 'icon'; |
|
80 |
||
81 |
// Are there new posts? |
|
82 |
if (!$pun_user['is_guest'] && $cur_forum['last_post'] > $pun_user['last_visit']) |
|
83 |
{ |
|
84 |
$item_status = 'inew'; |
|
85 |
$icon_text = $lang_common['New icon']; |
|
86 |
$icon_type = 'icon inew'; |
|
87 |
} |
|
88 |
||
89 |
// Is this a redirect forum? |
|
90 |
if ($cur_forum['redirect_url'] != '') |
|
91 |
{ |
|
92 |
$forum_field = '<h3><a href="'.pun_htmlspecialchars($cur_forum['redirect_url']).'" title="'.$lang_index['Link to'].' '.pun_htmlspecialchars($cur_forum['redirect_url']).'">'.pun_htmlspecialchars($cur_forum['forum_name']).'</a></h3>'; |
|
93 |
$num_topics = $num_posts = ' '; |
|
94 |
$item_status = 'iredirect'; |
|
95 |
$icon_text = $lang_common['Redirect icon']; |
|
96 |
$icon_type = 'icon'; |
|
97 |
} |
|
98 |
else |
|
99 |
{ |
|
100 |
$forum_field = '<h3><a href="viewforum.php?id='.$cur_forum['fid'].'">'.pun_htmlspecialchars($cur_forum['forum_name']).'</a></h3>'; |
|
101 |
$num_topics = $cur_forum['num_topics']; |
|
102 |
$num_posts = $cur_forum['num_posts']; |
|
103 |
} |
|
104 |
||
105 |
if ($cur_forum['forum_desc'] != '') |
|
106 |
$forum_field .= "\n\t\t\t\t\t\t\t\t".$cur_forum['forum_desc']; |
|
107 |
||
108 |
||
109 |
// If there is a last_post/last_poster. |
|
110 |
if ($cur_forum['last_post'] != '') |
|
111 |
$last_post = '<a href="viewtopic.php?pid='.$cur_forum['last_post_id'].'#p'.$cur_forum['last_post_id'].'">'.format_time($cur_forum['last_post']).'</a> <span class="byuser">'.$lang_common['by'].' '.pun_htmlspecialchars($cur_forum['last_poster']).'</span>'; |
|
112 |
else |
|
113 |
$last_post = ' '; |
|
114 |
||
115 |
if ($cur_forum['moderators'] != '') |
|
116 |
{ |
|
117 |
$mods_array = unserialize($cur_forum['moderators']); |
|
118 |
$moderators = array(); |
|
119 |
||
120 |
while (list($mod_username, $mod_id) = @each($mods_array)) |
|
121 |
$moderators[] = '<a href="profile.php?id='.$mod_id.'">'.pun_htmlspecialchars($mod_username).'</a>'; |
|
122 |
||
123 |
$moderators = "\t\t\t\t\t\t\t\t".'<p><em>('.$lang_common['Moderated by'].'</em> '.implode(', ', $moderators).')</p>'."\n"; |
|
124 |
} |
|
125 |
||
126 |
?> |
|
127 |
<tr<?php if ($item_status != '') echo ' class="'.$item_status.'"'; ?>> |
|
128 |
<td class="tcl"> |
|
129 |
<div class="intd"> |
|
130 |
<div class="<?php echo $icon_type ?>"><div class="nosize"><?php echo $icon_text ?></div></div> |
|
131 |
<div class="tclcon"> |
|
132 |
<?php echo $forum_field."\n".$moderators ?> |
|
133 |
</div> |
|
134 |
</div> |
|
135 |
</td> |
|
136 |
<td class="tc2"><?php echo $num_topics ?></td> |
|
137 |
<td class="tc3"><?php echo $num_posts ?></td> |
|
138 |
<td class="tcr"><?php echo $last_post ?></td> |
|
139 |
</tr> |
|
140 |
<?php |
|
141 |
||
142 |
} |
|
143 |
||
144 |
// Did we output any categories and forums? |
|
145 |
if ($cur_category > 0) |
|
146 |
echo "\t\t\t".'</tbody>'."\n\t\t\t".'</table>'."\n\t\t".'</div>'."\n\t".'</div>'."\n".'</div>'."\n\n"; |
|
147 |
else |
|
148 |
echo '<div id="idx0" class="block"><div class="box"><div class="inbox"><p>'.$lang_index['Empty board'].'</p></div></div></div>'; |
|
149 |
||
150 |
||
151 |
// Collect some statistics from the database |
|
2
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
152 |
$result = $pun_db->query('SELECT COUNT(id)-1 FROM '.$pun_db->prefix.'users') or error('Unable to fetch total user count', __FILE__, __LINE__, $pun_db->error()); |
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
153 |
$stats['total_users'] = $pun_db->result($result); |
0 | 154 |
|
2
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
155 |
$result = $pun_db->query('SELECT u.id, eu.username FROM '.$pun_db->prefix.'users AS u LEFT JOIN '.table_prefix.'users AS eu ON ( eu.user_id = u.id ) ORDER BY registered DESC LIMIT 1') or error('Unable to fetch newest registered user', __FILE__, __LINE__, $pun_db->error()); |
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
156 |
$stats['last_user'] = $pun_db->fetch_assoc($result); |
0 | 157 |
|
2
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
158 |
$result = $pun_db->query('SELECT SUM(num_topics), SUM(num_posts) FROM '.$pun_db->prefix.'forums') or error('Unable to fetch topic/post count', __FILE__, __LINE__, $pun_db->error()); |
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
159 |
list($stats['total_topics'], $stats['total_posts']) = $pun_db->fetch_row($result); |
0 | 160 |
|
161 |
?> |
|
162 |
<div id="brdstats" class="block"> |
|
163 |
<h2><span><?php echo $lang_index['Board info'] ?></span></h2> |
|
164 |
<div class="box"> |
|
165 |
<div class="inbox"> |
|
166 |
<dl class="conr"> |
|
167 |
<dt><strong><?php echo $lang_index['Board stats'] ?></strong></dt> |
|
168 |
<dd><?php echo $lang_index['No of users'].': <strong>'. $stats['total_users'] ?></strong></dd> |
|
169 |
<dd><?php echo $lang_index['No of topics'].': <strong>'.$stats['total_topics'] ?></strong></dd> |
|
170 |
<dd><?php echo $lang_index['No of posts'].': <strong>'.$stats['total_posts'] ?></strong></dd> |
|
171 |
</dl> |
|
172 |
<dl class="conl"> |
|
173 |
<dt><strong><?php echo $lang_index['User info'] ?></strong></dt> |
|
174 |
<dd><?php echo $lang_index['Newest user'] ?>: <a href="profile.php?id=<?php echo $stats['last_user']['id'] ?>"><?php echo pun_htmlspecialchars($stats['last_user']['username']) ?></a></dd> |
|
175 |
<?php |
|
176 |
||
177 |
if ($pun_config['o_users_online'] == '1') |
|
178 |
{ |
|
179 |
// Fetch users online info and generate strings for output |
|
180 |
$num_guests = 0; |
|
181 |
$users = array(); |
|
2
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
182 |
$result = $pun_db->query('SELECT user_id, ident FROM '.$pun_db->prefix.'online WHERE idle=0 ORDER BY ident', true) or error('Unable to fetch online list', __FILE__, __LINE__, $pun_db->error()); |
0 | 183 |
|
2
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
184 |
while ($pun_user_online = $pun_db->fetch_assoc($result)) |
0 | 185 |
{ |
186 |
if ($pun_user_online['user_id'] > 1) |
|
187 |
$users[] = "\n\t\t\t\t".'<dd><a href="profile.php?id='.$pun_user_online['user_id'].'">'.pun_htmlspecialchars($pun_user_online['ident']).'</a>'; |
|
188 |
else |
|
189 |
++$num_guests; |
|
190 |
} |
|
191 |
||
192 |
$num_users = count($users); |
|
193 |
echo "\t\t\t\t".'<dd>'. $lang_index['Users online'].': <strong>'.$num_users.'</strong></dd>'."\n\t\t\t\t".'<dd>'.$lang_index['Guests online'].': <strong>'.$num_guests.'</strong></dd>'."\n\t\t\t".'</dl>'."\n"; |
|
194 |
||
195 |
||
196 |
if ($num_users > 0) |
|
197 |
echo "\t\t\t".'<dl id="onlinelist" class= "clearb">'."\n\t\t\t\t".'<dt><strong>'.$lang_index['Online'].': </strong></dt>'."\t\t\t\t".implode(',</dd> ', $users).'</dd>'."\n\t\t\t".'</dl>'."\n"; |
|
198 |
else |
|
199 |
echo "\t\t\t".'<div class="clearer"></div>'."\n"; |
|
200 |
||
201 |
} |
|
202 |
else |
|
203 |
echo "\t\t".'</dl>'."\n\t\t\t".'<div class="clearer"></div>'."\n"; |
|
204 |
||
205 |
||
206 |
?> |
|
207 |
</div> |
|
208 |
</div> |
|
209 |
</div> |
|
210 |
<?php |
|
211 |
||
212 |
$footer_style = 'index'; |
|
213 |
require PUN_ROOT.'footer.php'; |