diff options
Diffstat (limited to 'phpBB/phpbb')
34 files changed, 252 insertions, 81 deletions
diff --git a/phpBB/phpbb/captcha/gd.php b/phpBB/phpbb/captcha/gd.php index 652df28f8a..e9538439c6 100644 --- a/phpBB/phpbb/captcha/gd.php +++ b/phpBB/phpbb/captcha/gd.php @@ -97,13 +97,12 @@ class gd if ($config['captcha_gd_3d_noise']) { - $xoffset = mt_rand(0,9); $noise_bitmaps = $this->captcha_noise_bg_bitmaps(); for ($i = 0; $i < $code_len; ++$i) { $noise[$i] = new char_cube3d($noise_bitmaps, mt_rand(1, sizeof($noise_bitmaps['data']))); - list($min, $max) = $noise[$i]->range(); + $noise[$i]->range(); //$box = $noise[$i]->dimensions($sizes[$i]); } $xoffset = 0; @@ -151,8 +150,6 @@ class gd */ function wave($img) { - global $config; - $period_x = mt_rand(12,18); $period_y = mt_rand(7,14); $amp_x = mt_rand(5,10); diff --git a/phpBB/phpbb/captcha/gd_wave.php b/phpBB/phpbb/captcha/gd_wave.php index d48fc753a5..f2ec4137d2 100644 --- a/phpBB/phpbb/captcha/gd_wave.php +++ b/phpBB/phpbb/captcha/gd_wave.php @@ -23,8 +23,6 @@ class gd_wave function execute($code, $seed) { - global $starttime; - // seed the random generator mt_srand($seed); @@ -77,7 +75,6 @@ class gd_wave // TODO $background = imagecolorallocate($img, mt_rand(155, 255), mt_rand(155, 255), mt_rand(155, 255)); imagefill($img, 0, 0, $background); - $black = imagecolorallocate($img, 0, 0, 0); $random = array(); $fontcolors = array(); @@ -155,7 +152,7 @@ class gd_wave // rather than recalculating from absolute coordinates // What we cache into the $img_buffer contains the raised text coordinates. $img_pos_prev = $img_buffer[0][0] = array($box['upper_left']['x'], $box['upper_left']['y']); - $cur_height = $prev_height = $this->wave_height(0, 0, $subdivision_factor); + $prev_height = $this->wave_height(0, 0, $subdivision_factor); $full_x = $plane_x * $subdivision_factor; $full_y = $plane_y * $subdivision_factor; diff --git a/phpBB/phpbb/captcha/plugins/captcha_abstract.php b/phpBB/phpbb/captcha/plugins/captcha_abstract.php index b29f144f97..82b08704ff 100644 --- a/phpBB/phpbb/captcha/plugins/captcha_abstract.php +++ b/phpBB/phpbb/captcha/plugins/captcha_abstract.php @@ -34,7 +34,7 @@ abstract class captcha_abstract function init($type) { - global $config, $db, $user, $request; + global $config, $request; // read input $this->confirm_id = $request->variable('confirm_id', ''); @@ -56,8 +56,6 @@ abstract class captcha_abstract function execute_demo() { - global $user; - $this->code = gen_rand_string_friendly(mt_rand(CAPTCHA_MIN_CHARS, CAPTCHA_MAX_CHARS)); $this->seed = hexdec(substr(unique_id(), 4, 10)); @@ -117,7 +115,7 @@ abstract class captcha_abstract function get_demo_template($id) { - global $config, $user, $template, $request, $phpbb_admin_path, $phpEx; + global $config, $template, $request, $phpbb_admin_path, $phpEx; $variables = ''; @@ -153,7 +151,7 @@ abstract class captcha_abstract function garbage_collect($type) { - global $db, $config; + global $db; $sql = 'SELECT DISTINCT c.session_id FROM ' . CONFIRM_TABLE . ' c @@ -193,7 +191,7 @@ abstract class captcha_abstract function validate() { - global $config, $db, $user; + global $user; if (!$user->is_setup()) { diff --git a/phpBB/phpbb/captcha/plugins/gd.php b/phpBB/phpbb/captcha/plugins/gd.php index 1727dcc1bb..831e5bcfdf 100644 --- a/phpBB/phpbb/captcha/plugins/gd.php +++ b/phpBB/phpbb/captcha/plugins/gd.php @@ -53,18 +53,11 @@ class gd extends captcha_abstract function acp_page($id, &$module) { - global $db, $user, $auth, $template, $phpbb_log, $request; - global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx; + global $user, $template, $phpbb_log, $request; + global $config; $user->add_lang('acp/board'); - $config_vars = array( - 'enable_confirm' => 'REG_ENABLE', - 'enable_post_confirm' => 'POST_ENABLE', - 'confirm_refresh' => 'CONFIRM_REFRESH', - 'captcha_gd' => 'CAPTCHA_GD', - ); - $module->tpl_name = 'captcha_gd_acp'; $module->page_title = 'ACP_VC_SETTINGS'; $form_key = 'acp_captcha'; diff --git a/phpBB/phpbb/captcha/plugins/gd_wave.php b/phpBB/phpbb/captcha/plugins/gd_wave.php index e1d44df778..bde46f8815 100644 --- a/phpBB/phpbb/captcha/plugins/gd_wave.php +++ b/phpBB/phpbb/captcha/plugins/gd_wave.php @@ -35,7 +35,7 @@ class gd_wave extends captcha_abstract function acp_page($id, &$module) { - global $config, $db, $template, $user; + global $user; trigger_error($user->lang['CAPTCHA_NO_OPTIONS'] . adm_back_link($module->u_action)); } diff --git a/phpBB/phpbb/composer.json b/phpBB/phpbb/composer.json index 8241091dc1..758125234f 100644 --- a/phpBB/phpbb/composer.json +++ b/phpBB/phpbb/composer.json @@ -23,5 +23,10 @@ }, "require": { "php": ">=5.4" - } + }, + "extra": { + "branch-alias": { + "dev-master": "3.2.x-dev" + } + } } diff --git a/phpBB/phpbb/db/driver/driver.php b/phpBB/phpbb/db/driver/driver.php index 5f06cb08fc..30cb667344 100644 --- a/phpBB/phpbb/db/driver/driver.php +++ b/phpBB/phpbb/db/driver/driver.php @@ -1012,7 +1012,7 @@ abstract class driver implements driver_interface */ function sql_report($mode, $query = '') { - global $cache, $starttime, $phpbb_root_path, $phpbb_path_helper, $user; + global $cache, $starttime, $phpbb_root_path, $phpbb_path_helper; global $request; if (is_object($request) && !$request->variable('explain', false)) diff --git a/phpBB/phpbb/db/driver/oracle.php b/phpBB/phpbb/db/driver/oracle.php index 89e1b68aac..54238a15ef 100644 --- a/phpBB/phpbb/db/driver/oracle.php +++ b/phpBB/phpbb/db/driver/oracle.php @@ -84,8 +84,6 @@ class oracle extends \phpbb\db\driver\driver * but I assume its because the Oracle extension provides a direct method to access it * without a query. */ - - $use_cache = false; /* global $cache; diff --git a/phpBB/phpbb/db/extractor/oracle_extractor.php b/phpBB/phpbb/db/extractor/oracle_extractor.php index 05f7b8ac95..79a991889b 100644 --- a/phpBB/phpbb/db/extractor/oracle_extractor.php +++ b/phpBB/phpbb/db/extractor/oracle_extractor.php @@ -192,8 +192,6 @@ class oracle_extractor extends base_extractor $ary_name[$i] = ocicolumnname($result, $i + 1); } - $sql_data = ''; - while ($row = $this->db->sql_fetchrow($result)) { $schema_vals = $schema_fields = array(); diff --git a/phpBB/phpbb/db/migration/data/v30x/release_3_0_5_rc1.php b/phpBB/phpbb/db/migration/data/v30x/release_3_0_5_rc1.php index 9f6e3efb91..084d00a13a 100644 --- a/phpBB/phpbb/db/migration/data/v30x/release_3_0_5_rc1.php +++ b/phpBB/phpbb/db/migration/data/v30x/release_3_0_5_rc1.php @@ -118,7 +118,7 @@ class release_3_0_5_rc1 extends container_aware_migration $result = $this->db->sql_query($sql); // Skip first row, this is our original auth option we want to preserve - $row = $this->db->sql_fetchrow($result); + $this->db->sql_fetchrow($result); while ($row = $this->db->sql_fetchrow($result)) { diff --git a/phpBB/phpbb/db/migration/data/v31x/update_custom_bbcodes_with_idn.php b/phpBB/phpbb/db/migration/data/v31x/update_custom_bbcodes_with_idn.php index 854ed1f568..14b7b7b0f6 100644 --- a/phpBB/phpbb/db/migration/data/v31x/update_custom_bbcodes_with_idn.php +++ b/phpBB/phpbb/db/migration/data/v31x/update_custom_bbcodes_with_idn.php @@ -45,7 +45,6 @@ class update_custom_bbcodes_with_idn extends \phpbb\db\migration\migration $sql_ary = array(); while ($row = $this->db->sql_fetchrow($result)) { - $data = array(); if (preg_match('/(URL|LOCAL_URL|RELATIVE_URL)/', $row['bbcode_match'])) { $data = $bbcodes->build_regexp($row['bbcode_match'], $row['bbcode_tpl']); diff --git a/phpBB/phpbb/db/migration/data/v31x/v317pl1.php b/phpBB/phpbb/db/migration/data/v31x/v317pl1.php new file mode 100644 index 0000000000..2e1b0e9b9d --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v31x/v317pl1.php @@ -0,0 +1,31 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v31x; + +class v317pl1 extends \phpbb\db\migration\migration +{ + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v31x\v317', + ); + } + + public function update_data() + { + return array( + array('config.update', array('version', '3.1.7-pl1')), + ); + } +} diff --git a/phpBB/phpbb/db/migrator.php b/phpBB/phpbb/db/migrator.php index a809bc14f9..d91860949a 100644 --- a/phpBB/phpbb/db/migrator.php +++ b/phpBB/phpbb/db/migrator.php @@ -535,7 +535,7 @@ class migrator } // Reverse the step that was run - $result = $this->run_step($reverse_step, false, !$revert); + $this->run_step($reverse_step, false, !$revert); } // rethrow the exception diff --git a/phpBB/phpbb/db/tools/tools.php b/phpBB/phpbb/db/tools/tools.php index 1d7b2ddfff..f06871a1d7 100644 --- a/phpBB/phpbb/db/tools/tools.php +++ b/phpBB/phpbb/db/tools/tools.php @@ -1116,7 +1116,7 @@ class tools implements tools_interface } // Get type - list($column_type, $orig_column_type) = $this->get_column_type($column_data[0]); + list($column_type) = $this->get_column_type($column_data[0]); // Adjust default value if db-dependent specified if (is_array($column_data[1])) diff --git a/phpBB/phpbb/file_downloader.php b/phpBB/phpbb/file_downloader.php index 462b87ca51..ab9505a14c 100644 --- a/phpBB/phpbb/file_downloader.php +++ b/phpBB/phpbb/file_downloader.php @@ -42,7 +42,7 @@ class file_downloader $this->error_number = 0; $this->error_string = ''; - if ($socket = @fsockopen($host, $port, $this->error_number, $this->error_string, $timeout)) + if ($socket = @fsockopen(($port == 443 ? 'tls://' : '') . $host, $port, $this->error_number, $this->error_string, $timeout)) { @fputs($socket, "GET $directory/$filename HTTP/1.0\r\n"); @fputs($socket, "HOST: $host\r\n"); diff --git a/phpBB/phpbb/files/types/remote.php b/phpBB/phpbb/files/types/remote.php index 4f4ce15c18..33cbfb00ae 100644 --- a/phpBB/phpbb/files/types/remote.php +++ b/phpBB/phpbb/files/types/remote.php @@ -97,7 +97,6 @@ class remote extends base $url['path'] = implode('', $url['path']); $upload_ary['name'] = utf8_basename($url['path']) . (($ext) ? '.' . $ext : ''); - $filename = $url['path']; $filesize = 0; $remote_max_filesize = $this->get_max_file_size(); diff --git a/phpBB/phpbb/install/console/command/install/config/validate.php b/phpBB/phpbb/install/console/command/install/config/validate.php index 19b6f99a8b..3bbbc23e34 100644 --- a/phpBB/phpbb/install/console/command/install/config/validate.php +++ b/phpBB/phpbb/install/console/command/install/config/validate.php @@ -117,7 +117,7 @@ class validate extends \phpbb\console\command\command try { - $config = $processor->processConfiguration($configuration, $config); + $processor->processConfiguration($configuration, $config); } catch (Exception $e) { diff --git a/phpBB/phpbb/install/controller/install.php b/phpBB/phpbb/install/controller/install.php index 8bf9062b08..b987d91c6a 100644 --- a/phpBB/phpbb/install/controller/install.php +++ b/phpBB/phpbb/install/controller/install.php @@ -19,7 +19,6 @@ use phpbb\install\helper\navigation\navigation_provider; use Symfony\Component\HttpFoundation\StreamedResponse; use Symfony\Component\HttpFoundation\Response; use phpbb\install\helper\iohandler\factory; -use phpbb\install\controller\helper; use phpbb\template\template; use phpbb\request\request_interface; use phpbb\install\installer; diff --git a/phpBB/phpbb/install/module/obtain_data/task/obtain_database_data.php b/phpBB/phpbb/install/module/obtain_data/task/obtain_database_data.php index f0e7f1f686..3458aab63e 100644 --- a/phpBB/phpbb/install/module/obtain_data/task/obtain_database_data.php +++ b/phpBB/phpbb/install/module/obtain_data/task/obtain_database_data.php @@ -76,7 +76,7 @@ class obtain_database_data extends \phpbb\install\task_base implements \phpbb\in { // Collect database data $dbms = $this->io_handler->get_input('dbms', ''); - $dbhost = $this->io_handler->get_input('dbhost', ''); + $dbhost = $this->io_handler->get_input('dbhost', '', true); $dbport = $this->io_handler->get_input('dbport', ''); $dbuser = $this->io_handler->get_input('dbuser', ''); $dbpasswd = $this->io_handler->get_input('dbpasswd', '', true); @@ -115,7 +115,7 @@ class obtain_database_data extends \phpbb\install\task_base implements \phpbb\in if ($use_request_data) { $dbms = $this->io_handler->get_input('dbms', ''); - $dbhost = $this->io_handler->get_input('dbhost', ''); + $dbhost = $this->io_handler->get_input('dbhost', '', true); $dbport = $this->io_handler->get_input('dbport', ''); $dbuser = $this->io_handler->get_input('dbuser', ''); $dbname = $this->io_handler->get_input('dbname', ''); diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index f0ba120625..ee002c560a 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -229,8 +229,8 @@ class log implements \phpbb\log\log_interface } $sql_ary = array( - 'user_id' => $user_id ? (int) $user_id : ANONYMOUS, - 'log_ip' => empty($log_ip) ? '' : $log_ip, + 'user_id' => !empty($user_id) ? $user_id : ANONYMOUS, + 'log_ip' => !empty($log_ip) ? $log_ip : '', 'log_time' => $log_time, 'log_operation' => $log_operation, ); @@ -420,7 +420,7 @@ class log implements \phpbb\log\log_interface $this->entry_count = 0; $this->last_page_offset = $offset; - $post_id_list = $topic_id_list = $reportee_id_list = array(); + $topic_id_list = $reportee_id_list = array(); $profile_url = ($this->get_is_admin() && $this->phpbb_admin_path) ? append_sid("{$this->phpbb_admin_path}index.{$this->php_ext}", 'i=users&mode=overview') : append_sid("{$this->phpbb_root_path}memberlist.{$this->php_ext}", 'mode=viewprofile'); diff --git a/phpBB/phpbb/report/report_handler_post.php b/phpBB/phpbb/report/report_handler_post.php index ce4ed67d27..5574a16dc0 100644 --- a/phpBB/phpbb/report/report_handler_post.php +++ b/phpBB/phpbb/report/report_handler_post.php @@ -66,7 +66,7 @@ class report_handler_post extends report_handler 'reported_post_enable_magic_url' => $this->report_data['enable_magic_url'], ); - $report_id = $this->create_report($report_data); + $this->create_report($report_data); $sql = 'UPDATE ' . POSTS_TABLE . ' SET post_reported = 1 diff --git a/phpBB/phpbb/request/type_cast_helper.php b/phpBB/phpbb/request/type_cast_helper.php index bc654e6182..96e66950ca 100644 --- a/phpBB/phpbb/request/type_cast_helper.php +++ b/phpBB/phpbb/request/type_cast_helper.php @@ -172,7 +172,6 @@ class type_cast_helper implements \phpbb\request\type_cast_helper_interface } list($default_key, $default_value) = each($default); - $value_type = gettype($default_value); $key_type = gettype($default_key); $_var = $var; diff --git a/phpBB/phpbb/search/fulltext_native.php b/phpBB/phpbb/search/fulltext_native.php index 3a74955a18..521eebb7ee 100644 --- a/phpBB/phpbb/search/fulltext_native.php +++ b/phpBB/phpbb/search/fulltext_native.php @@ -352,9 +352,6 @@ class fulltext_native extends \phpbb\search\base $this->must_not_contain_ids = array(); $this->must_exclude_one_ids = array(); - $mode = ''; - $ignore_no_id = true; - foreach ($query as $word) { if (empty($word)) @@ -597,7 +594,6 @@ class fulltext_native extends \phpbb\search\base $id_ary = array(); $sql_where = array(); - $group_by = false; $m_num = 0; $w_num = 0; @@ -1328,7 +1324,6 @@ class fulltext_native extends \phpbb\search\base $match[] = '#\[\/?[a-z0-9\*\+\-]+(?:=.*?)?(?::[a-z])?(\:?[0-9a-z]{5,})\]#'; $min = $this->word_length['min']; - $max = $this->word_length['max']; $isset_min = $min - 1; @@ -1737,7 +1732,7 @@ class fulltext_native extends \phpbb\search\base protected function cleanup($text, $allowed_chars = null, $encoding = 'utf-8') { static $conv = array(), $conv_loaded = array(); - $words = $allow = array(); + $allow = array(); // Convert the text to UTF-8 $encoding = strtolower($encoding); diff --git a/phpBB/phpbb/search/fulltext_postgres.php b/phpBB/phpbb/search/fulltext_postgres.php index ab28fd2957..42425cbc6b 100644 --- a/phpBB/phpbb/search/fulltext_postgres.php +++ b/phpBB/phpbb/search/fulltext_postgres.php @@ -501,7 +501,6 @@ class fulltext_postgres extends \phpbb\search\base $sql_select = ($type == 'posts') ? 'p.post_id' : 'DISTINCT t.topic_id'; $sql_from = ($join_topic) ? TOPICS_TABLE . ' t, ' : ''; $field = ($type == 'posts') ? 'post_id' : 'topic_id'; - $sql_author = (sizeof($author_ary) == 1) ? ' = ' . $author_ary[0] : 'IN (' . implode(', ', $author_ary) . ')'; if (sizeof($author_ary) && $author_name) { @@ -526,7 +525,6 @@ class fulltext_postgres extends \phpbb\search\base $sql_where_options .= ($sort_days) ? ' AND p.post_time >= ' . (time() - ($sort_days * 86400)) : ''; $sql_where_options .= $sql_match_where; - $tmp_sql_match = array(); $sql_match = str_replace(',', " || ' ' ||", $sql_match); $tmp_sql_match = "to_tsvector ('" . $this->db->sql_escape($this->config['fulltext_postgres_ts_name']) . "', " . $sql_match . ") @@ to_tsquery ('" . $this->db->sql_escape($this->config['fulltext_postgres_ts_name']) . "', '" . $this->db->sql_escape($this->tsearch_query) . "')"; @@ -838,7 +836,7 @@ class fulltext_postgres extends \phpbb\search\base GROUP BY t.topic_id, $sort_by_sql[$sort_key]"; } - $result = $this->db->sql_query($sql_count); + $this->db->sql_query($sql_count); $result_count = (int) $this->db->sql_fetchfield('result_count'); if (!$result_count) diff --git a/phpBB/phpbb/search/fulltext_sphinx.php b/phpBB/phpbb/search/fulltext_sphinx.php index 372a2792cf..504065e8cd 100644 --- a/phpBB/phpbb/search/fulltext_sphinx.php +++ b/phpBB/phpbb/search/fulltext_sphinx.php @@ -404,7 +404,7 @@ class fulltext_sphinx $variable = $section->get_variable_by_name($key); if (!$variable) { - $variable = $section->create_variable($key, $value); + $section->create_variable($key, $value); } else { @@ -413,7 +413,7 @@ class fulltext_sphinx } else { - $variable = $section->create_variable($key, $value); + $section->create_variable($key, $value); } } } @@ -437,7 +437,6 @@ class fulltext_sphinx $match = array('#\sand\s#i', '#\sor\s#i', '#\snot\s#i', '#\+#', '#-#', '#\|#', '#@#'); $replace = array(' & ', ' | ', ' - ', ' +', ' -', ' |', ''); - $replacements = 0; $keywords = preg_replace($match, $replace, $keywords); $this->sphinx->SetMatchMode(SPH_MATCH_EXTENDED); } @@ -490,8 +489,6 @@ class fulltext_sphinx $id_ary = array(); - $join_topic = ($type != 'posts'); - // Sorting if ($type == 'topics') diff --git a/phpBB/phpbb/session.php b/phpBB/phpbb/session.php index 5575c22846..3f7146c59b 100644 --- a/phpBB/phpbb/session.php +++ b/phpBB/phpbb/session.php @@ -494,7 +494,7 @@ class session */ function session_create($user_id = false, $set_admin = false, $persist_login = false, $viewonline = true) { - global $SID, $_SID, $db, $config, $cache, $phpbb_root_path, $phpEx, $phpbb_container, $phpbb_dispatcher; + global $SID, $_SID, $db, $config, $cache, $phpbb_container, $phpbb_dispatcher; $this->data = array(); @@ -883,7 +883,7 @@ class session */ function session_kill($new_session = true) { - global $SID, $_SID, $db, $config, $phpbb_root_path, $phpEx, $phpbb_container, $phpbb_dispatcher; + global $SID, $_SID, $db, $phpbb_container, $phpbb_dispatcher; $sql = 'DELETE FROM ' . SESSIONS_TABLE . " WHERE session_id = '" . $db->sql_escape($this->session_id) . "' @@ -975,7 +975,7 @@ class session */ function session_gc() { - global $db, $config, $phpbb_root_path, $phpEx, $phpbb_container, $phpbb_dispatcher; + global $db, $config, $phpbb_container, $phpbb_dispatcher; $batch_size = 10; @@ -1226,7 +1226,7 @@ class session if ($banned && !$return) { - global $template, $phpbb_root_path, $phpEx; + global $phpbb_root_path, $phpEx; // If the session is empty we need to create a valid one... if (empty($this->session_id)) @@ -1403,7 +1403,7 @@ class session */ function set_login_key($user_id = false, $key = false, $user_ip = false) { - global $config, $db; + global $db; $user_id = ($user_id === false) ? $this->data['user_id'] : $user_id; $user_ip = ($user_ip === false) ? $this->ip : $user_ip; @@ -1413,7 +1413,7 @@ class session $sql_ary = array( 'key_id' => (string) md5($key_id), - 'last_ip' => (string) $this->ip, + 'last_ip' => (string) $user_ip, 'last_login' => (int) time() ); @@ -1450,7 +1450,7 @@ class session */ function reset_login_keys($user_id = false) { - global $config, $db; + global $db; $user_id = ($user_id === false) ? (int) $this->data['user_id'] : (int) $user_id; @@ -1574,7 +1574,7 @@ class session public function update_session_infos() { - global $db, $request; + global $config, $db, $request; // No need to update if it's a new session. Informations are already inserted by session_create() if (isset($this->data['session_created']) && $this->data['session_created']) diff --git a/phpBB/phpbb/template/twig/node/includejs.php b/phpBB/phpbb/template/twig/node/includejs.php index 0f67f9ff60..e77f2afeed 100644 --- a/phpBB/phpbb/template/twig/node/includejs.php +++ b/phpBB/phpbb/template/twig/node/includejs.php @@ -28,8 +28,6 @@ class includejs extends \phpbb\template\twig\node\includeasset */ protected function append_asset(\Twig_Compiler $compiler) { - $config = $this->environment->get_phpbb_config(); - $compiler ->raw("<script type=\"text/javascript\" src=\"' . ") ->raw("\$asset_file") diff --git a/phpBB/phpbb/textformatter/s9e/factory.php b/phpBB/phpbb/textformatter/s9e/factory.php index 63b23d2fd0..8c273c342e 100644 --- a/phpBB/phpbb/textformatter/s9e/factory.php +++ b/phpBB/phpbb/textformatter/s9e/factory.php @@ -23,6 +23,11 @@ use s9e\TextFormatter\Configurator\Items\UnsafeTemplate; class factory implements \phpbb\textformatter\cache_interface { /** + * @var \phpbb\textformatter\s9e\link_helper + */ + protected $link_helper; + + /** * @var \phpbb\cache\driver\driver_interface */ protected $cache; @@ -94,7 +99,7 @@ class factory implements \phpbb\textformatter\cache_interface ]{TEXT2}[/QUOTE]", 'size' => '[SIZE={FONTSIZE}]{TEXT}[/SIZE]', 'u' => '[U]{TEXT}[/U]', - 'url' => '[URL={URL;useContent}]{TEXT}[/URL]', + 'url' => '[URL={URL;useContent} $forceLookahead=true]{TEXT}[/URL]', ); /** @@ -133,12 +138,14 @@ class factory implements \phpbb\textformatter\cache_interface * @param \phpbb\cache\driver\driver_interface $cache * @param \phpbb\event\dispatcher_interface $dispatcher * @param \phpbb\config\config $config + * @param \phpbb\textformatter\s9e\link_helper $link_helper * @param string $cache_dir Path to the cache dir * @param string $cache_key_parser Cache key used for the parser * @param string $cache_key_renderer Cache key used for the renderer */ - public function __construct(\phpbb\textformatter\data_access $data_access, \phpbb\cache\driver\driver_interface $cache, \phpbb\event\dispatcher_interface $dispatcher, \phpbb\config\config $config, $cache_dir, $cache_key_parser, $cache_key_renderer) + public function __construct(\phpbb\textformatter\data_access $data_access, \phpbb\cache\driver\driver_interface $cache, \phpbb\event\dispatcher_interface $dispatcher, \phpbb\config\config $config, \phpbb\textformatter\s9e\link_helper $link_helper, $cache_dir, $cache_key_parser, $cache_key_renderer) { + $this->link_helper = $link_helper; $this->cache = $cache; $this->cache_dir = $cache_dir; $this->cache_key_parser = $cache_key_parser; @@ -332,8 +339,7 @@ class factory implements \phpbb\textformatter\cache_interface } // Load the magic links plugins. We do that after BBCodes so that they use the same tags - $configurator->plugins->load('Autoemail'); - $configurator->plugins->load('Autolink', array('matchWww' => true)); + $this->configure_autolink($configurator); // Register some vars with a default value. Those should be set at runtime by whatever calls // the parser @@ -395,6 +401,47 @@ class factory implements \phpbb\textformatter\cache_interface } /** + * Configure the Autolink / Autoemail plugins used to linkify text + * + * @param \s9e\TextFormatter\Configurator $configurator + * @return void + */ + protected function configure_autolink(Configurator $configurator) + { + $configurator->plugins->load('Autoemail'); + $configurator->plugins->load('Autolink', array('matchWww' => true)); + + // Add a tag filter that creates a tag that stores and replace the + // content of a link created by the Autolink plugin + $configurator->Autolink->getTag()->filterChain + ->add(array($this->link_helper, 'generate_link_text_tag')) + ->resetParameters() + ->addParameterByName('tag') + ->addParameterByName('parser'); + + // Create a tag that will be used to display the truncated text by + // replacing the original content with the content of the @text attribute + $tag = $configurator->tags->add('LINK_TEXT'); + $tag->attributes->add('text'); + $tag->template = '<xsl:value-of select="@text"/>'; + + $tag->filterChain + ->add(array($this->link_helper, 'truncate_local_url')) + ->resetParameters() + ->addParameterByName('tag') + ->addParameterByValue(generate_board_url() . '/'); + $tag->filterChain + ->add(array($this->link_helper, 'truncate_text')) + ->resetParameters() + ->addParameterByName('tag'); + $tag->filterChain + ->add(array($this->link_helper, 'cleanup_tag')) + ->resetParameters() + ->addParameterByName('tag') + ->addParameterByName('parser'); + } + + /** * Return the default BBCodes configuration * * @return array 2D array. Each element has a 'usage' key, a 'template' key, and an optional 'options' key diff --git a/phpBB/phpbb/textformatter/s9e/link_helper.php b/phpBB/phpbb/textformatter/s9e/link_helper.php new file mode 100644 index 0000000000..0f44603dec --- /dev/null +++ b/phpBB/phpbb/textformatter/s9e/link_helper.php @@ -0,0 +1,118 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\textformatter\s9e; + +class link_helper +{ + /** + * Clean up and invalidate a LINK_TEXT tag if applicable + * + * Will invalidate the tag if its replacement text is the same as the original + * text and would have no visible effect + * + * @param \s9e\TextFormatter\Parser\Tag $tag LINK_TEXT tag + * @param \s9e\TextFormatter\Parser $parser Parser + * @return bool Whether the tag is valid + */ + public function cleanup_tag(\s9e\TextFormatter\Parser\Tag $tag, \s9e\TextFormatter\Parser $parser) + { + // Invalidate if the content of the tag matches the text attribute + $text = substr($parser->getText(), $tag->getPos(), $tag->getLen()); + + return ($text !== $tag->getAttribute('text')); + } + + /** + * Create a LINK_TEXT tag inside of a link + * + * Meant to only apply to linkified URLs and [url] BBCodes without a parameter + * + * @param \s9e\TextFormatter\Parser\Tag $tag URL tag (start tag) + * @param \s9e\TextFormatter\Parser $parser Parser + * @return bool Always true to indicate that the tag is valid + */ + public function generate_link_text_tag(\s9e\TextFormatter\Parser\Tag $tag, \s9e\TextFormatter\Parser $parser) + { + // Only create a LINK_TEXT tag if the start tag is paired with an end + // tag, which is the case with tags from the Autolink plugins and with + // the [url] BBCode when its content is used for the URL + if (!$tag->getEndTag() || !$this->should_shorten($tag, $parser->getText())) + { + return true; + } + + // Capture the text between the start tag and its end tag + $start = $tag->getPos() + $tag->getLen(); + $end = $tag->getEndTag()->getPos(); + $length = $end - $start; + $text = substr($parser->getText(), $start, $length); + + // Create a tag that consumes the link's text + $parser->addSelfClosingTag('LINK_TEXT', $start, $length)->setAttribute('text', $text); + + return true; + } + + /** + * Test whether we should shorten this tag's text + * + * Will test whether the tag either does not use any markup or uses a single + * [url] BBCode + * + * @param \s9e\TextFormatter\Parser\Tag $tag URL tag + * @param string $text Original text + * @return bool + */ + protected function should_shorten(\s9e\TextFormatter\Parser\Tag $tag, $text) + { + return ($tag->getLen() === 0 || strtolower(substr($text, $tag->getPos(), $tag->getLen())) === '[url]'); + } + + /** + * Remove the board's root URL from a the start of a string + * + * @param \s9e\TextFormatter\Parser\Tag $tag LINK_TEXT tag + * @param string $board_url Forum's root URL (with trailing slash) + * @return bool Always true to indicate that the tag is valid + */ + public function truncate_local_url(\s9e\TextFormatter\Parser\Tag $tag, $board_url) + { + $text = $tag->getAttribute('text'); + if (stripos($text, $board_url) === 0 && strlen($text) > strlen($board_url)) + { + $tag->setAttribute('text', substr($text, strlen($board_url))); + } + + return true; + } + + /** + * Truncate the replacement text set in a LINK_TEXT tag + * + * @param \s9e\TextFormatter\Parser\Tag $tag LINK_TEXT tag + * @return bool Always true to indicate that the tag is valid + */ + public function truncate_text(\s9e\TextFormatter\Parser\Tag $tag) + { + $text = $tag->getAttribute('text'); + if (utf8_strlen($text) > 55) + { + $text = utf8_substr($text, 0, 39) . ' ... ' . utf8_substr($text, -10); + } + + $tag->setAttribute('text', $text); + + return true; + } +} diff --git a/phpBB/phpbb/textformatter/s9e/parser.php b/phpBB/phpbb/textformatter/s9e/parser.php index ffaffbc63c..e2653d60f0 100644 --- a/phpBB/phpbb/textformatter/s9e/parser.php +++ b/phpBB/phpbb/textformatter/s9e/parser.php @@ -50,6 +50,7 @@ class parser implements \phpbb\textformatter\parser_interface $this->dispatcher = $dispatcher; $this->parser = $parser; + $parser = $this; /** @@ -195,7 +196,7 @@ class parser implements \phpbb\textformatter\parser_interface $errors = array(); foreach ($this->parser->getLogger()->get() as $entry) { - list($type, $msg, $context) = $entry; + list(, $msg, $context) = $entry; if ($msg === 'Tag limit exceeded') { diff --git a/phpBB/phpbb/textformatter/s9e/renderer.php b/phpBB/phpbb/textformatter/s9e/renderer.php index 2206605ba2..9be20b7f53 100644 --- a/phpBB/phpbb/textformatter/s9e/renderer.php +++ b/phpBB/phpbb/textformatter/s9e/renderer.php @@ -233,6 +233,7 @@ class renderer implements \phpbb\textformatter\renderer_interface { $xml = $this->quote_helper->inject_metadata($xml); } + $renderer = $this; /** diff --git a/phpBB/phpbb/tree/nestedset.php b/phpBB/phpbb/tree/nestedset.php index 8490c7c299..7149513fd9 100644 --- a/phpBB/phpbb/tree/nestedset.php +++ b/phpBB/phpbb/tree/nestedset.php @@ -391,7 +391,6 @@ abstract class nestedset implements \phpbb\tree\tree_interface throw new \OutOfBoundsException($this->message_prefix . 'INVALID_PARENT'); } - $diff = sizeof($move_items) * 2; $sql_exclude_moved_items = $this->db->sql_in_set($this->column_item_id, $move_items, true); $this->db->sql_transaction('begin'); @@ -490,7 +489,6 @@ abstract class nestedset implements \phpbb\tree\tree_interface throw new \OutOfBoundsException($this->message_prefix . 'INVALID_PARENT'); } - $diff = sizeof($move_items) * 2; $sql_exclude_moved_items = $this->db->sql_in_set($this->column_item_id, $move_items, true); $this->db->sql_transaction('begin'); diff --git a/phpBB/phpbb/user.php b/phpBB/phpbb/user.php index 173b20ee53..5262e10e87 100644 --- a/phpBB/phpbb/user.php +++ b/phpBB/phpbb/user.php @@ -747,8 +747,6 @@ class user extends \phpbb\session */ function leave_newly_registered() { - global $db; - if (empty($this->data['user_new'])) { return false; diff --git a/phpBB/phpbb/version_helper.php b/phpBB/phpbb/version_helper.php index e4f68f5aab..a1e66ba8fe 100644 --- a/phpBB/phpbb/version_helper.php +++ b/phpBB/phpbb/version_helper.php @@ -34,6 +34,11 @@ class version_helper protected $file = 'versions.json'; /** + * @var bool Use SSL or not + */ + protected $use_ssl = false; + + /** * @var string Current version installed */ protected $current_version; @@ -85,13 +90,15 @@ class version_helper * @param string $host Host (e.g. version.phpbb.com) * @param string $path Path to file (e.g. /phpbb) * @param string $file File name (Default: versions.json) + * @param bool $use_ssl Use SSL or not (Default: false) * @return version_helper */ - public function set_file_location($host, $path, $file = 'versions.json') + public function set_file_location($host, $path, $file = 'versions.json', $use_ssl = false) { $this->host = $host; $this->path = $path; $this->file = $file; + $this->use_ssl = $use_ssl; return $this; } @@ -244,7 +251,7 @@ class version_helper */ public function get_versions($force_update = false, $force_cache = false) { - $cache_file = '_versioncheck_' . $this->host . $this->path . $this->file; + $cache_file = '_versioncheck_' . $this->host . $this->path . $this->file . $this->use_ssl; $info = $this->cache->get($cache_file); @@ -255,7 +262,7 @@ class version_helper else if ($info === false || $force_update) { try { - $info = $this->file_downloader->get($this->host, $this->path, $this->file); + $info = $this->file_downloader->get($this->host, $this->path, $this->file, $this->use_ssl ? 443 : 80); } catch (\phpbb\exception\runtime_exception $exception) { |