Verzeichnisstruktur phpBB-3.0.0
- Veröffentlicht
- 12.12.2007
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
acp_main.php
001 <?php
002 /**
003 *
004 * @package acp
005 * @version $Id$
006 * @copyright (c) 2005 phpBB Group
007 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
008 *
009 */
010
011 /**
012 * @ignore
013 */
014 if (!defined('IN_PHPBB'))
015 {
016 exit;
017 }
018
019 /**
020 * @package acp
021 */
022 class acp_main
023 {
024 var $u_action;
025
026 function main($id, $mode)
027 {
028 global $config, $db, $user, $auth, $template;
029 global $phpbb_root_path, $phpbb_admin_path, $phpEx;
030
031 // Show restore permissions notice
032 if ($user->data['user_perm_from'] && $auth->acl_get('a_switchperm'))
033 {
034 $this->tpl_name = 'acp_main';
035 $this->page_title = 'ACP_MAIN';
036
037 $sql = 'SELECT user_id, username, user_colour
038 FROM ' . USERS_TABLE . '
039 WHERE user_id = ' . $user->data['user_perm_from'];
040 $result = $db->sql_query($sql);
041 $user_row = $db->sql_fetchrow($result);
042 $db->sql_freeresult($result);
043
044 $perm_from = '<strong' . (($user_row['user_colour']) ? ' style="color: #' . $user_row['user_colour'] . '">' : '>');
045 $perm_from .= ($user_row['user_id'] != ANONYMOUS) ? '<a href="' . append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&u=' . $user_row['user_id']) . '">' : '';
046 $perm_from .= $user_row['username'];
047 $perm_from .= ($user_row['user_id'] != ANONYMOUS) ? '</a>' : '';
048 $perm_from .= '</strong>';
049
050 $template->assign_vars(array(
051 'S_RESTORE_PERMISSIONS' => true,
052 'U_RESTORE_PERMISSIONS' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=restore_perm'),
053 'PERM_FROM' => $perm_from,
054 'L_PERMISSIONS_TRANSFERRED_EXPLAIN' => sprintf($user->lang['PERMISSIONS_TRANSFERRED_EXPLAIN'], $perm_from, append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=restore_perm')),
055 ));
056
057 return;
058 }
059
060 $action = request_var('action', '');
061
062 if ($action)
063 {
064 if (!confirm_box(true))
065 {
066 switch ($action)
067 {
068 case 'online':
069 $confirm = true;
070 $confirm_lang = 'RESET_ONLINE_CONFIRM';
071 break;
072 case 'stats':
073 $confirm = true;
074 $confirm_lang = 'RESYNC_STATS_CONFIRM';
075 break;
076 case 'user':
077 $confirm = true;
078 $confirm_lang = 'RESYNC_POSTCOUNTS_CONFIRM';
079 break;
080 case 'date':
081 $confirm = true;
082 $confirm_lang = 'RESET_DATE_CONFIRM';
083 break;
084 case 'db_track':
085 $confirm = true;
086 $confirm_lang = 'RESYNC_POST_MARKING_CONFIRM';
087 break;
088 case 'purge_cache':
089 $confirm = true;
090 $confirm_lang = 'PURGE_CACHE_CONFIRM';
091 break;
092
093 default:
094 $confirm = true;
095 $confirm_lang = 'CONFIRM_OPERATION';
096 }
097
098 if ($confirm)
099 {
100 confirm_box(false, $user->lang[$confirm_lang], build_hidden_fields(array(
101 'i' => $id,
102 'mode' => $mode,
103 'action' => $action,
104 )));
105 }
106 }
107 else
108 {
109 switch ($action)
110 {
111 case 'online':
112 if (!$auth->acl_get('a_board'))
113 {
114 trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
115 }
116
117 set_config('record_online_users', 1, true);
118 set_config('record_online_date', time(), true);
119 add_log('admin', 'LOG_RESET_ONLINE');
120 break;
121
122 case 'stats':
123 if (!$auth->acl_get('a_board'))
124 {
125 trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
126 }
127
128 $sql = 'SELECT COUNT(post_id) AS stat
129 FROM ' . POSTS_TABLE . '
130 WHERE post_approved = 1';
131 $result = $db->sql_query($sql);
132 set_config('num_posts', (int) $db->sql_fetchfield('stat'), true);
133 $db->sql_freeresult($result);
134
135 $sql = 'SELECT COUNT(topic_id) AS stat
136 FROM ' . TOPICS_TABLE . '
137 WHERE topic_approved = 1';
138 $result = $db->sql_query($sql);
139 set_config('num_topics', (int) $db->sql_fetchfield('stat'), true);
140 $db->sql_freeresult($result);
141
142 $sql = 'SELECT COUNT(user_id) AS stat
143 FROM ' . USERS_TABLE . '
144 WHERE user_type IN (' . USER_NORMAL . ',' . USER_FOUNDER . ')';
145 $result = $db->sql_query($sql);
146 set_config('num_users', (int) $db->sql_fetchfield('stat'), true);
147 $db->sql_freeresult($result);
148
149 $sql = 'SELECT COUNT(attach_id) as stat
150 FROM ' . ATTACHMENTS_TABLE . '
151 WHERE is_orphan = 0';
152 $result = $db->sql_query($sql);
153 set_config('num_files', (int) $db->sql_fetchfield('stat'), true);
154 $db->sql_freeresult($result);
155
156 $sql = 'SELECT SUM(filesize) as stat
157 FROM ' . ATTACHMENTS_TABLE . '
158 WHERE is_orphan = 0';
159 $result = $db->sql_query($sql);
160 set_config('upload_dir_size', (int) $db->sql_fetchfield('stat'), true);
161 $db->sql_freeresult($result);
162
163 if (!function_exists('update_last_username'))
164 {
165 include($phpbb_root_path . "includes/functions_user.$phpEx");
166 }
167 update_last_username();
168
169 add_log('admin', 'LOG_RESYNC_STATS');
170 break;
171
172 case 'user':
173 if (!$auth->acl_get('a_board'))
174 {
175 trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
176 }
177
178 $sql = 'SELECT COUNT(p.post_id) AS num_posts, u.user_id
179 FROM ' . USERS_TABLE . ' u
180 LEFT JOIN ' . POSTS_TABLE . ' p ON (u.user_id = p.poster_id AND p.post_postcount = 1)
181 GROUP BY u.user_id';
182 $result = $db->sql_query($sql);
183
184 while ($row = $db->sql_fetchrow($result))
185 {
186 $db->sql_query('UPDATE ' . USERS_TABLE . " SET user_posts = {$row['num_posts']} WHERE user_id = {$row['user_id']}");
187 }
188 $db->sql_freeresult($result);
189
190 add_log('admin', 'LOG_RESYNC_POSTCOUNTS');
191
192 break;
193
194 case 'date':
195 if (!$auth->acl_get('a_board'))
196 {
197 trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
198 }
199
200 set_config('board_startdate', time() - 1);
201 add_log('admin', 'LOG_RESET_DATE');
202 break;
203
204 case 'db_track':
205 switch ($db->sql_layer)
206 {
207 case 'sqlite':
208 case 'firebird':
209 $db->sql_query('DELETE FROM ' . TOPICS_POSTED_TABLE);
210 break;
211
212 default:
213 $db->sql_query('TRUNCATE TABLE ' . TOPICS_POSTED_TABLE);
214 break;
215 }
216
217 // This can get really nasty... therefore we only do the last six months
218 $get_from_time = time() - (6 * 4 * 7 * 24 * 60 * 60);
219
220 // Select forum ids, do not include categories
221 $sql = 'SELECT forum_id
222 FROM ' . FORUMS_TABLE . '
223 WHERE forum_type <> ' . FORUM_CAT;
224 $result = $db->sql_query($sql);
225
226 $forum_ids = array();
227 while ($row = $db->sql_fetchrow($result))
228 {
229 $forum_ids[] = $row['forum_id'];
230 }
231 $db->sql_freeresult($result);
232
233 // Any global announcements? ;)
234 $forum_ids[] = 0;
235
236 // Now go through the forums and get us some topics...
237 foreach ($forum_ids as $forum_id)
238 {
239 $sql = 'SELECT p.poster_id, p.topic_id
240 FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t
241 WHERE t.forum_id = ' . $forum_id . '
242 AND t.topic_moved_id = 0
243 AND t.topic_last_post_time > ' . $get_from_time . '
244 AND t.topic_id = p.topic_id
245 AND p.poster_id <> ' . ANONYMOUS . '
246 GROUP BY p.poster_id, p.topic_id';
247 $result = $db->sql_query($sql);
248
249 $posted = array();
250 while ($row = $db->sql_fetchrow($result))
251 {
252 $posted[$row['poster_id']][] = $row['topic_id'];
253 }
254 $db->sql_freeresult($result);
255
256 $sql_ary = array();
257 foreach ($posted as $user_id => $topic_row)
258 {
259 foreach ($topic_row as $topic_id)
260 {
261 $sql_ary[] = array(
262 'user_id' => (int) $user_id,
263 'topic_id' => (int) $topic_id,
264 'topic_posted' => 1,
265 );
266 }
267 }
268 unset($posted);
269
270 if (sizeof($sql_ary))
271 {
272 $db->sql_multi_insert(TOPICS_POSTED_TABLE, $sql_ary);
273 }
274 }
275
276 add_log('admin', 'LOG_RESYNC_POST_MARKING');
277 break;
278
279 case 'purge_cache':
280 if ((int) $user->data['user_type'] !== USER_FOUNDER)
281 {
282 trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
283 }
284
285 global $cache;
286 $cache->purge();
287
288 // Clear permissions
289 $auth->acl_clear_prefetch();
290 cache_moderators();
291
292 add_log('admin', 'LOG_PURGE_CACHE');
293 break;
294 }
295 }
296 }
297
298 // Get forum statistics
299 $total_posts = $config['num_posts'];
300 $total_topics = $config['num_topics'];
301 $total_users = $config['num_users'];
302 $total_files = $config['num_files'];
303
304 $start_date = $user->format_date($config['board_startdate']);
305
306 $boarddays = (time() - $config['board_startdate']) / 86400;
307
308 $posts_per_day = sprintf('%.2f', $total_posts / $boarddays);
309 $topics_per_day = sprintf('%.2f', $total_topics / $boarddays);
310 $users_per_day = sprintf('%.2f', $total_users / $boarddays);
311 $files_per_day = sprintf('%.2f', $total_files / $boarddays);
312
313 $upload_dir_size = ($config['upload_dir_size'] >= 1048576) ? sprintf('%.2f ' . $user->lang['MB'], ($config['upload_dir_size'] / 1048576)) : (($config['upload_dir_size'] >= 1024) ? sprintf('%.2f ' . $user->lang['KB'], ($config['upload_dir_size'] / 1024)) : sprintf('%.2f ' . $user->lang['BYTES'], $config['upload_dir_size']));
314
315 $avatar_dir_size = 0;
316
317 if ($avatar_dir = @opendir($phpbb_root_path . $config['avatar_path']))
318 {
319 while (($file = readdir($avatar_dir)) !== false)
320 {
321 if ($file[0] != '.' && $file != 'CVS' && strpos($file, 'index.') === false)
322 {
323 $avatar_dir_size += filesize($phpbb_root_path . $config['avatar_path'] . '/' . $file);
324 }
325 }
326 closedir($avatar_dir);
327
328 // This bit of code translates the avatar directory size into human readable format
329 // Borrowed the code from the PHP.net annoted manual, origanally written by:
330 // Jesse (jesse@jess.on.ca)
331 $avatar_dir_size = ($avatar_dir_size >= 1048576) ? sprintf('%.2f ' . $user->lang['MB'], ($avatar_dir_size / 1048576)) : (($avatar_dir_size >= 1024) ? sprintf('%.2f ' . $user->lang['KB'], ($avatar_dir_size / 1024)) : sprintf('%.2f ' . $user->lang['BYTES'], $avatar_dir_size));
332 }
333 else
334 {
335 // Couldn't open Avatar dir.
336 $avatar_dir_size = $user->lang['NOT_AVAILABLE'];
337 }
338
339 if ($posts_per_day > $total_posts)
340 {
341 $posts_per_day = $total_posts;
342 }
343
344 if ($topics_per_day > $total_topics)
345 {
346 $topics_per_day = $total_topics;
347 }
348
349 if ($users_per_day > $total_users)
350 {
351 $users_per_day = $total_users;
352 }
353
354 if ($files_per_day > $total_files)
355 {
356 $files_per_day = $total_files;
357 }
358
359 if ($config['allow_attachments'] || $config['allow_pm_attach'])
360 {
361 $sql = 'SELECT COUNT(attach_id) AS total_orphan
362 FROM ' . ATTACHMENTS_TABLE . '
363 WHERE is_orphan = 1
364 AND filetime < ' . (time() - 3*60*60);
365 $result = $db->sql_query($sql);
366 $total_orphan = (int) $db->sql_fetchfield('total_orphan');
367 $db->sql_freeresult($result);
368 }
369 else
370 {
371 $total_orphan = false;
372 }
373
374 $dbsize = get_database_size();
375
376 $template->assign_vars(array(
377 'TOTAL_POSTS' => $total_posts,
378 'POSTS_PER_DAY' => $posts_per_day,
379 'TOTAL_TOPICS' => $total_topics,
380 'TOPICS_PER_DAY' => $topics_per_day,
381 'TOTAL_USERS' => $total_users,
382 'USERS_PER_DAY' => $users_per_day,
383 'TOTAL_FILES' => $total_files,
384 'FILES_PER_DAY' => $files_per_day,
385 'START_DATE' => $start_date,
386 'AVATAR_DIR_SIZE' => $avatar_dir_size,
387 'DBSIZE' => $dbsize,
388 'UPLOAD_DIR_SIZE' => $upload_dir_size,
389 'TOTAL_ORPHAN' => $total_orphan,
390 'S_TOTAL_ORPHAN' => ($total_orphan === false) ? false : true,
391 'GZIP_COMPRESSION' => ($config['gzip_compress']) ? $user->lang['ON'] : $user->lang['OFF'],
392 'DATABASE_INFO' => $db->sql_server_info(),
393 'BOARD_VERSION' => $config['version'],
394
395 'U_ACTION' => append_sid("{$phpbb_admin_path}index.$phpEx"),
396 'U_ADMIN_LOG' => append_sid("{$phpbb_admin_path}index.$phpEx", 'i=logs&mode=admin'),
397 'U_INACTIVE_USERS' => append_sid("{$phpbb_admin_path}index.$phpEx", 'i=inactive&mode=list'),
398
399 'S_ACTION_OPTIONS' => ($auth->acl_get('a_board')) ? true : false,
400 'S_FOUNDER' => ($user->data['user_type'] == USER_FOUNDER) ? true : false,
401 )
402 );
403
404 $log_data = array();
405 $log_count = 0;
406
407 if ($auth->acl_get('a_viewlogs'))
408 {
409 view_log('admin', $log_data, $log_count, 5);
410
411 foreach ($log_data as $row)
412 {
413 $template->assign_block_vars('log', array(
414 'USERNAME' => $row['username_full'],
415 'IP' => $row['ip'],
416 'DATE' => $user->format_date($row['time']),
417 'ACTION' => $row['action'])
418 );
419 }
420 }
421
422 if ($auth->acl_get('a_user'))
423 {
424 $inactive = array();
425 $inactive_count = 0;
426
427 view_inactive_users($inactive, $inactive_count, 10);
428
429 foreach ($inactive as $row)
430 {
431 $template->assign_block_vars('inactive', array(
432 'INACTIVE_DATE' => $user->format_date($row['user_inactive_time']),
433 'JOINED' => $user->format_date($row['user_regdate']),
434 'LAST_VISIT' => (!$row['user_lastvisit']) ? ' - ' : $user->format_date($row['user_lastvisit']),
435 'REASON' => $row['inactive_reason'],
436 'USER_ID' => $row['user_id'],
437 'USERNAME' => $row['username'],
438 'U_USER_ADMIN' => append_sid("{$phpbb_admin_path}index.$phpEx", "i=users&mode=overview&u={$row['user_id']}"))
439 );
440 }
441
442 $option_ary = array('activate' => 'ACTIVATE', 'delete' => 'DELETE');
443 if ($config['email_enable'])
444 {
445 $option_ary += array('remind' => 'REMIND');
446 }
447
448 $template->assign_vars(array(
449 'S_INACTIVE_USERS' => true,
450 'S_INACTIVE_OPTIONS' => build_select($option_ary))
451 );
452 }
453
454 // Warn if install is still present
455 if (file_exists($phpbb_root_path . 'install'))
456 {
457 $template->assign_var('S_REMOVE_INSTALL', true);
458 }
459
460 $this->tpl_name = 'acp_main';
461 $this->page_title = 'ACP_MAIN';
462 }
463 }
464
465 ?>