summaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2021-02-23 09:01:27 +0300
committerAndrew Dolgov <[email protected]>2021-02-23 09:01:27 +0300
commit2ae0b7059f2ed56b92a8f396c63224b36f71df09 (patch)
tree3aa1f8e8b0980c12f2b9d2b37a73034b9108acd8 /classes
parent5229cc58b269bd04b2be7768107697063d95736e (diff)
cleanup some defined-stuff
Diffstat (limited to 'classes')
-rw-r--r--classes/auth/base.php2
-rw-r--r--classes/config.php6
-rwxr-xr-xclasses/db.php2
-rw-r--r--classes/pref/prefs.php4
-rwxr-xr-xclasses/rpc.php2
-rwxr-xr-xclasses/rssutils.php8
-rw-r--r--classes/urlhelper.php14
7 files changed, 22 insertions, 16 deletions
diff --git a/classes/auth/base.php b/classes/auth/base.php
index d54e9d8a2..f18cc2d2d 100644
--- a/classes/auth/base.php
+++ b/classes/auth/base.php
@@ -16,7 +16,7 @@ abstract class Auth_Base extends Plugin implements IAuthModule {
// Auto-creates specified user if allowed by system configuration
// Can be used instead of find_user_by_login() by external auth modules
function auto_create_user(string $login, $password = false) {
- if ($login && defined('AUTH_AUTO_CREATE') && AUTH_AUTO_CREATE) {
+ if ($login && Config::get(Config::AUTH_AUTO_CREATE)) {
$user_id = UserHelper::find_user_by_login($login);
if (!$user_id) {
diff --git a/classes/config.php b/classes/config.php
index 6f62863e9..e7455daab 100644
--- a/classes/config.php
+++ b/classes/config.php
@@ -47,6 +47,9 @@ class Config {
const MAX_CONDITIONAL_INTERVAL = "MAX_CONDITIONAL_INTERVAL";
const DAEMON_UNSUCCESSFUL_DAYS_LIMIT = "DAEMON_UNSUCCESSFUL_DAYS_LIMIT";
const LOG_SENT_MAIL = "LOG_SENT_MAIL";
+ const HTTP_PROXY = "HTTP_PROXY";
+ const FORBID_PASSWORD_CHANGES = "FORBID_PASSWORD_CHANGES";
+ const TTRSS_SESSION_NAME = "TTRSS_SESSION_NAME";
private const _DEFAULTS = [
Config::DB_TYPE => "pgsql",
@@ -92,6 +95,9 @@ class Config {
Config::MAX_CONDITIONAL_INTERVAL => 3600*12,
Config::DAEMON_UNSUCCESSFUL_DAYS_LIMIT => 30,
Config::LOG_SENT_MAIL => "",
+ Config::HTTP_PROXY => "",
+ Config::FORBID_PASSWORD_CHANGES => "",
+ Config::TTRSS_SESSION_NAME => "ttrss_sid",
];
private static $instance;
diff --git a/classes/db.php b/classes/db.php
index cbfb9e598..a760d4402 100755
--- a/classes/db.php
+++ b/classes/db.php
@@ -41,7 +41,7 @@ class Db
} else if (Config::get(Config::DB_TYPE) == "mysql") {
$pdo->query("SET time_zone = '+0:0'");
- if (defined('Config::get(Config::MYSQL_CHARSET)') && Config::get(Config::MYSQL_CHARSET)) {
+ if (Config::get(Config::MYSQL_CHARSET)) {
$pdo->query("SET NAMES " . Config::get(Config::MYSQL_CHARSET));
}
}
diff --git a/classes/pref/prefs.php b/classes/pref/prefs.php
index 1ca5b28be..7ee03c21f 100644
--- a/classes/pref/prefs.php
+++ b/classes/pref/prefs.php
@@ -123,8 +123,8 @@ class Pref_Prefs extends Handler_Protected {
function changepassword() {
- if (defined('_TTRSS_DEMO_INSTANCE')) {
- print "ERROR: ".format_error("Disabled in demo version.");
+ if (Config::get(Config::FORBID_PASSWORD_CHANGES)) {
+ print "ERROR: ".format_error("Access forbidden.");
return;
}
diff --git a/classes/rpc.php b/classes/rpc.php
index 4aa3f69d5..52d514aae 100755
--- a/classes/rpc.php
+++ b/classes/rpc.php
@@ -329,7 +329,7 @@ class RPC extends Handler_Protected {
get_version($git_commit, $git_timestamp);
- if (defined('Config::get(Config::CHECK_FOR_UPDATES)') && Config::get(Config::CHECK_FOR_UPDATES) && $_SESSION["access_level"] >= 10 && $git_timestamp) {
+ if (Config::get(Config::CHECK_FOR_UPDATES) && $_SESSION["access_level"] >= 10 && $git_timestamp) {
$content = @UrlHelper::fetch(["url" => "https://tt-rss.org/version.json"]);
if ($content) {
diff --git a/classes/rssutils.php b/classes/rssutils.php
index 5dcbb48d6..6479d9f97 100755
--- a/classes/rssutils.php
+++ b/classes/rssutils.php
@@ -1583,13 +1583,13 @@ class RSSUtils {
}
static function disable_failed_feeds() {
- if (defined('DAEMON_UNSUCCESSFUL_DAYS_LIMIT') && DAEMON_UNSUCCESSFUL_DAYS_LIMIT > 0) {
+ if (Config::get(Config::DAEMON_UNSUCCESSFUL_DAYS_LIMIT) > 0) {
$pdo = Db::pdo();
$pdo->beginTransaction();
- $days = DAEMON_UNSUCCESSFUL_DAYS_LIMIT;
+ $days = Config::get(Config::DAEMON_UNSUCCESSFUL_DAYS_LIMIT);
if (Config::get(Config::DB_TYPE) == "pgsql") {
$interval_query = "last_successful_update < NOW() - INTERVAL '$days days' AND last_updated > NOW() - INTERVAL '1 days'";
@@ -1606,10 +1606,10 @@ class RSSUtils {
while ($row = $sth->fetch()) {
Logger::get()->log(E_USER_NOTICE,
sprintf("Auto disabling feed %d (%s, UID: %d) because it failed to update for %d days.",
- $row["id"], clean($row["title"]), $row["owner_uid"], DAEMON_UNSUCCESSFUL_DAYS_LIMIT));
+ $row["id"], clean($row["title"]), $row["owner_uid"], Config::get(Config::DAEMON_UNSUCCESSFUL_DAYS_LIMIT)));
Debug::log(sprintf("Auto-disabling feed %d (%s) (failed to update for %d days).", $row["id"],
- clean($row["title"]), DAEMON_UNSUCCESSFUL_DAYS_LIMIT));
+ clean($row["title"]), Config::get(Config::DAEMON_UNSUCCESSFUL_DAYS_LIMIT)));
}
$sth = $pdo->prepare("UPDATE ttrss_feeds SET update_interval = -1 WHERE
diff --git a/classes/urlhelper.php b/classes/urlhelper.php
index 42aa069e6..bf2e22a76 100644
--- a/classes/urlhelper.php
+++ b/classes/urlhelper.php
@@ -123,9 +123,9 @@ class UrlHelper {
'protocol_version'=> 1.1)
);
- if (defined('_HTTP_PROXY')) {
+ if (Config::get(Config::HTTP_PROXY)) {
$context_options['http']['request_fulluri'] = true;
- $context_options['http']['proxy'] = _HTTP_PROXY;
+ $context_options['http']['proxy'] = Config::get(Config::HTTP_PROXY);
}
$context = stream_context_create($context_options);
@@ -231,7 +231,7 @@ class UrlHelper {
return false;
}
- if (!defined('NO_CURL') && function_exists('curl_init') && !ini_get("open_basedir")) {
+ if (function_exists('curl_init') && !ini_get("open_basedir")) {
$fetch_curl_used = true;
@@ -283,8 +283,8 @@ class UrlHelper {
curl_setopt($ch, CURLOPT_COOKIEJAR, "/dev/null");
}
- if (defined('_HTTP_PROXY')) {
- curl_setopt($ch, CURLOPT_PROXY, _HTTP_PROXY);
+ if (Config::get(Config::HTTP_PROXY)) {
+ curl_setopt($ch, CURLOPT_PROXY, Config::get(Config::HTTP_PROXY));
}
if ($post_query) {
@@ -408,9 +408,9 @@ class UrlHelper {
if ($http_referrer)
array_push($context_options['http']['header'], "Referer: $http_referrer");
- if (defined('_HTTP_PROXY')) {
+ if (Config::get(Config::HTTP_PROXY)) {
$context_options['http']['request_fulluri'] = true;
- $context_options['http']['proxy'] = _HTTP_PROXY;
+ $context_options['http']['proxy'] = Config::get(Config::HTTP_PROXY);
}
$context = stream_context_create($context_options);