|
@@ 518-524 (lines=7) @@
|
| 515 |
|
public static function host() |
| 516 |
|
{ |
| 517 |
|
// Check if overridden by alternate_base_url |
| 518 |
|
if ($baseURL = self::config()->get('alternate_base_url')) { |
| 519 |
|
$baseURL = Injector::inst()->convertServiceProperty($baseURL); |
| 520 |
|
$host = parse_url($baseURL, PHP_URL_HOST); |
| 521 |
|
if ($host) { |
| 522 |
|
return $host; |
| 523 |
|
} |
| 524 |
|
} |
| 525 |
|
|
| 526 |
|
$request = Injector::inst()->get(HTTPRequest::class); |
| 527 |
|
if ($request && $host = $request->getHeader('Host')) { |
|
@@ 537-543 (lines=7) @@
|
| 534 |
|
} |
| 535 |
|
|
| 536 |
|
// Check base url |
| 537 |
|
if ($baseURL = self::config()->uninherited('default_base_url')) { |
| 538 |
|
$baseURL = Injector::inst()->convertServiceProperty($baseURL); |
| 539 |
|
$host = parse_url($baseURL, PHP_URL_HOST); |
| 540 |
|
if ($host) { |
| 541 |
|
return $host; |
| 542 |
|
} |
| 543 |
|
} |
| 544 |
|
|
| 545 |
|
// Fail over to server_name (least reliable) |
| 546 |
|
return isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : gethostname(); |
|
@@ 578-584 (lines=7) @@
|
| 575 |
|
public static function is_https() |
| 576 |
|
{ |
| 577 |
|
// Check override from alternate_base_url |
| 578 |
|
if ($baseURL = self::config()->uninherited('alternate_base_url')) { |
| 579 |
|
$baseURL = Injector::inst()->convertServiceProperty($baseURL); |
| 580 |
|
$protocol = parse_url($baseURL, PHP_URL_SCHEME); |
| 581 |
|
if ($protocol) { |
| 582 |
|
return $protocol === 'https'; |
| 583 |
|
} |
| 584 |
|
} |
| 585 |
|
|
| 586 |
|
// Check the current request |
| 587 |
|
$request = Injector::inst()->get(HTTPRequest::class); |
|
@@ 593-599 (lines=7) @@
|
| 590 |
|
} |
| 591 |
|
|
| 592 |
|
// Check default_base_url |
| 593 |
|
if ($baseURL = self::config()->uninherited('default_base_url')) { |
| 594 |
|
$baseURL = Injector::inst()->convertServiceProperty($baseURL); |
| 595 |
|
$protocol = parse_url($baseURL, PHP_URL_SCHEME); |
| 596 |
|
if ($protocol) { |
| 597 |
|
return $protocol === 'https'; |
| 598 |
|
} |
| 599 |
|
} |
| 600 |
|
|
| 601 |
|
return false; |
| 602 |
|
} |