summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNate Silva <nate@natesilva.com>2015-11-05 22:43:53 +0100
committerNate Silva <nate@natesilva.com>2015-11-05 22:43:53 +0100
commit845ed89709f84d56edeeb91e877f585a5798006d (patch)
tree10b06ffebc0364b5d8dd257ea9c80bed8fcd09d7
parent66a8940823b8ce9cd9e0bfe5d4263008a437a422 (diff)
Build base_url correctly if SERVER_ADDR is IPv6
-rw-r--r--system/core/Config.php10
1 files changed, 9 insertions, 1 deletions
diff --git a/system/core/Config.php b/system/core/Config.php
index 0264776f9..dfef8dbe4 100644
--- a/system/core/Config.php
+++ b/system/core/Config.php
@@ -90,7 +90,15 @@ class CI_Config {
{
if (isset($_SERVER['SERVER_ADDR']))
{
- $base_url = (is_https() ? 'https' : 'http').'://'.$_SERVER['SERVER_ADDR']
+ if ((bool) filter_var($_SERVER['SERVER_ADDR'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6))
+ {
+ $server_addr = '[' . $_SERVER['SERVER_ADDR'] . ']';
+ }
+ else
+ {
+ $server_addr = $_SERVER['SERVER_ADDR'];
+ }
+ $base_url = (is_https() ? 'https' : 'http').'://'.$server_addr
.substr($_SERVER['SCRIPT_NAME'], 0, strpos($_SERVER['SCRIPT_NAME'], basename($_SERVER['SCRIPT_FILENAME'])));
}
else