function main($mode, $sub) { global $lang, $template, $language, $phpbb_root_path, $phpEx; global $phpbb_container, $cache, $phpbb_log, $request, $phpbb_config_php_file; switch ($sub) { case 'intro': $phpbb_container->get('cache.driver')->purge(); $this->page_title = $lang['SUB_INTRO']; $template->assign_vars(array('TITLE' => $lang['INSTALL_INTRO'], 'BODY' => $lang['INSTALL_INTRO_BODY'], 'L_SUBMIT' => $lang['NEXT_STEP'], 'S_LANG_SELECT' => '<select id="language" name="language">' . $this->p_master->inst_language_select($language) . '</select>', 'U_ACTION' => $this->p_master->module_url . "?mode={$mode}&sub=requirements&language={$language}")); break; case 'requirements': $this->check_server_requirements($mode, $sub); break; case 'database': $this->obtain_database_settings($mode, $sub); break; case 'administrator': $this->obtain_admin_settings($mode, $sub); break; case 'config_file': $this->create_config_file($mode, $sub); break; case 'advanced': $this->obtain_advanced_settings($mode, $sub); break; case 'create_table': $this->load_schema($mode, $sub); break; case 'final': // Enable super globals to prevent issues with the new \phpbb\request\request object $request->enable_super_globals(); // Create a normal container now $phpbb_container_builder = new \phpbb\di\container_builder($phpbb_root_path, $phpEx); $phpbb_container = $phpbb_container_builder->with_config($phpbb_config_php_file)->get_container(); // Sets the global variables /* @var $cache \phpbb\cache\service */ $cache = $phpbb_container->get('cache'); /* @var $phpbb_log \phpbb\log\log_interface */ $phpbb_log = $phpbb_container->get('log'); $this->build_search_index($mode, $sub); $this->add_modules($mode, $sub); $this->add_language($mode, $sub); $this->add_bots($mode, $sub); $this->email_admin($mode, $sub); $this->disable_avatars_if_unwritable(); $this->populate_migrations($phpbb_container->get('ext.manager'), $phpbb_container->get('migrator')); // Remove the lock file @unlink($phpbb_root_path . 'cache/install_lock'); break; } $this->tpl_name = 'install_install'; }
/** * Loads the ContainerBuilder from the cache. * * @return \Symfony\Component\DependencyInjection\ContainerBuilder * * @throws \LogicException */ protected function getContainerBuilder() { $container_builder = new \phpbb\di\container_builder($this->config_php_file, $this->phpbb_root_path, $this->php_ext); $container_builder->set_compile_container(true); $container_builder->set_dump_container(false); $container = $container_builder->get_container(); return $container; }
protected static function install_board() { global $phpbb_root_path, $phpEx; self::recreate_database(self::$config); $config_file = $phpbb_root_path . "config.{$phpEx}"; $config_file_dev = $phpbb_root_path . "config_dev.{$phpEx}"; $config_file_test = $phpbb_root_path . "config_test.{$phpEx}"; if (file_exists($config_file)) { if (!file_exists($config_file_dev)) { rename($config_file, $config_file_dev); } else { unlink($config_file); } } $container_builder = new \phpbb\di\container_builder($phpbb_root_path, $phpEx); $container = $container_builder->with_environment('installer')->without_extensions()->without_cache()->with_custom_parameters(['core.disable_super_globals' => false, 'installer.create_config_file.options' => ['debug' => true, 'environment' => 'test'], 'cache.driver.class' => 'phpbb\\cache\\driver\\file'])->without_compiled_container()->get_container(); $container->register('installer.install_finish.notify_user')->setSynthetic(true); $container->set('installer.install_finish.notify_user', new phpbb_mock_null_installer_task()); $container->compile(); $language = $container->get('language'); $language->add_lang(array('common', 'acp/common', 'acp/board', 'install', 'posting')); $iohandler_factory = $container->get('installer.helper.iohandler_factory'); $iohandler_factory->set_environment('cli'); $iohandler = $iohandler_factory->get(); $parseURL = parse_url(self::$config['phpbb_functional_url']); $output = new \Symfony\Component\Console\Output\NullOutput(); $style = new \Symfony\Component\Console\Style\SymfonyStyle(new \Symfony\Component\Console\Input\ArrayInput(array()), $output); $iohandler->set_style($style, $output); $installer = $container->get('installer.installer.install'); $installer->set_iohandler($iohandler); // Set data $iohandler->set_input('admin_name', 'admin'); $iohandler->set_input('admin_pass1', 'adminadmin'); $iohandler->set_input('admin_pass2', 'adminadmin'); $iohandler->set_input('board_email', '*****@*****.**'); $iohandler->set_input('submit_admin', 'submit'); $iohandler->set_input('default_lang', 'en'); $iohandler->set_input('board_name', 'yourdomain.com'); $iohandler->set_input('board_description', 'A short text to describe your forum'); $iohandler->set_input('submit_board', 'submit'); $iohandler->set_input('dbms', str_replace('phpbb\\db\\driver\\', '', self::$config['dbms'])); $iohandler->set_input('dbhost', self::$config['dbhost']); $iohandler->set_input('dbport', self::$config['dbport']); $iohandler->set_input('dbuser', self::$config['dbuser']); $iohandler->set_input('dbpasswd', self::$config['dbpasswd']); $iohandler->set_input('dbname', self::$config['dbname']); $iohandler->set_input('table_prefix', self::$config['table_prefix']); $iohandler->set_input('submit_database', 'submit'); $iohandler->set_input('email_enable', true); $iohandler->set_input('smtp_delivery', '1'); $iohandler->set_input('smtp_host', 'nxdomain.phpbb.com'); $iohandler->set_input('smtp_auth', 'PLAIN'); $iohandler->set_input('smtp_user', 'nxuser'); $iohandler->set_input('smtp_pass', 'nxpass'); $iohandler->set_input('submit_email', 'submit'); $iohandler->set_input('cookie_secure', '0'); $iohandler->set_input('server_protocol', '0'); $iohandler->set_input('force_server_vars', $parseURL['scheme'] . '://'); $iohandler->set_input('server_name', $parseURL['host']); $iohandler->set_input('server_port', isset($parseURL['port']) ? (int) $parseURL['port'] : 80); $iohandler->set_input('script_path', $parseURL['path']); $iohandler->set_input('submit_server', 'submit'); $installer->run(); copy($config_file, $config_file_test); self::$install_success = true; if (file_exists($phpbb_root_path . 'store/install_config.php')) { self::$install_success = false; @unlink($phpbb_root_path . 'store/install_config.php'); } if (file_exists($phpbb_root_path . 'cache/install_lock')) { @unlink($phpbb_root_path . 'cache/install_lock'); } global $phpbb_container, $cache, $phpbb_dispatcher, $request, $user, $auth, $db, $config, $phpbb_log, $symfony_request, $phpbb_filesystem, $phpbb_path_helper, $phpbb_extension_manager, $template; $phpbb_container->reset(); unset($phpbb_container, $cache, $phpbb_dispatcher, $request, $user, $auth, $db, $config, $phpbb_log, $symfony_request, $phpbb_filesystem, $phpbb_path_helper, $phpbb_extension_manager, $template); }
exit(1); } define('IN_PHPBB', true); $phpbb_root_path = __DIR__ . '/../'; $phpEx = substr(strrchr(__FILE__, '.'), 1); require $phpbb_root_path . 'includes/startup.' . $phpEx; require $phpbb_root_path . 'phpbb/class_loader.' . $phpEx; $phpbb_class_loader = new \phpbb\class_loader('phpbb\\', "{$phpbb_root_path}phpbb/", $phpEx); $phpbb_class_loader->register(); $phpbb_config_php_file = new \phpbb\config_php_file($phpbb_root_path, $phpEx); extract($phpbb_config_php_file->get_all()); require $phpbb_root_path . 'includes/constants.' . $phpEx; require $phpbb_root_path . 'includes/functions.' . $phpEx; require $phpbb_root_path . 'includes/functions_admin.' . $phpEx; require $phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx; $phpbb_container_builder = new \phpbb\di\container_builder($phpbb_config_php_file, $phpbb_root_path, $phpEx); $phpbb_container_builder->set_dump_container(false); $input = new ArgvInput(); if ($input->hasParameterOption(array('--safe-mode'))) { $phpbb_container_builder->set_use_extensions(false); $phpbb_container_builder->set_dump_container(false); } else { $phpbb_class_loader_ext = new \phpbb\class_loader('\\', "{$phpbb_root_path}ext/", $phpEx); $phpbb_class_loader_ext->register(); phpbb_load_extensions_autoloaders($phpbb_root_path); } $phpbb_container = $phpbb_container_builder->get_container(); $phpbb_container->get('request')->enable_super_globals(); require $phpbb_root_path . 'includes/compatibility_globals.' . $phpEx; $user = $phpbb_container->get('user'); $user->data['user_id'] = ANONYMOUS;
$phpbb_root_path = __DIR__ . '/../'; $phpEx = substr(strrchr(__FILE__, '.'), 1); require $phpbb_root_path . 'includes/startup.' . $phpEx; require $phpbb_root_path . 'phpbb/class_loader.' . $phpEx; $phpbb_class_loader = new \phpbb\class_loader('phpbb\\', "{$phpbb_root_path}phpbb/", $phpEx); $phpbb_class_loader->register(); $phpbb_config_php_file = new \phpbb\config_php_file($phpbb_root_path, $phpEx); extract($phpbb_config_php_file->get_all()); if (!defined('PHPBB_ENVIRONMENT')) { @define('PHPBB_ENVIRONMENT', 'production'); } require $phpbb_root_path . 'includes/constants.' . $phpEx; require $phpbb_root_path . 'includes/functions.' . $phpEx; require $phpbb_root_path . 'includes/functions_admin.' . $phpEx; require $phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx; $phpbb_container_builder = new \phpbb\di\container_builder($phpbb_root_path, $phpEx); $phpbb_container = $phpbb_container_builder->with_config($phpbb_config_php_file); $phpbb_container_builder->without_cache(); $input = new ArgvInput(); if ($input->hasParameterOption(array('--safe-mode'))) { $phpbb_container_builder->without_extensions(); } else { $phpbb_class_loader_ext = new \phpbb\class_loader('\\', "{$phpbb_root_path}ext/", $phpEx); $phpbb_class_loader_ext->register(); } $phpbb_container = $phpbb_container_builder->get_container(); $phpbb_container->get('request')->enable_super_globals(); require $phpbb_root_path . 'includes/compatibility_globals.' . $phpEx; /* @var $user \phpbb\user */ $user = $phpbb_container->get('user'); $user->add_lang('acp/common');
// In case $phpbb_adm_relative_path is not set (in case of an update), use the default. $phpbb_adm_relative_path = isset($phpbb_adm_relative_path) ? $phpbb_adm_relative_path : 'adm/'; $phpbb_admin_path = defined('PHPBB_ADMIN_PATH') ? PHPBB_ADMIN_PATH : $phpbb_root_path . $phpbb_adm_relative_path; // Include files require $phpbb_root_path . 'includes/functions.' . $phpEx; require $phpbb_root_path . 'includes/functions_content.' . $phpEx; include $phpbb_root_path . 'includes/functions_compatibility.' . $phpEx; require $phpbb_root_path . 'includes/constants.' . $phpEx; require $phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx; // Set PHP error handler to ours set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler'); $phpbb_class_loader_ext = new \phpbb\class_loader('\\', "{$phpbb_root_path}ext/", $phpEx); $phpbb_class_loader_ext->register(); // Set up container try { $phpbb_container_builder = new \phpbb\di\container_builder($phpbb_root_path, $phpEx); $phpbb_container = $phpbb_container_builder->with_config($phpbb_config_php_file)->get_container(); } catch (InvalidArgumentException $e) { trigger_error('The requested environment ' . PHPBB_ENVIRONMENT . ' is not available.', E_USER_ERROR); } $phpbb_class_loader->set_cache($phpbb_container->get('cache.driver')); $phpbb_class_loader_ext->set_cache($phpbb_container->get('cache.driver')); require $phpbb_root_path . 'includes/compatibility_globals.' . $phpEx; // Add own hook handler require $phpbb_root_path . 'includes/hooks/index.' . $phpEx; $phpbb_hook = new phpbb_hook(array('exit_handler', 'phpbb_user_session_handler', 'append_sid', array('template', 'display'))); /* @var $phpbb_hook_finder \phpbb\hook\finder */ $phpbb_hook_finder = $phpbb_container->get('hook_finder'); foreach ($phpbb_hook_finder->find() as $hook) { @(include $phpbb_root_path . 'includes/hooks/' . $hook . '.' . $phpEx); }
phpbb_require_updated('includes/functions.' . $phpEx); phpbb_require_updated('includes/functions_content.' . $phpEx, true); phpbb_include_updated('includes/functions_admin.' . $phpEx); phpbb_include_updated('includes/utf/utf_normalizer.' . $phpEx); phpbb_include_updated('includes/utf/utf_tools.' . $phpEx); phpbb_require_updated('includes/functions_install.' . $phpEx); // Setup class loader first $phpbb_class_loader_new = new \phpbb\class_loader('phpbb\\', "{$phpbb_root_path}install/update/new/phpbb/", $phpEx); $phpbb_class_loader_new->register(); $phpbb_class_loader = new \phpbb\class_loader('phpbb\\', "{$phpbb_root_path}phpbb/", $phpEx); $phpbb_class_loader->register(); $phpbb_class_loader_ext = new \phpbb\class_loader('\\', "{$phpbb_root_path}ext/", $phpEx); $phpbb_class_loader_ext->register(); // Set up container $phpbb_config_php_file = new \phpbb\config_php_file($phpbb_root_path, $phpEx); $phpbb_container_builder = new \phpbb\di\container_builder($phpbb_config_php_file, $phpbb_root_path, $phpEx); $phpbb_container_builder->set_use_extensions(false); $phpbb_container_builder->set_dump_container(false); $phpbb_container_builder->set_use_custom_pass(false); $phpbb_container_builder->set_inject_config(false); $phpbb_container_builder->set_compile_container(false); $other_config_path = $phpbb_root_path . 'install/update/new/config/'; $config_path = file_exists($other_config_path . 'services.yml') ? $other_config_path : $phpbb_root_path . 'config/'; $phpbb_container_builder->set_config_path($config_path); $phpbb_container_builder->set_custom_parameters(array('core.root_path' => $phpbb_root_path, 'core.adm_relative_path' => $phpbb_adm_relative_path, 'core.php_ext' => $phpEx, 'core.table_prefix' => '', 'cache.driver.class' => 'phpbb\\cache\\driver\\file')); $phpbb_container = $phpbb_container_builder->get_container(); $phpbb_container->register('dbal.conn.driver')->setSynthetic(true); $phpbb_container->compile(); $phpbb_class_loader->set_cache($phpbb_container->get('cache.driver')); $phpbb_class_loader_ext->set_cache($phpbb_container->get('cache.driver')); $phpbb_dispatcher = $phpbb_container->get('dispatcher');
// In case $phpbb_adm_relative_path is not set (in case of an update), use the default. $phpbb_adm_relative_path = isset($phpbb_adm_relative_path) ? $phpbb_adm_relative_path : 'adm/'; $phpbb_admin_path = defined('PHPBB_ADMIN_PATH') ? PHPBB_ADMIN_PATH : $phpbb_root_path . $phpbb_adm_relative_path; // Include files require $phpbb_root_path . 'includes/functions.' . $phpEx; require 'D:\\Dev\\UniServerZ\\www\\qwp\\wp-content\\plugins\\wp-phpbb-unicorn\\inc/cache/functions_content.' . $phpEx; include $phpbb_root_path . 'includes/functions_compatibility.' . $phpEx; require $phpbb_root_path . 'includes/constants.' . $phpEx; require $phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx; // Set PHP error handler to ours set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler'); $phpbb_class_loader_ext = new \phpbb\class_loader('\\', "{$phpbb_root_path}ext/", $phpEx); $phpbb_class_loader_ext->register(); phpbb_load_extensions_autoloaders($phpbb_root_path); // Set up container $phpbb_container_builder = new \phpbb\di\container_builder($phpbb_config_php_file, $phpbb_root_path, $phpEx); $phpbb_container = $phpbb_container_builder->get_container(); $phpbb_class_loader->set_cache($phpbb_container->get('cache.driver')); $phpbb_class_loader_ext->set_cache($phpbb_container->get('cache.driver')); require $phpbb_root_path . 'includes/compatibility_globals.' . $phpEx; // Add own hook handler require $phpbb_root_path . 'includes/hooks/index.' . $phpEx; $phpbb_hook = new phpbb_hook(array('exit_handler', 'phpbb_user_session_handler', 'append_sid', array('template', 'display'))); $phpbb_hook_finder = $phpbb_container->get('hook_finder'); foreach ($phpbb_hook_finder->find() as $hook) { @(include $phpbb_root_path . 'includes/hooks/' . $hook . '.' . $phpEx); } /** * Main event which is triggered on every page * * You can use this event to load function files and initiate objects
/** * Build dependency injection container * * @throws \phpbb\install\exception\cannot_build_container_exception When container cannot be built */ protected function build_container() { // If the container has been already built just return. // Although this should never happen if ($this->container instanceof \Symfony\Component\DependencyInjection\ContainerInterface) { return; } // Check whether container can be built // We need config.php for that so let's check if it has been set up yet if (!filesize($this->phpbb_root_path . 'config.' . $this->php_ext)) { throw new cannot_build_container_exception(); } $phpbb_config_php_file = new \phpbb\config_php_file($this->phpbb_root_path, $this->php_ext); $phpbb_container_builder = new \phpbb\di\container_builder($this->phpbb_root_path, $this->php_ext); // For BC with functions that we need during install global $phpbb_container, $table_prefix; $disable_super_globals = $this->request->super_globals_disabled(); // This is needed because container_builder::get_env_parameters() uses $_SERVER if ($disable_super_globals) { $this->request->enable_super_globals(); } $other_config_path = $this->phpbb_root_path . 'install/update/new/config'; $config_path = is_dir($other_config_path) ? $other_config_path : $this->phpbb_root_path . 'config'; $this->container = $phpbb_container_builder->with_environment('production')->with_config($phpbb_config_php_file)->with_config_path($config_path)->without_compiled_container()->get_container(); // Setting request is required for the compatibility globals as those are generated from // this container if (!$this->container->isFrozen()) { $this->container->register('request')->setSynthetic(true); $this->container->register('language')->setSynthetic(true); } $this->container->set('request', $this->request); $this->container->set('language', $this->language); $this->container->compile(); $phpbb_container = $this->container; $table_prefix = $phpbb_config_php_file->get('table_prefix'); // Restore super globals to previous state if ($disable_super_globals) { $this->request->disable_super_globals(); } // Get compatibilty globals and constants $this->update_helper->include_file('includes/compatibility_globals.' . $this->php_ext); register_compatibility_globals(); $this->update_helper->include_file('includes/constants.' . $this->php_ext); }
$phpbb_root_path = __DIR__ . '/../'; $phpEx = substr(strrchr(__FILE__, '.'), 1); require $phpbb_root_path . 'includes/startup.' . $phpEx; require $phpbb_root_path . 'phpbb/class_loader.' . $phpEx; $phpbb_class_loader = new \phpbb\class_loader('phpbb\\', "{$phpbb_root_path}phpbb/", $phpEx); $phpbb_class_loader->register(); $phpbb_config_php_file = new \phpbb\config_php_file($phpbb_root_path, $phpEx); extract($phpbb_config_php_file->get_all()); if (!defined('PHPBB_ENVIRONMENT')) { @define('PHPBB_ENVIRONMENT', 'production'); } require $phpbb_root_path . 'includes/constants.' . $phpEx; require $phpbb_root_path . 'includes/functions.' . $phpEx; require $phpbb_root_path . 'includes/functions_admin.' . $phpEx; require $phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx; $phpbb_container_builder = new \phpbb\di\container_builder($phpbb_root_path, $phpEx); $phpbb_container = $phpbb_container_builder->with_config($phpbb_config_php_file); $input = new ArgvInput(); if ($input->hasParameterOption(array('--env'))) { $phpbb_container_builder->with_environment($input->getParameterOption('--env')); } if ($input->hasParameterOption(array('--safe-mode'))) { $phpbb_container_builder->without_extensions(); $phpbb_container_builder->without_cache(); } else { $phpbb_class_loader_ext = new \phpbb\class_loader('\\', "{$phpbb_root_path}ext/", $phpEx); $phpbb_class_loader_ext->register(); } $phpbb_container = $phpbb_container_builder->get_container(); $phpbb_container->get('request')->enable_super_globals(); require $phpbb_root_path . 'includes/compatibility_globals.' . $phpEx;
function main($mode, $sub) { global $template, $phpEx, $phpbb_root_path, $user, $db, $config, $cache, $auth, $language; global $request, $phpbb_admin_path, $phpbb_adm_relative_path, $phpbb_container, $phpbb_config_php_file; // We must enable super globals, otherwise creating a new instance of the request class, // using the new container with a dbal connection will fail with the following PHP Notice: // Object of class phpbb_request_deactivated_super_global could not be converted to int $request->enable_super_globals(); // Create a normal container now $phpbb_container_builder = new \phpbb\di\container_builder($phpbb_config_php_file, $phpbb_root_path, $phpEx); $phpbb_container_builder->set_dump_container(false); $phpbb_container_builder->set_use_extensions(false); if (file_exists($phpbb_root_path . 'install/update/new/config')) { $phpbb_container_builder->set_config_path($phpbb_root_path . 'install/update/new/config'); } $phpbb_container = $phpbb_container_builder->get_container(); // Writes into global $cache $cache = $phpbb_container->get('cache'); $this->tpl_name = 'install_update'; $this->page_title = 'UPDATE_INSTALLATION'; $this->old_location = $phpbb_root_path . 'install/update/old/'; $this->new_location = $phpbb_root_path . 'install/update/new/'; // Init DB extract($phpbb_config_php_file->get_all()); require $phpbb_root_path . 'includes/constants.' . $phpEx; // Special options for conflicts/modified files define('MERGE_NO_MERGE_NEW', 1); define('MERGE_NO_MERGE_MOD', 2); define('MERGE_NEW_FILE', 3); define('MERGE_MOD_FILE', 4); $dbms = $phpbb_config_php_file->convert_30_dbms_to_31($dbms); $db = new $dbms(); // Connect to DB $db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, false); // We do not need this any longer, unset for safety purposes unset($dbpasswd); // We need to fill the config to let internal functions correctly work $config = new \phpbb\config\db($db, new \phpbb\cache\driver\null(), CONFIG_TABLE); set_config(null, null, null, $config); set_config_count(null, null, null, $config); // Force template recompile $config['load_tplcompile'] = 1; // First of all, init the user session $user->session_begin(); $auth->acl($user->data); // Overwrite user's language with the selected one. // Config needs to be changed to ensure that guests also get the selected language. $config_default_lang = $config['default_lang']; $config['default_lang'] = $language; $user->data['user_lang'] = $language; $user->add_lang(array('common', 'acp/common', 'acp/board', 'install', 'posting')); // Reset the default_lang $config['default_lang'] = $config_default_lang; unset($config_default_lang); // If we are within the intro page we need to make sure we get up-to-date version info if ($sub == 'intro') { $cache->destroy('_version_info'); } // Set custom template again. ;) $paths = array($phpbb_root_path . 'install/update/new/adm/style', $phpbb_admin_path . 'style'); $paths = array_filter($paths, 'is_dir'); $template->set_custom_style(array(array('name' => 'adm', 'ext_path' => 'adm/style/')), $paths); $template->assign_vars(array('S_USER_LANG' => $user->lang['USER_LANG'], 'S_CONTENT_DIRECTION' => $user->lang['DIRECTION'], 'S_CONTENT_ENCODING' => 'UTF-8', 'S_CONTENT_FLOW_BEGIN' => $user->lang['DIRECTION'] == 'ltr' ? 'left' : 'right', 'S_CONTENT_FLOW_END' => $user->lang['DIRECTION'] == 'ltr' ? 'right' : 'left')); // Get current and latest version $version_helper = $phpbb_container->get('version_helper'); try { $this->latest_version = $version_helper->get_latest_on_current_branch(true); } catch (\RuntimeException $e) { $this->latest_version = false; $update_info = array(); include $phpbb_root_path . 'install/update/index.' . $phpEx; $info = empty($update_info) || !is_array($update_info) ? false : $update_info; if ($info !== false) { $this->latest_version = !empty($info['version']['to']) ? trim($info['version']['to']) : false; } } // For the current version we trick a bit. ;) $this->current_version = !empty($config['version_update_from']) ? $config['version_update_from'] : $config['version']; $up_to_date = version_compare(str_replace('rc', 'RC', strtolower($this->current_version)), str_replace('rc', 'RC', strtolower($this->latest_version)), '<') ? false : true; // Check for a valid update directory, else point the user to the phpbb.com website if (!file_exists($phpbb_root_path . 'install/update') || !file_exists($phpbb_root_path . 'install/update/index.' . $phpEx) || !file_exists($this->old_location) || !file_exists($this->new_location)) { $template->assign_vars(array('S_ERROR' => true, 'ERROR_MSG' => $up_to_date ? $user->lang['NO_UPDATE_FILES_UP_TO_DATE'] : sprintf($user->lang['NO_UPDATE_FILES_OUTDATED'], $config['version'], $this->current_version, $this->latest_version))); return; } $this->update_info = $this->get_file('update_info'); // Make sure the update directory holds the correct information // Since admins are able to run the update/checks more than once we only check if the current version is lower or equal than the version to which we update to. if (version_compare(str_replace('rc', 'RC', strtolower($this->current_version)), str_replace('rc', 'RC', strtolower($this->update_info['version']['to'])), '>')) { $template->assign_vars(array('S_ERROR' => true, 'ERROR_MSG' => sprintf($user->lang['INCOMPATIBLE_UPDATE_FILES'], $config['version'], $this->update_info['version']['from'], $this->update_info['version']['to']))); return; } // Check if the update files are actually meant to update from the current version if ($this->current_version != $this->update_info['version']['from']) { $template->assign_vars(array('S_ERROR' => true, 'ERROR_MSG' => sprintf($user->lang['INCOMPATIBLE_UPDATE_FILES'], $this->current_version, $this->update_info['version']['from'], $this->update_info['version']['to']))); } // Check if the update files stored are for the latest version... if (version_compare(strtolower($this->latest_version), strtolower($this->update_info['version']['to']), '>')) { $template->assign_vars(array('S_WARNING' => true, 'WARNING_MSG' => sprintf($user->lang['OLD_UPDATE_FILES'], $this->update_info['version']['from'], $this->update_info['version']['to'], $this->latest_version))); } // We store the "update to" version, because it is not always the latest. ;) $this->update_to_version = $this->update_info['version']['to']; // Fill DB version if (empty($config['dbms_version'])) { set_config('dbms_version', $db->sql_server_info(true)); } if ($this->test_update === false) { // What about the language file? Got it updated? if (in_array('language/' . $language . '/install.' . $phpEx, $this->update_info['files'])) { $lang = array(); include $this->new_location . 'language/' . $language . '/install.' . $phpEx; // this is the user's language.. just merge it $user->lang = array_merge($user->lang, $lang); } if ($language != 'en' && in_array('language/en/install.' . $phpEx, $this->update_info['files'])) { $lang = array(); include $this->new_location . 'language/en/install.' . $phpEx; // only add new keys to user's language in english $new_keys = array_diff(array_keys($lang), array_keys($user->lang)); foreach ($new_keys as $i => $new_key) { $user->lang[$new_key] = $lang[$new_key]; } } } // Include renderer and engine $this->include_file('includes/diff/diff.' . $phpEx); $this->include_file('includes/diff/engine.' . $phpEx); $this->include_file('includes/diff/renderer.' . $phpEx); // Make sure we stay at the file check if checking the files again if ($request->variable('check_again', false, false, \phpbb\request\request_interface::POST)) { $sub = $this->p_master->sub = 'file_check'; } switch ($sub) { case 'intro': $this->page_title = 'UPDATE_INSTALLATION'; $template->assign_vars(array('S_INTRO' => true, 'U_ACTION' => append_sid($this->p_master->module_url, "language={$language}&mode={$mode}&sub=version_check"))); // Make sure the update list is destroyed. $cache->destroy('_update_list'); $cache->destroy('_diff_files'); $cache->destroy('_expected_files'); break; case 'version_check': $this->page_title = 'STAGE_VERSION_CHECK'; $template->assign_vars(array('S_VERSION_CHECK' => true, 'U_ACTION' => append_sid($this->p_master->module_url, "language={$language}&mode={$mode}&sub=file_check"), 'S_UP_TO_DATE' => $up_to_date, 'LATEST_VERSION' => $this->latest_version, 'CURRENT_VERSION' => $this->current_version)); // Print out version the update package updates to if ($this->latest_version != $this->update_info['version']['to']) { $template->assign_var('PACKAGE_VERSION', $this->update_info['version']['to']); } // Since some people try to update to RC releases, but phpBB.com tells them the last version is the version they currently run // we are faced with the updater thinking the database schema is up-to-date; which it is, but should be updated none-the-less // We now try to cope with this by triggering the update process if (version_compare(str_replace('rc', 'RC', strtolower($this->current_version)), str_replace('rc', 'RC', strtolower($this->update_info['version']['to'])), '<')) { $template->assign_vars(array('S_UP_TO_DATE' => false)); } break; case 'update_db': // Redirect the user to the database update script with some explanations... $template->assign_vars(array('S_DB_UPDATE' => true, 'S_DB_UPDATE_FINISHED' => $config['version'] == $this->update_info['version']['to'] ? true : false, 'U_DB_UPDATE' => append_sid($phpbb_root_path . 'install/database_update.' . $phpEx, 'type=1&language=' . $user->data['user_lang']), 'U_DB_UPDATE_ACTION' => append_sid($this->p_master->module_url, "language={$language}&mode={$mode}&sub=update_db"), 'U_ACTION' => append_sid($this->p_master->module_url, "language={$language}&mode={$mode}&sub=file_check"), 'L_EVERYTHING_UP_TO_DATE' => $user->lang('EVERYTHING_UP_TO_DATE', append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=login'), append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=login&redirect=' . $phpbb_adm_relative_path . 'index.php%3Fi=send_statistics%26mode=send_statistics')))); // Do not display incompatible package note after successful update if ($config['version'] == $this->update_info['version']['to']) { $template->assign_var('S_ERROR', false); } break; case 'file_check': // retrieve info on what changes should have already been made to the files. $expected_files = $cache->get('_expected_files'); if (!$expected_files) { $expected_files = array(); } // Now make sure the previous file collection is no longer valid... $cache->destroy('_diff_files'); $this->page_title = 'STAGE_FILE_CHECK'; // Now make sure our update list is correct if the admin refreshes $action = request_var('action', ''); // We are directly within an update. To make sure our update list is correct we check its status. $update_list = $request->variable('check_again', false, false, \phpbb\request\request_interface::POST) ? false : $cache->get('_update_list'); $modified = $update_list !== false ? @filemtime($cache->get_driver()->cache_dir . 'data_update_list.' . $phpEx) : 0; // Make sure the list is up-to-date if ($update_list !== false) { $get_new_list = false; foreach ($this->update_info['files'] as $file) { if (file_exists($phpbb_root_path . $file) && filemtime($phpbb_root_path . $file) > $modified) { $get_new_list = true; break; } } } else { $get_new_list = true; } if (!$get_new_list && $update_list['status'] != -1) { $get_new_list = true; } if ($get_new_list) { $this->get_update_structure($update_list, $expected_files); $cache->put('_update_list', $update_list); // Refresh the page if we are still not finished... if ($update_list['status'] != -1) { $refresh_url = append_sid($this->p_master->module_url, "language={$language}&mode={$mode}&sub=file_check"); meta_refresh(2, $refresh_url); $template->assign_vars(array('S_IN_PROGRESS' => true, 'S_COLLECTED' => (int) $update_list['status'], 'S_TO_COLLECT' => sizeof($this->update_info['files']), 'L_IN_PROGRESS' => $user->lang['COLLECTING_FILE_DIFFS'], 'L_IN_PROGRESS_EXPLAIN' => sprintf($user->lang['NUMBER_OF_FILES_COLLECTED'], (int) $update_list['status'], sizeof($this->update_info['files']) + sizeof($this->update_info['deleted'])))); return; } } if ($action == 'diff') { $this->show_diff($update_list); return; } if (sizeof($update_list['no_update'])) { $template->assign_vars(array('S_NO_UPDATE_FILES' => true, 'NO_UPDATE_FILES' => implode(', ', array_map('htmlspecialchars', $update_list['no_update'])))); } $new_expected_files = array(); // Now assign the list to the template foreach ($update_list as $status => $filelist) { if ($status == 'no_update' || !sizeof($filelist) || $status == 'status' || $status == 'status_deleted') { continue; } /* $template->assign_block_vars('files', array( 'S_STATUS' => true, 'STATUS' => $status, 'L_STATUS' => $user->lang['STATUS_' . strtoupper($status)], 'TITLE' => $user->lang['FILES_' . strtoupper($status)], 'EXPLAIN' => $user->lang['FILES_' . strtoupper($status) . '_EXPLAIN'], ) );*/ foreach ($filelist as $file_struct) { $s_binary = !empty($this->update_info['binary']) && in_array($file_struct['filename'], $this->update_info['binary']) ? true : false; $filename = htmlspecialchars($file_struct['filename']); if (strrpos($filename, '/') !== false) { $dir_part = substr($filename, 0, strrpos($filename, '/') + 1); $file_part = substr($filename, strrpos($filename, '/') + 1); } else { $dir_part = ''; $file_part = $filename; } $diff_url = append_sid($this->p_master->module_url, "language={$language}&mode={$mode}&sub=file_check&action=diff&status={$status}&file=" . urlencode($file_struct['filename'])); if (isset($file_struct['as_expected']) && $file_struct['as_expected']) { $new_expected_files[$file_struct['filename']] = $expected_files[$file_struct['filename']]; } else { $template->assign_block_vars($status, array('STATUS' => $status, 'FILENAME' => $filename, 'DIR_PART' => $dir_part, 'FILE_PART' => $file_part, 'NUM_CONFLICTS' => isset($file_struct['conflicts']) ? $file_struct['conflicts'] : 0, 'S_CUSTOM' => $file_struct['custom'] ? true : false, 'S_BINARY' => $s_binary, 'CUSTOM_ORIGINAL' => $file_struct['custom'] ? $file_struct['original'] : '', 'U_SHOW_DIFF' => $diff_url, 'L_SHOW_DIFF' => $status != 'up_to_date' ? $user->lang['SHOW_DIFF_' . strtoupper($status)] : '', 'U_VIEW_MOD_FILE' => $diff_url . '&op=' . MERGE_MOD_FILE, 'U_VIEW_NEW_FILE' => $diff_url . '&op=' . MERGE_NEW_FILE, 'U_VIEW_NO_MERGE_MOD' => $diff_url . '&op=' . MERGE_NO_MERGE_MOD, 'U_VIEW_NO_MERGE_NEW' => $diff_url . '&op=' . MERGE_NO_MERGE_NEW)); } } } $cache->put('_expected_files', $new_expected_files); $all_up_to_date = true; foreach ($update_list as $status => $filelist) { if ($status != 'up_to_date' && $status != 'custom' && $status != 'status' && $status != 'status_deleted' && sizeof($filelist)) { $all_up_to_date = false; break; } } $template->assign_vars(array('S_FILE_CHECK' => true, 'S_ALL_UP_TO_DATE' => $all_up_to_date, 'S_VERSION_UP_TO_DATE' => $up_to_date, 'S_UP_TO_DATE' => $up_to_date, 'U_ACTION' => append_sid($this->p_master->module_url, "language={$language}&mode={$mode}&sub=file_check"), 'U_UPDATE_ACTION' => append_sid($this->p_master->module_url, "language={$language}&mode={$mode}&sub=update_files"), 'U_DB_UPDATE_ACTION' => append_sid($this->p_master->module_url, "language={$language}&mode={$mode}&sub=update_db"))); // Since some people try to update to RC releases, but phpBB.com tells them the last version is the version they currently run // we are faced with the updater thinking the database schema is up-to-date; which it is, but should be updated none-the-less // We now try to cope with this by triggering the update process if (version_compare(str_replace('rc', 'RC', strtolower($this->current_version)), str_replace('rc', 'RC', strtolower($this->update_info['version']['to'])), '<')) { $template->assign_vars(array('S_UP_TO_DATE' => false)); } if ($all_up_to_date) { global $phpbb_container; $phpbb_log = $phpbb_container->get('log'); // Add database update to log $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_UPDATE_PHPBB', time(), array($this->current_version, $this->update_to_version)); $db->sql_return_on_error(true); $db->sql_query('DELETE FROM ' . CONFIG_TABLE . " WHERE config_name = 'version_update_from'"); $db->sql_return_on_error(false); $cache->purge(); } break; case 'update_files': $this->page_title = 'STAGE_UPDATE_FILES'; $s_hidden_fields = ''; $params = array(); $conflicts = request_var('conflict', array('' => 0)); $modified = request_var('modified', array('' => 0)); foreach ($conflicts as $filename => $merge_option) { $s_hidden_fields .= '<input type="hidden" name="conflict[' . htmlspecialchars($filename) . ']" value="' . $merge_option . '" />'; $params[] = 'conflict[' . urlencode($filename) . ']=' . urlencode($merge_option); } foreach ($modified as $filename => $merge_option) { if (!$merge_option) { continue; } $s_hidden_fields .= '<input type="hidden" name="modified[' . htmlspecialchars($filename) . ']" value="' . $merge_option . '" />'; $params[] = 'modified[' . urlencode($filename) . ']=' . urlencode($merge_option); } $no_update = request_var('no_update', array(0 => '')); foreach ($no_update as $index => $filename) { $s_hidden_fields .= '<input type="hidden" name="no_update[]" value="' . htmlspecialchars($filename) . '" />'; $params[] = 'no_update[]=' . urlencode($filename); } // Before the user is choosing his preferred method, let's create the content list... $update_list = $cache->get('_update_list'); if ($update_list === false) { trigger_error($user->lang['NO_UPDATE_INFO'], E_USER_ERROR); } // Check if the conflicts data is valid if (sizeof($conflicts)) { $conflict_filenames = array(); foreach ($update_list['conflict'] as $files) { $conflict_filenames[] = $files['filename']; } $new_conflicts = array(); foreach ($conflicts as $filename => $diff_method) { if (in_array($filename, $conflict_filenames)) { $new_conflicts[$filename] = $diff_method; } } $conflicts = $new_conflicts; } // Build list for modifications if (sizeof($modified)) { $modified_filenames = array(); foreach ($update_list['modified'] as $files) { $modified_filenames[] = $files['filename']; } $new_modified = array(); foreach ($modified as $filename => $diff_method) { if (in_array($filename, $modified_filenames)) { $new_modified[$filename] = $diff_method; } } $modified = $new_modified; } // Check number of conflicting files, they need to be equal. For modified files the number can differ if (sizeof($update_list['conflict']) != sizeof($conflicts)) { trigger_error($user->lang['MERGE_SELECT_ERROR'], E_USER_ERROR); } // Before we do anything, let us diff the files and store the raw file information "somewhere" $get_files = false; $file_list = $cache->get('_diff_files'); $expected_files = $cache->get('_expected_files'); if ($file_list === false || $file_list['status'] != -1) { $get_files = true; } if ($get_files) { if ($file_list === false) { $file_list = array('status' => 0); } if (!isset($expected_files) || $expected_files === false) { $expected_files = array(); } $processed = 0; foreach ($update_list as $status => $files) { if (!is_array($files)) { continue; } foreach ($files as $file_struct) { // Skip this file if the user selected to not update it if (in_array($file_struct['filename'], $no_update)) { $expected_files[$file_struct['filename']] = false; continue; } // Already handled... then skip of course... if (isset($file_list[$file_struct['filename']])) { continue; } // Refresh if we reach 5 diffs... if ($processed >= 5) { $cache->put('_diff_files', $file_list); if ($request->variable('download', false)) { $params[] = 'download=1'; } $redirect_url = append_sid($this->p_master->module_url, "language={$language}&mode={$mode}&sub=update_files&" . implode('&', $params)); meta_refresh(3, $redirect_url); $template->assign_vars(array('S_IN_PROGRESS' => true, 'L_IN_PROGRESS' => $user->lang['MERGING_FILES'], 'L_IN_PROGRESS_EXPLAIN' => $user->lang['MERGING_FILES_EXPLAIN'])); return; } if (file_exists($phpbb_root_path . $file_struct['filename'])) { $contents = file_get_contents($phpbb_root_path . $file_struct['filename']); if (isset($expected_files[$file_struct['filename']]) && md5($contents) == $expected_files[$file_struct['filename']]) { continue; } } $original_filename = $file_struct['custom'] ? $file_struct['original'] : $file_struct['filename']; switch ($status) { case 'modified': $option = isset($modified[$file_struct['filename']]) ? $modified[$file_struct['filename']] : 0; switch ($option) { case MERGE_NO_MERGE_NEW: $contents = file_get_contents($this->new_location . $original_filename); break; case MERGE_NO_MERGE_MOD: $contents = file_get_contents($phpbb_root_path . $file_struct['filename']); break; default: $diff = $this->return_diff($this->old_location . $original_filename, $phpbb_root_path . $file_struct['filename'], $this->new_location . $original_filename); $contents = implode("\n", $diff->merged_output()); unset($diff); break; } $expected_files[$file_struct['filename']] = md5($contents); $file_list[$file_struct['filename']] = '_file_' . md5($file_struct['filename']); $cache->put($file_list[$file_struct['filename']], base64_encode($contents)); $file_list['status']++; $processed++; break; case 'conflict': $option = $conflicts[$file_struct['filename']]; $contents = ''; switch ($option) { case MERGE_NO_MERGE_NEW: $contents = file_get_contents($this->new_location . $original_filename); break; case MERGE_NO_MERGE_MOD: $contents = file_get_contents($phpbb_root_path . $file_struct['filename']); break; default: $diff = $this->return_diff($this->old_location . $original_filename, $phpbb_root_path . $file_struct['filename'], $this->new_location . $original_filename); if ($option == MERGE_NEW_FILE) { $contents = implode("\n", $diff->merged_new_output()); } else { if ($option == MERGE_MOD_FILE) { $contents = implode("\n", $diff->merged_orig_output()); } else { unset($diff); break 2; } } unset($diff); break; } $expected_files[$file_struct['filename']] = md5($contents); $file_list[$file_struct['filename']] = '_file_' . md5($file_struct['filename']); $cache->put($file_list[$file_struct['filename']], base64_encode($contents)); $file_list['status']++; $processed++; break; } } } $cache->put('_expected_files', $expected_files); } $file_list['status'] = -1; $cache->put('_diff_files', $file_list); if ($request->variable('download', false)) { $this->include_file('includes/functions_compress.' . $phpEx); $use_method = request_var('use_method', ''); $methods = array('.tar'); $available_methods = array('.tar.gz' => 'zlib', '.tar.bz2' => 'bz2', '.zip' => 'zlib'); foreach ($available_methods as $type => $module) { if (!@extension_loaded($module)) { continue; } $methods[] = $type; } // Let the user decide in which format he wants to have the pack if (!$use_method) { $this->page_title = 'SELECT_DOWNLOAD_FORMAT'; $radio_buttons = ''; foreach ($methods as $method) { $radio_buttons .= '<label><input type="radio"' . (!$radio_buttons ? ' id="use_method"' : '') . ' class="radio" value="' . $method . '" name="use_method" /> ' . $method . '</label>'; } $template->assign_vars(array('S_DOWNLOAD_FILES' => true, 'U_ACTION' => append_sid($this->p_master->module_url, "language={$language}&mode={$mode}&sub=update_files"), 'RADIO_BUTTONS' => $radio_buttons, 'S_HIDDEN_FIELDS' => $s_hidden_fields)); // To ease the update process create a file location map $update_list = $cache->get('_update_list'); $script_path = $config['force_server_vars'] ? $config['script_path'] == '/' ? '/' : $config['script_path'] . '/' : $user->page['root_script_path']; foreach ($update_list as $status => $files) { if ($status == 'up_to_date' || $status == 'no_update' || $status == 'status' || $status == 'status_deleted') { continue; } foreach ($files as $file_struct) { if (in_array($file_struct['filename'], $no_update)) { continue; } $template->assign_block_vars('location', array('SOURCE' => htmlspecialchars($file_struct['filename']), 'DESTINATION' => $script_path . htmlspecialchars($file_struct['filename']))); } } return; } if (!in_array($use_method, $methods)) { $use_method = '.tar'; } $update_mode = 'download'; } else { $this->include_file('includes/functions_transfer.' . $phpEx); // Choose FTP, if not available use fsock... $method = basename(request_var('method', '')); $submit = isset($_POST['submit']) ? true : false; $test_ftp_connection = request_var('test_connection', ''); if (!$method || !class_exists($method)) { $method = 'ftp'; $methods = transfer::methods(); if (!in_array('ftp', $methods)) { $method = $methods[0]; } } $test_connection = false; if ($test_ftp_connection || $submit) { $transfer = new $method(request_var('host', ''), request_var('username', ''), htmlspecialchars_decode($request->untrimmed_variable('password', '')), request_var('root_path', ''), request_var('port', ''), request_var('timeout', '')); $test_connection = $transfer->open_session(); // Make sure that the directory is correct by checking for the existence of common.php if ($test_connection === true) { // Check for common.php file if (!$transfer->file_exists($phpbb_root_path, 'common.' . $phpEx)) { $test_connection = 'ERR_WRONG_PATH_TO_PHPBB'; } } $transfer->close_session(); // Make sure the login details are correct before continuing if ($submit && $test_connection !== true) { $submit = false; $test_ftp_connection = true; } } $s_hidden_fields .= build_hidden_fields(array('method' => $method)); if (!$submit) { $this->page_title = 'SELECT_FTP_SETTINGS'; if (!class_exists($method)) { trigger_error('Method does not exist.', E_USER_ERROR); } $requested_data = call_user_func(array($method, 'data')); foreach ($requested_data as $data => $default) { $template->assign_block_vars('data', array('DATA' => $data, 'NAME' => $user->lang[strtoupper($method . '_' . $data)], 'EXPLAIN' => $user->lang[strtoupper($method . '_' . $data) . '_EXPLAIN'], 'DEFAULT' => $request->variable($data, (string) $default))); } $template->assign_vars(array('S_CONNECTION_SUCCESS' => $test_ftp_connection && $test_connection === true ? true : false, 'S_CONNECTION_FAILED' => $test_ftp_connection && $test_connection !== true ? true : false, 'ERROR_MSG' => $test_ftp_connection && $test_connection !== true ? $user->lang[$test_connection] : '', 'S_FTP_UPLOAD' => true, 'UPLOAD_METHOD' => $method, 'U_ACTION' => append_sid($this->p_master->module_url, "language={$language}&mode={$mode}&sub=update_files"), 'U_DOWNLOAD_METHOD' => append_sid($this->p_master->module_url, "language={$language}&mode={$mode}&sub=update_files&download=1"), 'S_HIDDEN_FIELDS' => $s_hidden_fields)); return; } $update_mode = 'upload'; } // Now update the installation or download the archive... $download_filename = 'update_' . $this->update_info['version']['from'] . '_to_' . $this->update_info['version']['to']; $archive_filename = $download_filename . '_' . time() . '_' . unique_id(); // Now init the connection if ($update_mode == 'download') { if (function_exists('phpbb_is_writable') && !phpbb_is_writable($phpbb_root_path . 'store/')) { trigger_error(sprintf('The directory “%s” is not writable.', $phpbb_root_path . 'store/'), E_USER_ERROR); } if ($use_method == '.zip') { $compress = new compress_zip('w', $phpbb_root_path . 'store/' . $archive_filename . $use_method); } else { $compress = new compress_tar('w', $phpbb_root_path . 'store/' . $archive_filename . $use_method, $use_method); } } else { $transfer = new $method(request_var('host', ''), request_var('username', ''), htmlspecialchars_decode($request->untrimmed_variable('password', '')), request_var('root_path', ''), request_var('port', ''), request_var('timeout', '')); $transfer->open_session(); } // Ok, go through the update list and do the operations based on their status foreach ($update_list as $status => $files) { if (!is_array($files)) { continue; } foreach ($files as $file_struct) { // Skip this file if the user selected to not update it if (in_array($file_struct['filename'], $no_update)) { continue; } $original_filename = $file_struct['custom'] ? $file_struct['original'] : $file_struct['filename']; switch ($status) { case 'new': case 'new_conflict': case 'not_modified': if ($update_mode == 'download') { $compress->add_custom_file($this->new_location . $original_filename, $file_struct['filename']); } else { if ($status != 'new') { $transfer->rename($file_struct['filename'], $file_struct['filename'] . '.bak'); } // New directory too? $dirname = dirname($file_struct['filename']); if ($dirname && !file_exists($phpbb_root_path . $dirname)) { $transfer->make_dir($dirname); } $transfer->copy_file($this->new_location . $original_filename, $file_struct['filename']); } break; case 'modified': $contents = base64_decode($cache->get($file_list[$file_struct['filename']])); if ($update_mode == 'download') { $compress->add_data($contents, $file_struct['filename']); } else { // @todo add option to specify if a backup file should be created? $transfer->rename($file_struct['filename'], $file_struct['filename'] . '.bak'); $transfer->write_file($file_struct['filename'], $contents); } break; case 'conflict': $contents = base64_decode($cache->get($file_list[$file_struct['filename']])); if ($update_mode == 'download') { $compress->add_data($contents, $file_struct['filename']); } else { $transfer->rename($file_struct['filename'], $file_struct['filename'] . '.bak'); $transfer->write_file($file_struct['filename'], $contents); } break; case 'deleted': if ($update_mode != 'download') { $transfer->rename($file_struct['filename'], $file_struct['filename'] . '.bak'); } break; } } } if ($update_mode == 'download') { $compress->close(); $compress->download($archive_filename, $download_filename); @unlink($phpbb_root_path . 'store/' . $archive_filename . $use_method); exit; } else { $transfer->close_session(); $template->assign_vars(array('S_UPLOAD_SUCCESS' => true, 'U_ACTION' => append_sid($this->p_master->module_url, "language={$language}&mode={$mode}&sub=file_check"))); return; } break; } }
break; case E_DEPRECATED: return true; break; } return false; } phpbb_require_updated('includes/startup.' . $phpEx, $phpbb_root_path); phpbb_require_updated('phpbb/class_loader.' . $phpEx, $phpbb_root_path); $phpbb_class_loader_new = new \phpbb\class_loader('phpbb\\', "{$phpbb_root_path}install/update/new/phpbb/", $phpEx); $phpbb_class_loader_new->register(); $phpbb_class_loader = new \phpbb\class_loader('phpbb\\', "{$phpbb_root_path}phpbb/", $phpEx); $phpbb_class_loader->register(); $phpbb_class_loader_ext = new \phpbb\class_loader('\\', "{$phpbb_root_path}ext/", $phpEx); $phpbb_class_loader_ext->register(); // In case $phpbb_adm_relative_path is not set (in case of an update), use the default. $phpbb_adm_relative_path = isset($phpbb_adm_relative_path) ? $phpbb_adm_relative_path : 'adm/'; $phpbb_admin_path = defined('PHPBB_ADMIN_PATH') ? PHPBB_ADMIN_PATH : $phpbb_root_path . $phpbb_adm_relative_path; // Include files phpbb_require_updated('includes/functions.' . $phpEx, $phpbb_root_path); phpbb_require_updated('includes/functions_content.' . $phpEx, $phpbb_root_path); phpbb_include_updated('includes/functions_compatibility.' . $phpEx, $phpbb_root_path); phpbb_require_updated('includes/functions_user.' . $phpEx, $phpbb_root_path); phpbb_require_updated('includes/utf/utf_tools.' . $phpEx, $phpbb_root_path); // Set PHP error handler to ours set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'installer_msg_handler'); $phpbb_installer_container_builder = new \phpbb\di\container_builder($phpbb_root_path, $phpEx); $phpbb_installer_container_builder->with_environment('installer')->without_extensions(); $other_config_path = $phpbb_root_path . 'install/update/new/config'; $config_path = file_exists($other_config_path . '/installer/config.yml') ? $other_config_path : $phpbb_root_path . 'config'; $phpbb_installer_container = $phpbb_installer_container_builder->with_config_path($config_path)->with_custom_parameters(array('cache.driver.class' => 'phpbb\\cache\\driver\\file'))->get_container();
/** * Loads the ContainerBuilder from the cache. * @return \Symfony\Component\DependencyInjection\ContainerBuilder * @throws \LogicException */ protected function getContainerBuilder() { $phpbb_config_php_file = new \phpbb\config_php_file($this->phpbb_root_path, $this->php_ext); if (version_compare($this->config['version'], '3.2.*', '<')) { $container_builder = new \phpbb\di\container_builder($phpbb_config_php_file, $this->phpbb_root_path, $this->php_ext); $container_builder->set_compile_container(true); $container_builder->set_dump_container(false); $container = $container_builder->get_container(); } else { $this->request->enable_super_globals(); $container_builder = new \phpbb\di\container_builder($this->phpbb_root_path, $this->php_ext); $container_builder->without_cache(); $container = $container_builder->with_config($phpbb_config_php_file)->get_container(); $this->request->disable_super_globals(); } return $container; }
public function __construct() { global $db, $user, $auth, $cache, $settings, $table_prefix; global $quickinstall_path, $phpbb_root_path, $phpEx, $config; // include installation functions include $quickinstall_path . 'includes/functions_install.' . $phpEx; // postgres uses remove_comments function which is defined in functions_admin include $phpbb_root_path . 'includes/functions_admin.' . $phpEx; if (defined('PHPBB_31')) { $config->set('rand_seed', md5(mt_rand())); $config->set('rand_seed_last_update', time()); } else { $config = array_merge($config, array('rand_seed' => md5(mt_rand()), 'rand_seed_last_update' => time())); } // load installer lang // qi::add_lang('phpbb'); // phpbb's install uses $lang instead of $user->lang // need to use $GLOBALS here $GLOBALS['lang'] =& $user->lang; global $lang; // Request some variables that are used several times here. $dbms = $settings->get_config('dbms'); $dbhost = $settings->get_config('dbhost'); $db_prefix = validate_dbname($settings->get_config('db_prefix'), true); $dbname = validate_dbname($settings->get_config('dbname'), true); $dbpasswd = $settings->get_config('dbpasswd'); $dbuser = $settings->get_config('dbuser'); $site_dir = validate_dbname($settings->get_config('dbname'), true, true); $site_name = $settings->get_config('site_name', '', true); $site_desc = $settings->get_config('site_desc', '', true); $admin_name = $settings->get_config('admin_name', '', true); $admin_pass = $settings->get_config('admin_pass', '', true); $alt_env = $settings->get_config('alt_env', ''); $automod = !defined('PHPBB_31') && $settings->get_config('automod', false) ? true : false; if ($alt_env !== '' && (!file_exists("{$quickinstall_path}sources/phpBB3_alt/{$alt_env}") || is_file("{$quickinstall_path}sources/phpBB3_alt/{$alt_env}"))) { create_board_warning($user->lang['MINOR_MISHAP'], $user->lang['NO_ALT_ENV_FOUND'], 'main'); } if ($automod) { $empty = true; // There can be '.', '..' and/or '.gitkeep' in the AutoMOD directory. $dh = opendir("{$quickinstall_path}sources/automod"); while (($file = readdir($dh)) !== false) { if ($file[0] != '.') { $empty = false; break; } } if ($empty) { create_board_warning($user->lang['NO_AUTOMOD_TITLE'], $user->lang['NO_AUTOMOD'], 'main'); } } // Set up our basic founder. $user->data['user_id'] = 2; // $user->data['username'] = $admin_name; $user->data['user_colour'] = 'AA0000'; // overwrite some of them ;) $user->lang = array_merge($user->lang, array('CONFIG_SITE_DESC' => $site_desc, 'CONFIG_SITENAME' => $site_name)); // check if we have a board db (and directory) name if (!$dbname) { create_board_warning($user->lang['GENERAL_ERROR'], $user->lang['NO_DB'], 'main'); } // Set the new board as root path. $board_dir = $settings->get_boards_dir() . $site_dir . '/'; $board_url = $settings->get_boards_url() . $site_dir . '/'; $phpbb_root_path = $board_dir; if (!defined('PHPBB_ROOT_PATH')) { define('PHPBB_ROOT_PATH', $board_dir); } if (file_exists($board_dir)) { if ($settings->get_config('delete_files', false)) { file_functions::delete_dir($board_dir); } else { create_board_warning($user->lang['MINOR_MISHAP'], sprintf($user->lang['DIR_EXISTS'], $board_dir), 'main'); } } // copy all of our files file_functions::copy_dir($quickinstall_path . 'sources/' . ($alt_env === '' ? 'phpBB3/' : "phpBB3_alt/{$alt_env}/"), $board_dir); if (!defined('PHPBB_31')) { // copy qi's lang file for the log $qi_lang = $settings->get_config('qi_lang'); if (file_exists("{$quickinstall_path}language/{$qi_lang}/info_acp_qi.{$phpEx}") && file_exists("{$board_dir}language/{$qi_lang}")) { copy("{$quickinstall_path}language/{$qi_lang}/info_acp_qi.{$phpEx}", "{$board_dir}language/{$qi_lang}/mods/info_acp_qi.{$phpEx}"); } else { copy("{$quickinstall_path}language/en/info_acp_qi.{$phpEx}", "{$board_dir}language/en/mods/info_acp_qi.{$phpEx}"); } } if ($dbms == 'sqlite') { $dbhost = $dbhost . $db_prefix . $dbname; } else { if ($dbms == 'firebird') { $dbhost = $db_prefix . $dbname; // temp remove some list($db_prefix, $dbname, $temp1, $temp2) = array('', '', $db_prefix, $dbname); } } // Set the new board as language path to get language files from outside phpBB //$user->set_custom_lang_path($phpbb_root_path . 'language/'); $user->lang_path = $phpbb_root_path . 'language/'; if (substr($user->lang_path, -1) != '/') { $user->lang_path .= '/'; } // Write to config.php ;) if (defined('PHPBB_32')) { $config_version = '3.2'; } else { if (defined('PHPBB_31')) { $config_version = '3.1'; } else { $config_version = '3.0'; } } $config_data = "<?php\n"; $config_data .= "// phpBB {$config_version}.x auto-generated configuration file\n// Do not change anything in this file!\n"; $config_data_array = array('$dbhost' => $dbhost, '$dbport' => $settings->get_config('dbport'), '$dbname' => $db_prefix . $dbname, '$dbuser' => $dbuser, '$dbpasswd' => htmlspecialchars_decode($dbpasswd), '$table_prefix' => $table_prefix); if (defined('PHPBB_31')) { $config_data_array['$dbms'] = "phpbb\\\\db\\\\driver\\\\{$dbms}"; $config_data_array['$acm_type'] = 'phpbb\\\\cache\\\\driver\\\\file'; $config_data_array['$phpbb_adm_relative_path'] = 'adm/'; } else { $config_data_array['$dbms'] = $dbms; $config_data_array['$acm_type'] = 'file'; $config_data_array['$load_extensions'] = ''; } foreach ($config_data_array as $key => $value) { $config_data .= "{$key} = '{$value}';\n"; } unset($config_data_array); $config_data .= "\n@define('PHPBB_INSTALLED', true);\n"; $config_data .= "@define('DEBUG', true);\n"; if (defined('PHPBB_32')) { $config_data .= "@define('PHPBB_ENVIRONMENT', 'production');\n"; } if (defined('PHPBB_31')) { $config_data .= "//@define('DEBUG_CONTAINER', true);\n"; $config_data .= "@define('PHPBB_DISPLAY_LOAD_TIME', true);\n"; } else { $config_data .= "@define('DEBUG_EXTRA', true);\n"; $config_data .= '?' . '>'; // Done this to prevent highlighting editors getting confused! } file_put_contents($board_dir . 'config.' . $phpEx, $config_data); if ($dbms == 'firebird') { // and now restore list($db_prefix, $dbname) = array($temp1, $temp2); } $db = db_connect(); if ($settings->get_config('drop_db', 0)) { $db->sql_query('DROP DATABASE IF EXISTS ' . $db_prefix . $dbname); } else { // Check if the database exists. if ($dbms == 'sqlite') { $db_check = $db->sql_select_db($dbhost); } else { if ($dbms == 'firebird') { $db_check = $db->sql_select_db($settings->get_cache_dir() . $db_prefix . $dbname); } else { if ($dbms == 'postgres') { global $sql_db; $error_collector = new phpbb_error_collector(); $error_collector->install(); $db_check_conn = new $sql_db(); $db_check_conn->sql_connect($dbhost, $dbuser, $dbpasswd, $db_prefix . $dbname, $dbport, false, false); $error_collector->uninstall(); $db_check = count($error_collector->errors) == 0; } else { $db_check = $db->sql_select_db($db_prefix . $dbname); } } } if ($db_check) { create_board_warning($user->lang['MINOR_MISHAP'], sprintf($user->lang['DB_EXISTS'], $db_prefix . $dbname), 'main'); } } if ($dbms == 'sqlite') { $db->sql_create_db($dbhost); $db->sql_select_db($dbhost); } else { if ($dbms == 'firebird') { $db->sql_query('CREATE DATABASE ' . $settings->get_cache_dir() . $db_prefix . $dbname); $db->sql_select_db($settings->get_cache_dir() . $db_prefix . $dbname); } else { if ($dbms == 'postgres') { global $sql_db; $db->sql_query('CREATE DATABASE ' . $db_prefix . $dbname); $db = new $sql_db(); $db->sql_connect($dbhost, $dbuser, $dbpasswd, $db_prefix . $dbname, $dbport, false, false); $db->sql_return_on_error(true); } else { $db->sql_query('CREATE DATABASE ' . $db_prefix . $dbname); $db->sql_select_db($db_prefix . $dbname); } } } // include install lang from phpbb. But only if it exists $default_lang = $settings->get_config('default_lang'); $selected_lang = $phpbb_root_path . "language/{$default_lang}/"; if (file_exists($selected_lang)) { qi::add_lang('install', $selected_lang); } else { // Assume that English is always available $default_lang = 'en'; qi::add_lang('install', $phpbb_root_path . 'language/en/'); } // perform sql load_schema($phpbb_root_path . 'install/schemas/', $dbms); $current_time = time(); $user_ip = !empty($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '0.0.0.0'; $user_ip = htmlspecialchars($user_ip); $script_path = !empty($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : getenv('PHP_SELF'); if (!$script_path) { $script_path = !empty($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : getenv('REQUEST_URI'); } // Replace backslashes and doubled slashes (could happen on some proxy setups) $script_path = trim(dirname($script_path)); $script_path = str_replace(array('\\', '//'), '/', $script_path); // Make sure $script_path ends with a slash (/). $script_path = substr($script_path, -1) != '/' ? $script_path . '/' : $script_path; $script_path .= $settings->get_boards_dir() . $site_dir . '/'; $config_ary = array('board_startdate' => $current_time, 'default_lang' => $default_lang, 'server_name' => $settings->get_config('server_name'), 'server_port' => $settings->get_config('server_port', 0), 'board_email' => $settings->get_config('board_email'), 'board_contact' => $settings->get_config('board_email'), 'cookie_domain' => $settings->get_config('cookie_domain'), 'default_dateformat' => $user->lang['default_dateformat'], 'email_enable' => $settings->get_config('email_enable', 0), 'smtp_delivery' => $settings->get_config('smtp_delivery', 0), 'smtp_host' => $settings->get_config('smtp_host'), 'smtp_auth_method' => $settings->get_config('smtp_auth'), 'smtp_username' => $settings->get_config('smtp_user'), 'smtp_port' => $settings->get_config('smtp_port', 0), 'smtp_password' => $settings->get_config('smtp_pass'), 'cookie_secure' => $settings->get_config('cookie_secure', 0), 'script_path' => $script_path, 'server_protocol' => $settings->get_server_protocol(), 'newest_username' => $admin_name, 'avatar_salt' => md5(mt_rand()), 'cookie_name' => 'phpbb3_' . strtolower(gen_rand_string(5))); if (defined('PHPBB_31')) { $config_ary['board_timezone'] = $settings->get_config('qi_tz', ''); $tz_data = "user_timezone = '{$config_ary['board_timezone']}'"; } else { $tz = new DateTimeZone($settings->get_config('qi_tz', '')); $tz_ary = $tz->getTransitions(time()); $offset = (double) $tz_ary[0]['offset'] / 3600; // 3600 seconds = 1 hour. $dst = $tz_ary[0]['isdst'] ? 1 : 0; $tz_data = "user_timezone = {$offset}, user_dst = {$dst}"; $config_ary['user_timezone'] = $offset; $config_ary['user_dst'] = $dst; unset($tz_ary, $tz, $offset, $dst); } if (@extension_loaded('gd') || can_load_dll('gd')) { $config_ary['captcha_gd'] = 1; } if (defined('PHPBB_31')) { $current_config = $config; $config = new \phpbb\config\db($db, $cache, "{$table_prefix}config"); set_config(false, false, false, $config); foreach ($current_config as $key => $value) { $config->set($key, $value); } } foreach ($config_ary as $config_name => $config_value) { set_config($config_name, $config_value); } // Set default config and post data, this applies to all DB's $sql_ary = array("UPDATE {$table_prefix}users\n\t\t\t\tSET username\t\t= '" . $db->sql_escape($admin_name) . "',\n\t\t\t\t\tuser_password\t= '" . $db->sql_escape(md5($admin_pass)) . "',\n\t\t\t\t\tuser_ip\t\t\t= '" . $db->sql_escape($user_ip) . "',\n\t\t\t\t\tuser_lang\t\t= '" . $db->sql_escape($default_lang) . "',\n\t\t\t\t\tuser_email\t\t= '" . $db->sql_escape($settings->get_config('board_email')) . "',\n\t\t\t\t\tuser_dateformat\t= '" . $db->sql_escape($user->lang['default_dateformat']) . "',\n\t\t\t\t\tuser_email_hash\t= " . (crc32($settings->get_config('board_email')) . strlen($settings->get_config('board_email'))) . ",\n\t\t\t\t\tusername_clean\t= '" . $db->sql_escape(utf8_clean_string($admin_name)) . "',\n\t\t\t\t\t{$tz_data}\n\t\t\t\tWHERE username = '******'", "UPDATE {$table_prefix}moderator_cache\n\t\t\t\tSET username = '******'\n\t\t\t\tWHERE username = '******'", "UPDATE {$table_prefix}forums\n\t\t\t\tSET forum_last_poster_name = '" . $db->sql_escape($admin_name) . "'\n\t\t\t\tWHERE forum_last_poster_name = 'Admin'", "UPDATE {$table_prefix}topics\n\t\t\t\tSET topic_first_poster_name = '" . $db->sql_escape($admin_name) . "', topic_last_poster_name = '" . $db->sql_escape($admin_name) . "'\n\t\t\t\tWHERE topic_first_poster_name = 'Admin'\n\t\t\t\t\tOR topic_last_poster_name = 'Admin'", "UPDATE {$table_prefix}users\n\t\t\t\tSET user_regdate = {$current_time}", "UPDATE {$table_prefix}posts\n\t\t\t\tSET post_time = {$current_time}, poster_ip = '" . $db->sql_escape($user_ip) . "'", "UPDATE {$table_prefix}topics\n\t\t\t\tSET topic_time = {$current_time}, topic_last_post_time = {$current_time}", "UPDATE {$table_prefix}forums\n\t\t\t\tSET forum_last_post_time = {$current_time}", "UPDATE {$table_prefix}config\n\t\t\t\tSET config_value = '" . $db->sql_escape($site_name) . "'\n\t\t\t\tWHERE config_name = 'sitename'", "UPDATE {$table_prefix}config\n\t\t\t\tSET config_value = '" . $db->sql_escape($site_desc) . "'\n\t\t\t\tWHERE config_name = 'site_desc'", "UPDATE {$table_prefix}config\n\t\t\t\tSET config_value = '1'\n\t\t\t\tWHERE config_name = 'load_tplcompile'"); foreach ($sql_ary as $sql) { if (!$db->sql_query($sql)) { $error = $db->sql_error(); trigger_error($error['message']); } } // main sql is done, let's get a fresh $config array $sql = 'SELECT * FROM ' . CONFIG_TABLE; $result = $db->sql_query($sql); if (defined('PHPBB_31')) { $config = new \phpbb\config\config(array()); } else { $config = array(); } while ($row = $db->sql_fetchrow($result)) { $config[$row['config_name']] = $row['config_value']; } $db->sql_freeresult($result); // Set other optional config data. // Have it here to not having to do a query for each key // to see if it is a update or insert. if (($other_config = $settings->get_other_config(true)) != '') { foreach ($other_config as $config_row) { // First check if this is a comment. if (strpos($config_row, '#') === 0) { continue; } $row_ary = explode(';', $config_row); if (empty($row_ary[0]) || empty($row_ary[1])) { continue; } $config_name = trim($row_ary[0]); $config_value = trim($row_ary[1]); $is_dynamic = !empty($row_ary[2]) ? 1 : 0; $sql_ary = array('config_name' => $config_name, 'config_value' => $config_value, 'is_dynamic' => $is_dynamic); if (defined('PHPBB_31') && $config->offsetExists($config_name) || !defined('PHPBB_31') && array_key_exists($config_name, $config)) { $sql = "UPDATE {$table_prefix}config\n\t\t\t\t\t\tSET " . $db->sql_build_array('UPDATE', $sql_ary) . "\n\t\t\t\t\t\tWHERE config_name = '{$config_name}'"; if (!$db->sql_query($sql)) { $error = $db->sql_error(); trigger_error($error['message']); } } else { $sql = "INSERT INTO {$table_prefix}config " . $db->sql_build_array('INSERT', $sql_ary); if (!$db->sql_query($sql)) { $error = $db->sql_error(); trigger_error($error['message']); } } // Update the config array. $config[$config_name] = $config_value; } unset($other_config); } // no templates though :P $config['load_tplcompile'] = '1'; // build search index if (defined('PHPBB_31')) { $search = new \phpbb\search\fulltext_native($error = false, $phpbb_root_path, $phpEx, $auth, $config, $db, $user, null); } else { if (!class_exists('fulltext_native')) { include_once $phpbb_root_path . 'includes/search/fulltext_native.' . $phpEx; } $search = new fulltext_native($error = false); } $sql = 'SELECT post_id, post_subject, post_text, poster_id, forum_id FROM ' . POSTS_TABLE; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $search->index('post', $row['post_id'], $row['post_text'], $row['post_subject'], $row['poster_id'], $row['forum_id']); } $db->sql_freeresult($result); // extended phpbb install script if (!defined('PHPBB_32')) { include $phpbb_root_path . 'install/install_install.' . $phpEx; include $quickinstall_path . 'includes/install_install_qi.' . $phpEx; } if (defined('PHPBB_32')) { $container_builder = new \phpbb\di\container_builder($phpbb_root_path, $phpEx); $container = $container_builder->with_environment('installer')->without_extensions()->without_cache()->with_custom_parameters(['core.disable_super_globals' => false, 'installer.create_config_file.options' => ['debug' => true, 'environment' => 'production'], 'cache.driver.class' => 'phpbb\\cache\\driver\\file'])->without_compiled_container()->get_container(); $container->register('installer.install_finish.notify_user')->setSynthetic(true); $container->set('installer.install_finish.notify_user', null); $container->compile(); $language = $container->get('language'); $language->add_lang(array('common', 'acp/common', 'acp/board', 'install', 'posting')); $iohandler_factory = $container->get('installer.helper.iohandler_factory'); $iohandler_factory->set_environment('cli'); $iohandler = $iohandler_factory->get(); $output = new \Symfony\Component\Console\Output\NullOutput(); $style = new \Symfony\Component\Console\Style\SymfonyStyle(new \Symfony\Component\Console\Input\ArrayInput(array()), $output); $iohandler->set_style($style, $output); $installer = $container->get('installer.installer.install'); $installer->set_iohandler($iohandler); // Set data $iohandler->set_input('admin_name', $admin_name); $iohandler->set_input('admin_pass1', $admin_pass); $iohandler->set_input('admin_pass2', $admin_pass); $iohandler->set_input('board_email', $settings->get_config('board_email')); $iohandler->set_input('submit_admin', 'submit'); $iohandler->set_input('default_lang', $default_lang); $iohandler->set_input('board_name', $site_name); $iohandler->set_input('board_description', $site_desc); $iohandler->set_input('submit_board', 'submit'); $iohandler->set_input('dbms', $dbms); $iohandler->set_input('dbhost', $dbhost); $iohandler->set_input('dbport', $settings->get_config('dbport')); $iohandler->set_input('dbuser', $dbuser); $iohandler->set_input('dbpasswd', $dbpasswd); $iohandler->set_input('dbname', $dbname); $iohandler->set_input('table_prefix', $table_prefix); $iohandler->set_input('submit_database', 'submit'); $iohandler->set_input('email_enable', $settings->get_config('email_enable', 0)); $iohandler->set_input('smtp_delivery', $settings->get_config('smtp_delivery', 0)); $iohandler->set_input('smtp_host', $settings->get_config('smtp_host')); $iohandler->set_input('smtp_auth', $settings->get_config('smtp_auth')); $iohandler->set_input('smtp_user', $settings->get_config('smtp_user')); $iohandler->set_input('smtp_pass', $settings->get_config('smtp_pass')); $iohandler->set_input('submit_email', 'submit'); $iohandler->set_input('cookie_secure', $settings->get_config('cookie_secure', 0)); $iohandler->set_input('server_protocol', $settings->get_server_protocol()); $iohandler->set_input('force_server_vars', 'http://'); $iohandler->set_input('server_name', $settings->get_config('server_name')); $iohandler->set_input('server_port', $settings->get_config('server_port')); $iohandler->set_input('script_path', $script_path); $iohandler->set_input('submit_server', 'submit'); // Update the lang array with keys loaded for the installer $user->lang = array_merge($user->lang, $language->get_lang_array()); // Storing the db and user objects temporarily because they // are altered by the installer processes below...not sure why? $current_user = $user; $current_db = $db; // Suppress errors because constants.php is added again in these objects // leading to debug notices about the constants already being defined. @$container->get('installer.install_finish.populate_migrations')->run(); @$container->get('installer.install_data.add_modules')->run(); @$container->get('installer.install_data.add_languages')->run(); @$container->get('installer.install_data.add_bots')->run(); $container->reset(); // Set some services in the container that may be needed later global $phpbb_container, $phpbb_log, $phpbb_dispatcher, $request, $passwords_manager; global $symfony_request, $phpbb_filesystem; $phpbb_container = $container->get('installer.helper.container_factory'); $phpbb_dispatcher = $phpbb_container->get('dispatcher'); $phpbb_log = $phpbb_container->get('log'); $request = $phpbb_container->get('request'); $request->enable_super_globals(); $passwords_manager = $phpbb_container->get('passwords.manager'); $symfony_request = $phpbb_container->get('symfony_request'); $phpbb_filesystem = $phpbb_container->get('filesystem'); // Restore user and db objects to original state $user = $current_user; $db = $current_db; unset($current_user, $current_db); } else { if (defined('PHPBB_31')) { global $phpbb_container, $phpbb_config_php_file, $phpbb_log, $phpbb_dispatcher, $request, $passwords_manager; global $symfony_request, $phpbb_filesystem; $phpbb_config_php_file = new \phpbb\config_php_file($phpbb_root_path, $phpEx); $phpbb_container_builder = new \phpbb\di\container_builder($phpbb_config_php_file, $phpbb_root_path, $phpEx); $phpbb_container_builder->set_inject_config(false); $phpbb_container_builder->set_dump_container(false); $phpbb_container_builder->set_use_extensions(false); $phpbb_container_builder->set_compile_container(false); $phpbb_container_builder->set_custom_parameters(array('core.table_prefix' => $table_prefix, 'core.root_path' => $phpbb_root_path, 'core.php_ext' => $phpEx, 'core.adm_relative_path' => 'adm/')); $phpbb_container = $phpbb_container_builder->get_container(); $phpbb_container->register('dbal.conn')->setSynthetic(true); $phpbb_container->register('dbal.conn.driver')->setSynthetic(true); $phpbb_container->register('cache.driver')->setSynthetic(true); $phpbb_container->register('cache')->setSynthetic(true); $phpbb_container->register('auth')->setSynthetic(true); $phpbb_container->register('user')->setSynthetic(true); $phpbb_container->compile(); $phpbb_container->set('dbal.conn', $db); $phpbb_container->set('cache.driver', $cache); $phpbb_container->set('user', $user); $phpbb_container->set('auth', $auth); $cache = new \phpbb\cache\service($cache, $config, $db, $phpbb_root_path, $phpEx); $phpbb_container->set('cache', $cache); $phpbb_dispatcher = $phpbb_container->get('dispatcher'); $phpbb_log = $phpbb_container->get('log'); $request = $phpbb_container->get('request'); $request->enable_super_globals(); $passwords_manager = $phpbb_container->get('passwords.manager'); $symfony_request = $phpbb_container->get('symfony_request'); $phpbb_filesystem = $phpbb_container->get('filesystem'); // Populate migrations table. $install = new install_install($p_master = new p_master_dummy()); $install->populate_migrations($phpbb_container->get('ext.manager'), $phpbb_container->get('migrator')); unset($install); } } if (!defined('PHPBB_32')) { $install = new install_install_qi($p_master = new p_master_dummy()); $install->set_data(array('dbms' => $dbms, 'dbhost' => $dbhost, 'dbport' => $settings->get_config('dbport'), 'dbuser' => $dbuser, 'dbpasswd' => $dbpasswd, 'dbname' => $dbname, 'table_prefix' => $table_prefix, 'default_lang' => $default_lang, 'admin_name' => $admin_name, 'admin_pass1' => $admin_pass, 'admin_pass2' => $admin_pass, 'board_email1' => $settings->get_config('board_email'), 'board_email2' => $settings->get_config('board_email'), 'email_enable' => $settings->get_config('email_enable', 0), 'smtp_delivery' => $settings->get_config('smtp_delivery', 0), 'smtp_host' => $settings->get_config('smtp_host'), 'smtp_auth' => $settings->get_config('smtp_auth'), 'smtp_user' => $settings->get_config('smtp_user'), 'smtp_pass' => $settings->get_config('smtp_pass'), 'cookie_secure' => $settings->get_config('cookie_secure', 0), 'server_protocol' => $settings->get_server_protocol(), 'server_name' => $settings->get_config('server_name'), 'server_port' => $settings->get_config('server_port'), 'script_path' => $script_path)); $install->add_modules(false, false); $install->add_language(false, false); $install->add_bots(false, false); } // now automod (easymod) if ($automod && !defined('PHPBB_31')) { include $quickinstall_path . 'includes/functions_install_automod.' . $phpEx; automod_installer::install_automod($board_dir, $settings->get_config('make_writable', false)); } if ($dbms == 'firebird') { // copy the temp db over file_functions::copy_file($settings->get_cache_dir() . $db_prefix . $dbname, $board_dir . $db_prefix . $dbname); $db->sql_select_db($board_dir . $db_prefix . $dbname); } // clean up file_functions::delete_files($board_dir, array('Thumbs.db', 'DS_Store', 'CVS', '.svn', '.git')); // remove install dir, develop and umil file_functions::delete_dir($board_dir . 'install/'); file_functions::delete_dir($board_dir . 'develop/'); file_functions::delete_dir($board_dir . 'umil/'); // copy extra user added files file_functions::copy_dir($quickinstall_path . 'sources/extra/', $board_dir); // Install styles if (($install_styles = $settings->get_config('install_styles', 0)) != 0) { include $phpbb_root_path . 'includes/acp/acp_styles.' . $phpEx; if (!class_exists('bitfield')) { include $phpbb_root_path . 'includes/functions_content.' . $phpEx; } if (defined('PHPBB_31')) { include $quickinstall_path . 'includes/class_31_styles.' . $phpEx; new class_31_styles($install_styles); } else { include $quickinstall_path . 'includes/class_30_styles.' . $phpEx; new class_30_styles($install_styles); } } // Add some random users and posts. Revisit. if ($settings->get_config('populate', false)) { include $quickinstall_path . 'includes/functions_populate.' . $phpEx; new populate(); } // add log entry :D $user->ip =& $user_ip; if (defined('PHPBB_31')) { add_log('admin', sprintf($user->lang['LOG_INSTALL_INSTALLED_QI'], QI_VERSION)); } else { add_log('admin', 'LOG_INSTALL_INSTALLED_QI', QI_VERSION); } // purge cache $cache->purge(); // Make all files world writable. if ($settings->get_config('make_writable', false)) { file_functions::make_writable($board_dir); } // Grant additional permissions if (($grant_permissions = octdec($settings->get_config('grant_permissions', 0))) != 0) { file_functions::grant_permissions($board_dir, $grant_permissions); } // if he/she wants to be redirected, we'll do that. if ($settings->get_config('redirect', false)) { // Log him/her in first. $user->session_begin(); $auth->login($admin_name, $settings->get_config('admin_pass'), false, true, true); qi::redirect($board_url); } // On succces just return to main page. qi::redirect('index.' . $phpEx); }
include $new_path; } else { if (!$optional || file_exists($old_path)) { include $old_path; } } } phpbb_require_updated('includes/startup.' . $phpEx, $phpbb_root_path); phpbb_require_updated('phpbb/class_loader.' . $phpEx, $phpbb_root_path); $phpbb_class_loader_new = new \phpbb\class_loader('phpbb\\', "{$phpbb_root_path}install/update/new/phpbb/", $phpEx); $phpbb_class_loader_new->register(); $phpbb_class_loader = new \phpbb\class_loader('phpbb\\', "{$phpbb_root_path}phpbb/", $phpEx); $phpbb_class_loader->register(); $phpbb_class_loader_ext = new \phpbb\class_loader('\\', "{$phpbb_root_path}ext/", $phpEx); $phpbb_class_loader_ext->register(); // In case $phpbb_adm_relative_path is not set (in case of an update), use the default. $phpbb_adm_relative_path = isset($phpbb_adm_relative_path) ? $phpbb_adm_relative_path : 'adm/'; $phpbb_admin_path = defined('PHPBB_ADMIN_PATH') ? PHPBB_ADMIN_PATH : $phpbb_root_path . $phpbb_adm_relative_path; // Include files phpbb_require_updated('includes/functions.' . $phpEx, $phpbb_root_path); phpbb_require_updated('includes/functions_content.' . $phpEx, $phpbb_root_path); phpbb_include_updated('includes/functions_compatibility.' . $phpEx, $phpbb_root_path); phpbb_require_updated('includes/functions_user.' . $phpEx, $phpbb_root_path); phpbb_require_updated('includes/utf/utf_tools.' . $phpEx, $phpbb_root_path); // Set PHP error handler to ours set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler'); $phpbb_installer_container_builder = new \phpbb\di\container_builder($phpbb_root_path, $phpEx); $phpbb_installer_container_builder->with_environment('installer')->without_extensions(); $other_config_path = $phpbb_root_path . 'install/update/new/config'; $config_path = file_exists($other_config_path . '/installer/config.yml') ? $other_config_path : $phpbb_root_path . 'config'; $phpbb_installer_container = $phpbb_installer_container_builder->with_config_path($config_path)->get_container();
phpbb_require_updated('phpbb/class_loader.' . $phpEx); phpbb_require_updated('includes/functions.' . $phpEx); phpbb_require_updated('includes/functions_content.' . $phpEx, true); phpbb_include_updated('includes/functions_admin.' . $phpEx); phpbb_include_updated('includes/utf/utf_tools.' . $phpEx); phpbb_require_updated('includes/functions_install.' . $phpEx); // Setup class loader first $phpbb_class_loader_new = new \phpbb\class_loader('phpbb\\', "{$phpbb_root_path}install/update/new/phpbb/", $phpEx); $phpbb_class_loader_new->register(); $phpbb_class_loader = new \phpbb\class_loader('phpbb\\', "{$phpbb_root_path}phpbb/", $phpEx); $phpbb_class_loader->register(); $phpbb_class_loader_ext = new \phpbb\class_loader('\\', "{$phpbb_root_path}ext/", $phpEx); $phpbb_class_loader_ext->register(); // Set up container $phpbb_config_php_file = new \phpbb\config_php_file($phpbb_root_path, $phpEx); $phpbb_container_builder = new \phpbb\di\container_builder($phpbb_root_path, $phpEx); $phpbb_container_builder->without_extensions()->without_cache()->without_compiled_container(); $other_config_path = $phpbb_root_path . 'install/update/new/config/'; $config_path = file_exists($other_config_path . 'services.yml') ? $other_config_path : $phpbb_root_path . 'config/'; $phpbb_container_builder->with_config_path($config_path); $phpbb_container_builder->with_custom_parameters(array('core.root_path' => $phpbb_root_path, 'core.adm_relative_path' => $phpbb_adm_relative_path, 'core.php_ext' => $phpEx, 'core.table_prefix' => '', 'cache.driver.class' => 'phpbb\\cache\\driver\\file')); $phpbb_container = $phpbb_container_builder->get_container(); $phpbb_container->register('dbal.conn.driver')->setSynthetic(true); $phpbb_container->register('template.twig.environment')->setSynthetic(true); $phpbb_container->register('language.loader')->setSynthetic(true); $phpbb_container->compile(); $phpbb_class_loader->set_cache($phpbb_container->get('cache.driver')); $phpbb_class_loader_ext->set_cache($phpbb_container->get('cache.driver')); /* @var $phpbb_dispatcher \phpbb\event\dispatcher */ $phpbb_dispatcher = $phpbb_container->get('dispatcher'); /* @var $request \phpbb\request\request_interface */
function main($mode, $sub) { global $lang, $template, $phpbb_root_path, $phpEx, $cache, $config, $language, $table_prefix; global $convert, $request, $phpbb_container, $phpbb_config_php_file; $this->tpl_name = 'install_convert'; $this->mode = $mode; $this->lang = $lang; $this->language = $language; $this->template = $template; $this->phpbb_root_path = $phpbb_root_path; $this->php_ext = $phpEx; $this->filesystem = new \phpbb\filesystem\filesystem(); if (!$this->check_phpbb_installed()) { return; } $convert = new convert($this->p_master); // Enable super globals to prevent issues with the new \phpbb\request\request object $request->enable_super_globals(); // Create a normal container now $phpbb_container_builder = new \phpbb\di\container_builder($phpbb_root_path, $phpEx); $phpbb_container = $phpbb_container_builder->with_config($phpbb_config_php_file)->get_container(); // Create cache /* @var $cache \phpbb\cache\service */ $cache = $phpbb_container->get('cache'); switch ($sub) { case 'intro': extract($phpbb_config_php_file->get_all()); require $phpbb_root_path . 'includes/constants.' . $phpEx; require $phpbb_root_path . 'includes/functions_convert.' . $phpEx; $dbms = $phpbb_config_php_file->convert_30_dbms_to_31($dbms); $db = new $dbms(); $db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, true); unset($dbpasswd); // We need to fill the config to let internal functions correctly work $config = new \phpbb\config\db($db, new \phpbb\cache\driver\dummy(), CONFIG_TABLE); // Detect if there is already a conversion in progress at this point and offer to resume // It's quite possible that the user will get disconnected during a large conversion so they need to be able to resume it $new_conversion = $request->variable('new_conv', 0); if ($new_conversion) { $config['convert_progress'] = ''; $config['convert_db_server'] = ''; $config['convert_db_user'] = ''; $db->sql_query('DELETE FROM ' . CONFIG_TABLE . "\n\t\t\t\t\t\tWHERE config_name = 'convert_progress'\n\t\t\t\t\t\t\tOR config_name = 'convert_db_server'\n\t\t\t\t\t\t\tOR config_name = 'convert_db_user'"); } // Let's see if there is a conversion in the works... $options = array(); if (!empty($config['convert_progress']) && !empty($config['convert_db_server']) && !empty($config['convert_db_user']) && !empty($config['convert_options'])) { $options = unserialize($config['convert_progress']); $options = array_merge($options, unserialize($config['convert_db_server']), unserialize($config['convert_db_user']), unserialize($config['convert_options'])); } // This information should have already been checked once, but do it again for safety if (!empty($options) && !empty($options['tag']) && isset($options['dbms']) && isset($options['dbhost']) && isset($options['dbport']) && isset($options['dbuser']) && isset($options['dbpasswd']) && isset($options['dbname']) && isset($options['table_prefix'])) { $this->page_title = $lang['CONTINUE_CONVERT']; $template->assign_vars(array('TITLE' => $lang['CONTINUE_CONVERT'], 'BODY' => $lang['CONTINUE_CONVERT_BODY'], 'L_NEW' => $lang['CONVERT_NEW_CONVERSION'], 'L_CONTINUE' => $lang['CONTINUE_OLD_CONVERSION'], 'S_CONTINUE' => true, 'U_NEW_ACTION' => $this->p_master->module_url . "?mode={$this->mode}&sub=intro&new_conv=1&language={$language}", 'U_CONTINUE_ACTION' => $this->p_master->module_url . "?mode={$this->mode}&sub=in_progress&tag={$options['tag']}{$options['step']}&language={$language}")); return; } $this->list_convertors($sub); break; case 'settings': $this->get_convert_settings($sub); break; case 'in_progress': $this->convert_data($sub); break; case 'final': $this->page_title = $lang['CONVERT_COMPLETE']; $template->assign_vars(array('TITLE' => $lang['CONVERT_COMPLETE'], 'BODY' => $lang['CONVERT_COMPLETE_EXPLAIN'])); // If we reached this step (conversion completed) we want to purge the cache and log the user out. // This is for making sure the session get not screwed due to the 3.0.x users table being completely new. $cache->purge(); extract($phpbb_config_php_file->get_all()); require $phpbb_root_path . 'includes/constants.' . $phpEx; require $phpbb_root_path . 'includes/functions_convert.' . $phpEx; $dbms = $phpbb_config_php_file->convert_30_dbms_to_31($dbms); $db = new $dbms(); $db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, true); unset($dbpasswd); $sql = 'SELECT config_value FROM ' . CONFIG_TABLE . ' WHERE config_name = \'search_type\''; $result = $db->sql_query($sql); if ($db->sql_fetchfield('config_value') != 'fulltext_mysql') { $template->assign_vars(array('S_ERROR_BOX' => true, 'ERROR_TITLE' => $lang['SEARCH_INDEX_UNCONVERTED'], 'ERROR_MSG' => $lang['SEARCH_INDEX_UNCONVERTED_EXPLAIN'])); } switch ($db->get_sql_layer()) { case 'sqlite': case 'sqlite3': $db->sql_query('DELETE FROM ' . SESSIONS_KEYS_TABLE); $db->sql_query('DELETE FROM ' . SESSIONS_TABLE); break; default: $db->sql_query('TRUNCATE TABLE ' . SESSIONS_KEYS_TABLE); $db->sql_query('TRUNCATE TABLE ' . SESSIONS_TABLE); break; } break; } }
define('PHPBB_ENVIRONMENT', 'production'); $phpbb_root_path = __DIR__ . '/../'; $phpEx = substr(strrchr(__FILE__, '.'), 1); // // Let's do the common.php logic // require $phpbb_root_path . 'includes/startup.' . $phpEx; require $phpbb_root_path . 'phpbb/class_loader.' . $phpEx; $phpbb_class_loader = new \phpbb\class_loader('phpbb\\', "{$phpbb_root_path}phpbb/", $phpEx); $phpbb_class_loader->register(); // In case $phpbb_adm_relative_path is not set (in case of an update), use the default. $phpbb_adm_relative_path = isset($phpbb_adm_relative_path) ? $phpbb_adm_relative_path : 'adm/'; $phpbb_admin_path = defined('PHPBB_ADMIN_PATH') ? PHPBB_ADMIN_PATH : $phpbb_root_path . $phpbb_adm_relative_path; // Include files require $phpbb_root_path . 'includes/functions.' . $phpEx; require $phpbb_root_path . 'includes/functions_content.' . $phpEx; include $phpbb_root_path . 'includes/functions_compatibility.' . $phpEx; require $phpbb_root_path . 'includes/functions_user.' . $phpEx; require $phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx; // Set PHP error handler to ours set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler'); $phpbb_installer_container_builder = new \phpbb\di\container_builder($phpbb_root_path, $phpEx); $phpbb_installer_container = $phpbb_installer_container_builder->with_environment('installer')->without_extensions()->without_cache()->get_container(); /** @var \phpbb\filesystem\filesystem $phpbb_filesystem */ $phpbb_filesystem = $phpbb_installer_container->get('filesystem'); /** @var \phpbb\language\language $language */ $language = $phpbb_installer_container->get('language'); $language->add_lang(array('common', 'acp/common', 'acp/board', 'install_new', 'posting', 'cli')); $application = new \phpbb\console\application('phpBB Installer', PHPBB_VERSION, $language); $application->register_container_commands($phpbb_installer_container->get('console.installer.command_collection')); $application->run($input);
// In case $phpbb_adm_relative_path is not set (in case of an update), use the default. $phpbb_adm_relative_path = (isset($phpbb_adm_relative_path)) ? $phpbb_adm_relative_path : 'adm/'; $phpbb_admin_path = (defined('PHPBB_ADMIN_PATH')) ? PHPBB_ADMIN_PATH : $phpbb_root_path . $phpbb_adm_relative_path; // Include files require($phpbb_root_path . 'includes/functions.' . $phpEx); require($phpbb_root_path . 'includes/functions_content.' . $phpEx); include($phpbb_root_path . 'includes/functions_compatibility.' . $phpEx); require($phpbb_root_path . 'includes/functions_user.' . $phpEx); require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); // Set PHP error handler to ours set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler'); $phpbb_installer_container_builder = new \phpbb\di\container_builder($phpbb_root_path, $phpEx); $phpbb_installer_container = $phpbb_installer_container_builder ->with_environment('installer') ->without_extensions() ->without_cache() ->get_container(); /** @var \phpbb\filesystem\filesystem $phpbb_filesystem */ $phpbb_filesystem = $phpbb_installer_container->get('filesystem'); /** @var \phpbb\language\language $language */ $language = $phpbb_installer_container->get('language'); $language->add_lang(array('common', 'acp/common', 'acp/board', 'install_new', 'posting', 'cli')); $application = new \phpbb\console\application('phpBB Installer', PHPBB_VERSION, $language); $application->setDispatcher($phpbb_installer_container->get('dispatcher'));
/** * Build dependency injection container * * @throws \phpbb\install\exception\cannot_build_container_exception When container cannot be built */ protected function build_container() { // If the container has been already built just return. // Although this should never happen if ($this->container instanceof \Symfony\Component\DependencyInjection\ContainerInterface) { return; } // Check whether container can be built // We need config.php for that so let's check if it has been set up yet if (!filesize($this->phpbb_root_path . 'config.' . $this->php_ext)) { throw new cannot_build_container_exception(); } $phpbb_config_php_file = new \phpbb\config_php_file($this->phpbb_root_path, $this->php_ext); $phpbb_container_builder = new \phpbb\di\container_builder($this->phpbb_root_path, $this->php_ext); // For BC with functions that we need during install global $phpbb_container; $disable_super_globals = $this->request->super_globals_disabled(); // This is needed because container_builder::get_env_parameters() uses $_SERVER if ($disable_super_globals) { $this->request->enable_super_globals(); } $this->container = $phpbb_container = $phpbb_container_builder->with_config($phpbb_config_php_file)->without_cache()->without_compiled_container()->get_container(); // Setting request is required for the compatibility globals as those are generated from // this container $this->container->register('request')->setSynthetic(true); $this->container->set('request', $this->request); // Replace cache service, as config gets cached, and we don't want that $this->container->register('cache.driver')->setSynthetic(true); $this->container->set('cache.driver', new dummy()); $this->container->compile(); // Restore super globals to previous state if ($disable_super_globals) { $this->request->disable_super_globals(); } // Get compatibilty globals require $this->phpbb_root_path . 'includes/compatibility_globals.' . $this->php_ext; }