viewgit/inc/functions.php:22 Function utf8_encode() is deprecated [8192]

Better port checking getPages, a=chris

Chris Pollett [2018-04-13 05:Apr:th]
Better port checking getPages, a=chris
Filename
src/library/FetchUrl.php
diff --git a/src/library/FetchUrl.php b/src/library/FetchUrl.php
index ad348c2af..b1468a8d9 100755
--- a/src/library/FetchUrl.php
+++ b/src/library/FetchUrl.php
@@ -97,10 +97,17 @@ class FetchUrl implements CrawlConstants
             $is_gopher = false;
             $sites[$i][CrawlConstants::IS_GOPHER_URL] = $is_gopher;
             $host = @parse_url($sites[$i][$key], PHP_URL_HOST);
+            $local_hosts = ['localhost', '::1', '0.0.0.0',
+                '127.0.0.1', $_SERVER['SERVER_NAME']];
+            if (substr($_SERVER['SERVER_NAME'], 0, 3) != "www") {
+                $local_hosts[] = "www" . $_SERVER['SERVER_NAME'];
+            }
             if (C\nsdefined("IS_OWN_WEB_SERVER") &&
-                in_array($host, ['localhost', '::1', '0.0.0.0',
-                '127.0.0.1', $_SERVER['SERVER_NAME']])) {
+                in_array($host, $local_hosts)) {
                 $port = @parse_url($sites[$i][$key], PHP_URL_PORT);
+                if (empty($port)) {
+                    $port = $_SERVER['SERVER_PORT'];
+                }
                 if ($port == $_SERVER['SERVER_PORT']) {
                     $sites[$i][0] = "INTERNAL";
                     if (empty($GLOBALS['web_site'])) {
ViewGit