MINOR Simplified discovery of webserver during install

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/phpinstaller/branches/2.4@108568 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
sharvey 2010-07-27 05:05:27 +00:00 committed by Sam Minnee
parent e5ce99f4ad
commit 48a301266a

View File

@ -277,40 +277,34 @@ class InstallRequirements {
* @return boolean * @return boolean
*/ */
function isIIS() { function isIIS() {
if(isset($_SERVER['SERVER_SOFTWARE'])) { if(strpos($this->findWebserver(), 'IIS/7') !== false) {
if(strpos($_SERVER['SERVER_SOFTWARE'], 'IIS/7') !== false) {
return true; return true;
} } else {
}
return false; return false;
} }
}
function isApache() { function isApache() {
$signature = !empty($_SERVER['SERVER_SIGNATURE']) if(strpos($this->findWebserver(), 'Apache') !== false) {
? $_SERVER['SERVER_SIGNATURE']
: @$_SERVER['SERVER_SOFTWARE'];
$signature = strip_tags(trim($signature));
if($signature && strpos($signature, 'Apache') !== false) {
return true; return true;
} else { } else {
return false; return false;
} }
} }
/**
* Find the webserver software running on the PHP host.
* @return string Server software ("Unknown" if not able to find)
*/
function findWebserver() { function findWebserver() {
$webserver = strip_tags(trim(@$_SERVER['SERVER_SIGNATURE'])); // Try finding from SERVER_SIGNATURE or SERVER_SOFTWARE
if(!$webserver) { $webserver = @$_SERVER['SERVER_SIGNATURE'];
if(isset($_SERVER['SERVER_SOFTWARE'])) { if(!$webserver) $webserver = @$_SERVER['SERVER_SOFTWARE'];
if(strpos($_SERVER['SERVER_SOFTWARE'], 'IIS/7') !== false ||
strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') !== false) { // If we still can't find it, this is a completely unknown server
$webserver = $_SERVER['SERVER_SOFTWARE']; if(!$webserver) $webserver = 'Unknown';
}
} else { return strip_tags(trim($webserver));
$webserver = "I can't tell what webserver you are running";
}
}
return $webserver;
} }
/** /**