fixes php8

This commit is contained in:
Ortwin Pinke 2023-04-07 19:50:44 +02:00
parent fcda0a460b
commit b438f15708
24 changed files with 201 additions and 415 deletions

View file

@ -22,9 +22,9 @@ if (!defined('CON_FRAMEWORK')) {
define('CON_FRAMEWORK', true);
}
define('CON_SETUP_PATH', str_replace('\\', '/', realpath(dirname(__FILE__))));
define('CON_SETUP_PATH', str_replace('\\', '/', realpath(__DIR__)));
define('CON_FRONTEND_PATH', str_replace('\\', '/', realpath(dirname(__FILE__) . '/../')));
define('CON_FRONTEND_PATH', str_replace('\\', '/', realpath(__DIR__ . '/../')));
include_once('lib/startup.php');
@ -113,7 +113,7 @@ if (cFileHandler::exists('data/tables_pi.txt')) {
}
}
$pluginChunks = array();
$pluginChunks = [];
$baseChunks = txtFileToArray('data/base.txt');
@ -128,20 +128,12 @@ $contentChunks = txtFileToArray('data/examples.txt');
$sysadminChunk = txtFileToArray('data/sysadmin.txt');
if ($_SESSION['setuptype'] == 'setup') {
switch ($_SESSION['clientmode']) {
case 'CLIENT':
$fullChunks = array_merge($baseChunks, $sysadminChunk, $clientNoContentChunks);
break;
case 'CLIENTMODULES':
$fullChunks = array_merge($baseChunks, $sysadminChunk, $clientNoContentChunks, $moduleChunks);
break;
case 'CLIENTEXAMPLES':
$fullChunks = array_merge($baseChunks, $sysadminChunk, $clientChunks, $moduleChunks, $contentChunks);
break;
default:
$fullChunks = array_merge($baseChunks, $sysadminChunk);
break;
}
$fullChunks = match ($_SESSION['clientmode']) {
'CLIENT' => array_merge($baseChunks, $sysadminChunk, $clientNoContentChunks),
'CLIENTMODULES' => array_merge($baseChunks, $sysadminChunk, $clientNoContentChunks, $moduleChunks),
'CLIENTEXAMPLES' => array_merge($baseChunks, $sysadminChunk, $clientChunks, $moduleChunks, $contentChunks),
default => array_merge($baseChunks, $sysadminChunk),
};
} else {
$fullChunks = $baseChunks;
}
@ -149,22 +141,19 @@ if ($_SESSION['setuptype'] == 'setup') {
$fullChunks = array_merge($fullChunks, $pluginChunks);
list($root_path, $root_http_path) = getSystemDirectories();
[$root_path, $root_http_path] = getSystemDirectories();
$totalsteps = ceil($fullcount / 50) + count($fullChunks) + 1;
foreach ($fullChunks as $fullChunk) {
$step++;
if ($step == $currentstep) {
$failedChunks = array();
$failedChunks = [];
$replacements = array(
'<!--{conlite_root}-->' => addslashes($root_path),
'<!--{conlite_web}-->' => addslashes($root_http_path)
);
$replacements = ['<!--{conlite_root}-->' => addslashes($root_path), '<!--{conlite_web}-->' => addslashes($root_http_path)];
injectSQL($db, $_SESSION['dbprefix'], 'data/' . $fullChunk, $failedChunks, $replacements);
if (count($failedChunks) > 0) {
if ((is_countable($failedChunks) ? count($failedChunks) : 0) > 0) {
$fp = fopen('../data/logs/setuplog.txt', 'w');
foreach ($failedChunks as $failedChunk) {
fwrite($fp, sprintf("Setup was unable to execute SQL. MySQL-Error: %s, MySQL-Message: %s, SQL-Statements:\n%s", $failedChunk['errno'], $failedChunk['error'], $failedChunk['sql']));
@ -189,14 +178,14 @@ if ($currentstep < $totalsteps) {
// For import mod_history rows to versioning
if ($_SESSION['setuptype'] == 'migration' || $_SESSION['setuptype'] == 'upgrade') {
$cfgClient = array();
$cfgClient = [];
rereadClients_Setup();
$oVersion = new VersionImport($cfg, $cfgClient, $db, $client, $area, $frame);
$oVersion->CreateHistoryVersion();
}
$tables = array();
$tables = [];
while ($db->next_record()) {
$tables[] = $db->f(0);
@ -240,7 +229,7 @@ if ($currentstep < $totalsteps) {
}
// Update Keys
$aNothing = array();
$aNothing = [];
injectSQL($db, $_SESSION['dbprefix'], 'data/indexes.sql', $aNothing);
@ -259,7 +248,7 @@ if ($currentstep < $totalsteps) {
}
function txtFileToArray($sFile) {
$aFileArray = array();
$aFileArray = [];
if (file_exists($sFile) && is_readable($sFile)) {
$aFileArray = explode("\n", file_get_contents($sFile));
}

View file

@ -28,9 +28,9 @@ if (!defined('CON_FRAMEWORK')) {
define('CON_FRAMEWORK', true);
}
define('CON_SETUP_PATH', str_replace('\\', '/', realpath(dirname(__FILE__))));
define('CON_SETUP_PATH', str_replace('\\', '/', realpath(__DIR__)));
define('CON_FRONTEND_PATH', str_replace('\\', '/', realpath(dirname(__FILE__) . '/../')));
define('CON_FRONTEND_PATH', str_replace('\\', '/', realpath(__DIR__ . '/../')));
include_once('lib/startup.php');
@ -70,7 +70,7 @@ if (is_array($_REQUEST)) {
}
if (getPHPIniSetting('session.use_cookies') == 0) {
if (ini_get('session.use_cookies') == 0) {
$sNotInstallableReason = 'session_use_cookies';
checkAndInclude('steps/notinstallable.php');
}
@ -104,92 +104,35 @@ if (array_key_exists('step', $_REQUEST)) {
$iStep = '';
}
switch ($iStep) {
case 'setuptype':
checkAndInclude('steps/setuptype.php');
break;
case 'setup1':
checkAndInclude('steps/setup/step1.php');
break;
case 'setup2':
checkAndInclude('steps/setup/step2.php');
break;
case 'setup3':
checkAndInclude('steps/setup/step3.php');
break;
case 'setup4':
checkAndInclude('steps/setup/step4.php');
break;
case 'setup5':
checkAndInclude('steps/setup/step5.php');
break;
case 'setup6':
checkAndInclude('steps/setup/step6.php');
break;
case 'setup7':
checkAndInclude('steps/setup/step7.php');
break;
case 'setup8':
checkAndInclude('steps/setup/step8.php');
break;
case 'migration1':
checkAndInclude('steps/migration/step1.php');
break;
case 'migration2':
checkAndInclude('steps/migration/step2.php');
break;
case 'migration3':
checkAndInclude('steps/migration/step3.php');
break;
case 'migration4':
checkAndInclude('steps/migration/step4.php');
break;
case 'migration5':
checkAndInclude('steps/migration/step5.php');
break;
case 'migration6':
checkAndInclude('steps/migration/step6.php');
break;
case 'migration7':
checkAndInclude('steps/migration/step7.php');
break;
case 'migration8':
checkAndInclude('steps/migration/step8.php');
break;
case 'upgrade1':
checkAndInclude('steps/upgrade/step1.php');
break;
case 'upgrade2':
checkAndInclude('steps/upgrade/step2.php');
break;
case 'upgrade3':
checkAndInclude('steps/upgrade/step3.php');
break;
case 'upgrade4':
checkAndInclude('steps/upgrade/step4.php');
break;
case 'upgrade5':
checkAndInclude('steps/upgrade/step5.php');
break;
case 'upgrade6':
checkAndInclude('steps/upgrade/step6.php');
break;
case 'upgrade7':
checkAndInclude('steps/upgrade/step7.php');
break;
case 'domigration':
checkAndInclude('steps/migration/domigration.php');
break;
case 'doupgrade':
checkAndInclude('steps/upgrade/doupgrade.php');
break;
case 'doinstall':
checkAndInclude('steps/setup/doinstall.php');
break;
case 'languagechooser':
default:
checkAndInclude('steps/languagechooser.php');
break;
}
match ($iStep) {
'setuptype' => checkAndInclude('steps/setuptype.php'),
'setup1' => checkAndInclude('steps/setup/step1.php'),
'setup2' => checkAndInclude('steps/setup/step2.php'),
'setup3' => checkAndInclude('steps/setup/step3.php'),
'setup4' => checkAndInclude('steps/setup/step4.php'),
'setup5' => checkAndInclude('steps/setup/step5.php'),
'setup6' => checkAndInclude('steps/setup/step6.php'),
'setup7' => checkAndInclude('steps/setup/step7.php'),
'setup8' => checkAndInclude('steps/setup/step8.php'),
'migration1' => checkAndInclude('steps/migration/step1.php'),
'migration2' => checkAndInclude('steps/migration/step2.php'),
'migration3' => checkAndInclude('steps/migration/step3.php'),
'migration4' => checkAndInclude('steps/migration/step4.php'),
'migration5' => checkAndInclude('steps/migration/step5.php'),
'migration6' => checkAndInclude('steps/migration/step6.php'),
'migration7' => checkAndInclude('steps/migration/step7.php'),
'migration8' => checkAndInclude('steps/migration/step8.php'),
'upgrade1' => checkAndInclude('steps/upgrade/step1.php'),
'upgrade2' => checkAndInclude('steps/upgrade/step2.php'),
'upgrade3' => checkAndInclude('steps/upgrade/step3.php'),
'upgrade4' => checkAndInclude('steps/upgrade/step4.php'),
'upgrade5' => checkAndInclude('steps/upgrade/step5.php'),
'upgrade6' => checkAndInclude('steps/upgrade/step6.php'),
'upgrade7' => checkAndInclude('steps/upgrade/step7.php'),
'domigration' => checkAndInclude('steps/migration/domigration.php'),
'doupgrade' => checkAndInclude('steps/upgrade/doupgrade.php'),
'doinstall' => checkAndInclude('steps/setup/doinstall.php'),
default => checkAndInclude('steps/languagechooser.php'),
};
?>

View file

@ -33,12 +33,12 @@
class cHTMLAlphaImage extends cHTMLImage {
var $_sClickImage;
var $_sMouseoverClickImage;
var $_sMouseoverSrc;
public $_sClickImage;
public $_sMouseoverClickImage;
public $_sMouseoverSrc;
function __construct() {
parent::__construct();
public function __construct()
{
}
function setMouseover ($sMouseoverSrc)
@ -78,7 +78,7 @@ class cHTMLAlphaImage extends cHTMLImage {
}
return parent::toHTML();
return null;
}
}
@ -89,8 +89,7 @@ class cHTMLErrorMessageList extends cHTMLDiv {
*/
public function __construct() {
$this->_oTable = new cHTMLTable();
$this->_oTable->setWidth("100%");
parent::__construct();
$this->_oTable->setWidth("100%");
$this->setClass("errorlist");
$this->setStyle("width: 450px; height: 218px; overflow: auto; border: 1px solid black;");
}
@ -101,7 +100,7 @@ class cHTMLErrorMessageList extends cHTMLDiv {
function toHTML() {
$this->_setContent($this->_oTable->render());
return parent::toHTML();
return null;
}
}
@ -143,7 +142,7 @@ class cHTMLFoldableErrorMessage extends cHTMLTableRow {
$this->_oContent->setVerticalAlignment("top");
$this->_oContent->setClass("entry");
$this->_oContent->setContent(array($this->_oTitle, $this->_oMessage));
$this->_oContent->setContent([$this->_oTitle, $this->_oMessage]);
$this->_oIcon->setClass("icon");
$this->_oIcon->setVerticalAlignment("top");
@ -162,13 +161,11 @@ class cHTMLFoldableErrorMessage extends cHTMLTableRow {
} else {
$this->_oIcon->setContent("&nbsp;");
}
parent::__construct();
}
function toHTML() {
$this->setContent(array($this->_oFolding, $this->_oContent, $this->_oIcon));
return parent::toHTML();
$this->setContent([$this->_oFolding, $this->_oContent, $this->_oIcon]);
return null;
}
}
@ -190,13 +187,11 @@ class cHTMLInfoMessage extends cHTMLTableRow {
$this->_oTitle->setVerticalAlignment("top");
$this->_oMessage->setContent($sMessage);
$this->_oMessage->setClass("entry_nowrap");
parent::__construct();
}
function toHTML() {
$this->setContent(array($this->_oTitle, $this->_oMessage));
return parent::toHTML();
$this->setContent([$this->_oTitle, $this->_oMessage]);
return null;
}
}
@ -209,8 +204,6 @@ class cHTMLLanguageLink extends cHTMLDiv {
* @param int $stepnumber
*/
function __construct($langcode, $langname, $stepnumber) {
parent::__construct();
$linkImage = new cHTMLAlphaImage();
$linkImage->setAlt("");
$linkImage->setSrc("../conlite/images/submit.gif");
@ -249,8 +242,6 @@ class cHTMLButtonLink extends cHTMLDiv {
* @param string $title
*/
function __construct($href, $title) {
parent::__construct();
$linkImage = new cHTMLAlphaImage();
$linkImage->setSrc("../conlite/images/submit.gif");
$linkImage->setMouseover("../conlite/images/submit_hover.gif");

View file

@ -35,18 +35,6 @@ class cSetupMask {
*/
protected $_oStepTemplate;
/**
*
* @var string
*/
protected $_sStepTemplate;
/**
*
* @var int
*/
protected $_iStep;
/**
*
* @var bool
@ -59,12 +47,13 @@ class cSetupMask {
*/
protected $_sHeader;
public function __construct($sStepTemplate, $iStep = false) {
/**
* @param string $sStepTemplate
* @param int $iStep
*/
public function __construct(protected $_sStepTemplate, protected $_iStep = false) {
$this->_oTpl = new Template();
$this->_oStepTemplate = new Template();
$this->_sStepTemplate = $sStepTemplate;
$this->_iStep = $iStep;
}
public function setNavigation($sBackstep, $sNextstep) {
@ -80,20 +69,12 @@ class cSetupMask {
$sSetupType = "";
}
switch ($sSetupType) {
case "setup":
$this->_sHeader = "Setup - " . $sHeader;
break;
case "upgrade":
$this->_sHeader = "Upgrade - " . $sHeader;
break;
case "migration":
$this->_sHeader = "Migration - " . $sHeader;
break;
default:
$this->_sHeader = $sHeader;
break;
}
$this->_sHeader = match ($sSetupType) {
"setup" => "Setup - " . $sHeader,
"upgrade" => "Upgrade - " . $sHeader,
"migration" => "Migration - " . $sHeader,
default => $sHeader,
};
}
public function _createNavigation() {

View file

@ -29,55 +29,55 @@ class Template {
* Needles (static)
* @var array
*/
var $needles = array();
public $needles = [];
/**
* Replacements (static)
* @var array
*/
var $replacements = array();
public $replacements = [];
/**
* Dyn_Needles (dynamic)
* @var array
*/
var $Dyn_needles = array();
public $Dyn_needles = [];
/**
* Dyn_Replacements (dynamic)
* @var array
*/
var $Dyn_replacements = array();
public $Dyn_replacements = [];
/**
* Database instance
* @var object
*/
var $db;
public $db;
/**
* Template cache
* @var array
*/
var $tplcache;
public $tplcache;
/**
* Template name cache
* @var array
*/
var $tplnamecache;
public $tplnamecache;
/**
* Dynamic counter
* @var int
*/
var $dyn_cnt = 0;
public $dyn_cnt = 0;
/**
* Tags array (for dynamic blocks);
* @var array
*/
var $tags = array('static' => '{%s}', 'start' => '<!-- BEGIN:BLOCK -->', 'end' => '<!-- END:BLOCK -->');
public $tags = ['static' => '{%s}', 'start' => '<!-- BEGIN:BLOCK -->', 'end' => '<!-- END:BLOCK -->'];
protected $_sDomain;
protected $_encoding;
@ -87,8 +87,8 @@ class Template {
* @return void
*/
public function __construct($tags = false) {
$this->tplcache = Array();
$this->tplnamecache = Array();
$this->tplcache = [];
$this->tplnamecache = [];
if (is_array($tags)) {
$this->tags = $tags;
@ -160,10 +160,10 @@ class Template {
*/
public function reset() {
$this->dyn_cnt = 0;
$this->needles = array();
$this->replacements = array();
$this->Dyn_needles = array();
$this->Dyn_replacements = array();
$this->needles = [];
$this->replacements = [];
$this->Dyn_needles = [];
$this->Dyn_replacements = [];
}
/**
@ -187,7 +187,7 @@ class Template {
$content = (($note) ? "<!-- Generated by ConLite " . $cfg['version'] . "-->\n" : "") . $content;
$pieces = array();
$pieces = [];
//if content has dynamic blocks
if (preg_match("/^.*" . preg_quote($this->tags['start'], "/") . ".*?" . preg_quote($this->tags['end'], "/") . ".*$/s", $content)) {
@ -246,7 +246,7 @@ class Template {
* @param $functionName string Name of the translation function (e.g. i18n)
*/
public function replacei18n(& $template, $functionName) {
$matches = array();
$matches = [];
//if template contains functionName + parameter store all matches
preg_match_all("/" . preg_quote($functionName, "/") . "\\(([\\\"\\'])(.*?)\\1\\)/s", $template, $matches);

View file

@ -41,7 +41,7 @@ define('C_SETUP_MIN_PHP_VERSION', '7.4.0');
define('C_SETUP_MAX_PHP_VERSION', '8.3.0');
define('C_SETUP_VERSION', '3.0.0');
$sDefLocalPath = dirname(__FILE__).DIRECTORY_SEPARATOR.'defines.local.php';
$sDefLocalPath = __DIR__.DIRECTORY_SEPARATOR.'defines.local.php';
if(file_exists($sDefLocalPath)) {
include_once $sDefLocalPath;
}

View file

@ -48,7 +48,7 @@ function getServerUID ()
return posix_getuid();
}
$sFilename = md5(mt_rand()) . ".txt";
$sFilename = md5(random_int(0, mt_getrandmax())) . ".txt";
if (isWriteable("."))
{
@ -81,7 +81,7 @@ function getServerGID ()
return posix_getgid();
}
$sFilename = md5(mt_rand()) . ".txt";
$sFilename = md5(random_int(0, mt_getrandmax())) . ".txt";
if (isWriteable("."))
{
@ -131,7 +131,7 @@ function cInitializeArrayKey (&$aArray, $sKey, $mDefault = "")
return false;
}
$aArray = array();
$aArray = [];
}
if (!array_key_exists($sKey, $aArray))

View file

@ -101,7 +101,7 @@ function canWriteFile($sFilename) {
#try to find a random filename for write test, which does not exist
while (file_exists($sRandFilenamePath) && $i < 100) {
$sRandFilename = 'con_test' . rand(0, 1000000000) . 'con_test';
$sRandFilename = 'con_test' . random_int(0, 1_000_000_000) . 'con_test';
$sRandFilenamePath = '';
if ($sFilename[strlen($sFilename) - 1] == '/') {
@ -225,7 +225,7 @@ function getFileInfo($sFilename) {
break;
}
$aFileinfo = array();
$aFileinfo = [];
$aFileinfo["info"] = $info;
$aFileinfo["type"] = $type;
$aFileinfo["owner"]["read"] = ($oiFilePermissions & 0x0100) ? true : false;
@ -240,7 +240,7 @@ function getFileInfo($sFilename) {
}
function checkOpenBasedirCompatibility() {
$value = getPHPIniSetting("open_basedir");
$value = ini_get("open_basedir");
if (isWindows()) {
$aBasedirEntries = explode(";", $value);

View file

@ -80,7 +80,7 @@ function isImageMagickAvailable ()
}
}
$output = array();
$output = [];
$retval = "";
@ -91,7 +91,7 @@ function isImageMagickAvailable ()
return false;
}
if (strpos($output[0],"ImageMagick") !== false)
if (str_contains($output[0],"ImageMagick"))
{
$_imagemagickAvailable = true;
return true;

View file

@ -51,46 +51,25 @@ function hasMySQLiExtension() {
}
function doMySQLConnect($host, $username, $password) {
$aOptions = array(
'connection' => array(
'host' => $host,
'user' => $username,
'password' => $password,
),
);
$aOptions = ['connection' => ['host' => $host, 'user' => $username, 'password' => $password]];
$db = new DB_Contenido($aOptions);
//$sFile = '../data/logs/setup_queries.txt';
//file_put_contents($sFile, $db->getServerInfo(), FILE_APPEND);
//chmod($sFile, 0666);
if (empty($db->connect())) {
return array($db, false);
return [$db, false];
} else {
return array($db, true);
return [$db, true];
}
}
function getSetupMySQLDBConnection($full = true) {
if ($full === false) {
// host, user and password
$aOptions = array(
'connection' => array(
'host' => $_SESSION["dbhost"],
'user' => $_SESSION["dbuser"],
'password' => $_SESSION["dbpass"]
),
'sequenceTable' => $_SESSION['dbprefix'] . '_sequence'
);
$aOptions = ['connection' => ['host' => $_SESSION["dbhost"], 'user' => $_SESSION["dbuser"], 'password' => $_SESSION["dbpass"]], 'sequenceTable' => $_SESSION['dbprefix'] . '_sequence'];
} else {
// host, database, user and password
$aOptions = array(
'connection' => array(
'host' => $_SESSION["dbhost"],
'database' => $_SESSION["dbname"],
'user' => $_SESSION["dbuser"],
'password' => $_SESSION["dbpass"]
),
'sequenceTable' => $_SESSION['dbprefix'] . '_sequence'
);
$aOptions = ['connection' => ['host' => $_SESSION["dbhost"], 'database' => $_SESSION["dbname"], 'user' => $_SESSION["dbuser"], 'password' => $_SESSION["dbpass"]], 'sequenceTable' => $_SESSION['dbprefix'] . '_sequence'];
}
//$aOptions['enableProfiling'] = TRUE;
@ -253,7 +232,7 @@ function checkMySQLDropDatabase($db, $database) {
function fetchMySQLStorageEngines($db) {
$db->query("SHOW ENGINES");
$engines = array();
$engines = [];
while ($db->next_record()) {
$engines[] = $db->f(0);

View file

@ -37,118 +37,72 @@ define("E_EXTENSION_AVAILABLE", 1);
define("E_EXTENSION_UNAVAILABLE", 2);
define("E_EXTENSION_CANTCHECK", 3);
/**
* getPHPIniSetting ($setting)
*
* Retrieves the setting $setting from the PHP setup.
* Wrapper to avoid warnings if ini_get is in the
* disable_functions directive.
*/
function getPHPIniSetting($setting) {
/* Avoid errors if ini_get is in the disable_functions directive */
$value = @ini_get($setting);
return $value;
}
/**
* canPHPurlfopen: Checks if PHP is able to use
* allow_url_fopen.
*/
function canPHPurlfopen() {
return getPHPIniSetting("allow_url_fopen");
function canPHPurlfopen(): bool|string
{
return ini_get("allow_url_fopen");
}
/**
* checkPHPiniget: Checks if the ini_get function
* is available and not disabled. Returns true if the
* function is available.
*
* Uses the PHP configuration value y2k_compilance which
* is available in all PHP4 versions.
*/
function checkPHPiniget() {
$value = @ini_get("y2k_compliance");
if ($value === NULL) {
return false;
} else {
return true;
}
function getPHPDisplayErrorSetting(): bool|string
{
return ini_get("display_errors");
}
function getPHPDisplayErrorSetting() {
return getPHPIniSetting("display_errors");
function getPHPFileUploadSetting(): bool|string
{
return ini_get("file_uploads");
}
function getPHPFileUploadSetting() {
return getPHPIniSetting("file_uploads");
function getPHPGPCOrder(): bool|string
{
return ini_get("gpc_order");
}
function getPHPGPCOrder() {
return getPHPIniSetting("gpc_order");
function getPHPMagicQuotesRuntime(): bool|string
{
return ini_get("magic_quotes_runtime");
}
function getPHPMagicQuotesGPC() {
return getPHPIniSetting("magic_quotes_gpc");
function getPHPMagicQuotesSybase(): bool|string
{
return ini_get("magic_quotes_sybase");
}
function getPHPMagicQuotesRuntime() {
return getPHPIniSetting("magic_quotes_runtime");
function getPHPMaxExecutionTime(): bool|string
{
return ini_get("max_execution_time");
}
function getPHPMagicQuotesSybase() {
return getPHPIniSetting("magic_quotes_sybase");
function getPHPOpenBasedirSetting(): bool|string
{
return ini_get("open_basedir");
}
function getPHPMaxExecutionTime() {
return getPHPIniSetting("max_execution_time");
function checkPHPSQLSafeMode(): bool|string
{
return ini_get("sql.safe_mode");
}
function getPHPOpenBasedirSetting() {
return getPHPIniSetting("open_basedir");
}
function getPHPMaxPostSize() {
return getPHPIniSetting("post_max_size");
}
function checkPHPSQLSafeMode() {
return getPHPIniSetting("sql.safe_mode");
}
function checkPHPUploadMaxFilesize() {
return getPHPIniSetting("upload_max_filesize");
}
function return_bytes($val) {
function return_bytes($val): float|int|string
{
if (strlen($val) == 0) {
return 0;
}
$val = trim($val);
$last = $val[strlen($val) - 1];
switch ($last) {
case 'k':
case 'K':
return (int) $val * 1024;
break;
case 'm':
case 'M':
return (int) $val * 1048576;
break;
default:
return $val;
}
return match ($last) {
'k', 'K' => (int) $val * 1024,
'm', 'M' => (int) $val * 1_048_576,
default => $val,
};
}
function isPHPExtensionLoaded($extension) {
$value = extension_loaded($extension);
if ($value === NULL) {
return E_EXTENSION_CANTCHECK;
}
if ($value === true) {
return E_EXTENSION_AVAILABLE;
}
@ -156,16 +110,10 @@ function isPHPExtensionLoaded($extension) {
if ($value === false) {
return E_EXTENSION_UNAVAILABLE;
}
}
function isRegisterLongArraysActive() {
if (version_compare(phpversion(), "5.0.0", ">=") == true) {
if (getPHPIniSetting("register_long_arrays") == false) {
return false;
}
if ($value === NULL) {
return E_EXTENSION_CANTCHECK;
}
return true;
}
/**
@ -174,12 +122,7 @@ function isRegisterLongArraysActive() {
* @param string $sVersion phpversion to test
* @return boolean
*/
function isPHPCompatible($sVersion = "5.2.0") {
if (version_compare(phpversion(), $sVersion, ">=") == true) {
return true;
} else {
return false;
}
}
?>
function isPHPCompatible($sVersion = "8.0.0"): bool
{
return version_compare(phpversion(), $sVersion, ">=");
}

View file

@ -34,7 +34,7 @@
function getSafeModeStatus ()
{
if (getPHPIniSetting("safe_mode") == "1")
if (ini_get("safe_mode") == "1")
{
return true;
} else {
@ -44,7 +44,7 @@ function getSafeModeStatus ()
function getSafeModeGidStatus ()
{
if (getPHPIniSetting("safe_mode_gid") == "1")
if (ini_get("safe_mode_gid") == "1")
{
return true;
} else {
@ -54,16 +54,16 @@ function getSafeModeGidStatus ()
function getSafeModeIncludeDir ()
{
return getPHPIniSetting("safe_mode_include_dir");
return ini_get("safe_mode_include_dir");
}
function getOpenBasedir ()
{
return getPHPIniSetting("open_basedir");
return ini_get("open_basedir");
}
function getDisabledFunctions ()
{
return getPHPIniSetting("disable_functions");
return ini_get("disable_functions");
}
?>

View file

@ -32,7 +32,7 @@ if (!defined('CON_FRAMEWORK')) {
die('Illegal call');
}
function injectSQL(&$db, $prefix, $file, &$failedChunks, $replacements = array()) {
function injectSQL(&$db, $prefix, $file, &$failedChunks, $replacements = []) {
$file = trim($file);
if (!isReadable($file)) {
@ -56,7 +56,7 @@ function injectSQL(&$db, $prefix, $file, &$failedChunks, $replacements = array()
$db->query($sqlChunk);
if ($db->Errno != 0) {
$failedChunks[] = array("sql" => $sqlChunk, "errno" => $db->Errno, "error" => $db->Error);
$failedChunks[] = ["sql" => $sqlChunk, "errno" => $db->Errno, "error" => $db->Error];
}
}
@ -130,10 +130,10 @@ function split_sql_file($sql, $delimiter) {
// try to save mem.
$sql = "";
$output = array();
$output = [];
// we don't actually care about the matches preg gives us.
$matches = array();
$matches = [];
// this is faster than calling count($oktens) every time thru the loop.
$token_count = count($tokens);

View file

@ -48,27 +48,13 @@ function checkExistingPlugin($db, $sPluginname) {
$sTable = $_SESSION["dbprefix"] . "_nav_sub";
$sSql = "";
switch ($sPluginname) {
case 'plugin_conman':
$sSql = "SELECT * FROM %s WHERE idnavs='900'";
break;
case 'plugin_content_allocation':
$sSql = "SELECT * FROM %s WHERE idnavs='800'";
break;
case 'plugin_newsletter':
$sSql = "SELECT * FROM %s WHERE idnavs='610'";
break;
case 'mod_rewrite':
$sSql = "SELECT * FROM %s WHERE idnavs='700' OR location='mod_rewrite/xml/;navigation/content/mod_rewrite'";
break;
default:
$sSql = "";
break;
}
$sSql = match ($sPluginname) {
'plugin_conman' => "SELECT * FROM %s WHERE idnavs='900'",
'plugin_content_allocation' => "SELECT * FROM %s WHERE idnavs='800'",
'plugin_newsletter' => "SELECT * FROM %s WHERE idnavs='610'",
'mod_rewrite' => "SELECT * FROM %s WHERE idnavs='700' OR location='mod_rewrite/xml/;navigation/content/mod_rewrite'",
default => "",
};
if ($sSql) {
$db->query(sprintf($sSql, $sTable));
@ -86,21 +72,7 @@ function checkExistingPlugin($db, $sPluginname) {
* @param string $table db-table name
*/
function updateSystemProperties($db, $table) {
$aStandardvalues = array(array('type' => 'pw_request', 'name' => 'enable', 'value' => 'true'),
array('type' => 'system', 'name' => 'mail_sender_name', 'value' => 'noreply%40conlite.org'),
array('type' => 'system', 'name' => 'mail_sender', 'value' => 'ConLite+Backend'),
array('type' => 'system', 'name' => 'mail_host', 'value' => 'localhost'),
array('type' => 'maintenance', 'name' => 'mode', 'value' => 'disabled'),
array('type' => 'edit_area', 'name' => 'activated', 'value' => 'true'),
array('type' => 'update', 'name' => 'check', 'value' => 'false'),
array('type' => 'update', 'name' => 'news_feed', 'value' => 'false'),
array('type' => 'update', 'name' => 'check_period', 'value' => '60'),
array('type' => 'system', 'name' => 'clickmenu', 'value' => 'false'),
array('type' => 'versioning', 'name' => 'activated', 'value' => 'true'),
array('type' => 'versioning', 'name' => 'prune_limit', 'value' => '0'),
array('type' => 'versioning', 'name' => 'path', 'value' => ''),
array('type' => 'system', 'name' => 'insight_editing_activated', 'value' => 'true')
);
$aStandardvalues = [['type' => 'pw_request', 'name' => 'enable', 'value' => 'true'], ['type' => 'system', 'name' => 'mail_sender_name', 'value' => 'noreply%40conlite.org'], ['type' => 'system', 'name' => 'mail_sender', 'value' => 'ConLite+Backend'], ['type' => 'system', 'name' => 'mail_host', 'value' => 'localhost'], ['type' => 'maintenance', 'name' => 'mode', 'value' => 'disabled'], ['type' => 'edit_area', 'name' => 'activated', 'value' => 'true'], ['type' => 'update', 'name' => 'check', 'value' => 'false'], ['type' => 'update', 'name' => 'news_feed', 'value' => 'false'], ['type' => 'update', 'name' => 'check_period', 'value' => '60'], ['type' => 'system', 'name' => 'clickmenu', 'value' => 'false'], ['type' => 'versioning', 'name' => 'activated', 'value' => 'true'], ['type' => 'versioning', 'name' => 'prune_limit', 'value' => '0'], ['type' => 'versioning', 'name' => 'path', 'value' => ''], ['type' => 'system', 'name' => 'insight_editing_activated', 'value' => 'true']];
foreach ($aStandardvalues as $aData) {
$sql = "SELECT value FROM %s WHERE type='" . $aData['type'] . "' AND name='" . $aData['name'] . "'";
@ -163,10 +135,10 @@ function listClients($db, $table) {
$db->query(sprintf($sql, Contenido_Security::escapeDB($table, $db)));
$clients = array();
$clients = [];
while ($db->next_record()) {
$clients[$db->f("idclient")] = array("name" => $db->f("name"), "frontendpath" => $db->f("frontendpath"), "htmlpath" => $db->f("htmlpath"));
$clients[$db->f("idclient")] = ["name" => $db->f("name"), "frontendpath" => $db->f("frontendpath"), "htmlpath" => $db->f("htmlpath")];
}
return $clients;
@ -192,8 +164,8 @@ function getSystemDirectories($bOriginalPath = false) {
$root_path = str_replace("\\", "/", $root_path);
$root_path = dirname(dirname(dirname($root_path)));
$root_http_path = dirname(dirname($_SERVER["PHP_SELF"]));
$root_path = dirname($root_path, 3);
$root_http_path = dirname($_SERVER["PHP_SELF"], 2);
$root_path = str_replace("\\", "/", $root_path);
$root_http_path = str_replace("\\", "/", $root_http_path);
@ -216,7 +188,7 @@ function getSystemDirectories($bOriginalPath = false) {
}
if ($bOriginalPath == true) {
return array($root_path, $root_http_path);
return [$root_path, $root_http_path];
}
if (isset($_SESSION["override_root_path"])) {
@ -230,7 +202,7 @@ function getSystemDirectories($bOriginalPath = false) {
$root_path = stripLastSlash($root_path);
$root_http_path = stripLastSlash($root_http_path);
return array($root_path, $root_http_path);
return [$root_path, $root_http_path];
}
function findSimilarText($string1, $string2) {

View file

@ -33,13 +33,13 @@ if (!defined('CON_FRAMEWORK')) {
define('CON_FRAMEWORK', true);
}
define('CON_SETUP_PATH', str_replace('\\', '/', realpath(dirname(__FILE__))));
define('CON_SETUP_PATH', str_replace('\\', '/', realpath(__DIR__)));
define('CON_FRONTEND_PATH', str_replace('\\', '/', realpath(dirname(__FILE__) . '/../')));
define('CON_FRONTEND_PATH', str_replace('\\', '/', realpath(__DIR__ . '/../')));
include_once('lib/startup.php');
list($root_path, $root_http_path) = getSystemDirectories();
[$root_path, $root_http_path] = getSystemDirectories();
$tpl = new Template();
$tpl->set('s', 'CONTENIDO_ROOT', $root_path);
@ -94,7 +94,7 @@ if ($_SESSION['configmode'] == 'save') {
}
} else {
header('Content-Type: application/octet-stream');
header('Etag: ' . md5(mt_rand()));
header('Etag: ' . md5(random_int(0, mt_getrandmax())));
header('Content-Disposition: attachment;filename=config.php');
$tpl->generate('templates/config.php.tpl', false, false);
}

View file

@ -57,7 +57,7 @@ class cSetupAdditionalPlugins extends cSetupMask {
$this->_oStepTemplate->set("s", "DESCRIPTION", i18n_setup("Please select Plugins to be installed"));
// add new plugins to this array and you're done.
$aPlugins = array();
$aPlugins = [];
//$aPlugins['plugin_newsletter'] = array('label' => i18n_setup('Newsletter'), 'desc' => i18n_setup('Newsletterfunctionality for dispatching text newsletters and HTML-Newsletters, extensible with professional newsletter extensions. Definition of newsletter recipients and groups of recipients. Layout design of the HTML-Newsletters by ConLite articles.'));
//$aPlugins['plugin_content_allocation'] = array('label' => i18n_setup('Content Allocation'), 'desc' => i18n_setup('For the representation and administration of content, 4fb developed the Content Allocation and content include technology. This technology dynamically allows on basis of a Template, to put the content in different places and in different formats according to several criteria.'));
//$aPlugins['plugin_mod_rewrite'] = array('label' => i18n_setup('Mod Rewrite'), 'desc' => i18n_setup('Creates so called Clean URLs for a ConLite installation'));

View file

@ -50,11 +50,11 @@ class cSetupClientAdjust extends cSetupMask {
$cHTMLErrorMessageList = new cHTMLErrorMessageList;
$cHTMLErrorMessageList->setStyle("width: 580px; height: 200px; overflow: auto; border: 1px solid black;");
$cHTMLFoldableErrorMessages = array();
$cHTMLFoldableErrorMessages = [];
$aPathList = array();
$aPathList = [];
list($a_root_path, $a_root_http_path) = getSystemDirectories();
[$a_root_path, $a_root_http_path] = getSystemDirectories();
@include($a_root_path . "data/config/" . CL_ENVIRONMENT . "/config.php");
@ -91,7 +91,7 @@ class cSetupClientAdjust extends cSetupMask {
$oSystemPathBox = new cHTMLTextbox("frontendpath[$iIdClient]", $_SESSION["frontendpath"][$iIdClient]);
$oSystemPathBox->setWidth(100);
$oSystemPathBox->setClass("small");
$oClientSystemPath = new cHTMLInfoMessage(array($sName, $oSystemPathBox), "&nbsp;");
$oClientSystemPath = new cHTMLInfoMessage([$sName, $oSystemPathBox], "&nbsp;");
$oClientSystemPath->_oTitle->setStyle("padding-left: 8px; padding-bottom: 8px");
$aPathList[] = $oClientSystemPath;
@ -103,7 +103,7 @@ class cSetupClientAdjust extends cSetupMask {
$oSystemPathBox = new cHTMLTextbox("htmlpath[$iIdClient]", $_SESSION["htmlpath"][$iIdClient]);
$oSystemPathBox->setWidth(100);
$oSystemPathBox->setClass("small");
$oClientSystemPath = new cHTMLInfoMessage(array($sName, $oSystemPathBox), "&nbsp;");
$oClientSystemPath = new cHTMLInfoMessage([$sName, $oSystemPathBox], "&nbsp;");
$oClientSystemPath->_oTitle->setStyle("padding-left: 8px; padding-bottom: 8px");

View file

@ -41,7 +41,7 @@ class cSetupClientMode extends cSetupMask {
cInitializeArrayKey($_SESSION, "clientmode", "");
$aChoices = array();
$aChoices = [];
$aChoices["CLIENTEXAMPLES"] = "none"; //i18n_setup("Client with example modules and example content");
$aChoices["CLIENTMODULES"] = "none"; //i18n_setup("Client with example modules, but without example content");

View file

@ -39,13 +39,13 @@ class cSetupPath extends cSetupMask {
$this->_oStepTemplate->set("s", "TITLE", i18n_setup("System Directories"));
$this->_oStepTemplate->set("s", "DESCRIPTION", i18n_setup("Please check the directories identified by the system. If you need to change a path, click on the name and enter the new path in the available input box."));
list($root_path, $root_http_path) = getSystemDirectories(true);
[$root_path, $root_http_path] = getSystemDirectories(true);
$cHTMLErrorMessageList = new cHTMLErrorMessageList;
$cHTMLErrorMessageList->setStyle("width: 580px; height: 200px; overflow: auto; border: 1px solid black;");
$cHTMLFoldableErrorMessages = array();
$cHTMLFoldableErrorMessages = [];
list($a_root_path, $a_root_http_path) = getSystemDirectories();
[$a_root_path, $a_root_http_path] = getSystemDirectories();
$oRootPath = new cHTMLTextbox("override_root_path", $a_root_path);
$oRootPath->setWidth(100);
$oRootPath->setClass("small");

View file

@ -37,7 +37,7 @@ class cSetupResults extends cSetupMask {
$this->_oStepTemplate->set("s", "FINISHTEXT", i18n_setup("You can now start using ConLite. Please delete the folder named 'setup'!"));
list($root_path, $root_http_path) = getSystemDirectories();
[$root_path, $root_http_path] = getSystemDirectories();
@ -64,7 +64,7 @@ class cSetupResults extends cSetupMask {
list($sRootPath, $rootWebPath) = getSystemDirectories();
[$sRootPath, $rootWebPath] = getSystemDirectories();
if (file_exists($sRootPath . "/data/logs/setuplog.txt")) {
$sErrorLink = '<a target="_blank" href="../data/logs/setuplog.txt">setuplog.txt</a>';

View file

@ -64,27 +64,21 @@ class cSetupSetupSummary extends cSetupMask {
break;
}
$messages = array(
i18n_setup("Installation type") . ":" => $sType,
i18n_setup("Database parameters") . ":" => i18n_setup("Database host") . ": " . $_SESSION["dbhost"] . "<br>" . i18n_setup("Database name") . ": " . $_SESSION["dbname"] . "<br>" . i18n_setup("Database username") . ": " . $_SESSION["dbuser"] . "<br>" . i18n_setup("Database prefix") . ": " . $_SESSION["dbprefix"],
);
$messages = [i18n_setup("Installation type") . ":" => $sType, i18n_setup("Database parameters") . ":" => i18n_setup("Database host") . ": " . $_SESSION["dbhost"] . "<br>" . i18n_setup("Database name") . ": " . $_SESSION["dbname"] . "<br>" . i18n_setup("Database username") . ": " . $_SESSION["dbuser"] . "<br>" . i18n_setup("Database prefix") . ": " . $_SESSION["dbprefix"]];
if ($_SESSION["setuptype"] == "setup") {
$aChoices = array("CLIENTEXAMPLES" => i18n_setup("Client with example modules and example content"),
"CLIENTMODULES" => i18n_setup("Client with example modules but without example content"),
"CLIENT" => i18n_setup("Client without examples"),
"NOCLIENT" => i18n_setup("Don't create a client"));
$aChoices = ["CLIENTEXAMPLES" => i18n_setup("Client with example modules and example content"), "CLIENTMODULES" => i18n_setup("Client with example modules but without example content"), "CLIENT" => i18n_setup("Client without examples"), "NOCLIENT" => i18n_setup("Don't create a client")];
$messages[i18n_setup("Client installation") . ":"] = $aChoices[$_SESSION["clientmode"]];
}
// additional plugins
$aPlugins = $this->_getSelectedAdditionalPlugins();
if (count($aPlugins) > 0) {
if ((is_countable($aPlugins) ? count($aPlugins) : 0) > 0) {
$messages[i18n_setup("Additional Plugins") . ":"] = implode('<br>', $aPlugins);
;
}
$cHTMLFoldableErrorMessages = array();
$cHTMLFoldableErrorMessages = [];
foreach ($messages as $key => $message) {
$cHTMLFoldableErrorMessages[] = new cHTMLInfoMessage($key, $message);
@ -98,7 +92,7 @@ class cSetupSetupSummary extends cSetupMask {
}
public function _getSelectedAdditionalPlugins() {
$aPlugins = array();
$aPlugins = [];
if (isset($_SESSION['plugin_newsletter']) && $_SESSION['plugin_newsletter'] == 'true') {
$aPlugins[] = i18n_setup('Newsletter');
}

View file

@ -36,7 +36,7 @@ class cSetupSystemData extends cSetupMask {
public function __construct($step, $previous, $next) {
parent::__construct("templates/setup/forms/systemdata.tpl", $step);
list($a_root_path, $a_root_http_path) = getSystemDirectories();
[$a_root_path, $a_root_http_path] = getSystemDirectories();
cInitializeArrayKey($_SESSION, "dbprefix", "");
cInitializeArrayKey($_SESSION, "dbhost", "");
@ -58,11 +58,7 @@ class cSetupSystemData extends cSetupMask {
@include($a_root_path . "/data/config/" . CL_ENVIRONMENT . "/config.php");
}
$aVars = array("dbhost" => $contenido_host,
"dbuser" => $contenido_user,
"dbname" => $contenido_database,
"dbpass" => $contenido_password,
"dbprefix" => $cfg["sql"]["sqlprefix"]);
$aVars = ["dbhost" => $contenido_host, "dbuser" => $contenido_user, "dbname" => $contenido_database, "dbpass" => $contenido_password, "dbprefix" => $cfg["sql"]["sqlprefix"]];
foreach ($aVars as $aVar => $sValue) {
if ($_SESSION[$aVar] == "") {