ConLite/setup/lib/functions.phpinfo.php

128 Zeilen
2.4 KiB
PHP

<?php
2020-09-01 13:23:56 +00:00
/**
2023-07-04 15:09:34 +00:00
* Project:
* Contenido Content Management System
2023-07-04 15:09:34 +00:00
*
* Description:
*
* Requirements:
* @con_php_req 5
*
* @package ContenidoBackendArea
* @version 0.3
* @author unknown
* @copyright four for business AG <www.4fb.de>
* @license http://www.contenido.org/license/LIZENZ.txt
* @link http://www.4fb.de
* @link http://www.contenido.org
2023-07-04 15:09:34 +00:00
*
*
*
* {@internal
* created unknown
* modified 2008-07-07, bilal arslan, added security fix
* modified 2011-02-08, Dominik Ziegler, removed old PHP compatibility stuff as contenido now requires at least PHP 5
*
2019-07-03 11:58:28 +00:00
* $Id$:
* }}
2023-07-04 15:09:34 +00:00
*
*/
2020-09-01 13:23:56 +00:00
if (!defined('CON_FRAMEWORK')) {
die('Illegal call');
}
2023-07-04 15:19:57 +00:00
/** @todo move to enum */
2020-09-01 13:23:56 +00:00
define("E_EXTENSION_AVAILABLE", 1);
define("E_EXTENSION_UNAVAILABLE", 2);
define("E_EXTENSION_CANTCHECK", 3);
/**
* canPHPurlfopen: Checks if PHP is able to use
* allow_url_fopen.
*/
2023-07-04 15:09:34 +00:00
function canPHPurlfopen(): bool
2023-04-07 17:50:44 +00:00
{
return ini_get("allow_url_fopen");
}
2023-07-04 15:09:34 +00:00
function getPHPDisplayErrorSetting(): bool
2023-04-07 17:50:44 +00:00
{
return ini_get("display_errors");
}
2023-07-04 15:09:34 +00:00
function getPHPFileUploadSetting(): bool
2023-04-07 17:50:44 +00:00
{
return ini_get("file_uploads");
}
2023-07-04 15:09:34 +00:00
function getPHPGPCOrder(): bool
2023-04-07 17:50:44 +00:00
{
return ini_get("gpc_order");
}
2023-07-04 15:09:34 +00:00
function getPHPMagicQuotesRuntime(): bool
2023-04-07 17:50:44 +00:00
{
return ini_get("magic_quotes_runtime");
}
2023-07-04 15:09:34 +00:00
function getPHPMagicQuotesSybase(): bool
2023-04-07 17:50:44 +00:00
{
return ini_get("magic_quotes_sybase");
}
2023-07-04 15:09:34 +00:00
function getPHPMaxExecutionTime(): bool
2023-04-07 17:50:44 +00:00
{
return ini_get("max_execution_time");
}
2023-07-04 15:09:34 +00:00
function getPHPOpenBasedirSetting(): bool
2023-04-07 17:50:44 +00:00
{
return ini_get("open_basedir");
}
2023-07-04 15:09:34 +00:00
function checkPHPSQLSafeMode(): bool
2023-04-07 17:50:44 +00:00
{
return ini_get("sql.safe_mode");
}
2023-07-04 15:09:34 +00:00
function return_bytes($val): float|int
2023-04-07 17:50:44 +00:00
{
2020-09-01 13:23:56 +00:00
if (strlen($val) == 0) {
return 0;
}
$val = trim($val);
2020-09-01 13:23:56 +00:00
$last = $val[strlen($val) - 1];
2023-04-07 17:50:44 +00:00
return match ($last) {
2023-07-04 15:09:34 +00:00
'k', 'K' => (int)$val * 1024,
'm', 'M' => (int)$val * 1_048_576,
2023-04-07 17:50:44 +00:00
default => $val,
};
}
2023-07-04 15:09:34 +00:00
function isPHPExtensionLoaded($extension)
{
2020-09-01 13:23:56 +00:00
$value = extension_loaded($extension);
if ($value === true) {
return E_EXTENSION_AVAILABLE;
}
if ($value === false) {
return E_EXTENSION_UNAVAILABLE;
}
2023-04-07 17:50:44 +00:00
if ($value === NULL) {
return E_EXTENSION_CANTCHECK;
2020-09-01 13:23:56 +00:00
}
}
/**
* Test for PHP compatibility
2023-07-04 15:09:34 +00:00
*
* @param string $sVersion phpversion to test
*/
2023-04-07 17:50:44 +00:00
function isPHPCompatible($sVersion = "8.0.0"): bool
{
return version_compare(phpversion(), $sVersion, ">=");
}