[ticket/11259] Make phpbb_admin_path available everywhere

PHPBB3-11259
This commit is contained in:
Nathan Guse 2012-12-09 17:01:08 -06:00
parent bd987b6e14
commit 6dee253941
16 changed files with 45 additions and 32 deletions

View file

@ -42,7 +42,6 @@ if (!$auth->acl_get('a_'))
// We define the admin variables now, because the user is now able to use the admin related features... // We define the admin variables now, because the user is now able to use the admin related features...
define('IN_ADMIN', true); define('IN_ADMIN', true);
$phpbb_admin_path = (defined('PHPBB_ADMIN_PATH')) ? PHPBB_ADMIN_PATH : './';
// Some oft used variables // Some oft used variables
$safe_mode = (@ini_get('safe_mode') == '1' || strtolower(@ini_get('safe_mode')) === 'on') ? true : false; $safe_mode = (@ini_get('safe_mode') == '1' || strtolower(@ini_get('safe_mode')) === 'on') ? true : false;

View file

@ -5,7 +5,7 @@
<!-- IF META -->{META}<!-- ENDIF --> <!-- IF META -->{META}<!-- ENDIF -->
<title>{PAGE_TITLE}</title> <title>{PAGE_TITLE}</title>
<link href="../adm/style/admin.css" rel="stylesheet" type="text/css" media="screen" /> <link href="{T_TEMPLATE_PATH}/admin.css" rel="stylesheet" type="text/css" media="screen" />
<script type="text/javascript"> <script type="text/javascript">
// <![CDATA[ // <![CDATA[

View file

@ -5,7 +5,7 @@
<!-- IF META -->{META}<!-- ENDIF --> <!-- IF META -->{META}<!-- ENDIF -->
<title>{PAGE_TITLE}</title> <title>{PAGE_TITLE}</title>
<link href="../adm/style/admin.css" rel="stylesheet" type="text/css" media="screen" /> <link href="{T_TEMPLATE_PATH}/admin.css" rel="stylesheet" type="text/css" media="screen" />
<script type="text/javascript"> <script type="text/javascript">
// <![CDATA[ // <![CDATA[

View file

@ -21,8 +21,6 @@ $user->session_begin(false);
$auth->acl($user->data); $auth->acl($user->data);
$user->setup(); $user->setup();
$phpbb_admin_path = (defined('PHPBB_ADMIN_PATH')) ? PHPBB_ADMIN_PATH : './';
// Set custom template for admin area // Set custom template for admin area
$phpbb_style->set_custom_style('admin', $phpbb_admin_path . 'style', ''); $phpbb_style->set_custom_style('admin', $phpbb_admin_path . 'style', '');

View file

@ -63,6 +63,10 @@ if (!defined('PHPBB_INSTALLED'))
exit; exit;
} }
// In case $adm_relative_path is not set (in case of an update), use the default.
$adm_relative_path = (isset($adm_relative_path)) ? ((substr($adm_relative_path, -1) == '/') ? $adm_relative_path : $adm_relative_path . '/') : 'adm/';
$phpbb_admin_path = (defined('PHPBB_ADMIN_PATH')) ? PHPBB_ADMIN_PATH : $phpbb_root_path . $adm_relative_path;
// Include files // Include files
require($phpbb_root_path . 'includes/class_loader.' . $phpEx); require($phpbb_root_path . 'includes/class_loader.' . $phpEx);

View file

@ -822,7 +822,7 @@ class dbal
*/ */
function sql_report($mode, $query = '') function sql_report($mode, $query = '')
{ {
global $cache, $starttime, $phpbb_root_path, $user; global $cache, $starttime, $phpbb_root_path, $phpbb_admin_path, $user;
global $request; global $request;
if (is_object($request) && !$request->variable('explain', false)) if (is_object($request) && !$request->variable('explain', false))
@ -852,7 +852,7 @@ class dbal
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>SQL Report</title> <title>SQL Report</title>
<link href="' . $phpbb_root_path . 'adm/style/admin.css" rel="stylesheet" type="text/css" media="screen" /> <link href="' . $phpbb_admin_path . 'style/admin.css" rel="stylesheet" type="text/css" media="screen" />
</head> </head>
<body id="errorpage"> <body id="errorpage">
<div id="wrap"> <div id="wrap">

View file

@ -5339,7 +5339,7 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0
function page_footer($run_cron = true, $display_template = true, $exit_handler = true) function page_footer($run_cron = true, $display_template = true, $exit_handler = true)
{ {
global $db, $config, $template, $user, $auth, $cache, $starttime, $phpbb_root_path, $phpEx; global $db, $config, $template, $user, $auth, $cache, $starttime, $phpbb_root_path, $phpEx;
global $request, $phpbb_dispatcher; global $request, $phpbb_dispatcher, $phpbb_admin_path;
// A listener can set this variable to `true` when it overrides this function // A listener can set this variable to `true` when it overrides this function
$page_footer_override = false; $page_footer_override = false;
@ -5395,7 +5395,7 @@ function page_footer($run_cron = true, $display_template = true, $exit_handler =
'TRANSLATION_INFO' => (!empty($user->lang['TRANSLATION_INFO'])) ? $user->lang['TRANSLATION_INFO'] : '', 'TRANSLATION_INFO' => (!empty($user->lang['TRANSLATION_INFO'])) ? $user->lang['TRANSLATION_INFO'] : '',
'CREDIT_LINE' => $user->lang('POWERED_BY', '<a href="https://www.phpbb.com/">phpBB</a>&reg; Forum Software &copy; phpBB Group'), 'CREDIT_LINE' => $user->lang('POWERED_BY', '<a href="https://www.phpbb.com/">phpBB</a>&reg; Forum Software &copy; phpBB Group'),
'U_ACP' => ($auth->acl_get('a_') && !empty($user->data['is_registered'])) ? append_sid("{$phpbb_root_path}adm/index.$phpEx", false, true, $user->session_id) : '') 'U_ACP' => ($auth->acl_get('a_') && !empty($user->data['is_registered'])) ? append_sid("{$phpbb_admin_path}index.$phpEx", false, true, $user->session_id) : '')
); );
// Call cron-type script // Call cron-type script

View file

@ -515,6 +515,9 @@ function phpbb_create_config_file_data($data, $dbms, $debug = false, $debug_test
'dbuser' => $data['dbuser'], 'dbuser' => $data['dbuser'],
'dbpasswd' => htmlspecialchars_decode($data['dbpasswd']), 'dbpasswd' => htmlspecialchars_decode($data['dbpasswd']),
'table_prefix' => $data['table_prefix'], 'table_prefix' => $data['table_prefix'],
'adm_relative_path' => 'adm/',
'acm_type' => 'phpbb_cache_driver_file', 'acm_type' => 'phpbb_cache_driver_file',
); );

View file

@ -25,7 +25,7 @@ class ucp_groups
function main($id, $mode) function main($id, $mode)
{ {
global $config, $phpbb_root_path, $phpEx; global $config, $phpbb_root_path, $phpEx, $phpbb_admin_path;
global $db, $user, $auth, $cache, $template; global $db, $user, $auth, $cache, $template;
global $request; global $request;
@ -438,7 +438,7 @@ class ucp_groups
$group_name = $group_row['group_name']; $group_name = $group_row['group_name'];
$group_type = $group_row['group_type']; $group_type = $group_row['group_type'];
$avatar_img = (!empty($group_row['group_avatar'])) ? get_user_avatar($group_row['group_avatar'], $group_row['group_avatar_type'], $group_row['group_avatar_width'], $group_row['group_avatar_height'], 'GROUP_AVATAR') : '<img src="' . $phpbb_root_path . 'adm/images/no_avatar.gif" alt="" />'; $avatar_img = (!empty($group_row['group_avatar'])) ? get_user_avatar($group_row['group_avatar'], $group_row['group_avatar_type'], $group_row['group_avatar_width'], $group_row['group_avatar_height'], 'GROUP_AVATAR') : '<img src="' . $phpbb_admin_path . 'images/no_avatar.gif" alt="" />';
$template->assign_vars(array( $template->assign_vars(array(
'GROUP_NAME' => ($group_type == GROUP_SPECIAL) ? $user->lang['G_' . $group_name] : $group_name, 'GROUP_NAME' => ($group_type == GROUP_SPECIAL) ? $user->lang['G_' . $group_name] : $group_name,
@ -730,7 +730,7 @@ class ucp_groups
'GROUP_CLOSED' => $type_closed, 'GROUP_CLOSED' => $type_closed,
'GROUP_HIDDEN' => $type_hidden, 'GROUP_HIDDEN' => $type_hidden,
'U_SWATCH' => append_sid("{$phpbb_root_path}adm/swatch.$phpEx", 'form=ucp&amp;name=group_colour'), 'U_SWATCH' => append_sid("{$phpbb_admin_path}swatch.$phpEx", 'form=ucp&amp;name=group_colour'),
'S_UCP_ACTION' => $this->u_action . "&amp;action=$action&amp;g=$group_id", 'S_UCP_ACTION' => $this->u_action . "&amp;action=$action&amp;g=$group_id",
'L_AVATAR_EXPLAIN' => phpbb_avatar_explanation_string(), 'L_AVATAR_EXPLAIN' => phpbb_avatar_explanation_string(),
)); ));

View file

@ -73,6 +73,10 @@ if (!defined('PHPBB_INSTALLED') || empty($dbms) || empty($acm_type))
die("Please read: <a href='../docs/INSTALL.html'>INSTALL.html</a> before attempting to update."); die("Please read: <a href='../docs/INSTALL.html'>INSTALL.html</a> before attempting to update.");
} }
// In case $adm_relative_path is not set (in case of an update), use the default.
$adm_relative_path = (isset($adm_relative_path)) ? ((substr($adm_relative_path, -1) == '/') ? $adm_relative_path : $adm_relative_path . '/') : 'adm/';
$phpbb_admin_path = (defined('PHPBB_ADMIN_PATH')) ? PHPBB_ADMIN_PATH : $phpbb_root_path . $adm_relative_path;
// Include files // Include files
require($phpbb_root_path . 'includes/class_loader.' . $phpEx); require($phpbb_root_path . 'includes/class_loader.' . $phpEx);
@ -232,7 +236,7 @@ if ($has_global && !$ga_forum_id)
<title><?php echo $lang['UPDATING_TO_LATEST_STABLE']; ?></title> <title><?php echo $lang['UPDATING_TO_LATEST_STABLE']; ?></title>
<link href="../adm/style/admin.css" rel="stylesheet" type="text/css" media="screen" /> <link href="<?php echo $phpbb_admin_path; ?>style/admin.css" rel="stylesheet" type="text/css" media="screen" />
</head> </head>
@ -282,7 +286,7 @@ header('Content-type: text/html; charset=UTF-8');
<title><?php echo $lang['UPDATING_TO_LATEST_STABLE']; ?></title> <title><?php echo $lang['UPDATING_TO_LATEST_STABLE']; ?></title>
<link href="../adm/style/admin.css" rel="stylesheet" type="text/css" media="screen" /> <link href="<?php echo $phpbb_admin_path; ?>style/admin.css" rel="stylesheet" type="text/css" media="screen" />
</head> </head>

View file

@ -73,6 +73,10 @@ else
} }
@ini_set('memory_limit', $mem_limit); @ini_set('memory_limit', $mem_limit);
// In case $adm_relative_path is not set (in case of an update), use the default.
$adm_relative_path = (isset($adm_relative_path)) ? ((substr($adm_relative_path, -1) == '/') ? $adm_relative_path : $adm_relative_path . '/') : 'adm/';
$phpbb_admin_path = (defined('PHPBB_ADMIN_PATH')) ? PHPBB_ADMIN_PATH : $phpbb_root_path . $adm_relative_path;
// Include essential scripts // Include essential scripts
require($phpbb_root_path . 'includes/class_loader.' . $phpEx); require($phpbb_root_path . 'includes/class_loader.' . $phpEx);
@ -215,9 +219,9 @@ $phpbb_style_path_provider = new phpbb_style_path_provider();
$template = new phpbb_template($phpbb_root_path, $phpEx, $config, $user, $phpbb_style_resource_locator, new phpbb_template_context()); $template = new phpbb_template($phpbb_root_path, $phpEx, $config, $user, $phpbb_style_resource_locator, new phpbb_template_context());
$phpbb_style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $phpbb_style_resource_locator, $phpbb_style_path_provider, $template); $phpbb_style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $phpbb_style_resource_locator, $phpbb_style_path_provider, $template);
$phpbb_style->set_ext_dir_prefix('adm/'); $phpbb_style->set_ext_dir_prefix('adm/');
$phpbb_style->set_custom_style('admin', '../adm/style', ''); $phpbb_style->set_custom_style('admin', $phpbb_admin_path . 'style', '');
$template->assign_var('T_ASSETS_PATH', '../assets'); $template->assign_var('T_ASSETS_PATH', '../assets');
$template->assign_var('T_TEMPLATE_PATH', '../adm/style'); $template->assign_var('T_TEMPLATE_PATH', $phpbb_admin_path . 'style');
$install = new module(); $install = new module();
@ -361,7 +365,7 @@ class module
} }
define('HEADER_INC', true); define('HEADER_INC', true);
global $template, $lang, $stage, $phpbb_root_path; global $template, $lang, $stage, $phpbb_root_path, $phpbb_admin_path;
$template->assign_vars(array( $template->assign_vars(array(
'L_CHANGE' => $lang['CHANGE'], 'L_CHANGE' => $lang['CHANGE'],
@ -370,7 +374,7 @@ class module
'L_SELECT_LANG' => $lang['SELECT_LANG'], 'L_SELECT_LANG' => $lang['SELECT_LANG'],
'L_SKIP' => $lang['SKIP'], 'L_SKIP' => $lang['SKIP'],
'PAGE_TITLE' => $this->get_page_title(), 'PAGE_TITLE' => $this->get_page_title(),
'T_IMAGE_PATH' => $phpbb_root_path . 'adm/images/', 'T_IMAGE_PATH' => $phpbb_admin_path . 'images/',
'S_CONTENT_DIRECTION' => $lang['DIRECTION'], 'S_CONTENT_DIRECTION' => $lang['DIRECTION'],
'S_CONTENT_FLOW_BEGIN' => ($lang['DIRECTION'] == 'ltr') ? 'left' : 'right', 'S_CONTENT_FLOW_BEGIN' => ($lang['DIRECTION'] == 'ltr') ? 'left' : 'right',
@ -551,7 +555,7 @@ class module
*/ */
function error($error, $line, $file, $skip = false) function error($error, $line, $file, $skip = false)
{ {
global $lang, $db, $template; global $lang, $db, $template, $phpbb_admin_path;
if ($skip) if ($skip)
{ {
@ -573,7 +577,7 @@ class module
echo '<head>'; echo '<head>';
echo '<meta charset="utf-8">'; echo '<meta charset="utf-8">';
echo '<title>' . $lang['INST_ERR_FATAL'] . '</title>'; echo '<title>' . $lang['INST_ERR_FATAL'] . '</title>';
echo '<link href="../adm/style/admin.css" rel="stylesheet" type="text/css" media="screen" />'; echo '<link href="' . $phpbb_admin_path . 'style/admin.css" rel="stylesheet" type="text/css" media="screen" />';
echo '</head>'; echo '</head>';
echo '<body id="errorpage">'; echo '<body id="errorpage">';
echo '<div id="wrap">'; echo '<div id="wrap">';

View file

@ -1813,7 +1813,7 @@ class install_install extends module
*/ */
function email_admin($mode, $sub) function email_admin($mode, $sub)
{ {
global $auth, $config, $db, $lang, $template, $user, $phpbb_root_path, $phpEx; global $auth, $config, $db, $lang, $template, $user, $phpbb_root_path, $phpbb_admin_path, $phpEx;
$this->page_title = $lang['STAGE_FINAL']; $this->page_title = $lang['STAGE_FINAL'];
@ -1860,7 +1860,7 @@ class install_install extends module
'TITLE' => $lang['INSTALL_CONGRATS'], 'TITLE' => $lang['INSTALL_CONGRATS'],
'BODY' => sprintf($lang['INSTALL_CONGRATS_EXPLAIN'], $config['version'], append_sid($phpbb_root_path . 'install/index.' . $phpEx, 'mode=convert&amp;language=' . $data['language']), '../docs/README.html'), 'BODY' => sprintf($lang['INSTALL_CONGRATS_EXPLAIN'], $config['version'], append_sid($phpbb_root_path . 'install/index.' . $phpEx, 'mode=convert&amp;language=' . $data['language']), '../docs/README.html'),
'L_SUBMIT' => $lang['INSTALL_LOGIN'], 'L_SUBMIT' => $lang['INSTALL_LOGIN'],
'U_ACTION' => append_sid($phpbb_root_path . 'adm/index.' . $phpEx, 'i=send_statistics&amp;mode=send_statistics'), 'U_ACTION' => append_sid($phpbb_admin_path . 'index.' . $phpEx, 'i=send_statistics&amp;mode=send_statistics'),
)); ));
} }

View file

@ -72,7 +72,7 @@ class install_update extends module
function main($mode, $sub) function main($mode, $sub)
{ {
global $phpbb_style, $template, $phpEx, $phpbb_root_path, $user, $db, $config, $cache, $auth, $language; global $phpbb_style, $template, $phpEx, $phpbb_root_path, $user, $db, $config, $cache, $auth, $language;
global $request; global $request, $phpbb_admin_path, $adm_relative_path;
$this->tpl_name = 'install_update'; $this->tpl_name = 'install_update';
$this->page_title = 'UPDATE_INSTALLATION'; $this->page_title = 'UPDATE_INSTALLATION';
@ -131,7 +131,7 @@ class install_update extends module
} }
// Set custom template again. ;) // Set custom template again. ;)
$phpbb_style->set_custom_style('admin', '../adm/style', ''); $phpbb_style->set_custom_style('admin', $phpbb_admin_path . 'style', '');
$template->assign_vars(array( $template->assign_vars(array(
'S_USER_LANG' => $user->lang['USER_LANG'], 'S_USER_LANG' => $user->lang['USER_LANG'],
@ -216,7 +216,7 @@ class install_update extends module
if ($this->test_update === false) if ($this->test_update === false)
{ {
// Got the updater template itself updated? If so, we are able to directly use it - but only if all three files are present // Got the updater template itself updated? If so, we are able to directly use it - but only if all three files are present
if (in_array('adm/style/install_update.html', $this->update_info['files'])) if (in_array($adm_relative_path . 'style/install_update.html', $this->update_info['files']))
{ {
$this->tpl_name = '../../install/update/new/adm/style/install_update'; $this->tpl_name = '../../install/update/new/adm/style/install_update';
} }
@ -493,6 +493,7 @@ class install_update extends module
$template->assign_vars(array( $template->assign_vars(array(
'S_FILE_CHECK' => true, 'S_FILE_CHECK' => true,
'S_ALL_UP_TO_DATE' => $all_up_to_date, 'S_ALL_UP_TO_DATE' => $all_up_to_date,
'L_ALL_FILES_UP_TO_DATE' => $user->lang('ALL_FILES_UP_TO_DATE', append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login'), append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login&amp;redirect=' . $adm_relative_path . 'index.php%3Fi=send_statistics%26mode=send_statistics')),
'S_VERSION_UP_TO_DATE' => $up_to_date, 'S_VERSION_UP_TO_DATE' => $up_to_date,
'U_ACTION' => append_sid($this->p_master->module_url, "language=$language&amp;mode=$mode&amp;sub=file_check"), 'U_ACTION' => append_sid($this->p_master->module_url, "language=$language&amp;mode=$mode&amp;sub=file_check"),
'U_UPDATE_ACTION' => append_sid($this->p_master->module_url, "language=$language&amp;mode=$mode&amp;sub=update_files"), 'U_UPDATE_ACTION' => append_sid($this->p_master->module_url, "language=$language&amp;mode=$mode&amp;sub=update_files"),
@ -1077,12 +1078,12 @@ class install_update extends module
*/ */
function show_diff(&$update_list) function show_diff(&$update_list)
{ {
global $phpbb_root_path, $template, $user; global $phpbb_root_path, $template, $user, $adm_relative_path;
$this->tpl_name = 'install_update_diff'; $this->tpl_name = 'install_update_diff';
// Got the diff template itself updated? If so, we are able to directly use it // Got the diff template itself updated? If so, we are able to directly use it
if (in_array('adm/style/install_update_diff.html', $this->update_info['files'])) if (in_array($adm_relative_path . 'style/install_update_diff.html', $this->update_info['files']))
{ {
$this->tpl_name = '../../install/update/new/adm/style/install_update_diff'; $this->tpl_name = '../../install/update/new/adm/style/install_update_diff';
} }

View file

@ -374,7 +374,7 @@ $lang = array_merge($lang, array(
// Updater // Updater
$lang = array_merge($lang, array( $lang = array_merge($lang, array(
'ALL_FILES_UP_TO_DATE' => 'All files are up to date with the latest phpBB version. You should now <a href="../ucp.php?mode=login">login to your board</a> and check if everything is working fine. Do not forget to delete, rename or move your install directory! Please send us updated information about your server and board configurations from the <a href="../ucp.php?mode=login&amp;redirect=adm/index.php%3Fi=send_statistics%26mode=send_statistics">Send statistics</a> module in your ACP.', 'ALL_FILES_UP_TO_DATE' => 'All files are up to date with the latest phpBB version. You should now <a href="%1$s">login to your board</a> and check if everything is working fine. Do not forget to delete, rename or move your install directory! Please send us updated information about your server and board configurations from the <a href="%2$s">Send statistics</a> module in your ACP.',
'ARCHIVE_FILE' => 'Source file within archive', 'ARCHIVE_FILE' => 'Source file within archive',
'BACK' => 'Back', 'BACK' => 'Back',

View file

@ -649,7 +649,7 @@ switch ($mode)
'S_GROUP_OPTIONS' => $group_options, 'S_GROUP_OPTIONS' => $group_options,
'S_CUSTOM_FIELDS' => (isset($profile_fields['row']) && sizeof($profile_fields['row'])) ? true : false, 'S_CUSTOM_FIELDS' => (isset($profile_fields['row']) && sizeof($profile_fields['row'])) ? true : false,
'U_USER_ADMIN' => ($auth->acl_get('a_user')) ? append_sid("{$phpbb_root_path}adm/index.$phpEx", 'i=users&amp;mode=overview&amp;u=' . $user_id, true, $user->session_id) : '', 'U_USER_ADMIN' => ($auth->acl_get('a_user')) ? append_sid("{$phpbb_admin_path}index.$phpEx", 'i=users&amp;mode=overview&amp;u=' . $user_id, true, $user->session_id) : '',
'U_USER_BAN' => ($auth->acl_get('m_ban') && $user_id != $user->data['user_id']) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=ban&amp;mode=user&amp;u=' . $user_id, true, $user->session_id) : '', 'U_USER_BAN' => ($auth->acl_get('m_ban') && $user_id != $user->data['user_id']) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=ban&amp;mode=user&amp;u=' . $user_id, true, $user->session_id) : '',
'U_MCP_QUEUE' => ($auth->acl_getf_global('m_approve')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue', true, $user->session_id) : '', 'U_MCP_QUEUE' => ($auth->acl_getf_global('m_approve')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue', true, $user->session_id) : '',

View file

@ -216,7 +216,7 @@ while ($row = $db->sql_fetchrow($result))
$location_url = append_sid("{$phpbb_root_path}index.$phpEx"); $location_url = append_sid("{$phpbb_root_path}index.$phpEx");
break; break;
case 'adm/index': case $adm_relative_path . 'index':
$location = $user->lang['ACP']; $location = $user->lang['ACP'];
$location_url = append_sid("{$phpbb_root_path}index.$phpEx"); $location_url = append_sid("{$phpbb_root_path}index.$phpEx");
break; break;