diff --git a/README-rus.md b/README-rus.md index 73dcb96..1efd0ac 100644 --- a/README-rus.md +++ b/README-rus.md @@ -1,7 +1,7 @@ # imap Interactive map for Zabbix -Данная версия разработана для Zabbix версий 2.2 и 2.4 +Данная версия разработана для Zabbix версии 3.x На старых версиях работоспособность не гарантирована и дорабатываться не будет. @@ -16,9 +16,9 @@ Interactive map for Zabbix Для установки скопируйте содержимое папки zabbix в директорию вашего zabbix (/usr/share/zabbix для Debian, например). Чтобы подключить imap в стандартный интерфейс, отредактируйте include/menu.inc.php -В самый конец файла вставьте: +В 314 строку перед "$denied_page_requested = false;" вставьте: - require_once dirname(__FILE__).'/../imap/menu.inc.php'; + require_once dirname(__FILE__).'/../imap/menu3.inc.php'; Теперь основной функционал работоспособен. Зайдите в ваш Zabbix и вы увидите новый пункт меню. diff --git a/README.md b/README.md index 3dd6979..831d873 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Screenshots: http://zabbiximap.lisss.ru/ -This version is designed for Zabbix versions 2.2 and 2.4 +This version is designed for Zabbix versions 3.x In old versions of efficiency is not guaranteed and will not be further developed. @@ -15,9 +15,9 @@ For new versions the development will be output as the official release. For install copy the contents of a folder zabbix in the directory of your Zabbix Server (Example, /usr/share/zabbix for Debian). Edit include/menu.inc.php to connect Interactive Map at standard interface -Add this to the end of file: +Add this in 314 string, befor "$denied_page_requested = false;": - require_once dirname(__FILE__).'/../imap/menu.inc.php'; + require_once dirname(__FILE__).'/../imap/menu3.inc.php'; Now, the basic functionality is efficient. Go to your Zabbix and you'll see a new menu item. diff --git a/zabbix/imap.php b/zabbix/imap.php index c1560d1..cbd1ac9 100644 --- a/zabbix/imap.php +++ b/zabbix/imap.php @@ -13,25 +13,6 @@ $page['file'] = 'imap.php'; $page['hist_arg'] = array('groupid', 'hostid', 'show_severity','control_map','with_triggers_only'); -$fields = array( - 'lat' => array(T_ZBX_STR, O_OPT, P_SYS, null, null), - 'lng' => array(T_ZBX_STR, O_OPT, P_SYS, null, null), - 'with_triggers_only' => array(T_ZBX_INT, O_OPT, P_SYS, IN('0,1'), null), - 'control_map' => array(T_ZBX_INT, O_OPT, P_SYS, IN('0,1'), null), - 'severity_min' => array(T_ZBX_INT, O_OPT, P_SYS, IN('0,1,2,3,4,5'), null), - 'output' => array(T_ZBX_STR, O_OPT, P_SYS, null, null), - 'action_ajax' => array(T_ZBX_STR, O_OPT, P_SYS, null, null), - 'hostid' => array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, null), - 'thostid' => array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, null), - 'groupid' => array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, null), - 'hardware' => array(T_ZBX_STR, O_OPT, null, null, null), - 'linkid' => array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, null), - 'linkoptions' => array(T_ZBX_STR, O_OPT, P_SYS, null, null), - 'hardwareField' => array(T_ZBX_STR, O_OPT, null, null, null), - 'searchstring' => array(T_ZBX_STR, O_OPT, P_SYS, null, null) -); -check_fields($fields); - if (function_exists('get_request')) { $lat = get_request('lat', null); $lng = get_request('lng', null); @@ -84,6 +65,43 @@ require_once dirname(__FILE__).'/include/page_header.php'; }; +$fields = array( + 'groupid' => array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, null), + 'hostid' => array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, null), + 'thostid' => array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, null), + 'linkid' => array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, null), + 'severity_min' => array(T_ZBX_INT, O_OPT, P_SYS, IN('0,1,2,3,4,5'), null), + 'fullscreen' => array(T_ZBX_INT, O_OPT, P_SYS, IN('0,1'), null), + 'control_map' => array(T_ZBX_INT, O_OPT, P_SYS, IN('0,1'), null), + 'with_triggers_only' => array(T_ZBX_INT, O_OPT, P_SYS, IN('0,1'), null), + 'output' => array(T_ZBX_STR, O_OPT, P_SYS, null, null), + 'jsscriptid' => array(T_ZBX_STR, O_OPT, P_SYS, null, null), + // ajax + 'favobj' => array(T_ZBX_STR, O_OPT, P_ACT, null, null), + 'favref' => array(T_ZBX_STR, O_OPT, P_ACT, null, null), + 'favid' => array(T_ZBX_INT, O_OPT, P_ACT, null, null), + 'favcnt' => array(T_ZBX_INT, O_OPT, null, null, null), + 'pmasterid' => array(T_ZBX_STR, O_OPT, P_SYS, null, null), + 'favaction' => array(T_ZBX_STR, O_OPT, P_ACT, IN("'add','remove','refresh','flop','sort'"), null), + 'favstate' => array(T_ZBX_INT, O_OPT, P_ACT, NOT_EMPTY, 'isset({favaction})&&("flop"=={favaction})'), + 'favdata' => array(T_ZBX_STR, O_OPT, null, null, null), + 'hardwareField' => array(T_ZBX_STR, O_OPT, null, null, null), + //стандартные + 'btnSelect' => [T_ZBX_STR, O_OPT, null, null, null], + 'filter_rst' => [T_ZBX_STR, O_OPT, P_SYS, null, null], + 'filter_set' => [T_ZBX_STR, O_OPT, P_SYS, null, null], + 'show_triggers' => [T_ZBX_INT, O_OPT, null, null, null], + 'show_events' => [T_ZBX_INT, O_OPT, P_SYS, null, null], + 'ack_status' => [T_ZBX_INT, O_OPT, P_SYS, null, null], + 'show_severity' => [T_ZBX_INT, O_OPT, P_SYS, null, null], + 'status_change_days' => [T_ZBX_INT, O_OPT, null, BETWEEN(1, DAY_IN_YEAR * 2), null], + 'status_change' => [T_ZBX_INT, O_OPT, null, null, null], + 'txt_select' => [T_ZBX_STR, O_OPT, null, null, null], + 'application' => [T_ZBX_STR, O_OPT, null, null, null], + 'inventory' => [T_ZBX_STR, O_OPT, null, null, null] +); +check_fields($fields); + /* * Filter */ @@ -98,33 +116,133 @@ 'withInventory' => true ), 'hostid' => $hostid, - 'groupid' => $groupid, - 'severitiesMin' => array( - TRIGGER_SEVERITY_NOT_CLASSIFIED => getSeverityCaption(TRIGGER_SEVERITY_NOT_CLASSIFIED), - TRIGGER_SEVERITY_INFORMATION => getSeverityCaption(TRIGGER_SEVERITY_INFORMATION), - TRIGGER_SEVERITY_WARNING => getSeverityCaption(TRIGGER_SEVERITY_WARNING), - TRIGGER_SEVERITY_AVERAGE => getSeverityCaption(TRIGGER_SEVERITY_AVERAGE), - TRIGGER_SEVERITY_HIGH => getSeverityCaption(TRIGGER_SEVERITY_HIGH), - TRIGGER_SEVERITY_DISASTER => getSeverityCaption(TRIGGER_SEVERITY_DISASTER) - ), - 'severityMin' => $showSeverity + 'groupid' => $groupid )); $_REQUEST['groupid'] = $pageFilter->groupid; $_REQUEST['hostid'] = $pageFilter->hostid; + +// filter set +if (hasRequest('filter_set')) { + CProfile::update('web.tr_status.filter.show_details', getRequest('show_details', 0), PROFILE_TYPE_INT); + CProfile::update('web.tr_status.filter.show_maintenance', getRequest('show_maintenance', 0), PROFILE_TYPE_INT); + CProfile::update('web.tr_status.filter.show_severity', + getRequest('show_severity', TRIGGER_SEVERITY_NOT_CLASSIFIED), PROFILE_TYPE_INT + ); + CProfile::update('web.tr_status.filter.txt_select', getRequest('txt_select', ''), PROFILE_TYPE_STR); + CProfile::update('web.tr_status.filter.status_change', getRequest('status_change', 0), PROFILE_TYPE_INT); + CProfile::update('web.tr_status.filter.status_change_days', getRequest('status_change_days', 14), + PROFILE_TYPE_INT + ); + CProfile::update('web.tr_status.filter.application', getRequest('application'), PROFILE_TYPE_STR); + + // show triggers + // when this filter is set to "All" it must not be remembered in the profiles because it may render the + // whole page inaccessible on large installations. + if (getRequest('show_triggers') != TRIGGERS_OPTION_ALL) { + CProfile::update('web.tr_status.filter.show_triggers', getRequest('show_triggers'), PROFILE_TYPE_INT); + } + + // show events + $showEvents = getRequest('show_events', EVENTS_OPTION_NOEVENT); + if ($config['event_ack_enable'] == EVENT_ACK_ENABLED || $showEvents != EVENTS_OPTION_NOT_ACK) { + CProfile::update('web.tr_status.filter.show_events', $showEvents, PROFILE_TYPE_INT); + } + + // ack status + if ($config['event_ack_enable'] == EVENT_ACK_ENABLED) { + CProfile::update('web.tr_status.filter.ack_status', getRequest('ack_status', ZBX_ACK_STS_ANY), PROFILE_TYPE_INT); + } + + // update host inventory filter + $inventoryFields = []; + $inventoryValues = []; + foreach (getRequest('inventory', []) as $field) { + if ($field['value'] === '') { + continue; + } + + $inventoryFields[] = $field['field']; + $inventoryValues[] = $field['value']; + } + CProfile::updateArray('web.tr_status.filter.inventory.field', $inventoryFields, PROFILE_TYPE_STR); + CProfile::updateArray('web.tr_status.filter.inventory.value', $inventoryValues, PROFILE_TYPE_STR); +} +elseif (hasRequest('filter_rst')) { + DBStart(); + CProfile::delete('web.tr_status.filter.show_triggers'); + CProfile::delete('web.tr_status.filter.show_details'); + CProfile::delete('web.tr_status.filter.show_maintenance'); + CProfile::delete('web.tr_status.filter.show_events'); + CProfile::delete('web.tr_status.filter.ack_status'); + CProfile::delete('web.tr_status.filter.show_severity'); + CProfile::delete('web.tr_status.filter.txt_select'); + CProfile::delete('web.tr_status.filter.status_change'); + CProfile::delete('web.tr_status.filter.status_change_days'); + CProfile::delete('web.tr_status.filter.application'); + CProfile::deleteIdx('web.tr_status.filter.inventory.field'); + CProfile::deleteIdx('web.tr_status.filter.inventory.value'); + DBend(); +} + +if (hasRequest('filter_set') && getRequest('show_triggers') == TRIGGERS_OPTION_ALL) { + $showTriggers = TRIGGERS_OPTION_ALL; +} +else { + $showTriggers = CProfile::get('web.tr_status.filter.show_triggers', TRIGGERS_OPTION_RECENT_PROBLEM); +} +$showDetails = CProfile::get('web.tr_status.filter.show_details', 0); +$showMaintenance = CProfile::get('web.tr_status.filter.show_maintenance', 1); +$showSeverity = CProfile::get('web.tr_status.filter.show_severity', TRIGGER_SEVERITY_NOT_CLASSIFIED); +$txtSelect = CProfile::get('web.tr_status.filter.txt_select', ''); +$showChange = CProfile::get('web.tr_status.filter.status_change', 0); +$statusChangeBydays = CProfile::get('web.tr_status.filter.status_change_days', 14); +$ackStatus = ($config['event_ack_enable'] == EVENT_ACK_DISABLED) + ? ZBX_ACK_STS_ANY : CProfile::get('web.tr_status.filter.ack_status', ZBX_ACK_STS_ANY); +$showEvents = CProfile::get('web.tr_status.filter.show_events', EVENTS_OPTION_NOEVENT); + +// check event acknowledges +if ($config['event_ack_enable'] == EVENT_ACK_DISABLED && $showEvents == EVENTS_OPTION_NOT_ACK) { + $showEvents = EVENTS_OPTION_NOEVENT; +} + +// fetch filter from profiles +$filter = [ + 'application' => CProfile::get('web.tr_status.filter.application', ''), + 'inventory' => [] +]; + +foreach (CProfile::getArray('web.tr_status.filter.inventory.field', []) as $i => $field) { + $filter['inventory'][] = [ + 'field' => $field, + 'value' => CProfile::get('web.tr_status.filter.inventory.value', null, $i) + ]; +} + + + + + + function rightsErrorAjax() { $responseData = '{"jsonrpc": "2.0","error": {"message": "Access error. Check rights."}}'; echo $responseData; exit; }; +function checkHostsIsWritable($hostsids) { + $hosts = API::Host()->get(array('editable'=>true,'hostids'=>$hostsids)); + if (count($hosts) == count($hostsids)) return TRUE; + return FALSE; +} + function rightsForLink($idl) { $glinks = DBfetchArray(DBselect( 'SELECT host1, host2 FROM hosts_links WHERE hosts_links.id = '.$idl )); - if (API::Host()->isWritable(array(1*$glinks[0]['host1'])) and API::Host()->isWritable(array(1*$glinks[0]['host2']))) return (true); + if (checkHostsIsWritable(array(1*$glinks[0]['host1'], 1*$glinks[0]['host2']))) return (true); return (false); }; @@ -164,6 +282,7 @@ function rightsForLink($idl) { $options['sortfield'] = array('lastchange'); $options['sortorder'] = 'DESC'; $options['filter'] = array('value' => TRIGGER_VALUE_TRUE); + $options['selectHosts'] = array('hostid', 'name'); if ($showSeverity > TRIGGER_SEVERITY_NOT_CLASSIFIED) { $options['min_severity'] = $showSeverity; }; @@ -236,7 +355,7 @@ function rightsForLink($idl) { if ($action_ajax=='update_coords') { - if (!API::Host()->isWritable(array($hostid))) rightsErrorAjax(); + if (!checkHostsIsWritable(array($hostid))) rightsErrorAjax(); if ((lat=='none') or ($lng=='none')) { $lat=null; $lng=null; @@ -275,7 +394,7 @@ function rightsForLink($idl) { }; if ($action_ajax=='set_hardware') { - if (!API::Host()->isWritable(array($hostid))) rightsErrorAjax(); + if (!checkHostsIsWritable(array($hostid))) rightsErrorAjax(); $options = array( 'hostid' => $hostid, 'inventory' => array() @@ -348,10 +467,10 @@ function rightsForLink($idl) { if ($action_ajax=='add_links') { - if (!API::Host()->isWritable(array($hostid))) rightsErrorAjax(); + if (!checkHostsIsWritable(array($hostid))) rightsErrorAjax(); $shost=$hostid; foreach ($thostid as $thost) { - if (API::Host()->isWritable(array($hostid))) { + if (checkHostsIsWritable(array($hostid))) { $newlink = array('host1' => MIN($shost,$thost), 'host2' => MAX($shost,$thost)); $res = DBimap::insert('hosts_links', array($newlink)); }; @@ -403,25 +522,79 @@ function rightsForLink($idl) { // $showEvents = $_REQUEST['show_events']; // $ackStatus = $_REQUEST['ack_status']; - $triggerWidget = new CWidget(); +// $triggerWidget = new CWidget(); +// +// $rightForm = new CForm('get'); +// $rightForm->addItem(array(_('Group').SPACE, $pageFilter->getGroupsCB(true))); +// $rightForm->addItem(array(SPACE._('Host').SPACE, $pageFilter->getHostsCB(true))); +// $severityComboBox = new CComboBox('severity_min', $showSeverity,'javascript: submit();'); +// $severityComboBox->addItems($pageFilter->severitiesMin); +// $rightForm->addItem(array(SPACE._('Minimum trigger severity').SPACE, $severityComboBox)); +// +// textdomain("imap"); +// $rightForm->addItem(array(SPACE.SPACE._('Control map').SPACE, new CCheckBox('control_map', $control_map, '_imap.settings.do_map_control = jQuery(\'#control_map\')[0].checked; if (_imap.settings.do_map_control) {mapBbox(_imap.bbox)};', 1))); +// $rightForm->addItem(array(SPACE.SPACE._('With triggers only').SPACE, new CCheckBox('with_triggers_only', $with_triggers_only, 'javascript: submit();', 1))); +// textdomain("frontend"); +// +// $rightForm->addVar('fullscreen', $_REQUEST['fullscreen']); +// +// $triggerWidget->addHeader(SPACE,$rightForm); +// $triggerWidget->addPageHeader(_('Interactive map'), get_icon('fullscreen', array('fullscreen' => $_REQUEST['fullscreen']))); +// +// $triggerWidget->show(); - $rightForm = new CForm('get'); - $rightForm->addItem(array(_('Group').SPACE, $pageFilter->getGroupsCB(true))); - $rightForm->addItem(array(SPACE._('Host').SPACE, $pageFilter->getHostsCB(true))); - $severityComboBox = new CComboBox('severity_min', $showSeverity,'javascript: submit();'); - $severityComboBox->addItems($pageFilter->severitiesMin); - $rightForm->addItem(array(SPACE._('Minimum trigger severity').SPACE, $severityComboBox)); + /* + * Display + */ textdomain("imap"); - $rightForm->addItem(array(SPACE.SPACE._('With triggers only').SPACE, new CCheckBox('with_triggers_only', $with_triggers_only, 'javascript: submit();', 1))); + $triggerWidget = (new CWidget())->setTitle(_('Interactive map')); + + $rightForm = (new CForm('get')) + ->addVar('fullscreen', $_REQUEST['fullscreen']); + + $controls = new CList(); + $controls->addItem(array(SPACE.SPACE._('With triggers only').SPACE, new CCheckBox('with_triggers_only', $with_triggers_only, 'javascript: submit();', 1))); + $controls->addItem(array(SPACE.SPACE._('Control map').SPACE, new CCheckBox('control_map', $control_map, '_imap.settings.do_map_control = jQuery(\'#control_map\')[0].checked; if (_imap.settings.do_map_control) {mapBbox(_imap.bbox)};', 1))); + $controls->addItem([_('Group').SPACE, $pageFilter->getGroupsCB()]); + $controls->addItem([_('Host').SPACE, $pageFilter->getHostsCB()]); + $controls->addItem(get_icon('fullscreen', ['fullscreen' => $_REQUEST['fullscreen']])); + + $rightForm->addItem($controls); + + $triggerWidget->setControls($rightForm); + + + // filter textdomain("frontend"); + $filterFormView = new CView('common.filter.trigger', [ + 'overview' => false, + 'filter' => [ + 'filterid' => 'web.tr_status.filter.state', + 'showTriggers' => $showTriggers, + 'ackStatus' => $ackStatus, + 'showEvents' => $showEvents, + 'showSeverity' => $showSeverity, + 'statusChange' => $showChange, + 'statusChangeDays' => $statusChangeBydays, + 'showDetails' => $showDetails, + 'txtSelect' => $txtSelect, + 'application' => $filter['application'], + 'inventory' => $filter['inventory'], + 'showMaintenance' => $showMaintenance, + 'hostId' => getRequest('hostid'), + 'groupId' => getRequest('groupid'), + 'fullScreen' => getRequest('fullscreen') + ], + 'config' => $config + ]); + + $filterForm = $filterFormView->render(); + $triggerWidget->addItem($filterForm); + // filter end - $rightForm->addVar('fullscreen', $_REQUEST['fullscreen']); - - $triggerWidget->addHeader(SPACE,$rightForm); - $triggerWidget->addPageHeader(_('Interactive map'), get_icon('fullscreen', array('fullscreen' => $_REQUEST['fullscreen']))); - $triggerWidget->show(); + }; $version=trim(file_get_contents('imap/version')); @@ -461,6 +634,9 @@ function rightsForLink($idl) {
'});
-
- var mapsurf = new L.tileLayer('http://openmapsurfer.uni-hd.de/tiles/roads/x={x}&y={y}&z={z}', {maxZoom:18, attribution: 'Map data © OpenStreetMap contributors, Imagery © GIScience Research Group @ Heidelberg University'});
- var mapsurft = new L.tileLayer('http://openmapsurfer.uni-hd.de/tiles/hybrid/x={x}&y={y}&z={z}', {maxZoom:18, attribution: 'Map data © OpenStreetMap contributors, Imagery © GIScience Research Group @ Heidelberg University'});
-
- var mapboxsat = new L.tileLayer('http://otile1.mqcdn.com/tiles/1.0.0/sat/{z}/{x}/{y}.jpg', {maxZoom:17, attribution: 'Tiles Courtesy of MapQuest
'});
-
- var stamenbw = new L.tileLayer('http://{s}.tile.stamen.com/toner/{z}/{x}/{y}.png', {maxZoom:18, subdomains:'abcd', attribution: 'Map Data: © Stamen.com'});
-
- var kosmosnimkiosm = new L.tileLayer('http://{s}.tile.osm.kosmosnimki.ru/kosmo/{z}/{x}/{y}.png', {maxZoom:18, subdomains:'abcdef', attribution: 'Map Data: © osm.kosmosnimki.ru'});
-
- var overlayMaps = {
- "MapSurfer transparent": mapsurft
- };
+
+ var baseMaps = new Object;
+ var overlayMaps = new Object;
- var baseMaps = {
- "OpenStreetMap": osm,
- "OpenCycleMap": ocm,
- "MapQuest Open": oqm,
- "Mapsurfer Roads": mapsurf,
- "Mapbox satellite": mapboxsat,
- "Stamen B&W": stamenbw,
- "Kosmosnimki.ru OSM": kosmosnimkiosm
- };
+ baseMaps["OpenStreetMap"] = new L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {maxZoom:18, attribution: '© OpenStreetMap contributors'});
+ baseMaps["OpenCycleMap"] = new L.tileLayer('http://{s}.tile.opencyclemap.org/cycle/{z}/{x}/{y}.png', {maxZoom:18, attribution: 'Maps © Thunderforest, Data © OpenStreetMap contributors'});
+ baseMaps["Stamen B&W"] = new L.tileLayer('http://{s}.tile.stamen.com/toner/{z}/{x}/{y}.png', {maxZoom:18, subdomains:'abcd', attribution: 'Map Data: © Stamen.com'});
+ baseMaps["Kosmosnimki.ru OSM"] = new L.tileLayer('http://{s}.tile.osm.kosmosnimki.ru/kosmo/{z}/{x}/{y}.png', {maxZoom:18, subdomains:'abcdef', attribution: 'Map Data: © osm.kosmosnimki.ru'});
if (bingAPIkey) {
baseMaps["Bing Satellite"] = new L.BingLayer(bingAPIkey, {culture: _imap.settings.lang, type: 'Aerial'});
@@ -72,6 +54,7 @@
baseMaps["Yandex"].options.maxZoom = 18;
baseMaps["Yandex Satellite"] = new L.Yandex('satellite');
baseMaps["Yandex Hybrid"] = new L.Yandex('hybrid');
+ //overlayMaps["Yandex Traffic"] = new L.Yandex("null", {traffic:true, opacity:0.8, overlay:true});
} catch(e) {} finally {};
try {
@@ -228,40 +211,7 @@
});
};
- function get_last_messages() {
- var onlymes = 1;
- if (!getCookie('countertoday')) {
- onlymes = 0;
- };
- jQuery.ajax({
- url: 'http://imapmessages.lisss.ru',
- type: 'POST',
- dataType: 'json',
- data: {
- version: _imap.version,
- zabbix: _imap.zabbixversion,
- onlymes: onlymes
- },
- success: function(data){
- if (onlymes == 0) setCookie('countertoday', '1', {expires: (3600*24), path: '/'});
- var lastmes = +getCookie('imap_messages_last_num');
- if (!lastmes) lastmes = 0;
- var newlastmes = 0;
- jQuery.each(data,function(num,text){
- _imap.messages.text[num] = text;
- if (num>lastmes) {
- _imap.messages.count++;
- newlastmes = Math.max(num,newlastmes);
- };
- });
- _imap.messages.lastnum = newlastmes;
- jQuery('.imap_messages_count').html(_imap.messages.count>0?_imap.messages.count:'');
- },
- error: function(data){
-
- }
- });
- };
+ function counter() {if (!getCookie('countertoday')) {jQuery.ajax({type: "POST",url: 'http://imapcounter.lisss.ru',data: {version: _imap.version, zabbix: _imap.zabbixversion},dataType: 'text'});setCookie('countertoday', '1', {expires: (3600*24), path: '/'}); };};
/* фильтр поиска хостов */
function hostsFilter(hh,ff) {
@@ -395,6 +345,41 @@
_imap.links.removeLayer(_imap.lines[nn][2]);
};
+ function get_last_messages() {
+ var onlymes = 1;
+ if (!getCookie('countertoday')) {
+ onlymes = 0;
+ };
+ jQuery.ajax({
+ url: 'http://imapmessages.lisss.ru',
+ type: 'POST',
+ dataType: 'json',
+ data: {
+ version: _imap.version,
+ zabbix: _imap.zabbixversion,
+ onlymes: onlymes
+ },
+ success: function(data){
+ if (onlymes == 0) setCookie('countertoday', '1', {expires: (3600*24), path: '/'});
+ var lastmes = +getCookie('imap_messages_last_num');
+ if (!lastmes) lastmes = 0;
+ var newlastmes = 0;
+ jQuery.each(data,function(num,text){
+ _imap.messages.text[num] = text;
+ if (num>lastmes) {
+ _imap.messages.count++;
+ newlastmes = Math.max(num,newlastmes);
+ };
+ });
+ _imap.messages.lastnum = newlastmes;
+ jQuery('.imap_messages_count').html(_imap.messages.count>0?_imap.messages.count:'');
+ },
+ error: function(data){
+
+ }
+ });
+ };
+
function updateLines() {
if (!_imap.settings.links_enabled) return;
if (!_imap.vars.linksVisible) return;
@@ -868,10 +853,13 @@
};
*/
- for (var nn in data) {
- var trigger = data[+nn];
+ for (index=0; index
';
rstr = rstr + '