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