diff options
author | Roberts Lataria <roberts.lataria@zabbix.com> | 2020-06-26 15:26:44 +0300 |
---|---|---|
committer | Roberts Lataria <roberts.lataria@zabbix.com> | 2020-06-26 15:26:44 +0300 |
commit | f8ed22c4b257da9eed376f7bfc5e48a09fca7d02 (patch) | |
tree | 895db510913b90123972e456b990889680779f97 /ui | |
parent | 13e03222e7d61f6accf614ce88f4f03c561dad5b (diff) |
.......... [ZBXNEXT-5965] commited
Diffstat (limited to 'ui')
65 files changed, 572 insertions, 228 deletions
diff --git a/ui/api_jsonrpc.php b/ui/api_jsonrpc.php index 7ec56edcde5..12a7c8d67ea 100644 --- a/ui/api_jsonrpc.php +++ b/ui/api_jsonrpc.php @@ -78,3 +78,5 @@ catch (Exception $e) { echo json_encode($response); } + +session_write_close(); diff --git a/ui/app/controllers/CControllerAuthenticationUpdate.php b/ui/app/controllers/CControllerAuthenticationUpdate.php index 53cac78e739..58da4065bec 100644 --- a/ui/app/controllers/CControllerAuthenticationUpdate.php +++ b/ui/app/controllers/CControllerAuthenticationUpdate.php @@ -100,7 +100,7 @@ class CControllerAuthenticationUpdate extends CController { || $data['ldap_configured'] == ZBX_AUTH_LDAP_ENABLED); if (!$is_valid) { - $this->response->setMessageError(_s('Incorrect value for field "%1$s": %2$s.', 'authentication_type', + CMessages::addError(_s('Incorrect value for field "%1$s": %2$s.', 'authentication_type', _('LDAP is not configured') )); } @@ -131,16 +131,14 @@ class CControllerAuthenticationUpdate extends CController { foreach ($ldap_fields as $field) { if (trim($config[$field]) === '') { - $this->response->setMessageError( - _s('Incorrect value for field "%1$s": %2$s.', $field, _('cannot be empty')) - ); + CMessages::addError(_s('Incorrect value for field "%1$s": %2$s.', $field, _('cannot be empty'))); $is_valid = false; break; } } if ($is_valid && ($config['ldap_port'] < ZBX_MIN_PORT_NUMBER || $config['ldap_port'] > ZBX_MAX_PORT_NUMBER)) { - $this->response->setMessageError(_s( + CMessages::addError(_s( 'Incorrect value "%1$s" for "%2$s" field: must be between %3$s and %4$s.', $this->getInput('ldap_port'), 'ldap_port', ZBX_MIN_PORT_NUMBER, ZBX_MAX_PORT_NUMBER )); @@ -148,7 +146,7 @@ class CControllerAuthenticationUpdate extends CController { } if ($ldap_status['result'] != CFrontendSetup::CHECK_OK) { - $this->response->setMessageError($ldap_status['error']); + CMessages::addError($ldap_status['error']); $is_valid = false; } elseif ($is_valid) { @@ -169,7 +167,7 @@ class CControllerAuthenticationUpdate extends CController { ]); if (!$login) { - $this->response->setMessageError($ldap_validator->getError()); + CMessages::addError($ldap_validator->getError()); $is_valid = false; } } @@ -189,9 +187,7 @@ class CControllerAuthenticationUpdate extends CController { foreach ($saml_fields as $field) { if (trim($config[$field]) === '') { - $this->response->setMessageError( - _s('Incorrect value for field "%1$s": %2$s.', $field, _('cannot be empty')) - ); + CMessages::addError(_s('Incorrect value for field "%1$s": %2$s.', $field, _('cannot be empty'))); return false; } @@ -226,7 +222,7 @@ class CControllerAuthenticationUpdate extends CController { // Only ZBX_AUTH_LDAP have 'Test' option. if ($this->hasInput('ldap_test')) { - $this->response->setMessageOk(_('LDAP login successful')); + CMessages::addSuccess(_('LDAP login successful')); $this->response->setFormData($this->getInputAll()); $this->setResponse($this->response); return; @@ -301,12 +297,12 @@ class CControllerAuthenticationUpdate extends CController { $this->invalidateSessions(); } - $this->response->setMessageOk(_('Authentication settings updated')); + CMessages::addSuccess(_('Authentication settings updated')); add_audit(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_ZABBIX_CONFIG, _('Authentication method changed')); } else { $this->response->setFormData($this->getInputAll()); - $this->response->setMessageError(_('Cannot update authentication')); + CMessages::addError(_('Cannot update authentication')); } } diff --git a/ui/app/controllers/CControllerAutoregUpdate.php b/ui/app/controllers/CControllerAutoregUpdate.php index d1d0f3f4c4a..5017cc0d945 100644 --- a/ui/app/controllers/CControllerAutoregUpdate.php +++ b/ui/app/controllers/CControllerAutoregUpdate.php @@ -38,7 +38,7 @@ class CControllerAutoregUpdate extends CController { ->getUrl() ); $response->setFormData($this->getInputAll()); - $response->setMessageError(_('Cannot update configuration')); + CMessages::addError(_('Cannot update configuration')); $this->setResponse($response); break; case self::VALIDATION_FATAL_ERROR: @@ -66,11 +66,11 @@ class CControllerAutoregUpdate extends CController { ); if ($result) { - $response->setMessageOk(_('Configuration updated')); + CMessages::addSuccess(_('Configuration updated')); } else { $response->setFormData($this->getInputAll()); - $response->setMessageError(_('Cannot update configuration')); + CMessages::addError(_('Cannot update configuration')); } $this->setResponse($response); diff --git a/ui/app/controllers/CControllerDashboardDelete.php b/ui/app/controllers/CControllerDashboardDelete.php index 92a17df3a8b..ed735f6f0a5 100644 --- a/ui/app/controllers/CControllerDashboardDelete.php +++ b/ui/app/controllers/CControllerDashboardDelete.php @@ -56,10 +56,10 @@ class CControllerDashboardDelete extends CController { if ($result) { $response->setFormData(['uncheck' => '1']); - $response->setMessageOk(_n('Dashboard deleted', 'Dashboards deleted', $deleted)); + CMessages::addSuccess(_n('Dashboard deleted', 'Dashboards deleted', $deleted)); } else { - $response->setMessageError(_n('Cannot delete dashboard', 'Cannot delete dashboards', $deleted)); + CMessages::addError(_n('Cannot delete dashboard', 'Cannot delete dashboards', $deleted)); } $this->setResponse($response); diff --git a/ui/app/controllers/CControllerExportXml.php b/ui/app/controllers/CControllerExportXml.php index 6b1238b7008..090b19efe73 100644 --- a/ui/app/controllers/CControllerExportXml.php +++ b/ui/app/controllers/CControllerExportXml.php @@ -106,7 +106,7 @@ class CControllerExportXml extends CController { $response = new CControllerResponseRedirect( $this->getInput('backurl', 'zabbix.php?action=dashboard.view')); - $response->setMessageError(_('No permissions to referred object or it does not exist!')); + CMessages::addError(_('No permissions to referred object or it does not exist!')); } else { $response = new CControllerResponseData([ diff --git a/ui/app/controllers/CControllerGuiUpdate.php b/ui/app/controllers/CControllerGuiUpdate.php index fe50c9dc4d7..5f7f32b55c9 100644 --- a/ui/app/controllers/CControllerGuiUpdate.php +++ b/ui/app/controllers/CControllerGuiUpdate.php @@ -40,7 +40,7 @@ class CControllerGuiUpdate extends CController { ->getUrl() ); $response->setFormData($this->getInputAll()); - $response->setMessageError(_('Cannot update configuration')); + CMessages::addError(_('Cannot update configuration')); $this->setResponse($response); break; @@ -73,11 +73,11 @@ class CControllerGuiUpdate extends CController { ); if ($result) { - $response->setMessageOk(_('Configuration updated')); + CMessages::addSuccess(_('Configuration updated')); } else { $response->setFormData($this->getInputAll()); - $response->setMessageError(_('Cannot update configuration')); + CMessages::addError(_('Cannot update configuration')); } $this->setResponse($response); diff --git a/ui/app/controllers/CControllerHousekeepingUpdate.php b/ui/app/controllers/CControllerHousekeepingUpdate.php index ea2a3fdb458..ff88188c7ec 100644 --- a/ui/app/controllers/CControllerHousekeepingUpdate.php +++ b/ui/app/controllers/CControllerHousekeepingUpdate.php @@ -54,7 +54,7 @@ class CControllerHousekeepingUpdate extends CController { ->getUrl() ); $response->setFormData($this->getInputAll()); - $response->setMessageError(_('Cannot update configuration')); + CMessages::addError(_('Cannot update configuration')); $this->setResponse($response); break; case self::VALIDATION_FATAL_ERROR: @@ -119,11 +119,11 @@ class CControllerHousekeepingUpdate extends CController { ); if ($result) { - $response->setMessageOk(_('Configuration updated')); + CMessages::addSuccess(_('Configuration updated')); } else { $response->setFormData($this->getInputAll()); - $response->setMessageError(_('Cannot update configuration')); + CMessages::addError(_('Cannot update configuration')); } $this->setResponse($response); diff --git a/ui/app/controllers/CControllerIconMapCreate.php b/ui/app/controllers/CControllerIconMapCreate.php index 90770ac4808..516d01fabec 100644 --- a/ui/app/controllers/CControllerIconMapCreate.php +++ b/ui/app/controllers/CControllerIconMapCreate.php @@ -46,14 +46,14 @@ class CControllerIconMapCreate extends CController { $response = new CControllerResponseRedirect((new CUrl('zabbix.php')) ->setArgument('action', 'iconmap.list') ); - $response->setMessageOk(_('Icon map created')); + CMessages::addSuccess(_('Icon map created')); } else { $response = new CControllerResponseRedirect((new CUrl('zabbix.php')) ->setArgument('action', 'iconmap.edit') ); $response->setFormData($this->getInputAll()); - $response->setMessageError(_('Cannot create icon map')); + CMessages::addError(_('Cannot create icon map')); } $this->setResponse($response); diff --git a/ui/app/controllers/CControllerIconMapDelete.php b/ui/app/controllers/CControllerIconMapDelete.php index 4c9374b27d3..e9202cd81c2 100644 --- a/ui/app/controllers/CControllerIconMapDelete.php +++ b/ui/app/controllers/CControllerIconMapDelete.php @@ -58,14 +58,14 @@ class CControllerIconMapDelete extends CController { $response = new CControllerResponseRedirect((new CUrl('zabbix.php')) ->setArgument('action', 'iconmap.list') ); - $response->setMessageOk(_('Icon map deleted')); + CMessages::addSuccess(_('Icon map deleted')); } else { $response = new CControllerResponseRedirect((new CUrl('zabbix.php')) ->setArgument('action', 'iconmap.edit') ->setArgument('iconmapid', $this->getInput('iconmapid')) ); - $response->setMessageError(_('Cannot delete icon map')); + CMessages::addError(_('Cannot delete icon map')); } $this->setResponse($response); diff --git a/ui/app/controllers/CControllerIconMapUpdate.php b/ui/app/controllers/CControllerIconMapUpdate.php index 5874bf5f44c..d780092fa02 100644 --- a/ui/app/controllers/CControllerIconMapUpdate.php +++ b/ui/app/controllers/CControllerIconMapUpdate.php @@ -62,7 +62,7 @@ class CControllerIconMapUpdate extends CController { $response = new CControllerResponseRedirect((new CUrl('zabbix.php')) ->setArgument('action', 'iconmap.list') ); - $response->setMessageOk(_('Icon map updated')); + CMessages::addSuccess(_('Icon map updated')); } else { $response = new CControllerResponseRedirect((new CUrl('zabbix.php')) @@ -74,7 +74,7 @@ class CControllerIconMapUpdate extends CController { $form_data['iconmap']['mappings'] = []; } $response->setFormData($form_data); - $response->setMessageError(_('Cannot update icon map')); + CMessages::addError(_('Cannot update icon map')); } $this->setResponse($response); diff --git a/ui/app/controllers/CControllerImageCreate.php b/ui/app/controllers/CControllerImageCreate.php index 6c30331aab5..9b15a9f4e62 100644 --- a/ui/app/controllers/CControllerImageCreate.php +++ b/ui/app/controllers/CControllerImageCreate.php @@ -38,7 +38,7 @@ class CControllerImageCreate extends CController { $response = new CControllerResponseRedirect($url); $response->setFormData($this->getInputAll()); - $response->setMessageError(_('Cannot add image')); + CMessages::addError(_('Cannot add image')); $this->setResponse($response); break; @@ -104,7 +104,7 @@ class CControllerImageCreate extends CController { $response = new CControllerResponseRedirect($url); error($error); $response->setFormData($this->getInputAll()); - $response->setMessageError(_('Cannot add image')); + CMessages::addError(_('Cannot add image')); return $this->setResponse($response); } @@ -122,7 +122,7 @@ class CControllerImageCreate extends CController { ->setArgument('action', 'image.list') ->setArgument('imagetype', $this->getInput('imagetype')) ); - $response->setMessageOk(_('Image added')); + CMessages::addSuccess(_('Image added')); } else { $response = new CControllerResponseRedirect((new CUrl('zabbix.php')) @@ -130,7 +130,7 @@ class CControllerImageCreate extends CController { ->setArgument('imagetype', $this->getInput('imagetype')) ); $response->setFormData($this->getInputAll()); - $response->setMessageError(_('Cannot add image')); + CMessages::addError(_('Cannot add image')); } $this->setResponse($response); diff --git a/ui/app/controllers/CControllerImageDelete.php b/ui/app/controllers/CControllerImageDelete.php index 9f7a76b7816..93dfc023356 100644 --- a/ui/app/controllers/CControllerImageDelete.php +++ b/ui/app/controllers/CControllerImageDelete.php @@ -64,14 +64,14 @@ class CControllerImageDelete extends CController { ->setArgument('action', 'image.list') ->setArgument('imagetype', $this->getInput('imagetype')) ); - $response->setMessageOk(_('Image deleted')); + CMessages::addSuccess(_('Image deleted')); } else { $response = new CControllerResponseRedirect((new CUrl('zabbix.php')) ->setArgument('action', 'image.edit') ->setArgument('imageid', $this->getInput('imageid')) ); - $response->setMessageError(_('Cannot delete image')); + CMessages::addError(_('Cannot delete image')); } $this->setResponse($response); diff --git a/ui/app/controllers/CControllerImageUpdate.php b/ui/app/controllers/CControllerImageUpdate.php index fe6894c7992..59b60719cb4 100644 --- a/ui/app/controllers/CControllerImageUpdate.php +++ b/ui/app/controllers/CControllerImageUpdate.php @@ -40,7 +40,7 @@ class CControllerImageUpdate extends CController { $response = new CControllerResponseRedirect($url); $response->setFormData($this->getInputAll()); - $response->setMessageError(_('Cannot update image')); + CMessages::addError(_('Cannot update image')); $this->setResponse($response); break; @@ -107,7 +107,7 @@ class CControllerImageUpdate extends CController { ); error($error); $response->setFormData($this->getInputAll()); - $response->setMessageError(_('Cannot update image')); + CMessages::addError(_('Cannot update image')); return $this->setResponse($response); } @@ -134,7 +134,7 @@ class CControllerImageUpdate extends CController { ->setArgument('action', 'image.list') ->setArgument('imagetype', $this->getInput('imagetype')) ); - $response->setMessageOk(_('Image updated')); + CMessages::addSuccess(_('Image updated')); } else { $response = new CControllerResponseRedirect((new CUrl('zabbix.php')) @@ -143,7 +143,7 @@ class CControllerImageUpdate extends CController { ->setArgument('imageid', $this->getInput('imageid')) ); $response->setFormData($this->getInputAll()); - $response->setMessageError(_('Cannot update image')); + CMessages::addError(_('Cannot update image')); } $this->setResponse($response); diff --git a/ui/app/controllers/CControllerMacrosUpdate.php b/ui/app/controllers/CControllerMacrosUpdate.php index 5b983a87ae4..c3f6a28bf13 100644 --- a/ui/app/controllers/CControllerMacrosUpdate.php +++ b/ui/app/controllers/CControllerMacrosUpdate.php @@ -107,10 +107,10 @@ class CControllerMacrosUpdate extends CController { $response = new CControllerResponseRedirect((new CUrl('zabbix.php'))->setArgument('action', 'macros.edit')); if ($result) { - $response->setMessageOk(_('Macros updated')); + CMessages::addSuccess(_('Macros updated')); } else { - $response->setMessageError(_('Cannot update macros')); + CMessages::addError(_('Cannot update macros')); $form_data = $this->getInputAll(); $form_data['macros'] = array_values($form_data['macros']); $response->setFormData($form_data); diff --git a/ui/app/controllers/CControllerMediatypeCreate.php b/ui/app/controllers/CControllerMediatypeCreate.php index db8463fad61..9d4c8cd9e9f 100644 --- a/ui/app/controllers/CControllerMediatypeCreate.php +++ b/ui/app/controllers/CControllerMediatypeCreate.php @@ -73,7 +73,7 @@ class CControllerMediatypeCreate extends CController { case self::VALIDATION_ERROR: $response = new CControllerResponseRedirect('zabbix.php?action=mediatype.edit'); $response->setFormData($this->getInputAll()); - $response->setMessageError(_('Cannot add media type')); + CMessages::addError(_('Cannot add media type')); $this->setResponse($response); break; @@ -155,14 +155,14 @@ class CControllerMediatypeCreate extends CController { ->setArgument('page', CPagerHelper::loadPage('mediatype.list', null)) ); $response->setFormData(['uncheck' => '1']); - $response->setMessageOk(_('Media type added')); + CMessages::addSuccess(_('Media type added')); } else { $response = new CControllerResponseRedirect( (new CUrl('zabbix.php'))->setArgument('action', 'mediatype.edit') ); $response->setFormData($this->getInputAll()); - $response->setMessageError(_('Cannot add media type')); + CMessages::addError(_('Cannot add media type')); } $this->setResponse($response); } diff --git a/ui/app/controllers/CControllerMediatypeDelete.php b/ui/app/controllers/CControllerMediatypeDelete.php index 2b820fa2c01..f6dc8e6fc1a 100644 --- a/ui/app/controllers/CControllerMediatypeDelete.php +++ b/ui/app/controllers/CControllerMediatypeDelete.php @@ -63,10 +63,10 @@ class CControllerMediatypeDelete extends CController { if ($result) { $response->setFormData(['uncheck' => '1']); - $response->setMessageOk(_n('Media type deleted', 'Media types deleted', $deleted)); + CMessages::addSuccess(_n('Media type deleted', 'Media types deleted', $deleted)); } else { - $response->setMessageError(_n('Cannot delete media type', 'Cannot delete media types', $deleted)); + CMessages::addError(_n('Cannot delete media type', 'Cannot delete media types', $deleted)); } $this->setResponse($response); } diff --git a/ui/app/controllers/CControllerMediatypeDisable.php b/ui/app/controllers/CControllerMediatypeDisable.php index abb800e0193..41ee77277de 100644 --- a/ui/app/controllers/CControllerMediatypeDisable.php +++ b/ui/app/controllers/CControllerMediatypeDisable.php @@ -69,10 +69,10 @@ class CControllerMediatypeDisable extends CController { if ($result) { $response->setFormData(['uncheck' => '1']); - $response->setMessageOk(_n('Media type disabled', 'Media types disabled', $updated)); + CMessages::addSuccess(_n('Media type disabled', 'Media types disabled', $updated)); } else { - $response->setMessageError(_n('Cannot disable media type', 'Cannot disable media types', $updated)); + CMessages::addError(_n('Cannot disable media type', 'Cannot disable media types', $updated)); } $this->setResponse($response); } diff --git a/ui/app/controllers/CControllerMediatypeEnable.php b/ui/app/controllers/CControllerMediatypeEnable.php index a18fbaa58b2..23f482d662e 100644 --- a/ui/app/controllers/CControllerMediatypeEnable.php +++ b/ui/app/controllers/CControllerMediatypeEnable.php @@ -69,10 +69,10 @@ class CControllerMediatypeEnable extends CController { if ($result) { $response->setFormData(['uncheck' => '1']); - $response->setMessageOk(_n('Media type enabled', 'Media types enabled', $updated)); + CMessages::addSuccess(_n('Media type enabled', 'Media types enabled', $updated)); } else { - $response->setMessageError(_n('Cannot enable media type', 'Cannot enable media types', $updated)); + CMessages::addError(_n('Cannot enable media type', 'Cannot enable media types', $updated)); } $this->setResponse($response); } diff --git a/ui/app/controllers/CControllerMediatypeUpdate.php b/ui/app/controllers/CControllerMediatypeUpdate.php index 224200850ba..21854d16885 100644 --- a/ui/app/controllers/CControllerMediatypeUpdate.php +++ b/ui/app/controllers/CControllerMediatypeUpdate.php @@ -74,7 +74,7 @@ class CControllerMediatypeUpdate extends CController { case self::VALIDATION_ERROR: $response = new CControllerResponseRedirect('zabbix.php?action=mediatype.edit'); $response->setFormData($this->getInputAll()); - $response->setMessageError(_('Cannot update media type')); + CMessages::addError(_('Cannot update media type')); $this->setResponse($response); break; @@ -170,14 +170,14 @@ class CControllerMediatypeUpdate extends CController { ->setArgument('page', CPagerHelper::loadPage('mediatype.list', null)) ); $response->setFormData(['uncheck' => '1']); - $response->setMessageOk(_('Media type updated')); + CMessages::addSuccess(_('Media type updated')); } else { $response = new CControllerResponseRedirect((new CUrl('zabbix.php')) ->setArgument('action', 'mediatype.edit') ); $response->setFormData($this->getInputAll()); - $response->setMessageError(_('Cannot update media type')); + CMessages::addError(_('Cannot update media type')); } $this->setResponse($response); } diff --git a/ui/app/controllers/CControllerMiscConfigUpdate.php b/ui/app/controllers/CControllerMiscConfigUpdate.php index a1534a8e527..491e9f91931 100644 --- a/ui/app/controllers/CControllerMiscConfigUpdate.php +++ b/ui/app/controllers/CControllerMiscConfigUpdate.php @@ -40,7 +40,7 @@ class CControllerMiscConfigUpdate extends CController { ); $response->setFormData($this->getInputAll()); - $response->setMessageError(_('Cannot update configuration')); + CMessages::addError(_('Cannot update configuration')); $this->setResponse($response); break; @@ -74,10 +74,10 @@ class CControllerMiscConfigUpdate extends CController { $result = DBend($result); if ($result) { - $response->setMessageOk(_('Configuration updated')); + CMessages::addSuccess(_('Configuration updated')); } else { - $response->setMessageError(_('Cannot update configuration')); + CMessages::addError(_('Cannot update configuration')); $response->setFormData($this->getInputAll()); } diff --git a/ui/app/controllers/CControllerModuleEdit.php b/ui/app/controllers/CControllerModuleEdit.php index 9a4e21e5eaf..10ba8cfe9ba 100644 --- a/ui/app/controllers/CControllerModuleEdit.php +++ b/ui/app/controllers/CControllerModuleEdit.php @@ -103,7 +103,7 @@ class CControllerModuleEdit extends CController { ->setArgument('action', 'module.list') ->setArgument('page', CPagerHelper::loadPage('module.list', null)) ); - $response->setMessageError(_s('Cannot load module at: %1$s.', $this->module['relative_path'])); + CMessages::addError(_s('Cannot load module at: %1$s.', $this->module['relative_path'])); $this->setResponse($response); } } diff --git a/ui/app/controllers/CControllerModuleScan.php b/ui/app/controllers/CControllerModuleScan.php index 5bc559512e3..49555be5103 100644 --- a/ui/app/controllers/CControllerModuleScan.php +++ b/ui/app/controllers/CControllerModuleScan.php @@ -132,10 +132,10 @@ class CControllerModuleScan extends CController { : _('No new modules discovered'); if (hasErrorMesssages()) { - $response->setMessageError($message); + CMessages::addError($message); } else { - $response->setMessageOk($message); + CMessages::addSuccess($message); } $this->setResponse($response); diff --git a/ui/app/controllers/CControllerModuleUpdate.php b/ui/app/controllers/CControllerModuleUpdate.php index e25e8ca2a28..c35c95f7e41 100644 --- a/ui/app/controllers/CControllerModuleUpdate.php +++ b/ui/app/controllers/CControllerModuleUpdate.php @@ -139,24 +139,24 @@ class CControllerModuleUpdate extends CController { if ($result) { if ($set_status == MODULE_STATUS_ENABLED) { - $response->setMessageOk(_n('Module enabled: %1$s.', 'Modules enabled: %1$s.', + CMessages::addSuccess(_n('Module enabled: %1$s.', 'Modules enabled: %1$s.', implode(', ', $db_modules_update_names), count($this->modules) )); } else { - $response->setMessageOk(_n('Module disabled: %1$s.', 'Modules disabled: %1$s.', + CMessages::addSuccess(_n('Module disabled: %1$s.', 'Modules disabled: %1$s.', implode(', ', $db_modules_update_names), count($this->modules) )); } } else { if ($set_status == MODULE_STATUS_ENABLED) { - $response->setMessageError(_n('Cannot enable module: %1$s.', 'Cannot enable modules: %1$s.', + CMessages::addError(_n('Cannot enable module: %1$s.', 'Cannot enable modules: %1$s.', implode(', ', $db_modules_update_names), count($this->modules) )); } else { - $response->setMessageError(_n('Cannot disable module: %1$s.', 'Cannot disable modules: %1$s.', + CMessages::addError(_n('Cannot disable module: %1$s.', 'Cannot disable modules: %1$s.', implode(', ', $db_modules_update_names), count($this->modules) )); } diff --git a/ui/app/controllers/CControllerProxyCreate.php b/ui/app/controllers/CControllerProxyCreate.php index 295f0b3f58a..8aa11f6513d 100644 --- a/ui/app/controllers/CControllerProxyCreate.php +++ b/ui/app/controllers/CControllerProxyCreate.php @@ -53,7 +53,7 @@ class CControllerProxyCreate extends CController { case self::VALIDATION_ERROR: $response = new CControllerResponseRedirect('zabbix.php?action=proxy.edit'); $response->setFormData($this->getInputAll()); - $response->setMessageError(_('Cannot add proxy')); + CMessages::addError(_('Cannot add proxy')); $this->setResponse($response); break; case self::VALIDATION_FATAL_ERROR: @@ -102,14 +102,14 @@ class CControllerProxyCreate extends CController { ->setArgument('page', CPagerHelper::loadPage('proxy.list', null)) ); $response->setFormData(['uncheck' => '1']); - $response->setMessageOk(_('Proxy added')); + CMessages::addSuccess(_('Proxy added')); } else { $response = new CControllerResponseRedirect((new CUrl('zabbix.php')) ->setArgument('action', 'proxy.edit') ); $response->setFormData($this->getInputAll()); - $response->setMessageError(_('Cannot add proxy')); + CMessages::addError(_('Cannot add proxy')); } $this->setResponse($response); } diff --git a/ui/app/controllers/CControllerProxyDelete.php b/ui/app/controllers/CControllerProxyDelete.php index 1f5a8bc6dce..9829caf49c2 100644 --- a/ui/app/controllers/CControllerProxyDelete.php +++ b/ui/app/controllers/CControllerProxyDelete.php @@ -63,10 +63,10 @@ class CControllerProxyDelete extends CController { if ($result) { $response->setFormData(['uncheck' => '1']); - $response->setMessageOk(_n('Proxy deleted', 'Proxies deleted', $deleted)); + CMessages::addSuccess(_n('Proxy deleted', 'Proxies deleted', $deleted)); } else { - $response->setMessageError(_n('Cannot delete proxy', 'Cannot delete proxies', $deleted)); + CMessages::addError(_n('Cannot delete proxy', 'Cannot delete proxies', $deleted)); } $this->setResponse($response); } diff --git a/ui/app/controllers/CControllerProxyHostDisable.php b/ui/app/controllers/CControllerProxyHostDisable.php index c526b77a2f6..bc69cecbc6f 100644 --- a/ui/app/controllers/CControllerProxyHostDisable.php +++ b/ui/app/controllers/CControllerProxyHostDisable.php @@ -74,10 +74,10 @@ class CControllerProxyHostDisable extends CController { if ($result) { $response->setFormData(['uncheck' => '1']); - $response->setMessageOk(_n('Host disabled', 'Hosts disabled', $updated)); + CMessages::addSuccess(_n('Host disabled', 'Hosts disabled', $updated)); } else { - $response->setMessageError(_n('Cannot disable host', 'Cannot disable hosts', $updated)); + CMessages::addError(_n('Cannot disable host', 'Cannot disable hosts', $updated)); } $this->setResponse($response); } diff --git a/ui/app/controllers/CControllerProxyHostEnable.php b/ui/app/controllers/CControllerProxyHostEnable.php index e74826b48fa..fb1f72ca8f4 100644 --- a/ui/app/controllers/CControllerProxyHostEnable.php +++ b/ui/app/controllers/CControllerProxyHostEnable.php @@ -74,10 +74,10 @@ class CControllerProxyHostEnable extends CController { if ($result) { $response->setFormData(['uncheck' => '1']); - $response->setMessageOk(_n('Host enabled', 'Hosts enabled', $updated)); + CMessages::addSuccess(_n('Host enabled', 'Hosts enabled', $updated)); } else { - $response->setMessageError(_n('Cannot enable host', 'Cannot enable hosts', $updated)); + CMessages::addError(_n('Cannot enable host', 'Cannot enable hosts', $updated)); } $this->setResponse($response); } diff --git a/ui/app/controllers/CControllerProxyUpdate.php b/ui/app/controllers/CControllerProxyUpdate.php index 1cf39daabe3..3a2ca56e675 100644 --- a/ui/app/controllers/CControllerProxyUpdate.php +++ b/ui/app/controllers/CControllerProxyUpdate.php @@ -55,7 +55,7 @@ class CControllerProxyUpdate extends CController { case self::VALIDATION_ERROR: $response = new CControllerResponseRedirect('zabbix.php?action=proxy.edit'); $response->setFormData($this->getInputAll()); - $response->setMessageError(_('Cannot update proxy')); + CMessages::addError(_('Cannot update proxy')); $this->setResponse($response); break; case self::VALIDATION_FATAL_ERROR: @@ -112,7 +112,7 @@ class CControllerProxyUpdate extends CController { ->setArgument('page', CPagerHelper::loadPage('proxy.list', null)) ); $response->setFormData(['uncheck' => '1']); - $response->setMessageOk(_('Proxy updated')); + CMessages::addSuccess(_('Proxy updated')); } else { $response = new CControllerResponseRedirect((new CUrl('zabbix.php')) @@ -120,7 +120,7 @@ class CControllerProxyUpdate extends CController { ->setArgument('proxyid', $this->getInput('proxyid')) ); $response->setFormData($this->getInputAll()); - $response->setMessageError(_('Cannot update proxy')); + CMessages::addError(_('Cannot update proxy')); } $this->setResponse($response); } diff --git a/ui/app/controllers/CControllerRegExCreate.php b/ui/app/controllers/CControllerRegExCreate.php index 14a8455a69c..58abfeb52fe 100644 --- a/ui/app/controllers/CControllerRegExCreate.php +++ b/ui/app/controllers/CControllerRegExCreate.php @@ -40,7 +40,7 @@ class CControllerRegExCreate extends CController { $response = new CControllerResponseRedirect($url); $response->setFormData($this->getInputAll()); - $response->setMessageError(_('Cannot add regular expression')); + CMessages::addError(_('Cannot add regular expression')); $this->setResponse($response); break; @@ -82,12 +82,12 @@ class CControllerRegExCreate extends CController { if ($result) { $response = new CControllerResponseRedirect((new CUrl('zabbix.php'))->setArgument('action', 'regex.list')); - $response->setMessageOk(_('Regular expression added')); + CMessages::addSuccess(_('Regular expression added')); } else { $response = new CControllerResponseRedirect((new CUrl('zabbix.php'))->setArgument('action', 'regex.edit')); $response->setFormData($this->getInputAll()); - $response->setMessageError(_('Cannot add regular expression')); + CMessages::addError(_('Cannot add regular expression')); } $this->setResponse($response); diff --git a/ui/app/controllers/CControllerRegExDelete.php b/ui/app/controllers/CControllerRegExDelete.php index acdb7f75e02..b1feb70bed5 100644 --- a/ui/app/controllers/CControllerRegExDelete.php +++ b/ui/app/controllers/CControllerRegExDelete.php @@ -75,12 +75,12 @@ class CControllerRegExDelete extends CController { $response = new CControllerResponseRedirect((new CUrl('zabbix.php'))->setArgument('action', 'regex.list')); if ($result) { $response->setFormData(['uncheck' => '1']); - $response->setMessageOk(_n('Regular expression deleted', 'Regular expressions deleted', + CMessages::addSuccess(_n('Regular expression deleted', 'Regular expressions deleted', count($this->db_regexes) )); } else { - $response->setMessageError(_n('Cannot delete regular expression', 'Cannot delete regular expressions', + CMessages::addError(_n('Cannot delete regular expression', 'Cannot delete regular expressions', count($this->db_regexes) )); } diff --git a/ui/app/controllers/CControllerRegExUpdate.php b/ui/app/controllers/CControllerRegExUpdate.php index 986ed6d8889..6378626bc04 100644 --- a/ui/app/controllers/CControllerRegExUpdate.php +++ b/ui/app/controllers/CControllerRegExUpdate.php @@ -42,7 +42,7 @@ class CControllerRegExUpdate extends CController { ->setArgument('regexid', $this->getInput('regexid')) ); $response->setFormData($this->getInputAll()); - $response->setMessageError(_('Cannot update regular expression')); + CMessages::addError(_('Cannot update regular expression')); $this->setResponse($response); break; @@ -91,14 +91,14 @@ class CControllerRegExUpdate extends CController { if ($result) { $response = new CControllerResponseRedirect((new CUrl('zabbix.php'))->setArgument('action', 'regex.list')); - $response->setMessageOk(_('Regular expression updated')); + CMessages::addSuccess(_('Regular expression updated')); } else { $response = new CControllerResponseRedirect((new CUrl('zabbix.php')) ->setArgument('action', 'regex.edit') ->setArgument('regexid', $this->getInput('regexid'))); $response->setFormData($this->getInputAll()); - $response->setMessageError(_('Cannot update regular expression')); + CMessages::addError(_('Cannot update regular expression')); } $this->setResponse($response); diff --git a/ui/app/controllers/CControllerScriptCreate.php b/ui/app/controllers/CControllerScriptCreate.php index e9310cbfd5a..f4cf06e2515 100644 --- a/ui/app/controllers/CControllerScriptCreate.php +++ b/ui/app/controllers/CControllerScriptCreate.php @@ -44,7 +44,7 @@ class CControllerScriptCreate extends CController { case self::VALIDATION_ERROR: $response = new CControllerResponseRedirect('zabbix.php?action=script.edit'); $response->setFormData($this->getInputAll()); - $response->setMessageError(_('Cannot add script')); + CMessages::addError(_('Cannot add script')); $this->setResponse($response); break; case self::VALIDATION_FATAL_ERROR: @@ -87,14 +87,14 @@ class CControllerScriptCreate extends CController { ->setArgument('page', CPagerHelper::loadPage('script.list', null)) ); $response->setFormData(['uncheck' => '1']); - $response->setMessageOk(_('Script added')); + CMessages::addSuccess(_('Script added')); } else { $response = new CControllerResponseRedirect((new CUrl('zabbix.php')) ->setArgument('action', 'script.edit') ); $response->setFormData($this->getInputAll()); - $response->setMessageError(_('Cannot add script')); + CMessages::addError(_('Cannot add script')); } $this->setResponse($response); } diff --git a/ui/app/controllers/CControllerScriptDelete.php b/ui/app/controllers/CControllerScriptDelete.php index 50e4644da94..26e6e4435da 100644 --- a/ui/app/controllers/CControllerScriptDelete.php +++ b/ui/app/controllers/CControllerScriptDelete.php @@ -63,10 +63,10 @@ class CControllerScriptDelete extends CController { if ($result) { $response->setFormData(['uncheck' => '1']); - $response->setMessageOk(_n('Script deleted', 'Scripts deleted', $deleted)); + CMessages::addSuccess(_n('Script deleted', 'Scripts deleted', $deleted)); } else { - $response->setMessageError(_n('Cannot delete script', 'Cannot delete scripts', $deleted)); + CMessages::addError(_n('Cannot delete script', 'Cannot delete scripts', $deleted)); } $this->setResponse($response); diff --git a/ui/app/controllers/CControllerScriptUpdate.php b/ui/app/controllers/CControllerScriptUpdate.php index b8de8157432..6209634f594 100644 --- a/ui/app/controllers/CControllerScriptUpdate.php +++ b/ui/app/controllers/CControllerScriptUpdate.php @@ -45,7 +45,7 @@ class CControllerScriptUpdate extends CController { case self::VALIDATION_ERROR: $response = new CControllerResponseRedirect('zabbix.php?action=script.edit'); $response->setFormData($this->getInputAll()); - $response->setMessageError(_('Cannot update script')); + CMessages::addError(_('Cannot update script')); $this->setResponse($response); break; case self::VALIDATION_FATAL_ERROR: @@ -97,7 +97,7 @@ class CControllerScriptUpdate extends CController { ->setArgument('page', CPagerHelper::loadPage('script.list', null)) ); $response->setFormData(['uncheck' => '1']); - $response->setMessageOk(_('Script updated')); + CMessages::addSuccess(_('Script updated')); } else { $response = new CControllerResponseRedirect((new CUrl('zabbix.php')) @@ -105,7 +105,7 @@ class CControllerScriptUpdate extends CController { ->setArgument('scriptid', $this->getInput('scriptid')) ); $response->setFormData($this->getInputAll()); - $response->setMessageError(_('Cannot update script')); + CMessages::addError(_('Cannot update script')); } $this->setResponse($response); } diff --git a/ui/app/controllers/CControllerSystemWarning.php b/ui/app/controllers/CControllerSystemWarning.php index fcb820345da..f19d88d827e 100644 --- a/ui/app/controllers/CControllerSystemWarning.php +++ b/ui/app/controllers/CControllerSystemWarning.php @@ -39,9 +39,7 @@ class CControllerSystemWarning extends CController { 'messages' => [] ]; - if (hasRequest('system-messages')) { - $data['messages'] = getRequest('system-messages'); - } + $data['messages'] = CMessages::get(); $this->setResponse(new CControllerResponseData($data)); } diff --git a/ui/app/controllers/CControllerTrigDisplayUpdate.php b/ui/app/controllers/CControllerTrigDisplayUpdate.php index abc5ce5a675..b391f6ff665 100644 --- a/ui/app/controllers/CControllerTrigDisplayUpdate.php +++ b/ui/app/controllers/CControllerTrigDisplayUpdate.php @@ -44,7 +44,7 @@ class CControllerTrigDisplayUpdate extends CController { ); $response->setFormData($this->getInputAll()); - $response->setMessageError(_('Cannot update configuration')); + CMessages::addError(_('Cannot update configuration')); $this->setResponse($response); } @@ -83,10 +83,10 @@ class CControllerTrigDisplayUpdate extends CController { $result = DBend($result); if ($result) { - $response->setMessageOk(_('Configuration updated')); + CMessages::addSuccess(_('Configuration updated')); } else { - $response->setMessageError(_('Cannot update configuration')); + CMessages::addError(_('Cannot update configuration')); $response->setFormData($this->getInputAll()); } diff --git a/ui/app/controllers/CControllerTrigSeverityUpdate.php b/ui/app/controllers/CControllerTrigSeverityUpdate.php index bf7cb2ba6b5..a554a31b108 100644 --- a/ui/app/controllers/CControllerTrigSeverityUpdate.php +++ b/ui/app/controllers/CControllerTrigSeverityUpdate.php @@ -43,7 +43,7 @@ class CControllerTrigSeverityUpdate extends CController { $response = new CControllerResponseRedirect((new CUrl('zabbix.php')) ->setArgument('action', 'trigseverity.edit') ); - $response->setMessageError(_('Cannot update configuration')); + CMessages::addError(_('Cannot update configuration')); $response->setFormData($this->getInputAll()); $this->setResponse($response); } @@ -76,11 +76,11 @@ class CControllerTrigSeverityUpdate extends CController { ]); if ($result) { - $response->setMessageOk(_('Configuration updated')); + CMessages::addSuccess(_('Configuration updated')); } else { $response->setFormData($this->getInputAll()); - $response->setMessageError(_('Cannot update configuration')); + CMessages::addError(_('Cannot update configuration')); } $this->setResponse($response); diff --git a/ui/app/controllers/CControllerUserCreate.php b/ui/app/controllers/CControllerUserCreate.php index 832d659062f..a622ab81eb7 100644 --- a/ui/app/controllers/CControllerUserCreate.php +++ b/ui/app/controllers/CControllerUserCreate.php @@ -58,7 +58,7 @@ class CControllerUserCreate extends CControllerUserUpdateGeneral { case self::VALIDATION_ERROR: $response = new CControllerResponseRedirect('zabbix.php?action=user.edit'); $response->setFormData($this->getInputAll()); - $response->setMessageError(_('Cannot add user')); + CMessages::addError(_('Cannot add user')); $this->setResponse($response); break; @@ -107,14 +107,14 @@ class CControllerUserCreate extends CControllerUserUpdateGeneral { ->setArgument('page', CPagerHelper::loadPage('user.list', null)) ); $response->setFormData(['uncheck' => '1']); - $response->setMessageOk(_('User added')); + CMessages::addSuccess(_('User added')); } else { $response = new CControllerResponseRedirect((new CUrl('zabbix.php')) ->setArgument('action', 'user.edit') ); $response->setFormData($this->getInputAll()); - $response->setMessageError(_('Cannot add user')); + CMessages::addError(_('Cannot add user')); } $this->setResponse($response); } diff --git a/ui/app/controllers/CControllerUserDelete.php b/ui/app/controllers/CControllerUserDelete.php index a746d689a10..f231f4db14f 100644 --- a/ui/app/controllers/CControllerUserDelete.php +++ b/ui/app/controllers/CControllerUserDelete.php @@ -53,10 +53,10 @@ class CControllerUserDelete extends CController { if ($result) { $response->setFormData(['uncheck' => '1']); - $response->setMessageOk(_n('User deleted', 'Users deleted', $deleted)); + CMessages::addSuccess(_n('User deleted', 'Users deleted', $deleted)); } else { - $response->setMessageError(_n('Cannot delete user', 'Cannot delete users', $deleted)); + CMessages::addError(_n('Cannot delete user', 'Cannot delete users', $deleted)); } $this->setResponse($response); diff --git a/ui/app/controllers/CControllerUserProfileUpdate.php b/ui/app/controllers/CControllerUserProfileUpdate.php index cb5c5080a7d..54089cb3243 100644 --- a/ui/app/controllers/CControllerUserProfileUpdate.php +++ b/ui/app/controllers/CControllerUserProfileUpdate.php @@ -58,7 +58,7 @@ class CControllerUserProfileUpdate extends CControllerUserUpdateGeneral { case self::VALIDATION_ERROR: $response = new CControllerResponseRedirect('zabbix.php?action=userprofile.edit'); $response->setFormData($this->getInputAll()); - $response->setMessageError(_('Cannot update user')); + CMessages::addError(_('Cannot update user')); $this->setResponse($response); break; @@ -111,12 +111,12 @@ class CControllerUserProfileUpdate extends CControllerUserUpdateGeneral { if ($result) { $response = new CControllerResponseRedirect(ZBX_DEFAULT_URL); - $response->setMessageOk(_('User updated')); + CMessages::addSuccess(_('User updated')); } else { $response = new CControllerResponseRedirect('zabbix.php?action=userprofile.edit'); $response->setFormData($this->getInputAll()); - $response->setMessageError(_('Cannot update user')); + CMessages::addError(_('Cannot update user')); } $this->setResponse($response); diff --git a/ui/app/controllers/CControllerUserUnblock.php b/ui/app/controllers/CControllerUserUnblock.php index 2f89e053532..df966a335b2 100644 --- a/ui/app/controllers/CControllerUserUnblock.php +++ b/ui/app/controllers/CControllerUserUnblock.php @@ -72,10 +72,10 @@ class CControllerUserUnblock extends CController { if ($result) { $response->setFormData(['uncheck' => '1']); - $response->setMessageOk(_n('User unblocked', 'Users unblocked', $unblocked)); + CMessages::addSuccess(_n('User unblocked', 'Users unblocked', $unblocked)); } else { - $response->setMessageError(_n('Cannot unblock user', 'Cannot unblock users', $unblocked)); + CMessages::addError(_n('Cannot unblock user', 'Cannot unblock users', $unblocked)); } $this->setResponse($response); diff --git a/ui/app/controllers/CControllerUserUpdate.php b/ui/app/controllers/CControllerUserUpdate.php index 37163c28943..d81edd982bf 100644 --- a/ui/app/controllers/CControllerUserUpdate.php +++ b/ui/app/controllers/CControllerUserUpdate.php @@ -62,7 +62,7 @@ class CControllerUserUpdate extends CControllerUserUpdateGeneral { case self::VALIDATION_ERROR: $response = new CControllerResponseRedirect('zabbix.php?action=user.edit'); $response->setFormData($this->getInputAll()); - $response->setMessageError(_('Cannot update user')); + CMessages::addError(_('Cannot update user')); $this->setResponse($response); break; @@ -119,14 +119,14 @@ class CControllerUserUpdate extends CControllerUserUpdateGeneral { ->setArgument('page', CPagerHelper::loadPage('user.list', null)) ); $response->setFormData(['uncheck' => '1']); - $response->setMessageOk(_('User updated')); + CMessages::addSuccess(_('User updated')); } else { $response = new CControllerResponseRedirect((new CUrl('zabbix.php')) ->setArgument('action', 'user.edit') ); $response->setFormData($this->getInputAll()); - $response->setMessageError(_('Cannot update user')); + CMessages::addError(_('Cannot update user')); } $this->setResponse($response); diff --git a/ui/app/controllers/CControllerUsergroupCreate.php b/ui/app/controllers/CControllerUsergroupCreate.php index c32f3091508..548676c8592 100644 --- a/ui/app/controllers/CControllerUsergroupCreate.php +++ b/ui/app/controllers/CControllerUsergroupCreate.php @@ -48,7 +48,7 @@ class CControllerUsergroupCreate extends CController { ->getUrl() ); $response->setFormData($this->getInputAll()); - $response->setMessageError(_('Cannot add user group')); + CMessages::addError(_('Cannot add user group')); $this->setResponse($response); break; @@ -91,13 +91,13 @@ class CControllerUsergroupCreate extends CController { ->setArgument('page', CPagerHelper::loadPage('usergroup.list', null)) ); $response->setFormData(['uncheck' => '1']); - $response->setMessageOk(_('User group added')); + CMessages::addSuccess(_('User group added')); } else { $response = new CControllerResponseRedirect((new CUrl('zabbix.php')) ->setArgument('action', 'usergroup.edit') ); - $response->setMessageError(_('Cannot add user group')); + CMessages::addError(_('Cannot add user group')); $response->setFormData($this->getInputAll()); } diff --git a/ui/app/controllers/CControllerUsergroupDelete.php b/ui/app/controllers/CControllerUsergroupDelete.php index 1a8d029bfe9..1ca27764f8e 100644 --- a/ui/app/controllers/CControllerUsergroupDelete.php +++ b/ui/app/controllers/CControllerUsergroupDelete.php @@ -53,10 +53,10 @@ class CControllerUsergroupDelete extends CController { if ($result) { $response->setFormData(['uncheck' => '1']); - $response->setMessageOk(_n('User group deleted', 'User groups deleted', $deleted)); + CMessages::addSuccess(_n('User group deleted', 'User groups deleted', $deleted)); } else { - $response->setMessageError(_n('Cannot delete user group', 'Cannot delete user groups', $deleted)); + CMessages::addError(_n('Cannot delete user group', 'Cannot delete user groups', $deleted)); } $this->setResponse($response); diff --git a/ui/app/controllers/CControllerUsergroupMassUpdate.php b/ui/app/controllers/CControllerUsergroupMassUpdate.php index e4c7d656918..4ef45148424 100644 --- a/ui/app/controllers/CControllerUsergroupMassUpdate.php +++ b/ui/app/controllers/CControllerUsergroupMassUpdate.php @@ -63,10 +63,10 @@ class CControllerUsergroupMassUpdate extends CController { if ($result) { $response->setFormData(['uncheck' => '1']); - $response->setMessageOk(_n('User group updated', 'User groups updated', $updated)); + CMessages::addSuccess(_n('User group updated', 'User groups updated', $updated)); } else { - $response->setMessageError(_n('Cannot update user group', 'Cannot update user groups', $updated)); + CMessages::addError(_n('Cannot update user group', 'Cannot update user groups', $updated)); } $this->setResponse($response); diff --git a/ui/app/controllers/CControllerUsergroupUpdate.php b/ui/app/controllers/CControllerUsergroupUpdate.php index b60b0f27cd6..50cd8fc861c 100644 --- a/ui/app/controllers/CControllerUsergroupUpdate.php +++ b/ui/app/controllers/CControllerUsergroupUpdate.php @@ -50,7 +50,7 @@ class CControllerUsergroupUpdate extends CController { ->getUrl() ); $response->setFormData($this->getInputAll()); - $response->setMessageError(_('Cannot update user group')); + CMessages::addError(_('Cannot update user group')); $this->setResponse($response); break; @@ -95,14 +95,14 @@ class CControllerUsergroupUpdate extends CController { ->setArgument('page', CPagerHelper::loadPage('usergroup.list', null)) ); $response->setFormData(['uncheck' => '1']); - $response->setMessageOk(_('User group updated')); + CMessages::addSuccess(_('User group updated')); } else { $response = new CControllerResponseRedirect((new CUrl('zabbix.php')) ->setArgument('action', 'usergroup.edit') ->setArgument('usrgrpid', $this->getInput('usrgrpid')) ); - $response->setMessageError(_('Cannot update user group')); + CMessages::addError(_('Cannot update user group')); $response->setFormData($this->getInputAll()); } diff --git a/ui/app/controllers/CControllerValuemapCreate.php b/ui/app/controllers/CControllerValuemapCreate.php index f58c04a6fb6..828d3a78783 100644 --- a/ui/app/controllers/CControllerValuemapCreate.php +++ b/ui/app/controllers/CControllerValuemapCreate.php @@ -38,7 +38,7 @@ class CControllerValuemapCreate extends CController { $response = new CControllerResponseRedirect($url); $response->setFormData($this->getInputAll()); - $response->setMessageError(_('Cannot add value map')); + CMessages::addError(_('Cannot add value map')); $this->setResponse($response); break; @@ -68,13 +68,13 @@ class CControllerValuemapCreate extends CController { ->setArgument('page', CPagerHelper::loadPage('valuemap.list', null)) ); $response->setFormData(['uncheck' => '1']); - $response->setMessageOk(_('Value map added')); + CMessages::addSuccess(_('Value map added')); } else { $response = new CControllerResponseRedirect((new CUrl('zabbix.php')) ->setArgument('action', 'valuemap.edit') ); - $response->setMessageError(_('Cannot add value map')); + CMessages::addError(_('Cannot add value map')); $response->setFormData($this->getInputAll()); } diff --git a/ui/app/controllers/CControllerValuemapDelete.php b/ui/app/controllers/CControllerValuemapDelete.php index 2a2ca12a730..99884b2b8f3 100644 --- a/ui/app/controllers/CControllerValuemapDelete.php +++ b/ui/app/controllers/CControllerValuemapDelete.php @@ -64,10 +64,10 @@ class CControllerValuemapDelete extends CController { if ($result) { $response->setFormData(['uncheck' => '1']); - $response->setMessageOk(_n('Value map deleted', 'Value maps deleted', count($valuemapids))); + CMessages::addSuccess(_n('Value map deleted', 'Value maps deleted', count($valuemapids))); } else { - $response->setMessageError(_n('Cannot delete value map', 'Cannot delete value maps', count($valuemapids))); + CMessages::addError(_n('Cannot delete value map', 'Cannot delete value maps', count($valuemapids))); } $this->setResponse($response); diff --git a/ui/app/controllers/CControllerValuemapUpdate.php b/ui/app/controllers/CControllerValuemapUpdate.php index 6d2a6cd6b5f..9c82819cb8c 100644 --- a/ui/app/controllers/CControllerValuemapUpdate.php +++ b/ui/app/controllers/CControllerValuemapUpdate.php @@ -41,7 +41,7 @@ class CControllerValuemapUpdate extends CController { $response = new CControllerResponseRedirect($url); $response->setFormData($this->getInputAll()); - $response->setMessageError(_('Cannot update value map')); + CMessages::addError(_('Cannot update value map')); $this->setResponse($response); break; @@ -92,14 +92,14 @@ class CControllerValuemapUpdate extends CController { ->setArgument('page', CPagerHelper::loadPage('valuemap.list', null)) ); $response->setFormData(['uncheck' => '1']); - $response->setMessageOk(_('Value map updated')); + CMessages::addSuccess(_('Value map updated')); } else { $response = new CControllerResponseRedirect((new CUrl('zabbix.php')) ->setArgument('action', 'valuemap.edit') ->setArgument('valuemapid', $this->getInput('valuemapid')) ); - $response->setMessageError(_('Cannot update value map')); + CMessages::addError(_('Cannot update value map')); $response->setFormData($this->getInputAll()); } diff --git a/ui/app/controllers/CControllerWorkingTimeUpdate.php b/ui/app/controllers/CControllerWorkingTimeUpdate.php index 1fe158820db..c0e9a3dfc6e 100644 --- a/ui/app/controllers/CControllerWorkingTimeUpdate.php +++ b/ui/app/controllers/CControllerWorkingTimeUpdate.php @@ -34,7 +34,7 @@ class CControllerWorkingTimeUpdate extends CController { ->getUrl() ); $response->setFormData($this->getInputAll()); - $response->setMessageError(_('Cannot update configuration')); + CMessages::addError(_('Cannot update configuration')); $this->setResponse($response); } @@ -55,11 +55,11 @@ class CControllerWorkingTimeUpdate extends CController { $result = DBend($result); if ($result) { - $response->setMessageOk(_('Configuration updated')); + CMessages::addSuccess(_('Configuration updated')); } else { $response->setFormData($this->getInputAll()); - $response->setMessageError(_('Cannot update configuration')); + CMessages::addError(_('Cannot update configuration')); } $this->setResponse($response); diff --git a/ui/include/classes/core/CCookieSession.php b/ui/include/classes/core/CCookieSession.php index c04280b6a6c..47303e3040a 100644 --- a/ui/include/classes/core/CCookieSession.php +++ b/ui/include/classes/core/CCookieSession.php @@ -1,4 +1,4 @@ -<?php +<?php declare(strict_types = 1); /* ** Zabbix ** Copyright (C) 2001-2020 Zabbix SIA @@ -24,7 +24,10 @@ */ class CCookieSession implements \SessionHandlerInterface { - private const COOKIE_NAME = ZBX_SESSION_NAME; + /** + * Cookie name. + */ + public const COOKIE_NAME = ZBX_SESSION_NAME; /** * Class consturctor. Set session handlers and start session. @@ -33,7 +36,7 @@ class CCookieSession implements \SessionHandlerInterface { if (!headers_sent() && session_status() === PHP_SESSION_NONE) { // Set use standard cookie PHPSESSID to false. - ini_set('session.use_cookies', 0); + ini_set('session.use_cookies', '0'); // Set serialize method to standard serialize / unserialize. ini_set('session.serialize_handler', 'php_serialize'); @@ -42,15 +45,16 @@ class CCookieSession implements \SessionHandlerInterface { ); if (!$this->session_start()) { - throw new \Exception('Cannot start session.'); // FIXME: + throw new \Exception(_('Session initialization error.')); } CSessionHelper::set('sessionid', CSessionHelper::getId()); + CSessionHelper::set('lastacsess', time()); } } /** - * Undocumented function + * @inheritDoc * * @return boolean */ @@ -61,7 +65,7 @@ class CCookieSession implements \SessionHandlerInterface { } /** - * Undocumented function + * @inheritDoc * * @param string $session_id * @@ -74,7 +78,7 @@ class CCookieSession implements \SessionHandlerInterface { } /** - * Undocumented function + * @inheritDoc * * @param integer $maxlifetime * @@ -85,7 +89,7 @@ class CCookieSession implements \SessionHandlerInterface { } /** - * Undocumented function + * @inheritDoc * * @param string $save_path * @param string $session_name @@ -99,7 +103,7 @@ class CCookieSession implements \SessionHandlerInterface { } /** - * Undocumented function + * @inheritDoc * * @param string $session_id * @@ -110,7 +114,7 @@ class CCookieSession implements \SessionHandlerInterface { } /** - * Undocumented function + * @inheritDoc * * @param string $session_id * @param string $session_data @@ -121,12 +125,17 @@ class CCookieSession implements \SessionHandlerInterface { $session_data = $this->prepareData($session_data); if (!CCookieHelper::set(self::COOKIE_NAME, $session_data, 0)) { - throw new \Exception('Session cookie not set.'); // FIXME: + throw new \Exception(_('Cannot set session cookie.')); } return true; } + /** + * Run session_start. + * + * @return boolean + */ private function session_start(): bool { $session_data = $this->parseData(); @@ -143,6 +152,13 @@ class CCookieSession implements \SessionHandlerInterface { return session_start(); } + /** + * Prepare data and check sign. + * + * @param string $data + * + * @return boolean + */ private function checkSign(string $data): bool { $data = unserialize($data); $session_sign = $data['sign']; @@ -152,6 +168,13 @@ class CCookieSession implements \SessionHandlerInterface { return CEncryptHelper::checkSign($session_sign, $sign); } + /** + * Prepare session data. + * + * @param string $data + * + * @return string + */ private function prepareData(string $data): string { $data = unserialize($data); @@ -164,7 +187,16 @@ class CCookieSession implements \SessionHandlerInterface { return base64_encode(serialize($data)); } + /** + * Parse session data. + * + * @return string + */ private function parseData(): string { - return base64_decode(CCookieHelper::get(self::COOKIE_NAME)); + if (CCookieHelper::has(self::COOKIE_NAME)) { + return base64_decode(CCookieHelper::get(self::COOKIE_NAME)); + } + + return ''; } } diff --git a/ui/include/classes/core/CMessages.php b/ui/include/classes/core/CMessages.php new file mode 100644 index 00000000000..e2d22fdbce0 --- /dev/null +++ b/ui/include/classes/core/CMessages.php @@ -0,0 +1,129 @@ +<?php declare(strict_types = 1); +/* +** Zabbix +** Copyright (C) 2001-2020 Zabbix SIA +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +**/ + + +/** + * Helper to store succes / error messages. + */ +class CMessages { + + /** + * Messages array. + * + * @static + * + * @var array + */ + private static $msgs = []; + /** + * Success message. + * + * @static + * + * @var string + */ + private static $success; + /** + * Error message. + * + * @static + * + * @var string + */ + private static $error; + + /** + * Add messages. + * + * @static + * + * @param array $msg + * + * @return boolean + */ + public static function add(array $msg): bool { + self::$msgs[] = $msg; + + return true; + } + + /** + * Add success message. + * + * @static + * + * @param string $msg + * + * @return boolean + */ + public static function addSuccess(string $msg): bool { + self::$success = $msg; + + return true; + } + + /** + * Add error message. + * + * @static + * + * @param string $msg + * + * @return boolean + */ + public static function addError(string $msg): bool { + self::$error = $msg; + + return true; + } + + /** + * Get messages. + * + * @static + * + * @return array + */ + public static function get(): array { + return self::$msgs; + } + + /** + * Get success message. + * + * @static + * + * @return string|null + */ + public static function getSuccess(): ?string { + return self::$success; + } + + /** + * Get error message. + * + * @static + * + * @return string|null + */ + public static function getError(): ?string { + return self::$error; + } +} diff --git a/ui/include/classes/core/ZBase.php b/ui/include/classes/core/ZBase.php index 0af1a98e05a..461584deb2f 100644 --- a/ui/include/classes/core/ZBase.php +++ b/ui/include/classes/core/ZBase.php @@ -202,6 +202,9 @@ class ZBase { case self::EXEC_MODE_API: $this->loadConfigFile(); $this->initDB(); + + new CCookieSession(); + $this->initLocales(['lang' => 'en_gb']); break; @@ -210,8 +213,12 @@ class ZBase { // try to load config file, if it exists we need to init db and authenticate user to check permissions $this->loadConfigFile(); $this->initDB(); + + new CCookieSession(); + $this->authenticateUser(); $this->initLocales(CWebUser::$data); + $this->initComponents(); } catch (ConfigFileException $e) {} break; @@ -421,11 +428,13 @@ class ZBase { * Set messages received in cookies. */ private function initMessages(): void { - foreach (['system-message-ok', 'system-message-error'] as $message_type) { - if (array_key_exists($message_type, $_COOKIE)) { - $_REQUEST[$message_type] = $_COOKIE[$message_type]; - CCookieHelper::unset($message_type); - } + if (CCookieHelper::has('system-message-ok')) { + CMessages::addSuccess(CCookieHelper::get('system-message-ok')); + CCookieHelper::unset('system-message-ok'); + } + if (CCookieHelper::has('system-message-error')) { + CMessages::addError(CCookieHelper::get('system-message-error')); + CCookieHelper::unset('system-message-error'); } } @@ -514,7 +523,7 @@ class ZBase { global $ZBX_MESSAGES; $messages = (isset($ZBX_MESSAGES) && $ZBX_MESSAGES) ? filter_messages($ZBX_MESSAGES) : []; foreach ($messages as $message) { - $response->addMessage($message['message']); + CMessages::add($message); } $response->redirect(); @@ -526,14 +535,14 @@ class ZBase { global $ZBX_MESSAGES; $messages = (isset($ZBX_MESSAGES) && $ZBX_MESSAGES) ? filter_messages($ZBX_MESSAGES) : []; foreach ($messages as $message) { - $response->addMessage($message['message']); + CMessages::add($message); } - $response->addMessage('Controller: '.$router->getAction()); + CMessages::add(['message' => 'Controller: '.$router->getAction()]); ksort($_REQUEST); foreach ($_REQUEST as $key => $value) { if ($key !== 'sid') { - $response->addMessage(is_scalar($value) ? $key.': '.$value : $key.': '.gettype($value)); + CMessages::add(['message' => is_scalar($value) ? $key.': '.$value : $key.': '.gettype($value)]); } } diff --git a/ui/include/classes/helpers/CCookieHelper.php b/ui/include/classes/helpers/CCookieHelper.php index 08a76e61547..f790403dec5 100644 --- a/ui/include/classes/helpers/CCookieHelper.php +++ b/ui/include/classes/helpers/CCookieHelper.php @@ -1,28 +1,79 @@ -<?php +<?php declare(strict_types = 1); +/* +** Zabbix +** Copyright (C) 2001-2020 Zabbix SIA +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +**/ -final class CCookieHelper { +/** + * Cookie helper. + */ +class CCookieHelper { + + /** + * Check cookie exists. + * + * @static + * + * @param string $name + * + * @return boolean + */ public static function has(string $name): bool { return array_key_exists($name, $_COOKIE); } + /** + * Get cookie value. + * + * @static + * + * @param string $name + * + * @return mixed + */ public static function get(string $name) { return self::has($name) ? $_COOKIE[$name] : null; } - public static function set(string $name, $value, int $time = 0): bool { + /** + * Add cookie. + * + * @static + * + * @param string $name + * @param string $value + * @param integer $time + * + * @return boolean + */ + public static function set(string $name, string $value, int $time = 0): bool { if (headers_sent()) { - throw new \Exception('Headers already sent.'); // FIXME: + throw new \Exception(_('Headers already sent.')); } $path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); $path = rtrim(substr($path, 0, strrpos($path, '/')), '/'); - if (strlen($value) === 0) { - throw new \Exception("Value cannot be empty. To delete cookie use ".self::class."::unset()"); // FIXME: + if (mb_strlen($value) === 0) { + throw new \Exception(_('Value cannot be empty.')); } - if (!setcookie($name, $value, $time, $path, null, HTTPS, true)) { + if (!setcookie($name, $value, $time, $path, '', HTTPS, true)) { return false; } @@ -31,13 +82,22 @@ final class CCookieHelper { return true; } + /** + * Delete cookie. + * + * @static + * + * @param string $name + * + * @return boolean + */ public static function unset(string $name): bool { if (!self::has($name)) { return false; } if (headers_sent()) { - throw new \Exception('Headers already sent.'); // FIXME: + throw new \Exception(_('Headers already sent.')); } unset($_COOKIE[$name]); @@ -45,6 +105,13 @@ final class CCookieHelper { return setcookie($name, '', 0); } + /** + * Get all cookies. + * + * @static + * + * @return array + */ public static function getAll(): array { return $_COOKIE; } diff --git a/ui/include/classes/helpers/CEncryptHelper.php b/ui/include/classes/helpers/CEncryptHelper.php index 06a814d2af7..ad41a77b55b 100644 --- a/ui/include/classes/helpers/CEncryptHelper.php +++ b/ui/include/classes/helpers/CEncryptHelper.php @@ -1,16 +1,55 @@ -<?php +<?php declare(strict_types = 1); +/* +** Zabbix +** Copyright (C) 2001-2020 Zabbix SIA +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +**/ + +/** + * Helper class for sign / encrypt data. + */ class CEncryptHelper { - private const SIGN_ALGO = 'aes-256-ecb'; + /** + * Signature algorithm. + */ + public const SIGN_ALGO = 'aes-256-ecb'; + /** + * Session secret key. + * + * @static + * + * @var string + */ private static $key; + /** + * Return session key. + * + * @static + * + * @return string + */ private static function getKey(): string { if (!self::$key) { $config = select_config(); if (!array_key_exists('session_key', $config)) { - throw new \Exception('Please define session secret key'); // FIXME: + throw new \Exception(_('Session secret not defined.')); } self::$key = $config['session_key']; @@ -19,10 +58,29 @@ class CEncryptHelper { return self::$key; } + /** + * Timing attack safe string comparison. + * + * @static + * + * @param string $known_string + * @param string $user_string + * + * @return boolean + */ public static function checkSign(string $known_string, string $user_string): bool { return hash_equals($known_string, $user_string); } + /** + * Encrypt string with session key. + * + * @static + * + * @param string $data + * + * @return string + */ public static function sign(string $data): string { $key = self::getKey(); diff --git a/ui/include/classes/helpers/CSessionHelper.php b/ui/include/classes/helpers/CSessionHelper.php index ac6167c395d..693ba43bdae 100644 --- a/ui/include/classes/helpers/CSessionHelper.php +++ b/ui/include/classes/helpers/CSessionHelper.php @@ -1,33 +1,109 @@ -<?php +<?php declare(strict_types = 1); +/* +** Zabbix +** Copyright (C) 2001-2020 Zabbix SIA +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +**/ -final class CSessionHelper { +/** + * Session helper. + */ +class CSessionHelper { + + /** + * Clear session data. + * + * @static + * + * @return boolean + */ public static function clear(): bool { return session_unset(); } + /** + * Check has this key in session. + * + * @static + * + * @param string $key + * + * @return boolean + */ public static function has(string $key): bool { return array_key_exists($key, $_SESSION); } + /** + * Get session data. + * + * @static + * + * @param string $key + * + * @return mixed + */ public static function get(string $key) { return self::has($key) ? $_SESSION[$key] : null; } + /** + * Add to session. + * + * @static + * + * @param string $key + * @param mixed $value + */ public static function set(string $key, $value): void { $_SESSION[$key] = $value; } + /** + * Delete from session. + * + * @static + * + * @param array $keys + */ public static function unset(array $keys): void { foreach ($keys as $key) { unset($_SESSION[$key]); } } + /** + * Get session id. + * + * @static + * + * @return string + */ public static function getId(): string { return session_id(); } + /** + * Get all session data. + * + * @static + * + * @return array + */ public function getAll(): array { return $_SESSION; } diff --git a/ui/include/classes/mvc/CController.php b/ui/include/classes/mvc/CController.php index 13585b7f2bd..0857cff0601 100644 --- a/ui/include/classes/mvc/CController.php +++ b/ui/include/classes/mvc/CController.php @@ -139,6 +139,11 @@ abstract class CController { return substr($sessionid, 16, 16); } + /** + * Parse form data. + * + * @return boolean + */ protected function parseFormData(): bool { $data = base64_decode(getRequest('data')); $sign = base64_decode(getRequest('sign')); @@ -155,14 +160,16 @@ abstract class CController { if ($data['messages']) { if (array_key_exists('success', $data['messages'])) { - $_REQUEST['system-message-ok'] = $data['messages']['success']; + CMessages::addSuccess($data['messages']['success']); } if (array_key_exists('error', $data['messages'])) { - $_REQUEST['system-message-error'] = $data['messages']['error']; + CMessages::addError($data['messages']['error']); } if (array_key_exists('messages', $data['messages'])) { - $_REQUEST['system-messages'] = $data['messages']['messages']; + foreach ($data['messages']['messages'] as $message) { + CMessages::add($message); + } } } diff --git a/ui/include/classes/mvc/CControllerResponse.php b/ui/include/classes/mvc/CControllerResponse.php index 3b8dafee7c2..8e0ca0cf5cd 100644 --- a/ui/include/classes/mvc/CControllerResponse.php +++ b/ui/include/classes/mvc/CControllerResponse.php @@ -29,18 +29,10 @@ abstract class CControllerResponse { return $this->location; } - public function getMessages(): array { - return $this->messages; - } - - public function addMessage(string $msg): void { - $this->messages[] = $msg; - } - public function redirect(): void { // Redirect as simple request. if ($this instanceof CControllerResponseRedirect) { - if ($this->getFormData() === null && $this->getMessageOk() === null && $this->getMessageError() === null) { + if ($this->getFormData() === null && CMessages::getSuccess() === null && CMessages::getError() === null) { redirect($this->getLocation()); } } @@ -94,17 +86,21 @@ abstract class CControllerResponse { $data = []; $messages = []; - foreach ($this->getMessages() as $value) { - $messages['messages'][] = ['message' => $value]; + foreach (CMessages::get() as $value) { + if (!is_array($value)) { + $value = ['message' => $value]; + } + + $messages['messages'][] = $value; } if ($this instanceof CControllerResponseRedirect) { - if ($this->getMessageOk() !== null) { - $messages['success'] = $this->getMessageOk(); + if (CMessages::getSuccess() !== null) { + $messages['success'] = CMessages::getSuccess(); } - if ($this->getMessageError() !== null) { - $messages['error'] = $this->getMessageError(); + if (CMessages::getError() !== null) { + $messages['error'] = CMessages::getError(); } $data = $this->getFormData(); diff --git a/ui/include/classes/mvc/CControllerResponseRedirect.php b/ui/include/classes/mvc/CControllerResponseRedirect.php index e1b8f48881b..f0da6354670 100644 --- a/ui/include/classes/mvc/CControllerResponseRedirect.php +++ b/ui/include/classes/mvc/CControllerResponseRedirect.php @@ -39,23 +39,7 @@ class CControllerResponseRedirect extends CControllerResponse { $this->formData = $formData; } - public function setMessageOk(string $messageOk): void { - $this->messageOk = $messageOk; - } - - public function setMessageError(string $messageError): void { - $this->messageError = $messageError; - } - public function getFormData(): array { return $this->formData; } - - public function getMessageOk(): ?string { - return $this->messageOk; - } - - public function getMessageError(): ?string { - return $this->messageError; - } } diff --git a/ui/include/func.inc.php b/ui/include/func.inc.php index 9af7b773039..7a3b6dbd59d 100644 --- a/ui/include/func.inc.php +++ b/ui/include/func.inc.php @@ -1851,22 +1851,18 @@ function get_prepared_messages(array $options = []): ?string { // Process messages passed by the previous request. - if ($options['with_session_messages'] && (hasRequest('system-message-ok') || hasRequest('system-message-error'))) { - if (hasRequest('system-messages')) { - $ZBX_MESSAGES = getRequest('system-messages'); + if ($options['with_session_messages']) { + if (CMessages::get()) { + $ZBX_MESSAGES = CMessages::get(); } - if (hasRequest('system-message-ok')) { - show_messages(true, getRequest('system-message-ok'), null); + if (CMessages::getSuccess()) { + show_messages(true, CMessages::getSuccess(), null); } - if (hasRequest('system-message-error')) { - show_messages(false, null, getRequest('system-message-error')); + if (CMessages::getError()) { + show_messages(false, null, CMessages::getError()); } - - unset_request('system-messages'); - unset_request('system-message-ok'); - unset_request('system-message-error'); } $messages_session = $ZBX_MESSAGES_PREPARED; diff --git a/ui/include/page_header.php b/ui/include/page_header.php index cbae9419c38..ce233403677 100644 --- a/ui/include/page_header.php +++ b/ui/include/page_header.php @@ -165,7 +165,7 @@ if ($page['type'] == PAGE_TYPE_HTML) { ->getUrl() ); - if ($page['scripts']) { + if (array_key_exists('scripts', $page)) { $pageHeader->addJsFile((new CUrl('jsLoader.php')) ->setArgument('ver', ZABBIX_VERSION) ->setArgument('lang', CWebUser::$data['lang']) diff --git a/ui/index_http.php b/ui/index_http.php index 668e6282519..8a281e8db42 100644 --- a/ui/index_http.php +++ b/ui/index_http.php @@ -40,8 +40,6 @@ if ($request !== '') { if ($config['http_auth_enabled'] != ZBX_AUTH_HTTP_ENABLED) { redirect($redirect_to->toString()); - - exit; } $http_user = ''; @@ -70,11 +68,8 @@ if ($http_user) { ); if ($user) { - CWebUser::setSessionCookie($user['sessionid']); $redirect = array_filter([$request, $user['url'], ZBX_DEFAULT_URL]); redirect(reset($redirect)); - - exit; } } catch (APIException $e) { @@ -94,3 +89,5 @@ echo (new CView('general.warning', [ ], 'theme' => getUserTheme(CWebUser::$data) ]))->getOutput(); + +session_write_close(); diff --git a/ui/index_sso.php b/ui/index_sso.php index f92101e94fe..b46da2e5430 100644 --- a/ui/index_sso.php +++ b/ui/index_sso.php @@ -210,8 +210,6 @@ try { throw new Exception(_('GUI access disabled.')); } - CWebUser::setSessionCookie($user['sessionid']); - $redirect = array_filter([$user['url'], ZBX_DEFAULT_URL]); redirect(reset($redirect)); } @@ -230,3 +228,6 @@ echo (new CView('general.warning', [ ], 'theme' => getUserTheme(CWebUser::$data) ]))->getOutput(); + + +session_write_close(); diff --git a/ui/jsrpc.php b/ui/jsrpc.php index 036e38278c8..72518dca00b 100644 --- a/ui/jsrpc.php +++ b/ui/jsrpc.php @@ -65,8 +65,6 @@ switch ($data['method']) { break; case 'zabbix.status': - new CCookieSession; - if (!CSessionHelper::has('serverCheckResult') || (CSessionHelper::get('serverCheckTime') + SERVER_CHECK_INTERVAL) <= time()) { $zabbixServer = new CZabbixServer($ZBX_SERVER, $ZBX_SERVER_PORT, ZBX_SOCKET_TIMEOUT, 0); diff --git a/ui/setup.php b/ui/setup.php index c1bea1460f7..914bc537e56 100644 --- a/ui/setup.php +++ b/ui/setup.php @@ -33,7 +33,7 @@ catch (Exception $e) { 'theme' => ZBX_DEFAULT_THEME ]))->getOutput(); - exit; + exit(); } // VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION @@ -63,8 +63,6 @@ $fields = [ 'back' => [T_ZBX_STR, O_OPT, P_SYS, null, null], ]; -new CCookieSession; - CSessionHelper::set('check_fields_result', check_fields($fields, false)); if (!CSessionHelper::has('step')) { CSessionHelper::set('step', 0); |