includes/acp/acp_main.php
changeset 0 ceef6d64c21d
equal deleted inserted replaced
-1:000000000000 0:ceef6d64c21d
       
     1 <?php
       
     2 /**
       
     3 *
       
     4 * @package acp
       
     5 * @version $Id$
       
     6 * @copyright (c) 2005 phpBB Group
       
     7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
       
     8 *
       
     9 */
       
    10 
       
    11 /**
       
    12 * @ignore
       
    13 */
       
    14 if (!defined('IN_PHPBB'))
       
    15 {
       
    16 	exit;
       
    17 }
       
    18 
       
    19 /**
       
    20 * @package acp
       
    21 */
       
    22 class acp_main
       
    23 {
       
    24 	var $u_action;
       
    25 
       
    26 	function main($id, $mode)
       
    27 	{
       
    28 		global $config, $db, $user, $auth, $template;
       
    29 		global $phpbb_root_path, $phpbb_admin_path, $phpEx;
       
    30 
       
    31 		// Show restore permissions notice
       
    32 		if ($user->data['user_perm_from'] && $auth->acl_get('a_switchperm'))
       
    33 		{
       
    34 			$this->tpl_name = 'acp_main';
       
    35 			$this->page_title = 'ACP_MAIN';
       
    36 
       
    37 			$sql = 'SELECT user_id, username, user_colour
       
    38 				FROM ' . USERS_TABLE . '
       
    39 				WHERE user_id = ' . $user->data['user_perm_from'];
       
    40 			$result = $db->sql_query($sql);
       
    41 			$user_row = $db->sql_fetchrow($result);
       
    42 			$db->sql_freeresult($result);
       
    43 
       
    44 			$perm_from = '<strong' . (($user_row['user_colour']) ? ' style="color: #' . $user_row['user_colour'] . '">' : '>');
       
    45 			$perm_from .= ($user_row['user_id'] != ANONYMOUS) ? '<a href="' . append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&amp;u=' . $user_row['user_id']) . '">' : '';
       
    46 			$perm_from .= $user_row['username'];
       
    47 			$perm_from .= ($user_row['user_id'] != ANONYMOUS) ? '</a>' : '';
       
    48 			$perm_from .= '</strong>';
       
    49 
       
    50 			$template->assign_vars(array(
       
    51 				'S_RESTORE_PERMISSIONS'		=> true,
       
    52 				'U_RESTORE_PERMISSIONS'		=> append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=restore_perm'),
       
    53 				'PERM_FROM'					=> $perm_from,
       
    54 				'L_PERMISSIONS_TRANSFERRED_EXPLAIN'	=> sprintf($user->lang['PERMISSIONS_TRANSFERRED_EXPLAIN'], $perm_from, append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=restore_perm')),
       
    55 			));
       
    56 
       
    57 			return;
       
    58 		}
       
    59 
       
    60 		$action = request_var('action', '');
       
    61 
       
    62 		if ($action)
       
    63 		{
       
    64 			if ($action === 'admlogout')
       
    65 			{
       
    66 				$user->unset_admin();
       
    67 				$redirect_url = append_sid("{$phpbb_root_path}index.$phpEx");
       
    68 				meta_refresh(3, $redirect_url);
       
    69 				trigger_error($user->lang['ADM_LOGGED_OUT'] . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . $redirect_url . '">', '</a>'));
       
    70 			}
       
    71 
       
    72 			if (!confirm_box(true))
       
    73 			{
       
    74 				switch ($action)
       
    75 				{
       
    76 					case 'online':
       
    77 						$confirm = true;
       
    78 						$confirm_lang = 'RESET_ONLINE_CONFIRM';
       
    79 					break;
       
    80 					case 'stats':
       
    81 						$confirm = true;
       
    82 						$confirm_lang = 'RESYNC_STATS_CONFIRM';
       
    83 					break;
       
    84 					case 'user':
       
    85 						$confirm = true;
       
    86 						$confirm_lang = 'RESYNC_POSTCOUNTS_CONFIRM';
       
    87 					break;
       
    88 					case 'date':
       
    89 						$confirm = true;
       
    90 						$confirm_lang = 'RESET_DATE_CONFIRM';
       
    91 					break;
       
    92 					case 'db_track':
       
    93 						$confirm = true;
       
    94 						$confirm_lang = 'RESYNC_POST_MARKING_CONFIRM';
       
    95 					break;
       
    96 					case 'purge_cache':
       
    97 						$confirm = true;
       
    98 						$confirm_lang = 'PURGE_CACHE_CONFIRM';
       
    99 					break;
       
   100 					case 'purge_sessions':
       
   101 						$confirm = true;
       
   102 						$confirm_lang = 'PURGE_SESSIONS_CONFIRM';
       
   103 					break;
       
   104 
       
   105 					default:
       
   106 						$confirm = true;
       
   107 						$confirm_lang = 'CONFIRM_OPERATION';
       
   108 				}
       
   109 
       
   110 				if ($confirm)
       
   111 				{
       
   112 					confirm_box(false, $user->lang[$confirm_lang], build_hidden_fields(array(
       
   113 						'i'			=> $id,
       
   114 						'mode'		=> $mode,
       
   115 						'action'	=> $action,
       
   116 					)));
       
   117 				}
       
   118 			}
       
   119 			else
       
   120 			{
       
   121 				switch ($action)
       
   122 				{
       
   123 
       
   124 					case 'online':
       
   125 						if (!$auth->acl_get('a_board'))
       
   126 						{
       
   127 							trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
       
   128 						}
       
   129 
       
   130 						set_config('record_online_users', 1, true);
       
   131 						set_config('record_online_date', time(), true);
       
   132 						add_log('admin', 'LOG_RESET_ONLINE');
       
   133 					break;
       
   134 
       
   135 					case 'stats':
       
   136 						if (!$auth->acl_get('a_board'))
       
   137 						{
       
   138 							trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
       
   139 						}
       
   140 
       
   141 						$sql = 'SELECT COUNT(post_id) AS stat
       
   142 							FROM ' . POSTS_TABLE . '
       
   143 							WHERE post_approved = 1';
       
   144 						$result = $db->sql_query($sql);
       
   145 						set_config('num_posts', (int) $db->sql_fetchfield('stat'), true);
       
   146 						$db->sql_freeresult($result);
       
   147 
       
   148 						$sql = 'SELECT COUNT(topic_id) AS stat
       
   149 							FROM ' . TOPICS_TABLE . '
       
   150 							WHERE topic_approved = 1';
       
   151 						$result = $db->sql_query($sql);
       
   152 						set_config('num_topics', (int) $db->sql_fetchfield('stat'), true);
       
   153 						$db->sql_freeresult($result);
       
   154 
       
   155 						$sql = 'SELECT COUNT(user_id) AS stat
       
   156 							FROM ' . USERS_TABLE . '
       
   157 							WHERE user_type IN (' . USER_NORMAL . ',' . USER_FOUNDER . ')';
       
   158 						$result = $db->sql_query($sql);
       
   159 						set_config('num_users', (int) $db->sql_fetchfield('stat'), true);
       
   160 						$db->sql_freeresult($result);
       
   161 
       
   162 						$sql = 'SELECT COUNT(attach_id) as stat
       
   163 							FROM ' . ATTACHMENTS_TABLE . '
       
   164 							WHERE is_orphan = 0';
       
   165 						$result = $db->sql_query($sql);
       
   166 						set_config('num_files', (int) $db->sql_fetchfield('stat'), true);
       
   167 						$db->sql_freeresult($result);
       
   168 
       
   169 						$sql = 'SELECT SUM(filesize) as stat
       
   170 							FROM ' . ATTACHMENTS_TABLE . '
       
   171 							WHERE is_orphan = 0';
       
   172 						$result = $db->sql_query($sql);
       
   173 						set_config('upload_dir_size', (float) $db->sql_fetchfield('stat'), true);
       
   174 						$db->sql_freeresult($result);
       
   175 
       
   176 						if (!function_exists('update_last_username'))
       
   177 						{
       
   178 							include($phpbb_root_path . "includes/functions_user.$phpEx");
       
   179 						}
       
   180 						update_last_username();
       
   181 
       
   182 						add_log('admin', 'LOG_RESYNC_STATS');
       
   183 					break;
       
   184 
       
   185 					case 'user':
       
   186 						if (!$auth->acl_get('a_board'))
       
   187 						{
       
   188 							trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
       
   189 						}
       
   190 
       
   191 						// Resync post counts
       
   192 						$start = $max_post_id = 0;
       
   193 
       
   194 						// Find the maximum post ID, we can only stop the cycle when we've reached it
       
   195 						$sql = 'SELECT MAX(forum_last_post_id) as max_post_id
       
   196 							FROM ' . FORUMS_TABLE;
       
   197 						$result = $db->sql_query($sql);
       
   198 						$max_post_id = (int) $db->sql_fetchfield('max_post_id');
       
   199 						$db->sql_freeresult($result);
       
   200 
       
   201 						// No maximum post id? :o
       
   202 						if (!$max_post_id)
       
   203 						{
       
   204 							$sql = 'SELECT MAX(post_id)
       
   205 								FROM ' . POSTS_TABLE;
       
   206 							$result = $db->sql_query($sql);
       
   207 							$max_post_id = (int) $db->sql_fetchfield('max_post_id');
       
   208 							$db->sql_freeresult($result);
       
   209 						}
       
   210 
       
   211 						// Still no maximum post id? Then we are finished
       
   212 						if (!$max_post_id)
       
   213 						{
       
   214 							add_log('admin', 'LOG_RESYNC_POSTCOUNTS');
       
   215 							break;
       
   216 						}
       
   217 
       
   218 						$step = ($config['num_posts']) ? (max((int) ($config['num_posts'] / 5), 20000)) : 20000;
       
   219 						$db->sql_query('UPDATE ' . USERS_TABLE . ' SET user_posts = 0');
       
   220 
       
   221 						while ($start < $max_post_id)
       
   222 						{
       
   223 							$sql = 'SELECT COUNT(post_id) AS num_posts, poster_id
       
   224 								FROM ' . POSTS_TABLE . '
       
   225 								WHERE post_id BETWEEN ' . ($start + 1) . ' AND ' . ($start + $step) . '
       
   226 									AND post_postcount = 1 AND post_approved = 1
       
   227 								GROUP BY poster_id';
       
   228 							$result = $db->sql_query($sql);
       
   229 
       
   230 							if ($row = $db->sql_fetchrow($result))
       
   231 							{
       
   232 								do
       
   233 								{
       
   234 									$sql = 'UPDATE ' . USERS_TABLE . " SET user_posts = user_posts + {$row['num_posts']} WHERE user_id = {$row['poster_id']}";
       
   235 									$db->sql_query($sql);
       
   236 								}
       
   237 								while ($row = $db->sql_fetchrow($result));
       
   238 							}
       
   239 							$db->sql_freeresult($result);
       
   240 
       
   241 							$start += $step;
       
   242 						}
       
   243 
       
   244 						add_log('admin', 'LOG_RESYNC_POSTCOUNTS');
       
   245 
       
   246 					break;
       
   247 
       
   248 					case 'date':
       
   249 						if (!$auth->acl_get('a_board'))
       
   250 						{
       
   251 							trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
       
   252 						}
       
   253 
       
   254 						set_config('board_startdate', time() - 1);
       
   255 						add_log('admin', 'LOG_RESET_DATE');
       
   256 					break;
       
   257 
       
   258 					case 'db_track':
       
   259 						switch ($db->sql_layer)
       
   260 						{
       
   261 							case 'sqlite':
       
   262 							case 'firebird':
       
   263 								$db->sql_query('DELETE FROM ' . TOPICS_POSTED_TABLE);
       
   264 							break;
       
   265 
       
   266 							default:
       
   267 								$db->sql_query('TRUNCATE TABLE ' . TOPICS_POSTED_TABLE);
       
   268 							break;
       
   269 						}
       
   270 
       
   271 						// This can get really nasty... therefore we only do the last six months
       
   272 						$get_from_time = time() - (6 * 4 * 7 * 24 * 60 * 60);
       
   273 
       
   274 						// Select forum ids, do not include categories
       
   275 						$sql = 'SELECT forum_id
       
   276 							FROM ' . FORUMS_TABLE . '
       
   277 							WHERE forum_type <> ' . FORUM_CAT;
       
   278 						$result = $db->sql_query($sql);
       
   279 
       
   280 						$forum_ids = array();
       
   281 						while ($row = $db->sql_fetchrow($result))
       
   282 						{
       
   283 							$forum_ids[] = $row['forum_id'];
       
   284 						}
       
   285 						$db->sql_freeresult($result);
       
   286 
       
   287 						// Any global announcements? ;)
       
   288 						$forum_ids[] = 0;
       
   289 
       
   290 						// Now go through the forums and get us some topics...
       
   291 						foreach ($forum_ids as $forum_id)
       
   292 						{
       
   293 							$sql = 'SELECT p.poster_id, p.topic_id
       
   294 								FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t
       
   295 								WHERE t.forum_id = ' . $forum_id . '
       
   296 									AND t.topic_moved_id = 0
       
   297 									AND t.topic_last_post_time > ' . $get_from_time . '
       
   298 									AND t.topic_id = p.topic_id
       
   299 									AND p.poster_id <> ' . ANONYMOUS . '
       
   300 								GROUP BY p.poster_id, p.topic_id';
       
   301 							$result = $db->sql_query($sql);
       
   302 
       
   303 							$posted = array();
       
   304 							while ($row = $db->sql_fetchrow($result))
       
   305 							{
       
   306 								$posted[$row['poster_id']][] = $row['topic_id'];
       
   307 							}
       
   308 							$db->sql_freeresult($result);
       
   309 
       
   310 							$sql_ary = array();
       
   311 							foreach ($posted as $user_id => $topic_row)
       
   312 							{
       
   313 								foreach ($topic_row as $topic_id)
       
   314 								{
       
   315 									$sql_ary[] = array(
       
   316 										'user_id'		=> (int) $user_id,
       
   317 										'topic_id'		=> (int) $topic_id,
       
   318 										'topic_posted'	=> 1,
       
   319 									);
       
   320 								}
       
   321 							}
       
   322 							unset($posted);
       
   323 
       
   324 							if (sizeof($sql_ary))
       
   325 							{
       
   326 								$db->sql_multi_insert(TOPICS_POSTED_TABLE, $sql_ary);
       
   327 							}
       
   328 						}
       
   329 
       
   330 						add_log('admin', 'LOG_RESYNC_POST_MARKING');
       
   331 					break;
       
   332 
       
   333 					case 'purge_cache':
       
   334 						if ((int) $user->data['user_type'] !== USER_FOUNDER)
       
   335 						{
       
   336 							trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
       
   337 						}
       
   338 
       
   339 						global $cache;
       
   340 						$cache->purge();
       
   341 
       
   342 						// Clear permissions
       
   343 						$auth->acl_clear_prefetch();
       
   344 						cache_moderators();
       
   345 
       
   346 						add_log('admin', 'LOG_PURGE_CACHE');
       
   347 					break;
       
   348 
       
   349 					case 'purge_sessions':
       
   350 						if ((int) $user->data['user_type'] !== USER_FOUNDER)
       
   351 						{
       
   352 							trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
       
   353 						}
       
   354 
       
   355 						$tables = array(CONFIRM_TABLE, SESSIONS_TABLE);
       
   356 
       
   357 						foreach ($tables as $table)
       
   358 						{
       
   359 							switch ($db->sql_layer)
       
   360 							{
       
   361 								case 'sqlite':
       
   362 								case 'firebird':
       
   363 									$db->sql_query("DELETE FROM $table");
       
   364 								break;
       
   365 
       
   366 								default:
       
   367 									$db->sql_query("TRUNCATE TABLE $table");
       
   368 								break;
       
   369 							}
       
   370 						}
       
   371 
       
   372 						// let's restore the admin session
       
   373 						$reinsert_ary = array(
       
   374 								'session_id'			=> (string) $user->session_id,
       
   375 								'session_page'			=> (string) substr($user->page['page'], 0, 199),
       
   376 								'session_forum_id'		=> $user->page['forum'],
       
   377 								'session_user_id'		=> (int) $user->data['user_id'],
       
   378 								'session_start'			=> (int) $user->data['session_start'],
       
   379 								'session_last_visit'	=> (int) $user->data['session_last_visit'],
       
   380 								'session_time'			=> (int) $user->time_now,
       
   381 								'session_browser'		=> (string) trim(substr($user->browser, 0, 149)),
       
   382 								'session_forwarded_for'	=> (string) $user->forwarded_for,
       
   383 								'session_ip'			=> (string) $user->ip,
       
   384 								'session_autologin'		=> (int) $user->data['session_autologin'],
       
   385 								'session_admin'			=> 1,
       
   386 								'session_viewonline'	=> (int) $user->data['session_viewonline'],
       
   387 						);
       
   388 
       
   389 						$sql = 'INSERT INTO ' . SESSIONS_TABLE . ' ' . $db->sql_build_array('INSERT', $reinsert_ary);
       
   390 						$db->sql_query($sql);
       
   391 
       
   392 						add_log('admin', 'LOG_PURGE_SESSIONS');
       
   393 					break;
       
   394 				}
       
   395 			}
       
   396 		}
       
   397 
       
   398 		// Version check
       
   399 		$user->add_lang('install');
       
   400 
       
   401 		if ($auth->acl_get('a_server') && version_compare(PHP_VERSION, '5.2.0', '<'))
       
   402 		{
       
   403 			$template->assign_vars(array(
       
   404 				'S_PHP_VERSION_OLD'	=> true,
       
   405 				'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>'),
       
   406 			));
       
   407 		}
       
   408 
       
   409 		$latest_version_info = false;
       
   410 		if (($latest_version_info = obtain_latest_version_info(request_var('versioncheck_force', false))) === false)
       
   411 		{
       
   412 			$template->assign_var('S_VERSIONCHECK_FAIL', true);
       
   413 		}
       
   414 		else
       
   415 		{
       
   416 			$latest_version_info = explode("\n", $latest_version_info);
       
   417 
       
   418 			$template->assign_vars(array(
       
   419 				'S_VERSION_UP_TO_DATE'	=> phpbb_version_compare(trim($latest_version_info[0]), $config['version'], '<='),
       
   420 			));
       
   421 		}
       
   422 
       
   423 		// Get forum statistics
       
   424 		$total_posts = $config['num_posts'];
       
   425 		$total_topics = $config['num_topics'];
       
   426 		$total_users = $config['num_users'];
       
   427 		$total_files = $config['num_files'];
       
   428 
       
   429 		$start_date = $user->format_date($config['board_startdate']);
       
   430 
       
   431 		$boarddays = (time() - $config['board_startdate']) / 86400;
       
   432 
       
   433 		$posts_per_day = sprintf('%.2f', $total_posts / $boarddays);
       
   434 		$topics_per_day = sprintf('%.2f', $total_topics / $boarddays);
       
   435 		$users_per_day = sprintf('%.2f', $total_users / $boarddays);
       
   436 		$files_per_day = sprintf('%.2f', $total_files / $boarddays);
       
   437 
       
   438 		$upload_dir_size = get_formatted_filesize($config['upload_dir_size']);
       
   439 
       
   440 		$avatar_dir_size = 0;
       
   441 
       
   442 		if ($avatar_dir = @opendir($phpbb_root_path . $config['avatar_path']))
       
   443 		{
       
   444 			while (($file = readdir($avatar_dir)) !== false)
       
   445 			{
       
   446 				if ($file[0] != '.' && $file != 'CVS' && strpos($file, 'index.') === false)
       
   447 				{
       
   448 					$avatar_dir_size += filesize($phpbb_root_path . $config['avatar_path'] . '/' . $file);
       
   449 				}
       
   450 			}
       
   451 			closedir($avatar_dir);
       
   452 
       
   453 			$avatar_dir_size = get_formatted_filesize($avatar_dir_size);
       
   454 		}
       
   455 		else
       
   456 		{
       
   457 			// Couldn't open Avatar dir.
       
   458 			$avatar_dir_size = $user->lang['NOT_AVAILABLE'];
       
   459 		}
       
   460 
       
   461 		if ($posts_per_day > $total_posts)
       
   462 		{
       
   463 			$posts_per_day = $total_posts;
       
   464 		}
       
   465 
       
   466 		if ($topics_per_day > $total_topics)
       
   467 		{
       
   468 			$topics_per_day = $total_topics;
       
   469 		}
       
   470 
       
   471 		if ($users_per_day > $total_users)
       
   472 		{
       
   473 			$users_per_day = $total_users;
       
   474 		}
       
   475 
       
   476 		if ($files_per_day > $total_files)
       
   477 		{
       
   478 			$files_per_day = $total_files;
       
   479 		}
       
   480 
       
   481 		if ($config['allow_attachments'] || $config['allow_pm_attach'])
       
   482 		{
       
   483 			$sql = 'SELECT COUNT(attach_id) AS total_orphan
       
   484 				FROM ' . ATTACHMENTS_TABLE . '
       
   485 				WHERE is_orphan = 1
       
   486 					AND filetime < ' . (time() - 3*60*60);
       
   487 			$result = $db->sql_query($sql);
       
   488 			$total_orphan = (int) $db->sql_fetchfield('total_orphan');
       
   489 			$db->sql_freeresult($result);
       
   490 		}
       
   491 		else
       
   492 		{
       
   493 			$total_orphan = false;
       
   494 		}
       
   495 
       
   496 		$dbsize = get_database_size();
       
   497 
       
   498 		$template->assign_vars(array(
       
   499 			'TOTAL_POSTS'		=> $total_posts,
       
   500 			'POSTS_PER_DAY'		=> $posts_per_day,
       
   501 			'TOTAL_TOPICS'		=> $total_topics,
       
   502 			'TOPICS_PER_DAY'	=> $topics_per_day,
       
   503 			'TOTAL_USERS'		=> $total_users,
       
   504 			'USERS_PER_DAY'		=> $users_per_day,
       
   505 			'TOTAL_FILES'		=> $total_files,
       
   506 			'FILES_PER_DAY'		=> $files_per_day,
       
   507 			'START_DATE'		=> $start_date,
       
   508 			'AVATAR_DIR_SIZE'	=> $avatar_dir_size,
       
   509 			'DBSIZE'			=> $dbsize,
       
   510 			'UPLOAD_DIR_SIZE'	=> $upload_dir_size,
       
   511 			'TOTAL_ORPHAN'		=> $total_orphan,
       
   512 			'S_TOTAL_ORPHAN'	=> ($total_orphan === false) ? false : true,
       
   513 			'GZIP_COMPRESSION'	=> ($config['gzip_compress'] && @extension_loaded('zlib')) ? $user->lang['ON'] : $user->lang['OFF'],
       
   514 			'DATABASE_INFO'		=> $db->sql_server_info(),
       
   515 			'BOARD_VERSION'		=> $config['version'],
       
   516 
       
   517 			'U_ACTION'			=> $this->u_action,
       
   518 			'U_ADMIN_LOG'		=> append_sid("{$phpbb_admin_path}index.$phpEx", 'i=logs&amp;mode=admin'),
       
   519 			'U_INACTIVE_USERS'	=> append_sid("{$phpbb_admin_path}index.$phpEx", 'i=inactive&amp;mode=list'),
       
   520 			'U_VERSIONCHECK'	=> append_sid("{$phpbb_admin_path}index.$phpEx", 'i=update&amp;mode=version_check'),
       
   521 			'U_VERSIONCHECK_FORCE'	=> append_sid("{$phpbb_admin_path}index.$phpEx", 'versioncheck_force=1'),
       
   522 
       
   523 			'S_ACTION_OPTIONS'	=> ($auth->acl_get('a_board')) ? true : false,
       
   524 			'S_FOUNDER'			=> ($user->data['user_type'] == USER_FOUNDER) ? true : false,
       
   525 			)
       
   526 		);
       
   527 
       
   528 		$log_data = array();
       
   529 		$log_count = false;
       
   530 
       
   531 		if ($auth->acl_get('a_viewlogs'))
       
   532 		{
       
   533 			view_log('admin', $log_data, $log_count, 5);
       
   534 
       
   535 			foreach ($log_data as $row)
       
   536 			{
       
   537 				$template->assign_block_vars('log', array(
       
   538 					'USERNAME'	=> $row['username_full'],
       
   539 					'IP'		=> $row['ip'],
       
   540 					'DATE'		=> $user->format_date($row['time']),
       
   541 					'ACTION'	=> $row['action'])
       
   542 				);
       
   543 			}
       
   544 		}
       
   545 
       
   546 		if ($auth->acl_get('a_user'))
       
   547 		{
       
   548 			$user->add_lang('memberlist');
       
   549 
       
   550 			$inactive = array();
       
   551 			$inactive_count = 0;
       
   552 
       
   553 			view_inactive_users($inactive, $inactive_count, 10);
       
   554 
       
   555 			foreach ($inactive as $row)
       
   556 			{
       
   557 				$template->assign_block_vars('inactive', array(
       
   558 					'INACTIVE_DATE'	=> $user->format_date($row['user_inactive_time']),
       
   559 					'REMINDED_DATE'	=> $user->format_date($row['user_reminded_time']),
       
   560 					'JOINED'		=> $user->format_date($row['user_regdate']),
       
   561 					'LAST_VISIT'	=> (!$row['user_lastvisit']) ? ' - ' : $user->format_date($row['user_lastvisit']),
       
   562 
       
   563 					'REASON'		=> $row['inactive_reason'],
       
   564 					'USER_ID'		=> $row['user_id'],
       
   565 					'POSTS'			=> ($row['user_posts']) ? $row['user_posts'] : 0,
       
   566 					'REMINDED'		=> $row['user_reminded'],
       
   567 
       
   568 					'REMINDED_EXPLAIN'	=> $user->lang('USER_LAST_REMINDED', (int) $row['user_reminded'], $user->format_date($row['user_reminded_time'])),
       
   569 
       
   570 					'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')),
       
   571 					'USERNAME'			=> get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']),
       
   572 					'USER_COLOR'		=> get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']),
       
   573 
       
   574 					'U_USER_ADMIN'	=> append_sid("{$phpbb_admin_path}index.$phpEx", "i=users&amp;mode=overview&amp;u={$row['user_id']}"),
       
   575 					'U_SEARCH_USER'	=> ($auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", "author_id={$row['user_id']}&amp;sr=posts") : '',
       
   576 				));
       
   577 			}
       
   578 
       
   579 			$option_ary = array('activate' => 'ACTIVATE', 'delete' => 'DELETE');
       
   580 			if ($config['email_enable'])
       
   581 			{
       
   582 				$option_ary += array('remind' => 'REMIND');
       
   583 			}
       
   584 
       
   585 			$template->assign_vars(array(
       
   586 				'S_INACTIVE_USERS'		=> true,
       
   587 				'S_INACTIVE_OPTIONS'	=> build_select($option_ary))
       
   588 			);
       
   589 		}
       
   590 
       
   591 		// Warn if install is still present
       
   592 		if (file_exists($phpbb_root_path . 'install') && !is_file($phpbb_root_path . 'install'))
       
   593 		{
       
   594 			$template->assign_var('S_REMOVE_INSTALL', true);
       
   595 		}
       
   596 
       
   597 		if (!defined('PHPBB_DISABLE_CONFIG_CHECK') && file_exists($phpbb_root_path . 'config.' . $phpEx) && phpbb_is_writable($phpbb_root_path . 'config.' . $phpEx))
       
   598 		{
       
   599 			// World-Writable? (000x)
       
   600 			$template->assign_var('S_WRITABLE_CONFIG', (bool) (@fileperms($phpbb_root_path . 'config.' . $phpEx) & 0x0002));
       
   601 		}
       
   602 
       
   603 		if (extension_loaded('mbstring'))
       
   604 		{
       
   605 			$template->assign_vars(array(
       
   606 				'S_MBSTRING_LOADED'						=> true,
       
   607 				'S_MBSTRING_FUNC_OVERLOAD_FAIL'			=> (intval(@ini_get('mbstring.func_overload')) & (MB_OVERLOAD_MAIL | MB_OVERLOAD_STRING)),
       
   608 				'S_MBSTRING_ENCODING_TRANSLATION_FAIL'	=> (@ini_get('mbstring.encoding_translation') != 0),
       
   609 				'S_MBSTRING_HTTP_INPUT_FAIL'			=> (@ini_get('mbstring.http_input') != 'pass'),
       
   610 				'S_MBSTRING_HTTP_OUTPUT_FAIL'			=> (@ini_get('mbstring.http_output') != 'pass'),
       
   611 			));
       
   612 		}
       
   613 
       
   614 		// Fill dbms version if not yet filled
       
   615 		if (empty($config['dbms_version']))
       
   616 		{
       
   617 			set_config('dbms_version', $db->sql_server_info(true));
       
   618 		}
       
   619 
       
   620 		$this->tpl_name = 'acp_main';
       
   621 		$this->page_title = 'ACP_MAIN';
       
   622 	}
       
   623 }
       
   624 
       
   625 ?>