diff --git a/classes/config.php b/classes/config.php index 349706390..b154206da 100644 --- a/classes/config.php +++ b/classes/config.php @@ -2,7 +2,9 @@ class Config { private const _ENVVAR_PREFIX = "TTRSS_"; - /* overriding defaults (defined below in _DEFAULTS[]) via environment: DB_TYPE becomes TTRSS_DB_TYPE, etc */ + // TODO: this should be extensible so plugins could add their own global directives (with defaults) + + // overriding defaults (defined below in _DEFAULTS[]) via environment: DB_TYPE becomes TTRSS_DB_TYPE, etc const DB_TYPE = "DB_TYPE"; const DB_HOST = "DB_HOST"; diff --git a/classes/db.php b/classes/db.php index 5196e7c7d..cbfb9e598 100755 --- a/classes/db.php +++ b/classes/db.php @@ -17,8 +17,8 @@ class Db // normal usage is Db::pdo()->prepare(...) etc public function pdo_connect() { - $db_port = defined('DB_PORT') && DB_PORT ? ';port=' . DB_PORT : ''; - $db_host = defined('DB_HOST') && DB_HOST ? ';host=' . DB_HOST : ''; + $db_port = Config::get(Config::DB_PORT) ? ';port=' . Config::get(Config::DB_PORT) : ''; + $db_host = Config::get(Config::DB_HOST) ? ';host=' . Config::get(Config::DB_HOST) : ''; try { $pdo = new PDO(Config::get(Config::DB_TYPE) . ':dbname=' . Config::get(Config::DB_NAME) . $db_host . $db_port, diff --git a/include/functions.php b/include/functions.php index d42306147..172ba169d 100644 --- a/include/functions.php +++ b/include/functions.php @@ -30,7 +30,10 @@ ini_set('display_errors', "false"); ini_set('display_startup_errors', "false"); - require_once "config.php"; + // config.php is optional + if (stream_resolve_include_path("config.php")) + require_once "config.php"; + require_once "autoload.php"; if (Config::get(Config::DB_TYPE) == "pgsql") {