11 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. |
11 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. |
12 */ |
12 */ |
13 |
13 |
14 function page_Admin_Home() |
14 function page_Admin_Home() |
15 { |
15 { |
16 global $db, $session, $paths, $template, $plugins; // Common objects |
16 global $db, $session, $paths, $template, $plugins; // Common objects |
17 global $lang; |
17 global $lang; |
18 if ( $session->auth_level < USER_LEVEL_ADMIN || $session->user_level < USER_LEVEL_ADMIN ) |
18 if ( $session->auth_level < USER_LEVEL_ADMIN || $session->user_level < USER_LEVEL_ADMIN ) |
19 { |
19 { |
20 $login_link = makeUrlNS('Special', 'Login/' . $paths->nslist['Special'] . 'Administration', 'level=' . USER_LEVEL_ADMIN, true); |
20 $login_link = makeUrlNS('Special', 'Login/' . $paths->nslist['Special'] . 'Administration', 'level=' . USER_LEVEL_ADMIN, true); |
21 echo '<h3>' . $lang->get('adm_err_not_auth_title') . '</h3>'; |
21 echo '<h3>' . $lang->get('adm_err_not_auth_title') . '</h3>'; |
22 echo '<p>' . $lang->get('adm_err_not_auth_body', array( 'login_link' => $login_link )) . '</p>'; |
22 echo '<p>' . $lang->get('adm_err_not_auth_body', array( 'login_link' => $login_link )) . '</p>'; |
23 return; |
23 return; |
24 } |
24 } |
25 |
25 |
26 if ( $paths->getParam(0) == 'updates.xml' ) |
26 if ( $paths->getParam(0) == 'updates.xml' ) |
27 { |
27 { |
28 return acphome_process_updates(); |
28 return acphome_process_updates(); |
29 } |
29 } |
30 |
30 |
31 // Welcome |
31 // Welcome |
32 echo '<h2>' . $lang->get('acphome_heading_main') . '</h2>'; |
32 echo '<h2>' . $lang->get('acphome_heading_main') . '</h2>'; |
33 echo '<p>' . $lang->get('acphome_welcome_line1') . '</p>'; |
33 echo '<p>' . $lang->get('acphome_welcome_line1') . '</p>'; |
34 |
34 |
35 // Stats |
35 // Stats |
36 acphome_show_stats(); |
36 acphome_show_stats(); |
37 |
37 |
38 // |
38 // |
39 // Alerts |
39 // Alerts |
40 // |
40 // |
41 |
41 |
42 echo '<h3>' . $lang->get('acphome_heading_alerts') . '</h3>'; |
42 echo '<h3>' . $lang->get('acphome_heading_alerts') . '</h3>'; |
43 |
43 |
44 // Demo mode |
44 // Demo mode |
45 if ( defined('ENANO_DEMO_MODE') ) |
45 if ( defined('ENANO_DEMO_MODE') ) |
46 { |
46 { |
47 echo '<div class="acphome-box info">'; |
47 echo '<div class="acphome-box info">'; |
48 echo '<h3>' . $lang->get('acphome_msg_demo_title') . '</h3> |
48 echo '<h3>' . $lang->get('acphome_msg_demo_title') . '</h3> |
49 <p>' . $lang->get('acphome_msg_demo_body', array('reset_url' => makeUrlNS('Special', 'DemoReset', false, true))) . '</p>'; |
49 <p>' . $lang->get('acphome_msg_demo_body', array('reset_url' => makeUrlNS('Special', 'DemoReset', false, true))) . '</p>'; |
50 echo '</div>'; |
50 echo '</div>'; |
51 } |
51 } |
52 |
52 |
53 // Check for the installer scripts |
53 // Check for the installer scripts |
54 if( file_exists(ENANO_ROOT.'/install/install.php') && !defined('ENANO_DEMO_MODE') ) |
54 if( file_exists(ENANO_ROOT.'/install/install.php') && !defined('ENANO_DEMO_MODE') ) |
55 { |
55 { |
56 echo '<div class="acphome-box warning"> |
56 echo '<div class="acphome-box warning"> |
57 <h3>' . $lang->get('acphome_msg_install_files_title') . '</h3> |
57 <h3>' . $lang->get('acphome_msg_install_files_title') . '</h3> |
58 <p>' . $lang->get('acphome_msg_install_files_body') . '</p> |
58 <p>' . $lang->get('acphome_msg_install_files_body') . '</p> |
59 </div>'; |
59 </div>'; |
60 } |
60 } |
61 |
61 |
62 // Inactive users |
62 // Inactive users |
63 $q = $db->sql_query('SELECT time_id FROM '.table_prefix.'logs WHERE log_type=\'admin\' AND action=\'activ_req\';'); |
63 $q = $db->sql_query('SELECT time_id FROM '.table_prefix.'logs WHERE log_type=\'admin\' AND action=\'activ_req\';'); |
64 if ( $q ) |
64 if ( $q ) |
65 { |
65 { |
66 if ( $db->numrows() > 0 ) |
66 if ( $db->numrows() > 0 ) |
67 { |
67 { |
68 $n = $db->numrows(); |
68 $n = $db->numrows(); |
69 $um_flags = 'href="#" onclick="ajaxPage(\''.$paths->nslist['Admin'].'UserManager\'); return false;"'; |
69 $um_flags = 'href="#" onclick="ajaxPage(\''.$paths->nslist['Admin'].'UserManager\'); return false;"'; |
70 if ( $n == 1 ) |
70 if ( $n == 1 ) |
71 $s = $lang->get('acphome_msg_inactive_users_one', array('um_flags' => $um_flags)); |
71 $s = $lang->get('acphome_msg_inactive_users_one', array('um_flags' => $um_flags)); |
72 else |
72 else |
73 $s = $lang->get('acphome_msg_inactive_users_plural', array('um_flags' => $um_flags, 'num_users' => $n)); |
73 $s = $lang->get('acphome_msg_inactive_users_plural', array('um_flags' => $um_flags, 'num_users' => $n)); |
74 echo '<div class="acphome-box notice"> |
74 echo '<div class="acphome-box notice"> |
75 <h3>' . $lang->get('acphome_heading_inactive_users') . '</h3> |
75 <h3>' . $lang->get('acphome_heading_inactive_users') . '</h3> |
76 ' . $s . ' |
76 ' . $s . ' |
77 </div>'; |
77 </div>'; |
78 } |
78 } |
79 } |
79 } |
80 $db->free_result(); |
80 $db->free_result(); |
81 |
81 |
82 acp_usermanager_lockouts(true); |
82 acp_usermanager_lockouts(true); |
83 |
83 |
84 // Update checker |
84 // Update checker |
85 echo '<div class="acphome-box info">'; |
85 echo '<div class="acphome-box info">'; |
86 echo '<h3>' . $lang->get('acphome_heading_updates') . '</h3>'; |
86 echo '<h3>' . $lang->get('acphome_heading_updates') . '</h3>'; |
87 echo '<p>' . $lang->get('acphome_msg_updates_info', array('updates_url' => 'http://ktulu.enanocms.org/meta/updates.xml')) . '</p>'; |
87 echo '<p>' . $lang->get('acphome_msg_updates_info', array('updates_url' => 'http://ktulu.enanocms.org/meta/updates.xml')) . '</p>'; |
88 echo '<div id="update_check_container"><input type="button" onclick="ajaxUpdateCheck(this.parentNode.id);" value="' . $lang->get('acphome_btn_check_updates') . '" /></div>'; |
88 echo '<div id="update_check_container"><input type="button" onclick="ajaxUpdateCheck(this.parentNode.id);" value="' . $lang->get('acphome_btn_check_updates') . '" /></div>'; |
89 echo '</div>'; |
89 echo '</div>'; |
90 |
90 |
91 // Docs |
91 // Docs |
92 echo '<div class="acphome-box info halfwidth">'; |
92 echo '<div class="acphome-box info halfwidth">'; |
93 echo '<h3>' . $lang->get('acphome_heading_docs') . '</h3>'; |
93 echo '<h3>' . $lang->get('acphome_heading_docs') . '</h3>'; |
94 echo '<p>' . $lang->get('acphome_msg_docs_info') . '</p>'; |
94 echo '<p>' . $lang->get('acphome_msg_docs_info') . '</p>'; |
95 echo '</div>'; |
95 echo '</div>'; |
96 |
96 |
97 // Support |
97 // Support |
98 echo '<div class="acphome-box info halfwidth">'; |
98 echo '<div class="acphome-box info halfwidth">'; |
99 echo '<h3>' . $lang->get('acphome_heading_support') . '</h3>'; |
99 echo '<h3>' . $lang->get('acphome_heading_support') . '</h3>'; |
100 echo '<p>' . $lang->get('acphome_msg_support_info') . '</p>'; |
100 echo '<p>' . $lang->get('acphome_msg_support_info') . '</p>'; |
101 echo '</div>'; |
101 echo '</div>'; |
102 |
102 |
103 echo '<span class="menuclear"></span>'; |
103 echo '<span class="menuclear"></span>'; |
104 |
104 |
105 // |
105 // |
106 // Stats |
106 // Stats |
107 // |
107 // |
108 |
108 |
109 if(getConfig('log_hits') == '1') |
109 if(getConfig('log_hits') == '1') |
110 { |
110 { |
111 require_once(ENANO_ROOT . '/includes/stats.php'); |
111 require_once(ENANO_ROOT . '/includes/stats.php'); |
112 $stats = stats_top_pages(10); |
112 $stats = stats_top_pages(10); |
113 //die('<pre>'.print_r($stats,true).'</pre>'); |
113 //die('<pre>'.print_r($stats,true).'</pre>'); |
114 $c = 0; |
114 $c = 0; |
115 $cls = 'row2'; |
115 $cls = 'row2'; |
116 echo '<h3>' . $lang->get('acphome_heading_top_pages') . '</h3> |
116 echo '<h3>' . $lang->get('acphome_heading_top_pages') . '</h3> |
117 <div class="tblholder"> |
117 <div class="tblholder"> |
118 <table style="width: 100%;" border="0" cellspacing="1" cellpadding="4"> |
118 <table style="width: 100%;" border="0" cellspacing="1" cellpadding="4"> |
119 <tr> |
119 <tr> |
120 <th>' . $lang->get('acphome_th_toppages_page') . '</th> |
120 <th>' . $lang->get('acphome_th_toppages_page') . '</th> |
121 <th>' . $lang->get('acphome_th_toppages_hits') . '</th> |
121 <th>' . $lang->get('acphome_th_toppages_hits') . '</th> |
122 </tr>'; |
122 </tr>'; |
123 foreach($stats as $data) |
123 foreach($stats as $data) |
124 { |
124 { |
125 echo '<tr>'; |
125 echo '<tr>'; |
126 $cls = ( $cls == 'row1' ) ? 'row2' : 'row1'; |
126 $cls = ( $cls == 'row1' ) ? 'row2' : 'row1'; |
127 echo '<td class="'.$cls.'"> |
127 echo '<td class="'.$cls.'"> |
128 <a href="'.makeUrl($data['page_urlname']).'">'.$data['page_title'].'</a></td><td style="text-align: center;" class="'.$cls.'">'.$data['num_hits'] |
128 <a href="'.makeUrl($data['page_urlname']).'">'.$data['page_title'].'</a></td><td style="text-align: center;" class="'.$cls.'">'.$data['num_hits'] |
129 . '</td>'; |
129 . '</td>'; |
130 echo '</tr>'; |
130 echo '</tr>'; |
131 } |
131 } |
132 echo ' </table> |
132 echo ' </table> |
133 </div>'; |
133 </div>'; |
134 } |
134 } |
135 |
135 |
136 // Any hooks? |
136 // Any hooks? |
137 $code = $plugins->setHook('acp_home'); |
137 $code = $plugins->setHook('acp_home'); |
138 foreach ( $code as $cmd ) |
138 foreach ( $code as $cmd ) |
139 { |
139 { |
140 eval($cmd); |
140 eval($cmd); |
141 } |
141 } |
142 |
142 |
143 // |
143 // |
144 // Security log |
144 // Security log |
145 // |
145 // |
146 |
146 |
147 echo '<h3>' . $lang->get('acphome_heading_seclog') . '</h3>'; |
147 echo '<h3>' . $lang->get('acphome_heading_seclog') . '</h3>'; |
148 echo '<p>' . $lang->get('acphome_msg_seclog_info') . '</p>'; |
148 echo '<p>' . $lang->get('acphome_msg_seclog_info') . '</p>'; |
149 $seclog = get_security_log(5); |
149 $seclog = get_security_log(5); |
150 echo $seclog; |
150 echo $seclog; |
151 |
151 |
152 echo '<p><a href="#" onclick="ajaxPage(\''.$paths->nslist['Admin'].'SecurityLog\'); return false;">' . $lang->get('acphome_btn_seclog_full') . '</a></p>'; |
152 echo '<p><a href="#" onclick="ajaxPage(\''.$paths->nslist['Admin'].'SecurityLog\'); return false;">' . $lang->get('acphome_btn_seclog_full') . '</a></p>'; |
153 |
153 |
154 } |
154 } |
155 |
155 |
156 function acphome_process_updates() |
156 function acphome_process_updates() |
157 { |
157 { |
158 require_once(ENANO_ROOT . '/includes/http.php'); |
158 require_once(ENANO_ROOT . '/includes/http.php'); |
159 |
159 |
160 try |
160 try |
161 { |
161 { |
162 $req = new Request_HTTP('ktulu.enanocms.org', '/meta/updates.xml'); |
162 $req = new Request_HTTP('ktulu.enanocms.org', '/meta/updates.xml'); |
163 $response = $req->get_response_body(); |
163 $response = $req->get_response_body(); |
164 header('Content-type: application/xml'); |
164 header('Content-type: application/xml'); |
165 } |
165 } |
166 catch ( Exception $e ) |
166 catch ( Exception $e ) |
167 { |
167 { |
168 header('Content-type: application/xml'); |
168 header('Content-type: application/xml'); |
169 echo '<enano><error><![CDATA[ |
169 echo '<enano><error><![CDATA[ |
170 Cannot connect to server: ' . $e->getMessage() . ' |
170 Cannot connect to server: ' . $e->getMessage() . ' |
171 ]]></error></enano>'; |
171 ]]></error></enano>'; |
172 return true; |
172 return true; |
173 } |
173 } |
174 if ( $req->response_code != HTTP_OK ) |
174 if ( $req->response_code != HTTP_OK ) |
175 { |
175 { |
176 // Error in response |
176 // Error in response |
177 echo '<enano><error><![CDATA[ |
177 echo '<enano><error><![CDATA[ |
178 Did not properly receive response from server. Response code: ' . $req->response_code . ' ' . $req->response_string . ' |
178 Did not properly receive response from server. Response code: ' . $req->response_code . ' ' . $req->response_string . ' |
179 ]]></error></enano>'; |
179 ]]></error></enano>'; |
180 } |
180 } |
181 else |
181 else |
182 { |
182 { |
183 // Retrieve first update |
183 // Retrieve first update |
184 $first_update = preg_match('/<release tag="([^"]+)" version="([^"]+)" (codename="([^"]+)" )?relnotes="([^"]+)" ?\/>/', $response, $match); |
184 $first_update = preg_match('/<release tag="([^"]+)" version="([^"]+)" (codename="([^"]+)" )?relnotes="([^"]+)" ?\/>/', $response, $match); |
185 if ( !$first_update ) |
185 if ( !$first_update ) |
186 { |
186 { |
187 echo '<enano><error><![CDATA[ |
187 echo '<enano><error><![CDATA[ |
188 Received invalid XML response. |
188 Received invalid XML response. |
189 ]]></error></enano>'; |
189 ]]></error></enano>'; |
190 } |
190 } |
191 else |
191 else |
192 { |
192 { |
193 if ( version_compare(enano_version(true), $match[2], '<') ) |
193 if ( version_compare(enano_version(true), $match[2], '<') ) |
194 { |
194 { |
195 $response = str_replace_once('</latest>', " <haveupdates />\n </latest>", $response); |
195 $response = str_replace_once('</latest>', " <haveupdates />\n </latest>", $response); |
196 } |
196 } |
197 echo $response; |
197 echo $response; |
198 } |
198 } |
199 } |
199 } |
200 return true; |
200 return true; |
201 } |
201 } |
202 |
202 |
203 function acphome_show_stats() |
203 function acphome_show_stats() |
204 { |
204 { |
205 global $db, $session, $paths, $template, $plugins; // Common objects |
205 global $db, $session, $paths, $template, $plugins; // Common objects |
206 global $lang; |
206 global $lang; |
207 |
207 |
208 // Page count |
208 // Page count |
209 $q = $db->sql_query('SELECT COUNT(*) FROM ' . table_prefix . "pages"); |
209 $q = $db->sql_query('SELECT COUNT(*) FROM ' . table_prefix . "pages"); |
210 if ( !$q ) |
210 if ( !$q ) |
211 $db->_die(); |
211 $db->_die(); |
212 list($page_count) = $db->fetchrow_num(); |
212 list($page_count) = $db->fetchrow_num(); |
213 $db->free_result(); |
213 $db->free_result(); |
214 |
214 |
215 // Edits per day |
215 // Edits per day |
216 $q = $db->sql_query('SELECT ( COUNT(*) - 1 ) AS edit_count, MIN(time_id) AS install_date FROM ' . table_prefix . 'logs WHERE ( log_type = \'page\' AND action = \'edit\' ) OR ( log_type = \'security\' AND action = \'install_enano\' );'); |
216 $q = $db->sql_query('SELECT ( COUNT(*) - 1 ) AS edit_count, MIN(time_id) AS install_date FROM ' . table_prefix . 'logs WHERE ( log_type = \'page\' AND action = \'edit\' ) OR ( log_type = \'security\' AND action = \'install_enano\' );'); |
217 if ( !$q ) |
217 if ( !$q ) |
218 $db->_die(); |
218 $db->_die(); |
219 $edit_info = $db->fetchrow(); |
219 $edit_info = $db->fetchrow(); |
220 $install_date =& $edit_info['install_date']; |
220 $install_date =& $edit_info['install_date']; |
221 $db->free_result(); |
221 $db->free_result(); |
222 |
222 |
223 $days_installed = round( (time() / 86400) - ($install_date / 86400) ); |
223 $days_installed = round( (time() / 86400) - ($install_date / 86400) ); |
224 if ( $days_installed < 1 ) |
224 if ( $days_installed < 1 ) |
225 $days_installed = 1; |
225 $days_installed = 1; |
226 |
226 |
227 // Comments |
227 // Comments |
228 $q = $db->sql_query('SELECT COUNT(*) FROM ' . table_prefix . "comments"); |
228 $q = $db->sql_query('SELECT COUNT(*) FROM ' . table_prefix . "comments"); |
229 if ( !$q ) |
229 if ( !$q ) |
230 $db->_die(); |
230 $db->_die(); |
231 list($comment_count) = $db->fetchrow_num(); |
231 list($comment_count) = $db->fetchrow_num(); |
232 $db->free_result(); |
232 $db->free_result(); |
233 |
233 |
234 // Users |
234 // Users |
235 $q = $db->sql_query('SELECT ( COUNT(*) - 1 ) FROM ' . table_prefix . "users"); |
235 $q = $db->sql_query('SELECT ( COUNT(*) - 1 ) FROM ' . table_prefix . "users"); |
236 if ( !$q ) |
236 if ( !$q ) |
237 $db->_die(); |
237 $db->_die(); |
238 list($user_count) = $db->fetchrow_num(); |
238 list($user_count) = $db->fetchrow_num(); |
239 $db->free_result(); |
239 $db->free_result(); |
240 |
240 |
241 // Cache size |
241 // Cache size |
242 $cache_size = 0; |
242 $cache_size = 0; |
243 if ( $dr = @opendir(ENANO_ROOT . '/cache/') ) |
243 if ( $dr = @opendir(ENANO_ROOT . '/cache/') ) |
244 { |
244 { |
245 while ( $dh = @readdir($dr) ) |
245 while ( $dh = @readdir($dr) ) |
246 { |
246 { |
247 $file = ENANO_ROOT . "/cache/$dh"; |
247 $file = ENANO_ROOT . "/cache/$dh"; |
248 if ( @is_file($file) ) |
248 if ( @is_file($file) ) |
249 $cache_size += filesize($file); |
249 $cache_size += filesize($file); |
250 } |
250 } |
251 closedir($dr); |
251 closedir($dr); |
252 } |
252 } |
253 $cache_size = humanize_filesize($cache_size); |
253 $cache_size = humanize_filesize($cache_size); |
254 |
254 |
255 // Files directory size |
255 // Files directory size |
256 $files_size = 0; |
256 $files_size = 0; |
257 if ( $dr = @opendir(ENANO_ROOT . '/files/') ) |
257 if ( $dr = @opendir(ENANO_ROOT . '/files/') ) |
258 { |
258 { |
259 while ( $dh = @readdir($dr) ) |
259 while ( $dh = @readdir($dr) ) |
260 { |
260 { |
261 $file = ENANO_ROOT . "/files/$dh"; |
261 $file = ENANO_ROOT . "/files/$dh"; |
262 if ( @is_file($file) ) |
262 if ( @is_file($file) ) |
263 $files_size += filesize($file); |
263 $files_size += filesize($file); |
264 } |
264 } |
265 closedir($dr); |
265 closedir($dr); |
266 } |
266 } |
267 $files_size = humanize_filesize($files_size); |
267 $files_size = humanize_filesize($files_size); |
268 |
268 |
269 // Avatar directory size |
269 // Avatar directory size |
270 $avatar_size = 0; |
270 $avatar_size = 0; |
271 if ( $dr = @opendir(ENANO_ROOT . '/files/avatars/') ) |
271 if ( $dr = @opendir(ENANO_ROOT . '/files/avatars/') ) |
272 { |
272 { |
273 while ( $dh = @readdir($dr) ) |
273 while ( $dh = @readdir($dr) ) |
274 { |
274 { |
275 $file = ENANO_ROOT . "/files/avatars/$dh"; |
275 $file = ENANO_ROOT . "/files/avatars/$dh"; |
276 if ( @is_file($file) ) |
276 if ( @is_file($file) ) |
277 $avatar_size += filesize($file); |
277 $avatar_size += filesize($file); |
278 } |
278 } |
279 closedir($dr); |
279 closedir($dr); |
280 } |
280 } |
281 $avatar_size = humanize_filesize($avatar_size); |
281 $avatar_size = humanize_filesize($avatar_size); |
282 |
282 |
283 // Database size |
283 // Database size |
284 $db_size = $lang->get('acphome_stat_dbsize_unsupported'); |
284 $db_size = $lang->get('acphome_stat_dbsize_unsupported'); |
285 if ( ENANO_DBLAYER == 'MYSQL' ) |
285 if ( ENANO_DBLAYER == 'MYSQL' ) |
286 { |
286 { |
287 $q = $db->sql_query('SHOW TABLE STATUS;'); |
287 $q = $db->sql_query('SHOW TABLE STATUS;'); |
288 if ( $q ) |
288 if ( $q ) |
289 { |
289 { |
290 $db_size = 0; |
290 $db_size = 0; |
291 while ( $row = $db->fetchrow() ) |
291 while ( $row = $db->fetchrow() ) |
292 { |
292 { |
293 if ( preg_match('/^' . table_prefix . '/', $row['Name']) ) |
293 if ( preg_match('/^' . table_prefix . '/', $row['Name']) ) |
294 { |
294 { |
295 $db_size += $row['Data_length'] + $row['Index_length']; |
295 $db_size += $row['Data_length'] + $row['Index_length']; |
296 } |
296 } |
297 } |
297 } |
298 $db_size = humanize_filesize($db_size); |
298 $db_size = humanize_filesize($db_size); |
299 } |
299 } |
300 } |
300 } |
301 else if ( ENANO_DBLAYER == 'PGSQL' ) |
301 else if ( ENANO_DBLAYER == 'PGSQL' ) |
302 { |
302 { |
303 require(ENANO_ROOT . '/config.php'); |
303 require(ENANO_ROOT . '/config.php'); |
304 global $dbname, $dbuser, $dbpasswd; |
304 global $dbname, $dbuser, $dbpasswd; |
305 $dbuser = false; |
305 $dbuser = false; |
306 $dbpasswd = false; |
306 $dbpasswd = false; |
307 |
307 |
308 $q = $db->sql_query('SELECT pg_database_size(\'' . $db->escape($dbname) . '\');'); |
308 $q = $db->sql_query('SELECT pg_database_size(\'' . $db->escape($dbname) . '\');'); |
309 if ( $q ) |
309 if ( $q ) |
310 { |
310 { |
311 list($db_size) = $db->fetchrow_num(); |
311 list($db_size) = $db->fetchrow_num(); |
312 $db_size = humanize_filesize($db_size); |
312 $db_size = humanize_filesize($db_size); |
313 $db->free_result(); |
313 $db->free_result(); |
314 } |
314 } |
315 } |
315 } |
316 |
316 |
317 // Install date |
317 // Install date |
318 $site_age = floor((time() - $install_date) / 86400); |
318 $site_age = floor((time() - $install_date) / 86400); |
319 $install_date_human = MemberlistFormatter::format_date($install_date); |
319 $install_date_human = MemberlistFormatter::format_date($install_date); |
320 if ( $site_age > 7 ) |
320 if ( $site_age > 7 ) |
321 { |
321 { |
322 $install_date_human .= ' ' . $lang->get('acphome_stat_installdate_ago', array( |
322 $install_date_human .= ' ' . $lang->get('acphome_stat_installdate_ago', array( |
323 'days' => number_format($site_age) |
323 'days' => number_format($site_age) |
324 )); |
324 )); |
325 } |
325 } |
326 |
326 |
327 // Last upgrade |
327 // Last upgrade |
328 $q = $db->sql_query('SELECT time_id FROM ' . table_prefix . "logs WHERE log_type = 'security' AND action = 'upgrade_enano' ORDER BY time_id DESC LIMIT 1;"); |
328 $q = $db->sql_query('SELECT time_id FROM ' . table_prefix . "logs WHERE log_type = 'security' AND action = 'upgrade_enano' ORDER BY time_id DESC LIMIT 1;"); |
329 if ( !$q ) |
329 if ( !$q ) |
330 $db->_die(); |
330 $db->_die(); |
331 |
331 |
332 if ( $db->numrows() < 1 ) |
332 if ( $db->numrows() < 1 ) |
333 { |
333 { |
334 $last_upgrade = $lang->get('acphome_stat_lastupdate_never'); |
334 $last_upgrade = $lang->get('acphome_stat_lastupdate_never'); |
335 } |
335 } |
336 else |
336 else |
337 { |
337 { |
338 list($last_upgrade) = $db->fetchrow_num(); |
338 list($last_upgrade) = $db->fetchrow_num(); |
339 $ver_age = floor((time() - $last_upgrade) / 86400); |
339 $ver_age = floor((time() - $last_upgrade) / 86400); |
340 $last_upgrade = MemberlistFormatter::format_date($last_upgrade); |
340 $last_upgrade = MemberlistFormatter::format_date($last_upgrade); |
341 if ( $ver_age > 7 ) |
341 if ( $ver_age > 7 ) |
342 { |
342 { |
343 $last_upgrade .= ' ' . $lang->get('acphome_stat_installdate_ago', array( |
343 $last_upgrade .= ' ' . $lang->get('acphome_stat_installdate_ago', array( |
344 'days' => number_format($ver_age) |
344 'days' => number_format($ver_age) |
345 )); |
345 )); |
346 } |
346 } |
347 } |
347 } |
348 $db->free_result(); |
348 $db->free_result(); |
349 |
349 |
350 ?> |
350 ?> |
351 <div class="tblholder"> |
351 <div class="tblholder"> |
352 <table border="0" cellspacing="1" cellpadding="4"> |
352 <table border="0" cellspacing="1" cellpadding="4"> |
353 <tr> |
353 <tr> |
354 <th colspan="4"> |
354 <th colspan="4"> |
355 <?php echo $lang->get('acphome_stat_header'); ?> |
355 <?php echo $lang->get('acphome_stat_header'); ?> |
356 </th> |
356 </th> |
357 </tr> |
357 </tr> |
358 |
358 |
359 <tr> |
359 <tr> |
360 <td class="row2" style="width: 25%;"> |
360 <td class="row2" style="width: 25%;"> |
361 <?php echo $lang->get('acphome_stat_numpages'); ?> |
361 <?php echo $lang->get('acphome_stat_numpages'); ?> |
362 </td> |
362 </td> |
363 <td class="row1" style="width: 25%;"> |
363 <td class="row1" style="width: 25%;"> |
364 <?php echo strval($page_count); ?> |
364 <?php echo strval($page_count); ?> |
365 </td> |
365 </td> |
366 <td class="row2" style="width: 25%;"> |
366 <td class="row2" style="width: 25%;"> |
367 <?php echo $lang->get('acphome_stat_edits'); ?> |
367 <?php echo $lang->get('acphome_stat_edits'); ?> |
368 </td> |
368 </td> |
369 <td class="row1" style="width: 25%;"> |
369 <td class="row1" style="width: 25%;"> |
370 <?php echo $lang->get('acphome_stat_edits_data', array('edit_count' => $edit_info['edit_count'], 'per_day' => number_format($edit_info['edit_count'] / $days_installed, 2))); ?> |
370 <?php echo $lang->get('acphome_stat_edits_data', array('edit_count' => $edit_info['edit_count'], 'per_day' => number_format($edit_info['edit_count'] / $days_installed, 2))); ?> |
371 </td> |
371 </td> |
372 </tr> |
372 </tr> |
373 |
373 |
374 <tr> |
374 <tr> |
375 <td class="row2" style="width: 25%;"> |
375 <td class="row2" style="width: 25%;"> |
376 <?php echo $lang->get('acphome_stat_comments'); ?> |
376 <?php echo $lang->get('acphome_stat_comments'); ?> |
377 </td> |
377 </td> |
378 <td class="row1" style="width: 25%;"> |
378 <td class="row1" style="width: 25%;"> |
379 <?php echo $lang->get('acphome_stat_comments_data', array('comment_count' => $comment_count, 'per_day' => number_format($comment_count / $days_installed, 2))); ?> |
379 <?php echo $lang->get('acphome_stat_comments_data', array('comment_count' => $comment_count, 'per_day' => number_format($comment_count / $days_installed, 2))); ?> |
380 </td> |
380 </td> |
381 <td class="row2" style="width: 25%;"> |
381 <td class="row2" style="width: 25%;"> |
382 <?php echo $lang->get('acphome_stat_users'); ?> |
382 <?php echo $lang->get('acphome_stat_users'); ?> |
383 </td> |
383 </td> |
384 <td class="row1" style="width: 25%;"> |
384 <td class="row1" style="width: 25%;"> |
385 <?php echo strval($user_count); ?> |
385 <?php echo strval($user_count); ?> |
386 </td> |
386 </td> |
387 </tr> |
387 </tr> |
388 |
388 |
389 <tr> |
389 <tr> |
390 <td class="row2" style="width: 25%;"> |
390 <td class="row2" style="width: 25%;"> |
391 <?php echo $lang->get('acphome_stat_filesize'); ?> |
391 <?php echo $lang->get('acphome_stat_filesize'); ?> |
392 </td> |
392 </td> |
393 <td class="row1" style="width: 25%;"> |
393 <td class="row1" style="width: 25%;"> |
394 <?php echo $files_size; ?> |
394 <?php echo $files_size; ?> |
395 </td> |
395 </td> |
396 <td class="row2" style="width: 25%;"> |
396 <td class="row2" style="width: 25%;"> |
397 <?php echo $lang->get('acphome_stat_cachesize'); ?> |
397 <?php echo $lang->get('acphome_stat_cachesize'); ?> |
398 </td> |
398 </td> |
399 <td class="row1" style="width: 25%;"> |
399 <td class="row1" style="width: 25%;"> |
400 <?php echo $cache_size; ?> |
400 <?php echo $cache_size; ?> |
401 </td> |
401 </td> |
402 </tr> |
402 </tr> |
403 |
403 |
404 <tr> |
404 <tr> |
405 <td class="row2" style="width: 25%;"> |
405 <td class="row2" style="width: 25%;"> |
406 <?php echo $lang->get('acphome_stat_avatarsize'); ?> |
406 <?php echo $lang->get('acphome_stat_avatarsize'); ?> |
407 </td> |
407 </td> |
408 <td class="row1" style="width: 25%;"> |
408 <td class="row1" style="width: 25%;"> |
409 <?php echo $avatar_size; ?> |
409 <?php echo $avatar_size; ?> |
410 </td> |
410 </td> |
411 <td class="row2" style="width: 25%;"> |
411 <td class="row2" style="width: 25%;"> |
412 <?php echo $lang->get('acphome_stat_dbsize'); ?> |
412 <?php echo $lang->get('acphome_stat_dbsize'); ?> |
413 </td> |
413 </td> |
414 <td class="row1" style="width: 25%;"> |
414 <td class="row1" style="width: 25%;"> |
415 <?php echo $db_size; ?> |
415 <?php echo $db_size; ?> |
416 </td> |
416 </td> |
417 </tr> |
417 </tr> |
418 |
418 |
419 <tr> |
419 <tr> |
420 <td class="row2" style="width: 25%;"> |
420 <td class="row2" style="width: 25%;"> |
421 <?php echo $lang->get('acphome_stat_installdate'); ?> |
421 <?php echo $lang->get('acphome_stat_installdate'); ?> |
422 </td> |
422 </td> |
423 <td class="row1" style="width: 25%;"> |
423 <td class="row1" style="width: 25%;"> |
424 <?php echo $install_date_human; ?> |
424 <?php echo $install_date_human; ?> |
425 </td> |
425 </td> |
426 <td class="row2" style="width: 25%;"> |
426 <td class="row2" style="width: 25%;"> |
427 <?php echo $lang->get('acphome_stat_lastupdate'); ?> |
427 <?php echo $lang->get('acphome_stat_lastupdate'); ?> |
428 </td> |
428 </td> |
429 <td class="row1" style="width: 25%;"> |
429 <td class="row1" style="width: 25%;"> |
430 <?php echo $last_upgrade; ?> |
430 <?php echo $last_upgrade; ?> |
431 </td> |
431 </td> |
432 </tr> |
432 </tr> |
433 |
433 |
434 <tr> |
434 <tr> |
435 <th colspan="4" class="subhead systemversion"> |
435 <th colspan="4" class="subhead systemversion"> |
436 <?php echo $lang->get('acphome_stat_enano_version', array( |
436 <?php echo $lang->get('acphome_stat_enano_version', array( |
437 'version' => enano_version(true), |
437 'version' => enano_version(true), |
438 'releasename' => enano_codename(), |
438 'releasename' => enano_codename(), |
439 'aboutlink' => makeUrlNS('Special', 'About_Enano') |
439 'aboutlink' => makeUrlNS('Special', 'About_Enano') |
440 )); ?> |
440 )); ?> |
441 </th> |
441 </th> |
442 </tr> |
442 </tr> |
443 |
443 |
444 </table> |
444 </table> |
445 </div> |
445 </div> |
446 <?php |
446 <?php |
447 } |
447 } |