From 586188c2ccb9f57afeee91e974e4a95efdb2c96a Mon Sep 17 00:00:00 2001 From: "o.pinke" Date: Tue, 12 Jan 2021 19:46:45 +0100 Subject: [PATCH] fix php 8.0 errors in backend --- conlite/includes/functions.database.php | 4 +++- conlite/includes/functions.general.php | 13 ++++++++----- conlite/includes/include.con_str_overview.php | 2 +- setup/dbupdate.php | 5 ++++- setup/lib/functions.sql.php | 2 +- setup/steps/forms/setupsummary.php | 6 +++--- 6 files changed, 20 insertions(+), 12 deletions(-) diff --git a/conlite/includes/functions.database.php b/conlite/includes/functions.database.php index eb89886..4e546f4 100644 --- a/conlite/includes/functions.database.php +++ b/conlite/includes/functions.database.php @@ -133,6 +133,8 @@ function dbUpgradeTable($db, $table, $field, $type, $null, $key, $default, $extr } else { $parameter['DEFAULT'] = "DEFAULT '" . Contenido_Security::escapeDB($default, $db) . "'"; } + } else { + $parameter['DEFAULT'] = ''; } if (!dbTableExists($db, $table)) { @@ -145,7 +147,7 @@ function dbUpgradeTable($db, $table, $field, $type, $null, $key, $default, $extr // Remove auto_increment $structure = dbGetColumns($db, $table); - if ($structure[$field]["Extra"] == "auto_increment") { + if (isset($structure[$field]) && !empty($structure[$field]["Extra"]) && $structure[$field]["Extra"] == "auto_increment") { if ($structure[$field]['NULL'] == "") { $structure[$field]['NULL'] = "NOT NULL"; } diff --git a/conlite/includes/functions.general.php b/conlite/includes/functions.general.php index b1ca9a1..c4255ab 100644 --- a/conlite/includes/functions.general.php +++ b/conlite/includes/functions.general.php @@ -396,6 +396,7 @@ function getLanguagesByClient($client) { function getLanguageNamesByClient($client) { global $db; global $cfg; + $list = []; $sql = "SELECT a.idlang AS idlang, @@ -1238,7 +1239,7 @@ function buildCategorySelect($sName, $sValue, $sLevel = 0, $sStyle = "") { foreach ($categories as $tmpidcat => $props) { $spaces = "  "; - for ($i = 0; $i < $props["level"]; $i ++) { + for ($i = 0; $i < $props["level"]; $i++) { $spaces .= "     "; } @@ -1282,7 +1283,7 @@ function human_readable_size($number) { $n = (float) $number; //Appears to be necessary to avoid rounding while ($n >= $base) { $n /= (float) $base; - $usesuf ++; + $usesuf++; } $places = 2 - floor(log10($n)); @@ -1315,7 +1316,7 @@ function array_csort() { //coded by Ichier2003 $msortline = "return(array_multisort("; $i = 0; foreach ($args as $arg) { - $i ++; + $i++; if (is_string($arg)) { foreach ($marray as $row) { $a = strtoupper($row[$arg]); @@ -1327,7 +1328,9 @@ function array_csort() { //coded by Ichier2003 $msortline .= "\$sortarr[" . $i . "],"; } $msortline .= "\$marray));"; - @ eval($msortline); + if(is_array($marray) && count($marray) > 0) { + @ eval($msortline); + } return $marray; } @@ -1689,7 +1692,7 @@ function createRandomName($nameLength) { $Vouel = 'aeiou'; $Name = ""; - for ($index = 1; $index <= $nameLength; $index ++) { + for ($index = 1; $index <= $nameLength; $index++) { if ($index % 3 == 0) { $randomNumber = rand(1, strlen($Vouel)); $Name .= substr($Vouel, $randomNumber - 1, 1); diff --git a/conlite/includes/include.con_str_overview.php b/conlite/includes/include.con_str_overview.php index bdd598b..f66b416 100644 --- a/conlite/includes/include.con_str_overview.php +++ b/conlite/includes/include.con_str_overview.php @@ -754,7 +754,7 @@ if (isset($bDebug) && $bDebug === true) { var_dump($navigationTree); echo ''; } -if (count($navigationTree[0])) { +if (is_array($navigationTree[0]) && count($navigationTree[0])) { $sCategories = showTree(0, $aWholelist); } diff --git a/setup/dbupdate.php b/setup/dbupdate.php index 6ced99f..4a2a0b3 100644 --- a/setup/dbupdate.php +++ b/setup/dbupdate.php @@ -57,6 +57,9 @@ $currentstep = (empty($_GET['step'])) ? 1 : filter_input(INPUT_GET, "step", FILT // Count DB Chunks $file = fopen('data/tables.txt', 'r'); $step = 1; +$count = 1; +$fullcount = 1; + while (($data = fgetcsv($file, 4000, ';')) !== false) { if ($count == 50) { $count = 1; @@ -71,7 +74,7 @@ while (($data = fgetcsv($file, 4000, ';')) !== false) { } dbUpgradeTable($db, $_SESSION['dbprefix'] . '_' . $data[0], $data[1], $data[2], $data[3], $data[4], $data[5], $data[6], '', $drop); - if ($db->errno != 0) { + if ($db->getErrorNumber() != 0) { $_SESSION['install_failedupgradetable'] = true; } } diff --git a/setup/lib/functions.sql.php b/setup/lib/functions.sql.php index db32373..4d22595 100644 --- a/setup/lib/functions.sql.php +++ b/setup/lib/functions.sql.php @@ -107,7 +107,7 @@ function remove_remarks($sql) { for ($i = 0; $i < $linecount; $i++) { if (($i != ($linecount - 1)) || (strlen($lines[$i]) > 0)) { - if ($lines[$i][0] != "#") { + if (!empty($lines[$i][0]) && $lines[$i][0] != "#") { $output .= $lines[$i] . "\n"; } else { $output .= "\n"; diff --git a/setup/steps/forms/setupsummary.php b/setup/steps/forms/setupsummary.php index 33fda78..41f25f1 100644 --- a/setup/steps/forms/setupsummary.php +++ b/setup/steps/forms/setupsummary.php @@ -97,13 +97,13 @@ class cSetupSetupSummary extends cSetupMask { public function _getSelectedAdditionalPlugins() { $aPlugins = array(); - if ($_SESSION['plugin_newsletter'] == 'true') { + if (isset($_SESSION['plugin_newsletter']) && $_SESSION['plugin_newsletter'] == 'true') { $aPlugins[] = i18n_setup('Newsletter'); } - if ($_SESSION['plugin_content_allocation'] == 'true') { + if (isset($_SESSION['plugin_content_allocation']) && $_SESSION['plugin_content_allocation'] == 'true') { $aPlugins[] = i18n_setup('Content Allocation'); } - if ($_SESSION['plugin_mod_rewrite'] == 'true') { + if (isset($_SESSION['plugin_mod_rewrite']) && $_SESSION['plugin_mod_rewrite'] == 'true') { $aPlugins[] = i18n_setup('Mod Rewrite'); } return $aPlugins;