/** Main method for validating $_SERVER data
* @param array $serverData
* @throws PntValidationException if $this->serverVarValidationFatal with message about the last validation that failed
* @return array with valid server data
*/
function ($serverData) {
$this->validServerVars = array();
$error = false;
forEach($serverData as $key => $value) {
$errorMessage = $this->($key);
if ($errorMessage) {
$error = 'server var name';
$this->('server var name', $key, $errorMessage);
continue;
}
$sanitizedValue = $key == 'PHP_AUTH_USER' || $key == 'PHP_AUTH_PW'
? $this->($key, $value)
: $this->($key, $value);
$errorMessage = $this->($key, $sanitizedValue);
if ($errorMessage) {
$this->($key, $sanitizedValue, $errorMessage);
$error = $key;
} else {
$this->validServerVars[$key] = $sanitizedValue;
}
}
if ($error && $this->serverVarValidationFatal)
throw new PntValidationException("$this->serverVarValidationFailed $error");
return $this->validServerVars;
}
|