includes/acp/acp_main.php
changeset 0 ceef6d64c21d
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/includes/acp/acp_main.php	Wed Mar 07 16:41:10 2012 +0400
     1.3 @@ -0,0 +1,625 @@
     1.4 +<?php
     1.5 +/**
     1.6 +*
     1.7 +* @package acp
     1.8 +* @version $Id$
     1.9 +* @copyright (c) 2005 phpBB Group
    1.10 +* @license http://opensource.org/licenses/gpl-license.php GNU Public License
    1.11 +*
    1.12 +*/
    1.13 +
    1.14 +/**
    1.15 +* @ignore
    1.16 +*/
    1.17 +if (!defined('IN_PHPBB'))
    1.18 +{
    1.19 +	exit;
    1.20 +}
    1.21 +
    1.22 +/**
    1.23 +* @package acp
    1.24 +*/
    1.25 +class acp_main
    1.26 +{
    1.27 +	var $u_action;
    1.28 +
    1.29 +	function main($id, $mode)
    1.30 +	{
    1.31 +		global $config, $db, $user, $auth, $template;
    1.32 +		global $phpbb_root_path, $phpbb_admin_path, $phpEx;
    1.33 +
    1.34 +		// Show restore permissions notice
    1.35 +		if ($user->data['user_perm_from'] && $auth->acl_get('a_switchperm'))
    1.36 +		{
    1.37 +			$this->tpl_name = 'acp_main';
    1.38 +			$this->page_title = 'ACP_MAIN';
    1.39 +
    1.40 +			$sql = 'SELECT user_id, username, user_colour
    1.41 +				FROM ' . USERS_TABLE . '
    1.42 +				WHERE user_id = ' . $user->data['user_perm_from'];
    1.43 +			$result = $db->sql_query($sql);
    1.44 +			$user_row = $db->sql_fetchrow($result);
    1.45 +			$db->sql_freeresult($result);
    1.46 +
    1.47 +			$perm_from = '<strong' . (($user_row['user_colour']) ? ' style="color: #' . $user_row['user_colour'] . '">' : '>');
    1.48 +			$perm_from .= ($user_row['user_id'] != ANONYMOUS) ? '<a href="' . append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&amp;u=' . $user_row['user_id']) . '">' : '';
    1.49 +			$perm_from .= $user_row['username'];
    1.50 +			$perm_from .= ($user_row['user_id'] != ANONYMOUS) ? '</a>' : '';
    1.51 +			$perm_from .= '</strong>';
    1.52 +
    1.53 +			$template->assign_vars(array(
    1.54 +				'S_RESTORE_PERMISSIONS'		=> true,
    1.55 +				'U_RESTORE_PERMISSIONS'		=> append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=restore_perm'),
    1.56 +				'PERM_FROM'					=> $perm_from,
    1.57 +				'L_PERMISSIONS_TRANSFERRED_EXPLAIN'	=> sprintf($user->lang['PERMISSIONS_TRANSFERRED_EXPLAIN'], $perm_from, append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=restore_perm')),
    1.58 +			));
    1.59 +
    1.60 +			return;
    1.61 +		}
    1.62 +
    1.63 +		$action = request_var('action', '');
    1.64 +
    1.65 +		if ($action)
    1.66 +		{
    1.67 +			if ($action === 'admlogout')
    1.68 +			{
    1.69 +				$user->unset_admin();
    1.70 +				$redirect_url = append_sid("{$phpbb_root_path}index.$phpEx");
    1.71 +				meta_refresh(3, $redirect_url);
    1.72 +				trigger_error($user->lang['ADM_LOGGED_OUT'] . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . $redirect_url . '">', '</a>'));
    1.73 +			}
    1.74 +
    1.75 +			if (!confirm_box(true))
    1.76 +			{
    1.77 +				switch ($action)
    1.78 +				{
    1.79 +					case 'online':
    1.80 +						$confirm = true;
    1.81 +						$confirm_lang = 'RESET_ONLINE_CONFIRM';
    1.82 +					break;
    1.83 +					case 'stats':
    1.84 +						$confirm = true;
    1.85 +						$confirm_lang = 'RESYNC_STATS_CONFIRM';
    1.86 +					break;
    1.87 +					case 'user':
    1.88 +						$confirm = true;
    1.89 +						$confirm_lang = 'RESYNC_POSTCOUNTS_CONFIRM';
    1.90 +					break;
    1.91 +					case 'date':
    1.92 +						$confirm = true;
    1.93 +						$confirm_lang = 'RESET_DATE_CONFIRM';
    1.94 +					break;
    1.95 +					case 'db_track':
    1.96 +						$confirm = true;
    1.97 +						$confirm_lang = 'RESYNC_POST_MARKING_CONFIRM';
    1.98 +					break;
    1.99 +					case 'purge_cache':
   1.100 +						$confirm = true;
   1.101 +						$confirm_lang = 'PURGE_CACHE_CONFIRM';
   1.102 +					break;
   1.103 +					case 'purge_sessions':
   1.104 +						$confirm = true;
   1.105 +						$confirm_lang = 'PURGE_SESSIONS_CONFIRM';
   1.106 +					break;
   1.107 +
   1.108 +					default:
   1.109 +						$confirm = true;
   1.110 +						$confirm_lang = 'CONFIRM_OPERATION';
   1.111 +				}
   1.112 +
   1.113 +				if ($confirm)
   1.114 +				{
   1.115 +					confirm_box(false, $user->lang[$confirm_lang], build_hidden_fields(array(
   1.116 +						'i'			=> $id,
   1.117 +						'mode'		=> $mode,
   1.118 +						'action'	=> $action,
   1.119 +					)));
   1.120 +				}
   1.121 +			}
   1.122 +			else
   1.123 +			{
   1.124 +				switch ($action)
   1.125 +				{
   1.126 +
   1.127 +					case 'online':
   1.128 +						if (!$auth->acl_get('a_board'))
   1.129 +						{
   1.130 +							trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
   1.131 +						}
   1.132 +
   1.133 +						set_config('record_online_users', 1, true);
   1.134 +						set_config('record_online_date', time(), true);
   1.135 +						add_log('admin', 'LOG_RESET_ONLINE');
   1.136 +					break;
   1.137 +
   1.138 +					case 'stats':
   1.139 +						if (!$auth->acl_get('a_board'))
   1.140 +						{
   1.141 +							trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
   1.142 +						}
   1.143 +
   1.144 +						$sql = 'SELECT COUNT(post_id) AS stat
   1.145 +							FROM ' . POSTS_TABLE . '
   1.146 +							WHERE post_approved = 1';
   1.147 +						$result = $db->sql_query($sql);
   1.148 +						set_config('num_posts', (int) $db->sql_fetchfield('stat'), true);
   1.149 +						$db->sql_freeresult($result);
   1.150 +
   1.151 +						$sql = 'SELECT COUNT(topic_id) AS stat
   1.152 +							FROM ' . TOPICS_TABLE . '
   1.153 +							WHERE topic_approved = 1';
   1.154 +						$result = $db->sql_query($sql);
   1.155 +						set_config('num_topics', (int) $db->sql_fetchfield('stat'), true);
   1.156 +						$db->sql_freeresult($result);
   1.157 +
   1.158 +						$sql = 'SELECT COUNT(user_id) AS stat
   1.159 +							FROM ' . USERS_TABLE . '
   1.160 +							WHERE user_type IN (' . USER_NORMAL . ',' . USER_FOUNDER . ')';
   1.161 +						$result = $db->sql_query($sql);
   1.162 +						set_config('num_users', (int) $db->sql_fetchfield('stat'), true);
   1.163 +						$db->sql_freeresult($result);
   1.164 +
   1.165 +						$sql = 'SELECT COUNT(attach_id) as stat
   1.166 +							FROM ' . ATTACHMENTS_TABLE . '
   1.167 +							WHERE is_orphan = 0';
   1.168 +						$result = $db->sql_query($sql);
   1.169 +						set_config('num_files', (int) $db->sql_fetchfield('stat'), true);
   1.170 +						$db->sql_freeresult($result);
   1.171 +
   1.172 +						$sql = 'SELECT SUM(filesize) as stat
   1.173 +							FROM ' . ATTACHMENTS_TABLE . '
   1.174 +							WHERE is_orphan = 0';
   1.175 +						$result = $db->sql_query($sql);
   1.176 +						set_config('upload_dir_size', (float) $db->sql_fetchfield('stat'), true);
   1.177 +						$db->sql_freeresult($result);
   1.178 +
   1.179 +						if (!function_exists('update_last_username'))
   1.180 +						{
   1.181 +							include($phpbb_root_path . "includes/functions_user.$phpEx");
   1.182 +						}
   1.183 +						update_last_username();
   1.184 +
   1.185 +						add_log('admin', 'LOG_RESYNC_STATS');
   1.186 +					break;
   1.187 +
   1.188 +					case 'user':
   1.189 +						if (!$auth->acl_get('a_board'))
   1.190 +						{
   1.191 +							trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
   1.192 +						}
   1.193 +
   1.194 +						// Resync post counts
   1.195 +						$start = $max_post_id = 0;
   1.196 +
   1.197 +						// Find the maximum post ID, we can only stop the cycle when we've reached it
   1.198 +						$sql = 'SELECT MAX(forum_last_post_id) as max_post_id
   1.199 +							FROM ' . FORUMS_TABLE;
   1.200 +						$result = $db->sql_query($sql);
   1.201 +						$max_post_id = (int) $db->sql_fetchfield('max_post_id');
   1.202 +						$db->sql_freeresult($result);
   1.203 +
   1.204 +						// No maximum post id? :o
   1.205 +						if (!$max_post_id)
   1.206 +						{
   1.207 +							$sql = 'SELECT MAX(post_id)
   1.208 +								FROM ' . POSTS_TABLE;
   1.209 +							$result = $db->sql_query($sql);
   1.210 +							$max_post_id = (int) $db->sql_fetchfield('max_post_id');
   1.211 +							$db->sql_freeresult($result);
   1.212 +						}
   1.213 +
   1.214 +						// Still no maximum post id? Then we are finished
   1.215 +						if (!$max_post_id)
   1.216 +						{
   1.217 +							add_log('admin', 'LOG_RESYNC_POSTCOUNTS');
   1.218 +							break;
   1.219 +						}
   1.220 +
   1.221 +						$step = ($config['num_posts']) ? (max((int) ($config['num_posts'] / 5), 20000)) : 20000;
   1.222 +						$db->sql_query('UPDATE ' . USERS_TABLE . ' SET user_posts = 0');
   1.223 +
   1.224 +						while ($start < $max_post_id)
   1.225 +						{
   1.226 +							$sql = 'SELECT COUNT(post_id) AS num_posts, poster_id
   1.227 +								FROM ' . POSTS_TABLE . '
   1.228 +								WHERE post_id BETWEEN ' . ($start + 1) . ' AND ' . ($start + $step) . '
   1.229 +									AND post_postcount = 1 AND post_approved = 1
   1.230 +								GROUP BY poster_id';
   1.231 +							$result = $db->sql_query($sql);
   1.232 +
   1.233 +							if ($row = $db->sql_fetchrow($result))
   1.234 +							{
   1.235 +								do
   1.236 +								{
   1.237 +									$sql = 'UPDATE ' . USERS_TABLE . " SET user_posts = user_posts + {$row['num_posts']} WHERE user_id = {$row['poster_id']}";
   1.238 +									$db->sql_query($sql);
   1.239 +								}
   1.240 +								while ($row = $db->sql_fetchrow($result));
   1.241 +							}
   1.242 +							$db->sql_freeresult($result);
   1.243 +
   1.244 +							$start += $step;
   1.245 +						}
   1.246 +
   1.247 +						add_log('admin', 'LOG_RESYNC_POSTCOUNTS');
   1.248 +
   1.249 +					break;
   1.250 +
   1.251 +					case 'date':
   1.252 +						if (!$auth->acl_get('a_board'))
   1.253 +						{
   1.254 +							trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
   1.255 +						}
   1.256 +
   1.257 +						set_config('board_startdate', time() - 1);
   1.258 +						add_log('admin', 'LOG_RESET_DATE');
   1.259 +					break;
   1.260 +
   1.261 +					case 'db_track':
   1.262 +						switch ($db->sql_layer)
   1.263 +						{
   1.264 +							case 'sqlite':
   1.265 +							case 'firebird':
   1.266 +								$db->sql_query('DELETE FROM ' . TOPICS_POSTED_TABLE);
   1.267 +							break;
   1.268 +
   1.269 +							default:
   1.270 +								$db->sql_query('TRUNCATE TABLE ' . TOPICS_POSTED_TABLE);
   1.271 +							break;
   1.272 +						}
   1.273 +
   1.274 +						// This can get really nasty... therefore we only do the last six months
   1.275 +						$get_from_time = time() - (6 * 4 * 7 * 24 * 60 * 60);
   1.276 +
   1.277 +						// Select forum ids, do not include categories
   1.278 +						$sql = 'SELECT forum_id
   1.279 +							FROM ' . FORUMS_TABLE . '
   1.280 +							WHERE forum_type <> ' . FORUM_CAT;
   1.281 +						$result = $db->sql_query($sql);
   1.282 +
   1.283 +						$forum_ids = array();
   1.284 +						while ($row = $db->sql_fetchrow($result))
   1.285 +						{
   1.286 +							$forum_ids[] = $row['forum_id'];
   1.287 +						}
   1.288 +						$db->sql_freeresult($result);
   1.289 +
   1.290 +						// Any global announcements? ;)
   1.291 +						$forum_ids[] = 0;
   1.292 +
   1.293 +						// Now go through the forums and get us some topics...
   1.294 +						foreach ($forum_ids as $forum_id)
   1.295 +						{
   1.296 +							$sql = 'SELECT p.poster_id, p.topic_id
   1.297 +								FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t
   1.298 +								WHERE t.forum_id = ' . $forum_id . '
   1.299 +									AND t.topic_moved_id = 0
   1.300 +									AND t.topic_last_post_time > ' . $get_from_time . '
   1.301 +									AND t.topic_id = p.topic_id
   1.302 +									AND p.poster_id <> ' . ANONYMOUS . '
   1.303 +								GROUP BY p.poster_id, p.topic_id';
   1.304 +							$result = $db->sql_query($sql);
   1.305 +
   1.306 +							$posted = array();
   1.307 +							while ($row = $db->sql_fetchrow($result))
   1.308 +							{
   1.309 +								$posted[$row['poster_id']][] = $row['topic_id'];
   1.310 +							}
   1.311 +							$db->sql_freeresult($result);
   1.312 +
   1.313 +							$sql_ary = array();
   1.314 +							foreach ($posted as $user_id => $topic_row)
   1.315 +							{
   1.316 +								foreach ($topic_row as $topic_id)
   1.317 +								{
   1.318 +									$sql_ary[] = array(
   1.319 +										'user_id'		=> (int) $user_id,
   1.320 +										'topic_id'		=> (int) $topic_id,
   1.321 +										'topic_posted'	=> 1,
   1.322 +									);
   1.323 +								}
   1.324 +							}
   1.325 +							unset($posted);
   1.326 +
   1.327 +							if (sizeof($sql_ary))
   1.328 +							{
   1.329 +								$db->sql_multi_insert(TOPICS_POSTED_TABLE, $sql_ary);
   1.330 +							}
   1.331 +						}
   1.332 +
   1.333 +						add_log('admin', 'LOG_RESYNC_POST_MARKING');
   1.334 +					break;
   1.335 +
   1.336 +					case 'purge_cache':
   1.337 +						if ((int) $user->data['user_type'] !== USER_FOUNDER)
   1.338 +						{
   1.339 +							trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
   1.340 +						}
   1.341 +
   1.342 +						global $cache;
   1.343 +						$cache->purge();
   1.344 +
   1.345 +						// Clear permissions
   1.346 +						$auth->acl_clear_prefetch();
   1.347 +						cache_moderators();
   1.348 +
   1.349 +						add_log('admin', 'LOG_PURGE_CACHE');
   1.350 +					break;
   1.351 +
   1.352 +					case 'purge_sessions':
   1.353 +						if ((int) $user->data['user_type'] !== USER_FOUNDER)
   1.354 +						{
   1.355 +							trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
   1.356 +						}
   1.357 +
   1.358 +						$tables = array(CONFIRM_TABLE, SESSIONS_TABLE);
   1.359 +
   1.360 +						foreach ($tables as $table)
   1.361 +						{
   1.362 +							switch ($db->sql_layer)
   1.363 +							{
   1.364 +								case 'sqlite':
   1.365 +								case 'firebird':
   1.366 +									$db->sql_query("DELETE FROM $table");
   1.367 +								break;
   1.368 +
   1.369 +								default:
   1.370 +									$db->sql_query("TRUNCATE TABLE $table");
   1.371 +								break;
   1.372 +							}
   1.373 +						}
   1.374 +
   1.375 +						// let's restore the admin session
   1.376 +						$reinsert_ary = array(
   1.377 +								'session_id'			=> (string) $user->session_id,
   1.378 +								'session_page'			=> (string) substr($user->page['page'], 0, 199),
   1.379 +								'session_forum_id'		=> $user->page['forum'],
   1.380 +								'session_user_id'		=> (int) $user->data['user_id'],
   1.381 +								'session_start'			=> (int) $user->data['session_start'],
   1.382 +								'session_last_visit'	=> (int) $user->data['session_last_visit'],
   1.383 +								'session_time'			=> (int) $user->time_now,
   1.384 +								'session_browser'		=> (string) trim(substr($user->browser, 0, 149)),
   1.385 +								'session_forwarded_for'	=> (string) $user->forwarded_for,
   1.386 +								'session_ip'			=> (string) $user->ip,
   1.387 +								'session_autologin'		=> (int) $user->data['session_autologin'],
   1.388 +								'session_admin'			=> 1,
   1.389 +								'session_viewonline'	=> (int) $user->data['session_viewonline'],
   1.390 +						);
   1.391 +
   1.392 +						$sql = 'INSERT INTO ' . SESSIONS_TABLE . ' ' . $db->sql_build_array('INSERT', $reinsert_ary);
   1.393 +						$db->sql_query($sql);
   1.394 +
   1.395 +						add_log('admin', 'LOG_PURGE_SESSIONS');
   1.396 +					break;
   1.397 +				}
   1.398 +			}
   1.399 +		}
   1.400 +
   1.401 +		// Version check
   1.402 +		$user->add_lang('install');
   1.403 +
   1.404 +		if ($auth->acl_get('a_server') && version_compare(PHP_VERSION, '5.2.0', '<'))
   1.405 +		{
   1.406 +			$template->assign_vars(array(
   1.407 +				'S_PHP_VERSION_OLD'	=> true,
   1.408 +				'L_PHP_VERSION_OLD'	=> sprintf($user->lang['PHP_VERSION_OLD'], '<a href="http://www.phpbb.com/community/viewtopic.php?f=14&amp;t=1958605">', '</a>'),
   1.409 +			));
   1.410 +		}
   1.411 +
   1.412 +		$latest_version_info = false;
   1.413 +		if (($latest_version_info = obtain_latest_version_info(request_var('versioncheck_force', false))) === false)
   1.414 +		{
   1.415 +			$template->assign_var('S_VERSIONCHECK_FAIL', true);
   1.416 +		}
   1.417 +		else
   1.418 +		{
   1.419 +			$latest_version_info = explode("\n", $latest_version_info);
   1.420 +
   1.421 +			$template->assign_vars(array(
   1.422 +				'S_VERSION_UP_TO_DATE'	=> phpbb_version_compare(trim($latest_version_info[0]), $config['version'], '<='),
   1.423 +			));
   1.424 +		}
   1.425 +
   1.426 +		// Get forum statistics
   1.427 +		$total_posts = $config['num_posts'];
   1.428 +		$total_topics = $config['num_topics'];
   1.429 +		$total_users = $config['num_users'];
   1.430 +		$total_files = $config['num_files'];
   1.431 +
   1.432 +		$start_date = $user->format_date($config['board_startdate']);
   1.433 +
   1.434 +		$boarddays = (time() - $config['board_startdate']) / 86400;
   1.435 +
   1.436 +		$posts_per_day = sprintf('%.2f', $total_posts / $boarddays);
   1.437 +		$topics_per_day = sprintf('%.2f', $total_topics / $boarddays);
   1.438 +		$users_per_day = sprintf('%.2f', $total_users / $boarddays);
   1.439 +		$files_per_day = sprintf('%.2f', $total_files / $boarddays);
   1.440 +
   1.441 +		$upload_dir_size = get_formatted_filesize($config['upload_dir_size']);
   1.442 +
   1.443 +		$avatar_dir_size = 0;
   1.444 +
   1.445 +		if ($avatar_dir = @opendir($phpbb_root_path . $config['avatar_path']))
   1.446 +		{
   1.447 +			while (($file = readdir($avatar_dir)) !== false)
   1.448 +			{
   1.449 +				if ($file[0] != '.' && $file != 'CVS' && strpos($file, 'index.') === false)
   1.450 +				{
   1.451 +					$avatar_dir_size += filesize($phpbb_root_path . $config['avatar_path'] . '/' . $file);
   1.452 +				}
   1.453 +			}
   1.454 +			closedir($avatar_dir);
   1.455 +
   1.456 +			$avatar_dir_size = get_formatted_filesize($avatar_dir_size);
   1.457 +		}
   1.458 +		else
   1.459 +		{
   1.460 +			// Couldn't open Avatar dir.
   1.461 +			$avatar_dir_size = $user->lang['NOT_AVAILABLE'];
   1.462 +		}
   1.463 +
   1.464 +		if ($posts_per_day > $total_posts)
   1.465 +		{
   1.466 +			$posts_per_day = $total_posts;
   1.467 +		}
   1.468 +
   1.469 +		if ($topics_per_day > $total_topics)
   1.470 +		{
   1.471 +			$topics_per_day = $total_topics;
   1.472 +		}
   1.473 +
   1.474 +		if ($users_per_day > $total_users)
   1.475 +		{
   1.476 +			$users_per_day = $total_users;
   1.477 +		}
   1.478 +
   1.479 +		if ($files_per_day > $total_files)
   1.480 +		{
   1.481 +			$files_per_day = $total_files;
   1.482 +		}
   1.483 +
   1.484 +		if ($config['allow_attachments'] || $config['allow_pm_attach'])
   1.485 +		{
   1.486 +			$sql = 'SELECT COUNT(attach_id) AS total_orphan
   1.487 +				FROM ' . ATTACHMENTS_TABLE . '
   1.488 +				WHERE is_orphan = 1
   1.489 +					AND filetime < ' . (time() - 3*60*60);
   1.490 +			$result = $db->sql_query($sql);
   1.491 +			$total_orphan = (int) $db->sql_fetchfield('total_orphan');
   1.492 +			$db->sql_freeresult($result);
   1.493 +		}
   1.494 +		else
   1.495 +		{
   1.496 +			$total_orphan = false;
   1.497 +		}
   1.498 +
   1.499 +		$dbsize = get_database_size();
   1.500 +
   1.501 +		$template->assign_vars(array(
   1.502 +			'TOTAL_POSTS'		=> $total_posts,
   1.503 +			'POSTS_PER_DAY'		=> $posts_per_day,
   1.504 +			'TOTAL_TOPICS'		=> $total_topics,
   1.505 +			'TOPICS_PER_DAY'	=> $topics_per_day,
   1.506 +			'TOTAL_USERS'		=> $total_users,
   1.507 +			'USERS_PER_DAY'		=> $users_per_day,
   1.508 +			'TOTAL_FILES'		=> $total_files,
   1.509 +			'FILES_PER_DAY'		=> $files_per_day,
   1.510 +			'START_DATE'		=> $start_date,
   1.511 +			'AVATAR_DIR_SIZE'	=> $avatar_dir_size,
   1.512 +			'DBSIZE'			=> $dbsize,
   1.513 +			'UPLOAD_DIR_SIZE'	=> $upload_dir_size,
   1.514 +			'TOTAL_ORPHAN'		=> $total_orphan,
   1.515 +			'S_TOTAL_ORPHAN'	=> ($total_orphan === false) ? false : true,
   1.516 +			'GZIP_COMPRESSION'	=> ($config['gzip_compress'] && @extension_loaded('zlib')) ? $user->lang['ON'] : $user->lang['OFF'],
   1.517 +			'DATABASE_INFO'		=> $db->sql_server_info(),
   1.518 +			'BOARD_VERSION'		=> $config['version'],
   1.519 +
   1.520 +			'U_ACTION'			=> $this->u_action,
   1.521 +			'U_ADMIN_LOG'		=> append_sid("{$phpbb_admin_path}index.$phpEx", 'i=logs&amp;mode=admin'),
   1.522 +			'U_INACTIVE_USERS'	=> append_sid("{$phpbb_admin_path}index.$phpEx", 'i=inactive&amp;mode=list'),
   1.523 +			'U_VERSIONCHECK'	=> append_sid("{$phpbb_admin_path}index.$phpEx", 'i=update&amp;mode=version_check'),
   1.524 +			'U_VERSIONCHECK_FORCE'	=> append_sid("{$phpbb_admin_path}index.$phpEx", 'versioncheck_force=1'),
   1.525 +
   1.526 +			'S_ACTION_OPTIONS'	=> ($auth->acl_get('a_board')) ? true : false,
   1.527 +			'S_FOUNDER'			=> ($user->data['user_type'] == USER_FOUNDER) ? true : false,
   1.528 +			)
   1.529 +		);
   1.530 +
   1.531 +		$log_data = array();
   1.532 +		$log_count = false;
   1.533 +
   1.534 +		if ($auth->acl_get('a_viewlogs'))
   1.535 +		{
   1.536 +			view_log('admin', $log_data, $log_count, 5);
   1.537 +
   1.538 +			foreach ($log_data as $row)
   1.539 +			{
   1.540 +				$template->assign_block_vars('log', array(
   1.541 +					'USERNAME'	=> $row['username_full'],
   1.542 +					'IP'		=> $row['ip'],
   1.543 +					'DATE'		=> $user->format_date($row['time']),
   1.544 +					'ACTION'	=> $row['action'])
   1.545 +				);
   1.546 +			}
   1.547 +		}
   1.548 +
   1.549 +		if ($auth->acl_get('a_user'))
   1.550 +		{
   1.551 +			$user->add_lang('memberlist');
   1.552 +
   1.553 +			$inactive = array();
   1.554 +			$inactive_count = 0;
   1.555 +
   1.556 +			view_inactive_users($inactive, $inactive_count, 10);
   1.557 +
   1.558 +			foreach ($inactive as $row)
   1.559 +			{
   1.560 +				$template->assign_block_vars('inactive', array(
   1.561 +					'INACTIVE_DATE'	=> $user->format_date($row['user_inactive_time']),
   1.562 +					'REMINDED_DATE'	=> $user->format_date($row['user_reminded_time']),
   1.563 +					'JOINED'		=> $user->format_date($row['user_regdate']),
   1.564 +					'LAST_VISIT'	=> (!$row['user_lastvisit']) ? ' - ' : $user->format_date($row['user_lastvisit']),
   1.565 +
   1.566 +					'REASON'		=> $row['inactive_reason'],
   1.567 +					'USER_ID'		=> $row['user_id'],
   1.568 +					'POSTS'			=> ($row['user_posts']) ? $row['user_posts'] : 0,
   1.569 +					'REMINDED'		=> $row['user_reminded'],
   1.570 +
   1.571 +					'REMINDED_EXPLAIN'	=> $user->lang('USER_LAST_REMINDED', (int) $row['user_reminded'], $user->format_date($row['user_reminded_time'])),
   1.572 +
   1.573 +					'USERNAME_FULL'		=> get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], false, append_sid("{$phpbb_admin_path}index.$phpEx", 'i=users&amp;mode=overview')),
   1.574 +					'USERNAME'			=> get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']),
   1.575 +					'USER_COLOR'		=> get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']),
   1.576 +
   1.577 +					'U_USER_ADMIN'	=> append_sid("{$phpbb_admin_path}index.$phpEx", "i=users&amp;mode=overview&amp;u={$row['user_id']}"),
   1.578 +					'U_SEARCH_USER'	=> ($auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", "author_id={$row['user_id']}&amp;sr=posts") : '',
   1.579 +				));
   1.580 +			}
   1.581 +
   1.582 +			$option_ary = array('activate' => 'ACTIVATE', 'delete' => 'DELETE');
   1.583 +			if ($config['email_enable'])
   1.584 +			{
   1.585 +				$option_ary += array('remind' => 'REMIND');
   1.586 +			}
   1.587 +
   1.588 +			$template->assign_vars(array(
   1.589 +				'S_INACTIVE_USERS'		=> true,
   1.590 +				'S_INACTIVE_OPTIONS'	=> build_select($option_ary))
   1.591 +			);
   1.592 +		}
   1.593 +
   1.594 +		// Warn if install is still present
   1.595 +		if (file_exists($phpbb_root_path . 'install') && !is_file($phpbb_root_path . 'install'))
   1.596 +		{
   1.597 +			$template->assign_var('S_REMOVE_INSTALL', true);
   1.598 +		}
   1.599 +
   1.600 +		if (!defined('PHPBB_DISABLE_CONFIG_CHECK') && file_exists($phpbb_root_path . 'config.' . $phpEx) && phpbb_is_writable($phpbb_root_path . 'config.' . $phpEx))
   1.601 +		{
   1.602 +			// World-Writable? (000x)
   1.603 +			$template->assign_var('S_WRITABLE_CONFIG', (bool) (@fileperms($phpbb_root_path . 'config.' . $phpEx) & 0x0002));
   1.604 +		}
   1.605 +
   1.606 +		if (extension_loaded('mbstring'))
   1.607 +		{
   1.608 +			$template->assign_vars(array(
   1.609 +				'S_MBSTRING_LOADED'						=> true,
   1.610 +				'S_MBSTRING_FUNC_OVERLOAD_FAIL'			=> (intval(@ini_get('mbstring.func_overload')) & (MB_OVERLOAD_MAIL | MB_OVERLOAD_STRING)),
   1.611 +				'S_MBSTRING_ENCODING_TRANSLATION_FAIL'	=> (@ini_get('mbstring.encoding_translation') != 0),
   1.612 +				'S_MBSTRING_HTTP_INPUT_FAIL'			=> (@ini_get('mbstring.http_input') != 'pass'),
   1.613 +				'S_MBSTRING_HTTP_OUTPUT_FAIL'			=> (@ini_get('mbstring.http_output') != 'pass'),
   1.614 +			));
   1.615 +		}
   1.616 +
   1.617 +		// Fill dbms version if not yet filled
   1.618 +		if (empty($config['dbms_version']))
   1.619 +		{
   1.620 +			set_config('dbms_version', $db->sql_server_info(true));
   1.621 +		}
   1.622 +
   1.623 +		$this->tpl_name = 'acp_main';
   1.624 +		$this->page_title = 'ACP_MAIN';
   1.625 +	}
   1.626 +}
   1.627 +
   1.628 +?>
   1.629 \ No newline at end of file