Performed optimizations in the unit testing. Some minor useless functions (which already had replacements) have been removed.
This commit is contained in:
parent
c42cfffd40
commit
0c7ae1300b
@ -725,7 +725,7 @@ class Input {
|
||||
}
|
||||
else
|
||||
{
|
||||
set_status_header(503);
|
||||
Core::setStatusHeader(503);
|
||||
echo 'Disallowed Key Characters.';
|
||||
exit(7); // EXIT_USER_INPUT
|
||||
}
|
||||
|
@ -263,7 +263,7 @@ class Security {
|
||||
$cfg = Factory::getInstance()->config->get('main');
|
||||
$secure_cookie = (bool) $cfg->cookie_secure;
|
||||
|
||||
if ($secure_cookie && ! is_https())
|
||||
if ($secure_cookie && ! Core::isHttps())
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
|
@ -94,189 +94,6 @@ if ( ! function_exists('get_mimes'))
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
if ( ! function_exists('is_https'))
|
||||
{
|
||||
/**
|
||||
* Is HTTPS?
|
||||
*
|
||||
* Determines if the application is accessed via an encrypted
|
||||
* (HTTPS) connection.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function is_https()
|
||||
{
|
||||
if ( ! empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off')
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
elseif (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https')
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
elseif ( ! empty($_SERVER['HTTP_FRONT_END_HTTPS']) && strtolower($_SERVER['HTTP_FRONT_END_HTTPS']) !== 'off')
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
if ( ! function_exists('is_cli'))
|
||||
{
|
||||
|
||||
/**
|
||||
* Is CLI?
|
||||
*
|
||||
* Test to see if a request was made from the command line.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function is_cli()
|
||||
{
|
||||
return (PHP_SAPI === 'cli' OR defined('STDIN'));
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
if ( ! function_exists('set_status_header'))
|
||||
{
|
||||
/**
|
||||
* Set HTTP Status Header
|
||||
*
|
||||
* @param int the status code
|
||||
* @param string
|
||||
* @return void
|
||||
*/
|
||||
function set_status_header($code = 200, $text = '')
|
||||
{
|
||||
if (is_cli())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (empty($code) OR ! is_numeric($code))
|
||||
{
|
||||
throw new \FuzeWorks\Exception\Exception('Status codes must be numeric', 1);
|
||||
}
|
||||
|
||||
if (empty($text))
|
||||
{
|
||||
is_int($code) OR $code = (int) $code;
|
||||
$stati = array(
|
||||
100 => 'Continue',
|
||||
101 => 'Switching Protocols',
|
||||
|
||||
200 => 'OK',
|
||||
201 => 'Created',
|
||||
202 => 'Accepted',
|
||||
203 => 'Non-Authoritative Information',
|
||||
204 => 'No Content',
|
||||
205 => 'Reset Content',
|
||||
206 => 'Partial Content',
|
||||
|
||||
300 => 'Multiple Choices',
|
||||
301 => 'Moved Permanently',
|
||||
302 => 'Found',
|
||||
303 => 'See Other',
|
||||
304 => 'Not Modified',
|
||||
305 => 'Use Proxy',
|
||||
307 => 'Temporary Redirect',
|
||||
|
||||
400 => 'Bad Request',
|
||||
401 => 'Unauthorized',
|
||||
402 => 'Payment Required',
|
||||
403 => 'Forbidden',
|
||||
404 => 'Not Found',
|
||||
405 => 'Method Not Allowed',
|
||||
406 => 'Not Acceptable',
|
||||
407 => 'Proxy Authentication Required',
|
||||
408 => 'Request Timeout',
|
||||
409 => 'Conflict',
|
||||
410 => 'Gone',
|
||||
411 => 'Length Required',
|
||||
412 => 'Precondition Failed',
|
||||
413 => 'Request Entity Too Large',
|
||||
414 => 'Request-URI Too Long',
|
||||
415 => 'Unsupported Media Type',
|
||||
416 => 'Requested Range Not Satisfiable',
|
||||
417 => 'Expectation Failed',
|
||||
422 => 'Unprocessable Entity',
|
||||
|
||||
500 => 'Internal Server Error',
|
||||
501 => 'Not Implemented',
|
||||
502 => 'Bad Gateway',
|
||||
503 => 'Service Unavailable',
|
||||
504 => 'Gateway Timeout',
|
||||
505 => 'HTTP Version Not Supported'
|
||||
);
|
||||
|
||||
if (isset($stati[$code]))
|
||||
{
|
||||
$text = $stati[$code];
|
||||
}
|
||||
else
|
||||
{
|
||||
show_error('No status text available. Please check your status code number or supply your own message text.', 500);
|
||||
}
|
||||
}
|
||||
|
||||
if (strpos(PHP_SAPI, 'cgi') === 0)
|
||||
{
|
||||
header('Status: '.$code.' '.$text, TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
$server_protocol = isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.1';
|
||||
header($server_protocol.' '.$code.' '.$text, TRUE, $code);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
if ( ! function_exists('remove_invisible_characters'))
|
||||
{
|
||||
/**
|
||||
* Remove Invisible Characters
|
||||
*
|
||||
* This prevents sandwiching null characters
|
||||
* between ascii characters, like Java\0script.
|
||||
*
|
||||
* @param string
|
||||
* @param bool
|
||||
* @return string
|
||||
*/
|
||||
function remove_invisible_characters($str, $url_encoded = TRUE)
|
||||
{
|
||||
$non_displayables = array();
|
||||
|
||||
// every control character except newline (dec 10),
|
||||
// carriage return (dec 13) and horizontal tab (dec 09)
|
||||
if ($url_encoded)
|
||||
{
|
||||
$non_displayables[] = '/%0[0-8bcef]/'; // url encoded 00-08, 11, 12, 14, 15
|
||||
$non_displayables[] = '/%1[0-9a-f]/'; // url encoded 16-31
|
||||
}
|
||||
|
||||
$non_displayables[] = '/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+/S'; // 00-08, 11, 12, 14-31, 127
|
||||
|
||||
do
|
||||
{
|
||||
$str = preg_replace($non_displayables, '', $str, -1, $count);
|
||||
}
|
||||
while ($count);
|
||||
|
||||
return $str;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
if ( ! function_exists('html_escape'))
|
||||
{
|
||||
/**
|
||||
@ -345,50 +162,3 @@ if ( ! function_exists('_stringify_attributes'))
|
||||
return rtrim($atts, ',');
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
if ( ! function_exists('function_usable'))
|
||||
{
|
||||
/**
|
||||
* Function usable
|
||||
*
|
||||
* Executes a function_exists() check, and if the Suhosin PHP
|
||||
* extension is loaded - checks whether the function that is
|
||||
* checked might be disabled in there as well.
|
||||
*
|
||||
* This is useful as function_exists() will return FALSE for
|
||||
* functions disabled via the *disable_functions* php.ini
|
||||
* setting, but not for *suhosin.executor.func.blacklist* and
|
||||
* *suhosin.executor.disable_eval*. These settings will just
|
||||
* terminate script execution if a disabled function is executed.
|
||||
*
|
||||
* The above described behavior turned out to be a bug in Suhosin,
|
||||
* but even though a fix was commited for 0.9.34 on 2012-02-12,
|
||||
* that version is yet to be released. This function will therefore
|
||||
* be just temporary, but would probably be kept for a few years.
|
||||
*
|
||||
* @link http://www.hardened-php.net/suhosin/
|
||||
* @param string $function_name Function to check for
|
||||
* @return bool TRUE if the function exists and is safe to call,
|
||||
* FALSE otherwise.
|
||||
*/
|
||||
function function_usable($function_name)
|
||||
{
|
||||
static $_suhosin_func_blacklist;
|
||||
|
||||
if (function_exists($function_name))
|
||||
{
|
||||
if ( ! isset($_suhosin_func_blacklist))
|
||||
{
|
||||
$_suhosin_func_blacklist = extension_loaded('suhosin')
|
||||
? explode(',', trim(ini_get('suhosin.executor.func.blacklist')))
|
||||
: array();
|
||||
}
|
||||
|
||||
return ! in_array($function_name, $_suhosin_func_blacklist, TRUE);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -33,6 +33,9 @@
|
||||
<exclude>
|
||||
<directory suffix=".php">../vendor/</directory>
|
||||
<directory suffix=".php">../tests/</directory>
|
||||
<directory suffix=".php">../src/Layout/</directory>
|
||||
<directory suffix=".php">../src/Config/</directory>
|
||||
<directory suffix=".php">../src/Language/</directory>
|
||||
</exclude>
|
||||
</whitelist>
|
||||
</filter>
|
||||
|
Loading…
Reference in New Issue
Block a user