|
1 <?php |
|
2 /*********************************************************************** |
|
3 |
|
4 Copyright (C) 2002-2008 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 |
|
26 // Make sure no one attempts to run this script "directly" |
|
27 if (!defined('PUN')) |
|
28 exit; |
|
29 |
|
30 ($hook = get_hook('ft_pun_main_end')) ? eval($hook) : null; |
|
31 |
|
32 $tpl_temp = trim(ob_get_contents()); |
|
33 $tpl_main = str_replace('<!-- pun_main -->', $tpl_temp, $tpl_main); |
|
34 ob_end_clean(); |
|
35 // END SUBST - <!-- pun_main --> |
|
36 |
|
37 |
|
38 // START SUBST - <!-- pun_stats --> |
|
39 if (PUN_PAGE == 'index') |
|
40 { |
|
41 ob_start(); |
|
42 |
|
43 // Collect some statistics from the database |
|
44 $query = array( |
|
45 'SELECT' => 'COUNT(u.id)-1', |
|
46 'FROM' => 'users AS u' |
|
47 ); |
|
48 |
|
49 ($hook = get_hook('ft_qr_get_user_count')) ? eval($hook) : null; |
|
50 $result = $pun_db->query_build($query) or error(__FILE__, __LINE__); |
|
51 $stats['total_users'] = $pun_db->result($result); |
|
52 |
|
53 $query = array( |
|
54 'SELECT' => 'u.id, u.username', |
|
55 'FROM' => 'users AS u', |
|
56 'ORDER BY' => 'u.registered DESC', |
|
57 'LIMIT' => '1' |
|
58 ); |
|
59 |
|
60 ($hook = get_hook('ft_qr_get_newest_user')) ? eval($hook) : null; |
|
61 $result = $pun_db->query_build($query) or error(__FILE__, __LINE__); |
|
62 $stats['last_user'] = $pun_db->fetch_assoc($result); |
|
63 |
|
64 $query = array( |
|
65 'SELECT' => 'SUM(f.num_topics), SUM(f.num_posts)', |
|
66 'FROM' => 'forums AS f' |
|
67 ); |
|
68 |
|
69 ($hook = get_hook('ft_qr_get_post_stats')) ? eval($hook) : null; |
|
70 $result = $pun_db->query_build($query) or error(__FILE__, __LINE__); |
|
71 list($stats['total_topics'], $stats['total_posts']) = $pun_db->fetch_row($result); |
|
72 |
|
73 $stats_list[] = '<li class="st-users"><span>'.$lang_index['No of users'].':</span> <strong>'. $stats['total_users'].'</strong></li>'; |
|
74 $stats_list[] = '<li class="st-users"><span>'.$lang_index['Newest user'].':</span> <strong><a href="'.pun_link($pun_url['user'], $stats['last_user']['id']).'">'.htmlspecialchars($stats['last_user']['username']).'</a></strong></li>'; |
|
75 $stats_list[] = '<li class="st-activity"><span>'.$lang_index['No of topics'].':</span> <strong>'.intval($stats['total_topics']).'</strong></li>'; |
|
76 $stats_list[] = '<li class="st-activity"><span>'.$lang_index['No of posts'].':</span> <strong>'.intval($stats['total_posts']).'</strong></li>'; |
|
77 |
|
78 ?> |
|
79 <div id="pun-info" class="main"> |
|
80 <div class="main-head"> |
|
81 <h2><span><?php echo $lang_index['Forum information'] ?></span></h2> |
|
82 </div> |
|
83 <div class="main-content"> |
|
84 <div id="stats"> |
|
85 <h3><?php echo $lang_index['Statistics'] ?></h3> |
|
86 <ul> |
|
87 <?php echo implode("\n\t\t\t\t", $stats_list)."\n" ?> |
|
88 </ul> |
|
89 </div> |
|
90 <?php |
|
91 |
|
92 if ($pun_config['o_users_online'] == '1') |
|
93 { |
|
94 // Fetch users online info and generate strings for output |
|
95 $query = array( |
|
96 'SELECT' => 'o.user_id, o.ident', |
|
97 'FROM' => 'online AS o', |
|
98 'WHERE' => 'o.idle=0', |
|
99 'ORDER BY' => 'o.ident' |
|
100 ); |
|
101 |
|
102 $result = $pun_db->query_build($query, true) or error(__FILE__, __LINE__); |
|
103 $num_guests = 0; |
|
104 $users = array(); |
|
105 |
|
106 while ($pun_user_online = $pun_db->fetch_assoc($result)) |
|
107 { |
|
108 if ($pun_user_online['user_id'] > 1) |
|
109 $users[] = '<a href="'.pun_link($pun_url['user'], $pun_user_online['user_id']).'">'.htmlspecialchars($pun_user_online['ident']).'</a>'; |
|
110 else |
|
111 ++$num_guests; |
|
112 } |
|
113 |
|
114 ?> |
|
115 <div id="onlinelist"> |
|
116 <h3><?php printf($lang_index['Online'], $num_guests, count($users)) ?></h3> |
|
117 <?php |
|
118 |
|
119 // If there are registered users logged in, list them |
|
120 if (count($users) > 0) |
|
121 echo "\t\t\t".'<p>'.implode(', ', $users).'</p>'."\n"; |
|
122 |
|
123 ?> |
|
124 </div> |
|
125 <?php |
|
126 |
|
127 } |
|
128 |
|
129 ?> |
|
130 </div> |
|
131 </div> |
|
132 <?php |
|
133 |
|
134 $tpl_temp = trim(ob_get_contents()); |
|
135 $tpl_main = str_replace('<!-- pun_stats -->', $tpl_temp, $tpl_main); |
|
136 ob_end_clean(); |
|
137 } |
|
138 // END SUBST - <!-- pun_stats --> |
|
139 |
|
140 |
|
141 // START SUBST - <!-- pun_about --> |
|
142 ob_start(); |
|
143 |
|
144 ?> |
|
145 <div id="pun-about"> |
|
146 <?php |
|
147 |
|
148 // Display the "Jump to" drop list |
|
149 if ($pun_config['o_quickjump'] == '1') |
|
150 { |
|
151 // Load cached quickjump |
|
152 if (file_exists(PUN_CACHE_DIR.'cache_quickjump_'.$pun_user['g_id'].'.php')) |
|
153 include PUN_CACHE_DIR.'cache_quickjump_'.$pun_user['g_id'].'.php'; |
|
154 |
|
155 if (!defined('PUN_QJ_LOADED')) |
|
156 { |
|
157 require_once PUN_ROOT.'include/cache.php'; |
|
158 generate_quickjump_cache($pun_user['g_id']); |
|
159 require PUN_CACHE_DIR.'cache_quickjump_'.$pun_user['g_id'].'.php'; |
|
160 } |
|
161 } |
|
162 |
|
163 |
|
164 // End the transaction |
|
165 $pun_db->end_transaction(); |
|
166 |
|
167 ?> |
|
168 <p id="copyright">Powered by <strong><a href="http://punbb.org/">PunBB</a><?php if ($pun_config['o_show_version'] == '1') echo ' '.$pun_config['o_cur_version']; ?></strong></p> |
|
169 <?php |
|
170 |
|
171 ($hook = get_hook('ft_about_info_extra')) ? eval($hook) : null; |
|
172 |
|
173 // Display debug info (if enabled/defined) |
|
174 if (defined('PUN_DEBUG')) |
|
175 { |
|
176 // Calculate script generation time |
|
177 list($usec, $sec) = explode(' ', microtime()); |
|
178 $time_diff = sprintf('%.3f', ((float)$usec + (float)$sec) - $pun_start); |
|
179 echo "\t".'<p id="querytime">[ Generated in '.$time_diff.' seconds, '.$pun_db->get_num_queries().' queries executed ]</p>'."\n"; |
|
180 } |
|
181 echo '</div>'."\n"; |
|
182 |
|
183 $tpl_temp = trim(ob_get_contents()); |
|
184 $tpl_main = str_replace('<!-- pun_about -->', $tpl_temp, $tpl_main); |
|
185 ob_end_clean(); |
|
186 // END SUBST - <!-- pun_about --> |
|
187 |
|
188 |
|
189 // START SUBST - <!-- pun_debug --> |
|
190 if (defined('PUN_SHOW_QUERIES')) |
|
191 $tpl_main = str_replace('<!-- pun_debug -->', get_saved_queries(), $tpl_main); |
|
192 // END SUBST - <!-- pun_debug --> |
|
193 |
|
194 |
|
195 // START SUBST - <!-- pun_include "*" --> |
|
196 while (preg_match('#<!-- ?pun_include "([^/\\\\]*?)" ?-->#', $tpl_main, $cur_include)) |
|
197 { |
|
198 if (!file_exists(PUN_ROOT.'include/user/'.$cur_include[1])) |
|
199 error('Unable to process user include <!-- pun_include "'.htmlspecialchars($cur_include[1]).'" --> from template main.tpl. There is no such file in folder /include/user/', __FILE__, __LINE__); |
|
200 |
|
201 ob_start(); |
|
202 include PUN_ROOT.'include/user/'.$cur_include[1]; |
|
203 $tpl_temp = ob_get_contents(); |
|
204 $tpl_main = str_replace($cur_include[0], $tpl_temp, $tpl_main); |
|
205 ob_end_clean(); |
|
206 } |
|
207 // END SUBST - <!-- pun_include "*" --> |
|
208 |
|
209 |
|
210 // Last call! |
|
211 ($hook = get_hook('ft_end')) ? eval($hook) : null; |
|
212 |
|
213 |
|
214 // Close the db connection (and free up any result data) |
|
215 $pun_db->close(); |
|
216 |
|
217 // Spit out the page |
|
218 global $template; |
|
219 $template->header(); |
|
220 echo($tpl_main); |
|
221 $template->footer(); |