Skip to content

Commit

Permalink
FIX: Check for POST support in installer
Browse files Browse the repository at this point in the history
Also two minor fixes for Web server configuration
	* Prevent notice on unsupported setups.
	* Show successful message.

Conflicts:
	dev/install/install.php5
  • Loading branch information
wilr committed May 8, 2013
1 parent c01511e commit 22e8ba6
Showing 1 changed file with 32 additions and 6 deletions.
38 changes: 32 additions & 6 deletions dev/install/install.php5
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,9 @@ class InstallRequirements {
$this->warning(array("Webserver Configuration", "URL rewriting support", "I can't tell whether any rewriting module is running. You may need to configure a rewriting rule yourself."));
}

$this->requireServerVariables(array('SCRIPT_NAME','HTTP_HOST','SCRIPT_FILENAME'), array("Webserver config", "Recognised webserver", "You seem to be using an unsupported webserver. The server variables SCRIPT_NAME, HTTP_HOST, SCRIPT_FILENAME need to be set."));
$this->requireServerVariables(array('SCRIPT_NAME','HTTP_HOST','SCRIPT_FILENAME'), array("Webserver Configuration", "Recognised webserver", "You seem to be using an unsupported webserver. The server variables SCRIPT_NAME, HTTP_HOST, SCRIPT_FILENAME need to be set."));

$this->requirePostSupport(array("Webserver Configuration", "POST Support", 'I can\'t find $_POST, make sure POST is enabled.'));

// Check for GD support
if(!$this->requireFunction("imagecreatetruecolor", array("PHP Configuration", "GD2 support", "PHP must have GD version 2."))) {
Expand Down Expand Up @@ -469,6 +471,7 @@ class InstallRequirements {

function suggestPHPSetting($settingName, $settingValues, $testDetails) {
$this->testing($testDetails);

$val = ini_get($settingName);
if(!in_array($val, $settingValues) && $val != $settingValues) {
$testDetails[2] = "$settingName is set to '$val' in php.ini. $testDetails[2]";
Expand All @@ -478,13 +481,15 @@ class InstallRequirements {

function suggestClass($class, $testDetails) {
$this->testing($testDetails);

if(!class_exists($class)) {
$this->warning($testDetails);
}
}

function requireDateTimezone($testDetails) {
$this->testing($testDetails);

$result = ini_get('date.timezone') && in_array(ini_get('date.timezone'), timezone_identifiers_list());
if(!$result) {
$this->error($testDetails);
Expand Down Expand Up @@ -597,7 +602,10 @@ class InstallRequirements {

function requireFunction($funcName, $testDetails) {
$this->testing($testDetails);
if(!function_exists($funcName)) $this->error($testDetails);

if(!function_exists($funcName)) {
$this->error($testDetails);
}
else return true;
}

Expand Down Expand Up @@ -912,19 +920,37 @@ class InstallRequirements {
}
}

function requireServerVariables($varNames, $errorMessage) {
//$this->testing($testDetails);
function requireServerVariables($varNames, $testDetails) {
$this->testing($testDetails);
$missing = array();

foreach($varNames as $varName) {
if(!$_SERVER[$varName]) $missing[] = '$_SERVER[' . $varName . ']';
if(!isset($_SERVER[$varName]) || !$_SERVER[$varName]) {
$missing[] = '$_SERVER[' . $varName . ']';
}
}
if(!isset($missing)) {

if(!$missing) {
return true;
} else {
$testDetails[2] .= " (the following PHP variables are missing: " . implode(", ", $missing) . ")";
$this->error($testDetails);
}
}


function requirePostSupport($testDetails) {
$this->testing($testDetails);

if(!isset($_POST)) {
$this->error($testDetails);

return false;
}

return true;
}

function isRunningWebServer($testDetails) {
$this->testing($testDetails);
if($testDetails[3]) {
Expand Down

0 comments on commit 22e8ba6

Please sign in to comment.