From 2503660f97c3f9588f1965c23b98d0c78109ee0b Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 24 Jun 2018 20:26:00 -0400 Subject: [PATCH] Add new INI config files - Add new local.ini.tpl template - Change all references from .htconfig.php to config/local.ini.php --- INSTALL.txt | 30 +- boot.php | 13 +- config/defaults.ini.php | 444 +++++++++++++++++++++++++++ config/local-sample.ini.php | 41 +++ index.php | 2 +- mod/admin.php | 2 +- mod/install.php | 2 +- src/Core/Config/JITConfigAdapter.php | 2 +- src/Core/Install.php | 20 +- view/templates/local.ini.tpl | 65 ++++ 10 files changed, 585 insertions(+), 36 deletions(-) create mode 100644 config/defaults.ini.php create mode 100644 config/local-sample.ini.php create mode 100644 view/templates/local.ini.tpl diff --git a/INSTALL.txt b/INSTALL.txt index 4345fcab1b..c6a994da63 100644 --- a/INSTALL.txt +++ b/INSTALL.txt @@ -106,8 +106,8 @@ password, database name). - Please check the additional notes if running on MySQ 5.7.17 or newer 4. If you know in advance that it will be impossible for the web server to -write or create files in your web directory, create an empty file called -.htconfig.php and make it writable by the web server. +write or create files in the /config/ subfolder, create an empty file called +local.ini.php and make it writable by the web server. 5. Visit your website with a web browser and follow the instructions. Please note any error messages and correct these before continuing. @@ -121,9 +121,9 @@ so in the host name setting for the database. 6. *If* the automated installation fails for any reason, check the following: - - ".htconfig.php" exists - If not, edit htconfig.php and change system settings. Rename -to .htconfig.php + - "config/local.ini.php" exists + If not, edit local-sample.ini.php and change system settings. Rename +to local.ini.php - Database is populated. If not, import the contents of "database.sql" with phpmyadmin or mysql command line @@ -132,7 +132,7 @@ or mysql command line Registration errors should all be recoverable automatically. If you get any *critical* failure at this point, it generally indicates the database was not installed correctly. You might wish to move/rename -.htconfig.php to another name and empty (called 'dropping') the database +local.ini.php to another name and empty (called 'dropping') the database tables, so that you can start fresh. **************************************************************************** @@ -177,7 +177,7 @@ Bad things will happen. Let there be a hardware failure, a corrupted database or whatever you can think of. So once the installation of your Friendica node is done, you should make yoursef a backup plan. -The most important file is the `.htconfig.php` file in the base directory. +The most important file is the `config/local.ini.php` file in the base directory. As it stores all your data, you should also have a recent dump of your Friendica database at hand, should you have to recover your node. @@ -274,21 +274,21 @@ Windows). ##################################################################### -- If you are unable to write the file .htconfig.php during installation +- If you are unable to write the file config/local.ini.php during installation due to permissions issues: ##################################################################### create an empty file with that name and give it world-write permission. For Linux: -% touch .htconfig.php -% chmod 777 .htconfig.php +% touch config/local.ini.php +% chmod 777 config/local.ini.php Retry the installation. As soon as the database has been created, ******* this is important ********* -% chmod 755 .htconfig.php +% chmod 755 config/local.ini.php ##################################################################### - Some configurations with "suhosin" security are configured without @@ -327,11 +327,11 @@ After a while I noticed, that bin/worker.php calls further php script via proc_open. These scripts themselves also use proc_open and fail, because they are NOT called with -d suhosin.executor.func.blacklist=none. -So the simple solution is to put the correct parameters into .htconfig.php: - // Location of PHP command line processor - $a->config['php_path'] = '/usr/bin/php -d suhosin.executor.func.blacklist=none --d suhosin.executor.eval.blacklist=none'; +So the simple solution is to put the correct parameters into config/local.ini.php: +[config] +; Location of PHP command line processor +php_path = "/usr/bin/php -d suhosin.executor.func.blacklist=none -d suhosin.executor.eval.blacklist=none" This is obvious as soon as you notice that the friendica-cron uses proc_open to execute php-scripts that also use proc_open, but it took me quite some time to diff --git a/boot.php b/boot.php index ae33f7c414..bececa9470 100644 --- a/boot.php +++ b/boot.php @@ -64,15 +64,13 @@ define('EOL', "
\r\n"); * @brief Image storage quality. * * Lower numbers save space at cost of image detail. - * For ease of upgrade, please do not change here. Change jpeg quality with - * $a->config['system']['jpeg_quality'] = n; - * in .htconfig.php, where n is netween 1 and 100, and with very poor results - * below about 50 + * For ease of upgrade, please do not change here. Set [system] jpegquality = n in config/local.ini.php, + * where n is between 1 and 100, and with very poor results below about 50 */ define('JPEG_QUALITY', 100); /** - * $a->config['system']['png_quality'] from 0 (uncompressed) to 9 + * [system] png_quality = n where is between 0 (uncompressed) to 9 */ define('PNG_QUALITY', 8); @@ -83,9 +81,10 @@ define('PNG_QUALITY', 8); * this length (on the longest side, the other side will be scaled appropriately). * Modify this value using * - * $a->config['system']['max_image_length'] = n; + * [system] + * max_image_length = n; * - * in .htconfig.php + * in config/local.ini.php * * If you don't want to set a maximum length, set to -1. The default value is * defined by 'MAX_IMAGE_LENGTH' below. diff --git a/config/defaults.ini.php b/config/defaults.ini.php new file mode 100644 index 0000000000..ffc3c495de --- /dev/null +++ b/config/defaults.ini.php @@ -0,0 +1,444 @@ +mode == App::MODE_INSTALL) { } /** - * Load configs from db. Overwrite configs from .htconfig.php + * Load configs from db. Overwrite configs from config/local.ini.php */ Config::load(); diff --git a/mod/admin.php b/mod/admin.php index 54b7e6504e..b308a2049b 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -2378,7 +2378,7 @@ function admin_page_logs(App $a) '$loglevel' => ['loglevel', L10n::t("Log level"), Config::get('system', 'loglevel'), "", $log_choices], '$form_security_token' => get_form_security_token("admin_logs"), '$phpheader' => L10n::t("PHP logging"), - '$phphint' => L10n::t("To enable logging of PHP errors and warnings you can add the following to the .htconfig.php file of your installation. The filename set in the 'error_log' line is relative to the friendica top-level directory and must be writeable by the web server. The option '1' for 'log_errors' and 'display_errors' is to enable these options, set to '0' to disable them."), + '$phphint' => L10n::t("To temporarily enable logging of PHP errors and warnings you can prepend the following to the index.php file of your installation. The filename set in the 'error_log' line is relative to the friendica top-level directory and must be writeable by the web server. The option '1' for 'log_errors' and 'display_errors' is to enable these options, set to '0' to disable them."), '$phplogcode' => "error_reporting(E_ERROR | E_WARNING | E_PARSE);\nini_set('error_log','php.out');\nini_set('log_errors','1');\nini_set('display_errors', '1');", '$phplogenabled' => $phplogenabled, ]); diff --git a/mod/install.php b/mod/install.php index 4596f9a251..79a5c40a3f 100644 --- a/mod/install.php +++ b/mod/install.php @@ -245,7 +245,7 @@ function install_content(App $a) { function manual_config(App $a) { $data = htmlentities($a->data['txt'],ENT_COMPAT, 'UTF-8'); - $o = L10n::t('The database configuration file ".htconfig.php" could not be written. Please use the enclosed text to create a configuration file in your web server root.'); + $o = L10n::t('The database configuration file "config/local.ini.php" could not be written. Please use the enclosed text to create a configuration file in your web server root.'); $o .= ""; return $o; } diff --git a/src/Core/Config/JITConfigAdapter.php b/src/Core/Config/JITConfigAdapter.php index 0e7731690b..0596974aaa 100644 --- a/src/Core/Config/JITConfigAdapter.php +++ b/src/Core/Config/JITConfigAdapter.php @@ -66,7 +66,7 @@ class JITConfigAdapter extends BaseObject implements IConfigAdapter $this->in_db[$cat][$k] = true; return $value; } elseif (isset($a->config[$cat][$k])) { - // Assign the value (mostly) from the .htconfig.php to the cache + // Assign the value (mostly) from config/local.ini.php file to the cache $this->cache[$cat][$k] = $a->config[$cat][$k]; $this->in_db[$cat][$k] = false; diff --git a/src/Core/Install.php b/src/Core/Install.php index 65ef1db241..663195e104 100644 --- a/src/Core/Install.php +++ b/src/Core/Install.php @@ -66,7 +66,7 @@ class Install extends BaseObject /** * Executes the installation of Friendica in the given environment. - * - Creates `.htconfig.php` + * - Creates `config/local.ini.php` * - Installs Database Structure * * @param string $urlpath Path based on the URL of Friendica (e.g. '/friendica') @@ -82,7 +82,7 @@ class Install extends BaseObject */ public static function install($urlpath, $dbhost, $dbuser, $dbpass, $dbdata, $phpath, $timezone, $language, $adminmail, $rino = 1) { - $tpl = get_markup_template('htconfig.tpl'); + $tpl = get_markup_template('local.ini.tpl'); $txt = replace_macros($tpl,[ '$dbhost' => $dbhost, '$dbuser' => $dbuser, @@ -96,7 +96,7 @@ class Install extends BaseObject '$rino' => $rino ]); - $result = file_put_contents('.htconfig.php', $txt); + $result = file_put_contents('config/local.ini.php', $txt); if (! $result) { self::getApp()->data['txt'] = $txt; } @@ -303,9 +303,9 @@ class Install extends BaseObject } /** - * ".htconfig.php" - Check + * "config/local.ini.php" - Check * - * Checks if it's possible to create the ".htconfig.php" + * Checks if it's possible to create the "config/local.ini.php" * * @param array $checks The list of all checks (by-ref parameter!) */ @@ -313,17 +313,17 @@ class Install extends BaseObject { $status = true; $help = ""; - if ((file_exists('.htconfig.php') && !is_writable('.htconfig.php')) || - (!file_exists('.htconfig.php') && !is_writable('.'))) { + if ((file_exists('config/local.ini.php') && !is_writable('config/local.ini.php')) || + (!file_exists('config/local.ini.php') && !is_writable('.'))) { $status = false; - $help = L10n::t('The web installer needs to be able to create a file called ".htconfig.php" in the top folder of your web server and it is unable to do so.') . EOL; + $help = L10n::t('The web installer needs to be able to create a file called "local.ini.php" in the "config" folder of your web server and it is unable to do so.') . EOL; $help .= L10n::t('This is most often a permission setting, as the web server may not be able to write files in your folder - even if you can.') . EOL; - $help .= L10n::t('At the end of this procedure, we will give you a text to save in a file named .htconfig.php in your Friendica top folder.') . EOL; + $help .= L10n::t('At the end of this procedure, we will give you a text to save in a file named local.ini.php in your Friendica "config" folder.') . EOL; $help .= L10n::t('You can alternatively skip this procedure and perform a manual installation. Please see the file "INSTALL.txt" for instructions.') . EOL; } - self::addCheck($checks, L10n::t('.htconfig.php is writable'), $status, false, $help); + self::addCheck($checks, L10n::t('config/local.ini.php is writable'), $status, false, $help); } diff --git a/view/templates/local.ini.tpl b/view/templates/local.ini.tpl new file mode 100644 index 0000000000..1b91fec88f --- /dev/null +++ b/view/templates/local.ini.tpl @@ -0,0 +1,65 @@ +