source: trunk/web/punbb/index2.php @ 1

Last change on this file since 1 was 1, checked in by dj3c1t, 12 years ago

import initial

File size: 9.5 KB
Line 
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
26define('PUN_ROOT', './');
27require PUN_ROOT.'include/common.php';
28
29
30if ($pun_user['g_read_board'] == '0')
31        message($lang_common['No view']);
32
33
34// Load the index.php language file
35require PUN_ROOT.'lang/'.$pun_user['language'].'/index.php';
36
37$page_title = pun_htmlspecialchars($pun_config['o_board_title']);
38define('PUN_ALLOW_INDEX', 1);
39require PUN_ROOT.'header.php';
40
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('Impossible de retrouver la liste des catégories et des forums', __FILE__, __LINE__, $db->error());
43
44$cur_category = 0;
45$cat_count = 0;
46while ($cur_forum = $db->fetch_assoc($result))
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 = '&#160;';
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 = '&#160;';
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?
145if ($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";
147else
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
152$result = $db->query('SELECT COUNT(id)-1 FROM '.$db->prefix.'users') or error('Impossible de retrouver le nombre total d\utilisateurs', __FILE__, __LINE__, $db->error());
153$stats['total_users'] = $db->result($result);
154
155$result = $db->query('SELECT id, username FROM '.$db->prefix.'users ORDER BY registered DESC LIMIT 1') or error('Impossible de retrouver le dernier membre inscrit', __FILE__, __LINE__, $db->error());
156$stats['last_user'] = $db->fetch_assoc($result);
157
158$result = $db->query('SELECT SUM(num_topics), SUM(num_posts) FROM '.$db->prefix.'forums') or error('Impossible de retrouver le nombre de discussions et de messages', __FILE__, __LINE__, $db->error());
159list($stats['total_topics'], $stats['total_posts']) = $db->fetch_row($result);
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
177if ($pun_config['o_users_online'] == '1')
178{
179        // Fetch users online info and generate strings for output
180        $num_guests = 0;
181        $users = array();
182        $result = $db->query('SELECT user_id, ident FROM '.$db->prefix.'online WHERE idle=0 ORDER BY ident', true) or error('Impossible de retrouver la liste des utilisateurs en ligne', __FILE__, __LINE__, $db->error());
183
184        while ($pun_user_online = $db->fetch_assoc($result))
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        // utilisateurs en ligne aujourd'hui
194        $date = getdate(time());
195        $todaystamp = mktime(0,0,0, $date['mon'], $date['mday'], $date['year']);
196
197        $result = $db->query('SELECT username, id, last_visit from '.$db->prefix.'users WHERE last_visit >= \''.$todaystamp.'\' ORDER by last_visit DESC') or error('Impossible de retrouver la liste des utilisateurs en ligne aujourd\'hui', __FILE__, __LINE__, $db->error());
198
199        $users_today = array();
200        while ($pun_user_online_today = $db->fetch_assoc($result))
201                $users_today[] .=  "\n\t\t\t\t".'<dd><a href="profile.php?id='.$pun_user_online_today['id'].'" title="DerniÚre visite de '.$pun_user_online_today['username'].' : '.format_time($pun_user_online_today['last_visit']).'">'.$pun_user_online_today['username'].'</a>';
202        // liste utilisateurs en ligne aujourd'hui
203        echo "\t\t\t".'<dl id="onlinetodaylist">'."\n\t\t\t\t".'<dt><strong>'.$lang_index['Online today'].': </strong></dt>';
204                               
205        if ($num_users_today > 0) 
206                echo implode(',</dd> ', $users_today).'</dd>'."\n\t\t\t".'</dl>'."\n";
207        else
208                echo '<dd><em>aucun</em></dd>'."\n\t\t\t".'</dl>'."\n";
209                       
210        $num_users_today = count($users_today);
211        echo "\t\t\t\t".'<dd>'.$lang_index['Users online'].': <strong>'.$num_users.'</strong></dd>'."\n\t\t\t\t".'<dd>'.$lang_index['Users today'].': <strong>'.$num_users_today.'</strong></dd>'."\n\t\t\t\t".'<dd>'.$lang_index['Guests online'].': <strong>'.$num_guests.'</strong></dd>'."\n\t\t\t".'</dl>'."\n";
212
213
214        if ($num_users > 0)
215                echo "\t\t\t".'<dl id="onlinelist" class= "clearb">'."\n\t\t\t\t".'<dt><strong>'.$lang_index['Online'].':&#160;</strong></dt>'."\t\t\t\t".implode(',</dd> ', $users).'</dd>'."\n\t\t\t".'</dl>'."\n";
216        else
217                echo "\t\t\t".'<div class="clearer"></div>'."\n";
218
219}
220else
221        echo "\t\t".'</dl>'."\n\t\t\t".'<div class="clearer"></div>'."\n";
222
223
224?>
225                </div>
226        </div>
227</div>
228<?php
229
230$footer_style = 'index';
231require PUN_ROOT.'footer.php';
Note: See TracBrowser for help on using the repository browser.