From b3f4d9ee276bf24afa44352ba51444c874310b22 Mon Sep 17 00:00:00 2001 From: "o.pinke" Date: Mon, 11 Jan 2021 19:41:20 +0100 Subject: [PATCH] fix php8.0 errors and issue #10 --- setup/dbupdate.php | 4 ++-- setup/lib/class.template.php | 3 ++- setup/lib/defines.php | 12 +++++++++--- setup/lib/functions.mysql.php | 2 +- setup/lib/functions.sql.php | 2 +- setup/lib/startup.php | 30 +++++++++++++----------------- 6 files changed, 28 insertions(+), 25 deletions(-) diff --git a/setup/dbupdate.php b/setup/dbupdate.php index 91ba4e0..6ced99f 100644 --- a/setup/dbupdate.php +++ b/setup/dbupdate.php @@ -159,7 +159,7 @@ foreach ($fullChunks as $fullChunk) { '' => addslashes($root_http_path) ); - injectSQL($db, $_SESSION['dbprefix'], 'data/' . $fullChunk, $replacements, $failedChunks); + injectSQL($db, $_SESSION['dbprefix'], 'data/' . $fullChunk, $failedChunks, $replacements); if (count($failedChunks) > 0) { $fp = fopen('../data/logs/setuplog.txt', 'w'); @@ -239,7 +239,7 @@ if ($currentstep < $totalsteps) { // Update Keys $aNothing = array(); - injectSQL($db, $_SESSION['dbprefix'], 'data/indexes.sql', array(), $aNothing); + injectSQL($db, $_SESSION['dbprefix'], 'data/indexes.sql', $aNothing); // logging query stuff $aSqlArray = $db->getProfileData(); diff --git a/setup/lib/class.template.php b/setup/lib/class.template.php index 0e9ea5c..8e587d1 100644 --- a/setup/lib/class.template.php +++ b/setup/lib/class.template.php @@ -121,7 +121,8 @@ class Template { * * @return void */ - public function set($which = 's', $needle, $replacement) { + public function set($which, $needle, $replacement) { + $which = empty($which)?'s':$which; if ($which == 's') { // static $this->needles[] = sprintf($this->tags['static'], $needle); $this->replacements[] = $replacement; diff --git a/setup/lib/defines.php b/setup/lib/defines.php index d99880a..affd3eb 100644 --- a/setup/lib/defines.php +++ b/setup/lib/defines.php @@ -5,8 +5,14 @@ * * @package ConLite * @subpackage Setup - * @license https://www.gnu.de/documents/gpl-3.0.de.html GNU General Public License (GPL) + * @version 1.0.0 + * @author Ortwin Pinke + * @author Murat Purc + * @copyright (c) 2020, ConLite.org + * @license https://www.gnu.org/licenses/gpl-3.0.de.html GNU General Public License 3 * @link https://conlite.org ConLite Portal + * @since file available since contenido release <= 4.8.15 + * */ if (!defined('CON_FRAMEWORK')) { @@ -32,5 +38,5 @@ define('C_SETUP_STEPFILE_ACTIVE', 'images/steps/s%da.png'); define('C_SETUP_STEPWIDTH', 28); define('C_SETUP_STEPHEIGHT', 28); define('C_SETUP_MIN_PHP_VERSION', '7.2'); -define('C_SETUP_MAX_PHP_VERSION', '7.4'); -define('C_SETUP_VERSION', '2.2.0'); +define('C_SETUP_MAX_PHP_VERSION', '8.1'); +define('C_SETUP_VERSION', '2.2.0'); \ No newline at end of file diff --git a/setup/lib/functions.mysql.php b/setup/lib/functions.mysql.php index 46c1440..2ffd7ed 100644 --- a/setup/lib/functions.mysql.php +++ b/setup/lib/functions.mysql.php @@ -139,7 +139,7 @@ function checkMySQLDatabaseExists($db, $database) { $db->connect(); if (hasMySQLiExtension() && !hasMySQLExtension()) { - if (@mysqli_select_db($database, $db->Link_ID)) { + if (mysqli_select_db($db->Link_ID,$database)) { return true; } else { $db->query("SHOW DATABASES LIKE '$database'"); diff --git a/setup/lib/functions.sql.php b/setup/lib/functions.sql.php index 1c79847..db32373 100644 --- a/setup/lib/functions.sql.php +++ b/setup/lib/functions.sql.php @@ -32,7 +32,7 @@ if (!defined('CON_FRAMEWORK')) { die('Illegal call'); } -function injectSQL(&$db, $prefix, $file, $replacements = array(), &$failedChunks) { +function injectSQL(&$db, $prefix, $file, &$failedChunks, $replacements = array()) { $file = trim($file); if (!isReadable($file)) { diff --git a/setup/lib/startup.php b/setup/lib/startup.php index f46891d..3bb96bd 100644 --- a/setup/lib/startup.php +++ b/setup/lib/startup.php @@ -1,24 +1,28 @@ + * @author Murat Purc + * @copyright (c) 2020, ConLite.org + * @license https://www.gnu.org/licenses/gpl-3.0.de.html GNU General Public License 3 * @link https://conlite.org ConLite Portal + * @since file available since contenido release <= 4.8.15 + * */ if (!defined('CON_FRAMEWORK')) { die('Illegal call'); } define('CON_BE_PATH', '../conlite/'); -require_once 'defines.php'; -require_once dirname(__FILE__).'/defines.php'; +session_start(); + +require_once 'lib/defines.php'; // uncomment this lines during development if needed error_reporting(E_ALL ^ E_NOTICE); @@ -29,16 +33,11 @@ ini_set("error_log", "../data/logs/setup_errorlog.txt"); header('Content-Type: text/html; charset=UTF-8'); // Check php version -if (version_compare(PHP_VERSION, C_SETUP_MIN_PHP_VERSION, '<')) { +if (version_compare(PHP_VERSION, C_SETUP_MIN_PHP_VERSION, '<') + || version_compare(PHP_VERSION, C_SETUP_MAX_PHP_VERSION, '>')) { die("You need PHP >= " . C_SETUP_MIN_PHP_VERSION . " to install ConLite " . C_SETUP_VERSION . ". Sorry, even the setup doesn't work otherwise. Your version: " . PHP_VERSION . "\n"); } -$iVersionMax = substr(C_SETUP_MAX_PHP_VERSION, 0, strrpos(C_SETUP_MAX_PHP_VERSION, ".") + 1) . (1 + substr(C_SETUP_MAX_PHP_VERSION, strrpos(C_SETUP_MAX_PHP_VERSION, ".") + 1)); - -if (!(version_compare($iVersionMax, PHP_VERSION, ">") && version_compare(C_SETUP_MAX_PHP_VERSION, PHP_VERSION, "<="))) { - die("You need PHP >= " . C_SETUP_MIN_PHP_VERSION . " and <= " . C_SETUP_MAX_PHP_VERSION . " to install ConLite " . C_SETUP_VERSION . ". Sorry, even the setup doesn't work otherwise. Your version: " . PHP_VERSION . "\n"); -} - /* * Do not edit this value! @@ -99,10 +98,7 @@ if(!is_dir($cfg['path']['conlite_config'])) { // native gettext() behavior. $cfg['native_i18n'] = false; -session_start(); - // includes -checkAndInclude('lib/defines.php'); checkAndInclude($cfg['path']['frontend'] . '/pear/HTML/Common2.php'); checkAndInclude($cfg['path']['conlite'] . 'classes/cHTML5/class.chtml.php'); checkAndInclude($cfg['path']['conlite'] . 'classes/class.htmlelements.php');