From 4a0be40f928c4ecc7c0bcfe9db56a3ca7f70955b Mon Sep 17 00:00:00 2001 From: Michael Kaufmann Date: Mon, 3 Dec 2018 17:15:54 +0100 Subject: [PATCH] =?UTF-8?q?require=20php-5.6=20for=200.10.0;=20fixes=20#60?= =?UTF-8?q?6=20and=20remove=20invalid=20value=20NO=5FAUTO=5FCREATE=5FUSER?= =?UTF-8?q?=EF=BB=BF=20in=20mysql-attributes=20for=20mysql8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michael Kaufmann --- composer.json | 7 +++-- install/lib/class.FroxlorInstall.php | 37 ++++++++++++----------- install/lng/english.lng.php | 6 ++-- install/lng/french.lng.php | 4 +-- install/lng/german.lng.php | 6 ++-- lib/classes/api/abstract.ApiParameter.php | 7 +---- lib/classes/database/class.Database.php | 9 +++++- lib/classes/dns/class.PowerDNS.php | 7 ++++- lib/init.php | 30 ------------------ 9 files changed, 44 insertions(+), 69 deletions(-) diff --git a/composer.json b/composer.json index 2d88f405..4b065d3c 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ "docs" : "https://github.com/Froxlor/Froxlor/wiki" }, "require" : { - "php" : ">=5.3", + "php" : ">=5.6", "ext-session" : "*", "ext-ctype" : "*", "ext-pdo" : "*", @@ -51,10 +51,11 @@ "theseer/phpdox" : "0.11.2", "phpunit/php-invoker" : "1.1.4", "php" : ">=7.0", - "ext-pcntl" : "*" + "ext-pcntl" : "*", + "phpcompatibility/php-compatibility": "*" }, "suggest" : { "ext-bcmath" : "*", "ext-zip" : "*" } -} \ No newline at end of file +} diff --git a/install/lib/class.FroxlorInstall.php b/install/lib/class.FroxlorInstall.php index 6895df63..d6db93b1 100644 --- a/install/lib/class.FroxlorInstall.php +++ b/install/lib/class.FroxlorInstall.php @@ -210,8 +210,13 @@ class FroxlorInstall // check for mysql-root-connection $content .= $this->_status_message('begin', $this->_lng['install']['testing_mysql']); + $version_server = PDO::getAttribute(PDO::ATTR_SERVER_VERSION); + $sql_mode = 'NO_ENGINE_SUBSTITUTION'; + if (version_compare($version_server, '8.0.11', '<')) { + $sql_mode .= ',NO_AUTO_CREATE_USER'; + } $options = array( - 'PDO::MYSQL_ATTR_INIT_COMMAND' => 'SET names utf8,sql_mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"' + PDO::MYSQL_ATTR_INIT_COMMAND => 'SET names utf8,sql_mode="' . $sql_mode . '"' ); $dsn = "mysql:host=" . $this->_data['mysql_host'] . ";"; $fatal_fail = false; @@ -247,8 +252,13 @@ class FroxlorInstall $content .= $this->_importDatabaseData(); if (! $this->_abort) { // create DB object for new database + $version_server = PDO::getAttribute(PDO::ATTR_SERVER_VERSION); + $sql_mode = 'NO_ENGINE_SUBSTITUTION'; + if (version_compare($version_server, '8.0.11', '<')) { + $sql_mode .= ',NO_AUTO_CREATE_USER'; + } $options = array( - 'PDO::MYSQL_ATTR_INIT_COMMAND' => 'SET names utf8,sql_mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"' + PDO::MYSQL_ATTR_INIT_COMMAND => 'SET names utf8,sql_mode="' . $sql_mode . '"' ); $dsn = "mysql:host=" . $this->_data['mysql_host'] . ";dbname=" . $this->_data['mysql_database'] . ";"; $another_fail = false; @@ -519,8 +529,13 @@ class FroxlorInstall { $content = ""; $content .= $this->_status_message('begin', $this->_lng['install']['testing_new_db']); + $version_server = PDO::getAttribute(PDO::ATTR_SERVER_VERSION); + $sql_mode = 'NO_ENGINE_SUBSTITUTION'; + if (version_compare($version_server, '8.0.11', '<')) { + $sql_mode .= ',NO_AUTO_CREATE_USER'; + } $options = array( - 'PDO::MYSQL_ATTR_INIT_COMMAND' => 'SET names utf8,sql_mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"' + PDO::MYSQL_ATTR_INIT_COMMAND => 'SET names utf8,sql_mode="' . $sql_mode . '"' ); $dsn = "mysql:host=" . $this->_data['mysql_host'] . ";dbname=" . $this->_data['mysql_database'] . ";"; $fatal_fail = false; @@ -932,29 +947,17 @@ class FroxlorInstall // check for correct php version $content .= $this->_status_message('begin', $this->_lng['requirements']['phpversion']); - if (version_compare("5.3.0", PHP_VERSION, ">=")) { + if (version_compare("5.6.0", PHP_VERSION, ">=")) { $content .= $this->_status_message('red', $this->_lng['requirements']['notfound'] . ' (' . PHP_VERSION . ')'); $_die = true; } else { - if (version_compare("5.6.0", PHP_VERSION, ">=")) { + if (version_compare("7.0.0", PHP_VERSION, ">=")) { $content .= $this->_status_message('orange', $this->_lng['requirements']['newerphpprefered'] . ' (' . PHP_VERSION . ')'); } else { $content .= $this->_status_message('green', PHP_VERSION); } } - // Check if magic_quotes_runtime is active | get_magic_quotes_runtime() is always FALSE since 5.4 - if (version_compare(PHP_VERSION, "5.4.0", "<")) { - $content .= $this->_status_message('begin', $this->_lng['requirements']['phpmagic_quotes_runtime']); - if (get_magic_quotes_runtime()) { - // deactivate it - set_magic_quotes_runtime(false); - $content .= $this->_status_message('orange', $this->_lng['requirements']['not_true'] . "
" . $this->_lng['requirements']['phpmagic_quotes_runtime_description']); - } else { - $content .= $this->_status_message('green', 'off'); - } - } - // check for php_pdo and pdo_mysql $content .= $this->_status_message('begin', $this->_lng['requirements']['phppdo']); diff --git a/install/lng/english.lng.php b/install/lng/english.lng.php index c1020569..cd4c9663 100644 --- a/install/lng/english.lng.php +++ b/install/lng/english.lng.php @@ -23,10 +23,8 @@ $lng['requirements']['not_true'] = 'no'; $lng['requirements']['notfound'] = 'not found'; $lng['requirements']['notinstalled'] = 'not installed'; $lng['requirements']['activated'] = 'enabled'; -$lng['requirements']['phpversion'] = 'PHP version >= 5.3'; -$lng['requirements']['newerphpprefered'] = 'Good, but php-5.6 is prefered.'; -$lng['requirements']['phpmagic_quotes_runtime'] = 'magic_quotes_runtime...'; -$lng['requirements']['phpmagic_quotes_runtime_description'] = 'PHP setting "magic_quotes_runtime" must be set to "Off". We have disabled it temporary for now please fix the coresponding php.ini.'; +$lng['requirements']['phpversion'] = 'PHP version >= 5.6'; +$lng['requirements']['newerphpprefered'] = 'Good, but php-7.0 is prefered.'; $lng['requirements']['phppdo'] = 'PHP PDO extension and PDO-MySQL driver...'; $lng['requirements']['phpsession'] = 'PHP session-extension...'; $lng['requirements']['phpctype'] = 'PHP ctype-extension...'; diff --git a/install/lng/french.lng.php b/install/lng/french.lng.php index 43d86530..a312bcf7 100644 --- a/install/lng/french.lng.php +++ b/install/lng/french.lng.php @@ -23,9 +23,7 @@ $lng['requirements']['not_true'] = 'non'; $lng['requirements']['notfound'] = 'introuvable'; $lng['requirements']['notinstalled'] = 'non installé'; $lng['requirements']['activated'] = 'activé'; -$lng['requirements']['phpversion'] = 'PHP version >= 5.3'; -$lng['requirements']['phpmagic_quotes_runtime'] = 'magic_quotes_runtime...'; -$lng['requirements']['phpmagic_quotes_runtime_description'] = 'Le réglage PHP "magic_quotes_runtime" doit être positionné à "Off". Nous l\'avons désactivé temporairement pour l\'instant; merci de corriger le php.ini correspondant.'; +$lng['requirements']['phpversion'] = 'PHP version >= 5.6'; $lng['requirements']['phppdo'] = 'extension PHP PDO et pilote PDO-MySQL ...'; $lng['requirements']['phpxml'] = 'extension PHP XML...'; $lng['requirements']['phpfilter'] = 'extension PHP filter ...'; diff --git a/install/lng/german.lng.php b/install/lng/german.lng.php index 49998936..107ff06c 100644 --- a/install/lng/german.lng.php +++ b/install/lng/german.lng.php @@ -23,10 +23,8 @@ $lng['requirements']['not_true'] = 'nein'; $lng['requirements']['notfound'] = 'nicht gefunden'; $lng['requirements']['notinstalled'] = 'nicht installiert'; $lng['requirements']['activated'] = 'ist aktiviert.'; -$lng['requirements']['phpversion'] = 'PHP Version >= 5.3'; -$lng['requirements']['newerphpprefered'] = 'Passt, aber php-5.6 wird bevorzugt.'; -$lng['requirements']['phpmagic_quotes_runtime'] = 'magic_quotes_runtime'; -$lng['requirements']['phpmagic_quotes_runtime_description'] = 'Die PHP Einstellung "magic_quotes_runtime" muss deaktiviert sein ("Off"). Die Einstellung wurde temporär deaktiviert, bitte ändern Sie diese in der entsprechenden php.ini.'; +$lng['requirements']['phpversion'] = 'PHP Version >= 5.6'; +$lng['requirements']['newerphpprefered'] = 'Passt, aber php-7.0 wird bevorzugt.'; $lng['requirements']['phppdo'] = 'PHP PDO Erweiterung und PDO-MySQL Treiber...'; $lng['requirements']['phpsession'] = 'PHP session-Erweiterung...'; $lng['requirements']['phpctype'] = 'PHP ctype-Erweiterung...'; diff --git a/lib/classes/api/abstract.ApiParameter.php b/lib/classes/api/abstract.ApiParameter.php index 4bc957d3..e2171a79 100644 --- a/lib/classes/api/abstract.ApiParameter.php +++ b/lib/classes/api/abstract.ApiParameter.php @@ -127,13 +127,8 @@ abstract class ApiParameter // which class called us $_class = get_called_class(); if (empty($trace)) { - // check php version for backtrace flags - $_traceopts = false; - if (version_compare(PHP_VERSION, "5.3.6", ">")) { - $_traceopts = DEBUG_BACKTRACE_IGNORE_ARGS; - } // get backtrace - $trace = debug_backtrace($_traceopts); + $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); } // check class and function $class = $trace[$level]['class']; diff --git a/lib/classes/database/class.Database.php b/lib/classes/database/class.Database.php index 079086f8..f7dcd35c 100644 --- a/lib/classes/database/class.Database.php +++ b/lib/classes/database/class.Database.php @@ -267,7 +267,14 @@ class Database { // build up connection string $driver = 'mysql'; $dsn = $driver.":"; - $options = array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET names utf8,sql_mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"'); + $version_server = PDO::getAttribute(PDO::ATTR_SERVER_VERSION); + $sql_mode = 'NO_ENGINE_SUBSTITUTION'; + if (version_compare($version_server, '8.0.11', '<')) { + $sql_mode .= ',NO_AUTO_CREATE_USER'; + } + $options = array( + PDO::MYSQL_ATTR_INIT_COMMAND => 'SET names utf8,sql_mode="' . $sql_mode . '"' + ); $attributes = array('ATTR_ERRMODE' => 'ERRMODE_EXCEPTION'); $dbconf["dsn"] = array( diff --git a/lib/classes/dns/class.PowerDNS.php b/lib/classes/dns/class.PowerDNS.php index 525b366a..08d6dec6 100644 --- a/lib/classes/dns/class.PowerDNS.php +++ b/lib/classes/dns/class.PowerDNS.php @@ -41,8 +41,13 @@ class PowerDNS // build up connection string $driver = 'mysql'; $dsn = $driver . ":"; + $version_server = PDO::getAttribute(PDO::ATTR_SERVER_VERSION); + $sql_mode = 'NO_ENGINE_SUBSTITUTION'; + if (version_compare($version_server, '8.0.11', '<')) { + $sql_mode .= ',NO_AUTO_CREATE_USER'; + } $options = array( - PDO::MYSQL_ATTR_INIT_COMMAND => 'SET names utf8,sql_mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"' + PDO::MYSQL_ATTR_INIT_COMMAND => 'SET names utf8,sql_mode="' . $sql_mode . '"' ); $attributes = array( 'ATTR_ERRMODE' => 'ERRMODE_EXCEPTION' diff --git a/lib/init.php b/lib/init.php index 90df446a..960d9e49 100644 --- a/lib/init.php +++ b/lib/init.php @@ -140,36 +140,6 @@ if (isset($_SERVER['HTTPS']) && (strtolower($_SERVER['HTTPS']) != 'off')) { header($hsts_header); } -/** - * disable magic_quotes_runtime if enabled - */ -// since 5.4 get_magic_quotes_runtime() and get_magic_quotes_gpc() return always FALSE -if (version_compare(PHP_VERSION, "5.4.0", "<")) { - if (get_magic_quotes_runtime()) { - // deactivate - set_magic_quotes_runtime(false); - } - - /** - * Reverse magic_quotes_gpc=on to have clean GPC data again - */ - if (get_magic_quotes_gpc()) { - $in = array(&$_GET, &$_POST, &$_COOKIE); - - $_in = $in; - foreach ($_in as $k => $v) { - foreach ($v as $key => $val) { - if (!is_array($val)) { - $in[$k][$key] = stripslashes($val); - continue; - } - $in[] = & $in[$k][$key]; - } - } - unset($in); - } -} - /** * SESSION MANAGEMENT */