aboutsummaryrefslogtreecommitdiff
path: root/lib/lib_rss.php
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2015-07-23 14:24:00 +0200
committerGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2015-07-23 14:24:00 +0200
commit7242806c309afdc38a0b5fa165a2a00f87292c9d (patch)
treee112184b03d01c5bcd2382d91f88505f48dd9f6d /lib/lib_rss.php
parentd2caf4349c4c5957ddc453795ffe8ea10237231c (diff)
parentf4472fc918c1fa1d1cfb2adae6c38a9a261e8c9b (diff)
Merge pull request #917 from marienfressinaud/865-base_url-pubsubhubbub
Generate base_url during installation
Diffstat (limited to 'lib/lib_rss.php')
-rw-r--r--lib/lib_rss.php27
1 files changed, 27 insertions, 0 deletions
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