aboutsummaryrefslogtreecommitdiff
path: root/lib/lib_rss.php
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2018-09-09 13:03:51 +0200
committerGravatar GitHub <noreply@github.com> 2018-09-09 13:03:51 +0200
commit44bd07e506ade204151c276fdc05994d51efdd7a (patch)
tree2efe48133d2c874c65a99ae3a6cd92bb0dff4fe8 /lib/lib_rss.php
parent3306a1679c2570c30d4b662c887b4a71ce147398 (diff)
parent1802c1e9ae7d3d55a0e37e1cc2e7c0acc25f70ba (diff)
Merge pull request #2001 from FreshRSS/dev1.11.2
FreshRSS 1.11.2
Diffstat (limited to 'lib/lib_rss.php')
-rw-r--r--lib/lib_rss.php20
1 files changed, 16 insertions, 4 deletions
diff --git a/lib/lib_rss.php b/lib/lib_rss.php
index 5f460862e..44123b746 100644
--- a/lib/lib_rss.php
+++ b/lib/lib_rss.php
@@ -21,6 +21,12 @@ if (!function_exists('json_encode')) {
defined('JSON_UNESCAPED_UNICODE') or define('JSON_UNESCAPED_UNICODE', 256); //PHP 5.3
+if (!function_exists('mb_strcut')) {
+ function mb_strcut($str, $start, $length = null, $encoding = 'UTF-8') {
+ return substr($str, $start, $length);
+ }
+}
+
/**
* Build a directory path by concatenating a list of directory names.
*
@@ -103,24 +109,29 @@ function safe_ascii($text) {
* localhost address.
*
* @param $address the address to test, can be an IP or a URL.
- * @return true if server is accessible, false else.
+ * @return true if server is accessible, false otherwise.
* @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]',
+ 'ip6-localhost',
'localhost6',
'localhost6.localdomain6',
));
- return $is_public;
-}
+ if ($is_public) {
+ $ip = gethostbyname($host);
+ $is_public &= !preg_match('/^(10|127|172[.]16|192[.]168)[.]/', $ip);
+ $is_public &= !preg_match('/^(\[)?(::1$|fc00::|fe80::)/i', $ip);
+ }
+ return (bool)$is_public;
+}
function format_number($n, $precision = 0) {
// number_format does not seem to be Unicode-compatible
@@ -405,6 +416,7 @@ function check_install_php() {
'fileinfo' => extension_loaded('fileinfo'),
'dom' => class_exists('DOMDocument'),
'json' => extension_loaded('json'),
+ 'mbstring' => extension_loaded('mbstring'),
'zip' => extension_loaded('zip'),
);
}