mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
[ticket/13740] Installer's install tasks and modules
[ci skip] PHPBB3-13740
This commit is contained in:
parent
11623dd671
commit
0b74e3b0de
38 changed files with 3983 additions and 0 deletions
2
phpBB/config/installer/config.yml
Normal file
2
phpBB/config/installer/config.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
imports:
|
||||
- { resource: ../default/config.yml }
|
3
phpBB/config/installer/container/environment.yml
Normal file
3
phpBB/config/installer/container/environment.yml
Normal file
|
@ -0,0 +1,3 @@
|
|||
imports:
|
||||
- { resource: services.yml }
|
||||
- { resource: parameters.yml }
|
2
phpBB/config/installer/container/parameters.yml
Normal file
2
phpBB/config/installer/container/parameters.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
imports:
|
||||
- { resource: ../../default/container/parameters.yml }
|
70
phpBB/config/installer/container/services.yml
Normal file
70
phpBB/config/installer/container/services.yml
Normal file
|
@ -0,0 +1,70 @@
|
|||
imports:
|
||||
- { resource: services_installer.yml }
|
||||
- { resource: ../../default/container/services_files.yml }
|
||||
- { resource: ../../default/container/services_http.yml }
|
||||
- { resource: ../../default/container/services_language.yml }
|
||||
- { resource: ../../default/container/services_php.yml }
|
||||
- { resource: ../../default/container/services_routing.yml }
|
||||
- { resource: ../../default/container/services_twig.yml }
|
||||
|
||||
services:
|
||||
config:
|
||||
class: phpbb\config\config
|
||||
arguments:
|
||||
- []
|
||||
|
||||
controller.resolver:
|
||||
class: phpbb\controller\resolver
|
||||
arguments:
|
||||
- @service_container
|
||||
- %core.root_path%
|
||||
- @template
|
||||
|
||||
dispatcher:
|
||||
class: phpbb\event\dispatcher
|
||||
arguments:
|
||||
- @service_container
|
||||
|
||||
language.loader:
|
||||
parent: language.loader_abstract
|
||||
|
||||
path_helper:
|
||||
class: phpbb\path_helper
|
||||
arguments:
|
||||
- @symfony_request
|
||||
- @filesystem
|
||||
- @request
|
||||
- %core.root_path%
|
||||
- %core.php_ext%
|
||||
|
||||
router:
|
||||
class: phpbb\routing\router
|
||||
arguments:
|
||||
- @service_container
|
||||
- @filesystem
|
||||
- %core.root_path%
|
||||
- %core.php_ext%
|
||||
- %core.environment%
|
||||
|
||||
template:
|
||||
class: phpbb\template\twig\twig
|
||||
arguments:
|
||||
- @path_helper
|
||||
- @config
|
||||
- @template_context
|
||||
- @template.twig.environment
|
||||
- %core.template.cache_path%
|
||||
- null
|
||||
- @template.twig.extensions.collection
|
||||
|
||||
template.twig.environment:
|
||||
class: phpbb\template\twig\environment
|
||||
arguments:
|
||||
- @config
|
||||
- @filesystem
|
||||
- @path_helper
|
||||
- @service_container
|
||||
- %core.template.cache_path%
|
||||
- null
|
||||
- @template.twig.loader
|
||||
- []
|
|
@ -0,0 +1,29 @@
|
|||
services:
|
||||
phpbb.installer.controller.welcome:
|
||||
class: phpbb\install\controller\install_index
|
||||
arguments:
|
||||
- @phpbb.installer.controller.helper
|
||||
- @language
|
||||
- @template
|
||||
- %core.root_path%
|
||||
|
||||
phpbb.installer.controller.helper:
|
||||
class: phpbb\install\controller\helper
|
||||
arguments:
|
||||
- @language
|
||||
- @language.helper.language_file
|
||||
- @installer.navigation.provider
|
||||
- @template
|
||||
- @path_helper
|
||||
- @symfony_request
|
||||
- @router
|
||||
- %core.root_path%
|
||||
|
||||
phpbb.installer.controller.install:
|
||||
class: phpbb\install\controller\install
|
||||
arguments:
|
||||
- @phpbb.installer.controller.helper
|
||||
- @installer.helper.iohandler_factory
|
||||
- @template
|
||||
- @request
|
||||
- @installer.installer.install
|
29
phpBB/config/installer/container/services_install_data.yml
Normal file
29
phpBB/config/installer/container/services_install_data.yml
Normal file
|
@ -0,0 +1,29 @@
|
|||
services:
|
||||
installer.install_data.add_bots:
|
||||
class: phpbb\install\module\install_data\task\add_bots
|
||||
arguments:
|
||||
- @installer.helper.config
|
||||
- @installer.helper.iohandler
|
||||
- @installer.helper.container_factory
|
||||
- @language
|
||||
- %core.root_path%
|
||||
- %core.php_ext%
|
||||
|
||||
installer.install_data.add_languages:
|
||||
class: phpbb\install\module\install_data\task\add_languages
|
||||
arguments:
|
||||
- @installer.helper.iohandler
|
||||
- @installer.helper.container_factory
|
||||
- @language.helper.language_file
|
||||
|
||||
installer.install_data.add_modules:
|
||||
class: phpbb\install\module\install_data\task\add_modules
|
||||
arguments:
|
||||
- @installer.helper.iohandler
|
||||
- @installer.helper.container_factory
|
||||
|
||||
installer.module.data_install:
|
||||
class: phpbb\install\module\install_data\module
|
||||
parent: installer.module_base
|
||||
arguments:
|
||||
- ["installer.install_data.add_languages", "installer.install_data.add_bots", "installer.install_data.add_modules"]
|
|
@ -0,0 +1,36 @@
|
|||
services:
|
||||
installer.install_database.create_schema:
|
||||
class: phpbb\install\module\install_database\task\create_schema
|
||||
arguments:
|
||||
- @installer.helper.config
|
||||
- @installer.helper.database
|
||||
- @filesystem
|
||||
- @installer.helper.iohandler
|
||||
# - @installer.helper.container_factory
|
||||
- %core.root_path%
|
||||
- %core.php_ext%
|
||||
|
||||
installer.install_database.add_default_data:
|
||||
class: phpbb\install\module\install_database\task\add_default_data
|
||||
arguments:
|
||||
- @installer.helper.database
|
||||
- @installer.helper.config
|
||||
- @installer.helper.iohandler
|
||||
- @installer.helper.container_factory
|
||||
- @language
|
||||
|
||||
installer.install_database.add_config_settings:
|
||||
class: phpbb\install\module\install_database\task\add_config_settings
|
||||
arguments:
|
||||
- @filesystem
|
||||
- @installer.helper.config
|
||||
- @installer.helper.iohandler
|
||||
- @installer.helper.container_factory
|
||||
- @language
|
||||
- %core.root_path%
|
||||
|
||||
installer.module.database_install:
|
||||
class: phpbb\install\module\install_database\module
|
||||
parent: installer.module_base
|
||||
arguments:
|
||||
- ["installer.install_database.create_schema", "installer.install_database.add_default_data", "installer.install_database.add_config_settings"]
|
|
@ -0,0 +1,16 @@
|
|||
services:
|
||||
installer.filesystem.create_config:
|
||||
class: phpbb\install\module\install_filesystem\task\create_config_file
|
||||
arguments:
|
||||
- @filesystem
|
||||
- @installer.helper.config
|
||||
- @installer.helper.database
|
||||
- @installer.helper.iohandler
|
||||
- %core.root_path%
|
||||
- %core.php_ext%
|
||||
|
||||
installer.module.filesystem_install:
|
||||
class: phpbb\install\module\install_filesystem\module
|
||||
parent: installer.module_base
|
||||
arguments:
|
||||
- ["installer.filesystem.create_config"]
|
20
phpBB/config/installer/container/services_install_finish.yml
Normal file
20
phpBB/config/installer/container/services_install_finish.yml
Normal file
|
@ -0,0 +1,20 @@
|
|||
services:
|
||||
installer.finish.populate_migrations:
|
||||
class: phpbb\install\module\install_finish\task\populate_migrations
|
||||
arguments:
|
||||
- @installer.helper.container_factory
|
||||
|
||||
installer.finish.notify_user:
|
||||
class: phpbb\install\module\install_finish\task\notify_user
|
||||
arguments:
|
||||
- @installer.helper.container_factory
|
||||
- @installer.helper.config
|
||||
- @installer.helper.iohandler
|
||||
- %core.root_path%
|
||||
- %core.php_ext%
|
||||
|
||||
installer.module.finish_install:
|
||||
class: phpbb\install\module\install_filesystem\module
|
||||
parent: installer.module_base
|
||||
arguments:
|
||||
- ["installer.finish.populate_migrations", "installer.finish.notify_user"]
|
|
@ -0,0 +1,25 @@
|
|||
services:
|
||||
installer.navigation.provider:
|
||||
class: phpbb\install\helper\navigation\navigation_provider
|
||||
arguments:
|
||||
- @installer.navigation.service_collection
|
||||
|
||||
installer.navigation.service_collection:
|
||||
class: phpbb\di\service_collection
|
||||
arguments:
|
||||
- @service_container
|
||||
tags:
|
||||
- { name: service_collection, tag: installer.navigation }
|
||||
|
||||
installer.navigation.main_navigation:
|
||||
class: phpbb\install\helper\navigation\main_navigation
|
||||
scope: prototype
|
||||
tags:
|
||||
- { name: installer.navigation }
|
||||
|
||||
installer.navigation.install_navigation:
|
||||
class: phpbb\install\helper\navigation\install_navigation
|
||||
scope: prototype
|
||||
tags:
|
||||
- { name: installer.navigation }
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
services:
|
||||
installer.obtain_data.admin:
|
||||
class: phpbb\install\module\obtain_data\task\obtain_admin_data
|
||||
arguments:
|
||||
- @installer.helper.config
|
||||
- @installer.helper.iohandler
|
||||
|
||||
installer.obtain_data.board:
|
||||
class: phpbb\install\module\obtain_data\task\obtain_board_data
|
||||
arguments:
|
||||
- @installer.helper.config
|
||||
- @installer.helper.iohandler
|
||||
- @language.helper.language_file
|
||||
|
||||
installer.obtain_data.database:
|
||||
class: phpbb\install\module\obtain_data\task\obtain_database_data
|
||||
arguments:
|
||||
- @installer.helper.database
|
||||
- @installer.helper.config
|
||||
- @installer.helper.iohandler
|
||||
|
||||
installer.obtain_data.email:
|
||||
class: phpbb\install\module\obtain_data\task\obtain_email_data
|
||||
arguments:
|
||||
- @installer.helper.config
|
||||
- @installer.helper.iohandler
|
||||
|
||||
installer.obtain_data.imagick:
|
||||
class: phpbb\install\module\obtain_data\task\obtain_imagick_path
|
||||
arguments:
|
||||
- @installer.helper.config
|
||||
|
||||
installer.obtain_data.server:
|
||||
class: phpbb\install\module\obtain_data\task\obtain_server_data
|
||||
arguments:
|
||||
- @installer.helper.config
|
||||
- @installer.helper.iohandler
|
||||
|
||||
installer.module.obtain_data_install:
|
||||
class: phpbb\install\module\obtain_data\module
|
||||
parent: installer.module_base
|
||||
arguments:
|
||||
- ["installer.obtain_data.admin", "installer.obtain_data.database", "installer.obtain_data.server", "installer.obtain_data.email", "installer.obtain_data.board", "installer.obtain_data.imagick"]
|
|
@ -0,0 +1,20 @@
|
|||
services:
|
||||
installer.requirements.task.filesystem:
|
||||
class: phpbb\install\module\requirements\task\check_filesystem
|
||||
arguments:
|
||||
- @filesystem
|
||||
- @installer.helper.iohandler
|
||||
- %core.root_path%
|
||||
- %core.php_ext%
|
||||
|
||||
installer.requirements.task.server:
|
||||
class: phpbb\install\module\requirements\task\check_server_environment
|
||||
arguments:
|
||||
- @installer.helper.database
|
||||
- @installer.helper.iohandler
|
||||
|
||||
installer.module.requirements_install:
|
||||
class: phpbb\install\module\requirements\module
|
||||
parent: installer.module_base
|
||||
arguments:
|
||||
- ["installer.requirements.task.filesystem", "installer.requirements.task.server"]
|
70
phpBB/config/installer/container/services_installer.yml
Normal file
70
phpBB/config/installer/container/services_installer.yml
Normal file
|
@ -0,0 +1,70 @@
|
|||
imports:
|
||||
- { resource: services_install_controller.yml }
|
||||
- { resource: services_install_data.yml }
|
||||
- { resource: services_install_database.yml }
|
||||
- { resource: services_install_filesystem.yml }
|
||||
- { resource: services_install_finish.yml }
|
||||
- { resource: services_install_navigation.yml }
|
||||
- { resource: services_install_obtain_data.yml }
|
||||
- { resource: services_install_requirements.yml }
|
||||
|
||||
services:
|
||||
# -------- Installer helpers ------------------------
|
||||
installer.helper.config:
|
||||
class: phpbb\install\helper\config
|
||||
arguments:
|
||||
- @filesystem
|
||||
- @php_ini
|
||||
- %core.root_path%
|
||||
|
||||
installer.helper.database:
|
||||
class: phpbb\install\helper\database
|
||||
arguments:
|
||||
- @filesystem
|
||||
- %core.root_path%
|
||||
|
||||
installer.helper.iohandler_factory:
|
||||
class: phpbb\install\helper\iohandler\factory
|
||||
arguments:
|
||||
- @service_container
|
||||
|
||||
installer.helper.iohandler_abstract:
|
||||
abstract: true
|
||||
calls:
|
||||
- [set_language, ["@language"]]
|
||||
|
||||
installer.helper.iohandler_ajax:
|
||||
class: phpbb\install\helper\iohandler\ajax_iohandler
|
||||
parent: installer.helper.iohandler_abstract
|
||||
arguments:
|
||||
- @request
|
||||
- @template
|
||||
|
||||
installer.helper.iohandler:
|
||||
class: phpbb\install\helper\iohandler\iohandler_interface
|
||||
factory: ["@installer.helper.iohandler_factory", get]
|
||||
|
||||
installer.helper.container_factory:
|
||||
class: phpbb\install\helper\container_factory
|
||||
arguments:
|
||||
- @request
|
||||
- %core.root_path%
|
||||
- %core.php_ext%
|
||||
|
||||
# -------- Installer --------------------------------
|
||||
installer.module_base:
|
||||
abstract: true
|
||||
calls:
|
||||
- [setup, [@service_container, @installer.helper.config, @installer.helper.iohandler]]
|
||||
|
||||
installer.installer.abstract:
|
||||
class: phpbb\install\installer
|
||||
abstract: true
|
||||
arguments:
|
||||
- @installer.helper.config
|
||||
- @service_container
|
||||
|
||||
installer.installer.install:
|
||||
parent: installer.installer.abstract
|
||||
calls:
|
||||
- [set_modules, [["installer.module.requirements_install", "installer.module.obtain_data_install", "installer.module.filesystem_install", "installer.module.database_install", "installer.module.data_install", "installer.module.finish_install"]]]
|
22
phpBB/install/exception/installer_exception.php
Normal file
22
phpBB/install/exception/installer_exception.php
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\install\exception;
|
||||
|
||||
/**
|
||||
* Installer's base exception
|
||||
*/
|
||||
class installer_exception extends \Exception
|
||||
{
|
||||
|
||||
}
|
45
phpBB/install/helper/navigation/main_navigation.php
Normal file
45
phpBB/install/helper/navigation/main_navigation.php
Normal file
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\install\helper\navigation;
|
||||
|
||||
class main_navigation implements navigation_interface
|
||||
{
|
||||
public function get()
|
||||
{
|
||||
return array(
|
||||
'overview' => array(
|
||||
'label' => 'MENU_OVERVIEW',
|
||||
'route' => 'phpbb_installer_index',
|
||||
'order' => 0,
|
||||
array(
|
||||
'introduction' => array(
|
||||
'label' => 'MENU_INTRO',
|
||||
'route' => 'phpbb_installer_index',
|
||||
'order' => 0,
|
||||
),
|
||||
'support' => array(
|
||||
'label' => 'MENU_SUPPORT',
|
||||
'route' => 'phpbb_installer_support',
|
||||
'order' => 1,
|
||||
),
|
||||
'license' => array(
|
||||
'label' => 'MENU_LICENSE',
|
||||
'route' => 'phpbb_installer_license',
|
||||
'order' => 2,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
22
phpBB/install/module/install_data/module.php
Normal file
22
phpBB/install/module/install_data/module.php
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\install\module\install_data;
|
||||
|
||||
/**
|
||||
* Installer module for recovering and installing default data installation
|
||||
*/
|
||||
class module extends \phpbb\install\module_base
|
||||
{
|
||||
|
||||
}
|
224
phpBB/install/module/install_data/task/add_bots.php
Normal file
224
phpBB/install/module/install_data/task/add_bots.php
Normal file
|
@ -0,0 +1,224 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\install\module\install_data\task;
|
||||
|
||||
class add_bots extends \phpbb\install\task_base
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $bot_list;
|
||||
|
||||
/**
|
||||
* @var \phpbb\db\driver\driver_interface
|
||||
*/
|
||||
protected $db;
|
||||
|
||||
/**
|
||||
* @var \phpbb\install\helper\config
|
||||
*/
|
||||
protected $install_config;
|
||||
|
||||
/**
|
||||
* @var \phpbb\install\helper\iohandler\iohandler_interface
|
||||
*/
|
||||
protected $io_handler;
|
||||
|
||||
/**
|
||||
* @var \phpbb\language\language
|
||||
*/
|
||||
protected $language;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $phpbb_root_path;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $php_ext;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \phpbb\install\helper\config $install_config Installer's config
|
||||
* @param \phpbb\install\helper\iohandler\iohandler_interface $iohandler Input-output handler for the installer
|
||||
* @param \phpbb\install\helper\container_factory $container Installer's DI container
|
||||
* @param \phpbb\language\language $language Language provider
|
||||
* @param string $phpbb_root_path Relative path to phpBB root
|
||||
* @param string $php_ext PHP extension
|
||||
*/
|
||||
public function __construct(\phpbb\install\helper\config $install_config,
|
||||
\phpbb\install\helper\iohandler\iohandler_interface $iohandler,
|
||||
\phpbb\install\helper\container_factory $container,
|
||||
\phpbb\language\language $language,
|
||||
$phpbb_root_path,
|
||||
$php_ext)
|
||||
{
|
||||
parent::__construct(true);
|
||||
|
||||
$this->db = $container->get('dbal.conn');
|
||||
$this->install_config = $install_config;
|
||||
$this->io_handler = $iohandler;
|
||||
$this->language = $language;
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
$this->php_ext = $php_ext;
|
||||
|
||||
/**
|
||||
* A list of the web-crawlers/bots we recognise by default
|
||||
*
|
||||
* Candidates but not included:
|
||||
* 'Accoona [Bot]' 'Accoona-AI-Agent/'
|
||||
* 'ASPseek [Crawler]' 'ASPseek/'
|
||||
* 'Boitho [Crawler]' 'boitho.com-dc/'
|
||||
* 'Bunnybot [Bot]' 'powered by www.buncat.de'
|
||||
* 'Cosmix [Bot]' 'cfetch/'
|
||||
* 'Crawler Search [Crawler]' '.Crawler-Search.de'
|
||||
* 'Findexa [Crawler]' 'Findexa Crawler ('
|
||||
* 'GBSpider [Spider]' 'GBSpider v'
|
||||
* 'genie [Bot]' 'genieBot ('
|
||||
* 'Hogsearch [Bot]' 'oegp v. 1.3.0'
|
||||
* 'Insuranco [Bot]' 'InsurancoBot'
|
||||
* 'IRLbot [Bot]' 'http://irl.cs.tamu.edu/crawler'
|
||||
* 'ISC Systems [Bot]' 'ISC Systems iRc Search'
|
||||
* 'Jyxobot [Bot]' 'Jyxobot/'
|
||||
* 'Kraehe [Metasuche]' '-DIE-KRAEHE- META-SEARCH-ENGINE/'
|
||||
* 'LinkWalker' 'LinkWalker'
|
||||
* 'MMSBot [Bot]' 'http://www.mmsweb.at/bot.html'
|
||||
* 'Naver [Bot]' 'nhnbot@naver.com)'
|
||||
* 'NetResearchServer' 'NetResearchServer/'
|
||||
* 'Nimble [Crawler]' 'NimbleCrawler'
|
||||
* 'Ocelli [Bot]' 'Ocelli/'
|
||||
* 'Onsearch [Bot]' 'onCHECK-Robot'
|
||||
* 'Orange [Spider]' 'OrangeSpider'
|
||||
* 'Sproose [Bot]' 'http://www.sproose.com/bot'
|
||||
* 'Susie [Sync]' '!Susie (http://www.sync2it.com/susie)'
|
||||
* 'Tbot [Bot]' 'Tbot/'
|
||||
* 'Thumbshots [Capture]' 'thumbshots-de-Bot'
|
||||
* 'Vagabondo [Crawler]' 'http://webagent.wise-guys.nl/'
|
||||
* 'Walhello [Bot]' 'appie 1.1 (www.walhello.com)'
|
||||
* 'WissenOnline [Bot]' 'WissenOnline-Bot'
|
||||
* 'WWWeasel [Bot]' 'WWWeasel Robot v'
|
||||
* 'Xaldon [Spider]' 'Xaldon WebSpider'
|
||||
*/
|
||||
$this->bot_list = array(
|
||||
'AdsBot [Google]' => array('AdsBot-Google', ''),
|
||||
'Alexa [Bot]' => array('ia_archiver', ''),
|
||||
'Alta Vista [Bot]' => array('Scooter/', ''),
|
||||
'Ask Jeeves [Bot]' => array('Ask Jeeves', ''),
|
||||
'Baidu [Spider]' => array('Baiduspider', ''),
|
||||
'Bing [Bot]' => array('bingbot/', ''),
|
||||
'Exabot [Bot]' => array('Exabot', ''),
|
||||
'FAST Enterprise [Crawler]' => array('FAST Enterprise Crawler', ''),
|
||||
'FAST WebCrawler [Crawler]' => array('FAST-WebCrawler/', ''),
|
||||
'Francis [Bot]' => array('http://www.neomo.de/', ''),
|
||||
'Gigabot [Bot]' => array('Gigabot/', ''),
|
||||
'Google Adsense [Bot]' => array('Mediapartners-Google', ''),
|
||||
'Google Desktop' => array('Google Desktop', ''),
|
||||
'Google Feedfetcher' => array('Feedfetcher-Google', ''),
|
||||
'Google [Bot]' => array('Googlebot', ''),
|
||||
'Heise IT-Markt [Crawler]' => array('heise-IT-Markt-Crawler', ''),
|
||||
'Heritrix [Crawler]' => array('heritrix/1.', ''),
|
||||
'IBM Research [Bot]' => array('ibm.com/cs/crawler', ''),
|
||||
'ICCrawler - ICjobs' => array('ICCrawler - ICjobs', ''),
|
||||
'ichiro [Crawler]' => array('ichiro/', ''),
|
||||
'Majestic-12 [Bot]' => array('MJ12bot/', ''),
|
||||
'Metager [Bot]' => array('MetagerBot/', ''),
|
||||
'MSN NewsBlogs' => array('msnbot-NewsBlogs/', ''),
|
||||
'MSN [Bot]' => array('msnbot/', ''),
|
||||
'MSNbot Media' => array('msnbot-media/', ''),
|
||||
'Nutch [Bot]' => array('http://lucene.apache.org/nutch/', ''),
|
||||
'Online link [Validator]' => array('online link validator', ''),
|
||||
'psbot [Picsearch]' => array('psbot/0', ''),
|
||||
'Sensis [Crawler]' => array('Sensis Web Crawler', ''),
|
||||
'SEO Crawler' => array('SEO search Crawler/', ''),
|
||||
'Seoma [Crawler]' => array('Seoma [SEO Crawler]', ''),
|
||||
'SEOSearch [Crawler]' => array('SEOsearch/', ''),
|
||||
'Snappy [Bot]' => array('Snappy/1.1 ( http://www.urltrends.com/ )', ''),
|
||||
'Steeler [Crawler]' => array('http://www.tkl.iis.u-tokyo.ac.jp/~crawler/', ''),
|
||||
'Telekom [Bot]' => array('crawleradmin.t-info@telekom.de', ''),
|
||||
'TurnitinBot [Bot]' => array('TurnitinBot/', ''),
|
||||
'Voyager [Bot]' => array('voyager/', ''),
|
||||
'W3 [Sitesearch]' => array('W3 SiteSearch Crawler', ''),
|
||||
'W3C [Linkcheck]' => array('W3C-checklink/', ''),
|
||||
'W3C [Validator]' => array('W3C_Validator', ''),
|
||||
'YaCy [Bot]' => array('yacybot', ''),
|
||||
'Yahoo MMCrawler [Bot]' => array('Yahoo-MMCrawler/', ''),
|
||||
'Yahoo Slurp [Bot]' => array('Yahoo! DE Slurp', ''),
|
||||
'Yahoo [Bot]' => array('Yahoo! Slurp', ''),
|
||||
'YahooSeeker [Bot]' => array('YahooSeeker/', ''),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$this->db->sql_return_on_error(true);
|
||||
|
||||
$sql = 'SELECT group_id
|
||||
FROM ' . GROUPS_TABLE . "
|
||||
WHERE group_name = 'BOTS'";
|
||||
$result = $this->db->sql_query($sql);
|
||||
$group_id = (int) $this->db->sql_fetchfield('group_id');
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
if (!$group_id)
|
||||
{
|
||||
// If we reach this point then something has gone very wrong
|
||||
$this->io_handler->add_error_message('NO_GROUP');
|
||||
}
|
||||
|
||||
foreach ($this->bot_list as $bot_name => $bot_ary)
|
||||
{
|
||||
$user_row = array(
|
||||
'user_type' => USER_IGNORE,
|
||||
'group_id' => $group_id,
|
||||
'username' => $bot_name,
|
||||
'user_regdate' => time(),
|
||||
'user_password' => '',
|
||||
'user_colour' => '9E8DA7',
|
||||
'user_email' => '',
|
||||
'user_lang' => $this->install_config->get('default_lang'),
|
||||
'user_style' => 1,
|
||||
'user_timezone' => 'UTC',
|
||||
'user_dateformat' => $this->language->lang('default_dateformat'),
|
||||
'user_allow_massemail' => 0,
|
||||
'user_allow_pm' => 0,
|
||||
);
|
||||
|
||||
$user_id = user_add($user_row);
|
||||
|
||||
if (!$user_id)
|
||||
{
|
||||
// If we can't insert this user then continue to the next one to avoid inconsistent data
|
||||
$this->io_handler->add_error_message('CONV_ERROR_INSERT_BOT');
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$sql = 'INSERT INTO ' . BOTS_TABLE . ' ' . $this->db->sql_build_array('INSERT', array(
|
||||
'bot_active' => 1,
|
||||
'bot_name' => (string) $bot_name,
|
||||
'user_id' => (int) $user_id,
|
||||
'bot_agent' => (string) $bot_ary[0],
|
||||
'bot_ip' => (string) $bot_ary[1],
|
||||
));
|
||||
|
||||
$this->db->sql_query($sql);
|
||||
}
|
||||
}
|
||||
}
|
105
phpBB/install/module/install_data/task/add_languages.php
Normal file
105
phpBB/install/module/install_data/task/add_languages.php
Normal file
|
@ -0,0 +1,105 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\install\module\install_data\task;
|
||||
|
||||
class add_languages extends \phpbb\install\task_base
|
||||
{
|
||||
/**
|
||||
* @var \phpbb\db\driver\driver_interface
|
||||
*/
|
||||
protected $db;
|
||||
|
||||
/**
|
||||
* @var \phpbb\install\helper\iohandler\iohandler_interface
|
||||
*/
|
||||
protected $iohandler;
|
||||
|
||||
/**
|
||||
* @var \phpbb\language\language_file_helper
|
||||
*/
|
||||
protected $language_helper;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \phpbb\install\helper\iohandler\iohandler_interface $iohandler Installer's input-output handler
|
||||
* @param \phpbb\install\helper\container_factory $container Installer's DI container
|
||||
* @param \phpbb\language\language_file_helper $language_helper Language file helper service
|
||||
*/
|
||||
public function __construct(\phpbb\install\helper\iohandler\iohandler_interface $iohandler,
|
||||
\phpbb\install\helper\container_factory $container,
|
||||
\phpbb\language\language_file_helper $language_helper)
|
||||
{
|
||||
$this->db = $container->get('dbal.conn');
|
||||
$this->iohandler = $iohandler;
|
||||
$this->language_helper = $language_helper;
|
||||
|
||||
parent::__construct(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$this->db->sql_return_on_error(true);
|
||||
|
||||
$languages = $this->language_helper->get_available_languages();
|
||||
$installed_languages = array();
|
||||
|
||||
foreach ($languages as $lang_info)
|
||||
{
|
||||
$lang_pack = array(
|
||||
'lang_iso' => $lang_info['iso'],
|
||||
'lang_dir' => $lang_info['iso'],
|
||||
'lang_english_name' => htmlspecialchars($lang_info['name']),
|
||||
'lang_local_name' => htmlspecialchars($lang_info['local_name'], ENT_COMPAT, 'UTF-8'),
|
||||
'lang_author' => htmlspecialchars($lang_info['author'], ENT_COMPAT, 'UTF-8'),
|
||||
);
|
||||
|
||||
$this->db->sql_query('INSERT INTO ' . LANG_TABLE . ' ' . $this->db->sql_build_array('INSERT', $lang_pack));
|
||||
|
||||
$installed_languages[] = (int) $this->db->sql_nextid();
|
||||
if ($this->db->get_sql_error_triggered())
|
||||
{
|
||||
$error = $this->db->sql_error($this->db->get_sql_error_sql());
|
||||
$this->iohandler->add_error_message($error['message']);
|
||||
}
|
||||
}
|
||||
|
||||
$sql = 'SELECT * FROM ' . PROFILE_FIELDS_TABLE;
|
||||
$result = $this->db->sql_query($sql);
|
||||
|
||||
$insert_buffer = new \phpbb\db\sql_insert_buffer($this->db, PROFILE_LANG_TABLE);
|
||||
while ($row = $this->db->sql_fetchrow($result))
|
||||
{
|
||||
foreach ($installed_languages as $lang_id)
|
||||
{
|
||||
$insert_buffer->insert(array(
|
||||
'field_id' => $row['field_id'],
|
||||
'lang_id' => $lang_id,
|
||||
|
||||
// Remove phpbb_ from field name
|
||||
'lang_name' => strtoupper(substr($row['field_name'], 6)),
|
||||
'lang_explain' => '',
|
||||
'lang_default_value' => '',
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
$insert_buffer->flush();
|
||||
}
|
||||
}
|
452
phpBB/install/module/install_data/task/add_modules.php
Normal file
452
phpBB/install/module/install_data/task/add_modules.php
Normal file
|
@ -0,0 +1,452 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\install\module\install_data\task;
|
||||
|
||||
class add_modules extends \phpbb\install\task_base
|
||||
{
|
||||
/**
|
||||
* @var \phpbb\db\driver\driver_interface
|
||||
*/
|
||||
protected $db;
|
||||
|
||||
/**
|
||||
* @var \phpbb\extension\manager
|
||||
*/
|
||||
protected $extension_manager;
|
||||
|
||||
/**
|
||||
* @var \phpbb\install\helper\iohandler\iohandler_interface
|
||||
*/
|
||||
protected $iohandler;
|
||||
|
||||
/**
|
||||
* @var \phpbb\module\module_manager
|
||||
*/
|
||||
protected $module_manager;
|
||||
|
||||
/**
|
||||
* Define the module structure so that we can populate the database without
|
||||
* needing to hard-code module_id values
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $module_categories;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $module_categories_basenames;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $module_extras;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \phpbb\install\helper\iohandler\iohandler_interface $iohandler Installer's input-output handler
|
||||
* @param \phpbb\install\helper\container_factory $container Installer's DI container
|
||||
*/
|
||||
public function __construct(\phpbb\install\helper\iohandler\iohandler_interface $iohandler,
|
||||
\phpbb\install\helper\container_factory $container)
|
||||
{
|
||||
$this->db = $container->get('dbal.conn');
|
||||
$this->extension_manager = $container->get('ext.manager');
|
||||
$this->iohandler = $iohandler;
|
||||
$this->module_manager = $container->get('module.manager');
|
||||
|
||||
parent::__construct(true);
|
||||
|
||||
$this->module_categories = array(
|
||||
'acp' => array(
|
||||
'ACP_CAT_GENERAL' => array(
|
||||
'ACP_QUICK_ACCESS',
|
||||
'ACP_BOARD_CONFIGURATION',
|
||||
'ACP_CLIENT_COMMUNICATION',
|
||||
'ACP_SERVER_CONFIGURATION',
|
||||
),
|
||||
'ACP_CAT_FORUMS' => array(
|
||||
'ACP_MANAGE_FORUMS',
|
||||
'ACP_FORUM_BASED_PERMISSIONS',
|
||||
),
|
||||
'ACP_CAT_POSTING' => array(
|
||||
'ACP_MESSAGES',
|
||||
'ACP_ATTACHMENTS',
|
||||
),
|
||||
'ACP_CAT_USERGROUP' => array(
|
||||
'ACP_CAT_USERS',
|
||||
'ACP_GROUPS',
|
||||
'ACP_USER_SECURITY',
|
||||
),
|
||||
'ACP_CAT_PERMISSIONS' => array(
|
||||
'ACP_GLOBAL_PERMISSIONS',
|
||||
'ACP_FORUM_BASED_PERMISSIONS',
|
||||
'ACP_PERMISSION_ROLES',
|
||||
'ACP_PERMISSION_MASKS',
|
||||
),
|
||||
'ACP_CAT_CUSTOMISE' => array(
|
||||
'ACP_STYLE_MANAGEMENT',
|
||||
'ACP_EXTENSION_MANAGEMENT',
|
||||
'ACP_LANGUAGE',
|
||||
),
|
||||
'ACP_CAT_MAINTENANCE' => array(
|
||||
'ACP_FORUM_LOGS',
|
||||
'ACP_CAT_DATABASE',
|
||||
),
|
||||
'ACP_CAT_SYSTEM' => array(
|
||||
'ACP_AUTOMATION',
|
||||
'ACP_GENERAL_TASKS',
|
||||
'ACP_MODULE_MANAGEMENT',
|
||||
),
|
||||
'ACP_CAT_DOT_MODS' => null,
|
||||
),
|
||||
'mcp' => array(
|
||||
'MCP_MAIN' => null,
|
||||
'MCP_QUEUE' => null,
|
||||
'MCP_REPORTS' => null,
|
||||
'MCP_NOTES' => null,
|
||||
'MCP_WARN' => null,
|
||||
'MCP_LOGS' => null,
|
||||
'MCP_BAN' => null,
|
||||
),
|
||||
'ucp' => array(
|
||||
'UCP_MAIN' => null,
|
||||
'UCP_PROFILE' => null,
|
||||
'UCP_PREFS' => null,
|
||||
'UCP_PM' => null,
|
||||
'UCP_USERGROUPS' => null,
|
||||
'UCP_ZEBRA' => null,
|
||||
),
|
||||
);
|
||||
|
||||
$this->module_categories_basenames = array(
|
||||
'UCP_PM' => 'ucp_pm',
|
||||
);
|
||||
|
||||
$this->module_extras = array(
|
||||
'acp' => array(
|
||||
'ACP_QUICK_ACCESS' => array(
|
||||
'ACP_MANAGE_USERS',
|
||||
'ACP_GROUPS_MANAGE',
|
||||
'ACP_MANAGE_FORUMS',
|
||||
'ACP_MOD_LOGS',
|
||||
'ACP_BOTS',
|
||||
'ACP_PHP_INFO',
|
||||
),
|
||||
'ACP_FORUM_BASED_PERMISSIONS' => array(
|
||||
'ACP_FORUM_PERMISSIONS',
|
||||
'ACP_FORUM_PERMISSIONS_COPY',
|
||||
'ACP_FORUM_MODERATORS',
|
||||
'ACP_USERS_FORUM_PERMISSIONS',
|
||||
'ACP_GROUPS_FORUM_PERMISSIONS',
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$this->db->sql_return_on_error(true);
|
||||
|
||||
$module_classes = array('acp', 'mcp', 'ucp');
|
||||
foreach ($module_classes as $module_class)
|
||||
{
|
||||
$categories = array();
|
||||
|
||||
foreach ($this->module_categories[$module_class] as $cat_name => $subs)
|
||||
{
|
||||
// Check if this sub-category has a basename. If it has, use it.
|
||||
$basename = (isset($this->module_categories_basenames[$cat_name])) ? $this->module_categories_basenames[$cat_name] : '';
|
||||
|
||||
$module_data = array(
|
||||
'module_basename' => $basename,
|
||||
'module_enabled' => 1,
|
||||
'module_display' => 1,
|
||||
'parent_id' => 0,
|
||||
'module_class' => $module_class,
|
||||
'module_langname' => $cat_name,
|
||||
'module_mode' => '',
|
||||
'module_auth' => '',
|
||||
);
|
||||
|
||||
$this->module_manager->update_module_data($module_data);
|
||||
|
||||
// Check for last sql error happened
|
||||
if ($this->db->get_sql_error_triggered())
|
||||
{
|
||||
$error = $this->db->sql_error($this->db->get_sql_error_sql());
|
||||
$this->iohandler->add_error_message('INST_ERR_DB', $error['message']);
|
||||
}
|
||||
|
||||
$categories[$cat_name]['id'] = (int)$module_data['module_id'];
|
||||
$categories[$cat_name]['parent_id'] = 0;
|
||||
|
||||
if (is_array($subs))
|
||||
{
|
||||
foreach ($subs as $level2_name)
|
||||
{
|
||||
// Check if this sub-category has a basename. If it has, use it.
|
||||
$basename = (isset($this->module_categories_basenames[$level2_name])) ? $this->module_categories_basenames[$level2_name] : '';
|
||||
|
||||
$module_data = array(
|
||||
'module_basename' => $basename,
|
||||
'module_enabled' => 1,
|
||||
'module_display' => 1,
|
||||
'parent_id' => (int)$categories[$cat_name]['id'],
|
||||
'module_class' => $module_class,
|
||||
'module_langname' => $level2_name,
|
||||
'module_mode' => '',
|
||||
'module_auth' => '',
|
||||
);
|
||||
|
||||
$this->module_manager->update_module_data($module_data);
|
||||
|
||||
// Check for last sql error happened
|
||||
if ($this->db->get_sql_error_triggered())
|
||||
{
|
||||
$error = $this->db->sql_error($this->db->get_sql_error_sql());
|
||||
$this->iohandler->add_error_message('INST_ERR_DB', $error['message']);
|
||||
}
|
||||
|
||||
$categories[$level2_name]['id'] = (int)$module_data['module_id'];
|
||||
$categories[$level2_name]['parent_id'] = (int)$categories[$cat_name]['id'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get the modules we want to add... returned sorted by name
|
||||
$module_info = $this->module_manager->get_module_infos($module_class);
|
||||
|
||||
foreach ($module_info as $module_basename => $fileinfo)
|
||||
{
|
||||
foreach ($fileinfo['modes'] as $module_mode => $row)
|
||||
{
|
||||
foreach ($row['cat'] as $cat_name)
|
||||
{
|
||||
if (!isset($categories[$cat_name]))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$module_data = array(
|
||||
'module_basename' => $module_basename,
|
||||
'module_enabled' => 1,
|
||||
'module_display' => (isset($row['display'])) ? (int) $row['display'] : 1,
|
||||
'parent_id' => (int) $categories[$cat_name]['id'],
|
||||
'module_class' => $module_class,
|
||||
'module_langname' => $row['title'],
|
||||
'module_mode' => $module_mode,
|
||||
'module_auth' => $row['auth'],
|
||||
);
|
||||
|
||||
$this->module_manager->update_module_data($module_data);
|
||||
|
||||
// Check for last sql error happened
|
||||
if ($this->db->get_sql_error_triggered())
|
||||
{
|
||||
$error = $this->db->sql_error($this->db->get_sql_error_sql());
|
||||
$this->iohandler->add_error_message('INST_ERR_DB', $error['message']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Move some of the modules around since the code above will put them in the wrong place
|
||||
if ($module_class === 'acp')
|
||||
{
|
||||
// Move main module 4 up...
|
||||
$sql = 'SELECT *
|
||||
FROM ' . MODULES_TABLE . "
|
||||
WHERE module_basename = 'acp_main'
|
||||
AND module_class = 'acp'
|
||||
AND module_mode = 'main'";
|
||||
$result = $this->db->sql_query($sql);
|
||||
$row = $this->db->sql_fetchrow($result);
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
$this->module_manager->move_module_by($row, 'acp', 'move_up', 4);
|
||||
|
||||
// Move permissions intro screen module 4 up...
|
||||
$sql = 'SELECT *
|
||||
FROM ' . MODULES_TABLE . "
|
||||
WHERE module_basename = 'acp_permissions'
|
||||
AND module_class = 'acp'
|
||||
AND module_mode = 'intro'";
|
||||
$result = $this->db->sql_query($sql);
|
||||
$row = $this->db->sql_fetchrow($result);
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
$this->module_manager->move_module_by($row, 'acp', 'move_up', 4);
|
||||
|
||||
// Move manage users screen module 5 up...
|
||||
$sql = 'SELECT *
|
||||
FROM ' . MODULES_TABLE . "
|
||||
WHERE module_basename = 'acp_users'
|
||||
AND module_class = 'acp'
|
||||
AND module_mode = 'overview'";
|
||||
$result = $this->db->sql_query($sql);
|
||||
$row = $this->db->sql_fetchrow($result);
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
$this->module_manager->move_module_by($row, 'acp', 'move_up', 5);
|
||||
|
||||
// Move extension management module 1 up...
|
||||
$sql = 'SELECT *
|
||||
FROM ' . MODULES_TABLE . "
|
||||
WHERE module_langname = 'ACP_EXTENSION_MANAGEMENT'
|
||||
AND module_class = 'acp'
|
||||
AND module_mode = ''
|
||||
AND module_basename = ''";
|
||||
$result = $this->db->sql_query($sql);
|
||||
$row = $this->db->sql_fetchrow($result);
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
$this->module_manager->move_module_by($row, 'acp', 'move_up', 1);
|
||||
}
|
||||
|
||||
if ($module_class == 'mcp')
|
||||
{
|
||||
// Move pm report details module 3 down...
|
||||
$sql = 'SELECT *
|
||||
FROM ' . MODULES_TABLE . "
|
||||
WHERE module_basename = 'mcp_pm_reports'
|
||||
AND module_class = 'mcp'
|
||||
AND module_mode = 'pm_report_details'";
|
||||
$result = $this->db->sql_query($sql);
|
||||
$row = $this->db->sql_fetchrow($result);
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
$this->module_manager->move_module_by($row, 'mcp', 'move_down', 3);
|
||||
|
||||
// Move closed pm reports module 3 down...
|
||||
$sql = 'SELECT *
|
||||
FROM ' . MODULES_TABLE . "
|
||||
WHERE module_basename = 'mcp_pm_reports'
|
||||
AND module_class = 'mcp'
|
||||
AND module_mode = 'pm_reports_closed'";
|
||||
$result = $this->db->sql_query($sql);
|
||||
$row = $this->db->sql_fetchrow($result);
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
$this->module_manager->move_module_by($row, 'mcp', 'move_down', 3);
|
||||
|
||||
// Move open pm reports module 3 down...
|
||||
$sql = 'SELECT *
|
||||
FROM ' . MODULES_TABLE . "
|
||||
WHERE module_basename = 'mcp_pm_reports'
|
||||
AND module_class = 'mcp'
|
||||
AND module_mode = 'pm_reports'";
|
||||
$result = $this->db->sql_query($sql);
|
||||
$row = $this->db->sql_fetchrow($result);
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
$this->module_manager->move_module_by($row, 'mcp', 'move_down', 3);
|
||||
}
|
||||
|
||||
if ($module_class == 'ucp')
|
||||
{
|
||||
// Move attachment module 4 down...
|
||||
$sql = 'SELECT *
|
||||
FROM ' . MODULES_TABLE . "
|
||||
WHERE module_basename = 'ucp_attachments'
|
||||
AND module_class = 'ucp'
|
||||
AND module_mode = 'attachments'";
|
||||
$result = $this->db->sql_query($sql);
|
||||
$row = $this->db->sql_fetchrow($result);
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
$this->module_manager->move_module_by($row, 'ucp', 'move_down', 4);
|
||||
|
||||
// Move notification options module 4 down...
|
||||
$sql = 'SELECT *
|
||||
FROM ' . MODULES_TABLE . "
|
||||
WHERE module_basename = 'ucp_notifications'
|
||||
AND module_class = 'ucp'
|
||||
AND module_mode = 'notification_options'";
|
||||
$result = $this->db->sql_query($sql);
|
||||
$row = $this->db->sql_fetchrow($result);
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
$this->module_manager->move_module_by($row, 'ucp', 'move_down', 4);
|
||||
|
||||
// Move OAuth module 5 down...
|
||||
$sql = 'SELECT *
|
||||
FROM ' . MODULES_TABLE . "
|
||||
WHERE module_basename = 'ucp_auth_link'
|
||||
AND module_class = 'ucp'
|
||||
AND module_mode = 'auth_link'";
|
||||
$result = $this->db->sql_query($sql);
|
||||
$row = $this->db->sql_fetchrow($result);
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
$this->module_manager->move_module_by($row, 'ucp', 'move_down', 5);
|
||||
}
|
||||
|
||||
// And now for the special ones
|
||||
// (these are modules which appear in multiple categories and thus get added manually
|
||||
// to some for more control)
|
||||
if (isset($this->module_extras[$module_class]))
|
||||
{
|
||||
foreach ($this->module_extras[$module_class] as $cat_name => $mods)
|
||||
{
|
||||
$sql = 'SELECT module_id, left_id, right_id
|
||||
FROM ' . MODULES_TABLE . "
|
||||
WHERE module_langname = '" . $this->db->sql_escape($cat_name) . "'
|
||||
AND module_class = '" . $this->db->sql_escape($module_class) . "'";
|
||||
$result = $this->db->sql_query_limit($sql, 1);
|
||||
$row2 = $this->db->sql_fetchrow($result);
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
foreach ($mods as $mod_name)
|
||||
{
|
||||
$sql = 'SELECT *
|
||||
FROM ' . MODULES_TABLE . "
|
||||
WHERE module_langname = '" . $this->db->sql_escape($mod_name) . "'
|
||||
AND module_class = '" . $this->db->sql_escape($module_class) . "'
|
||||
AND module_basename <> ''";
|
||||
$result = $this->db->sql_query_limit($sql, 1);
|
||||
$row = $this->db->sql_fetchrow($result);
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
$module_data = array(
|
||||
'module_basename' => $row['module_basename'],
|
||||
'module_enabled' => (int) $row['module_enabled'],
|
||||
'module_display' => (int) $row['module_display'],
|
||||
'parent_id' => (int) $row2['module_id'],
|
||||
'module_class' => $row['module_class'],
|
||||
'module_langname' => $row['module_langname'],
|
||||
'module_mode' => $row['module_mode'],
|
||||
'module_auth' => $row['module_auth'],
|
||||
);
|
||||
|
||||
$this->module_manager->update_module_data($module_data);
|
||||
|
||||
// Check for last sql error happened
|
||||
if ($this->db->get_sql_error_triggered())
|
||||
{
|
||||
$error = $this->db->sql_error($this->db->get_sql_error_sql());
|
||||
$this->iohandler->add_error_message('INST_ERR_DB', $error['message']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->module_manager->remove_cache_file($module_class);
|
||||
}
|
||||
}
|
||||
}
|
22
phpBB/install/module/install_database/module.php
Normal file
22
phpBB/install/module/install_database/module.php
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\install\module\install_database;
|
||||
|
||||
/**
|
||||
* Installer module for database installation
|
||||
*/
|
||||
class module extends \phpbb\install\module_base
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,325 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\install\module\install_database\task;
|
||||
|
||||
/**
|
||||
* Create database schema
|
||||
*/
|
||||
class add_config_settings extends \phpbb\install\task_base
|
||||
{
|
||||
/**
|
||||
* @var \phpbb\db\driver\driver_interface
|
||||
*/
|
||||
protected $db;
|
||||
|
||||
/**
|
||||
* @var \phpbb\filesystem\filesystem_interface
|
||||
*/
|
||||
protected $filesystem;
|
||||
|
||||
/**
|
||||
* @var \phpbb\install\helper\config
|
||||
*/
|
||||
protected $install_config;
|
||||
|
||||
/**
|
||||
* @var \phpbb\install\helper\iohandler\iohandler_interface
|
||||
*/
|
||||
protected $iohandler;
|
||||
|
||||
/**
|
||||
* @var \phpbb\language\language
|
||||
*/
|
||||
protected $language;
|
||||
|
||||
/**
|
||||
* @var \phpbb\passwords\manager
|
||||
*/
|
||||
protected $password_manager;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $phpbb_root_path;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $config_table;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $user_table;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $topics_table;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $forums_table;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $posts_table;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $moderator_cache_table;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \phpbb\filesystem\filesystem_interface $filesystem Filesystem service
|
||||
* @param \phpbb\install\helper\config $install_config Installer's config helper
|
||||
* @param \phpbb\install\helper\iohandler\iohandler_interface $iohandler Installer's input-output handler
|
||||
* @param \phpbb\install\helper\container_factory $container Installer's DI container
|
||||
* @param \phpbb\language\language $language Language service
|
||||
* @param string $phpbb_root_path Path to phpBB's root
|
||||
*/
|
||||
public function __construct(\phpbb\filesystem\filesystem_interface $filesystem,
|
||||
\phpbb\install\helper\config $install_config,
|
||||
\phpbb\install\helper\iohandler\iohandler_interface $iohandler,
|
||||
\phpbb\install\helper\container_factory $container,
|
||||
\phpbb\language\language $language,
|
||||
$phpbb_root_path)
|
||||
{
|
||||
$this->db = $container->get('dbal.conn');
|
||||
$this->filesystem = $filesystem;
|
||||
$this->install_config = $install_config;
|
||||
$this->iohandler = $iohandler;
|
||||
$this->language = $language;
|
||||
$this->password_manager = $container->get('passwords.manager');
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
|
||||
// Table names
|
||||
$this->config_table = $container->get_parameter('tables.config');
|
||||
$this->forums_table = $container->get_parameter('tables.forums');
|
||||
$this->topics_table = $container->get_parameter('tables.topics');
|
||||
$this->user_table = $container->get_parameter('tables.users');
|
||||
$this->moderator_cache_table = $container->get_parameter('tables.moderator_cache');
|
||||
$this->posts_table = $container->get_parameter('tables.posts');
|
||||
|
||||
parent::__construct(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$this->db->sql_return_on_error(true);
|
||||
|
||||
$server_name = $this->install_config->get('server_name');
|
||||
$cookie_domain = $this->install_config->get('cookie_domain');
|
||||
$current_time = time();
|
||||
$user_ip = phpbb_ip_normalise($this->iohandler->get_server_variable('REMOTE_ADDR'));
|
||||
$user_ip = ($user_ip === false) ? '' : $user_ip;
|
||||
$referer = $this->iohandler->get_server_variable('REFERER');
|
||||
|
||||
// Set default config and post data, this applies to all DB's
|
||||
$sql_ary = array(
|
||||
'INSERT INTO ' . $this->config_table . " (config_name, config_value)
|
||||
VALUES ('board_startdate', '$current_time')",
|
||||
|
||||
'INSERT INTO ' . $this->config_table . " (config_name, config_value)
|
||||
VALUES ('default_lang', '" . $this->db->sql_escape($this->install_config->get('default_lang')) . "')",
|
||||
|
||||
'UPDATE ' . $this->config_table . "
|
||||
SET config_value = '" . $this->db->sql_escape($this->install_config->get('img_imagick')) . "'
|
||||
WHERE config_name = 'img_imagick'",
|
||||
|
||||
'UPDATE ' . $this->config_table . "
|
||||
SET config_value = '" . $this->db->sql_escape($this->install_config->get('server_name')) . "'
|
||||
WHERE config_name = 'server_name'",
|
||||
|
||||
'UPDATE ' . $this->config_table . "
|
||||
SET config_value = '" . $this->db->sql_escape($this->install_config->get('server_port')) . "'
|
||||
WHERE config_name = 'server_port'",
|
||||
|
||||
'UPDATE ' . $this->config_table . "
|
||||
SET config_value = '" . $this->db->sql_escape($this->install_config->get('board_email')) . "'
|
||||
WHERE config_name = 'board_email'",
|
||||
|
||||
'UPDATE ' . $this->config_table . "
|
||||
SET config_value = '" . $this->db->sql_escape($this->install_config->get('board_email')) . "'
|
||||
WHERE config_name = 'board_contact'",
|
||||
|
||||
'UPDATE ' . $this->config_table . "
|
||||
SET config_value = '" . $this->db->sql_escape($cookie_domain) . "'
|
||||
WHERE config_name = 'cookie_domain'",
|
||||
|
||||
'UPDATE ' . $this->config_table . "
|
||||
SET config_value = '" . $this->db->sql_escape($this->language->lang('default_dateformat')) . "'
|
||||
WHERE config_name = 'default_dateformat'",
|
||||
|
||||
'UPDATE ' . $this->config_table . "
|
||||
SET config_value = '" . $this->db->sql_escape($this->install_config->get('email_enable')) . "'
|
||||
WHERE config_name = 'email_enable'",
|
||||
|
||||
'UPDATE ' . $this->config_table . "
|
||||
SET config_value = '" . $this->db->sql_escape($this->install_config->get('smtp_delivery')) . "'
|
||||
WHERE config_name = 'smtp_delivery'",
|
||||
|
||||
'UPDATE ' . $this->config_table . "
|
||||
SET config_value = '" . $this->db->sql_escape($this->install_config->get('smtp_host')) . "'
|
||||
WHERE config_name = 'smtp_host'",
|
||||
|
||||
'UPDATE ' . $this->config_table . "
|
||||
SET config_value = '" . $this->db->sql_escape($this->install_config->get('smtp_auth')) . "'
|
||||
WHERE config_name = 'smtp_auth_method'",
|
||||
|
||||
'UPDATE ' . $this->config_table . "
|
||||
SET config_value = '" . $this->db->sql_escape($this->install_config->get('smtp_user')) . "'
|
||||
WHERE config_name = 'smtp_username'",
|
||||
|
||||
'UPDATE ' . $this->config_table . "
|
||||
SET config_value = '" . $this->db->sql_escape($this->install_config->get('smtp_pass')) . "'
|
||||
WHERE config_name = 'smtp_password'",
|
||||
|
||||
'UPDATE ' . $this->config_table . "
|
||||
SET config_value = '" . $this->db->sql_escape($this->install_config->get('cookie_secure')) . "'
|
||||
WHERE config_name = 'cookie_secure'",
|
||||
|
||||
'UPDATE ' . $this->config_table . "
|
||||
SET config_value = '" . $this->db->sql_escape($this->install_config->get('force_server_vars')) . "'
|
||||
WHERE config_name = 'force_server_vars'",
|
||||
|
||||
'UPDATE ' . $this->config_table . "
|
||||
SET config_value = '" . $this->db->sql_escape($this->install_config->get('script_path')) . "'
|
||||
WHERE config_name = 'script_path'",
|
||||
|
||||
'UPDATE ' . $this->config_table . "
|
||||
SET config_value = '" . $this->db->sql_escape($this->install_config->get('server_protocol')) . "'
|
||||
WHERE config_name = 'server_protocol'",
|
||||
|
||||
'UPDATE ' . $this->config_table . "
|
||||
SET config_value = '" . $this->db->sql_escape($this->install_config->get('admin_name')) . "'
|
||||
WHERE config_name = 'newest_username'",
|
||||
|
||||
'UPDATE ' . $this->config_table . "
|
||||
SET config_value = '" . md5(mt_rand()) . "'
|
||||
WHERE config_name = 'avatar_salt'",
|
||||
|
||||
'UPDATE ' . $this->config_table . "
|
||||
SET config_value = '" . md5(mt_rand()) . "'
|
||||
WHERE config_name = 'plupload_salt'",
|
||||
|
||||
'UPDATE ' . $this->config_table . "
|
||||
SET config_value = '" . $this->db->sql_escape($this->install_config->get('board_name')) . "'
|
||||
WHERE config_name = 'sitename'",
|
||||
|
||||
'UPDATE ' . $this->config_table . "
|
||||
SET config_value = '" . $this->db->sql_escape($this->install_config->get('board_description')) . "'
|
||||
WHERE config_name = 'site_desc'",
|
||||
|
||||
'UPDATE ' . $this->user_table . "
|
||||
SET username = '" . $this->db->sql_escape($this->install_config->get('admin_name')) . "',
|
||||
user_password='" . $this->password_manager->hash($this->install_config->get('admin_passwd')) . "',
|
||||
user_ip = '" . $this->db->sql_escape($user_ip) . "',
|
||||
user_lang = '" . $this->db->sql_escape($this->install_config->get('language')) . "',
|
||||
user_email='" . $this->db->sql_escape($this->install_config->get('board_email')) . "',
|
||||
user_dateformat='" . $this->db->sql_escape($this->language->lang('default_dateformat')) . "',
|
||||
user_email_hash = " . $this->db->sql_escape(phpbb_email_hash($this->install_config->get('board_email'))) . ",
|
||||
username_clean = '" . $this->db->sql_escape(utf8_clean_string($this->install_config->get('admin_name'))) . "'
|
||||
WHERE username = 'Admin'",
|
||||
|
||||
'UPDATE ' . $this->moderator_cache_table . "
|
||||
SET username = '" . $this->db->sql_escape($this->install_config->get('admin_name')) . "'
|
||||
WHERE username = 'Admin'",
|
||||
|
||||
'UPDATE ' . $this->forums_table . "
|
||||
SET forum_last_poster_name = '" . $this->db->sql_escape($this->install_config->get('admin_name')) . "'
|
||||
WHERE forum_last_poster_name = 'Admin'",
|
||||
|
||||
'UPDATE ' . $this->topics_table . "
|
||||
SET topic_first_poster_name = '" . $this->db->sql_escape($this->install_config->get('admin_name')) . "',
|
||||
topic_last_poster_name = '" . $this->db->sql_escape($this->install_config->get('admin_name')) . "'
|
||||
WHERE topic_first_poster_name = 'Admin'
|
||||
OR topic_last_poster_name = 'Admin'",
|
||||
|
||||
'UPDATE ' . $this->user_table . "
|
||||
SET user_regdate = $current_time",
|
||||
|
||||
'UPDATE ' . $this->posts_table . "
|
||||
SET post_time = $current_time, poster_ip = '" . $this->db->sql_escape($user_ip) . "'",
|
||||
|
||||
'UPDATE ' . $this->topics_table . "
|
||||
SET topic_time = $current_time, topic_last_post_time = $current_time",
|
||||
|
||||
'UPDATE ' . $this->forums_table . "
|
||||
SET forum_last_post_time = $current_time",
|
||||
|
||||
'UPDATE ' . $this->config_table . "
|
||||
SET config_value = '" . $this->db->sql_escape($this->db->sql_server_info(true)) . "'
|
||||
WHERE config_name = 'dbms_version'",
|
||||
);
|
||||
|
||||
if (@extension_loaded('gd'))
|
||||
{
|
||||
$sql_ary[] = 'UPDATE ' . $this->config_table . "
|
||||
SET config_value = 'core.captcha.plugins.gd'
|
||||
WHERE config_name = 'captcha_plugin'";
|
||||
|
||||
$sql_ary[] = 'UPDATE ' . $this->config_table . "
|
||||
SET config_value = '1'
|
||||
WHERE config_name = 'captcha_gd'";
|
||||
}
|
||||
|
||||
$ref = substr($referer, strpos($referer, '://') + 3);
|
||||
if (!(stripos($ref, $server_name) === 0))
|
||||
{
|
||||
$sql_ary[] = 'UPDATE ' . $this->config_table . "
|
||||
SET config_value = '0'
|
||||
WHERE config_name = 'referer_validation'";
|
||||
}
|
||||
|
||||
// We set a (semi-)unique cookie name to bypass login issues related to the cookie name.
|
||||
$cookie_name = 'phpbb3_';
|
||||
$rand_str = md5(mt_rand());
|
||||
$rand_str = str_replace('0', 'z', base_convert($rand_str, 16, 35));
|
||||
$rand_str = substr($rand_str, 0, 5);
|
||||
$cookie_name .= strtolower($rand_str);
|
||||
|
||||
$sql_ary[] = 'UPDATE ' . $this->config_table . "
|
||||
SET config_value = '" . $this->db->sql_escape($cookie_name) . "'
|
||||
WHERE config_name = 'cookie_name'";
|
||||
|
||||
// Disable avatars if upload directory is not writable
|
||||
if (!$this->filesystem->is_writable($this->phpbb_root_path . 'images/avatars/upload/'))
|
||||
{
|
||||
$sql_ary[] = 'UPDATE ' . $this->config_table . "
|
||||
SET config_value = '0'
|
||||
WHERE config_name = 'allow_avatar'";
|
||||
|
||||
$sql_ary[] = 'UPDATE ' . $this->config_table . "
|
||||
SET config_value = '0'
|
||||
WHERE config_name = 'allow_avatar_upload'";
|
||||
}
|
||||
|
||||
foreach ($sql_ary as $sql)
|
||||
{
|
||||
if (!$this->db->sql_query($sql))
|
||||
{
|
||||
$error = $this->db->sql_error($this->db->get_sql_error_sql());
|
||||
$this->iohandler->add_error_message('INST_ERR_DB', $error['message']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
145
phpBB/install/module/install_database/task/add_default_data.php
Normal file
145
phpBB/install/module/install_database/task/add_default_data.php
Normal file
|
@ -0,0 +1,145 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\install\module\install_database\task;
|
||||
|
||||
/**
|
||||
* Create database schema
|
||||
*/
|
||||
class add_default_data extends \phpbb\install\task_base
|
||||
{
|
||||
/**
|
||||
* @var \phpbb\db\driver\driver_interface
|
||||
*/
|
||||
protected $db;
|
||||
|
||||
/**
|
||||
* @var \phpbb\install\helper\database
|
||||
*/
|
||||
protected $database_helper;
|
||||
|
||||
/**
|
||||
* @var \phpbb\install\helper\config
|
||||
*/
|
||||
protected $config;
|
||||
|
||||
/**
|
||||
* @var \phpbb\install\helper\iohandler\iohandler_interface
|
||||
*/
|
||||
protected $iohandler;
|
||||
|
||||
/**
|
||||
* @var \phpbb\language\language
|
||||
*/
|
||||
protected $language;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \phpbb\install\helper\database $db_helper Installer's database helper
|
||||
* @param \phpbb\install\helper\config $config Installer config
|
||||
* @param \phpbb\install\helper\iohandler\iohandler_interface $iohandler Installer's input-output handler
|
||||
* @param \phpbb\install\helper\container_factory $container Installer's DI container
|
||||
* @param \phpbb\language\language $language Language service
|
||||
*/
|
||||
public function __construct(\phpbb\install\helper\database $db_helper,
|
||||
\phpbb\install\helper\config $config,
|
||||
\phpbb\install\helper\iohandler\iohandler_interface $iohandler,
|
||||
\phpbb\install\helper\container_factory $container,
|
||||
\phpbb\language\language $language)
|
||||
{
|
||||
$dbms = $db_helper->get_available_dbms($config->get('dbms'));
|
||||
$dbms = $dbms[$config->get('dbms')]['DRIVER'];
|
||||
|
||||
$this->db = $container->get('dbal.conn'); //new $dbms();
|
||||
$this->database_helper = $db_helper;
|
||||
$this->config = $config;
|
||||
$this->iohandler = $iohandler;
|
||||
$this->language = $language;
|
||||
|
||||
parent::__construct(true);
|
||||
|
||||
// Connect to DB
|
||||
//$this->db->sql_connect($config->get('dbhost'), $config->get('dbuser'), $config->get('dbpasswd'), $config->get('dbname'), $config->get('dbport'), false, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$this->db->sql_return_on_error(true);
|
||||
|
||||
$table_prefix = $this->config->get('table_prefix');
|
||||
$dbms = $this->config->get('dbms');
|
||||
$dbms_info = $this->database_helper->get_available_dbms($dbms);
|
||||
|
||||
// Get schema data from file
|
||||
$sql_query = @file_get_contents('schemas/schema_data.sql');
|
||||
|
||||
// Clean up SQL
|
||||
$sql_query = $this->replace_dbms_specific_sql($sql_query);
|
||||
$sql_query = preg_replace('# phpbb_([^\s]*) #i', ' ' . $table_prefix . '\1 ', $sql_query);
|
||||
$sql_query = preg_replace_callback('#\{L_([A-Z0-9\-_]*)\}#s', array($this, 'lang_replace_callback'), $sql_query);
|
||||
$sql_query = $this->database_helper->remove_comments($sql_query);
|
||||
$sql_query = $this->database_helper->split_sql_file($sql_query, $dbms_info[$dbms]['DELIM']);
|
||||
|
||||
foreach ($sql_query as $sql)
|
||||
{
|
||||
if (!$this->db->sql_query($sql))
|
||||
{
|
||||
$error = $this->db->sql_error($this->db->get_sql_error_sql());
|
||||
$this->iohandler->add_error_message('INST_ERR_DB', $error['message']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process DB specific SQL
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function replace_dbms_specific_sql($query)
|
||||
{
|
||||
if ($this->db instanceof \phpbb\db\driver\mssql_base || $this->db instanceof \phpbb\db\driver\mssql)
|
||||
{
|
||||
$query = preg_replace('#\# MSSQL IDENTITY (phpbb_[a-z_]+) (ON|OFF) \##s', 'SET IDENTITY_INSERT \1 \2;', $query);
|
||||
}
|
||||
else if ($this->db instanceof \phpbb\db\driver\postgres)
|
||||
{
|
||||
$query = preg_replace('#\# POSTGRES (BEGIN|COMMIT) \##s', '\1; ', $query);
|
||||
}
|
||||
else if ($this->db instanceof \phpbb\db\driver\mysql_base)
|
||||
{
|
||||
$query = str_replace('\\', '\\\\', $query);
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback function for language replacing
|
||||
*
|
||||
* @param array $matches
|
||||
* @return string
|
||||
*/
|
||||
public function lang_replace_callback($matches)
|
||||
{
|
||||
if (!empty($matches[1]))
|
||||
{
|
||||
return $this->db->sql_escape($this->language->lang($matches[1]));
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
198
phpBB/install/module/install_database/task/create_schema.php
Normal file
198
phpBB/install/module/install_database/task/create_schema.php
Normal file
|
@ -0,0 +1,198 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\install\module\install_database\task;
|
||||
|
||||
/**
|
||||
* Create database schema
|
||||
*/
|
||||
class create_schema extends \phpbb\install\task_base
|
||||
{
|
||||
/**
|
||||
* @var \phpbb\install\helper\config
|
||||
*/
|
||||
protected $config;
|
||||
|
||||
/**
|
||||
* @var \phpbb\db\driver\driver_interface
|
||||
*/
|
||||
protected $db;
|
||||
|
||||
/**
|
||||
* @var \phpbb\db\tools\tools_interface
|
||||
*/
|
||||
protected $db_tools;
|
||||
|
||||
/**
|
||||
* @var \phpbb\install\helper\database
|
||||
*/
|
||||
protected $database_helper;
|
||||
|
||||
/**
|
||||
* @var \phpbb\filesystem\filesystem_interface
|
||||
*/
|
||||
protected $filesystem;
|
||||
|
||||
/**
|
||||
* @var \phpbb\install\helper\iohandler\iohandler_interface
|
||||
*/
|
||||
protected $iohandler;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $phpbb_root_path;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $php_ext;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \phpbb\install\helper\config $config Installer's config provider
|
||||
* @param \phpbb\install\helper\database $db_helper Installer's database helper
|
||||
* @param \phpbb\filesystem\filesystem_interface $filesystem Filesystem service
|
||||
* @param \phpbb\install\helper\iohandler\iohandler_interface $iohandler Installer's input-output handler
|
||||
* @param string $phpbb_root_path Path phpBB's root
|
||||
* @param string $php_ext Extension of PHP files
|
||||
*/
|
||||
public function __construct(\phpbb\install\helper\config $config,
|
||||
\phpbb\install\helper\database $db_helper,
|
||||
\phpbb\filesystem\filesystem_interface $filesystem,
|
||||
\phpbb\install\helper\iohandler\iohandler_interface $iohandler,
|
||||
$phpbb_root_path,
|
||||
$php_ext)
|
||||
{
|
||||
$dbms = $db_helper->get_available_dbms($config->get('dbms'));
|
||||
$dbms = $dbms[$config->get('dbms')]['DRIVER'];
|
||||
$factory = new \phpbb\db\tools\factory();
|
||||
|
||||
$this->db = new $dbms();
|
||||
$this->config = $config;
|
||||
$this->db_tools = $factory->get($this->db);
|
||||
$this->database_helper = $db_helper;
|
||||
$this->filesystem = $filesystem;
|
||||
$this->iohandler = $iohandler;
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
$this->php_ext = $php_ext;
|
||||
|
||||
parent::__construct(true);
|
||||
|
||||
// Connect to DB
|
||||
$this->db->sql_connect($config->get('dbhost'), $config->get('dbuser'), $config->get('dbpasswd'), $config->get('dbname'), $config->get('dbport'), false, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$this->db->sql_return_on_error(true);
|
||||
|
||||
$dbms = $this->config->get('dbms');
|
||||
$dbms_info = $this->database_helper->get_available_dbms($dbms);
|
||||
$schema_name = $dbms_info[$dbms]['SCHEMA'];
|
||||
$delimiter = $dbms_info[$dbms]['DELIM'];
|
||||
$table_prefix = $this->config->get('table_prefix');
|
||||
|
||||
if ($dbms === 'mysql')
|
||||
{
|
||||
if (version_compare($this->db->sql_server_info(true), '4.1.3', '>='))
|
||||
{
|
||||
$schema_name .= '_41';
|
||||
}
|
||||
else
|
||||
{
|
||||
$schema_name .= '_40';
|
||||
}
|
||||
}
|
||||
|
||||
$db_schema_path = $this->phpbb_root_path . 'install/schemas/' . $schema_name . '_schema.sql';
|
||||
|
||||
// Load database vendor specific code if there is any
|
||||
if ($this->filesystem->exists($db_schema_path))
|
||||
{
|
||||
$sql_query = @file_get_contents($db_schema_path);
|
||||
$sql_query = preg_replace('#phpbb_#i', $table_prefix, $sql_query);
|
||||
$sql_query = $this->database_helper->remove_comments($sql_query);
|
||||
$sql_query = $this->database_helper->split_sql_file($sql_query, $delimiter);
|
||||
|
||||
foreach ($sql_query as $sql)
|
||||
{
|
||||
if (!$this->db->sql_query($sql))
|
||||
{
|
||||
$error = $this->db->sql_error($this->db->get_sql_error_sql());
|
||||
$this->iohandler->add_error_message('INST_ERR_DB', $error['message']);
|
||||
}
|
||||
}
|
||||
|
||||
unset($sql_query);
|
||||
}
|
||||
|
||||
$change_prefix = false;
|
||||
|
||||
// Generate database schema
|
||||
if ($this->filesystem->exists($this->phpbb_root_path . 'install/schemas/schema.json'))
|
||||
{
|
||||
$db_table_schema = @file_get_contents($this->phpbb_root_path . 'install/schemas/schema.json');
|
||||
$db_table_schema = json_decode($db_table_schema, true);
|
||||
$change_prefix = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
global $table_prefix;
|
||||
|
||||
$table_prefix = $this->config->get('table_prefix');
|
||||
|
||||
if (!defined('CONFIG_TABLE'))
|
||||
{
|
||||
// We need to include the constants file for the table constants
|
||||
// when we generate the schema from the migration files.
|
||||
include ($this->phpbb_root_path . 'includes/constants.' . $this->php_ext);
|
||||
}
|
||||
|
||||
$finder = new \phpbb\finder($this->filesystem, $this->phpbb_root_path, null, $this->php_ext);
|
||||
$migrator_classes = $finder->core_path('phpbb/db/migration/data/')->get_classes();
|
||||
$factory = new \phpbb\db\tools\factory();
|
||||
$db_tools = $factory->get($this->db, true);
|
||||
$schema_generator = new \phpbb\db\migration\schema_generator(
|
||||
$migrator_classes,
|
||||
new \phpbb\config\config(array()),
|
||||
$this->db,
|
||||
$db_tools,
|
||||
$this->phpbb_root_path,
|
||||
$this->php_ext,
|
||||
$table_prefix
|
||||
);
|
||||
$db_table_schema = $schema_generator->get_schema();
|
||||
}
|
||||
|
||||
if (!defined('CONFIG_TABLE'))
|
||||
{
|
||||
// CONFIG_TABLE is required by sql_create_index() to check the
|
||||
// length of index names. However table_prefix is not defined
|
||||
// here yet, so we need to create the constant ourselves.
|
||||
define('CONFIG_TABLE', $table_prefix . 'config');
|
||||
}
|
||||
|
||||
foreach ($db_table_schema as $table_name => $table_data)
|
||||
{
|
||||
$this->db_tools->sql_create_table(
|
||||
( ($change_prefix) ? ($table_prefix . substr($table_name, 6)) : $table_name ),
|
||||
$table_data
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
22
phpBB/install/module/install_filesystem/module.php
Normal file
22
phpBB/install/module/install_filesystem/module.php
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\install\module\install_filesystem;
|
||||
|
||||
/**
|
||||
* Installer module for filesystem installation
|
||||
*/
|
||||
class module extends \phpbb\install\module_base
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,219 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\install\module\install_filesystem\task;
|
||||
|
||||
use phpbb\install\exception\user_interaction_required_exception;
|
||||
|
||||
/**
|
||||
* Dumps config file
|
||||
*/
|
||||
class create_config_file extends \phpbb\install\task_base
|
||||
{
|
||||
/**
|
||||
* @var \phpbb\filesystem\filesystem_interface
|
||||
*/
|
||||
protected $filesystem;
|
||||
|
||||
/**
|
||||
* @var \phpbb\install\helper\database
|
||||
*/
|
||||
protected $db_helper;
|
||||
|
||||
/**
|
||||
* @var \phpbb\install\helper\config
|
||||
*/
|
||||
protected $install_config;
|
||||
|
||||
/**
|
||||
* @var \phpbb\install\helper\iohandler\iohandler_interface
|
||||
*/
|
||||
protected $iohandler;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $phpbb_root_path;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $php_ext;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \phpbb\filesystem\filesystem_interface $filesystem
|
||||
* @param \phpbb\install\helper\config $install_config
|
||||
* @param \phpbb\install\helper\database $db_helper
|
||||
* @param \phpbb\install\helper\iohandler\iohandler_interface $iohandler
|
||||
* @param string $phpbb_root_path
|
||||
* @param string $php_ext
|
||||
*/
|
||||
public function __construct(\phpbb\filesystem\filesystem_interface $filesystem,
|
||||
\phpbb\install\helper\config $install_config,
|
||||
\phpbb\install\helper\database $db_helper,
|
||||
\phpbb\install\helper\iohandler\iohandler_interface $iohandler,
|
||||
$phpbb_root_path,
|
||||
$php_ext)
|
||||
{
|
||||
$this->install_config = $install_config;
|
||||
$this->db_helper = $db_helper;
|
||||
$this->filesystem = $filesystem;
|
||||
$this->iohandler = $iohandler;
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
$this->php_ext = $php_ext;
|
||||
|
||||
parent::__construct(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$config_written = true;
|
||||
|
||||
// Create config.php
|
||||
$path_to_config = $this->phpbb_root_path . 'config.' . $this->php_ext;
|
||||
|
||||
$fp = @fopen($path_to_config, 'w');
|
||||
if (!$fp)
|
||||
{
|
||||
$config_written = false;
|
||||
}
|
||||
|
||||
$config_content = $this->get_config_data();
|
||||
|
||||
if (!@fwrite($fp, $config_content))
|
||||
{
|
||||
$config_written = false;
|
||||
}
|
||||
|
||||
@fclose($fp);
|
||||
|
||||
// chmod config.php to be only readable
|
||||
if ($config_written)
|
||||
{
|
||||
try
|
||||
{
|
||||
$this->filesystem->phpbb_chmod($path_to_config, \phpbb\filesystem\filesystem_interface::CHMOD_READ);
|
||||
}
|
||||
catch (\phpbb\filesystem\exception\filesystem_exception $e)
|
||||
{
|
||||
// Do nothing, the user will get a notice later
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->iohandler->add_error_message('UNABLE_TO_WRITE_CONFIG_FILE');
|
||||
$this->iohandler->send_response();
|
||||
throw new user_interaction_required_exception();
|
||||
}
|
||||
|
||||
// Create a lock file to indicate that there is an install in progress
|
||||
$fp = @fopen($this->phpbb_root_path . 'cache/install_lock', 'wb');
|
||||
if ($fp === false)
|
||||
{
|
||||
// We were unable to create the lock file - abort
|
||||
$this->iohandler->add_error_message('UNABLE_TO_WRITE_LOCK');
|
||||
$this->iohandler->send_response();
|
||||
throw new user_interaction_required_exception();
|
||||
}
|
||||
@fclose($fp);
|
||||
|
||||
try
|
||||
{
|
||||
$this->filesystem->phpbb_chmod($this->phpbb_root_path . 'cache/install_lock', 0777);
|
||||
}
|
||||
catch (\phpbb\filesystem\exception\filesystem_exception $e)
|
||||
{
|
||||
// Do nothing, the user will get a notice later
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the content which should be dumped to config.php
|
||||
*
|
||||
* @param bool $debug If the debug constants should be enabled by default or not
|
||||
* @param bool $debug_container If the container should be compiled on
|
||||
* every page load or not
|
||||
* @param bool $debug_test If the DEBUG_TEST constant should be added
|
||||
* NOTE: Only for use within the testing framework
|
||||
*
|
||||
* @return string content to be written to the config file
|
||||
*/
|
||||
protected function get_config_data($debug = false, $debug_container = false, $debug_test = false)
|
||||
{
|
||||
$config_content = "<?php\n";
|
||||
$config_content .= "// phpBB 3.2.x auto-generated configuration file\n// Do not change anything in this file!\n";
|
||||
|
||||
$dbms = $this->install_config->get('dbms');
|
||||
$db_driver = $this->db_helper->get_available_dbms($dbms);
|
||||
$db_driver = $db_driver[$dbms]['DRIVER'];
|
||||
|
||||
$config_data_array = array(
|
||||
'dbms' => $db_driver,
|
||||
'dbhost' => $this->install_config->get('dbhost'),
|
||||
'dbport' => $this->install_config->get('dbport'),
|
||||
'dbname' => $this->install_config->get('dbname'),
|
||||
'dbuser' => $this->install_config->get('dbuser'),
|
||||
'dbpasswd' => $this->install_config->get('dbpasswd'),
|
||||
'table_prefix' => $this->install_config->get('table_prefix'),
|
||||
|
||||
'phpbb_adm_relative_path' => 'adm/',
|
||||
|
||||
'acm_type' => 'phpbb\cache\driver\file',
|
||||
);
|
||||
|
||||
foreach ($config_data_array as $key => $value)
|
||||
{
|
||||
$config_content .= "\${$key} = '" . str_replace("'", "\\'", str_replace('\\', '\\\\', $value)) . "';\n";
|
||||
}
|
||||
|
||||
$config_content .= "\n@define('PHPBB_INSTALLED', true);\n";
|
||||
$config_content .= "// @define('PHPBB_DISPLAY_LOAD_TIME', true);\n";
|
||||
|
||||
if ($debug_test)
|
||||
{
|
||||
$config_content .= "@define('PHPBB_ENVIRONMENT', 'test');\n";
|
||||
}
|
||||
else if ($debug)
|
||||
{
|
||||
$config_content .= "@define('PHPBB_ENVIRONMENT', 'development');\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$config_content .= "@define('PHPBB_ENVIRONMENT', 'production');\n";
|
||||
}
|
||||
|
||||
if ($debug_container)
|
||||
{
|
||||
$config_content .= "@define('DEBUG_CONTAINER', true);\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$config_content .= "// @define('DEBUG_CONTAINER', true);\n";
|
||||
}
|
||||
|
||||
if ($debug_test)
|
||||
{
|
||||
$config_content .= "@define('DEBUG_TEST', true);\n";
|
||||
|
||||
// Mandatory for the functional tests, will be removed by PHPBB3-12623
|
||||
$config_content .= "@define('DEBUG', true);\n";
|
||||
}
|
||||
|
||||
return $config_content;
|
||||
}
|
||||
}
|
22
phpBB/install/module/install_finish/module.php
Normal file
22
phpBB/install/module/install_finish/module.php
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\install\module\install_finish;
|
||||
|
||||
/**
|
||||
* Installer module for filesystem installation
|
||||
*/
|
||||
class module extends \phpbb\install\module_base
|
||||
{
|
||||
|
||||
}
|
113
phpBB/install/module/install_finish/task/notify_user.php
Normal file
113
phpBB/install/module/install_finish/task/notify_user.php
Normal file
|
@ -0,0 +1,113 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\install\module\install_finish\task;
|
||||
|
||||
/**
|
||||
* Logs installation and sends an email to the admin
|
||||
*/
|
||||
class notify_user extends \phpbb\install\task_base
|
||||
{
|
||||
/**
|
||||
* @var \phpbb\install\helper\config
|
||||
*/
|
||||
protected $install_config;
|
||||
|
||||
/**
|
||||
* @var \phpbb\install\helper\iohandler\iohandler_interface
|
||||
*/
|
||||
protected $iohandler;
|
||||
|
||||
/**
|
||||
* @var \phpbb\auth\auth
|
||||
*/
|
||||
protected $auth;
|
||||
|
||||
/**
|
||||
* @var \phpbb\config\db
|
||||
*/
|
||||
protected $config;
|
||||
|
||||
/**
|
||||
* @var \phpbb\log\log_interface
|
||||
*/
|
||||
protected $log;
|
||||
|
||||
/**
|
||||
* @var \phpbb\user
|
||||
*/
|
||||
protected $user;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $phpbb_root_path;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $php_ext;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \phpbb\install\helper\container_factory $container
|
||||
* @param \phpbb\install\helper\config $install_config
|
||||
* @param \phpbb\install\helper\iohandler\iohandler_interface $iohandler
|
||||
* @param string $phpbb_root_path
|
||||
* @param string $php_ext
|
||||
*/
|
||||
public function __construct(\phpbb\install\helper\container_factory $container, \phpbb\install\helper\config $install_config, \phpbb\install\helper\iohandler\iohandler_interface $iohandler, $phpbb_root_path, $php_ext)
|
||||
{
|
||||
$this->install_config = $install_config;
|
||||
$this->iohandler = $iohandler;
|
||||
|
||||
$this->auth = $container->get('auth');
|
||||
$this->config = $container->get('config');
|
||||
$this->log = $container->get('log');
|
||||
$this->user = $container->get('user');
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
$this->php_ext = $php_ext;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
// @todo
|
||||
//$this->user->setup('common');
|
||||
|
||||
//$this->user->session_begin();
|
||||
//$this->auth->login($this->install_config->get('admin_name'), $this->install_config->get('admin_pass1'), false, true, true);
|
||||
|
||||
if ($this->config['email_enable'])
|
||||
{
|
||||
include ($this->phpbb_root_path . 'includes/functions_messenger.' . $this->php_ext);
|
||||
|
||||
$messenger = new \messenger(false);
|
||||
$messenger->template('installed', $this->install_config->get('language'));
|
||||
$messenger->to($this->config['board_email'], $this->install_config->get('admin_name'));
|
||||
$messenger->anti_abuse_headers($this->config, $this->user);
|
||||
$messenger->assign_vars(array(
|
||||
'USERNAME' => htmlspecialchars_decode($this->install_config->get('admin_name')),
|
||||
'PASSWORD' => htmlspecialchars_decode($this->install_config->get('admin_pass1')))
|
||||
);
|
||||
$messenger->send(NOTIFY_EMAIL);
|
||||
}
|
||||
|
||||
$this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_INSTALL_INSTALLED', false, array($this->config['version']));
|
||||
|
||||
@unlink($this->phpbb_root_path . 'cache/install_lock');
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\install\module\install_finish\task;
|
||||
|
||||
/**
|
||||
* Populates migrations
|
||||
*/
|
||||
class populate_migrations extends \phpbb\install\task_base
|
||||
{
|
||||
/**
|
||||
* @var \phpbb\extension\manager
|
||||
*/
|
||||
protected $extension_manager;
|
||||
|
||||
/**
|
||||
* @var \phpbb\db\migrator
|
||||
*/
|
||||
protected $migrator;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \phpbb\install\helper\container_factory $container phpBB's DI contianer
|
||||
*/
|
||||
public function __construct(\phpbb\install\helper\container_factory $container)
|
||||
{
|
||||
$this->extension_manager = $container->get('ext.manager');
|
||||
$this->migrator = $container->get('migrator');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$finder = $this->extension_manager->get_finder();
|
||||
|
||||
$migrations = $finder
|
||||
->core_path('phpbb/db/migration/data/')
|
||||
->get_classes();
|
||||
$this->migrator->populate_migrations($migrations);
|
||||
}
|
||||
}
|
63
phpBB/install/module/obtain_data/module.php
Normal file
63
phpBB/install/module/obtain_data/module.php
Normal file
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\install\module\obtain_data;
|
||||
|
||||
class module extends \phpbb\install\module_base
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
// Recover install progress
|
||||
$task_index = $this->recover_progress();
|
||||
|
||||
// Run until there are available resources
|
||||
while ($this->install_config->get_time_remaining() > 0 && $this->install_config->get_memory_remaining() > 0)
|
||||
{
|
||||
// Check if task exists
|
||||
if (!isset($this->task_collection[$task_index]))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
// Recover task to be executed
|
||||
/** @var \phpbb\install\task_interface $task */
|
||||
$task = $this->container->get($this->task_collection[$task_index]);
|
||||
|
||||
// Iterate to the next task
|
||||
$task_index++;
|
||||
|
||||
// Check if we can run the task
|
||||
if (!$task->is_essential() && !$task->check_requirements())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$task->run();
|
||||
|
||||
// Log install progress
|
||||
$current_task_index = $task_index - 1;
|
||||
$this->install_config->set_finished_task($this->task_collection[$current_task_index], $current_task_index);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_task_count()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
207
phpBB/install/module/obtain_data/task/obtain_admin_data.php
Normal file
207
phpBB/install/module/obtain_data/task/obtain_admin_data.php
Normal file
|
@ -0,0 +1,207 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\install\module\obtain_data\task;
|
||||
|
||||
use phpbb\install\exception\user_interaction_required_exception;
|
||||
|
||||
/**
|
||||
* This class requests and validates admin account data from the user
|
||||
*/
|
||||
class obtain_admin_data extends \phpbb\install\task_base implements \phpbb\install\task_interface
|
||||
{
|
||||
/**
|
||||
* @var \phpbb\install\helper\config
|
||||
*/
|
||||
protected $install_config;
|
||||
|
||||
/**
|
||||
* @var \phpbb\install\helper\iohandler\iohandler_interface
|
||||
*/
|
||||
protected $io_handler;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \phpbb\install\helper\config $install_config Installer's config helper
|
||||
* @param \phpbb\install\helper\iohandler\iohandler_interface $iohandler Installer's input-output handler
|
||||
*/
|
||||
public function __construct(\phpbb\install\helper\config $install_config,
|
||||
\phpbb\install\helper\iohandler\iohandler_interface $iohandler)
|
||||
{
|
||||
$this->install_config = $install_config;
|
||||
$this->io_handler = $iohandler;
|
||||
|
||||
parent::__construct(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
// Check if data is sent
|
||||
if ($this->io_handler->get_input('submit_admin', false))
|
||||
{
|
||||
$this->process_form();
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->request_form_data();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process form data
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
protected function process_form()
|
||||
{
|
||||
// Admin data
|
||||
$admin_name = $this->io_handler->get_input('admin_name', '', true);
|
||||
$admin_pass1 = $this->io_handler->get_input('admin_pass1', '', true);
|
||||
$admin_pass2 = $this->io_handler->get_input('admin_pass2', '', true);
|
||||
$board_email = $this->io_handler->get_input('board_email', '');
|
||||
|
||||
$admin_data_valid = $this->check_admin_data($admin_name, $admin_pass1, $admin_pass2, $board_email);
|
||||
|
||||
if ($admin_data_valid)
|
||||
{
|
||||
$this->install_config->set('admin_name', $admin_name);
|
||||
$this->install_config->set('admin_passwd', $admin_pass1);
|
||||
$this->install_config->set('board_email', $board_email);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->request_form_data(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Request data from the user
|
||||
*
|
||||
* @param bool $use_request_data Whether to use submited data
|
||||
*
|
||||
* @return null
|
||||
*
|
||||
* @throws \phpbb\install\exception\user_interaction_required_exception When the user is required to provide data
|
||||
*/
|
||||
protected function request_form_data($use_request_data = false)
|
||||
{
|
||||
if ($use_request_data)
|
||||
{
|
||||
$admin_username = $this->io_handler->get_input('admin_name', '', true);
|
||||
$admin_email = $this->io_handler->get_input('board_email', '', true);
|
||||
}
|
||||
else
|
||||
{
|
||||
$admin_username = '';
|
||||
$admin_email = '';
|
||||
}
|
||||
|
||||
$admin_form = array(
|
||||
'admin_name' => array(
|
||||
'label' => 'ADMIN_USERNAME',
|
||||
'description' => 'ADMIN_USERNAME_EXPLAIN',
|
||||
'type' => 'text',
|
||||
'default' => $admin_username,
|
||||
),
|
||||
'board_email' => array(
|
||||
'label' => 'CONTACT_EMAIL',
|
||||
'type' => 'email',
|
||||
'default' => $admin_email,
|
||||
),
|
||||
'admin_pass1' => array(
|
||||
'label' => 'ADMIN_PASSWORD',
|
||||
'description' => 'ADMIN_PASSWORD_EXPLAIN',
|
||||
'type' => 'password',
|
||||
),
|
||||
'admin_pass2' => array(
|
||||
'label' => 'ADMIN_PASSWORD_CONFIRM',
|
||||
'type' => 'password',
|
||||
),
|
||||
'submit_admin' => array(
|
||||
'label' => 'SUBMIT',
|
||||
'type' => 'submit',
|
||||
),
|
||||
);
|
||||
|
||||
$this->io_handler->add_user_form_group('ADMIN_CONFIG', $admin_form);
|
||||
|
||||
// Require user interaction
|
||||
$this->io_handler->send_response();
|
||||
throw new user_interaction_required_exception();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check admin data
|
||||
*
|
||||
* @param string $username Admin username
|
||||
* @param string $pass1 Admin password
|
||||
* @param string $pass2 Admin password confirmation
|
||||
* @param string $email Admin e-mail address
|
||||
*
|
||||
* @return bool True if data is valid, false otherwise
|
||||
*/
|
||||
protected function check_admin_data($username, $pass1, $pass2, $email)
|
||||
{
|
||||
$data_valid = true;
|
||||
|
||||
// Check if none of admin data is empty
|
||||
if (in_array('', array($username, $pass1, $pass2, $email)))
|
||||
{
|
||||
$this->io_handler->add_error_message('INST_ERR_MISSING_DATA');
|
||||
$data_valid = false;
|
||||
}
|
||||
|
||||
if (utf8_strlen($username) < 3)
|
||||
{
|
||||
$this->io_handler->add_error_message('INST_ERR_USER_TOO_SHORT');
|
||||
$data_valid = false;
|
||||
}
|
||||
|
||||
if (utf8_strlen($username) > 20)
|
||||
{
|
||||
$this->io_handler->add_error_message('INST_ERR_USER_TOO_LONG');
|
||||
$data_valid = false;
|
||||
}
|
||||
|
||||
if ($pass1 !== $pass2 && $pass1 !== '')
|
||||
{
|
||||
$this->io_handler->add_error_message('INST_ERR_PASSWORD_MISMATCH');
|
||||
$data_valid = false;
|
||||
}
|
||||
|
||||
// Test against the default password rules
|
||||
if (utf8_strlen($pass1) < 6)
|
||||
{
|
||||
$this->io_handler->add_error_message('INST_ERR_PASSWORD_TOO_SHORT');
|
||||
$data_valid = false;
|
||||
}
|
||||
|
||||
if (utf8_strlen($pass1) > 30)
|
||||
{
|
||||
$this->io_handler->add_error_message('INST_ERR_PASSWORD_TOO_LONG');
|
||||
$data_valid = false;
|
||||
}
|
||||
|
||||
if (!preg_match('/^' . get_preg_expression('email') . '$/i', $email))
|
||||
{
|
||||
$this->io_handler->add_error_message('INST_ERR_EMAIL_INVALID');
|
||||
$data_valid = false;
|
||||
}
|
||||
|
||||
return $data_valid;
|
||||
}
|
||||
}
|
172
phpBB/install/module/obtain_data/task/obtain_board_data.php
Normal file
172
phpBB/install/module/obtain_data/task/obtain_board_data.php
Normal file
|
@ -0,0 +1,172 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\install\module\obtain_data\task;
|
||||
|
||||
use phpbb\install\exception\user_interaction_required_exception;
|
||||
|
||||
/**
|
||||
* This class obtains default data from the user related to board (Board name, Board descritpion, etc...)
|
||||
*/
|
||||
class obtain_board_data extends \phpbb\install\task_base implements \phpbb\install\task_interface
|
||||
{
|
||||
/**
|
||||
* @var \phpbb\install\helper\config
|
||||
*/
|
||||
protected $install_config;
|
||||
|
||||
/**
|
||||
* @var \phpbb\install\helper\iohandler\iohandler_interface
|
||||
*/
|
||||
protected $io_handler;
|
||||
|
||||
/**
|
||||
* @var \phpbb\language\language_file_helper
|
||||
*/
|
||||
protected $language_helper;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \phpbb\install\helper\config $config Installer's config
|
||||
* @param \phpbb\install\helper\iohandler\iohandler_interface $iohandler Installer's input-output handler
|
||||
* @param \phpbb\language\language_file_helper $lang_helper Language file helper
|
||||
*/
|
||||
public function __construct(\phpbb\install\helper\config $config,
|
||||
\phpbb\install\helper\iohandler\iohandler_interface $iohandler,
|
||||
\phpbb\language\language_file_helper $lang_helper)
|
||||
{
|
||||
$this->install_config = $config;
|
||||
$this->io_handler = $iohandler;
|
||||
$this->language_helper = $lang_helper;
|
||||
|
||||
parent::__construct(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
// Check if data is sent
|
||||
if ($this->io_handler->get_input('submit_board', false))
|
||||
{
|
||||
$this->process_form();
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->request_form_data();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process form data
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
protected function process_form()
|
||||
{
|
||||
// Board data
|
||||
$default_lang = $this->io_handler->get_input('default_lang', '');
|
||||
$board_name = $this->io_handler->get_input('board_name', '');
|
||||
$board_desc = $this->io_handler->get_input('board_description', '');
|
||||
|
||||
// Check default lang
|
||||
$langs = $this->language_helper->get_available_languages();
|
||||
$lang_valid = false;
|
||||
|
||||
foreach ($langs as $lang)
|
||||
{
|
||||
if ($lang['iso'] === $default_lang)
|
||||
{
|
||||
$lang_valid = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$this->install_config->set('board_name', $board_name);
|
||||
$this->install_config->set('board_description', $board_desc);
|
||||
|
||||
if ($lang_valid)
|
||||
{
|
||||
$this->install_config->set('default_lang', $default_lang);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->request_form_data(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Request data from the user
|
||||
*
|
||||
* @param bool $use_request_data Whether to use submited data
|
||||
*
|
||||
* @throws \phpbb\install\exception\user_interaction_required_exception When the user is required to provide data
|
||||
*/
|
||||
protected function request_form_data($use_request_data = false)
|
||||
{
|
||||
if ($use_request_data)
|
||||
{
|
||||
$board_name = $this->io_handler->get_input('board_name', '');
|
||||
$board_desc = $this->io_handler->get_input('board_description', '');
|
||||
}
|
||||
else
|
||||
{
|
||||
$board_name = '{L_CONFIG_SITENAME}';
|
||||
$board_desc = '{L_CONFIG_SITE_DESC}';
|
||||
}
|
||||
|
||||
// Use language because we only check this to be valid
|
||||
$default_lang = $this->install_config->get('language', '');
|
||||
|
||||
$langs = $this->language_helper->get_available_languages();
|
||||
$lang_options = array();
|
||||
|
||||
foreach ($langs as $lang)
|
||||
{
|
||||
$lang_options[] = array(
|
||||
'value' => $lang['iso'],
|
||||
'label' => $lang['local_name'],
|
||||
'selected' => ($default_lang === $lang['iso']),
|
||||
);
|
||||
}
|
||||
|
||||
$board_form = array(
|
||||
'default_lang' => array(
|
||||
'label' => 'DEFAULT_LANGUAGE',
|
||||
'type' => 'select',
|
||||
'options' => $lang_options,
|
||||
),
|
||||
'board_name' => array(
|
||||
'label' => 'BOARD_NAME',
|
||||
'type' => 'text',
|
||||
'default' => $board_name,
|
||||
),
|
||||
'board_description' => array(
|
||||
'label' => 'BOARD_DESCRIPTION',
|
||||
'type' => 'text',
|
||||
'default' => $board_desc,
|
||||
),
|
||||
'submit_board' => array(
|
||||
'label' => 'SUBMIT',
|
||||
'type' => 'submit',
|
||||
),
|
||||
);
|
||||
|
||||
$this->io_handler->add_user_form_group('BOARD_CONFIG', $board_form);
|
||||
|
||||
$this->io_handler->send_response();
|
||||
throw new user_interaction_required_exception;
|
||||
}
|
||||
}
|
259
phpBB/install/module/obtain_data/task/obtain_database_data.php
Normal file
259
phpBB/install/module/obtain_data/task/obtain_database_data.php
Normal file
|
@ -0,0 +1,259 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\install\module\obtain_data\task;
|
||||
|
||||
use phpbb\install\exception\user_interaction_required_exception;
|
||||
|
||||
/**
|
||||
* This class requests and validates database information from the user
|
||||
*/
|
||||
class obtain_database_data extends \phpbb\install\task_base implements \phpbb\install\task_interface
|
||||
{
|
||||
/**
|
||||
* @var \phpbb\install\helper\database
|
||||
*/
|
||||
protected $database_helper;
|
||||
|
||||
/**
|
||||
* @var \phpbb\install\helper\config
|
||||
*/
|
||||
protected $install_config;
|
||||
|
||||
/**
|
||||
* @var \phpbb\install\helper\iohandler\iohandler_interface
|
||||
*/
|
||||
protected $io_handler;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \phpbb\install\helper\database $database_helper Installer's database helper
|
||||
* @param \phpbb\install\helper\config $install_config Installer's config helper
|
||||
* @param \phpbb\install\helper\iohandler\iohandler_interface $iohandler Installer's input-output handler
|
||||
*/
|
||||
public function __construct(\phpbb\install\helper\database $database_helper,
|
||||
\phpbb\install\helper\config $install_config,
|
||||
\phpbb\install\helper\iohandler\iohandler_interface $iohandler)
|
||||
{
|
||||
$this->database_helper = $database_helper;
|
||||
$this->install_config = $install_config;
|
||||
$this->io_handler = $iohandler;
|
||||
|
||||
parent::__construct(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
// Check if data is sent
|
||||
if ($this->io_handler->get_input('submit_database', false))
|
||||
{
|
||||
$this->process_form();
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->request_form_data();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process form data
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
protected function process_form()
|
||||
{
|
||||
// Collect database data
|
||||
$dbms = $this->io_handler->get_input('dbms', '');
|
||||
$dbhost = $this->io_handler->get_input('dbhost', '');
|
||||
$dbport = $this->io_handler->get_input('dbport', '');
|
||||
$dbuser = $this->io_handler->get_input('dbuser', '');
|
||||
$dbpasswd = $this->io_handler->get_input('dbpasswd', '', true);
|
||||
$dbname = $this->io_handler->get_input('dbname', '');
|
||||
$table_prefix = $this->io_handler->get_input('table_prefix', '');
|
||||
|
||||
// Check database data
|
||||
$user_data_vaild = $this->check_database_data($dbms, $dbhost, $dbport, $dbuser, $dbpasswd, $dbname, $table_prefix);
|
||||
|
||||
// Save database data if it is correct
|
||||
if ($user_data_vaild)
|
||||
{
|
||||
$this->install_config->set('dbms', $dbms);
|
||||
$this->install_config->set('dbhost', $dbhost);
|
||||
$this->install_config->set('dbport', $dbport);
|
||||
$this->install_config->set('dbuser', $dbuser);
|
||||
$this->install_config->set('dbpasswd', $dbpasswd);
|
||||
$this->install_config->set('dbname', $dbname);
|
||||
$this->install_config->set('table_prefix', $table_prefix);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->request_form_data(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Request data from the user
|
||||
*
|
||||
* @param bool $use_request_data Whether to use submited data
|
||||
*
|
||||
* @return null
|
||||
*
|
||||
* @throws \phpbb\install\exception\user_interaction_required_exception When the user is required to provide data
|
||||
*/
|
||||
protected function request_form_data($use_request_data = false)
|
||||
{
|
||||
if ($use_request_data)
|
||||
{
|
||||
$dbms = $this->io_handler->get_input('dbms', '');
|
||||
$dbhost = $this->io_handler->get_input('dbhost', '');
|
||||
$dbport = $this->io_handler->get_input('dbport', '');
|
||||
$dbuser = $this->io_handler->get_input('dbuser', '');
|
||||
$dbname = $this->io_handler->get_input('dbname', '');
|
||||
$table_prefix = $this->io_handler->get_input('table_prefix', 'phpbb_');
|
||||
}
|
||||
else
|
||||
{
|
||||
$dbms = '';
|
||||
$dbhost = '';
|
||||
$dbport = '';
|
||||
$dbuser = '';
|
||||
$dbname = '';
|
||||
$table_prefix = 'phpbb_';
|
||||
}
|
||||
|
||||
$dbms_select = array();
|
||||
foreach ($this->database_helper->get_available_dbms() as $dbms_key => $dbms_array)
|
||||
{
|
||||
$dbms_select[] = array(
|
||||
'value' => $dbms_key,
|
||||
'label' => 'DB_OPTION_' . strtoupper($dbms_key),
|
||||
'selected' => ($dbms_key === $dbms),
|
||||
);
|
||||
}
|
||||
|
||||
$database_form = array(
|
||||
'dbms' => array(
|
||||
'label' => 'DBMS',
|
||||
'type' => 'select',
|
||||
'options' => $dbms_select,
|
||||
),
|
||||
'dbhost' => array(
|
||||
'label' => 'DB_HOST',
|
||||
'description' => 'DB_HOST_EXPLAIN',
|
||||
'type' => 'text',
|
||||
'default' => $dbhost,
|
||||
),
|
||||
'dbport' => array(
|
||||
'label' => 'DB_PORT',
|
||||
'description' => 'DB_PORT_EXPLAIN',
|
||||
'type' => 'text',
|
||||
'default' => $dbport,
|
||||
),
|
||||
'dbuser' => array(
|
||||
'label' => 'DB_USERNAME',
|
||||
'type' => 'text',
|
||||
'default' => $dbuser,
|
||||
),
|
||||
'dbpasswd' => array(
|
||||
'label' => 'DB_PASSWORD',
|
||||
'type' => 'password',
|
||||
),
|
||||
'dbname' => array(
|
||||
'label' => 'DB_NAME',
|
||||
'type' => 'text',
|
||||
'default' => $dbname,
|
||||
),
|
||||
'table_prefix' => array(
|
||||
'label' => 'TABLE_PREFIX',
|
||||
'description' => 'TABLE_PREFIX_EXPLAIN',
|
||||
'type' => 'text',
|
||||
'default' => $table_prefix,
|
||||
),
|
||||
'submit_database' => array(
|
||||
'label' => 'SUBMIT',
|
||||
'type' => 'submit',
|
||||
),
|
||||
);
|
||||
|
||||
$this->io_handler->add_user_form_group('DB_CONFIG', $database_form);
|
||||
|
||||
// Require user interaction
|
||||
$this->io_handler->send_response();
|
||||
throw new user_interaction_required_exception();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check database data
|
||||
*
|
||||
* @param string $dbms Selected database type
|
||||
* @param string $dbhost Database host address
|
||||
* @param int $dbport Database port number
|
||||
* @param string $dbuser Database username
|
||||
* @param string $dbpass Database password
|
||||
* @param string $dbname Database name
|
||||
* @param string $table_prefix Database table prefix
|
||||
*
|
||||
* @return bool True if database data is correct, false otherwise
|
||||
*/
|
||||
protected function check_database_data($dbms, $dbhost, $dbport, $dbuser, $dbpass, $dbname, $table_prefix)
|
||||
{
|
||||
$available_dbms = $this->database_helper->get_available_dbms();
|
||||
$data_valid = true;
|
||||
|
||||
// Check if PHP has the database extensions for the specified DBMS
|
||||
if (!isset($available_dbms[$dbms]))
|
||||
{
|
||||
$this->io_handler->add_error_message('INST_ERR_NO_DB');
|
||||
$data_valid = false;
|
||||
}
|
||||
|
||||
// Validate table prefix
|
||||
$prefix_valid = $this->database_helper->validate_table_prefix($dbms, $table_prefix);
|
||||
if (is_array($prefix_valid))
|
||||
{
|
||||
foreach ($prefix_valid as $error)
|
||||
{
|
||||
$this->io_handler->add_error_message(
|
||||
$error['title'],
|
||||
(isset($error['description'])) ? $error['description'] : false
|
||||
);
|
||||
}
|
||||
|
||||
$data_valid = false;
|
||||
}
|
||||
|
||||
// Try to connect to database if all provided data is valid
|
||||
if ($data_valid)
|
||||
{
|
||||
$connect_test = $this->database_helper->check_database_connection($dbms, $dbhost, $dbport, $dbuser, $dbpass, $dbname, $table_prefix);
|
||||
if (is_array($connect_test))
|
||||
{
|
||||
foreach ($prefix_valid as $error)
|
||||
{
|
||||
$this->io_handler->add_error_message(
|
||||
$error['title'],
|
||||
(isset($error['description'])) ? $error['description'] : false
|
||||
);
|
||||
}
|
||||
|
||||
$data_valid = false;
|
||||
}
|
||||
}
|
||||
|
||||
return $data_valid;
|
||||
}
|
||||
}
|
151
phpBB/install/module/obtain_data/task/obtain_email_data.php
Normal file
151
phpBB/install/module/obtain_data/task/obtain_email_data.php
Normal file
|
@ -0,0 +1,151 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\install\module\obtain_data\task;
|
||||
|
||||
use phpbb\install\exception\user_interaction_required_exception;
|
||||
|
||||
class obtain_email_data extends \phpbb\install\task_base implements \phpbb\install\task_interface
|
||||
{
|
||||
/**
|
||||
* @var \phpbb\install\helper\config
|
||||
*/
|
||||
protected $install_config;
|
||||
|
||||
/**
|
||||
* @var \phpbb\install\helper\iohandler\iohandler_interface
|
||||
*/
|
||||
protected $io_handler;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \phpbb\install\helper\config $config Installer's config
|
||||
* @param \phpbb\install\helper\iohandler\iohandler_interface $iohandler Installer's input-output handler
|
||||
*/
|
||||
public function __construct(\phpbb\install\helper\config $config,
|
||||
\phpbb\install\helper\iohandler\iohandler_interface $iohandler)
|
||||
{
|
||||
$this->install_config = $config;
|
||||
$this->io_handler = $iohandler;
|
||||
|
||||
parent::__construct(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
// E-mail data
|
||||
$email_enable = $this->io_handler->get_input('email_enable', true);
|
||||
$smtp_delivery = $this->io_handler->get_input('smtp_delivery', '');
|
||||
$smtp_host = $this->io_handler->get_input('smtp_host', '');
|
||||
$smtp_auth = $this->io_handler->get_input('smtp_auth', '');
|
||||
$smtp_user = $this->io_handler->get_input('smtp_user', '');
|
||||
$smtp_passwd = $this->io_handler->get_input('smtp_pass', '');
|
||||
|
||||
$auth_methods = array('PLAIN', 'LOGIN', 'CRAM-MD5', 'DIGEST-MD5', 'POP-BEFORE-SMTP');
|
||||
|
||||
// Check if data is sent
|
||||
if ($this->io_handler->get_input('submit_email', false))
|
||||
{
|
||||
$this->install_config->set('email_enable', $email_enable);
|
||||
$this->install_config->set('smtp_delivery', $smtp_delivery);
|
||||
$this->install_config->set('smtp_host', $smtp_host);
|
||||
$this->install_config->set('smtp_auth', $smtp_auth);
|
||||
$this->install_config->set('smtp_user', $smtp_user);
|
||||
$this->install_config->set('smtp_pass', $smtp_passwd);
|
||||
}
|
||||
else
|
||||
{
|
||||
$auth_options = array();
|
||||
foreach ($auth_methods as $method)
|
||||
{
|
||||
$auth_options[] = array(
|
||||
'value' => $method,
|
||||
'label' => 'SMTP_' . str_replace('-', '_', $method),
|
||||
'selected' => false,
|
||||
);
|
||||
}
|
||||
|
||||
$email_form = array(
|
||||
'email_enable' => array(
|
||||
'label' => 'ENABLE_EMAIL',
|
||||
'description' => 'COOKIE_SECURE_EXPLAIN',
|
||||
'type' => 'radio',
|
||||
'options' => array(
|
||||
array(
|
||||
'value' => 1,
|
||||
'label' => 'ENABLE',
|
||||
'selected' => true,
|
||||
),
|
||||
array(
|
||||
'value' => 0,
|
||||
'label' => 'DISABLE',
|
||||
'selected' => false,
|
||||
),
|
||||
),
|
||||
),
|
||||
'smtp_delivery' => array(
|
||||
'label' => 'USE_SMTP',
|
||||
'description' => 'USE_SMTP_EXPLAIN',
|
||||
'type' => 'radio',
|
||||
'options' => array(
|
||||
array(
|
||||
'value' => 0,
|
||||
'label' => 'NO',
|
||||
'selected' => true,
|
||||
),
|
||||
array(
|
||||
'value' => 1,
|
||||
'label' => 'YES',
|
||||
'selected' => false,
|
||||
),
|
||||
),
|
||||
),
|
||||
'smtp_host' => array(
|
||||
'label' => 'SMTP_SERVER',
|
||||
'description' => 'SMTP_SERVER_EXPLAIN',
|
||||
'type' => 'text',
|
||||
'default' => $smtp_host,
|
||||
),
|
||||
'smtp_auth' => array(
|
||||
'label' => 'SMTP_AUTH_METHOD',
|
||||
'type' => 'select',
|
||||
'options' => $auth_options,
|
||||
),
|
||||
'smtp_user' => array(
|
||||
'label' => 'SMTP_USERNAME',
|
||||
'description' => 'SMTP_USERNAME_EXPLAIN',
|
||||
'type' => 'text',
|
||||
'default' => $smtp_user,
|
||||
),
|
||||
'smtp_pass' => array(
|
||||
'label' => 'SMTP_PASSWORD',
|
||||
'description' => 'SMTP_PASSWORD_EXPLAIN',
|
||||
'type' => 'password',
|
||||
),
|
||||
'submit_email' => array(
|
||||
'label' => 'SUBMIT',
|
||||
'type' => 'submit',
|
||||
),
|
||||
);
|
||||
|
||||
$this->io_handler->add_user_form_group('EMAIL_CONFIG', $email_form);
|
||||
|
||||
$this->io_handler->send_response();
|
||||
throw new user_interaction_required_exception();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\install\module\obtain_data\task;
|
||||
|
||||
class obtain_imagick_path extends \phpbb\install\task_base implements \phpbb\install\task_interface
|
||||
{
|
||||
/**
|
||||
* @var \phpbb\install\helper\config
|
||||
*/
|
||||
protected $config;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \phpbb\install\helper\config $config Installer's config
|
||||
*/
|
||||
public function __construct(\phpbb\install\helper\config $config)
|
||||
{
|
||||
$this->config = $config;
|
||||
|
||||
parent::__construct(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
// Can we find Imagemagick anywhere on the system?
|
||||
$exe = (DIRECTORY_SEPARATOR == '\\') ? '.exe' : '';
|
||||
|
||||
$magic_home = getenv('MAGICK_HOME');
|
||||
$img_imagick = '';
|
||||
if (empty($magic_home))
|
||||
{
|
||||
$locations = array('C:/WINDOWS/', 'C:/WINNT/', 'C:/WINDOWS/SYSTEM/', 'C:/WINNT/SYSTEM/', 'C:/WINDOWS/SYSTEM32/', 'C:/WINNT/SYSTEM32/', '/usr/bin/', '/usr/sbin/', '/usr/local/bin/', '/usr/local/sbin/', '/opt/', '/usr/imagemagick/', '/usr/bin/imagemagick/');
|
||||
$path_locations = str_replace('\\', '/', (explode(($exe) ? ';' : ':', getenv('PATH'))));
|
||||
|
||||
$locations = array_merge($path_locations, $locations);
|
||||
foreach ($locations as $location)
|
||||
{
|
||||
// The path might not end properly, fudge it
|
||||
if (substr($location, -1, 1) !== '/')
|
||||
{
|
||||
$location .= '/';
|
||||
}
|
||||
|
||||
if (@file_exists($location) && @is_readable($location . 'mogrify' . $exe) && @filesize($location . 'mogrify' . $exe) > 3000)
|
||||
{
|
||||
$img_imagick = str_replace('\\', '/', $location);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$img_imagick = str_replace('\\', '/', $magic_home);
|
||||
}
|
||||
|
||||
$this->config->set('img_imagick', $img_imagick);
|
||||
}
|
||||
}
|
187
phpBB/install/module/obtain_data/task/obtain_server_data.php
Normal file
187
phpBB/install/module/obtain_data/task/obtain_server_data.php
Normal file
|
@ -0,0 +1,187 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\install\module\obtain_data\task;
|
||||
|
||||
use phpbb\install\exception\user_interaction_required_exception;
|
||||
|
||||
/**
|
||||
* This class requests and saves some information about the server
|
||||
*/
|
||||
class obtain_server_data extends \phpbb\install\task_base implements \phpbb\install\task_interface
|
||||
{
|
||||
/**
|
||||
* @var \phpbb\install\helper\config
|
||||
*/
|
||||
protected $install_config;
|
||||
|
||||
/**
|
||||
* @var \phpbb\install\helper\iohandler\iohandler_interface
|
||||
*/
|
||||
protected $io_handler;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \phpbb\install\helper\config $config Installer's config
|
||||
* @param \phpbb\install\helper\iohandler\iohandler_interface $iohandler Installer's input-output handler
|
||||
*/
|
||||
public function __construct(\phpbb\install\helper\config $config,
|
||||
\phpbb\install\helper\iohandler\iohandler_interface $iohandler)
|
||||
{
|
||||
$this->install_config = $config;
|
||||
$this->io_handler = $iohandler;
|
||||
|
||||
parent::__construct(true);
|
||||
}
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$cookie_secure = $this->io_handler->is_secure();
|
||||
$server_protocol = ($this->io_handler->is_secure()) ? 'https://' : 'http://';
|
||||
$server_port = $this->io_handler->get_server_variable('SERVER_PORT', 0);
|
||||
|
||||
// HTTP_HOST is having the correct browser url in most cases...
|
||||
$server_name = strtolower(htmlspecialchars_decode($this->io_handler->get_header_variable(
|
||||
'Host',
|
||||
$this->io_handler->get_server_variable('SERVER_NAME')
|
||||
)));
|
||||
|
||||
// HTTP HOST can carry a port number...
|
||||
if (strpos($server_name, ':') !== false)
|
||||
{
|
||||
$server_name = substr($server_name, 0, strpos($server_name, ':'));
|
||||
}
|
||||
|
||||
$script_path = htmlspecialchars_decode($this->io_handler->get_server_variable('PHP_SELF'));
|
||||
|
||||
if (!$script_path)
|
||||
{
|
||||
$script_path = htmlspecialchars_decode($this->io_handler->get_server_variable('REQUEST_URI'));
|
||||
}
|
||||
|
||||
$script_path = str_replace(array('\\', '//'), '/', $script_path);
|
||||
$script_path = trim(dirname(dirname($script_path)));
|
||||
|
||||
// Server data
|
||||
$cookie_secure = $this->io_handler->get_input('cookie_secure', $cookie_secure);
|
||||
$server_protocol = $this->io_handler->get_input('server_protocol', $server_protocol);
|
||||
$force_server_vars = $this->io_handler->get_input('force_server_vars', 0);
|
||||
$server_name = $this->io_handler->get_input('server_name', $server_name);
|
||||
$server_port = $this->io_handler->get_input('server_port', $server_port);
|
||||
$script_path = $this->io_handler->get_input('script_path', $script_path);
|
||||
|
||||
// Clean up script path
|
||||
if ($script_path !== '/')
|
||||
{
|
||||
// Adjust destination path (no trailing slash)
|
||||
if (substr($script_path, -1) === '/')
|
||||
{
|
||||
$script_path = substr($script_path, 0, -1);
|
||||
}
|
||||
|
||||
$script_path = str_replace(array('../', './'), '', $script_path);
|
||||
|
||||
if ($script_path[0] !== '/')
|
||||
{
|
||||
$script_path = '/' . $script_path;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if data is sent
|
||||
if ($this->io_handler->get_input('submit_server', false))
|
||||
{
|
||||
$this->install_config->set('cookie_secure', $cookie_secure);
|
||||
$this->install_config->set('server_protocol', $server_protocol);
|
||||
$this->install_config->set('force_server_vars', $force_server_vars);
|
||||
$this->install_config->set('server_name', $server_name);
|
||||
$this->install_config->set('server_port', $server_port);
|
||||
$this->install_config->set('script_path', $script_path);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Render form
|
||||
$server_form = array(
|
||||
'cookie_secure' => array(
|
||||
'label' => 'COOKIE_SECURE',
|
||||
'description' => 'COOKIE_SECURE_EXPLAIN',
|
||||
'type' => 'radio',
|
||||
'options' => array(
|
||||
array(
|
||||
'value' => 0,
|
||||
'label' => 'NO',
|
||||
'selected' => (!$cookie_secure),
|
||||
),
|
||||
array(
|
||||
'value' => 1,
|
||||
'label' => 'YES',
|
||||
'selected' => ($cookie_secure),
|
||||
),
|
||||
),
|
||||
),
|
||||
'force_server_vars' => array(
|
||||
'label' => 'FORCE_SERVER_VARS',
|
||||
'description' => 'FORCE_SERVER_VARS_EXPLAIN',
|
||||
'type' => 'radio',
|
||||
'options' => array(
|
||||
array(
|
||||
'value' => 0,
|
||||
'label' => 'NO',
|
||||
'selected' => true,
|
||||
),
|
||||
array(
|
||||
'value' => 1,
|
||||
'label' => 'YES',
|
||||
'selected' => false,
|
||||
),
|
||||
),
|
||||
),
|
||||
'server_protocol' => array(
|
||||
'label' => 'SERVER_PROTOCOL',
|
||||
'description' => 'SERVER_PROTOCOL_EXPLAIN',
|
||||
'type' => 'text',
|
||||
'default' => $server_protocol,
|
||||
),
|
||||
'server_name' => array(
|
||||
'label' => 'SERVER_NAME',
|
||||
'description' => 'SERVER_NAME_EXPLAIN',
|
||||
'type' => 'text',
|
||||
'default' => $server_name,
|
||||
),
|
||||
'server_port' => array(
|
||||
'label' => 'SERVER_PORT',
|
||||
'description' => 'SERVER_PORT_EXPLAIN',
|
||||
'type' => 'text',
|
||||
'default' => $server_port,
|
||||
),
|
||||
'script_path' => array(
|
||||
'label' => 'SCRIPT_PATH',
|
||||
'description' => 'SCRIPT_PATH_EXPLAIN',
|
||||
'type' => 'text',
|
||||
'default' => $script_path,
|
||||
),
|
||||
'submit_server' => array(
|
||||
'label' => 'SUBMIT',
|
||||
'type' => 'submit',
|
||||
)
|
||||
);
|
||||
|
||||
$this->io_handler->add_user_form_group('SERVER_CONFIG', $server_form);
|
||||
|
||||
$this->io_handler->send_response();
|
||||
throw new user_interaction_required_exception();
|
||||
}
|
||||
}
|
||||
}
|
73
phpBB/install/module/requirements/module.php
Normal file
73
phpBB/install/module/requirements/module.php
Normal file
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\install\module\requirements;
|
||||
|
||||
use phpbb\install\exception\user_interaction_required_exception;
|
||||
|
||||
class module extends \phpbb\install\module_base
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
$tests_passed = true;
|
||||
|
||||
// Recover install progress
|
||||
$task_index = 0;
|
||||
|
||||
// Run until there are available resources
|
||||
while ($this->install_config->get_time_remaining() > 0 && $this->install_config->get_memory_remaining() > 0)
|
||||
{
|
||||
// Check if task exists
|
||||
if (!isset($this->task_collection[$task_index]))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
// Recover task to be executed
|
||||
/** @var \phpbb\install\task_interface $task */
|
||||
$task = $this->container->get($this->task_collection[$task_index]);
|
||||
|
||||
// Iterate to the next task
|
||||
$task_index++;
|
||||
|
||||
// Check if we can run the task
|
||||
if (!$task->is_essential() && !$task->check_requirements())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$test_result = $task->run();
|
||||
$tests_passed = ($tests_passed) ? $test_result : false;
|
||||
}
|
||||
|
||||
// Check if tests have failed
|
||||
if (!$tests_passed)
|
||||
{
|
||||
// If requirements are not met, exit form installer
|
||||
$this->iohandler->send_response();
|
||||
throw new user_interaction_required_exception();
|
||||
}
|
||||
|
||||
// Log install progress
|
||||
$current_task_index = $task_index - 1;
|
||||
$this->install_config->set_finished_task($this->task_collection[$current_task_index], $current_task_index);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_task_count()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
258
phpBB/install/module/requirements/task/check_filesystem.php
Normal file
258
phpBB/install/module/requirements/task/check_filesystem.php
Normal file
|
@ -0,0 +1,258 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\install\module\requirements\task;
|
||||
|
||||
/**
|
||||
* Checks filesystem requirements
|
||||
*/
|
||||
class check_filesystem extends \phpbb\install\task_base
|
||||
{
|
||||
/**
|
||||
* @var \phpbb\filesystem\filesystem_interface
|
||||
*/
|
||||
protected $filesystem;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $files_to_check;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $tests_passed;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $phpbb_root_path;
|
||||
|
||||
/**
|
||||
* @var \phpbb\install\helper\iohandler\iohandler_interface
|
||||
*/
|
||||
protected $response;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \phpbb\filesystem\filesystem_interface $filesystem filesystem handler
|
||||
* @parma \phpbb\install\helper\iohandler\iohandler_interface $response response helper
|
||||
* @param string $phpbb_root_path relative path to phpBB's root
|
||||
* @param string $php_ext extension of php files
|
||||
*/
|
||||
public function __construct(\phpbb\filesystem\filesystem_interface $filesystem,
|
||||
\phpbb\install\helper\iohandler\iohandler_interface $response,
|
||||
$phpbb_root_path,
|
||||
$php_ext)
|
||||
{
|
||||
parent::__construct(true);
|
||||
|
||||
$this->filesystem = $filesystem;
|
||||
$this->response = $response;
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
|
||||
$this->tests_passed = false;
|
||||
|
||||
// Files/Directories to check
|
||||
// All file/directory names must be relative to phpBB's root path
|
||||
$this->files_to_check = array(
|
||||
array(
|
||||
'path' => 'cache/',
|
||||
'failable' => false,
|
||||
'is_file' => false,
|
||||
),
|
||||
array(
|
||||
'path' => 'store/',
|
||||
'failable' => false,
|
||||
'is_file' => false,
|
||||
),
|
||||
array(
|
||||
'path' => 'files/',
|
||||
'failable' => false,
|
||||
'is_file' => false,
|
||||
),
|
||||
array(
|
||||
'path' => 'images/avatars/upload/',
|
||||
'failable' => true,
|
||||
'is_file' => false,
|
||||
),
|
||||
array(
|
||||
'path' => "config.$php_ext",
|
||||
'failable' => false,
|
||||
'is_file' => true,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$this->tests_passed = true;
|
||||
|
||||
// Check files/directories to be writable
|
||||
foreach ($this->files_to_check as $file)
|
||||
{
|
||||
if ($file['is_file'])
|
||||
{
|
||||
$this->check_file($file['path'], $file['failable']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->check_dir($file['path'], $file['failable']);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->tests_passed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets $this->tests_passed
|
||||
*
|
||||
* @param bool $is_passed
|
||||
* @return null
|
||||
*/
|
||||
protected function set_test_passed($is_passed)
|
||||
{
|
||||
// If one test failed, tests_passed should be false
|
||||
$this->tests_passed = (!$this->tests_passed) ? false : $is_passed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a file is readable and writable
|
||||
*
|
||||
* @param string $file Filename
|
||||
* @param bool $failable Whether failing test should interrupt installation process
|
||||
*/
|
||||
protected function check_file($file, $failable = false)
|
||||
{
|
||||
$path = $this->phpbb_root_path . $file;
|
||||
$exists = $writable = true;
|
||||
|
||||
// Try to create file if it does not exists
|
||||
if (!file_exists($path))
|
||||
{
|
||||
$fp = @fopen($path, 'w');
|
||||
@fclose($fp);
|
||||
try
|
||||
{
|
||||
$this->filesystem->phpbb_chmod($path,
|
||||
\phpbb\filesystem\filesystem_interface::CHMOD_READ | \phpbb\filesystem\filesystem_interface::CHMOD_WRITE
|
||||
);
|
||||
$exists = true;
|
||||
}
|
||||
catch (\phpbb\filesystem\exception\filesystem_exception $e)
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
|
||||
if (file_exists($path))
|
||||
{
|
||||
if (!$this->filesystem->is_writable($path))
|
||||
{
|
||||
$writable = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$exists = $writable = false;
|
||||
}
|
||||
|
||||
$this->set_test_passed(($exists && $writable) || $failable);
|
||||
|
||||
if (!($exists && $writable))
|
||||
{
|
||||
$title = ($exists) ? 'FILE_NOT_WRITABLE' : 'FILE_NOT_EXISTS';
|
||||
$description = array($title . '_EXPLAIN', $file);
|
||||
|
||||
if ($failable)
|
||||
{
|
||||
$this->response->add_warning_message($title, $description);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->response->add_error_message($title, $description);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a directory is readable and writable
|
||||
*
|
||||
* @param string $dir Filename
|
||||
* @param bool $failable Whether failing test should abort the installation process
|
||||
*/
|
||||
protected function check_dir($dir, $failable = false)
|
||||
{
|
||||
$path = $this->phpbb_root_path . $dir;
|
||||
$exists = $writable = false;
|
||||
|
||||
// Try to create the directory if it does not exist
|
||||
if (!file_exists($path))
|
||||
{
|
||||
try
|
||||
{
|
||||
$this->filesystem->mkdir($path, 0777);
|
||||
$this->filesystem->phpbb_chmod($path,
|
||||
\phpbb\filesystem\filesystem_interface::CHMOD_READ | \phpbb\filesystem\filesystem_interface::CHMOD_WRITE
|
||||
);
|
||||
$exists = true;
|
||||
}
|
||||
catch (\phpbb\filesystem\exception\filesystem_exception $e)
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
|
||||
// Now really check
|
||||
if (file_exists($path) && is_dir($path))
|
||||
{
|
||||
try
|
||||
{
|
||||
$exists = true;
|
||||
$this->filesystem->phpbb_chmod($path,
|
||||
\phpbb\filesystem\filesystem_interface::CHMOD_READ | \phpbb\filesystem\filesystem_interface::CHMOD_WRITE
|
||||
);
|
||||
}
|
||||
catch (\phpbb\filesystem\exception\filesystem_exception $e)
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->filesystem->is_writable($path))
|
||||
{
|
||||
$writable = true;
|
||||
}
|
||||
|
||||
$this->set_test_passed(($exists && $writable) || $failable);
|
||||
|
||||
if (!($exists && $writable))
|
||||
{
|
||||
$title = ($exists) ? 'DIRECTORY_NOT_WRITABLE' : 'DIRECTORY_NOT_EXISTS';
|
||||
$description = array($title . '_EXPLAIN', $dir);
|
||||
|
||||
if ($failable)
|
||||
{
|
||||
$this->response->add_warning_message($title, $description);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->response->add_error_message($title, $description);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,185 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\install\module\requirements\task;
|
||||
|
||||
/**
|
||||
* Installer task that checks if the server meats phpBB requirements
|
||||
*/
|
||||
class check_server_environment extends \phpbb\install\task_base
|
||||
{
|
||||
/**
|
||||
* @var \phpbb\install\helper\database
|
||||
*/
|
||||
protected $database_helper;
|
||||
|
||||
/**
|
||||
* @var \phpbb\install\helper\iohandler\iohandler_interface
|
||||
*/
|
||||
protected $response_helper;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $tests_passed;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \phpbb\install\helper\database $database_helper
|
||||
* @param \phpbb\install\helper\iohandler\iohandler_interface $response
|
||||
*/
|
||||
public function __construct(\phpbb\install\helper\database $database_helper,
|
||||
\phpbb\install\helper\iohandler\iohandler_interface $response)
|
||||
{
|
||||
$this->database_helper = $database_helper;
|
||||
$this->response_helper = $response;
|
||||
$this->tests_passed = true;
|
||||
|
||||
parent::__construct(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
//
|
||||
// Check requirements
|
||||
// The error messages should be set in the check_ functions
|
||||
//
|
||||
|
||||
// Check PHP version
|
||||
$this->check_php_version();
|
||||
|
||||
// Check for getimagesize()
|
||||
$this->check_image_size();
|
||||
|
||||
// Check for PCRE support
|
||||
$this->check_pcre();
|
||||
|
||||
// Check for JSON support
|
||||
$this->check_json();
|
||||
|
||||
// Check for dbms support
|
||||
$this->check_available_dbms();
|
||||
|
||||
return $this->tests_passed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets $this->tests_passed
|
||||
*
|
||||
* @param bool $is_passed
|
||||
* @return null
|
||||
*/
|
||||
protected function set_test_passed($is_passed)
|
||||
{
|
||||
// If one test failed, tests_passed should be false
|
||||
$this->tests_passed = (!$this->tests_passed) ? false : $is_passed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the requirements for PHP version is met
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
protected function check_php_version()
|
||||
{
|
||||
$php_version = PHP_VERSION;
|
||||
|
||||
if (version_compare($php_version, '5.3.9') < 0)
|
||||
{
|
||||
$this->response_helper->add_error_message('PHP_VERSION_REQD', 'PHP_VERSION_REQD_EXPLAIN');
|
||||
|
||||
$this->set_test_passed(false);
|
||||
return;
|
||||
}
|
||||
|
||||
$this->set_test_passed(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the installed PHP has getimagesize() available
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
protected function check_image_size()
|
||||
{
|
||||
if (!@function_exists('getimagesize'))
|
||||
{
|
||||
$this->response_helper->add_error_message('PHP_GETIMAGESIZE_SUPPORT', 'PHP_GETIMAGESIZE_SUPPORT_EXPLAIN');
|
||||
|
||||
$this->set_test_passed(false);
|
||||
return;
|
||||
}
|
||||
|
||||
$this->set_test_passed(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the installed PHP supports PCRE
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
protected function check_pcre()
|
||||
{
|
||||
if (@preg_match('//u', ''))
|
||||
{
|
||||
$this->set_test_passed(true);
|
||||
return;
|
||||
}
|
||||
|
||||
$this->response_helper->add_error_message('PCRE_UTF_SUPPORT', 'PCRE_UTF_SUPPORT_EXPLAIN');
|
||||
|
||||
$this->set_test_passed(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether PHP's JSON extension is available or not
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
protected function check_json()
|
||||
{
|
||||
if (@extension_loaded('json'))
|
||||
{
|
||||
$this->set_test_passed(true);
|
||||
return;
|
||||
}
|
||||
|
||||
$this->response_helper->add_error_message('PHP_JSON_SUPPORT', 'PHP_JSON_SUPPORT_EXPLAIN');
|
||||
|
||||
$this->set_test_passed(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if any supported DBMS is available
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
protected function check_available_dbms()
|
||||
{
|
||||
$available_dbms = $this->database_helper->get_available_dbms(false, true);
|
||||
|
||||
if ($available_dbms['ANY_DB_SUPPORT'])
|
||||
{
|
||||
$this->set_test_passed(true);
|
||||
return;
|
||||
}
|
||||
|
||||
$this->response_helper->add_error_message('PHP_SUPPORTED_DB', 'PHP_SUPPORTED_DB_EXPLAIN');
|
||||
|
||||
$this->set_test_passed(false);
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue