summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2023-10-22 12:20:38 +0300
committerAndrew Dolgov <[email protected]>2023-10-22 12:20:38 +0300
commit8d3f570ee9b14560ac4cb48543b28b9a5a1281fc (patch)
treec696572269b95a51893b676aa10a99c53521035c
parent382d01e8db053023d4e461e535d6cc49c7ecc76f (diff)
parent7bba4ae558e6c9015a4efb063c92cf0b8037708b (diff)
Merge branch 'master' into protected/selenium
-rw-r--r--.env-dist4
-rw-r--r--[-rwxr-xr-x]cache/export/.empty0
-rw-r--r--[-rwxr-xr-x]cache/images/.empty0
-rw-r--r--classes/config.php57
-rw-r--r--[-rwxr-xr-x]feed-icons/.empty0
-rwxr-xr-xinclude/login_form.php2
-rw-r--r--[-rwxr-xr-x]lock/.empty0
7 files changed, 20 insertions, 43 deletions
diff --git a/.env-dist b/.env-dist
index c43ad0eed..7af56ef56 100644
--- a/.env-dist
+++ b/.env-dist
@@ -30,8 +30,8 @@ TTRSS_DB_USER=postgres
TTRSS_DB_NAME=postgres
TTRSS_DB_PASS=password
-# You will likely need to set this to the correct value - it should point to external tt-rss URL as seen in your browser.
-TTRSS_SELF_URL_PATH=http://example.com/tt-rss
+# This is a fallback value for PHP CLI SAPI, it should be set to a fully-qualified tt-rss URL
+# TTRSS_SELF_URL_PATH=http://example.com/tt-rss
# You can customize other config.php defines by setting overrides here. See tt-rss/.docker/app/Dockerfile for complete list. Examples:
diff --git a/cache/export/.empty b/cache/export/.empty
index e69de29bb..e69de29bb 100755..100644
--- a/cache/export/.empty
+++ b/cache/export/.empty
diff --git a/cache/images/.empty b/cache/images/.empty
index e69de29bb..e69de29bb 100755..100644
--- a/cache/images/.empty
+++ b/cache/images/.empty
diff --git a/classes/config.php b/classes/config.php
index 50ad8c10f..17c555fa9 100644
--- a/classes/config.php
+++ b/classes/config.php
@@ -46,10 +46,7 @@ class Config {
* garbage unicode characters with this option, try setting it to a blank string. */
const MYSQL_CHARSET = "MYSQL_CHARSET";
- /** this should be set to a fully qualified URL used to access
- * your tt-rss instance over the net, such as: https://example.com/tt-rss/
- * if your tt-rss instance is behind a reverse proxy, use external URL.
- * tt-rss will likely help you pick correct value for this on startup */
+ /** this is a fallback falue for the CLI SAPI, it should be set to a fully-qualified tt-rss URL */
const SELF_URL_PATH = "SELF_URL_PATH";
/** operate in single user mode, disables all functionality related to
@@ -207,7 +204,7 @@ class Config {
Config::DB_PASS => [ "", Config::T_STRING ],
Config::DB_PORT => [ "5432", Config::T_STRING ],
Config::MYSQL_CHARSET => [ "UTF8", Config::T_STRING ],
- Config::SELF_URL_PATH => [ "", Config::T_STRING ],
+ Config::SELF_URL_PATH => [ "https://example.com/tt-rss", Config::T_STRING ],
Config::SINGLE_USER_MODE => [ "", Config::T_BOOL ],
Config::SIMPLE_UPDATE_MODE => [ "", Config::T_BOOL ],
Config::PHP_EXECUTABLE => [ "/usr/bin/php", Config::T_STRING ],
@@ -474,32 +471,30 @@ class Config {
return $instance->_get($param);
}
- /** this returns Config::SELF_URL_PATH sans trailing slash */
- static function get_self_url() : string {
- return preg_replace("#/*$#", "", self::get(Config::SELF_URL_PATH));
- }
-
static function is_server_https() : bool {
return (!empty($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] != 'off')) ||
(!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https');
}
- /** generates reference self_url_path (no trailing slash) */
- static function make_self_url() : string {
- $proto = self::is_server_https() ? 'https' : 'http';
-
- $self_url_path = $proto . '://' . $_SERVER["HTTP_HOST"] . parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH);
+ /** returns fully-qualified external URL to tt-rss (no trailing slash)
+ * SELF_URL_PATH configuration variable is used as a fallback for the CLI SAPI
+ * */
+ static function get_self_url() : string {
+ if (php_sapi_name() == "cli") {
+ return self::get(Config::SELF_URL_PATH);
+ } else {
+ $proto = self::is_server_https() ? 'https' : 'http';
- $self_url_path = preg_replace("/\w+\.php(\?.*$)?$/", "", $self_url_path);
- #$self_url_path = preg_replace("/(\?.*$)?$/", "", $self_url_path);
+ $self_url_path = $proto . '://' . $_SERVER["HTTP_HOST"] . parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH);
+ $self_url_path = preg_replace("/\w+\.php(\?.*$)?$/", "", $self_url_path);
- if (substr($self_url_path, -1) === "/") {
- return substr($self_url_path, 0, -1);
- } else {
- return $self_url_path;
+ if (substr($self_url_path, -1) === "/") {
+ return substr($self_url_path, 0, -1);
+ } else {
+ return $self_url_path;
+ }
}
}
-
/* sanity check stuff */
/** checks for mysql tables not using InnoDB (tt-rss is incompatible with MyISAM)
@@ -620,27 +615,9 @@ class Config {
// skip check for CLI scripts so that we could install database schema if it is missing.
if (php_sapi_name() != "cli") {
-
if (self::get_schema_version() < 0) {
array_push($errors, "Base database schema is missing. Either load it manually or perform a migration (<code>update.php --update-schema</code>)");
}
-
- $ref_self_url_path = self::make_self_url();
-
- if ($ref_self_url_path) {
- $ref_self_url_path = preg_replace("/\w+\.php$/", "", $ref_self_url_path);
- }
-
- if (self::get_self_url() == "http://example.org/tt-rss") {
- $hint = $ref_self_url_path ? "(possible value: <b>$ref_self_url_path</b>)" : "";
- array_push($errors,
- "Please set SELF_URL_PATH to the correct value for your server: $hint");
- }
-
- if (self::get_self_url() != $ref_self_url_path) {
- array_push($errors,
- "Please set SELF_URL_PATH to the correct value detected for your server: <b>$ref_self_url_path</b> (you're using: <b>" . self::get_self_url() . "</b>)");
- }
}
if (self::get(Config::DB_TYPE) == "mysql") {
diff --git a/feed-icons/.empty b/feed-icons/.empty
index e69de29bb..e69de29bb 100755..100644
--- a/feed-icons/.empty
+++ b/feed-icons/.empty
diff --git a/include/login_form.php b/include/login_form.php
index a26a58cc9..0545a51be 100755
--- a/include/login_form.php
+++ b/include/login_form.php
@@ -104,7 +104,7 @@
</script>
-<?php $return = urlencode(!empty($_REQUEST['return']) ? $_REQUEST['return'] : with_trailing_slash(Config::make_self_url())) ?>
+<?php $return = urlencode(!empty($_REQUEST['return']) ? $_REQUEST['return'] : with_trailing_slash(Config::get_self_url())) ?>
<div class="container">
diff --git a/lock/.empty b/lock/.empty
index e69de29bb..e69de29bb 100755..100644
--- a/lock/.empty
+++ b/lock/.empty