Source
xxxxxxxxxx
98
98
null
99
99
],
100
100
'clone' => [T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null],
101
101
'del_history' => [T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null],
102
102
'add' => [T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null],
103
103
'update' => [T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null],
104
104
'delete' => [T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null],
105
105
'cancel' => [T_ZBX_STR, O_OPT, P_SYS, null, null],
106
106
'form' => [T_ZBX_STR, O_OPT, P_SYS, null, null],
107
107
'form_refresh' => [T_ZBX_INT, O_OPT, P_SYS, null, null],
108
+
'backurl' => [T_ZBX_STR, O_OPT, null, null, null],
108
109
// sort and sortorder
109
110
'sort' => [T_ZBX_STR, O_OPT, P_SYS, IN('"hostname","name","status"'), null],
110
111
'sortorder' => [T_ZBX_STR, O_OPT, P_SYS, IN('"'.ZBX_SORT_DOWN.'","'.ZBX_SORT_UP.'"'), null]
111
112
];
112
113
113
114
check_fields($fields);
114
115
115
116
if (!empty($_REQUEST['steps'])) {
116
117
order_result($_REQUEST['steps'], 'no');
117
118
}
127
128
]);
128
129
129
130
if (!$httptests) {
130
131
access_deny();
131
132
}
132
133
}
133
134
elseif (getRequest('hostid') && !isWritableHostTemplates([getRequest('hostid')])) {
134
135
access_deny();
135
136
}
136
137
138
+
// Validate backurl.
139
+
if (hasRequest('backurl') && !CHtmlUrlValidator::validateSameSite(getRequest('backurl'))) {
140
+
access_deny();
141
+
}
142
+
137
143
$tags = getRequest('tags', []);
138
144
foreach ($tags as $key => $tag) {
139
145
if ($tag['tag'] === '' && $tag['value'] === '') {
140
146
unset($tags[$key]);
141
147
}
142
148
elseif (array_key_exists('type', $tag) && !($tag['type'] & ZBX_PROPERTY_OWN)) {
143
149
unset($tags[$key]);
144
150
}
145
151
else {
146
152
unset($tags[$key]['type']);
348
354
349
355
$msg = $e->getMessage();
350
356
if (!empty($msg)) {
351
357
error($msg);
352
358
}
353
359
show_messages(false, null, $messageFalse);
354
360
}
355
361
}
356
362
elseif (hasRequest('action') && str_in_array(getRequest('action'), ['httptest.massenable', 'httptest.massdisable'])
357
363
&& hasRequest('group_httptestid') && is_array(getRequest('group_httptestid'))) {
358
-
$enable = (getRequest('action') === 'httptest.massenable');
359
-
$status = $enable ? HTTPTEST_STATUS_ACTIVE : HTTPTEST_STATUS_DISABLED;
360
-
$updated = 0;
361
-
$result = true;
362
-
364
+
$status = getRequest('action') === 'httptest.massenable' ? HTTPTEST_STATUS_ACTIVE : HTTPTEST_STATUS_DISABLED;
363
365
$upd_httptests = [];
364
366
365
367
foreach (getRequest('group_httptestid') as $httptestid) {
366
368
$upd_httptests[] = [
367
369
'httptestid' => $httptestid,
368
370
'status' => $status
369
371
];
370
372
}
371
373
372
-
if ($upd_httptests) {
373
-
$result = (bool) API::HttpTest()->update($upd_httptests);
374
-
}
374
+
$result = (bool) API::HttpTest()->update($upd_httptests);
375
375
376
376
$updated = count($upd_httptests);
377
377
378
-
$messageSuccess = $enable
379
-
? _n('Web scenario enabled', 'Web scenarios enabled', $updated)
380
-
: _n('Web scenario disabled', 'Web scenarios disabled', $updated);
381
-
$messageFailed = $enable
382
-
? _n('Cannot enable web scenario', 'Cannot enable web scenarios', $updated)
383
-
: _n('Cannot disable web scenario', 'Cannot disable web scenarios', $updated);
384
-
385
378
if ($result) {
386
379
uncheckTableRows(getRequest('hostid'));
380
+
381
+
$message = $status == HTTPTEST_STATUS_ACTIVE
382
+
? _n('Web scenario enabled', 'Web scenarios enabled', $updated)
383
+
: _n('Web scenario disabled', 'Web scenarios disabled', $updated);
384
+
385
+
CMessageHelper::setSuccessTitle($message);
387
386
}
387
+
else {
388
+
$message = $status == HTTPTEST_STATUS_ACTIVE
389
+
? _n('Cannot enable web scenario', 'Cannot enable web scenarios', $updated)
390
+
: _n('Cannot disable web scenario', 'Cannot disable web scenarios', $updated);
388
391
389
-
show_messages($result, $messageSuccess, $messageFailed);
392
+
CMessageHelper::setErrorTitle($message);
393
+
}
394
+
395
+
if (hasRequest('backurl')) {
396
+
$response = new CControllerResponseRedirect(getRequest('backurl'));
397
+
$response->redirect();
398
+
}
390
399
}
391
400
elseif (hasRequest('action') && getRequest('action') === 'httptest.massclearhistory'
392
401
&& hasRequest('group_httptestid') && is_array(getRequest('group_httptestid'))
393
402
&& getRequest('group_httptestid')) {
394
403
$result = deleteHistoryByHttpTestIds(getRequest('group_httptestid'));
395
404
396
405
if ($result) {
397
406
uncheckTableRows(getRequest('hostid'));
398
407
}
399
408