aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes')
-rw-r--r--phpBB/includes/acp/acp_groups.php6
-rw-r--r--phpBB/includes/db/dbal.php4
-rw-r--r--phpBB/includes/db/firebird.php6
-rw-r--r--phpBB/includes/db/mssql.php6
-rw-r--r--phpBB/includes/db/mssql_odbc.php6
-rw-r--r--phpBB/includes/db/mssqlnative.php6
-rw-r--r--phpBB/includes/db/mysql.php6
-rw-r--r--phpBB/includes/db/mysqli.php6
-rw-r--r--phpBB/includes/db/oracle.php6
-rw-r--r--phpBB/includes/db/postgres.php6
-rw-r--r--phpBB/includes/db/sqlite.php6
-rw-r--r--phpBB/includes/functions.php8
-rw-r--r--phpBB/includes/functions_acp.php4
-rw-r--r--phpBB/includes/functions_install.php2
-rw-r--r--phpBB/includes/functions_upload.php45
-rw-r--r--phpBB/includes/functions_user.php10
-rw-r--r--phpBB/includes/message_parser.php5
-rw-r--r--phpBB/includes/request/interface.php1
-rw-r--r--phpBB/includes/request/request.php14
-rw-r--r--phpBB/includes/session.php2
-rw-r--r--phpBB/includes/template/filter.php61
-rw-r--r--phpBB/includes/template/template.php10
-rw-r--r--phpBB/includes/ucp/ucp_groups.php5
-rw-r--r--phpBB/includes/user.php10
24 files changed, 150 insertions, 91 deletions
diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php
index 9621407211..b604e20094 100644
--- a/phpBB/includes/acp/acp_groups.php
+++ b/phpBB/includes/acp/acp_groups.php
@@ -26,6 +26,7 @@ class acp_groups
{
global $config, $db, $user, $auth, $template, $cache;
global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix, $file_uploads;
+ global $request;
$user->add_lang('acp/groups');
$this->tpl_name = 'acp_groups';
@@ -323,7 +324,8 @@ class acp_groups
$submit_ary['founder_manage'] = isset($_REQUEST['group_founder_manage']) ? 1 : 0;
}
- if (!empty($_FILES['uploadfile']['tmp_name']) || $data['uploadurl'] || $data['remotelink'])
+ $uploadfile = $request->file('uploadfile');
+ if (!empty($uploadfile['tmp_name']) || $data['uploadurl'] || $data['remotelink'])
{
// Avatar stuff
$var_ary = array(
@@ -337,7 +339,7 @@ class acp_groups
{
$data['user_id'] = "g$group_id";
- if ((!empty($_FILES['uploadfile']['tmp_name']) || $data['uploadurl']) && $can_upload)
+ if ((!empty($uploadfile['tmp_name']) || $data['uploadurl']) && $can_upload)
{
list($submit_ary['avatar_type'], $submit_ary['avatar'], $submit_ary['avatar_width'], $submit_ary['avatar_height']) = avatar_upload($data, $error);
}
diff --git a/phpBB/includes/db/dbal.php b/phpBB/includes/db/dbal.php
index 1de236d3de..ef1dd7d14d 100644
--- a/phpBB/includes/db/dbal.php
+++ b/phpBB/includes/db/dbal.php
@@ -766,8 +766,8 @@ class dbal
// Show complete SQL error and path to administrators only
// Additionally show complete error on installation or if extended debug mode is enabled
- // The DEBUG_EXTRA constant is for development only!
- if ((isset($auth) && $auth->acl_get('a_')) || defined('IN_INSTALL') || defined('DEBUG_EXTRA'))
+ // The DEBUG constant is for development only!
+ if ((isset($auth) && $auth->acl_get('a_')) || defined('IN_INSTALL') || defined('DEBUG'))
{
$message .= ($sql) ? '<br /><br />SQL<br /><br />' . htmlspecialchars($sql) : '';
}
diff --git a/phpBB/includes/db/firebird.php b/phpBB/includes/db/firebird.php
index 9f9b8a1abd..5728eb901c 100644
--- a/phpBB/includes/db/firebird.php
+++ b/phpBB/includes/db/firebird.php
@@ -150,7 +150,7 @@ class dbal_firebird extends dbal
global $cache;
// EXPLAIN only in extra debug mode
- if (defined('DEBUG_EXTRA'))
+ if (defined('DEBUG'))
{
$this->sql_report('start', $query);
}
@@ -251,7 +251,7 @@ class dbal_firebird extends dbal
$this->sql_error($query);
}
- if (defined('DEBUG_EXTRA'))
+ if (defined('DEBUG'))
{
$this->sql_report('stop', $query);
}
@@ -279,7 +279,7 @@ class dbal_firebird extends dbal
$this->open_queries[(int) $this->query_result] = $this->query_result;
}
}
- else if (defined('DEBUG_EXTRA'))
+ else if (defined('DEBUG'))
{
$this->sql_report('fromcache', $query);
}
diff --git a/phpBB/includes/db/mssql.php b/phpBB/includes/db/mssql.php
index bde283c3ea..1ec8517308 100644
--- a/phpBB/includes/db/mssql.php
+++ b/phpBB/includes/db/mssql.php
@@ -139,7 +139,7 @@ class dbal_mssql extends dbal
global $cache;
// EXPLAIN only in extra debug mode
- if (defined('DEBUG_EXTRA'))
+ if (defined('DEBUG'))
{
$this->sql_report('start', $query);
}
@@ -154,7 +154,7 @@ class dbal_mssql extends dbal
$this->sql_error($query);
}
- if (defined('DEBUG_EXTRA'))
+ if (defined('DEBUG'))
{
$this->sql_report('stop', $query);
}
@@ -169,7 +169,7 @@ class dbal_mssql extends dbal
$this->open_queries[(int) $this->query_result] = $this->query_result;
}
}
- else if (defined('DEBUG_EXTRA'))
+ else if (defined('DEBUG'))
{
$this->sql_report('fromcache', $query);
}
diff --git a/phpBB/includes/db/mssql_odbc.php b/phpBB/includes/db/mssql_odbc.php
index 687bc52abc..7c1ffbc808 100644
--- a/phpBB/includes/db/mssql_odbc.php
+++ b/phpBB/includes/db/mssql_odbc.php
@@ -157,7 +157,7 @@ class dbal_mssql_odbc extends dbal
global $cache;
// EXPLAIN only in extra debug mode
- if (defined('DEBUG_EXTRA'))
+ if (defined('DEBUG'))
{
$this->sql_report('start', $query);
}
@@ -173,7 +173,7 @@ class dbal_mssql_odbc extends dbal
$this->sql_error($query);
}
- if (defined('DEBUG_EXTRA'))
+ if (defined('DEBUG'))
{
$this->sql_report('stop', $query);
}
@@ -188,7 +188,7 @@ class dbal_mssql_odbc extends dbal
$this->open_queries[(int) $this->query_result] = $this->query_result;
}
}
- else if (defined('DEBUG_EXTRA'))
+ else if (defined('DEBUG'))
{
$this->sql_report('fromcache', $query);
}
diff --git a/phpBB/includes/db/mssqlnative.php b/phpBB/includes/db/mssqlnative.php
index c31f7f6892..e9191fae8a 100644
--- a/phpBB/includes/db/mssqlnative.php
+++ b/phpBB/includes/db/mssqlnative.php
@@ -311,7 +311,7 @@ class dbal_mssqlnative extends dbal
global $cache;
// EXPLAIN only in extra debug mode
- if (defined('DEBUG_EXTRA'))
+ if (defined('DEBUG'))
{
$this->sql_report('start', $query);
}
@@ -329,7 +329,7 @@ class dbal_mssqlnative extends dbal
// reset options for next query
$this->query_options = array();
- if (defined('DEBUG_EXTRA'))
+ if (defined('DEBUG'))
{
$this->sql_report('stop', $query);
}
@@ -344,7 +344,7 @@ class dbal_mssqlnative extends dbal
$this->open_queries[(int) $this->query_result] = $this->query_result;
}
}
- else if (defined('DEBUG_EXTRA'))
+ else if (defined('DEBUG'))
{
$this->sql_report('fromcache', $query);
}
diff --git a/phpBB/includes/db/mysql.php b/phpBB/includes/db/mysql.php
index 5b4ff86579..f685ab055c 100644
--- a/phpBB/includes/db/mysql.php
+++ b/phpBB/includes/db/mysql.php
@@ -167,7 +167,7 @@ class dbal_mysql extends dbal
global $cache;
// EXPLAIN only in extra debug mode
- if (defined('DEBUG_EXTRA'))
+ if (defined('DEBUG'))
{
$this->sql_report('start', $query);
}
@@ -182,7 +182,7 @@ class dbal_mysql extends dbal
$this->sql_error($query);
}
- if (defined('DEBUG_EXTRA'))
+ if (defined('DEBUG'))
{
$this->sql_report('stop', $query);
}
@@ -197,7 +197,7 @@ class dbal_mysql extends dbal
$this->open_queries[(int) $this->query_result] = $this->query_result;
}
}
- else if (defined('DEBUG_EXTRA'))
+ else if (defined('DEBUG'))
{
$this->sql_report('fromcache', $query);
}
diff --git a/phpBB/includes/db/mysqli.php b/phpBB/includes/db/mysqli.php
index 1f13bd5459..6d81b8bc3e 100644
--- a/phpBB/includes/db/mysqli.php
+++ b/phpBB/includes/db/mysqli.php
@@ -174,7 +174,7 @@ class dbal_mysqli extends dbal
global $cache;
// EXPLAIN only in extra debug mode
- if (defined('DEBUG_EXTRA'))
+ if (defined('DEBUG'))
{
$this->sql_report('start', $query);
}
@@ -189,7 +189,7 @@ class dbal_mysqli extends dbal
$this->sql_error($query);
}
- if (defined('DEBUG_EXTRA'))
+ if (defined('DEBUG'))
{
$this->sql_report('stop', $query);
}
@@ -199,7 +199,7 @@ class dbal_mysqli extends dbal
$this->query_result = $cache->sql_save($query, $this->query_result, $cache_ttl);
}
}
- else if (defined('DEBUG_EXTRA'))
+ else if (defined('DEBUG'))
{
$this->sql_report('fromcache', $query);
}
diff --git a/phpBB/includes/db/oracle.php b/phpBB/includes/db/oracle.php
index de2729e973..6d9339b2d8 100644
--- a/phpBB/includes/db/oracle.php
+++ b/phpBB/includes/db/oracle.php
@@ -236,7 +236,7 @@ class dbal_oracle extends dbal
global $cache;
// EXPLAIN only in extra debug mode
- if (defined('DEBUG_EXTRA'))
+ if (defined('DEBUG'))
{
$this->sql_report('start', $query);
}
@@ -413,7 +413,7 @@ class dbal_oracle extends dbal
}
}
- if (defined('DEBUG_EXTRA'))
+ if (defined('DEBUG'))
{
$this->sql_report('stop', $query);
}
@@ -428,7 +428,7 @@ class dbal_oracle extends dbal
$this->open_queries[(int) $this->query_result] = $this->query_result;
}
}
- else if (defined('DEBUG_EXTRA'))
+ else if (defined('DEBUG'))
{
$this->sql_report('fromcache', $query);
}
diff --git a/phpBB/includes/db/postgres.php b/phpBB/includes/db/postgres.php
index f0a4a7a7a2..8dfbfc3b60 100644
--- a/phpBB/includes/db/postgres.php
+++ b/phpBB/includes/db/postgres.php
@@ -194,7 +194,7 @@ class dbal_postgres extends dbal
global $cache;
// EXPLAIN only in extra debug mode
- if (defined('DEBUG_EXTRA'))
+ if (defined('DEBUG'))
{
$this->sql_report('start', $query);
}
@@ -210,7 +210,7 @@ class dbal_postgres extends dbal
$this->sql_error($query);
}
- if (defined('DEBUG_EXTRA'))
+ if (defined('DEBUG'))
{
$this->sql_report('stop', $query);
}
@@ -225,7 +225,7 @@ class dbal_postgres extends dbal
$this->open_queries[(int) $this->query_result] = $this->query_result;
}
}
- else if (defined('DEBUG_EXTRA'))
+ else if (defined('DEBUG'))
{
$this->sql_report('fromcache', $query);
}
diff --git a/phpBB/includes/db/sqlite.php b/phpBB/includes/db/sqlite.php
index 2cf55b07e2..5fc89ced18 100644
--- a/phpBB/includes/db/sqlite.php
+++ b/phpBB/includes/db/sqlite.php
@@ -112,7 +112,7 @@ class dbal_sqlite extends dbal
global $cache;
// EXPLAIN only in extra debug mode
- if (defined('DEBUG_EXTRA'))
+ if (defined('DEBUG'))
{
$this->sql_report('start', $query);
}
@@ -127,7 +127,7 @@ class dbal_sqlite extends dbal
$this->sql_error($query);
}
- if (defined('DEBUG_EXTRA'))
+ if (defined('DEBUG'))
{
$this->sql_report('stop', $query);
}
@@ -142,7 +142,7 @@ class dbal_sqlite extends dbal
$this->open_queries[(int) $this->query_result] = $this->query_result;
}
}
- else if (defined('DEBUG_EXTRA'))
+ else if (defined('DEBUG'))
{
$this->sql_report('fromcache', $query);
}
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index 39642acf6d..4e26d2c642 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -4239,12 +4239,12 @@ function msg_handler($errno, $msg_text, $errfile, $errline)
$log_text .= '<br /><br />BACKTRACE<br />' . $backtrace;
}
- if (defined('IN_INSTALL') || defined('DEBUG_EXTRA') || isset($auth) && $auth->acl_get('a_'))
+ if (defined('IN_INSTALL') || defined('DEBUG') || isset($auth) && $auth->acl_get('a_'))
{
$msg_text = $log_text;
}
- if ((defined('DEBUG') || defined('IN_CRON') || defined('IMAGE_OUTPUT')) && isset($db))
+ if ((defined('IN_CRON') || defined('IMAGE_OUTPUT')) && isset($db))
{
// let's avoid loops
$db->sql_return_on_error(true);
@@ -5308,14 +5308,14 @@ function page_footer($run_cron = true)
$mtime = explode(' ', microtime());
$totaltime = $mtime[0] + $mtime[1] - $starttime;
- if ($request->variable('explain', false) && $auth->acl_get('a_') && defined('DEBUG_EXTRA') && method_exists($db, 'sql_report'))
+ if ($request->variable('explain', false) && $auth->acl_get('a_') && defined('DEBUG') && method_exists($db, 'sql_report'))
{
$db->sql_report('display');
}
$debug_output = sprintf('Time : %.3fs | ' . $db->sql_num_queries() . ' Queries | GZIP : ' . (($config['gzip_compress'] && @extension_loaded('zlib')) ? 'On' : 'Off') . (($user->load) ? ' | Load : ' . $user->load : ''), $totaltime);
- if ($auth->acl_get('a_') && defined('DEBUG_EXTRA'))
+ if ($auth->acl_get('a_') && defined('DEBUG'))
{
if (function_exists('memory_get_peak_usage'))
{
diff --git a/phpBB/includes/functions_acp.php b/phpBB/includes/functions_acp.php
index 11cc1f6dd8..2f3fd7bac0 100644
--- a/phpBB/includes/functions_acp.php
+++ b/phpBB/includes/functions_acp.php
@@ -145,14 +145,14 @@ function adm_page_footer($copyright_html = true)
$mtime = explode(' ', microtime());
$totaltime = $mtime[0] + $mtime[1] - $starttime;
- if ($request->variable('explain', false) && $auth->acl_get('a_') && defined('DEBUG_EXTRA') && method_exists($db, 'sql_report'))
+ if ($request->variable('explain', false) && $auth->acl_get('a_') && defined('DEBUG') && method_exists($db, 'sql_report'))
{
$db->sql_report('display');
}
$debug_output = sprintf('Time : %.3fs | ' . $db->sql_num_queries() . ' Queries | GZIP : ' . (($config['gzip_compress']) ? 'On' : 'Off') . (($user->load) ? ' | Load : ' . $user->load : ''), $totaltime);
- if ($auth->acl_get('a_') && defined('DEBUG_EXTRA'))
+ if ($auth->acl_get('a_') && defined('DEBUG'))
{
if (function_exists('memory_get_peak_usage'))
{
diff --git a/phpBB/includes/functions_install.php b/phpBB/includes/functions_install.php
index 3421c90c88..7a799993db 100644
--- a/phpBB/includes/functions_install.php
+++ b/phpBB/includes/functions_install.php
@@ -528,12 +528,10 @@ function phpbb_create_config_file_data($data, $dbms, $debug = false, $debug_test
if ($debug)
{
$config_data .= "@define('DEBUG', true);\n";
- $config_data .= "@define('DEBUG_EXTRA', true);\n";
}
else
{
$config_data .= "// @define('DEBUG', true);\n";
- $config_data .= "// @define('DEBUG_EXTRA', true);\n";
}
if ($debug_test)
diff --git a/phpBB/includes/functions_upload.php b/phpBB/includes/functions_upload.php
index d4c6b42cf4..b467aa93d1 100644
--- a/phpBB/includes/functions_upload.php
+++ b/phpBB/includes/functions_upload.php
@@ -566,10 +566,11 @@ class fileupload
*/
function form_upload($form_name)
{
- global $user;
+ global $user, $request;
- unset($_FILES[$form_name]['local_mode']);
- $file = new filespec($_FILES[$form_name], $this);
+ $upload = $request->file($form_name);
+ unset($upload['local_mode']);
+ $file = new filespec($upload, $this);
if ($file->init_error)
{
@@ -578,9 +579,9 @@ class fileupload
}
// Error array filled?
- if (isset($_FILES[$form_name]['error']))
+ if (isset($upload['error']))
{
- $error = $this->assign_internal_error($_FILES[$form_name]['error']);
+ $error = $this->assign_internal_error($upload['error']);
if ($error !== false)
{
@@ -590,7 +591,7 @@ class fileupload
}
// Check if empty file got uploaded (not catched by is_uploaded_file)
- if (isset($_FILES[$form_name]['size']) && $_FILES[$form_name]['size'] == 0)
+ if (isset($upload['size']) && $upload['size'] == 0)
{
$file->error[] = $user->lang[$this->error_prefix . 'EMPTY_FILEUPLOAD'];
return $file;
@@ -631,17 +632,17 @@ class fileupload
*/
function local_upload($source_file, $filedata = false)
{
- global $user;
+ global $user, $request;
- $form_name = 'local';
+ $upload = array();
- $_FILES[$form_name]['local_mode'] = true;
- $_FILES[$form_name]['tmp_name'] = $source_file;
+ $upload['local_mode'] = true;
+ $upload['tmp_name'] = $source_file;
if ($filedata === false)
{
- $_FILES[$form_name]['name'] = utf8_basename($source_file);
- $_FILES[$form_name]['size'] = 0;
+ $upload['name'] = utf8_basename($source_file);
+ $upload['size'] = 0;
$mimetype = '';
if (function_exists('mime_content_type'))
@@ -655,16 +656,16 @@ class fileupload
$mimetype = 'application/octetstream';
}
- $_FILES[$form_name]['type'] = $mimetype;
+ $upload['type'] = $mimetype;
}
else
{
- $_FILES[$form_name]['name'] = $filedata['realname'];
- $_FILES[$form_name]['size'] = $filedata['size'];
- $_FILES[$form_name]['type'] = $filedata['type'];
+ $upload['name'] = $filedata['realname'];
+ $upload['size'] = $filedata['size'];
+ $upload['type'] = $filedata['type'];
}
- $file = new filespec($_FILES[$form_name], $this);
+ $file = new filespec($upload, $this);
if ($file->init_error)
{
@@ -672,9 +673,9 @@ class fileupload
return $file;
}
- if (isset($_FILES[$form_name]['error']))
+ if (isset($upload['error']))
{
- $error = $this->assign_internal_error($_FILES[$form_name]['error']);
+ $error = $this->assign_internal_error($upload['error']);
if ($error !== false)
{
@@ -709,6 +710,7 @@ class fileupload
}
$this->common_checks($file);
+ $request->overwrite('local', $upload, phpbb_request_interface::FILES);
return $file;
}
@@ -1001,7 +1003,10 @@ class fileupload
*/
function is_valid($form_name)
{
- return (isset($_FILES[$form_name]) && $_FILES[$form_name]['name'] != 'none') ? true : false;
+ global $request;
+ $upload = $request->file($form_name);
+
+ return (!empty($upload) && $upload['name'] !== 'none');
}
diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php
index 0e347fe477..8f9c9198f4 100644
--- a/phpBB/includes/functions_user.php
+++ b/phpBB/includes/functions_user.php
@@ -2140,13 +2140,14 @@ function avatar_remote($data, &$error)
*/
function avatar_upload($data, &$error)
{
- global $phpbb_root_path, $config, $db, $user, $phpEx;
+ global $phpbb_root_path, $config, $db, $user, $phpEx, $request;
// Init upload class
include_once($phpbb_root_path . 'includes/functions_upload.' . $phpEx);
$upload = new fileupload('AVATAR_', array('jpg', 'jpeg', 'gif', 'png'), $config['avatar_filesize'], $config['avatar_min_width'], $config['avatar_min_height'], $config['avatar_max_width'], $config['avatar_max_height'], (isset($config['mime_triggers']) ? explode('|', $config['mime_triggers']) : false));
- if (!empty($_FILES['uploadfile']['name']))
+ $uploadfile = $request->file('uploadfile');
+ if (!empty($uploadfile['name']))
{
$file = $upload->form_upload('uploadfile');
}
@@ -2369,7 +2370,7 @@ function avatar_get_dimensions($avatar, $avatar_type, &$error, $current_x = 0, $
*/
function avatar_process_user(&$error, $custom_userdata = false, $can_upload = null)
{
- global $config, $phpbb_root_path, $auth, $user, $db;
+ global $config, $phpbb_root_path, $auth, $user, $db, $request;
$data = array(
'uploadurl' => request_var('uploadurl', ''),
@@ -2411,7 +2412,8 @@ function avatar_process_user(&$error, $custom_userdata = false, $can_upload = nu
$can_upload = ($config['allow_avatar_upload'] && file_exists($phpbb_root_path . $config['avatar_path']) && phpbb_is_writable($phpbb_root_path . $config['avatar_path']) && $change_avatar && (@ini_get('file_uploads') || strtolower(@ini_get('file_uploads')) == 'on')) ? true : false;
}
- if ((!empty($_FILES['uploadfile']['name']) || $data['uploadurl']) && $can_upload)
+ $uploadfile = $request->file('uploadfile');
+ if ((!empty($uploadfile['name']) || $data['uploadurl']) && $can_upload)
{
list($sql_ary['user_avatar_type'], $sql_ary['user_avatar'], $sql_ary['user_avatar_width'], $sql_ary['user_avatar_height']) = avatar_upload($data, $error);
}
diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php
index 6695047b56..1cd2a46fa1 100644
--- a/phpBB/includes/message_parser.php
+++ b/phpBB/includes/message_parser.php
@@ -1363,13 +1363,14 @@ class parse_message extends bbcode_firstpass
*/
function parse_attachments($form_name, $mode, $forum_id, $submit, $preview, $refresh, $is_message = false)
{
- global $config, $auth, $user, $phpbb_root_path, $phpEx, $db;
+ global $config, $auth, $user, $phpbb_root_path, $phpEx, $db, $request;
$error = array();
$num_attachments = sizeof($this->attachment_data);
$this->filename_data['filecomment'] = utf8_normalize_nfc(request_var('filecomment', '', true));
- $upload_file = (isset($_FILES[$form_name]) && $_FILES[$form_name]['name'] != 'none' && trim($_FILES[$form_name]['name'])) ? true : false;
+ $upload = $request->file($form_name);
+ $upload_file = (!empty($upload) && $upload['name'] !== 'none' && trim($upload['name']));
$add_file = (isset($_POST['add_file'])) ? true : false;
$delete_file = (isset($_POST['delete_file'])) ? true : false;
diff --git a/phpBB/includes/request/interface.php b/phpBB/includes/request/interface.php
index afd53002e3..741db35917 100644
--- a/phpBB/includes/request/interface.php
+++ b/phpBB/includes/request/interface.php
@@ -30,6 +30,7 @@ interface phpbb_request_interface
const REQUEST = 2;
const COOKIE = 3;
const SERVER = 4;
+ const FILES = 5;
/**#@-*/
/**
diff --git a/phpBB/includes/request/request.php b/phpBB/includes/request/request.php
index a06fc0d85d..ae3c526d89 100644
--- a/phpBB/includes/request/request.php
+++ b/phpBB/includes/request/request.php
@@ -34,6 +34,7 @@ class phpbb_request implements phpbb_request_interface
phpbb_request_interface::REQUEST => '_REQUEST',
phpbb_request_interface::COOKIE => '_COOKIE',
phpbb_request_interface::SERVER => '_SERVER',
+ phpbb_request_interface::FILES => '_FILES',
);
/**
@@ -269,6 +270,19 @@ class phpbb_request implements phpbb_request_interface
}
/**
+ * Shortcut method to retrieve $_FILES variables
+ *
+ * @param string $form_name The name of the file input form element
+ *
+ * @return array The uploaded file's information or an empty array if the
+ * variable does not exist in _FILES.
+ */
+ public function file($form_name)
+ {
+ return $this->variable($form_name, array('name' => 'none'), false, phpbb_request_interface::FILES);
+ }
+
+ /**
* Checks whether a certain variable was sent via POST.
* To make sure that a request was sent using POST you should call this function
* on at least one variable.
diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php
index 257ffb07f6..ee8a4094c7 100644
--- a/phpBB/includes/session.php
+++ b/phpBB/includes/session.php
@@ -474,7 +474,7 @@ class phpbb_session
else
{
// Added logging temporarly to help debug bugs...
- if (defined('DEBUG_EXTRA') && $this->data['user_id'] != ANONYMOUS)
+ if (defined('DEBUG') && $this->data['user_id'] != ANONYMOUS)
{
if ($referer_valid)
{
diff --git a/phpBB/includes/template/filter.php b/phpBB/includes/template/filter.php
index abee32c8f7..66d28242a3 100644
--- a/phpBB/includes/template/filter.php
+++ b/phpBB/includes/template/filter.php
@@ -362,6 +362,43 @@ class phpbb_template_filter extends php_user_filter
}
/**
+ * Parse paths of the form {FOO}/a/{BAR}/b
+ *
+ * Note: this method assumes at least one variable in the path, this should
+ * be checked before this method is called.
+ *
+ * @param string $path The path to parse
+ * @param string $include_type The type of template function to call
+ * @return string An appropriately formatted string to include in the
+ * template or an empty string if an expression like S_FIRST_ROW was
+ * incorrectly used
+ */
+ private function parse_dynamic_path($path, $include_type)
+ {
+ $matches = array();
+ $replace = array();
+ $is_expr = true;
+
+ preg_match_all('#\{((?:' . self::REGEX_NS . '\.)*)(\$)?(' . self::REGEX_VAR . ')\}#', $path, $matches);
+ foreach ($matches[0] as $var_str)
+ {
+ $tmp_is_expr = false;
+ $var = $this->get_varref($var_str, $tmp_is_expr);
+ $is_expr = $is_expr && $tmp_is_expr;
+ $replace[] = "' . $var . '";
+ }
+
+ if (!$is_expr)
+ {
+ return " \$_template->$include_type('" . str_replace($matches[0], $replace, $path) . "', true);";
+ }
+ else
+ {
+ return '';
+ }
+ }
+
+ /**
* Compile variables
*
* @param string $text_blocks Variable reference in source template
@@ -774,15 +811,9 @@ class phpbb_template_filter extends php_user_filter
private function compile_tag_include($tag_args)
{
// Process dynamic includes
- if ($tag_args[0] == '{')
+ if (strpos($tag_args, '{') !== false)
{
- $var = $this->get_varref($tag_args, $is_expr);
-
- // Make sure someone didn't try to include S_FIRST_ROW or similar
- if (!$is_expr)
- {
- return "if (isset($var)) { \$_template->_tpl_include($var); }";
- }
+ return $this->parse_dynamic_path($tag_args, '_tpl_include');
}
return "\$_template->_tpl_include('$tag_args');";
@@ -796,6 +827,11 @@ class phpbb_template_filter extends php_user_filter
*/
private function compile_tag_include_php($tag_args)
{
+ if (strpos($tag_args, '{') !== false)
+ {
+ return $this->parse_dynamic_path($tag_args, '_php_include');
+ }
+
return "\$_template->_php_include('$tag_args');";
}
@@ -883,14 +919,9 @@ class phpbb_template_filter extends php_user_filter
private function compile_tag_include_js($tag_args)
{
// Process dynamic includes
- if ($tag_args[0] == '{')
+ if (strpos($tag_args, '{') !== false)
{
- $var = $this->get_varref($tag_args, $is_expr);
- if (!$is_expr)
- {
- return " \$_template->_js_include($var, true);";
- }
- return '';
+ return $this->parse_dynamic_path($tag_args, '_js_include');
}
// Locate file
diff --git a/phpBB/includes/template/template.php b/phpBB/includes/template/template.php
index 5d3ce4c82b..8a7dc6b2f3 100644
--- a/phpBB/includes/template/template.php
+++ b/phpBB/includes/template/template.php
@@ -250,7 +250,7 @@ class phpbb_template
* If template cache is writable the compiled php code will be stored
* on filesystem and template will not be subsequently recompiled.
* If template cache is not writable template source will be recompiled
- * every time it is needed. DEBUG_EXTRA define and load_tplcompile
+ * every time it is needed. DEBUG define and load_tplcompile
* configuration setting may be used to force templates to be always
* recompiled.
*
@@ -268,7 +268,7 @@ class phpbb_template
{
$output_file = $this->_compiled_file_for_handle($handle);
- $recompile = defined('DEBUG_EXTRA') ||
+ $recompile = defined('DEBUG') ||
!file_exists($output_file) ||
@filesize($output_file) === 0;
@@ -538,7 +538,11 @@ class phpbb_template
// Locate file
if ($locate)
{
- $file = $this->locator->get_first_file_location(array($file), true, true);
+ $located = $this->locator->get_first_file_location(array($file), false, true);
+ if ($located)
+ {
+ $file = $located;
+ }
}
else if ($relative)
{
diff --git a/phpBB/includes/ucp/ucp_groups.php b/phpBB/includes/ucp/ucp_groups.php
index 65ab92e78e..9652986cf2 100644
--- a/phpBB/includes/ucp/ucp_groups.php
+++ b/phpBB/includes/ucp/ucp_groups.php
@@ -513,7 +513,8 @@ class ucp_groups
$data['height'] = request_var('height', '');
$delete = request_var('delete', '');
- if (!empty($_FILES['uploadfile']['tmp_name']) || $data['uploadurl'] || $data['remotelink'])
+ $uploadfile = $request->file('uploadfile');
+ if (!empty($uploadfile['tmp_name']) || $data['uploadurl'] || $data['remotelink'])
{
// Avatar stuff
$var_ary = array(
@@ -527,7 +528,7 @@ class ucp_groups
{
$data['user_id'] = "g$group_id";
- if ((!empty($_FILES['uploadfile']['tmp_name']) || $data['uploadurl']) && $can_upload)
+ if ((!empty($uploadfile['tmp_name']) || $data['uploadurl']) && $can_upload)
{
list($submit_ary['avatar_type'], $submit_ary['avatar'], $submit_ary['avatar_width'], $submit_ary['avatar_height']) = avatar_upload($data, $error);
}
diff --git a/phpBB/includes/user.php b/phpBB/includes/user.php
index 93557f3558..9ddd806b27 100644
--- a/phpBB/includes/user.php
+++ b/phpBB/includes/user.php
@@ -162,8 +162,8 @@ class phpbb_user extends phpbb_session
// We include common language file here to not load it every time a custom language file is included
$lang = &$this->lang;
- // Do not suppress error if in DEBUG_EXTRA mode
- $include_result = (defined('DEBUG_EXTRA')) ? (include $this->lang_path . $this->lang_name . "/common.$phpEx") : (@include $this->lang_path . $this->lang_name . "/common.$phpEx");
+ // Do not suppress error if in DEBUG mode
+ $include_result = (defined('DEBUG')) ? (include $this->lang_path . $this->lang_name . "/common.$phpEx") : (@include $this->lang_path . $this->lang_name . "/common.$phpEx");
if ($include_result === false)
{
@@ -252,7 +252,7 @@ class phpbb_user extends phpbb_session
// Disable board if the install/ directory is still present
// For the brave development army we do not care about this, else we need to comment out this everytime we develop locally
- if (!defined('DEBUG_EXTRA') && !defined('ADMIN_START') && !defined('IN_INSTALL') && !defined('IN_LOGIN') && file_exists($phpbb_root_path . 'install') && !is_file($phpbb_root_path . 'install'))
+ if (!defined('DEBUG') && !defined('ADMIN_START') && !defined('IN_INSTALL') && !defined('IN_LOGIN') && file_exists($phpbb_root_path . 'install') && !is_file($phpbb_root_path . 'install'))
{
// Adjust the message slightly according to the permissions
if ($auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_'))
@@ -618,8 +618,8 @@ class phpbb_user extends phpbb_session
return;
}
- // Do not suppress error if in DEBUG_EXTRA mode
- $include_result = (defined('DEBUG_EXTRA')) ? (include $language_filename) : (@include $language_filename);
+ // Do not suppress error if in DEBUG mode
+ $include_result = (defined('DEBUG')) ? (include $language_filename) : (@include $language_filename);
if ($include_result === false)
{