aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes')
-rw-r--r--phpBB/includes/cache/driver/apc.php2
-rw-r--r--phpBB/includes/cache/driver/eaccelerator.php4
-rw-r--r--phpBB/includes/cache/driver/file.php23
-rw-r--r--phpBB/includes/cache/driver/interface.php47
-rw-r--r--phpBB/includes/cache/driver/memcache.php4
-rw-r--r--phpBB/includes/cache/driver/memory.php7
-rw-r--r--phpBB/includes/cache/driver/null.php1
-rw-r--r--phpBB/includes/cache/driver/redis.php32
-rw-r--r--phpBB/includes/cache/driver/wincache.php2
-rw-r--r--phpBB/includes/cache/driver/xcache.php2
-rw-r--r--phpBB/includes/config/config.php2
-rw-r--r--phpBB/includes/config/db.php2
-rw-r--r--phpBB/includes/controller/exception.php24
-rw-r--r--phpBB/includes/controller/helper.php117
-rw-r--r--phpBB/includes/controller/provider.php82
-rw-r--r--phpBB/includes/controller/resolver.php128
-rw-r--r--phpBB/includes/cron/manager.php2
-rw-r--r--phpBB/includes/cron/task/core/prune_all_forums.php2
-rw-r--r--phpBB/includes/cron/task/core/prune_forum.php4
-rw-r--r--phpBB/includes/cron/task/core/queue.php2
-rw-r--r--phpBB/includes/cron/task/core/tidy_cache.php2
-rw-r--r--phpBB/includes/cron/task/core/tidy_database.php2
-rw-r--r--phpBB/includes/cron/task/core/tidy_search.php2
-rw-r--r--phpBB/includes/cron/task/core/tidy_sessions.php2
-rw-r--r--phpBB/includes/cron/task/core/tidy_warnings.php2
-rw-r--r--phpBB/includes/cron/task/parametrized.php2
-rw-r--r--phpBB/includes/cron/task/task.php2
-rw-r--r--phpBB/includes/db/mssql.php66
-rw-r--r--phpBB/includes/db/mssql_odbc.php40
-rw-r--r--phpBB/includes/db/mssqlnative.php52
-rw-r--r--phpBB/includes/db/mysql.php45
-rw-r--r--phpBB/includes/db/mysqli.php32
-rw-r--r--phpBB/includes/db/oracle.php53
-rw-r--r--phpBB/includes/db/sqlite.php41
-rw-r--r--phpBB/includes/di/extension/ext.php2
-rw-r--r--phpBB/includes/di/pass/kernel_pass.php68
-rw-r--r--phpBB/includes/di/service_collection.php2
-rw-r--r--phpBB/includes/event/kernel_exception_subscriber.php85
-rw-r--r--phpBB/includes/event/kernel_request_subscriber.php83
-rw-r--r--phpBB/includes/event/kernel_terminate_subscriber.php43
-rw-r--r--phpBB/includes/functions.php218
-rw-r--r--phpBB/includes/functions_admin.php2
-rw-r--r--phpBB/includes/functions_container.php16
-rw-r--r--phpBB/includes/functions_download.php2
-rw-r--r--phpBB/includes/functions_install.php2
-rw-r--r--phpBB/includes/functions_messenger.php85
-rw-r--r--phpBB/includes/functions_module.php21
-rw-r--r--phpBB/includes/functions_url_matcher.php106
-rw-r--r--phpBB/includes/group_positions.php10
-rw-r--r--phpBB/includes/lock/db.php2
-rw-r--r--phpBB/includes/lock/flock.php133
-rw-r--r--phpBB/includes/questionnaire/questionnaire.php2
-rw-r--r--phpBB/includes/search/fulltext_mysql.php10
-rw-r--r--phpBB/includes/search/fulltext_postgres.php8
-rw-r--r--phpBB/includes/style/resource_locator.php118
-rw-r--r--phpBB/includes/style/style.php12
-rw-r--r--phpBB/includes/template/compile.php10
-rw-r--r--phpBB/includes/template/locator.php52
-rw-r--r--phpBB/includes/template/template.php75
-rw-r--r--phpBB/includes/ucp/info/ucp_profile.php2
-rw-r--r--phpBB/includes/ucp/ucp_prefs.php33
-rw-r--r--phpBB/includes/ucp/ucp_profile.php5
62 files changed, 1727 insertions, 312 deletions
diff --git a/phpBB/includes/cache/driver/apc.php b/phpBB/includes/cache/driver/apc.php
index dc0144fac3..0516b669c8 100644
--- a/phpBB/includes/cache/driver/apc.php
+++ b/phpBB/includes/cache/driver/apc.php
@@ -26,7 +26,7 @@ class phpbb_cache_driver_apc extends phpbb_cache_driver_memory
/**
* Purge cache data
*
- * @return void
+ * @return null
*/
function purge()
{
diff --git a/phpBB/includes/cache/driver/eaccelerator.php b/phpBB/includes/cache/driver/eaccelerator.php
index 7939f043c9..257b90c76e 100644
--- a/phpBB/includes/cache/driver/eaccelerator.php
+++ b/phpBB/includes/cache/driver/eaccelerator.php
@@ -30,7 +30,7 @@ class phpbb_cache_driver_eaccelerator extends phpbb_cache_driver_memory
/**
* Purge cache data
*
- * @return void
+ * @return null
*/
function purge()
{
@@ -47,7 +47,7 @@ class phpbb_cache_driver_eaccelerator extends phpbb_cache_driver_memory
/**
* Perform cache garbage collection
*
- * @return void
+ * @return null
*/
function tidy()
{
diff --git a/phpBB/includes/cache/driver/file.php b/phpBB/includes/cache/driver/file.php
index b20c0064ea..691abe0438 100644
--- a/phpBB/includes/cache/driver/file.php
+++ b/phpBB/includes/cache/driver/file.php
@@ -214,7 +214,8 @@ class phpbb_cache_driver_file extends phpbb_cache_driver_base
while (($entry = readdir($dir)) !== false)
{
- if (strpos($entry, 'container') !== 0 &&
+ if (strpos($entry, 'container_') !== 0 &&
+ strpos($entry, 'url_matcher') !== 0 &&
strpos($entry, 'sql_') !== 0 &&
strpos($entry, 'data_') !== 0 &&
strpos($entry, 'ctpl_') !== 0 &&
@@ -387,10 +388,10 @@ class phpbb_cache_driver_file extends phpbb_cache_driver_base
if ($this->_write('sql_' . md5($query), $this->sql_rowset[$query_id], $ttl + time(), $query))
{
- $query_result = $query_id;
+ return $query_id;
}
- return $query_id;
+ return $query_result;
}
/**
@@ -652,10 +653,11 @@ class phpbb_cache_driver_file extends phpbb_cache_driver_base
$file = "{$this->cache_dir}$filename.$phpEx";
+ $lock = new phpbb_lock_flock($file);
+ $lock->acquire();
+
if ($handle = @fopen($file, 'wb'))
{
- @flock($handle, LOCK_EX);
-
// File header
fwrite($handle, '<' . '?php exit; ?' . '>');
@@ -696,7 +698,6 @@ class phpbb_cache_driver_file extends phpbb_cache_driver_base
fwrite($handle, $data);
}
- @flock($handle, LOCK_UN);
fclose($handle);
if (!function_exists('phpbb_chmod'))
@@ -707,10 +708,16 @@ class phpbb_cache_driver_file extends phpbb_cache_driver_base
phpbb_chmod($file, CHMOD_READ | CHMOD_WRITE);
- return true;
+ $return_value = true;
+ }
+ else
+ {
+ $return_value = false;
}
- return false;
+ $lock->release();
+
+ return $return_value;
}
/**
diff --git a/phpBB/includes/cache/driver/interface.php b/phpBB/includes/cache/driver/interface.php
index 847ba97262..d403bbcd71 100644
--- a/phpBB/includes/cache/driver/interface.php
+++ b/phpBB/includes/cache/driver/interface.php
@@ -63,42 +63,81 @@ interface phpbb_cache_driver_interface
public function destroy($var_name, $table = '');
/**
- * Check if a given cache entry exist
+ * Check if a given cache entry exists
*/
public function _exists($var_name);
/**
- * Load cached sql query
+ * Load result of an SQL query from cache.
+ *
+ * @param string $query SQL query
+ *
+ * @return int|bool Query ID (integer) if cache contains a rowset
+ * for the specified query.
+ * False otherwise.
*/
public function sql_load($query);
/**
- * Save sql query
+ * Save result of an SQL query in cache.
+ *
+ * In persistent cache stores, this function stores the query
+ * result to persistent storage. In other words, there is no need
+ * to call save() afterwards.
+ *
+ * @param string $query SQL query, should be used for generating storage key
+ * @param mixed $query_result The result from dbal::sql_query, to be passed to
+ * dbal::sql_fetchrow to get all rows and store them
+ * in cache.
+ * @param int $ttl Time to live, after this timeout the query should
+ * expire from the cache.
+ * @return int|mixed If storing in cache succeeded, an integer $query_id
+ * representing the query should be returned. Otherwise
+ * the original $query_result should be returned.
*/
public function sql_save($query, $query_result, $ttl);
/**
- * Ceck if a given sql query exist in cache
+ * Check if result for a given SQL query exists in cache.
+ *
+ * @param int $query_id
+ * @return bool
*/
public function sql_exists($query_id);
/**
* Fetch row from cache (database)
+ *
+ * @param int $query_id
+ * @return array|bool The query result if found in the cache, otherwise
+ * false.
*/
public function sql_fetchrow($query_id);
/**
* Fetch a field from the current row of a cached database result (database)
+ *
+ * @param int $query_id
+ * @param $field The name of the column.
+ * @return string|bool The field of the query result if found in the cache,
+ * otherwise false.
*/
public function sql_fetchfield($query_id, $field);
/**
* Seek a specific row in an a cached database result (database)
+ *
+ * @param int $rownum Row to seek to.
+ * @param int $query_id
+ * @return bool
*/
public function sql_rowseek($rownum, $query_id);
/**
* Free memory used for a cached database result (database)
+ *
+ * @param int $query_id
+ * @return bool
*/
public function sql_freeresult($query_id);
}
diff --git a/phpBB/includes/cache/driver/memcache.php b/phpBB/includes/cache/driver/memcache.php
index 9fe70f8b44..3fd16b23b0 100644
--- a/phpBB/includes/cache/driver/memcache.php
+++ b/phpBB/includes/cache/driver/memcache.php
@@ -64,7 +64,7 @@ class phpbb_cache_driver_memcache extends phpbb_cache_driver_memory
/**
* Unload the cache resources
*
- * @return void
+ * @return null
*/
function unload()
{
@@ -76,7 +76,7 @@ class phpbb_cache_driver_memcache extends phpbb_cache_driver_memory
/**
* Purge cache data
*
- * @return void
+ * @return null
*/
function purge()
{
diff --git a/phpBB/includes/cache/driver/memory.php b/phpBB/includes/cache/driver/memory.php
index 98ac02b161..c39f9f7850 100644
--- a/phpBB/includes/cache/driver/memory.php
+++ b/phpBB/includes/cache/driver/memory.php
@@ -162,7 +162,8 @@ abstract class phpbb_cache_driver_memory extends phpbb_cache_driver_base
while (($entry = readdir($dir)) !== false)
{
- if (strpos($entry, 'container') !== 0 &&
+ if (strpos($entry, 'container_') !== 0 &&
+ strpos($entry, 'url_matcher') !== 0 &&
strpos($entry, 'sql_') !== 0 &&
strpos($entry, 'data_') !== 0 &&
strpos($entry, 'ctpl_') !== 0 &&
@@ -298,7 +299,7 @@ abstract class phpbb_cache_driver_memory extends phpbb_cache_driver_base
if (!preg_match('/FROM \\(?(`?\\w+`?(?: \\w+)?(?:, ?`?\\w+`?(?: \\w+)?)*)\\)?/', $query, $regs))
{
// Bail out if the match fails.
- return;
+ return $query_result;
}
$tables = array_map('trim', explode(',', $regs[1]));
@@ -338,8 +339,6 @@ abstract class phpbb_cache_driver_memory extends phpbb_cache_driver_base
$this->_write('sql_' . $hash, $this->sql_rowset[$query_id], $ttl);
- $query_result = $query_id;
-
return $query_id;
}
diff --git a/phpBB/includes/cache/driver/null.php b/phpBB/includes/cache/driver/null.php
index df2c6c026f..687604d14f 100644
--- a/phpBB/includes/cache/driver/null.php
+++ b/phpBB/includes/cache/driver/null.php
@@ -109,6 +109,7 @@ class phpbb_cache_driver_null extends phpbb_cache_driver_base
*/
function sql_save($query, $query_result, $ttl)
{
+ return $query_result;
}
/**
diff --git a/phpBB/includes/cache/driver/redis.php b/phpBB/includes/cache/driver/redis.php
index a768885962..960735b673 100644
--- a/phpBB/includes/cache/driver/redis.php
+++ b/phpBB/includes/cache/driver/redis.php
@@ -39,13 +39,39 @@ class phpbb_cache_driver_redis extends phpbb_cache_driver_memory
var $redis;
+ /**
+ * Creates a redis cache driver.
+ *
+ * The following global constants affect operation:
+ *
+ * PHPBB_ACM_REDIS_HOST
+ * PHPBB_ACM_REDIS_PORT
+ * PHPBB_ACM_REDIS_PASSWORD
+ * PHPBB_ACM_REDIS_DB
+ *
+ * There are no publicly documented constructor parameters.
+ */
function __construct()
{
// Call the parent constructor
parent::__construct();
$this->redis = new Redis();
- $this->redis->connect(PHPBB_ACM_REDIS_HOST, PHPBB_ACM_REDIS_PORT);
+
+ $args = func_get_args();
+ if (!empty($args))
+ {
+ $ok = call_user_func_array(array($this->redis, 'connect'), $args);
+ }
+ else
+ {
+ $ok = $this->redis->connect(PHPBB_ACM_REDIS_HOST, PHPBB_ACM_REDIS_PORT);
+ }
+
+ if (!$ok)
+ {
+ trigger_error('Could not connect to redis server');
+ }
if (defined('PHPBB_ACM_REDIS_PASSWORD'))
{
@@ -74,7 +100,7 @@ class phpbb_cache_driver_redis extends phpbb_cache_driver_memory
/**
* Unload the cache resources
*
- * @return void
+ * @return null
*/
function unload()
{
@@ -86,7 +112,7 @@ class phpbb_cache_driver_redis extends phpbb_cache_driver_memory
/**
* Purge cache data
*
- * @return void
+ * @return null
*/
function purge()
{
diff --git a/phpBB/includes/cache/driver/wincache.php b/phpBB/includes/cache/driver/wincache.php
index fa9eb95f88..58f3b4a581 100644
--- a/phpBB/includes/cache/driver/wincache.php
+++ b/phpBB/includes/cache/driver/wincache.php
@@ -26,7 +26,7 @@ class phpbb_cache_driver_wincache extends phpbb_cache_driver_memory
/**
* Purge cache data
*
- * @return void
+ * @return null
*/
function purge()
{
diff --git a/phpBB/includes/cache/driver/xcache.php b/phpBB/includes/cache/driver/xcache.php
index 0b768bdb3e..06c5fafd97 100644
--- a/phpBB/includes/cache/driver/xcache.php
+++ b/phpBB/includes/cache/driver/xcache.php
@@ -41,7 +41,7 @@ class phpbb_cache_driver_xcache extends phpbb_cache_driver_memory
/**
* Purge cache data
*
- * @return void
+ * @return null
*/
function purge()
{
diff --git a/phpBB/includes/config/config.php b/phpBB/includes/config/config.php
index 12a4a418b2..4b533dd55c 100644
--- a/phpBB/includes/config/config.php
+++ b/phpBB/includes/config/config.php
@@ -109,7 +109,7 @@ class phpbb_config implements ArrayAccess, IteratorAggregate, Countable
* @param String $key The configuration option's name
* @param bool $use_cache Whether this variable should be cached or if it
* changes too frequently to be efficiently cached
- * @return void
+ * @return null
*/
public function delete($key, $use_cache = true)
{
diff --git a/phpBB/includes/config/db.php b/phpBB/includes/config/db.php
index 993a764a7f..45f9f1cb21 100644
--- a/phpBB/includes/config/db.php
+++ b/phpBB/includes/config/db.php
@@ -96,7 +96,7 @@ class phpbb_config_db extends phpbb_config
* @param String $key The configuration option's name
* @param bool $use_cache Whether this variable should be cached or if it
* changes too frequently to be efficiently cached
- * @return void
+ * @return null
*/
public function delete($key, $use_cache = true)
{
diff --git a/phpBB/includes/controller/exception.php b/phpBB/includes/controller/exception.php
new file mode 100644
index 0000000000..faa8b6b584
--- /dev/null
+++ b/phpBB/includes/controller/exception.php
@@ -0,0 +1,24 @@
+<?php
+/**
+*
+* @package controller
+* @copyright (c) 2012 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+/**
+* @ignore
+*/
+if (!defined('IN_PHPBB'))
+{
+ exit;
+}
+
+/**
+* Controller exception class
+* @package phpBB3
+*/
+class phpbb_controller_exception extends RuntimeException
+{
+}
diff --git a/phpBB/includes/controller/helper.php b/phpBB/includes/controller/helper.php
new file mode 100644
index 0000000000..6cacc8fefa
--- /dev/null
+++ b/phpBB/includes/controller/helper.php
@@ -0,0 +1,117 @@
+<?php
+/**
+*
+* @package controller
+* @copyright (c) 2012 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+/**
+* @ignore
+*/
+if (!defined('IN_PHPBB'))
+{
+ exit;
+}
+
+use Symfony\Component\HttpFoundation\Response;
+
+/**
+* Controller helper class, contains methods that do things for controllers
+* @package phpBB3
+*/
+class phpbb_controller_helper
+{
+ /**
+ * Template object
+ * @var phpbb_template
+ */
+ protected $template;
+
+ /**
+ * User object
+ * @var phpbb_user
+ */
+ protected $user;
+
+ /**
+ * phpBB root path
+ * @var string
+ */
+ protected $phpbb_root_path;
+
+ /**
+ * PHP extension
+ * @var string
+ */
+ protected $php_ext;
+
+ /**
+ * Constructor
+ *
+ * @param phpbb_template $template Template object
+ * @param phpbb_user $user User object
+ * @param string $phpbb_root_path phpBB root path
+ * @param string $php_ext PHP extension
+ */
+ public function __construct(phpbb_template $template, phpbb_user $user, $phpbb_root_path, $php_ext)
+ {
+ $this->template = $template;
+ $this->user = $user;
+ $this->phpbb_root_path = $phpbb_root_path;
+ $this->php_ext = $php_ext;
+ }
+
+ /**
+ * Automate setting up the page and creating the response object.
+ *
+ * @param string $handle The template handle to render
+ * @param string $page_title The title of the page to output
+ * @param int $status_code The status code to be sent to the page header
+ * @return Response object containing rendered page
+ */
+ public function render($template_file, $page_title = '', $status_code = 200)
+ {
+ page_header($page_title);
+
+ $this->template->set_filenames(array(
+ 'body' => $template_file,
+ ));
+
+ page_footer(true, false, false);
+
+ return new Response($this->template->assign_display('body'), $status_code);
+ }
+
+ /**
+ * Easily generate a URL
+ *
+ * @param array $url_parts Each array element is a 'folder'
+ * i.e. array('my', 'ext') maps to ./app.php/my/ext
+ * @param mixed $query The Query string, passed directly into the second
+ * argument of append_sid()
+ * @return string A URL that has already been run through append_sid()
+ */
+ public function url(array $url_parts, $query = '')
+ {
+ return append_sid($this->phpbb_root_path . implode('/', $url_parts), $query);
+ }
+
+ /**
+ * Output an error, effectively the same thing as trigger_error
+ *
+ * @param string $message The error message
+ * @param string $code The error code (e.g. 404, 500, 503, etc.)
+ * @return Response A Reponse instance
+ */
+ public function error($message, $code = 500)
+ {
+ $this->template->assign_vars(array(
+ 'MESSAGE_TEXT' => $message,
+ 'MESSAGE_TITLE' => $this->user->lang('INFORMATION'),
+ ));
+
+ return $this->render('message_body.html', $this->user->lang('INFORMATION'), $code);
+ }
+}
diff --git a/phpBB/includes/controller/provider.php b/phpBB/includes/controller/provider.php
new file mode 100644
index 0000000000..b2a5b9f6b2
--- /dev/null
+++ b/phpBB/includes/controller/provider.php
@@ -0,0 +1,82 @@
+<?php
+/**
+*
+* @package controller
+* @copyright (c) 2012 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+/**
+* @ignore
+*/
+if (!defined('IN_PHPBB'))
+{
+ exit;
+}
+
+use Symfony\Component\Routing\RouteCollection;
+use Symfony\Component\Routing\Loader\YamlFileLoader;
+use Symfony\Component\Config\FileLocator;
+
+/**
+* Controller interface
+* @package phpBB3
+*/
+class phpbb_controller_provider
+{
+ /**
+ * YAML file(s) containing route information
+ * @var array
+ */
+ protected $routing_paths;
+
+ /**
+ * Construct method
+ *
+ * @param array() $routing_paths Array of strings containing paths
+ * to YAML files holding route information
+ */
+ public function __construct($routing_paths = array())
+ {
+ $this->routing_paths = $routing_paths;
+ }
+
+ /**
+ * Locate paths containing routing files
+ * This sets an internal property but does not return the paths.
+ *
+ * @return The current instance of this object for method chaining
+ */
+ public function import_paths_from_finder(phpbb_extension_finder $finder)
+ {
+ // We hardcode the path to the core config directory
+ // because the finder cannot find it
+ $this->routing_paths = array_merge(array('config'), array_map('dirname', array_keys($finder
+ ->directory('config')
+ ->prefix('routing')
+ ->suffix('yml')
+ ->find()
+ )));
+
+ return $this;
+ }
+
+ /**
+ * Get a list of controllers and return it
+ *
+ * @param string $base_path Base path to prepend to file paths
+ * @return array Array of controllers and their route information
+ */
+ public function find($base_path = '')
+ {
+ $routes = new RouteCollection;
+ foreach ($this->routing_paths as $path)
+ {
+ $loader = new YamlFileLoader(new FileLocator($base_path . $path));
+ $routes->addCollection($loader->load('routing.yml'));
+ }
+
+ return $routes;
+ }
+}
diff --git a/phpBB/includes/controller/resolver.php b/phpBB/includes/controller/resolver.php
new file mode 100644
index 0000000000..ee469aa9c8
--- /dev/null
+++ b/phpBB/includes/controller/resolver.php
@@ -0,0 +1,128 @@
+<?php
+/**
+*
+* @package controller
+* @copyright (c) 2012 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+/**
+* @ignore
+*/
+if (!defined('IN_PHPBB'))
+{
+ exit;
+}
+
+use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface;
+use Symfony\Component\DependencyInjection\ContainerInterface;
+use Symfony\Component\HttpFoundation\Request;
+
+/**
+* Controller manager class
+* @package phpBB3
+*/
+class phpbb_controller_resolver implements ControllerResolverInterface
+{
+ /**
+ * User object
+ * @var phpbb_user
+ */
+ protected $user;
+
+ /**
+ * ContainerInterface object
+ * @var ContainerInterface
+ */
+ protected $container;
+
+ /**
+ * Construct method
+ *
+ * @param phpbb_user $user User Object
+ * @param ContainerInterface $container ContainerInterface object
+ */
+ public function __construct(phpbb_user $user, ContainerInterface $container)
+ {
+ $this->user = $user;
+ $this->container = $container;
+ }
+
+ /**
+ * Load a controller callable
+ *
+ * @param Symfony\Component\HttpFoundation\Request $request Symfony Request object
+ * @return bool|Callable Callable or false
+ * @throws phpbb_controller_exception
+ */
+ public function getController(Request $request)
+ {
+ $controller = $request->attributes->get('_controller');
+
+ if (!$controller)
+ {
+ throw new phpbb_controller_exception($this->user->lang['CONTROLLER_NOT_SPECIFIED']);
+ }
+
+ // Require a method name along with the service name
+ if (stripos($controller, ':') === false)
+ {
+ throw new phpbb_controller_exception($this->user->lang['CONTROLLER_METHOD_NOT_SPECIFIED']);
+ }
+
+ list($service, $method) = explode(':', $controller);
+
+ if (!$this->container->has($service))
+ {
+ throw new phpbb_controller_exception($this->user->lang('CONTROLLER_SERVICE_UNDEFINED', $service));
+ }
+
+ $controller_object = $this->container->get($service);
+
+ return array($controller_object, $method);
+ }
+
+ /**
+ * Dependencies should be specified in the service definition and can be
+ * then accessed in __construct(). Arguments are sent through the URL path
+ * and should match the parameters of the method you are using as your
+ * controller.
+ *
+ * @param Symfony\Component\HttpFoundation\Request $request Symfony Request object
+ * @param mixed $controller A callable (controller class, method)
+ * @return bool False
+ * @throws phpbb_controller_exception
+ */
+ public function getArguments(Request $request, $controller)
+ {
+ // At this point, $controller contains the object and method name
+ list($object, $method) = $controller;
+ $mirror = new ReflectionMethod($object, $method);
+
+ $arguments = array();
+ $parameters = $mirror->getParameters();
+ $attributes = $request->attributes->all();
+ foreach ($parameters as $param)
+ {
+ if (array_key_exists($param->name, $attributes))
+ {
+ $arguments[] = $attributes[$param->name];
+ }
+ else if ($param->getClass() && $param->getClass()->isInstance($request))
+ {
+ $arguments[] = $request;
+ }
+ else if ($param->isDefaultValueAvailable())
+ {
+ $arguments[] = $param->getDefaultValue();
+ }
+ else
+ {
+ throw new phpbb_controller_exception($this->user->lang('CONTROLLER_ARGUMENT_VALUE_MISSING', $param->getPosition() + 1, get_class($object) . ':' . $method, $param->name));
+ }
+ }
+
+ return $arguments;
+ }
+}
diff --git a/phpBB/includes/cron/manager.php b/phpBB/includes/cron/manager.php
index ccaa4f3764..84c9650830 100644
--- a/phpBB/includes/cron/manager.php
+++ b/phpBB/includes/cron/manager.php
@@ -54,7 +54,7 @@ class phpbb_cron_manager
*
* @param array|Traversable $tasks Array of instances of phpbb_cron_task
*
- * @return void
+ * @return null
*/
public function load_tasks($tasks)
{
diff --git a/phpBB/includes/cron/task/core/prune_all_forums.php b/phpBB/includes/cron/task/core/prune_all_forums.php
index 252e16e57d..ee0b5f7626 100644
--- a/phpBB/includes/cron/task/core/prune_all_forums.php
+++ b/phpBB/includes/cron/task/core/prune_all_forums.php
@@ -50,7 +50,7 @@ class phpbb_cron_task_core_prune_all_forums extends phpbb_cron_task_base
/**
* Runs this cron task.
*
- * @return void
+ * @return null
*/
public function run()
{
diff --git a/phpBB/includes/cron/task/core/prune_forum.php b/phpBB/includes/cron/task/core/prune_forum.php
index 41d60af921..fa7a761d88 100644
--- a/phpBB/includes/cron/task/core/prune_forum.php
+++ b/phpBB/includes/cron/task/core/prune_forum.php
@@ -70,7 +70,7 @@ class phpbb_cron_task_core_prune_forum extends phpbb_cron_task_base implements p
/**
* Runs this cron task.
*
- * @return void
+ * @return null
*/
public function run()
{
@@ -138,7 +138,7 @@ class phpbb_cron_task_core_prune_forum extends phpbb_cron_task_base implements p
*
* @param phpbb_request_interface $request Request object.
*
- * @return void
+ * @return null
*/
public function parse_parameters(phpbb_request_interface $request)
{
diff --git a/phpBB/includes/cron/task/core/queue.php b/phpBB/includes/cron/task/core/queue.php
index c765660906..732f9c6bea 100644
--- a/phpBB/includes/cron/task/core/queue.php
+++ b/phpBB/includes/cron/task/core/queue.php
@@ -43,7 +43,7 @@ class phpbb_cron_task_core_queue extends phpbb_cron_task_base
/**
* Runs this cron task.
*
- * @return void
+ * @return null
*/
public function run()
{
diff --git a/phpBB/includes/cron/task/core/tidy_cache.php b/phpBB/includes/cron/task/core/tidy_cache.php
index 6017eea561..16a45dae7c 100644
--- a/phpBB/includes/cron/task/core/tidy_cache.php
+++ b/phpBB/includes/cron/task/core/tidy_cache.php
@@ -40,7 +40,7 @@ class phpbb_cron_task_core_tidy_cache extends phpbb_cron_task_base
/**
* Runs this cron task.
*
- * @return void
+ * @return null
*/
public function run()
{
diff --git a/phpBB/includes/cron/task/core/tidy_database.php b/phpBB/includes/cron/task/core/tidy_database.php
index 1d256f964f..b882e7b500 100644
--- a/phpBB/includes/cron/task/core/tidy_database.php
+++ b/phpBB/includes/cron/task/core/tidy_database.php
@@ -43,7 +43,7 @@ class phpbb_cron_task_core_tidy_database extends phpbb_cron_task_base
/**
* Runs this cron task.
*
- * @return void
+ * @return null
*/
public function run()
{
diff --git a/phpBB/includes/cron/task/core/tidy_search.php b/phpBB/includes/cron/task/core/tidy_search.php
index 2e5f3d79d5..fdbe31346e 100644
--- a/phpBB/includes/cron/task/core/tidy_search.php
+++ b/phpBB/includes/cron/task/core/tidy_search.php
@@ -54,7 +54,7 @@ class phpbb_cron_task_core_tidy_search extends phpbb_cron_task_base
/**
* Runs this cron task.
*
- * @return void
+ * @return null
*/
public function run()
{
diff --git a/phpBB/includes/cron/task/core/tidy_sessions.php b/phpBB/includes/cron/task/core/tidy_sessions.php
index 13531aa30b..95f55235c9 100644
--- a/phpBB/includes/cron/task/core/tidy_sessions.php
+++ b/phpBB/includes/cron/task/core/tidy_sessions.php
@@ -40,7 +40,7 @@ class phpbb_cron_task_core_tidy_sessions extends phpbb_cron_task_base
/**
* Runs this cron task.
*
- * @return void
+ * @return null
*/
public function run()
{
diff --git a/phpBB/includes/cron/task/core/tidy_warnings.php b/phpBB/includes/cron/task/core/tidy_warnings.php
index 8dd0674fe5..2a7798e56e 100644
--- a/phpBB/includes/cron/task/core/tidy_warnings.php
+++ b/phpBB/includes/cron/task/core/tidy_warnings.php
@@ -45,7 +45,7 @@ class phpbb_cron_task_core_tidy_warnings extends phpbb_cron_task_base
/**
* Runs this cron task.
*
- * @return void
+ * @return null
*/
public function run()
{
diff --git a/phpBB/includes/cron/task/parametrized.php b/phpBB/includes/cron/task/parametrized.php
index 0714b2e701..5f0e46eafc 100644
--- a/phpBB/includes/cron/task/parametrized.php
+++ b/phpBB/includes/cron/task/parametrized.php
@@ -46,7 +46,7 @@ interface phpbb_cron_task_parametrized extends phpbb_cron_task
*
* @param phpbb_request_interface $request Request object.
*
- * @return void
+ * @return null
*/
public function parse_parameters(phpbb_request_interface $request);
}
diff --git a/phpBB/includes/cron/task/task.php b/phpBB/includes/cron/task/task.php
index 7b08fed413..2d585df96d 100644
--- a/phpBB/includes/cron/task/task.php
+++ b/phpBB/includes/cron/task/task.php
@@ -31,7 +31,7 @@ interface phpbb_cron_task
/**
* Runs this cron task.
*
- * @return void
+ * @return null
*/
public function run();
diff --git a/phpBB/includes/db/mssql.php b/phpBB/includes/db/mssql.php
index 1ec8517308..235c48d3f0 100644
--- a/phpBB/includes/db/mssql.php
+++ b/phpBB/includes/db/mssql.php
@@ -24,11 +24,19 @@ include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx);
*/
class dbal_mssql extends dbal
{
+ var $connect_error = '';
+
/**
* Connect to server
*/
function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false)
{
+ if (!function_exists('mssql_connect'))
+ {
+ $this->connect_error = 'mssql_connect function does not exist, is mssql extension installed?';
+ return $this->sql_error('');
+ }
+
$this->persistency = $persistency;
$this->user = $sqluser;
$this->dbname = $database;
@@ -355,34 +363,44 @@ class dbal_mssql extends dbal
*/
function _sql_error()
{
- $error = array(
- 'message' => @mssql_get_last_message(),
- 'code' => ''
- );
-
- // Get error code number
- $result_id = @mssql_query('SELECT @@ERROR as code', $this->db_connect_id);
- if ($result_id)
+ if (function_exists('mssql_get_last_message'))
{
- $row = @mssql_fetch_assoc($result_id);
- $error['code'] = $row['code'];
- @mssql_free_result($result_id);
- }
+ $error = array(
+ 'message' => @mssql_get_last_message(),
+ 'code' => '',
+ );
- // Get full error message if possible
- $sql = 'SELECT CAST(description as varchar(255)) as message
- FROM master.dbo.sysmessages
- WHERE error = ' . $error['code'];
- $result_id = @mssql_query($sql);
-
- if ($result_id)
- {
- $row = @mssql_fetch_assoc($result_id);
- if (!empty($row['message']))
+ // Get error code number
+ $result_id = @mssql_query('SELECT @@ERROR as code', $this->db_connect_id);
+ if ($result_id)
+ {
+ $row = @mssql_fetch_assoc($result_id);
+ $error['code'] = $row['code'];
+ @mssql_free_result($result_id);
+ }
+
+ // Get full error message if possible
+ $sql = 'SELECT CAST(description as varchar(255)) as message
+ FROM master.dbo.sysmessages
+ WHERE error = ' . $error['code'];
+ $result_id = @mssql_query($sql);
+
+ if ($result_id)
{
- $error['message'] .= '<br />' . $row['message'];
+ $row = @mssql_fetch_assoc($result_id);
+ if (!empty($row['message']))
+ {
+ $error['message'] .= '<br />' . $row['message'];
+ }
+ @mssql_free_result($result_id);
}
- @mssql_free_result($result_id);
+ }
+ else
+ {
+ $error = array(
+ 'message' => $this->connect_error,
+ 'code' => '',
+ );
}
return $error;
diff --git a/phpBB/includes/db/mssql_odbc.php b/phpBB/includes/db/mssql_odbc.php
index 7c1ffbc808..2194de4a5e 100644
--- a/phpBB/includes/db/mssql_odbc.php
+++ b/phpBB/includes/db/mssql_odbc.php
@@ -31,6 +31,7 @@ include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx);
class dbal_mssql_odbc extends dbal
{
var $last_query_text = '';
+ var $connect_error = '';
/**
* Connect to server
@@ -67,7 +68,24 @@ class dbal_mssql_odbc extends dbal
@ini_set('odbc.defaultlrl', $max_size);
}
- $this->db_connect_id = ($this->persistency) ? @odbc_pconnect($this->server, $this->user, $sqlpassword) : @odbc_connect($this->server, $this->user, $sqlpassword);
+ if ($this->persistency)
+ {
+ if (!function_exists('odbc_pconnect'))
+ {
+ $this->connect_error = 'odbc_pconnect function does not exist, is odbc extension installed?';
+ return $this->sql_error('');
+ }
+ $this->db_connect_id = @odbc_pconnect($this->server, $this->user, $sqlpassword);
+ }
+ else
+ {
+ if (!function_exists('odbc_connect'))
+ {
+ $this->connect_error = 'odbc_connect function does not exist, is odbc extension installed?';
+ return $this->sql_error('');
+ }
+ $this->db_connect_id = @odbc_connect($this->server, $this->user, $sqlpassword);
+ }
return ($this->db_connect_id) ? $this->db_connect_id : $this->sql_error('');
}
@@ -349,10 +367,22 @@ class dbal_mssql_odbc extends dbal
*/
function _sql_error()
{
- return array(
- 'message' => @odbc_errormsg(),
- 'code' => @odbc_error()
- );
+ if (function_exists('odbc_errormsg'))
+ {
+ $error = array(
+ 'message' => @odbc_errormsg(),
+ 'code' => @odbc_error(),
+ );
+ }
+ else
+ {
+ $error = array(
+ 'message' => $this->connect_error,
+ 'code' => '',
+ );
+ }
+
+ return $error;
}
/**
diff --git a/phpBB/includes/db/mssqlnative.php b/phpBB/includes/db/mssqlnative.php
index e9191fae8a..4a969828e7 100644
--- a/phpBB/includes/db/mssqlnative.php
+++ b/phpBB/includes/db/mssqlnative.php
@@ -198,16 +198,18 @@ class dbal_mssqlnative extends dbal
var $m_insert_id = NULL;
var $last_query_text = '';
var $query_options = array();
+ var $connect_error = '';
/**
* Connect to server
*/
function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false)
{
- # Test for driver support, to avoid suppressed fatal error
+ // Test for driver support, to avoid suppressed fatal error
if (!function_exists('sqlsrv_connect'))
{
- trigger_error('Native MS SQL Server driver for PHP is missing or needs to be updated. Version 1.1 or later is required to install phpBB3. You can download the driver from: http://www.microsoft.com/sqlserver/2005/en/us/PHP-Driver.aspx\n', E_USER_ERROR);
+ $this->connect_error = 'Native MS SQL Server driver for PHP is missing or needs to be updated. Version 1.1 or later is required to install phpBB3. You can download the driver from: http://www.microsoft.com/sqlserver/2005/en/us/PHP-Driver.aspx';
+ return $this->sql_error('');
}
//set up connection variables
@@ -521,31 +523,43 @@ class dbal_mssqlnative extends dbal
*/
function _sql_error()
{
- $errors = @sqlsrv_errors(SQLSRV_ERR_ERRORS);
- $error_message = '';
- $code = 0;
-
- if ($errors != null)
+ if (function_exists('sqlsrv_errors'))
{
- foreach ($errors as $error)
+ $errors = @sqlsrv_errors(SQLSRV_ERR_ERRORS);
+ $error_message = '';
+ $code = 0;
+
+ if ($errors != null)
+ {
+ foreach ($errors as $error)
+ {
+ $error_message .= "SQLSTATE: " . $error[ 'SQLSTATE'] . "\n";
+ $error_message .= "code: " . $error[ 'code'] . "\n";
+ $code = $error['code'];
+ $error_message .= "message: " . $error[ 'message'] . "\n";
+ }
+ $this->last_error_result = $error_message;
+ $error = $this->last_error_result;
+ }
+ else
{
- $error_message .= "SQLSTATE: ".$error[ 'SQLSTATE']."\n";
- $error_message .= "code: ".$error[ 'code']."\n";
- $code = $error['code'];
- $error_message .= "message: ".$error[ 'message']."\n";
+ $error = (isset($this->last_error_result) && $this->last_error_result) ? $this->last_error_result : array();
}
- $this->last_error_result = $error_message;
- $error = $this->last_error_result;
+
+ $error = array(
+ 'message' => $error,
+ 'code' => $code,
+ );
}
else
{
- $error = (isset($this->last_error_result) && $this->last_error_result) ? $this->last_error_result : array();
+ $error = array(
+ 'message' => $this->connect_error,
+ 'code' => '',
+ );
}
- return array(
- 'message' => $error,
- 'code' => $code,
- );
+ return $error;
}
/**
diff --git a/phpBB/includes/db/mysql.php b/phpBB/includes/db/mysql.php
index f685ab055c..dcdeec0401 100644
--- a/phpBB/includes/db/mysql.php
+++ b/phpBB/includes/db/mysql.php
@@ -29,6 +29,7 @@ include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx);
class dbal_mysql extends dbal
{
var $multi_insert = true;
+ var $connect_error = '';
/**
* Connect to server
@@ -43,7 +44,24 @@ class dbal_mysql extends dbal
$this->sql_layer = 'mysql4';
- $this->db_connect_id = ($this->persistency) ? @mysql_pconnect($this->server, $this->user, $sqlpassword) : @mysql_connect($this->server, $this->user, $sqlpassword, $new_link);
+ if ($this->persistency)
+ {
+ if (!function_exists('mysql_pconnect'))
+ {
+ $this->connect_error = 'mysql_pconnect function does not exist, is mysql extension installed?';
+ return $this->sql_error('');
+ }
+ $this->db_connect_id = @mysql_pconnect($this->server, $this->user, $sqlpassword);
+ }
+ else
+ {
+ if (!function_exists('mysql_connect'))
+ {
+ $this->connect_error = 'mysql_connect function does not exist, is mysql extension installed?';
+ return $this->sql_error('');
+ }
+ $this->db_connect_id = @mysql_connect($this->server, $this->user, $sqlpassword, $new_link);
+ }
if ($this->db_connect_id && $this->dbname != '')
{
@@ -426,18 +444,29 @@ class dbal_mysql extends dbal
*/
function _sql_error()
{
- if (!$this->db_connect_id)
+ if ($this->db_connect_id)
+ {
+ $error = array(
+ 'message' => @mysql_error($this->db_connect_id),
+ 'code' => @mysql_errno($this->db_connect_id),
+ );
+ }
+ else if (function_exists('mysql_error'))
{
- return array(
+ $error = array(
'message' => @mysql_error(),
- 'code' => @mysql_errno()
+ 'code' => @mysql_errno(),
+ );
+ }
+ else
+ {
+ $error = array(
+ 'message' => $this->connect_error,
+ 'code' => '',
);
}
- return array(
- 'message' => @mysql_error($this->db_connect_id),
- 'code' => @mysql_errno($this->db_connect_id)
- );
+ return $error;
}
/**
diff --git a/phpBB/includes/db/mysqli.php b/phpBB/includes/db/mysqli.php
index 6d81b8bc3e..5713b1992c 100644
--- a/phpBB/includes/db/mysqli.php
+++ b/phpBB/includes/db/mysqli.php
@@ -26,12 +26,19 @@ include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx);
class dbal_mysqli extends dbal
{
var $multi_insert = true;
+ var $connect_error = '';
/**
* Connect to server
*/
function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false , $new_link = false)
{
+ if (!function_exists('mysqli_connect'))
+ {
+ $this->connect_error = 'mysqli_connect function does not exist, is mysqli extension installed?';
+ return $this->sql_error('');
+ }
+
// Mysqli extension supports persistent connection since PHP 5.3.0
$this->persistency = (version_compare(PHP_VERSION, '5.3.0', '>=')) ? $persistency : false;
$this->user = $sqluser;
@@ -423,18 +430,29 @@ class dbal_mysqli extends dbal
*/
function _sql_error()
{
- if (!$this->db_connect_id)
+ if ($this->db_connect_id)
+ {
+ $error = array(
+ 'message' => @mysqli_error($this->db_connect_id),
+ 'code' => @mysqli_errno($this->db_connect_id)
+ );
+ }
+ else if (function_exists('mysqli_connect_error'))
{
- return array(
+ $error = array(
'message' => @mysqli_connect_error(),
- 'code' => @mysqli_connect_errno()
+ 'code' => @mysqli_connect_errno(),
+ );
+ }
+ else
+ {
+ $error = array(
+ 'message' => $this->connect_error,
+ 'code' => '',
);
}
- return array(
- 'message' => @mysqli_error($this->db_connect_id),
- 'code' => @mysqli_errno($this->db_connect_id)
- );
+ return $error;
}
/**
diff --git a/phpBB/includes/db/oracle.php b/phpBB/includes/db/oracle.php
index 6d9339b2d8..4a2b107865 100644
--- a/phpBB/includes/db/oracle.php
+++ b/phpBB/includes/db/oracle.php
@@ -24,6 +24,7 @@ include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx);
class dbal_oracle extends dbal
{
var $last_query_text = '';
+ var $connect_error = '';
/**
* Connect to server
@@ -47,7 +48,33 @@ class dbal_oracle extends dbal
$connect = $sqlserver . (($port) ? ':' . $port : '') . '/' . $database;
}
- $this->db_connect_id = ($new_link) ? @ocinlogon($this->user, $sqlpassword, $connect, 'UTF8') : (($this->persistency) ? @ociplogon($this->user, $sqlpassword, $connect, 'UTF8') : @ocilogon($this->user, $sqlpassword, $connect, 'UTF8'));
+ if ($new_link)
+ {
+ if (!function_exists('ocinlogon'))
+ {
+ $this->connect_error = 'ocinlogon function does not exist, is oci extension installed?';
+ return $this->sql_error('');
+ }
+ $this->db_connect_id = @ocinlogon($this->user, $sqlpassword, $connect, 'UTF8');
+ }
+ else if ($this->persistency)
+ {
+ if (!function_exists('ociplogon'))
+ {
+ $this->connect_error = 'ociplogon function does not exist, is oci extension installed?';
+ return $this->sql_error('');
+ }
+ $this->db_connect_id = @ociplogon($this->user, $sqlpassword, $connect, 'UTF8');
+ }
+ else
+ {
+ if (!function_exists('ocilogon'))
+ {
+ $this->connect_error = 'ocilogon function does not exist, is oci extension installed?';
+ return $this->sql_error('');
+ }
+ $this->db_connect_id = @ocilogon($this->user, $sqlpassword, $connect, 'UTF8');
+ }
return ($this->db_connect_id) ? $this->db_connect_id : $this->sql_error('');
}
@@ -646,17 +673,27 @@ class dbal_oracle extends dbal
*/
function _sql_error()
{
- $error = @ocierror();
- $error = (!$error) ? @ocierror($this->query_result) : $error;
- $error = (!$error) ? @ocierror($this->db_connect_id) : $error;
-
- if ($error)
+ if (function_exists('ocierror'))
{
- $this->last_error_result = $error;
+ $error = @ocierror();
+ $error = (!$error) ? @ocierror($this->query_result) : $error;
+ $error = (!$error) ? @ocierror($this->db_connect_id) : $error;
+
+ if ($error)
+ {
+ $this->last_error_result = $error;
+ }
+ else
+ {
+ $error = (isset($this->last_error_result) && $this->last_error_result) ? $this->last_error_result : array();
+ }
}
else
{
- $error = (isset($this->last_error_result) && $this->last_error_result) ? $this->last_error_result : array();
+ $error = array(
+ 'message' => $this->connect_error,
+ 'code' => '',
+ );
}
return $error;
diff --git a/phpBB/includes/db/sqlite.php b/phpBB/includes/db/sqlite.php
index 5fc89ced18..06e368d586 100644
--- a/phpBB/includes/db/sqlite.php
+++ b/phpBB/includes/db/sqlite.php
@@ -24,6 +24,8 @@ include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx);
*/
class dbal_sqlite extends dbal
{
+ var $connect_error = '';
+
/**
* Connect to server
*/
@@ -35,7 +37,24 @@ class dbal_sqlite extends dbal
$this->dbname = $database;
$error = '';
- $this->db_connect_id = ($this->persistency) ? @sqlite_popen($this->server, 0666, $error) : @sqlite_open($this->server, 0666, $error);
+ if ($this->persistency)
+ {
+ if (!function_exists('sqlite_popen'))
+ {
+ $this->connect_error = 'sqlite_popen function does not exist, is sqlite extension installed?';
+ return $this->sql_error('');
+ }
+ $this->db_connect_id = @sqlite_popen($this->server, 0666, $error);
+ }
+ else
+ {
+ if (!function_exists('sqlite_open'))
+ {
+ $this->connect_error = 'sqlite_open function does not exist, is sqlite extension installed?';
+ return $this->sql_error('');
+ }
+ $this->db_connect_id = @sqlite_open($this->server, 0666, $error);
+ }
if ($this->db_connect_id)
{
@@ -280,10 +299,22 @@ class dbal_sqlite extends dbal
*/
function _sql_error()
{
- return array(
- 'message' => @sqlite_error_string(@sqlite_last_error($this->db_connect_id)),
- 'code' => @sqlite_last_error($this->db_connect_id)
- );
+ if (function_exists('sqlite_error_string'))
+ {
+ $error = array(
+ 'message' => @sqlite_error_string(@sqlite_last_error($this->db_connect_id)),
+ 'code' => @sqlite_last_error($this->db_connect_id),
+ );
+ }
+ else
+ {
+ $error = array(
+ 'message' => $this->connect_error,
+ 'code' => '',
+ );
+ }
+
+ return $error;
}
/**
diff --git a/phpBB/includes/di/extension/ext.php b/phpBB/includes/di/extension/ext.php
index e76c543ee1..7d9b433751 100644
--- a/phpBB/includes/di/extension/ext.php
+++ b/phpBB/includes/di/extension/ext.php
@@ -49,7 +49,7 @@ class phpbb_di_extension_ext extends Extension
{
if (file_exists($path . '/config/services.yml'))
{
- $loader = new YamlFileLoader($container, new FileLocator(phpbb_real_path($path . '/config')));
+ $loader = new YamlFileLoader($container, new FileLocator(phpbb_realpath($path . '/config')));
$loader->load('services.yml');
}
}
diff --git a/phpBB/includes/di/pass/kernel_pass.php b/phpBB/includes/di/pass/kernel_pass.php
new file mode 100644
index 0000000000..a701ebcfa6
--- /dev/null
+++ b/phpBB/includes/di/pass/kernel_pass.php
@@ -0,0 +1,68 @@
+<?php
+/**
+*
+* @package phpBB3
+* @copyright (c) 2012 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+/**
+* @ignore
+*/
+if (!defined('IN_PHPBB'))
+{
+ exit;
+}
+
+use Symfony\Component\DependencyInjection\ContainerBuilder;
+use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
+
+class phpbb_di_pass_kernel_pass implements CompilerPassInterface
+{
+ /**
+ * Modify the container before it is passed to the rest of the code
+ *
+ * @param ContainerBuilder $container ContainerBuilder object
+ * @return null
+ */
+ public function process(ContainerBuilder $container)
+ {
+ $definition = $container->getDefinition('dispatcher');
+
+ foreach ($container->findTaggedServiceIds('kernel.event_listener') as $id => $events)
+ {
+ foreach ($events as $event)
+ {
+ $priority = isset($event['priority']) ? $event['priority'] : 0;
+
+ if (!isset($event['event']))
+ {
+ throw new InvalidArgumentException(sprintf('Service "%1$s" must define the "event" attribute on "kernel.event_listener" tags.', $id));
+ }
+
+ if (!isset($event['method']))
+ {
+ throw new InvalidArgumentException(sprintf('Service "%1$s" must define the "method" attribute on "kernel.event_listener" tags.', $id));
+ }
+
+ $definition->addMethodCall('addListenerService', array($event['event'], array($id, $event['method']), $priority));
+ }
+ }
+
+ foreach ($container->findTaggedServiceIds('kernel.event_subscriber') as $id => $attributes)
+ {
+ // We must assume that the class value has been correctly filled, even if the service is created by a factory
+ $class = $container->getDefinition($id)->getClass();
+
+ $refClass = new ReflectionClass($class);
+ $interface = 'Symfony\Component\EventDispatcher\EventSubscriberInterface';
+ if (!$refClass->implementsInterface($interface))
+ {
+ throw new InvalidArgumentException(sprintf('Service "%1$s" must implement interface "%2$s".', $id, $interface));
+ }
+
+ $definition->addMethodCall('addSubscriberService', array($id, $class));
+ }
+ }
+}
diff --git a/phpBB/includes/di/service_collection.php b/phpBB/includes/di/service_collection.php
index 60323c8dba..880cb46d4d 100644
--- a/phpBB/includes/di/service_collection.php
+++ b/phpBB/includes/di/service_collection.php
@@ -43,7 +43,7 @@ class phpbb_di_service_collection extends ArrayObject
public function add($name)
{
$task = $this->container->get($name);
- $task->set_name($name);
+
$this->offsetSet($name, $task);
}
}
diff --git a/phpBB/includes/event/kernel_exception_subscriber.php b/phpBB/includes/event/kernel_exception_subscriber.php
new file mode 100644
index 0000000000..f90989a74c
--- /dev/null
+++ b/phpBB/includes/event/kernel_exception_subscriber.php
@@ -0,0 +1,85 @@
+<?php
+/**
+*
+* @package phpBB3
+* @copyright (c) 2012 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+/**
+* @ignore
+*/
+if (!defined('IN_PHPBB'))
+{
+ exit;
+}
+
+use Symfony\Component\EventDispatcher\EventSubscriberInterface;
+use Symfony\Component\HttpKernel\KernelEvents;
+use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
+use Symfony\Component\HttpKernel\Exception\HttpException;
+use Symfony\Component\HttpFoundation\Response;
+
+class phpbb_event_kernel_exception_subscriber implements EventSubscriberInterface
+{
+ /**
+ * Template object
+ * @var phpbb_template
+ */
+ protected $template;
+
+ /**
+ * User object
+ * @var phpbb_user
+ */
+ protected $user;
+
+ /**
+ * Construct method
+ *
+ * @param phpbb_template $template Template object
+ * @param phpbb_user $user User object
+ */
+ public function __construct(phpbb_template $template, phpbb_user $user)
+ {
+ $this->template = $template;
+ $this->user = $user;
+ }
+
+ /**
+ * This listener is run when the KernelEvents::EXCEPTION event is triggered
+ *
+ * @param GetResponseForExceptionEvent $event
+ * @return null
+ */
+ public function on_kernel_exception(GetResponseForExceptionEvent $event)
+ {
+ page_header($this->user->lang('INFORMATION'));
+
+ $exception = $event->getException();
+
+ $this->template->assign_vars(array(
+ 'MESSAGE_TITLE' => $this->user->lang('INFORMATION'),
+ 'MESSAGE_TEXT' => $exception->getMessage(),
+ ));
+
+ $this->template->set_filenames(array(
+ 'body' => 'message_body.html',
+ ));
+
+ page_footer(true, false, false);
+
+
+ $status_code = $exception instanceof HttpException ? $exception->getStatusCode() : 500;
+ $response = new Response($this->template->assign_display('body'), $status_code);
+ $event->setResponse($response);
+ }
+
+ public static function getSubscribedEvents()
+ {
+ return array(
+ KernelEvents::EXCEPTION => 'on_kernel_exception',
+ );
+ }
+}
diff --git a/phpBB/includes/event/kernel_request_subscriber.php b/phpBB/includes/event/kernel_request_subscriber.php
new file mode 100644
index 0000000000..afb8464f80
--- /dev/null
+++ b/phpBB/includes/event/kernel_request_subscriber.php
@@ -0,0 +1,83 @@
+<?php
+/**
+*
+* @package phpBB3
+* @copyright (c) 2012 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+/**
+* @ignore
+*/
+if (!defined('IN_PHPBB'))
+{
+ exit;
+}
+
+use Symfony\Component\EventDispatcher\EventSubscriberInterface;
+use Symfony\Component\HttpKernel\KernelEvents;
+use Symfony\Component\HttpKernel\Event\GetResponseEvent;
+use Symfony\Component\HttpKernel\EventListener\RouterListener;
+use Symfony\Component\Routing\RequestContext;
+
+class phpbb_event_kernel_request_subscriber implements EventSubscriberInterface
+{
+ /**
+ * Extension finder object
+ * @var phpbb_extension_finder
+ */
+ protected $finder;
+
+ /**
+ * PHP extension
+ * @var string
+ */
+ protected $php_ext;
+
+ /**
+ * Root path
+ * @var string
+ */
+ protected $root_path;
+
+ /**
+ * Construct method
+ *
+ * @param phpbb_extension_finder $finder Extension finder object
+ * @param string $root_path Root path
+ * @param string $php_ext PHP extension
+ */
+ public function __construct(phpbb_extension_finder $finder, $root_path, $php_ext)
+ {
+ $this->finder = $finder;
+ $this->root_path = $root_path;
+ $this->php_ext = $php_ext;
+ }
+
+ /**
+ * This listener is run when the KernelEvents::REQUEST event is triggered
+ *
+ * This is responsible for setting up the routing information
+ *
+ * @param GetResponseEvent $event
+ * @return null
+ */
+ public function on_kernel_request(GetResponseEvent $event)
+ {
+ $request = $event->getRequest();
+ $context = new RequestContext();
+ $context->fromRequest($request);
+
+ $matcher = phpbb_get_url_matcher($this->finder, $context, $this->root_path, $this->php_ext);
+ $router_listener = new RouterListener($matcher, $context);
+ $router_listener->onKernelRequest($event);
+ }
+
+ public static function getSubscribedEvents()
+ {
+ return array(
+ KernelEvents::REQUEST => 'on_kernel_request',
+ );
+ }
+}
diff --git a/phpBB/includes/event/kernel_terminate_subscriber.php b/phpBB/includes/event/kernel_terminate_subscriber.php
new file mode 100644
index 0000000000..1eaf890e42
--- /dev/null
+++ b/phpBB/includes/event/kernel_terminate_subscriber.php
@@ -0,0 +1,43 @@
+<?php
+/**
+*
+* @package phpBB3
+* @copyright (c) 2012 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+/**
+* @ignore
+*/
+if (!defined('IN_PHPBB'))
+{
+ exit;
+}
+
+use Symfony\Component\EventDispatcher\EventSubscriberInterface;
+use Symfony\Component\HttpKernel\KernelEvents;
+use Symfony\Component\HttpKernel\Event\PostResponseEvent;
+
+class phpbb_event_kernel_terminate_subscriber implements EventSubscriberInterface
+{
+ /**
+ * This listener is run when the KernelEvents::TERMINATE event is triggered
+ * This comes after a Response has been sent to the server; this is
+ * primarily cleanup stuff.
+ *
+ * @param PostResponseEvent $event
+ * @return null
+ */
+ public function on_kernel_terminate(PostResponseEvent $event)
+ {
+ exit_handler();
+ }
+
+ public static function getSubscribedEvents()
+ {
+ return array(
+ KernelEvents::TERMINATE => 'on_kernel_terminate',
+ );
+ }
+}
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index 804d89d1a2..e492f97022 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -7,6 +7,8 @@
*
*/
+use Symfony\Component\HttpFoundation\Request;
+
/**
* @ignore
*/
@@ -229,7 +231,8 @@ function phpbb_gmgetdate($time = false)
/**
* Return formatted string for filesizes
*
-* @param int $value filesize in bytes
+* @param mixed $value filesize in bytes
+* (non-negative number; int, float or string)
* @param bool $string_only true if language string should be returned
* @param array $allowed_units only allow these units (data array indexes)
*
@@ -241,6 +244,12 @@ function get_formatted_filesize($value, $string_only = true, $allowed_units = fa
global $user;
$available_units = array(
+ 'tb' => array(
+ 'min' => 1099511627776, // pow(2, 40)
+ 'index' => 4,
+ 'si_unit' => 'TB',
+ 'iec_unit' => 'TIB',
+ ),
'gb' => array(
'min' => 1073741824, // pow(2, 30)
'index' => 3,
@@ -2847,12 +2856,10 @@ function meta_refresh($time, $url, $disable_cd_check = false)
*
* @param int $code HTTP status code
* @param string $message Message for the status code
-* @return void
+* @return null
*/
function send_status_line($code, $message)
{
- global $request;
-
if (substr(strtolower(@php_sapi_name()), 0, 3) === 'cgi')
{
// in theory, we shouldn't need that due to php doing it. Reality offers a differing opinion, though
@@ -2860,18 +2867,35 @@ function send_status_line($code, $message)
}
else
{
- if ($request->server('SERVER_PROTOCOL'))
- {
- $version = $request->server('SERVER_PROTOCOL');
- }
- else
- {
- $version = 'HTTP/1.0';
- }
+ $version = phpbb_request_http_version();
header("$version $code $message", true, $code);
}
}
+/**
+* Returns the HTTP version used in the current request.
+*
+* Handles the case of being called before $request is present,
+* in which case it falls back to the $_SERVER superglobal.
+*
+* @return string HTTP version
+*/
+function phpbb_request_http_version()
+{
+ global $request;
+
+ if ($request && $request->server('SERVER_PROTOCOL'))
+ {
+ return $request->server('SERVER_PROTOCOL');
+ }
+ else if (isset($_SERVER['SERVER_PROTOCOL']))
+ {
+ return $_SERVER['SERVER_PROTOCOL'];
+ }
+
+ return 'HTTP/1.0';
+}
+
//Form validation
@@ -4771,7 +4795,7 @@ function phpbb_get_plural_form($rule, $number)
*
* @param array $param Parameter array, see $param_defaults array.
*
-* @return void
+* @return null
*/
function phpbb_http_login($param)
{
@@ -4870,12 +4894,107 @@ function phpbb_http_login($param)
}
/**
+* Escapes and quotes a string for use as an HTML/XML attribute value.
+*
+* This is a port of Python xml.sax.saxutils quoteattr.
+*
+* The function will attempt to choose a quote character in such a way as to
+* avoid escaping quotes in the string. If this is not possible the string will
+* be wrapped in double quotes and double quotes will be escaped.
+*
+* @param string $data The string to be escaped
+* @param array $entities Associative array of additional entities to be escaped
+* @return string Escaped and quoted string
+*/
+function phpbb_quoteattr($data, $entities = null)
+{
+ $data = str_replace('&', '&amp;', $data);
+ $data = str_replace('>', '&gt;', $data);
+ $data = str_replace('<', '&lt;', $data);
+
+ $data = str_replace("\n", '&#10;', $data);
+ $data = str_replace("\r", '&#13;', $data);
+ $data = str_replace("\t", '&#9;', $data);
+
+ if (!empty($entities))
+ {
+ $data = str_replace(array_keys($entities), array_values($entities), $data);
+ }
+
+ if (strpos($data, '"') !== false)
+ {
+ if (strpos($data, "'") !== false)
+ {
+ $data = '"' . str_replace('"', '&quot;', $data) . '"';
+ }
+ else
+ {
+ $data = "'" . $data . "'";
+ }
+ }
+ else
+ {
+ $data = '"' . $data . '"';
+ }
+
+ return $data;
+}
+
+/**
+* Converts query string (GET) parameters in request into hidden fields.
+*
+* Useful for forwarding GET parameters when submitting forms with GET method.
+*
+* It is possible to omit some of the GET parameters, which is useful if
+* they are specified in the form being submitted.
+*
+* sid is always omitted.
+*
+* @param phpbb_request $request Request object
+* @param array $exclude A list of variable names that should not be forwarded
+* @return string HTML with hidden fields
+*/
+function phpbb_build_hidden_fields_for_query_params($request, $exclude = null)
+{
+ $names = $request->variable_names(phpbb_request_interface::GET);
+ $hidden = '';
+ foreach ($names as $name)
+ {
+ // Sessions are dealt with elsewhere, omit sid always
+ if ($name == 'sid')
+ {
+ continue;
+ }
+
+ // Omit any additional parameters requested
+ if (!empty($exclude) && in_array($name, $exclude))
+ {
+ continue;
+ }
+
+ $escaped_name = phpbb_quoteattr($name);
+
+ // Note: we might retrieve the variable from POST or cookies
+ // here. To avoid exposing cookies, skip variables that are
+ // overwritten somewhere other than GET entirely.
+ $value = $request->variable($name, '', true);
+ $get_value = $request->variable($name, '', true, phpbb_request_interface::GET);
+ if ($value === $get_value)
+ {
+ $escaped_value = phpbb_quoteattr($value);
+ $hidden .= "<input type='hidden' name=$escaped_name value=$escaped_value />";
+ }
+ }
+ return $hidden;
+}
+
+/**
* Generate page header
*/
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;
+ global $phpbb_dispatcher, $request;
if (defined('HEADER_INC'))
{
@@ -5064,6 +5183,8 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0
$timezone_name = $user->lang['timezones'][$timezone_name];
}
+ $hidden_fields_for_jumpbox = phpbb_build_hidden_fields_for_query_params($request, array('f'));
+
// The following assigns all _common_ variables that may be used at any point in a template.
$template->assign_vars(array(
'SITENAME' => $config['sitename'],
@@ -5078,6 +5199,7 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0
'RECORD_USERS' => $l_online_record,
'PRIVATE_MESSAGE_INFO' => $l_privmsgs_text,
'PRIVATE_MESSAGE_INFO_UNREAD' => $l_privmsgs_text_unread,
+ 'HIDDEN_FIELDS_FOR_JUMPBOX' => $hidden_fields_for_jumpbox,
'S_USER_NEW_PRIVMSG' => $user->data['user_new_privmsg'],
'S_USER_UNREAD_PRIVMSG' => $user->data['user_unread_privmsg'],
@@ -5209,8 +5331,12 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0
/**
* Generate page footer
+*
+* @param bool $run_cron Whether or not to run the cron
+* @param bool $display_template Whether or not to display the template
+* @param bool $exit_handler Whether or not to run the exit_handler()
*/
-function page_footer($run_cron = 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 $request, $phpbb_dispatcher;
@@ -5305,10 +5431,17 @@ function page_footer($run_cron = true)
}
}
- $template->display('body');
+ if ($display_template)
+ {
+ $template->display('body');
+ }
garbage_collection();
- exit_handler();
+
+ if ($exit_handler)
+ {
+ exit_handler();
+ }
}
/**
@@ -5326,7 +5459,10 @@ function garbage_collection()
* @event core.garbage_collection
* @since 3.1-A1
*/
- $phpbb_dispatcher->dispatch('core.garbage_collection');
+ if (!empty($phpbb_dispatcher))
+ {
+ $phpbb_dispatcher->dispatch('core.garbage_collection');
+ }
// Unload cache, must be done before the DB connection if closed
if (!empty($cache))
@@ -5412,3 +5548,49 @@ function phpbb_to_numeric($input)
{
return ($input > PHP_INT_MAX) ? (float) $input : (int) $input;
}
+
+/**
+* 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)
+{
+ // 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);
+
+ // Until we fix the issue with relative paths, we have to fake path info
+ // to allow urls like app.php?controller=foo/bar
+ $controller = $request->variable('controller', '');
+ $path_info = '/' . $controller;
+ $request_uri = $server_parameters['REQUEST_URI'];
+
+ // Remove the query string from REQUEST_URI
+ if ($pos = strpos($request_uri, '?'))
+ {
+ $request_uri = substr($request_uri, 0, $pos);
+ }
+
+ // Add the path info (i.e. controller route) to the REQUEST_URI
+ $server_parameters['REQUEST_URI'] = $request_uri . $path_info;
+ $server_parameters['SCRIPT_NAME'] = '';
+
+ return new Request($get_parameters, $post_parameters, array(), $cookie_parameters, $files_parameters, $server_parameters);
+}
diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php
index 5e2ee8c8f6..15930f9a2c 100644
--- a/phpBB/includes/functions_admin.php
+++ b/phpBB/includes/functions_admin.php
@@ -3308,7 +3308,7 @@ function obtain_latest_version_info($force_update = false, $warn_fail = false, $
* @param int $flag The binary flag which is OR-ed with the current column value
* @param string $sql_more This string is attached to the sql query generated to update the table.
*
- * @return void
+ * @return null
*/
function enable_bitfield_column_flag($table_name, $column_name, $flag, $sql_more = '')
{
diff --git a/phpBB/includes/functions_container.php b/phpBB/includes/functions_container.php
index 1de1d9f7ea..8014574443 100644
--- a/phpBB/includes/functions_container.php
+++ b/phpBB/includes/functions_container.php
@@ -84,8 +84,13 @@ function phpbb_create_compiled_container(array $extensions, array $passes, $phpb
$tmp_container = phpbb_create_container($extensions, $phpbb_root_path, $php_ext);
$tmp_container->compile();
+ // XXX stop writing to global $cache when
+ // http://tracker.phpbb.com/browse/PHPBB3-11203 is fixed
+ $GLOBALS['cache'] = $tmp_container->get('cache');
+ $installed_exts = $tmp_container->get('ext.manager')->all_enabled();
+
// Now pass the enabled extension paths into the ext compiler extension
- $extensions[] = new phpbb_di_extension_ext($tmp_container->get('ext.manager')->all_enabled());
+ $extensions[] = new phpbb_di_extension_ext($installed_exts);
// Create the final container to be compiled and cached
$container = phpbb_create_container($extensions, $phpbb_root_path, $php_ext);
@@ -126,15 +131,12 @@ function phpbb_create_dumped_container(array $extensions, array $passes, $phpbb_
function phpbb_create_dumped_container_unless_debug(array $extensions, array $passes, $phpbb_root_path, $php_ext)
{
- if (defined('DEBUG')) {
- return phpbb_create_compiled_container($extensions, $passes, $phpbb_root_path, $php_ext);
- }
-
- return phpbb_create_dumped_container($extensions, $passes, $phpbb_root_path, $php_ext);
+ $container_factory = defined('DEBUG') ? 'phpbb_create_compiled_container' : 'phpbb_create_dumped_container';
+ return $container_factory($extensions, $passes, $phpbb_root_path, $php_ext);
}
function phpbb_container_filename($phpbb_root_path, $php_ext)
{
$filename = str_replace(array('/', '.'), array('slash', 'dot'), $phpbb_root_path);
- return $phpbb_root_path . 'cache/' . $filename . '_container.' . $php_ext;
+ return $phpbb_root_path . 'cache/container_' . $filename . '.' . $php_ext;
}
diff --git a/phpBB/includes/functions_download.php b/phpBB/includes/functions_download.php
index b6371dbecc..fc6f1cc762 100644
--- a/phpBB/includes/functions_download.php
+++ b/phpBB/includes/functions_download.php
@@ -433,7 +433,7 @@ function set_modified_headers($stamp, $browser)
*
* @param bool $exit Whether to die or not.
*
-* @return void
+* @return null
*/
function file_gc($exit = true)
{
diff --git a/phpBB/includes/functions_install.php b/phpBB/includes/functions_install.php
index 7a799993db..ab6b3ea009 100644
--- a/phpBB/includes/functions_install.php
+++ b/phpBB/includes/functions_install.php
@@ -87,7 +87,7 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20
'2.0.x' => false,
),
'postgres' => array(
- 'LABEL' => 'PostgreSQL 7.x/8.x',
+ 'LABEL' => 'PostgreSQL 8.3+',
'SCHEMA' => 'postgres',
'MODULE' => 'pgsql',
'DELIM' => ';',
diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php
index cf03de08c4..a18aeddabd 100644
--- a/phpBB/includes/functions_messenger.php
+++ b/phpBB/includes/functions_messenger.php
@@ -651,64 +651,6 @@ class queue
}
/**
- * Obtains exclusive lock on queue cache file.
- * Returns resource representing the lock
- */
- function lock()
- {
- // For systems that can't have two processes opening
- // one file for writing simultaneously
- if (file_exists($this->cache_file . '.lock'))
- {
- $mode = 'rb';
- }
- else
- {
- $mode = 'wb';
- }
-
- $lock_fp = @fopen($this->cache_file . '.lock', $mode);
-
- if ($mode == 'wb')
- {
- if (!$lock_fp)
- {
- // Two processes may attempt to create lock file at the same time.
- // Have the losing process try opening the lock file again for reading
- // on the assumption that the winning process created it
- $mode = 'rb';
- $lock_fp = @fopen($this->cache_file . '.lock', $mode);
- }
- else
- {
- // Only need to set mode when the lock file is written
- @chmod($this->cache_file . '.lock', 0666);
- }
- }
-
- if ($lock_fp)
- {
- @flock($lock_fp, LOCK_EX);
- }
-
- return $lock_fp;
- }
-
- /**
- * Releases lock on queue cache file, using resource obtained from lock()
- */
- function unlock($lock_fp)
- {
- // lock() will return null if opening lock file, and thus locking, failed.
- // Accept null values here so that client code does not need to check them
- if ($lock_fp)
- {
- @flock($lock_fp, LOCK_UN);
- fclose($lock_fp);
- }
- }
-
- /**
* Process queue
* Using lock file
*/
@@ -716,16 +658,24 @@ class queue
{
global $db, $config, $phpEx, $phpbb_root_path, $user;
- $lock_fp = $this->lock();
+ $lock = new phpbb_lock_flock($this->cache_file);
+ $lock->acquire();
- set_config('last_queue_run', time(), true);
-
- if (!file_exists($this->cache_file) || filemtime($this->cache_file) > time() - $config['queue_interval'])
+ // avoid races, check file existence once
+ $have_cache_file = file_exists($this->cache_file);
+ if (!$have_cache_file || $config['last_queue_run'] > time() - $config['queue_interval'])
{
- $this->unlock($lock_fp);
+ if (!$have_cache_file)
+ {
+ set_config('last_queue_run', time(), true);
+ }
+
+ $lock->release();
return;
}
+ set_config('last_queue_run', time(), true);
+
include($this->cache_file);
foreach ($this->queue_data as $object => $data_ary)
@@ -789,7 +739,7 @@ class queue
break;
default:
- $this->unlock($lock_fp);
+ $lock->release();
return;
}
@@ -865,7 +815,7 @@ class queue
}
}
- $this->unlock($lock_fp);
+ $lock->release();
}
/**
@@ -878,7 +828,8 @@ class queue
return;
}
- $lock_fp = $this->lock();
+ $lock = new phpbb_lock_flock($this->cache_file);
+ $lock->acquire();
if (file_exists($this->cache_file))
{
@@ -905,7 +856,7 @@ class queue
phpbb_chmod($this->cache_file, CHMOD_READ | CHMOD_WRITE);
}
- $this->unlock($lock_fp);
+ $lock->release();
}
}
diff --git a/phpBB/includes/functions_module.php b/phpBB/includes/functions_module.php
index ad76be9f2f..0d387ace6d 100644
--- a/phpBB/includes/functions_module.php
+++ b/phpBB/includes/functions_module.php
@@ -759,7 +759,26 @@ class p_master
}
}
- $u_title = $module_url . $delim . 'i=' . (($item_ary['cat']) ? $item_ary['id'] : $item_ary['name'] . (($item_ary['is_duplicate']) ? '&amp;icat=' . $current_id : '') . '&amp;mode=' . $item_ary['mode']);
+ $u_title = $module_url . $delim . 'i=';
+ // if the item has a name use it, else use its id
+ if (empty($item_ary['name']))
+ {
+ $u_title .= $item_ary['id'];
+ }
+ else
+ {
+ // if the category has a name, then use it.
+ $u_title .= $item_ary['name'];
+ }
+ // If the item is not a category append the mode
+ if (!$item_ary['cat'])
+ {
+ if ($item_ary['is_duplicate'])
+ {
+ $u_title .= '&amp;icat=' . $current_id;
+ }
+ $u_title .= '&amp;mode=' . $item_ary['mode'];
+ }
// Was not allowed in categories before - /*!$item_ary['cat'] && */
$u_title .= (isset($item_ary['url_extra'])) ? $item_ary['url_extra'] : '';
diff --git a/phpBB/includes/functions_url_matcher.php b/phpBB/includes/functions_url_matcher.php
new file mode 100644
index 0000000000..7280cb74eb
--- /dev/null
+++ b/phpBB/includes/functions_url_matcher.php
@@ -0,0 +1,106 @@
+<?php
+/**
+*
+* @package phpBB3
+* @copyright (c) 2005 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+use Symfony\Component\Routing\Matcher\Dumper\PhpMatcherDumper;
+use Symfony\Component\Routing\Matcher\UrlMatcher;
+use Symfony\Component\Routing\RequestContext;
+
+/**
+* @ignore
+*/
+if (!defined('IN_PHPBB'))
+{
+ exit;
+}
+
+/**
+* Create a new UrlMatcher class and dump it into the cache file
+*
+* @param phpbb_extension_finder $finder Extension finder
+* @param RequestContext $context Symfony RequestContext object
+* @param string $root_path Root path
+* @param string $php_ext PHP extension
+* @return null
+*/
+function phpbb_get_url_matcher(phpbb_extension_finder $finder, RequestContext $context, $root_path, $php_ext)
+{
+ if (defined('DEBUG'))
+ {
+ return phpbb_create_url_matcher($finder, $context);
+ }
+
+ if (!phpbb_url_matcher_dumped($root_path, $php_ext))
+ {
+ phpbb_create_dumped_url_matcher($finder, $root_path, $php_ext);
+ }
+
+ return phpbb_load_url_matcher($context, $root_path, $php_ext);
+}
+
+/**
+* Create a new UrlMatcher class and dump it into the cache file
+*
+* @param phpbb_extension_finder $finder Extension finder
+* @param string $root_path Root path
+* @param string $php_ext PHP extension
+* @return null
+*/
+function phpbb_create_dumped_url_matcher(phpbb_extension_finder $finder, $root_path, $php_ext)
+{
+ $provider = new phpbb_controller_provider();
+ $routes = $provider->import_paths_from_finder($finder)->find();
+ $dumper = new PhpMatcherDumper($routes);
+ $cached_url_matcher_dump = $dumper->dump(array(
+ 'class' => 'phpbb_url_matcher',
+ ));
+
+ file_put_contents($root_path . 'cache/url_matcher' . $php_ext, $cached_url_matcher_dump);
+}
+
+/**
+* Create a non-cached UrlMatcher
+*
+* @param phpbb_extension_finder $finder Extension finder
+* @param RequestContext $context Symfony RequestContext object
+* @return UrlMatcher
+*/
+function phpbb_create_url_matcher(phpbb_extension_finder $finder, RequestContext $context)
+{
+ $provider = new phpbb_controller_provider();
+ $routes = $provider->import_paths_from_finder($finder)->find();
+ return new UrlMatcher($routes, $context);
+}
+
+/**
+* Load the cached phpbb_url_matcher class
+*
+* @param RequestContext $context Symfony RequestContext object
+* @param string $root_path Root path
+* @param string $php_ext PHP extension
+* @return phpbb_url_matcher
+*/
+function phpbb_load_url_matcher(RequestContext $context, $root_path, $php_ext)
+{
+ require($root_path . 'cache/url_matcher' . $php_ext);
+ return new phpbb_url_matcher($context);
+}
+
+/**
+* Determine whether we have our dumped URL matcher
+*
+* The class is automatically dumped to the cache directory
+*
+* @param string $root_path Root path
+* @param string $php_ext PHP extension
+* @return bool True if it exists, false if not
+*/
+function phpbb_url_matcher_dumped($root_path, $php_ext)
+{
+ return file_exists($root_path . 'cache/url_matcher' . $php_ext);
+}
diff --git a/phpBB/includes/group_positions.php b/phpBB/includes/group_positions.php
index 74de3516cb..60352ed97d 100644
--- a/phpBB/includes/group_positions.php
+++ b/phpBB/includes/group_positions.php
@@ -104,7 +104,7 @@ class phpbb_group_positions
* Addes a group by group_id
*
* @param int $group_id group_id of the group to be added
- * @return void
+ * @return null
*/
public function add_group($group_id)
{
@@ -128,7 +128,7 @@ class phpbb_group_positions
*
* @param int $group_id group_id of the group to be deleted
* @param bool $skip_group Skip setting the group to GROUP_DISABLED, to save the query, when you need to update it anyway.
- * @return void
+ * @return null
*/
public function delete_group($group_id, $skip_group = false)
{
@@ -159,7 +159,7 @@ class phpbb_group_positions
* Moves a group up by group_id
*
* @param int $group_id group_id of the group to be moved
- * @return void
+ * @return null
*/
public function move_up($group_id)
{
@@ -170,7 +170,7 @@ class phpbb_group_positions
* Moves a group down by group_id
*
* @param int $group_id group_id of the group to be moved
- * @return void
+ * @return null
*/
public function move_down($group_id)
{
@@ -184,7 +184,7 @@ class phpbb_group_positions
* @param int $delta number of steps:
* - positive = move up
* - negative = move down
- * @return void
+ * @return null
*/
public function move($group_id, $delta)
{
diff --git a/phpBB/includes/lock/db.php b/phpBB/includes/lock/db.php
index fa559d6887..6e94dd5a85 100644
--- a/phpBB/includes/lock/db.php
+++ b/phpBB/includes/lock/db.php
@@ -125,7 +125,7 @@ class phpbb_lock_db
* Note: Attempting to release a lock that is already released,
* that is, calling release() multiple times, is harmless.
*
- * @return void
+ * @return null
*/
public function release()
{
diff --git a/phpBB/includes/lock/flock.php b/phpBB/includes/lock/flock.php
new file mode 100644
index 0000000000..97bc7dd2b9
--- /dev/null
+++ b/phpBB/includes/lock/flock.php
@@ -0,0 +1,133 @@
+<?php
+/**
+*
+* @package phpBB3
+* @copyright (c) 2012 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+/**
+* @ignore
+*/
+if (!defined('IN_PHPBB'))
+{
+ exit;
+}
+
+/**
+* File locking class
+* @package phpBB3
+*/
+class phpbb_lock_flock
+{
+ /**
+ * Path to the file to which access is controlled
+ *
+ * @var string
+ */
+ private $path;
+
+ /**
+ * File pointer for the lock file
+ * @var string
+ */
+ private $lock_fp;
+
+ /**
+ * Constructor.
+ *
+ * You have to call acquire() to actually acquire the lock.
+ *
+ * @param string $path Path to the file to which access is controlled
+ */
+ public function __construct($path)
+ {
+ $this->path = $path;
+ $this->lock_fp = null;
+ }
+
+ /**
+ * Tries to acquire the lock.
+ *
+ * If the lock is already held by another process, this call will block
+ * until the other process releases the lock. If a lock is acquired and
+ * is not released before script finishes but the process continues to
+ * live (apache/fastcgi) then subsequent processes trying to acquire
+ * the same lock will be blocked forever.
+ *
+ * If the lock is already held by the same process via another instance
+ * of this class, this call will block forever.
+ *
+ * If flock function is disabled in php or fails to work, lock
+ * acquisition will fail and false will be returned.
+ *
+ * @return bool true if lock was acquired
+ * false otherwise
+ */
+ public function acquire()
+ {
+ if ($this->lock_fp)
+ {
+ return false;
+ }
+
+ // For systems that can't have two processes opening
+ // one file for writing simultaneously
+ if (file_exists($this->path . '.lock'))
+ {
+ $mode = 'rb';
+ }
+ else
+ {
+ $mode = 'wb';
+ }
+
+ $this->lock_fp = @fopen($this->path . '.lock', $mode);
+
+ if ($mode == 'wb')
+ {
+ if (!$this->lock_fp)
+ {
+ // Two processes may attempt to create lock file at the same time.
+ // Have the losing process try opening the lock file again for reading
+ // on the assumption that the winning process created it
+ $mode = 'rb';
+ $this->lock_fp = @fopen($this->path . '.lock', $mode);
+ }
+ else
+ {
+ // Only need to set mode when the lock file is written
+ @chmod($this->path . '.lock', 0666);
+ }
+ }
+
+ if ($this->lock_fp)
+ {
+ @flock($this->lock_fp, LOCK_EX);
+ }
+
+ return (bool) $this->lock_fp;
+ }
+
+ /**
+ * Releases the lock.
+ *
+ * The lock must have been previously obtained, that is, acquire() call
+ * was issued and returned true.
+ *
+ * Note: Attempting to release a lock that is already released,
+ * that is, calling release() multiple times, is harmless.
+ *
+ * @return null
+ */
+ public function release()
+ {
+ if ($this->lock_fp)
+ {
+ @flock($this->lock_fp, LOCK_UN);
+ fclose($this->lock_fp);
+ $this->lock_fp = null;
+ }
+ }
+}
diff --git a/phpBB/includes/questionnaire/questionnaire.php b/phpBB/includes/questionnaire/questionnaire.php
index f0fb8c3c06..2d29fe978e 100644
--- a/phpBB/includes/questionnaire/questionnaire.php
+++ b/phpBB/includes/questionnaire/questionnaire.php
@@ -70,7 +70,7 @@ class phpbb_questionnaire_data_collector
/**
* Collect info into the data property.
*
- * @return void
+ * @return null
*/
function collect()
{
diff --git a/phpBB/includes/search/fulltext_mysql.php b/phpBB/includes/search/fulltext_mysql.php
index 58a4dd7d6a..ff2e24aa05 100644
--- a/phpBB/includes/search/fulltext_mysql.php
+++ b/phpBB/includes/search/fulltext_mysql.php
@@ -86,6 +86,14 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
$this->word_length = array('min' => $this->config['fulltext_mysql_min_word_len'], 'max' => $this->config['fulltext_mysql_max_word_len']);
+ /**
+ * Load the UTF tools
+ */
+ if (!function_exists('utf8_strlen'))
+ {
+ include($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx);
+ }
+
$error = false;
}
@@ -230,7 +238,7 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
}
else
{
- $tmp_split_words[] = $word . ' ';
+ $tmp_split_words[] = $word;
}
}
if ($phrase)
diff --git a/phpBB/includes/search/fulltext_postgres.php b/phpBB/includes/search/fulltext_postgres.php
index 08f64735b6..2880610655 100644
--- a/phpBB/includes/search/fulltext_postgres.php
+++ b/phpBB/includes/search/fulltext_postgres.php
@@ -121,6 +121,14 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
}
}
+ /**
+ * Load the UTF tools
+ */
+ if (!function_exists('utf8_strlen'))
+ {
+ include($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx);
+ }
+
$error = false;
}
diff --git a/phpBB/includes/style/resource_locator.php b/phpBB/includes/style/resource_locator.php
index 8658fe4a36..4cf767c062 100644
--- a/phpBB/includes/style/resource_locator.php
+++ b/phpBB/includes/style/resource_locator.php
@@ -44,7 +44,7 @@ class phpbb_style_resource_locator implements phpbb_template_locator
* style directory, such as admin control panel templates.
* @var string
*/
- public $template_path = 'template/';
+ private $template_path;
/**
* Map from root index to handles to source template file paths.
@@ -64,6 +64,16 @@ class phpbb_style_resource_locator implements phpbb_template_locator
private $filenames = array();
/**
+ * Constructor.
+ *
+ * Sets default template path to template/.
+ */
+ public function __construct()
+ {
+ $this->set_default_template_path();
+ }
+
+ /**
* Sets the list of style paths
*
* These paths will be searched for style files in the provided order.
@@ -94,6 +104,31 @@ class phpbb_style_resource_locator implements phpbb_template_locator
}
/**
+ * Sets the location of templates directory within style directories.
+ *
+ * The location must be a relative path, with a trailing slash.
+ * Typically it is one directory level deep, e.g. "template/".
+ *
+ * @param string $template_path Relative path to templates directory within style directories
+ * @return null
+ */
+ public function set_template_path($template_path)
+ {
+ $this->template_path = $template_path;
+ }
+
+ /**
+ * Sets the location of templates directory within style directories
+ * to the default, which is "template/".
+ *
+ * @return null
+ */
+ public function set_default_template_path()
+ {
+ $this->template_path = 'template/';
+ }
+
+ /**
* {@inheritDoc}
*/
public function set_filenames(array $filename_array)
@@ -229,4 +264,85 @@ class phpbb_style_resource_locator implements phpbb_template_locator
// search failed
return $default_result;
}
+
+ /**
+ * Obtains filesystem path for a template file.
+ *
+ * The simplest use is specifying a single template file as a string
+ * in the first argument. This template file should be a basename
+ * of a template file in the selected style, or its parent styles
+ * if template inheritance is being utilized.
+ *
+ * Note: "selected style" is whatever style the style resource locator
+ * is configured for.
+ *
+ * The return value then will be a path, relative to the current
+ * directory or absolute, to the template file in the selected style
+ * or its closest parent.
+ *
+ * If the selected style does not have the template file being searched,
+ * (and if inheritance is involved, none of the parents have it either),
+ * false will be returned.
+ *
+ * Specifying true for $return_default will cause the function to
+ * return the first path which was checked for existence in the event
+ * that the template file was not found, instead of false.
+ * This is the path in the selected style itself, not any of its
+ * parents.
+ *
+ * $files can be given an array of templates instead of a single
+ * template. When given an array, the function will try to resolve
+ * each template in the array to a path, and will return the first
+ * path that exists, or false if none exist.
+ *
+ * If $files is an array and template inheritance is involved, first
+ * each of the files will be checked in the selected style, then each
+ * of the files will be checked in the immediate parent, and so on.
+ *
+ * If $return_full_path is false, then instead of returning a usable
+ * path (when the template is found) only the template's basename
+ * will be returned. This can be used to check which of the templates
+ * specified in $files exists. Naturally more than one template must
+ * be given in $files.
+ *
+ * This function works identically to get_first_file_location except
+ * it operates on a list of templates, not files. Practically speaking,
+ * the templates given in the first argument first are prepended with
+ * the template path (property in this class), then given to
+ * get_first_file_location for the rest of the processing.
+ *
+ * Templates given to this function can be relative paths for templates
+ * located in subdirectories of the template directories. The paths
+ * should be relative to the templates directory (template/ by default).
+ *
+ * @param string or array $files List of templates to locate. If there is only
+ * one template, $files can be a string to make code easier to read.
+ * @param bool $return_default Determines what to return if template does not
+ * exist. If true, function will return location where template is
+ * supposed to be. If false, function will return false.
+ * @param bool $return_full_path If true, function will return full path
+ * to template. If false, function will return template file name.
+ * This parameter can be used to check which one of set of template
+ * files is available.
+ * @return string or boolean Source template path if template exists or $return_default is
+ * true. False if template does not exist and $return_default is false
+ */
+ public function get_first_template_location($templates, $return_default = false, $return_full_path = true)
+ {
+ // add template path prefix
+ $files = array();
+ if (is_string($templates))
+ {
+ $files[] = $this->template_path . $templates;
+ }
+ else
+ {
+ foreach ($templates as $template)
+ {
+ $files[] = $this->template_path . $template;
+ }
+ }
+
+ return $this->get_first_file_location($files, $return_default, $return_full_path);
+ }
}
diff --git a/phpBB/includes/style/style.php b/phpBB/includes/style/style.php
index 36298b49ec..effd496fb9 100644
--- a/phpBB/includes/style/style.php
+++ b/phpBB/includes/style/style.php
@@ -110,7 +110,7 @@ class phpbb_style
*
* @param string $name Name of style, used for cache prefix. Examples: "admin", "prosilver"
* @param array or string $paths Array of style paths, relative to current root directory
- * @param string $template_path Path to templates, relative to style directory. False if path should not be changed.
+ * @param string $template_path Path to templates, relative to style directory. False if path should be set to default (templates/).
*/
public function set_custom_style($name, $paths, $template_path = false)
{
@@ -122,13 +122,17 @@ class phpbb_style
$this->provider->set_styles($paths);
$this->locator->set_paths($this->provider);
- $this->template->cachepath = $this->phpbb_root_path . 'cache/tpl_' . str_replace('_', '-', $name) . '_';
-
if ($template_path !== false)
{
- $this->template->template_path = $this->locator->template_path = $template_path;
+ $this->locator->set_template_path($template_path);
+ }
+ else
+ {
+ $this->locator->set_default_template_path();
}
+ $this->template->cachepath = $this->phpbb_root_path . 'cache/tpl_' . str_replace('_', '-', $name) . '_';
+
return true;
}
diff --git a/phpBB/includes/template/compile.php b/phpBB/includes/template/compile.php
index 82b301c1a2..22da21820e 100644
--- a/phpBB/includes/template/compile.php
+++ b/phpBB/includes/template/compile.php
@@ -58,6 +58,9 @@ class phpbb_template_compile
*/
public function compile_file_to_file($source_file, $compiled_file)
{
+ $lock = new phpbb_lock_flock($compiled_file);
+ $lock->acquire();
+
$source_handle = @fopen($source_file, 'rb');
$destination_handle = @fopen($compiled_file, 'wb');
@@ -66,16 +69,15 @@ class phpbb_template_compile
return false;
}
- @flock($destination_handle, LOCK_EX);
-
$this->compile_stream_to_stream($source_handle, $destination_handle);
@fclose($source_handle);
- @flock($destination_handle, LOCK_UN);
@fclose($destination_handle);
phpbb_chmod($compiled_file, CHMOD_READ | CHMOD_WRITE);
+ $lock->release();
+
clearstatcache();
return true;
@@ -118,7 +120,7 @@ class phpbb_template_compile
*
* @param resource $source_stream Source stream
* @param resource $dest_stream Destination stream
- * @return void
+ * @return null
*/
private function compile_stream_to_stream($source_stream, $dest_stream)
{
diff --git a/phpBB/includes/template/locator.php b/phpBB/includes/template/locator.php
index 01c79eec4e..42db91efb2 100644
--- a/phpBB/includes/template/locator.php
+++ b/phpBB/includes/template/locator.php
@@ -99,12 +99,54 @@ interface phpbb_template_locator
public function get_source_file_for_handle($handle, $find_all = false);
/**
- * Locates source file path, accounting for styles tree and verifying that
- * the path exists.
+ * Obtains a complete filesystem path for a file in a style.
*
- * Unlike previous functions, this function works without template handle
- * and it can search for more than one file. If more than one file name is
- * specified, it will return location of file that it finds first.
+ * This function traverses the style tree (selected style and
+ * its parents in order, if inheritance is being used) and finds
+ * the first file on the filesystem matching specified relative path,
+ * or the first of the specified paths if more than one path is given.
+ *
+ * This function can be used to determine filesystem path of any
+ * file under any style, with the consequence being that complete
+ * relative to the style directory path must be provided as an argument.
+ *
+ * In particular, this function can be used to locate templates
+ * and javascript files.
+ *
+ * For locating templates get_first_template_location should be used
+ * as it prepends the configured template path to the template basename.
+ *
+ * Note: "selected style" is whatever style the style resource locator
+ * is configured for.
+ *
+ * The return value then will be a path, relative to the current
+ * directory or absolute, to the first existing file in the selected
+ * style or its closest parent.
+ *
+ * If the selected style does not have the file being searched,
+ * (and if inheritance is involved, none of the parents have it either),
+ * false will be returned.
+ *
+ * Multiple files can be specified, in which case the first file in
+ * the list that can be found on the filesystem is returned.
+ *
+ * If multiple files are specified and inheritance is involved,
+ * first each of the specified files is checked in the selected style,
+ * then each of the specified files is checked in the immediate parent,
+ * etc.
+ *
+ * Specifying true for $return_default will cause the function to
+ * return the first path which was checked for existence in the event
+ * that the template file was not found, instead of false.
+ * This is always a path in the selected style itself, not any of its
+ * parents.
+ *
+ * If $return_full_path is false, then instead of returning a usable
+ * path (when the file is found) the file's path relative to the style
+ * directory will be returned. This is the same path as was given to
+ * the function as a parameter. This can be used to check which of the
+ * files specified in $files exists. Naturally this requires passing
+ * more than one file in $files.
*
* @param array $files List of files to locate.
* @param bool $return_default Determines what to return if file does not
diff --git a/phpBB/includes/template/template.php b/phpBB/includes/template/template.php
index 8a7dc6b2f3..5396ddbfad 100644
--- a/phpBB/includes/template/template.php
+++ b/phpBB/includes/template/template.php
@@ -75,12 +75,6 @@ class phpbb_template
private $locator;
/**
- * Location of templates directory within style directories
- * @var string
- */
- public $template_path = 'template/';
-
- /**
* Constructor.
*
* @param string $phpbb_root_path phpBB root path
@@ -95,7 +89,6 @@ class phpbb_template
$this->config = $config;
$this->user = $user;
$this->locator = $locator;
- $this->template_path = $this->locator->template_path;
$this->context = $context;
}
@@ -459,74 +452,6 @@ class phpbb_template
}
/**
- * Obtains filesystem path for a template file.
- *
- * The simplest use is specifying a single template file as a string
- * in the first argument. This template file should be a basename
- * of a template file in the selected style, or its parent styles
- * if template inheritance is being utilized.
- *
- * Note: "selected style" is whatever style the style resource locator
- * is configured for.
- *
- * The return value then will be a path, relative to the current
- * directory or absolute, to the template file in the selected style
- * or its closest parent.
- *
- * If the selected style does not have the template file being searched,
- * (and if inheritance is involved, none of the parents have it either),
- * false will be returned.
- *
- * Specifying true for $return_default will cause the function to
- * return the first path which was checked for existence in the event
- * that the template file was not found, instead of false.
- * This is the path in the selected style itself, not any of its
- * parents.
- *
- * $files can be given an array of templates instead of a single
- * template. When given an array, the function will try to resolve
- * each template in the array to a path, and will return the first
- * path that exists, or false if none exist.
- *
- * If $return_full_path is false, then instead of returning a usable
- * path (when the template is found) only the template's basename
- * will be returned. This can be used to check which of the templates
- * specified in $files exists, provided different file names are
- * used for different templates.
- *
- * @param string or array $files List of templates to locate. If there is only
- * one template, $files can be a string to make code easier to read.
- * @param bool $return_default Determines what to return if template does not
- * exist. If true, function will return location where template is
- * supposed to be. If false, function will return false.
- * @param bool $return_full_path If true, function will return full path
- * to template. If false, function will return template file name.
- * This parameter can be used to check which one of set of template
- * files is available.
- * @return string or boolean Source template path if template exists or $return_default is
- * true. False if template does not exist and $return_default is false
- */
- public function locate($files, $return_default = false, $return_full_path = true)
- {
- // add template path prefix
- $templates = array();
- if (is_string($files))
- {
- $templates[] = $this->template_path . $files;
- }
- else
- {
- foreach ($files as $file)
- {
- $templates[] = $this->template_path . $file;
- }
- }
-
- // use resource locator to find files
- return $this->locator->get_first_file_location($templates, $return_default, $return_full_path);
- }
-
- /**
* Include JS file
*
* @param string $file file name
diff --git a/phpBB/includes/ucp/info/ucp_profile.php b/phpBB/includes/ucp/info/ucp_profile.php
index a0f9598e93..98ab0597ff 100644
--- a/phpBB/includes/ucp/info/ucp_profile.php
+++ b/phpBB/includes/ucp/info/ucp_profile.php
@@ -19,7 +19,7 @@ class ucp_profile_info
'title' => 'UCP_PROFILE',
'version' => '1.0.0',
'modes' => array(
- 'profile_info' => array('title' => 'UCP_PROFILE_PROFILE_INFO', 'auth' => '', 'cat' => array('UCP_PROFILE')),
+ 'profile_info' => array('title' => 'UCP_PROFILE_PROFILE_INFO', 'auth' => 'acl_u_chgprofileinfo', 'cat' => array('UCP_PROFILE')),
'signature' => array('title' => 'UCP_PROFILE_SIGNATURE', 'auth' => 'acl_u_sig', 'cat' => array('UCP_PROFILE')),
'avatar' => array('title' => 'UCP_PROFILE_AVATAR', 'auth' => 'cfg_allow_avatar && (cfg_allow_avatar_local || cfg_allow_avatar_remote || cfg_allow_avatar_upload || cfg_allow_avatar_remote_upload || cfg_allow_avatar_gravatar)', 'cat' => array('UCP_PROFILE')),
'reg_details' => array('title' => 'UCP_PROFILE_REG_DETAILS', 'auth' => '', 'cat' => array('UCP_PROFILE')),
diff --git a/phpBB/includes/ucp/ucp_prefs.php b/phpBB/includes/ucp/ucp_prefs.php
index 2228bc7931..23892c2c8c 100644
--- a/phpBB/includes/ucp/ucp_prefs.php
+++ b/phpBB/includes/ucp/ucp_prefs.php
@@ -132,6 +132,36 @@ class ucp_prefs
$dateformat_options .= '>' . $user->lang['CUSTOM_DATEFORMAT'] . '</option>';
$timezone_selects = phpbb_timezone_select($user, $data['tz'], true);
+
+ // check if there are any user-selectable languages
+ $sql = 'SELECT COUNT(lang_id) as languages_count
+ FROM ' . LANG_TABLE;
+ $result = $db->sql_query($sql);
+ if ($db->sql_fetchfield('languages_count') > 1)
+ {
+ $s_more_languages = true;
+ }
+ else
+ {
+ $s_more_languages = false;
+ }
+ $db->sql_freeresult($result);
+
+ // check if there are any user-selectable styles
+ $sql = 'SELECT COUNT(style_id) as styles_count
+ FROM ' . STYLES_TABLE . '
+ WHERE style_active = 1';
+ $result = $db->sql_query($sql);
+ if ($db->sql_fetchfield('styles_count') > 1)
+ {
+ $s_more_styles = true;
+ }
+ else
+ {
+ $s_more_styles = false;
+ }
+ $db->sql_freeresult($result);
+
$template->assign_vars(array(
'ERROR' => (sizeof($error)) ? implode('<br />', $error) : '',
@@ -152,6 +182,9 @@ class ucp_prefs
'DEFAULT_DATEFORMAT' => $config['default_dateformat'],
'A_DEFAULT_DATEFORMAT' => addslashes($config['default_dateformat']),
+ 'S_MORE_LANGUAGES' => $s_more_languages,
+ 'S_MORE_STYLES' => $s_more_styles,
+
'S_LANG_OPTIONS' => language_select($data['lang']),
'S_STYLE_OPTIONS' => ($config['override_user_style']) ? '' : style_select($data['style']),
'S_TZ_OPTIONS' => $timezone_selects['tz_select'],
diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php
index 7b4dddf12b..14639b00ff 100644
--- a/phpBB/includes/ucp/ucp_profile.php
+++ b/phpBB/includes/ucp/ucp_profile.php
@@ -252,6 +252,11 @@ class ucp_profile
break;
case 'profile_info':
+ // Do not display profile information panel if not authed to do so
+ if (!$auth->acl_get('u_chgprofileinfo'))
+ {
+ trigger_error('NO_AUTH_PROFILEINFO');
+ }
include($phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx);