mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
aoneil: allow the dev servers and test servers to be set via Director (merged from branches/2.1.0)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@42736 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
a6700028b2
commit
07c3a3a32b
@ -399,6 +399,20 @@ class Director {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static $dev_servers = array(
|
||||||
|
'localhost',
|
||||||
|
'127.0.0.1'
|
||||||
|
);
|
||||||
|
static function set_dev_servers($servers) {
|
||||||
|
Director::$dev_servers = $servers;
|
||||||
|
}
|
||||||
|
|
||||||
|
static $test_servers = array();
|
||||||
|
static function set_test_servers($servers) {
|
||||||
|
Director::$test_servers = $servers;
|
||||||
|
}
|
||||||
|
|
||||||
static protected $environment_type;
|
static protected $environment_type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -431,17 +445,30 @@ class Director {
|
|||||||
|
|
||||||
if(isset($_SESSION['isDev']) && $_SESSION['isDev']) return true;
|
if(isset($_SESSION['isDev']) && $_SESSION['isDev']) return true;
|
||||||
|
|
||||||
// Anything running on localhost is automatically dev
|
// Check if we are running on one of the development servers
|
||||||
if($_SERVER['SERVER_ADDR'] == '0.0.0.0' || $_SERVER['REMOTE_ADDR'] == $_SERVER['SERVER_ADDR']) return true;
|
if(in_array($_SERVER['SERVER_ADDR'], Director::$dev_servers)) {
|
||||||
|
return true;
|
||||||
$testURL = ".$_SERVER[HTTP_HOST].";
|
|
||||||
return (strpos($testURL, '.test.') === false) && (strpos($testURL, '.dev.') !== false) ;
|
|
||||||
}
|
}
|
||||||
static function isTest() {
|
|
||||||
if(self::$environment_type) return self::$environment_type == 'test';
|
|
||||||
|
|
||||||
$testURL = ".$_SERVER[HTTP_HOST].";
|
// Check if we are running on one of the test servers
|
||||||
return (strpos($testURL, '.test.') !== false);
|
if(in_array($_SERVER['SERVER_ADDR'], Director::$test_servers)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static function isTest() {
|
||||||
|
if(self::$environment_type) {
|
||||||
|
return self::$environment_type == 'test';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if we are running on one of the test servers
|
||||||
|
if(in_array($_SERVER['SERVER_ADDR'], Director::$test_servers)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user