diff -urN zabbix-2.0.0.orig/frontends/php/api/classes/CMap.php zabbix-2.0.0/frontends/php/api/classes/CMap.php
--- zabbix-2.0.0.orig/frontends/php/api/classes/CMap.php	2012-05-21 10:07:35.000000000 -0400
+++ zabbix-2.0.0/frontends/php/api/classes/CMap.php	2012-07-13 15:59:12.000000000 -0400
@@ -475,7 +475,7 @@
 				if (!isset($result[$link['sysmapid']]['links'])) {
 					$result[$link['sysmapid']]['links'] = array();
 				}
-
+				$link = $this->splitDrawtypeAndAnchors($link);
 				if (!is_null($options['preservekeys'])) {
 					$result[$link['sysmapid']]['links'][$link['linkid']] = $link;
 				}
@@ -783,6 +783,47 @@
 		return array('sysmapids' => $sysmapids);
 	}
 
+	/**
+	 * Split the database draw type to return the proper drawtype and anchors position.
+	 * In order to avoid modifying the database, we use the last digit to keep the drawtype and
+	 * store the anchor1 with the hundreds and anchor2 in decimals.
+	 *
+	 * @param array $selement an array containing the element data
+	 * @return the updated array containing the element data
+	 */
+	private function splitDrawtypeAndAnchors($link) {
+		if (!is_null($link['drawtype'])) {
+			# Anchor1 is stored in the hundreds
+			$link['anchor1'] = intval($link['drawtype']/100);
+		# Anchor2 is stored in the decimals
+		$link['anchor2'] = intval($link['drawtype']/10)%10;
+		# drawtype is stored in the units
+		$link['drawtype'] = $link['drawtype']%10;
+		}
+		return $link;
+	}
+	/**
+	 * Merge the drawtype and anchor fields to be stored in the database.
+	 * In order to avoid modifying the database, we use the last digit to keep the drawtype and
+	 * store the anchor1 with the hundreds and anchor2 in decimals.
+	 *
+	 * @param array $selements multidimensional array with elements data
+	 * @return the updated multidimensional array with elements data
+	 */
+	private function mergeDrawtypeAndAnchors($links) {
+		foreach (array_keys($links) as $key) {
+			if (key_exists('anchor1', $links[$key]) && !is_null($links[$key]['anchor1'])) {
+				$links[$key]['drawtype']+=$links[$key]['anchor1']*100;
+				unset($links[$key]['anchor1']);
+			}
+			if (key_exists('anchor2', $links[$key]) && !is_null($links[$key]['anchor2'])) {
+				$links[$key]['drawtype']+=$links[$key]['anchor2']*10;
+				unset($links[$key]['anchor2']);
+			}
+		}
+		return $links;
+	}
+
 /**
  * Update Map
  *
@@ -910,10 +951,12 @@
 
 		$newLinkids = $updLinkids = array('linkids' => array());
 		if (!empty($linksToAdd)) {
+			$linksToAdd=$this->mergeDrawtypeAndAnchors($linksToAdd);
 			$newLinkids = $this->createLinks($linksToAdd);
 		}
 
 		if (!empty($linksToUpdate)) {
+			$linksToUpdate=$this->mergeDrawtypeAndAnchors($linksToUpdate);
 			$updLinkids = $this->updateLinks($linksToUpdate);
 		}
 
diff -urN zabbix-2.0.0.orig/frontends/php/include/defines.inc.php zabbix-2.0.0/frontends/php/include/defines.inc.php
--- zabbix-2.0.0.orig/frontends/php/include/defines.inc.php	2012-05-21 10:07:27.000000000 -0400
+++ zabbix-2.0.0/frontends/php/include/defines.inc.php	2012-07-13 16:07:34.000000000 -0400
@@ -270,6 +270,12 @@
 define('MAP_LABEL_LOC_RIGHT',		2);
 define('MAP_LABEL_LOC_TOP',			3);
 
+define('MAP_LABEL_ALIGN_CENTER',0);
+define('MAP_LABEL_ALIGN_BOTTOM',1);
+define('MAP_LABEL_ALIGN_LEFT',2);
+define('MAP_LABEL_ALIGN_RIGHT',3);
+define('MAP_LABEL_ALIGN_TOP',4);
+
 define('SYSMAP_ELEMENT_TYPE_HOST',		0);
 define('SYSMAP_ELEMENT_TYPE_MAP',		1);
 define('SYSMAP_ELEMENT_TYPE_TRIGGER',	2);
diff -urN zabbix-2.0.0.orig/frontends/php/include/defines.inc.php.orig zabbix-2.0.0/frontends/php/include/defines.inc.php.orig
--- zabbix-2.0.0.orig/frontends/php/include/defines.inc.php.orig	1969-12-31 19:00:00.000000000 -0500
+++ zabbix-2.0.0/frontends/php/include/defines.inc.php.orig	2012-05-21 10:07:27.000000000 -0400
@@ -0,0 +1,915 @@
+<?php
+/*
+** Zabbix
+** Copyright (C) 2000-2011 Zabbix SIA
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+**/
+?>
+<?php
+define('ZABBIX_VERSION',		'2.0.0');
+define('ZABBIX_API_VERSION',	'1.4');
+
+define('ZBX_LOGIN_ATTEMPTS',			5);
+define('ZBX_LOGIN_BLOCK',				30); // sec
+
+define('ZBX_MIN_PERIOD',				3600); // 1 hour
+define('ZBX_MAX_PERIOD',				63072000); // the maximum period for the time bar control, ~2 years (2 * 365 * 86400)
+define('ZBX_PERIOD_DEFAULT',			3600); // 1 hour
+
+define('ZBX_WIDGET_ROWS',				20);
+
+define('ZBX_FONTPATH',					realpath('fonts')); // where to search for font (GD > 2.0.18)
+define('ZBX_GRAPH_FONT_NAME',			'DejaVuSans'); // font file name
+define('ZBX_GRAPH_LEGEND_HEIGHT',		120); // when graph height is less then this value, some legend will not show up
+
+define('ZBX_SCRIPT_TIMEOUT',			60); // in seconds
+define('ZBX_SCRIPT_BYTES_LIMIT',		1048576); // 1048576 is 1MB in bytes
+
+define('GRAPH_YAXIS_SIDE_DEFAULT',		0); // 0 - LEFT SIDE, 1 - RIGHT SIDE
+
+define('ZBX_MAX_IMAGE_SIZE',			1048576); // 1024 * 1024
+
+define('ZBX_UNITS_ROUNDOFF_THRESHOLD',		0.01);
+define('ZBX_UNITS_ROUNDOFF_UPPER_LIMIT',	2);
+define('ZBX_UNITS_ROUNDOFF_LOWER_LIMIT',	6);
+
+define('ZBX_DEFAULT_INTERVAL', '1-7,00:00-24:00');
+
+// for partitioned DB installs!!
+define('ZBX_HISTORY_DATA_UPKEEP',		-1); // in days; -1: disabled, 0: always use trends
+
+define('ZBX_SCRIPT_TYPE_CUSTOM_SCRIPT',	0);
+define('ZBX_SCRIPT_TYPE_IPMI',			1);
+define('ZBX_SCRIPT_TYPE_SSH',			2);
+define('ZBX_SCRIPT_TYPE_TELNET',		3);
+define('ZBX_SCRIPT_TYPE_GLOBAL_SCRIPT',	4);
+
+define('ZBX_SCRIPT_EXECUTE_ON_AGENT',	0);
+define('ZBX_SCRIPT_EXECUTE_ON_SERVER',	1);
+
+define('ZBX_FLAG_DISCOVERY_NORMAL',		0x0); // a normal item
+define('ZBX_FLAG_DISCOVERY',			0x1); // a low level discovery rule
+define('ZBX_FLAG_DISCOVERY_CHILD',		0x2); // an item prototype
+define('ZBX_FLAG_DISCOVERY_CREATED',	0x4); // an item created via a discovery rule
+
+define('EXTACK_OPTION_ALL',		0);
+define('EXTACK_OPTION_UNACK',	1);
+define('EXTACK_OPTION_BOTH',	2);
+
+define('TRIGGERS_OPTION_ONLYTRUE',	1);
+define('TRIGGERS_OPTION_ALL',		2);
+
+define('ZBX_ACK_STS_ANY',				1);
+define('ZBX_ACK_STS_WITH_UNACK',		2);
+define('ZBX_ACK_STS_WITH_LAST_UNACK',	3);
+
+define('EVENTS_OPTION_NOEVENT', 1);
+define('EVENTS_OPTION_ALL',		2);
+define('EVENTS_OPTION_NOT_ACK', 3);
+
+define('ZBX_FONT_NAME', 'DejaVuSans');
+
+define('ZBX_AUTH_INTERNAL',	0);
+define('ZBX_AUTH_LDAP',		1);
+define('ZBX_AUTH_HTTP',		2);
+
+define('ZBX_DB_DB2',		'IBM_DB2');
+define('ZBX_DB_MYSQL',		'MYSQL');
+define('ZBX_DB_ORACLE',		'ORACLE');
+define('ZBX_DB_POSTGRESQL',		'POSTGRESQL');
+define('ZBX_DB_SQLITE3',		'SQLITE3');
+
+define('PAGE_TYPE_HTML',			0);
+define('PAGE_TYPE_IMAGE',			1);
+define('PAGE_TYPE_XML',				2);
+define('PAGE_TYPE_JS',				3);	// javascript
+define('PAGE_TYPE_CSS',				4);
+define('PAGE_TYPE_HTML_BLOCK',		5);	// simple block of html (as text)
+define('PAGE_TYPE_JSON',			6);	// simple JSON
+define('PAGE_TYPE_JSON_RPC',		7);	// api call
+define('PAGE_TYPE_TEXT_FILE',		8);	// api call
+define('PAGE_TYPE_TEXT',			9); // simple text
+define('PAGE_TYPE_CSV',				10); // CSV format
+
+define('ZBX_SESSION_ACTIVE',		0);
+define('ZBX_SESSION_PASSIVE',		1);
+
+define('ZBX_DROPDOWN_FIRST_NONE',	0);
+define('ZBX_DROPDOWN_FIRST_ALL',	1);
+
+define('T_ZBX_STR',			0);
+define('T_ZBX_INT',			1);
+define('T_ZBX_DBL',			2);
+define('T_ZBX_PERIOD',		3);
+define('T_ZBX_IP',			4);
+define('T_ZBX_CLR',			5);
+define('T_ZBX_IP_RANGE',	7);
+define('T_ZBX_INT_RANGE',	8);
+
+define('O_MAND',			0);
+define('O_OPT',				1);
+define('O_NO',				2);
+
+define('P_SYS',				1);
+define('P_UNSET_EMPTY',		2);
+define('P_ACT',				16);
+define('P_NZERO',			32);
+
+//	misc parameters
+define('IMAGE_FORMAT_PNG',		'PNG');
+define('IMAGE_FORMAT_JPEG',		'JPEG');
+define('IMAGE_FORMAT_TEXT',		'JPEG');
+
+define('IMAGE_TYPE_UNKNOWN',		0);
+define('IMAGE_TYPE_ICON',			1);
+define('IMAGE_TYPE_BACKGROUND',		2);
+
+define('ITEM_CONVERT_WITH_UNITS',	0); // - do not convert empty units
+define('ITEM_CONVERT_NO_UNITS',		1); // - no units
+define('ITEM_CONVERT_SHORT_UNITS',	2); // - to short units
+define('ITEM_CONVERT_LONG_UNITS',	3); // - to long units
+
+define('ZBX_SORT_UP',			'ASC');
+define('ZBX_SORT_DOWN',			'DESC');
+
+define('AUDIT_ACTION_ADD',			0);
+define('AUDIT_ACTION_UPDATE',		1);
+define('AUDIT_ACTION_DELETE',		2);
+define('AUDIT_ACTION_LOGIN',		3);
+define('AUDIT_ACTION_LOGOUT',		4);
+define('AUDIT_ACTION_ENABLE',		5);
+define('AUDIT_ACTION_DISABLE',		6);
+
+define('AUDIT_RESOURCE_USER',			0);
+define('AUDIT_RESOURCE_ZABBIX_CONFIG',	2);
+define('AUDIT_RESOURCE_MEDIA_TYPE',		3);
+define('AUDIT_RESOURCE_HOST',			4);
+define('AUDIT_RESOURCE_ACTION',			5);
+define('AUDIT_RESOURCE_GRAPH',			6);
+define('AUDIT_RESOURCE_GRAPH_ELEMENT',	7);
+define('AUDIT_RESOURCE_USER_GROUP',		11);
+define('AUDIT_RESOURCE_APPLICATION',	12);
+define('AUDIT_RESOURCE_TRIGGER',		13);
+define('AUDIT_RESOURCE_HOST_GROUP',		14);
+define('AUDIT_RESOURCE_ITEM',			15);
+define('AUDIT_RESOURCE_IMAGE',			16);
+define('AUDIT_RESOURCE_VALUE_MAP',		17);
+define('AUDIT_RESOURCE_IT_SERVICE',		18);
+define('AUDIT_RESOURCE_MAP',			19);
+define('AUDIT_RESOURCE_SCREEN',			20);
+define('AUDIT_RESOURCE_NODE',			21);
+define('AUDIT_RESOURCE_SCENARIO',		22);
+define('AUDIT_RESOURCE_DISCOVERY_RULE',	23);
+define('AUDIT_RESOURCE_SLIDESHOW',		24);
+define('AUDIT_RESOURCE_SCRIPT',			25);
+define('AUDIT_RESOURCE_PROXY',			26);
+define('AUDIT_RESOURCE_MAINTENANCE',	27);
+define('AUDIT_RESOURCE_REGEXP',			28);
+define('AUDIT_RESOURCE_MACRO',			29);
+define('AUDIT_RESOURCE_TEMPLATE',		30);
+define('AUDIT_RESOURCE_TRIGGER_PROTOTYPE', 31);
+
+define('CONDITION_TYPE_HOST_GROUP',			0);
+define('CONDITION_TYPE_HOST',				1);
+define('CONDITION_TYPE_TRIGGER',			2);
+define('CONDITION_TYPE_TRIGGER_NAME',		3);
+define('CONDITION_TYPE_TRIGGER_SEVERITY',	4);
+define('CONDITION_TYPE_TRIGGER_VALUE',		5);
+define('CONDITION_TYPE_TIME_PERIOD',		6);
+define('CONDITION_TYPE_DHOST_IP',			7);
+define('CONDITION_TYPE_DSERVICE_TYPE',		8);
+define('CONDITION_TYPE_DSERVICE_PORT',		9);
+define('CONDITION_TYPE_DSTATUS',			10);
+define('CONDITION_TYPE_DUPTIME',			11);
+define('CONDITION_TYPE_DVALUE',				12);
+define('CONDITION_TYPE_HOST_TEMPLATE',		13);
+define('CONDITION_TYPE_EVENT_ACKNOWLEDGED',	14);
+define('CONDITION_TYPE_APPLICATION',		15);
+define('CONDITION_TYPE_MAINTENANCE',		16);
+define('CONDITION_TYPE_NODE',				17);
+define('CONDITION_TYPE_DRULE',				18);
+define('CONDITION_TYPE_DCHECK',				19);
+define('CONDITION_TYPE_PROXY',				20);
+define('CONDITION_TYPE_DOBJECT',			21);
+define('CONDITION_TYPE_HOST_NAME',			22);
+
+define('CONDITION_OPERATOR_EQUAL',		0);
+define('CONDITION_OPERATOR_NOT_EQUAL',	1);
+define('CONDITION_OPERATOR_LIKE',		2);
+define('CONDITION_OPERATOR_NOT_LIKE',	3);
+define('CONDITION_OPERATOR_IN',			4);
+define('CONDITION_OPERATOR_MORE_EQUAL',	5);
+define('CONDITION_OPERATOR_LESS_EQUAL',	6);
+define('CONDITION_OPERATOR_NOT_IN',		7);
+
+define('HOST_STATUS_MONITORED',		0);
+define('HOST_STATUS_NOT_MONITORED',	1);
+define('HOST_STATUS_TEMPLATE',		3);
+define('HOST_STATUS_PROXY_ACTIVE',	5);
+define('HOST_STATUS_PROXY_PASSIVE',	6);
+
+define('HOST_MAINTENANCE_STATUS_OFF',	0);
+define('HOST_MAINTENANCE_STATUS_ON',	1);
+
+define('INTERFACE_SECONDARY',	0);
+define('INTERFACE_PRIMARY',		1);
+
+define('INTERFACE_USE_DNS',		0);
+define('INTERFACE_USE_IP',		1);
+
+define('INTERFACE_TYPE_ANY',		-1);
+define('INTERFACE_TYPE_UNKNOWN',	0);
+define('INTERFACE_TYPE_AGENT',		1);
+define('INTERFACE_TYPE_SNMP',		2);
+define('INTERFACE_TYPE_IPMI',		3);
+define('INTERFACE_TYPE_JMX',		4);
+
+define('MAINTENANCE_STATUS_ACTIVE',		0);
+define('MAINTENANCE_STATUS_APPROACH',	1);
+define('MAINTENANCE_STATUS_EXPIRED',	2);
+
+define('HOST_AVAILABLE_UNKNOWN',	0);
+define('HOST_AVAILABLE_TRUE',		1);
+define('HOST_AVAILABLE_FALSE',		2);
+
+define('MAINTENANCE_TYPE_NORMAL',	0);
+define('MAINTENANCE_TYPE_NODATA',	1);
+
+define('TIMEPERIOD_TYPE_ONETIME',	0);
+define('TIMEPERIOD_TYPE_HOURLY',	1);
+define('TIMEPERIOD_TYPE_DAILY',		2);
+define('TIMEPERIOD_TYPE_WEEKLY',	3);
+define('TIMEPERIOD_TYPE_MONTHLY',	4);
+define('TIMEPERIOD_TYPE_YEARLY',	5);
+
+define('SYSMAP_LABEL_ADVANCED_OFF',		0);
+define('SYSMAP_LABEL_ADVANCED_ON',		1);
+
+define('MAP_LABEL_TYPE_LABEL',		0);
+define('MAP_LABEL_TYPE_IP',			1);
+define('MAP_LABEL_TYPE_NAME',		2);
+define('MAP_LABEL_TYPE_STATUS',		3);
+define('MAP_LABEL_TYPE_NOTHING',	4);
+define('MAP_LABEL_TYPE_CUSTOM',		5);
+
+define('MAP_LABEL_LOC_BOTTOM',		0);
+define('MAP_LABEL_LOC_LEFT',		1);
+define('MAP_LABEL_LOC_RIGHT',		2);
+define('MAP_LABEL_LOC_TOP',			3);
+
+define('SYSMAP_ELEMENT_TYPE_HOST',		0);
+define('SYSMAP_ELEMENT_TYPE_MAP',		1);
+define('SYSMAP_ELEMENT_TYPE_TRIGGER',	2);
+define('SYSMAP_ELEMENT_TYPE_HOST_GROUP',3);
+define('SYSMAP_ELEMENT_TYPE_IMAGE',		4);
+
+define('SYSMAP_ELEMENT_SUBTYPE_HOST_GROUP', 0);
+define('SYSMAP_ELEMENT_SUBTYPE_HOST_GROUP_ELEMENTS', 1);
+
+define('SYSMAP_ELEMENT_AREA_TYPE_FIT', 0);
+define('SYSMAP_ELEMENT_AREA_TYPE_CUSTOM', 1);
+
+define('SYSMAP_ELEMENT_AREA_VIEWTYPE_GRID', 0);
+
+define('SYSMAP_ELEMENT_ICON_ON',			0);
+define('SYSMAP_ELEMENT_ICON_OFF',			1);
+define('SYSMAP_ELEMENT_ICON_MAINTENANCE',	3);
+define('SYSMAP_ELEMENT_ICON_DISABLED',		4);
+
+define('SYSMAP_HIGHLIGHT_OFF',		0);
+define('SYSMAP_HIGHLIGHT_ON',		1);
+
+define('SYSMAP_EXPANDPROBLEM_OFF',		0);
+define('SYSMAP_EXPANDPROBLEM_ON',		1);
+
+define('SYSMAP_MARKELEMENTS_OFF',		0);
+define('SYSMAP_MARKELEMENTS_ON',		1);
+
+define('SYSMAP_GRID_SHOW_ON',		1);
+define('SYSMAP_GRID_SHOW_OFF',		0);
+
+define('SYSMAP_EXPAND_MACROS_OFF',	0);
+define('SYSMAP_EXPAND_MACROS_ON',	1);
+
+define('SYSMAP_GRID_ALIGN_ON',		1);
+define('SYSMAP_GRID_ALIGN_OFF',		0);
+
+define('ZBX_ITEM_DELAY_DEFAULT', 30);
+
+define('ITEM_TYPE_ZABBIX',			0);
+define('ITEM_TYPE_SNMPV1',			1);
+define('ITEM_TYPE_TRAPPER',			2);
+define('ITEM_TYPE_SIMPLE',			3);
+define('ITEM_TYPE_SNMPV2C',			4);
+define('ITEM_TYPE_INTERNAL',		5);
+define('ITEM_TYPE_SNMPV3',			6);
+define('ITEM_TYPE_ZABBIX_ACTIVE',	7);
+define('ITEM_TYPE_AGGREGATE',		8);
+define('ITEM_TYPE_HTTPTEST',		9);
+define('ITEM_TYPE_EXTERNAL',		10);
+define('ITEM_TYPE_DB_MONITOR',		11);
+define('ITEM_TYPE_IPMI',			12);
+define('ITEM_TYPE_SSH',				13);
+define('ITEM_TYPE_TELNET',			14);
+define('ITEM_TYPE_CALCULATED',		15);
+define('ITEM_TYPE_JMX',				16);
+
+define('ITEM_VALUE_TYPE_FLOAT',		0);
+define('ITEM_VALUE_TYPE_STR',		1);
+define('ITEM_VALUE_TYPE_LOG',		2);
+define('ITEM_VALUE_TYPE_UINT64',	3);
+define('ITEM_VALUE_TYPE_TEXT',		4);
+
+define('ITEM_DATA_TYPE_DECIMAL',		0);
+define('ITEM_DATA_TYPE_OCTAL',			1);
+define('ITEM_DATA_TYPE_HEXADECIMAL',	2);
+define('ITEM_DATA_TYPE_BOOLEAN',		3);
+
+define('ZBX_DEFAULT_KEY_DB_MONITOR',	'db.odbc.select[<unique short description>]');
+define('ZBX_DEFAULT_KEY_SSH',			'ssh.run[<unique short description>,<ip>,<port>,<encoding>]');
+define('ZBX_DEFAULT_KEY_TELNET',		'telnet.run[<unique short description>,<ip>,<port>,<encoding>]');
+define('ZBX_DEFAULT_KEY_JMX',			'jmx[<object name>,<attribute name>]');
+
+define('SYSMAP_ELEMENT_USE_ICONMAP_ON',		1);
+define('SYSMAP_ELEMENT_USE_ICONMAP_OFF',	0);
+
+define('ZBX_ICON_PREVIEW_HEIGHT',	24);
+define('ZBX_ICON_PREVIEW_WIDTH',	24);
+
+define('ITEM_STATUS_ACTIVE',		0);
+define('ITEM_STATUS_DISABLED',		1);
+define('ITEM_STATUS_NOTSUPPORTED',	3);
+
+define('ITEM_TYPE_SNMPTRAP',			17);
+
+define('ITEM_SNMPV3_SECURITYLEVEL_NOAUTHNOPRIV',	0);
+define('ITEM_SNMPV3_SECURITYLEVEL_AUTHNOPRIV',		1);
+define('ITEM_SNMPV3_SECURITYLEVEL_AUTHPRIV',		2);
+
+define('ITEM_AUTHTYPE_PASSWORD',	0);
+define('ITEM_AUTHTYPE_PUBLICKEY',	1);
+
+define('ITEM_LOGTYPE_INFORMATION',	1);
+define('ITEM_LOGTYPE_WARNING',		2);
+define('ITEM_LOGTYPE_ERROR',		4);
+define('ITEM_LOGTYPE_FAILURE_AUDIT',	7);
+define('ITEM_LOGTYPE_SUCCESS_AUDIT',	8);
+
+define('GRAPH_ITEM_DRAWTYPE_LINE',			0);
+define('GRAPH_ITEM_DRAWTYPE_FILLED_REGION',	1);
+define('GRAPH_ITEM_DRAWTYPE_BOLD_LINE',		2);
+define('GRAPH_ITEM_DRAWTYPE_DOT',			3);
+define('GRAPH_ITEM_DRAWTYPE_DASHED_LINE',	4);
+define('GRAPH_ITEM_DRAWTYPE_GRADIENT_LINE',	5);
+define('GRAPH_ITEM_DRAWTYPE_BOLD_DOT',		6);
+
+define('MAP_LINK_DRAWTYPE_LINE',			0);
+define('MAP_LINK_DRAWTYPE_BOLD_LINE',		2);
+define('MAP_LINK_DRAWTYPE_DOT',				3);
+define('MAP_LINK_DRAWTYPE_DASHED_LINE',		4);
+
+define('SERVICE_ALGORITHM_NONE',	0); // do not calculate
+define('SERVICE_ALGORITHM_MAX',		1); // problem, if one children has a problem
+define('SERVICE_ALGORITHM_MIN',		2); // problem, if all children have problems
+
+define('SERVICE_SLA', 99.05);
+
+define('SERVICE_SHOW_SLA_OFF', 0);
+define('SERVICE_SHOW_SLA_ON',  1);
+
+define('SERVICE_STATUS_OK',  0);
+
+define('TRIGGER_MULT_EVENT_DISABLED',	0);
+define('TRIGGER_MULT_EVENT_ENABLED',	1);
+
+define('TRIGGER_STATUS_ENABLED',	0);
+define('TRIGGER_STATUS_DISABLED',	1);
+
+define('TRIGGER_VALUE_FALSE',		0);
+define('TRIGGER_VALUE_TRUE',		1);
+define('TRIGGER_VALUE_UNKNOWN',		2); // only in "events" table
+
+define('TRIGGER_VALUE_FLAG_NORMAL',	0);
+define('TRIGGER_VALUE_FLAG_UNKNOWN',1);
+
+define('TRIGGER_VALUE_CHANGED_NO',	0);
+define('TRIGGER_VALUE_CHANGED_YES',	1);
+
+define('TRIGGER_SEVERITY_NOT_CLASSIFIED',	0);
+define('TRIGGER_SEVERITY_INFORMATION',		1);
+define('TRIGGER_SEVERITY_WARNING',			2);
+define('TRIGGER_SEVERITY_AVERAGE',			3);
+define('TRIGGER_SEVERITY_HIGH',				4);
+define('TRIGGER_SEVERITY_DISASTER',			5);
+
+define('TRIGGER_SEVERITY_COUNT',			6);
+
+define('ALERT_MAX_RETRIES',		3);
+
+define('ALERT_STATUS_NOT_SENT',		0);
+define('ALERT_STATUS_SENT',			1);
+define('ALERT_STATUS_FAILED',		2);
+
+define('ALERT_TYPE_MESSAGE',		0);
+define('ALERT_TYPE_COMMAND',		1);
+
+define('MEDIA_TYPE_STATUS_ACTIVE',	0);
+define('MEDIA_TYPE_STATUS_DISABLED',1);
+
+define('MEDIA_TYPE_EMAIL',		0);
+define('MEDIA_TYPE_EXEC',		1);
+define('MEDIA_TYPE_SMS',		2);
+define('MEDIA_TYPE_JABBER',		3);
+define('MEDIA_TYPE_EZ_TEXTING',	100);
+
+define('EZ_TEXTING_LIMIT_USA',		0);
+define('EZ_TEXTING_LIMIT_CANADA',	1);
+
+define('ACTION_DEFAULT_SUBJ_TRIGGER', '{TRIGGER.STATUS}: {TRIGGER.NAME}');
+define('ACTION_DEFAULT_SUBJ_AUTOREG', 'Auto registration: {HOST.HOST}');
+define('ACTION_DEFAULT_SUBJ_DISCOVERY', 'Discovery: {DISCOVERY.DEVICE.STATUS} {DISCOVERY.DEVICE.IPADDRESS}');
+
+define('ACTION_DEFAULT_MSG_TRIGGER', "Trigger: {TRIGGER.NAME}\nTrigger status: {TRIGGER.STATUS}\n".
+		"Trigger severity: {TRIGGER.SEVERITY}\nTrigger URL: {TRIGGER.URL}\n\nItem values:\n\n".
+		"1. {ITEM.NAME1} ({HOST.NAME1}:{ITEM.KEY1}): {ITEM.VALUE1}\n".
+		"2. {ITEM.NAME2} ({HOST.NAME2}:{ITEM.KEY2}): {ITEM.VALUE2}\n".
+		"3. {ITEM.NAME3} ({HOST.NAME3}:{ITEM.KEY3}): {ITEM.VALUE3}"
+);
+define('ACTION_DEFAULT_MSG_AUTOREG', "Host name: {HOST.HOST}\nHost IP: {HOST.IP}\nAgent port: {HOST.PORT}");
+define('ACTION_DEFAULT_MSG_DISCOVERY', "Discovery rule: {DISCOVERY.RULE.NAME}\n\nDevice IP:{DISCOVERY.DEVICE.IPADDRESS}\n".
+		"Device DNS: {DISCOVERY.DEVICE.DNS}\nDevice status: {DISCOVERY.DEVICE.STATUS}\n".
+		"Device uptime: {DISCOVERY.DEVICE.UPTIME}\n\nDevice service name: {DISCOVERY.SERVICE.NAME}\n".
+		"Device service port: {DISCOVERY.SERVICE.PORT}\nDevice service status: {DISCOVERY.SERVICE.STATUS}\n".
+		"Device service uptime: {DISCOVERY.SERVICE.UPTIME}"
+);
+
+define('ACTION_STATUS_ENABLED',		0);
+define('ACTION_STATUS_DISABLED',	1);
+
+define('OPERATION_TYPE_MESSAGE',		0);
+define('OPERATION_TYPE_COMMAND',		1);
+define('OPERATION_TYPE_HOST_ADD',		2);
+define('OPERATION_TYPE_HOST_REMOVE',	3);
+define('OPERATION_TYPE_GROUP_ADD',		4);
+define('OPERATION_TYPE_GROUP_REMOVE',	5);
+define('OPERATION_TYPE_TEMPLATE_ADD',	6);
+define('OPERATION_TYPE_TEMPLATE_REMOVE',7);
+define('OPERATION_TYPE_HOST_ENABLE',	8);
+define('OPERATION_TYPE_HOST_DISABLE',	9);
+
+define('ACTION_EVAL_TYPE_AND_OR',	0);
+define('ACTION_EVAL_TYPE_AND',		1);
+define('ACTION_EVAL_TYPE_OR',		2);
+
+define('OPERATION_OBJECT_USER',		0);
+define('OPERATION_OBJECT_GROUP',	1);
+
+define('LOGFILE_SEVERITY_NOT_CLASSIFIED',	0);
+define('LOGFILE_SEVERITY_INFORMATION',		1);
+define('LOGFILE_SEVERITY_WARNING',			2);
+define('LOGFILE_SEVERITY_AVERAGE',			3);
+define('LOGFILE_SEVERITY_HIGH',				4);
+define('LOGFILE_SEVERITY_DISASTER',			5);
+define('LOGFILE_SEVERITY_AUDIT_SUCCESS',	6);
+define('LOGFILE_SEVERITY_AUDIT_FAILURE',	7);
+
+define('SCREEN_SIMPLE_ITEM',		0);
+define('SCREEN_DYNAMIC_ITEM',		1);
+
+define('SCREEN_RESOURCE_GRAPH',				0);
+define('SCREEN_RESOURCE_SIMPLE_GRAPH',		1);
+define('SCREEN_RESOURCE_MAP',				2);
+define('SCREEN_RESOURCE_PLAIN_TEXT',		3);
+define('SCREEN_RESOURCE_HOSTS_INFO',		4);
+define('SCREEN_RESOURCE_TRIGGERS_INFO',		5);
+define('SCREEN_RESOURCE_SERVER_INFO',		6);
+define('SCREEN_RESOURCE_CLOCK',				7);
+define('SCREEN_RESOURCE_SCREEN',			8);
+define('SCREEN_RESOURCE_TRIGGERS_OVERVIEW',	9);
+define('SCREEN_RESOURCE_DATA_OVERVIEW',		10);
+define('SCREEN_RESOURCE_URL',				11);
+define('SCREEN_RESOURCE_ACTIONS',			12);
+define('SCREEN_RESOURCE_EVENTS',			13);
+define('SCREEN_RESOURCE_HOSTGROUP_TRIGGERS',14);
+define('SCREEN_RESOURCE_SYSTEM_STATUS',		15);
+define('SCREEN_RESOURCE_HOST_TRIGGERS',		16);
+
+define('SCREEN_TYPE_NORMAL',	0);
+define('SCREEN_TYPE_TEMPLATED',	1);
+
+define('DEFAULT_LATEST_ISSUES_CNT', 20);
+
+define('SCREEN_SORT_TRIGGERS_DATE_DESC',		0);
+define('SCREEN_SORT_TRIGGERS_SEVERITY_DESC',	1);
+define('SCREEN_SORT_TRIGGERS_HOST_NAME_ASC',	2);
+
+// alignes
+define('HALIGN_DEFAULT',	0);
+define('HALIGN_CENTER',		0);
+define('HALIGN_LEFT',		1);
+define('HALIGN_RIGHT',		2);
+
+define('VALIGN_DEFAULT',	0);
+define('VALIGN_MIDDLE',		0);
+define('VALIGN_TOP',		1);
+define('VALIGN_BOTTOM',		2);
+
+// info module style
+define('STYLE_HORISONTAL',	0);
+define('STYLE_VERTICAL',	1);
+
+// view style [Overview]
+define('STYLE_LEFT',	0);
+define('STYLE_TOP',		1);
+
+// time module type
+define('TIME_TYPE_LOCAL',	0);
+define('TIME_TYPE_SERVER',	1);
+define('TIME_TYPE_HOST',	2);
+
+define('FILTER_TASK_SHOW',			0);
+define('FILTER_TASK_HIDE',			1);
+define('FILTER_TASK_MARK',			2);
+define('FILTER_TASK_INVERT_MARK',	3);
+
+define('MARK_COLOR_RED',	1);
+define('MARK_COLOR_GREEN',	2);
+define('MARK_COLOR_BLUE',	3);
+
+define('PROFILE_TYPE_UNKNOWN',		0);
+define('PROFILE_TYPE_ID',			1);
+define('PROFILE_TYPE_INT',			2);
+define('PROFILE_TYPE_STR',			3);
+define('PROFILE_TYPE_ARRAY_ID',		4);
+define('PROFILE_TYPE_ARRAY_INT',	5);
+define('PROFILE_TYPE_ARRAY_STR',	6);
+
+define('CALC_FNC_MIN',	1);
+define('CALC_FNC_AVG',	2);
+define('CALC_FNC_MAX',	4);
+define('CALC_FNC_ALL',	7);
+define('CALC_FNC_LST',	9);
+
+define('SERVICE_TIME_TYPE_UPTIME',				0);
+define('SERVICE_TIME_TYPE_DOWNTIME',			1);
+define('SERVICE_TIME_TYPE_ONETIME_DOWNTIME',	2);
+
+define('USER_TYPE_ZABBIX_USER',		1);
+define('USER_TYPE_ZABBIX_ADMIN',	2);
+define('USER_TYPE_SUPER_ADMIN',		3);
+
+define('ZBX_NOT_INTERNAL_GROUP',	0);
+define('ZBX_INTERNAL_GROUP',		1);
+
+define('GROUP_STATUS_DISABLED',		1);
+define('GROUP_STATUS_ENABLED',		0);
+
+// IMPORTANT!!! by priority DESC
+define('GROUP_GUI_ACCESS_SYSTEM',	0);
+define('GROUP_GUI_ACCESS_INTERNAL',	1);
+define('GROUP_GUI_ACCESS_DISABLED',	2);
+
+define('GROUP_API_ACCESS_DISABLED',	0);
+define('GROUP_API_ACCESS_ENABLED',	1);
+
+define('GROUP_DEBUG_MODE_DISABLED',	0);
+define('GROUP_DEBUG_MODE_ENABLED',	1);
+
+define('PERM_MAX',			3);
+define('PERM_READ_WRITE',	3);
+define('PERM_READ_ONLY',	2);
+define('PERM_READ_LIST',	1);
+define('PERM_DENY',			0);
+
+define('PERM_RES_STRING_LINE',	0); // return string of nodes id - '1,2,3,4,5'
+define('PERM_RES_IDS_ARRAY',	1); // return array of nodes id - array(1,2,3,4)
+define('PERM_RES_DATA_ARRAY',	2);
+
+define('RESOURCE_TYPE_NODE',	0);
+define('RESOURCE_TYPE_GROUP',	1);
+
+define('PARAM_TYPE_SECONDS',	0);
+define('PARAM_TYPE_COUNTS',		1);
+
+define('ZBX_NODE_CHILD',	0);
+define('ZBX_NODE_LOCAL',	1);
+define('ZBX_NODE_MASTER',	2);
+
+define('ZBX_FLAG_TRIGGER',	0);
+define('ZBX_FLAG_EVENT',	1);
+
+define('HTTPTEST_AUTH_NONE',	0);
+define('HTTPTEST_AUTH_BASIC',	1);
+define('HTTPTEST_AUTH_NTLM',	2);
+
+define('HTTPTEST_STATUS_ACTIVE',	0);
+define('HTTPTEST_STATUS_DISABLED',	1);
+
+define('HTTPSTEP_ITEM_TYPE_RSPCODE',	0);
+define('HTTPSTEP_ITEM_TYPE_TIME',		1);
+define('HTTPSTEP_ITEM_TYPE_IN',			2);
+define('HTTPSTEP_ITEM_TYPE_LASTSTEP',	3);
+define('HTTPSTEP_ITEM_TYPE_LASTERROR',	4);
+
+define('EVENT_ACK_DISABLED',	'0');
+define('EVENT_ACK_ENABLED',		'1');
+
+define('EVENT_NOT_ACKNOWLEDGED',	'0');
+define('EVENT_ACKNOWLEDGED',		'1');
+
+define('EVENTS_NOFALSEFORB_STATUS_ALL',		0); // used with TRIGGERS_OPTION_NOFALSEFORB
+define('EVENTS_NOFALSEFORB_STATUS_FALSE',	1); // used with TRIGGERS_OPTION_NOFALSEFORB
+define('EVENTS_NOFALSEFORB_STATUS_TRUE',	2); // used with TRIGGERS_OPTION_NOFALSEFORB
+
+define('EVENT_SOURCE_TRIGGERS',			0);
+define('EVENT_SOURCE_DISCOVERY',		1);
+define('EVENT_SOURCE_AUTO_REGISTRATION',2);
+
+define('EVENT_OBJECT_TRIGGER',		0);
+define('EVENT_OBJECT_DHOST',		1);
+define('EVENT_OBJECT_DSERVICE',		2);
+
+define('GRAPH_YAXIS_TYPE_CALCULATED',	0);
+define('GRAPH_YAXIS_TYPE_FIXED',		1);
+define('GRAPH_YAXIS_TYPE_ITEM_VALUE',	2);
+
+define('GRAPH_YAXIS_SIDE_LEFT',		0);
+define('GRAPH_YAXIS_SIDE_RIGHT',	1);
+
+define('GRAPH_ITEM_SIMPLE',			0);
+define('GRAPH_ITEM_SUM',			2);
+
+define('GRAPH_TYPE_NORMAL',			0);
+define('GRAPH_TYPE_STACKED',		1);
+define('GRAPH_TYPE_PIE',			2);
+define('GRAPH_TYPE_EXPLODED',		3);
+define('GRAPH_TYPE_3D',				4);
+define('GRAPH_TYPE_3D_EXPLODED',	5);
+define('GRAPH_TYPE_BAR',			6);
+define('GRAPH_TYPE_COLUMN',			7);
+define('GRAPH_TYPE_BAR_STACKED',	8);
+define('GRAPH_TYPE_COLUMN_STACKED',	9);
+
+define('GRAPH_3D_ANGLE',			70);
+
+define('GRAPH_STACKED_ALFA',		15); // 0..100 transparency
+
+define('GRAPH_ZERO_LINE_COLOR_LEFT',	'AAAAAA');
+define('GRAPH_ZERO_LINE_COLOR_RIGHT',	'888888');
+
+define('GRAPH_TRIGGER_LINE_OPPOSITE_COLOR', '000');
+
+define('ZBX_MAX_TREND_DIFF',		3600);
+
+define('ZBX_GRAPH_MAX_SKIP_CELL',	16);
+define('ZBX_GRAPH_MAX_SKIP_DELAY',	4);
+
+define('DOBJECT_STATUS_UP',			0);
+define('DOBJECT_STATUS_DOWN',		1);
+define('DOBJECT_STATUS_DISCOVER',	2); // only for events
+define('DOBJECT_STATUS_LOST',		3); // generated by discovery
+
+define('DRULE_STATUS_ACTIVE',		0);
+define('DRULE_STATUS_DISABLED',		1);
+
+define('DSVC_STATUS_ACTIVE',		0);
+define('DSVC_STATUS_DISABLED',		1);
+
+define('SVC_SSH',	0);
+define('SVC_LDAP',	1);
+define('SVC_SMTP',	2);
+define('SVC_FTP',	3);
+define('SVC_HTTP',	4);
+define('SVC_POP',	5);
+define('SVC_NNTP',	6);
+define('SVC_IMAP',	7);
+define('SVC_TCP',	8);
+define('SVC_AGENT',	9);
+define('SVC_SNMPv1',	10);
+define('SVC_SNMPv2c',	11);
+define('SVC_ICMPPING',	12);
+define('SVC_SNMPv3',	13);
+define('SVC_HTTPS',		14);
+define('SVC_TELNET',	15);
+
+define('DHOST_STATUS_ACTIVE',		0);
+define('DHOST_STATUS_DISABLED',		1);
+
+define('IM_FORCED',		0);
+define('IM_ESTABLISHED',1);
+define('IM_TREE',		2);
+
+define('EXPRESSION_TYPE_INCLUDED',		0);
+define('EXPRESSION_TYPE_ANY_INCLUDED',	1);
+define('EXPRESSION_TYPE_NOT_INCLUDED',	2);
+define('EXPRESSION_TYPE_TRUE',			3);
+define('EXPRESSION_TYPE_FALSE',			4);
+
+define('HOST_INVENTORY_DISABLED',		-1);
+define('HOST_INVENTORY_MANUAL',			0);
+define('HOST_INVENTORY_AUTOMATIC',		1);
+
+define('EXPRESSION_VALUE_TYPE_UNKNOWN',	'#ERROR_VALUE_TYPE#');
+define('EXPRESSION_HOST_UNKNOWN',		'#ERROR_HOST#');
+define('EXPRESSION_HOST_ITEM_UNKNOWN',	'#ERROR_ITEM#');
+define('EXPRESSION_NOT_A_MACRO_ERROR',	'#ERROR_MACRO#');
+
+define('AVAILABLE_NOCACHE', 0);	// take available objects not from cache
+
+define('SBR',	"<br/>\n");
+define('SPACE',	'&nbsp;');
+define('RARR',	'&rArr;');
+define('SQUAREBRACKETS', '%5B%5D');
+
+// affects multibyte strings [in mb_ereg char "-" must be backslashed]!!!
+if (in_array(ini_get('mbstring.func_overload'), array(2,3,6,7))) {
+	define('ZBX_MBSTRINGS_OVERLOADED', 1);
+}
+
+define('REGEXP_INCLUDE', 0);
+define('REGEXP_EXCLUDE', 1);
+
+// preg
+define('ZBX_PREG_PRINT', '^\x{00}-\x{1F}');
+define('ZBX_PREG_MACRO_NAME', '([A-Z0-9\._]+)');
+define('ZBX_PREG_INTERNAL_NAMES', '([0-9a-zA-Z_\. \-]+)'); // !!! Don't forget sync code with C !!!
+define('ZBX_PREG_PARAMS', '(['.ZBX_PREG_PRINT.']+?){0,1}');
+define('ZBX_PREG_SIGN', '([&|><=+*\/#\-])');
+define('ZBX_PREG_NUMBER', '([\-+]{0,1}[0-9]+[.]{0,1}[0-9]*[KMGTsmhdw]{0,1})');
+define('ZBX_PREG_DEF_FONT_STRING', '/^[0-9\.:% ]+$/');
+define('ZBX_PREG_DNS_FORMAT', '([0-9a-zA-Z_\.\-$]|\{\$?'.ZBX_PREG_MACRO_NAME.'\})*');
+define('ZBX_PREG_HOST_FORMAT', ZBX_PREG_INTERNAL_NAMES);
+define('ZBX_PREG_NODE_FORMAT', ZBX_PREG_INTERNAL_NAMES);
+define('ZBX_PREG_FUNCTION_FORMAT', '([a-z]+(\('.ZBX_PREG_PARAMS.'\)))');
+define('ZBX_PREG_MACRO_NAME_FORMAT', '(\{[A-Z\.]+\})');
+define('ZBX_PREG_EXPRESSION_SIMPLE_MACROS', '(\{TRIGGER\.VALUE\})');
+define('ZBX_PREG_EXPRESSION_USER_MACROS', '(\{\$'.ZBX_PREG_MACRO_NAME.'\})');
+
+// regexp ids
+define('ZBX_KEY_ID',		1);
+define('ZBX_KEY_NAME_ID',	2);
+define('ZBX_KEY_PARAM_ID',	6);
+
+define('ZBX_HISTORY_COUNT', 5);
+
+define('ZBX_USER_ONLINE_TIME', 600); // 10min
+define('ZBX_GUEST_USER','guest');
+
+define('ZBX_FAVORITES_ALL', -1);
+
+// allow for testing
+define('ZBX_ALLOW_UNICODE', 1);
+
+// IPMI
+define('IPMI_AUTHTYPE_DEFAULT',		-1);
+define('IPMI_AUTHTYPE_NONE',		0);
+define('IPMI_AUTHTYPE_MD2',			1);
+define('IPMI_AUTHTYPE_MD5',			2);
+define('IPMI_AUTHTYPE_STRAIGHT',	4);
+define('IPMI_AUTHTYPE_OEM',			5);
+define('IPMI_AUTHTYPE_RMCP_PLUS',	6);
+
+define('IPMI_PRIVILEGE_CALLBACK',	1);
+define('IPMI_PRIVILEGE_USER',		2);
+define('IPMI_PRIVILEGE_OPERATOR',	3);
+define('IPMI_PRIVILEGE_ADMIN',		4);
+define('IPMI_PRIVILEGE_OEM',		5);
+
+define('ZBX_HAVE_IPV6', 1);
+
+// XML export|import tags
+define('XML_TAG_MACROS',			'macros');
+define('XML_TAG_MACRO',				'macro');
+define('XML_TAG_ZABBIX_EXPORT',		'zabbix_export');
+define('XML_TAG_HOSTS',				'hosts');
+define('XML_TAG_HOST',				'host');
+define('XML_TAG_HOSTINVENTORY',		'host_inventory');
+define('XML_TAG_GROUPS',			'groups');
+define('XML_TAG_GROUP',				'group');
+define('XML_TAG_APPLICATIONS',		'applications');
+define('XML_TAG_APPLICATION',		'application');
+define('XML_TAG_ITEMS',				'items');
+define('XML_TAG_ITEM',				'item');
+define('XML_TAG_TEMPLATES',			'templates');
+define('XML_TAG_TEMPLATE',			'template');
+define('XML_TAG_TRIGGERS',			'triggers');
+define('XML_TAG_TRIGGER',			'trigger');
+define('XML_TAG_GRAPHS',			'graphs');
+define('XML_TAG_GRAPH',				'graph');
+define('XML_TAG_GRAPH_ELEMENT',		'graph_element');
+define('XML_TAG_GRAPH_ELEMENTS',	'graph_elements');
+define('XML_TAG_SCREENS',			'screens');
+define('XML_TAG_SCREEN',			'screen');
+define('XML_TAG_SCREEN_ELEMENT',	'screen_element');
+define('XML_TAG_SCREEN_ELEMENTS',	'screen_elements');
+define('XML_TAG_DEPENDENCIES',		'dependencies');
+define('XML_TAG_DEPENDENCY',		'dependency');
+define('XML_TAG_DEPENDS',			'depends');
+
+define('ZBX_DEFAULT_IMPORT_HOST_GROUP', 'Imported hosts');
+
+// API errors
+define('ZBX_API_ERROR_INTERNAL',	111);
+define('ZBX_API_ERROR_PARAMETERS',	100);
+define('ZBX_API_ERROR_PERMISSIONS',	120);
+define('ZBX_API_ERROR_NO_AUTH',		200);
+define('ZBX_API_ERROR_NO_METHOD',	300);
+
+define('API_OUTPUT_SHORTEN',	'shorten');
+define('API_OUTPUT_REFER',		'refer');
+define('API_OUTPUT_EXTEND',		'extend');
+define('API_OUTPUT_COUNT',		'count');
+define('API_OUTPUT_CUSTOM',		'custom');
+
+define('SEC_PER_MIN',	60);
+define('SEC_PER_HOUR',	3600);
+define('SEC_PER_DAY',	86400);
+define('SEC_PER_WEEK',	604800); // 7 * SEC_PER_DAY
+define('SEC_PER_MONTH',	2592000); // 30 * SEC_PER_DAY
+define('SEC_PER_YEAR',	31536000); // 365 * SEC_PER_DAY
+
+define('DAY_IN_YEAR',	365);
+
+define('ZBX_MIN_PORT_NUMBER', 0);
+define('ZBX_MAX_PORT_NUMBER', 65535);
+
+// input fields
+define('ZBX_TEXTBOX_STANDARD_SIZE',		50);
+define('ZBX_TEXTBOX_SMALL_SIZE',		25);
+define('ZBX_TEXTBOX_FILTER_SIZE',		20);
+define('ZBX_TEXTAREA_STANDARD_WIDTH',	312);
+define('ZBX_TEXTAREA_BIG_WIDTH',		524);
+define('ZBX_TEXTAREA_STANDARD_ROWS',	7);
+
+// validation
+define('DB_ID',		"({}>=0&&bccomp('{}',\"10000000000000000000\")<0)&&");
+define('NOT_EMPTY',	"({}!='')&&");
+define('NOT_ZERO',	"({}!=0)&&");
+define('NO_TRIM',	'NO_TRIM');
+
+define('ZBX_VALID_OK',		0);
+define('ZBX_VALID_ERROR',	1);
+define('ZBX_VALID_WARNING',	2);
+
+// user default theme
+define('THEME_DEFAULT', 'default');
+
+// the default theme
+define('ZBX_DEFAULT_THEME', 'originalblue');
+
+define('ZABBIX_HOMEPAGE', 'http://www.zabbix.com');
+
+// date formats
+define('HISTORY_OF_ACTIONS_DATE_FORMAT', _('d M Y H:i:s'));
+define('EVENT_ACTION_MESSAGES_DATE_FORMAT', _('d M Y H:i:s'));
+define('EVENT_ACTION_CMDS_DATE_FORMAT', _('Y.M.d H:i:s'));
+define('HISTORY_LOG_LOCALTIME_DATE_FORMAT', _('Y.M.d H:i:s'));
+define('HISTORY_LOG_ITEM_PLAINTEXT', _('Y-m-d H:i:s'));
+define('HISTORY_PLAINTEXT_DATE_FORMAT', _('Y-m-d H:i:s'));
+define('HISTORY_ITEM_DATE_FORMAT', _('Y.M.d H:i:s'));
+define('EVENTS_DISCOVERY_TIME_FORMAT', _('d M Y H:i:s'));
+define('EVENTS_ACTION_TIME_FORMAT', _('d M Y H:i:s'));
+define('QUEUE_NODES_DATE_FORMAT', _('d M Y H:i:s'));
+define('CHARTBAR_HOURLY_DATE_FORMAT', _('Y.m.d H:i'));
+define('CHARTBAR_DAILY_DATE_FORMAT', _('Y.m.d'));
+// GETTEXT: Date format (year). Do not translate.
+define('REPORT4_ANNUALLY_DATE_FORMAT', _x('Y', 'date format'));
+define('REPORT4_MONTHLY_DATE_FORMAT', _('M Y'));
+define('REPORT4_DAILY_DATE_FORMAT', _('d M Y'));
+define('REPORT4_WEEKLY_DATE_FORMAT', _('d M Y H:i'));
+define('REPORTS_BAR_REPORT_DATE_FORMAT', _('d M Y H:i:s'));
+define('POPUP_PERIOD_CAPTION_DATE_FORMAT', _('d M Y H:i:s'));
+define('MAPS_DATE_FORMAT', _('Y.m.d H:i:s'));
+define('SERVER_INFO_DATE_FORMAT', _('D, d M Y H:i:s O'));
+define('XML_DATE_DATE_FORMAT', _('d.m.y'));
+define('XML_TIME_DATE_FORMAT', _('H.i'));
+
+// if magic quotes on, then get rid of them
+if (version_compare(phpversion(), '6.0', '<') && get_magic_quotes_gpc()) {
+	$_GET = zbx_stripslashes($_GET);
+	$_POST = zbx_stripslashes($_POST);
+	$_COOKIE = zbx_stripslashes($_COOKIE);
+}
+
+// init $_REQUEST
+ini_set('variables_order', 'GP');
+$_REQUEST = $_POST + $_GET;
+
+// init precision
+ini_set('precision', 14);
+
+// BC Math scale
+bcscale(7);
diff -urN zabbix-2.0.0.orig/frontends/php/include/defines.inc.php.rej zabbix-2.0.0/frontends/php/include/defines.inc.php.rej
--- zabbix-2.0.0.orig/frontends/php/include/defines.inc.php.rej	1969-12-31 19:00:00.000000000 -0500
+++ zabbix-2.0.0/frontends/php/include/defines.inc.php.rej	2012-07-13 16:06:50.000000000 -0400
@@ -0,0 +1,21 @@
+***************
+*** 270,275 ****
+  define('MAP_LABEL_LOC_RIGHT',    2);
+  define('MAP_LABEL_LOC_TOP',      3);
+  
+  define('SYSMAP_ELEMENT_TYPE_HOST',   0);
+  define('SYSMAP_ELEMENT_TYPE_MAP',    1);
+  define('SYSMAP_ELEMENT_TYPE_TRIGGER',  2);
+--- 270,281 ----
+  define('MAP_LABEL_LOC_RIGHT',    2);
+  define('MAP_LABEL_LOC_TOP',      3);
+  
++ define('MAP_LABEL_ALIGN_CENTER',0);
++ define('MAP_LABEL_ALIGN_BOTTOM',1);
++ define('MAP_LABEL_ALIGN_LEFT',2);
++ define('MAP_LABEL_ALIGN_RIGHT',3);
++ define('MAP_LABEL_ALIGN_TOP',4);
++ 
+  define('SYSMAP_ELEMENT_TYPE_HOST',   0);
+  define('SYSMAP_ELEMENT_TYPE_MAP',    1);
+  define('SYSMAP_ELEMENT_TYPE_TRIGGER',  2);
diff -urN zabbix-2.0.0.orig/frontends/php/include/maps.inc.php zabbix-2.0.0/frontends/php/include/maps.inc.php
--- zabbix-2.0.0.orig/frontends/php/include/maps.inc.php	2012-05-21 10:07:27.000000000 -0400
+++ zabbix-2.0.0/frontends/php/include/maps.inc.php	2012-07-13 15:56:40.000000000 -0400
@@ -1291,49 +1291,188 @@
 	}
 	return $elements;
 }
+/*
+ * Calculate the distance between two points
+*
+* Params:       $point1         The first point to evaluate (Array containing component for X,Y and Z)
+*               $point2         The second point to evaluate (Array containing component for X,Y and Z)
+*
+* Returns the distance between 2 points in space as a float
+*/
+function distancePointPoint($point1, $point2) {
+	$tmp=array('x'=>$point2['x']-$point1['x'],'y'=>$point2['y']-$point1['y'],'z'=>$point2['z']-$point1['z']);
+	return sqrt($tmp['x']*$tmp['x']+$tmp['y']*$tmp['y']+$tmp['z']*$tmp['z']);
+}
+/*
+ * Calculate the distance between a point and a line
+*
+* Params:       $point          The point to valuate (Array containing component for X,Y and Z)
+*               $start          The point where the segment starts (Array containing component for X,Y and Z)
+*               $end            The point where the segment ends (Array containing component for X,Y and Z)
+*
+* Returns the closest point on the line from the provided point. The distance between both points is also returned.
+*/
+function  distancePointLine($point, $start, $end) {
+	$res=array('x'=>-1,'y'=>-1,'z'=>-1,'dst'=>0);
+	$distance= distancePointPoint($end,$start);
+	// The next line allow to use this fonction to calculate the distance between two points ($start == $end)
+	if ($distance==0) $distance=1;
+	$u = (  (($point['x']-$start['x'])*($end['x']-$start['x'])) +
+					(($point['y']-$start['y'])*($end['y']-$start['y'])) +
+					(($point['z']-$start['z'])*($end['z']-$start['z']))) /
+					($distance*$distance);
+	if ($u<0) {
+		$res['x'] = $start['x'];
+		$res['y'] = $start['y'];
+		$res['z'] = $start['z'];
+	} else if ($u>1) {
+		$res['x'] = $end['x'];
+		$res['y'] = $end['y'];
+		$res['z'] = $end['z'];
+	} else {
+		$res['x'] = $start['x'] + $u * ($end['x'] - $start['x']);
+		$res['y'] = $start['y'] + $u * ($end['y'] - $start['y']);
+		$res['z'] = $start['z'] + $u * ($end['z'] - $start['z']);
+	}
+	$res['dst'] = distancePointPoint($point,$res);
+	return $res;
+}
+
+/*
+ * Determine if a point is closer than another point, inclusive or not.
+*
+* Params:       $point1         The first point to evaluate (Array containing component for X,Y,Z and distance)
+*               $point2         The second point to evaluate (Array containing component for X,Y,Z and distance)
+*               $inclusive      True if we want verification to be inclusive (if $p1.dst<=$p2.dst instead of $p1.dst<$p2.dst)
+*
+* Returns true if the distance contained in the $point1 array is lower (lower and equals if $inclusive) than the distance component of $point2
+*/
+function isCloser($point1,$point2,$inclusive) {
+	$res=false;
+	if ($inclusive and $point1['dst'] <= $point2['dst'])
+	$res=true;
+	else if ($point1['dst'] < $point2['dst'])
+	$res=true;
+	return $res;
+}
+function getIconLineByElement($element, $anchor, $map, $info=null) {
+	$res = array();
+	$x = $element['x'];
+	$y = $element['y'];
+	$dx = 0;
+	$dy = 0;
+	$image = get_png_by_selement($element, $info);
+	if($image){
+		$dx = imagesx($image);
+		$dy = imagesy($image);
+	}
+	switch($anchor) {
+		// Steady Y axis, we move along the X axis
+		case MAP_LABEL_ALIGN_BOTTOM:
+			$res['start']   = array('x'=>$x,        'y'=>$y+$dy,    'z'=>0);
+			$res['center']  = array('x'=>$x+$dx/2,  'y'=>$y+$dy,    'z'=>0);
+			$res['end']     = array('x'=>$x+$dx,    'y'=>$y+$dy,    'z'=>0);
+			break;
+		case MAP_LABEL_ALIGN_TOP:
+			$res['start']   = array('x'=>$x,        'y'=>$y,        'z'=>0);
+			$res['center']  = array('x'=>$x+$dx/2,  'y'=>$y,        'z'=>0);
+			$res['end']     = array('x'=>$x+$dx,    'y'=>$y,        'z'=>0);
+			break;
+			// Steady X axis, we move along the Y axis
+		case MAP_LABEL_ALIGN_LEFT:
+			$res['start']   = array('x'=>$x,        'y'=>$y,        'z'=>0);
+			$res['center']  = array('x'=>$x,        'y'=>$y+$dy/2,  'z'=>0);
+			$res['end']     = array('x'=>$x,        'y'=>$y+$dy,    'z'=>0);
+			break;
+		case MAP_LABEL_ALIGN_RIGHT:
+			$res['start']   = array('x'=>$x+$dx,    'y'=>$y,        'z'=>0);
+			$res['center']  = array('x'=>$x+$dx,    'y'=>$y+$dy/2,  'z'=>0);
+			$res['end']     = array('x'=>$x+$dx,    'y'=>$y+$dy,    'z'=>0);
+			break;
+			// Middle point (default behavior)
+		case MAP_LABEL_ALIGN_CENTER:
+		default:
+			$res=pointToCoord(get_icon_center_by_selement($element, $info, $map),0);
+	}
+	return $res;
+}
+
+function pointToCoord($point) {
+	$res = array();
+	$res['start'] = array('x'=>$point[0],'y'=>$point[1],'z'=>0);
+	$res['center'] = $res['start'];
+	$res['end'] = $res['start'];
+	return $res;
+}
 
-function drawMapConnectors(&$im, $map, $map_info, $drawAll = false) {
+function getConnectorCoordinates($map, $map_info, $link, $drawAll = false) {
 	$selements = $map['selements'];
+	$selement1 = $selements[$link['selementid1']];
+	$selement2 = $selements[$link['selementid2']];
 
-	foreach ($map['links'] as $link) {
-		$selement1 = $selements[$link['selementid1']];
-		$selement2 = $selements[$link['selementid2']];
-
-		list($x1, $y1) = get_icon_center_by_selement($selement1, $map_info[$link['selementid1']], $map);
-		list($x2, $y2) = get_icon_center_by_selement($selement2, $map_info[$link['selementid2']], $map);
-
-		if (isset($selement1['elementsubtype']) && $selement1['elementsubtype'] == SYSMAP_ELEMENT_AREA_TYPE_CUSTOM) {
-			if (!$drawAll && ($selement2['elementsubtype'] != SYSMAP_ELEMENT_SUBTYPE_HOST_GROUP_ELEMENTS)) {
-				continue;
-			}
-
-			if ($selement1['areatype'] == SYSMAP_ELEMENT_AREA_TYPE_CUSTOM) {
-				$w = $selement1['width'];
-				$h = $selement1['height'];
-			}
-			else {
-				$w = $map['width'];
-				$h = $map['height'];
-			}
-			list($x1, $y1) = calculateMapAreaLinkCoord($x1, $y1, $w, $h, $x2, $y2);
+	$line1 = getIconLineByElement($selement1, $link['anchor1'], $map, $map_info[$link['selementid1']]);
+	$line2 = getIconLineByElement($selement2, $link['anchor2'], $map, $map_info[$link['selementid2']]);
+	
+	if (isset($selement1['elementsubtype']) && $selement1['elementsubtype'] == SYSMAP_ELEMENT_AREA_TYPE_CUSTOM) {
+		if (!$drawAll && ($selement2['elementsubtype'] != SYSMAP_ELEMENT_SUBTYPE_HOST_GROUP_ELEMENTS)) {
+			continue;
 		}
-
-		if (isset($selement2['elementsubtype']) && $selement2['elementsubtype'] == SYSMAP_ELEMENT_AREA_TYPE_CUSTOM) {
-			if (!$drawAll && ($selement1['elementsubtype'] != SYSMAP_ELEMENT_SUBTYPE_HOST_GROUP_ELEMENTS)) {
-				continue;
-			}
-
-			if ($selement2['areatype'] == SYSMAP_ELEMENT_AREA_TYPE_CUSTOM) {
-				$w = $selement2['width'];
-				$h = $selement2['height'];
-			}
-			else {
-				$w = $map['width'];
-				$h = $map['height'];
-			}
-			list($x2, $y2) = calculateMapAreaLinkCoord($x2, $y2, $w,$h, $x1, $y1);
+	
+		if ($selement1['areatype'] == SYSMAP_ELEMENT_AREA_TYPE_CUSTOM) {
+			$w = $selement1['width'];
+			$h = $selement1['height'];
+		}
+		else {
+			$w = $map['width'];
+			$h = $map['height'];
+		}
+		$line1 = pointToLine(caculateMapAreaLinkCoord($x1, $y1, $w, $h, $x2, $y2));
+	}
+	
+	if (isset($selement2['elementsubtype']) && $selement2['elementsubtype'] == SYSMAP_ELEMENT_AREA_TYPE_CUSTOM) {
+		if (!$drawAll && ($selement1['elementsubtype'] != SYSMAP_ELEMENT_SUBTYPE_HOST_GROUP_ELEMENTS)) {
+			continue;
+		}
+	
+		if ($selement2['areatype'] == SYSMAP_ELEMENT_AREA_TYPE_CUSTOM) {
+			$w = $selement2['width'];
+			$h = $selement2['height'];
+		}
+		else {
+			$w = $map['width'];
+			$h = $map['height'];
+		}
+		$line2 = pointToLine(calculateMapAreaLinkCoord($x2, $y2, $w,$h, $x1, $y1));
+	} 
+	
+	// Okay, this is where the fun begins. The next array (tests) will hold all distance that must be mesured. Since we are working
+	// with finite lines, we know for sure that the closest point will be an extremity of one of the two lines. Therefore,
+	// all we need to do is to test the extremities of each line (start-end) with the other line.
+	// Yet, for two parallel lines, I prefer to view the line starting from the center than the extremities.
+	// By adding the incl=true to those tests, that will give them predominance, line of element 2 being predominant
+	// of element 1.
+	$res=array('x'=>-1,'y'=>-1,'z'=>-1,'dst'=>99999999999);
+	$tests=array(   array('point'=>$line1['start'], 'incl'=>false,'line'=>$line2),
+	array('point'=>$line2['start'], 'incl'=>false,'line'=>$line1),
+	array('point'=>$line1['center'],'incl'=>true, 'line'=>$line2),
+	array('point'=>$line2['center'],'incl'=>true, 'line'=>$line1),
+	array('point'=>$line1['end'],   'incl'=>false,'line'=>$line2),
+	array('point'=>$line2['end'],   'incl'=>false,'line'=>$line1)
+	);
+	foreach ($tests as $test) {
+		$tmp=distancePointLine($test['point'],$test['line']['start'],$test['line']['end']);
+		if (isCloser($tmp,$res,$test['incl'])) {
+			$p1=$test['point'];
+			$res=$tmp;
 		}
+	}
+	return array($p1['x'],$p1['y'],$res['x'],$res['y']);
+}
 
+function drawMapConnectors(&$im, $map, $map_info, $drawAll = false) {
+	foreach ($map['links'] as $link) {
+		list($x1,$y1,$x2,$y2) = getConnectorCoordinates($map, $map_info, $link,$drawAll);
+		
 		$drawtype = $link['drawtype'];
 		$color = convertColor($im, $link['color']);
 
@@ -1593,42 +1732,13 @@
 	global $colors;
 
 	$links = $map['links'];
-	$selements = $map['selements'];
 
 	foreach ($links as $link) {
 		if (empty($link['label'])) {
 			continue;
 		}
 
-		$selement1 = $selements[$link['selementid1']];
-		list($x1, $y1) = get_icon_center_by_selement($selement1, $map_info[$link['selementid1']], $map);
-
-		$selement2 = $selements[$link['selementid2']];
-		list($x2, $y2) = get_icon_center_by_selement($selement2, $map_info[$link['selementid2']], $map);
-
-		if (isset($selement1['elementsubtype']) && $selement1['elementsubtype'] == SYSMAP_ELEMENT_AREA_TYPE_CUSTOM) {
-			if ($selement1['areatype'] == SYSMAP_ELEMENT_AREA_TYPE_CUSTOM) {
-				$w = $selement1['width'];
-				$h = $selement1['height'];
-			}
-			else {
-				$w = $map['width'];
-				$h = $map['height'];
-			}
-			list($x1, $y1) = calculateMapAreaLinkCoord($x1, $y1, $w, $h, $x2, $y2);
-		}
-
-		if (isset($selement2['elementsubtype']) && $selement2['elementsubtype'] == SYSMAP_ELEMENT_AREA_TYPE_CUSTOM) {
-			if ($selement2['areatype'] == SYSMAP_ELEMENT_AREA_TYPE_CUSTOM) {
-				$w = $selement2['width'];
-				$h = $selement2['height'];
-			}
-			else {
-				$w = $map['width'];
-				$h = $map['height'];
-			}
-			list($x2, $y2) = calculateMapAreaLinkCoord($x2, $y2, $w, $h, $x1, $y1);
-		}
+		list($x1,$y1,$x2,$y2) = getConnectorCoordinates($map, $map_info, $link);
 
 		$drawtype = $link['drawtype'];
 		$color = convertColor($im, $link['color']);
diff -urN zabbix-2.0.0.orig/frontends/php/include/views/js/configuration.sysmaps.js.php zabbix-2.0.0/frontends/php/include/views/js/configuration.sysmaps.js.php
--- zabbix-2.0.0.orig/frontends/php/include/views/js/configuration.sysmaps.js.php	2012-05-21 10:07:27.000000000 -0400
+++ zabbix-2.0.0/frontends/php/include/views/js/configuration.sysmaps.js.php	2012-07-13 15:56:40.000000000 -0400
@@ -207,6 +207,7 @@
 
 		<form id="linkForm" name="linkForm" style="display: none;">
 			<input type="hidden" name="selementid1">
+			<input type="hidden" name="anchor1">
 
 			<table class="formtable" style="width: 100%;">
 				<tbody>
@@ -219,6 +220,18 @@
 					<td><select class="input" name="selementid2" id="selementid2"></select></td>
 				</tr>
 				<tr>
+					<td><label for="anchor2"><?php echo _('Anchor point'); ?></label></td>
+					<td>
+						<select class="input" name="anchor2" id="anchor2">
+							<option value="<?php echo MAP_LABEL_ALIGN_CENTER; ?>"><?php echo _('Center'); ?></option>
+							<option value="<?php echo MAP_LABEL_ALIGN_BOTTOM; ?>"><?php echo _('Bottom'); ?></option>
+							<option value="<?php echo MAP_LABEL_ALIGN_TOP; ?>"><?php echo _('Top'); ?></option>
+							<option value="<?php echo MAP_LABEL_ALIGN_LEFT; ?>"><?php echo _('Left'); ?></option>
+							<option value="<?php echo MAP_LABEL_ALIGN_RIGHT; ?>"><?php echo _('Right'); ?></option>
+						</select>
+					</td>
+				</tr>
+				<tr>
 					<td><label for="drawtype"><?php echo _('Type (OK)'); ?></label></td>
 					<td >
 						<select size="1" class="input" name="drawtype" id="drawtype">
diff -urN zabbix-2.0.0.orig/frontends/php/js/class.cmap.js zabbix-2.0.0/frontends/php/js/class.cmap.js
--- zabbix-2.0.0.orig/frontends/php/js/class.cmap.js	2012-05-21 10:07:27.000000000 -0400
+++ zabbix-2.0.0/frontends/php/js/class.cmap.js	2012-07-13 15:56:40.000000000 -0400
@@ -643,6 +643,8 @@
 					selementid2:	null,
 					linktriggers:	{},
 					drawtype:		0,
+					anchor1:		0,
+					anchor2:		0,
 					color:			'00CC00'
 				};
 
@@ -1634,8 +1636,13 @@
 					tmp = link.selementid1;
 					link.selementid1 = selement1.id;
 					link.selementid2 = tmp;
-				}
 
+					tmp = link.anchor1;
+					link.anchor1 = link.anchor2;
+					link.anchor2 = tmp;
+
+				}
+				
 				// populate list of elements to connect with
 				jQuery('#selementid2').empty();
 
