From a57aaed71631e044cf07dec124aae442ed207ac4 Mon Sep 17 00:00:00 2001 From: dingguodong Date: Tue, 19 Dec 2023 15:16:18 +0800 Subject: [PATCH] * Add codes to control if it can be upgraded automatically or has a valid safe file. --- framework/base/router.class.php | 22 ++++++++++++++++++++++ module/common/model.php | 2 ++ www/upgrade.php.tmp | 2 +- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/framework/base/router.class.php b/framework/base/router.class.php index 5068a63a41..194ca63565 100644 --- a/framework/base/router.class.php +++ b/framework/base/router.class.php @@ -3149,6 +3149,28 @@ class baseRouter return strtolower(getenv('IS_CONTAINER')) == 'true'; } + /** + * Check app if it can be upgraded automatically. + * + * @access public + * @return bool + */ + public function canAutoUpgrade() + { + return strtolower(getenv('ZT_AUTO_UPGRADE')) == 'true'; + } + + /** + * Check app if it need check safe file. + * + * @access public + * @return bool + */ + public function hasValidSafeFile() + { + return strtolower(getenv('ZT_CHECK_SAFE_FILE')) == 'true'; + } + /** * Get main file and ext files. * diff --git a/module/common/model.php b/module/common/model.php index 82082ae76a..c272d195e5 100644 --- a/module/common/model.php +++ b/module/common/model.php @@ -2474,6 +2474,8 @@ EOF; { if($this->app->isContainer()) return false; + if($this->app->hasValidSafeFile()) return false; + if($this->app->getModuleName() == 'upgrade' and $this->session->upgrading) return false; $statusFile = $this->app->getAppRoot() . 'www' . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'ok.txt'; diff --git a/www/upgrade.php.tmp b/www/upgrade.php.tmp index ba88e4ac24..8fc4a5bcfe 100644 --- a/www/upgrade.php.tmp +++ b/www/upgrade.php.tmp @@ -66,7 +66,7 @@ $config->installedVersion = $common->loadModel('setting')->getVersion(); if(!$app->session->upgrading && ($config->version[0] == $config->installedVersion[0] or (is_numeric($config->version[0]) and is_numeric($config->installedVersion[0]))) and version_compare($config->version, $config->installedVersion) <= 0) die(header('location: index.php')); /* If run in container, upgrade automatically. */ -if($app->isContainer()) +if($app->isContainer() || $app->canAutoUpgrade()) { $upgradeModel = $common->loadModel('upgrade'); $alterSQL = $upgradeModel->checkConsistency();