1<?php
2/*
3** Zabbix
4** Copyright (C) 2001-2021 Zabbix SIA
5**
6** This program is free software; you can redistribute it and/or modify
7** it under the terms of the GNU General Public License as published by
8** the Free Software Foundation; either version 2 of the License, or
9** (at your option) any later version.
10**
11** This program is distributed in the hope that it will be useful,
12** but WITHOUT ANY WARRANTY; without even the implied warranty of
13** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14** GNU General Public License for more details.
15**
16** You should have received a copy of the GNU General Public License
17** along with this program; if not, write to the Free Software
18** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19**/
20
21
22/**
23 * Validate import data from Zabbix 5.2.x.
24 */
25class C52XmlValidator extends CXmlValidatorGeneral {
26
27	private $PREPROCESSING_STEP_TYPE = [
28		CXmlConstantValue::MULTIPLIER => CXmlConstantName::MULTIPLIER,
29		CXmlConstantValue::RTRIM => CXmlConstantName::RTRIM,
30		CXmlConstantValue::LTRIM => CXmlConstantName::LTRIM,
31		CXmlConstantValue::TRIM => CXmlConstantName::TRIM,
32		CXmlConstantValue::REGEX => CXmlConstantName::REGEX,
33		CXmlConstantValue::BOOL_TO_DECIMAL => CXmlConstantName::BOOL_TO_DECIMAL,
34		CXmlConstantValue::OCTAL_TO_DECIMAL => CXmlConstantName::OCTAL_TO_DECIMAL,
35		CXmlConstantValue::HEX_TO_DECIMAL => CXmlConstantName::HEX_TO_DECIMAL,
36		CXmlConstantValue::SIMPLE_CHANGE => CXmlConstantName::SIMPLE_CHANGE,
37		CXmlConstantValue::CHANGE_PER_SECOND => CXmlConstantName::CHANGE_PER_SECOND,
38		CXmlConstantValue::XMLPATH => CXmlConstantName::XMLPATH,
39		CXmlConstantValue::JSONPATH => CXmlConstantName::JSONPATH,
40		CXmlConstantValue::IN_RANGE => CXmlConstantName::IN_RANGE,
41		CXmlConstantValue::MATCHES_REGEX => CXmlConstantName::MATCHES_REGEX,
42		CXmlConstantValue::NOT_MATCHES_REGEX => CXmlConstantName::NOT_MATCHES_REGEX,
43		CXmlConstantValue::CHECK_JSON_ERROR => CXmlConstantName::CHECK_JSON_ERROR,
44		CXmlConstantValue::CHECK_XML_ERROR => CXmlConstantName::CHECK_XML_ERROR,
45		CXmlConstantValue::CHECK_REGEX_ERROR => CXmlConstantName::CHECK_REGEX_ERROR,
46		CXmlConstantValue::CHECK_NOT_SUPPORTED => CXmlConstantName::CHECK_NOT_SUPPORTED,
47		CXmlConstantValue::DISCARD_UNCHANGED => CXmlConstantName::DISCARD_UNCHANGED,
48		CXmlConstantValue::DISCARD_UNCHANGED_HEARTBEAT => CXmlConstantName::DISCARD_UNCHANGED_HEARTBEAT,
49		CXmlConstantValue::JAVASCRIPT => CXmlConstantName::JAVASCRIPT,
50		CXmlConstantValue::PROMETHEUS_PATTERN => CXmlConstantName::PROMETHEUS_PATTERN,
51		CXmlConstantValue::PROMETHEUS_TO_JSON => CXmlConstantName::PROMETHEUS_TO_JSON,
52		CXmlConstantValue::CSV_TO_JSON => CXmlConstantName::CSV_TO_JSON,
53		CXmlConstantValue::STR_REPLACE => CXmlConstantName::STR_REPLACE
54	];
55
56	private $PREPROCESSING_STEP_TYPE_DRULE = [
57		CXmlConstantValue::REGEX => CXmlConstantName::REGEX,
58		CXmlConstantValue::XMLPATH => CXmlConstantName::XMLPATH,
59		CXmlConstantValue::JSONPATH => CXmlConstantName::JSONPATH,
60		CXmlConstantValue::NOT_MATCHES_REGEX => CXmlConstantName::NOT_MATCHES_REGEX,
61		CXmlConstantValue::CHECK_JSON_ERROR => CXmlConstantName::CHECK_JSON_ERROR,
62		CXmlConstantValue::CHECK_XML_ERROR => CXmlConstantName::CHECK_XML_ERROR,
63		CXmlConstantValue::DISCARD_UNCHANGED_HEARTBEAT => CXmlConstantName::DISCARD_UNCHANGED_HEARTBEAT,
64		CXmlConstantValue::JAVASCRIPT => CXmlConstantName::JAVASCRIPT,
65		CXmlConstantValue::PROMETHEUS_TO_JSON => CXmlConstantName::PROMETHEUS_TO_JSON,
66		CXmlConstantValue::CSV_TO_JSON => CXmlConstantName::CSV_TO_JSON,
67		CXmlConstantValue::STR_REPLACE => CXmlConstantName::STR_REPLACE
68	];
69
70	private $GRAPH_GRAPH_ITEM_CALC_FNC = [
71		CXmlConstantValue::MIN => CXmlConstantName::MIN,
72		CXmlConstantValue::AVG => CXmlConstantName::AVG,
73		CXmlConstantValue::MAX => CXmlConstantName::MAX,
74		CXmlConstantValue::ALL => CXmlConstantName::ALL,
75		CXmlConstantValue::LAST => CXmlConstantName::LAST
76	];
77
78	private $GRAPH_GRAPH_ITEM_DRAWTYPE = [
79		CXmlConstantValue::SINGLE_LINE => CXmlConstantName::SINGLE_LINE,
80		CXmlConstantValue::FILLED_REGION => CXmlConstantName::FILLED_REGION,
81		CXmlConstantValue::BOLD_LINE => CXmlConstantName::BOLD_LINE,
82		CXmlConstantValue::DOTTED_LINE => CXmlConstantName::DOTTED_LINE,
83		CXmlConstantValue::DASHED_LINE => CXmlConstantName::DASHED_LINE,
84		CXmlConstantValue::GRADIENT_LINE => CXmlConstantName::GRADIENT_LINE
85	];
86
87	private $GRAPH_TYPE = [
88		CXmlConstantValue::NORMAL => CXmlConstantName::NORMAL,
89		CXmlConstantValue::STACKED => CXmlConstantName::STACKED,
90		CXmlConstantValue::PIE => CXmlConstantName::PIE,
91		CXmlConstantValue::EXPLODED => CXmlConstantName::EXPLODED
92	];
93
94	private $GRAPH_Y_TYPE = [
95		CXmlConstantValue::CALCULATED => CXmlConstantName::CALCULATED,
96		CXmlConstantValue::FIXED => CXmlConstantName::FIXED,
97		CXmlConstantValue::ITEM => CXmlConstantName::ITEM
98	];
99
100	private $GRAPH_GRAPH_ITEM_YAXISSIDE = [
101		CXmlConstantValue::LEFT => CXmlConstantName::LEFT,
102		CXmlConstantValue::RIGHT => CXmlConstantName::RIGHT
103	];
104
105	private $GRAPH_GRAPH_ITEM_TYPE = [
106		CXmlConstantValue::SIMPLE => CXmlConstantName::SIMPLE,
107		CXmlConstantValue::GRAPH_SUM => CXmlConstantName::GRAPH_SUM
108	];
109
110	private $ITEM_INVENTORY_LINK = [
111		CXmlConstantValue::NONE => CXmlConstantName::NONE,
112		CXmlConstantValue::ALIAS => CXmlConstantName::ALIAS,
113		CXmlConstantValue::ASSET_TAG => CXmlConstantName::ASSET_TAG,
114		CXmlConstantValue::CHASSIS => CXmlConstantName::CHASSIS,
115		CXmlConstantValue::CONTACT => CXmlConstantName::CONTACT,
116		CXmlConstantValue::CONTRACT_NUMBER => CXmlConstantName::CONTRACT_NUMBER,
117		CXmlConstantValue::DATE_HW_DECOMM => CXmlConstantName::DATE_HW_DECOMM,
118		CXmlConstantValue::DATE_HW_EXPIRY => CXmlConstantName::DATE_HW_EXPIRY,
119		CXmlConstantValue::DATE_HW_INSTALL => CXmlConstantName::DATE_HW_INSTALL,
120		CXmlConstantValue::DATE_HW_PURCHASE => CXmlConstantName::DATE_HW_PURCHASE,
121		CXmlConstantValue::DEPLOYMENT_STATUS => CXmlConstantName::DEPLOYMENT_STATUS,
122		CXmlConstantValue::HARDWARE => CXmlConstantName::HARDWARE,
123		CXmlConstantValue::HARDWARE_FULL => CXmlConstantName::HARDWARE_FULL,
124		CXmlConstantValue::HOST_NETMASK => CXmlConstantName::HOST_NETMASK,
125		CXmlConstantValue::HOST_NETWORKS => CXmlConstantName::HOST_NETWORKS,
126		CXmlConstantValue::HOST_ROUTER => CXmlConstantName::HOST_ROUTER,
127		CXmlConstantValue::HW_ARCH => CXmlConstantName::HW_ARCH,
128		CXmlConstantValue::INSTALLER_NAME => CXmlConstantName::INSTALLER_NAME,
129		CXmlConstantValue::LOCATION => CXmlConstantName::LOCATION,
130		CXmlConstantValue::LOCATION_LAT => CXmlConstantName::LOCATION_LAT,
131		CXmlConstantValue::LOCATION_LON => CXmlConstantName::LOCATION_LON,
132		CXmlConstantValue::MACADDRESS_A => CXmlConstantName::MACADDRESS_A,
133		CXmlConstantValue::MACADDRESS_B => CXmlConstantName::MACADDRESS_B,
134		CXmlConstantValue::MODEL => CXmlConstantName::MODEL,
135		CXmlConstantValue::NAME => CXmlConstantName::NAME,
136		CXmlConstantValue::NOTES => CXmlConstantName::NOTES,
137		CXmlConstantValue::OOB_IP => CXmlConstantName::OOB_IP,
138		CXmlConstantValue::OOB_NETMASK => CXmlConstantName::OOB_NETMASK,
139		CXmlConstantValue::OOB_ROUTER => CXmlConstantName::OOB_ROUTER,
140		CXmlConstantValue::OS => CXmlConstantName::OS,
141		CXmlConstantValue::OS_FULL => CXmlConstantName::OS_FULL,
142		CXmlConstantValue::OS_SHORT => CXmlConstantName::OS_SHORT,
143		CXmlConstantValue::POC_1_CELL => CXmlConstantName::POC_1_CELL,
144		CXmlConstantValue::POC_1_EMAIL => CXmlConstantName::POC_1_EMAIL,
145		CXmlConstantValue::POC_1_NAME => CXmlConstantName::POC_1_NAME,
146		CXmlConstantValue::POC_1_NOTES => CXmlConstantName::POC_1_NOTES,
147		CXmlConstantValue::POC_1_PHONE_A => CXmlConstantName::POC_1_PHONE_A,
148		CXmlConstantValue::POC_1_PHONE_B => CXmlConstantName::POC_1_PHONE_B,
149		CXmlConstantValue::POC_1_SCREEN => CXmlConstantName::POC_1_SCREEN,
150		CXmlConstantValue::POC_2_CELL => CXmlConstantName::POC_2_CELL,
151		CXmlConstantValue::POC_2_EMAIL => CXmlConstantName::POC_2_EMAIL,
152		CXmlConstantValue::POC_2_NAME => CXmlConstantName::POC_2_NAME,
153		CXmlConstantValue::POC_2_NOTES => CXmlConstantName::POC_2_NOTES,
154		CXmlConstantValue::POC_2_PHONE_A => CXmlConstantName::POC_2_PHONE_A,
155		CXmlConstantValue::POC_2_PHONE_B => CXmlConstantName::POC_2_PHONE_B,
156		CXmlConstantValue::POC_2_SCREEN => CXmlConstantName::POC_2_SCREEN,
157		CXmlConstantValue::SERIALNO_A => CXmlConstantName::SERIALNO_A,
158		CXmlConstantValue::SERIALNO_B => CXmlConstantName::SERIALNO_B,
159		CXmlConstantValue::SITE_ADDRESS_A => CXmlConstantName::SITE_ADDRESS_A,
160		CXmlConstantValue::SITE_ADDRESS_B => CXmlConstantName::SITE_ADDRESS_B,
161		CXmlConstantValue::SITE_ADDRESS_C => CXmlConstantName::SITE_ADDRESS_C,
162		CXmlConstantValue::SITE_CITY => CXmlConstantName::SITE_CITY,
163		CXmlConstantValue::SITE_COUNTRY => CXmlConstantName::SITE_COUNTRY,
164		CXmlConstantValue::SITE_NOTES => CXmlConstantName::SITE_NOTES,
165		CXmlConstantValue::SITE_RACK => CXmlConstantName::SITE_RACK,
166		CXmlConstantValue::SITE_STATE => CXmlConstantName::SITE_STATE,
167		CXmlConstantValue::SITE_ZIP => CXmlConstantName::SITE_ZIP,
168		CXmlConstantValue::SOFTWARE => CXmlConstantName::SOFTWARE,
169		CXmlConstantValue::SOFTWARE_APP_A => CXmlConstantName::SOFTWARE_APP_A,
170		CXmlConstantValue::SOFTWARE_APP_B => CXmlConstantName::SOFTWARE_APP_B,
171		CXmlConstantValue::SOFTWARE_APP_C => CXmlConstantName::SOFTWARE_APP_C,
172		CXmlConstantValue::SOFTWARE_APP_D => CXmlConstantName::SOFTWARE_APP_D,
173		CXmlConstantValue::SOFTWARE_APP_E => CXmlConstantName::SOFTWARE_APP_E,
174		CXmlConstantValue::SOFTWARE_FULL => CXmlConstantName::SOFTWARE_FULL,
175		CXmlConstantValue::TAG => CXmlConstantName::TAG,
176		CXmlConstantValue::TYPE => CXmlConstantName::TYPE,
177		CXmlConstantValue::TYPE_FULL => CXmlConstantName::TYPE_FULL,
178		CXmlConstantValue::URL_A => CXmlConstantName::URL_A,
179		CXmlConstantValue::URL_B => CXmlConstantName::URL_B,
180		CXmlConstantValue::URL_C => CXmlConstantName::URL_C,
181		CXmlConstantValue::VENDOR => CXmlConstantName::VENDOR
182	];
183
184	private $ITEM_POST_TYPE = [
185		CXmlConstantValue::RAW => CXmlConstantName::RAW,
186		CXmlConstantValue::JSON => CXmlConstantName::JSON,
187		CXmlConstantValue::XML => CXmlConstantName::XML
188	];
189
190	private $ITEM_PREPROCESSING_ERROR_HANDLER = [
191		CXmlConstantValue::ORIGINAL_ERROR => CXmlConstantName::ORIGINAL_ERROR,
192		CXmlConstantValue::DISCARD_VALUE => CXmlConstantName::DISCARD_VALUE,
193		CXmlConstantValue::CUSTOM_VALUE => CXmlConstantName::CUSTOM_VALUE,
194		CXmlConstantValue::CUSTOM_ERROR => CXmlConstantName::CUSTOM_ERROR
195	];
196
197	private $ITEM_REQUEST_METHOD = [
198		CXmlConstantValue::GET => CXmlConstantName::GET,
199		CXmlConstantValue::POST => CXmlConstantName::POST,
200		CXmlConstantValue::PUT => CXmlConstantName::PUT,
201		CXmlConstantValue::HEAD => CXmlConstantName::HEAD
202	];
203
204	private $ITEM_RETRIEVE_MODE = [
205		CXmlConstantValue::BODY => CXmlConstantName::BODY,
206		CXmlConstantValue::HEADERS => CXmlConstantName::HEADERS,
207		CXmlConstantValue::BOTH => CXmlConstantName::BOTH
208	];
209
210	private $ITEM_SNMPV3_SECURITYLEVEL = [
211		CXmlConstantValue::NOAUTHNOPRIV => CXmlConstantName::NOAUTHNOPRIV,
212		CXmlConstantValue::AUTHNOPRIV => CXmlConstantName::AUTHNOPRIV,
213		CXmlConstantValue::AUTHPRIV => CXmlConstantName::AUTHPRIV
214	];
215
216	private $ITEM_TYPE = [
217		CXmlConstantValue::ITEM_TYPE_ZABBIX_PASSIVE => CXmlConstantName::ZABBIX_PASSIVE,
218		CXmlConstantValue::ITEM_TYPE_TRAP => CXmlConstantName::TRAP,
219		CXmlConstantValue::ITEM_TYPE_SIMPLE => CXmlConstantName::SIMPLE,
220		CXmlConstantValue::ITEM_TYPE_INTERNAL => CXmlConstantName::INTERNAL,
221		CXmlConstantValue::ITEM_TYPE_ZABBIX_ACTIVE => CXmlConstantName::ZABBIX_ACTIVE,
222		CXmlConstantValue::ITEM_TYPE_AGGREGATE => CXmlConstantName::AGGREGATE,
223		CXmlConstantValue::ITEM_TYPE_EXTERNAL => CXmlConstantName::EXTERNAL,
224		CXmlConstantValue::ITEM_TYPE_ODBC => CXmlConstantName::ODBC,
225		CXmlConstantValue::ITEM_TYPE_IPMI => CXmlConstantName::IPMI,
226		CXmlConstantValue::ITEM_TYPE_SSH => CXmlConstantName::SSH,
227		CXmlConstantValue::ITEM_TYPE_TELNET => CXmlConstantName::TELNET,
228		CXmlConstantValue::ITEM_TYPE_CALCULATED => CXmlConstantName::CALCULATED,
229		CXmlConstantValue::ITEM_TYPE_JMX => CXmlConstantName::JMX,
230		CXmlConstantValue::ITEM_TYPE_SNMP_TRAP => CXmlConstantName::SNMP_TRAP,
231		CXmlConstantValue::ITEM_TYPE_DEPENDENT => CXmlConstantName::DEPENDENT,
232		CXmlConstantValue::ITEM_TYPE_HTTP_AGENT => CXmlConstantName::HTTP_AGENT,
233		CXmlConstantValue::ITEM_TYPE_SNMP => CXmlConstantName::SNMP_AGENT,
234		CXmlConstantValue::ITEM_TYPE_SCRIPT => CXmlConstantName::SCRIPT
235	];
236
237	private $ITEM_TYPE_DRULE = [
238		CXmlConstantValue::ITEM_TYPE_ZABBIX_PASSIVE => CXmlConstantName::ZABBIX_PASSIVE,
239		CXmlConstantValue::ITEM_TYPE_TRAP => CXmlConstantName::TRAP,
240		CXmlConstantValue::ITEM_TYPE_SIMPLE => CXmlConstantName::SIMPLE,
241		CXmlConstantValue::ITEM_TYPE_INTERNAL => CXmlConstantName::INTERNAL,
242		CXmlConstantValue::ITEM_TYPE_ZABBIX_ACTIVE => CXmlConstantName::ZABBIX_ACTIVE,
243		CXmlConstantValue::ITEM_TYPE_EXTERNAL => CXmlConstantName::EXTERNAL,
244		CXmlConstantValue::ITEM_TYPE_ODBC => CXmlConstantName::ODBC,
245		CXmlConstantValue::ITEM_TYPE_IPMI => CXmlConstantName::IPMI,
246		CXmlConstantValue::ITEM_TYPE_SSH => CXmlConstantName::SSH,
247		CXmlConstantValue::ITEM_TYPE_TELNET => CXmlConstantName::TELNET,
248		CXmlConstantValue::ITEM_TYPE_JMX => CXmlConstantName::JMX,
249		CXmlConstantValue::ITEM_TYPE_DEPENDENT => CXmlConstantName::DEPENDENT,
250		CXmlConstantValue::ITEM_TYPE_HTTP_AGENT => CXmlConstantName::HTTP_AGENT,
251		CXmlConstantValue::ITEM_TYPE_SNMP => CXmlConstantName::SNMP_AGENT,
252		CXmlConstantValue::ITEM_TYPE_SCRIPT => CXmlConstantName::SCRIPT
253	];
254
255	private $ITEM_VALUE_TYPE = [
256		CXmlConstantValue::FLOAT => CXmlConstantName::FLOAT,
257		CXmlConstantValue::CHAR => CXmlConstantName::CHAR,
258		CXmlConstantValue::LOG => CXmlConstantName::LOG,
259		CXmlConstantValue::UNSIGNED => CXmlConstantName::UNSIGNED,
260		CXmlConstantValue::TEXT => CXmlConstantName::TEXT
261	];
262
263	private $TRIGGER_PRIORITY = [
264		CXmlConstantValue::NOT_CLASSIFIED => CXmlConstantName::NOT_CLASSIFIED,
265		CXmlConstantValue::INFO => CXmlConstantName::INFO,
266		CXmlConstantValue::WARNING => CXmlConstantName::WARNING,
267		CXmlConstantValue::AVERAGE => CXmlConstantName::AVERAGE,
268		CXmlConstantValue::HIGH => CXmlConstantName::HIGH,
269		CXmlConstantValue::DISASTER => CXmlConstantName::DISASTER
270	];
271
272	private $TRIGGER_RECOVERY_MODE = [
273		CXmlConstantValue::TRIGGER_EXPRESSION => CXmlConstantName::EXPRESSION,
274		CXmlConstantValue::TRIGGER_RECOVERY_EXPRESSION => CXmlConstantName::RECOVERY_EXPRESSION,
275		CXmlConstantValue::TRIGGER_NONE => CXmlConstantName::NONE
276	];
277
278	private $MEDIA_TYPE = [
279		CXmlConstantValue::MEDIA_TYPE_EMAIL => CXmlConstantName::EMAIL,
280		CXmlConstantValue::MEDIA_TYPE_SCRIPT => CXmlConstantName::SCRIPT,
281		CXmlConstantValue::MEDIA_TYPE_SMS => CXmlConstantName::SMS,
282		CXmlConstantValue::MEDIA_TYPE_WEBHOOK => CXmlConstantName::WEBHOOK
283	];
284
285	private $SMTP_AUTHENTICATION = [
286		CXmlConstantValue::SMTP_AUTHENTICATION_NONE => CXmlConstantName::SMTP_AUTHENTICATION_NONE,
287		CXmlConstantValue::SMTP_AUTHENTICATION_PASSWORD => CXmlConstantName::SMTP_AUTHENTICATION_PASSWORD
288	];
289
290	private $EVENT_SOURCE = [
291		CXmlConstantValue::EVENT_SOURCE_TRIGGERS => CXmlConstantName::TRIGGERS,
292		CXmlConstantValue::EVENT_SOURCE_DISCOVERY => CXmlConstantName::DISCOVERY,
293		CXmlConstantValue::EVENT_SOURCE_AUTOREGISTRATION => CXmlConstantName::AUTOREGISTRATION,
294		CXmlConstantValue::EVENT_SOURCE_INTERNAL => CXmlConstantName::INTERNAL
295	];
296
297	private $OPERATION_MODE = [
298		CXmlConstantValue::OPERATION_MODE_PROBLEM => CXmlConstantName::PROBLEM,
299		CXmlConstantValue::OPERATION_MODE_RECOVERY => CXmlConstantName::RECOVERY,
300		CXmlConstantValue::OPERATION_MODE_UPDATE => CXmlConstantName::UPDATE
301	];
302
303	private $LLD_OVERRIDE_STOP = [
304		CXmlConstantValue::LLD_OVERRIDE_STOP_NO => CXmlConstantName::LLD_OVERRIDE_STOP_NO,
305		CXmlConstantValue::LLD_OVERRIDE_STOP_YES => CXmlConstantName::LLD_OVERRIDE_STOP_YES
306	];
307
308	private $EVALTPYE = [
309		CXmlConstantValue::AND_OR => CXmlConstantName::AND_OR,
310		CXmlConstantValue::XML_AND => CXmlConstantName::XML_AND,
311		CXmlConstantValue::XML_OR => CXmlConstantName::XML_OR,
312		CXmlConstantValue::FORMULA => CXmlConstantName::FORMULA
313	];
314
315	private $FILTER_CONDITION_OPERATOR = [
316		CXmlConstantValue::CONDITION_MATCHES_REGEX => CXmlConstantName::MATCHES_REGEX,
317		CXmlConstantValue::CONDITION_NOT_MATCHES_REGEX => CXmlConstantName::NOT_MATCHES_REGEX
318	];
319
320	private $LLD_OVERRIDE_OPERATION_OBJECT = [
321		CXmlConstantValue::LLD_OVERRIDE_OPERATION_OBJECT_ITEM_PROTOTYPE => CXmlConstantName::LLD_OVERRIDE_OPERATION_OBJECT_ITEM_PROTOTYPE,
322		CXmlConstantValue::LLD_OVERRIDE_OPERATION_OBJECT_TRIGGER_PROTOTYPE => CXmlConstantName::LLD_OVERRIDE_OPERATION_OBJECT_TRIGGER_PROTOTYPE,
323		CXmlConstantValue::LLD_OVERRIDE_OPERATION_OBJECT_GRAPH_PROTOTYPE => CXmlConstantName::LLD_OVERRIDE_OPERATION_OBJECT_GRAPH_PROTOTYPE,
324		CXmlConstantValue::LLD_OVERRIDE_OPERATION_OBJECT_HOST_PROTOTYPE => CXmlConstantName::LLD_OVERRIDE_OPERATION_OBJECT_HOST_PROTOTYPE
325	];
326
327	private $CONDITION_OPERATOR = [
328		CXmlConstantValue::CONDITION_OPERATOR_EQUAL => CXmlConstantName::CONDITION_OPERATOR_EQUAL,
329		CXmlConstantValue::CONDITION_OPERATOR_NOT_EQUAL => CXmlConstantName::CONDITION_OPERATOR_NOT_EQUAL,
330		CXmlConstantValue::CONDITION_OPERATOR_LIKE => CXmlConstantName::CONDITION_OPERATOR_LIKE,
331		CXmlConstantValue::CONDITION_OPERATOR_NOT_LIKE => CXmlConstantName::CONDITION_OPERATOR_NOT_LIKE,
332		CXmlConstantValue::CONDITION_OPERATOR_REGEXP => CXmlConstantName::CONDITION_OPERATOR_REGEXP,
333		CXmlConstantValue::CONDITION_OPERATOR_NOT_REGEXP => CXmlConstantName::CONDITION_OPERATOR_NOT_REGEXP
334	];
335
336	private $INVENTORY_MODE = [
337		CXmlConstantValue::INV_MODE_DISABLED => CXmlConstantName::DISABLED,
338		CXmlConstantValue::INV_MODE_MANUAL => CXmlConstantName::MANUAL,
339		CXmlConstantValue::INV_MODE_AUTOMATIC => CXmlConstantName::AUTOMATIC
340	];
341
342	private $CUSTOM_INTERFACES = [
343		CXmlConstantValue::CUSTOM_INTERFACES_NO => CXmlConstantName::NO,
344		CXmlConstantValue::CUSTOM_INTERFACES_YES => CXmlConstantName::YES
345	];
346
347	private $DASHBOARD_WIDGET_TYPE = [
348		CXmlConstantValue::DASHBOARD_WIDGET_TYPE_CLOCK => CXmlConstantName::DASHBOARD_WIDGET_TYPE_CLOCK,
349		CXmlConstantValue::DASHBOARD_WIDGET_TYPE_GRAPH_CLASSIC => CXmlConstantName::DASHBOARD_WIDGET_TYPE_GRAPH_CLASSIC,
350		CXmlConstantValue::DASHBOARD_WIDGET_TYPE_GRAPH_PROTOTYPE => CXmlConstantName::DASHBOARD_WIDGET_TYPE_GRAPH_PROTOTYPE,
351		CXmlConstantValue::DASHBOARD_WIDGET_TYPE_PLAIN_TEXT => CXmlConstantName::DASHBOARD_WIDGET_TYPE_PLAIN_TEXT,
352		CXmlConstantValue::DASHBOARD_WIDGET_TYPE_URL => CXmlConstantName::DASHBOARD_WIDGET_TYPE_URL
353	];
354
355	private $DASHBOARD_WIDGET_FIELD_TYPE = [
356		CXmlConstantValue::DASHBOARD_WIDGET_FIELD_TYPE_INTEGER => CXmlConstantName::DASHBOARD_WIDGET_FIELD_TYPE_INTEGER,
357		CXmlConstantValue::DASHBOARD_WIDGET_FIELD_TYPE_STRING => CXmlConstantName::DASHBOARD_WIDGET_FIELD_TYPE_STRING,
358		CXmlConstantValue::DASHBOARD_WIDGET_FIELD_TYPE_HOST => CXmlConstantName::DASHBOARD_WIDGET_FIELD_TYPE_HOST,
359		CXmlConstantValue::DASHBOARD_WIDGET_FIELD_TYPE_ITEM => CXmlConstantName::DASHBOARD_WIDGET_FIELD_TYPE_ITEM,
360		CXmlConstantValue::DASHBOARD_WIDGET_FIELD_TYPE_ITEM_PROTOTYPE => CXmlConstantName::DASHBOARD_WIDGET_FIELD_TYPE_ITEM_PROTOTYPE,
361		CXmlConstantValue::DASHBOARD_WIDGET_FIELD_TYPE_GRAPH => CXmlConstantName::DASHBOARD_WIDGET_FIELD_TYPE_GRAPH,
362		CXmlConstantValue::DASHBOARD_WIDGET_FIELD_TYPE_GRAPH_PROTOTYPE => CXmlConstantName::DASHBOARD_WIDGET_FIELD_TYPE_GRAPH_PROTOTYPE
363	];
364
365	private $HTTP_TEST_AUTHENTICATION = [
366		CXmlConstantValue::NONE => CXmlConstantName::NONE,
367		CXmlConstantValue::BASIC => CXmlConstantName::BASIC,
368		CXmlConstantValue::NTLM => CXmlConstantName::NTLM,
369		CXmlConstantValue::KERBEROS => CXmlConstantName::KERBEROS
370	];
371
372	/**
373	 * Get validation rules schema.
374	 *
375	 * @return array
376	 */
377	public function getSchema() {
378		return ['type' => XML_ARRAY, 'rules' => [
379			'version' =>				['type' => XML_STRING | XML_REQUIRED],
380			'date' =>					['type' => XML_STRING, 'ex_validate' => [$this, 'validateDateTime']],
381			'groups' =>					['type' => XML_INDEXED_ARRAY, 'prefix' => 'group', 'rules' => [
382				'group' =>					['type' => XML_ARRAY, 'rules' => [
383					'name' =>					['type' => XML_STRING | XML_REQUIRED]
384				]]
385			]],
386			'hosts' =>					['type' => XML_INDEXED_ARRAY, 'prefix' => 'host', 'rules' => [
387				'host' =>					['type' => XML_ARRAY, 'rules' => [
388					'host' =>					['type' => XML_STRING | XML_REQUIRED],
389					'name' =>					['type' => XML_STRING, 'default' => ''],
390					'description' =>			['type' => XML_STRING, 'default' => ''],
391					'proxy' =>					['type' => XML_ARRAY, 'rules' => [
392						'name' =>					['type' => XML_STRING | XML_REQUIRED]
393					]],
394					'status' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::ENABLED, 'in' => [CXmlConstantValue::ENABLED => CXmlConstantName::ENABLED, CXmlConstantValue::DISABLED => CXmlConstantName::DISABLED]],
395					'ipmi_authtype' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::XML_DEFAULT, 'in' => [CXmlConstantValue::XML_DEFAULT => CXmlConstantName::XML_DEFAULT, CXmlConstantValue::NONE => CXmlConstantName::NONE, CXmlConstantValue::MD2 => CXmlConstantName::MD2, CXmlConstantValue::MD5 => CXmlConstantName::MD5, CXmlConstantValue::STRAIGHT => CXmlConstantName::STRAIGHT, CXmlConstantValue::OEM => CXmlConstantName::OEM, CXmlConstantValue::RMCP_PLUS => CXmlConstantName::RMCP_PLUS]],
396					'ipmi_privilege' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::USER, 'in' => [CXmlConstantValue::CALLBACK => CXmlConstantName::CALLBACK, CXmlConstantValue::USER => CXmlConstantName::USER, CXmlConstantValue::OPERATOR => CXmlConstantName::OPERATOR, CXmlConstantValue::ADMIN => CXmlConstantName::ADMIN, CXmlConstantValue::OEM => CXmlConstantName::OEM]],
397					'ipmi_username' =>			['type' => XML_STRING, 'default' => ''],
398					'ipmi_password' =>			['type' => XML_STRING, 'default' => ''],
399					'tls_connect' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NO_ENCRYPTION, 'in' => [CXmlConstantValue::NO_ENCRYPTION => CXmlConstantName::NO_ENCRYPTION, CXmlConstantValue::TLS_PSK => CXmlConstantName::TLS_PSK, CXmlConstantValue::TLS_CERTIFICATE => CXmlConstantName::TLS_CERTIFICATE]],
400					'tls_accept' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'option', 'default' => CXmlConstantValue::NO_ENCRYPTION, 'export' => [$this, 'hostTlsAcceptExport'], 'rules' => [
401						'option' =>					['type' => XML_STRING, 'in' => [CXmlConstantValue::NO_ENCRYPTION => CXmlConstantName::NO_ENCRYPTION, CXmlConstantValue::TLS_PSK => CXmlConstantName::TLS_PSK, CXmlConstantValue::TLS_CERTIFICATE => CXmlConstantName::TLS_CERTIFICATE]]
402					]],
403					'tls_issuer' =>				['type' => XML_STRING, 'default' => ''],
404					'tls_subject' =>			['type' => XML_STRING, 'default' => ''],
405					'tls_psk_identity' =>		['type' => XML_STRING, 'default' => ''],
406					'tls_psk' =>				['type' => XML_STRING, 'default' => ''],
407					'templates' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'template', 'rules' => [
408						'template' =>				['type' => XML_ARRAY, 'rules' => [
409							'name' =>					['type' => XML_STRING | XML_REQUIRED]
410						]]
411					]],
412					'groups' =>					['type' => XML_INDEXED_ARRAY | XML_REQUIRED, 'prefix' => 'group', 'rules' => [
413						'group' =>					['type' => XML_ARRAY, 'rules' => [
414							'name' =>					['type' => XML_STRING | XML_REQUIRED]
415						]]
416					]],
417					'interfaces' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'interface', 'rules' => [
418						'interface' =>				['type' => XML_ARRAY, 'rules' => [
419							'default' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::YES, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
420							'type' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::ZABBIX, 'in' => [CXmlConstantValue::ZABBIX => CXmlConstantName::ZABBIX, CXmlConstantValue::SNMP => CXmlConstantName::SNMP, CXmlConstantValue::IPMI => CXmlConstantName::IPMI, CXmlConstantValue::JMX => CXmlConstantName::JMX]],
421							'useip' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::YES, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
422							'ip' =>						['type' => XML_STRING, 'default' => '127.0.0.1'],
423							'dns' =>					['type' => XML_STRING, 'default' => ''],
424							'port' =>					['type' => XML_STRING, 'default' => '10050'],
425							'details' =>				['type' => XML_ARRAY, 'rules' => [
426								'version' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::SNMP_V2, 'in' => [CXmlConstantValue::SNMP_V1 => CXmlConstantName::SNMPV1, CXmlConstantValue::SNMP_V2 => CXmlConstantName::SNMPV2, CXmlConstantValue::SNMP_V3 => CXmlConstantName::SNMPV3]],
427								'community' =>				['type' => XML_STRING, 'default' => ''],
428								'contextname' =>			['type' => XML_STRING, 'default' => ''],
429								'securityname' =>			['type' => XML_STRING, 'default' => ''],
430								'securitylevel' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NOAUTHNOPRIV, 'in' => $this->ITEM_SNMPV3_SECURITYLEVEL],
431								'authprotocol' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::SNMPV3_MD5, 'in' => [CXmlConstantValue::SNMPV3_MD5 => CXmlConstantName::MD5, CXmlConstantValue::SNMPV3_SHA1 => CXmlConstantName::SHA]],
432								'authpassphrase' =>			['type' => XML_STRING, 'default' => ''],
433								'privprotocol' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::SNMPV3_DES, 'in' => [CXmlConstantValue::SNMPV3_DES => CXmlConstantName::DES, CXmlConstantValue::SNMPV3_AES128 => CXmlConstantName::AES]],
434								'privpassphrase' =>			['type' => XML_STRING, 'default' => ''],
435								'bulk' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::YES, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]]
436							]],
437							'interface_ref' =>			['type' => XML_STRING | XML_REQUIRED]
438						]]
439					]],
440					'applications' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'application', 'rules' => [
441						'application' =>			['type' => XML_ARRAY, 'rules' => [
442							'name' =>					['type' => XML_STRING | XML_REQUIRED]
443						]]
444					]],
445					'items' =>					['type' => XML_INDEXED_ARRAY, 'prefix' => 'item', 'rules' => [
446						'item' =>					['type' => XML_ARRAY, 'rules' => [
447							'name' =>					['type' => XML_STRING | XML_REQUIRED],
448							'type' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::ITEM_TYPE_ZABBIX_PASSIVE, 'in' => $this->ITEM_TYPE],
449							'snmp_oid' =>				['type' => XML_STRING, 'default' => ''],
450							'key' =>					['type' => XML_STRING | XML_REQUIRED],
451							'delay' =>					['type' => XML_STRING, 'default' => '1m'],
452							'history' =>				['type' => XML_STRING, 'default' => '90d'],
453							'trends' =>					['type' => XML_STRING, 'default' => '365d'],
454							'status' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::ENABLED, 'in' => [CXmlConstantValue::ENABLED => CXmlConstantName::ENABLED, CXmlConstantValue::DISABLED => CXmlConstantName::DISABLED]],
455							'value_type' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::UNSIGNED, 'in' => $this->ITEM_VALUE_TYPE],
456							'allowed_hosts' =>			['type' => XML_STRING, 'default' => ''],
457							'units' =>					['type' => XML_STRING, 'default' => ''],
458							'params' =>					['type' => XML_STRING, 'default' => ''],
459							'ipmi_sensor' =>			['type' => XML_STRING, 'default' => ''],
460							'authtype' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::NONE, 'ex_validate' => [$this, 'validateAuthType'], 'ex_rules' => [$this, 'getAuthTypeExtendedRules'], 'export' => [$this, 'itemAuthtypeExport']],
461							'username' =>				['type' => XML_STRING, 'default' => ''],
462							'password' =>				['type' => XML_STRING, 'default' => ''],
463							'publickey' =>				['type' => XML_STRING, 'default' => ''],
464							'privatekey' =>				['type' => XML_STRING, 'default' => ''],
465							'description' =>			['type' => XML_STRING, 'default' => ''],
466							'inventory_link' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NONE, 'in' => $this->ITEM_INVENTORY_LINK],
467							'applications' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'application', 'rules' => [
468								'application' =>			['type' => XML_ARRAY, 'rules' => [
469									'name' =>					['type' => XML_STRING | XML_REQUIRED]
470								]]
471							]],
472							'valuemap' =>				['type' => XML_ARRAY, 'rules' => [
473								'name' =>					['type' => XML_STRING | XML_REQUIRED]
474							]],
475							'logtimefmt' =>				['type' => XML_STRING, 'default' => ''],
476							'preprocessing' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'step', 'rules' => [
477								'step' =>					['type' => XML_ARRAY, 'rules' => [
478									'type' =>					['type' => XML_STRING | XML_REQUIRED, 'in' => $this->PREPROCESSING_STEP_TYPE],
479									'parameters' =>				['type' => XML_INDEXED_ARRAY | XML_REQUIRED, 'prefix' => 'parameter', 'export' => [$this, 'preprocessingParametersExport'], 'rules' => [
480										'parameter' =>				['type' => XML_STRING, 'flags' => CImportDataNormalizer::EOL_LF]
481									]],
482									'error_handler' =>			['type' => XML_STRING, 'ex_default' => [$this, 'defaultPreprocErrHandler'], 'ex_validate' => [$this, 'validatePreprocErrHandler'], 'in' => $this->ITEM_PREPROCESSING_ERROR_HANDLER],
483									'error_handler_params' =>	['type' => XML_STRING, 'default' => '']
484								]]
485							]],
486							'interface_ref' =>			['type' => XML_STRING],
487							'jmx_endpoint' =>			['type' => XML_STRING, 'default' => ''],
488							'master_item' =>			['type' => XML_ARRAY, 'ex_validate' => [$this, 'validateMasterItem'], 'rules' => [
489								'key' =>					['type' => XML_STRING | XML_REQUIRED]
490							]],
491							'timeout' =>				['type' => XML_STRING, 'default' => '3s'],
492							'url' =>					['type' => XML_STRING, 'default' => ''],
493							'query_fields' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'query_field', 'rules' => [
494								'query_field' =>			['type' => XML_ARRAY, 'rules' => [
495									'name' =>					['type' => XML_STRING | XML_REQUIRED],
496									'value' =>					['type' => XML_STRING, 'default' => '']
497								]]
498							]],
499							'parameters' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'parameter', 'rules' => [
500								'parameter' =>			['type' => XML_ARRAY, 'rules' => [
501									'name' =>					['type' => XML_STRING | XML_REQUIRED],
502									'value' =>					['type' => XML_STRING, 'default' => '']
503								]]
504							]],
505							'posts' =>					['type' => XML_STRING, 'default' => ''],
506							'status_codes' =>			['type' => XML_STRING, 'default' => '200'],
507							'follow_redirects' =>		['type' => XML_STRING, 'default' => CXmlConstantValue::YES, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
508							'post_type' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::RAW, 'in' => $this->ITEM_POST_TYPE],
509							'http_proxy' =>				['type' => XML_STRING, 'default' => ''],
510							'headers' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'header', 'rules' => [
511								'header' =>					['type' => XML_ARRAY, 'rules' => [
512									'name' =>					['type' => XML_STRING | XML_REQUIRED],
513									'value' =>					['type' => XML_STRING | XML_REQUIRED]
514								]]
515							]],
516							'retrieve_mode' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::BODY, 'in' => $this->ITEM_RETRIEVE_MODE],
517							'request_method' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::GET, 'in' => $this->ITEM_REQUEST_METHOD],
518							'output_format' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::OUTPUT_FORMAT_RAW, 'in' => [CXmlConstantValue::OUTPUT_FORMAT_RAW => CXmlConstantName::RAW, CXmlConstantValue::OUTPUT_FORMAT_JSON => CXmlConstantName::JSON]],
519							'allow_traps' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
520							'ssl_cert_file' =>			['type' => XML_STRING, 'default' => ''],
521							'ssl_key_file' =>			['type' => XML_STRING, 'default' => ''],
522							'ssl_key_password' =>		['type' => XML_STRING, 'default' => ''],
523							'verify_peer' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
524							'verify_host' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
525							'triggers' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'trigger', 'rules' => [
526								'trigger' =>				['type' => XML_ARRAY, 'rules' => [
527									'expression' =>				['type' => XML_STRING | XML_REQUIRED],
528									'recovery_mode' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::TRIGGER_EXPRESSION, 'in' => $this->TRIGGER_RECOVERY_MODE],
529									'recovery_expression' =>	['type' => XML_STRING, 'default' => ''],
530									'correlation_mode' =>		['type' => XML_STRING, 'default' => CXmlConstantValue::TRIGGER_DISABLED, 'in' => [CXmlConstantValue::TRIGGER_DISABLED => CXmlConstantName::DISABLED, CXmlConstantValue::TRIGGER_TAG_VALUE => CXmlConstantName::TAG_VALUE]],
531									'correlation_tag' =>		['type' => XML_STRING, 'default' => ''],
532									'name' =>					['type' => XML_STRING | XML_REQUIRED],
533									'event_name' =>				['type' => XML_STRING, 'default' => ''],
534									'opdata' =>					['type' => XML_STRING, 'default' => ''],
535									'url' =>					['type' => XML_STRING, 'default' => ''],
536									'status' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::ENABLED, 'in' => [CXmlConstantValue::ENABLED => CXmlConstantName::ENABLED, CXmlConstantValue::DISABLED => CXmlConstantName::DISABLED]],
537									'priority' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::NOT_CLASSIFIED, 'in' => $this->TRIGGER_PRIORITY],
538									'description' =>			['type' => XML_STRING, 'default' => ''],
539									'type' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::SINGLE, 'in' => [CXmlConstantValue::SINGLE => CXmlConstantName::SINGLE, CXmlConstantValue::MULTIPLE => CXmlConstantName::MULTIPLE]],
540									'manual_close' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
541									'dependencies' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'dependency', 'rules' => [
542										'dependency' =>				['type' => XML_ARRAY, 'rules' => [
543											'name' =>					['type' => XML_STRING | XML_REQUIRED],
544											'expression' =>				['type' => XML_STRING | XML_REQUIRED],
545											'recovery_expression' =>	['type' => XML_STRING, 'default' => '']
546										]]
547									]],
548									'tags' =>					['type' => XML_INDEXED_ARRAY, 'prefix' => 'tag', 'rules' => [
549										'tag' =>					['type' => XML_ARRAY, 'rules' => [
550											'tag' =>					['type' => XML_STRING | XML_REQUIRED],
551											'value' =>					['type' => XML_STRING, 'default' => '']
552										]]
553									]]
554								]]
555							]]
556						]]
557					]],
558					'discovery_rules' =>		['type' => XML_INDEXED_ARRAY, 'prefix' => 'discovery_rule', 'rules' => [
559						'discovery_rule' =>			['type' => XML_ARRAY, 'rules' => [
560							'name' =>					['type' => XML_STRING | XML_REQUIRED],
561							'type' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::ITEM_TYPE_ZABBIX_PASSIVE, 'in' => $this->ITEM_TYPE_DRULE],
562							'snmp_oid' =>				['type' => XML_STRING, 'default' => ''],
563							'key' =>					['type' => XML_STRING | XML_REQUIRED],
564							'delay' =>					['type' => XML_STRING, 'default' => '1m'],
565							'status' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::ENABLED, 'in' => [CXmlConstantValue::ENABLED => CXmlConstantName::ENABLED, CXmlConstantValue::DISABLED => CXmlConstantName::DISABLED]],
566							'allowed_hosts' =>			['type' => XML_STRING, 'default' => ''],
567							'params' =>					['type' => XML_STRING, 'default' => ''],
568							'ipmi_sensor' =>			['type' => XML_STRING, 'default' => ''],
569							'authtype' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::NONE, 'ex_validate' => [$this, 'validateAuthType'], 'ex_rules' => [$this, 'getAuthTypeExtendedRules'], 'export' => [$this, 'itemAuthtypeExport']],
570							'username' =>				['type' => XML_STRING, 'default' => ''],
571							'password' =>				['type' => XML_STRING, 'default' => ''],
572							'publickey' =>				['type' => XML_STRING, 'default' => ''],
573							'privatekey' =>				['type' => XML_STRING, 'default' => ''],
574							'filter' =>					['type' => XML_ARRAY, 'import' => [$this, 'itemFilterImport'], 'rules' => [
575								'evaltype' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::AND_OR, 'in' => $this->EVALTPYE],
576								'formula' =>				['type' => XML_STRING, 'default' => ''],
577								'conditions' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'condition', 'rules' => [
578									'condition' =>				['type' => XML_ARRAY, 'rules' => [
579										'macro' =>					['type' => XML_STRING | XML_REQUIRED],
580										'value' =>					['type' => XML_STRING, 'default' => ''],
581										'operator' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::CONDITION_MATCHES_REGEX, 'in' => $this->FILTER_CONDITION_OPERATOR],
582										'formulaid' =>				['type' => XML_STRING | XML_REQUIRED]
583									]]
584								]]
585							]],
586							'lifetime' =>				['type' => XML_STRING, 'default' => '30d'],
587							'description' =>			['type' => XML_STRING, 'default' => ''],
588							'interface_ref' =>			['type' => XML_STRING],
589							'item_prototypes' =>		['type' => XML_INDEXED_ARRAY, 'prefix' => 'item_prototype', 'rules' => [
590								'item_prototype' =>			['type' => XML_ARRAY, 'rules' => [
591									'name' =>					['type' => XML_STRING | XML_REQUIRED],
592									'type' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::ITEM_TYPE_ZABBIX_PASSIVE, 'in' => $this->ITEM_TYPE],
593									'snmp_oid' =>				['type' => XML_STRING, 'default' => ''],
594									'key' =>					['type' => XML_STRING | XML_REQUIRED],
595									'delay' =>					['type' => XML_STRING, 'default' => '1m'],
596									'history' =>				['type' => XML_STRING, 'default' => '90d'],
597									'trends' =>					['type' => XML_STRING, 'default' => '365d'],
598									'status' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::ENABLED, 'in' => [CXmlConstantValue::ENABLED => CXmlConstantName::ENABLED, CXmlConstantValue::DISABLED => CXmlConstantName::DISABLED]],
599									'discover' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::ITEM_DISCOVER, 'in' => [CXmlConstantValue::ITEM_DISCOVER => CXmlConstantName::DISCOVER, CXmlConstantValue::ITEM_NO_DISCOVER => CXmlConstantName::NO_DISCOVER]],
600									'value_type' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::UNSIGNED, 'in' => $this->ITEM_VALUE_TYPE],
601									'allowed_hosts' =>			['type' => XML_STRING, 'default' => ''],
602									'units' =>					['type' => XML_STRING, 'default' => ''],
603									'params' =>					['type' => XML_STRING, 'default' => ''],
604									'ipmi_sensor' =>			['type' => XML_STRING, 'default' => ''],
605									'authtype' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::NONE, 'ex_validate' => [$this, 'validateAuthType'], 'ex_rules' => [$this, 'getAuthTypeExtendedRules'], 'export' => [$this, 'itemAuthtypeExport']],
606									'username' =>				['type' => XML_STRING, 'default' => ''],
607									'password' =>				['type' => XML_STRING, 'default' => ''],
608									'publickey' =>				['type' => XML_STRING, 'default' => ''],
609									'privatekey' =>				['type' => XML_STRING, 'default' => ''],
610									'description' =>			['type' => XML_STRING, 'default' => ''],
611									'inventory_link' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NONE, 'in' => $this->ITEM_INVENTORY_LINK],
612									'applications' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'application', 'rules' => [
613										'application' =>			['type' => XML_ARRAY, 'rules' => [
614											'name' =>					['type' => XML_STRING | XML_REQUIRED]
615										]]
616									]],
617									'application_prototypes' =>	['type' => XML_INDEXED_ARRAY, 'prefix' => 'application_prototype', 'rules' => [
618										'application_prototype' =>	['type' => XML_ARRAY, 'rules' => [
619											'name' =>					['type' => XML_STRING | XML_REQUIRED]
620										]]
621									]],
622									'valuemap' =>				['type' => XML_ARRAY, 'rules' => [
623										'name' =>					['type' => XML_STRING | XML_REQUIRED]
624									]],
625									'logtimefmt' =>				['type' => XML_STRING, 'default' => ''],
626									'preprocessing' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'step', 'rules' => [
627										'step' =>					['type' => XML_ARRAY, 'rules' => [
628											'type' =>					['type' => XML_STRING | XML_REQUIRED, 'in' => $this->PREPROCESSING_STEP_TYPE],
629											'parameters' =>				['type' => XML_INDEXED_ARRAY | XML_REQUIRED, 'prefix' => 'parameter', 'export' => [$this, 'preprocessingParametersExport'], 'rules' => [
630												'parameter' =>				['type' => XML_STRING, 'flags' => CImportDataNormalizer::EOL_LF]
631											]],
632											'error_handler' =>			['type' => XML_STRING, 'ex_default' => [$this, 'defaultPreprocErrHandler'], 'ex_validate' => [$this, 'validatePreprocErrHandler'], 'in' => $this->ITEM_PREPROCESSING_ERROR_HANDLER],
633											'error_handler_params' =>	['type' => XML_STRING, 'default' => '']
634										]]
635									]],
636									'interface_ref' =>			['type' => XML_STRING],
637									'jmx_endpoint' =>			['type' => XML_STRING, 'default' => ''],
638									'master_item' =>			['type' => XML_ARRAY, 'ex_validate' => [$this, 'validateMasterItem'],  'rules' => [
639										'key' =>					['type' => XML_STRING | XML_REQUIRED]
640									]],
641									'timeout' =>				['type' => XML_STRING, 'default' => '3s'],
642									'url' =>					['type' => XML_STRING, 'default' => ''],
643									'query_fields' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'query_field', 'rules' => [
644										'query_field' =>			['type' => XML_ARRAY, 'rules' => [
645											'name' =>					['type' => XML_STRING | XML_REQUIRED],
646											'value' =>					['type' => XML_STRING, 'default' => '']
647										]]
648									]],
649									'parameters' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'parameter', 'rules' => [
650										'parameter' =>			['type' => XML_ARRAY, 'rules' => [
651											'name' =>					['type' => XML_STRING | XML_REQUIRED],
652											'value' =>					['type' => XML_STRING, 'default' => '']
653										]]
654									]],
655									'posts' =>					['type' => XML_STRING, 'default' => ''],
656									'status_codes' =>			['type' => XML_STRING, 'default' => '200'],
657									'follow_redirects' =>		['type' => XML_STRING, 'default' => CXmlConstantValue::YES, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
658									'post_type' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::RAW, 'in' => $this->ITEM_POST_TYPE],
659									'http_proxy' =>				['type' => XML_STRING, 'default' => ''],
660									'headers' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'header', 'rules' => [
661										'header' =>					['type' => XML_ARRAY, 'rules' => [
662											'name' =>					['type' => XML_STRING | XML_REQUIRED],
663											'value' =>					['type' => XML_STRING | XML_REQUIRED]
664										]]
665									]],
666									'retrieve_mode' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::BODY, 'in' => $this->ITEM_RETRIEVE_MODE],
667									'request_method' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::GET, 'in' => $this->ITEM_REQUEST_METHOD],
668									'output_format' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::OUTPUT_FORMAT_RAW, 'in' => [CXmlConstantValue::OUTPUT_FORMAT_RAW => CXmlConstantName::RAW, CXmlConstantValue::OUTPUT_FORMAT_JSON => CXmlConstantName::JSON]],
669									'allow_traps' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
670									'ssl_cert_file' =>			['type' => XML_STRING, 'default' => ''],
671									'ssl_key_file' =>			['type' => XML_STRING, 'default' => ''],
672									'ssl_key_password' =>		['type' => XML_STRING, 'default' => ''],
673									'verify_peer' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
674									'verify_host' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
675									'trigger_prototypes' =>		['type' => XML_INDEXED_ARRAY, 'prefix' => 'trigger_prototype', 'rules' => [
676										'trigger_prototype' =>		['type' => XML_ARRAY, 'rules' => [
677											'expression' =>				['type' => XML_STRING | XML_REQUIRED],
678											'recovery_mode' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::TRIGGER_EXPRESSION, 'in' => $this->TRIGGER_RECOVERY_MODE],
679											'recovery_expression' =>	['type' => XML_STRING, 'default' => ''],
680											'correlation_mode' =>		['type' => XML_STRING, 'default' => CXmlConstantValue::TRIGGER_DISABLED, 'in' => [CXmlConstantValue::TRIGGER_DISABLED => CXmlConstantName::DISABLED, CXmlConstantValue::TRIGGER_TAG_VALUE => CXmlConstantName::TAG_VALUE]],
681											'correlation_tag' =>		['type' => XML_STRING, 'default' => ''],
682											'name' =>					['type' => XML_STRING | XML_REQUIRED],
683											'event_name' =>				['type' => XML_STRING, 'default' => ''],
684											'opdata' =>					['type' => XML_STRING, 'default' => ''],
685											'url' =>					['type' => XML_STRING, 'default' => ''],
686											'status' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::ENABLED, 'in' => [CXmlConstantValue::ENABLED => CXmlConstantName::ENABLED, CXmlConstantValue::DISABLED => CXmlConstantName::DISABLED]],
687											'discover' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::TRIGGER_DISCOVER, 'in' => [CXmlConstantValue::TRIGGER_DISCOVER => CXmlConstantName::DISCOVER, CXmlConstantValue::TRIGGER_NO_DISCOVER => CXmlConstantName::NO_DISCOVER]],
688											'priority' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::NOT_CLASSIFIED, 'in' => $this->TRIGGER_PRIORITY],
689											'description' =>			['type' => XML_STRING, 'default' => ''],
690											'type' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::SINGLE, 'in' => [CXmlConstantValue::SINGLE => CXmlConstantName::SINGLE, CXmlConstantValue::MULTIPLE => CXmlConstantName::MULTIPLE]],
691											'manual_close' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
692											'dependencies' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'dependency', 'rules' => [
693												'dependency' =>				['type' => XML_ARRAY, 'rules' => [
694													'name' =>					['type' => XML_STRING | XML_REQUIRED],
695													'expression' =>				['type' => XML_STRING | XML_REQUIRED],
696													'recovery_expression' =>	['type' => XML_STRING, 'default' => '']
697												]]
698											]],
699											'tags' =>					['type' => XML_INDEXED_ARRAY, 'prefix' => 'tag', 'rules' => [
700												'tag' =>					['type' => XML_ARRAY, 'rules' => [
701													'tag' =>					['type' => XML_STRING | XML_REQUIRED],
702													'value' =>					['type' => XML_STRING, 'default' => '']
703												]]
704											]]
705										]]
706									]]
707								]]
708							]],
709							'trigger_prototypes' =>		['type' => XML_INDEXED_ARRAY, 'prefix' => 'trigger_prototype', 'rules' => [
710								'trigger_prototype' =>		['type' => XML_ARRAY, 'rules' => [
711									'expression' =>				['type' => XML_STRING | XML_REQUIRED],
712									'recovery_mode' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::TRIGGER_EXPRESSION, 'in' => $this->TRIGGER_RECOVERY_MODE],
713									'recovery_expression' =>	['type' => XML_STRING, 'default' => ''],
714									'correlation_mode' =>		['type' => XML_STRING, 'default' => CXmlConstantValue::TRIGGER_DISABLED, 'in' => [CXmlConstantValue::TRIGGER_DISABLED => CXmlConstantName::DISABLED, CXmlConstantValue::TRIGGER_TAG_VALUE => CXmlConstantName::TAG_VALUE]],
715									'correlation_tag' =>		['type' => XML_STRING, 'default' => ''],
716									'name' =>					['type' => XML_STRING | XML_REQUIRED],
717									'event_name' =>				['type' => XML_STRING, 'default' => ''],
718									'opdata' =>					['type' => XML_STRING, 'default' => ''],
719									'url' =>					['type' => XML_STRING, 'default' => ''],
720									'status' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::ENABLED, 'in' => [CXmlConstantValue::ENABLED => CXmlConstantName::ENABLED, CXmlConstantValue::DISABLED => CXmlConstantName::DISABLED]],
721									'discover' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::TRIGGER_DISCOVER, 'in' => [CXmlConstantValue::TRIGGER_DISCOVER => CXmlConstantName::DISCOVER, CXmlConstantValue::TRIGGER_NO_DISCOVER => CXmlConstantName::NO_DISCOVER]],
722									'priority' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::NOT_CLASSIFIED, 'in' => $this->TRIGGER_PRIORITY],
723									'description' =>			['type' => XML_STRING, 'default' => ''],
724									'type' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::SINGLE, 'in' => [CXmlConstantValue::SINGLE => CXmlConstantName::SINGLE, CXmlConstantValue::MULTIPLE => CXmlConstantName::MULTIPLE]],
725									'manual_close' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
726									'dependencies' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'dependency', 'rules' => [
727										'dependency' =>				['type' => XML_ARRAY, 'rules' => [
728											'name' =>					['type' => XML_STRING | XML_REQUIRED],
729											'expression' =>				['type' => XML_STRING | XML_REQUIRED],
730											'recovery_expression' =>	['type' => XML_STRING, 'default' => '']
731										]]
732									]],
733									'tags' =>					['type' => XML_INDEXED_ARRAY, 'prefix' => 'tag', 'rules' => [
734										'tag' =>					['type' => XML_ARRAY, 'rules' => [
735											'tag' =>					['type' => XML_STRING | XML_REQUIRED],
736											'value' =>					['type' => XML_STRING, 'default' => '']
737										]]
738									]]
739								]]
740							]],
741							'graph_prototypes' =>		['type' => XML_INDEXED_ARRAY, 'prefix' => 'graph_prototype', 'rules' => [
742								'graph_prototype' =>		['type' => XML_ARRAY, 'rules' => [
743									'name' =>					['type' => XML_STRING | XML_REQUIRED],
744									'width' =>					['type' => XML_STRING, 'default' => '900'],
745									'height' =>					['type' => XML_STRING, 'default' => '200'],
746									'yaxismin' =>				['type' => XML_STRING, 'default' => '0'],
747									'yaxismax' =>				['type' => XML_STRING, 'default' => '100'],
748									'show_work_period' =>		['type' => XML_STRING, 'default' => CXmlConstantValue::YES, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
749									'show_triggers' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::YES, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
750									'type' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::NORMAL, 'in' => $this->GRAPH_TYPE],
751									'show_legend' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::YES, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
752									'show_3d' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
753									'percent_left' =>			['type' => XML_STRING, 'default' => '0'],
754									'percent_right' =>			['type' => XML_STRING, 'default' => '0'],
755									// The tag 'ymin_type_1' should be validated before the 'ymin_item_1' because it is used in 'ex_validate' method.
756									'ymin_type_1' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::CALCULATED, 'in' => $this->GRAPH_Y_TYPE],
757									'ymin_item_1' =>			['type' => 0, 'default' => '0', 'preprocessor' => [$this, 'transformZero2Array'], 'ex_validate' => [$this, 'validateYMinItem'], 'export' => [$this, 'graphMinItemExport']],
758									// The tag 'ymax_type_1' should be validated before the 'ymax_item_1' because it is used in 'ex_validate' method.
759									'ymax_type_1' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::CALCULATED, 'in' => $this->GRAPH_Y_TYPE],
760									'ymax_item_1' =>			['type' => 0, 'default' => '0', 'preprocessor' => [$this, 'transformZero2Array'], 'ex_validate' => [$this, 'validateYMaxItem'], 'export' => [$this, 'graphMaxItemExport']],
761									'graph_items' =>			['type' => XML_INDEXED_ARRAY | XML_REQUIRED, 'prefix' => 'graph_item', 'ex_validate' => [$this, 'validateGraphItems'], 'rules' => [
762										'graph_item' =>				['type' => XML_ARRAY, 'rules' => [
763											'sortorder' =>				['type' => XML_STRING, 'default' => '0'],
764											'drawtype' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::SINGLE_LINE, 'in' => $this->GRAPH_GRAPH_ITEM_DRAWTYPE],
765											'color' =>					['type' => XML_STRING, 'default' => '009600'],
766											'yaxisside' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::LEFT, 'in' => $this->GRAPH_GRAPH_ITEM_YAXISSIDE],
767											'calc_fnc' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::AVG, 'in' => $this->GRAPH_GRAPH_ITEM_CALC_FNC],
768											'type' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::SIMPLE, 'in' => $this->GRAPH_GRAPH_ITEM_TYPE],
769											'item' =>					['type' => XML_ARRAY | XML_REQUIRED, 'rules' => [
770												'host' =>					['type' => XML_STRING | XML_REQUIRED],
771												'key' =>					['type' => XML_STRING | XML_REQUIRED]
772											]]
773										]]
774									]],
775									'discover' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::GRAPH_DISCOVER, 'in' => [CXmlConstantValue::GRAPH_DISCOVER => CXmlConstantName::DISCOVER, CXmlConstantValue::GRAPH_NO_DISCOVER => CXmlConstantName::NO_DISCOVER]]
776								]]
777							]],
778							'host_prototypes' =>		['type' => XML_INDEXED_ARRAY, 'prefix' => 'host_prototype', 'rules' => [
779								'host_prototype' =>			['type' => XML_ARRAY, 'rules' => [
780									'host' =>					['type' => XML_STRING | XML_REQUIRED],
781									'name' =>					['type' => XML_STRING, 'default' => ''],
782									'status' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::ENABLED, 'in' => [CXmlConstantValue::ENABLED => CXmlConstantName::ENABLED, CXmlConstantValue::DISABLED => CXmlConstantName::DISABLED]],
783									'discover' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::HOST_DISCOVER, 'in' => [CXmlConstantValue::HOST_DISCOVER => CXmlConstantName::DISCOVER, CXmlConstantValue::HOST_NO_DISCOVER => CXmlConstantName::NO_DISCOVER]],
784									'inventory_mode' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::INV_MODE_MANUAL, 'in' => $this->INVENTORY_MODE],
785									'group_links' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'group_link', 'rules' => [
786										'group_link' =>				['type' => XML_ARRAY, 'rules' => [
787											'group' =>					['type' => XML_ARRAY | XML_REQUIRED, 'rules' => [
788												'name' =>					['type' => XML_STRING | XML_REQUIRED]
789											]]
790										]]
791									]],
792									'group_prototypes' =>		['type' => XML_INDEXED_ARRAY, 'prefix' => 'group_prototype', 'rules' => [
793										'group_prototype' =>		['type' => XML_ARRAY, 'rules' => [
794											'name' =>					['type' => XML_STRING | XML_REQUIRED]
795										]]
796									]],
797									'templates' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'template', 'rules' => [
798										'template' =>				['type' => XML_ARRAY, 'rules' => [
799											'name' =>					['type' => XML_STRING | XML_REQUIRED]
800										]]
801									]],
802									'macros' =>					['type' => XML_INDEXED_ARRAY, 'prefix' => 'macro', 'rules' => [
803										'macro' =>					['type' => XML_ARRAY, 'rules' => [
804											'macro' =>					['type' => XML_STRING | XML_REQUIRED],
805											'type' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::MACRO_TYPE_TEXT, 'in' => [CXmlConstantValue::MACRO_TYPE_TEXT => CXmlConstantName::MACRO_TYPE_TEXT, CXmlConstantValue::MACRO_TYPE_SECRET => CXmlConstantName::MACRO_TYPE_SECRET, CXmlConstantValue::MACRO_TYPE_VAULT => CXmlConstantName::MACRO_TYPE_VAULT]],
806											'value' =>					['type' => XML_STRING, 'default' => ''],
807											'description' =>			['type' => XML_STRING, 'default' => '']
808										]]
809									]],
810									'tags' =>					['type' => XML_INDEXED_ARRAY, 'prefix' => 'tag', 'rules' => [
811										'tag' =>					['type' => XML_ARRAY, 'rules' => [
812											'tag' =>					['type' => XML_STRING | XML_REQUIRED],
813											'value' =>					['type' => XML_STRING, 'default' => '']
814										]]
815									]],
816									'custom_interfaces' =>		['type' => XML_STRING, 'default' => CXmlConstantValue::CUSTOM_INTERFACES_NO, 'in' => $this->CUSTOM_INTERFACES],
817									'interfaces' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'interface', 'rules' => [
818										'interface' =>				['type' => XML_ARRAY, 'rules' => [
819											'default' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::YES, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
820											'type' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::ZABBIX, 'in' => [CXmlConstantValue::ZABBIX => CXmlConstantName::ZABBIX, CXmlConstantValue::SNMP => CXmlConstantName::SNMP, CXmlConstantValue::IPMI => CXmlConstantName::IPMI, CXmlConstantValue::JMX => CXmlConstantName::JMX]],
821											'useip' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::YES, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
822											'ip' =>						['type' => XML_STRING, 'default' => '127.0.0.1'],
823											'dns' =>					['type' => XML_STRING, 'default' => ''],
824											'port' =>					['type' => XML_STRING, 'default' => '10050'],
825											'details' =>				['type' => XML_ARRAY, 'rules' => [
826												'version' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::SNMP_V2, 'in' => [CXmlConstantValue::SNMP_V1 => CXmlConstantName::SNMPV1, CXmlConstantValue::SNMP_V2 => CXmlConstantName::SNMPV2, CXmlConstantValue::SNMP_V3 => CXmlConstantName::SNMPV3]],
827												'community' =>				['type' => XML_STRING, 'default' => ''],
828												'contextname' =>			['type' => XML_STRING, 'default' => ''],
829												'securityname' =>			['type' => XML_STRING, 'default' => ''],
830												'securitylevel' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NOAUTHNOPRIV, 'in' => $this->ITEM_SNMPV3_SECURITYLEVEL],
831												'authprotocol' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::SNMPV3_MD5, 'in' => [CXmlConstantValue::SNMPV3_MD5 => CXmlConstantName::MD5, CXmlConstantValue::SNMPV3_SHA1 => CXmlConstantName::SHA]],
832												'authpassphrase' =>			['type' => XML_STRING, 'default' => ''],
833												'privprotocol' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::SNMPV3_DES, 'in' => [CXmlConstantValue::SNMPV3_DES => CXmlConstantName::DES, CXmlConstantValue::SNMPV3_AES128 => CXmlConstantName::AES]],
834												'privpassphrase' =>			['type' => XML_STRING, 'default' => ''],
835												'bulk' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::YES, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]]
836											]]
837										]]
838									]]
839								]]
840							]],
841							'jmx_endpoint' =>			['type' => XML_STRING, 'default' => ''],
842							'master_item' =>			['type' => XML_ARRAY, 'ex_validate' => [$this, 'validateMasterItem'], 'rules' => [
843								'key' =>					['type' => XML_STRING | XML_REQUIRED]
844							]],
845							'timeout' =>				['type' => XML_STRING, 'default' => '3s'],
846							'url' =>					['type' => XML_STRING, 'default' => ''],
847							'query_fields' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'query_field', 'rules' => [
848								'query_field' =>			['type' => XML_ARRAY, 'rules' => [
849									'name' =>					['type' => XML_STRING | XML_REQUIRED],
850									'value' =>					['type' => XML_STRING, 'default' => '']
851								]]
852							]],
853							'parameters' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'parameter', 'rules' => [
854								'parameter' =>			['type' => XML_ARRAY, 'rules' => [
855									'name' =>					['type' => XML_STRING | XML_REQUIRED],
856									'value' =>					['type' => XML_STRING, 'default' => '']
857								]]
858							]],
859							'posts' =>					['type' => XML_STRING, 'default' => ''],
860							'status_codes' =>			['type' => XML_STRING, 'default' => '200'],
861							'follow_redirects' =>		['type' => XML_STRING, 'default' => CXmlConstantValue::YES, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
862							'post_type' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::RAW, 'in' => $this->ITEM_POST_TYPE],
863							'http_proxy' =>				['type' => XML_STRING, 'default' => ''],
864							'headers' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'header', 'rules' => [
865								'header' =>					['type' => XML_ARRAY, 'rules' => [
866									'name' =>					['type' => XML_STRING | XML_REQUIRED],
867									'value' =>					['type' => XML_STRING | XML_REQUIRED]
868								]]
869							]],
870							'retrieve_mode' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::BODY, 'in' => $this->ITEM_RETRIEVE_MODE],
871							'request_method' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::GET, 'in' => $this->ITEM_REQUEST_METHOD],
872							'allow_traps' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
873							'ssl_cert_file' =>			['type' => XML_STRING, 'default' => ''],
874							'ssl_key_file' =>			['type' => XML_STRING, 'default' => ''],
875							'ssl_key_password' =>		['type' => XML_STRING, 'default' => ''],
876							'verify_peer' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
877							'verify_host' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
878							'lld_macro_paths' =>		['type' => XML_INDEXED_ARRAY, 'prefix' => 'lld_macro_path', 'rules' => [
879								'lld_macro_path' =>			['type' => XML_ARRAY, 'rules' => [
880									'lld_macro' =>				['type' => XML_STRING | XML_REQUIRED],
881									'path' =>					['type' => XML_STRING | XML_REQUIRED]
882								]]
883							]],
884							'preprocessing' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'step', 'rules' => [
885								'step' =>					['type' => XML_ARRAY, 'rules' => [
886									'type' =>					['type' => XML_STRING | XML_REQUIRED, 'in' => $this->PREPROCESSING_STEP_TYPE_DRULE],
887									'parameters' =>				['type' => XML_INDEXED_ARRAY | XML_REQUIRED, 'prefix' => 'parameter', 'export' => [$this, 'preprocessingParametersExport'], 'rules' => [
888										'parameter' =>				['type' => XML_STRING, 'flags' => CImportDataNormalizer::EOL_LF]
889									]],
890									'error_handler' =>			['type' => XML_STRING, 'ex_default' => [$this, 'defaultPreprocErrHandler'], 'ex_validate' => [$this, 'validatePreprocErrHandler'], 'in' => $this->ITEM_PREPROCESSING_ERROR_HANDLER],
891									'error_handler_params' =>	['type' => XML_STRING, 'default' => '']
892								]]
893							]],
894							'overrides'	=>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'override', 'rules' => [
895								'override' =>				['type' => XML_ARRAY, 'rules' => [
896									'name' =>					['type' => XML_STRING | XML_REQUIRED],
897									'step' =>					['type' => XML_STRING | XML_REQUIRED],
898									'stop' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::LLD_OVERRIDE_STOP_NO, 'in' => $this->LLD_OVERRIDE_STOP],
899									'filter' =>					['type' => XML_ARRAY, 'rules' => [
900										'evaltype' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::AND_OR, 'in' => $this->EVALTPYE],
901										'formula' =>				['type' => XML_STRING, 'default' => ''],
902										'conditions' =>				['type' => XML_INDEXED_ARRAY | XML_REQUIRED, 'prefix' => 'condition', 'rules' => [
903											'condition' =>				['type' => XML_ARRAY | XML_REQUIRED, 'rules' => [
904												'macro' =>					['type' => XML_STRING | XML_REQUIRED],
905												'value' =>					['type' => XML_STRING, 'default' => ''],
906												'operator' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::CONDITION_MATCHES_REGEX, 'in' => $this->FILTER_CONDITION_OPERATOR],
907												'formulaid' =>				['type' => XML_STRING | XML_REQUIRED]
908											]]
909										]]
910									]],
911									'operations' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'operation', 'rules' => [
912										'operation' =>				['type' => XML_ARRAY, 'rules' => [
913											'operationobject' =>		['type' => XML_STRING, 'in' => $this->LLD_OVERRIDE_OPERATION_OBJECT],
914											'operator' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::CONDITION_OPERATOR_EQUAL, 'in' => $this->CONDITION_OPERATOR],
915											'value' =>					['type' => XML_STRING, 'default' => ''],
916											'status' =>					['type' => XML_STRING, 'in' => [CXmlConstantValue::LLD_OVERRIDE_OPERATION_STATUS_ENABLED => CXmlConstantName::ENABLED, CXmlConstantValue::LLD_OVERRIDE_OPERATION_STATUS_DISABLED => CXmlConstantName::DISABLED]],
917											'discover' =>				['type' => XML_STRING, 'in' => [CXmlConstantValue::LLD_OVERRIDE_OPERATION_DISCOVER => CXmlConstantName::DISCOVER, CXmlConstantValue::LLD_OVERRIDE_OPERATION_NO_DISCOVER => CXmlConstantName::NO_DISCOVER]],
918											'delay' =>					['type' => XML_STRING, 'default' => ''],
919											'history' =>				['type' => XML_STRING, 'default' => ''],
920											'trends' =>					['type' => XML_STRING, 'default' => ''],
921											'severity' =>				['type' => XML_STRING, 'in' => $this->TRIGGER_PRIORITY],
922											'tags' =>					['type' => XML_INDEXED_ARRAY, 'prefix' => 'tag', 'rules' => [
923												'tag' =>					['type' => XML_ARRAY, 'rules' => [
924													'tag' =>					['type' => XML_STRING | XML_REQUIRED],
925													'value' =>					['type' => XML_STRING, 'default' => '']
926												]]
927											]],
928											'templates' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'template', 'rules' => [
929												'template' =>				['type' => XML_ARRAY, 'rules' => [
930													'name' =>					['type' => XML_STRING | XML_REQUIRED]
931												]]
932											]],
933											'inventory_mode' =>			['type' => XML_STRING, 'in' => $this->INVENTORY_MODE]
934										]]
935									]]
936								]]
937							]]
938						]]
939					]],
940					'httptests' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'httptest', 'rules' => [
941						'httptest' =>				['type' => XML_ARRAY, 'rules' => [
942							'name' =>					['type' => XML_STRING | XML_REQUIRED],
943							'application' =>			['type' => XML_ARRAY, 'rules' => [
944								'name' =>					['type' => XML_STRING | XML_REQUIRED]
945							]],
946							'delay' =>					['type' => XML_STRING, 'default' => '1m'],
947							'attempts' =>				['type' => XML_STRING, 'default' => '1'],
948							'agent' =>					['type' => XML_STRING, 'default' => 'Zabbix'],
949							'http_proxy' =>				['type' => XML_STRING, 'default' => ''],
950							'variables' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'variable', 'rules' => [
951								'variable' =>				['type' => XML_ARRAY, 'rules' => [
952									'name' =>					['type' => XML_STRING | XML_REQUIRED],
953									'value' =>					['type' => XML_STRING | XML_REQUIRED]
954								]]
955							]],
956							'headers' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'header', 'rules' => [
957								'header' =>					['type' => XML_ARRAY, 'rules' => [
958									'name' =>					['type' => XML_STRING | XML_REQUIRED],
959									'value' =>					['type' => XML_STRING | XML_REQUIRED]
960								]]
961							]],
962							'status' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::ENABLED, 'in' => [CXmlConstantValue::ENABLED => CXmlConstantName::ENABLED, CXmlConstantValue::DISABLED => CXmlConstantName::DISABLED]],
963							'authentication' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NONE, 'in' => $this->HTTP_TEST_AUTHENTICATION],
964							'http_user' =>				['type' => XML_STRING, 'default' => ''],
965							'http_password' =>			['type' => XML_STRING, 'default' => ''],
966							'verify_peer' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
967							'verify_host' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
968							'ssl_cert_file' =>			['type' => XML_STRING, 'default' => ''],
969							'ssl_key_file' =>			['type' => XML_STRING, 'default' => ''],
970							'ssl_key_password' =>		['type' => XML_STRING, 'default' => ''],
971							'steps' =>					['type' => XML_INDEXED_ARRAY | XML_REQUIRED, 'prefix' => 'step', 'rules' => [
972								'step' =>					['type' => XML_ARRAY, 'rules' => [
973									'name' =>					['type' => XML_STRING | XML_REQUIRED],
974									'url' =>					['type' => XML_STRING | XML_REQUIRED],
975									'query_fields' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'query_field', 'rules' => [
976										'query_field' =>			['type' => XML_ARRAY, 'rules' => [
977											'name' =>					['type' => XML_STRING | XML_REQUIRED],
978											'value' =>					['type' => XML_STRING, 'default' => '']
979										]]
980									]],
981									'posts' =>					['type' => 0, 'ex_validate' => [$this, 'validateHttpPosts']],
982									'variables' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'variable', 'rules' => [
983										'variable' =>				['type' => XML_ARRAY, 'rules' => [
984											'name' =>					['type' => XML_STRING | XML_REQUIRED],
985											'value' =>					['type' => XML_STRING | XML_REQUIRED]
986										]]
987									]],
988									'headers' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'header', 'rules' => [
989										'header' =>					['type' => XML_ARRAY, 'rules' => [
990											'name' =>					['type' => XML_STRING | XML_REQUIRED],
991											'value' =>					['type' => XML_STRING | XML_REQUIRED]
992										]]
993									]],
994									'follow_redirects' =>		['type' => XML_STRING, 'default' => CXmlConstantValue::YES, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
995									'retrieve_mode' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::BODY, 'in' => $this->ITEM_RETRIEVE_MODE],
996									'timeout' =>				['type' => XML_STRING, 'default' => '15s'],
997									'required' =>				['type' => XML_STRING, 'default' => ''],
998									'status_codes' =>			['type' => XML_STRING, 'default' => '']
999								]]
1000							]]
1001						]]
1002					]],
1003					'tags' =>					['type' => XML_INDEXED_ARRAY, 'prefix' => 'tag', 'rules' => [
1004						'tag' =>					['type' => XML_ARRAY, 'rules' => [
1005							'tag' =>					['type' => XML_STRING | XML_REQUIRED],
1006							'value' =>					['type' => XML_STRING, 'default' => '']
1007						]]
1008					]],
1009					'macros' =>					['type' => XML_INDEXED_ARRAY, 'prefix' => 'macro', 'rules' => [
1010						'macro' =>					['type' => XML_ARRAY, 'rules' => [
1011							'macro' =>					['type' => XML_STRING | XML_REQUIRED],
1012							'type' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::MACRO_TYPE_TEXT, 'in' => [CXmlConstantValue::MACRO_TYPE_TEXT => CXmlConstantName::MACRO_TYPE_TEXT, CXmlConstantValue::MACRO_TYPE_SECRET => CXmlConstantName::MACRO_TYPE_SECRET, CXmlConstantValue::MACRO_TYPE_VAULT => CXmlConstantName::MACRO_TYPE_VAULT]],
1013							'value' =>					['type' => XML_STRING, 'default' => ''],
1014							'description' =>			['type' => XML_STRING, 'default' => '']
1015						]]
1016					]],
1017					'inventory' =>				['type' => XML_ARRAY, 'rules' => [
1018						'type' =>					['type' => XML_STRING, 'default' => ''],
1019						'type_full' =>				['type' => XML_STRING, 'default' => ''],
1020						'name' =>					['type' => XML_STRING, 'default' => ''],
1021						'alias' =>					['type' => XML_STRING, 'default' => ''],
1022						'os' =>						['type' => XML_STRING, 'default' => ''],
1023						'os_full' =>				['type' => XML_STRING, 'default' => ''],
1024						'os_short' =>				['type' => XML_STRING, 'default' => ''],
1025						'serialno_a' =>				['type' => XML_STRING, 'default' => ''],
1026						'serialno_b' =>				['type' => XML_STRING, 'default' => ''],
1027						'tag' =>					['type' => XML_STRING, 'default' => ''],
1028						'asset_tag' =>				['type' => XML_STRING, 'default' => ''],
1029						'macaddress_a' =>			['type' => XML_STRING, 'default' => ''],
1030						'macaddress_b' =>			['type' => XML_STRING, 'default' => ''],
1031						'hardware' =>				['type' => XML_STRING, 'default' => ''],
1032						'hardware_full' =>			['type' => XML_STRING, 'default' => ''],
1033						'software' =>				['type' => XML_STRING, 'default' => ''],
1034						'software_full' =>			['type' => XML_STRING, 'default' => ''],
1035						'software_app_a' =>			['type' => XML_STRING, 'default' => ''],
1036						'software_app_b' =>			['type' => XML_STRING, 'default' => ''],
1037						'software_app_c' =>			['type' => XML_STRING, 'default' => ''],
1038						'software_app_d' =>			['type' => XML_STRING, 'default' => ''],
1039						'software_app_e' =>			['type' => XML_STRING, 'default' => ''],
1040						'contact' =>				['type' => XML_STRING, 'default' => ''],
1041						'location' =>				['type' => XML_STRING, 'default' => ''],
1042						'location_lat' =>			['type' => XML_STRING, 'default' => ''],
1043						'location_lon' =>			['type' => XML_STRING, 'default' => ''],
1044						'notes' =>					['type' => XML_STRING, 'default' => ''],
1045						'chassis' =>				['type' => XML_STRING, 'default' => ''],
1046						'model' =>					['type' => XML_STRING, 'default' => ''],
1047						'hw_arch' =>				['type' => XML_STRING, 'default' => ''],
1048						'vendor' =>					['type' => XML_STRING, 'default' => ''],
1049						'contract_number' =>		['type' => XML_STRING, 'default' => ''],
1050						'installer_name' =>			['type' => XML_STRING, 'default' => ''],
1051						'deployment_status' =>		['type' => XML_STRING, 'default' => ''],
1052						'url_a' =>					['type' => XML_STRING, 'default' => ''],
1053						'url_b' =>					['type' => XML_STRING, 'default' => ''],
1054						'url_c' =>					['type' => XML_STRING, 'default' => ''],
1055						'host_networks' =>			['type' => XML_STRING, 'default' => ''],
1056						'host_netmask' =>			['type' => XML_STRING, 'default' => ''],
1057						'host_router' =>			['type' => XML_STRING, 'default' => ''],
1058						'oob_ip' =>					['type' => XML_STRING, 'default' => ''],
1059						'oob_netmask' =>			['type' => XML_STRING, 'default' => ''],
1060						'oob_router' =>				['type' => XML_STRING, 'default' => ''],
1061						'date_hw_purchase' =>		['type' => XML_STRING, 'default' => ''],
1062						'date_hw_install' =>		['type' => XML_STRING, 'default' => ''],
1063						'date_hw_expiry' =>			['type' => XML_STRING, 'default' => ''],
1064						'date_hw_decomm' =>			['type' => XML_STRING, 'default' => ''],
1065						'site_address_a' =>			['type' => XML_STRING, 'default' => ''],
1066						'site_address_b' =>			['type' => XML_STRING, 'default' => ''],
1067						'site_address_c' =>			['type' => XML_STRING, 'default' => ''],
1068						'site_city' =>				['type' => XML_STRING, 'default' => ''],
1069						'site_state' =>				['type' => XML_STRING, 'default' => ''],
1070						'site_country' =>			['type' => XML_STRING, 'default' => ''],
1071						'site_zip' =>				['type' => XML_STRING, 'default' => ''],
1072						'site_rack' =>				['type' => XML_STRING, 'default' => ''],
1073						'site_notes' =>				['type' => XML_STRING, 'default' => ''],
1074						'poc_1_name' =>				['type' => XML_STRING, 'default' => ''],
1075						'poc_1_email' =>			['type' => XML_STRING, 'default' => ''],
1076						'poc_1_phone_a' =>			['type' => XML_STRING, 'default' => ''],
1077						'poc_1_phone_b' =>			['type' => XML_STRING, 'default' => ''],
1078						'poc_1_cell' =>				['type' => XML_STRING, 'default' => ''],
1079						'poc_1_screen' =>			['type' => XML_STRING, 'default' => ''],
1080						'poc_1_notes' =>			['type' => XML_STRING, 'default' => ''],
1081						'poc_2_name' =>				['type' => XML_STRING, 'default' => ''],
1082						'poc_2_email' =>			['type' => XML_STRING, 'default' => ''],
1083						'poc_2_phone_a' =>			['type' => XML_STRING, 'default' => ''],
1084						'poc_2_phone_b' =>			['type' => XML_STRING, 'default' => ''],
1085						'poc_2_cell' =>				['type' => XML_STRING, 'default' => ''],
1086						'poc_2_screen' =>			['type' => XML_STRING, 'default' => ''],
1087						'poc_2_notes' =>			['type' => XML_STRING, 'default' => '']
1088					]],
1089					'inventory_mode' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::INV_MODE_MANUAL, 'in' => $this->INVENTORY_MODE]
1090				]]
1091			]],
1092			'templates' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'template', 'rules' => [
1093				'template' =>				['type' => XML_ARRAY, 'rules' => [
1094					'template' =>				['type' => XML_STRING | XML_REQUIRED],
1095					'name' =>					['type' => XML_STRING, 'default' => ''],
1096					'description' =>			['type' => XML_STRING, 'default' => ''],
1097					'templates' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'template', 'rules' => [
1098						'template' =>				['type' => XML_ARRAY, 'rules' => [
1099							'name' =>					['type' => XML_STRING | XML_REQUIRED]
1100						]]
1101					]],
1102					'groups' =>					['type' => XML_INDEXED_ARRAY | XML_REQUIRED, 'prefix' => 'group', 'rules' => [
1103						'group' =>					['type' => XML_ARRAY, 'rules' => [
1104							'name' =>					['type' => XML_STRING | XML_REQUIRED]
1105						]]
1106					]],
1107					'applications' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'application', 'rules' => [
1108						'application' =>			['type' => XML_ARRAY, 'rules' => [
1109							'name' =>					['type' => XML_STRING | XML_REQUIRED]
1110						]]
1111					]],
1112					'items' =>					['type' => XML_INDEXED_ARRAY, 'prefix' => 'item', 'rules' => [
1113						'item' =>					['type' => XML_ARRAY, 'rules' => [
1114							'name' =>					['type' => XML_STRING | XML_REQUIRED],
1115							'type' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::ITEM_TYPE_ZABBIX_PASSIVE, 'in' => $this->ITEM_TYPE],
1116							'snmp_oid' =>				['type' => XML_STRING, 'default' => ''],
1117							'key' =>					['type' => XML_STRING | XML_REQUIRED],
1118							'delay' =>					['type' => XML_STRING, 'default' => '1m'],
1119							'history' =>				['type' => XML_STRING, 'default' => '90d'],
1120							'trends' =>					['type' => XML_STRING, 'default' => '365d'],
1121							'status' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::ENABLED, 'in' => [CXmlConstantValue::ENABLED => CXmlConstantName::ENABLED, CXmlConstantValue::DISABLED => CXmlConstantName::DISABLED]],
1122							'value_type' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::UNSIGNED, 'in' => $this->ITEM_VALUE_TYPE],
1123							'allowed_hosts' =>			['type' => XML_STRING, 'default' => ''],
1124							'units' =>					['type' => XML_STRING, 'default' => ''],
1125							'params' =>					['type' => XML_STRING, 'default' => ''],
1126							'ipmi_sensor' =>			['type' => XML_STRING, 'default' => ''],
1127							'authtype' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::NONE, 'ex_validate' => [$this, 'validateAuthType'], 'ex_rules' => [$this, 'getAuthTypeExtendedRules'], 'export' => [$this, 'itemAuthtypeExport']],
1128							'username' =>				['type' => XML_STRING, 'default' => ''],
1129							'password' =>				['type' => XML_STRING, 'default' => ''],
1130							'publickey' =>				['type' => XML_STRING, 'default' => ''],
1131							'privatekey' =>				['type' => XML_STRING, 'default' => ''],
1132							'description' =>			['type' => XML_STRING, 'default' => ''],
1133							'inventory_link' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NONE, 'in' => $this->ITEM_INVENTORY_LINK],
1134							'applications' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'application', 'rules' => [
1135								'application' =>			['type' => XML_ARRAY, 'rules' => [
1136									'name' =>					['type' => XML_STRING | XML_REQUIRED]
1137								]]
1138							]],
1139							'valuemap' =>				['type' => XML_ARRAY, 'rules' => [
1140								'name' =>					['type' => XML_STRING | XML_REQUIRED]
1141							]],
1142							'logtimefmt' =>				['type' => XML_STRING, 'default' => ''],
1143							'preprocessing' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'step', 'rules' => [
1144								'step' =>					['type' => XML_ARRAY, 'rules' => [
1145									'type' =>					['type' => XML_STRING | XML_REQUIRED, 'in' => $this->PREPROCESSING_STEP_TYPE],
1146									'parameters' =>				['type' => XML_INDEXED_ARRAY | XML_REQUIRED, 'prefix' => 'parameter', 'export' => [$this, 'preprocessingParametersExport'], 'rules' => [
1147										'parameter' =>				['type' => XML_STRING, 'flags' => CImportDataNormalizer::EOL_LF]
1148									]],
1149									'error_handler' =>			['type' => XML_STRING, 'ex_default' => [$this, 'defaultPreprocErrHandler'], 'ex_validate' => [$this, 'validatePreprocErrHandler'], 'in' => $this->ITEM_PREPROCESSING_ERROR_HANDLER],
1150									'error_handler_params' =>	['type' => XML_STRING, 'default' => '']
1151								]]
1152							]],
1153							'jmx_endpoint' =>			['type' => XML_STRING, 'default' => ''],
1154							'master_item' =>			['type' => XML_ARRAY, 'ex_validate' => [$this, 'validateMasterItem'], 'rules' => [
1155								'key' =>					['type' => XML_STRING | XML_REQUIRED]
1156							]],
1157							'timeout' =>				['type' => XML_STRING, 'default' => '3s'],
1158							'url' =>					['type' => XML_STRING, 'default' => ''],
1159							'query_fields' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'query_field', 'rules' => [
1160								'query_field' =>			['type' => XML_ARRAY, 'rules' => [
1161									'name' =>					['type' => XML_STRING | XML_REQUIRED],
1162									'value' =>					['type' => XML_STRING, 'default' => '']
1163								]]
1164							]],
1165							'parameters' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'parameter', 'rules' => [
1166								'parameter' =>			['type' => XML_ARRAY, 'rules' => [
1167									'name' =>					['type' => XML_STRING | XML_REQUIRED],
1168									'value' =>					['type' => XML_STRING, 'default' => '']
1169								]]
1170							]],
1171							'posts' =>					['type' => XML_STRING, 'default' => ''],
1172							'status_codes' =>			['type' => XML_STRING, 'default' => '200'],
1173							'follow_redirects' =>		['type' => XML_STRING, 'default' => CXmlConstantValue::YES, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1174							'post_type' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::RAW, 'in' => $this->ITEM_POST_TYPE],
1175							'http_proxy' =>				['type' => XML_STRING, 'default' => ''],
1176							'headers' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'header', 'rules' => [
1177								'header' =>					['type' => XML_ARRAY, 'rules' => [
1178									'name' =>					['type' => XML_STRING | XML_REQUIRED],
1179									'value' =>					['type' => XML_STRING | XML_REQUIRED]
1180								]]
1181							]],
1182							'retrieve_mode' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::BODY, 'in' => $this->ITEM_RETRIEVE_MODE],
1183							'request_method' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::GET, 'in' => $this->ITEM_REQUEST_METHOD],
1184							'output_format' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::OUTPUT_FORMAT_RAW, 'in' => [CXmlConstantValue::OUTPUT_FORMAT_RAW => CXmlConstantName::RAW, CXmlConstantValue::OUTPUT_FORMAT_JSON => CXmlConstantName::JSON]],
1185							'allow_traps' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1186							'ssl_cert_file' =>			['type' => XML_STRING, 'default' => ''],
1187							'ssl_key_file' =>			['type' => XML_STRING, 'default' => ''],
1188							'ssl_key_password' =>		['type' => XML_STRING, 'default' => ''],
1189							'verify_peer' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1190							'verify_host' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1191							'triggers' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'trigger', 'rules' => [
1192								'trigger' =>				['type' => XML_ARRAY, 'rules' => [
1193									'expression' =>				['type' => XML_STRING | XML_REQUIRED],
1194									'recovery_mode' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::TRIGGER_EXPRESSION, 'in' => $this->TRIGGER_RECOVERY_MODE],
1195									'recovery_expression' =>	['type' => XML_STRING, 'default' => ''],
1196									'correlation_mode' =>		['type' => XML_STRING, 'default' => CXmlConstantValue::TRIGGER_DISABLED, 'in' => [CXmlConstantValue::TRIGGER_DISABLED => CXmlConstantName::DISABLED, CXmlConstantValue::TRIGGER_TAG_VALUE => CXmlConstantName::TAG_VALUE]],
1197									'correlation_tag' =>		['type' => XML_STRING, 'default' => ''],
1198									'name' =>					['type' => XML_STRING | XML_REQUIRED],
1199									'event_name' =>				['type' => XML_STRING, 'default' => ''],
1200									'opdata' =>					['type' => XML_STRING, 'default' => ''],
1201									'url' =>					['type' => XML_STRING, 'default' => ''],
1202									'status' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::ENABLED, 'in' => [CXmlConstantValue::ENABLED => CXmlConstantName::ENABLED, CXmlConstantValue::DISABLED => CXmlConstantName::DISABLED]],
1203									'priority' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::NOT_CLASSIFIED, 'in' => $this->TRIGGER_PRIORITY],
1204									'description' =>			['type' => XML_STRING, 'default' => ''],
1205									'type' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::SINGLE, 'in' => [CXmlConstantValue::SINGLE => CXmlConstantName::SINGLE, CXmlConstantValue::MULTIPLE => CXmlConstantName::MULTIPLE]],
1206									'manual_close' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1207									'dependencies' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'dependency', 'rules' => [
1208										'dependency' =>				['type' => XML_ARRAY, 'rules' => [
1209											'name' =>					['type' => XML_STRING | XML_REQUIRED],
1210											'expression' =>				['type' => XML_STRING | XML_REQUIRED],
1211											'recovery_expression' =>	['type' => XML_STRING, 'default' => '']
1212										]]
1213									]],
1214									'tags' =>					['type' => XML_INDEXED_ARRAY, 'prefix' => 'tag', 'rules' => [
1215										'tag' =>					['type' => XML_ARRAY, 'rules' => [
1216											'tag' =>					['type' => XML_STRING | XML_REQUIRED],
1217											'value' =>					['type' => XML_STRING, 'default' => '']
1218										]]
1219									]]
1220								]]
1221							]]
1222						]]
1223					]],
1224					'discovery_rules' =>		['type' => XML_INDEXED_ARRAY, 'prefix' => 'discovery_rule', 'rules' => [
1225						'discovery_rule' =>			['type' => XML_ARRAY, 'rules' => [
1226							'name' =>					['type' => XML_STRING | XML_REQUIRED],
1227							'type' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::ITEM_TYPE_ZABBIX_PASSIVE, 'in' => $this->ITEM_TYPE_DRULE],
1228							'snmp_oid' =>				['type' => XML_STRING, 'default' => ''],
1229							'key' =>					['type' => XML_STRING | XML_REQUIRED],
1230							'delay' =>					['type' => XML_STRING, 'default' => '1m'],
1231							'status' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::ENABLED, 'in' => [CXmlConstantValue::ENABLED => CXmlConstantName::ENABLED, CXmlConstantValue::DISABLED => CXmlConstantName::DISABLED]],
1232							'allowed_hosts' =>			['type' => XML_STRING, 'default' => ''],
1233							'params' =>					['type' => XML_STRING, 'default' => ''],
1234							'ipmi_sensor' =>			['type' => XML_STRING, 'default' => ''],
1235							'authtype' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::NONE, 'ex_validate' => [$this, 'validateAuthType'], 'ex_rules' => [$this, 'getAuthTypeExtendedRules'], 'export' => [$this, 'itemAuthtypeExport']],
1236							'username' =>				['type' => XML_STRING, 'default' => ''],
1237							'password' =>				['type' => XML_STRING, 'default' => ''],
1238							'publickey' =>				['type' => XML_STRING, 'default' => ''],
1239							'privatekey' =>				['type' => XML_STRING, 'default' => ''],
1240							'filter' =>					['type' => XML_ARRAY, 'import' => [$this, 'itemFilterImport'], 'rules' => [
1241								'evaltype' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::AND_OR, 'in' => $this->EVALTPYE],
1242								'formula' =>				['type' => XML_STRING, 'default' => ''],
1243								'conditions' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'condition', 'rules' => [
1244									'condition' =>				['type' => XML_ARRAY, 'rules' => [
1245										'macro' =>					['type' => XML_STRING | XML_REQUIRED],
1246										'value' =>					['type' => XML_STRING, 'default' => ''],
1247										'operator' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::CONDITION_MATCHES_REGEX, 'in' => $this->FILTER_CONDITION_OPERATOR],
1248										'formulaid' =>				['type' => XML_STRING | XML_REQUIRED]
1249									]]
1250								]]
1251							]],
1252							'lifetime' =>				['type' => XML_STRING, 'default' => '30d'],
1253							'description' =>			['type' => XML_STRING, 'default' => ''],
1254							'item_prototypes' =>		['type' => XML_INDEXED_ARRAY, 'prefix' => 'item_prototype', 'rules' => [
1255								'item_prototype' =>			['type' => XML_ARRAY, 'rules' => [
1256									'name' =>					['type' => XML_STRING | XML_REQUIRED],
1257									'type' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::ITEM_TYPE_ZABBIX_PASSIVE, 'in' => $this->ITEM_TYPE],
1258									'snmp_oid' =>				['type' => XML_STRING, 'default' => ''],
1259									'key' =>					['type' => XML_STRING | XML_REQUIRED],
1260									'delay' =>					['type' => XML_STRING, 'default' => '1m'],
1261									'history' =>				['type' => XML_STRING, 'default' => '90d'],
1262									'trends' =>					['type' => XML_STRING, 'default' => '365d'],
1263									'status' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::ENABLED, 'in' => [CXmlConstantValue::ENABLED => CXmlConstantName::ENABLED, CXmlConstantValue::DISABLED => CXmlConstantName::DISABLED]],
1264									'discover' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::ITEM_DISCOVER, 'in' => [CXmlConstantValue::ITEM_DISCOVER => CXmlConstantName::DISCOVER, CXmlConstantValue::ITEM_NO_DISCOVER => CXmlConstantName::NO_DISCOVER]],
1265									'value_type' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::UNSIGNED, 'in' => $this->ITEM_VALUE_TYPE],
1266									'allowed_hosts' =>			['type' => XML_STRING, 'default' => ''],
1267									'units' =>					['type' => XML_STRING, 'default' => ''],
1268									'params' =>					['type' => XML_STRING, 'default' => ''],
1269									'ipmi_sensor' =>			['type' => XML_STRING, 'default' => ''],
1270									'authtype' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::NONE, 'ex_validate' => [$this, 'validateAuthType'], 'ex_rules' => [$this, 'getAuthTypeExtendedRules'], 'export' => [$this, 'itemAuthtypeExport']],
1271									'username' =>				['type' => XML_STRING, 'default' => ''],
1272									'password' =>				['type' => XML_STRING, 'default' => ''],
1273									'publickey' =>				['type' => XML_STRING, 'default' => ''],
1274									'privatekey' =>				['type' => XML_STRING, 'default' => ''],
1275									'description' =>			['type' => XML_STRING, 'default' => ''],
1276									'inventory_link' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NONE, 'in' => $this->ITEM_INVENTORY_LINK],
1277									'applications' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'application', 'rules' => [
1278										'application' =>			['type' => XML_ARRAY, 'rules' => [
1279											'name' =>					['type' => XML_STRING | XML_REQUIRED]
1280										]]
1281									]],
1282									'application_prototypes' =>	['type' => XML_INDEXED_ARRAY, 'prefix' => 'application_prototype', 'rules' => [
1283										'application_prototype' =>	['type' => XML_ARRAY, 'rules' => [
1284											'name' =>					['type' => XML_STRING | XML_REQUIRED]
1285										]]
1286									]],
1287									'valuemap' =>				['type' => XML_ARRAY, 'rules' => [
1288										'name' =>					['type' => XML_STRING | XML_REQUIRED]
1289									]],
1290									'logtimefmt' =>				['type' => XML_STRING, 'default' => ''],
1291									'preprocessing' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'step', 'rules' => [
1292										'step' =>					['type' => XML_ARRAY, 'rules' => [
1293											'type' =>					['type' => XML_STRING | XML_REQUIRED, 'in' => $this->PREPROCESSING_STEP_TYPE],
1294											'parameters' =>				['type' => XML_INDEXED_ARRAY | XML_REQUIRED, 'prefix' => 'parameter', 'export' => [$this, 'preprocessingParametersExport'], 'rules' => [
1295												'parameter' =>				['type' => XML_STRING, 'flags' => CImportDataNormalizer::EOL_LF]
1296											]],
1297											'error_handler' =>			['type' => XML_STRING, 'ex_default' => [$this, 'defaultPreprocErrHandler'], 'ex_validate' => [$this, 'validatePreprocErrHandler'], 'in' => $this->ITEM_PREPROCESSING_ERROR_HANDLER],
1298											'error_handler_params' =>	['type' => XML_STRING, 'default' => '']
1299										]]
1300									]],
1301									'jmx_endpoint' =>			['type' => XML_STRING, 'default' => ''],
1302									'master_item' =>			['type' => XML_ARRAY, 'ex_validate' => [$this, 'validateMasterItem'],  'rules' => [
1303										'key' =>					['type' => XML_STRING | XML_REQUIRED]
1304									]],
1305									'timeout' =>				['type' => XML_STRING, 'default' => '3s'],
1306									'url' =>					['type' => XML_STRING, 'default' => ''],
1307									'query_fields' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'query_field', 'rules' => [
1308										'query_field' =>			['type' => XML_ARRAY, 'rules' => [
1309											'name' =>					['type' => XML_STRING | XML_REQUIRED],
1310											'value' =>					['type' => XML_STRING, 'default' => '']
1311										]]
1312									]],
1313									'parameters' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'parameter', 'rules' => [
1314										'parameter' =>			['type' => XML_ARRAY, 'rules' => [
1315											'name' =>					['type' => XML_STRING | XML_REQUIRED],
1316											'value' =>					['type' => XML_STRING, 'default' => '']
1317										]]
1318									]],
1319									'posts' =>					['type' => XML_STRING, 'default' => ''],
1320									'status_codes' =>			['type' => XML_STRING, 'default' => '200'],
1321									'follow_redirects' =>		['type' => XML_STRING, 'default' => CXmlConstantValue::YES, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1322									'post_type' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::RAW, 'in' => $this->ITEM_POST_TYPE],
1323									'http_proxy' =>				['type' => XML_STRING, 'default' => ''],
1324									'headers' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'header', 'rules' => [
1325										'header' =>					['type' => XML_ARRAY, 'rules' => [
1326											'name' =>					['type' => XML_STRING | XML_REQUIRED],
1327											'value' =>					['type' => XML_STRING | XML_REQUIRED]
1328										]]
1329									]],
1330									'retrieve_mode' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::BODY, 'in' => $this->ITEM_RETRIEVE_MODE],
1331									'request_method' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::GET, 'in' => $this->ITEM_REQUEST_METHOD],
1332									'output_format' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::OUTPUT_FORMAT_RAW, 'in' => [CXmlConstantValue::OUTPUT_FORMAT_RAW => CXmlConstantName::RAW, CXmlConstantValue::OUTPUT_FORMAT_JSON => CXmlConstantName::JSON]],
1333									'allow_traps' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1334									'ssl_cert_file' =>			['type' => XML_STRING, 'default' => ''],
1335									'ssl_key_file' =>			['type' => XML_STRING, 'default' => ''],
1336									'ssl_key_password' =>		['type' => XML_STRING, 'default' => ''],
1337									'verify_peer' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1338									'verify_host' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1339									'trigger_prototypes' =>		['type' => XML_INDEXED_ARRAY, 'prefix' => 'trigger_prototype', 'rules' => [
1340										'trigger_prototype' =>		['type' => XML_ARRAY, 'rules' => [
1341											'expression' =>				['type' => XML_STRING | XML_REQUIRED],
1342											'recovery_mode' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::TRIGGER_EXPRESSION, 'in' => $this->TRIGGER_RECOVERY_MODE],
1343											'recovery_expression' =>	['type' => XML_STRING, 'default' => ''],
1344											'correlation_mode' =>		['type' => XML_STRING, 'default' => CXmlConstantValue::TRIGGER_DISABLED, 'in' => [CXmlConstantValue::TRIGGER_DISABLED => CXmlConstantName::DISABLED, CXmlConstantValue::TRIGGER_TAG_VALUE => CXmlConstantName::TAG_VALUE]],
1345											'correlation_tag' =>		['type' => XML_STRING, 'default' => ''],
1346											'name' =>					['type' => XML_STRING | XML_REQUIRED],
1347											'event_name' =>				['type' => XML_STRING, 'default' => ''],
1348											'opdata' =>					['type' => XML_STRING, 'default' => ''],
1349											'url' =>					['type' => XML_STRING, 'default' => ''],
1350											'status' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::ENABLED, 'in' => [CXmlConstantValue::ENABLED => CXmlConstantName::ENABLED, CXmlConstantValue::DISABLED => CXmlConstantName::DISABLED]],
1351											'discover' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::TRIGGER_DISCOVER, 'in' => [CXmlConstantValue::TRIGGER_DISCOVER => CXmlConstantName::DISCOVER, CXmlConstantValue::TRIGGER_NO_DISCOVER => CXmlConstantName::NO_DISCOVER]],
1352											'priority' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::NOT_CLASSIFIED, 'in' => $this->TRIGGER_PRIORITY],
1353											'description' =>			['type' => XML_STRING, 'default' => ''],
1354											'type' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::SINGLE, 'in' => [CXmlConstantValue::SINGLE => CXmlConstantName::SINGLE, CXmlConstantValue::MULTIPLE => CXmlConstantName::MULTIPLE]],
1355											'manual_close' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1356											'dependencies' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'dependency', 'rules' => [
1357												'dependency' =>				['type' => XML_ARRAY, 'rules' => [
1358													'name' =>					['type' => XML_STRING | XML_REQUIRED],
1359													'expression' =>				['type' => XML_STRING | XML_REQUIRED],
1360													'recovery_expression' =>	['type' => XML_STRING, 'default' => '']
1361												]]
1362											]],
1363											'tags' =>					['type' => XML_INDEXED_ARRAY, 'prefix' => 'tag', 'rules' => [
1364												'tag' =>					['type' => XML_ARRAY, 'rules' => [
1365													'tag' =>					['type' => XML_STRING | XML_REQUIRED],
1366													'value' =>					['type' => XML_STRING, 'default' => '']
1367												]]
1368											]]
1369										]]
1370									]]
1371								]]
1372							]],
1373							'trigger_prototypes' =>		['type' => XML_INDEXED_ARRAY, 'prefix' => 'trigger_prototype', 'rules' => [
1374								'trigger_prototype' =>		['type' => XML_ARRAY, 'rules' => [
1375									'expression' =>				['type' => XML_STRING | XML_REQUIRED],
1376									'recovery_mode' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::TRIGGER_EXPRESSION, 'in' => $this->TRIGGER_RECOVERY_MODE],
1377									'recovery_expression' =>	['type' => XML_STRING, 'default' => ''],
1378									'correlation_mode' =>		['type' => XML_STRING, 'default' => CXmlConstantValue::TRIGGER_DISABLED, 'in' => [CXmlConstantValue::TRIGGER_DISABLED => CXmlConstantName::DISABLED, CXmlConstantValue::TRIGGER_TAG_VALUE => CXmlConstantName::TAG_VALUE]],
1379									'correlation_tag' =>		['type' => XML_STRING, 'default' => ''],
1380									'name' =>					['type' => XML_STRING | XML_REQUIRED],
1381									'event_name' =>				['type' => XML_STRING, 'default' => ''],
1382									'opdata' =>					['type' => XML_STRING, 'default' => ''],
1383									'url' =>					['type' => XML_STRING, 'default' => ''],
1384									'status' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::ENABLED, 'in' => [CXmlConstantValue::ENABLED => CXmlConstantName::ENABLED, CXmlConstantValue::DISABLED => CXmlConstantName::DISABLED]],
1385									'discover' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::TRIGGER_DISCOVER, 'in' => [CXmlConstantValue::TRIGGER_DISCOVER => CXmlConstantName::DISCOVER, CXmlConstantValue::TRIGGER_NO_DISCOVER => CXmlConstantName::NO_DISCOVER]],
1386									'priority' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::NOT_CLASSIFIED, 'in' => $this->TRIGGER_PRIORITY],
1387									'description' =>			['type' => XML_STRING, 'default' => ''],
1388									'type' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::SINGLE, 'in' => [CXmlConstantValue::SINGLE => CXmlConstantName::SINGLE, CXmlConstantValue::MULTIPLE => CXmlConstantName::MULTIPLE]],
1389									'manual_close' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1390									'dependencies' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'dependency', 'rules' => [
1391										'dependency' =>				['type' => XML_ARRAY, 'rules' => [
1392											'name' =>					['type' => XML_STRING | XML_REQUIRED],
1393											'expression' =>				['type' => XML_STRING | XML_REQUIRED],
1394											'recovery_expression' =>	['type' => XML_STRING, 'default' => '']
1395										]]
1396									]],
1397									'tags' =>					['type' => XML_INDEXED_ARRAY, 'prefix' => 'tag', 'rules' => [
1398										'tag' =>					['type' => XML_ARRAY, 'rules' => [
1399											'tag' =>					['type' => XML_STRING | XML_REQUIRED],
1400											'value' =>					['type' => XML_STRING, 'default' => '']
1401										]]
1402									]]
1403								]]
1404							]],
1405							'graph_prototypes' =>		['type' => XML_INDEXED_ARRAY, 'prefix' => 'graph_prototype', 'rules' => [
1406								'graph_prototype' =>		['type' => XML_ARRAY, 'rules' => [
1407									'name' =>					['type' => XML_STRING | XML_REQUIRED],
1408									'width' =>					['type' => XML_STRING, 'default' => '900'],
1409									'height' =>					['type' => XML_STRING, 'default' => '200'],
1410									'yaxismin' =>				['type' => XML_STRING, 'default' => '0'],
1411									'yaxismax' =>				['type' => XML_STRING, 'default' => '100'],
1412									'show_work_period' =>		['type' => XML_STRING, 'default' => CXmlConstantValue::YES, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1413									'show_triggers' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::YES, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1414									'type' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::NORMAL, 'in' => $this->GRAPH_TYPE],
1415									'show_legend' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::YES, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1416									'show_3d' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1417									'percent_left' =>			['type' => XML_STRING, 'default' => '0'],
1418									'percent_right' =>			['type' => XML_STRING, 'default' => '0'],
1419									// The tag 'ymin_type_1' should be validated before the 'ymin_item_1' because it is used in 'ex_validate' method.
1420									'ymin_type_1' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::CALCULATED, 'in' => $this->GRAPH_Y_TYPE],
1421									'ymin_item_1' =>			['type' => 0, 'default' => '0', 'preprocessor' => [$this, 'transformZero2Array'], 'ex_validate' => [$this, 'validateYMinItem'], 'export' => [$this, 'graphMinItemExport']],
1422									// The tag 'ymax_type_1' should be validated before the 'ymax_item_1' because it is used in 'ex_validate' method.
1423									'ymax_type_1' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::CALCULATED, 'in' => $this->GRAPH_Y_TYPE],
1424									'ymax_item_1' =>			['type' => 0, 'default' => '0', 'preprocessor' => [$this, 'transformZero2Array'], 'ex_validate' => [$this, 'validateYMaxItem'], 'export' => [$this, 'graphMaxItemExport']],
1425									'graph_items' =>			['type' => XML_INDEXED_ARRAY | XML_REQUIRED, 'prefix' => 'graph_item', 'ex_validate' => [$this, 'validateGraphItems'], 'rules' => [
1426										'graph_item' =>				['type' => XML_ARRAY, 'rules' => [
1427											'sortorder' =>				['type' => XML_STRING, 'default' => '0'],
1428											'drawtype' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::SINGLE_LINE, 'in' => $this->GRAPH_GRAPH_ITEM_DRAWTYPE],
1429											'color' =>					['type' => XML_STRING, 'default' => '009600'],
1430											'yaxisside' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::LEFT, 'in' => $this->GRAPH_GRAPH_ITEM_YAXISSIDE],
1431											'calc_fnc' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::AVG, 'in' => $this->GRAPH_GRAPH_ITEM_CALC_FNC],
1432											'type' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::SIMPLE, 'in' => $this->GRAPH_GRAPH_ITEM_TYPE],
1433											'item' =>					['type' => XML_ARRAY | XML_REQUIRED, 'rules' => [
1434												'host' =>					['type' => XML_STRING | XML_REQUIRED],
1435												'key' =>					['type' => XML_STRING | XML_REQUIRED]
1436											]]
1437										]]
1438									]],
1439									'discover' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::GRAPH_DISCOVER, 'in' => [CXmlConstantValue::GRAPH_DISCOVER => CXmlConstantName::DISCOVER, CXmlConstantValue::GRAPH_NO_DISCOVER => CXmlConstantName::NO_DISCOVER]]
1440								]]
1441							]],
1442							'host_prototypes' =>		['type' => XML_INDEXED_ARRAY, 'prefix' => 'host_prototype', 'rules' => [
1443								'host_prototype' =>			['type' => XML_ARRAY, 'rules' => [
1444									'host' =>					['type' => XML_STRING | XML_REQUIRED],
1445									'name' =>					['type' => XML_STRING, 'default' => ''],
1446									'status' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::ENABLED, 'in' => [CXmlConstantValue::ENABLED => CXmlConstantName::ENABLED, CXmlConstantValue::DISABLED => CXmlConstantName::DISABLED]],
1447									'discover' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::HOST_DISCOVER, 'in' => [CXmlConstantValue::HOST_DISCOVER => CXmlConstantName::DISCOVER, CXmlConstantValue::HOST_NO_DISCOVER => CXmlConstantName::NO_DISCOVER]],
1448									'group_links' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'group_link', 'rules' => [
1449										'group_link' =>				['type' => XML_ARRAY, 'rules' => [
1450											'group' =>					['type' => XML_ARRAY | XML_REQUIRED, 'rules' => [
1451												'name' =>					['type' => XML_STRING | XML_REQUIRED]
1452											]]
1453										]]
1454									]],
1455									'group_prototypes' =>		['type' => XML_INDEXED_ARRAY, 'prefix' => 'group_prototype', 'rules' => [
1456										'group_prototype' =>		['type' => XML_ARRAY, 'rules' => [
1457											'name' =>					['type' => XML_STRING | XML_REQUIRED]
1458										]]
1459									]],
1460									'templates' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'template', 'rules' => [
1461										'template' =>				['type' => XML_ARRAY, 'rules' => [
1462											'name' =>					['type' => XML_STRING | XML_REQUIRED]
1463										]]
1464									]],
1465									'macros' =>					['type' => XML_INDEXED_ARRAY, 'prefix' => 'macro', 'rules' => [
1466										'macro' =>					['type' => XML_ARRAY, 'rules' => [
1467											'macro' =>					['type' => XML_STRING | XML_REQUIRED],
1468											'type' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::MACRO_TYPE_TEXT, 'in' => [CXmlConstantValue::MACRO_TYPE_TEXT => CXmlConstantName::MACRO_TYPE_TEXT, CXmlConstantValue::MACRO_TYPE_SECRET => CXmlConstantName::MACRO_TYPE_SECRET, CXmlConstantValue::MACRO_TYPE_VAULT => CXmlConstantName::MACRO_TYPE_VAULT]],
1469											'value' =>					['type' => XML_STRING, 'default' => ''],
1470											'description' =>			['type' => XML_STRING, 'default' => '']
1471										]]
1472									]],
1473									'tags' =>					['type' => XML_INDEXED_ARRAY, 'prefix' => 'tag', 'rules' => [
1474										'tag' =>					['type' => XML_ARRAY, 'rules' => [
1475											'tag' =>					['type' => XML_STRING | XML_REQUIRED],
1476											'value' =>					['type' => XML_STRING, 'default' => '']
1477										]]
1478									]],
1479									'custom_interfaces' =>		['type' => XML_STRING, 'default' => CXmlConstantValue::CUSTOM_INTERFACES_NO, 'in' => $this->CUSTOM_INTERFACES],
1480									'interfaces' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'interface', 'rules' => [
1481										'interface' =>				['type' => XML_ARRAY, 'rules' => [
1482											'default' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::YES, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1483											'type' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::ZABBIX, 'in' => [CXmlConstantValue::ZABBIX => CXmlConstantName::ZABBIX, CXmlConstantValue::SNMP => CXmlConstantName::SNMP, CXmlConstantValue::IPMI => CXmlConstantName::IPMI, CXmlConstantValue::JMX => CXmlConstantName::JMX]],
1484											'useip' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::YES, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1485											'ip' =>						['type' => XML_STRING, 'default' => '127.0.0.1'],
1486											'dns' =>					['type' => XML_STRING, 'default' => ''],
1487											'port' =>					['type' => XML_STRING, 'default' => '10050'],
1488											'details' =>				['type' => XML_ARRAY, 'rules' => [
1489												'version' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::SNMP_V2, 'in' => [CXmlConstantValue::SNMP_V1 => CXmlConstantName::SNMPV1, CXmlConstantValue::SNMP_V2 => CXmlConstantName::SNMPV2, CXmlConstantValue::SNMP_V3 => CXmlConstantName::SNMPV3]],
1490												'community' =>				['type' => XML_STRING, 'default' => ''],
1491												'contextname' =>			['type' => XML_STRING, 'default' => ''],
1492												'securityname' =>			['type' => XML_STRING, 'default' => ''],
1493												'securitylevel' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NOAUTHNOPRIV, 'in' => $this->ITEM_SNMPV3_SECURITYLEVEL],
1494												'authprotocol' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::SNMPV3_MD5, 'in' => [CXmlConstantValue::SNMPV3_MD5 => CXmlConstantName::MD5, CXmlConstantValue::SNMPV3_SHA1 => CXmlConstantName::SHA]],
1495												'authpassphrase' =>			['type' => XML_STRING, 'default' => ''],
1496												'privprotocol' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::SNMPV3_DES, 'in' => [CXmlConstantValue::SNMPV3_DES => CXmlConstantName::DES, CXmlConstantValue::SNMPV3_AES128 => CXmlConstantName::AES]],
1497												'privpassphrase' =>			['type' => XML_STRING, 'default' => ''],
1498												'bulk' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::YES, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]]
1499											]]
1500										]]
1501									]],
1502									'inventory_mode' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::INV_MODE_DISABLED, 'in' => $this->INVENTORY_MODE]
1503								]]
1504							]],
1505							'jmx_endpoint' =>			['type' => XML_STRING, 'default' => ''],
1506							'master_item' =>			['type' => XML_ARRAY, 'ex_validate' => [$this, 'validateMasterItem'], 'rules' => [
1507								'key' =>					['type' => XML_STRING | XML_REQUIRED]
1508							]],
1509							'timeout' =>				['type' => XML_STRING, 'default' => '3s'],
1510							'url' =>					['type' => XML_STRING, 'default' => ''],
1511							'query_fields' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'query_field', 'rules' => [
1512								'query_field' =>			['type' => XML_ARRAY, 'rules' => [
1513									'name' =>					['type' => XML_STRING | XML_REQUIRED],
1514									'value' =>					['type' => XML_STRING, 'default' => '']
1515								]]
1516							]],
1517							'parameters' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'parameter', 'rules' => [
1518								'parameter' =>			['type' => XML_ARRAY, 'rules' => [
1519									'name' =>					['type' => XML_STRING | XML_REQUIRED],
1520									'value' =>					['type' => XML_STRING, 'default' => '']
1521								]]
1522							]],
1523							'posts' =>					['type' => XML_STRING, 'default' => ''],
1524							'status_codes' =>			['type' => XML_STRING, 'default' => '200'],
1525							'follow_redirects' =>		['type' => XML_STRING, 'default' => CXmlConstantValue::YES, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1526							'post_type' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::RAW, 'in' => $this->ITEM_POST_TYPE],
1527							'http_proxy' =>				['type' => XML_STRING, 'default' => ''],
1528							'headers' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'header', 'rules' => [
1529								'header' =>					['type' => XML_ARRAY, 'rules' => [
1530									'name' =>					['type' => XML_STRING | XML_REQUIRED],
1531									'value' =>					['type' => XML_STRING | XML_REQUIRED]
1532								]]
1533							]],
1534							'retrieve_mode' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::BODY, 'in' => $this->ITEM_RETRIEVE_MODE],
1535							'request_method' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::GET, 'in' => $this->ITEM_REQUEST_METHOD],
1536							'allow_traps' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1537							'ssl_cert_file' =>			['type' => XML_STRING, 'default' => ''],
1538							'ssl_key_file' =>			['type' => XML_STRING, 'default' => ''],
1539							'ssl_key_password' =>		['type' => XML_STRING, 'default' => ''],
1540							'verify_peer' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1541							'verify_host' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1542							'lld_macro_paths' =>		['type' => XML_INDEXED_ARRAY, 'prefix' => 'lld_macro_path', 'rules' => [
1543								'lld_macro_path' =>			['type' => XML_ARRAY, 'rules' => [
1544									'lld_macro' =>				['type' => XML_STRING | XML_REQUIRED],
1545									'path' =>					['type' => XML_STRING | XML_REQUIRED]
1546								]]
1547							]],
1548							'preprocessing' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'step', 'rules' => [
1549								'step' =>					['type' => XML_ARRAY, 'rules' => [
1550									'type' =>					['type' => XML_STRING | XML_REQUIRED, 'in' => $this->PREPROCESSING_STEP_TYPE_DRULE],
1551									'parameters' =>				['type' => XML_INDEXED_ARRAY | XML_REQUIRED, 'prefix' => 'parameter', 'export' => [$this, 'preprocessingParametersExport'], 'rules' => [
1552										'parameter' =>				['type' => XML_STRING, 'flags' => CImportDataNormalizer::EOL_LF]
1553									]],
1554									'error_handler' =>			['type' => XML_STRING, 'ex_default' => [$this, 'defaultPreprocErrHandler'], 'ex_validate' => [$this, 'validatePreprocErrHandler'], 'in' => $this->ITEM_PREPROCESSING_ERROR_HANDLER],
1555									'error_handler_params' =>	['type' => XML_STRING, 'default' => '']
1556								]]
1557							]],
1558							'overrides'	=>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'override', 'rules' => [
1559								'override' =>				['type' => XML_ARRAY, 'rules' => [
1560									'name' =>					['type' => XML_STRING | XML_REQUIRED],
1561									'step' =>					['type' => XML_STRING | XML_REQUIRED],
1562									'stop' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::LLD_OVERRIDE_STOP_NO, 'in' => $this->LLD_OVERRIDE_STOP],
1563									'filter' =>					['type' => XML_ARRAY, 'rules' => [
1564										'evaltype' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::AND_OR, 'in' => $this->EVALTPYE],
1565										'formula' =>				['type' => XML_STRING, 'default' => ''],
1566										'conditions' =>				['type' => XML_INDEXED_ARRAY | XML_REQUIRED, 'prefix' => 'condition', 'rules' => [
1567											'condition' =>				['type' => XML_ARRAY | XML_REQUIRED, 'rules' => [
1568												'macro' =>					['type' => XML_STRING | XML_REQUIRED],
1569												'value' =>					['type' => XML_STRING, 'default' => ''],
1570												'operator' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::CONDITION_MATCHES_REGEX, 'in' => $this->FILTER_CONDITION_OPERATOR],
1571												'formulaid' =>				['type' => XML_STRING | XML_REQUIRED]
1572											]]
1573										]]
1574									]],
1575									'operations' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'operation', 'rules' => [
1576										'operation' =>				['type' => XML_ARRAY, 'rules' => [
1577											'operationobject' =>		['type' => XML_STRING, 'in' => $this->LLD_OVERRIDE_OPERATION_OBJECT],
1578											'operator' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::CONDITION_OPERATOR_EQUAL, 'in' => $this->CONDITION_OPERATOR],
1579											'value' =>					['type' => XML_STRING, 'default' => ''],
1580											'status' =>					['type' => XML_STRING, 'in' => [CXmlConstantValue::LLD_OVERRIDE_OPERATION_STATUS_ENABLED => CXmlConstantName::ENABLED, CXmlConstantValue::LLD_OVERRIDE_OPERATION_STATUS_DISABLED => CXmlConstantName::DISABLED]],
1581											'discover' =>				['type' => XML_STRING, 'in' => [CXmlConstantValue::LLD_OVERRIDE_OPERATION_DISCOVER => CXmlConstantName::DISCOVER, CXmlConstantValue::LLD_OVERRIDE_OPERATION_NO_DISCOVER => CXmlConstantName::NO_DISCOVER]],
1582											'delay' =>					['type' => XML_STRING, 'default' => ''],
1583											'history' =>				['type' => XML_STRING, 'default' => ''],
1584											'trends' =>					['type' => XML_STRING, 'default' => ''],
1585											'severity' =>				['type' => XML_STRING, 'in' => $this->TRIGGER_PRIORITY],
1586											'tags' =>					['type' => XML_INDEXED_ARRAY, 'prefix' => 'tag', 'rules' => [
1587												'tag' =>					['type' => XML_ARRAY, 'rules' => [
1588													'tag' =>					['type' => XML_STRING | XML_REQUIRED],
1589													'value' =>					['type' => XML_STRING, 'default' => '']
1590												]]
1591											]],
1592											'templates' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'template', 'rules' => [
1593												'template' =>				['type' => XML_ARRAY, 'rules' => [
1594													'name' =>					['type' => XML_STRING | XML_REQUIRED]
1595												]]
1596											]],
1597											'inventory_mode' =>			['type' => XML_STRING, 'in' => $this->INVENTORY_MODE]
1598										]]
1599									]]
1600								]]
1601							]]
1602						]]
1603					]],
1604					'httptests' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'httptest', 'rules' => [
1605						'httptest' =>				['type' => XML_ARRAY, 'rules' => [
1606							'name' =>					['type' => XML_STRING | XML_REQUIRED],
1607							'application' =>			['type' => XML_ARRAY, 'rules' => [
1608								'name' =>					['type' => XML_STRING | XML_REQUIRED]
1609							]],
1610							'delay' =>					['type' => XML_STRING, 'default' => '1m'],
1611							'attempts' =>				['type' => XML_STRING, 'default' => '1'],
1612							'agent' =>					['type' => XML_STRING, 'default' => 'Zabbix'],
1613							'http_proxy' =>				['type' => XML_STRING, 'default' => ''],
1614							'variables' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'variable', 'rules' => [
1615								'variable' =>				['type' => XML_ARRAY, 'rules' => [
1616									'name' =>					['type' => XML_STRING | XML_REQUIRED],
1617									'value' =>					['type' => XML_STRING | XML_REQUIRED]
1618								]]
1619							]],
1620							'headers' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'header', 'rules' => [
1621								'header' =>					['type' => XML_ARRAY, 'rules' => [
1622									'name' =>					['type' => XML_STRING | XML_REQUIRED],
1623									'value' =>					['type' => XML_STRING | XML_REQUIRED]
1624								]]
1625							]],
1626							'status' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::ENABLED, 'in' => [CXmlConstantValue::ENABLED => CXmlConstantName::ENABLED, CXmlConstantValue::DISABLED => CXmlConstantName::DISABLED]],
1627							'authentication' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NONE, 'in' => $this->HTTP_TEST_AUTHENTICATION],
1628							'http_user' =>				['type' => XML_STRING, 'default' => ''],
1629							'http_password' =>			['type' => XML_STRING, 'default' => ''],
1630							'verify_peer' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1631							'verify_host' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1632							'ssl_cert_file' =>			['type' => XML_STRING, 'default' => ''],
1633							'ssl_key_file' =>			['type' => XML_STRING, 'default' => ''],
1634							'ssl_key_password' =>		['type' => XML_STRING, 'default' => ''],
1635							'steps' =>					['type' => XML_INDEXED_ARRAY | XML_REQUIRED, 'prefix' => 'step', 'rules' => [
1636								'step' =>					['type' => XML_ARRAY, 'rules' => [
1637									'name' =>					['type' => XML_STRING | XML_REQUIRED],
1638									'url' =>					['type' => XML_STRING | XML_REQUIRED],
1639									'query_fields' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'query_field', 'rules' => [
1640										'query_field' =>			['type' => XML_ARRAY, 'rules' => [
1641											'name' =>					['type' => XML_STRING | XML_REQUIRED],
1642											'value' =>					['type' => XML_STRING, 'default' => '']
1643										]]
1644									]],
1645									'posts' =>					['type' => 0, 'ex_validate' => [$this, 'validateHttpPosts']],
1646									'variables' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'variable', 'rules' => [
1647										'variable' =>				['type' => XML_ARRAY, 'rules' => [
1648											'name' =>					['type' => XML_STRING | XML_REQUIRED],
1649											'value' =>					['type' => XML_STRING | XML_REQUIRED]
1650										]]
1651									]],
1652									'headers' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'header', 'rules' => [
1653										'header' =>					['type' => XML_ARRAY, 'rules' => [
1654											'name' =>					['type' => XML_STRING | XML_REQUIRED],
1655											'value' =>					['type' => XML_STRING | XML_REQUIRED]
1656										]]
1657									]],
1658									'follow_redirects' =>		['type' => XML_STRING, 'default' => CXmlConstantValue::YES, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1659									'retrieve_mode' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::BODY, 'in' => $this->ITEM_RETRIEVE_MODE],
1660									'timeout' =>				['type' => XML_STRING, 'default' => '15s'],
1661									'required' =>				['type' => XML_STRING, 'default' => ''],
1662									'status_codes' =>			['type' => XML_STRING, 'default' => '']
1663								]]
1664							]]
1665						]]
1666					]],
1667					'tags' =>					['type' => XML_INDEXED_ARRAY, 'prefix' => 'tag', 'rules' => [
1668						'tag' =>					['type' => XML_ARRAY, 'rules' => [
1669							'tag' =>					['type' => XML_STRING | XML_REQUIRED],
1670							'value' =>					['type' => XML_STRING, 'default' => '']
1671						]]
1672					]],
1673					'macros' =>					['type' => XML_INDEXED_ARRAY, 'prefix' => 'macro', 'rules' => [
1674						'macro' =>					['type' => XML_ARRAY, 'rules' => [
1675							'macro' =>					['type' => XML_STRING | XML_REQUIRED],
1676							'type' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::MACRO_TYPE_TEXT, 'in' => [CXmlConstantValue::MACRO_TYPE_TEXT => CXmlConstantName::MACRO_TYPE_TEXT, CXmlConstantValue::MACRO_TYPE_SECRET => CXmlConstantName::MACRO_TYPE_SECRET, CXmlConstantValue::MACRO_TYPE_VAULT => CXmlConstantName::MACRO_TYPE_VAULT]],
1677							'value' =>					['type' => XML_STRING, 'default' => ''],
1678							'description' =>			['type' => XML_STRING, 'default' => '']
1679						]]
1680					]],
1681					'dashboards' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'dashboard', 'rules' => [
1682						'dashboard' =>				['type' => XML_ARRAY, 'rules' => [
1683							'name' =>					['type' => XML_STRING | XML_REQUIRED],
1684							'widgets' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'widget', 'rules' => [
1685								'widget' =>					['type' => XML_ARRAY, 'rules' => [
1686									'type' =>					['type' => XML_STRING | XML_REQUIRED, 'in' => $this->DASHBOARD_WIDGET_TYPE],
1687									'name' =>					['type' => XML_STRING, 'default' => ''],
1688									'x' =>						['type' => XML_STRING, 'default' => '0'],
1689									'y' =>						['type' => XML_STRING, 'default' => '0'],
1690									'width' =>					['type' => XML_STRING, 'default' => '1'],
1691									'height' =>					['type' => XML_STRING, 'default' => '2'],
1692									'hide_header' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1693									'fields' =>					['type' => XML_INDEXED_ARRAY, 'prefix' => 'field', 'rules' => [
1694										'field' =>					['type' => XML_ARRAY, 'rules' => [
1695											'type' =>					['type' => XML_STRING | XML_REQUIRED, 'in' => $this->DASHBOARD_WIDGET_FIELD_TYPE],
1696											'name' =>					['type' => XML_STRING | XML_REQUIRED],
1697											'value' =>					['type' => XML_REQUIRED, 'ex_validate' => [$this, 'validateWidgetFieldValue'], 'ex_rules' => [$this, 'getWidgetFieldValueExtendedRules']]
1698										]]
1699									]]
1700								]]
1701							]]
1702						]]
1703					]]
1704				]]
1705			]],
1706			'triggers' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'trigger', 'rules' => [
1707				'trigger' =>				['type' => XML_ARRAY, 'rules' => [
1708					'expression' =>				['type' => XML_STRING | XML_REQUIRED],
1709					'recovery_mode' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::TRIGGER_EXPRESSION, 'in' => $this->TRIGGER_RECOVERY_MODE],
1710					'recovery_expression' =>	['type' => XML_STRING, 'default' => ''],
1711					'correlation_mode' =>		['type' => XML_STRING, 'default' => CXmlConstantValue::TRIGGER_DISABLED, 'in' => [CXmlConstantValue::TRIGGER_DISABLED => CXmlConstantName::DISABLED, CXmlConstantValue::TRIGGER_TAG_VALUE => CXmlConstantName::TAG_VALUE]],
1712					'correlation_tag' =>		['type' => XML_STRING, 'default' => ''],
1713					'name' =>					['type' => XML_STRING | XML_REQUIRED],
1714					'event_name' =>				['type' => XML_STRING, 'default' => ''],
1715					'opdata' =>					['type' => XML_STRING, 'default' => ''],
1716					'url' =>					['type' => XML_STRING, 'default' => ''],
1717					'status' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::ENABLED, 'in' => [CXmlConstantValue::ENABLED => CXmlConstantName::ENABLED, CXmlConstantValue::DISABLED => CXmlConstantName::DISABLED]],
1718					'priority' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::NOT_CLASSIFIED, 'in' => $this->TRIGGER_PRIORITY],
1719					'description' =>			['type' => XML_STRING, 'default' => ''],
1720					'type' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::SINGLE, 'in' => [CXmlConstantValue::SINGLE => CXmlConstantName::SINGLE, CXmlConstantValue::MULTIPLE => CXmlConstantName::MULTIPLE]],
1721					'manual_close' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1722					'dependencies' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'dependency', 'rules' => [
1723						'dependency' =>				['type' => XML_ARRAY, 'rules' => [
1724							'name' =>					['type' => XML_STRING | XML_REQUIRED],
1725							'expression' =>				['type' => XML_STRING | XML_REQUIRED],
1726							'recovery_expression' =>	['type' => XML_STRING, 'default' => '']
1727						]]
1728					]],
1729					'tags' =>					['type' => XML_INDEXED_ARRAY, 'prefix' => 'tag', 'rules' => [
1730						'tag' =>					['type' => XML_ARRAY, 'rules' => [
1731							'tag' =>					['type' => XML_STRING | XML_REQUIRED],
1732							'value' =>					['type' => XML_STRING, 'default' => '']
1733						]]
1734					]]
1735				]]
1736			]],
1737			'graphs' =>					['type' => XML_INDEXED_ARRAY, 'prefix' => 'graph', 'rules' => [
1738				'graph' =>					['type' => XML_ARRAY, 'rules' => [
1739					'name' =>					['type' => XML_STRING | XML_REQUIRED],
1740					'width' =>					['type' => XML_STRING, 'default' => '900'],
1741					'height' =>					['type' => XML_STRING, 'default' => '200'],
1742					'yaxismin' =>				['type' => XML_STRING, 'default' => '0'],
1743					'yaxismax' =>				['type' => XML_STRING, 'default' => '100'],
1744					'show_work_period' =>		['type' => XML_STRING, 'default' => CXmlConstantValue::YES, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1745					'show_triggers' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::YES, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1746					'type' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::NORMAL, 'in' => $this->GRAPH_TYPE],
1747					'show_legend' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::YES, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1748					'show_3d' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1749					'percent_left' =>			['type' => XML_STRING, 'default' => '0'],
1750					'percent_right' =>			['type' => XML_STRING, 'default' => '0'],
1751					// The tag 'ymin_type_1' should be validated before the 'ymin_item_1' because it is used in 'ex_validate' method.
1752					'ymin_type_1' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::CALCULATED, 'in' => $this->GRAPH_Y_TYPE],
1753					'ymin_item_1' =>			['type' => 0, 'default' => '0', 'preprocessor' => [$this, 'transformZero2Array'], 'ex_validate' => [$this, 'validateYMinItem'], 'export' => [$this, 'graphMinItemExport']],
1754					// The tag 'ymax_type_1' should be validated before the 'ymax_item_1' because it is used in 'ex_validate' method.
1755					'ymax_type_1' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::CALCULATED, 'in' => $this->GRAPH_Y_TYPE],
1756					'ymax_item_1' =>			['type' => 0, 'default' => '0', 'preprocessor' => [$this, 'transformZero2Array'], 'ex_validate' => [$this, 'validateYMaxItem'], 'export' => [$this, 'graphMaxItemExport']],
1757					'graph_items' =>			['type' => XML_INDEXED_ARRAY | XML_REQUIRED, 'prefix' => 'graph_item', 'ex_validate' => [$this, 'validateGraphItems'], 'rules' => [
1758						'graph_item' =>				['type' => XML_ARRAY, 'rules' => [
1759							'sortorder' =>				['type' => XML_STRING, 'default' => '0'],
1760							'drawtype' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::SINGLE_LINE, 'in' => $this->GRAPH_GRAPH_ITEM_DRAWTYPE],
1761							'color' =>					['type' => XML_STRING, 'default' => '009600'],
1762							'yaxisside' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::LEFT, 'in' => $this->GRAPH_GRAPH_ITEM_YAXISSIDE],
1763							'calc_fnc' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::AVG, 'in' => $this->GRAPH_GRAPH_ITEM_CALC_FNC],
1764							'type' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::SIMPLE, 'in' => $this->GRAPH_GRAPH_ITEM_TYPE],
1765							'item' =>					['type' => XML_ARRAY | XML_REQUIRED, 'rules' => [
1766								'host' =>					['type' => XML_STRING | XML_REQUIRED],
1767								'key' =>					['type' => XML_STRING | XML_REQUIRED]
1768							]]
1769						]]
1770					]]
1771				]]
1772			]],
1773			'images' =>					['type' => XML_INDEXED_ARRAY, 'prefix' => 'image', 'rules' => [
1774				'image' =>					['type' => XML_ARRAY, 'rules' => [
1775					'name' =>					['type' => XML_STRING | XML_REQUIRED],
1776					'imagetype' =>				['type' => XML_STRING | XML_REQUIRED],
1777					'encodedImage' =>			['type' => XML_STRING | XML_REQUIRED]
1778				]]
1779			]],
1780			'maps' =>					['type' => XML_INDEXED_ARRAY, 'prefix' => 'map', 'rules' => [
1781				'map' =>					['type' => XML_ARRAY, 'rules' => [
1782					'name' =>					['type' => XML_STRING | XML_REQUIRED],
1783					'width' =>					['type' => XML_STRING | XML_REQUIRED],
1784					'height' =>					['type' => XML_STRING | XML_REQUIRED],
1785					'label_type' =>				['type' => XML_STRING | XML_REQUIRED],
1786					'label_location' =>			['type' => XML_STRING | XML_REQUIRED],
1787					'highlight' =>				['type' => XML_STRING | XML_REQUIRED],
1788					'expandproblem' =>			['type' => XML_STRING | XML_REQUIRED],
1789					'markelements' =>			['type' => XML_STRING | XML_REQUIRED],
1790					'show_unack' =>				['type' => XML_STRING | XML_REQUIRED],
1791					'severity_min' =>			['type' => XML_STRING | XML_REQUIRED],
1792					'show_suppressed' =>		['type' => XML_STRING | XML_REQUIRED],
1793					'grid_size' =>				['type' => XML_STRING | XML_REQUIRED],
1794					'grid_show' =>				['type' => XML_STRING | XML_REQUIRED],
1795					'grid_align' =>				['type' => XML_STRING | XML_REQUIRED],
1796					'label_format' =>			['type' => XML_STRING | XML_REQUIRED],
1797					'label_type_host' =>		['type' => XML_STRING | XML_REQUIRED],
1798					'label_type_hostgroup' =>	['type' => XML_STRING | XML_REQUIRED],
1799					'label_type_trigger' =>		['type' => XML_STRING | XML_REQUIRED],
1800					'label_type_map' =>			['type' => XML_STRING | XML_REQUIRED],
1801					'label_type_image' =>		['type' => XML_STRING | XML_REQUIRED],
1802					'label_string_host' =>		['type' => XML_STRING | XML_REQUIRED],
1803					'label_string_hostgroup' =>	['type' => XML_STRING | XML_REQUIRED],
1804					'label_string_trigger' =>	['type' => XML_STRING | XML_REQUIRED],
1805					'label_string_map' =>		['type' => XML_STRING | XML_REQUIRED],
1806					'label_string_image' =>		['type' => XML_STRING | XML_REQUIRED],
1807					'expand_macros' =>			['type' => XML_STRING | XML_REQUIRED],
1808					'background' =>				['type' => XML_ARRAY | XML_REQUIRED, 'rules' => [
1809						'name' =>					['type' => XML_STRING]
1810					]],
1811					'iconmap' =>				['type' => XML_ARRAY | XML_REQUIRED, 'rules' => [
1812						'name' =>					['type' => XML_STRING]
1813					]],
1814					'urls' =>					['type' => XML_INDEXED_ARRAY | XML_REQUIRED, 'prefix' => 'url', 'rules' => [
1815						'url' =>					['type' => XML_ARRAY, 'rules' => [
1816							'name' =>					['type' => XML_STRING | XML_REQUIRED],
1817							'url' =>					['type' => XML_STRING | XML_REQUIRED],
1818							'elementtype' =>			['type' => XML_STRING | XML_REQUIRED]
1819						]]
1820					]],
1821					'selements' =>				['type' => XML_INDEXED_ARRAY | XML_REQUIRED, 'prefix' => 'selement', 'rules' => [
1822						'selement' =>				['type' => XML_ARRAY, 'rules' => [
1823							// The tag 'elementtype' should be validated before the 'elements' because it is used in 'ex_required' and 'ex_validate' methods.
1824							'elementtype' =>			['type' => XML_STRING | XML_REQUIRED],
1825							'elements' =>				['type' => 0, 'ex_required' => [$this, 'requiredMapElement'], 'ex_validate' => [$this, 'validateMapElements'], 'ex_rules' => [$this, 'getMapElementsExtendedRules'], 'export' => [$this, 'mapElementsExport']],
1826							'label' =>					['type' => XML_STRING | XML_REQUIRED],
1827							'label_location' =>			['type' => XML_STRING | XML_REQUIRED],
1828							'x' =>						['type' => XML_STRING | XML_REQUIRED],
1829							'y' =>						['type' => XML_STRING | XML_REQUIRED],
1830							'elementsubtype' =>			['type' => XML_STRING | XML_REQUIRED],
1831							'areatype' =>				['type' => XML_STRING | XML_REQUIRED],
1832							'width' =>					['type' => XML_STRING | XML_REQUIRED],
1833							'height' =>					['type' => XML_STRING | XML_REQUIRED],
1834							'viewtype' =>				['type' => XML_STRING | XML_REQUIRED],
1835							'use_iconmap' =>			['type' => XML_STRING | XML_REQUIRED],
1836							'selementid' =>				['type' => XML_STRING | XML_REQUIRED],
1837							'icon_off' =>				['type' => XML_ARRAY | XML_REQUIRED, 'rules' => [
1838								'name' =>					['type' => XML_STRING | XML_REQUIRED]
1839							]],
1840							'icon_on' =>				['type' => XML_ARRAY | XML_REQUIRED, 'rules' => [
1841								'name' =>					['type' => XML_STRING]
1842							]],
1843							'icon_disabled' =>			['type' => XML_ARRAY | XML_REQUIRED, 'rules' => [
1844								'name' =>					['type' => XML_STRING]
1845							]],
1846							'icon_maintenance' =>		['type' => XML_ARRAY | XML_REQUIRED, 'rules' => [
1847								'name' =>					['type' => XML_STRING]
1848							]],
1849							'application' =>			['type' => XML_STRING | XML_REQUIRED],
1850							'urls' =>					['type' => XML_INDEXED_ARRAY | XML_REQUIRED, 'prefix' => 'url', 'rules' => [
1851								'url' =>					['type' => XML_ARRAY, 'rules' => [
1852									'name' =>					['type' => XML_STRING | XML_REQUIRED],
1853									'url' =>					['type' => XML_STRING | XML_REQUIRED]
1854								]]
1855							]]
1856						]]
1857					]],
1858					'shapes' =>				['type' => XML_INDEXED_ARRAY | XML_REQUIRED, 'prefix' => 'shape', 'rules' => [
1859						'shape' =>				['type' => XML_ARRAY, 'rules' => [
1860							'type' =>				['type' => XML_STRING | XML_REQUIRED],
1861							'x' =>					['type' => XML_STRING | XML_REQUIRED],
1862							'y' =>					['type' => XML_STRING | XML_REQUIRED],
1863							'width' =>				['type' => XML_STRING | XML_REQUIRED],
1864							'height' =>				['type' => XML_STRING | XML_REQUIRED],
1865							'text' =>				['type' => XML_STRING | XML_REQUIRED],
1866							'font' =>				['type' => XML_STRING | XML_REQUIRED],
1867							'font_size' =>			['type' => XML_STRING | XML_REQUIRED],
1868							'font_color' =>			['type' => XML_STRING | XML_REQUIRED],
1869							'text_halign' =>		['type' => XML_STRING | XML_REQUIRED],
1870							'text_valign' =>		['type' => XML_STRING | XML_REQUIRED],
1871							'border_type' =>		['type' => XML_STRING | XML_REQUIRED],
1872							'border_width' =>		['type' => XML_STRING | XML_REQUIRED],
1873							'border_color' =>		['type' => XML_STRING | XML_REQUIRED],
1874							'background_color' =>	['type' => XML_STRING | XML_REQUIRED],
1875							'zindex' =>				['type' => XML_STRING | XML_REQUIRED]
1876						]]
1877					]],
1878					'lines' =>				['type' => XML_INDEXED_ARRAY | XML_REQUIRED, 'prefix' => 'line', 'rules' => [
1879						'line' =>				['type' => XML_ARRAY, 'rules' => [
1880							'x1' =>					['type' => XML_STRING | XML_REQUIRED],
1881							'y1' =>					['type' => XML_STRING | XML_REQUIRED],
1882							'x2' =>					['type' => XML_STRING | XML_REQUIRED],
1883							'y2' =>					['type' => XML_STRING | XML_REQUIRED],
1884							'line_type' =>			['type' => XML_STRING | XML_REQUIRED],
1885							'line_width' =>			['type' => XML_STRING | XML_REQUIRED],
1886							'line_color' =>			['type' => XML_STRING | XML_REQUIRED],
1887							'zindex' =>				['type' => XML_STRING | XML_REQUIRED]
1888						]]
1889					]],
1890					'links' =>					['type' => XML_INDEXED_ARRAY | XML_REQUIRED, 'prefix' => 'link', 'rules' => [
1891						'link' =>					['type' => XML_ARRAY, 'rules' => [
1892							'drawtype' =>				['type' => XML_STRING | XML_REQUIRED],
1893							'color' =>					['type' => XML_STRING | XML_REQUIRED],
1894							'label' =>					['type' => XML_STRING | XML_REQUIRED],
1895							'selementid1' =>			['type' => XML_STRING | XML_REQUIRED],
1896							'selementid2' =>			['type' => XML_STRING | XML_REQUIRED],
1897							'linktriggers' =>			['type' => XML_INDEXED_ARRAY | XML_REQUIRED, 'prefix' => 'linktrigger', 'rules' => [
1898								'linktrigger' =>            ['type' => XML_ARRAY, 'rules' => [
1899									'drawtype' =>				['type' => XML_STRING | XML_REQUIRED],
1900									'color' =>					['type' => XML_STRING | XML_REQUIRED],
1901									'trigger' =>				['type' => XML_ARRAY | XML_REQUIRED, 'rules' => [
1902										'description' =>			['type' => XML_STRING | XML_REQUIRED],
1903										'expression' =>				['type' => XML_STRING | XML_REQUIRED],
1904										'recovery_expression' =>	['type' => XML_STRING | XML_REQUIRED]
1905									]]
1906								]]
1907							]]
1908						]]
1909					]]
1910				]]
1911			]],
1912			'media_types' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'media_type', 'rules' => [
1913				'media_type' =>				['type' => XML_ARRAY, 'rules' => [
1914					'name' =>					['type' => XML_STRING | XML_REQUIRED],
1915					'type' =>					['type' => XML_STRING | XML_REQUIRED, 'in' => $this->MEDIA_TYPE],
1916					'smtp_server' =>			['type' => XML_STRING, 'default' => ''],
1917					'smtp_port' =>				['type' => XML_STRING, 'default' => '25'],
1918					'smtp_helo' =>				['type' => XML_STRING, 'default' => ''],
1919					'smtp_email' =>				['type' => XML_STRING, 'default' => ''],
1920					'smtp_security' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NONE, 'in' => [CXmlConstantValue::NONE => CXmlConstantName::NONE, CXmlConstantValue::STARTTLS => CXmlConstantName::STARTTLS, CXmlConstantValue::SSL_OR_TLS => CXmlConstantName::SSL_OR_TLS]],
1921					'smtp_verify_host' =>		['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1922					'smtp_verify_peer' =>		['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1923					'smtp_authentication' =>	['type' => XML_STRING, 'default' => CXmlConstantValue::SMTP_AUTHENTICATION_NONE, 'in' => $this->SMTP_AUTHENTICATION],
1924					'username' =>				['type' => XML_STRING, 'default' => ''],
1925					'password' =>				['type' => XML_STRING, 'default' => ''],
1926					'content_type' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::CONTENT_TYPE_HTML, 'in' => [CXmlConstantValue::CONTENT_TYPE_TEXT => CXmlConstantName::CONTENT_TYPE_TEXT, CXmlConstantValue::CONTENT_TYPE_HTML => CXmlConstantName::CONTENT_TYPE_HTML]],
1927					'script_name' =>			['type' => XML_STRING, 'default' => ''],
1928					'parameters' =>				['type' => 0, 'ex_validate' => [$this, 'validateMediaTypeParameters'], 'ex_rules' => [$this, 'getMediaTypeParametersExtendedRules'], 'export' => [$this, 'mediaTypeParametersExport']],
1929					'gsm_modem' =>				['type' => XML_STRING, 'default' => ''],
1930					'status' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::ENABLED, 'in' => [CXmlConstantValue::ENABLED => CXmlConstantName::ENABLED, CXmlConstantValue::DISABLED => CXmlConstantName::DISABLED]],
1931					'max_sessions' =>			['type' => XML_STRING, 'default' => '1'],
1932					'attempts' =>				['type' => XML_STRING, 'default' => '3'],
1933					'attempt_interval' =>		['type' => XML_STRING, 'default' => '10s'],
1934					'script' => 				['type' => XML_STRING, 'default' => ''],
1935					'timeout' => 				['type' => XML_STRING, 'default' => '30s'],
1936					'process_tags' => 			['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1937					'show_event_menu' => 		['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1938					'event_menu_url' => 		['type' => XML_STRING, 'default' => ''],
1939					'event_menu_name' => 		['type' => XML_STRING, 'default' => ''],
1940					'description' => 			['type' => XML_STRING, 'default' => ''],
1941					'message_templates' =>		['type' => XML_INDEXED_ARRAY, 'prefix' => 'message_template', 'rules' => [
1942						'message_template' =>		['type' => XML_ARRAY, 'rules' => [
1943							'event_source' =>			['type' => XML_STRING | XML_REQUIRED, 'in' => $this->EVENT_SOURCE],
1944							'operation_mode' =>			['type' => XML_STRING | XML_REQUIRED, 'in' => $this->OPERATION_MODE],
1945							'subject' =>				['type' => XML_STRING, 'default' => ''],
1946							'message' =>				['type' => XML_STRING, 'default' => '']
1947						]]
1948					]]
1949				]]
1950			]],
1951			'value_maps' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'value_map', 'rules' => [
1952				'value_map' =>				['type' => XML_ARRAY, 'rules' => [
1953					'name' =>					['type' => XML_STRING | XML_REQUIRED],
1954					'mappings' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'mapping', 'rules' => [
1955						'mapping' =>				['type' => XML_ARRAY, 'rules' => [
1956							'value' =>					['type' => XML_STRING, 'default' => ''],
1957							'newvalue' =>				['type' => XML_STRING, 'default' => '']
1958						]]
1959					]]
1960				]]
1961			]]
1962		]];
1963	}
1964
1965	/**
1966	 * Base validation function.
1967	 *
1968	 * @param array  $data  Import data.
1969	 * @param string $path  XML path (for error reporting).
1970	 *
1971	 * @throws Exception if $data does not correspond to validation rules.
1972	 *
1973	 * @return array  Validator does some manipulations for the incoming data. For example, converts empty tags to an
1974	 *                array, if desired. Converted array is returned.
1975	 */
1976	public function validate(array $data, $path) {
1977		return $this->doValidate($this->getSchema(), $data, $path);
1978	}
1979
1980	/**
1981	 * Validate date and time format.
1982	 *
1983	 * @param string $data         Import data.
1984	 * @param array  $parent_data  Data's parent array.
1985	 * @param string $path         XML path (for error reporting).
1986	 *
1987	 * @throws Exception if the date or time is invalid.
1988	 *
1989	 * @return string
1990	 */
1991	public function validateDateTime($data, array $parent_data = null, $path) {
1992		if (!preg_match('/^20[0-9]{2}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[01])T(2[0-3]|[01][0-9]):[0-5][0-9]:[0-5][0-9]Z$/', $data)) {
1993			throw new Exception(_s('Invalid tag "%1$s": %2$s.', $path, _s('"%1$s" is expected', _x('YYYY-MM-DDThh:mm:ssZ', 'XML date and time format'))));
1994		}
1995
1996		return $data;
1997	}
1998
1999	/**
2000	 * Checking the map element for requirement.
2001	 *
2002	 * @param array $parent_data  Data's parent array.
2003	 *
2004	 * @throws Exception if the check is failed.
2005	 *
2006	 * @return bool
2007	 */
2008	public function requiredMapElement(array $parent_data = null) {
2009		if (zbx_is_int($parent_data['elementtype'])) {
2010			switch ($parent_data['elementtype']) {
2011				case SYSMAP_ELEMENT_TYPE_HOST:
2012				case SYSMAP_ELEMENT_TYPE_MAP:
2013				case SYSMAP_ELEMENT_TYPE_TRIGGER:
2014				case SYSMAP_ELEMENT_TYPE_HOST_GROUP:
2015					return true;
2016			}
2017		}
2018
2019		return false;
2020	}
2021
2022	/**
2023	 * Validate map elements.
2024	 *
2025	 * @param array|string $data         Import data.
2026	 * @param array        $parent_data  Data's parent array.
2027	 * @param string       $path         XML path.
2028	 *
2029	 * @throws Exception if the map elements are invalid.
2030	 *
2031	 * @return array|string
2032	 */
2033	public function validateMapElements($data, array $parent_data = null, $path) {
2034		$rules = $this->getMapElementsExtendedRules($parent_data);
2035
2036		return $this->doValidate($rules, $data, $path);
2037	}
2038
2039	/**
2040	 * Chooses default value for preprocessing step error handler.
2041	 *
2042	 * @param array $parent_data  Data's parent array.
2043	 *
2044	 * @return int
2045	 */
2046	public function defaultPreprocErrHandler(array $parent_data): int {
2047		if ($parent_data['type'] == CXmlConstantValue::CHECK_NOT_SUPPORTED) {
2048			return CXmlConstantValue::DISCARD_VALUE;
2049		}
2050
2051		return CXmlConstantValue::ORIGINAL_ERROR;
2052	}
2053
2054	/**
2055	 * Validate "ymin_item_1" tag.
2056	 *
2057	 * @param string $data         Import data.
2058	 * @param array  $parent_data  Data's parent array.
2059	 * @param string $path         XML path.
2060	 *
2061	 * @throws Exception if the element is invalid.
2062	 *
2063	 * @return array
2064	 */
2065	public function validateYMinItem($data, array $parent_data = null, $path) {
2066		if (array_key_exists('ymin_type_1', $parent_data)) {
2067			if (($parent_data['ymin_type_1'] == GRAPH_YAXIS_TYPE_ITEM_VALUE || $parent_data['ymin_type_1'] == CXmlConstantName::ITEM)) {
2068				$rules = ['type' => XML_ARRAY, 'rules' => [
2069					'host' =>	['type' => XML_STRING | XML_REQUIRED],
2070					'key' =>	['type' => XML_STRING | XML_REQUIRED]
2071				]];
2072			}
2073			else {
2074				$rules = ['type' => XML_ARRAY, 'rules' => []];
2075			}
2076		}
2077		else {
2078			$rules = ['type' => XML_ARRAY, 'rules' => []];
2079		}
2080
2081		return $this->doValidate($rules, $data, $path);
2082	}
2083
2084	/**
2085	 * Validate "ymax_item_1" tag.
2086	 *
2087	 * @param string $data         Import data.
2088	 * @param array  $parent_data  Data's parent array.
2089	 * @param string $path         XML path.
2090	 *
2091	 * @throws Exception if the element is invalid.
2092	 *
2093	 * @return array
2094	 */
2095	public function validateYMaxItem($data, array $parent_data = null, $path) {
2096		if (array_key_exists('ymax_type_1', $parent_data)) {
2097			if (($parent_data['ymax_type_1'] == GRAPH_YAXIS_TYPE_ITEM_VALUE || $parent_data['ymax_type_1'] == CXmlConstantName::ITEM)) {
2098				$rules = ['type' => XML_ARRAY, 'rules' => [
2099					'host' =>	['type' => XML_STRING | XML_REQUIRED],
2100					'key' =>	['type' => XML_STRING | XML_REQUIRED]
2101				]];
2102			}
2103			else {
2104				$rules = ['type' => XML_ARRAY, 'rules' => []];
2105			}
2106		}
2107		else {
2108			$rules = ['type' => XML_ARRAY, 'rules' => []];
2109		}
2110
2111		return $this->doValidate($rules, $data, $path);
2112	}
2113
2114	/**
2115	 * Validate media type "parameters" tag.
2116	 *
2117	 * @param string $data         Import data.
2118	 * @param array  $parent_data  Data's parent array.
2119	 * @param string $path         XML path.
2120	 *
2121	 * @throws Exception if the element is invalid.
2122	 *
2123	 * @return array
2124	 */
2125	public function validateMediaTypeParameters($data, array $parent_data, $path) {
2126		$rules = $this->getMediaTypeParametersExtendedRules($parent_data);
2127
2128		return $this->doValidate($rules, $data, $path);
2129	}
2130
2131	/**
2132	 * Transforms tags containing zero into an empty array.
2133	 *
2134	 * @param mixed $value
2135	 *
2136	 * @return mixed  Converted value.
2137	 */
2138	public function transformZero2Array($value) {
2139		return ($value === '0') ? [] : $value;
2140	}
2141
2142	/**
2143	 * Validate "posts" tag of http test step.
2144	 *
2145	 * @param array|string $data         Import data.
2146	 * @param array        $parent_data  Data's parent array.
2147	 * @param string       $path         XML path.
2148	 *
2149	 * @throws Exception if the element is invalid.
2150	 *
2151	 * @return array
2152	 */
2153	public function validateHttpPosts($data, array $parent_data = null, $path) {
2154		if (is_array($data)) {
2155			// Posts can be an HTTP pair array.
2156			$rules = ['type' => XML_INDEXED_ARRAY, 'prefix' => 'post_field', 'rules' => [
2157				'post_field' =>	['type' => XML_ARRAY, 'rules' => [
2158					'name' =>		['type' => XML_STRING | XML_REQUIRED],
2159					'value' =>		['type' => XML_STRING | XML_REQUIRED]
2160				]]
2161			]];
2162		}
2163		else {
2164			// Posts can be string.
2165			$rules = ['type' => XML_STRING, 'default' => ''];
2166		}
2167
2168		return $this->doValidate($rules, $data, $path);
2169	}
2170
2171	/**
2172	 * Validate master item.
2173	 *
2174	 * @param string $data         Import data.
2175	 * @param array  $parent_data  Data's parent array.
2176	 * @param string $path         XML path.
2177	 *
2178	 * @throws Exception if the element is invalid.
2179	 *
2180	 * @return array
2181	 */
2182	public function validateMasterItem($data, array $parent_data = null, $path) {
2183		$prefix = substr(strrchr($path, '/'), 1);
2184		$rules = ['type' => XML_ARRAY | XML_REQUIRED, 'prefix' => $prefix, 'rules' => ['key' => ['type' => XML_STRING]]];
2185
2186		if ($parent_data['type'] == ITEM_TYPE_DEPENDENT) {
2187			$rules['rules']['key']['type'] |= XML_REQUIRED;
2188		}
2189
2190		return $this->doValidate($rules, $data, $path);
2191	}
2192
2193	/**
2194	 * Validate authtype.
2195	 *
2196	 * @param string $data         Import data.
2197	 * @param array  $parent_data  Data's parent array.
2198	 * @param string $path         XML path.
2199	 *
2200	 * @throws Exception if the element is invalid.
2201	 *
2202	 * @return array
2203	 */
2204	public function validateAuthType($data, array $parent_data = null, $path) {
2205		$rules = $this->getAuthTypeExtendedRules($parent_data);
2206
2207		return $this->doValidate($rules, $data, $path);
2208	}
2209
2210	/**
2211	 * Validate graph_items tag.
2212	 *
2213	 * @param array  $data         Import data.
2214	 * @param array  $parent_data  Data's parent array.
2215	 * @param string $path         XML path.
2216	 *
2217	 * @throws Exception if the element is invalid.
2218	 *
2219	 * @return array
2220	 */
2221	public function validateGraphItems(array $data, array $parent_data = null, $path) {
2222		if (!$data) {
2223			throw new Exception(_s('Invalid tag "%1$s": %2$s.', $path, _s('the tag "%1$s" is missing', 'graph_item')));
2224		}
2225
2226		return $data;
2227	}
2228
2229	/**
2230	 * Validate preprocessing step error handler.
2231	 *
2232	 * @param string|array $data         Import data.
2233	 * @param array        $parent_data  Data's parent array.
2234	 * @param string       $path         XML path.
2235	 *
2236	 * @throws Exception if the element is invalid.
2237	 *
2238	 * @return string|array
2239	 */
2240	public function validatePreprocErrHandler($data, array $parent_data, $path) {
2241		$in = $this->ITEM_PREPROCESSING_ERROR_HANDLER;
2242
2243		if ($parent_data['type'] == CXmlConstantName::CHECK_NOT_SUPPORTED) {
2244			unset($in[CXmlConstantValue::ORIGINAL_ERROR]);
2245		}
2246
2247		$rules = ['type' => XML_STRING, 'in' => $in];
2248
2249		return $this->doValidate($rules, $data, $path);
2250	}
2251
2252	/**
2253	 * Validate widget field "value" tag.
2254	 *
2255	 * @param string|array $data         Import data.
2256	 * @param array        $parent_data  Data's parent array.
2257	 * @param string       $path         XML path.
2258	 *
2259	 * @throws Exception if the element is invalid.
2260	 *
2261	 * @return string|array
2262	 */
2263	public function validateWidgetFieldValue($data, array $parent_data = null, string $path) {
2264		$rules = $this->getWidgetFieldValueExtendedRules($parent_data);
2265
2266		return $this->doValidate($rules, $data, $path);
2267	}
2268
2269	/**
2270	 * Get extended validation rules.
2271	 *
2272	 * @param array $data  Import data.
2273	 *
2274	 * @return array
2275	 */
2276	public function getAuthTypeExtendedRules(array $data) {
2277		if (array_key_exists('type', $data)) {
2278			if ($data['type'] == CXmlConstantValue::ITEM_TYPE_SSH || $data['type'] == CXmlConstantName::SSH) {
2279				return ['type' => XML_STRING, 'default' => CXmlConstantValue::PASSWORD, 'in' => [CXmlConstantValue::PASSWORD => CXmlConstantName::PASSWORD, CXmlConstantValue::PUBLIC_KEY => CXmlConstantName::PUBLIC_KEY]];
2280			}
2281		}
2282
2283		return ['type' => XML_STRING, 'default' => CXmlConstantValue::NONE, 'in' => [CXmlConstantValue::NONE => CXmlConstantName::NONE, CXmlConstantValue::BASIC => CXmlConstantName::BASIC, CXmlConstantValue::NTLM => CXmlConstantName::NTLM, CXmlConstantValue::KERBEROS => CXmlConstantName::KERBEROS, CXmlConstantValue::DIGEST => CXmlConstantName::DIGEST]];
2284	}
2285
2286	/**
2287	 * Get extended validation rules for map elements.
2288	 *
2289	 * @param array $data  Import data.
2290	 *
2291	 * @return array
2292	 */
2293	public function getMapElementsExtendedRules(array $data) {
2294		if (array_key_exists('elementtype', $data)) {
2295			switch ($data['elementtype']) {
2296				case SYSMAP_ELEMENT_TYPE_HOST:
2297					return ['type' => XML_INDEXED_ARRAY, 'prefix' => 'element', 'rules' => [
2298						'element' => ['type' => XML_ARRAY, 'rules' => [
2299							'host' =>					['type' => XML_STRING | XML_REQUIRED]
2300						]]
2301					]];
2302					// no break;
2303
2304				case SYSMAP_ELEMENT_TYPE_MAP:
2305				case SYSMAP_ELEMENT_TYPE_HOST_GROUP:
2306					return ['type' => XML_INDEXED_ARRAY, 'prefix' => 'element', 'rules' => [
2307						'element' => ['type' => XML_ARRAY, 'rules' => [
2308							'name' =>					['type' => XML_STRING | XML_REQUIRED]
2309						]]
2310					]];
2311					// no break;
2312
2313				case SYSMAP_ELEMENT_TYPE_TRIGGER:
2314					return ['type' => XML_INDEXED_ARRAY, 'prefix' => 'element', 'rules' => [
2315						'element' => ['type' => XML_ARRAY, 'rules' => [
2316							'description' =>			['type' => XML_STRING | XML_REQUIRED],
2317							'expression' =>				['type' => XML_STRING | XML_REQUIRED],
2318							'recovery_expression' =>	['type' => XML_STRING | XML_REQUIRED]
2319						]]
2320					]];
2321					// no break;
2322
2323				case SYSMAP_ELEMENT_TYPE_IMAGE:
2324					return ['type' => XML_ARRAY, 'rules' => []];
2325					// no break;
2326			}
2327		}
2328
2329		return ['type' => XML_ARRAY, 'rules' => []];
2330	}
2331
2332	/**
2333	 * Get extended validation rules for media type "parameters" tag.
2334	 *
2335	 * @param array $data  Import data.
2336	 *
2337	 * @return array
2338	 */
2339	public function getMediaTypeParametersExtendedRules(array $data) {
2340		switch ($data['type']) {
2341			case CXmlConstantName::SCRIPT:
2342			case CXmlConstantValue::MEDIA_TYPE_SCRIPT:
2343				return ['type' => XML_INDEXED_ARRAY, 'prefix' => 'parameter', 'rules' => [
2344					'parameter' => ['type' => XML_STRING]
2345				]];
2346
2347			case CXmlConstantName::WEBHOOK:
2348			case CXmlConstantValue::MEDIA_TYPE_WEBHOOK:
2349				return ['type' => XML_INDEXED_ARRAY, 'prefix' => 'parameter', 'rules' => [
2350					'parameter' => ['type' => XML_ARRAY, 'rules' => [
2351						'name' => ['type' => XML_STRING | XML_REQUIRED],
2352						'value' => ['type' => XML_STRING, 'default' => '']
2353					]]
2354				]];
2355
2356			default:
2357				return ['type' => XML_ARRAY, 'rules' => []];
2358		}
2359	}
2360
2361	/**
2362	 * Get extended validation rules for widget field "value" tag.
2363	 *
2364	 * @param array $data
2365	 *
2366	 * @return array
2367	 */
2368	public function getWidgetFieldValueExtendedRules(array $data): array {
2369		switch ($data['type']) {
2370			case CXmlConstantName::DASHBOARD_WIDGET_FIELD_TYPE_HOST:
2371			case CXmlConstantValue::DASHBOARD_WIDGET_FIELD_TYPE_HOST:
2372				return ['type' => XML_ARRAY, 'rules' => [
2373					'host' => ['type' => XML_STRING | XML_REQUIRED]
2374				]];
2375			case CXmlConstantName::DASHBOARD_WIDGET_FIELD_TYPE_ITEM:
2376			case CXmlConstantName::DASHBOARD_WIDGET_FIELD_TYPE_ITEM_PROTOTYPE:
2377			case CXmlConstantValue::DASHBOARD_WIDGET_FIELD_TYPE_ITEM:
2378			case CXmlConstantValue::DASHBOARD_WIDGET_FIELD_TYPE_ITEM_PROTOTYPE:
2379				return ['type' => XML_ARRAY, 'rules' => [
2380					'host' => ['type' => XML_STRING | XML_REQUIRED],
2381					'key' => ['type' => XML_STRING | XML_REQUIRED]
2382				]];
2383			case CXmlConstantName::DASHBOARD_WIDGET_FIELD_TYPE_GRAPH:
2384			case CXmlConstantName::DASHBOARD_WIDGET_FIELD_TYPE_GRAPH_PROTOTYPE:
2385			case CXmlConstantValue::DASHBOARD_WIDGET_FIELD_TYPE_GRAPH:
2386			case CXmlConstantValue::DASHBOARD_WIDGET_FIELD_TYPE_GRAPH_PROTOTYPE:
2387				return ['type' => XML_ARRAY, 'rules' => [
2388					'host' => ['type' => XML_STRING | XML_REQUIRED],
2389					'name' => ['type' => XML_STRING | XML_REQUIRED]
2390				]];
2391			default:
2392				return ['type' => XML_STRING | XML_REQUIRED];
2393		}
2394	}
2395
2396	/**
2397	 * Export check for ymax_item_1 if ymax_type_1 === ITEM.
2398	 *
2399	 * @param array $data  Export data.
2400	 *
2401	 * @throws Exception if the element is invalid.
2402	 *
2403	 * @return array
2404	 */
2405	public function graphMaxItemExport(array $data) {
2406		if ($data['ymax_type_1'] == CXmlConstantValue::ITEM
2407				&& array_key_exists('ymax_item_1', $data)
2408				&& (!array_key_exists('host', $data['ymax_item_1'])
2409					|| !array_key_exists('key', $data['ymax_item_1']))) {
2410			throw new Exception(_s('Invalid tag "%1$s": %2$s.', 'ymax_item_1', _('an array is expected')));
2411		}
2412
2413		return $data['ymax_item_1'];
2414	}
2415
2416	/**
2417	 * Export check for ymin_item_1 if ymin_type_1 === ITEM.
2418	 *
2419	 * @param array $data  Export data.
2420	 *
2421	 * @throws Exception if the element is invalid.
2422	 *
2423	 * @return array
2424	 */
2425	public function graphMinItemExport(array $data) {
2426		if ($data['ymin_type_1'] == CXmlConstantValue::ITEM
2427				&& array_key_exists('ymin_item_1', $data)
2428				&& (!array_key_exists('host', $data['ymin_item_1'])
2429					|| !array_key_exists('key', $data['ymin_item_1']))) {
2430			throw new Exception(_s('Invalid tag "%1$s": %2$s.', 'ymin_item_1', _('an array is expected')));
2431		}
2432
2433		return $data['ymin_item_1'];
2434	}
2435
2436	/**
2437	 * Export check for authtype tag.
2438	 *
2439	 * @param array $data  Export data.
2440	 *
2441	 * @throws Exception if the element is invalid.
2442	 *
2443	 * @return string Tag constant.
2444	 */
2445	public function itemAuthtypeExport(array $data) {
2446		if ($data['type'] != CXmlConstantValue::ITEM_TYPE_HTTP_AGENT
2447				&& $data['type'] != CXmlConstantValue::ITEM_TYPE_SSH) {
2448			return CXmlConstantName::NONE;
2449		}
2450
2451		$rules = $this->getAuthTypeExtendedRules($data);
2452
2453		if (!array_key_exists($data['authtype'], $rules['in'])) {
2454			throw new Exception(_s('Invalid tag "%1$s": %2$s.',
2455				'authtype', _s('unexpected constant value "%1$s"', $data['type'])
2456			));
2457		}
2458
2459		return $rules['in'][$data['authtype']];
2460	}
2461
2462	/**
2463	 * Export transformation for tls_accept tag.
2464	 *
2465	 * @param array $data  Export data.
2466	 *
2467	 * @throws Exception if the element is invalid.
2468	 *
2469	 * @return array
2470	 */
2471	public function hostTlsAcceptExport(array $data) {
2472		$consts = [
2473			CXmlConstantValue::NO_ENCRYPTION => [CXmlConstantName::NO_ENCRYPTION],
2474			CXmlConstantValue::TLS_PSK=> [CXmlConstantName::TLS_PSK],
2475			CXmlConstantValue::NO_ENCRYPTION | CXmlConstantValue::TLS_PSK => [
2476				CXmlConstantName::NO_ENCRYPTION,
2477				CXmlConstantName::TLS_PSK
2478			],
2479			CXmlConstantValue::TLS_CERTIFICATE => [CXmlConstantName::TLS_CERTIFICATE],
2480			CXmlConstantValue::NO_ENCRYPTION | CXmlConstantValue::TLS_CERTIFICATE => [
2481				CXmlConstantName::NO_ENCRYPTION,
2482				CXmlConstantName::TLS_CERTIFICATE
2483			],
2484			CXmlConstantValue::TLS_PSK | CXmlConstantValue::TLS_CERTIFICATE => [
2485				CXmlConstantName::TLS_PSK,
2486				CXmlConstantName::TLS_CERTIFICATE
2487			],
2488			CXmlConstantValue::NO_ENCRYPTION | CXmlConstantValue::TLS_PSK | CXmlConstantValue::TLS_CERTIFICATE => [
2489				CXmlConstantName::NO_ENCRYPTION,
2490				CXmlConstantName::TLS_PSK,
2491				CXmlConstantName::TLS_CERTIFICATE
2492			]
2493		];
2494
2495		if (!array_key_exists($data['tls_accept'], $consts)) {
2496			throw new Exception(_s('Invalid tag "%1$s": %2$s.',
2497				'tls_accept', _s('unexpected constant "%1$s"', $data['tls_accept'])
2498			));
2499		}
2500
2501		return $consts[$data['tls_accept']];
2502	}
2503
2504	/**
2505	 * Export transformation for media type "parameters" tag.
2506	 *
2507	 * @param array $data  Export data.
2508	 *
2509	 * @throws Exception if the element is invalid.
2510	 *
2511	 * @return array
2512	 */
2513	public function mediaTypeParametersExport(array $data) {
2514		switch ($data['type']) {
2515			case CXmlConstantValue::MEDIA_TYPE_SCRIPT:
2516				return $this->scriptParameterExport($data);
2517
2518			case CXmlConstantValue::MEDIA_TYPE_WEBHOOK:
2519				return $data['parameters'];
2520
2521			default:
2522				return [];
2523		}
2524	}
2525
2526	/**
2527	 * Import check for filter tag.
2528	 * API validation throws an error when filter tag is an empty array.
2529	 *
2530	 * @param array $data  Import data.
2531	 *
2532	 * @return array
2533	 */
2534	public function itemFilterImport(array $data) {
2535		if (!array_key_exists('filter', $data)) {
2536			return [
2537				'conditions' => '',
2538				'evaltype' => CXmlConstantName::AND_OR,
2539				'formula' => ''
2540			];
2541		}
2542
2543		return $data['filter'];
2544	}
2545
2546	/**
2547	 * Converts script parameters to an array.
2548	 *
2549	 * @param array  $data               Export data.
2550	 * @param string $data['parameters]  Script parameters.
2551	 *
2552	 * @return array
2553	 */
2554	public function scriptParameterExport(array $data) {
2555		return explode("\n", substr($data['parameters'], 0, -1));
2556	}
2557
2558	/**
2559	 * Function prepares map element for export builder.
2560	 *
2561	 * @param array $data  Export data.
2562	 *
2563	 * @throws Exception on invalid input.
2564	 *
2565	 * @return array
2566	 */
2567	public function mapElementsExport(array $data): array {
2568		$element_types = [SYSMAP_ELEMENT_TYPE_HOST, SYSMAP_ELEMENT_TYPE_MAP, SYSMAP_ELEMENT_TYPE_TRIGGER,
2569			SYSMAP_ELEMENT_TYPE_HOST_GROUP
2570		];
2571
2572		if (!array_key_exists('elementtype', $data) || !in_array($data['elementtype'], $element_types)) {
2573			throw new Exception(_s('Invalid tag "%1$s": %2$s.',
2574				'elementtype', _s('value must be one of %1$s', implode(', ', $element_types))
2575			));
2576		}
2577
2578		if (!array_key_exists('elements', $data) || !is_array($data['elements'])) {
2579			throw new Exception(_s('Invalid tag "%1$s": %2$s.', 'elements', _('an array is expected')));
2580		}
2581
2582		return ($data['elementtype'] == SYSMAP_ELEMENT_TYPE_TRIGGER)
2583			? array_map(function($trigger) {
2584					if (array_key_exists('expression', $trigger)) {
2585						$trigger['expression'] = str_replace("\r\n", "\n", $trigger['expression']);
2586					}
2587					if (array_key_exists('recovery_expression', $trigger)) {
2588						$trigger['recovery_expression'] = str_replace("\r\n", "\n", $trigger['recovery_expression']);
2589					}
2590					return $trigger;
2591				}, $data['elements'])
2592			: $data['elements'];
2593	}
2594
2595	/**
2596	 * Function prepares preprocessing parameters for export builder.
2597	 *
2598	 * @param array $data  Export data.
2599	 *
2600	 * @throws Exception on invalid input.
2601	 *
2602	 * @return array
2603	 */
2604	public function preprocessingParametersExport(array $data): array {
2605		return $data['parameters'];
2606	}
2607}
2608