diff --git a/.gitignore b/.gitignore
index eaf169cb8..c8aa69a4d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,25 +1,13 @@
Thumbs.db
/.app_is_ready
-/deploy.exclude
-/deploy.sh
/messages.mo
/node_modules
+/locale/**/*.po~
/package-lock.json
-*~
-*.DS_Store
-#*
-.idea/*
-plugins.local/*
-themes.local/*
-config.php
-feed-icons/*
-cache/*/*
-lock/*
-tags
-cache/htmlpurifier/*/*ser
-lib/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer/*/*ser
-web.config
-/.save.cson
-/.tags*
-/.gutentags
+/plugins.local/*
+/themes.local/*
+/config.php
+/feed-icons/*
+/cache/*/*
+/lock/*
/.vscode/settings.json
diff --git a/api/index.php b/api/index.php
index 6b0071141..d1e02bbd4 100644
--- a/api/index.php
+++ b/api/index.php
@@ -1,8 +1,6 @@
ICONS_DIR,
- "icons_url" => ICONS_URL);
+ $config = [
+ "icons_dir" => Config::get(Config::ICONS_DIR),
+ "icons_url" => Config::get(Config::ICONS_URL)
+ ];
$config["daemon_is_running"] = file_is_locked("update_daemon.lock");
diff --git a/classes/article.php b/classes/article.php
index acd83694c..a2a38118b 100755
--- a/classes/article.php
+++ b/classes/article.php
@@ -85,7 +85,7 @@ class Article extends Handler_Protected {
content = ?, content_hash = ? WHERE id = ?");
$sth->execute([$content, $content_hash, $ref_id]);
- if (DB_TYPE == "pgsql"){
+ if (Config::get(Config::DB_TYPE) == "pgsql") {
$sth = $pdo->prepare("UPDATE ttrss_entries
SET tsvector_combined = to_tsvector( :ts_content)
WHERE id = :id");
@@ -130,7 +130,7 @@ class Article extends Handler_Protected {
if ($row = $sth->fetch()) {
$ref_id = $row["id"];
- if (DB_TYPE == "pgsql"){
+ if (Config::get(Config::DB_TYPE) == "pgsql"){
$sth = $pdo->prepare("UPDATE ttrss_entries
SET tsvector_combined = to_tsvector( :ts_content)
WHERE id = :id");
@@ -475,7 +475,7 @@ class Article extends Handler_Protected {
// purge orphaned posts in main content table
- if (DB_TYPE == "mysql")
+ if (Config::get(Config::DB_TYPE) == "mysql")
$limit_qpart = "LIMIT 5000";
else
$limit_qpart = "";
diff --git a/classes/config.php b/classes/config.php
new file mode 100644
index 000000000..6f62863e9
--- /dev/null
+++ b/classes/config.php
@@ -0,0 +1,142 @@
+ "pgsql",
+ Config::DB_HOST => "db",
+ Config::DB_USER => "",
+ Config::DB_NAME => "",
+ Config::DB_PASS => "",
+ Config::DB_PORT => "5432",
+ Config::MYSQL_CHARSET => "UTF8",
+ Config::SELF_URL_PATH => "",
+ Config::SINGLE_USER_MODE => "",
+ Config::SIMPLE_UPDATE_MODE => "",
+ Config::PHP_EXECUTABLE => "/usr/bin/php",
+ Config::LOCK_DIRECTORY => "lock",
+ Config::CACHE_DIR => "cache",
+ Config::ICONS_DIR => "feed-icons",
+ Config::ICONS_URL => "feed-icons",
+ Config::AUTH_AUTO_CREATE => "true",
+ Config::AUTH_AUTO_LOGIN => "true",
+ Config::FORCE_ARTICLE_PURGE => 0,
+ Config::ENABLE_REGISTRATION => "",
+ Config::SESSION_COOKIE_LIFETIME => 86400,
+ Config::SMTP_FROM_NAME => "Tiny Tiny RSS",
+ Config::SMTP_FROM_ADDRESS => "noreply@localhost",
+ Config::DIGEST_SUBJECT => "[tt-rss] New headlines for last 24 hours",
+ Config::CHECK_FOR_UPDATES => "true",
+ Config::PLUGINS => "auth_internal",
+ Config::LOG_DESTINATION => "sql",
+ Config::LOCAL_OVERRIDE_STYLESHEET => "local-overrides.css",
+ Config::DAEMON_MAX_CHILD_RUNTIME => 1800,
+ Config::DAEMON_MAX_JOBS => 2,
+ Config::FEED_FETCH_TIMEOUT => 45,
+ Config::FEED_FETCH_NO_CACHE_TIMEOUT => 15,
+ Config::FILE_FETCH_TIMEOUT => 45,
+ Config::FILE_FETCH_CONNECT_TIMEOUT => 15,
+ Config::DAEMON_UPDATE_LOGIN_LIMIT => 30,
+ Config::DAEMON_FEED_LIMIT => 500,
+ Config::DAEMON_SLEEP_INTERVAL => 120,
+ Config::MAX_CACHE_FILE_SIZE => 64*1024*1024,
+ Config::MAX_DOWNLOAD_FILE_SIZE => 16*1024*1024,
+ Config::MAX_FAVICON_FILE_SIZE => 1*1024*1024,
+ Config::CACHE_MAX_DAYS => 7,
+ Config::MAX_CONDITIONAL_INTERVAL => 3600*12,
+ Config::DAEMON_UNSUCCESSFUL_DAYS_LIMIT => 30,
+ Config::LOG_SENT_MAIL => "",
+ ];
+
+ private static $instance;
+
+ private $params = [];
+
+ public static function get_instance() {
+ if (self::$instance == null)
+ self::$instance = new self();
+
+ return self::$instance;
+ }
+
+ function __construct() {
+ $ref = new ReflectionClass(get_class($this));
+
+ foreach ($ref->getConstants() as $const => $cvalue) {
+ if (strpos($const, "_") !== 0) {
+ $override = getenv($this::_ENVVAR_PREFIX . $const);
+
+ $this->params[$cvalue] = !empty($override) ? $override : $this::_DEFAULTS[$const];
+ }
+ }
+ }
+
+ private function _get(string $param) {
+ return $this->params[$param];
+ }
+
+ private function _add(string $param, string $default) {
+ $override = getenv($this::_ENVVAR_PREFIX . $param);
+
+ $this->params[$param] = !empty($override) ? $override : $default;
+ }
+
+ static function add(string $param, string $default) {
+ $instance = self::get_instance();
+
+ return $instance->_add($param, $default);
+ }
+
+ static function get(string $param) {
+ $instance = self::get_instance();
+
+ return $instance->_get($param);
+ }
+
+}
diff --git a/classes/db.php b/classes/db.php
index 490cecd57..cbfb9e598 100755
--- a/classes/db.php
+++ b/classes/db.php
@@ -17,13 +17,13 @@ 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(DB_TYPE . ':dbname=' . DB_NAME . $db_host . $db_port,
- DB_USER,
- DB_PASS);
+ $pdo = new PDO(Config::get(Config::DB_TYPE) . ':dbname=' . Config::get(Config::DB_NAME) . $db_host . $db_port,
+ Config::get(Config::DB_USER),
+ Config::get(Config::DB_PASS));
} catch (Exception $e) {
print "
Exception while creating PDO object:" . $e->getMessage() . "
";
exit(101);
@@ -31,18 +31,18 @@ class Db
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- if (DB_TYPE == "pgsql") {
+ if (Config::get(Config::DB_TYPE) == "pgsql") {
$pdo->query("set client_encoding = 'UTF-8'");
$pdo->query("set datestyle = 'ISO, european'");
$pdo->query("set TIME ZONE 0");
$pdo->query("set cpu_tuple_cost = 0.5");
- } else if (DB_TYPE == "mysql") {
+ } else if (Config::get(Config::DB_TYPE) == "mysql") {
$pdo->query("SET time_zone = '+0:0'");
- if (defined('MYSQL_CHARSET') && MYSQL_CHARSET) {
- $pdo->query("SET NAMES " . MYSQL_CHARSET);
+ if (defined('Config::get(Config::MYSQL_CHARSET)') && Config::get(Config::MYSQL_CHARSET)) {
+ $pdo->query("SET NAMES " . Config::get(Config::MYSQL_CHARSET));
}
}
@@ -68,7 +68,7 @@ class Db
}
public static function sql_random_function() {
- if (DB_TYPE == "mysql") {
+ if (Config::get(Config::DB_TYPE) == "mysql") {
return "RAND()";
} else {
return "RANDOM()";
diff --git a/classes/digest.php b/classes/digest.php
index e0c23d705..a6a0c47de 100644
--- a/classes/digest.php
+++ b/classes/digest.php
@@ -8,9 +8,9 @@ class Digest
Debug::log("Sending digests, batch of max $user_limit users, headline limit = $limit");
- if (DB_TYPE == "pgsql") {
+ if (Config::get(Config::DB_TYPE) == "pgsql") {
$interval_qpart = "last_digest_sent < NOW() - INTERVAL '1 days'";
- } else /* if (DB_TYPE == "mysql") */ {
+ } else /* if (Config::get(Config::DB_TYPE) == "mysql") */ {
$interval_qpart = "last_digest_sent < DATE_SUB(NOW(), INTERVAL 1 DAY)";
}
@@ -48,11 +48,11 @@ class Digest
$mailer = new Mailer();
- //$rc = $mail->quickMail($line["email"], $line["login"], DIGEST_SUBJECT, $digest, $digest_text);
+ //$rc = $mail->quickMail($line["email"], $line["login"], Config::get(Config::DIGEST_SUBJECT), $digest, $digest_text);
$rc = $mailer->mail(["to_name" => $line["login"],
"to_address" => $line["email"],
- "subject" => DIGEST_SUBJECT,
+ "subject" => Config::get(Config::DIGEST_SUBJECT),
"message" => $digest_text,
"message_html" => $digest]);
@@ -91,19 +91,19 @@ class Digest
$tpl->setVariable('CUR_DATE', date('Y/m/d', $local_ts));
$tpl->setVariable('CUR_TIME', date('G:i', $local_ts));
- $tpl->setVariable('TTRSS_HOST', SELF_URL_PATH);
+ $tpl->setVariable('TTRSS_HOST', Config::get(Config::get(Config::SELF_URL_PATH)));
$tpl_t->setVariable('CUR_DATE', date('Y/m/d', $local_ts));
$tpl_t->setVariable('CUR_TIME', date('G:i', $local_ts));
- $tpl_t->setVariable('TTRSS_HOST', SELF_URL_PATH);
+ $tpl_t->setVariable('TTRSS_HOST', Config::get(Config::get(Config::SELF_URL_PATH)));
$affected_ids = array();
$days = (int) $days;
- if (DB_TYPE == "pgsql") {
+ if (Config::get(Config::DB_TYPE) == "pgsql") {
$interval_qpart = "ttrss_entries.date_updated > NOW() - INTERVAL '$days days'";
- } else /* if (DB_TYPE == "mysql") */ {
+ } else /* if (Config::get(Config::DB_TYPE) == "mysql") */ {
$interval_qpart = "ttrss_entries.date_updated > DATE_SUB(NOW(), INTERVAL $days DAY)";
}
diff --git a/classes/diskcache.php b/classes/diskcache.php
index 94f645f32..9c594acc5 100644
--- a/classes/diskcache.php
+++ b/classes/diskcache.php
@@ -191,7 +191,7 @@ class DiskCache {
];
public function __construct($dir) {
- $this->dir = CACHE_DIR . "/" . basename(clean($dir));
+ $this->dir = Config::get(Config::CACHE_DIR) . "/" . basename(clean($dir));
}
public function get_dir() {
@@ -339,7 +339,7 @@ class DiskCache {
}
static function expire() {
- $dirs = array_filter(glob(CACHE_DIR . "/*"), "is_dir");
+ $dirs = array_filter(glob(Config::get(Config::CACHE_DIR) . "/*"), "is_dir");
foreach ($dirs as $cache_dir) {
$num_deleted = 0;
@@ -349,7 +349,7 @@ class DiskCache {
if ($files) {
foreach ($files as $file) {
- if (time() - filemtime($file) > 86400*CACHE_MAX_DAYS) {
+ if (time() - filemtime($file) > 86400*Config::get(Config::CACHE_MAX_DAYS)) {
unlink($file);
++$num_deleted;
@@ -396,7 +396,7 @@ class DiskCache {
$tmppluginhost = new PluginHost();
- $tmppluginhost->load(PLUGINS, PluginHost::KIND_SYSTEM);
+ $tmppluginhost->load(Config::get(Config::PLUGINS), PluginHost::KIND_SYSTEM);
//$tmppluginhost->load_data();
if ($tmppluginhost->run_hooks_until(PluginHost::HOOK_SEND_LOCAL_FILE, true, $filename))
diff --git a/classes/feeditem/common.php b/classes/feeditem/common.php
index f387e0779..8f2b9188b 100755
--- a/classes/feeditem/common.php
+++ b/classes/feeditem/common.php
@@ -179,7 +179,7 @@ abstract class FeedItem_Common extends FeedItem {
$cat = preg_replace('/[,\'\"]/', "", $cat);
- if (DB_TYPE == "mysql") {
+ if (Config::get(Config::DB_TYPE) == "mysql") {
$cat = preg_replace('/[\x{10000}-\x{10FFFF}]/u', "\xEF\xBF\xBD", $cat);
}
diff --git a/classes/feeds.php b/classes/feeds.php
index b59504c03..eaedc1aee 100755
--- a/classes/feeds.php
+++ b/classes/feeds.php
@@ -186,7 +186,7 @@ class Feeds extends Handler_Protected {
$id = $line["id"];
// frontend doesn't expect pdo returning booleans as strings on mysql
- if (DB_TYPE == "mysql") {
+ if (Config::get(Config::DB_TYPE) == "mysql") {
foreach (["unread", "marked", "published"] as $k) {
$line[$k] = $line[$k] === "1";
}
@@ -576,7 +576,7 @@ class Feeds extends Handler_Protected {
function search() {
print json_encode([
- "show_language" => DB_TYPE == "pgsql",
+ "show_language" => Config::get(Config::DB_TYPE) == "pgsql",
"show_syntax_help" => count(PluginHost::getInstance()->get_hooks(PluginHost::HOOK_SEARCH)) == 0,
"all_languages" => Pref_Feeds::get_ts_languages(),
"default_language" => get_pref('DEFAULT_SEARCH_LANGUAGE')
@@ -716,21 +716,21 @@ class Feeds extends Handler_Protected {
switch ($mode) {
case "1day":
- if (DB_TYPE == "pgsql") {
+ if (Config::get(Config::DB_TYPE) == "pgsql") {
$date_qpart = "date_entered < NOW() - INTERVAL '1 day' ";
} else {
$date_qpart = "date_entered < DATE_SUB(NOW(), INTERVAL 1 DAY) ";
}
break;
case "1week":
- if (DB_TYPE == "pgsql") {
+ if (Config::get(Config::DB_TYPE) == "pgsql") {
$date_qpart = "date_entered < NOW() - INTERVAL '1 week' ";
} else {
$date_qpart = "date_entered < DATE_SUB(NOW(), INTERVAL 1 WEEK) ";
}
break;
case "2week":
- if (DB_TYPE == "pgsql") {
+ if (Config::get(Config::DB_TYPE) == "pgsql") {
$date_qpart = "date_entered < NOW() - INTERVAL '2 week' ";
} else {
$date_qpart = "date_entered < DATE_SUB(NOW(), INTERVAL 2 WEEK) ";
@@ -807,7 +807,7 @@ class Feeds extends Handler_Protected {
$intl = (int) get_pref("FRESH_ARTICLE_MAX_AGE");
- if (DB_TYPE == "pgsql") {
+ if (Config::get(Config::DB_TYPE) == "pgsql") {
$match_part = "date_entered > NOW() - INTERVAL '$intl hour' ";
} else {
$match_part = "date_entered > DATE_SUB(NOW(),
@@ -900,7 +900,7 @@ class Feeds extends Handler_Protected {
$intl = (int) get_pref("FRESH_ARTICLE_MAX_AGE", $owner_uid);
- if (DB_TYPE == "pgsql") {
+ if (Config::get(Config::DB_TYPE) == "pgsql") {
$match_part .= " AND date_entered > NOW() - INTERVAL '$intl hour' ";
} else {
$match_part .= " AND date_entered > DATE_SUB(NOW(), INTERVAL $intl HOUR) ";
@@ -1056,11 +1056,11 @@ class Feeds extends Handler_Protected {
}
static function _get_icon_file($feed_id) {
- return ICONS_DIR . "/$feed_id.ico";
+ return Config::get(Config::ICONS_DIR) . "/$feed_id.ico";
}
static function _has_icon($id) {
- return is_file(ICONS_DIR . "/$id.ico") && filesize(ICONS_DIR . "/$id.ico") > 0;
+ return is_file(Config::get(Config::ICONS_DIR) . "/$id.ico") && filesize(Config::get(Config::ICONS_DIR) . "/$id.ico") > 0;
}
static function _get_icon($id) {
@@ -1084,7 +1084,7 @@ class Feeds extends Handler_Protected {
$icon = self::_get_icon_file($id);
if ($icon && file_exists($icon)) {
- return ICONS_URL . "/" . basename($icon) . "?" . filemtime($icon);
+ return Config::get(Config::ICONS_URL) . "/" . basename($icon) . "?" . filemtime($icon);
}
}
break;
@@ -1332,7 +1332,7 @@ class Feeds extends Handler_Protected {
list($search_query_part, $search_words) = self::_search_to_sql($search, $search_language, $owner_uid);
}
- if (DB_TYPE == "pgsql") {
+ if (Config::get(Config::DB_TYPE) == "pgsql") {
$test_sth = $pdo->prepare("select $search_query_part
FROM ttrss_entries, ttrss_user_entries WHERE id = ref_id limit 1");
@@ -1469,7 +1469,7 @@ class Feeds extends Handler_Protected {
} else if ($feed == -6) { // recently read
$query_strategy_part = "unread = false AND last_read IS NOT NULL";
- if (DB_TYPE == "pgsql") {
+ if (Config::get(Config::DB_TYPE) == "pgsql") {
$query_strategy_part .= " AND last_read > NOW() - INTERVAL '1 DAY' ";
} else {
$query_strategy_part .= " AND last_read > DATE_SUB(NOW(), INTERVAL 1 DAY) ";
@@ -1486,7 +1486,7 @@ class Feeds extends Handler_Protected {
$intl = (int) get_pref("FRESH_ARTICLE_MAX_AGE", $owner_uid);
- if (DB_TYPE == "pgsql") {
+ if (Config::get(Config::DB_TYPE) == "pgsql") {
$query_strategy_part .= " AND date_entered > NOW() - INTERVAL '$intl hour' ";
} else {
$query_strategy_part .= " AND date_entered > DATE_SUB(NOW(), INTERVAL $intl HOUR) ";
@@ -1605,7 +1605,7 @@ class Feeds extends Handler_Protected {
if ($feed == -3)
$first_id_query_strategy_part = "true";
- if (DB_TYPE == "pgsql") {
+ if (Config::get(Config::DB_TYPE) == "pgsql") {
$sanity_interval_qpart = "date_entered >= NOW() - INTERVAL '1 hour' AND";
$yyiw_qpart = "to_char(date_entered, 'IYYY-IW') AS yyiw";
@@ -1705,7 +1705,7 @@ class Feeds extends Handler_Protected {
} else {
// browsing by tag
- if (DB_TYPE == "pgsql") {
+ if (Config::get(Config::DB_TYPE) == "pgsql") {
$distinct_columns = str_replace("desc", "", strtolower($order_by));
$distinct_qpart = "DISTINCT ON (id, $distinct_columns)";
} else {
@@ -1948,10 +1948,10 @@ class Feeds extends Handler_Protected {
if ($row = $sth->fetch()) {
$owner_uid = $row["owner_uid"];
- if (FORCE_ARTICLE_PURGE != 0) {
- Debug::log("purge_feed: FORCE_ARTICLE_PURGE is set, overriding interval to " . FORCE_ARTICLE_PURGE, Debug::$LOG_VERBOSE);
+ if (Config::get(Config::FORCE_ARTICLE_PURGE) != 0) {
+ Debug::log("purge_feed: FORCE_ARTICLE_PURGE is set, overriding interval to " . Config::get(Config::FORCE_ARTICLE_PURGE), Debug::$LOG_VERBOSE);
$purge_unread = true;
- $purge_interval = FORCE_ARTICLE_PURGE;
+ $purge_interval = Config::get(Config::FORCE_ARTICLE_PURGE);
} else {
$purge_unread = get_pref("PURGE_UNREAD_ARTICLES", $owner_uid, false);
}
@@ -1970,7 +1970,7 @@ class Feeds extends Handler_Protected {
else
$query_limit = "";
- if (DB_TYPE == "pgsql") {
+ if (Config::get(Config::DB_TYPE) == "pgsql") {
$sth = $pdo->prepare("DELETE FROM ttrss_user_entries
USING ttrss_entries
WHERE ttrss_entries.id = ref_id AND
@@ -2153,7 +2153,7 @@ class Feeds extends Handler_Protected {
array_push($query_keywords, "(".SUBSTRING_FOR_DATE."(updated,1,LENGTH('$k')) $not = '$k')");
} else {
- if (DB_TYPE == "pgsql") {
+ if (Config::get(Config::DB_TYPE) == "pgsql") {
$k = mb_strtolower($k);
array_push($search_query_leftover, $not ? "!$k" : $k);
} else {
@@ -2168,7 +2168,7 @@ class Feeds extends Handler_Protected {
if (count($search_query_leftover) > 0) {
- if (DB_TYPE == "pgsql") {
+ if (Config::get(Config::DB_TYPE) == "pgsql") {
// if there's no joiners consider this a "simple" search and
// concatenate everything with &, otherwise don't try to mess with tsquery syntax
diff --git a/classes/handler/public.php b/classes/handler/public.php
index 3910cf7c1..79dff37b5 100755
--- a/classes/handler/public.php
+++ b/classes/handler/public.php
@@ -43,7 +43,7 @@ class Handler_Public extends Handler {
$user_plugins = get_pref("_ENABLED_PLUGINS", $owner_uid);
$tmppluginhost = new PluginHost();
- $tmppluginhost->load(PLUGINS, PluginHost::KIND_ALL);
+ $tmppluginhost->load(Config::get(Config::PLUGINS), PluginHost::KIND_ALL);
$tmppluginhost->load((string)$user_plugins, PluginHost::KIND_USER, $owner_uid);
//$tmppluginhost->load_data();
@@ -309,7 +309,7 @@ class Handler_Public extends Handler {
$format = clean($_REQUEST['format'] ?? "atom");
$orig_guid = clean($_REQUEST["orig_guid"] ?? false);
- if (SINGLE_USER_MODE) {
+ if (Config::get(Config::SINGLE_USER_MODE)) {
UserHelper::authenticate("admin", null);
}
@@ -347,7 +347,7 @@ class Handler_Public extends Handler {
}
function login() {
- if (!SINGLE_USER_MODE) {
+ if (!Config::get(Config::SINGLE_USER_MODE)) {
$login = clean($_POST["login"]);
$password = clean($_POST["password"]);
@@ -355,7 +355,7 @@ class Handler_Public extends Handler {
$safe_mode = checkbox_to_sql_bool(clean($_POST["safe_mode"] ?? false));
if ($remember_me) {
- @session_set_cookie_params(SESSION_COOKIE_LIFETIME);
+ @session_set_cookie_params(Config::get(Config::SESSION_COOKIE_LIFETIME));
} else {
@session_set_cookie_params(0);
}
@@ -398,7 +398,7 @@ class Handler_Public extends Handler {
$return = clean($_REQUEST['return']);
- if ($_REQUEST['return'] && mb_strpos($return, SELF_URL_PATH) === 0) {
+ if ($_REQUEST['return'] && mb_strpos($return, Config::get(Config::SELF_URL_PATH)) === 0) {
header("Location: " . clean($_REQUEST['return']));
} else {
header("Location: " . get_self_url_prefix());
@@ -559,7 +559,7 @@ class Handler_Public extends Handler {
$tpl->setVariable('LOGIN', $login);
$tpl->setVariable('RESETPASS_LINK', $resetpass_link);
- $tpl->setVariable('TTRSS_HOST', SELF_URL_PATH);
+ $tpl->setVariable('TTRSS_HOST', Config::get(Config::SELF_URL_PATH));
$tpl->addBlock('message');
@@ -613,7 +613,7 @@ class Handler_Public extends Handler {
function dbupdate() {
startup_gettext();
- if (!SINGLE_USER_MODE && $_SESSION["access_level"] < 10) {
+ if (!Config::get(Config::SINGLE_USER_MODE) && $_SESSION["access_level"] < 10) {
$_SESSION["login_error_msg"] = __("Your access level is insufficient to run this script.");
$this->_render_login_form();
exit;
@@ -660,7 +660,7 @@ class Handler_Public extends Handler {
is_update_required()) {
@@ -709,7 +709,7 @@ class Handler_Public extends Handler {
print "".T_sprintf("Tiny Tiny RSS database needs update to the latest version (%d to %d).",
$updater->get_schema_version(), SCHEMA_VERSION)."
";
- if (DB_TYPE == "mysql") {
+ if (Config::get(Config::DB_TYPE) == "mysql") {
print_error("READ THIS: Due to MySQL limitations, your database is not completely protected while updating. ".
"Errors may put it in an inconsistent state requiring manual rollback. BACKUP YOUR DATABASE BEFORE CONTINUING.");
} else {
diff --git a/classes/logger.php b/classes/logger.php
index cdc6b240a..6cc33314d 100755
--- a/classes/logger.php
+++ b/classes/logger.php
@@ -42,7 +42,7 @@ class Logger {
}
function __construct() {
- switch (LOG_DESTINATION) {
+ switch (Config::get(Config::LOG_DESTINATION)) {
case "sql":
$this->adapter = new Logger_SQL();
break;
diff --git a/classes/mailer.php b/classes/mailer.php
index 16be16523..93f778210 100644
--- a/classes/mailer.php
+++ b/classes/mailer.php
@@ -11,15 +11,15 @@ class Mailer {
$subject = $params["subject"];
$message = $params["message"];
$message_html = $params["message_html"];
- $from_name = $params["from_name"] ? $params["from_name"] : SMTP_FROM_NAME;
- $from_address = $params["from_address"] ? $params["from_address"] : SMTP_FROM_ADDRESS;
+ $from_name = $params["from_name"] ? $params["from_name"] : Config::get(Config::SMTP_FROM_NAME);
+ $from_address = $params["from_address"] ? $params["from_address"] : Config::get(Config::SMTP_FROM_ADDRESS);
$additional_headers = $params["headers"] ? $params["headers"] : [];
$from_combined = $from_name ? "$from_name <$from_address>" : $from_address;
$to_combined = $to_name ? "$to_name <$to_address>" : $to_address;
- if (defined('_LOG_SENT_MAIL') && _LOG_SENT_MAIL)
+ if (Config::get(Config::LOG_SENT_MAIL))
Logger::get()->log(E_USER_NOTICE, "Sending mail from $from_combined to $to_combined [$subject]: $message");
// HOOK_SEND_MAIL plugin instructions:
diff --git a/classes/opml.php b/classes/opml.php
index 04d287125..cbc1269e3 100644
--- a/classes/opml.php
+++ b/classes/opml.php
@@ -594,7 +594,7 @@ class OPML extends Handler_Protected {
}
if (is_uploaded_file($_FILES['opml_file']['tmp_name'])) {
- $tmp_file = (string)tempnam(CACHE_DIR . '/upload', 'opml');
+ $tmp_file = (string)tempnam(Config::get(Config::CACHE_DIR) . '/upload', 'opml');
$result = move_uploaded_file($_FILES['opml_file']['tmp_name'],
$tmp_file);
diff --git a/classes/pref/feeds.php b/classes/pref/feeds.php
index e583a5f51..7c3a40647 100755
--- a/classes/pref/feeds.php
+++ b/classes/pref/feeds.php
@@ -9,7 +9,7 @@ class Pref_Feeds extends Handler_Protected {
public static function get_ts_languages() {
$rv = [];
- if (DB_TYPE == "pgsql") {
+ if (Config::get(Config::DB_TYPE) == "pgsql") {
$dbh = Db::pdo();
$res = $dbh->query("SELECT cfgname FROM pg_ts_config");
@@ -441,7 +441,7 @@ class Pref_Feeds extends Handler_Protected {
$sth->execute([$feed_id, $_SESSION['uid']]);
if ($row = $sth->fetch()) {
- @unlink(ICONS_DIR . "/$feed_id.ico");
+ @unlink(Config::get(Config::ICONS_DIR) . "/$feed_id.ico");
$sth = $this->pdo->prepare("UPDATE ttrss_feeds SET favicon_avg_color = NULL, favicon_last_checked = '1970-01-01'
where id = ?");
@@ -453,7 +453,7 @@ class Pref_Feeds extends Handler_Protected {
header("Content-type: text/html");
if (is_uploaded_file($_FILES['icon_file']['tmp_name'])) {
- $tmp_file = tempnam(CACHE_DIR . '/upload', 'icon');
+ $tmp_file = tempnam(Config::get(Config::CACHE_DIR) . '/upload', 'icon');
if (!$tmp_file)
return;
@@ -479,7 +479,7 @@ class Pref_Feeds extends Handler_Protected {
$sth->execute([$feed_id, $_SESSION['uid']]);
if ($row = $sth->fetch()) {
- $new_filename = ICONS_DIR . "/$feed_id.ico";
+ $new_filename = Config::get(Config::ICONS_DIR) . "/$feed_id.ico";
if (file_exists($new_filename)) unlink($new_filename);
@@ -529,7 +529,7 @@ class Pref_Feeds extends Handler_Protected {
$local_update_intervals = $update_intervals;
$local_update_intervals[0] .= sprintf(" (%s)", $update_intervals[get_pref("DEFAULT_UPDATE_INTERVAL")]);
- if (FORCE_ARTICLE_PURGE == 0) {
+ if (Config::get(Config::FORCE_ARTICLE_PURGE) == 0) {
$local_purge_intervals = $purge_intervals;
$default_purge_interval = get_pref("PURGE_OLD_DAYS");
@@ -539,7 +539,7 @@ class Pref_Feeds extends Handler_Protected {
$local_purge_intervals[0] .= " " . sprintf("(%s)", __("Disabled"));
} else {
- $purge_interval = FORCE_ARTICLE_PURGE;
+ $purge_interval = Config::get(Config::FORCE_ARTICLE_PURGE);
$local_purge_intervals = [ T_nsprintf('%d day', '%d days', $purge_interval, $purge_interval) ];
}
@@ -550,13 +550,13 @@ class Pref_Feeds extends Handler_Protected {
"select" => \Controls\select_feeds_cats("cat_id", $row["cat_id"]),
],
"plugin_data" => $plugin_data,
- "force_purge" => (int)FORCE_ARTICLE_PURGE,
+ "force_purge" => (int)Config::get(Config::FORCE_ARTICLE_PURGE),
"intervals" => [
"update" => $local_update_intervals,
"purge" => $local_purge_intervals,
],
"lang" => [
- "enabled" => DB_TYPE == "pgsql",
+ "enabled" => Config::get(Config::DB_TYPE) == "pgsql",
"default" => get_pref('DEFAULT_SEARCH_LANGUAGE'),
"all" => $this::get_ts_languages(),
]
@@ -614,7 +614,7 @@ class Pref_Feeds extends Handler_Protected {
-
+
-
+