diff --git a/phpBB/adm/index.php b/phpBB/adm/index.php
index 907fed3681..beba6d00a6 100644
--- a/phpBB/adm/index.php
+++ b/phpBB/adm/index.php
@@ -408,6 +408,35 @@ function validate_config_vars($config_vars, &$cfg_array, &$error)
$cfg_array[$config_name] = (int) $cfg_array[$config_name];
break;
+ // Absolute path
+ case 'script_path':
+ if (!$cfg_array[$config_name])
+ {
+ break;
+ }
+
+ $destination = str_replace('\\', '/', $cfg_array[$config_name]);
+
+ if ($destination !== '/')
+ {
+ // Adjust destination path (no trailing slash)
+ if (substr($destination, -1, 1) == '/')
+ {
+ $destination = substr($destination, 0, -1);
+ }
+
+ $destination = str_replace(array('../', './'), '', $destination);
+
+ if ($destination[0] != '/')
+ {
+ $destination = '/' . $destination;
+ }
+ }
+
+ $cfg_array[$config_name] = trim($destination);
+
+ break;
+
// Relative path (appended $phpbb_root_path)
case 'rpath':
case 'rwpath':
@@ -419,9 +448,9 @@ function validate_config_vars($config_vars, &$cfg_array, &$error)
$destination = $cfg_array[$config_name];
// Adjust destination path (no trailing slash)
- if ($destination{(sizeof($destination)-1)} == '/' || $destination{(sizeof($destination)-1)} == '\\')
+ if (substr($destination, -1, 1) == '/' || substr($destination, -1, 1) == '\\')
{
- $destination = substr($destination, 0, sizeof($destination)-2);
+ $destination = substr($destination, 0, -1);
}
$destination = str_replace(array('../', '..\\', './', '.\\'), '', $destination);
diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php
index 92f8057676..d67cfba2f3 100644
--- a/phpBB/includes/acp/acp_board.php
+++ b/phpBB/includes/acp/acp_board.php
@@ -27,7 +27,12 @@ class acp_board
$action = request_var('action', '');
$submit = (isset($_POST['submit'])) ? true : false;
- // Validation types are: string, int, bool, rpath (relative), rwpath (realtive, writeable), path (relative path, but able to escape the root), wpath (writeable)
+ /**
+ * Validation types are:
+ * string, int, bool,
+ * script_path (absolute path in url - beginning with / and no trailing slash),
+ * rpath (relative), rwpath (realtive, writeable), path (relative path, but able to escape the root), wpath (writeable)
+ */
switch ($mode)
{
case 'settings':
@@ -283,10 +288,11 @@ class acp_board
'ranks_path' => array('lang' => 'RANKS_PATH', 'validate' => 'rpath', 'type' => 'text:20:255', 'explain' => true),
'legend3' => 'SERVER_URL_SETTINGS',
- 'force_server_vars' => array('lang' => 'FORCE_SERVER_VARS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
- 'server_protocol' => array('lang' => 'SERVER_PROTOCOL', 'validate' => 'string', 'type' => 'text:10:10', 'explain' => true),
- 'server_name' => array('lang' => 'SERVER_NAME', 'validate' => 'string', 'type' => 'text:40:255', 'explain' => true),
- 'server_port' => array('lang' => 'SERVER_PORT', 'validate' => 'int', 'type' => 'text:5:5', 'explain' => true),
+ 'force_server_vars' => array('lang' => 'FORCE_SERVER_VARS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
+ 'server_protocol' => array('lang' => 'SERVER_PROTOCOL', 'validate' => 'string', 'type' => 'text:10:10', 'explain' => true),
+ 'server_name' => array('lang' => 'SERVER_NAME', 'validate' => 'string', 'type' => 'text:40:255', 'explain' => true),
+ 'server_port' => array('lang' => 'SERVER_PORT', 'validate' => 'int', 'type' => 'text:5:5', 'explain' => true),
+ 'script_path' => array('lang' => 'SCRIPT_PATH', 'validate' => 'script_path', 'type' => 'text::255', 'explain' => true),
)
);
break;
diff --git a/phpBB/includes/acp/acp_inactive.php b/phpBB/includes/acp/acp_inactive.php
index 68eeaab5b4..84387b4f5c 100755
--- a/phpBB/includes/acp/acp_inactive.php
+++ b/phpBB/includes/acp/acp_inactive.php
@@ -94,10 +94,8 @@ class acp_inactive
include_once($phpbb_root_path . 'includes/functions_messenger.'.$phpEx);
$messenger = new messenger();
-
- $board_url = generate_board_url() . "/ucp.$phpEx?mode=activate";
-
$usernames = array();
+
do
{
$messenger->template('user_remind_inactive', $row['user_lang']);
@@ -109,7 +107,7 @@ class acp_inactive
$messenger->assign_vars(array(
'USERNAME' => htmlspecialchars_decode($row['username']),
'REGISTER_DATE' => $user->format_date($row['user_regdate']),
- 'U_ACTIVATE' => "$board_url&mode=activate&u=" . $row['user_id'] . '&k=' . $row['user_actkey'])
+ 'U_ACTIVATE' => generate_board_url() . "/ucp.$phpEx?mode=activate&u=" . $row['user_id'] . '&k=' . $row['user_actkey'])
);
$messenger->send($row['user_notify_type']);
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index 3b0cd9a055..4c417cc03e 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -1451,6 +1451,7 @@ function generate_board_url($without_script_path = false)
$server_protocol = ($config['server_protocol']) ? $config['server_protocol'] : (($config['cookie_secure']) ? 'https://' : 'http://');
$server_name = $config['server_name'];
$server_port = (int) $config['server_port'];
+ $script_path = $config['script_path'];
$url = $server_protocol . $server_name;
}
@@ -1459,6 +1460,8 @@ function generate_board_url($without_script_path = false)
// Do not rely on cookie_secure, users seem to think that it means a secured cookie instead of an encrypted connection
$cookie_secure = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 1 : 0;
$url = (($cookie_secure) ? 'https://' : 'http://') . $server_name;
+
+ $script_path = $user->page['root_script_path'];
}
if ($server_port && (($config['cookie_secure'] && $server_port <> 443) || (!$config['cookie_secure'] && $server_port <> 80)))
@@ -1466,13 +1469,18 @@ function generate_board_url($without_script_path = false)
$url .= ':' . $server_port;
}
- if ($without_script_path)
+ if (!$without_script_path)
{
- return $url;
+ $url .= $script_path;
}
// Strip / from the end
- return $url . substr($user->page['root_script_path'], 0, -1);
+ if (substr($url, -1, 1) == '/')
+ {
+ $url = substr($url, 0, -1);
+ }
+
+ return $url;
}
/**
diff --git a/phpBB/includes/functions_transfer.php b/phpBB/includes/functions_transfer.php
index 4c47f99412..8c00f2b1dd 100644
--- a/phpBB/includes/functions_transfer.php
+++ b/phpBB/includes/functions_transfer.php
@@ -359,9 +359,12 @@ class ftp extends transfer
*/
function _chdir($dir = '')
{
- if (substr($dir, -1, 1) == '/')
+ if ($dir && $dir !== '/')
{
- $dir = substr($dir, 0, -1);
+ if (substr($dir, -1, 1) == '/')
+ {
+ $dir = substr($dir, 0, -1);
+ }
}
return @ftp_chdir($this->connection, $dir);
@@ -585,9 +588,12 @@ class ftp_fsock extends transfer
*/
function _chdir($dir = '')
{
- if (substr($dir, -1, 1) == '/')
+ if ($dir && $dir !== '/')
{
- $dir = substr($dir, 0, -1);
+ if (substr($dir, -1, 1) == '/')
+ {
+ $dir = substr($dir, 0, -1);
+ }
}
return $this->_send_command('CWD', $dir);
diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php
index 285b0d0649..ed6f69cf49 100644
--- a/phpBB/includes/message_parser.php
+++ b/phpBB/includes/message_parser.php
@@ -840,7 +840,14 @@ class bbcode_firstpass extends bbcode
{
global $config, $phpEx, $user;
- $check_path = ($user->page['root_script_path'] != '/') ? substr($user->page['root_script_path'], 0, -1) : '/';
+ if ($config['force_server_vars'])
+ {
+ $check_path = $config['script_path'];
+ }
+ else
+ {
+ $check_path = ($user->page['root_script_path'] != '/') ? substr($user->page['root_script_path'], 0, -1) : '/';
+ }
// Is the user trying to link to a php file in this domain and script path?
if (strpos($url, ".{$phpEx}") !== false && strpos($url, $check_path) !== false)
diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php
index 29055f0d89..cfd6f217c0 100644
--- a/phpBB/includes/ucp/ucp_profile.php
+++ b/phpBB/includes/ucp/ucp_profile.php
@@ -173,7 +173,7 @@ class ucp_profile
$messenger->assign_vars(array(
'USERNAME' => htmlspecialchars_decode($data['username']),
- 'U_USER_DETAILS' => "$server_url/memberlist.$phpEx?mode=viewprofile&u={$user->data['user_id']}",
+ 'U_USER_DETAILS' => "$server_url/memberlist.$phpEx?mode=viewprofile&u={$user->data['user_id']}",
'U_ACTIVATE' => "$server_url/ucp.$phpEx?mode=activate&u={$user->data['user_id']}&k=$user_actkey")
);
diff --git a/phpBB/includes/ucp/ucp_resend.php b/phpBB/includes/ucp/ucp_resend.php
index fe5801b37d..c61859b3e2 100644
--- a/phpBB/includes/ucp/ucp_resend.php
+++ b/phpBB/includes/ucp/ucp_resend.php
@@ -113,7 +113,7 @@ class ucp_resend
$messenger->assign_vars(array(
'USERNAME' => htmlspecialchars_decode($user_row['username']),
- 'U_USER_DETAILS' => "$server_url/memberlist.$phpEx?mode=viewprofile&u={$user->data['user_id']}",
+ 'U_USER_DETAILS' => generate_board_url() . "/memberlist.$phpEx?mode=viewprofile&u={$user->data['user_id']}",
'U_ACTIVATE' => generate_board_url() . "/ucp.$phpEx?mode=activate&u={$user_row['user_id']}&k={$user_row['user_actkey']}")
);
diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php
index dae441f40b..e5c0998be5 100644
--- a/phpBB/install/database_update.php
+++ b/phpBB/install/database_update.php
@@ -490,6 +490,14 @@ if (version_compare($current_version, '3.0.b3', '<'))
$no_updates = false;
}
+if (version_compare($current_version, '3.0.b4', '<'))
+{
+ // Add config value
+ set_config('script_path', '/');
+
+ $no_updates = false;
+}
+
_write_result($no_updates, $errored, $error_ary);
$error_ary = array();
diff --git a/phpBB/install/install_install.php b/phpBB/install/install_install.php
index e88e13a05e..f5cf049327 100755
--- a/phpBB/install/install_install.php
+++ b/phpBB/install/install_install.php
@@ -987,6 +987,19 @@ class install_install extends module
$server_protocol = ($server_protocol !== '') ? $server_protocol : ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://');
$cookie_secure = ($cookie_secure !== '') ? $cookie_secure : ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? true : false);
+ if ($script_path === '')
+ {
+ $name = (!empty($_SERVER['PHP_SELF'])) ? $_SERVER['PHP_SELF'] : getenv('PHP_SELF');
+ if (!$name)
+ {
+ $name = (!empty($_SERVER['REQUEST_URI'])) ? $_SERVER['REQUEST_URI'] : getenv('REQUEST_URI');
+ }
+
+ // Replace backslashes and doubled slashes (could happen on some proxy setups)
+ $name = str_replace(array('\\', '//', '/install'), '/', $name);
+ $script_path = trim(dirname($name));
+ }
+
foreach ($this->advanced_config_options as $config_key => $vars)
{
if (!is_array($vars) && strpos($config_key, 'legend') === false)
@@ -1166,6 +1179,22 @@ class install_install extends module
$user_ip = (!empty($_SERVER['REMOTE_ADDR'])) ? htmlspecialchars($_SERVER['REMOTE_ADDR']) : '';
+ if ($script_path !== '/')
+ {
+ // Adjust destination path (no trailing slash)
+ if ($script_path[sizeof($script_path) - 1] == '/')
+ {
+ $script_path = substr($script_path, 0, -1);
+ }
+
+ $script_path = str_replace(array('../', './'), '', $script_path);
+
+ if ($script_path[0] != '/')
+ {
+ $script_path = '/' . $script_path;
+ }
+ }
+
// Set default config and post data, this applies to all DB's
$sql_ary = array(
'INSERT INTO ' . $table_prefix . "config (config_name, config_value)
@@ -1235,17 +1264,13 @@ class install_install extends module
WHERE config_name = 'force_server_vars'",
'UPDATE ' . $table_prefix . "config
- SET config_value = '" . $db->sql_escape($server_name) . "'
- WHERE config_name = 'server_name'",
+ SET config_value = '" . $db->sql_escape($script_path) . "'
+ WHERE config_name = 'script_path'",
'UPDATE ' . $table_prefix . "config
SET config_value = '" . $db->sql_escape($server_protocol) . "'
WHERE config_name = 'server_protocol'",
- 'UPDATE ' . $table_prefix . "config
- SET config_value = '" . $db->sql_escape($server_port) . "'
- WHERE config_name = 'server_port'",
-
'UPDATE ' . $table_prefix . "config
SET config_value = '" . $db->sql_escape($admin_name) . "'
WHERE config_name = 'newest_username'",
@@ -2025,7 +2050,7 @@ class install_install extends module
* The variables that we will be passing between pages
* Used to retrieve data quickly on each page
*/
- var $request_vars = array('language', 'dbms', 'dbhost', 'dbport', 'dbuser', 'dbpasswd', 'dbname', 'table_prefix', 'default_lang', 'admin_name', 'admin_pass1', 'admin_pass2', 'board_email1', 'board_email2', 'img_imagick', 'ftp_path', 'ftp_user', 'ftp_pass', 'email_enable', 'smtp_delivery', 'smtp_host', 'smtp_auth', 'smtp_user', 'smtp_pass', 'cookie_secure', 'force_server_vars', 'server_protocol', 'server_name', 'server_port');
+ var $request_vars = array('language', 'dbms', 'dbhost', 'dbport', 'dbuser', 'dbpasswd', 'dbname', 'table_prefix', 'default_lang', 'admin_name', 'admin_pass1', 'admin_pass2', 'board_email1', 'board_email2', 'img_imagick', 'ftp_path', 'ftp_user', 'ftp_pass', 'email_enable', 'smtp_delivery', 'smtp_host', 'smtp_auth', 'smtp_user', 'smtp_pass', 'cookie_secure', 'force_server_vars', 'server_protocol', 'server_name', 'server_port', 'script_path');
/**
* The information below will be used to build the input fields presented to the user
@@ -2064,6 +2089,7 @@ class install_install extends module
'server_protocol' => array('lang' => 'SERVER_PROTOCOL', 'type' => 'text:10:10', 'explain' => true),
'server_name' => array('lang' => 'SERVER_NAME', 'type' => 'text:40:255', 'explain' => true),
'server_port' => array('lang' => 'SERVER_PORT', 'type' => 'text:5:5', 'explain' => true),
+ 'script_path' => array('lang' => 'SCRIPT_PATH', 'type' => 'text::255', 'explain' => true),
);
/**
diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php
index 2a6de60d47..fed66a0a07 100644
--- a/phpBB/install/install_update.php
+++ b/phpBB/install/install_update.php
@@ -412,6 +412,7 @@ class install_update extends module
// To ease the update process create a file location map
$update_list = $cache->get('_update_list');
+ $script_path = ($config['force_server_vars']) ? (($config['script_path'] == '/') ? '/' : $config['script_path'] . '/') : $user->page['root_script_path'];
foreach ($update_list as $status => $files)
{
@@ -429,7 +430,7 @@ class install_update extends module
$template->assign_block_vars('location', array(
'SOURCE' => htmlspecialchars($file_struct['filename']),
- 'DESTINATION' => $user->page['root_script_path'] . htmlspecialchars($file_struct['filename']),
+ 'DESTINATION' => $script_path . htmlspecialchars($file_struct['filename']),
));
}
}
diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql
index 0cea5a5f72..795ca8becd 100644
--- a/phpBB/install/schemas/schema_data.sql
+++ b/phpBB/install/schemas/schema_data.sql
@@ -170,6 +170,7 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('print_pm', '1');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('queue_interval', '600');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('ranks_path', 'images/ranks');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('require_activation', '0');
+INSERT INTO phpbb_config (config_name, config_value) VALUES ('script_path', '');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('search_block_size', '250');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('search_gc', '7200');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('search_indexing_state', '');
diff --git a/phpBB/language/en/acp/board.php b/phpBB/language/en/acp/board.php
index c5c31767c6..e34c65bf90 100644
--- a/phpBB/language/en/acp/board.php
+++ b/phpBB/language/en/acp/board.php
@@ -249,7 +249,7 @@ $lang = array_merge($lang, array(
'LIMIT_LOAD_EXPLAIN' => 'If the 1 minute system load exceeds this value the board will go offline, 1.0 equals ~100% utilisation of one processor. This only functions on UNIX based servers.',
'LIMIT_SESSIONS' => 'Limit sessions',
'LIMIT_SESSIONS_EXPLAIN' => 'If the number of sessions exceeds this value within a one minute period the board will go offline. Set to 0 for unlimited sessions.',
- 'LOAD_CPF_MEMBERLIST' => 'Display custom profile fields in memberlist',
+ 'LOAD_CPF_MEMBERLIST' => 'Allow styles to display custom profile fields in memberlist',
'LOAD_CPF_VIEWPROFILE' => 'Display custom profile fields in user profiles',
'LOAD_CPF_VIEWTOPIC' => 'Display custom profile fields on viewtopic',
'LOAD_USER_ACTIVITY' => 'Show users activity',
@@ -305,6 +305,8 @@ $lang = array_merge($lang, array(
'PATH_SETTINGS' => 'Path settings',
'RANKS_PATH' => 'Rank image storage path',
'RANKS_PATH_EXPLAIN' => 'Path under your phpBB root dir, e.g. images/ranks',
+ 'SCRIPT_PATH' => 'Script path',
+ 'SCRIPT_PATH_EXPLAIN' => 'The path where phpBB is located relative to the domain name, e.g. /phpBB3',
'SEND_ENCODING' => 'Send encoding',
'SEND_ENCODING_EXPLAIN' => 'Send the file encoding from phpBB via HTTP overriding the webserver configuration',
'SERVER_NAME' => 'Domain name',
diff --git a/phpBB/language/en/install.php b/phpBB/language/en/install.php
index 08c07cdeb8..b0a8171dc1 100755
--- a/phpBB/language/en/install.php
+++ b/phpBB/language/en/install.php
@@ -259,7 +259,7 @@ $lang = array_merge($lang, array(
'RETRY_WRITE_EXPLAIN' => 'If you wish you can change the permissions on config.php to allow phpBB to write to it. Should you wish to do that you can click Retry below to try again. Remember to return the permissions on config.php after phpBB has finished installation.',
'SCRIPT_PATH' => 'Script path',
- 'SCRIPT_PATH_EXPLAIN' => 'The path where phpBB is located relative to the domain name',
+ 'SCRIPT_PATH_EXPLAIN' => 'The path where phpBB is located relative to the domain name, e.g. /phpBB3',
'SELECT_LANG' => 'Select language',
'SERVER_CONFIG' => 'Server Configuration',
'SOFTWARE' => 'Forum Software',
diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php
index 8b35a162e5..6b8455ef3b 100644
--- a/phpBB/memberlist.php
+++ b/phpBB/memberlist.php
@@ -1444,14 +1444,17 @@ function show_profile($data)
// Dump it out to the template
return array(
'AGE' => $age,
- 'USERNAME' => $username,
- 'USER_COLOR' => (!empty($data['user_colour'])) ? $data['user_colour'] : '',
'RANK_TITLE' => $rank_title,
'JOINED' => $user->format_date($data['user_regdate']),
'VISITED' => (empty($last_visit)) ? ' - ' : $user->format_date($last_visit),
'POSTS' => ($data['user_posts']) ? $data['user_posts'] : 0,
'WARNINGS' => isset($data['user_warnings']) ? $data['user_warnings'] : 0,
+ 'USERNAME_FULL' => get_username_string('full', $user_id, $username, $data['user_colour']),
+ 'USERNAME' => get_username_string('username', $user_id, $username, $data['user_colour']),
+ 'USER_COLOR' => get_username_string('colour', $user_id, $username, $data['user_colour']),
+ 'U_VIEW_PROFILE' => get_username_string('profile', $user_id, $username, $data['user_colour']),
+
'ONLINE_IMG' => (!$config['load_onlinetrack']) ? '' : (($online) ? $user->img('icon_user_online', 'ONLINE') : $user->img('icon_user_offline', 'OFFLINE')),
'S_ONLINE' => ($config['load_onlinetrack'] && $online) ? true : false,
'RANK_IMG' => $rank_img,
@@ -1459,7 +1462,6 @@ function show_profile($data)
'ICQ_STATUS_IMG' => (!empty($data['user_icq'])) ? '' : '',
'S_JABBER_ENABLED' => ($config['jab_enable']) ? true : false,
- 'U_PROFILE' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&u=' . $user_id),
'U_SEARCH_USER' => ($auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", "author_id=$user_id&sr=posts") : '',
'U_NOTES' => $auth->acl_getf_global('m_') ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $user_id, true, $user->session_id) : '',
'U_WARN' => $auth->acl_getf_global('m_warn') ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=warn&mode=warn_user&u=' . $user_id, true, $user->session_id) : '',
diff --git a/phpBB/styles/subSilver/template/memberlist_body.html b/phpBB/styles/subSilver/template/memberlist_body.html
index a266299932..911d980f75 100644
--- a/phpBB/styles/subSilver/template/memberlist_body.html
+++ b/phpBB/styles/subSilver/template/memberlist_body.html
@@ -61,10 +61,10 @@