aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/adm/index.php
diff options
context:
space:
mode:
authorMeik Sievertsen <acydburn@phpbb.com>2005-12-19 18:55:52 +0000
committerMeik Sievertsen <acydburn@phpbb.com>2005-12-19 18:55:52 +0000
commit1855c017e95795966149c6c265a7588f8f5ad19e (patch)
tree63862425f20f4c478cf4fd3effbcfeb9572c846a /phpBB/adm/index.php
parent738bf09f92d6c268c71c8f38311c8af7d2659db1 (diff)
downloadforums-1855c017e95795966149c6c265a7588f8f5ad19e.tar
forums-1855c017e95795966149c6c265a7588f8f5ad19e.tar.gz
forums-1855c017e95795966149c6c265a7588f8f5ad19e.tar.bz2
forums-1855c017e95795966149c6c265a7588f8f5ad19e.tar.xz
forums-1855c017e95795966149c6c265a7588f8f5ad19e.zip
- drop in the new administration panel
- not finished yet: some user related items, style admin, database admin and permissions - Graham: Please add your MCP schema data to the schema data file. ;) git-svn-id: file:///svn/phpbb/trunk@5357 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/adm/index.php')
-rw-r--r--phpBB/adm/index.php850
1 files changed, 230 insertions, 620 deletions
diff --git a/phpBB/adm/index.php b/phpBB/adm/index.php
index 050a698256..a2499451c0 100644
--- a/phpBB/adm/index.php
+++ b/phpBB/adm/index.php
@@ -11,720 +11,330 @@
/**
*/
define('IN_PHPBB', 1);
+define('IN_ADMIN', true);
+define('NEED_SID', true);
+
// Include files
$phpbb_root_path = './../';
+$phpbb_admin_path = './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
-require('pagestart.' . $phpEx);
+require($phpbb_root_path . 'common.'.$phpEx);
+require($phpbb_root_path . 'includes/functions_admin.'.$phpEx);
+require($phpbb_root_path . 'includes/functions_module.'.$phpEx);
+
+// Start session management
+$user->session_begin();
+$auth->acl($user->data);
+$user->setup('acp/common');
+// End session management
+
+// Did user forget to login? Give 'em a chance to here ...
+if ($user->data['user_id'] == ANONYMOUS)
+{
+ login_box('', $user->lang['LOGIN_ADMIN'], $user->lang['LOGIN_ADMIN_SUCCESS'], true);
+}
-// Do we have any admin permissions at all?
+// Have they authenticated (again) as an admin for this session?
+if (!isset($user->data['session_admin']) || !$user->data['session_admin'])
+{
+ login_box('', $user->lang['LOGIN_ADMIN_CONFIRM'], $user->lang['LOGIN_ADMIN_SUCCESS'], true, false);
+}
+
+// Is user any type of admin? No, then stop here, each script needs to
+// check specific permissions but this is a catchall
if (!$auth->acl_get('a_'))
{
trigger_error($user->lang['NO_ADMIN']);
}
-// Define some vars
-$pane = request_var('pane', '');
+// Some oft used variables
+$safe_mode = (@ini_get('safe_mode') || @strtolower(ini_get('safe_mode')) == 'on') ? true : false;
+$file_uploads = (@ini_get('file_uploads') || strtolower(@ini_get('file_uploads')) == 'on') ? true : false;
+$module_id = request_var('i', '');
+$mode = request_var('mode', '');
-// Generate relevant output
-if ($pane == 'top')
-{
- adm_page_header('', '', false);
+$user->theme['primary']['pagination_sep'] = '';
-?>
+// Set custom template for admin area
+$template->set_custom_template($phpbb_admin_path . 'style', 'admin');
-<table width="100%" cellspacing="0" cellpadding="0" border="0">
- <tr>
- <td><a href="<?php echo "{$phpbb_root_path}index.$phpEx$SID"; ?>" target="_top"><img src="images/header_left.jpg" width="200" height="60" alt="phpBB Logo" title="phpBB Logo" border="0"/></a></td>
- <td width="100%" background="images/header_bg.jpg" height="60" align="right" nowrap="nowrap"><span class="maintitle"><?php echo $user->lang['ADMIN_TITLE']; ?></span> &nbsp; &nbsp; &nbsp;</td>
- </tr>
-</table>
+// Instantiate new module
+$module = new p_master();
-<?php
+// Instantiate module system and generate list of available modules
+$module->list_modules('acp');
- adm_page_footer(false);
+// Select the active module
+$module->set_active($module_id, $mode);
-}
-else if ($pane == 'left')
-{
- // Cheat and use the meta tag to change some stylesheet info
- adm_page_header('', '<style type="text/css">body {background-color: #98AAB1}</style>', false);
+// Assign data to the template engine for the list of modules
+// We do this before loading the active module for correct menu display in trigger_error
+$module->assign_tpl_vars("{$phpbb_admin_path}index.$phpEx$SID");
+
+// Load and execute the relevant module
+$module->load_active();
- // Grab module information using Bart's "neat-o-module" system (tm)
- $dir = @opendir('.');
+// Generate the page
+adm_page_header($module->get_page_title());
- $setmodules = 1;
- while ($file = readdir($dir))
+$template->set_filenames(array(
+ 'body' => $module->get_tpl_name())
+);
+
+adm_page_footer();
+
+// ---------
+// FUNCTIONS
+//
+function adm_page_header($page_title)
+{
+ global $config, $db, $user, $template;
+ global $phpbb_root_path, $phpbb_admin_path, $phpEx, $SID;
+
+ if (defined('HEADER_INC'))
{
- if (preg_match('#^admin_(.*?)\.' . $phpEx . '$#', $file))
- {
- include($file);
- }
+ return;
}
- @closedir($dir);
-
- unset($setmodules);
-
-?>
-
-<table width="100%" cellpadding="0" cellspacing="0" border="0">
- <tr>
- <td width="100%"><table width="100%" cellpadding="4" cellspacing="1" border="0">
- <tr>
- <th class="menu" height="25">&#0187; <?php echo $user->lang['RETURN_TO']; ?></th>
- </tr>
- <tr>
- <td class="row1"><a class="genmed" href="<?php echo "index.$phpEx$SID"; ?>&amp;pane=right" target="main"><?php echo $user->lang['ADMIN_INDEX']; ?></a></td>
- </tr>
- <tr>
- <td class="row2"><a class="genmed" href="<?php echo "../index.$phpEx$SID"; ?>" target="_top"><?php echo $user->lang['FORUM_INDEX']; ?></a></td>
- </tr>
-<?php
+
+ define('HEADER_INC', true);
- if (is_array($module))
+ // gzip_compression
+ if ($config['gzip_compress'])
{
- @ksort($module);
- foreach ($module as $cat => $action_ary)
+ if (extension_loaded('zlib') && !headers_sent())
{
- $cat = (!empty($user->lang[$cat . '_CAT'])) ? $user->lang[$cat . '_CAT'] : preg_replace('#_#', ' ', $cat);
-
-?>
- <tr>
- <th class="menu" height="25">&#0187; <?php echo $cat; ?></th>
- </tr>
-<?php
+ ob_start('ob_gzhandler');
+ }
+ }
- @ksort($action_ary);
+ $template->assign_vars(array(
+ 'PAGE_TITLE' => $page_title,
+ 'USERNAME' => $user->data['username'],
+ 'ROOT_PATH' => $phpbb_admin_path,
- $row_class = '';
- foreach ($action_ary as $action => $file)
- {
- if (!empty($file))
- {
- $action = (!empty($user->lang[$action])) ? $user->lang[$action] : preg_replace('#_#', ' ', $action);
+ 'U_LOGOUT' => "{$phpbb_root_path}ucp.$phpEx$SID&amp;mode=logout",
+ 'U_ADM_INDEX' => "{$phpbb_admin_path}index.$phpEx$SID",
+ 'U_INDEX' => "{$phpbb_root_path}index.$phpEx$SID",
- $row_class = ($row_class == 'row1') ? 'row2' : 'row1';
-?>
- <tr>
- <td class="<?php echo $row_class; ?>"><a class="genmed" href="<?php echo $file; ?>" target="main"><?php echo $action; ?></a></td>
- </tr>
-<?php
+ 'S_CONTENT_DIRECTION' => $user->lang['DIRECTION'],
+ 'S_CONTENT_ENCODING' => $user->lang['ENCODING'],
+ 'S_CONTENT_DIR_LEFT' => $user->lang['LEFT'],
+ 'S_CONTENT_DIR_RIGHT' => $user->lang['RIGHT'],
+ )
+ );
- }
- }
- }
+ if (!empty($config['send_encoding']))
+ {
+ header('Content-type: text/html; charset: ' . $user->lang['ENCODING']);
}
+ header('Cache-Control: private, no-cache="set-cookie", pre-check=0, post-check=0');
+ header('Expires: 0');
+ header('Pragma: no-cache');
-?>
- </table></td>
- </tr>
-</table>
-</body>
-</html>
-<?php
-
- // Output footer but don't include copyright info
- adm_page_footer(false);
-
+ return;
}
-elseif ($pane == 'right')
+
+function adm_page_footer($copyright_html = true)
{
- $action = request_var('action', '');
- $mark = (isset($_REQUEST['mark'])) ? implode(', ', request_var('mark', array(0))) : '';
+ global $db, $config, $template, $SID, $user, $auth, $starttime, $phpbb_root_path, $phpEx;
- if ($mark)
+ // Output page creation time
+ if (defined('DEBUG'))
{
- switch ($action)
- {
- case 'activate':
- case 'delete':
- if (!$auth->acl_get('a_user'))
- {
- trigger_error($user->lang['NO_ADMIN']);
- }
+ $mtime = explode(' ', microtime());
+ $totaltime = $mtime[0] + $mtime[1] - $starttime;
- $sql = 'SELECT username
- FROM ' . USERS_TABLE . "
- WHERE user_id IN ($mark)";
- $result = $db->sql_query($sql);
-
- $user_affected = array();
- while ($row = $db->sql_fetchrow($result))
- {
- $user_affected[] = $row['username'];
- }
- $db->sql_freeresult($result);
+ if (!empty($_REQUEST['explain']) && $auth->acl_get('a_') && method_exists($db, 'sql_report'))
+ {
+ $db->sql_report('display');
+ }
- if ($action == 'activate')
- {
- include($phpbb_root_path . 'includes/functions_user.php');
- $mark_ary = explode(', ', $mark);
+ $debug_output = sprintf('Time : %.3fs | ' . $db->sql_num_queries() . ' Queries | GZIP : ' . (($config['gzip_compress']) ? 'On' : 'Off' ) . ' | Load : ' . (($user->load) ? $user->load : 'N/A'), $totaltime);
- foreach ($mark_ary as $user_id)
- {
- user_active_flip($user_id, USER_INACTIVE);
- }
- }
- else if ($action == 'delete')
+ if ($auth->acl_get('a_') && defined('DEBUG_EXTRA'))
+ {
+ if (function_exists('memory_get_usage'))
+ {
+ if ($memory_usage = memory_get_usage())
{
- $sql = 'DELETE FROM ' . USER_GROUP_TABLE . " WHERE user_id IN ($mark)";
- $db->sql_query($sql);
- $sql = 'DELETE FROM ' . USERS_TABLE . " WHERE user_id IN ($mark)";
- $db->sql_query($sql);
-
- add_log('admin', 'LOG_INDEX_' . strtoupper($action), implode(', ', $user_affected));
- }
+ global $base_memory_usage;
+ $memory_usage -= $base_memory_usage;
+ $memory_usage = ($memory_usage >= 1048576) ? round((round($memory_usage / 1048576 * 100) / 100), 2) . ' ' . $user->lang['MB'] : (($memory_usage >= 1024) ? round((round($memory_usage / 1024 * 100) / 100), 2) . ' ' . $user->lang['KB'] : $memory_usage . ' ' . $user->lang['BYTES']);
- if ($action != 'delete')
- {
- set_config('num_users', $config['num_users'] + $db->sql_affectedrows(), true);
+ $debug_output .= ' | Memory Usage: ' . $memory_usage;
}
+ }
- break;
+ $debug_output .= ' | <a href="' . (($_SERVER['REQUEST_URI']) ? htmlspecialchars($_SERVER['REQUEST_URI']) : "index.$phpEx$SID") . ((strpos($_SERVER['REQUEST_URI'], '?') !== false) ? '&amp;' : '?') . 'explain=1">Explain</a>';
+ }
+ }
- case 'remind':
- if (!$auth->acl_get('a_user'))
- {
- trigger_error($user->lang['NO_ADMIN']);
- }
+ $template->assign_vars(array(
+ 'DEBUG_OUTPUT' => (defined('DEBUG')) ? $debug_output : '',
+ 'S_COPYRIGHT_HTML' => $copyright_html,
+ 'VERSION' => $config['version']
+ )
+ );
- if (empty($config['email_enable']))
- {
- trigger_error($user->lang['EMAIL_DISABLED']);
- }
+ $template->display('body');
- $sql = 'SELECT user_id, username, user_email, user_lang, user_jabber, user_notify_type, user_regdate, user_actkey
- FROM ' . USERS_TABLE . "
- WHERE user_id IN ($mark)";
- $result = $db->sql_query($sql);
+ // Unload cache, must be done before the DB connection if closed
+ if (!empty($cache))
+ {
+ $cache->unload();
+ }
- if ($row = $db->sql_fetchrow($result))
- {
- // Send the messages
- include_once($phpbb_root_path . 'includes/functions_messenger.'.$phpEx);
+ // Close our DB connection.
+ $db->sql_close();
- $messenger = new messenger();
+ exit;
+}
- $board_url = generate_board_url() . "/ucp.$phpEx?mode=activate";
- $sig = str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']);
+function adm_back_link($u_action)
+{
+ return '<br /><br /><a href="' . $u_action . '">&laquo; Back to previous page</a>';
+}
- $usernames = array();
- do
- {
- $messenger->template('user_remind_inactive', $row['user_lang']);
+function build_select($option_ary, $option_default = false)
+{
+ global $user;
- $messenger->replyto($config['board_email']);
- $messenger->to($row['user_email'], $row['username']);
- $messenger->im($row['user_jabber'], $row['username']);
+ $html = '';
+ foreach ($option_ary as $value => $title)
+ {
+ $selected = ($option_default !== false && $value == $option_default) ? ' selected="selected"' : '';
+ $html .= '<option value="' . $value . '"' . $selected . '>' . $user->lang[$title] . '</option>';
+ }
- $messenger->assign_vars(array(
- 'EMAIL_SIG' => $sig,
- 'USERNAME' => $row['username'],
- 'SITENAME' => $config['sitename'],
- 'REGISTER_DATE' => $user->format_date($row['user_regdate']),
-
- 'U_ACTIVATE' => "$board_url&mode=activate&u=" . $row['user_id'] . '&k=' . $row['user_actkey'])
- );
+ return $html;
+}
- $messenger->send($row['user_notify_type']);
+function h_radio($name, &$input_ary, $input_default = false, $id = false, $key = false)
+{
+ global $user;
- $usernames[] = $row['username'];
- }
- while ($row = $db->sql_fetchrow($result));
+ $html = '';
+ $id_assigned = false;
+ foreach ($input_ary as $value => $title)
+ {
+ $selected = ($input_default !== false && $value == $input_default) ? ' checked="checked"' : '';
+ $html .= ($html) ? ' &nbsp; ' : '';
+ $html .= '<input type="radio" name="' . $name . '"' . (($id && !$id_assigned) ? ' id="' . $id . '"' : '') . ' value="' . $value . '"' . $selected . (($key) ? ' accesskey="' . $key . '"' : '') . ' /> ' . $user->lang[$title];
+ $id_assigned = true;
+ }
- $messenger->save_queue();
+ return $html;
+}
- unset($email_list);
+function build_cfg_template($tpl_type, $key, &$new, $config_key, $vars)
+{
+ global $user, $module;
- add_log('admin', 'LOG_INDEX_REMIND', implode(', ', $usernames));
- unset($usernames);
- }
- $db->sql_freeresult($result);
- break;
- }
- }
+ $tpl = '';
+ $name = 'config[' . $config_key . ']';
- switch ($action)
+ switch ($tpl_type[0])
{
- case 'online':
- if (!$auth->acl_get('a_defaults'))
- {
- trigger_error($user->lang['NO_ADMIN']);
- }
+ case 'text':
+ case 'password':
+ $size = (int) $tpl_type[1];
+ $maxlength = (int) $tpl_type[2];
- set_config('record_online_users', 1, true);
- set_config('record_online_date', time(), true);
- add_log('admin', 'LOG_RESET_ONLINE');
+ $tpl = '<input id="' . $key . '" type="' . $tpl_type[0] . '"' . (($size) ? ' size="' . $size . '"' : '') . ' maxlength="' . (($maxlength) ? $maxlength : 255) . '" name="' . $name . '" value="' . $new[$config_key] . '" />';
break;
- case 'stats':
- if (!$auth->acl_get('a_defaults'))
- {
- trigger_error($user->lang['NO_ADMIN']);
- }
-
- $sql = 'SELECT COUNT(post_id) AS stat
- FROM ' . POSTS_TABLE . '
- WHERE post_approved = 1';
- $result = $db->sql_query($sql);
-
- $row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
- set_config('num_posts', (int) $row['stat'], true);
-
- $sql = 'SELECT COUNT(topic_id) AS stat
- FROM ' . TOPICS_TABLE . '
- WHERE topic_approved = 1';
- $result = $db->sql_query($sql);
+ case 'dimension':
+ $size = (int) $tpl_type[1];
+ $maxlength = (int) $tpl_type[2];
- $row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
- set_config('num_topics', (int) $row['stat'], true);
-
- $sql = 'SELECT COUNT(user_id) AS stat
- FROM ' . USERS_TABLE . '
- WHERE user_type IN (' . USER_NORMAL . ',' . USER_FOUNDER . ')';
- $result = $db->sql_query($sql);
+ $tpl = '<input id="' . $key . '" type="text"' . (($size) ? ' size="' . $size . '"' : '') . ' maxlength="' . (($maxlength) ? $maxlength : 255) . '" name="config[' . $config_key . '_height]" value="' . $new[$config_key . '_height'] . '" /> x <input type="text"' . (($size) ? ' size="' . $size . '"' : '') . ' maxlength="' . (($maxlength) ? $maxlength : 255) . '" name="config[' . $config_key . '_width]" value="' . $new[$config_key . '_width'] . '" />';
+ break;
- $row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
- set_config('num_users', (int) $row['stat'], true);
+ case 'textarea':
+ $rows = (int) $tpl_type[1];
+ $cols = (int) $tpl_type[2];
- $sql = 'SELECT COUNT(attach_id) as stat
- FROM ' . ATTACHMENTS_TABLE;
- $result = $db->sql_query($sql);
+ $tpl = '<textarea id="' . $key . '" name="' . $name . '" rows="' . $rows . '" cols="' . $cols . '">' . $new[$config_key] . '</textarea>';
+ break;
- set_config('num_files', (int) $db->sql_fetchfield('stat', 0, $result), true);
- $db->sql_freeresult($result);
+ case 'radio':
+ $key_yes = ($new[$config_key]) ? ' checked="checked"' : '';
+ $key_no = (!$new[$config_key]) ? ' checked="checked"' : '';
- $sql = 'SELECT SUM(filesize) as stat
- FROM ' . ATTACHMENTS_TABLE;
- $result = $db->sql_query($sql);
+ $tpl_type_cond = explode('_', $tpl_type[1]);
+ $type_no = ($tpl_type_cond[0] == 'disabled' || $tpl_type_cond[0] == 'enabled') ? false : true;
- set_config('upload_dir_size', (int) $db->sql_fetchfield('stat', 0, $result), true);
- $db->sql_freeresult($result);
+ $tpl_no = '<input type="radio" name="' . $name . '" value="0"' . $key_no . ' />&nbsp;' . (($type_no) ? $user->lang['NO'] : $user->lang['DISABLED']);
+ $tpl_yes = '<input type="radio" id="' . $key . '" name="' . $name . '" value="1"' . $key_yes . ' />&nbsp;' . (($type_no) ? $user->lang['YES'] : $user->lang['ENABLED']);
- add_log('admin', 'LOG_RESYNC_STATS');
+ $tpl = ($tpl_type_cond[0] == 'yes' || $tpl_type_cond[0] == 'enabled') ? $tpl_yes . '&nbsp;&nbsp;' . $tpl_no : $tpl_no . '&nbsp;&nbsp;' . $tpl_yes;
break;
- case 'user':
- if (!$auth->acl_get('a_defaults'))
- {
- trigger_error($user->lang['NO_ADMIN']);
- }
-
- $post_count_ary = $auth->acl_getf('f_postcount');
+ case 'select':
+ case 'custom':
+
+ $return = '';
- $forum_ary = array();
- foreach ($post_count_ary as $forum_id => $allowed)
+ if (isset($vars['method']))
{
- if ($allowed['f_postcount'])
- {
- $forum_ary[] = $forum_id;
- }
+ $call = array($module->module, $vars['method']);
}
-
- if (!sizeof($forum_ary))
+ else if (isset($vars['function']))
{
- $db->sql_query('UPDATE ' . USERS_TABLE . ' SET user_posts = 0');
+ $call = $vars['function'];
}
else
{
- $sql = 'SELECT COUNT(post_id) AS num_posts, poster_id
- FROM ' . POSTS_TABLE . '
- WHERE poster_id <> ' . ANONYMOUS . '
- AND forum_id IN (' . implode(', ', $forum_ary) . ')
- GROUP BY poster_id';
- $result = $db->sql_query($sql);
-
- while ($row = $db->sql_fetchrow($result))
- {
- $db->sql_query('UPDATE ' . USERS_TABLE . " SET user_posts = {$row['num_posts']} WHERE user_id = {$row['poster_id']}");
- }
- $db->sql_freeresult($result);
- }
-
- add_log('admin', 'LOG_RESYNC_POSTCOUNTS');
- break;
-
- case 'date':
- if (!$auth->acl_get('a_defaults'))
- {
- trigger_error($user->lang['NO_ADMIN']);
- }
-
- set_config('board_startdate', time() - 1);
- add_log('admin', 'LOG_RESET_DATE');
- break;
- }
-
- // Get forum statistics
- $total_posts = $config['num_posts'];
- $total_topics = $config['num_topics'];
- $total_users = $config['num_users'];
- $total_files = $config['num_files'];
-
- $start_date = $user->format_date($config['board_startdate']);
-
- $boarddays = (time() - $config['board_startdate']) / 86400;
-
- $posts_per_day = sprintf('%.2f', $total_posts / $boarddays);
- $topics_per_day = sprintf('%.2f', $total_topics / $boarddays);
- $users_per_day = sprintf('%.2f', $total_users / $boarddays);
- $files_per_day = sprintf('%.2f', $total_files / $boarddays);
-
- $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']));
-
- $avatar_dir_size = 0;
-
- if ($avatar_dir = @opendir($phpbb_root_path . $config['avatar_path']))
- {
- while ($file = readdir($avatar_dir))
- {
- if ($file{0} != '.')
- {
- $avatar_dir_size += filesize($phpbb_root_path . $config['avatar_path'] . '/' . $file);
+ break;
}
- }
- @closedir($avatar_dir);
-
- // This bit of code translates the avatar directory size into human readable format
- // Borrowed the code from the PHP.net annoted manual, origanally written by:
- // Jesse (jesse@jess.on.ca)
- $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));
- }
- else
- {
- // Couldn't open Avatar dir.
- $avatar_dir_size = $user->lang['NOT_AVAILABLE'];
- }
-
- if ($posts_per_day > $total_posts)
- {
- $posts_per_day = $total_posts;
- }
-
- if ($topics_per_day > $total_topics)
- {
- $topics_per_day = $total_topics;
- }
-
- if ($users_per_day > $total_users)
- {
- $users_per_day = $total_users;
- }
-
- if ($files_per_day > $total_files)
- {
- $files_per_day = $total_files;
- }
-
- // DB size ... MySQL only
- // This code is heavily influenced by a similar routine
- // in phpMyAdmin 2.2.0
- if (preg_match('#^mysql#', SQL_LAYER))
- {
- $result = $db->sql_query('SELECT VERSION() AS mysql_version');
-
- if ($row = $db->sql_fetchrow($result))
- {
- $version = $row['mysql_version'];
-
- if (preg_match('#^(3\.23|4\.)#', $version))
+
+ if (isset($vars['params']))
{
- $db_name = (preg_match('#^(3\.23\.[6-9])|(3\.23\.[1-9][1-9])|(4\.)#', $version)) ? "`$dbname`" : $dbname;
-
- $sql = "SHOW TABLE STATUS
- FROM " . $db_name;
- $result = $db->sql_query($sql);
-
- $dbsize = 0;
- while ($row = $db->sql_fetchrow($result))
+ $args = array();
+ foreach ($vars['params'] as $value)
{
- if ((isset($row['Type']) && $row['Type'] != 'MRG_MyISAM') || (isset($row['Engine']) && $row['Engine'] == 'MyISAM'))
+ switch ($value)
{
- if ($table_prefix != '')
- {
- if (strstr($row['Name'], $table_prefix))
- {
- $dbsize += $row['Data_length'] + $row['Index_length'];
- }
- }
- else
- {
- $dbsize += $row['Data_length'] + $row['Index_length'];
- }
+ case '{CONFIG_VALUE}':
+ $value = $new[$config_key];
+ break;
+
+ case '{KEY}':
+ $value = $key;
+ break;
}
+
+ $args[] = $value;
}
}
else
{
- $dbsize = $user->lang['NOT_AVAILABLE'];
+ $args = array($new[$config_key], $key);
}
- }
- else
- {
- $dbsize = $user->lang['NOT_AVAILABLE'];
- }
- }
- else if (preg_match('#^mssql#', SQL_LAYER))
- {
- $sql = 'SELECT ((SUM(size) * 8.0) * 1024.0) as dbsize
- FROM sysfiles';
- $result = $db->sql_query($sql);
-
- $dbsize = ($row = $db->sql_fetchrow($result)) ? intval($row['dbsize']) : $user->lang['NOT_AVAILABLE'];
- }
- else
- {
- $dbsize = $user->lang['NOT_AVAILABLE'];
- }
-
- if (is_int($dbsize))
- {
- $dbsize = ($dbsize >= 1048576) ? sprintf('%.2f ' . $user->lang['MB'], ($dbsize / 1048576)) : (($dbsize >= 1024) ? sprintf('%.2f ' . $user->lang['KB'], ($dbsize / 1024)) : sprintf('%.2f ' . $user->lang['BYTES'], $dbsize));
- }
-
- adm_page_header($user->lang['ADMIN_INDEX']);
-
-?>
-
-<script language="Javascript" type="text/javascript">
-<!--
- function marklist(status)
- {
- for (i = 0; i < document.inactive.length; i++)
- {
- document.inactive.elements[i].checked = status;
- }
- }
-//-->
-</script>
-
-<h1><?php echo $user->lang['WELCOME_PHPBB']; ?></h1>
-
-<p><?php echo $user->lang['ADMIN_INTRO']; ?></p>
-
-<h1><?php echo $user->lang['FORUM_STATS']; ?></h1>
-
-<form name="statistics" method="post" action="index.<?php echo $phpEx . $SID; ?>&amp;pane=right"><table class="bg" width="100%" cellpadding="4" cellspacing="1" border="0">
- <tr>
- <th width="25%" nowrap="nowrap" height="25"><?php echo $user->lang['STATISTIC']; ?></th>
- <th width="25%"><?php echo $user->lang['VALUE']; ?></th>
- <th width="25%" nowrap="nowrap"><?php echo $user->lang['STATISTIC']; ?></th>
- <th width="25%"><?php echo $user->lang['VALUE']; ?></th>
- </tr>
- <tr>
- <td class="row1" nowrap="nowrap"><?php echo $user->lang['NUMBER_POSTS']; ?>:</td>
- <td class="row2"><b><?php echo $total_posts; ?></b></td>
- <td class="row1" nowrap="nowrap"><?php echo $user->lang['POSTS_PER_DAY']; ?>:</td>
- <td class="row2"><b><?php echo $posts_per_day; ?></b></td>
- </tr>
- <tr>
- <td class="row1" nowrap="nowrap"><?php echo $user->lang['NUMBER_TOPICS']; ?>:</td>
- <td class="row2"><b><?php echo $total_topics; ?></b></td>
- <td class="row1" nowrap="nowrap"><?php echo $user->lang['TOPICS_PER_DAY']; ?>:</td>
- <td class="row2"><b><?php echo $topics_per_day; ?></b></td>
- </tr>
- <tr>
- <td class="row1" nowrap="nowrap"><?php echo $user->lang['NUMBER_USERS']; ?>:</td>
- <td class="row2"><b><?php echo $total_users; ?></b></td>
- <td class="row1" nowrap="nowrap"><?php echo $user->lang['USERS_PER_DAY']; ?>:</td>
- <td class="row2"><b><?php echo $users_per_day; ?></b></td>
- </tr>
- <tr>
- <td class="row1" nowrap="nowrap"><?php echo $user->lang['NUMBER_FILES']; ?>:</td>
- <td class="row2"><b><?php echo $total_files; ?></b></td>
- <td class="row1" nowrap="nowrap"><?php echo $user->lang['FILES_PER_DAY']; ?>:</td>
- <td class="row2"><b><?php echo $files_per_day; ?></b></td>
- </tr>
- <tr>
- <td class="row1" nowrap="nowrap"><?php echo $user->lang['BOARD_STARTED']; ?>:</td>
- <td class="row2"><b><?php echo $start_date; ?></b></td>
- <td class="row1" nowrap="nowrap"><?php echo $user->lang['AVATAR_DIR_SIZE']; ?>:</td>
- <td class="row2"><b><?php echo $avatar_dir_size; ?></b></td>
- </tr>
- <tr>
- <td class="row1" nowrap="nowrap"><?php echo $user->lang['DATABASE_SIZE']; ?>:</td>
- <td class="row2"><b><?php echo $dbsize; ?></b></td>
- <td class="row1" nowrap="nowrap"><?php echo $user->lang['UPLOAD_DIR_SIZE']; ?>:</td>
- <td class="row2"><b><?php echo $upload_dir_size; ?></b></td>
- </tr>
- <tr>
- <td class="row1" nowrap="nowrap"><?php echo $user->lang['GZIP_COMPRESSION']; ?>:</td>
- <td class="row2"><b><?php echo ($config['gzip_compress']) ? $user->lang['ON'] : $user->lang['OFF']; ?></b></td>
- <td class="row1" nowrap="nowrap">&nbsp;</td>
- <td class="row2">&nbsp;</td>
- </tr>
- <tr>
- <td class="cat" colspan="4" align="right"><select name="action"><option value="online"><?php echo $user->lang['RESET_ONLINE']; ?></option><option value="date"><?php echo $user->lang['RESET_DATE']; ?></option><option value="stats"><?php echo $user->lang['RESYNC_STATS']; ?></option><option value="user"><?php echo $user->lang['RESYNC_POSTCOUNTS']; ?></option>
- </select> <input class="btnlite" type="submit" name="submit" value="<?php echo $user->lang['SUBMIT']; ?>" />&nbsp;</td>
- </tr>
-</table></form>
-
-<h1><?php echo $user->lang['ADMIN_LOG']; ?></h1>
-
-<p><?php echo $user->lang['ADMIN_LOG_INDEX_EXPLAIN']; ?></p>
-
-<table class="bg" width="100%" cellpadding="4" cellspacing="1" border="0">
- <tr>
- <th width="15%" height="25" nowrap="nowrap"><?php echo $user->lang['USERNAME']; ?></th>
- <th width="15%"><?php echo $user->lang['IP']; ?></th>
- <th width="20%"><?php echo $user->lang['TIME']; ?></th>
- <th width="45%" nowrap="nowrap"><?php echo $user->lang['ACTION']; ?></th>
- </tr>
-<?php
-
- view_log('admin', $log_data, $log_count, 5);
-
- $row_class = 'row2';
- for($i = 0; $i < sizeof($log_data); $i++)
- {
- $row_class = ($row_class == 'row1') ? 'row2' : 'row1';
-
-?>
- <tr>
- <td class="<?php echo $row_class; ?>"><?php echo $log_data[$i]['username']; ?></td>
- <td class="<?php echo $row_class; ?>" align="center"><?php echo $log_data[$i]['ip']; ?></td>
- <td class="<?php echo $row_class; ?>" align="center"><?php echo $user->format_date($log_data[$i]['time']); ?></td>
- <td class="<?php echo $row_class; ?>"><?php echo $log_data[$i]['action']; ?></td>
- </tr>
-<?php
-
- }
-
- if ($auth->acl_get('a_user'))
- {
-
-?>
-</table>
-
-<h1><?php echo $user->lang['INACTIVE_USERS']; ?></h1>
-
-<p><?php echo $user->lang['INACTIVE_USERS_EXPLAIN']; ?></p>
-
-<form method="post" name="inactive" action="<?php echo "index.$phpEx$SID&amp;pane=right"; ?>"><table class="bg" width="100%" cellpadding="4" cellspacing="1" border="0">
- <tr>
- <th width="45%" height="25" nowrap="nowrap"><?php echo $user->lang['USERNAME']; ?></th>
- <th width="45%"><?php echo $user->lang['JOINED']; ?></th>
- <th width="5%" nowrap="nowrap"><?php echo $user->lang['MARK']; ?></th>
- </tr>
-<?php
-
- $sql = 'SELECT user_id, username, user_regdate
- FROM ' . USERS_TABLE . '
- WHERE user_type = ' . USER_INACTIVE . '
- ORDER BY user_regdate ASC';
- $result = $db->sql_query($sql);
+
+ $return = call_user_func_array($call, $args);
- if ($row = $db->sql_fetchrow($result))
- {
- do
+ if ($tpl_type[0] == 'select')
{
- $row_class = ($row_class == 'row1') ? 'row2' : 'row1';
-
-?>
- <tr>
- <td class="<?php echo $row_class; ?>"><a href="<?php echo "admin_users.$phpEx$SID&amp;u=" . $row['user_id']; ?>"><?php echo $row['username']; ?></a></td>
- <td class="<?php echo $row_class; ?>"><?php echo $user->format_date($row['user_regdate']); ?></td>
- <td class="<?php echo $row_class; ?>">&nbsp;<input type="checkbox" name="mark[]" value="<?php echo $row['user_id']; ?>" />&nbsp;</td>
- </tr>
-<?php
-
+ $tpl = '<select id="' . $key . '" name="' . $name . '">' . $return . '</select>';
}
- while ($row = $db->sql_fetchrow($result));
-
-?>
- <tr>
- <td class="cat" colspan="3" height="28" align="right"><select name="action"><option value="activate"><?php echo $user->lang['ACTIVATE']; ?></option><?php
-
- if (!empty($config['email_enable']))
+ else
{
-
-?><option value="remind"><?php echo $user->lang['REMIND']; ?></option><?php
-
+ $tpl = $return;
}
-?><option value="delete"><?php echo $user->lang['DELETE']; ?></option></select> <input class="btnlite" type="submit" name="submit" value="<?php echo $user->lang['SUBMIT']; ?>" />&nbsp;</td>
- </tr>
-<?php
-
- }
- else
- {
-
-?>
- <tr>
- <td class="row1" colspan="3" align="center"><?php echo $user->lang['NO_INACTIVE_USERS']; ?></td>
- </tr>
-<?php
-
- }
-
-?>
-</table>
-
-<table width="100%" cellspacing="1" cellpadding="4" border="0" align="center">
- <tr>
- <td align="right" valign="top" nowrap="nowrap"><b><span class="gensmall"><a href="javascript:marklist(true);" class="gensmall"><?php echo $user->lang['MARK_ALL']; ?></a> :: <a href="javascript:marklist(false);" class="gensmall"><?php echo $user->lang['UNMARK_ALL']; ?></a></span></b></td>
- </tr>
-</table></form>
-
-<?php
+ break;
+ default:
+ break;
}
- adm_page_footer();
-
-}
-else
-{
- //
- // Output the frameset ...
- //
- header("Expires: " . gmdate("D, d M Y H:i:s", time()) . " GMT");
- header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
- header("Content-type: text/html; charset=" . $user->lang['ENCODING']);
-
- $adm_url = "index.$phpEx$SID&amp;pane=right";
-
- /*
- // Allows non-admin pages to link to admin pages
- // eg: http://forums.foo.com/adm/index.php?sid=&mod=admin_forums&f=1
- if (!empty($_GET['mod']) && preg_match('/admin_([a-z]+)/', $_GET['mod'], $m))
+ if (isset($vars['append']))
{
- if (file_exists($phpbb_root_path . 'adm/admin_' . $m[1] . '.' . $phpEx))
- {
- $adm_url = 'admin_' . $m[1] . '.' . $phpEx . $SID;
- $adm_url .= (!empty($_GET['mode'])) ? '&amp;mode=' . htmlspecialchars($_GET['mode']) : '';
- $adm_url .= (!empty($_GET['f'])) ? '&amp;f=' . intval($_GET['f']) : '';
- $adm_url .= (!empty($_GET['u'])) ? '&amp;u=' . intval($_GET['u']) : '';
- $adm_url .= (!empty($_GET['g'])) ? '&amp;g=' . intval($_GET['g']) : '';
- }
+ $tpl .= $vars['append'];
}
- */
-?>
-<html>
-<head>
-<title><?php echo $user->lang['ADMIN_TITLE']; ?></title>
-</head>
-
-<frameset rows="60, *" border="0" framespacing="0" frameborder="NO">
- <frame src="<?php echo "index.$phpEx$SID&amp;pane=top"; ?>" name="title" noresize marginwidth="0" marginheight="0" scrolling="NO">
- <frameset cols="155,*" rows="*" border="2" framespacing="0" frameborder="yes">
- <frame src="<?php echo "index.$phpEx$SID&amp;pane=left"; ?>" name="nav" marginwidth="3" marginheight="3" scrolling="yes">
- <frame src="<?php echo $adm_url ?>" name="main" marginwidth="0" marginheight="0" scrolling="auto">
- </frameset>
-</frameset>
-
-<noframes>
- <body bgcolor="white" text="#000000">
- <p><?php echo $user->lang['NO_FRAMES']; ?></p>
- </body>
-</noframes>
-</html>
-<?php
-
- exit;
+
+ return $tpl;
}
-?>
+?> \ No newline at end of file