From 8cdd96f286c589e808f45f09f716c578c3ba2299 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 8 Feb 2022 13:29:51 -0500 Subject: [PATCH] Implement a check on change of language. Make sure that the specified language file exists. Reports errors to UI --- web/includes/actions/options.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/web/includes/actions/options.php b/web/includes/actions/options.php index 07b71c001..9b0033f4e 100644 --- a/web/includes/actions/options.php +++ b/web/includes/actions/options.php @@ -24,6 +24,8 @@ if ( !canEdit('System') ) { return; } +global $error_message; + if ( $action == 'delete' ) { if ( isset($_REQUEST['object']) ) { if ( $_REQUEST['object'] == 'server' ) { @@ -65,10 +67,19 @@ if ( $action == 'delete' ) { } if ( isset($newValue) && ($newValue != $config['Value']) ) { + # Handle special cases first + if ($config['Name'] == 'ZM_LANG_DEFAULT') { + # Verify that the language file exists in the lang directory. + if (!file_exists(ZM_PATH_WEB.'/lang/'.$newValue.'.php')) { + $error_message .= 'Error setting ' . $config['Name'].'. New value ' .$newValue.' not saved because '.ZM_PATH_WEB.'/lang/'.$newValue.'.php doesn\'t exist.
'; + ZM\Error($error_message); + continue; + } + } dbQuery('UPDATE Config SET Value=? WHERE Name=?', array($newValue, $config['Name'])); $changed = true; - } - } + } # end if value changed + } # end foreach config entry if ( $changed ) { switch ( $_REQUEST['tab'] ) { case 'system' :