From c22562f5cdb3db9482a7c6bc2398ebb12cbcfb8b Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Fri, 30 May 2014 14:57:19 +0200 Subject: [ticket/12620] Allow the user to define multiples environments PHPBB3-12620 --- phpBB/includes/functions_install.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions_install.php') diff --git a/phpBB/includes/functions_install.php b/phpBB/includes/functions_install.php index 28cc603bdb..2be8e6e860 100644 --- a/phpBB/includes/functions_install.php +++ b/phpBB/includes/functions_install.php @@ -453,11 +453,11 @@ function phpbb_create_config_file_data($data, $dbms, $debug = false, $debug_cont if ($debug) { - $config_data .= "@define('DEBUG', true);\n"; + $config_data .= "@define('ENVIRONMENT', 'debug');\n"; } else { - $config_data .= "// @define('DEBUG', true);\n"; + $config_data .= "@define('ENVIRONMENT', 'productive');\n"; } if ($debug_container) -- cgit v1.2.1 From 70201ee8fa084da667b0b1a308d48d2f3c8a541b Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Fri, 30 May 2014 15:37:45 +0200 Subject: [ticket/12620] Rename debug to development PHPBB3-12620 --- phpBB/includes/functions_install.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions_install.php') diff --git a/phpBB/includes/functions_install.php b/phpBB/includes/functions_install.php index 2be8e6e860..1b63414cec 100644 --- a/phpBB/includes/functions_install.php +++ b/phpBB/includes/functions_install.php @@ -453,7 +453,7 @@ function phpbb_create_config_file_data($data, $dbms, $debug = false, $debug_cont if ($debug) { - $config_data .= "@define('ENVIRONMENT', 'debug');\n"; + $config_data .= "@define('ENVIRONMENT', 'development');\n"; } else { -- cgit v1.2.1 From c4842fe119a2947c3d6c34239f83d4d887a39f00 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Fri, 30 May 2014 16:18:11 +0200 Subject: [ticket/12620] Fix functional tests PHPBB3-12620 --- phpBB/includes/functions_install.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/includes/functions_install.php') diff --git a/phpBB/includes/functions_install.php b/phpBB/includes/functions_install.php index 1b63414cec..4ed44da0b1 100644 --- a/phpBB/includes/functions_install.php +++ b/phpBB/includes/functions_install.php @@ -472,6 +472,7 @@ function phpbb_create_config_file_data($data, $dbms, $debug = false, $debug_cont if ($debug_test) { $config_data .= "@define('DEBUG_TEST', true);\n"; + $config_data .= "@define('DEBUG', true);\n"; // Mandatory for the functional tests, will be removed by PHPBB3-12623 } return $config_data; -- cgit v1.2.1 From 7fa3b4c6860d85c7616e2182241eefe9515dc8a8 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Fri, 30 May 2014 18:33:56 +0200 Subject: [ticket/12620] Rename productive to production PHPBB3-12620 --- phpBB/includes/functions_install.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions_install.php') diff --git a/phpBB/includes/functions_install.php b/phpBB/includes/functions_install.php index 4ed44da0b1..e0ecda3bfa 100644 --- a/phpBB/includes/functions_install.php +++ b/phpBB/includes/functions_install.php @@ -457,7 +457,7 @@ function phpbb_create_config_file_data($data, $dbms, $debug = false, $debug_cont } else { - $config_data .= "@define('ENVIRONMENT', 'productive');\n"; + $config_data .= "@define('ENVIRONMENT', 'production');\n"; } if ($debug_container) -- cgit v1.2.1 From b697273aaa53d9f9f4a3d4a53cc6267e906953cd Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Thu, 4 Sep 2014 17:06:39 +0200 Subject: [ticket/12620] Use PHPBB_ENVIRONMENT PHPBB3-12620 --- phpBB/includes/functions_install.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions_install.php') diff --git a/phpBB/includes/functions_install.php b/phpBB/includes/functions_install.php index e0ecda3bfa..cdd9c7864b 100644 --- a/phpBB/includes/functions_install.php +++ b/phpBB/includes/functions_install.php @@ -453,11 +453,11 @@ function phpbb_create_config_file_data($data, $dbms, $debug = false, $debug_cont if ($debug) { - $config_data .= "@define('ENVIRONMENT', 'development');\n"; + $config_data .= "@define('PHPBB_ENVIRONMENT', 'development');\n"; } else { - $config_data .= "@define('ENVIRONMENT', 'production');\n"; + $config_data .= "@define('PHPBB_ENVIRONMENT', 'production');\n"; } if ($debug_container) -- cgit v1.2.1 From 48950be82bca0c85347f5aa1585de44c369780c6 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Wed, 19 Nov 2014 20:54:14 +0100 Subject: [ticket/12620] Fix tests PHPBB3-12620 --- phpBB/includes/functions_install.php | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'phpBB/includes/functions_install.php') diff --git a/phpBB/includes/functions_install.php b/phpBB/includes/functions_install.php index cdd9c7864b..ef4e3166e3 100644 --- a/phpBB/includes/functions_install.php +++ b/phpBB/includes/functions_install.php @@ -450,15 +450,7 @@ function phpbb_create_config_file_data($data, $dbms, $debug = false, $debug_cont $config_data .= "\n@define('PHPBB_INSTALLED', true);\n"; $config_data .= "// @define('PHPBB_DISPLAY_LOAD_TIME', true);\n"; - - if ($debug) - { - $config_data .= "@define('PHPBB_ENVIRONMENT', 'development');\n"; - } - else - { - $config_data .= "@define('PHPBB_ENVIRONMENT', 'production');\n"; - } + $config_data .= "@define('PHPBB_ENVIRONMENT', 'test');\n"; if ($debug_container) { -- cgit v1.2.1 From 93f61a4a7d34f8ad565bdc1605784284994ecdfc Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Thu, 20 Nov 2014 18:38:32 +0100 Subject: [ticket/12620] Use the right environment while installing PHPBB3-12620 --- phpBB/includes/functions_install.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/functions_install.php') diff --git a/phpBB/includes/functions_install.php b/phpBB/includes/functions_install.php index ef4e3166e3..a60ddd40c5 100644 --- a/phpBB/includes/functions_install.php +++ b/phpBB/includes/functions_install.php @@ -450,7 +450,19 @@ function phpbb_create_config_file_data($data, $dbms, $debug = false, $debug_cont $config_data .= "\n@define('PHPBB_INSTALLED', true);\n"; $config_data .= "// @define('PHPBB_DISPLAY_LOAD_TIME', true);\n"; - $config_data .= "@define('PHPBB_ENVIRONMENT', 'test');\n"; + + if ($debug_test) + { + $config_data .= "@define('PHPBB_ENVIRONMENT', 'test');\n"; + } + else if ($debug) + { + $config_data .= "@define('PHPBB_ENVIRONMENT', 'development');\n"; + } + else + { + $config_data .= "@define('PHPBB_ENVIRONMENT', 'production');\n"; + } if ($debug_container) { -- cgit v1.2.1 From ec90f2b380a598a3dbf7ada0e95878d9d1b85cbe Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 6 Dec 2014 16:34:02 +0100 Subject: [ticket/13421] Move tools to subdirectory PHPBB3-13421 --- phpBB/includes/functions_install.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions_install.php') diff --git a/phpBB/includes/functions_install.php b/phpBB/includes/functions_install.php index a60ddd40c5..956e5a5180 100644 --- a/phpBB/includes/functions_install.php +++ b/phpBB/includes/functions_install.php @@ -188,7 +188,7 @@ function dbms_select($default = '', $only_20x_options = false) */ function get_tables(&$db) { - $db_tools = new \phpbb\db\tools($db); + $db_tools = new \phpbb\db\tools\tools($db); return $db_tools->sql_list_tables(); } -- cgit v1.2.1 From 37ae99c75d388221489aa1069078d92eca413741 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 24 Jan 2015 12:06:45 +0100 Subject: [ticket/10748] Replace direct creations of tools(); PHPBB3-10748 --- phpBB/includes/functions_install.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/functions_install.php') diff --git a/phpBB/includes/functions_install.php b/phpBB/includes/functions_install.php index 956e5a5180..4217617b53 100644 --- a/phpBB/includes/functions_install.php +++ b/phpBB/includes/functions_install.php @@ -188,7 +188,8 @@ function dbms_select($default = '', $only_20x_options = false) */ function get_tables(&$db) { - $db_tools = new \phpbb\db\tools\tools($db); + $factory = new \phpbb\db\tools\factory(); + $db_tools = $factory->get($db); return $db_tools->sql_list_tables(); } -- cgit v1.2.1 From 50478e68b093c71022337469bfa04f27382a8efb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gae=CC=88tan=20Muller?= Date: Sun, 11 Jan 2015 20:59:17 +0100 Subject: [ticket/13497] Update calls to `get_tables()` PHPBB3-13497 --- phpBB/includes/functions_install.php | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) (limited to 'phpBB/includes/functions_install.php') diff --git a/phpBB/includes/functions_install.php b/phpBB/includes/functions_install.php index 4217617b53..8dacd25230 100644 --- a/phpBB/includes/functions_install.php +++ b/phpBB/includes/functions_install.php @@ -181,19 +181,6 @@ function dbms_select($default = '', $only_20x_options = false) return $dbms_options; } -/** -* Get tables of a database -* -* @deprecated -*/ -function get_tables(&$db) -{ - $factory = new \phpbb\db\tools\factory(); - $db_tools = $factory->get($db); - - return $db_tools->sql_list_tables(); -} - /** * Used to test whether we are able to connect to the database the user has specified * and identify any problems (eg there are already tables with the names we want to use @@ -277,7 +264,9 @@ function connect_check_db($error_connect, &$error, $dbms_details, $table_prefix, $temp_prefix = strtolower($table_prefix); $table_ary = array($temp_prefix . 'attachments', $temp_prefix . 'config', $temp_prefix . 'sessions', $temp_prefix . 'topics', $temp_prefix . 'users'); - $tables = get_tables($db); + $db_tools_factory = new \phpbb\db\tools\factory(); + $db_tools = $db_tools_factory->get($db); + $tables = $db_tools->sql_list_tables(); $tables = array_map('strtolower', $tables); $table_intersect = array_intersect($tables, $table_ary); -- cgit v1.2.1 From 4bdef6fd21a5dcab455b0cd1ee2652de606929c3 Mon Sep 17 00:00:00 2001 From: MateBartus Date: Thu, 12 Mar 2015 00:25:00 +0100 Subject: [ticket/13697] Moving filesystem related functions to filesystem service * Moving filesystem service to \phpbb\filesystem namespace * Wraping Symfony's Filesystem component * Moving filesystem related functions from includes/functions.php into \phpbb\filesystem\filesystem Functions moved (and deprecated): - phpbb_chmod - phpbb_is_writable - phpbb_is_absolute - phpbb_own_realpath - phpbb_realpath * Adding interface for filesystem service PHPBB3-13697 --- phpBB/includes/functions_install.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions_install.php') diff --git a/phpBB/includes/functions_install.php b/phpBB/includes/functions_install.php index 8dacd25230..d9d073e984 100644 --- a/phpBB/includes/functions_install.php +++ b/phpBB/includes/functions_install.php @@ -189,7 +189,7 @@ function dbms_select($default = '', $only_20x_options = false) */ function connect_check_db($error_connect, &$error, $dbms_details, $table_prefix, $dbhost, $dbuser, $dbpasswd, $dbname, $dbport, $prefix_may_exist = false, $load_dbal = true, $unicode_check = true) { - global $phpbb_root_path, $phpEx, $config, $lang; + global $phpbb_root_path, $phpEx, $config, $lang, $phpbb_filesystem; $dbms = $dbms_details['DRIVER']; @@ -205,7 +205,7 @@ function connect_check_db($error_connect, &$error, $dbms_details, $table_prefix, } // Make sure we don't have a daft user who thinks having the SQLite database in the forum directory is a good idea - if (($dbms_details['DRIVER'] == 'phpbb\db\driver\sqlite' || $dbms_details['DRIVER'] == 'phpbb\db\driver\sqlite3') && stripos(phpbb_realpath($dbhost), phpbb_realpath('../')) === 0) + if (($dbms_details['DRIVER'] == 'phpbb\db\driver\sqlite' || $dbms_details['DRIVER'] == 'phpbb\db\driver\sqlite3') && stripos($phpbb_filesystem->realpath($dbhost), $phpbb_filesystem->realpath('../')) === 0) { $error[] = $lang['INST_ERR_DB_FORUM_PATH']; return false; -- cgit v1.2.1 From 597297b169e2ae14684ad1f40c8e083be22b241d Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Sun, 18 Oct 2015 22:47:04 +0200 Subject: [ticket/14044] Deduplicate the installers PHPBB3-14044 --- phpBB/includes/functions_install.php | 540 ----------------------------------- 1 file changed, 540 deletions(-) delete mode 100644 phpBB/includes/functions_install.php (limited to 'phpBB/includes/functions_install.php') diff --git a/phpBB/includes/functions_install.php b/phpBB/includes/functions_install.php deleted file mode 100644 index d9d073e984..0000000000 --- a/phpBB/includes/functions_install.php +++ /dev/null @@ -1,540 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* Returns an array of available DBMS with some data, if a DBMS is specified it will only -* return data for that DBMS and will load its extension if necessary. -*/ -function get_available_dbms($dbms = false, $return_unavailable = false, $only_20x_options = false) -{ - global $lang; - $available_dbms = array( - // Note: php 5.5 alpha 2 deprecated mysql. - // Keep mysqli before mysql in this list. - 'mysqli' => array( - 'LABEL' => 'MySQL with MySQLi Extension', - 'SCHEMA' => 'mysql_41', - 'MODULE' => 'mysqli', - 'DELIM' => ';', - 'DRIVER' => 'phpbb\db\driver\mysqli', - 'AVAILABLE' => true, - '2.0.x' => true, - ), - 'mysql' => array( - 'LABEL' => 'MySQL', - 'SCHEMA' => 'mysql', - 'MODULE' => 'mysql', - 'DELIM' => ';', - 'DRIVER' => 'phpbb\db\driver\mysql', - 'AVAILABLE' => true, - '2.0.x' => true, - ), - 'mssql' => array( - 'LABEL' => 'MS SQL Server 2000+', - 'SCHEMA' => 'mssql', - 'MODULE' => 'mssql', - 'DELIM' => 'GO', - 'DRIVER' => 'phpbb\db\driver\mssql', - 'AVAILABLE' => true, - '2.0.x' => true, - ), - 'mssql_odbc'=> array( - 'LABEL' => 'MS SQL Server [ ODBC ]', - 'SCHEMA' => 'mssql', - 'MODULE' => 'odbc', - 'DELIM' => 'GO', - 'DRIVER' => 'phpbb\db\driver\mssql_odbc', - 'AVAILABLE' => true, - '2.0.x' => true, - ), - 'mssqlnative' => array( - 'LABEL' => 'MS SQL Server 2005+ [ Native ]', - 'SCHEMA' => 'mssql', - 'MODULE' => 'sqlsrv', - 'DELIM' => 'GO', - 'DRIVER' => 'phpbb\db\driver\mssqlnative', - 'AVAILABLE' => true, - '2.0.x' => false, - ), - 'oracle' => array( - 'LABEL' => 'Oracle', - 'SCHEMA' => 'oracle', - 'MODULE' => 'oci8', - 'DELIM' => '/', - 'DRIVER' => 'phpbb\db\driver\oracle', - 'AVAILABLE' => true, - '2.0.x' => false, - ), - 'postgres' => array( - 'LABEL' => 'PostgreSQL 8.3+', - 'SCHEMA' => 'postgres', - 'MODULE' => 'pgsql', - 'DELIM' => ';', - 'DRIVER' => 'phpbb\db\driver\postgres', - 'AVAILABLE' => true, - '2.0.x' => true, - ), - 'sqlite' => array( - 'LABEL' => 'SQLite', - 'SCHEMA' => 'sqlite', - 'MODULE' => 'sqlite', - 'DELIM' => ';', - 'DRIVER' => 'phpbb\db\driver\sqlite', - 'AVAILABLE' => true, - '2.0.x' => false, - ), - 'sqlite3' => array( - 'LABEL' => 'SQLite3', - 'SCHEMA' => 'sqlite', - 'MODULE' => 'sqlite3', - 'DELIM' => ';', - 'DRIVER' => 'phpbb\db\driver\sqlite3', - 'AVAILABLE' => true, - '2.0.x' => false, - ), - ); - - if ($dbms) - { - if (isset($available_dbms[$dbms])) - { - $available_dbms = array($dbms => $available_dbms[$dbms]); - } - else - { - return array(); - } - } - - // now perform some checks whether they are really available - foreach ($available_dbms as $db_name => $db_ary) - { - if ($only_20x_options && !$db_ary['2.0.x']) - { - if ($return_unavailable) - { - $available_dbms[$db_name]['AVAILABLE'] = false; - } - else - { - unset($available_dbms[$db_name]); - } - continue; - } - - $dll = $db_ary['MODULE']; - - if (!@extension_loaded($dll)) - { - if ($return_unavailable) - { - $available_dbms[$db_name]['AVAILABLE'] = false; - } - else - { - unset($available_dbms[$db_name]); - } - continue; - } - $any_db_support = true; - } - - if ($return_unavailable) - { - $available_dbms['ANY_DB_SUPPORT'] = $any_db_support; - } - return $available_dbms; -} - -/** -* Generate the drop down of available database options -*/ -function dbms_select($default = '', $only_20x_options = false) -{ - global $lang; - - $available_dbms = get_available_dbms(false, false, $only_20x_options); - $dbms_options = ''; - foreach ($available_dbms as $dbms_name => $details) - { - $selected = ($dbms_name == $default) ? ' selected="selected"' : ''; - $dbms_options .= ''; - } - return $dbms_options; -} - -/** -* Used to test whether we are able to connect to the database the user has specified -* and identify any problems (eg there are already tables with the names we want to use -* @param array $dbms should be of the format of an element of the array returned by {@link get_available_dbms get_available_dbms()} -* necessary extensions should be loaded already -*/ -function connect_check_db($error_connect, &$error, $dbms_details, $table_prefix, $dbhost, $dbuser, $dbpasswd, $dbname, $dbport, $prefix_may_exist = false, $load_dbal = true, $unicode_check = true) -{ - global $phpbb_root_path, $phpEx, $config, $lang, $phpbb_filesystem; - - $dbms = $dbms_details['DRIVER']; - - // Instantiate it and set return on error true - $db = new $dbms(); - $db->sql_return_on_error(true); - - // Check that we actually have a database name before going any further..... - if ($dbms_details['DRIVER'] != 'phpbb\db\driver\sqlite' && $dbms_details['DRIVER'] != 'phpbb\db\driver\sqlite3' && $dbms_details['DRIVER'] != 'phpbb\db\driver\oracle' && $dbname === '') - { - $error[] = $lang['INST_ERR_DB_NO_NAME']; - return false; - } - - // Make sure we don't have a daft user who thinks having the SQLite database in the forum directory is a good idea - if (($dbms_details['DRIVER'] == 'phpbb\db\driver\sqlite' || $dbms_details['DRIVER'] == 'phpbb\db\driver\sqlite3') && stripos($phpbb_filesystem->realpath($dbhost), $phpbb_filesystem->realpath('../')) === 0) - { - $error[] = $lang['INST_ERR_DB_FORUM_PATH']; - return false; - } - - // Check the prefix length to ensure that index names are not too long and does not contain invalid characters - switch ($dbms_details['DRIVER']) - { - case 'phpbb\db\driver\mysql': - case 'phpbb\db\driver\mysqli': - if (strspn($table_prefix, '-./\\') !== 0) - { - $error[] = $lang['INST_ERR_PREFIX_INVALID']; - return false; - } - - // no break; - - case 'phpbb\db\driver\postgres': - $prefix_length = 36; - break; - - case 'phpbb\db\driver\mssql': - case 'phpbb\db\driver\mssql_odbc': - case 'phpbb\db\driver\mssqlnative': - $prefix_length = 90; - break; - - case 'phpbb\db\driver\sqlite': - case 'phpbb\db\driver\sqlite3': - $prefix_length = 200; - break; - - case 'phpbb\db\driver\oracle': - $prefix_length = 6; - break; - } - - if (strlen($table_prefix) > $prefix_length) - { - $error[] = sprintf($lang['INST_ERR_PREFIX_TOO_LONG'], $prefix_length); - return false; - } - - // Try and connect ... - if (is_array($db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, true))) - { - $db_error = $db->sql_error(); - $error[] = $lang['INST_ERR_DB_CONNECT'] . '
' . (($db_error['message']) ? utf8_convert_message($db_error['message']) : $lang['INST_ERR_DB_NO_ERROR']); - } - else - { - // Likely matches for an existing phpBB installation - if (!$prefix_may_exist) - { - $temp_prefix = strtolower($table_prefix); - $table_ary = array($temp_prefix . 'attachments', $temp_prefix . 'config', $temp_prefix . 'sessions', $temp_prefix . 'topics', $temp_prefix . 'users'); - - $db_tools_factory = new \phpbb\db\tools\factory(); - $db_tools = $db_tools_factory->get($db); - $tables = $db_tools->sql_list_tables(); - $tables = array_map('strtolower', $tables); - $table_intersect = array_intersect($tables, $table_ary); - - if (sizeof($table_intersect)) - { - $error[] = $lang['INST_ERR_PREFIX']; - } - } - - // Make sure that the user has selected a sensible DBAL for the DBMS actually installed - switch ($dbms_details['DRIVER']) - { - case 'phpbb\db\driver\mysqli': - if (version_compare(mysqli_get_server_info($db->get_db_connect_id()), '4.1.3', '<')) - { - $error[] = $lang['INST_ERR_DB_NO_MYSQLI']; - } - break; - - case 'phpbb\db\driver\sqlite': - if (version_compare(sqlite_libversion(), '2.8.2', '<')) - { - $error[] = $lang['INST_ERR_DB_NO_SQLITE']; - } - break; - - case 'phpbb\db\driver\sqlite3': - $version = \SQLite3::version(); - if (version_compare($version['versionString'], '3.6.15', '<')) - { - $error[] = $lang['INST_ERR_DB_NO_SQLITE3']; - } - break; - - case 'phpbb\db\driver\oracle': - if ($unicode_check) - { - $sql = "SELECT * - FROM NLS_DATABASE_PARAMETERS - WHERE PARAMETER = 'NLS_RDBMS_VERSION' - OR PARAMETER = 'NLS_CHARACTERSET'"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $stats[$row['parameter']] = $row['value']; - } - $db->sql_freeresult($result); - - if (version_compare($stats['NLS_RDBMS_VERSION'], '9.2', '<') && $stats['NLS_CHARACTERSET'] !== 'UTF8') - { - $error[] = $lang['INST_ERR_DB_NO_ORACLE']; - } - } - break; - - case 'phpbb\db\driver\postgres': - if ($unicode_check) - { - $sql = "SHOW server_encoding;"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row['server_encoding'] !== 'UNICODE' && $row['server_encoding'] !== 'UTF8') - { - $error[] = $lang['INST_ERR_DB_NO_POSTGRES']; - } - } - break; - } - - } - - if ($error_connect && (!isset($error) || !sizeof($error))) - { - return true; - } - return false; -} - -/** -* Removes "/* style" as well as "# style" comments from $input. -* -* @param string $input Input string -* -* @return string Input string with comments removed -*/ -function phpbb_remove_comments($input) -{ - // Remove /* */ comments (http://ostermiller.org/findcomment.html) - $input = preg_replace('#/\*(.|[\r\n])*?\*/#', "\n", $input); - - // Remove # style comments - $input = preg_replace('/\n{2,}/', "\n", preg_replace('/^#.*$/m', "\n", $input)); - - return $input; -} - -/** -* split_sql_file will split an uploaded sql file into single sql statements. -* Note: expects trim() to have already been run on $sql. -*/ -function split_sql_file($sql, $delimiter) -{ - $sql = str_replace("\r" , '', $sql); - $data = preg_split('/' . preg_quote($delimiter, '/') . '$/m', $sql); - - $data = array_map('trim', $data); - - // The empty case - $end_data = end($data); - - if (empty($end_data)) - { - unset($data[key($data)]); - } - - return $data; -} - -/** -* For replacing {L_*} strings with preg_replace_callback -*/ -function adjust_language_keys_callback($matches) -{ - if (!empty($matches[1])) - { - global $lang, $db; - - return (!empty($lang[$matches[1]])) ? $db->sql_escape($lang[$matches[1]]) : $db->sql_escape($matches[1]); - } -} - -/** -* Creates the output to be stored in a phpBB config.php file -* -* @param array $data Array containing the database connection information -* @param string $dbms The name of the DBAL class to use -* @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 The output to write to the file -*/ -function phpbb_create_config_file_data($data, $dbms, $debug = false, $debug_container = false, $debug_test = false) -{ - $config_data = " $dbms, - 'dbhost' => $data['dbhost'], - 'dbport' => $data['dbport'], - 'dbname' => $data['dbname'], - 'dbuser' => $data['dbuser'], - 'dbpasswd' => htmlspecialchars_decode($data['dbpasswd']), - 'table_prefix' => $data['table_prefix'], - - 'phpbb_adm_relative_path' => 'adm/', - - 'acm_type' => 'phpbb\cache\driver\file', - ); - - foreach ($config_data_array as $key => $value) - { - $config_data .= "\${$key} = '" . str_replace("'", "\\'", str_replace('\\', '\\\\', $value)) . "';\n"; - } - - $config_data .= "\n@define('PHPBB_INSTALLED', true);\n"; - $config_data .= "// @define('PHPBB_DISPLAY_LOAD_TIME', true);\n"; - - if ($debug_test) - { - $config_data .= "@define('PHPBB_ENVIRONMENT', 'test');\n"; - } - else if ($debug) - { - $config_data .= "@define('PHPBB_ENVIRONMENT', 'development');\n"; - } - else - { - $config_data .= "@define('PHPBB_ENVIRONMENT', 'production');\n"; - } - - if ($debug_container) - { - $config_data .= "@define('DEBUG_CONTAINER', true);\n"; - } - else - { - $config_data .= "// @define('DEBUG_CONTAINER', true);\n"; - } - - if ($debug_test) - { - $config_data .= "@define('DEBUG_TEST', true);\n"; - $config_data .= "@define('DEBUG', true);\n"; // Mandatory for the functional tests, will be removed by PHPBB3-12623 - } - - return $config_data; -} - -/** -* Check whether a file should be ignored on update -* -* We ignore new files in some circumstances: -* 1. The file is a language file, but the language is not installed -* 2. The file is a style file, but the style is not installed -* 3. The file is a style language file, but the language is not installed -* -* @param string $phpbb_root_path phpBB root path -* @param string $file File including path from phpbb root -* @return bool Should we ignore the new file or add it to the board? -*/ -function phpbb_ignore_new_file_on_update($phpbb_root_path, $file) -{ - $ignore_new_file = false; - - // We ignore new files in some circumstances: - // 1. The file is a language file, but the language is not installed - if (!$ignore_new_file && strpos($file, 'language/') === 0) - { - list($language_dir, $language_iso) = explode('/', $file); - $ignore_new_file = !file_exists($phpbb_root_path . $language_dir . '/' . $language_iso); - } - - // 2. The file is a style file, but the style is not installed - if (!$ignore_new_file && strpos($file, 'styles/') === 0) - { - list($styles_dir, $style_name) = explode('/', $file); - $ignore_new_file = !file_exists($phpbb_root_path . $styles_dir . '/' . $style_name); - } - - // 3. The file is a style language file, but the language is not installed - if (!$ignore_new_file && strpos($file, 'styles/') === 0) - { - $dirs = explode('/', $file); - if (sizeof($dirs) >= 5) - { - list($styles_dir, $style_name, $template_component, $language_iso) = explode('/', $file); - if ($template_component == 'theme' && $language_iso !== 'images') - { - $ignore_new_file = !file_exists($phpbb_root_path . 'language/' . $language_iso); - } - } - } - - return $ignore_new_file; -} - -/** -* Check whether phpBB is installed. -* -* @param string $phpbb_root_path Path to the phpBB board root. -* @param string $php_ext PHP file extension. -* -* @return bool Returns true if phpBB is installed. -*/ -function phpbb_check_installation_exists($phpbb_root_path, $php_ext) -{ - // Try opening config file - if (file_exists($phpbb_root_path . 'config.' . $php_ext)) - { - include($phpbb_root_path . 'config.' . $php_ext); - } - - return defined('PHPBB_INSTALLED'); -} -- cgit v1.2.1