changeset 2 | a8a21e1c7afa |
parent 0 | f9ffdbd96607 |
child 4 | eb9ed4c366d0 |
1:8f6143115bf5 | 2:a8a21e1c7afa |
---|---|
21 MA 02111-1307 USA |
21 MA 02111-1307 USA |
22 |
22 |
23 ************************************************************************/ |
23 ************************************************************************/ |
24 |
24 |
25 |
25 |
26 define('PUN_ROOT', './'); |
26 //define('PUN_ROOT', './'); |
27 require PUN_ROOT.'include/common.php'; |
27 //require PUN_ROOT.'include/common.php'; |
28 |
28 |
29 global $pun_db, $pun_user, $pun_config, $lang_common; |
|
29 |
30 |
30 if ($pun_user['g_read_board'] == '0') |
31 if ($pun_user['g_read_board'] == '0') |
31 message($lang_common['No view']); |
32 message($lang_common['No view']); |
32 |
|
33 |
33 |
34 // Load the index.php language file |
34 // Load the index.php language file |
35 require PUN_ROOT.'lang/'.$pun_user['language'].'/index.php'; |
35 require PUN_ROOT.'lang/'.$pun_user['language'].'/index.php'; |
36 |
36 |
37 $page_title = pun_htmlspecialchars($pun_config['o_board_title']); |
37 $page_title = pun_htmlspecialchars($pun_config['o_board_title']); |
38 define('PUN_ALLOW_INDEX', 1); |
38 define('PUN_ALLOW_INDEX', 1); |
39 require PUN_ROOT.'header.php'; |
39 require PUN_ROOT.'header.php'; |
40 |
40 |
41 // Print the categories and forums |
41 // Print the categories and forums |
42 $result = $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 '.$db->prefix.'categories AS c INNER JOIN '.$db->prefix.'forums AS f ON c.id=f.cat_id LEFT JOIN '.$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__, $db->error()); |
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()); |
43 |
43 |
44 $cur_category = 0; |
44 $cur_category = 0; |
45 $cat_count = 0; |
45 $cat_count = 0; |
46 while ($cur_forum = $db->fetch_assoc($result)) |
46 while ($cur_forum = $pun_db->fetch_assoc($result)) |
47 { |
47 { |
48 $moderators = ''; |
48 $moderators = ''; |
49 |
49 |
50 if ($cur_forum['cid'] != $cur_category) // A new category since last iteration? |
50 if ($cur_forum['cid'] != $cur_category) // A new category since last iteration? |
51 { |
51 { |
147 else |
147 else |
148 echo '<div id="idx0" class="block"><div class="box"><div class="inbox"><p>'.$lang_index['Empty board'].'</p></div></div></div>'; |
148 echo '<div id="idx0" class="block"><div class="box"><div class="inbox"><p>'.$lang_index['Empty board'].'</p></div></div></div>'; |
149 |
149 |
150 |
150 |
151 // Collect some statistics from the database |
151 // Collect some statistics from the database |
152 $result = $db->query('SELECT COUNT(id)-1 FROM '.$db->prefix.'users') or error('Unable to fetch total user count', __FILE__, __LINE__, $db->error()); |
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()); |
153 $stats['total_users'] = $db->result($result); |
153 $stats['total_users'] = $pun_db->result($result); |
154 |
154 |
155 $result = $db->query('SELECT id, username FROM '.$db->prefix.'users ORDER BY registered DESC LIMIT 1') or error('Unable to fetch newest registered user', __FILE__, __LINE__, $db->error()); |
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()); |
156 $stats['last_user'] = $db->fetch_assoc($result); |
156 $stats['last_user'] = $pun_db->fetch_assoc($result); |
157 |
157 |
158 $result = $db->query('SELECT SUM(num_topics), SUM(num_posts) FROM '.$db->prefix.'forums') or error('Unable to fetch topic/post count', __FILE__, __LINE__, $db->error()); |
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()); |
159 list($stats['total_topics'], $stats['total_posts']) = $db->fetch_row($result); |
159 list($stats['total_topics'], $stats['total_posts']) = $pun_db->fetch_row($result); |
160 |
160 |
161 ?> |
161 ?> |
162 <div id="brdstats" class="block"> |
162 <div id="brdstats" class="block"> |
163 <h2><span><?php echo $lang_index['Board info'] ?></span></h2> |
163 <h2><span><?php echo $lang_index['Board info'] ?></span></h2> |
164 <div class="box"> |
164 <div class="box"> |
177 if ($pun_config['o_users_online'] == '1') |
177 if ($pun_config['o_users_online'] == '1') |
178 { |
178 { |
179 // Fetch users online info and generate strings for output |
179 // Fetch users online info and generate strings for output |
180 $num_guests = 0; |
180 $num_guests = 0; |
181 $users = array(); |
181 $users = array(); |
182 $result = $db->query('SELECT user_id, ident FROM '.$db->prefix.'online WHERE idle=0 ORDER BY ident', true) or error('Unable to fetch online list', __FILE__, __LINE__, $db->error()); |
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()); |
183 |
183 |
184 while ($pun_user_online = $db->fetch_assoc($result)) |
184 while ($pun_user_online = $pun_db->fetch_assoc($result)) |
185 { |
185 { |
186 if ($pun_user_online['user_id'] > 1) |
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>'; |
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 |
188 else |
189 ++$num_guests; |
189 ++$num_guests; |