From 3dcaa48850bf823b238391fbf9c3f085092010bc Mon Sep 17 00:00:00 2001 From: CHItA Date: Sat, 13 Jun 2015 15:35:19 +0200 Subject: [ticket/13740] Move installer files to phpbb/install directory PHPBB3-13740 --- .../install/helper/iohandler/ajax_iohandler.php | 272 +++++++++++++++++++++ 1 file changed, 272 insertions(+) create mode 100644 phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php (limited to 'phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php') diff --git a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php new file mode 100644 index 0000000000..71571fecba --- /dev/null +++ b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php @@ -0,0 +1,272 @@ + + * @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\install\helper\iohandler; + +/** + * Input-Output handler for the AJAX frontend + */ +class ajax_iohandler extends iohandler_base +{ + /** + * @var \phpbb\request\request_interface + */ + protected $request; + + /** + * @var \phpbb\template\template + */ + protected $template; + + /** + * @var string + */ + protected $form; + + /** + * @var bool + */ + protected $request_client_refresh; + + /** + * @var array + */ + protected $nav_data; + + /** + * Constructor + * + * @param \phpbb\request\request_interface $request HTTP request interface + * @param \phpbb\template\template $template Template engine + */ + public function __construct(\phpbb\request\request_interface $request, \phpbb\template\template $template) + { + $this->request = $request; + $this->template = $template; + $this->form = ''; + $this->nav_data = array(); + + parent::__construct(); + } + + /** + * {@inheritdoc} + */ + public function get_input($name, $default, $multibyte = false) + { + return $this->request->variable($name, $default, $multibyte); + } + + /** + * {@inheritdoc} + */ + public function get_server_variable($name, $default = '') + { + return $this->request->server($name, $default); + } + + /** + * {@inheritdoc} + */ + public function get_header_variable($name, $default = '') + { + return $this->request->header($name, $default); + } + + /** + * {@inheritdoc} + */ + public function is_secure() + { + return $this->request->is_secure(); + } + + /** + * {@inheritdoc} + */ + public function add_user_form_group($title, $form) + { + // + // This code is pretty ugly... but works + // + + $this->template->assign_var('S_FORM_ELEM_COUNT', sizeof($form)); + + $this->template->assign_block_vars('options', array( + 'LEGEND' => $this->language->lang($title), + 'S_LEGEND' => true, + )); + + foreach ($form as $input_name => $input_options) + { + if (!isset($input_options['type'])) + { + continue; + } + + $tpl_ary = array(); + + $tpl_ary['TYPE'] = $input_options['type']; + $tpl_ary['TITLE'] = $this->language->lang($input_options['label']); + $tpl_ary['KEY'] = $input_name; + $tpl_ary['S_EXPLAIN'] = false; + + if (isset($input_options['default'])) + { + $default = $input_options['default']; + $default = preg_replace_callback('#\{L_([A-Z0-9\-_]*)\}#s', array($this, 'lang_replace_callback'), $default); + $tpl_ary['DEFAULT'] = $default; + } + + if (isset($input_options['description'])) + { + $tpl_ary['TITLE_EXPLAIN'] = $this->language->lang($input_options['description']); + $tpl_ary['S_EXPLAIN'] = true; + } + + if (in_array($input_options['type'], array('select', 'radio'))) + { + for ($i = 0, $total = sizeof($input_options['options']); $i < $total; $i++) + { + if (isset($input_options['options'][$i]['label'])) + { + $input_options['options'][$i]['label'] = $this->language->lang($input_options['options'][$i]['label']); + } + } + + $tpl_ary['OPTIONS'] = $input_options['options']; + } + + $this->template->assign_block_vars('options', $tpl_ary); + } + + $this->template->set_filenames(array( + 'form_install' => 'installer_form.html', + )); + + $this->form = $this->template->assign_display('form_install'); + } + + /** + * {@inheritdoc} + */ + public function send_response() + { + $json_data_array = $this->prepare_json_array(); + $json_data = json_encode($json_data_array); + + // Try to push content to the browser + print (str_pad(' ', 4096) . "\n"); + print ($json_data . "\n\n"); + flush(); + } + + /** + * Prepares iohandler's data to be sent out to the client. + * + * @return array + */ + protected function prepare_json_array() + { + $json_array = array( + 'errors' => $this->errors, + 'warnings' => $this->warnings, + 'logs' => $this->logs, + ); + + if (!empty($this->form)) + { + $json_array['form'] = $this->form; + $this->form = ''; + } + + // If current task name is set, we push progress message to the client side + if (!empty($this->current_task_name)) + { + $json_array['progress'] = array( + 'task_name' => $this->current_task_name, + 'task_num' => $this->current_task_progress, + 'task_count' => $this->task_progress_count, + ); + } + + if (!empty($this->nav_data)) + { + $json_array['nav'] = $this->nav_data; + } + + $this->errors = array(); + $this->warnings = array(); + $this->logs = array(); + $this->nav_data = array(); + + if ($this->request_client_refresh) + { + $json_array['refresh'] = true; + $this->request_client_refresh = false; + } + + return $json_array; + } + + /** + * {@inheritdoc} + */ + public function set_progress($task_lang_key, $task_number) + { + parent::set_progress($task_lang_key, $task_number); + $this->send_response(); + } + + /** + * {@inheritdoc} + */ + public function request_refresh() + { + $this->request_client_refresh = true; + } + + /** + * {@inheritdoc} + */ + public function set_active_stage_menu($menu_path) + { + $this->nav_data['active'] = $menu_path[sizeof($menu_path) - 1]; + $this->send_response(); + } + + /** + * {@inheritdoc} + */ + public function set_finished_stage_menu($menu_path) + { + $this->nav_data['finished'][] = $menu_path[sizeof($menu_path) - 1]; + $this->send_response(); + } + + /** + * Callback function for language replacing + * + * @param array $matches + * @return string + */ + public function lang_replace_callback($matches) + { + if (!empty($matches[1])) + { + return $this->language->lang($matches[1]); + } + + return ''; + } +} -- cgit v1.2.1 From 06f4ebce1b1cc8ecd5ddd84f7d2705007a685de3 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 31 May 2015 17:19:42 +0200 Subject: [ticket/13740] CLI installer and fixes [ci skip] PHPBB3-13740 --- phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php') diff --git a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php index 71571fecba..85cb2ca753 100644 --- a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php @@ -182,6 +182,7 @@ class ajax_iohandler extends iohandler_base 'errors' => $this->errors, 'warnings' => $this->warnings, 'logs' => $this->logs, + 'success' => $this->success, ); if (!empty($this->form)) @@ -208,6 +209,7 @@ class ajax_iohandler extends iohandler_base $this->errors = array(); $this->warnings = array(); $this->logs = array(); + $this->success = array(); $this->nav_data = array(); if ($this->request_client_refresh) -- cgit v1.2.1 From b2b9fb1df2e6d37c8a327b7b6c380f19e1ff6496 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Tue, 21 Jul 2015 14:42:15 +0200 Subject: [ticket/13740] Fix CS and docblocks PHPBB3-13740 --- phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php') diff --git a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php index 85cb2ca753..ce1112c7a1 100644 --- a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php @@ -96,10 +96,6 @@ class ajax_iohandler extends iohandler_base */ public function add_user_form_group($title, $form) { - // - // This code is pretty ugly... but works - // - $this->template->assign_var('S_FORM_ELEM_COUNT', sizeof($form)); $this->template->assign_block_vars('options', array( @@ -166,8 +162,8 @@ class ajax_iohandler extends iohandler_base $json_data = json_encode($json_data_array); // Try to push content to the browser - print (str_pad(' ', 4096) . "\n"); - print ($json_data . "\n\n"); + print(str_pad(' ', 4096) . "\n"); + print($json_data . "\n\n"); flush(); } -- cgit v1.2.1 From fbd5929606169d3f780f0a59760c171b20bd906d Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Thu, 23 Jul 2015 20:50:33 +0200 Subject: [ticket/13740] Login admin when install finished PHPBB3-13740 --- .../install/helper/iohandler/ajax_iohandler.php | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php') diff --git a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php index ce1112c7a1..fa628f3365 100644 --- a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php @@ -43,6 +43,11 @@ class ajax_iohandler extends iohandler_base */ protected $nav_data; + /** + * @var array + */ + protected $cookies; + /** * Constructor * @@ -55,6 +60,7 @@ class ajax_iohandler extends iohandler_base $this->template = $template; $this->form = ''; $this->nav_data = array(); + $this->cookies = array(); parent::__construct(); } @@ -214,6 +220,12 @@ class ajax_iohandler extends iohandler_base $this->request_client_refresh = false; } + if (!empty($this->cookies)) + { + $json_array['cookies'] = $this->cookies; + $this->cookies = array(); + } + return $json_array; } @@ -252,6 +264,17 @@ class ajax_iohandler extends iohandler_base $this->send_response(); } + /** + * {@inheritdoc} + */ + public function set_cookie($cookie_name, $cookie_value) + { + $this->cookies[] = array( + 'name' => $cookie_name, + 'value' => $cookie_value + ); + } + /** * Callback function for language replacing * -- cgit v1.2.1 From 8f5a0ad6f73e7b7757b02c827436384c96069b5a Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Fri, 24 Jul 2015 09:20:50 +0200 Subject: [ticket/14039] Revamp updater PHPBB3-14039 --- .../install/helper/iohandler/ajax_iohandler.php | 119 +++++++++++++++++++-- 1 file changed, 108 insertions(+), 11 deletions(-) (limited to 'phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php') diff --git a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php index fa628f3365..1342ffa30f 100644 --- a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php @@ -13,11 +13,19 @@ namespace phpbb\install\helper\iohandler; +use phpbb\path_helper; +use phpbb\routing\router; + /** * Input-Output handler for the AJAX frontend */ class ajax_iohandler extends iohandler_base { + /** + * @var path_helper + */ + protected $path_helper; + /** * @var \phpbb\request\request_interface */ @@ -28,6 +36,16 @@ class ajax_iohandler extends iohandler_base */ protected $template; + /** + * @var router + */ + protected $router; + + /** + * @var string + */ + protected $file_status; + /** * @var string */ @@ -48,19 +66,30 @@ class ajax_iohandler extends iohandler_base */ protected $cookies; + /** + * @var array + */ + protected $download; + /** * Constructor * + * @param path_helper $path_helper * @param \phpbb\request\request_interface $request HTTP request interface * @param \phpbb\template\template $template Template engine + * @param router $router Router */ - public function __construct(\phpbb\request\request_interface $request, \phpbb\template\template $template) + public function __construct(path_helper $path_helper, \phpbb\request\request_interface $request, \phpbb\template\template $template, router $router) { + $this->path_helper = $path_helper; $this->request = $request; + $this->router = $router; $this->template = $template; $this->form = ''; $this->nav_data = array(); $this->cookies = array(); + $this->download = array(); + $this->file_status = ''; parent::__construct(); } @@ -102,13 +131,13 @@ class ajax_iohandler extends iohandler_base */ public function add_user_form_group($title, $form) { - $this->template->assign_var('S_FORM_ELEM_COUNT', sizeof($form)); - $this->template->assign_block_vars('options', array( 'LEGEND' => $this->language->lang($title), 'S_LEGEND' => true, )); + $not_button_form = false; + foreach ($form as $input_name => $input_options) { if (!isset($input_options['type'])) @@ -117,6 +146,7 @@ class ajax_iohandler extends iohandler_base } $tpl_ary = array(); + $not_button_form = ($input_options['type'] !== 'submit' || $not_button_form); $tpl_ary['TYPE'] = $input_options['type']; $tpl_ary['TITLE'] = $this->language->lang($input_options['label']); @@ -136,7 +166,7 @@ class ajax_iohandler extends iohandler_base $tpl_ary['S_EXPLAIN'] = true; } - if (in_array($input_options['type'], array('select', 'radio'))) + if (in_array($input_options['type'], array('select', 'radio'), true)) { for ($i = 0, $total = sizeof($input_options['options']); $i < $total; $i++) { @@ -149,9 +179,12 @@ class ajax_iohandler extends iohandler_base $tpl_ary['OPTIONS'] = $input_options['options']; } - $this->template->assign_block_vars('options', $tpl_ary); + $block_name = ($input_options['type'] === 'submit') ? 'submit_buttons' : 'options'; + $this->template->assign_block_vars($block_name, $tpl_ary); } + $this->template->assign_var('S_NOT_ONLY_BUTTON_FORM', $not_button_form); + $this->template->set_filenames(array( 'form_install' => 'installer_form.html', )); @@ -185,14 +218,27 @@ class ajax_iohandler extends iohandler_base 'warnings' => $this->warnings, 'logs' => $this->logs, 'success' => $this->success, + 'download' => $this->download, ); + $this->errors = array(); + $this->warnings = array(); + $this->logs = array(); + $this->success = array(); + $this->download = array(); + if (!empty($this->form)) { $json_array['form'] = $this->form; $this->form = ''; } + if (!empty($this->file_status)) + { + $json_array['file_status'] = $this->file_status; + $this->file_status = ''; + } + // If current task name is set, we push progress message to the client side if (!empty($this->current_task_name)) { @@ -201,19 +247,20 @@ class ajax_iohandler extends iohandler_base 'task_num' => $this->current_task_progress, 'task_count' => $this->task_progress_count, ); + + if ($this->restart_progress_bar) + { + $json_array['progress']['restart'] = 1; + $this->restart_progress_bar = false; + } } if (!empty($this->nav_data)) { $json_array['nav'] = $this->nav_data; + $this->nav_data = array(); } - $this->errors = array(); - $this->warnings = array(); - $this->logs = array(); - $this->success = array(); - $this->nav_data = array(); - if ($this->request_client_refresh) { $json_array['refresh'] = true; @@ -275,6 +322,56 @@ class ajax_iohandler extends iohandler_base ); } + /** + * {@inheritdoc} + */ + public function add_download_link($route, $title, $msg = null) + { + $link_properties = array( + 'href' => $this->router->generate($route), + 'title' => $this->language->lang($title), + 'download' => $this->language->lang('DOWNLOAD'), + ); + + if ($msg !== null) + { + $link_properties['msg'] = htmlspecialchars_decode($this->language->lang($msg)); + } + + $this->download[] = $link_properties; + } + + /** + * {@inheritdoc} + */ + public function render_update_file_status($status_array) + { + $this->template->assign_vars(array( + 'T_IMAGE_PATH' => $this->path_helper->get_web_root_path() . 'adm/images/', + )); + + foreach ($status_array as $block => $list) + { + foreach ($list as $filename) + { + $dirname = dirname($filename); + + $this->template->assign_block_vars($block, array( + 'STATUS' => $block, + 'FILENAME' => $filename, + 'DIR_PART' => (!empty($dirname) && $dirname !== '.') ? dirname($filename) . '/' : false, + 'FILE_PART' => basename($filename), + )); + } + } + + $this->template->set_filenames(array( + 'file_status' => 'installer_update_file_status.html', + )); + + $this->file_status = $this->template->assign_display('file_status'); + } + /** * Callback function for language replacing * -- cgit v1.2.1 From a649768e17d25bcf55ae539420abe4eb4b7a1ef1 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Wed, 28 Oct 2015 15:00:11 +0100 Subject: [ticket/14262] Move convertor to controller PHPBB3-14262 --- .../install/helper/iohandler/ajax_iohandler.php | 31 +++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php') diff --git a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php index 1342ffa30f..31474ae4e9 100644 --- a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php @@ -71,6 +71,11 @@ class ajax_iohandler extends iohandler_base */ protected $download; + /** + * @var array + */ + protected $redirect_url; + /** * Constructor * @@ -89,6 +94,7 @@ class ajax_iohandler extends iohandler_base $this->nav_data = array(); $this->cookies = array(); $this->download = array(); + $this->redirect_url = array(); $this->file_status = ''; parent::__construct(); @@ -130,6 +136,14 @@ class ajax_iohandler extends iohandler_base * {@inheritdoc} */ public function add_user_form_group($title, $form) + { + $this->form = $this->generate_form_render_data($title, $form); + } + + /** + * {@inheritdoc} + */ + public function generate_form_render_data($title, $form) { $this->template->assign_block_vars('options', array( 'LEGEND' => $this->language->lang($title), @@ -189,7 +203,7 @@ class ajax_iohandler extends iohandler_base 'form_install' => 'installer_form.html', )); - $this->form = $this->template->assign_display('form_install'); + return $this->template->assign_display('form_install'); } /** @@ -273,6 +287,12 @@ class ajax_iohandler extends iohandler_base $this->cookies = array(); } + if (!empty($this->redirect_url)) + { + $json_array['redirect'] = $this->redirect_url; + $this->redirect_url = array(); + } + return $json_array; } @@ -372,6 +392,15 @@ class ajax_iohandler extends iohandler_base $this->file_status = $this->template->assign_display('file_status'); } + /** + * {@inheritdoc} + */ + public function redirect($url, $use_ajax = false) + { + $this->redirect_url = array('url' => $url, 'use_ajax' => $use_ajax); + $this->send_response(); + } + /** * Callback function for language replacing * -- cgit v1.2.1 From 955b9ede33c5696173a760ea271ec32d79e843b9 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Thu, 11 Feb 2016 13:18:30 +0100 Subject: [ticket/14462] Further speed improvements - Cache the secondary container - Only initialize tasks/modules that are being used - Add timeout error message in the AJAX UI PHPBB3-14462 --- .../install/helper/iohandler/ajax_iohandler.php | 63 ++++++++++++++++------ 1 file changed, 47 insertions(+), 16 deletions(-) (limited to 'phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php') diff --git a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php index 31474ae4e9..8c62ec7bd0 100644 --- a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php @@ -209,9 +209,15 @@ class ajax_iohandler extends iohandler_base /** * {@inheritdoc} */ - public function send_response() + public function send_response($no_more_output = false) { - $json_data_array = $this->prepare_json_array(); + $json_data_array = $this->prepare_json_array($no_more_output); + + if (empty($json_data_array)) + { + return; + } + $json_data = json_encode($json_data_array); // Try to push content to the browser @@ -223,23 +229,43 @@ class ajax_iohandler extends iohandler_base /** * Prepares iohandler's data to be sent out to the client. * + * @param bool $no_more_output Whether or not there will be more output in this response + * * @return array */ - protected function prepare_json_array() + protected function prepare_json_array($no_more_output = false) { - $json_array = array( - 'errors' => $this->errors, - 'warnings' => $this->warnings, - 'logs' => $this->logs, - 'success' => $this->success, - 'download' => $this->download, - ); + $json_array = array(); + + if (!empty($this->errors)) + { + $json_array['errors'] = $this->errors; + $this->errors = array(); + } + + if (!empty($this->warnings)) + { + $json_array['warnings'] = $this->warnings; + $this->warnings = array(); + } - $this->errors = array(); - $this->warnings = array(); - $this->logs = array(); - $this->success = array(); - $this->download = array(); + if (!empty($this->logs)) + { + $json_array['logs'] = $this->logs; + $this->logs = array(); + } + + if (!empty($this->success)) + { + $json_array['success'] = $this->success; + $this->success = array(); + } + + if (!empty($this->download)) + { + $json_array['download'] = $this->download; + $this->download = array(); + } if (!empty($this->form)) { @@ -293,6 +319,11 @@ class ajax_iohandler extends iohandler_base $this->redirect_url = array(); } + if ($no_more_output) + { + $json_array['over'] = true; + } + return $json_array; } @@ -398,7 +429,7 @@ class ajax_iohandler extends iohandler_base public function redirect($url, $use_ajax = false) { $this->redirect_url = array('url' => $url, 'use_ajax' => $use_ajax); - $this->send_response(); + $this->send_response(true); } /** -- cgit v1.2.1 From 062358f8b1d9a7fa3d9be97f6b58e06fea7ca844 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Bartus?= Date: Sun, 28 Feb 2016 00:19:24 +0100 Subject: [ticket/14487] Try to handle connection timeouts PHPBB3-14487 --- .../install/helper/iohandler/ajax_iohandler.php | 41 +++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) (limited to 'phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php') diff --git a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php index 8c62ec7bd0..c168d26425 100644 --- a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php @@ -41,6 +41,11 @@ class ajax_iohandler extends iohandler_base */ protected $router; + /** + * @var string + */ + protected $phpbb_root_path; + /** * @var string */ @@ -76,6 +81,11 @@ class ajax_iohandler extends iohandler_base */ protected $redirect_url; + /** + * @var resource + */ + protected $file_lock_pointer; + /** * Constructor * @@ -83,8 +93,9 @@ class ajax_iohandler extends iohandler_base * @param \phpbb\request\request_interface $request HTTP request interface * @param \phpbb\template\template $template Template engine * @param router $router Router + * @param string $root_path Path to phpBB's root */ - public function __construct(path_helper $path_helper, \phpbb\request\request_interface $request, \phpbb\template\template $template, router $router) + public function __construct(path_helper $path_helper, \phpbb\request\request_interface $request, \phpbb\template\template $template, router $router, $root_path) { $this->path_helper = $path_helper; $this->request = $request; @@ -96,6 +107,7 @@ class ajax_iohandler extends iohandler_base $this->download = array(); $this->redirect_url = array(); $this->file_status = ''; + $this->phpbb_root_path = $root_path; parent::__construct(); } @@ -432,6 +444,33 @@ class ajax_iohandler extends iohandler_base $this->send_response(true); } + /** + * Acquires a file lock + */ + public function acquire_lock() + { + $lock_file = $this->phpbb_root_path . 'store/io_lock.lock'; + $this->file_lock_pointer = @fopen($lock_file, 'w+'); + + if ($this->file_lock_pointer) + { + flock($this->file_lock_pointer, LOCK_EX); + } + } + + /** + * Release file lock + */ + public function release_lock() + { + if ($this->file_lock_pointer) + { + fwrite($this->file_lock_pointer, 'ok'); + flock($this->file_lock_pointer, LOCK_UN); + fclose($this->file_lock_pointer); + } + } + /** * Callback function for language replacing * -- cgit v1.2.1 From 23f5b6debdd24cc1caefd3bb8cd6da96a88abe9a Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 24 Nov 2016 22:22:38 +0100 Subject: [ticket/14875] Add method for untrimmed input to ajax iohandler Due to the pre-encoded input and the escaping of the input, the string has to be decoded twice for the password. PHPBB3-14875 --- phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php') diff --git a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php index c168d26425..591a19b7c1 100644 --- a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php @@ -120,6 +120,22 @@ class ajax_iohandler extends iohandler_base return $this->request->variable($name, $default, $multibyte); } + /** + * Returns untrimmed input variable + * + * @param string $name Name of the input variable to obtain + * @param mixed $default A default value that is returned if the variable was not set. + * This function will always return a value of the same type as the default. + * @param bool $multibyte If $default is a string this paramater has to be true if the variable may contain any UTF-8 characters + * Default is false, causing all bytes outside the ASCII range (0-127) to be replaced with question marks + * + * @return mixed Value of the untrimmed input variable + */ + public function get_untrimmed_input($name, $default, $multibyte = false) + { + return $this->request->untrimmed_variable($name, $default, $multibyte); + } + /** * {@inheritdoc} */ -- cgit v1.2.1 From 9aa017d0f7ce13a11114cbae24b694e935931342 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 25 Nov 2016 22:15:13 +0100 Subject: [ticket/14875] Add method for raw input to request and add to installer A method for retrieving raw input has been added to the request class. This will be used in the installer to retrieve the datatabase password while also allowing utf8 characters. Not escaping the input is ok in this case as it won't be put anywhere in this raw form and only be used to populate the entry for the password field in config.php. PHPBB3-14875 --- .../install/helper/iohandler/ajax_iohandler.php | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php') diff --git a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php index 591a19b7c1..2db6750f3f 100644 --- a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php @@ -27,7 +27,7 @@ class ajax_iohandler extends iohandler_base protected $path_helper; /** - * @var \phpbb\request\request_interface + * @var \phpbb\request\request */ protected $request; @@ -90,12 +90,12 @@ class ajax_iohandler extends iohandler_base * Constructor * * @param path_helper $path_helper - * @param \phpbb\request\request_interface $request HTTP request interface + * @param \phpbb\request\request $request HTTP request interface * @param \phpbb\template\template $template Template engine * @param router $router Router * @param string $root_path Path to phpBB's root */ - public function __construct(path_helper $path_helper, \phpbb\request\request_interface $request, \phpbb\template\template $template, router $router, $root_path) + public function __construct(path_helper $path_helper, \phpbb\request\request $request, \phpbb\template\template $template, router $router, $root_path) { $this->path_helper = $path_helper; $this->request = $request; @@ -121,19 +121,11 @@ class ajax_iohandler extends iohandler_base } /** - * Returns untrimmed input variable - * - * @param string $name Name of the input variable to obtain - * @param mixed $default A default value that is returned if the variable was not set. - * This function will always return a value of the same type as the default. - * @param bool $multibyte If $default is a string this paramater has to be true if the variable may contain any UTF-8 characters - * Default is false, causing all bytes outside the ASCII range (0-127) to be replaced with question marks - * - * @return mixed Value of the untrimmed input variable + * {@inheritdoc} */ - public function get_untrimmed_input($name, $default, $multibyte = false) + public function get_raw_input($name, $default) { - return $this->request->untrimmed_variable($name, $default, $multibyte); + return $this->request->raw_variable($name, $default); } /** -- cgit v1.2.1 From 9bdd002f584de78475362067b777749486504172 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 2 Dec 2016 11:36:07 +0100 Subject: [ticket/14875] Move raw_variable() method to request_interface PHPBB3-14875 --- phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php') diff --git a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php index 2db6750f3f..a40d457466 100644 --- a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php @@ -27,7 +27,7 @@ class ajax_iohandler extends iohandler_base protected $path_helper; /** - * @var \phpbb\request\request + * @var \phpbb\request\request_interface */ protected $request; @@ -90,12 +90,12 @@ class ajax_iohandler extends iohandler_base * Constructor * * @param path_helper $path_helper - * @param \phpbb\request\request $request HTTP request interface + * @param \phpbb\request\request_interface $request HTTP request interface * @param \phpbb\template\template $template Template engine * @param router $router Router * @param string $root_path Path to phpBB's root */ - public function __construct(path_helper $path_helper, \phpbb\request\request $request, \phpbb\template\template $template, router $router, $root_path) + public function __construct(path_helper $path_helper, \phpbb\request\request_interface $request, \phpbb\template\template $template, router $router, $root_path) { $this->path_helper = $path_helper; $this->request = $request; -- cgit v1.2.1 From d84834db88ea54bc33a323457236943a56399747 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 23 Jul 2017 21:09:30 +0200 Subject: [ticket/15293] Prevent continuing to database update on incomplete file update PHPBB3-15293 --- phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php') diff --git a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php index a40d457466..bce0149890 100644 --- a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php @@ -186,6 +186,7 @@ class ajax_iohandler extends iohandler_base $tpl_ary['TITLE'] = $this->language->lang($input_options['label']); $tpl_ary['KEY'] = $input_name; $tpl_ary['S_EXPLAIN'] = false; + $tpl_ary['DISABLED'] = isset($input_options['disabled']) ? $input_options['disabled'] : false; if (isset($input_options['default'])) { @@ -219,6 +220,11 @@ class ajax_iohandler extends iohandler_base $this->template->assign_var('S_NOT_ONLY_BUTTON_FORM', $not_button_form); + if (!$not_button_form) + { + $this->template->destroy_block_vars('options'); + } + $this->template->set_filenames(array( 'form_install' => 'installer_form.html', )); -- cgit v1.2.1 From f8f985c099225700a888a91c34f0481910e08378 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 10 Sep 2017 12:50:06 +0200 Subject: [ticket/15353] Make sure users can continue update after merging file diff PHPBB3-15353 --- phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php') diff --git a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php index bce0149890..dd584eff30 100644 --- a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php @@ -187,6 +187,7 @@ class ajax_iohandler extends iohandler_base $tpl_ary['KEY'] = $input_name; $tpl_ary['S_EXPLAIN'] = false; $tpl_ary['DISABLED'] = isset($input_options['disabled']) ? $input_options['disabled'] : false; + $tpl_ary['IS_SECONDARY'] = isset($input_options['is_secondary']) ? $input_options['is_secondary'] : false; if (isset($input_options['default'])) { @@ -218,6 +219,11 @@ class ajax_iohandler extends iohandler_base $this->template->assign_block_vars($block_name, $tpl_ary); } + if (isset($form['database_update_submit']) && !$form['database_update_submit']['disabled']) + { + $this->template->assign_var('FORM_TITLE', $this->language->lang('UPDATE_CONTINUE_UPDATE_PROCESS')); + } + $this->template->assign_var('S_NOT_ONLY_BUTTON_FORM', $not_button_form); if (!$not_button_form) -- cgit v1.2.1 From f8fbe3793680af1dae2db2829cfc84068831c52f Mon Sep 17 00:00:00 2001 From: rxu Date: Wed, 28 Jun 2017 00:58:03 +0700 Subject: [ticket/14972] replace all occurrences of sizeof() with the count() PHPBB3-14972 --- phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php') diff --git a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php index dd584eff30..2a608f504e 100644 --- a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php @@ -204,7 +204,7 @@ class ajax_iohandler extends iohandler_base if (in_array($input_options['type'], array('select', 'radio'), true)) { - for ($i = 0, $total = sizeof($input_options['options']); $i < $total; $i++) + for ($i = 0, $total = count($input_options['options']); $i < $total; $i++) { if (isset($input_options['options'][$i]['label'])) { @@ -381,7 +381,7 @@ class ajax_iohandler extends iohandler_base */ public function set_active_stage_menu($menu_path) { - $this->nav_data['active'] = $menu_path[sizeof($menu_path) - 1]; + $this->nav_data['active'] = $menu_path[count($menu_path) - 1]; $this->send_response(); } @@ -390,7 +390,7 @@ class ajax_iohandler extends iohandler_base */ public function set_finished_stage_menu($menu_path) { - $this->nav_data['finished'][] = $menu_path[sizeof($menu_path) - 1]; + $this->nav_data['finished'][] = $menu_path[count($menu_path) - 1]; $this->send_response(); } -- cgit v1.2.1