diff --git a/admin_autoupdate.php b/admin_autoupdate.php index ddcea413..1632b1e3 100644 --- a/admin_autoupdate.php +++ b/admin_autoupdate.php @@ -45,6 +45,14 @@ if (version_compare("7.4.0", PHP_VERSION, ">=")) { )); } +// check for webupdate to be enabled +if (\Froxlor\Settings::Config('enable_webupdate') != true) { + \Froxlor\UI\Response::redirectTo($filename, array( + 'page' => 'error', + 'errno' => 11 + )); +} + // display initial version check if ($page == 'overview') { @@ -281,5 +289,6 @@ elseif ($page == 'error') { // 8 = could not extract archive // 9 = checksum mismatch // 10 = false + ]; + + $configfile = Froxlor::getInstallDir() . '/lib/config.inc.php'; + if (@file_exists($configfile) && is_readable($configfile)) { + self::$conf = include $configfile; + } + return true; + } + /** * update a value in the database * @@ -122,7 +149,7 @@ class Settings self::init(); $sstr = explode(".", $setting); // no separator - do'h - if (! isset($sstr[1])) { + if (!isset($sstr[1])) { return null; } $result = null; @@ -170,7 +197,7 @@ class Settings if (self::Get($setting) !== null) { // set new value in array $sstr = explode(".", $setting); - if (! isset($sstr[1])) { + if (!isset($sstr[1])) { return false; } self::$data[$sstr[0]][$sstr[1]] = $value; @@ -179,12 +206,12 @@ class Settings self::storeSetting($sstr[0], $sstr[1], $value); } else { // set temporary data for usage - if (! isset(self::$data[$sstr[0]]) || ! is_array(self::$data[$sstr[0]])) { + if (!isset(self::$data[$sstr[0]]) || !is_array(self::$data[$sstr[0]])) { self::$data[$sstr[0]] = array(); } self::$data[$sstr[0]][$sstr[1]] = $value; // set update-data when invoking Flush() - if (! isset(self::$updatedata[$sstr[0]]) || ! is_array(self::$updatedata[$sstr[0]])) { + if (!isset(self::$updatedata[$sstr[0]]) || !is_array(self::$updatedata[$sstr[0]])) { self::$updatedata[$sstr[0]] = array(); } self::$updatedata[$sstr[0]][$sstr[1]] = $value; @@ -210,7 +237,7 @@ class Settings if (self::Get($setting) === null) { // validate parameter $sstr = explode(".", $setting); - if (! isset($sstr[1])) { + if (!isset($sstr[1])) { return false; } // prepare statement @@ -291,7 +318,7 @@ class Settings 'varname' => $field_details['varname'] )); - if (! empty($row)) { + if (!empty($row)) { $varvalue = $row['value']; } else { $varvalue = $field_details['default']; @@ -306,4 +333,19 @@ class Settings } } } + + /** + * get value from config by identifier + */ + public static function Config(string $config) + { + self::init(); + $sstr = explode(".", $config); + $result = self::$conf; + foreach ($sstr as $key) { + $result = $result[$key] ?? null; + if (empty($result)) break; + } + return $result; + } } diff --git a/lib/config.inc.php b/lib/config.inc.php new file mode 100644 index 00000000..26d1be34 --- /dev/null +++ b/lib/config.inc.php @@ -0,0 +1,8 @@ + false +]; diff --git a/lib/navigation/00.froxlor.main.php b/lib/navigation/00.froxlor.main.php index 7260665e..0ee610e5 100644 --- a/lib/navigation/00.froxlor.main.php +++ b/lib/navigation/00.froxlor.main.php @@ -228,7 +228,7 @@ return array( 'url' => 'admin_autoupdate.php?page=overview', 'label' => $lng['admin']['autoupdate'], 'required_resources' => 'change_serversettings', - 'show_element' => extension_loaded('zip') + 'show_element' => extension_loaded('zip') && \Froxlor\Settings::Config('enable_webupdate') ), array( 'url' => 'admin_settings.php?page=wipecleartextmailpws', diff --git a/lng/english.lng.php b/lng/english.lng.php index 6e36e933..cfaa8781 100644 --- a/lng/english.lng.php +++ b/lng/english.lng.php @@ -1878,6 +1878,7 @@ $lng['error']['autoupdate_7'] = 'The downloaded archive could not be found :('; $lng['error']['autoupdate_8'] = 'The archive could not be extracted :('; $lng['error']['autoupdate_9'] = 'The downloaded file did not pass the integrity check. Please try to update again.'; $lng['error']['autoupdate_10'] = 'Minimum supported version of PHP is 7.4.0'; +$lng['error']['autoupdate_11'] = 'Webupdate is disabled'; $lng['admin']['server_php'] = 'PHP'; $lng['domains']['termination_date'] = 'Date of termination'; diff --git a/lng/german.lng.php b/lng/german.lng.php index bed2dfeb..8002cc72 100644 --- a/lng/german.lng.php +++ b/lng/german.lng.php @@ -1525,6 +1525,7 @@ $lng['error']['autoupdate_7'] = 'Das heruntergeladene Archiv konnte nicht gefund $lng['error']['autoupdate_8'] = 'Das Archiv konnte nicht entpackt werden :('; $lng['error']['autoupdate_9'] = 'Die heruntergeladene Datei konnte nicht verifiziert werden. Bitte erneut versuchen zu aktualisieren.'; $lng['error']['autoupdate_10'] = 'Minimum unterstützte Version von PHP ist 7.4.0'; +$lng['error']['autoupdate_11'] = 'Webupdate ist deaktiviert'; $lng['domains']['termination_date'] = 'Kündigungsdatum'; $lng['domains']['termination_date_overview'] = 'gekündigt zum ';