From eaccc1eba4bf7a00a6cce26de9e4da22067fe86b Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Thu, 23 Jul 2015 12:24:24 +0200 Subject: Generate base_url during installation See https://github.com/FreshRSS/FreshRSS/issues/865 --- app/install.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'app/install.php') diff --git a/app/install.php b/app/install.php index d5455f17d..3930a3d41 100644 --- a/app/install.php +++ b/app/install.php @@ -212,8 +212,11 @@ function saveStep3() { $_SESSION['bd_prefix_user'] = $_SESSION['bd_prefix'] . (empty($_SESSION['default_user']) ? '' : ($_SESSION['default_user'] . '_')); } + // We use dirname to remove the /i part + $base_url = dirname(Minz_Request::guessBaseUrl()); $config_array = array( 'salt' => $_SESSION['salt'], + 'base_url' => $base_url, 'title' => $_SESSION['title'], 'default_user' => $_SESSION['default_user'], 'auth_type' => $_SESSION['auth_type'], -- cgit v1.2.3 From 339e32424fa60fc0c99a4c10890abef139444f6d Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Thu, 23 Jul 2015 12:38:22 +0200 Subject: Add a simple test to detect if server is public If the server is not accessible by an external server, pubsubhubbub should be disable. See https://github.com/FreshRSS/FreshRSS/issues/865 --- app/install.php | 1 + lib/lib_rss.php | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) (limited to 'app/install.php') diff --git a/app/install.php b/app/install.php index 3930a3d41..65138a683 100644 --- a/app/install.php +++ b/app/install.php @@ -229,6 +229,7 @@ function saveStep3() { 'prefix' => $_SESSION['bd_prefix'], 'pdo_options' => array(), ), + 'enable_pubsubhubbub' => server_is_public($base_url), ); @unlink(join_path(DATA_PATH, 'config.php')); //To avoid access-rights problems diff --git a/lib/lib_rss.php b/lib/lib_rss.php index c99e2c7e8..2a23fca45 100644 --- a/lib/lib_rss.php +++ b/lib/lib_rss.php @@ -83,6 +83,33 @@ function checkUrl($url) { } } + +/** + * Test if a given server address is publicly accessible. + * + * Note: for the moment it tests only if address is corresponding to a + * localhost address. + * + * @param $address the address to test, can be an IP or a URL. + * @return true if server is accessible, false else. + * @todo improve test with a more valid technique (e.g. test with an external server?) + */ +function server_is_public($address) { + $host = parse_url($address, PHP_URL_HOST); + + $is_public = !in_array($host, array( + '127.0.0.1', + 'localhost', + 'localhost.localdomain', + '[::1]', + 'localhost6', + 'localhost6.localdomain6', + )); + + return $is_public; +} + + function format_number($n, $precision = 0) { // number_format does not seem to be Unicode-compatible return str_replace(' ', ' ', //Espace fine insécable -- cgit v1.2.3 From baa36f158b59c9229e3f1a5a0edb6f1bb3a54198 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Thu, 23 Jul 2015 13:54:34 +0200 Subject: Add pubsubhubbub_enabled to default configuration Rename enable_pubsubhubbub into pubsubhubbub_enabled See https://github.com/FreshRSS/FreshRSS/issues/865 --- app/install.php | 2 +- data/config.default.php | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'app/install.php') diff --git a/app/install.php b/app/install.php index 65138a683..5a774d7c1 100644 --- a/app/install.php +++ b/app/install.php @@ -229,7 +229,7 @@ function saveStep3() { 'prefix' => $_SESSION['bd_prefix'], 'pdo_options' => array(), ), - 'enable_pubsubhubbub' => server_is_public($base_url), + 'pubsubhubbub_enabled' => server_is_public($base_url), ); @unlink(join_path(DATA_PATH, 'config.php')); //To avoid access-rights problems diff --git a/data/config.default.php b/data/config.default.php index 5db933ff8..a7a29b12c 100644 --- a/data/config.default.php +++ b/data/config.default.php @@ -57,6 +57,10 @@ return array( # SimplePie, which is retrieving RSS feeds via HTTP requests. 'simplepie_syslog_enabled' => true, + # Enable or not support of PubSubHubbub. + # /!\ It should NOT be enabled if base_url is not reachable by an external server. + 'pubsubhubbub_enabled' => false, + 'limits' => array( # Duration in seconds of the SimplePie cache, -- cgit v1.2.3