diff --git a/.gitignore b/.gitignore
index de0fbc3d76..114bb5dbb9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,20 +2,22 @@ favicon.*
.htconfig.php
.htpreconfig.php
\#*
-include/jquery-1.4.2.min.js
*.log
*.out
*.version*
-favicon.*
home.html
-addon
+
*~
robots.txt
-#ignore documentation, it should be newly built
-doc/html
+#ignore local config
+/config/local.ini.php
+/config/addon.ini.php
-#ignore reports, should be generted with every build
+#ignore documentation, it should be newly built
+/doc/html
+
+#ignore reports, should be generated with every build
report/
#ignore config files from eclipse, we don't want IDE files in our repository
@@ -61,5 +63,6 @@ venv/
#ignore config files from JetBrains
/.idea
-#ignore addons/ directory
-addons/
+#ignore addons directory
+/addons
+/addon
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
index 6e7ac1c2e0..6d133a0b4a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,6 +1,6 @@
---
language: php
-## Friendica supports PHP version >= 5.6
+## Friendica supports PHP version >= 5.6.1
php:
- 5.6
- 7.0
@@ -17,7 +17,9 @@ env:
install:
- composer install
before_script:
+ - cp config/local-sample.ini.php config/local.ini.php
- mysql -e 'CREATE DATABASE IF NOT EXISTS test;'
- mysql -utravis test < database.sql
- echo "extension=redis.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
- echo "extension=memcached.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
+
diff --git a/INSTALL.txt b/INSTALL.txt
index 4345fcab1b..705eb8fed2 100644
--- a/INSTALL.txt
+++ b/INSTALL.txt
@@ -32,7 +32,7 @@ link if your cert is self-signed).
- Apache with mod-rewrite enabled and "Options All" so you can use a
local .htaccess file
- - PHP 5.6+ (PHP 7 recommended for performance).
+ - PHP 5.6.1+ (PHP 7 recommended for performance).
- PHP *command line* access with register_argc_argv set to true in the
php.ini file [or see 'poormancron' in section 8]
@@ -85,7 +85,7 @@ Clone the addon repository (separately):
git clone https://github.com/friendica/friendica-addons.git -b master addon
-If you copy the directory tree to your webserver, make sure that you also
+If you copy the directory tree to your webserver, make sure that you also
copy .htaccess - as "dot" files are often hidden and aren't normally copied.
If you want to use the development version of Friendica you can switch to
@@ -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 664 config/local.ini.php
Retry the installation. As soon as the database has been created,
******* this is important *********
-% chmod 755 .htconfig.php
+% chmod 644 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/bin/auth_ejabberd.php b/bin/auth_ejabberd.php
index 06d8488df8..7ad28c96f5 100755
--- a/bin/auth_ejabberd.php
+++ b/bin/auth_ejabberd.php
@@ -33,8 +33,6 @@
*/
use Friendica\App;
-use Friendica\BaseObject;
-use Friendica\Core\Config;
use Friendica\Util\ExAuth;
if (sizeof($_SERVER["argv"]) == 0) {
@@ -55,12 +53,8 @@ require_once "boot.php";
require_once "include/dba.php";
$a = new App(dirname(__DIR__));
-BaseObject::setApp($a);
-@include ".htconfig.php";
-dba::connect($db_host, $db_user, $db_pass, $db_data);
-unset($db_host, $db_user, $db_pass, $db_data);
-
-$oAuth = new ExAuth();
-
-$oAuth->readStdin();
+if ($a->mode === App::MODE_NORMAL) {
+ $oAuth = new ExAuth();
+ $oAuth->readStdin();
+}
\ No newline at end of file
diff --git a/bin/daemon.php b/bin/daemon.php
index 1abb701462..65ae2a53b6 100755
--- a/bin/daemon.php
+++ b/bin/daemon.php
@@ -8,7 +8,6 @@
*/
use Friendica\App;
-use Friendica\BaseObject;
use Friendica\Core\Config;
use Friendica\Core\Worker;
@@ -28,18 +27,21 @@ require_once "boot.php";
require_once "include/dba.php";
$a = new App(dirname(__DIR__));
-BaseObject::setApp($a);
-require_once ".htconfig.php";
-dba::connect($db_host, $db_user, $db_pass, $db_data);
+if ($a->isInstallMode()) {
+ die("Friendica isn't properly installed yet.\n");
+}
Config::load();
-if (!isset($pidfile)) {
- die('Please specify a pid file in the variable $pidfile in the .htconfig.php. For example:'."\n".
- '$pidfile = "/path/to/daemon.pid";'."\n");
+if (empty(Config::get('system', 'pidfile'))) {
+ die('Please set system.pidfile in config/local.ini.php. For example:'."\n".
+ '[system]'."\n".
+ 'pidfile = /path/to/daemon.pid'."\n");
}
+$pidfile = Config::get('system', 'pidfile');
+
if (in_array("start", $_SERVER["argv"])) {
$mode = "start";
}
@@ -127,11 +129,9 @@ if (!$foreground) {
file_put_contents($pidfile, $pid);
// We lose the database connection upon forking
- dba::connect($db_host, $db_user, $db_pass, $db_data);
+ $a->loadDatabase();
}
-unset($db_host, $db_user, $db_pass, $db_data);
-
Config::set('system', 'worker_daemon_mode', true);
// Just to be sure that this script really runs endlessly
diff --git a/bin/dev/friendica-to-smarty-tpl.py b/bin/dev/friendica-to-smarty-tpl.py
index 8149051cae..017b8b77ae 100755
--- a/bin/dev/friendica-to-smarty-tpl.py
+++ b/bin/dev/friendica-to-smarty-tpl.py
@@ -83,7 +83,7 @@ def fix_element(element):
element += ldelim + parts[first+1].rstrip('}') + rdelim
else:
# This takes care of elements where the filename is a path, e.g. {{ inc file.tpl }}
- element += parts[first+1].rstrip('}')
+ element += parts[first+1].rstrip('}')
element += '"'
@@ -205,7 +205,7 @@ try:
except getopt.GetoptError:
help(sys.argv[0])
sys.exit(2)
-
+
if path == '':
path = raw_input('Path to template folder to convert: ')
@@ -220,7 +220,7 @@ if not os.path.exists(outpath):
files = os.listdir(path)
for a_file in files:
- if a_file == 'htconfig.tpl':
+ if a_file == 'local.ini.tpl':
php_tpl = True
else:
php_tpl = False
diff --git a/bin/worker.php b/bin/worker.php
index 44980961cf..2abfa0ad92 100755
--- a/bin/worker.php
+++ b/bin/worker.php
@@ -24,14 +24,8 @@ if (!file_exists("boot.php") && (sizeof($_SERVER["argv"]) != 0)) {
}
require_once "boot.php";
-require_once "include/dba.php";
$a = new App(dirname(__DIR__));
-BaseObject::setApp($a);
-
-require_once ".htconfig.php";
-dba::connect($db_host, $db_user, $db_pass, $db_data);
-unset($db_host, $db_user, $db_pass, $db_data);
Config::load();
diff --git a/boot.php b/boot.php
index ae33f7c414..8f25c2b931 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.
@@ -509,14 +508,7 @@ if (!defined('CURLE_OPERATION_TIMEDOUT')) {
*/
function get_app()
{
- global $a;
-
- if (empty($a)) {
- $a = new App(dirname(__DIR__));
- BaseObject::setApp($a);
- }
-
- return $a;
+ return BaseObject::getApp();
}
/**
@@ -782,7 +774,7 @@ function run_update_function($x)
/**
* @brief Synchronise addons:
*
- * $a->config['system']['addon'] contains a comma-separated list of names
+ * system.addon contains a comma-separated list of names
* of addons which are used on this system.
* Go through the database list of already installed addons, and if we have
* an entry, but it isn't in the config list, call the uninstall procedure
@@ -965,17 +957,6 @@ function info($s)
}
}
-/**
- * @brief Wrapper around config to limit the text length of an incoming message
- *
- * @return int
- */
-function get_max_import_size()
-{
- $a = get_app();
- return (x($a->config, 'max_import_size') ? $a->config['max_import_size'] : 0);
-}
-
function feed_birthday($uid, $tz)
{
/**
@@ -1031,14 +1012,11 @@ function is_site_admin()
{
$a = get_app();
- $adminlist = explode(",", str_replace(" ", "", $a->config['admin_email']));
+ $admin_email = Config::get('config', 'admin_email');
- //if(local_user() && x($a->user,'email') && x($a->config,'admin_email') && ($a->user['email'] === $a->config['admin_email']))
- /// @TODO This if() + 2 returns can be shrinked into one return
- if (local_user() && x($a->user, 'email') && x($a->config, 'admin_email') && in_array($a->user['email'], $adminlist)) {
- return true;
- }
- return false;
+ $adminlist = explode(',', str_replace(' ', '', $admin_email));
+
+ return local_user() && $admin_email && in_array(defaults($a->user, 'email', ''), $adminlist);
}
/**
diff --git a/composer.json b/composer.json
index 941464e70c..9ef0dcd101 100644
--- a/composer.json
+++ b/composer.json
@@ -13,7 +13,7 @@
"issues": "https://github.com/friendica/friendica/issues"
},
"require": {
- "php": ">5.6",
+ "php": ">=5.6.1",
"ext-xml": "*",
"asika/simple-console": "^1.0",
"divineomega/password_exposed": "^2.4",
diff --git a/composer.lock b/composer.lock
index 7ba8fc1cfd..5ba2709835 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
- "content-hash": "4fcae78061a3eb72f91e4fa81e53af56",
+ "content-hash": "9e24971ae9340c5d9d4d4ca477d4ec29",
"packages": [
{
"name": "asika/simple-console",
@@ -3582,7 +3582,7 @@
"prefer-stable": false,
"prefer-lowest": false,
"platform": {
- "php": ">5.6",
+ "php": ">=5.6.1",
"ext-xml": "*"
},
"platform-dev": []
diff --git a/config/addon-sample.ini.php b/config/addon-sample.ini.php
new file mode 100644
index 0000000000..7d8054cd2a
--- /dev/null
+++ b/config/addon-sample.ini.php
@@ -0,0 +1,10 @@
+
+table.config {
+ margin: 1em 0;
+ background-color: #f9f9f9;
+ border: 1px solid #aaa;
+ border-collapse: collapse;
+ color: #000;
+ width: 100%;
+}
+
+table.config > tr > th,
+table.config > tr > td,
+table.config > * > tr > th,
+table.config > * > tr > td {
+ border: 1px solid #aaa;
+ padding: 0.2em 0.4em
+}
+
+table.config > tr > th,
+table.config > * > tr > th {
+ background-color: #f2f2f2;
+ text-align: center;
+ width: 50%
+}
+
+
+
+
+
+ .htconfig.php
+ config/local.ini.php
+
+
+
+
+
+$db_host = 'localhost';
+$db_user = 'mysqlusername';
+$db_pass = 'mysqlpassword';
+$db_data = 'mysqldatabasename';
+$a->config["system"]["db_charset"] = 'utf8mb4';
+
+
+[database]
+hostname = localhost
+username = mysqlusername
+password = mysqlpassword
+database = mysqldatabasename
+charset = utf8mb4
+
+
+
+
+
+$a->config["section"]["key"] = "value";
+
+
+[section]
+key = value
+
+
+
+
+
+$a->config["section"]["key"] = array(
+ "value1",
+ "value2",
+ "value3"
+);
+
+
+[section]
+key[] = value1
+key[] = value2
+key[] = value3
+
+
+
+
+
+$a->config["key"] = "value";
+
+
+[config]
+key = value
+
+
+
+
+
+$a->path = "value";
+
+
+[system]
+urlpath = value
+
+
+
+
+
+$default_timezone = "value";
+
+
+[system]
+default_timezone = value
+
+
+
+
+
+$pidfile = "value";
+
+
+[system]
+pidfile = value
+
+
+
+
+
+$lang = "value";
+
+
+[system]
+language = value
+
+
+
+
+
+
+
+### Database Settings
+
+The configuration variables database.hostname, database.username, database.password, database.database and database.charset are holding your credentials for the database connection.
+If you need to specify a port to access the database, you can do so by appending ":portnumber" to the database.hostname variable.
+
+ [database]
+ hostname = your.mysqlhost.com:123456
+
+If all of the following environment variables are set, Friendica will use them instead of the previously configured variables for the db:
+
+ MYSQL_HOST
+ MYSQL_PORT
+ MYSQL_USERNAME
+ MYSQL_PASSWORD
+ MYSQL_DATABASE
+
+## Config values that can only be set in config/local.ini.php
+
+There are some config values that haven't found their way into the administration page.
+This has several reasons.
+Maybe they are part of a current development that isn't considered stable and will be added later in the administration page when it is considered safe.
+Or it triggers something that isn't expected to be of public interest.
+Or it is for testing purposes only.
+
+**Attention:** Please be warned that you shouldn't use one of these values without the knowledge what it could trigger.
+Especially don't do that with undocumented values.
+
+These configurations keys and their default value are listed in `config/config.ini.php` and should be ovewritten in `config/local.ini.php`.
+
+## Administrator Options
+
+Enabling the admin panel for an account, and thus making the account holder admin of the node, is done by setting the variable
+
+ [config]
+ admin_email = someone@example.com
+
+Where you have to match the email address used for the account with the one you enter to the config/local.ini.php file.
+If more then one account should be able to access the admin panel, separate the email addresses with a comma.
+
+ [config]
+ admin_email = someone@example.com,someoneelse@example.com
+
+If you want to have a more personalized closing line for the notification emails you can set a variable for the admin_name.
+
+ [config]
+ admin_name = Marvin
diff --git a/doc/FAQ.md b/doc/FAQ.md
index 31d980a9a1..1b84b5cd80 100644
--- a/doc/FAQ.md
+++ b/doc/FAQ.md
@@ -197,14 +197,14 @@ If you are searching for new themes, you can find them at [Friendica-Themes.com]
### I've changed my email address now the admin panel is gone?
-Have a look into your .htconfig.php and fix your email address there.
+Have a look into your config/local.ini.php and fix your email address there.
### Can there be more then one admin for a node?
Yes.
You just have to list more then one email address in the
-.htconfig.php file.
+config/local.ini.php file.
The listed emails need to be separated by a comma.
diff --git a/doc/Home.md b/doc/Home.md
index 0a41a46146..a353bab0d3 100644
--- a/doc/Home.md
+++ b/doc/Home.md
@@ -32,7 +32,7 @@ Friendica Documentation and Resources
* [Installing Connectors (Twitter/GNU Social)](help/Installing-Connectors)
* [Install an ejabberd server (XMPP chat) with synchronized credentials](help/install-ejabberd)
* [Using SSL with Friendica](help/SSL)
-* [Config values that can only be set in .htconfig.php](help/htconfig)
+* [Config values that can only be set in config/local.ini.php](help/Config)
* [Improve Performance](help/Improve-Performance)
* [Administration Tools](help/tools)
diff --git a/doc/Install.md b/doc/Install.md
index 3574780961..6eb249a812 100644
--- a/doc/Install.md
+++ b/doc/Install.md
@@ -27,7 +27,7 @@ Requirements
---
* Apache with mod-rewrite enabled and "Options All" so you can use a local .htaccess file
-* PHP 5.6+ (PHP 7 is recommended for performance)
+* PHP 5.6.1+ (PHP 7 is recommended for performance)
* PHP *command line* access with register_argc_argv set to true in the php.ini file
* Curl, GD, PDO, MySQLi, hash, xml, zip and OpenSSL extensions
* The POSIX module of PHP needs to be activated (e.g. [RHEL, CentOS](http://www.bigsoft.co.uk/blog/index.php/2014/12/08/posix-php-commands-not-working-under-centos-7) have disabled it)
@@ -100,19 +100,20 @@ If you need to specify a port for the connection to the database, you can do so
*If* the manual installation fails for any reason, check the following:
-* Does ".htconfig.php" exist? If not, edit htconfig.php and change the system settings. Rename to .htconfig.php
-* Is the database is populated? If not, import the contents of "database.sql" with phpmyadmin or the mysql command line.
+* Does "config/local.ini.php" exist? If not, edit config/local-sample.ini.php and change the system settings.
+* Rename to `config/local.ini.php`.
+* Is the database is populated? If not, import the contents of `database.sql` with phpmyadmin or the mysql command line.
At this point visit your website again, and register your personal account.
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 tables, so that you can start fresh.
+You might wish to move/rename `config/local.ini.php` to another name and empty (called 'dropping') the database tables, so that you can start fresh.
### Option B: Run the automatic install script
Open the file htconfig.php in the main Friendica directory with a text editor.
Remove the `die('...');` line and edit the lines to suit your installation (MySQL, language, theme etc.).
-Then save the file (do not rename it).
+Then save the file (do not rename it).
Navigate to the main Friendica directory and execute the following command:
@@ -126,7 +127,7 @@ At this point visit your website again, and register your personal account.
*If* the automatic installation fails for any reason, check the following:
-* Does ".htconfig.php" already exist? If yes, the automatic installation won't start
+* Does "config/local.ini.php" already exist? If yes, the automatic installation won't start
* Are the settings inside "htconfig.php" correct? If not, edit the file again.
* Is the empty MySQL-database created? If not, create it.
@@ -162,5 +163,5 @@ 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 yourself 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.
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.
diff --git a/doc/Installing-Connectors.md b/doc/Installing-Connectors.md
index 5ea34d4733..f1eba5a6a0 100644
--- a/doc/Installing-Connectors.md
+++ b/doc/Installing-Connectors.md
@@ -4,7 +4,7 @@ Installing Connectors (Twitter/GNU Social)
* [Home](help)
-Friendica uses addons to provide connectivity to some networks, such as Twitter or App.net.
+Friendica uses addons to provide connectivity to some networks, such as Twitter.
There is also a addon to post through to an existing account on a GNU Social service.
You only need this to post to an already existing GNU Social account, but not to communicate with GNU Social members in general.
@@ -19,7 +19,7 @@ Addons must be installed by the site administrator before they can be used.
This is accomplished through the site administration panel.
Each of the connectors also requires an "API key" from the service you wish to connect with.
-Some addons allow you to enter this information in the site administration pages, while others may require you to edit your configuration file (.htconfig.php).
+Some addons allow you to enter this information in the site administration pages, while others may require you to edit your configuration file (config/local.ini.php).
The ways to obtain these keys vary between the services, but they all require an existing account on the target service.
Once installed, these API keys can usually be shared by all site members.
@@ -39,10 +39,11 @@ You can get it from [Twitter](https://twitter.com/apps).
Register your Friendica site as "Client" application with "Read & Write" access.
We do not need "Twitter as login".
When you've registered the app you get a key pair with an OAuth Consumer key and a secret key for your application/site.
-Add this key pair to your global .htconfig.php:
+Add this key pair to your config/local.ini.php:
- $a->config['twitter']['consumerkey'] = 'your consumer_key here';
- $a->config['twitter']['consumersecret'] = 'your consumer_secret here';
+ [twitter]
+ consumerkey = your consumer_key here
+ consumersecret = your consumer_secret here
After this, your users can configure their Twitter account settings from "Settings -> Connector Settings".
@@ -67,8 +68,8 @@ When the addon is activated the user has to acquire the following in order to co
To get the OAuth Consumer key pair the user has to
-1 ask her Friendica admin if a pair already exists or
-2 has to register the Friendica server as a client application on the GNU Social server.
+1 ask her Friendica admin if a pair already exists or
+2 has to register the Friendica server as a client application on the GNU Social server.
This can be done from the account settings under "Settings -> Connections -> Register an OAuth client application -> Register a new application" on the GNU Social server.
@@ -83,6 +84,6 @@ During the registration of the OAuth client remember the following:
After the required credentials for the application are stored in the configuration you have to actually connect your Friendica account with GNU Social.
This is done from the Settings -> Connector Settings page.
Follow the Sign in with GNU Social button, allow access and then copy the security code into the box provided.
-Friendica will then try to acquire the final OAuth credentials from the API.
+Friendica will then try to acquire the final OAuth credentials from the API.
If successful, the addon settings will allow you to select to post your public messages to your GNU Social account (have a look behind the little lock symbol beneath the status "editor" on your Home or Network pages).
diff --git a/doc/Settings.md b/doc/Settings.md
index 04a9b9699a..dda2a9a587 100644
--- a/doc/Settings.md
+++ b/doc/Settings.md
@@ -69,7 +69,7 @@ You can chose between the following modes:
##### Invitation based registry
Additionally to the setting in the admin panel, you can devide if registrations are only possible using an invitation code or not.
-To enable invitation based registration, you have to set the `invitation_only` setting in the [.htconfig.php](/help/htconfig) file.
+To enable invitation based registration, you have to set the `invitation_only` setting in the [config/local.ini.php](/help/Config) file.
If you want to use this method, the registration policy has to be set to either *open* or *requires approval*.
#### Check Full Names
@@ -325,7 +325,7 @@ You should set up some kind of [log rotation](https://en.wikipedia.org/wiki/Log_
**Known Issues**: The filename ``friendica.log`` can cause problems depending on your server configuration (see [issue 2209](https://github.com/friendica/friendica/issues/2209)).
By default PHP warnings and error messages are supressed.
-If you want to enable those, you have to activate them in the ``.htconfig.php`` file.
+If you want to enable those, you have to activate them in the ``config/local.ini.php`` file.
Use the following settings to redirect PHP errors to a file.
Config:
@@ -373,24 +373,27 @@ By default this will be the one account you create during the installation proce
But you can expand the list of email addresses by any used email address you want.
Registration of new accounts with a listed email address is not possible.
- $a->config['admin_email'] = 'you@example.com, buddy@example.com';
+ [config]
+ admin_email = you@example.com, buddy@example.com
## PHP Path
Some of Friendicas processes are running in the background.
For this you need to specify the path to the PHP binary to be used.
- $a->config['php_path'] = '{{$phpath}}';
+ [config]
+ php_path = {{$phpath}}
## Subdirectory configuration
It is possible to install Friendica into a subdirectory of your webserver.
-We strongly discurage you from doing so, as this will break federation to other networks (e.g. Diaspora, GNU Socia, Hubzilla)
+We strongly discourage you from doing so, as this will break federation to other networks (e.g. Diaspora, GNU Socia, Hubzilla)
Say you have a subdirectory for tests and put Friendica into a further subdirectory, the config would be:
- $a->path = 'tests/friendica';
+ [system]
+ urlpath = tests/friendica
## Other exceptions
-Furthermore there are some experimental settings, you can read-up in the [Config values that can only be set in .htconfig.php](help/htconfig) section of the documentation.
+Furthermore there are some experimental settings, you can read-up in the [Config values that can only be set in config/local.ini.php](help/Config) section of the documentation.
diff --git a/doc/Update.md b/doc/Update.md
index 9e9324da94..835dd3375d 100644
--- a/doc/Update.md
+++ b/doc/Update.md
@@ -7,7 +7,7 @@ Updating Friendica
If you installed Friendica in the ``path/to/friendica`` folder:
1. Unpack the new Friendica archive in ``path/to/friendica_new``.
-2. Copy ``.htconfig.php``, ``photo/`` and ``proxy/`` from ``path/to/friendica`` to ``path/to/friendica_new``.
+2. Copy ``config/local.ini.php``, ``photo/`` and ``proxy/`` from ``path/to/friendica`` to ``path/to/friendica_new``.
3. Rename the ``path/to/friendica`` folder to ``path/to/friendica_old``.
4. Rename the ``path/to/friendica_new`` folder to ``path/to/friendica``.
5. Check your site. Note: it may go into maintenance mode to update the database schema.
diff --git a/doc/Vagrant.md b/doc/Vagrant.md
index a224ebafc2..6fd74240d9 100644
--- a/doc/Vagrant.md
+++ b/doc/Vagrant.md
@@ -42,7 +42,7 @@ This will not delete the virtual machine.
9. To ultimately delete the virtual machine run
$> vagrant destroy
- $> rm /vagrant/.htconfig.php
+ $> rm /vagrant/config/local.ini.php
to make sure that you can start from scratch with another "vagrant up".
@@ -53,6 +53,6 @@ You will then have the following accounts to login:
* friendica1, password friendica1
* friendica2, password friendica2 and so on until friendica5
* friendica1 is connected to all others. friendica1 has two groups: group1 with friendica2 and friendica4, group2 with friendica3 and friendica5.
- * friendica2 and friendica3 are conntected. friendica4 and friendica5 are connected.
+ * friendica2 and friendica3 are conntected. friendica4 and friendica5 are connected.
For further documentation of vagrant, please see [the vagrant*docs*](https://docs.vagrantup.com/v2/).
diff --git a/doc/de/FAQ.md b/doc/de/FAQ.md
index b52aa3d396..6baa5c5f5e 100644
--- a/doc/de/FAQ.md
+++ b/doc/de/FAQ.md
@@ -85,9 +85,9 @@ Zum Konvertieren von Videos in das lizenfreie Videoformat WebM gibt es unter Win
### Ist es möglich, bei mehreren Profilen verschiedene Avatare (Nutzerbilder) zu haben?
Ja.
-Auf Deiner ["Profile verwalten/editieren"-Seite](../profiles) wählst Du zunächst das gewünschte Profil aus.
-Anschließend siehst Du eine Seite mit allen Infos zu diesem Profil.
-Klicke nun oben auf den Link "Profilbild ändern" und lade im nächsten Fenster ein Bild von Deinem PC hoch.
+Auf Deiner ["Profile verwalten/editieren"-Seite](../profiles) wählst Du zunächst das gewünschte Profil aus.
+Anschließend siehst Du eine Seite mit allen Infos zu diesem Profil.
+Klicke nun oben auf den Link "Profilbild ändern" und lade im nächsten Fenster ein Bild von Deinem PC hoch.
Um Deine privaten Daten zu schützen, wird in Beiträgen nur das Bild aus Deinem öffentlichen Profil angezeigt.
@@ -180,7 +180,7 @@ Hier ist eine Liste von Clients bei denen dies möglich ist, bzw. die speziell f
### Wo finde ich Hilfe?
-Wenn Du Probleme mit Deiner Friendica-Seite hast, dann kannst Du die Community in der [Friendica-Support-Gruppe](https://forum.friendi.ca/profile/helpers) oder im [deutschen Friendica-Support-Forum](http://toktan.org/profile/wiki) fragen oder Dir das [deutsche Wiki](http://wiki.toktan.org/doku.php) anschauen.
+Wenn Du Probleme mit Deiner Friendica-Seite hast, dann kannst Du die Community in der [Friendica-Support-Gruppe](https://forum.friendi.ca/profile/helpers) oder im [deutschen Friendica-Support-Forum](http://toktan.org/profile/wiki) fragen oder Dir das [deutsche Wiki](http://wiki.toktan.org/doku.php) anschauen.
Wenn Du Deinen Account nicht nutzen kannst, kannst Du entweder einen [Testaccount](https://tryfriendica.de) bzw. einen Account auf einer öffentlichen Seite ([Liste](https://dir.friendica.social/servers)) nutzen.
Wenn du dir keinen weiteren Friendica Account einrichten willst, kannst du auch gerne über einen der folgenden alternativen Kanäle Hilfe suchen:
@@ -199,7 +199,7 @@ Admin
Ja, das ist möglich.
Es ist allerdings nicht möglich, eine Datenbank durch zwei Domains zu nutzen.
-Solange Du Deine .htconfig.php allerdings so einrichtest, dass das System nicht versucht, eine Installation durchzuführen, kannst Du die richtige Config-Datei in include/$hostname/.htconfig.php hinterlegen.
+Solange Du Deine config/local.ini.php allerdings so einrichtest, dass das System nicht versucht, eine Installation durchzuführen, kannst Du die richtige Config-Datei in include/$hostname/config/local.ini.php hinterlegen.
Alle Cache-Aspekte und der Zugriffsschutz können pro Instanz konfiguriert werden.
@@ -216,13 +216,13 @@ Wenn Du neue Themen suchst, findest Du sie auf [Friendica-Themes.com](http://fri
### Ich habe meine E-Mail Adresse geändern und jetzt ist das Admin Panel verschwunden?
-Bitte aktualisiere deine E-Mail Adresse in der .htconfig.php Datei.
+Bitte aktualisiere deine E-Mail Adresse in der config/local.ini.php Datei.
### Kann es mehr als einen Admin auf einer Friendica Instanz geben?
Ja.
-Du kannst in der .htconfig.php Datei mehrere E-Mail Adressen auflisten.
+Du kannst in der config/local.ini.php Datei mehrere E-Mail Adressen auflisten.
Die aufgelisteten Adressen werden mit Kommata von einander getrennt.
diff --git a/doc/de/Home.md b/doc/de/Home.md
index 31cce7aea4..b6a07cc09a 100644
--- a/doc/de/Home.md
+++ b/doc/de/Home.md
@@ -34,7 +34,7 @@ Friendica - Dokumentation und Ressourcen
* [Konnektoren (Connectors) installieren (Twitter/GNU Social)](help/Installing-Connectors)
* [Installation eines ejabberd Servers (XMPP-Chat) mit synchronisierten Anmeldedaten](help/install-ejabberd) (EN)
* [Betreibe deine Seite mit einem SSL-Zertifikat](help/SSL)
-* [Konfigurationswerte, die nur in der .htconfig.php gesetzt werden können](help/htconfig) (EN)
+* [Konfigurationswerte, die nur in der config/local.ini.php gesetzt werden können](help/Config) (EN)
* [Performance verbessern](help/Improve-Performance)
* [Administration Werkzeuge](help/tools) (EN)
diff --git a/doc/de/Install.md b/doc/de/Install.md
index f324da68e0..84941d9282 100644
--- a/doc/de/Install.md
+++ b/doc/de/Install.md
@@ -28,7 +28,7 @@ Requirements
---
* Apache mit einer aktiverten mod-rewrite-Funktion und dem Eintrag "Options All", so dass du die lokale .htaccess-Datei nutzen kannst
-* PHP 5.6+ (PHP 7 ist aufgrund der Performance empfohlen)
+* PHP 5.6.1+ (PHP 7 ist aufgrund der Performance empfohlen)
* PHP *Kommandozeilen*-Zugang mit register_argc_argv auf "true" gesetzt in der php.ini-Datei
* Curl, GD, PDO, MySQLi, xml, zip und OpenSSL-Erweiterung
* Das POSIX Modul muss aktiviert sein ([CentOS, RHEL](http://www.bigsoft.co.uk/blog/index.php/2014/12/08/posix-php-commands-not-working-under-centos-7http://www.bigsoft.co.uk/blog/index.php/2014/12/08/posix-php-commands-not-working-under-centos-7) haben dies z.B. deaktiviert)
@@ -56,7 +56,7 @@ Stelle sicher, dass der Ordner *view/smarty3* existiert and von dem Webserver-Be
mkdir view/smarty3
chmod 775 view/smarty3
-Falls Addons installiert werden sollen: Gehe in den Friendica-Ordner
+Falls Addons installiert werden sollen: Gehe in den Friendica-Ordner
cd mywebsite
@@ -98,19 +98,19 @@ Starte MySQL dann neu und es sollte klappen.
### Option A: Der manuelle Installer
-Besuche deine Webseite mit deinem Browser und befolge die Anleitung.
+Besuche deine Webseite mit deinem Browser und befolge die Anleitung.
Bitte beachte jeden Fehler und korrigiere diese, bevor du fortfährst.
Falls du einen Port für die Datenbankverbindung angeben musst, kannst du diesen in der Host-Eingabe Zeile angeben.
*Wenn* die manuelle Installation aus irgendeinem Grund fehlschlägt, dann prüfe das Folgende:
-* ".htconfig.php" existiert ... wenn nicht, bearbeite die „htconfig.php“ und ändere die Systemeinstellungen. Benenne sie um in „.htconfig.php".
+* "config/local.ini.php" existiert ... wenn nicht, bearbeite die „config/local-sample.ini.php“ und ändere die Systemeinstellungen. Benenne sie um in „config/local.ini.php".
* die Datenbank beinhaltet Daten. ... wenn nicht, importiere den Inhalt der Datei "database.sql" mit phpmyadmin oder per mysql-Kommandozeile.
Besuche deine Seite an diesem Punkt wieder und registriere deinen persönlichen Account.
Alle Registrierungsprobleme sollten automatisch behebbar sein.
Wenn du irgendwelche **kritischen** Fehler zu diesen Zeitpunkt erhalten solltest, deutet das darauf hin, dass die Datenbank nicht korrekt installiert wurde.
-Du kannst bei Bedarf die Datei .htconfig.php verschieben/umbenennen und die Datenbank leeren (als „Dropping“ bezeichnet), so dass du mit einem sauberen System neu starten kannst.
+Du kannst bei Bedarf die Datei config/local.ini.php verschieben/umbenennen und die Datenbank leeren (als „Dropping“ bezeichnet), so dass du mit einem sauberen System neu starten kannst.
### Option B: Starte das manuelle Installationsscript
@@ -127,8 +127,8 @@ Oder falls du alle optionalen Checks ausfürehn lassen möchtest, benutze diese
bin/console autoinstall -a
*Wenn* die automatisierte Installation aus irgendeinem Grund fehlschlägt, dann prüfe das Folgende:
-* Existiert die `.htconfig.php`? Falls ja, wird die automatisierte Installation nicht gestartet.
-* Sind Einstellungen in der `.htconfig.php` korrekt? Falls nicht, bitte bearbeite diese Datei erneut.
+* Existiert die `config/local.ini.php`? Falls ja, wird die automatisierte Installation nicht gestartet.
+* Sind Einstellungen in der `config/local.ini.php` korrekt? Falls nicht, bitte bearbeite diese Datei erneut.
* Ist die leere MySQL-Datenbank erstellt? Falls nicht, erstelle diese.
Für mehr Informationen kannst du diese Option verwenden:
@@ -137,7 +137,7 @@ Für mehr Informationen kannst du diese Option verwenden:
### Einen Worker einrichten
-Erstelle einen Cron job oder einen regelmäßigen Task, um den Poller alle 5-10 Minuten im Hintergrund ablaufen zu lassen.
+Erstelle einen Cron job oder einen regelmäßigen Task, um den Poller alle 5-10 Minuten im Hintergrund ablaufen zu lassen.
Beispiel:
cd /base/directory; /path/to/php bin/worker.php
@@ -160,5 +160,5 @@ Es werden schlimme Dinge geschehen.
Sei es nun ein Hardwareversagen oder eine kaputte Datenbank.
Deshalb solltest du dir, nachdem die Installation deines Friendica Knotens abgeschlossen ist, einen Backup Plan erstellen.
-Die wichtigste Datei ist die `.htconfig.php` im Stammverzeichnis deiner Friendica Installation.
+Die wichtigste Datei ist die `config/local.ini.php` im Stammverzeichnis deiner Friendica Installation.
Und da alle Daten in der Datenbank gespeichert werden, solltest du einen nicht all zu alten Dump der Friendica Datenbank zur Hand haben, solltest du deinen Knoten wieder herstellen müssen.
diff --git a/doc/de/Installing-Connectors.md b/doc/de/Installing-Connectors.md
index f9fe5b0f72..3fa46ab5a4 100644
--- a/doc/de/Installing-Connectors.md
+++ b/doc/de/Installing-Connectors.md
@@ -1,25 +1,25 @@
-Konnektoren installieren (Twitter/GNU Social)
+Konnektoren installieren (Twitter/GNU Social)
==================================================
* [Zur Startseite der Hilfe](help)
Friendica nutzt Erweiterung, um die Verbindung zu anderen Netzwerken wie Twitter oder App.net zu gewährleisten.
-Es gibt außerdem ein Erweiterung, um über einen bestehenden GNU Social-Account diesen Service zu nutzen.
-Du brauchst dieses Erweiterung aber nicht, um mit GNU Social-Mitgliedern von Friendica aus zu kommunizieren - es sei denn, du wünschst es, über einen existierenden Account einen Beitrag zu schreiben.
+Es gibt außerdem ein Erweiterung, um über einen bestehenden GNU Social-Account diesen Service zu nutzen.
+Du brauchst dieses Erweiterung aber nicht, um mit GNU Social-Mitgliedern von Friendica aus zu kommunizieren - es sei denn, du wünschst es, über einen existierenden Account einen Beitrag zu schreiben.
-Alle drei Erweiterung benötigen einen Account im gewünschten Netzwerk.
+Alle drei Erweiterung benötigen einen Account im gewünschten Netzwerk.
Zusätzlich musst du (bzw. der Administrator der Seite) einen API-Schlüssel holen, um einen authentifizierten Zugriff zu deinem Friendica-Server herstellen zu lassen.
**Seitenkonfiguration**
-Erweiterung müssen vom Administrator installiert werden, bevor sie genutzt werden können.
+Erweiterung müssen vom Administrator installiert werden, bevor sie genutzt werden können.
Dieses kann über das Administrationsmenü erstellt werden.
-Jeder der Konnektoren benötigt zudem einen API-Schlüssel vom Service, der verbunden werden soll.
-Einige Erweiterung erlaube es, diese Informationen auf den Administrationsseiten einzustellen, wohingegen andere eine direkte Bearbeitung der Konfigurationsdatei ".htconfig.php" erfordern.
-Der Weg, um diese Schlüssel zu erhalten, variiert stark, jedoch brauchen fast alle einen bestehenden Account im gewünschten Service.
+Jeder der Konnektoren benötigt zudem einen API-Schlüssel vom Service, der verbunden werden soll.
+Einige Erweiterung erlaube es, diese Informationen auf den Administrationsseiten einzustellen, wohingegen andere eine direkte Bearbeitung der Konfigurationsdatei "config/local.ini.php" erfordern.
+Der Weg, um diese Schlüssel zu erhalten, variiert stark, jedoch brauchen fast alle einen bestehenden Account im gewünschten Service.
Einmal installiert, können diese Schlüssel von allen Seitennutzern genutzt werden.
Im Folgenden findest du die Einstellungen für die verschiedenen Services (viele dieser Informationen kommen direkt aus den Quelldateien der Erweiterung):
@@ -37,11 +37,12 @@ Um dieses Erweiterung zu nutzen, benötigst du einen OAuth Consumer-Schlüsselpa
Registriere deine Friendica-Seite als "Client"-Anwendung mit "Read&Write"-Zugriff. Wir benötigen "Twitter als Login" nicht. Sobald du deine Anwendung installiert hast, erhältst du das Schlüsselpaar für deine Seite.
-Trage dieses Schlüsselpaar in deine globale ".htconfig.php"-Datei ein.
+Trage dieses Schlüsselpaar in deine globale "config/local.ini.php"-Datei ein.
```
-$a->config['twitter']['consumerkey'] = 'your consumer_key here';
-$a->config['twitter']['consumersecret'] = 'your consumer_secret here';
+[twitter]
+consumerkey = your consumer_key here
+consumersecret = your consumer_secret here
```
Anschließend kann der Nutzer deiner Seite die Twitter-Einstellungen selbst eintragen: "Einstellungen -> Connector Einstellungen".
@@ -63,10 +64,10 @@ Wenn das Addon aktiv ist, muss der Nutzer die folgenden Einstellungen vornehmen,
Um das OAuth-Schlüsselpaar zu erhalten, muss der Nutzer
-(a) seinen Friendica-Admin fragen, ob bereits ein Schlüsselpaar existiert oder
+(a) seinen Friendica-Admin fragen, ob bereits ein Schlüsselpaar existiert oder
(b) einen Friendica-Server als Anwendung auf dem GNU Social-Server anmelden.
-Dies kann über Einstellungen --> Connections --> "Register an OAuth client application" -> "Register a new application" auf dem GNU Social-Server durchgeführt werden.
+Dies kann über Einstellungen --> Connections --> "Register an OAuth client application" -> "Register a new application" auf dem GNU Social-Server durchgeführt werden.
Während der Registrierung des OAuth-Clients ist Folgendes zu beachten:
@@ -76,9 +77,9 @@ Während der Registrierung des OAuth-Clients ist Folgendes zu beachten:
* stelle Lese- und Schreibrechte ein
* die Quell-URL sollte die URL deines Friendica-Servers sein
-Sobald die benötigten Daten gespeichert sind, musst du deinen Friendica-Account mit GNU Social verbinden.
-Das kannst du über Einstellungen --> Connector-Einstellungen durchführen.
-Folge dem "Einloggen mit GNU Social"-Button, erlaube den Zugriff und kopiere den Sicherheitscode in die entsprechende Box.
+Sobald die benötigten Daten gespeichert sind, musst du deinen Friendica-Account mit GNU Social verbinden.
+Das kannst du über Einstellungen --> Connector-Einstellungen durchführen.
+Folge dem "Einloggen mit GNU Social"-Button, erlaube den Zugriff und kopiere den Sicherheitscode in die entsprechende Box.
Friendica wird dann versuchen, die abschließende OAuth-Einstellungen über die API zu beziehen.
Wenn es geklappt hat, kannst du in den Einstellungen festlegen, ob deine öffentlichen Nachrichten automatisch in deinem GNU Social-Account erscheinen soll (achte hierbei auf das kleine Schloss-Symbol im Status-Editor)
diff --git a/doc/de/Settings.md b/doc/de/Settings.md
index 6365668729..4d84f873ff 100644
--- a/doc/de/Settings.md
+++ b/doc/de/Settings.md
@@ -8,8 +8,8 @@ Auf der Startseite des Admin Panels werden die Informationen zu der Instanz zusa
Die erste Zahl gibt die Anzahl von Nachrichten an, die nicht zugestellt werden konnten.
Die Zustellung wird zu einem späteren Zeitpunkt noch einmal versucht.
Unter dem Punkt "Warteschlange Inspizieren" kannst du einen schnellen Blick auf die zweite Warteschlange werfen.
-Die zweite Zahl steht für die Anzahl der Aufgaben, die die Worker noch vor sich haben.
-Die Worker arbeiten Hintergrundprozesse ab.
+Die zweite Zahl steht für die Anzahl der Aufgaben, die die Worker noch vor sich haben.
+Die Worker arbeiten Hintergrundprozesse ab.
Die Aufgaben der Worker sind priorisiert und werden anhand dieser Prioritäten abgearbeitet.
Desweiteren findest du eine Übersicht über die Accounts auf dem Friendica Knoten, die unter dem Punkt "Nutzer" moderiert werden können.
@@ -31,7 +31,7 @@ Da die meisten Konfigurationsoptionen einen Hilfstext im Admin Panel haben, kann
#### Banner/Logo
-Hiermit legst du das Banner der Seite fest. Standardmäßig ist das Friendica-Logo und der Name festgelegt.
+Hiermit legst du das Banner der Seite fest. Standardmäßig ist das Friendica-Logo und der Name festgelegt.
Du kannst hierfür HTML/CSS nutzen, um den Inhalt zu gestalten und/oder die Position zu ändern, wenn es nicht bereits voreingestellt ist.
#### Systensprache
@@ -63,33 +63,33 @@ Dabei kannst du zwischen den folgenden Optionen wählen:
* **Bedarf der Zustimmung**: Jeder kann ein Nutzerkonto anlegen. Dieses muss allerdings durch den Admin freigeschaltet werden, bevor es verwendet werden kann.
* **Geschlossen**: Es können keine weiteren Nutzerkonten angelegt werden.
-##### Einladungen
+##### Einladungen
Zusätzlich zu den oben genannten Möglichkeiten, kann die Registrierung eines neuen Nutzerkontos an eine Einladung durch einen bestehenden Nutzer gekoppelt werden.
-Hierzu muss in der [.htconfig.php](/help/htconfig) Datei die Option `invitation_only` aktiviert und als Registrierungsmethode entweder *Offen* oder *Bedarf der Zustimmung* gewählt werden.
+Hierzu muss in der [config/local.ini.php](/help/Config) Datei die Option `invitation_only` aktiviert und als Registrierungsmethode entweder *Offen* oder *Bedarf der Zustimmung* gewählt werden.
#### Namen auf Vollständigkeit überprüfen
-Es kann vorkommen, dass viele Spammer versuchen, sich auf deiner Seite zu registrieren.
-In Testphasen haben wir festgestellt, dass diese automatischen Registrierungen das Feld "Vollständiger Name" oft nur mit Namen ausfüllen, die kein Leerzeichen beinhalten.
-Wenn du Leuten erlauben willst, sich nur mit einem Namen anzumelden, dann setze die Einstellung auf "true".
+Es kann vorkommen, dass viele Spammer versuchen, sich auf deiner Seite zu registrieren.
+In Testphasen haben wir festgestellt, dass diese automatischen Registrierungen das Feld "Vollständiger Name" oft nur mit Namen ausfüllen, die kein Leerzeichen beinhalten.
+Wenn du Leuten erlauben willst, sich nur mit einem Namen anzumelden, dann setze die Einstellung auf "true".
Die Standardeinstellung ist auf "false" gesetzt.
-
+
#### OpenID Unterstützung
-Standardmäßig wird OpenID für die Registrierung und für Logins genutzt.
+Standardmäßig wird OpenID für die Registrierung und für Logins genutzt.
Wenn du nicht willst, dass OpenID-Strukturen für dein System übernommen werden, dann setze "no_openid" auf "true".
Standardmäßig ist hier "false" gesetzt.
#### Unterbinde Mehrfachregistrierung
-Um mehrfache Seiten zu erstellen, muss sich eine Person mehrfach registrieren können.
-Deine Seiteneinstellung kann Registrierungen komplett blockieren oder an Bedingungen knüpfen.
-Standardmäßig können eingeloggte Nutzer weitere Accounts für die Seitenerstellung registrieren.
-Hier ist weiterhin eine Bestätigung notwendig, wenn "REGISTER_APPROVE" ausgewählt ist.
-Wenn du die Erstellung weiterer Accounts blockieren willst, dann setze die Einstellung "block_extended_register" auf "true".
+Um mehrfache Seiten zu erstellen, muss sich eine Person mehrfach registrieren können.
+Deine Seiteneinstellung kann Registrierungen komplett blockieren oder an Bedingungen knüpfen.
+Standardmäßig können eingeloggte Nutzer weitere Accounts für die Seitenerstellung registrieren.
+Hier ist weiterhin eine Bestätigung notwendig, wenn "REGISTER_APPROVE" ausgewählt ist.
+Wenn du die Erstellung weiterer Accounts blockieren willst, dann setze die Einstellung "block_extended_register" auf "true".
Standardmäßig ist hier "false" gesetzt.
-
+
### Datei hochladen
#### Maximale Bildgröße
@@ -100,26 +100,26 @@ Maximale Bild-Dateigröße in Byte. Standardmäßig ist 0 gesetzt, was bedeutet,
#### URL des weltweiten Verzeichnisses
-Mit diesem Befehl wird die URL eingestellt, die zum Update des globalen Verzeichnisses genutzt wird.
-Dieser Befehl ist in der Standardkonfiguration enthalten.
-Der nicht dokumentierte Teil dieser Einstellung ist, dass das globale Verzeichnis gar nicht verfügbar ist, wenn diese Einstellung nicht gesetzt wird.
+Mit diesem Befehl wird die URL eingestellt, die zum Update des globalen Verzeichnisses genutzt wird.
+Dieser Befehl ist in der Standardkonfiguration enthalten.
+Der nicht dokumentierte Teil dieser Einstellung ist, dass das globale Verzeichnis gar nicht verfügbar ist, wenn diese Einstellung nicht gesetzt wird.
Dies erlaubt eine private Kommunikation, die komplett vom globalen Verzeichnis isoliert ist.
#### Erzwinge Veröffentlichung
-Standardmäßig können Nutzer selbst auswählen, ob ihr Profil im Seitenverzeichnis erscheint.
-Diese Einstellung zwingt alle Nutzer dazu, im Verzeichnis zu erscheinen.
+Standardmäßig können Nutzer selbst auswählen, ob ihr Profil im Seitenverzeichnis erscheint.
+Diese Einstellung zwingt alle Nutzer dazu, im Verzeichnis zu erscheinen.
Diese Einstellung kann vom Nutzer nicht deaktiviert werden. Die Standardeinstellung steht auf "false".
#### Öffentlichen Zugriff blockieren
-Aktiviere diese Einstellung um den öffentlichen Zugriff auf alle Seiten zu sperren, solange man nicht eingeloggt ist.
-Das blockiert die Ansicht von Profilen, Freunden, Fotos, vom Verzeichnis und den Suchseiten.
-Ein Nebeneffekt ist, dass Einträge dieser Seite nicht im globalen Verzeichnis erscheinen.
-Wir empfehlen, speziell diese Einstellung auszuschalten (die Einstellung ist an anderer Stelle auf dieser Seite erklärt).
-Beachte: das ist speziell für Seiten, die beabsichtigen, von anderen Friendica-Netzwerken abgeschottet zu sein.
-Unautorisierte Personen haben ebenfalls nicht die Möglichkeit, Freundschaftsanfragen von Seitennutzern zu beantworten.
-Die Standardeinstellung ist deaktiviert.
+Aktiviere diese Einstellung um den öffentlichen Zugriff auf alle Seiten zu sperren, solange man nicht eingeloggt ist.
+Das blockiert die Ansicht von Profilen, Freunden, Fotos, vom Verzeichnis und den Suchseiten.
+Ein Nebeneffekt ist, dass Einträge dieser Seite nicht im globalen Verzeichnis erscheinen.
+Wir empfehlen, speziell diese Einstellung auszuschalten (die Einstellung ist an anderer Stelle auf dieser Seite erklärt).
+Beachte: das ist speziell für Seiten, die beabsichtigen, von anderen Friendica-Netzwerken abgeschottet zu sein.
+Unautorisierte Personen haben ebenfalls nicht die Möglichkeit, Freundschaftsanfragen von Seitennutzern zu beantworten.
+Die Standardeinstellung ist deaktiviert.
Verfügbar in Version 2.2 und höher.
#### Für Besucher verfügbare Gemeinschaftsseiten
@@ -133,15 +133,15 @@ Angemeldete Nutzer des Knotens können grundsätzlich beide Seiten verwenden.
#### Erlaubte Domains für Kontakte
-Kommagetrennte Liste von Domains, welche eine Freundschaft mit dieser Seite eingehen dürfen.
+Kommagetrennte Liste von Domains, welche eine Freundschaft mit dieser Seite eingehen dürfen.
Wildcards werden akzeptiert (Wildcard-Unterstützung unter Windows benötigt PHP5.3) Standardmäßig sind alle gültigen Domains erlaubt.
Mit dieser Option kann man einfach geschlossene Netzwerke, z.B. im schulischen Bereich aufbauen, aus denen nicht mit dem Rest des Netzwerks kommuniziert werden soll.
#### Erlaubte Domains für E-Mails
-Kommagetrennte Liste von Domains, welche bei der Registrierung als Part der Email-Adresse erlaubt sind.
-Das grenzt Leute aus, die nicht Teil der Gruppe oder Organisation sind.
+Kommagetrennte Liste von Domains, welche bei der Registrierung als Part der Email-Adresse erlaubt sind.
+Das grenzt Leute aus, die nicht Teil der Gruppe oder Organisation sind.
Wildcards werden akzeptiert (Wildcard-Unterstützung unter Windows benötigt PHP5.3) Standardmäßig sind alle gültigen Email-Adressen erlaubt.
#### Nutzern erlauben das remote_self Flag zu setzen
@@ -172,23 +172,23 @@ Wenn deine Seite eine Proxy-Einstellung nutzt, musst du diese Einstellungen vorn
#### Netzwerk Wartezeit
-Legt fest, wie lange das Netzwerk warten soll, bevor ein Timeout eintritt.
+Legt fest, wie lange das Netzwerk warten soll, bevor ein Timeout eintritt.
Der Wert wird in Sekunden angegeben. Standardmäßig ist 60 eingestellt; 0 steht für "unbegrenzt" (nicht empfohlen).
#### UTF-8 Reguläre Ausdrücke
-Während der Registrierung werden die Namen daraufhin geprüft, ob sie reguläre UTF-8-Ausdrücke nutzen.
-Hierfür wird PHP benötigt, um mit einer speziellen Einstellung kompiliert zu werden, die UTF-8-Ausdrücke benutzt.
+Während der Registrierung werden die Namen daraufhin geprüft, ob sie reguläre UTF-8-Ausdrücke nutzen.
+Hierfür wird PHP benötigt, um mit einer speziellen Einstellung kompiliert zu werden, die UTF-8-Ausdrücke benutzt.
Wenn du absolut keine Möglichkeit hast, Accounts zu registrieren, setze diesen Wert auf ja.
#### SSL Überprüfen
-Standardmäßig erlaubt Friendica SSL-Kommunikation von Seiten, die "selbst unterzeichnete" SSL-Zertifikate nutzen.
-Um eine weitreichende Kompatibilität mit anderen Netzwerken und Browsern zu gewährleisten, empfehlen wir, selbst unterzeichnete Zertifikate **nicht** zu nutzen.
-Aber wir halten dich nicht davon ab, solche zu nutzen. SSL verschlüsselt alle Daten zwischen den Webseiten (und für deinen Browser), was dir eine komplett verschlüsselte Kommunikation erlaubt.
-Auch schützt es deine Login-Daten vor Datendiebstahl. Selbst unterzeichnete Zertifikate können kostenlos erstellt werden.
-Diese Zertifikate können allerdings Opfer eines sogenannten ["man-in-the-middle"-Angriffs](http://de.wikipedia.org/wiki/Man-in-the-middle-Angriff) werden, und sind daher weniger bevorzugt.
-Wenn du es wünscht, kannst du eine strikte Zertifikatabfrage einstellen.
+Standardmäßig erlaubt Friendica SSL-Kommunikation von Seiten, die "selbst unterzeichnete" SSL-Zertifikate nutzen.
+Um eine weitreichende Kompatibilität mit anderen Netzwerken und Browsern zu gewährleisten, empfehlen wir, selbst unterzeichnete Zertifikate **nicht** zu nutzen.
+Aber wir halten dich nicht davon ab, solche zu nutzen. SSL verschlüsselt alle Daten zwischen den Webseiten (und für deinen Browser), was dir eine komplett verschlüsselte Kommunikation erlaubt.
+Auch schützt es deine Login-Daten vor Datendiebstahl. Selbst unterzeichnete Zertifikate können kostenlos erstellt werden.
+Diese Zertifikate können allerdings Opfer eines sogenannten ["man-in-the-middle"-Angriffs](http://de.wikipedia.org/wiki/Man-in-the-middle-Angriff) werden, und sind daher weniger bevorzugt.
+Wenn du es wünscht, kannst du eine strikte Zertifikatabfrage einstellen.
Das führt dazu, dass du keinerlei Verbindung zu einer selbst unterzeichneten SSL-Seite erstellen kannst
### Automatisch ein Kontaktverzeichnis erstellen
@@ -313,7 +313,7 @@ Du solltest deshalb einen Dienst zur [log rotation](https://en.wikipedia.org/wik
**Bekannte Probleme**: Der Dateiname `friendica.log` kann bei speziellen Server Konfigurationen zu Problemen führen (siehe [issue 2209](https://github.com/friendica/friendica/issues/2209)).
Normalerweise werden Fehler- und Warnmeldungen von PHP unterdrückt.
-Wenn du sie aktivieren willst, musst du folgendes in der `.htconfig.php` Datei eintragen um die Meldungen in die Datei `php.out` zu speichern
+Wenn du sie aktivieren willst, musst du folgendes in der `config/local.ini.php` Datei eintragen um die Meldungen in die Datei `php.out` zu speichern
error_reporting(E_ERROR | E_WARNING | E_PARSE );
ini_set('error_log','php.out');
@@ -367,14 +367,16 @@ Normalerweise trifft dies auf den ersten Account zu, der nach der Installation a
Die Liste der E-Mail Adressen kann aber einfach erweitert werden.
Mit keiner der angegebenen E-Mail Adressen können weitere Accounts registriert werden.
- $a->config['admin_email'] = 'you@example.com, buddy@example.com';
+ [config]
+ admin_email = you@example.com, buddy@example.com
## PHP Pfad
Einige Prozesse von Friendica laufen im Hintergrund.
Für diese Prozesse muss der Pfad zu der PHP Version gesetzt sein, die verwendet werden soll.
- $a->config['php_path'] = '/pfad/zur/php-version';
+ [config]
+ php_path = {{$phpath}}
## Unterverzeichnis Konfiguration
@@ -382,9 +384,10 @@ Man kann Friendica in ein Unterverzeichnis des Webservers installieren.
Wir raten allerdings dringen davon ab, da es die Interoperabilität mit anderen Netzwerken (z.B. Diaspora, GNU Social, Hubzilla) verhindert.
Mal angenommen, du hast ein Unterverzeichnis tests und willst Friendica in ein weiteres Unterverzeichnis installieren, dann lautet die Konfiguration hierfür:
- $a->path = 'tests/friendica';
+ [system]
+ urlpath = tests/friendica
## Weitere Ausnahmen
-Es gibt noch einige experimentelle Einstellungen, die nur in der ``.htconfig.php`` Datei konfiguriert werden können.
-Im [Konfigurationswerte, die nur in der .htconfig.php gesetzt werden können (EN)](help/htconfig) Artikel kannst du mehr darüber erfahren.
+Es gibt noch einige experimentelle Einstellungen, die nur in der ``config/local.ini.php`` Datei konfiguriert werden können.
+Im [Konfigurationswerte, die nur in der config/local.ini.php gesetzt werden können (EN)](help/Config) Artikel kannst du mehr darüber erfahren.
diff --git a/doc/htconfig.md b/doc/htconfig.md
deleted file mode 100644
index a2ce91d4dc..0000000000
--- a/doc/htconfig.md
+++ /dev/null
@@ -1,138 +0,0 @@
-Config values that can only be set in .htconfig.php
-===================================================
-
-* [Home](help)
-
-There are some config values that haven't found their way into the administration page.
-This has several reasons.
-Maybe they are part of a current development that isn't considered stable and will be added later in the administration page when it is considered safe.
-Or it triggers something that isn't expected to be of public interest.
-Or it is for testing purposes only.
-
-**Attention:** Please be warned that you shouldn't use one of these values without the knowledge what it could trigger.
-Especially don't do that with undocumented values.
-
-The header of the section describes the category, the value is the parameter.
-Example: To set the automatic database cleanup process add this line to your .htconfig.php:
-
- $a->config['system']['always_show_preview'] = true;
-
-## jabber ##
-* **debug** (Boolean) - Enable debug level for the jabber account synchronisation.
-* **lockpath** - Must be writable by the ejabberd process. if set then it will prevent the running of multiple processes.
-
-## system ##
-
-* **allowed_link_protocols** (Array) - Allowed protocols in links URLs, add at your own risk. http is always allowed.
-* **always_show_preview** (Boolean) - Only show small preview picures. Default value is false.
-* **archival_days** (Integer) - Number of days that we try to deliver content before we archive a contact. Defaults to 32.
-* **auth_cookie_lifetime** (Integer) - Number of days that should pass without any activity before a user who chose "Remember me" when logging in is considered logged out. Defaults to 7.
-* **block_local_dir** (Boolean) - Blocks the access to the directory of the local users.
-* **config_adapter** (jit|preload) - Allow to switch the configuration adapter to improve performances at the cost of memory consumption. Default value is "jit"
-* **curl_range_bytes** - Maximum number of bytes that should be fetched. Default is 0, which mean "no limit".
-* **db_log** - Name of a logfile to log slow database queries
-* **db_loglimit** - If a database call lasts longer than this value it is logged
-* **db_log_index** - Name of a logfile to log queries with bad indexes
-* **db_log_index_watch** - Watchlist of indexes to watch
-* **db_loglimit_index** - Number of index rows needed to be logged for indexes on the watchlist
-* **db_loglimit_index_high** - Number of index rows to be logged anyway (for any index)
-* **db_log_index_blacklist** - Blacklist of indexes that shouldn't be watched
-* **dbclean_expire_conversation** (Integer) - When DBClean is enabled, any entry in the conversation table will be deleted after this many days. These data are normally needed only for debugging purposes and they are safe to delete. Default 90.
-* **diaspora_test** (Boolean) - For development only. Disables the message transfer.
-* **disable_email_validation** (Boolean) - Disables the check if a mail address is in a valid format and can be resolved via DNS.
-* **disable_url_validation** (Boolean) - Disables the DNS lookup of an URL.
-* **disable_password_exposed** (Boolean) - Disable the exposition check against the remote haveibeenpwned API on password change. Default value is false.
-* **dlogfile** - location of the developer log file
-* **dlogip** - restricts develop log writes to requests originating from this IP address
-* **frontend_worker_timeout** - Value in minutes after we think that a frontend task was killed by the webserver. Default value is 10.
-* **groupedit_image_limit** (Integer) - Number of contacts at which the group editor should switch from display the profile pictures of the contacts to only display the names. Default is 400. This can alternatively be set on a per account basis in the pconfig table.
-* **hsts** (Boolean) - Enables the sending of HTTP Strict Transport Security headers
-* **ignore_cache** (Boolean) - For development only. Disables the item cache.
-* **instances_social_key** - Key to the API of https://instances.social which retrieves data about mastodon servers. See https://instances.social/api/token to get an API key.
-* **ipv4_resolve** (Boolean) - Resolve IPV4 addresses only. Don't resolve to IPV6. Default value is false.
-* **invitation_only** (Boolean) - If set true registration is only possible after a current member of the node has send an invitation. Default is false.
-* **like_no_comment** (Boolean) - Don't update the "commented" value of an item when it is liked.
-* **local_block** (Boolean) - Used in conjunction with "block_public".
-* **local_search** (Boolean) - Blocks search for users who are not logged in to prevent crawlers from blocking your system.
-* **local_tags** (Boolean) - If activated, all hashtags will point to the local server.
-* **max_connections** - The maximum number of database connections which can be in use before the worker process is deferred to it's next interval. When the system can't detect the maximum numbers of connection then this value can be used.
-* **max_connections_level** - The maximum level of connections that are allowed to let the worker start. It is a percentage value. Default value is 75.
-* **max_contact_queue** - Default value is 500.
-* **max_batch_queue** - Default value is 1000.
-* **max_processes_backend** - Maximum number of concurrent database processes for background tasks. Default value is 5.
-* **max_processes_frontend** - Maximum number of concurrent database processes for foreground tasks. Default value is 20.
-* **min_poll_interval** - minimal distance in minutes between two polls for a contact. Default is 1. Reasonable values are between 1 and 59.
-* **session_handler** (database|cache|native) - Whether to use Cache to store session data or to use PHP native session storage. Default value is `database`.
-* **cache_driver** (database|memcache|memcached) - Whether to use Memcache or Memcached to store temporary cache. Default value is `database`.
-* **memcache_host** - Host name of the memcache daemon. Default is '127.0.0.1'.
-* **memcache_port** - Port number of the memcache daemon. Default is 11211.
-* **memcached_hosts** - Array of Memcached servers info `[host, port(, weight)]`. Default value is `[['127.0.0.1', 11211]]`.
-* **no_count** (Boolean) - Don't do count calculations (currently only when showing albums)
-* **no_oembed** (Boolean) - Don't use OEmbed to fetch more information about a link.
-* **no_smilies** (Boolean) - Don't show smilies.
-* **no_view_full_size** (Boolean) - Don't add the link "View full size" under a resized image.
-* **optimize_items** (Boolean) - Triggers an SQL command to optimize the item table before expiring items.
-* **ostatus_poll_timeframe** - Defines how old an item can be to try to complete the conversation with it.
-* **paranoia** (Boolean) - Log out users if their IP address changed.
-* **permit_crawling** (Boolean) - Restricts the search for not logged in users to one search per minute.
-* **queue_no_dead_check** (Boolean) - Ignore if the target contact or server seems to be dead during queue delivery.
-* **worker_debug** (Boolean) - If enabled, it prints out the number of running processes split by priority.
-* **worker_fetch_limit** - Number of worker tasks that are fetched in a single query. Default is 1.
-* **profiler** (Boolean) - Enable internal timings to help optimize code. Needed for "rendertime" addon. Default is false.
-* **free_crawls** - Number of "free" searches when "permit_crawling" is activated (Default value is 10)
-* **crawl_permit_period** - Period in seconds between allowed searches when the number of free searches is reached and "permit_crawling" is activated (Default value is 60)
-* **png_quality** - Default value is 8.
-* **proc_windows** (Boolean) - Should be enabled if Friendica is running under Windows.
-* **proxy_cache_time** - Time after which the cache is cleared. Default value is one day.
-* **pushpoll_frequency** -
-* **qsearch_limit** - Default value is 100.
-* **remove_multiplicated_lines** (Boolean) - If enabled, multiple linefeeds in items are stripped to a single one.
-* **sendmail_params** (Boolean) - Normal sendmail command parameters will be added when the PHP mail() function is called for sending e-mails. This ensures the Sender Email address setting is applied to the message envelope rather than the host's default address. Default is true. Set to false if your non-sendmail agent is incompatible, or to restore old behavior of using the host address.
-* **show_unsupported_addons** (Boolean) - Show all addons including the unsupported ones.
-* **show_unsupported_themes** (Boolean) - Show all themes including the unsupported ones.
-* **show_global_community_hint** (Boolean) - When the global community page is enabled, use this option to display a hint above the stream, that this is a collection of all public top-level postings that arrive on your node.
-* **throttle_limit_day** - Maximum number of posts that a user can send per day with the API.
-* **throttle_limit_week** - Maximum number of posts that a user can send per week with the API.
-* **throttle_limit_month** - Maximum number of posts that a user can send per month with the API.
-* **wall-to-wall_share** (Boolean) - Displays forwarded posts like "wall-to-wall" posts.
-* **worker_cooldown** - Cooldown time after each worker function call. Default value is 0 seconds.
-* **worker_load_exponent** (Integer) - Default 3, which allows only 25% of the maximum worker queues when server load reaches around 37% of maximum load. For a linear response where 25% of worker queues are allowed at 75% of maximum load, set this to 1. Setting 0 would allow maximum worker queues at all times, which is not recommended.
-* **xrd_timeout** - Timeout for fetching the XRD links. Default value is 20 seconds.
-
-## experimental ##
-
-* **exp_themes** (Boolean) - Show experimental themes as well.
-
-## theme ##
-
-* **hide_eventlist** (Boolean) - Don't show the birthdays and events on the profile and network page
-
-# Administrator Options #
-
-Enabling the admin panel for an account, and thus making the account holder admin of the node, is done by setting the variable
-
- $a->config['admin_email'] = "someone@example.com";
-
-Where you have to match the email address used for the account with the one you enter to the .htconfig file.
-If more then one account should be able to access the admin panel, seperate the email addresses with a comma.
-
- $a->config['admin_email'] = "someone@example.com,someonelese@example.com";
-
-If you want to have a more personalized closing line for the notification emails you can set a variable for the admin_name.
-
- $a->config['admin_name'] = "Marvin";
-
-## Database Settings
-
-The configuration variables db_host, db_user, db_pass and db_data are holding your credentials for the database connection.
-If you need to specify a port to access the database, you can do so by appending ":portnumber" to the db_host variable.
-
- $db_host = 'your.mysqlhost.com:123456';
-
-If all of the following environment variables are set, Friendica will use them instead of the previously configured variables for the db:
-
- MYSQL_HOST
- MYSQL_PORT
- MYSQL_USERNAME
- MYSQL_PASSWORD
- MYSQL_DATABASE
diff --git a/htconfig.php b/htconfig.php
deleted file mode 100644
index 87c1301abd..0000000000
--- a/htconfig.php
+++ /dev/null
@@ -1,114 +0,0 @@
-config['system']['db_charset'] = "utf8mb4";
-
-// Choose a legal default timezone. If you are unsure, use "America/Los_Angeles".
-// It can be changed later and only applies to timestamps for anonymous viewers.
-
-$default_timezone = 'America/Los_Angeles';
-
-// Default system language
-
-$a->config['system']['language'] = 'en';
-
-// What is your site name?
-
-$a->config['sitename'] = "Friendica Social Network";
-
-// Your choices are REGISTER_OPEN, REGISTER_APPROVE, or REGISTER_CLOSED.
-// Be certain to create your own personal account before setting
-// REGISTER_CLOSED. 'register_text' (if set) will be displayed prominently on
-// the registration page. REGISTER_APPROVE requires you set 'admin_email'
-// to the email address of an already registered person who can authorise
-// and/or approve/deny the request.
-
-// In order to perform system administration via the admin panel, admin_email
-// must precisely match the email address of the person logged in.
-
-$a->config['register_policy'] = REGISTER_OPEN;
-$a->config['register_text'] = '';
-$a->config['admin_email'] = '';
-
-// Maximum size of an imported message, 0 is unlimited
-
-$a->config['max_import_size'] = 200000;
-
-// maximum size of uploaded photos
-
-$a->config['system']['maximagesize'] = 800000;
-
-// Location of PHP command line processor
-
-$a->config['php_path'] = 'php';
-
-// Server-to-server private message encryption (RINO) is allowed by default.
-// set to 0 to disable, 1 to enable
-
-$a->config['system']['rino_encrypt'] = 1;
-
-// allowed themes (change this from admin panel after installation)
-
-$a->config['system']['allowed_themes'] = 'quattro,vier,duepuntozero,smoothly';
-
-// default system theme
-
-$a->config['system']['theme'] = 'vier';
-
-
-// By default allow pseudonyms
-
-$a->config['system']['no_regfullname'] = true;
-
-//Deny public access to the local directory
-//$a->config['system']['block_local_dir'] = false;
-
-// Location of the global directory
-$a->config['system']['directory'] = 'https://dir.friendica.social';
-
-// Allowed protocols in link URLs; HTTP protocols always are accepted
-$a->config['system']['allowed_link_protocols'] = ['ftp', 'ftps', 'mailto', 'cid', 'gopher'];
-
-// Authentication cookie lifetime, in days
-$a->config['system']['auth_cookie_lifetime'] = 7;
diff --git a/include/api.php b/include/api.php
index 4e8e9c2323..58f086c012 100644
--- a/include/api.php
+++ b/include/api.php
@@ -772,6 +772,7 @@ function api_get_user(App $a, $contact_id = null)
$theme_info = dba::selectFirst('user', ['theme'], ['uid' => $ret['uid']]);
if ($theme_info['theme'] === 'frio') {
$schema = PConfig::get($ret['uid'], 'frio', 'schema');
+
if ($schema && ($schema != '---')) {
if (file_exists('view/theme/frio/schema/'.$schema.'.php')) {
$schemefile = 'view/theme/frio/schema/'.$schema.'.php';
@@ -3344,7 +3345,7 @@ function api_statusnet_config($type)
$server = $a->get_hostname();
$logo = System::baseUrl() . '/images/friendica-64.png';
$email = Config::get('config', 'admin_email');
- $closed = Config::get('config', 'register_policy') == REGISTER_CLOSED ? 'true' : 'false';
+ $closed = intval(Config::get('config', 'register_policy')) === REGISTER_CLOSED ? 'true' : 'false';
$private = Config::get('system', 'block_public') ? 'true' : 'false';
$textlimit = (string) Config::get('config', 'api_import_size', Config::get('config', 'max_import_size', 200000));
$ssl = Config::get('system', 'have_ssl') ? 'true' : 'false';
diff --git a/include/dba.php b/include/dba.php
index b95589970e..0b5c822531 100644
--- a/include/dba.php
+++ b/include/dba.php
@@ -1,7 +1,9 @@
getConfigVariable() instead.
+//use Friendica\Core\Config;
+
use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Database\DBStructure;
@@ -29,21 +31,20 @@ class dba {
private static $db_user = '';
private static $db_pass = '';
private static $db_name = '';
+ private static $db_charset = '';
- public static function connect($serveraddr, $user, $pass, $db) {
+ public static function connect($serveraddr, $user, $pass, $db, $charset = null)
+ {
if (!is_null(self::$db) && self::connected()) {
return true;
}
- $a = get_app();
-
- $stamp1 = microtime(true);
-
// We are storing these values for being able to perform a reconnect
self::$db_serveraddr = $serveraddr;
self::$db_user = $user;
self::$db_pass = $pass;
self::$db_name = $db;
+ self::$db_charset = $charset;
$serveraddr = trim($serveraddr);
@@ -58,6 +59,7 @@ class dba {
$user = trim($user);
$pass = trim($pass);
$db = trim($db);
+ $charset = trim($charset);
if (!(strlen($server) && strlen($user))) {
return false;
@@ -71,9 +73,10 @@ class dba {
$connect .= ";port=".$port;
}
- if (isset($a->config["system"]["db_charset"])) {
- $connect .= ";charset=".$a->config["system"]["db_charset"];
+ if ($charset) {
+ $connect .= ";charset=".$charset;
}
+
try {
self::$db = @new PDO($connect, $user, $pass);
self::$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
@@ -88,8 +91,8 @@ class dba {
if (!mysqli_connect_errno()) {
self::$connected = true;
- if (isset($a->config["system"]["db_charset"])) {
- self::$db->set_charset($a->config["system"]["db_charset"]);
+ if ($charset) {
+ self::$db->set_charset($charset);
}
}
}
@@ -99,7 +102,6 @@ class dba {
self::$driver = null;
self::$db = null;
}
- $a->save_timestamp($stamp1, "network");
return self::$connected;
}
@@ -130,7 +132,7 @@ class dba {
public static function reconnect() {
self::disconnect();
- $ret = self::connect(self::$db_serveraddr, self::$db_user, self::$db_pass, self::$db_name);
+ $ret = self::connect(self::$db_serveraddr, self::$db_user, self::$db_pass, self::$db_name, self::$db_charset);
return $ret;
}
@@ -184,7 +186,7 @@ class dba {
private static function logIndex($query) {
$a = get_app();
- if (empty($a->config["system"]["db_log_index"])) {
+ if (!$a->getConfigVariable('system', 'db_log_index')) {
return;
}
@@ -203,18 +205,18 @@ class dba {
return;
}
- $watchlist = explode(',', $a->config["system"]["db_log_index_watch"]);
- $blacklist = explode(',', $a->config["system"]["db_log_index_blacklist"]);
+ $watchlist = explode(',', $a->getConfigVariable('system', 'db_log_index_watch'));
+ $blacklist = explode(',', $a->getConfigVariable('system', 'db_log_index_blacklist'));
while ($row = dba::fetch($r)) {
- if ((intval($a->config["system"]["db_loglimit_index"]) > 0)) {
+ if ((intval($a->getConfigVariable('system', 'db_loglimit_index')) > 0)) {
$log = (in_array($row['key'], $watchlist) &&
- ($row['rows'] >= intval($a->config["system"]["db_loglimit_index"])));
+ ($row['rows'] >= intval($a->getConfigVariable('system', 'db_loglimit_index'))));
} else {
$log = false;
}
- if ((intval($a->config["system"]["db_loglimit_index_high"]) > 0) && ($row['rows'] >= intval($a->config["system"]["db_loglimit_index_high"]))) {
+ if ((intval($a->getConfigVariable('system', 'db_loglimit_index_high')) > 0) && ($row['rows'] >= intval($a->getConfigVariable('system', 'db_loglimit_index_high')))) {
$log = true;
}
@@ -224,7 +226,7 @@ class dba {
if ($log) {
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
- @file_put_contents($a->config["system"]["db_log_index"], DateTimeFormat::utcNow()."\t".
+ @file_put_contents($a->getConfigVariable('system', 'db_log_index'), DateTimeFormat::utcNow()."\t".
$row['key']."\t".$row['rows']."\t".$row['Extra']."\t".
basename($backtrace[1]["file"])."\t".
$backtrace[1]["line"]."\t".$backtrace[2]["function"]."\t".
@@ -384,7 +386,7 @@ class dba {
$orig_sql = $sql;
- if (x($a->config,'system') && x($a->config['system'], 'db_callstack')) {
+ if ($a->getConfigValue('system', 'db_callstack')) {
$sql = "/*".System::callstack()." */ ".$sql;
}
@@ -545,16 +547,15 @@ class dba {
$a->save_timestamp($stamp1, 'database');
- if (x($a->config,'system') && x($a->config['system'], 'db_log')) {
-
+ if ($a->getConfigValue('system', 'db_log')) {
$stamp2 = microtime(true);
$duration = (float)($stamp2 - $stamp1);
- if (($duration > $a->config["system"]["db_loglimit"])) {
+ if (($duration > $a->getConfigValue('system', 'db_loglimit'))) {
$duration = round($duration, 3);
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
- @file_put_contents($a->config["system"]["db_log"], DateTimeFormat::utcNow()."\t".$duration."\t".
+ @file_put_contents($a->getConfigValue('system', 'db_log'), DateTimeFormat::utcNow()."\t".$duration."\t".
basename($backtrace[1]["file"])."\t".
$backtrace[1]["line"]."\t".$backtrace[2]["function"]."\t".
substr(self::replaceParameters($sql, $args), 0, 2000)."\n", FILE_APPEND);
@@ -1377,7 +1378,7 @@ class dba {
$is_alpha = true;
}
}
-
+
if ($is_int && $is_alpha) {
foreach ($value as &$ref) {
if (is_int($ref)) {
diff --git a/include/enotify.php b/include/enotify.php
index a19693816f..2d4cbdadb5 100644
--- a/include/enotify.php
+++ b/include/enotify.php
@@ -33,11 +33,11 @@ function notification($params)
$product = FRIENDICA_PLATFORM;
$siteurl = System::baseUrl(true);
$thanks = L10n::t('Thank You,');
- $sitename = $a->config['sitename'];
- if (empty($a->config['admin_name'])) {
- $site_admin = L10n::t('%s Administrator', $sitename);
+ $sitename = Config::get('config', 'sitename');
+ if (Config::get('config', 'admin_name')) {
+ $site_admin = L10n::t('%1$s, %2$s Administrator', Config::get('config', 'admin_name'), $sitename);
} else {
- $site_admin = L10n::t('%1$s, %2$s Administrator', $a->config['admin_name'], $sitename);
+ $site_admin = L10n::t('%s Administrator', $sitename);
}
$sender_name = $sitename;
diff --git a/include/text.php b/include/text.php
index 3ee23ff164..6aa0c9d2dd 100644
--- a/include/text.php
+++ b/include/text.php
@@ -462,86 +462,6 @@ function perms2str($p) {
return $ret;
}
-/**
- * @deprecated
- * wrapper to load a view template, checking for alternate
- * languages before falling back to the default
- *
- * @global string $lang
- * @global App $a
- * @param string $s view name
- * @return string
- */
-function load_view_file($s) {
- global $lang, $a;
- if (!isset($lang)) {
- $lang = 'en';
- }
- $b = basename($s);
- $d = dirname($s);
- if (file_exists("$d/$lang/$b")) {
- $stamp1 = microtime(true);
- $content = file_get_contents("$d/$lang/$b");
- $a->save_timestamp($stamp1, "file");
- return $content;
- }
-
- $theme = $a->getCurrentTheme();
-
- if (file_exists("$d/theme/$theme/$b")) {
- $stamp1 = microtime(true);
- $content = file_get_contents("$d/theme/$theme/$b");
- $a->save_timestamp($stamp1, "file");
- return $content;
- }
-
- $stamp1 = microtime(true);
- $content = file_get_contents($s);
- $a->save_timestamp($stamp1, "file");
- return $content;
-}
-
-
-/**
- * load a view template, checking for alternate
- * languages before falling back to the default
- *
- * @global string $lang
- * @param string $s view path
- * @return string
- */
-function get_intltext_template($s) {
- global $lang;
-
- $a = get_app();
- $engine = '';
- if ($a->theme['template_engine'] === 'smarty3') {
- $engine = "/smarty3";
- }
-
- if (!isset($lang)) {
- $lang = 'en';
- }
-
- if (file_exists("view/lang/$lang$engine/$s")) {
- $stamp1 = microtime(true);
- $content = file_get_contents("view/lang/$lang$engine/$s");
- $a->save_timestamp($stamp1, "file");
- return $content;
- } elseif (file_exists("view/lang/en$engine/$s")) {
- $stamp1 = microtime(true);
- $content = file_get_contents("view/lang/en$engine/$s");
- $a->save_timestamp($stamp1, "file");
- return $content;
- } else {
- $stamp1 = microtime(true);
- $content = file_get_contents("view$engine/$s");
- $a->save_timestamp($stamp1, "file");
- return $content;
- }
-}
-
-
/**
* load template $s
*
@@ -599,7 +519,6 @@ $LOGGER_LEVELS = [];
* LOGGER_DATA
* LOGGER_ALL
*
- * @global App $a
* @global array $LOGGER_LEVELS
* @param string $msg
* @param int $level
@@ -608,17 +527,9 @@ function logger($msg, $level = 0) {
$a = get_app();
global $LOGGER_LEVELS;
- // turn off logger in install mode
- if (
- $a->mode == App::MODE_INSTALL
- || !dba::$connected
- ) {
- return;
- }
-
- $debugging = Config::get('system','debugging');
- $logfile = Config::get('system','logfile');
- $loglevel = intval(Config::get('system','loglevel'));
+ $debugging = Config::get('system', 'debugging');
+ $logfile = Config::get('system', 'logfile');
+ $loglevel = intval(Config::get('system', 'loglevel'));
if (
!$debugging
@@ -678,23 +589,13 @@ function logger($msg, $level = 0) {
* LOGGER_DATA
* LOGGER_ALL
*
- * @global App $a
* @global array $LOGGER_LEVELS
* @param string $msg
* @param int $level
*/
-
function dlogger($msg, $level = 0) {
$a = get_app();
- // turn off logger in install mode
- if (
- $a->mode == App::MODE_INSTALL
- || !dba::$connected
- ) {
- return;
- }
-
$logfile = Config::get('system', 'dlogfile');
if (!$logfile) {
return;
@@ -716,7 +617,7 @@ function dlogger($msg, $level = 0) {
$process_id = session_id();
if ($process_id == '') {
- $process_id = get_app()->process_id;
+ $process_id = $a->process_id;
}
$callers = debug_backtrace();
diff --git a/index.php b/index.php
index ed558e5feb..a8098942c2 100644
--- a/index.php
+++ b/index.php
@@ -9,7 +9,6 @@
*/
use Friendica\App;
-use Friendica\BaseObject;
use Friendica\Content\Nav;
use Friendica\Core\Addon;
use Friendica\Core\Config;
@@ -25,44 +24,31 @@ use Friendica\Module\Login;
require_once 'boot.php';
$a = new App(__DIR__);
-BaseObject::setApp($a);
// We assume that the index.php is called by a frontend process
// The value is set to "true" by default in boot.php
$a->backend = false;
-// Only load config if found, don't suppress errors
-if (!$a->mode == App::MODE_INSTALL) {
- include ".htconfig.php";
-}
-
/**
* Try to open the database;
*/
require_once "include/dba.php";
-if (!$a->mode == App::MODE_INSTALL) {
- $result = dba::connect($db_host, $db_user, $db_pass, $db_data);
- unset($db_host, $db_user, $db_pass, $db_data);
+// Missing DB connection: ERROR
+if ($a->mode & App::MODE_LOCALCONFIGPRESENT && !($a->mode & App::MODE_DBAVAILABLE)) {
+ System::httpExit(500, ['title' => 'Error 500 - Internal Server Error', 'description' => 'Apologies but the website is unavailable at the moment.']);
+}
- if (!$result) {
- System::unavailable();
- }
+// Max Load Average reached: ERROR
+if ($a->isMaxProcessesReached() || $a->isMaxLoadReached()) {
+ header('Retry-After: 120');
+ header('Refresh: 120; url=' . System::baseUrl() . "/" . $a->query_string);
- /**
- * Load configs from db. Overwrite configs from .htconfig.php
- */
-
- Config::load();
-
- if ($a->max_processes_reached() || $a->maxload_reached()) {
- header($_SERVER["SERVER_PROTOCOL"] . ' 503 Service Temporarily Unavailable');
- header('Retry-After: 120');
- header('Refresh: 120; url=' . System::baseUrl() . "/" . $a->query_string);
- die("System is currently unavailable. Please try again later");
- }
+ System::httpExit(503, ['title' => 'Error 503 - Service Temporarily Unavailable', 'description' => 'System is currently overloaded. Please try again later.']);
+}
+if ($a->isInstallMode()) {
if (Config::get('system', 'force_ssl') && ($a->get_scheme() == "http")
&& (intval(Config::get('system', 'ssl_policy')) == SSL_POLICY_FULL)
&& (substr(System::baseUrl(), 0, 8) == "https://")
@@ -76,8 +62,6 @@ if (!$a->mode == App::MODE_INSTALL) {
Session::init();
Addon::loadHooks();
Addon::callHooks('init_1');
-
- $a->checkMaintenanceMode();
}
$lang = L10n::getBrowserLanguage();
@@ -183,9 +167,9 @@ $_SESSION['last_updated'] = defaults($_SESSION, 'last_updated', []);
// in install mode, any url loads install module
// but we need "view" module for stylesheet
-if ($a->mode == App::MODE_INSTALL && $a->module!="view") {
+if ($a->isInstallMode() && $a->module!="view") {
$a->module = 'install';
-} elseif ($a->mode == App::MODE_MAINTENANCE && $a->module!="view") {
+} elseif (!($a->mode & App::MODE_MAINTENANCEDISABLED) && $a->module != "view") {
$a->module = 'maintenance';
} else {
check_url($a);
diff --git a/mod/admin.php b/mod/admin.php
index 54b7e6504e..349e5b29ac 100644
--- a/mod/admin.php
+++ b/mod/admin.php
@@ -845,6 +845,12 @@ function admin_page_summary(App $a)
$warningtext[] = L10n::t('The last worker execution was on %s UTC. This is older than one hour. Please check your crontab settings.', $last_worker_call);
}
+ // Legacy config file warning
+ if (file_exists('.htconfig.php')) {
+ $showwarning = true;
+ $warningtext[] = L10n::t('Friendica\'s configuration now is stored in config/local.ini.php, please copy config/local-sample.ini.php and move your config from .htconfig.php
. See the Config help page for help with the transition.', $a->get_baseurl() . '/help/Config');
+ }
+
$r = q("SELECT `page-flags`, COUNT(`uid`) AS `count` FROM `user` GROUP BY `page-flags`");
$accounts = [
[L10n::t('Normal Account'), 0],
@@ -938,8 +944,6 @@ function admin_page_site_post(App $a)
function update_table($table_name, $fields, $old_url, $new_url)
{
- global $a;
-
$dbold = dbesc($old_url);
$dbnew = dbesc($new_url);
@@ -1378,8 +1382,8 @@ function admin_page_site(App $a)
"develop" => L10n::t("check the development version")
];
- if ($a->config['hostname'] == "") {
- $a->config['hostname'] = $a->get_hostname();
+ if (empty(Config::get('config', 'hostname'))) {
+ Config::set('config', 'hostname', $a->get_hostname());
}
$diaspora_able = ($a->get_path() == "");
@@ -1388,8 +1392,6 @@ function admin_page_site(App $a)
if ($optimize_max_tablesize <= 0) {
$optimize_max_tablesize = -1;
}
- // Default list of forbidden names, classic role names from RFC 2142
- $default_forbidden_nicknames = 'info, marketing, sales, support, abuse, noc, security, postmaster, hostmaster, usenet, news, webmaster, www, uucp, ftp, root, sysop';
$t = get_markup_template('admin/site.tpl');
return replace_macros($t, [
@@ -1408,9 +1410,9 @@ function admin_page_site(App $a)
'$relocate' => L10n::t('Relocate - WARNING: advanced function. Could make this server unreachable.'),
'$baseurl' => System::baseUrl(true),
// name, label, value, help string, extra data...
- '$sitename' => ['sitename', L10n::t("Site name"), $a->config['sitename'],''],
- '$hostname' => ['hostname', L10n::t("Host name"), $a->config['hostname'], ""],
- '$sender_email' => ['sender_email', L10n::t("Sender Email"), $a->config['sender_email'], L10n::t("The email address your server shall use to send notification emails from."), "", "", "email"],
+ '$sitename' => ['sitename', L10n::t("Site name"), Config::get('config', 'sitename'),''],
+ '$hostname' => ['hostname', L10n::t("Host name"), Config::get('config', 'hostname'), ""],
+ '$sender_email' => ['sender_email', L10n::t("Sender Email"), Config::get('config', 'sender_email'), L10n::t("The email address your server shall use to send notification emails from."), "", "", "email"],
'$banner' => ['banner', L10n::t("Banner/Logo"), $banner, ""],
'$shortcut_icon' => ['shortcut_icon', L10n::t("Shortcut icon"), Config::get('system','shortcut_icon'), L10n::t("Link to an icon that will be used for browsers.")],
'$touch_icon' => ['touch_icon', L10n::t("Touch icon"), Config::get('system','touch_icon'), L10n::t("Link to an icon that will be used for tablets and mobiles.")],
@@ -1426,10 +1428,10 @@ function admin_page_site(App $a)
'$maximagelength' => ['maximagelength', L10n::t("Maximum image length"), Config::get('system','max_image_length'), L10n::t("Maximum length in pixels of the longest side of uploaded images. Default is -1, which means no limits.")],
'$jpegimagequality' => ['jpegimagequality', L10n::t("JPEG image quality"), Config::get('system','jpeg_quality'), L10n::t("Uploaded JPEGS will be saved at this quality setting [0-100]. Default is 100, which is full quality.")],
- '$register_policy' => ['register_policy', L10n::t("Register policy"), $a->config['register_policy'], "", $register_choices],
+ '$register_policy' => ['register_policy', L10n::t("Register policy"), Config::get('config', 'register_policy'), "", $register_choices],
'$daily_registrations' => ['max_daily_registrations', L10n::t("Maximum Daily Registrations"), Config::get('system', 'max_daily_registrations'), L10n::t("If registration is permitted above, this sets the maximum number of new user registrations to accept per day. If register is set to closed, this setting has no effect.")],
- '$register_text' => ['register_text', L10n::t("Register text"), $a->config['register_text'], L10n::t("Will be displayed prominently on the registration page. You can use BBCode here.")],
- '$forbidden_nicknames' => ['forbidden_nicknames', L10n::t('Forbidden Nicknames'), Config::get('system', 'forbidden_nicknames', $default_forbidden_nicknames), L10n::t('Comma separated list of nicknames that are forbidden from registration. Preset is a list of role names according RFC 2142.')],
+ '$register_text' => ['register_text', L10n::t("Register text"), Config::get('config', 'register_text'), L10n::t("Will be displayed prominently on the registration page. You can use BBCode here.")],
+ '$forbidden_nicknames' => ['forbidden_nicknames', L10n::t('Forbidden Nicknames'), Config::get('system', 'forbidden_nicknames'), L10n::t('Comma separated list of nicknames that are forbidden from registration. Preset is a list of role names according RFC 2142.')],
'$abandon_days' => ['abandon_days', L10n::t('Accounts abandoned after x days'), Config::get('system','account_abandon_days'), L10n::t('Will not waste system resources polling external sites for abandonded accounts. Enter 0 for no time limit.')],
'$allowed_sites' => ['allowed_sites', L10n::t("Allowed friend domains"), Config::get('system','allowed_sites'), L10n::t("Comma separated list of domains which are allowed to establish friendships with this site. Wildcards are accepted. Empty to allow any domains")],
'$allowed_email' => ['allowed_email', L10n::t("Allowed email domains"), Config::get('system','allowed_email'), L10n::t("Comma separated list of domains which are allowed in email addresses for registrations to this site. Wildcards are accepted. Empty to allow any domains")],
@@ -1666,13 +1668,13 @@ function admin_page_users_post(App $a)
Thank you and welcome to %4$s.'));
- $preamble = sprintf($preamble, $user['username'], $a->config['sitename']);
- $body = sprintf($body, System::baseUrl(), $user['email'], $result['password'], $a->config['sitename']);
+ $preamble = sprintf($preamble, $user['username'], Config::get('config', 'sitename'));
+ $body = sprintf($body, System::baseUrl(), $user['email'], $result['password'], Config::get('config', 'sitename'));
notification([
'type' => SYSTEM_EMAIL,
'to_email' => $user['email'],
- 'subject' => L10n::t('Registration details for %s', $a->config['sitename']),
+ 'subject' => L10n::t('Registration details for %s', Config::get('config', 'sitename')),
'preamble' => $preamble,
'body' => $body]);
}
@@ -1797,7 +1799,7 @@ function admin_page_users(App $a)
ORDER BY $sql_order $sql_order_direction LIMIT %d, %d", intval($a->pager['start']), intval($a->pager['itemspage'])
);
- $adminlist = explode(",", str_replace(" ", "", $a->config['admin_email']));
+ $adminlist = explode(",", str_replace(" ", "", Config::get('config', 'admin_email')));
$_setup_users = function ($e) use ($adminlist) {
$page_types = [
PAGE_NORMAL => L10n::t('Normal Account Page'),
@@ -1824,7 +1826,6 @@ function admin_page_users(App $a)
$e['register_date'] = Temporal::getRelativeDate($e['register_date']);
$e['login_date'] = Temporal::getRelativeDate($e['login_date']);
$e['lastitem_date'] = Temporal::getRelativeDate($e['lastitem_date']);
- //$e['is_admin'] = ($e['email'] === $a->config['admin_email']);
$e['is_admin'] = in_array($e['email'], $adminlist);
$e['is_deletable'] = (intval($e['uid']) != local_user());
$e['deleted'] = ($e['account_removed'] ? Temporal::getRelativeDate($e['account_expires_on']) : False);
@@ -2378,7 +2379,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/bookmarklet.php b/mod/bookmarklet.php
index 9ae3e28f08..a26757740a 100644
--- a/mod/bookmarklet.php
+++ b/mod/bookmarklet.php
@@ -5,6 +5,7 @@
use Friendica\App;
use Friendica\Core\ACL;
+use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Module\Login;
@@ -21,7 +22,7 @@ function bookmarklet_content(App $a)
{
if (!local_user()) {
$o = '' . L10n::t('Login') . ' ';
- $o .= Login::form($a->query_string, $a->config['register_policy'] == REGISTER_CLOSED ? false : true);
+ $o .= Login::form($a->query_string, intval(Config::get('config', 'register_policy')) === REGISTER_CLOSED ? false : true);
return $o;
}
diff --git a/mod/dfrn_request.php b/mod/dfrn_request.php
index 6592bf901f..b7a0dd7487 100644
--- a/mod/dfrn_request.php
+++ b/mod/dfrn_request.php
@@ -611,7 +611,7 @@ function dfrn_request_content(App $a)
} elseif (x($_GET, 'address') && ($_GET['address'] != "")) {
$myaddr = $_GET['address'];
} elseif (local_user()) {
- if (strlen($a->path)) {
+ if (strlen($a->urlpath)) {
$myaddr = System::baseUrl() . '/profile/' . $a->user['nickname'];
} else {
$myaddr = $a->user['nickname'] . '@' . substr(System::baseUrl(), strpos(System::baseUrl(), '://') + 3);
diff --git a/mod/friendica.php b/mod/friendica.php
index 9d4bdd801c..f1b0fb4761 100644
--- a/mod/friendica.php
+++ b/mod/friendica.php
@@ -2,11 +2,12 @@
/**
* @file mod/friendica.php
*/
+
use Friendica\App;
use Friendica\Core\Addon;
-use Friendica\Core\System;
use Friendica\Core\Config;
use Friendica\Core\L10n;
+use Friendica\Core\System;
use Friendica\Database\DBM;
function friendica_init(App $a)
@@ -16,10 +17,10 @@ function friendica_init(App $a)
$sql_extra = '';
if (x($a->config, 'admin_nickname')) {
- $sql_extra = sprintf(" AND `nickname` = '%s' ", dbesc($a->config['admin_nickname']));
+ $sql_extra = sprintf(" AND `nickname` = '%s' ", dbesc(Config::get('config', 'admin_nickname')));
}
- if (isset($a->config['admin_email']) && $a->config['admin_email']!='') {
- $adminlist = explode(",", str_replace(" ", "", $a->config['admin_email']));
+ if (!empty(Config::get('config', 'admin_email'))) {
+ $adminlist = explode(",", str_replace(" ", "", Config::get('config', 'admin_email')));
$r = q("SELECT `username`, `nickname` FROM `user` WHERE `email` = '%s' $sql_extra", dbesc($adminlist[0]));
$admin = [
@@ -55,13 +56,13 @@ function friendica_init(App $a)
$data = [
'version' => FRIENDICA_VERSION,
'url' => System::baseUrl(),
- 'addons' => $visible_addons,
+ 'addons' => $visible_addons,
'locked_features' => $locked_features,
- 'register_policy' => $register_policy[$a->config['register_policy']],
+ 'register_policy' => $register_policy[intval(Config::get('config', 'register_policy'))],
'admin' => $admin,
- 'site_name' => $a->config['sitename'],
+ 'site_name' => Config::get('config', 'sitename'),
'platform' => FRIENDICA_PLATFORM,
- 'info' => ((x($a->config, 'info')) ? $a->config['info'] : ''),
+ 'info' => Config::get('config', 'info'),
'no_scrape_url' => System::baseUrl().'/noscrape'
];
diff --git a/mod/hcard.php b/mod/hcard.php
index 07c551ebdb..f2b86baf99 100644
--- a/mod/hcard.php
+++ b/mod/hcard.php
@@ -49,7 +49,7 @@ function hcard_init(App $a)
$a->page['htmlhead'] .= ' ' . "\r\n" ;
$a->page['htmlhead'] .= ' ' . "\r\n" ;
- $uri = urlencode('acct:' . $a->profile['nickname'] . '@' . $a->get_hostname() . (($a->path) ? '/' . $a->path : ''));
+ $uri = urlencode('acct:' . $a->profile['nickname'] . '@' . $a->get_hostname() . (($a->urlpath) ? '/' . $a->urlpath : ''));
$a->page['htmlhead'] .= ' ' . "\r\n";
header('Link: <' . System::baseUrl() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);
diff --git a/mod/help.php b/mod/help.php
index 981fe97f70..5db74c15e8 100644
--- a/mod/help.php
+++ b/mod/help.php
@@ -2,44 +2,45 @@
/**
* @file mod/help.php
*/
+
use Friendica\App;
use Friendica\Content\Nav;
use Friendica\Content\Text\Markdown;
+use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\System;
-if (!function_exists('load_doc_file')) {
-
- function load_doc_file($s) {
- global $lang;
- if (!isset($lang))
- $lang = 'en';
- $b = basename($s);
- $d = dirname($s);
- if (file_exists("$d/$lang/$b"))
- return file_get_contents("$d/$lang/$b");
- if (file_exists($s))
- return file_get_contents($s);
- return '';
+function load_doc_file($s)
+{
+ $lang = Config::get('system', 'language');
+ $b = basename($s);
+ $d = dirname($s);
+ if (file_exists("$d/$lang/$b")) {
+ return file_get_contents("$d/$lang/$b");
}
+ if (file_exists($s)) {
+ return file_get_contents($s);
+ }
+
+ return '';
}
-function help_content(App $a) {
-
+function help_content(App $a)
+{
Nav::setSelected('help');
- global $lang;
-
$text = '';
if ($a->argc > 1) {
$path = '';
// looping through the argv keys bigger than 0 to build
// a path relative to /help
- for($x = 1; $x < argc(); $x ++) {
- if(strlen($path))
+ for ($x = 1; $x < argc(); $x ++) {
+ if (strlen($path)) {
$path .= '/';
+ }
+
$path .= argv($x);
}
$title = basename($path);
@@ -47,6 +48,7 @@ function help_content(App $a) {
$text = load_doc_file('doc/' . $path . '.md');
$a->page['title'] = L10n::t('Help:') . ' ' . str_replace('-', ' ', notags($title));
}
+
$home = load_doc_file('doc/Home.md');
if (!$text) {
$text = $home;
@@ -60,8 +62,8 @@ function help_content(App $a) {
header($_SERVER["SERVER_PROTOCOL"] . ' 404 ' . L10n::t('Not Found'));
$tpl = get_markup_template("404.tpl");
return replace_macros($tpl, [
- '$message' => L10n::t('Page not found.')
- ]);
+ '$message' => L10n::t('Page not found.')
+ ]);
}
$html = Markdown::convert($text, false);
@@ -69,34 +71,46 @@ function help_content(App $a) {
if ($filename !== "Home") {
// create TOC but not for home
$lines = explode("\n", $html);
- $toc="TOC ";
- $lastlevel=1;
- $idnum = [0,0,0,0,0,0,0];
- foreach($lines as &$line){
- if (substr($line,0,2)=="TOC";
+ $lastlevel = 1;
+ $idnum = [0, 0, 0, 0, 0, 0, 0];
+ foreach ($lines as &$line) {
+ if (substr($line, 0, 2) == "";
- for($k=$level+1;$k$lastlevel) $toc.="";
- $idnum[$level]++;
- $id = implode("_", array_slice($idnum,1,$level));
- $href = System::baseUrl()."/help/{$filename}#{$id}";
- $toc .= "".strip_tags($line)." ";
- $line = " ".$line;
+
+ if ($level > $lastlevel) {
+ $toc .= "";
+ }
+
+ $idnum[$level] ++;
+ $id = implode("_", array_slice($idnum, 1, $level));
+ $href = System::baseUrl() . "/help/{$filename}#{$id}";
+ $toc .= "" . strip_tags($line) . " ";
+ $line = " " . $line;
$lastlevel = $level;
}
}
}
- for($k=0;$k<$lastlevel; $k++) $toc.=" ";
- $html = implode("\n",$lines);
+
+ for ($k = 0; $k < $lastlevel; $k++) {
+ $toc .= " ";
+ }
+
+ $html = implode("\n", $lines);
$a->page['aside'] = '';
}
return $html;
-
}
diff --git a/mod/home.php b/mod/home.php
index 206a1827ea..d28bf3cb43 100644
--- a/mod/home.php
+++ b/mod/home.php
@@ -36,7 +36,7 @@ function home_content(App $a) {
}
$customhome = false;
- $defaultheader = ''.((x($a->config,'sitename')) ? L10n::t("Welcome to %s", $a->config['sitename']) : "").' ';
+ $defaultheader = '' . (Config::get('config', 'sitename') ? L10n::t('Welcome to %s', Config::get('config', 'sitename')) : '') . ' ';
$homefilepath = $a->basepath . "/home.html";
$cssfilepath = $a->basepath . "/home.css";
@@ -45,9 +45,9 @@ function home_content(App $a) {
if (file_exists($cssfilepath)) {
$a->page['htmlhead'] .= ' ';
}
- }
+ }
- $login = Login::form($a->query_string, $a->config['register_policy'] == REGISTER_CLOSED ? 0 : 1);
+ $login = Login::form($a->query_string, intval(Config::get('config', 'register_policy')) === REGISTER_CLOSED ? 0 : 1);
$content = '';
Addon::callHooks("home_content",$content);
diff --git a/mod/install.php b/mod/install.php
index 4596f9a251..55a7cdd7fd 100644
--- a/mod/install.php
+++ b/mod/install.php
@@ -22,7 +22,8 @@ function install_init(App $a) {
// We overwrite current theme css, because during install we could not have a working mod_rewrite
// so we could not have a css at all. Here we set a static css file for the install procedure pages
- $a->config['system']['theme'] = "../install";
+
+ $a->setConfigValue('system', 'value', '../install');
$a->theme['stylesheet'] = System::baseUrl()."/view/install/style.css";
Install::setInstallMode();
@@ -67,12 +68,11 @@ function install_post(App $a) {
$timezone = notags(trim($_POST['timezone']));
$language = notags(trim($_POST['language']));
$adminmail = notags(trim($_POST['adminmail']));
- $rino = 1;
// connect to db
dba::connect($dbhost, $dbuser, $dbpass, $dbdata);
- Install::install($urlpath, $dbhost, $dbuser, $dbpass, $dbdata, $phpath, $timezone, $language, $adminmail, $rino);
+ Install::install($urlpath, $dbhost, $dbuser, $dbpass, $dbdata, $phpath, $timezone, $language, $adminmail);
return;
break;
@@ -140,9 +140,7 @@ function install_content(App $a) {
switch ($install_wizard_pass) {
case 1: { // System check
- if (x($_POST, 'phpath')) {
- $phpath = notags(trim($_POST['phpath']));
- }
+ $phpath = defaults($_POST, 'phpath', 'php');
list($checks, $checkspassed) = Install::check($phpath);
@@ -163,13 +161,12 @@ function install_content(App $a) {
case 2: { // Database config
- $dbhost = ((x($_POST, 'dbhost')) ? notags(trim($_POST['dbhost'])) : 'localhost');
- $dbuser = notags(trim($_POST['dbuser']));
- $dbpass = notags(trim($_POST['dbpass']));
- $dbdata = notags(trim($_POST['dbdata']));
- $phpath = notags(trim($_POST['phpath']));
-
- $adminmail = notags(trim($_POST['adminmail']));
+ $dbhost = notags(trim(defaults($_POST, 'dbhost' , 'localhost')));
+ $dbuser = notags(trim(defaults($_POST, 'dbuser' , '' )));
+ $dbpass = notags(trim(defaults($_POST, 'dbpass' , '' )));
+ $dbdata = notags(trim(defaults($_POST, 'dbdata' , '' )));
+ $phpath = notags(trim(defaults($_POST, 'phpath' , '' )));
+ $adminmail = notags(trim(defaults($_POST, 'adminmail', '' )));
$tpl = get_markup_template('install_db.tpl');
$o .= replace_macros($tpl, [
@@ -187,8 +184,6 @@ function install_content(App $a) {
'$dbdata' => ['dbdata', L10n::t('Database Name'), $dbdata, '', 'required'],
'$adminmail' => ['adminmail', L10n::t('Site administrator email address'), $adminmail, L10n::t('Your account email address must match this in order to use the web admin panel.'), 'required', 'autofocus', 'email'],
-
-
'$lbl_10' => L10n::t('Please select a default timezone for your website'),
'$baseurl' => System::baseUrl(),
@@ -196,7 +191,6 @@ function install_content(App $a) {
'$phpath' => $phpath,
'$submit' => L10n::t('Submit'),
-
]);
return $o;
}; break;
@@ -245,7 +239,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/mod/invite.php b/mod/invite.php
index 813dbf7044..d8d98bec28 100644
--- a/mod/invite.php
+++ b/mod/invite.php
@@ -126,14 +126,14 @@ function invite_content(App $a) {
$dirloc = Config::get('system', 'directory');
if (strlen($dirloc)) {
- if ($a->config['register_policy'] == REGISTER_CLOSED) {
+ if (intval(Config::get('config', 'register_policy')) === REGISTER_CLOSED) {
$linktxt = L10n::t('Visit %s for a list of public sites that you can join. Friendica members on other sites can all connect with each other, as well as with members of many other social networks.', $dirloc . '/servers');
} else {
$linktxt = L10n::t('To accept this invitation, please visit and register at %s or any other public Friendica website.', System::baseUrl())
. "\r\n" . "\r\n" . L10n::t('Friendica sites all inter-connect to create a huge privacy-enhanced social web that is owned and controlled by its members. They can also connect with many traditional social networks. See %s for a list of alternate Friendica sites you can join.', $dirloc . '/servers');
}
} else { // there is no global directory URL defined
- if ($a->config['register_policy'] == REGISTER_CLOSED) {
+ if (intval(Config::get('config', 'register_policy')) === REGISTER_CLOSED) {
$o = L10n::t('Our apologies. This system is not currently configured to connect with other public sites or invite members.');
return $o;
} else {
diff --git a/mod/lostpass.php b/mod/lostpass.php
index af4518ca16..0d22252bdc 100644
--- a/mod/lostpass.php
+++ b/mod/lostpass.php
@@ -39,7 +39,7 @@ function lostpass_post(App $a)
info(L10n::t('Password reset request issued. Check your email.') . EOL);
}
- $sitename = $a->config['sitename'];
+ $sitename = Config::get('config', 'sitename');
$resetlink = System::baseUrl() . '/lostpass/' . $pwdreset_token;
$preamble = deindent(L10n::t('
@@ -145,7 +145,7 @@ function lostpass_generate_password($user)
info("Your password has been reset." . EOL);
- $sitename = $a->config['sitename'];
+ $sitename = Config::get('config', 'sitename');
$preamble = deindent(L10n::t('
Dear %1$s,
Your password has been changed as requested. Please retain this
diff --git a/mod/nodeinfo.php b/mod/nodeinfo.php
index 1b9dce5f55..fad7246075 100644
--- a/mod/nodeinfo.php
+++ b/mod/nodeinfo.php
@@ -61,9 +61,9 @@ function nodeinfo_init(App $a) {
$nodeinfo['usage'] = [];
- $nodeinfo['openRegistrations'] = ($a->config['register_policy'] != 0);
+ $nodeinfo['openRegistrations'] = intval(Config::get('config', 'register_policy')) !== REGISTER_CLOSED;
- $nodeinfo['metadata'] = ['nodeName' => $a->config['sitename']];
+ $nodeinfo['metadata'] = ['nodeName' => Config::get('config', 'sitename')];
if (Config::get('system', 'nodeinfo')) {
diff --git a/mod/openid.php b/mod/openid.php
index 2c284f76d8..3baeec28d0 100644
--- a/mod/openid.php
+++ b/mod/openid.php
@@ -62,7 +62,7 @@ function openid_content(App $a) {
// Successful OpenID login - but we can't match it to an existing account.
// New registration?
- if ($a->config['register_policy'] == REGISTER_CLOSED) {
+ if (intval(Config::get('config', 'register_policy')) === REGISTER_CLOSED) {
notice(L10n::t('Account not found and OpenID registration is not permitted on this site.') . EOL);
goaway(System::baseUrl());
}
diff --git a/mod/ping.php b/mod/ping.php
index 196758b0df..f68040a2cb 100644
--- a/mod/ping.php
+++ b/mod/ping.php
@@ -9,6 +9,7 @@ use Friendica\Content\ForumManager;
use Friendica\Content\Text\BBCode;
use Friendica\Core\Addon;
use Friendica\Core\Cache;
+use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
use Friendica\Core\System;
@@ -200,7 +201,7 @@ function ping_init(App $a)
);
$mail_count = count($mails);
- if ($a->config['register_policy'] == REGISTER_APPROVE && is_site_admin()) {
+ if (intval(Config::get('config', 'register_policy')) === REGISTER_APPROVE && is_site_admin()) {
$regs = q(
"SELECT `contact`.`name`, `contact`.`url`, `contact`.`micro`, `register`.`created`
FROM `contact` RIGHT JOIN `register` ON `register`.`uid` = `contact`.`uid`
diff --git a/mod/profile.php b/mod/profile.php
index 60741db726..08c0dfdb86 100644
--- a/mod/profile.php
+++ b/mod/profile.php
@@ -79,7 +79,7 @@ function profile_init(App $a)
$a->page['htmlhead'] .= ' ' . "\r\n";
$a->page['htmlhead'] .= ' ' . "\r\n";
$a->page['htmlhead'] .= ' ' . "\r\n";
- $uri = urlencode('acct:' . $a->profile['nickname'] . '@' . $a->get_hostname() . ($a->path ? '/' . $a->path : ''));
+ $uri = urlencode('acct:' . $a->profile['nickname'] . '@' . $a->get_hostname() . ($a->urlpath ? '/' . $a->urlpath : ''));
$a->page['htmlhead'] .= ' ' . "\r\n";
header('Link: <' . System::baseUrl() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);
diff --git a/mod/profile_photo.php b/mod/profile_photo.php
index 1a80b539db..a1428adc87 100644
--- a/mod/profile_photo.php
+++ b/mod/profile_photo.php
@@ -13,54 +13,52 @@ use Friendica\Model\Contact;
use Friendica\Model\Photo;
use Friendica\Model\Profile;
use Friendica\Object\Image;
-use Friendica\Util\DateTimeFormat;
function profile_photo_init(App $a)
{
- if (! local_user()) {
+ if (!local_user()) {
return;
}
Profile::load($a, $a->user['nickname']);
}
-function profile_photo_post(App $a) {
+function profile_photo_post(App $a)
+{
- if (! local_user()) {
- notice(L10n::t('Permission denied.') . EOL );
+ if (!local_user()) {
+ notice(L10n::t('Permission denied.') . EOL);
return;
}
check_form_security_token_redirectOnErr('/profile_photo', 'profile_photo');
- if((x($_POST,'cropfinal')) && ($_POST['cropfinal'] == 1)) {
+ if ((x($_POST, 'cropfinal')) && ($_POST['cropfinal'] == 1)) {
// unless proven otherwise
$is_default_profile = 1;
- if($_REQUEST['profile']) {
- $r = q("select id, `is-default` from profile where id = %d and uid = %d limit 1",
- intval($_REQUEST['profile']),
+ if ($_REQUEST['profile']) {
+ $r = q("select id, `is-default` from profile where id = %d and uid = %d limit 1", intval($_REQUEST['profile']),
intval(local_user())
);
- if (DBM::is_result($r) && (! intval($r[0]['is-default'])))
- $is_default_profile = 0;
+ if (DBM::is_result($r) && (!intval($r[0]['is-default']))) $is_default_profile = 0;
}
// phase 2 - we have finished cropping
- if($a->argc != 2) {
- notice(L10n::t('Image uploaded but image cropping failed.') . EOL );
+ if ($a->argc != 2) {
+ notice(L10n::t('Image uploaded but image cropping failed.') . EOL);
return;
}
$image_id = $a->argv[1];
- if(substr($image_id,-2,1) == '-') {
- $scale = substr($image_id,-1,1);
- $image_id = substr($image_id,0,-2);
+ if (substr($image_id, -2, 1) == '-') {
+ $scale = substr($image_id, -1, 1);
+ $image_id = substr($image_id, 0, -2);
}
@@ -69,10 +67,8 @@ function profile_photo_post(App $a) {
$srcW = $_POST['xfinal'] - $srcX;
$srcH = $_POST['yfinal'] - $srcY;
- $r = q("SELECT * FROM `photo` WHERE `resource-id` = '%s' AND `uid` = %d AND `scale` = %d LIMIT 1",
- dbesc($image_id),
- dbesc(local_user()),
- intval($scale));
+ $r = q("SELECT * FROM `photo` WHERE `resource-id` = '%s' AND `uid` = %d AND `scale` = %d LIMIT 1", dbesc($image_id),
+ dbesc(local_user()), intval($scale));
if (DBM::is_result($r)) {
@@ -80,9 +76,10 @@ function profile_photo_post(App $a) {
$Image = new Image($base_image['data'], $base_image['type']);
if ($Image->isValid()) {
- $Image->crop(175,$srcX,$srcY,$srcW,$srcH);
+ $Image->crop(175, $srcX, $srcY, $srcW, $srcH);
- $r = Photo::store($Image, local_user(), 0, $base_image['resource-id'],$base_image['filename'], L10n::t('Profile Photos'), 4, $is_default_profile);
+ $r = Photo::store($Image, local_user(), 0, $base_image['resource-id'], $base_image['filename'],
+ L10n::t('Profile Photos'), 4, $is_default_profile);
if ($r === false) {
notice(L10n::t('Image size reduction [%s] failed.', "175") . EOL);
@@ -90,7 +87,8 @@ function profile_photo_post(App $a) {
$Image->scaleDown(80);
- $r = Photo::store($Image, local_user(), 0, $base_image['resource-id'],$base_image['filename'], L10n::t('Profile Photos'), 5, $is_default_profile);
+ $r = Photo::store($Image, local_user(), 0, $base_image['resource-id'], $base_image['filename'],
+ L10n::t('Profile Photos'), 5, $is_default_profile);
if ($r === false) {
notice(L10n::t('Image size reduction [%s] failed.', "80") . EOL);
@@ -98,7 +96,8 @@ function profile_photo_post(App $a) {
$Image->scaleDown(48);
- $r = Photo::store($Image, local_user(), 0, $base_image['resource-id'],$base_image['filename'], L10n::t('Profile Photos'), 6, $is_default_profile);
+ $r = Photo::store($Image, local_user(), 0, $base_image['resource-id'], $base_image['filename'],
+ L10n::t('Profile Photos'), 6, $is_default_profile);
if ($r === false) {
notice(L10n::t('Image size reduction [%s] failed.', "48") . EOL);
@@ -108,15 +107,13 @@ function profile_photo_post(App $a) {
if ($is_default_profile) {
$r = q("UPDATE `photo` SET `profile` = 0 WHERE `profile` = 1 AND `resource-id` != '%s' AND `uid` = %d",
- dbesc($base_image['resource-id']),
- intval(local_user())
+ dbesc($base_image['resource-id']), intval(local_user())
);
} else {
$r = q("update profile set photo = '%s', thumb = '%s' where id = %d and uid = %d",
dbesc(System::baseUrl() . '/photo/' . $base_image['resource-id'] . '-4.' . $Image->getExt()),
dbesc(System::baseUrl() . '/photo/' . $base_image['resource-id'] . '-5.' . $Image->getExt()),
- intval($_REQUEST['profile']),
- intval(local_user())
+ intval($_REQUEST['profile']), intval(local_user())
);
}
@@ -125,7 +122,7 @@ function profile_photo_post(App $a) {
info(L10n::t('Shift-reload the page or clear browser cache if the new photo does not display immediately.') . EOL);
// Update global directory in background
$url = System::baseUrl() . '/profile/' . $a->user['nickname'];
- if ($url && strlen(Config::get('system','directory'))) {
+ if ($url && strlen(Config::get('system', 'directory'))) {
Worker::add(PRIORITY_LOW, "Directory", $url);
}
@@ -139,7 +136,7 @@ function profile_photo_post(App $a) {
return; // NOTREACHED
}
- $src = $_FILES['userfile']['tmp_name'];
+ $src = $_FILES['userfile']['tmp_name'];
$filename = basename($_FILES['userfile']['name']);
$filesize = intval($_FILES['userfile']['size']);
$filetype = $_FILES['userfile']['type'];
@@ -158,7 +155,7 @@ function profile_photo_post(App $a) {
$imagedata = @file_get_contents($src);
$ph = new Image($imagedata, $filetype);
- if (! $ph->isValid()) {
+ if (!$ph->isValid()) {
notice(L10n::t('Unable to process image.') . EOL);
@unlink($src);
return;
@@ -166,25 +163,28 @@ function profile_photo_post(App $a) {
$ph->orient($src);
@unlink($src);
- return profile_photo_crop_ui_head($a, $ph);
+ profile_photo_crop_ui_head($a, $ph);
}
+function profile_photo_content(App $a)
+{
-function profile_photo_content(App $a) {
-
- if (! local_user()) {
- notice(L10n::t('Permission denied.') . EOL );
+ if (!local_user()) {
+ notice(L10n::t('Permission denied.') . EOL);
return;
}
$newuser = false;
- if($a->argc == 2 && $a->argv[1] === 'new')
+ if ($a->argc == 2 && $a->argv[1] === 'new') {
$newuser = true;
+ }
- if( $a->argv[1]=='use'){
- if ($a->argc<3){
- notice(L10n::t('Permission denied.') . EOL );
+ $imagecrop = [];
+
+ if ($a->argv[1] == 'use') {
+ if ($a->argc < 3) {
+ notice(L10n::t('Permission denied.') . EOL);
return;
};
@@ -192,36 +192,32 @@ function profile_photo_content(App $a) {
$resource_id = $a->argv[2];
//die(":".local_user());
- $r=q("SELECT * FROM `photo` WHERE `uid` = %d AND `resource-id` = '%s' ORDER BY `scale` ASC",
- intval(local_user()),
+ $r = q("SELECT * FROM `photo` WHERE `uid` = %d AND `resource-id` = '%s' ORDER BY `scale` ASC", intval(local_user()),
dbesc($resource_id)
- );
- if (!DBM::is_result($r)){
- notice(L10n::t('Permission denied.') . EOL );
+ );
+ if (!DBM::is_result($r)) {
+ notice(L10n::t('Permission denied.') . EOL);
return;
}
$havescale = false;
foreach ($r as $rr) {
- if($rr['scale'] == 5)
- $havescale = true;
+ if ($rr['scale'] == 5) $havescale = true;
}
// set an already uloaded photo as profile photo
// if photo is in 'Profile Photos', change it in db
- if (($r[0]['album']== L10n::t('Profile Photos')) && ($havescale)){
- $r=q("UPDATE `photo` SET `profile`=0 WHERE `profile`=1 AND `uid`=%d",
- intval(local_user()));
+ if (($r[0]['album'] == L10n::t('Profile Photos')) && ($havescale)) {
+ $r = q("UPDATE `photo` SET `profile`=0 WHERE `profile`=1 AND `uid`=%d", intval(local_user()));
- $r=q("UPDATE `photo` SET `profile`=1 WHERE `uid` = %d AND `resource-id` = '%s'",
- intval(local_user()),
+ $r = q("UPDATE `photo` SET `profile`=1 WHERE `uid` = %d AND `resource-id` = '%s'", intval(local_user()),
dbesc($resource_id)
- );
+ );
Contact::updateSelfFromUserID(local_user(), true);
// Update global directory in background
$url = $_SESSION['my_url'];
- if ($url && strlen(Config::get('system','directory'))) {
+ if ($url && strlen(Config::get('system', 'directory'))) {
Worker::add(PRIORITY_LOW, "Directory", $url);
}
@@ -229,7 +225,7 @@ function profile_photo_content(App $a) {
return; // NOTREACHED
}
$ph = new Image($r[0]['data'], $r[0]['type']);
- profile_photo_crop_ui_head($a, $ph);
+ $imagecrop = profile_photo_crop_ui_head($a, $ph);
// go ahead as we have jus uploaded a new photo to crop
}
@@ -238,11 +234,11 @@ function profile_photo_content(App $a) {
);
- if(! x($a->config,'imagecrop')) {
-
+ if (!empty($imagecrop)) {
$tpl = get_markup_template('profile_photo.tpl');
- $o = replace_macros($tpl,[
+ $o = replace_macros($tpl,
+ [
'$user' => $a->user['nickname'],
'$lbl_upfile' => L10n::t('Upload File:'),
'$lbl_profiles' => L10n::t('Select a profile:'),
@@ -250,23 +246,24 @@ function profile_photo_content(App $a) {
'$submit' => L10n::t('Upload'),
'$profiles' => $profiles,
'$form_security_token' => get_form_security_token("profile_photo"),
- '$select' => sprintf('%s %s', L10n::t('or'), ($newuser) ? '' . L10n::t('skip this step') . ' ' : '' . L10n::t('select a photo from your photo albums') . ' ')
+ '$select' => sprintf('%s %s', L10n::t('or'),
+ ($newuser) ? '' . L10n::t('skip this step') . ' ' : '' . L10n::t('select a photo from your photo albums') . ' ')
]);
return $o;
- }
- else {
- $filename = $a->config['imagecrop'] . '-' . $a->config['imagecrop_resolution'] . '.'.$a->config['imagecrop_ext'];
+ } else {
+ $filename = $imagecrop['hash'] . '-' . $imagecrop['resolution'] . '.' . $imagecrop['ext'];
$tpl = get_markup_template("cropbody.tpl");
- $o = replace_macros($tpl,[
- '$filename' => $filename,
- '$profile' => intval($_REQUEST['profile']),
- '$resource' => $a->config['imagecrop'] . '-' . $a->config['imagecrop_resolution'],
+ $o = replace_macros($tpl,
+ [
+ '$filename' => $filename,
+ '$profile' => intval($_REQUEST['profile']),
+ '$resource' => $imagecrop['hash'] . '-' . $imagecrop['resolution'],
'$image_url' => System::baseUrl() . '/photo/' . $filename,
- '$title' => L10n::t('Crop Image'),
- '$desc' => L10n::t('Please adjust the image cropping for optimum viewing.'),
+ '$title' => L10n::t('Crop Image'),
+ '$desc' => L10n::t('Please adjust the image cropping for optimum viewing.'),
'$form_security_token' => get_form_security_token("profile_photo"),
- '$done' => L10n::t('Done Editing')
+ '$done' => L10n::t('Done Editing')
]);
return $o;
}
@@ -274,10 +271,10 @@ function profile_photo_content(App $a) {
return; // NOTREACHED
}
-
-function profile_photo_crop_ui_head(App $a, Image $Image) {
- $max_length = Config::get('system','max_image_length');
- if (! $max_length) {
+function profile_photo_crop_ui_head(App $a, Image $Image)
+{
+ $max_length = Config::get('system', 'max_image_length');
+ if (!$max_length) {
$max_length = MAX_IMAGE_LENGTH;
}
if ($max_length > 0) {
@@ -318,10 +315,14 @@ function profile_photo_crop_ui_head(App $a, Image $Image) {
}
}
- $a->config['imagecrop'] = $hash;
- $a->config['imagecrop_resolution'] = $smallest;
- $a->config['imagecrop_ext'] = $Image->getExt();
$a->page['htmlhead'] .= replace_macros(get_markup_template("crophead.tpl"), []);
$a->page['end'] .= replace_macros(get_markup_template("cropend.tpl"), []);
- return;
+
+ $imagecrop = [
+ 'hash' => $hash,
+ 'resolution' => $smallest,
+ 'ext' => $Image->getExt(),
+ ];
+
+ return $imagecrop;
}
diff --git a/mod/redir.php b/mod/redir.php
index 8484b53eba..e448aa36d3 100644
--- a/mod/redir.php
+++ b/mod/redir.php
@@ -56,7 +56,7 @@ function redir_init(App $a) {
}
if (remote_user()) {
- $host = substr(System::baseUrl() . ($a->path ? '/' . $a->path : ''), strpos(System::baseUrl(), '://') + 3);
+ $host = substr(System::baseUrl() . ($a->urlpath ? '/' . $a->urlpath : ''), strpos(System::baseUrl(), '://') + 3);
$remotehost = substr($contact['addr'], strpos($contact['addr'], '@') + 1);
// On a local instance we have to check if the local user has already authenticated
diff --git a/mod/register.php b/mod/register.php
index 6b4f2b1f5c..aa0f2f59bc 100644
--- a/mod/register.php
+++ b/mod/register.php
@@ -21,8 +21,6 @@ function register_post(App $a)
{
check_form_security_token_redirectOnErr('/register', 'register');
- global $lang;
-
$verified = 0;
$blocked = 1;
@@ -37,7 +35,7 @@ function register_post(App $a)
}
}
- switch ($a->config['register_policy']) {
+ switch (Config::get('config', 'register_policy')) {
case REGISTER_OPEN:
$blocked = 0;
$verified = 1;
@@ -50,7 +48,7 @@ function register_post(App $a)
default:
case REGISTER_CLOSED:
- if ((!x($_SESSION, 'authenticated') && (!x($_SESSION, 'administrator')))) {
+ if (empty($_SESSION['authenticated']) && empty($_SESSION['administrator'])) {
notice(L10n::t('Permission denied.') . EOL);
return;
}
@@ -76,7 +74,7 @@ function register_post(App $a)
$user = $result['user'];
- if ($netpublish && $a->config['register_policy'] != REGISTER_APPROVE) {
+ if ($netpublish && intval(Config::get('config', 'register_policy')) !== REGISTER_APPROVE) {
$url = System::baseUrl() . '/profile/' . $user['nickname'];
Worker::add(PRIORITY_LOW, "Directory", $url);
}
@@ -85,7 +83,7 @@ function register_post(App $a)
$num_invites = Config::get('system', 'number_invites');
$invite_id = ((x($_POST, 'invite_id')) ? notags(trim($_POST['invite_id'])) : '');
- if ($a->config['register_policy'] == REGISTER_OPEN) {
+ if (intval(Config::get('config', 'register_policy')) === REGISTER_OPEN) {
if ($using_invites && $invite_id) {
q("delete * from register where hash = '%s' limit 1", dbesc($invite_id));
PConfig::set($user['uid'], 'system', 'invites_remaining', $num_invites);
@@ -94,7 +92,7 @@ function register_post(App $a)
// Only send a password mail when the password wasn't manually provided
if (!x($_POST, 'password1') || !x($_POST, 'confirm')) {
$res = User::sendRegisterOpenEmail(
- $user['email'], $a->config['sitename'], System::baseUrl(), $user['username'], $result['password']);
+ $user['email'], Config::get('config', 'sitename'), System::baseUrl(), $user['username'], $result['password']);
if ($res) {
info(L10n::t('Registration successful. Please check your email for further instructions.') . EOL);
@@ -111,8 +109,8 @@ function register_post(App $a)
info(L10n::t('Registration successful.') . EOL);
goaway(System::baseUrl());
}
- } elseif ($a->config['register_policy'] == REGISTER_APPROVE) {
- if (!strlen($a->config['admin_email'])) {
+ } elseif (intval(Config::get('config', 'register_policy')) === REGISTER_APPROVE) {
+ if (!strlen(Config::get('config', 'admin_email'))) {
notice(L10n::t('Your registration can not be processed.') . EOL);
goaway(System::baseUrl());
}
@@ -123,7 +121,7 @@ function register_post(App $a)
dbesc(DateTimeFormat::utcNow()),
intval($user['uid']),
dbesc($result['password']),
- dbesc($lang),
+ dbesc(Config::get('system', 'language')),
dbesc($_POST['permonlybox'])
);
@@ -134,7 +132,7 @@ function register_post(App $a)
}
// send email to admins
- $admin_mail_list = "'" . implode("','", array_map("dbesc", explode(",", str_replace(" ", "", $a->config['admin_email'])))) . "'";
+ $admin_mail_list = "'" . implode("','", array_map("dbesc", explode(",", str_replace(" ", "", Config::get('config', 'admin_email'))))) . "'";
$adminlist = q("SELECT uid, language, email FROM user WHERE email IN (%s)",
$admin_mail_list
);
@@ -158,7 +156,7 @@ function register_post(App $a)
}
// send notification to the user, that the registration is pending
User::sendRegisterPendingEmail(
- $user['email'], $a->config['sitename'], $user['username']);
+ $user['email'], Config::get('config', 'sitename'), $user['username']);
info(L10n::t('Your registration is pending approval by the site owner.') . EOL);
goaway(System::baseUrl());
@@ -179,7 +177,7 @@ function register_content(App $a)
return;
}
- if ((!local_user()) && ($a->config['register_policy'] == REGISTER_CLOSED)) {
+ if ((!local_user()) && (intval(Config::get('config', 'register_policy')) === REGISTER_CLOSED)) {
notice("Permission denied." . EOL);
return;
}
@@ -258,7 +256,7 @@ function register_content(App $a)
$o = replace_macros($tpl, [
'$oidhtml' => $oidhtml,
'$invitations' => Config::get('system', 'invitation_only'),
- '$permonly' => $a->config['register_policy'] == REGISTER_APPROVE,
+ '$permonly' => intval(Config::get('config', 'register_policy')) === REGISTER_APPROVE,
'$permonlybox' => ['permonlybox', L10n::t('Note for the admin'), '', L10n::t('Leave a message for the admin, why you want to join this node')],
'$invite_desc' => L10n::t('Membership on this site is by invitation only.'),
'$invite_label' => L10n::t('Your invitation code: '),
diff --git a/mod/regmod.php b/mod/regmod.php
index aa64986d06..2b7df0bd13 100644
--- a/mod/regmod.php
+++ b/mod/regmod.php
@@ -2,6 +2,7 @@
/**
* @file mod/regmod.php
*/
+
use Friendica\App;
use Friendica\Core\Config;
use Friendica\Core\L10n;
@@ -57,7 +58,7 @@ function user_allow($hash)
$res = User::sendRegisterOpenEmail(
$user[0]['email'],
- $a->config['sitename'],
+ Config::get('config', 'sitename'),
System::baseUrl(),
$user[0]['username'],
$register[0]['password']);
@@ -96,11 +97,9 @@ function user_deny($hash)
function regmod_content(App $a)
{
- global $lang;
-
if (!local_user()) {
info(L10n::t('Please login.') . EOL);
- $o = ' ' . Login::form($a->query_string, $a->config['register_policy'] == REGISTER_CLOSED ? 0 : 1);
+ $o = ' ' . Login::form($a->query_string, intval(Config::get('config', 'register_policy')) === REGISTER_CLOSED ? 0 : 1);
return $o;
}
diff --git a/mod/removeme.php b/mod/removeme.php
index 2db63d8d8e..dd0ca0f81f 100644
--- a/mod/removeme.php
+++ b/mod/removeme.php
@@ -2,11 +2,13 @@
/**
* @file mod/removeme.php
*/
+
use Friendica\App;
+use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\System;
-use Friendica\Model\User;
use Friendica\Database\DBM;
+use Friendica\Model\User;
require_once 'include/enotify.php';
@@ -34,7 +36,7 @@ function removeme_post(App $a)
// send notification to admins so that they can clean um the backups
// send email to admins
- $admin_mails = explode(",", str_replace(" ", "", $a->config['admin_email']));
+ $admin_mails = explode(",", str_replace(" ", "", Config::get('config', 'admin_email')));
foreach ($admin_mails as $mail) {
$admin = dba::selectFirst('user', ['uid', 'language', 'email'], ['email' => $mail]);
if (!DBM::is_result($admin)) {
diff --git a/mod/settings.php b/mod/settings.php
index d7e8b7b459..ff969d65eb 100644
--- a/mod/settings.php
+++ b/mod/settings.php
@@ -26,14 +26,12 @@ use Friendica\Util\Temporal;
function get_theme_config_file($theme)
{
$a = get_app();
- if (!empty($a->theme_info['extends'])) {
- $base_theme = $a->theme_info['extends'];
- }
+ $base_theme = defaults($a->theme_info, 'extends');
if (file_exists("view/theme/$theme/config.php")) {
return "view/theme/$theme/config.php";
}
- if (!empty($base_theme) && file_exists("view/theme/$base_theme/config.php")) {
+ if ($base_theme && file_exists("view/theme/$base_theme/config.php")) {
return "view/theme/$base_theme/config.php";
}
return null;
@@ -511,9 +509,8 @@ function settings_post(App $a)
$err .= L10n::t('Invalid email.');
}
// ensure new email is not the admin mail
- //if ((x($a->config, 'admin_email')) && (strcasecmp($email, $a->config['admin_email']) == 0)) {
- if (x($a->config, 'admin_email')) {
- $adminlist = explode(",", str_replace(" ", "", strtolower($a->config['admin_email'])));
+ if (Config::get('config', 'admin_email')) {
+ $adminlist = explode(",", str_replace(" ", "", strtolower(Config::get('config', 'admin_email'))));
if (in_array(strtolower($email), $adminlist)) {
$err .= L10n::t('Cannot change to that email.');
$email = $a->user['email'];
diff --git a/mod/statistics_json.php b/mod/statistics_json.php
index c035c1c05a..c197060ff5 100644
--- a/mod/statistics_json.php
+++ b/mod/statistics_json.php
@@ -17,10 +17,10 @@ function statistics_json_init(App $a) {
}
$statistics = [
- "name" => $a->config["sitename"],
+ "name" => Config::get('config', 'sitename'),
"network" => FRIENDICA_PLATFORM,
"version" => FRIENDICA_VERSION . "-" . DB_UPDATE_VERSION,
- "registrations_open" => ($a->config['register_policy'] != 0),
+ "registrations_open" => intval(Config::get('config', 'register_policy')) !== REGISTER_CLOSED,
"total_users" => Config::get('nodeinfo', 'total_users'),
"active_users_halfyear" => Config::get('nodeinfo', 'active_users_halfyear'),
"active_users_monthly" => Config::get('nodeinfo', 'active_users_monthly'),
diff --git a/mod/uimport.php b/mod/uimport.php
index 7d6805e7c7..1dbc571e2f 100644
--- a/mod/uimport.php
+++ b/mod/uimport.php
@@ -11,7 +11,7 @@ use Friendica\Core\UserImport;
function uimport_post(App $a)
{
- switch ($a->config['register_policy']) {
+ switch (Config::get('config', 'register_policy')) {
case REGISTER_OPEN:
$blocked = 0;
$verified = 1;
@@ -42,7 +42,7 @@ function uimport_post(App $a)
function uimport_content(App $a) {
- if ((!local_user()) && ($a->config['register_policy'] == REGISTER_CLOSED)) {
+ if ((!local_user()) && (intval(Config::get('config', 'register_policy')) === REGISTER_CLOSED)) {
notice("Permission denied." . EOL);
return;
}
diff --git a/src/App.php b/src/App.php
index 059efc17cc..08cf382b54 100644
--- a/src/App.php
+++ b/src/App.php
@@ -4,7 +4,6 @@
*/
namespace Friendica;
-use Friendica\Core\Cache;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
@@ -17,6 +16,7 @@ use Detection\MobileDetect;
use Exception;
require_once 'boot.php';
+require_once 'include/dba.php';
require_once 'include/text.php';
/**
@@ -34,15 +34,27 @@ require_once 'include/text.php';
*/
class App
{
- const MODE_NORMAL = 0;
- const MODE_INSTALL = 1;
- const MODE_MAINTENANCE = 2;
+ const MODE_LOCALCONFIGPRESENT = 1;
+ const MODE_DBAVAILABLE = 2;
+ const MODE_DBCONFIGAVAILABLE = 4;
+ const MODE_MAINTENANCEDISABLED = 8;
+
+ /**
+ * @deprecated since version 2008.08 Use App->isInstallMode() instead to check for install mode.
+ */
+ const MODE_INSTALL = 0;
+
+ /**
+ * @deprecated since version 2008.08 Use the precise mode constant to check for a specific capability instead.
+ */
+ const MODE_NORMAL = App::MODE_LOCALCONFIGPRESENT | App::MODE_DBAVAILABLE | App::MODE_DBCONFIGAVAILABLE | App::MODE_MAINTENANCEDISABLED;
public $module_loaded = false;
public $module_class = null;
- public $query_string;
- public $config;
- public $page;
+ public $query_string = '';
+ public $config = [];
+ public $page = [];
+ public $pager = [];
public $page_offset;
public $profile;
public $profile_uid;
@@ -54,16 +66,15 @@ class App
public $content;
public $data = [];
public $error = false;
- public $cmd;
+ public $cmd = '';
public $argv;
public $argc;
public $module;
- public $mode = App::MODE_NORMAL;
- public $pager;
+ public $mode = App::MODE_INSTALL;
public $strings;
public $basepath;
- public $path;
- public $hooks;
+ public $urlpath;
+ public $hooks = [];
public $timezone;
public $interactive = true;
public $addons;
@@ -127,7 +138,6 @@ class App
private $curl_code;
private $curl_content_type;
private $curl_headers;
- private static $a;
/**
* @brief App constructor.
@@ -136,21 +146,32 @@ class App
*/
public function __construct($basepath)
{
- global $default_timezone;
-
if (!static::directory_usable($basepath, false)) {
throw new Exception('Basepath ' . $basepath . ' isn\'t usable.');
}
+ BaseObject::setApp($this);
+
$this->basepath = rtrim($basepath, DIRECTORY_SEPARATOR);
- if (file_exists($this->basepath . DIRECTORY_SEPARATOR . '.htpreconfig.php')) {
- include $this->basepath . DIRECTORY_SEPARATOR . '.htpreconfig.php';
+ // The order of the following calls is important to ensure proper initialization
+ $this->loadConfigFiles();
+
+ $this->loadDatabase();
+
+ $this->determineMode();
+
+ $this->determineUrlPath();
+
+ Config::load();
+
+ if ($this->mode & self::MODE_DBAVAILABLE) {
+ Core\Addon::loadHooks();
+
+ $this->loadAddonConfig();
}
- $this->timezone = ((x($default_timezone)) ? $default_timezone : 'UTC');
-
- date_default_timezone_set($this->timezone);
+ $this->loadDefaultTimezone();
$this->performance['start'] = microtime(true);
$this->performance['database'] = 0;
@@ -173,8 +194,6 @@ class App
$this->callstack['rendering'] = [];
$this->callstack['parser'] = [];
- $this->config = [];
-
$this->page = [
'aside' => '',
'bottom' => '',
@@ -189,10 +208,6 @@ class App
'title' => ''
];
- $this->pager = [];
-
- $this->query_string = '';
-
$this->process_id = System::processID('log');
set_time_limit(0);
@@ -218,16 +233,6 @@ class App
if (x($_SERVER, 'SERVER_PORT') && $_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443) {
$this->hostname .= ':' . $_SERVER['SERVER_PORT'];
}
- /*
- * Figure out if we are running at the top of a domain
- * or in a sub-directory and adjust accordingly
- */
-
- /// @TODO This kind of escaping breaks syntax-highlightning on CoolEdit (Midnight Commander)
- $path = trim(dirname($_SERVER['SCRIPT_NAME']), '/\\');
- if (isset($path) && strlen($path) && ($path != $this->path)) {
- $this->path = $path;
- }
}
set_include_path(
@@ -238,19 +243,16 @@ class App
if ((x($_SERVER, 'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'], 0, 9) === 'pagename=') {
$this->query_string = substr($_SERVER['QUERY_STRING'], 9);
-
- // removing trailing / - maybe a nginx problem
- $this->query_string = ltrim($this->query_string, '/');
} elseif ((x($_SERVER, 'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'], 0, 2) === 'q=') {
$this->query_string = substr($_SERVER['QUERY_STRING'], 2);
-
- // removing trailing / - maybe a nginx problem
- $this->query_string = ltrim($this->query_string, '/');
}
- if (x($_GET, 'pagename')) {
+ // removing trailing / - maybe a nginx problem
+ $this->query_string = ltrim($this->query_string, '/');
+
+ if (!empty($_GET['pagename'])) {
$this->cmd = trim($_GET['pagename'], '/\\');
- } elseif (x($_GET, 'q')) {
+ } elseif (!empty($_GET['q'])) {
$this->cmd = trim($_GET['q'], '/\\');
}
@@ -311,16 +313,251 @@ class App
// Register template engines
$this->register_template_engine('Friendica\Render\FriendicaSmartyEngine');
+ }
- /**
- * Load the configuration file which contains our DB credentials.
- * Ignore errors. If the file doesn't exist or is empty, we are running in
- * installation mode. *
+ /**
+ * Load the configuration files
+ *
+ * First loads the default value for all the configuration keys, then the legacy configuration files, then the
+ * expected local.ini.php
+ */
+ private function loadConfigFiles()
+ {
+ $this->loadConfigFile($this->basepath . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.ini.php');
+ $this->loadConfigFile($this->basepath . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'settings.ini.php');
+
+ // Legacy .htconfig.php support
+ if (file_exists($this->basepath . DIRECTORY_SEPARATOR . '.htpreconfig.php')) {
+ $a = $this;
+ include $this->basepath . DIRECTORY_SEPARATOR . '.htpreconfig.php';
+ }
+
+ // Legacy .htconfig.php support
+ if (file_exists($this->basepath . DIRECTORY_SEPARATOR . '.htconfig.php')) {
+ $a = $this;
+
+ include $this->basepath . DIRECTORY_SEPARATOR . '.htconfig.php';
+
+ $this->setConfigValue('database', 'hostname', $db_host);
+ $this->setConfigValue('database', 'username', $db_user);
+ $this->setConfigValue('database', 'password', $db_pass);
+ $this->setConfigValue('database', 'database', $db_data);
+ if (isset($a->config['system']['db_charset'])) {
+ $this->setConfigValue('database', 'charset', $a->config['system']['db_charset']);
+ }
+
+ unset($db_host, $db_user, $db_pass, $db_data);
+
+ if (isset($default_timezone)) {
+ $this->setConfigValue('system', 'default_timezone', $default_timezone);
+ unset($default_timezone);
+ }
+
+ if (isset($pidfile)) {
+ $this->setConfigValue('system', 'pidfile', $pidfile);
+ unset($pidfile);
+ }
+
+ if (isset($lang)) {
+ $this->setConfigValue('system', 'language', $lang);
+ unset($lang);
+ }
+ }
+
+ if (file_exists($this->basepath . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'local.ini.php')) {
+ $this->loadConfigFile($this->basepath . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'local.ini.php');
+ }
+ }
+
+ /**
+ * Tries to load the specified configuration file into the App->config array.
+ * Overwrites previously set values.
+ *
+ * The config format is INI and the template for configuration files is the following:
+ *
+ * $values) {
+ foreach ($values as $key => $value) {
+ $this->setConfigValue($category, $key, $value);
+ }
+ }
+ }
+
+ /**
+ * Loads addons configuration files
+ *
+ * First loads all activated addons default configuration throught the load_config hook, then load the local.ini.php
+ * again to overwrite potential local addon configuration.
+ */
+ private function loadAddonConfig()
+ {
+ // Loads addons default config
+ Core\Addon::callHooks('load_config');
+
+ // Load the local addon config file to overwritten default addon config values
+ if (file_exists($this->basepath . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'addon.ini.php')) {
+ $this->loadConfigFile($this->basepath . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'addon.ini.php');
+ }
+ }
+
+ /**
+ * Loads the default timezone
+ *
+ * Include support for legacy $default_timezone
+ *
+ * @global string $default_timezone
+ */
+ private function loadDefaultTimezone()
+ {
+ if ($this->getConfigValue('system', 'default_timezone')) {
+ $this->timezone = $this->getConfigValue('system', 'default_timezone');
+ } else {
+ global $default_timezone;
+ $this->timezone = !empty($default_timezone) ? $default_timezone : 'UTC';
+ }
+
+ if ($this->timezone) {
+ date_default_timezone_set($this->timezone);
+ }
+ }
+
+ /**
+ * Figure out if we are running at the top of a domain or in a sub-directory and adjust accordingly
+ */
+ private function determineUrlPath()
+ {
+ $this->urlpath = $this->getConfigValue('system', 'urlpath');
+
+ /* SCRIPT_URL gives /path/to/friendica/module/parameter
+ * QUERY_STRING gives pagename=module/parameter
+ *
+ * To get /path/to/friendica we perform dirname() for as many levels as there are slashes in the QUERY_STRING
*/
- $this->mode = ((file_exists('.htconfig.php') && filesize('.htconfig.php')) ? App::MODE_NORMAL : App::MODE_INSTALL);
+ if (!empty($_SERVER['SCRIPT_URL'])) {
+ // Module
+ if (!empty($_SERVER['QUERY_STRING'])) {
+ $path = trim(dirname($_SERVER['SCRIPT_URL'], substr_count(trim($_SERVER['QUERY_STRING'], '/'), '/') + 1), '/');
+ } else {
+ // Root page
+ $path = trim($_SERVER['SCRIPT_URL'], '/');
+ }
+ if ($path && $path != $this->urlpath) {
+ $this->urlpath = $path;
+ }
+ }
+ }
- self::$a = $this;
+ /**
+ * Sets the App mode
+ *
+ * - App::MODE_INSTALL : Either the database connection can't be established or the config table doesn't exist
+ * - App::MODE_MAINTENANCE: The maintenance mode has been set
+ * - App::MODE_NORMAL : Normal run with all features enabled
+ *
+ * @return type
+ */
+ private function determineMode()
+ {
+ $this->mode = 0;
+
+ if (!file_exists($this->basepath . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'local.ini.php')
+ && !file_exists($this->basepath . DIRECTORY_SEPARATOR . '.htconfig.php')) {
+ return;
+ }
+
+ $this->mode |= App::MODE_LOCALCONFIGPRESENT;
+
+ if (!\dba::connected()) {
+ return;
+ }
+
+ $this->mode |= App::MODE_DBAVAILABLE;
+
+ if (\dba::fetch_first("SHOW TABLES LIKE 'config'") === false) {
+ return;
+ }
+
+ $this->mode |= App::MODE_DBCONFIGAVAILABLE;
+
+ if (Config::get('system', 'maintenance')) {
+ return;
+ }
+
+ $this->mode |= App::MODE_MAINTENANCEDISABLED;
+ }
+
+ public function loadDatabase()
+ {
+ if (\dba::connected()) {
+ return;
+ }
+
+ $db_host = $this->getConfigValue('database', 'hostname');
+ $db_user = $this->getConfigValue('database', 'username');
+ $db_pass = $this->getConfigValue('database', 'password');
+ $db_data = $this->getConfigValue('database', 'database');
+ $charset = $this->getConfigValue('database', 'charset');
+
+ // Use environment variables for mysql if they are set beforehand
+ if (!empty(getenv('MYSQL_HOST'))
+ && (!empty(getenv('MYSQL_USERNAME')) || !empty(getenv('MYSQL_USER')))
+ && getenv('MYSQL_PASSWORD') !== false
+ && !empty(getenv('MYSQL_DATABASE')))
+ {
+ $db_host = getenv('MYSQL_HOST');
+ if (!empty(getenv('MYSQL_PORT'))) {
+ $db_host .= ':' . getenv('MYSQL_PORT');
+ }
+ if (!empty(getenv('MYSQL_USERNAME'))) {
+ $db_user = getenv('MYSQL_USERNAME');
+ } else {
+ $db_user = getenv('MYSQL_USER');
+ }
+ $db_pass = (string) getenv('MYSQL_PASSWORD');
+ $db_data = getenv('MYSQL_DATABASE');
+ }
+
+ $stamp1 = microtime(true);
+
+ \dba::connect($db_host, $db_user, $db_pass, $db_data, $charset);
+ unset($db_host, $db_user, $db_pass, $db_data, $charset);
+
+ $this->save_timestamp($stamp1, 'network');
+ }
+
+ /**
+ * Install mode is when the local config file is missing or the DB schema hasn't been installed yet.
+ *
+ * @return bool
+ */
+ public function isInstallMode()
+ {
+ return !($this->mode & App::MODE_LOCALCONFIGPRESENT) || !($this->mode & App::MODE_DBCONFIGAVAILABLE);
}
/**
@@ -413,7 +650,7 @@ class App
$this->hostname = Config::get('config', 'hostname');
}
- return $scheme . '://' . $this->hostname . ((isset($this->path) && strlen($this->path)) ? '/' . $this->path : '' );
+ return $scheme . '://' . $this->hostname . (!empty($this->urlpath) ? '/' . $this->urlpath : '' );
}
/**
@@ -441,7 +678,7 @@ class App
$hostname .= ':' . $parsed['port'];
}
if (x($parsed, 'path')) {
- $this->path = trim($parsed['path'], '\\/');
+ $this->urlpath = trim($parsed['path'], '\\/');
}
if (file_exists($this->basepath . DIRECTORY_SEPARATOR . '.htpreconfig.php')) {
@@ -469,7 +706,7 @@ class App
public function get_path()
{
- return $this->path;
+ return $this->urlpath;
}
public function set_pager_total($n)
@@ -775,7 +1012,7 @@ class App
*
* @return bool Is the limit reached?
*/
- public function max_processes_reached()
+ public function isMaxProcessesReached()
{
// Deactivated, needs more investigating if this check really makes sense
return false;
@@ -855,7 +1092,7 @@ class App
*
* @return bool Is the load reached?
*/
- public function maxload_reached()
+ public function isMaxLoadReached()
{
if ($this->is_backend()) {
$process = 'backend';
@@ -1107,21 +1344,6 @@ class App
return $sender_email;
}
- /**
- * @note Checks, if the App is in the Maintenance-Mode
- *
- * @return boolean
- */
- public function checkMaintenanceMode()
- {
- if (Config::get('system', 'maintenance')) {
- $this->mode = App::MODE_MAINTENANCE;
- return true;
- }
-
- return false;
- }
-
/**
* Returns the current theme name.
*
@@ -1129,7 +1351,7 @@ class App
*/
public function getCurrentTheme()
{
- if ($this->mode == App::MODE_INSTALL) {
+ if ($this->isInstallMode()) {
return '';
}
diff --git a/src/BaseObject.php b/src/BaseObject.php
index 5adfe096d7..6b64daccf0 100644
--- a/src/BaseObject.php
+++ b/src/BaseObject.php
@@ -24,12 +24,10 @@ class BaseObject
*/
public static function getApp()
{
- if (self::$app) {
- return self::$app;
+ if (empty(self::$app)) {
+ self::$app = new App(dirname(__DIR__));
}
- self::$app = get_app();
-
return self::$app;
}
@@ -40,7 +38,7 @@ class BaseObject
*
* @return void
*/
- public static function setApp($app)
+ public static function setApp(App $app)
{
self::$app = $app;
}
diff --git a/src/Content/Nav.php b/src/Content/Nav.php
index b0fe8a14e6..92ca714df8 100644
--- a/src/Content/Nav.php
+++ b/src/Content/Nav.php
@@ -124,7 +124,7 @@ class Nav
$nav['home'] = [$homelink, L10n::t('Home'), '', L10n::t('Home Page')];
}
- if (($a->config['register_policy'] == REGISTER_OPEN) && (! local_user()) && (! remote_user())) {
+ if (intval(Config::get('config', 'register_policy')) === REGISTER_OPEN && !local_user() && !remote_user()) {
$nav['register'] = ['register', L10n::t('Register'), '', L10n::t('Create an account')];
}
diff --git a/src/Content/Text/BBCode.php b/src/Content/Text/BBCode.php
index fdabadef56..6c21a37cba 100644
--- a/src/Content/Text/BBCode.php
+++ b/src/Content/Text/BBCode.php
@@ -1,5 +1,4 @@
"hostname, port(, weight)",
+ * 1 => ...
+ * }
+ *
+ * @param array $memcached_hosts
+ * @throws \Exception
+ */
public function __construct(array $memcached_hosts)
{
if (!class_exists('Memcached', false)) {
@@ -30,6 +40,12 @@ class MemcachedCacheDriver extends AbstractCacheDriver implements IMemoryCacheDr
$this->memcached = new Memcached();
+ array_walk($memcached_hosts, function (&$value) {
+ if (is_string($value)) {
+ $value = array_map('trim', explode(',', $value));
+ }
+ });
+
$this->memcached->addServers($memcached_hosts);
if (count($this->memcached->getServerList()) == 0) {
diff --git a/src/Core/Config.php b/src/Core/Config.php
index 3c1d3245fd..93cb266577 100644
--- a/src/Core/Config.php
+++ b/src/Core/Config.php
@@ -29,6 +29,11 @@ class Config extends BaseObject
public static function init()
{
+ // Database isn't ready or populated yet
+ if (!(self::getApp()->mode & \Friendica\App::MODE_DBCONFIGAVAILABLE)) {
+ return;
+ }
+
if (self::getApp()->getConfigValue('system', 'config_adapter') == 'preload') {
self::$adapter = new Config\PreloadConfigAdapter();
} else {
@@ -48,6 +53,11 @@ class Config extends BaseObject
*/
public static function load($family = "config")
{
+ // Database isn't ready or populated yet
+ if (!(self::getApp()->mode & \Friendica\App::MODE_DBCONFIGAVAILABLE)) {
+ return;
+ }
+
if (empty(self::$adapter)) {
self::init();
}
@@ -76,6 +86,11 @@ class Config extends BaseObject
*/
public static function get($family, $key, $default_value = null, $refresh = false)
{
+ // Database isn't ready or populated yet, fallback to file config
+ if (!(self::getApp()->mode & \Friendica\App::MODE_DBCONFIGAVAILABLE)) {
+ return self::getApp()->getConfigValue($family, $key, $default_value);
+ }
+
if (empty(self::$adapter)) {
self::init();
}
@@ -99,6 +114,11 @@ class Config extends BaseObject
*/
public static function set($family, $key, $value)
{
+ // Database isn't ready or populated yet
+ if (!(self::getApp()->mode & \Friendica\App::MODE_DBCONFIGAVAILABLE)) {
+ return false;
+ }
+
if (empty(self::$adapter)) {
self::init();
}
@@ -119,6 +139,11 @@ class Config extends BaseObject
*/
public static function delete($family, $key)
{
+ // Database isn't ready or populated yet
+ if (!(self::getApp()->mode & \Friendica\App::MODE_DBCONFIGAVAILABLE)) {
+ return false;
+ }
+
if (empty(self::$adapter)) {
self::init();
}
diff --git a/src/Core/Config/JITConfigAdapter.php b/src/Core/Config/JITConfigAdapter.php
index 0e7731690b..c03a010cd4 100644
--- a/src/Core/Config/JITConfigAdapter.php
+++ b/src/Core/Config/JITConfigAdapter.php
@@ -66,11 +66,17 @@ 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;
return $a->config[$cat][$k];
+ } elseif (isset($a->config[$k])) {
+ // Assign the value (mostly) from config/local.ini.php file to the cache
+ $this->cache[$k] = $a->config[$k];
+ $this->in_db[$k] = false;
+
+ return $a->config[$k];
}
$this->cache[$cat][$k] = '!!';
diff --git a/src/Core/Console/ArchiveContact.php b/src/Core/Console/ArchiveContact.php
index 7a973f3116..63ace91c0f 100644
--- a/src/Core/Console/ArchiveContact.php
+++ b/src/Core/Console/ArchiveContact.php
@@ -54,12 +54,8 @@ HELP;
throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
}
- require_once '.htconfig.php';
- $result = \dba::connect($db_host, $db_user, $db_pass, $db_data);
- unset($db_host, $db_user, $db_pass, $db_data);
-
- if (!$result) {
- throw new \RuntimeException('Unable to connect to database');
+ if ($a->mode === App::MODE_INSTALL) {
+ throw new \RuntimeException('Friendica isn\'t properly installed yet.');
}
$nurl = normalise_link($this->getArgument(0));
diff --git a/src/Core/Console/AutomaticInstallation.php b/src/Core/Console/AutomaticInstallation.php
index e0eea1f507..4822368ab5 100644
--- a/src/Core/Console/AutomaticInstallation.php
+++ b/src/Core/Console/AutomaticInstallation.php
@@ -5,8 +5,10 @@ namespace Friendica\Core\Console;
use Asika\SimpleConsole\Console;
use dba;
use Friendica\App;
+use Friendica\Core\Config;
use Friendica\Core\Install;
use Friendica\Core\Theme;
+use RuntimeException;
require_once 'mod/install.php';
require_once 'include/dba.php';
@@ -18,8 +20,8 @@ class AutomaticInstallation extends Console
return <<extractErrors($checkResults['basic']);
if ($errorMessage !== '') {
- throw new \RuntimeException($errorMessage);
+ throw new RuntimeException($errorMessage);
}
$this->out(" Complete!\n\n");
@@ -75,7 +77,7 @@ HELP;
$errorMessage = $this->extractErrors($checkResults['db']);
if ($errorMessage !== '') {
- throw new \RuntimeException($errorMessage);
+ throw new RuntimeException($errorMessage);
}
$this->out(" Complete!\n\n");
@@ -86,15 +88,15 @@ HELP;
$checkResults['data'] = Install::installDatabaseStructure();
if ($checkResults['data'] !== '') {
- throw new \RuntimeException("ERROR: DB Database creation error. Is the DB empty?\n");
+ throw new RuntimeException("ERROR: DB Database creation error. Is the DB empty?\n");
}
$this->out(" Complete!\n\n");
// Install theme
$this->out("Installing theme\n");
- if (!empty($a->config['system']['theme'])) {
- Theme::install($a->config['system']['theme']);
+ if (!empty(Config::get('system', 'theme'))) {
+ Theme::install(Config::get('system', 'theme'));
$this->out(" Complete\n\n");
} else {
$this->out(" Theme setting is empty. Please check the file htconfig.php\n\n");
@@ -103,7 +105,7 @@ HELP;
// Copy config file
$this->out("Saving config file...\n");
if ($config_file != '.htconfig.php' && !copy($config_file, '.htconfig.php')) {
- throw new \RuntimeException("ERROR: Saving config file failed. Please copy '$config_file' to '.htconfig.php' manually.\n");
+ throw new RuntimeException("ERROR: Saving config file failed. Please copy '$config_file' to '.htconfig.php' manually.\n");
}
$this->out(" Complete!\n\n");
$this->out("\nInstallation is finished\n");
@@ -121,14 +123,14 @@ HELP;
Install::checkFunctions($checks);
Install::checkImagick($checks);
- Install::checkHtConfig($checks);
+ Install::checkLocalIni($checks);
Install::checkSmarty3($checks);
Install::checkKeys($checks);
- if (!empty($app->config['php_path'])) {
- Install::checkPHP($app->config['php_path'], $checks);
+ if (!empty(Config::get('config', 'php_path'))) {
+ Install::checkPHP(Config::get('config', 'php_path'), $checks);
} else {
- throw new \RuntimeException(" ERROR: The php_path is not set in the config. Please check the file .htconfig.php.\n");
+ throw new RuntimeException(" ERROR: The php_path is not set in the config.\n");
}
$this->out(" NOTICE: Not checking .htaccess/URL-Rewrite during CLI installation.\n");
diff --git a/src/Core/Console/Config.php b/src/Core/Console/Config.php
index 306e1c275e..c37dd26b15 100644
--- a/src/Core/Console/Config.php
+++ b/src/Core/Console/Config.php
@@ -67,7 +67,7 @@ Description
Sets the value of the provided key in the category
Notes:
- Setting config entries which are manually set in .htconfig.php may result in
+ Setting config entries which are manually set in config/local.ini.php may result in
conflict between database settings and the manual startup settings.
Options
@@ -92,32 +92,56 @@ HELP;
throw new CommandArgsException('Too many arguments');
}
- require_once '.htconfig.php';
- $result = dba::connect($db_host, $db_user, $db_pass, $db_data);
- unset($db_host, $db_user, $db_pass, $db_data);
-
- if (!$result) {
- throw new \RuntimeException('Unable to connect to database');
+ if (!($a->mode & \Friendica\App::MODE_DBCONFIGAVAILABLE)) {
+ $this->out('Database isn\'t ready or populated yet, showing file config only');
}
if (count($this->args) == 3) {
- Core\Config::set($this->getArgument(0), $this->getArgument(1), $this->getArgument(2));
- $this->out("config[{$this->getArgument(0)}][{$this->getArgument(1)}] = " . Core\Config::get($this->getArgument(0),
- $this->getArgument(1)));
+ $cat = $this->getArgument(0);
+ $key = $this->getArgument(1);
+ $value = $this->getArgument(2);
+
+ if (is_array(Core\Config::get($cat, $key))) {
+ throw new \RuntimeException("$cat.$key is an array and can't be set using this command.");
+ }
+
+ $result = Core\Config::set($cat, $key, $value);
+ if ($result) {
+ $this->out("{$cat}.{$key} <= " .
+ Core\Config::get($cat, $key));
+ } else {
+ $this->out("Unable to set {$cat}.{$key}");
+ }
}
if (count($this->args) == 2) {
- $this->out("config[{$this->getArgument(0)}][{$this->getArgument(1)}] = " . Core\Config::get($this->getArgument(0),
- $this->getArgument(1)));
+ $cat = $this->getArgument(0);
+ $key = $this->getArgument(1);
+ $value = Core\Config::get($this->getArgument(0), $this->getArgument(1));
+
+ if (is_array($value)) {
+ foreach ($value as $k => $v) {
+ $this->out("{$cat}.{$key}[{$k}] => " . $v);
+ }
+ } else {
+ $this->out("{$cat}.{$key} => " . $value);
+ }
}
if (count($this->args) == 1) {
- Core\Config::load($this->getArgument(0));
+ $cat = $this->getArgument(0);
+ Core\Config::load($cat);
- $a = get_app();
- if (!is_null($a->config[$this->getArgument(0)])) {
- foreach ($a->config[$this->getArgument(0)] as $k => $x) {
- $this->out("config[{$this->getArgument(0)}][{$k}] = " . $x);
+ if (!is_null($a->config[$cat])) {
+ $this->out("[{$cat}]");
+ foreach ($a->config[$cat] as $key => $value) {
+ if (is_array($value)) {
+ foreach ($value as $k => $v) {
+ $this->out("{$key}[{$k}] => " . $v);
+ }
+ } else {
+ $this->out("{$key} => " . $value);
+ }
}
} else {
$this->out('Config section ' . $this->getArgument(0) . ' returned nothing');
@@ -125,13 +149,29 @@ HELP;
}
if (count($this->args) == 0) {
- $configs = dba::select('config');
- foreach ($configs as $config) {
- $this->out("config[{$config['cat']}][{$config['k']}] = " . $config['v']);
+ Core\Config::load();
+
+ if (Core\Config::get('system', 'config_adapter') == 'jit' && $a->mode & \Friendica\App::MODE_DBCONFIGAVAILABLE) {
+ $this->out('Warning: The JIT (Just In Time) Config adapter doesn\'t support loading the entire configuration, showing file config only');
+ }
+
+ foreach ($a->config as $cat => $section) {
+ if (is_array($section)) {
+ foreach ($section as $key => $value) {
+ if (is_array($value)) {
+ foreach ($value as $k => $v) {
+ $this->out("{$cat}.{$key}[{$k}] => " . $v);
+ }
+ } else {
+ $this->out("{$cat}.{$key} => " . $value);
+ }
+ }
+ } else {
+ $this->out("config.{$cat} => " . $section);
+ }
}
}
return 0;
}
-
}
diff --git a/src/Core/Console/DatabaseStructure.php b/src/Core/Console/DatabaseStructure.php
index eb4c6df998..1190484310 100644
--- a/src/Core/Console/DatabaseStructure.php
+++ b/src/Core/Console/DatabaseStructure.php
@@ -56,11 +56,7 @@ HELP;
throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
}
- require_once '.htconfig.php';
- $result = \dba::connect($db_host, $db_user, $db_pass, $db_data);
- unset($db_host, $db_user, $db_pass, $db_data);
-
- if (!$result) {
+ if (!\dba::connected()) {
throw new \RuntimeException('Unable to connect to database');
}
diff --git a/src/Core/Console/GlobalCommunityBlock.php b/src/Core/Console/GlobalCommunityBlock.php
index 26c5d13131..59a5d9cfdc 100644
--- a/src/Core/Console/GlobalCommunityBlock.php
+++ b/src/Core/Console/GlobalCommunityBlock.php
@@ -56,12 +56,8 @@ HELP;
throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
}
- require_once '.htconfig.php';
- $result = \dba::connect($db_host, $db_user, $db_pass, $db_data);
- unset($db_host, $db_user, $db_pass, $db_data);
-
- if (!$result) {
- throw new \RuntimeException('Unable to connect to database');
+ if ($a->isInstallMode()) {
+ throw new \RuntimeException('Database isn\'t ready or populated yet');
}
$contact_id = Contact::getIdForURL($this->getArgument(0));
diff --git a/src/Core/Console/GlobalCommunitySilence.php b/src/Core/Console/GlobalCommunitySilence.php
index 72d5a4f881..ccd6014e9c 100644
--- a/src/Core/Console/GlobalCommunitySilence.php
+++ b/src/Core/Console/GlobalCommunitySilence.php
@@ -64,12 +64,8 @@ HELP;
throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
}
- require_once '.htconfig.php';
- $result = \dba::connect($db_host, $db_user, $db_pass, $db_data);
- unset($db_host, $db_user, $db_pass, $db_data);
-
- if (!$result) {
- throw new \RuntimeException('Unable to connect to database');
+ if ($a->isInstallMode()) {
+ throw new \RuntimeException('Database isn\'t ready or populated yet');
}
/**
diff --git a/src/Core/Console/Maintenance.php b/src/Core/Console/Maintenance.php
index 6638e4bfe1..90449c4787 100644
--- a/src/Core/Console/Maintenance.php
+++ b/src/Core/Console/Maintenance.php
@@ -64,12 +64,8 @@ HELP;
throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
}
- require_once '.htconfig.php';
- $result = \dba::connect($db_host, $db_user, $db_pass, $db_data);
- unset($db_host, $db_user, $db_pass, $db_data);
-
- if (!$result) {
- throw new \RuntimeException('Unable to connect to database');
+ if ($a->isInstallMode()) {
+ throw new \RuntimeException('Database isn\'t ready or populated yet');
}
Core\Config::load();
diff --git a/src/Core/Console/NewPassword.php b/src/Core/Console/NewPassword.php
index f5698ba716..0035974727 100644
--- a/src/Core/Console/NewPassword.php
+++ b/src/Core/Console/NewPassword.php
@@ -58,12 +58,8 @@ HELP;
throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
}
- require_once '.htconfig.php';
- $result = \dba::connect($db_host, $db_user, $db_pass, $db_data);
- unset($db_host, $db_user, $db_pass, $db_data);
-
- if (!$result) {
- throw new \RuntimeException('Unable to connect to database');
+ if ($a->isInstallMode()) {
+ throw new \RuntimeException('Database isn\'t ready or populated yet');
}
$nick = $this->getArgument(0);
diff --git a/src/Core/Install.php b/src/Core/Install.php
index 65ef1db241..ec33ef9634 100644
--- a/src/Core/Install.php
+++ b/src/Core/Install.php
@@ -42,7 +42,7 @@ class Install extends BaseObject
self::checkImagick($checks);
- self::checkHtConfig($checks);
+ self::checkLocalIni($checks);
self::checkSmarty3($checks);
@@ -54,7 +54,7 @@ class Install extends BaseObject
$checkspassed = array_reduce($checks,
function ($v, $c) {
- if ($c['require']) {
+ if (!empty($c['require'])) {
$v = $v && $c['status'];
}
return $v;
@@ -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')
@@ -80,9 +80,9 @@ class Install extends BaseObject
* @param string $adminmail Mail-Adress of the administrator
* @param int $rino Rino-enabled (1 = true, 0 = false)
*/
- public static function install($urlpath, $dbhost, $dbuser, $dbpass, $dbdata, $phpath, $timezone, $language, $adminmail, $rino = 1)
+ public static function install($urlpath, $dbhost, $dbuser, $dbpass, $dbdata, $phpath, $timezone, $language, $adminmail)
{
- $tpl = get_markup_template('htconfig.tpl');
+ $tpl = get_markup_template('local.ini.tpl');
$txt = replace_macros($tpl,[
'$dbhost' => $dbhost,
'$dbuser' => $dbuser,
@@ -93,10 +93,9 @@ class Install extends BaseObject
'$urlpath' => $urlpath,
'$phpath' => $phpath,
'$adminmail' => $adminmail,
- '$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,27 +302,27 @@ 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!)
*/
- public static function checkHtConfig(&$checks)
+ public static function checkLocalIni(&$checks)
{
$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);
}
@@ -376,7 +375,7 @@ class Install extends BaseObject
$error_msg = [];
$error_msg['head'] = L10n::t('Error message from Curl when fetching');
$error_msg['url'] = $test['redirect_url'];
- $error_msg['msg'] = $test['error'];
+ $error_msg['msg'] = defaults($test, 'error', '');
}
self::addCheck($checks, L10n::t('Url rewrite is working'), $status, true, $help, $error_msg);
} else {
diff --git a/src/Core/L10n.php b/src/Core/L10n.php
index 24be010955..2389817021 100644
--- a/src/Core/L10n.php
+++ b/src/Core/L10n.php
@@ -14,7 +14,7 @@ require_once 'include/dba.php';
* Provide Languange, Translation, and Localisation functions to the application
* Localisation can be referred to by the numeronym L10N (as in: "L", followed by ten more letters, and then "N").
*/
-class L10n
+class L10n extends \Friendica\BaseObject
{
/**
* @brief get the prefered language from the HTTP_ACCEPT_LANGUAGE header
@@ -62,11 +62,11 @@ class L10n
*/
public static function pushLang($language)
{
- global $lang, $a;
+ $a = self::getApp();
- $a->langsave = $lang;
+ $a->langsave = Config::get('system', 'language');
- if ($language === $lang) {
+ if ($language === $a->langsave) {
return;
}
@@ -75,7 +75,7 @@ class L10n
}
$a->strings = [];
self::loadTranslationTable($language);
- $lang = $language;
+ Config::set('system', 'language', $language);
}
/**
@@ -83,9 +83,9 @@ class L10n
*/
public static function popLang()
{
- global $lang, $a;
+ $a = self::getApp();
- if ($lang === $a->langsave) {
+ if (Config::get('system', 'language') === $a->langsave) {
return;
}
@@ -95,7 +95,7 @@ class L10n
$a->strings = [];
}
- $lang = $a->langsave;
+ Config::set('system', 'language', $a->langsave);
}
/**
@@ -107,7 +107,7 @@ class L10n
*/
public static function loadTranslationTable($lang)
{
- $a = get_app();
+ $a = self::getApp();
$a->strings = [];
// load enabled addons strings
@@ -142,7 +142,7 @@ class L10n
*/
public static function t($s, ...$vars)
{
- $a = get_app();
+ $a = self::getApp();
if (empty($s)) {
return '';
@@ -173,7 +173,6 @@ class L10n
* - L10n::tt('Like', 'Likes', $count)
* - L10n::tt("%s user deleted", "%s users deleted", count($users))
*
- * @global type $lang
* @param string $singular
* @param string $plural
* @param int $count
@@ -181,10 +180,9 @@ class L10n
*/
public static function tt($singular, $plural, $count)
{
- global $lang;
- $a = get_app();
+ $lang = Config::get('system', 'language');
- if (x($a->strings, $singular)) {
+ if (!empty($a->strings[$singular])) {
$t = $a->strings[$singular];
if (is_array($t)) {
$plural_function = 'string_plural_select_' . str_replace('-', '_', $lang);
diff --git a/src/Core/NotificationsManager.php b/src/Core/NotificationsManager.php
index 507d4db131..fa8476b906 100644
--- a/src/Core/NotificationsManager.php
+++ b/src/Core/NotificationsManager.php
@@ -613,7 +613,7 @@ class NotificationsManager extends BaseObject
// We have to distinguish between these two because they use different data.
// Contact suggestions
if ($it['fid']) {
- $return_addr = bin2hex(self::getApp()->user['nickname'] . '@' . self::getApp()->get_hostname() . ((self::getApp()->path) ? '/' . self::getApp()->path : ''));
+ $return_addr = bin2hex(self::getApp()->user['nickname'] . '@' . self::getApp()->get_hostname() . ((self::getApp()->urlpath) ? '/' . self::getApp()->urlpath : ''));
$intro = [
'label' => 'friend_suggestion',
diff --git a/src/Core/PConfig.php b/src/Core/PConfig.php
index 274122deda..aa5f75abe7 100644
--- a/src/Core/PConfig.php
+++ b/src/Core/PConfig.php
@@ -9,7 +9,6 @@
namespace Friendica\Core;
use Friendica\BaseObject;
-use Friendica\Core\Config;
require_once 'include/dba.php';
@@ -29,7 +28,12 @@ class PConfig extends BaseObject
public static function init($uid)
{
- if (Config::get('system', 'config_adapter') == 'preload') {
+ // Database isn't ready or populated yet
+ if (!(self::getApp()->mode & \Friendica\App::MODE_DBCONFIGAVAILABLE)) {
+ return;
+ }
+
+ if (self::getApp()->getConfigValue('system', 'config_adapter') == 'preload') {
self::$adapter = new Config\PreloadPConfigAdapter($uid);
} else {
self::$adapter = new Config\JITPConfigAdapter($uid);
@@ -49,6 +53,11 @@ class PConfig extends BaseObject
*/
public static function load($uid, $family)
{
+ // Database isn't ready or populated yet
+ if (!(self::getApp()->mode & \Friendica\App::MODE_DBCONFIGAVAILABLE)) {
+ return;
+ }
+
if (empty(self::$adapter)) {
self::init($uid);
}
@@ -73,6 +82,11 @@ class PConfig extends BaseObject
*/
public static function get($uid, $family, $key, $default_value = null, $refresh = false)
{
+ // Database isn't ready or populated yet
+ if (!(self::getApp()->mode & \Friendica\App::MODE_DBCONFIGAVAILABLE)) {
+ return;
+ }
+
if (empty(self::$adapter)) {
self::init($uid);
}
@@ -97,6 +111,11 @@ class PConfig extends BaseObject
*/
public static function set($uid, $family, $key, $value)
{
+ // Database isn't ready or populated yet
+ if (!(self::getApp()->mode & \Friendica\App::MODE_DBCONFIGAVAILABLE)) {
+ return false;
+ }
+
if (empty(self::$adapter)) {
self::init($uid);
}
@@ -118,6 +137,11 @@ class PConfig extends BaseObject
*/
public static function delete($uid, $family, $key)
{
+ // Database isn't ready or populated yet
+ if (!(self::getApp()->mode & \Friendica\App::MODE_DBCONFIGAVAILABLE)) {
+ return false;
+ }
+
if (empty(self::$adapter)) {
self::init($uid);
}
diff --git a/src/Core/System.php b/src/Core/System.php
index e3dc4e5870..4e2b63f044 100644
--- a/src/Core/System.php
+++ b/src/Core/System.php
@@ -85,20 +85,6 @@ class System extends BaseObject
return implode(', ', $callstack2);
}
- /**
- * @brief Called from db initialisation when db is dead.
- */
- static public function unavailable() {
-echo <<< EOT
-
- System Unavailable
- Apologies but this site is unavailable at the moment. Please try again later.
-
-EOT;
-
- killme();
- }
-
/**
* Generic XML return
* Outputs a basic dfrn XML status structure to STDOUT, with a variable
diff --git a/src/Core/Worker.php b/src/Core/Worker.php
index 0d51bb725d..897a80111d 100644
--- a/src/Core/Worker.php
+++ b/src/Core/Worker.php
@@ -41,7 +41,7 @@ class Worker
self::$up_start = microtime(true);
// At first check the maximum load. We shouldn't continue with a high load
- if ($a->maxload_reached()) {
+ if ($a->isMaxLoadReached()) {
logger('Pre check: maximum load reached, quitting.', LOGGER_DEBUG);
return;
}
@@ -75,7 +75,7 @@ class Worker
}
// Possibly there are too much database processes that block the system
- if ($a->max_processes_reached()) {
+ if ($a->isMaxProcessesReached()) {
logger('Pre check: maximum processes reached, quitting.', LOGGER_DEBUG);
return;
}
@@ -203,7 +203,7 @@ class Worker
}
// Constantly check the number of parallel database processes
- if ($a->max_processes_reached()) {
+ if ($a->isMaxProcessesReached()) {
logger("Max processes reached for process ".$mypid, LOGGER_DEBUG);
return false;
}
diff --git a/src/Database/DBStructure.php b/src/Database/DBStructure.php
index 5c03c1afd6..ee46c2b4cb 100644
--- a/src/Database/DBStructure.php
+++ b/src/Database/DBStructure.php
@@ -53,7 +53,7 @@ class DBStructure
$a = get_app();
//send the administrators an e-mail
- $admin_mail_list = "'".implode("','", array_map(dbesc, explode(",", str_replace(" ", "", $a->config['admin_email']))))."'";
+ $admin_mail_list = "'".implode("','", array_map('dbesc', explode(",", str_replace(" ", "", Config::get('config', 'admin_email')))))."'";
$adminlist = q("SELECT uid, language, email FROM user WHERE email IN (%s)",
$admin_mail_list
);
diff --git a/src/Model/Contact.php b/src/Model/Contact.php
index dcd6c37db5..093ee0d91e 100644
--- a/src/Model/Contact.php
+++ b/src/Model/Contact.php
@@ -1316,7 +1316,7 @@ class Contact extends BaseObject
if (($ret['network'] === NETWORK_DFRN) && !DBM::is_result($r)) {
if ($interactive) {
- if (strlen($a->path)) {
+ if (strlen($a->urlpath)) {
$myaddr = bin2hex(System::baseUrl() . '/profile/' . $a->user['nickname']);
} else {
$myaddr = bin2hex($a->user['nickname'] . '@' . $a->get_hostname());
diff --git a/src/Model/Profile.php b/src/Model/Profile.php
index c16fb745a7..92355b216e 100644
--- a/src/Model/Profile.php
+++ b/src/Model/Profile.php
@@ -138,7 +138,7 @@ class Profile
$a->profile['mobile-theme'] = PConfig::get($a->profile['profile_uid'], 'system', 'mobile_theme');
$a->profile['network'] = NETWORK_DFRN;
- $a->page['title'] = $a->profile['name'] . ' @ ' . $a->config['sitename'];
+ $a->page['title'] = $a->profile['name'] . ' @ ' . Config::get('config', 'sitename');
if (!$profiledata && !PConfig::get(local_user(), 'system', 'always_my_theme')) {
$_SESSION['theme'] = $a->profile['theme'];
diff --git a/src/Model/User.php b/src/Model/User.php
index dc5702b605..57a3ecb50d 100644
--- a/src/Model/User.php
+++ b/src/Model/User.php
@@ -454,8 +454,8 @@ class User
// Disallow somebody creating an account using openid that uses the admin email address,
// since openid bypasses email verification. We'll allow it if there is not yet an admin account.
- if (x($a->config, 'admin_email') && strlen($openid_url)) {
- $adminlist = explode(',', str_replace(' ', '', strtolower($a->config['admin_email'])));
+ if (Config::get('config', 'admin_email') && strlen($openid_url)) {
+ $adminlist = explode(',', str_replace(' ', '', strtolower(Config::get('config', 'admin_email'))));
if (in_array(strtolower($email), $adminlist)) {
throw new Exception(L10n::t('Cannot use that email.'));
}
diff --git a/src/Module/Login.php b/src/Module/Login.php
index 4df03f26dc..06d724bb2a 100644
--- a/src/Module/Login.php
+++ b/src/Module/Login.php
@@ -43,7 +43,7 @@ class Login extends BaseModule
goaway(self::getApp()->get_baseurl());
}
- return self::form(self::getApp()->get_baseurl(), $a->config['register_policy'] != REGISTER_CLOSED);
+ return self::form(self::getApp()->get_baseurl(), intval(Config::get('config', 'register_policy')) !== REGISTER_CLOSED);
}
public static function post()
@@ -266,7 +266,7 @@ class Login extends BaseModule
* @param string $return_url The url relative to the base the user should be sent
* back to after login completes
* @param bool $register If $register == true provide a registration link.
- * This will most always depend on the value of $a->config['register_policy'].
+ * This will most always depend on the value of config.register_policy.
* @param array $hiddens optional
*
* @return string Returns the complete html for inserting into the page
diff --git a/src/Module/Magic.php b/src/Module/Magic.php
index 0b6874069a..d55e8f93bc 100644
--- a/src/Module/Magic.php
+++ b/src/Module/Magic.php
@@ -80,7 +80,7 @@ class Magic extends BaseModule
'',
$headers,
$user['prvkey'],
- 'acct:' . $user['nickname'] . '@' . $a->get_hostname() . ($a->path ? '/' . $a->path : ''),
+ 'acct:' . $user['nickname'] . '@' . $a->get_hostname() . ($a->urlpath ? '/' . $a->urlpath : ''),
false,
true,
'sha512'
diff --git a/src/Protocol/OStatus.php b/src/Protocol/OStatus.php
index 36f3faf2de..f4b299761d 100644
--- a/src/Protocol/OStatus.php
+++ b/src/Protocol/OStatus.php
@@ -1269,7 +1269,7 @@ class OStatus
XML::addElement($doc, $root, "generator", FRIENDICA_PLATFORM, $attributes);
XML::addElement($doc, $root, "id", System::baseUrl() . "/profile/" . $owner["nick"]);
XML::addElement($doc, $root, "title", $title);
- XML::addElement($doc, $root, "subtitle", sprintf("Updates from %s on %s", $owner["name"], $a->config["sitename"]));
+ XML::addElement($doc, $root, "subtitle", sprintf("Updates from %s on %s", $owner["name"], Config::get('config', 'sitename')));
XML::addElement($doc, $root, "logo", $owner["photo"]);
XML::addElement($doc, $root, "updated", DateTimeFormat::utcNow(DateTimeFormat::ATOM));
diff --git a/src/Util/Network.php b/src/Util/Network.php
index 0e65145b78..aa118e3dd4 100644
--- a/src/Util/Network.php
+++ b/src/Util/Network.php
@@ -559,9 +559,8 @@ class Network
*/
public static function isUrlBlocked($url)
{
- $h = @parse_url($url);
-
- if (! $h) {
+ $host = @parse_url($url, PHP_URL_HOST);
+ if (! $host) {
return true;
}
@@ -570,10 +569,8 @@ class Network
return false;
}
- $host = strtolower($h['host']);
-
foreach ($domain_blocklist as $domain_block) {
- if (strtolower($domain_block['domain']) == $host) {
+ if (strcasecmp($domain_block['domain'], $host) === 0) {
return true;
}
}
diff --git a/src/Worker/CheckVersion.php b/src/Worker/CheckVersion.php
index a6056ccbc4..e37e37a060 100644
--- a/src/Worker/CheckVersion.php
+++ b/src/Worker/CheckVersion.php
@@ -16,10 +16,10 @@ use Friendica\Util\Network;
* Checking the upstream version is optional (opt-in) and can be done to either
* the master or the develop branch in the repository.
*/
-class CheckVersion {
- public static function execute() {
- global $a;
-
+class CheckVersion
+{
+ public static function execute()
+ {
logger('checkversion: start');
$checkurl = Config::get('system', 'check_new_version_url', 'none');
diff --git a/src/Worker/Cron.php b/src/Worker/Cron.php
index e425c03508..a0dfda3309 100644
--- a/src/Worker/Cron.php
+++ b/src/Worker/Cron.php
@@ -13,9 +13,11 @@ use dba;
require_once 'include/dba.php';
-Class Cron {
- public static function execute($parameter = '', $generation = 0) {
- global $a;
+class Cron
+{
+ public static function execute($parameter = '', $generation = 0)
+ {
+ $a = \Friendica\BaseObject::getApp();
// Poll contacts with specific parameters
if (!empty($parameter)) {
diff --git a/src/Worker/CronJobs.php b/src/Worker/CronJobs.php
index 80839874da..8b9d3b9bcf 100644
--- a/src/Worker/CronJobs.php
+++ b/src/Worker/CronJobs.php
@@ -24,7 +24,7 @@ class CronJobs
{
public static function execute($command = '')
{
- global $a;
+ $a = \Friendica\BaseObject::getApp();
// No parameter set? So return
if ($command == '') {
diff --git a/src/Worker/DBClean.php b/src/Worker/DBClean.php
index deb23e8dd8..7a0b1f8473 100644
--- a/src/Worker/DBClean.php
+++ b/src/Worker/DBClean.php
@@ -60,8 +60,6 @@ class DBClean {
* 10: Old conversations.
*/
private static function removeOrphans($stage) {
- global $db;
-
$count = 0;
// We split the deletion in many small tasks
diff --git a/src/Worker/DBUpdate.php b/src/Worker/DBUpdate.php
index 5f85c8ebef..ed8e409e98 100644
--- a/src/Worker/DBUpdate.php
+++ b/src/Worker/DBUpdate.php
@@ -7,9 +7,11 @@ namespace Friendica\Worker;
use Friendica\Core\Config;
-class DBUpdate {
- public static function execute() {
- $a = get_app();
+class DBUpdate
+{
+ public static function execute()
+ {
+ $a = \Friendica\BaseObject::getApp();
// We are deleting the latest dbupdate entry.
// This is done to avoid endless loops because the update was interupted.
diff --git a/src/Worker/DiscoverPoCo.php b/src/Worker/DiscoverPoCo.php
index f0335bc8e4..c77830d60a 100644
--- a/src/Worker/DiscoverPoCo.php
+++ b/src/Worker/DiscoverPoCo.php
@@ -15,7 +15,8 @@ use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network;
use dba;
-class DiscoverPoCo {
+class DiscoverPoCo
+{
/// @todo Clean up this mess of a parameter hell and split it in several classes
public static function execute($command = '', $param1 = '', $param2 = '', $param3 = '', $param4 = '')
{
@@ -276,8 +277,6 @@ class DiscoverPoCo {
// It is not removed since I hope that there will be a successor.
return false;
- $a = get_app();
-
$url = "http://gstools.org/api/users_search/".urlencode($search);
$result = Network::curl($url);
diff --git a/src/Worker/Expire.php b/src/Worker/Expire.php
index 6cc333dd05..685fad49e8 100644
--- a/src/Worker/Expire.php
+++ b/src/Worker/Expire.php
@@ -15,9 +15,11 @@ use dba;
require_once 'include/dba.php';
-class Expire {
- public static function execute($param = '', $hook_name = '') {
- global $a;
+class Expire
+{
+ public static function execute($param = '', $hook_name = '')
+ {
+ $a = \Friendica\BaseObject::getApp();
require_once 'include/items.php';
diff --git a/src/Worker/ForkHook.php b/src/Worker/ForkHook.php
index 6c138bace4..3654bdd3ca 100644
--- a/src/Worker/ForkHook.php
+++ b/src/Worker/ForkHook.php
@@ -7,9 +7,11 @@ namespace Friendica\Worker;
use Friendica\Core\Addon;
-Class ForkHook {
- public static function execute($name, $hook, $data) {
- global $a;
+Class ForkHook
+{
+ public static function execute($name, $hook, $data)
+ {
+ $a = \Friendica\BaseObject::getApp();
Addon::callSingleHook($a, $name, $hook, $data);
}
diff --git a/src/Worker/Notifier.php b/src/Worker/Notifier.php
index 6c3717200b..385892f991 100644
--- a/src/Worker/Notifier.php
+++ b/src/Worker/Notifier.php
@@ -48,9 +48,11 @@ require_once 'include/items.php';
* and ITEM_ID is the id of the item in the database that needs to be sent to others.
*/
-class Notifier {
- public static function execute($cmd, $item_id) {
- global $a;
+class Notifier
+{
+ public static function execute($cmd, $item_id)
+ {
+ $a = \Friendica\BaseObject::getApp();
logger('notifier: invoked: '.$cmd.': '.$item_id, LOGGER_DEBUG);
diff --git a/src/Worker/OnePoll.php b/src/Worker/OnePoll.php
index eaef5f252d..951a20b012 100644
--- a/src/Worker/OnePoll.php
+++ b/src/Worker/OnePoll.php
@@ -21,8 +21,9 @@ require_once 'include/dba.php';
class OnePoll
{
- public static function execute($contact_id = 0, $command = '') {
- global $a;
+ public static function execute($contact_id = 0, $command = '')
+ {
+ $a = \Friendica\BaseObject::getApp();
require_once 'include/items.php';
@@ -634,7 +635,8 @@ class OnePoll
return;
}
- private static function RemoveReply($subject) {
+ private static function RemoveReply($subject)
+ {
while (in_array(strtolower(substr($subject, 0, 3)), ["re:", "aw:"])) {
$subject = trim(substr($subject, 4));
}
@@ -648,7 +650,8 @@ class OnePoll
* @param array $contact The personal contact entry
* @param array $fields The fields that are updated
*/
- private static function updateContact($contact, $fields) {
+ private static function updateContact($contact, $fields)
+ {
dba::update('contact', $fields, ['id' => $contact['id']]);
dba::update('contact', $fields, ['uid' => 0, 'nurl' => $contact['nurl']]);
}
diff --git a/src/Worker/PubSubPublish.php b/src/Worker/PubSubPublish.php
index 0a60e5a599..b90fc11a49 100644
--- a/src/Worker/PubSubPublish.php
+++ b/src/Worker/PubSubPublish.php
@@ -15,7 +15,8 @@ use dba;
require_once 'include/items.php';
-class PubSubPublish {
+class PubSubPublish
+{
public static function execute($pubsubpublish_id = 0)
{
if ($pubsubpublish_id == 0) {
@@ -25,8 +26,9 @@ class PubSubPublish {
self::publish($pubsubpublish_id);
}
- private static function publish($id) {
- global $a;
+ private static function publish($id)
+ {
+ $a = \Friendica\BaseObject::getApp();
$subscriber = dba::selectFirst('push_subscriber', [], ['id' => $id]);
if (!DBM::is_result($subscriber)) {
diff --git a/src/Worker/Queue.php b/src/Worker/Queue.php
index c8ba5795a6..1ec4090565 100644
--- a/src/Worker/Queue.php
+++ b/src/Worker/Queue.php
@@ -25,8 +25,6 @@ class Queue
{
public static function execute($queue_id = 0)
{
- global $a;
-
$cachekey_deadguy = 'queue_run:deadguy:';
$cachekey_server = 'queue_run:server:';
diff --git a/src/Worker/UpdateGContact.php b/src/Worker/UpdateGContact.php
index 98a62818e9..b943d966be 100644
--- a/src/Worker/UpdateGContact.php
+++ b/src/Worker/UpdateGContact.php
@@ -15,8 +15,6 @@ class UpdateGContact
{
public static function execute($contact_id)
{
- global $a;
-
logger('update_gcontact: start');
if (empty($contact_id)) {
diff --git a/tests/ApiTest.php b/tests/ApiTest.php
index c8443512c8..1854c996b0 100644
--- a/tests/ApiTest.php
+++ b/tests/ApiTest.php
@@ -5,12 +5,11 @@
namespace Friendica\Test;
-use Friendica\App;
use Friendica\Core\Config;
use Friendica\Core\PConfig;
-use Friendica\Network\BadRequestException;
+use Friendica\Core\Protocol;
+use Friendica\Core\System;
use Friendica\Network\HTTPException;
-use Friendica\Render\FriendicaSmarty;
/**
* Tests for the API functions.
@@ -26,12 +25,10 @@ class ApiTest extends DatabaseTest
*/
protected function setUp()
{
- global $a;
parent::setUp();
// Reusable App object
- $this->app = new App(__DIR__.'/../');
- $a = $this->app;
+ $this->app = \Friendica\BaseObject::getApp();
// User data that the test database is populated with
$this->selfUser = [
@@ -719,10 +716,10 @@ class ApiTest extends DatabaseTest
*/
public function testApiGetUserWithCustomFrioSchema()
{
- PConfig::set($this->selfUser['id'], 'frio', 'schema', '---');
- PConfig::set($this->selfUser['id'], 'frio', 'nav_bg', '#123456');
- PConfig::set($this->selfUser['id'], 'frio', 'link_color', '#123456');
- PConfig::set($this->selfUser['id'], 'frio', 'background_color', '#123456');
+ $ret1 = PConfig::set($this->selfUser['id'], 'frio', 'schema', '---');
+ $ret2 = PConfig::set($this->selfUser['id'], 'frio', 'nav_bg', '#123456');
+ $ret3 = PConfig::set($this->selfUser['id'], 'frio', 'link_color', '#123456');
+ $ret4 = PConfig::set($this->selfUser['id'], 'frio', 'background_color', '#123456');
$user = api_get_user($this->app);
$this->assertSelfUser($user);
$this->assertEquals('123456', $user['profile_sidebar_fill_color']);
@@ -2164,7 +2161,7 @@ class ApiTest extends DatabaseTest
public function testApiFormatItemsEmbededImages()
{
$this->assertEquals(
- 'text ' . \Friendica\Core\System::baseUrl() . '/display/item_guid',
+ 'text ' . System::baseUrl() . '/display/item_guid',
api_format_items_embeded_images(['guid' => 'item_guid'], 'text data:image/foo')
);
}
@@ -2338,7 +2335,7 @@ class ApiTest extends DatabaseTest
'body' => '',
'verb' => '',
'author-id' => 43,
- 'author-network' => \Friendica\Core\Protocol::DFRN,
+ 'author-network' => Protocol::DFRN,
'author-link' => 'http://localhost/profile/othercontact',
'plink' => '',
]
@@ -2361,7 +2358,7 @@ class ApiTest extends DatabaseTest
'body' => '',
'verb' => '',
'author-id' => 43,
- 'author-network' => \Friendica\Core\Protocol::DFRN,
+ 'author-network' => Protocol::DFRN,
'author-link' => 'http://localhost/profile/othercontact',
'plink' => '',
]
@@ -2635,7 +2632,7 @@ class ApiTest extends DatabaseTest
$result = api_statusnet_config('json');
$this->assertEquals('localhost', $result['config']['site']['server']);
$this->assertEquals('default', $result['config']['site']['theme']);
- $this->assertEquals(\Friendica\Core\System::baseUrl() . '/images/friendica-64.png', $result['config']['site']['logo']);
+ $this->assertEquals(System::baseUrl() . '/images/friendica-64.png', $result['config']['site']['logo']);
$this->assertTrue($result['config']['site']['fancy']);
$this->assertEquals('en', $result['config']['site']['language']);
$this->assertEquals('UTC', $result['config']['site']['timezone']);
diff --git a/tests/DatabaseTest.php b/tests/DatabaseTest.php
index e79e9237be..579e45084d 100644
--- a/tests/DatabaseTest.php
+++ b/tests/DatabaseTest.php
@@ -20,54 +20,6 @@ abstract class DatabaseTest extends TestCase
use TestCaseTrait;
- /**
- * Renames an eventually existing .htconfig.php to .htconfig.php.tmp
- * Creates a new .htconfig.php for bin/worker.php execution
- */
- public static function setUpBeforeClass()
- {
- parent::setUpBeforeClass();
-
- $base_config_file_name = 'htconfig.php';
- $config_file_name = '.htconfig.php';
-
- $base_config_file_path = stream_resolve_include_path($base_config_file_name);
- $config_file_path = dirname($base_config_file_path) . DIRECTORY_SEPARATOR . $config_file_name;
- $config_file_path_tmp = $config_file_path . '.tmp';
-
- if (file_exists($config_file_path)) {
- rename($config_file_path, $config_file_path_tmp);
- }
-
- $config_string = file_get_contents($base_config_file_path);
-
- $config_string = str_replace('die(', '// die(', $config_string);
-
- file_put_contents($config_file_path, $config_string);
- }
-
- /**
- * Delete the created .htconfig.php
- * Renames an eventually existing .htconfig.php.tmp to .htconfig.php
- */
- public static function tearDownAfterClass()
- {
- $base_config_file_name = 'htconfig.php';
- $config_file_name = '.htconfig.php';
-
- $base_config_file_path = stream_resolve_include_path($base_config_file_name);
- $config_file_path = dirname($base_config_file_path) . DIRECTORY_SEPARATOR . $config_file_name;
- $config_file_path_tmp = $config_file_path . '.tmp';
-
- if (file_exists($config_file_path)) {
- unlink($config_file_path);
- }
-
- if (file_exists($config_file_path_tmp)) {
- rename($config_file_path_tmp, $config_file_path);
- }
- }
-
/**
* Get database connection.
*
@@ -81,21 +33,8 @@ abstract class DatabaseTest extends TestCase
*/
protected function getConnection()
{
- if (!dba::$connected) {
- dba::connect(getenv('MYSQL_HOST') . ':' . getenv('MYSQL_PORT'), getenv('MYSQL_USERNAME'), getenv('MYSQL_PASSWORD'), getenv('MYSQL_DATABASE'));
-
- if (dba::$connected) {
- $app = get_app();
- // We need to do this in order to disable logging
- $app->mode = \Friendica\App::MODE_INSTALL;
-
- // Create database structure
- DBStructure::update(false, true, true);
-
- $app->mode = \Friendica\App::MODE_NORMAL;
- } else {
- $this->markTestSkipped('Could not connect to the database. Please check the MYSQL_* environment variables.');
- }
+ if (!dba::connected()) {
+ $this->markTestSkipped('Could not connect to the database.');
}
return $this->createDefaultDBConnection(dba::get_db(), getenv('MYSQL_DATABASE'));
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index 4474e4ee8e..4bc3e932f0 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -3,6 +3,7 @@
* This file is loaded by PHPUnit before any test.
*/
+use Friendica\App;
use PHPUnit\DbUnit\DataSet\YamlDataSet;
use PHPUnit\DbUnit\TestCaseTrait;
use PHPUnit\Framework\TestCase;
@@ -10,6 +11,12 @@ use PHPUnit\Framework\TestCase;
require_once __DIR__.'/../boot.php';
require_once __DIR__.'/../include/api.php';
+new App(dirname(__DIR__));
+
+\Friendica\Core\Config::set('system', 'url', 'http://localhost');
+\Friendica\Core\Config::set('system', 'hostname', 'localhost');
+\Friendica\Core\Config::set('system', 'worker_dont_fork', true);
+
// Backward compatibility
if (!class_exists(TestCase::class)) {
class_alias(PHPUnit_Framework_TestCase::class, TestCase::class);
diff --git a/tests/datasets/api.yml b/tests/datasets/api.yml
index 25c9dade60..124c6b0d54 100644
--- a/tests/datasets/api.yml
+++ b/tests/datasets/api.yml
@@ -1,13 +1,27 @@
---
# Empty these tables
cache:
-config:
conversation:
pconfig:
photo:
workerqueue:
mail:
+# Base test config to avoid notice messages
+config:
+ -
+ cat: system
+ k: url
+ v: http://localhost
+ -
+ cat: system
+ k: hostname
+ v: localhost
+ -
+ cat: system
+ k: worker_dont_fork
+ v: 1
+
# Populate tables with test data
user:
-
diff --git a/tests/src/Core/Cache/CacheTest.php b/tests/src/Core/Cache/CacheTest.php
index 5be0e4b893..39dc56f301 100644
--- a/tests/src/Core/Cache/CacheTest.php
+++ b/tests/src/Core/Cache/CacheTest.php
@@ -2,7 +2,6 @@
namespace Friendica\Test\src\Core\Cache;
-use Friendica\App;
use Friendica\Core\Config;
use Friendica\Test\DatabaseTest;
use Friendica\Util\DateTimeFormat;
@@ -18,13 +17,11 @@ abstract class CacheTest extends DatabaseTest
protected function setUp()
{
- global $a;
parent::setUp();
$this->instance = $this->getInstance();
// Reusable App object
- $this->app = new App(__DIR__.'/../');
- $a = $this->app;
+ $this->app = \Friendica\BaseObject::getApp();
// Default config
Config::set('config', 'hostname', 'localhost');
diff --git a/tests/src/Core/Cache/MemcacheCacheDriverTest.php b/tests/src/Core/Cache/MemcacheCacheDriverTest.php
index d2078236e2..5ed0a3a2e5 100644
--- a/tests/src/Core/Cache/MemcacheCacheDriverTest.php
+++ b/tests/src/Core/Cache/MemcacheCacheDriverTest.php
@@ -19,8 +19,7 @@ class MemcacheCacheDriverTest extends MemoryCacheTest
try {
$this->cache = CacheDriverFactory::create('memcache');
} catch (\Exception $exception) {
- print "Memcache - TestCase failed: " . $exception->getMessage();
- throw new \Exception();
+ throw new \Exception("Memcache - TestCase failed: " . $exception->getMessage(), $exception->getCode(), $exception);
}
return $this->cache;
} else {
diff --git a/tests/src/Core/Cache/MemcachedCacheDriverTest.php b/tests/src/Core/Cache/MemcachedCacheDriverTest.php
index 2484517424..4872546b54 100644
--- a/tests/src/Core/Cache/MemcachedCacheDriverTest.php
+++ b/tests/src/Core/Cache/MemcachedCacheDriverTest.php
@@ -19,8 +19,7 @@ class MemcachedCacheDriverTest extends MemoryCacheTest
try {
$this->cache = CacheDriverFactory::create('memcached');
} catch (\Exception $exception) {
- print "Memcached - TestCase failed: " . $exception->getMessage();
- throw new \Exception();
+ throw new \Exception("Memcached - TestCase failed: " . $exception->getMessage(), $exception->getCode(), $exception);
}
return $this->cache;
} else {
diff --git a/tests/src/Core/Cache/RedisCacheDriverTest.php b/tests/src/Core/Cache/RedisCacheDriverTest.php
index e13d95df4d..158534602a 100644
--- a/tests/src/Core/Cache/RedisCacheDriverTest.php
+++ b/tests/src/Core/Cache/RedisCacheDriverTest.php
@@ -19,8 +19,7 @@ class RedisCacheDriverTest extends MemoryCacheTest
try {
$this->cache = CacheDriverFactory::create('redis');
} catch (\Exception $exception) {
- print "Redis - TestCase failed: " . $exception->getMessage();
- throw new \Exception();
+ throw new \Exception("Redis - TestCase failed: " . $exception->getMessage(), $exception->getCode(), $exception);
}
return $this->cache;
} else {
diff --git a/tests/src/Core/Lock/LockTest.php b/tests/src/Core/Lock/LockTest.php
index dafbd74a6f..79ee023bd8 100644
--- a/tests/src/Core/Lock/LockTest.php
+++ b/tests/src/Core/Lock/LockTest.php
@@ -2,10 +2,8 @@
namespace Friendica\Test\src\Core\Lock;
-use Friendica\App;
use Friendica\Core\Config;
use Friendica\Test\DatabaseTest;
-use PHPUnit\Framework\TestCase;
abstract class LockTest extends DatabaseTest
{
@@ -18,13 +16,11 @@ abstract class LockTest extends DatabaseTest
protected function setUp()
{
- global $a;
parent::setUp();
$this->instance = $this->getInstance();
// Reusable App object
- $this->app = new App(__DIR__.'/../');
- $a = $this->app;
+ $this->app = \Friendica\BaseObject::getApp();
// Default config
Config::set('config', 'hostname', 'localhost');
diff --git a/util/Doxyfile b/util/Doxyfile
index 373d172558..aef2307927 100644
--- a/util/Doxyfile
+++ b/util/Doxyfile
@@ -2,8 +2,8 @@ INPUT = README.md index.php boot.php testargs.php update.php mod/ object/ includ
RECURSIVE = YES
PROJECT_NAME = "Friendica"
PROJECT_LOGO = images/friendica-64.jpg
-EXCLUDE = .htconfig.php library/ doc/ .git/ log/ util/zotsh/easywebdav/ addon/ report/ privacy_image_cache/ photo/ proxy/ local/
-EXCLUDE_PATTERNS = *smarty3* *strings.php*.log *.out *test*
+EXCLUDE = .htconfig.php config/ library/ doc/ .git/ log/ util/zotsh/easywebdav/ addon/ report/ privacy_image_cache/ photo/ proxy/ local/
+EXCLUDE_PATTERNS = *smarty3* *strings.php*.log *.out *test*
OUTPUT_DIRECTORY = doc
GENERATE_HTML = YES
HTML_OUTPUT = html/
diff --git a/util/htconfig.vagrant.php b/util/htconfig.vagrant.php
index 623b587ef0..f75e208ee5 100644
--- a/util/htconfig.vagrant.php
+++ b/util/htconfig.vagrant.php
@@ -13,7 +13,7 @@ $db_data = 'friendica';
// For instance if your URL is 'http://example.com/directory/subdirectory',
// set path to 'directory/subdirectory'.
-$a->path = '';
+$a->urlpath = '';
// Choose a legal default timezone. If you are unsure, use "America/Los_Angeles".
// It can be changed later and only applies to timestamps for anonymous viewers.
diff --git a/view/templates/htconfig.tpl b/view/templates/htconfig.tpl
deleted file mode 100644
index dc2d4bcdab..0000000000
--- a/view/templates/htconfig.tpl
+++ /dev/null
@@ -1,118 +0,0 @@
-config['system']['db_charset'] = "utf8mb4";
-
-// email adress for the system admin
-
-$a->config['admin_email'] = '{{$adminmail}}';
-
-// Location of PHP command line processor
-
-$a->config['php_path'] = '{{$phpath}}';
-
-// If you are using a subdirectory of your domain you will need to put the
-// relative path (from the root of your domain) here.
-// For instance if your URL is 'http://example.com/directory/subdirectory',
-// set path to 'directory/subdirectory'.
-
-$a->path = '{{$urlpath}}';
-
-// Allowed protocols in link URLs; HTTP protocols always are accepted
-$a->config['system']['allowed_link_protocols'] = array('ftp', 'ftps', 'mailto', 'cid', 'gopher');
-
-/* *********************************************************************
- * The configuration below will be overruled by the admin panel.
- * Changes made below will only have an effect if the database does
- * not contain any configuration for the friendica system.
- * *********************************************************************/
-
-// Choose a legal default timezone. If you are unsure, use "America/Los_Angeles".
-// It can be changed later and only applies to timestamps for anonymous viewers.
-
-$default_timezone = '{{$timezone}}';
-
-// Default system language
-
-$a->config['system']['language'] = '{{$language}}';
-
-// What is your site name?
-
-$a->config['sitename'] = "My Friend Network";
-
-// Your choices are REGISTER_OPEN, REGISTER_APPROVE, or REGISTER_CLOSED.
-// Be certain to create your own personal account before setting
-// REGISTER_CLOSED. 'register_text' (if set) will be displayed prominently on
-// the registration page. REGISTER_APPROVE requires you set 'admin_email'
-// to the email address of an already registered person who can authorise
-// and/or approve/deny the request.
-
-$a->config['register_policy'] = REGISTER_OPEN;
-$a->config['register_text'] = '';
-
-// Maximum size of an imported message, 0 is unlimited
-
-$a->config['max_import_size'] = 200000;
-
-// maximum size of uploaded photos
-
-$a->config['system']['maximagesize'] = 800000;
-
-// Server-to-server private message encryption (RINO) is allowed by default.
-// set to 0 to disable, 1 to enable
-
-$a->config['system']['rino_encrypt'] = {{$rino}};
-
-// default system theme
-
-$a->config['system']['theme'] = 'vier';
-$a->config['system']['allowed_themes'] = 'vier,quattro,duepuntozero,smoothly,frio';
-
-// By default allow pseudonyms
-
-$a->config['system']['no_regfullname'] = true;
-
-//Deny public access to the local directory
-//$a->config['system']['block_local_dir'] = false;
-
-// Location of the global directory
-$a->config['system']['directory'] = 'https://dir.friendica.social';
-
-// Authentication cookie lifetime, in days
-$a->config['system']['auth_cookie_lifetime'] = 7;
diff --git a/view/templates/local.ini.tpl b/view/templates/local.ini.tpl
new file mode 100644
index 0000000000..109a732301
--- /dev/null
+++ b/view/templates/local.ini.tpl
@@ -0,0 +1,56 @@
+var baseurl = "";
path ? "/" . $a->path . "/" : "/";
+ $basepath = $a->urlpath ? "/" . $a->urlpath . "/" : "/";
$frio = "view/theme/frio";
// Because we use minimal for modals the header and the included js stuff should be only loaded
diff --git a/view/theme/frio/theme.php b/view/theme/frio/theme.php
index 9d2b77d1f1..f2cbb7e6ac 100644
--- a/view/theme/frio/theme.php
+++ b/view/theme/frio/theme.php
@@ -268,7 +268,7 @@ function frio_remote_nav($a, &$nav)
$nav['messages'] = [$server_url . '/message', L10n::t('Messages'), '', L10n::t('Private mail')];
$nav['settings'] = [$server_url . '/settings', L10n::t('Settings'), '', L10n::t('Account settings')];
$nav['contacts'] = [$server_url . '/contacts', L10n::t('Contacts'), '', L10n::t('Manage/edit friends and contacts')];
- $nav['sitename'] = $a->config['sitename'];
+ $nav['sitename'] = Config::get('config', 'sitename');
}
}