aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB')
-rw-r--r--phpBB/common.php11
-rw-r--r--phpBB/config/services.yml14
-rw-r--r--phpBB/includes/bbcode.php4
-rw-r--r--phpBB/includes/functions.php139
-rw-r--r--phpBB/includes/functions_content.php53
-rw-r--r--phpBB/includes/functions_messenger.php4
-rw-r--r--phpBB/install/index.php3
-rw-r--r--phpBB/language/en/acp/board.php2
-rw-r--r--phpBB/phpbb/filesystem.php146
-rw-r--r--phpBB/phpbb/symfony_request.php46
-rw-r--r--phpBB/phpbb/template/asset.php9
-rw-r--r--phpBB/phpbb/template/twig/environment.php33
-rw-r--r--phpBB/phpbb/template/twig/node/includeasset.php2
-rw-r--r--phpBB/phpbb/template/twig/twig.php25
-rw-r--r--phpBB/styles/prosilver/template/ucp_notifications.html2
-rw-r--r--phpBB/styles/subsilver2/template/ucp_notifications.html2
16 files changed, 345 insertions, 150 deletions
diff --git a/phpBB/common.php b/phpBB/common.php
index a7b7db28ac..b9ba37935d 100644
--- a/phpBB/common.php
+++ b/phpBB/common.php
@@ -47,7 +47,13 @@ if (!defined('PHPBB_INSTALLED'))
// Eliminate . and .. from the path
require($phpbb_root_path . 'phpbb/filesystem.' . $phpEx);
- $phpbb_filesystem = new phpbb_filesystem();
+ $phpbb_filesystem = new phpbb_filesystem(
+ new phpbb_symfony_request(
+ new phpbb_request()
+ ),
+ $phpbb_root_path,
+ $phpEx
+ );
$script_path = $phpbb_filesystem->clean_path($script_path);
$url = (($secure) ? 'https://' : 'http://') . $server_name;
@@ -110,7 +116,8 @@ $db = $phpbb_container->get('dbal.conn');
request_var('', 0, false, false, $request); // "dependency injection" for a function
// Create a Symfony Request object from our phpbb_request object
-$symfony_request = phpbb_create_symfony_request($request);
+$symfony_request = $phpbb_container->get('symfony_request');
+$phpbb_filesystem = $phpbb_container->get('filesystem');
// Grab global variables, re-cache if necessary
$config = $phpbb_container->get('config');
diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml
index ba3b2a407d..9231138e1c 100644
--- a/phpBB/config/services.yml
+++ b/phpBB/config/services.yml
@@ -169,6 +169,11 @@ services:
filesystem:
class: phpbb_filesystem
+ arguments:
+ - @symfony_request
+ - %core.root_path%
+ - %core.php_ext%
+ - %core.adm_relative_path%
groupposition.legend:
class: phpbb_groupposition_legend
@@ -252,16 +257,19 @@ services:
request:
class: phpbb_request
+ symfony_request:
+ class: phpbb_symfony_request
+ arguments:
+ - @request
+
template:
class: phpbb_template_twig
arguments:
- - %core.root_path%
- - %core.php_ext%
+ - @filesystem
- @config
- @user
- @template_context
- @ext.manager
- - %core.adm_relative_path%
template_context:
class: phpbb_template_context
diff --git a/phpBB/includes/bbcode.php b/phpBB/includes/bbcode.php
index 2fa6a8b099..0c567dd012 100644
--- a/phpBB/includes/bbcode.php
+++ b/phpBB/includes/bbcode.php
@@ -126,13 +126,13 @@ class bbcode
*/
function bbcode_cache_init()
{
- global $phpbb_root_path, $phpEx, $config, $user, $phpbb_extension_manager;
+ global $phpbb_root_path, $phpEx, $config, $user, $phpbb_extension_manager, $phpbb_filesystem;
if (empty($this->template_filename))
{
$this->template_bitfield = new bitfield($user->style['bbcode_bitfield']);
- $template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $user, new phpbb_template_context(), $phpbb_extension_manager);
+ $template = new phpbb_template_twig($phpbb_filesystem, $config, $user, new phpbb_template_context(), $phpbb_extension_manager);
$template->set_style();
$template->set_filenames(array('bbcode.html' => 'bbcode.html'));
$this->template_filename = $template->get_source_file_for_handle('bbcode.html');
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index 888ef59222..89c562fde6 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -7,8 +7,6 @@
*
*/
-use Symfony\Component\HttpFoundation\Request;
-
/**
* @ignore
*/
@@ -1072,7 +1070,14 @@ function phpbb_clean_path($path)
global $phpbb_root_path, $phpEx;
require($phpbb_root_path . 'includes/filesystem.' . $phpEx);
}
- $phpbb_filesystem = new phpbb_filesystem();
+
+ $phpbb_filesystem = new phpbb_filesystem(
+ new phpbb_symfony_request(
+ new phpbb_request()
+ ),
+ $phpbb_root_path,
+ $phpEx
+ );
}
return $phpbb_filesystem->clean_path($path);
@@ -2410,9 +2415,8 @@ function phpbb_on_page($template, $user, $base_url, $num_items, $per_page, $star
*/
function append_sid($url, $params = false, $is_amp = true, $session_id = false)
{
- global $_SID, $_EXTRA_URL, $phpbb_hook;
+ global $_SID, $_EXTRA_URL, $phpbb_hook, $phpbb_filesystem;
global $phpbb_dispatcher;
- global $symfony_request, $phpbb_root_path;
if ($params === '' || (is_array($params) && empty($params)))
{
@@ -2420,10 +2424,10 @@ function append_sid($url, $params = false, $is_amp = true, $session_id = false)
$params = false;
}
- $corrected_path = $symfony_request !== null ? phpbb_get_web_root_path($symfony_request, $phpbb_root_path) : '';
- if ($corrected_path)
+ // Update the root path with the correct relative web path
+ if ($phpbb_filesystem instanceof phpbb_filesystem)
{
- $url = substr($corrected_path . $url, strlen($phpbb_root_path));
+ $url = $phpbb_filesystem->update_web_root_path($url);
}
$append_sid_overwrite = false;
@@ -2815,8 +2819,22 @@ function build_url($strip_vars = false)
{
global $user, $phpbb_root_path;
+ $page = $user->page['page'];
+
+ // We need to be cautious here.
+ // On some situations, the redirect path is an absolute URL, sometimes a relative path
+ // For a relative path, let's prefix it with $phpbb_root_path to point to the correct location,
+ // else we use the URL directly.
+ $url_parts = parse_url($page);
+
+ // URL
+ if ($url_parts !== false && !empty($url_parts['scheme']) && !empty($url_parts['host']))
+ {
+ $page = $phpbb_root_path . $page;
+ }
+
// Append SID
- $redirect = append_sid($user->page['page'], false, false);
+ $redirect = append_sid($page, false, false);
// Add delimiter if not there...
if (strpos($redirect, '?') === false)
@@ -2871,19 +2889,7 @@ function build_url($strip_vars = false)
$redirect .= ($query) ? '?' . $query : '';
}
- // We need to be cautious here.
- // On some situations, the redirect path is an absolute URL, sometimes a relative path
- // For a relative path, let's prefix it with $phpbb_root_path to point to the correct location,
- // else we use the URL directly.
- $url_parts = @parse_url($redirect);
-
- // URL
- if ($url_parts !== false && !empty($url_parts['scheme']) && !empty($url_parts['host']))
- {
- return str_replace('&', '&', $redirect);
- }
-
- return $phpbb_root_path . str_replace('&', '&', $redirect);
+ return str_replace('&', '&', $redirect);
}
/**
@@ -5080,7 +5086,7 @@ function phpbb_build_hidden_fields_for_query_params($request, $exclude = null)
function page_header($page_title = '', $display_online_list = true, $item_id = 0, $item = 'forum')
{
global $db, $config, $template, $SID, $_SID, $_EXTRA_URL, $user, $auth, $phpEx, $phpbb_root_path;
- global $phpbb_dispatcher, $request, $phpbb_container, $symfony_request;
+ global $phpbb_dispatcher, $request, $phpbb_container, $adm_relative_path;
if (defined('HEADER_INC'))
{
@@ -5240,7 +5246,8 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0
// This path is sent with the base template paths in the assign_vars()
// call below. We need to correct it in case we are accessing from a
// controller because the web paths will be incorrect otherwise.
- $corrected_path = $symfony_request !== null ? phpbb_get_web_root_path($symfony_request, $phpbb_root_path) : '';
+ $phpbb_filesystem = $phpbb_container->get('filesystem');
+ $corrected_path = $phpbb_filesystem->get_web_root_path();
$web_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? $board_url : $corrected_path;
// Send a proper content-language to the output
@@ -5322,7 +5329,7 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0
'SID' => $SID,
'_SID' => $_SID,
'SESSION_ID' => $user->session_id,
- 'ROOT_PATH' => $phpbb_root_path,
+ 'ROOT_PATH' => $web_path,
'BOARD_URL' => $board_url,
'L_LOGIN_LOGOUT' => $l_login_logout,
@@ -5378,7 +5385,7 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0
'S_FORUM_ID' => $forum_id,
'S_TOPIC_ID' => $topic_id,
- 'S_LOGIN_ACTION' => ((!defined('ADMIN_START')) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login') : append_sid("index.$phpEx", false, true, $user->session_id)),
+ 'S_LOGIN_ACTION' => ((!defined('ADMIN_START')) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login') : append_sid("{$phpbb_root_path}{$adm_relative_path}index.$phpEx", false, true, $user->session_id)),
'S_LOGIN_REDIRECT' => build_hidden_fields(array('redirect' => build_url())),
'S_ENABLE_FEEDS' => ($config['feed_enable']) ? true : false,
@@ -5705,83 +5712,3 @@ function phpbb_convert_30_dbms_to_31($dbms)
throw new \RuntimeException("You have specified an invalid dbms driver: $dbms");
}
-
-/**
-* Create a Symfony Request object from phpbb_request object
-*
-* @param phpbb_request $request Request object
-* @return Request A Symfony Request object
-*/
-function phpbb_create_symfony_request(phpbb_request $request)
-{
- // If we have already gotten it, don't go back through all the trouble of
- // creating it again; instead, just return it. This allows multiple calls
- // of this method so we don't have to globalize $symfony_request in other
- // functions.
- static $symfony_request;
- if (null !== $symfony_request)
- {
- return $symfony_request;
- }
-
- // This function is meant to sanitize the global input arrays
- $sanitizer = function(&$value, $key) {
- $type_cast_helper = new phpbb_request_type_cast_helper();
- $type_cast_helper->set_var($value, $value, gettype($value), true);
- };
-
- // We need to re-enable the super globals so we can access them here
- $request->enable_super_globals();
- $get_parameters = $_GET;
- $post_parameters = $_POST;
- $server_parameters = $_SERVER;
- $files_parameters = $_FILES;
- $cookie_parameters = $_COOKIE;
- // And now disable them again for security
- $request->disable_super_globals();
-
- array_walk_recursive($get_parameters, $sanitizer);
- array_walk_recursive($post_parameters, $sanitizer);
-
- $symfony_request = new Request($get_parameters, $post_parameters, array(), $cookie_parameters, $files_parameters, $server_parameters);
- return $symfony_request;
-}
-
-/**
-* Get a relative root path from the current URL
-*
-* @param Request $symfony_request Symfony Request object
-*/
-function phpbb_get_web_root_path(Request $symfony_request, $phpbb_root_path = '')
-{
- global $phpbb_container;
-
- static $path;
- if (null !== $path)
- {
- return $path;
- }
-
- $path_info = $symfony_request->getPathInfo();
- if ($path_info === '/')
- {
- $path = $phpbb_root_path;
- return $path;
- }
-
- $filesystem = $phpbb_container->get('filesystem');
- $path_info = $filesystem->clean_path($path_info);
-
- // Do not count / at start of path
- $corrections = substr_count(substr($path_info, 1), '/');
-
- // When URL Rewriting is enabled, app.php is optional. We have to
- // correct for it not being there
- if (strpos($symfony_request->getRequestUri(), $symfony_request->getScriptName()) === false)
- {
- $corrections -= 1;
- }
-
- $path = $phpbb_root_path . str_repeat('../', $corrections);
- return $path;
-}
diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php
index 05d3c5fde2..7ecc99b39c 100644
--- a/phpBB/includes/functions_content.php
+++ b/phpBB/includes/functions_content.php
@@ -727,37 +727,58 @@ function make_clickable($text, $server_url = false, $class = 'postlink')
$server_url = generate_board_url();
}
- static $magic_url_match;
- static $magic_url_replace;
static $static_class;
+ static $magic_url_match_args;
- if (!is_array($magic_url_match) || $static_class != $class)
+ if (!is_array($magic_url_match_args) || $static_class != $class)
{
$static_class = $class;
$class = ($static_class) ? ' class="' . $static_class . '"' : '';
$local_class = ($static_class) ? ' class="' . $static_class . '-local"' : '';
- $magic_url_match = $magic_url_replace = array();
- // Be sure to not let the matches cross over. ;)
+ $magic_url_match_args = array();
// relative urls for this board
- $magic_url_match[] = '#(^|[\n\t (>.])(' . preg_quote($server_url, '#') . ')/(' . get_preg_expression('relative_url_inline') . ')#ie';
- $magic_url_replace[] = "make_clickable_callback(MAGIC_URL_LOCAL, '\$1', '\$2', '\$3', '$local_class')";
+ $magic_url_match_args[] = array(
+ '#(^|[\n\t (>.])(' . preg_quote($server_url, '#') . ')/(' . get_preg_expression('relative_url_inline') . ')#i',
+ MAGIC_URL_LOCAL,
+ $local_class,
+ );
// matches a xxxx://aaaaa.bbb.cccc. ...
- $magic_url_match[] = '#(^|[\n\t (>.])(' . get_preg_expression('url_inline') . ')#ie';
- $magic_url_replace[] = "make_clickable_callback(MAGIC_URL_FULL, '\$1', '\$2', '', '$class')";
+ $magic_url_match_args[] = array(
+ '#(^|[\n\t (>.])(' . get_preg_expression('url_inline') . ')#i',
+ MAGIC_URL_FULL,
+ $class,
+ );
// matches a "www.xxxx.yyyy[/zzzz]" kinda lazy URL thing
- $magic_url_match[] = '#(^|[\n\t (>])(' . get_preg_expression('www_url_inline') . ')#ie';
- $magic_url_replace[] = "make_clickable_callback(MAGIC_URL_WWW, '\$1', '\$2', '', '$class')";
+ $magic_url_match_args[] = array(
+ '#(^|[\n\t (>])(' . get_preg_expression('www_url_inline') . ')#i',
+ MAGIC_URL_WWW,
+ $class,
+ );
// matches an email@domain type address at the start of a line, or after a space or after what might be a BBCode.
- $magic_url_match[] = '/(^|[\n\t (>])(' . get_preg_expression('email') . ')/ie';
- $magic_url_replace[] = "make_clickable_callback(MAGIC_URL_EMAIL, '\$1', '\$2', '', '')";
+ $magic_url_match_args[] = array(
+ '/(^|[\n\t (>])(' . get_preg_expression('email') . ')/i',
+ MAGIC_URL_EMAIL,
+ '',
+ );
}
- return preg_replace($magic_url_match, $magic_url_replace, $text);
+ foreach ($magic_url_match_args as $magic_args)
+ {
+ if (preg_match($magic_args[0], $text, $matches))
+ {
+ $text = preg_replace_callback($magic_args[0], function($matches) use ($magic_args)
+ {
+ return make_clickable_callback($magic_args[1], $matches[1], $matches[2], $matches[3], $magic_args[2]);
+ }, $text);
+ }
+ }
+
+ return $text;
}
/**
@@ -813,7 +834,7 @@ function bbcode_nl2br($text)
*/
function smiley_text($text, $force_option = false)
{
- global $config, $user, $phpbb_root_path;
+ global $config, $user, $phpbb_filesystem;
if ($force_option || !$config['allow_smilies'] || !$user->optionget('viewsmilies'))
{
@@ -821,7 +842,7 @@ function smiley_text($text, $force_option = false)
}
else
{
- $root_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? generate_board_url() . '/' : $phpbb_root_path;
+ $root_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? generate_board_url() . '/' : $phpbb_filesystem->get_web_root_path();
return preg_replace('#<!\-\- s(.*?) \-\-><img src="\{SMILIES_PATH\}\/(.*?) \/><!\-\- s\1 \-\->#', '<img class="smilies" src="' . $root_path . $config['smilies_path'] . '/\2 />', $text);
}
}
diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php
index 3bfc1a44f0..13e25b4f5e 100644
--- a/phpBB/includes/functions_messenger.php
+++ b/phpBB/includes/functions_messenger.php
@@ -626,14 +626,14 @@ class messenger
*/
protected function setup_template()
{
- global $config, $phpbb_root_path, $phpEx, $user, $phpbb_extension_manager;
+ global $config, $phpbb_filesystem, $user, $phpbb_extension_manager;
if ($this->template instanceof phpbb_template)
{
return;
}
- $this->template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $user, new phpbb_template_context(), $phpbb_extension_manager);
+ $this->template = new phpbb_template_twig($phpbb_filesystem, $config, $user, new phpbb_template_context(), $phpbb_extension_manager);
}
/**
diff --git a/phpBB/install/index.php b/phpBB/install/index.php
index ec9aa5f32a..fbc47872c8 100644
--- a/phpBB/install/index.php
+++ b/phpBB/install/index.php
@@ -244,7 +244,8 @@ $config = new phpbb_config(array(
'load_tplcompile' => '1'
));
-$template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $user, new phpbb_template_context());
+$phpbb_filesystem = $phpbb_container->get('filesystem');
+$template = new phpbb_template_twig($phpbb_filesystem, $config, $user, new phpbb_template_context());
$paths = array($phpbb_root_path . 'install/update/new/adm/style', $phpbb_admin_path . 'style');
$paths = array_filter($paths, 'is_dir');
$template->set_custom_style('adm', $paths);
diff --git a/phpBB/language/en/acp/board.php b/phpBB/language/en/acp/board.php
index 6eabe99d80..f786374ba6 100644
--- a/phpBB/language/en/acp/board.php
+++ b/phpBB/language/en/acp/board.php
@@ -392,7 +392,7 @@ $lang = array_merge($lang, array(
// Auth settings
$lang = array_merge($lang, array(
- 'ACP_AUTH_SETTINGS_EXPLAIN' => 'phpBB supports authentication plug-ins, or modules. These allow you determine how users are authenticated when they log into the board. By default three plug-ins are provided; DB, LDAP and Apache. Not all methods require additional information so only fill out fields if they are relevant to the selected method.',
+ 'ACP_AUTH_SETTINGS_EXPLAIN' => 'phpBB supports authentication plug-ins, or modules. These allow you determine how users are authenticated when they log into the board. By default four plug-ins are provided: DB, LDAP, Apache, and OAuth. Not all methods require additional information so only fill out fields if they are relevant to the selected method.',
'AUTH_METHOD' => 'Select an authentication method',
diff --git a/phpBB/phpbb/filesystem.php b/phpBB/phpbb/filesystem.php
index 27cab48fb0..433fa9a62b 100644
--- a/phpBB/phpbb/filesystem.php
+++ b/phpBB/phpbb/filesystem.php
@@ -6,6 +6,7 @@
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
+
/**
* @ignore
*/
@@ -20,6 +21,151 @@ if (!defined('IN_PHPBB'))
*/
class phpbb_filesystem
{
+ /** @var phpbb_symfony_request */
+ protected $symfony_request;
+
+ /** @var string */
+ protected $phpbb_root_path;
+
+ /** @var string */
+ protected $adm_relative_path;
+
+ /** @var string */
+ protected $php_ext;
+
+ /** @var string */
+ protected $web_root_path;
+
+ /**
+ * Constructor
+ *
+ * @param phpbb_symfony_request $symfony_request
+ * @param string $phpbb_root_path Relative path to phpBB root
+ * @param string $php_ext PHP extension (php)
+ */
+ public function __construct(phpbb_symfony_request $symfony_request, $phpbb_root_path, $php_ext, $adm_relative_path = null)
+ {
+ $this->symfony_request = $symfony_request;
+ $this->phpbb_root_path = $phpbb_root_path;
+ $this->php_ext = $php_ext;
+ $this->adm_relative_path = $adm_relative_path;
+ }
+
+ /**
+ * Get the phpBB root path
+ *
+ * @return string
+ */
+ public function get_phpbb_root_path()
+ {
+ return $this->phpbb_root_path;
+ }
+
+ /**
+ * Get the adm root path
+ *
+ * @return string
+ */
+ public function get_adm_relative_path()
+ {
+ return $this->adm_relative_path;
+ }
+
+ /**
+ * Get the php extension
+ *
+ * @return string
+ */
+ public function get_php_ext()
+ {
+ return $this->php_ext;
+ }
+
+ /**
+ * Update a path to the correct relative root path
+ *
+ * This replaces $phpbb_root_path . some_url with
+ * get_web_root_path() . some_url OR if $phpbb_root_path
+ * is not at the beginning of $path, just prepends the
+ * web root path
+ *
+ * @param string $path The path to be updated
+ * @return string
+ */
+ public function update_web_root_path($path)
+ {
+ $web_root_path = $this->get_web_root_path($this->symfony_request);
+
+ if (strpos($path, $this->phpbb_root_path) === 0)
+ {
+ $path = substr($path, strlen($this->phpbb_root_path));
+ }
+
+ return $web_root_path . $path;
+ }
+
+ /**
+ * Get a relative root path from the current URL
+ *
+ * @return string
+ */
+ public function get_web_root_path()
+ {
+ if ($this->symfony_request === null)
+ {
+ return $this->phpbb_root_path;
+ }
+
+ if (null !== $this->web_root_path)
+ {
+ return $this->web_root_path;
+ }
+
+ // Path info (e.g. /foo/bar)
+ $path_info = $this->clean_path($this->symfony_request->getPathInfo());
+
+ // Full request URI (e.g. phpBB/app.php/foo/bar)
+ $request_uri = $this->symfony_request->getRequestUri();
+
+ // Script name URI (e.g. phpBB/app.php)
+ $script_name = $this->symfony_request->getScriptName();
+
+ /*
+ * If the path info is empty (single /), then we're not using
+ * a route like app.php/foo/bar
+ */
+ if ($path_info === '/')
+ {
+ return $this->web_root_path = $this->phpbb_root_path;
+ }
+
+ // How many corrections might we need?
+ $corrections = substr_count($path_info, '/');
+
+ /*
+ * If the script name (e.g. phpBB/app.php) exists in the
+ * requestUri (e.g. phpBB/app.php/foo/template), then we
+ * are have a non-rewritten URL.
+ */
+ if (strpos($request_uri, $script_name) === 0)
+ {
+ /*
+ * Append ../ to the end of the phpbb_root_path as many times
+ * as / exists in path_info
+ */
+ return $this->web_root_path = $this->phpbb_root_path . str_repeat('../', $corrections);
+ }
+
+ /*
+ * If we're here it means we're at a re-written path, so we must
+ * correct the relative path for web URLs. We must append ../
+ * to the end of the root path as many times as / exists in path_info
+ * less one time (because the script, e.g. /app.php, doesn't exist in
+ * the URL)
+ */
+ return $this->web_root_path = $this->phpbb_root_path . str_repeat('../', $corrections - 1);
+ }
+
/**
* Eliminates useless . and .. components from specified path.
*
diff --git a/phpBB/phpbb/symfony_request.php b/phpBB/phpbb/symfony_request.php
new file mode 100644
index 0000000000..29ab8c000e
--- /dev/null
+++ b/phpBB/phpbb/symfony_request.php
@@ -0,0 +1,46 @@
+<?php
+/**
+*
+* @package phpBB3
+* @copyright (c) 2013 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+use Symfony\Component\HttpFoundation\Request;
+
+/**
+* @ignore
+*/
+if (!defined('IN_PHPBB'))
+{
+ exit;
+}
+
+class phpbb_symfony_request extends Request
+{
+ /**
+ * Constructor
+ *
+ * @param phpbb_request_interface $phpbb_request
+ */
+ public function __construct(phpbb_request_interface $phpbb_request)
+ {
+ // This function is meant to sanitize the global input arrays
+ $sanitizer = function(&$value, $key) {
+ $type_cast_helper = new phpbb_request_type_cast_helper();
+ $type_cast_helper->set_var($value, $value, gettype($value), true);
+ };
+
+ $get_parameters = $phpbb_request->get_super_global(phpbb_request_interface::GET);
+ $post_parameters = $phpbb_request->get_super_global(phpbb_request_interface::POST);
+ $server_parameters = $phpbb_request->get_super_global(phpbb_request_interface::SERVER);
+ $files_parameters = $phpbb_request->get_super_global(phpbb_request_interface::FILES);
+ $cookie_parameters = $phpbb_request->get_super_global(phpbb_request_interface::COOKIE);
+
+ array_walk_recursive($get_parameters, $sanitizer);
+ array_walk_recursive($post_parameters, $sanitizer);
+
+ parent::__construct($get_parameters, $post_parameters, array(), $cookie_parameters, $files_parameters, $server_parameters);
+ }
+}
diff --git a/phpBB/phpbb/template/asset.php b/phpBB/phpbb/template/asset.php
index 7c322cd971..2b10dd8848 100644
--- a/phpBB/phpbb/template/asset.php
+++ b/phpBB/phpbb/template/asset.php
@@ -19,13 +19,18 @@ class phpbb_template_asset
{
protected $components = array();
+ /** @var phpbb_filesystem **/
+ protected $phpbb_filesystem;
+
/**
* Constructor
*
* @param string $url URL
*/
- public function __construct($url)
+ public function __construct($url, phpbb_filesystem $phpbb_filesystem)
{
+ $this->phpbb_filesystem = $phpbb_filesystem;
+
$this->set_url($url);
}
@@ -112,7 +117,7 @@ class phpbb_template_asset
*/
public function get_url()
{
- return $this->join_url($this->components);
+ return $this->phpbb_filesystem->update_web_root_path($this->join_url($this->components));
}
/**
diff --git a/phpBB/phpbb/template/twig/environment.php b/phpBB/phpbb/template/twig/environment.php
index 9a40dc2b15..612519db69 100644
--- a/phpBB/phpbb/template/twig/environment.php
+++ b/phpBB/phpbb/template/twig/environment.php
@@ -23,9 +23,15 @@ class phpbb_template_twig_environment extends Twig_Environment
/** @var phpbb_config */
protected $phpbb_config;
+ /** @var phpbb_filesystem */
+ protected $phpbb_filesystem;
+
/** @var string */
protected $phpbb_root_path;
+ /** @var string */
+ protected $web_root_path;
+
/** @var array **/
protected $namespace_look_up_order = array('__main__');
@@ -38,11 +44,14 @@ class phpbb_template_twig_environment extends Twig_Environment
* @param Twig_LoaderInterface $loader
* @param array $options Array of options to pass to Twig
*/
- public function __construct($phpbb_config, $phpbb_extensions, $phpbb_root_path, Twig_LoaderInterface $loader = null, $options = array())
+ public function __construct($phpbb_config, $phpbb_extensions, phpbb_filesystem $phpbb_filesystem, Twig_LoaderInterface $loader = null, $options = array())
{
$this->phpbb_config = $phpbb_config;
$this->phpbb_extensions = $phpbb_extensions;
- $this->phpbb_root_path = $phpbb_root_path;
+
+ $this->phpbb_filesystem = $phpbb_filesystem;
+ $this->phpbb_root_path = $this->phpbb_filesystem->get_phpbb_root_path();
+ $this->web_root_path = $this->phpbb_filesystem->get_web_root_path();
return parent::__construct($loader, $options);
}
@@ -80,6 +89,26 @@ class phpbb_template_twig_environment extends Twig_Environment
}
/**
+ * Get the web root path
+ *
+ * @return string
+ */
+ public function get_web_root_path()
+ {
+ return $this->web_root_path;
+ }
+
+ /**
+ * Get the phpbb_filesystem object
+ *
+ * @return phpbb_filesystem
+ */
+ public function get_filesystem()
+ {
+ return $this->phpbb_filesystem;
+ }
+
+ /**
* Get the namespace look up order
*
* @return array
diff --git a/phpBB/phpbb/template/twig/node/includeasset.php b/phpBB/phpbb/template/twig/node/includeasset.php
index 0808e2b10e..8629395898 100644
--- a/phpBB/phpbb/template/twig/node/includeasset.php
+++ b/phpBB/phpbb/template/twig/node/includeasset.php
@@ -33,7 +33,7 @@ abstract class phpbb_template_twig_node_includeasset extends Twig_Node
->write("\$asset_file = ")
->subcompile($this->getNode('expr'))
->raw(";\n")
- ->write("\$asset = new phpbb_template_asset(\$asset_file);\n")
+ ->write("\$asset = new phpbb_template_asset(\$asset_file, \$this->getEnvironment()->get_filesystem());\n")
->write("if (substr(\$asset_file, 0, 2) !== './' && \$asset->is_relative()) {\n")
->indent()
->write("\$asset_path = \$asset->get_path();")
diff --git a/phpBB/phpbb/template/twig/twig.php b/phpBB/phpbb/template/twig/twig.php
index 5746cc64a3..3aa063ffc6 100644
--- a/phpBB/phpbb/template/twig/twig.php
+++ b/phpBB/phpbb/template/twig/twig.php
@@ -31,6 +31,12 @@ class phpbb_template_twig extends phpbb_template_base
private $cachepath = '';
/**
+ * phpBB filesystem
+ * @var phpbb_filesystem
+ */
+ protected $phpbb_filesystem;
+
+ /**
* phpBB root path
* @var string
*/
@@ -71,24 +77,23 @@ class phpbb_template_twig extends phpbb_template_base
/**
* Constructor.
*
- * @param string $phpbb_root_path phpBB root path
- * @param string $php_ext php extension (typically 'php')
+ * @param phpbb_filesystem $phpbb_filesystem
* @param phpbb_config $config
* @param phpbb_user $user
* @param phpbb_template_context $context template context
* @param phpbb_extension_manager $extension_manager extension manager, if null then template events will not be invoked
- * @param string $adm_relative_path relative path to adm directory
*/
- public function __construct($phpbb_root_path, $php_ext, $config, $user, phpbb_template_context $context, phpbb_extension_manager $extension_manager = null, $adm_relative_path = null)
+ public function __construct(phpbb_filesystem $phpbb_filesystem, $config, $user, phpbb_template_context $context, phpbb_extension_manager $extension_manager = null)
{
- $this->phpbb_root_path = $phpbb_root_path;
- $this->php_ext = $php_ext;
+ $this->phpbb_filesystem = $phpbb_filesystem;
+ $this->phpbb_root_path = $phpbb_filesystem->get_phpbb_root_path();
+ $this->php_ext = $phpbb_filesystem->get_php_ext();
$this->config = $config;
$this->user = $user;
$this->context = $context;
$this->extension_manager = $extension_manager;
- $this->cachepath = $phpbb_root_path . 'cache/twig/';
+ $this->cachepath = $this->phpbb_root_path . 'cache/twig/';
// Initiate the loader, __main__ namespace paths will be setup later in set_style_names()
$loader = new phpbb_template_twig_loader('');
@@ -96,7 +101,7 @@ class phpbb_template_twig extends phpbb_template_base
$this->twig = new phpbb_template_twig_environment(
$this->config,
($this->extension_manager) ? $this->extension_manager->all_enabled() : array(),
- $this->phpbb_root_path,
+ $this->phpbb_filesystem,
$loader,
array(
'cache' => (defined('IN_INSTALL')) ? false : $this->cachepath,
@@ -118,9 +123,9 @@ class phpbb_template_twig extends phpbb_template_base
$this->twig->setLexer($lexer);
// Add admin namespace
- if ($adm_relative_path !== null && is_dir($this->phpbb_root_path . $adm_relative_path . 'style/'))
+ if ($this->phpbb_filesystem->get_adm_relative_path() !== null && is_dir($this->phpbb_root_path . $this->phpbb_filesystem->get_adm_relative_path() . 'style/'))
{
- $this->twig->getLoader()->setPaths($this->phpbb_root_path . $adm_relative_path . 'style/', 'admin');
+ $this->twig->getLoader()->setPaths($this->phpbb_root_path . $this->phpbb_filesystem->get_adm_relative_path() . 'style/', 'admin');
}
}
diff --git a/phpBB/styles/prosilver/template/ucp_notifications.html b/phpBB/styles/prosilver/template/ucp_notifications.html
index 6a1d3b8de4..2088de49e8 100644
--- a/phpBB/styles/prosilver/template/ucp_notifications.html
+++ b/phpBB/styles/prosilver/template/ucp_notifications.html
@@ -83,7 +83,7 @@
</div>
</dt>
- <dd class="mark">&nbsp;<!-- IF notification_list.UNREAD --><input type="checkbox" name="mark[]" value="{notification_list.NOTIFICATION_ID}" /> <dfn>{L_MARK_READ}</dfn><!-- ENDIF -->&nbsp;</dd>
+ <dd class="mark">&nbsp;<input type="checkbox" name="mark[]" value="{notification_list.NOTIFICATION_ID}"<!-- IF not notification_list.UNREAD --> disabled="disabled"<!-- ENDIF --> /> <dfn>{L_MARK_READ}</dfn>&nbsp;</dd>
</dl>
</li>
<!-- END notification_list -->
diff --git a/phpBB/styles/subsilver2/template/ucp_notifications.html b/phpBB/styles/subsilver2/template/ucp_notifications.html
index d85584d20e..4a1630786a 100644
--- a/phpBB/styles/subsilver2/template/ucp_notifications.html
+++ b/phpBB/styles/subsilver2/template/ucp_notifications.html
@@ -102,7 +102,7 @@
</span>
</td>
<td align="center">
- <!-- IF notification_list.UNREAD --><input type="checkbox" name="mark[]" value="{notification_list.NOTIFICATION_ID}" /><!-- ENDIF -->
+ <input type="checkbox" name="mark[]" value="{notification_list.NOTIFICATION_ID}"<!-- IF not notification_list.UNREAD --> disabled="disabled"<!-- ENDIF --> />
</td>
</tr>
<!-- END notification_list -->