', {text: item.label});
@@ -4027,9 +4034,9 @@ function setSelectMenus() {
}
if (item.element.attr('data-style') != '') {
- var style = item.element.attr('data-style')+';background:transparent;min-width:20px;';
+ style = item.element.attr('data-style')+';background:transparent;min-width:20px;';
} else {
- var style = 'background:transparent;min-width:20px;';
+ style = 'background:transparent;min-width:20px;';
}
var iclass = item.element.attr('data-class');
@@ -4273,10 +4280,10 @@ function setupEllipsis() {
/* re-position */
var position = $(this).position();
- if (position.left - parseInt(submenu.outerWidth()) < 0) {
+ if (position.left - Number.parseInt(submenu.outerWidth()) < 0) {
submenu.css({ 'left': 0 }).slideDown(120);
} else {
- submenu.css({ 'left': position.left - parseInt(submenu.outerWidth()) + parseInt($(this).outerWidth()) }).slideDown(120);
+ submenu.css({ 'left': position.left - Number.parseInt(submenu.outerWidth()) + Number.parseInt($(this).outerWidth()) }).slideDown(120);
}
} else {
submenu.slideUp(120);
@@ -4308,6 +4315,7 @@ function setupEllipsis() {
function keepWindowSize() {
$(window).on('resize', function (event) {
waitForFinalEvent(function () {
+ var graphTabWidth, userTabs, items, done;
$('.cactiGraphContentArea').show();
var resizeTime = new Date();
@@ -4355,15 +4363,15 @@ function keepWindowSize() {
$('.dropdownMenu > ul').hide();
if ($('#gtabs > .tabs').is(':visible')) {
- var graphTabWidth = $('#gtabs > .tabs').outerWidth();
+ graphTabWidth = $('#gtabs > .tabs').outerWidth();
} else {
- var graphTabWidth = 0;
+ graphTabWidth = 0;
}
if ($('.usertabs').length) {
- var userTabs = $('.usertabs').outerWidth();
+ userTabs = $('.usertabs').outerWidth();
} else {
- var userTabs = 0;
+ userTabs = 0;
}
var bodyWidth = $('body').width();
@@ -4372,7 +4380,7 @@ function keepWindowSize() {
otherWidth += $(this).outerWidth();
});
- var ellipsisWidth = $('.maintabs-submenu-ellipsis').outerWidth();
+ $('.maintabs-submenu-ellipsis').outerWidth();
var tabHeight = $('#tabs').outerHeight();
var mainTabPos = false;
@@ -4390,8 +4398,8 @@ function keepWindowSize() {
pageWidth = bodyWidth;
- var items = $($('.maintabs nav ul li a.lefttab').get());
- var done = false;
+ items = $($('.maintabs nav ul li a.lefttab').get());
+ done = false;
items.each(function () {
var id = $(this).attr('id');
@@ -4399,8 +4407,8 @@ function keepWindowSize() {
});
// Hide top menus if you have to
- var items = $($('.maintabs nav ul li a.lefttab').get().reverse());
- var done = false;
+ items = $($('.maintabs nav ul li a.lefttab').get().reverse());
+ done = false;
items.each(function () {
var id = $(this).attr('id');
@@ -4447,15 +4455,16 @@ function showCurrentTab(id) {
}
function tabsWrapping() {
+ var mainTabHeight, userTabPos, gtabsWidth, utabsWidth;
var mainTabPos = $('.maintabs:first').position();
var tabHeight = $('#tabs').height();
if ($('.usertabs').length) {
- var mainTabHeight = tabHeight;
- var userTabPos = $('.usertabs').position();
+ mainTabHeight = tabHeight;
+ userTabPos = $('.usertabs').position();
} else {
- var mainTabHeight = $('.maintabs:first nav').height();
- var userTabPos = mainTabPos;
+ mainTabHeight = $('.maintabs:first nav').height();
+ userTabPos = mainTabPos;
}
var bodyWidth = $('body').width();
@@ -4468,15 +4477,15 @@ function tabsWrapping() {
var mtabsWidth = $('.maintabs:not(.usertabs)').outerWidth();
if ($('#gtabs>.tabs').length) {
- var gtabsWidth = $('#gtabs>.tabs').outerWidth();
+ gtabsWidth = $('#gtabs>.tabs').outerWidth();
} else {
- var gtabsWidth = 0;
+ gtabsWidth = 0;
}
if ($('.usertabs').length) {
- var utabsWidth = $('.usertabs').outerWidth();
+ utabsWidth = $('.usertabs').outerWidth();
} else {
- var utabsWidth = 0;
+ utabsWidth = 0;
}
if (gtabsWidth + mtabsWidth + utabsWidth + otherWidth + ellipsisWidth > bodyWidth - 20) {
@@ -4521,7 +4530,7 @@ function setCactiTabCookie() {
}
function checkForRedirects(data, href) {
- if (typeof data == 'undefined') {
+ if (data === undefined) {
return true;
} else if (typeof data == 'object') {
return true;
@@ -4535,7 +4544,7 @@ function checkForRedirects(data, href) {
$.ajaxQ.abortAll();
document.location = urlPath + 'permission_denied.php';
} else if (data.indexOf('cactiRedirect') >= 0) {
- if (typeof href == 'undefined' || href == null) {
+ if (href === undefined || href == null) {
$.ajaxQ.abortAll();
location.reload();
} else {
@@ -4590,13 +4599,13 @@ function finalizeGraphFilter(options, data) {
function applyGraphFilter() {
var href = correctUrlParameters(graphPage + '?action=' + pageAction +
'&rfilter=' + base64_encode($('#rfilter').val()) +
- (typeof $('#site_id').val() != 'undefined' ? '&site_id=' + $('#site_id').val() : '') +
- (typeof $('#location').val() != 'undefined' ? '&location=' + $('#location').val() : '') +
- (typeof $('#host_id').val() != 'undefined' ? '&host_id=' + $('#host_id').val() : '') +
- (typeof $('#graph_source').val() != 'undefined' ? '&graph_source=' + $('#graph_source').val() : '') +
- (typeof $('#graph_order').val() != 'undefined' ? '&graph_order=' + $('#graph_order').val() : '') +
- (typeof $('#cf').val() != 'undefined' ? '&cf=' + $('#cf').val() : '') +
- (typeof $('#measure').val() != 'undefined' ? '&measure=' + $('#measure').val() : '') +
+ ($('#site_id').val() !== undefined ? '&site_id=' + $('#site_id').val() : '') +
+ ($('#location').val() !== undefined ? '&location=' + $('#location').val() : '') +
+ ($('#host_id').val() !== undefined ? '&host_id=' + $('#host_id').val() : '') +
+ ($('#graph_source').val() !== undefined ? '&graph_source=' + $('#graph_source').val() : '') +
+ ($('#graph_order').val() !== undefined ? '&graph_order=' + $('#graph_order').val() : '') +
+ ($('#cf').val() !== undefined ? '&cf=' + $('#cf').val() : '') +
+ ($('#measure').val() !== undefined ? '&measure=' + $('#measure').val() : '') +
'&columns=' + $('#columns').val() +
'&graphs=' + $('#graphs').val() +
'&graph_template_id=' + $('#graph_template_id').val() +
@@ -4618,7 +4627,7 @@ function pushState(myTitle, options) {
options = sanitizeAjaxOptions(options);
if (!options.noState) {
if (statePushed == false) {
- if (typeof window.history.pushState != 'undefined') {
+ if (window.history.pushState !== undefined) {
var myObject = { Page: myTitle, Url: cleanUrlParameters(options.url), Options: Object.assign({}, options) };
window.history.pushState(myObject, myObject.Page, myObject.Url);
}
@@ -4630,11 +4639,11 @@ function pushState(myTitle, options) {
function handlePopState(e) {
var href = document.location.href;
- if (typeof e !== 'undefined' && e.state != 'undefined' && e.state != null) {
- if (typeof e.state.Options != 'undefined' && e.state.Options != null) {
+ if (e !== undefined && e.state != 'undefined' && e.state != null) {
+ if (e.state.Options !== undefined && e.state.Options != null) {
loadUrl(e.state.Options);
return false;
- } else if (typeof e.state.Url != 'undefined' && e.state.Url != null) {
+ } else if (e.state.Url !== undefined && e.state.Url != null) {
loadUrl({ url: href });
return false;
}
@@ -4647,13 +4656,13 @@ function applyGraphTimespan() {
($('#rfilter').length ? '&rfilter=' + base64_encode($('#rfilter').val()) : '') +
'&predefined_timespan=' + $('#predefined_timespan').val() +
'&predefined_timeshift=' + $('#predefined_timeshift').val() +
- (typeof $('#site_id').val() != 'undefined' ? '&site_id=' + $('#site_id').val() : '') +
- (typeof $('#location').val() != 'undefined' ? '&location=' + $('#location').val() : '') +
- (typeof $('#host_id').val() != 'undefined' ? '&host_id=' + $('#host_id').val() : '') +
- (typeof $('#graph_source').val() != 'undefined' ? '&graph_source=' + $('#graph_source').val() : '') +
- (typeof $('#graph_order').val() != 'undefined' ? '&graph_order=' + $('#graph_order').val() : '') +
- (typeof $('#cf').val() != 'undefined' ? '&cf=' + $('#cf').val() : '') +
- (typeof $('#measure').val() != 'undefined' ? '&measure=' + $('#measure').val() : '') +
+ ($('#site_id').val() !== undefined ? '&site_id=' + $('#site_id').val() : '') +
+ ($('#location').val() !== undefined ? '&location=' + $('#location').val() : '') +
+ ($('#host_id').val() !== undefined ? '&host_id=' + $('#host_id').val() : '') +
+ ($('#graph_source').val() !== undefined ? '&graph_source=' + $('#graph_source').val() : '') +
+ ($('#graph_order').val() !== undefined ? '&graph_order=' + $('#graph_order').val() : '') +
+ ($('#cf').val() !== undefined ? '&cf=' + $('#cf').val() : '') +
+ ($('#measure').val() !== undefined ? '&measure=' + $('#measure').val() : '') +
'&columns=' + $('#columns').val() +
'&graphs=' + $('#graphs').val() +
'&graph_template_id=' + $('#graph_template_id').val() +
@@ -4795,15 +4804,15 @@ function redrawGraph(graph_id) {
'&business_hours=' + (isBusiness ? 'true' : 'false') +
$.getJSON(href, function(data) {
- if (typeof data.status == 'undefined') {
+ if (data.status === undefined) {
if (myWidth < data.image_width) {
ratio = myWidth / data.image_width;
- data.image_width = parseInt(data.image_width * ratio);
- data.image_height = parseInt(data.image_height * ratio);
- data.graph_width = parseInt(data.graph_width * ratio);
- data.graph_height = parseInt(data.graph_height * ratio);
- data.graph_top = parseInt(data.graph_top * ratio);
- data.graph_left = parseInt(data.graph_left * ratio);
+ data.image_width = Number.parseInt(data.image_width * ratio);
+ data.image_height = Number.parseInt(data.image_height * ratio);
+ data.graph_width = Number.parseInt(data.graph_width * ratio);
+ data.graph_height = Number.parseInt(data.graph_height * ratio);
+ data.graph_top = Number.parseInt(data.graph_top * ratio);
+ data.graph_left = Number.parseInt(data.graph_left * ratio);
}
$('#wrapper_' + data.local_graph_id).empty().html(
@@ -4916,7 +4925,7 @@ function initGraphDrilldown() {
}
function initializeGraphs(disable_cache) {
- disable_cache = (typeof disable_cache == 'undefined') ? false : true;
+ disable_cache = (disable_cache === undefined) ? false : true;
$.ajaxQ.abortAll();
@@ -5044,12 +5053,12 @@ function initializeGraphs(disable_cache) {
if (myWidth < data.image_width) {
ratio = myWidth / data.image_width;
- data.image_width = parseInt(data.image_width * ratio);
- data.image_height = parseInt(data.image_height * ratio);
- data.graph_width = parseInt(data.graph_width * ratio);
- data.graph_height = parseInt(data.graph_height * ratio);
- data.graph_top = parseInt(data.graph_top * ratio);
- data.graph_left = parseInt(data.graph_left * ratio);
+ data.image_width = Number.parseInt(data.image_width * ratio);
+ data.image_height = Number.parseInt(data.image_height * ratio);
+ data.graph_width = Number.parseInt(data.graph_width * ratio);
+ data.graph_height = Number.parseInt(data.graph_height * ratio);
+ data.graph_top = Number.parseInt(data.graph_top * ratio);
+ data.graph_left = Number.parseInt(data.graph_left * ratio);
}
var wrapper_id = '#wrapper_' + data.local_graph_id;
@@ -5417,7 +5426,7 @@ $.widget('custom.dropcolor', {
_select: function (event, ui) {
var regExp = /\(([^)]+)\)/;
var hex = regExp.exec(ui.item.label);
- var id = $(ui.item.option).attr('value');
+ $(ui.item.option).attr('value');
if (hex !== null) {
color = hex[1];
@@ -5512,7 +5521,7 @@ function expandClipboardSection(section) {
section.slideDown('fast');
}
- var children = section.find('table').each(function (i) {
+ section.find('table').each(function (i) {
expandClipboardSection($(this));
});
}
@@ -5821,16 +5830,17 @@ function setSNMP() {
}
function checkSNMPPassphrase(type) {
+ var pass, conf, span;
var minChars = 8;
if (type == 'priv') {
- var pass = '#snmp_priv_passphrase';
- var conf = '#snmp_priv_passphrase_confirm';
- var span = 'priv';
+ pass = '#snmp_priv_passphrase';
+ conf = '#snmp_priv_passphrase_confirm';
+ span = 'priv';
} else {
- var pass = '#snmp_password';
- var conf = '#snmp_password_confirm';
- var span = 'auth';
+ pass = '#snmp_password';
+ conf = '#snmp_password_confirm';
+ span = 'auth';
}
if ($(pass).val().length == 0) {
@@ -5848,18 +5858,19 @@ function checkSNMPPassphrase(type) {
}
function checkSNMPPassphraseConfirm(type) {
+ var pass, conf, span, spanconf;
var minChars = 8;
if (type == 'priv') {
- var pass = '#snmp_priv_passphrase';
- var conf = '#snmp_priv_passphrase_confirm';
- var span = 'priv';
- var spanconf = 'privconf';
+ pass = '#snmp_priv_passphrase';
+ conf = '#snmp_priv_passphrase_confirm';
+ span = 'priv';
+ spanconf = 'privconf';
} else {
- var pass = '#snmp_password';
- var conf = '#snmp_password_confirm';
- var span = 'auth';
- var spanconf = 'authconf';
+ pass = '#snmp_password';
+ conf = '#snmp_password_confirm';
+ span = 'auth';
+ spanconf = 'authconf';
}
if ($(conf).val().length < minChars) {
@@ -5897,7 +5908,7 @@ const streamAvailabilityToggleOptions = ['0', '1', '2', '3', '4', '5', '6'];
const streamSNMPToggleOptions = ['1', '2', '3'];
function setAvailability() {
- var hasChanged = false;
+
if ($('#availability_method').val() != '7') {
if ($('#snmp_version').val() == '0') {
@@ -6020,7 +6031,7 @@ function formValidate(formId, href) {
}
if (name !== null && name.length > 0) {
- if (typeof formRules[formId] !== 'undefined') {
+ if (formRules[formId] !== undefined) {
formRules[formId][name] = {
required: true,
email: true,
@@ -6080,7 +6091,7 @@ function toggleFields(fields, prefix = '#row_') {
Object.keys(fields).forEach(index => {
curParent = $(prefix + index).parent().attr('id');
- if (typeof curParent != 'undefined' && curParent != lastParent) {
+ if (curParent !== undefined && curParent != lastParent) {
parents.push(curParent);
}
@@ -6092,7 +6103,7 @@ function toggleFields(fields, prefix = '#row_') {
$(prefix + index).hide();
}
- if (typeof curParent != 'undefined') {
+ if (curParent !== undefined) {
lastParent = curParent;
}
});
diff --git a/include/realtime.js b/include/realtime.js
index 0bc4bde67..e11b5fe46 100644
--- a/include/realtime.js
+++ b/include/realtime.js
@@ -38,16 +38,17 @@ var url;
var local_graph_id = null;
function realtimeDetectBrowser() {
+ var browser;
if (navigator.userAgent.indexOf('MSIE') >= 0) {
- var browser = 'IE';
+ browser = 'IE';
} else if (navigator.userAgent.indexOf('Chrome') >= 0) {
- var browser = 'Chrome';
+ browser = 'Chrome';
} else if (navigator.userAgent.indexOf('Mozilla') >= 0) {
- var browser = 'FF';
+ browser = 'FF';
} else if (navigator.userAgent.indexOf('Opera') >= 0) {
- var browser = 'Opera';
+ browser = 'Opera';
} else {
- var browser = 'Other';
+ browser = 'Other';
}
return browser;
@@ -55,7 +56,7 @@ function realtimeDetectBrowser() {
function imageOptionsChanged(action) {
const graph_start = $('#graph_start').val();
- var graph_end = 0;
+
const ds_step = $('#ds_step').val();
var size = $('#size').val();
const isThumb = $('#thumbnails').is(':checked');
@@ -78,12 +79,12 @@ function imageOptionsChanged(action) {
if (action === 'countdown') {
url = `graph_realtime.php?action=countdown&top=0&left=0&local_graph_id=${local_graph_id}&ds_step=${ds_step}&count=${count}&size=${size}&graph_nolegend=${isThumb}`;
} else if (action === 'initial') {
- url = `graph_realtime.php?action=initial&top=0&left=0&local_graph_id=${local_graph_id}&graph_start=-${parseInt(graph_start) > 0 ? graph_start:'60'}&ds_step=${ds_step}&count=${count}&size=${size}`;
+ url = `graph_realtime.php?action=initial&top=0&left=0&local_graph_id=${local_graph_id}&graph_start=-${Number.parseInt(graph_start) > 0 ? graph_start:'60'}&ds_step=${ds_step}&count=${count}&size=${size}`;
} else {
- url = `graph_realtime.php?action=${action}&top=0&left=0&local_graph_id=${local_graph_id}&graph_start=-${parseInt(graph_start) > 0 ? graph_start:'60'}&ds_step=${ds_step}&count=${count}&size=${size}&graph_nolegend=${isThumb}`;
+ url = `graph_realtime.php?action=${action}&top=0&left=0&local_graph_id=${local_graph_id}&graph_start=-${Number.parseInt(graph_start) > 0 ? graph_start:'60'}&ds_step=${ds_step}&count=${count}&size=${size}&graph_nolegend=${isThumb}`;
}
- Pace.stop;
+ Pace.stop();
$.getJSON(url)
.done(function(data) {
@@ -170,7 +171,7 @@ function countRealtimeGraphs() {
}
function stopRealtime() {
- var graph;
+
for (key in realtimeArray) {
var graph_id = key;
@@ -239,7 +240,7 @@ function realtimeGrapher() {
}
const graph_start = $('#graph_start').val();
- var graph_end = 0;
+
const ds_step = $('#ds_step').val();
var size = $('#size').val();
const isThumb = $('#thumbnails').is(':checked');
@@ -276,7 +277,7 @@ function realtimeGrapher() {
position = $('body').position();
}
- $.get(`${urlPath}graph_realtime.php?action=countdown&top=${parseInt(position.top)}&left=${parseInt(position.left)}${isThumb ? '&graph_nolegend=true':'&graph_nolegend=false'}&graph_end=0&graph_start=-${parseInt(graph_start) > 0 ? graph_start:'60'}&local_graph_id=${local_graph_id}&ds_step=${ds_step}&count=${count}&size=${size}`)
+ $.get(`${urlPath}graph_realtime.php?action=countdown&top=${Number.parseInt(position.top)}&left=${Number.parseInt(position.left)}${isThumb ? '&graph_nolegend=true':'&graph_nolegend=false'}&graph_end=0&graph_start=-${Number.parseInt(graph_start) > 0 ? graph_start:'60'}&local_graph_id=${local_graph_id}&ds_step=${ds_step}&count=${count}&size=${size}`)
.done(function(data) {
var results = (typeof data === 'string') ? JSON.parse(data) : data;
diff --git a/include/themes/cacti/main.js b/include/themes/cacti/main.js
index cd3da52b7..16abaf657 100644
--- a/include/themes/cacti/main.js
+++ b/include/themes/cacti/main.js
@@ -134,12 +134,12 @@ function themeReady() {
}
function setMenuVisibility() {
- storage=Storages.sessionStorage;
+ const storage = Storages.sessionStorage;
// Initialize the navigation settings
$('#navigation').hide();
$('li.menuitem').each(function() {
- active = storage.get($(this).attr('id'));
+ const active = storage.get($(this).attr('id'));
if (active != null && active == 'active') {
$(this).find('ul').attr('aria-hidden', 'false').attr('aria-expanded', 'true').show();
$(this).next('a').show();
@@ -155,7 +155,7 @@ function setMenuVisibility() {
$('#nav li:has(ul) a.active').rebind('click', function(event) {
event.preventDefault();
- id = $(this).closest('.menuitem').attr('id');
+ const id = $(this).closest('.menuitem').attr('id');
if ($(this).next().is(':visible')){
$(this).next('ul').attr('aria-hidden', 'true').attr('aria-expanded', 'false');
@@ -172,8 +172,6 @@ function setMenuVisibility() {
}
$('li.menuitem').not('#'+id).each(function() {
- text = $(this).attr('id');
- id = $(this).attr('id');
$(this).find('ul').attr('aria-hidden', 'true').attr('aria-expanded', 'false');
$(this).find('ul').slideUp( { duration: 200, easing: 'swing' } );
diff --git a/include/themes/carrot/main.js b/include/themes/carrot/main.js
index cd3da52b7..16abaf657 100644
--- a/include/themes/carrot/main.js
+++ b/include/themes/carrot/main.js
@@ -134,12 +134,12 @@ function themeReady() {
}
function setMenuVisibility() {
- storage=Storages.sessionStorage;
+ const storage = Storages.sessionStorage;
// Initialize the navigation settings
$('#navigation').hide();
$('li.menuitem').each(function() {
- active = storage.get($(this).attr('id'));
+ const active = storage.get($(this).attr('id'));
if (active != null && active == 'active') {
$(this).find('ul').attr('aria-hidden', 'false').attr('aria-expanded', 'true').show();
$(this).next('a').show();
@@ -155,7 +155,7 @@ function setMenuVisibility() {
$('#nav li:has(ul) a.active').rebind('click', function(event) {
event.preventDefault();
- id = $(this).closest('.menuitem').attr('id');
+ const id = $(this).closest('.menuitem').attr('id');
if ($(this).next().is(':visible')){
$(this).next('ul').attr('aria-hidden', 'true').attr('aria-expanded', 'false');
@@ -172,8 +172,6 @@ function setMenuVisibility() {
}
$('li.menuitem').not('#'+id).each(function() {
- text = $(this).attr('id');
- id = $(this).attr('id');
$(this).find('ul').attr('aria-hidden', 'true').attr('aria-expanded', 'false');
$(this).find('ul').slideUp( { duration: 200, easing: 'swing' } );
diff --git a/include/themes/dark/main.js b/include/themes/dark/main.js
index d010b93ad..de2d11dc5 100644
--- a/include/themes/dark/main.js
+++ b/include/themes/dark/main.js
@@ -96,18 +96,14 @@ function themeReady() {
}
function setMenuVisibility() {
- storage=Storages.sessionStorage;
+ const storage = Storages.sessionStorage;
// Initialize the navigation settings
// This will setup the initial visibility of the menu
$('li.menuitem').each(function() {
- var id = $(this).attr('id');
+ const id = $(this).attr('id');
- if (storage.isSet(id)) {
- var active = storage.get(id);
- } else {
- var active = null;
- }
+ const active = storage.isSet(id) ? storage.get(id) : null;
if (active != null && active == 'active') {
$(this).find('ul').attr('aria-hidden', 'false').attr('aria-expanded', 'true').show();
@@ -132,7 +128,7 @@ function setMenuVisibility() {
$('#nav li:has(ul) a.active').rebind('click', function(event) {
event.preventDefault();
- id = $(this).closest('.menuitem').attr('id');
+ const id = $(this).closest('.menuitem').attr('id');
if ($(this).next().is(':visible')) {
$(this).next('ul').attr('aria-hidden', 'true').attr('aria-expanded', 'false');
@@ -149,8 +145,6 @@ function setMenuVisibility() {
}
$('li.menuitem').not('#'+id).each(function() {
- text = $(this).attr('id');
- id = $(this).attr('id');
$(this).find('ul').attr('aria-hidden', 'true').attr('aria-expanded', 'false');
$(this).find('ul').slideUp( { duration: 200, easing: 'swing' } );
diff --git a/include/themes/deepness/main.js b/include/themes/deepness/main.js
index 1fc26dd5b..01e1d5fd5 100644
--- a/include/themes/deepness/main.js
+++ b/include/themes/deepness/main.js
@@ -135,18 +135,14 @@ function themeReady() {
}
function setMenuVisibility() {
- storage=Storages.sessionStorage;
+ const storage = Storages.sessionStorage;
// Initialize the navigation settings
// This will setup the initial visibility of the menu
$('li.menuitem').each(function() {
- var id = $(this).attr('id');
+ const id = $(this).attr('id');
- if (storage.isSet(id)) {
- var active = storage.get(id);
- } else {
- var active = null;
- }
+ const active = storage.isSet(id) ? storage.get(id) : null;
if (active != null && active == 'active') {
$(this).find('ul').attr('aria-hidden', 'false').attr('aria-expanded', 'true').show();
@@ -172,7 +168,7 @@ function setMenuVisibility() {
$('#nav li:has(ul) a.active').rebind('click', function(event) {
event.preventDefault();
- id = $(this).closest('.menuitem').attr('id');
+ const id = $(this).closest('.menuitem').attr('id');
if ($(this).next().is(':visible')) {
$(this).next('ul').attr('aria-hidden', 'true').attr('aria-expanded', 'false');
@@ -189,8 +185,6 @@ function setMenuVisibility() {
}
$('li.menuitem').not('#'+id).each(function() {
- text = $(this).attr('id');
- id = $(this).attr('id');
$(this).find('ul').attr('aria-hidden', 'true').attr('aria-expanded', 'false');
$(this).find('ul').slideUp( { duration: 200, easing: 'swing' } );
diff --git a/include/themes/hollyberry/main.js b/include/themes/hollyberry/main.js
index cd3da52b7..16abaf657 100644
--- a/include/themes/hollyberry/main.js
+++ b/include/themes/hollyberry/main.js
@@ -134,12 +134,12 @@ function themeReady() {
}
function setMenuVisibility() {
- storage=Storages.sessionStorage;
+ const storage = Storages.sessionStorage;
// Initialize the navigation settings
$('#navigation').hide();
$('li.menuitem').each(function() {
- active = storage.get($(this).attr('id'));
+ const active = storage.get($(this).attr('id'));
if (active != null && active == 'active') {
$(this).find('ul').attr('aria-hidden', 'false').attr('aria-expanded', 'true').show();
$(this).next('a').show();
@@ -155,7 +155,7 @@ function setMenuVisibility() {
$('#nav li:has(ul) a.active').rebind('click', function(event) {
event.preventDefault();
- id = $(this).closest('.menuitem').attr('id');
+ const id = $(this).closest('.menuitem').attr('id');
if ($(this).next().is(':visible')){
$(this).next('ul').attr('aria-hidden', 'true').attr('aria-expanded', 'false');
@@ -172,8 +172,6 @@ function setMenuVisibility() {
}
$('li.menuitem').not('#'+id).each(function() {
- text = $(this).attr('id');
- id = $(this).attr('id');
$(this).find('ul').attr('aria-hidden', 'true').attr('aria-expanded', 'false');
$(this).find('ul').slideUp( { duration: 200, easing: 'swing' } );
diff --git a/include/themes/midwinter/main.js b/include/themes/midwinter/main.js
index 59952ba1c..a1e898c30 100755
--- a/include/themes/midwinter/main.js
+++ b/include/themes/midwinter/main.js
@@ -456,7 +456,7 @@ function setupTheme() {
});
} else {
$("#navBackdrop").on('click', function() {
- window.open('https://cacti.net', '_blank');
+ window.open('https://cacti.net', '_blank', 'noopener,noreferrer');
});
}
}
@@ -597,7 +597,7 @@ function toggleCactiNavigationBoxPin(event) {
let caller = $(event.currentTarget);
let helper = caller.attr('data-helper');
let navigationBox = $('[class^="mdw-ConsoleNavigationBox"][data-helper="' + helper + '"]');
- let compact_nav_icon = $('[class^="compact_nav_icon"][data-helper="' + helper + '"]');
+ $('[class^="compact_nav_icon"][data-helper="' + helper + '"]');
if(event.data && event.data.dock) {
event.data.dock = event.data.dock.replace(/^./, str => str.toUpperCase());
@@ -670,7 +670,7 @@ function hideDropDownMenu() {
function toggleTableColumn(event) {
let storage = Storages.localStorage;
let tableHash = event.target.dataset.table;
- let cIndex = parseInt(event.target.dataset.column);
+ let cIndex = Number.parseInt(event.target.dataset.column);
let cClass = 'no-col'+cIndex;
let storage_table_headers = storage.get('midWinter_' + tableHash);
@@ -914,7 +914,7 @@ function changeGuiFontSize(change=true) {
setDocumentAttribute('zoom-level', mdw.session.theme.font.zoom);
}
/* update output field beside input selector */
- $('#mdw_themeFontSizeValue').val((parseFloat(mdw.session.theme.font.zoom) + 25).toFixed(1) + ' %');
+ $('#mdw_themeFontSizeValue').val((Number.parseFloat(mdw.session.theme.font.zoom) + 25).toFixed(1) + ' %');
}
function toggleGuiAnimations() {
@@ -1022,9 +1022,9 @@ function togglePopOver(force) {
function fullScreen(event) {
if (!document.fullscreenElement) {
- document.documentElement.requestFullscreen().then( r => fullScreenChangeHandler() );
+ document.documentElement.requestFullscreen().then(() => fullScreenChangeHandler()).catch(() => fullScreenChangeHandler());
}else if (document.exitFullscreen) {
- document.exitFullscreen().then( r => fullScreenChangeHandler() );
+ document.exitFullscreen().then(() => fullScreenChangeHandler()).catch(() => fullScreenChangeHandler());
}
}
@@ -1328,7 +1328,7 @@ registry.midwinter = {
let midWinter_Color_Mode_Auto = mdw.session.theme.color.auto;
let midWinter_Font_Size = mdw.session.theme.font.zoom;
let midWinter_Animations = mdw.session.theme.boxes.animated
- let midWinter_ShownFontSizeValue = parseFloat(midWinter_Font_Size) + 25;
+ let midWinter_ShownFontSizeValue = Number.parseFloat(midWinter_Font_Size) + 25;
let midWinter_Auto_Table_Layout = mdw.session.theme.mobile.autoTableLayout;
let midWinter_Controls_SubTitle = mdw.session.theme.controls.subTitle;
@@ -1413,4 +1413,4 @@ registry.midwinter = {
}
}
}
-}
\ No newline at end of file
+}
diff --git a/include/themes/modern/main.js b/include/themes/modern/main.js
index d08b69797..faa53cadf 100644
--- a/include/themes/modern/main.js
+++ b/include/themes/modern/main.js
@@ -88,18 +88,14 @@ function themeReady() {
}
function setMenuVisibility() {
- storage=Storages.sessionStorage;
+ const storage = Storages.sessionStorage;
// Initialize the navigation settings
// This will setup the initial visibility of the menu
$('li.menuitem').each(function() {
- var id = $(this).attr('id');
+ const id = $(this).attr('id');
- if (storage.isSet(id)) {
- var active = storage.get(id);
- } else {
- var active = null;
- }
+ const active = storage.isSet(id) ? storage.get(id) : null;
if (active != null && active == 'active') {
$(this).find('ul').attr('aria-hidden', 'false').attr('aria-expanded', 'true').show();
@@ -125,7 +121,7 @@ function setMenuVisibility() {
$('#nav li:has(ul) a.active').rebind('click', function(event) {
event.preventDefault();
- id = $(this).closest('.menuitem').attr('id');
+ const id = $(this).closest('.menuitem').attr('id');
if ($(this).next().is(':visible')) {
$(this).next('ul').attr('aria-hidden', 'true').attr('aria-expanded', 'false');
@@ -142,8 +138,6 @@ function setMenuVisibility() {
}
$('li.menuitem').not('#'+id).each(function() {
- text = $(this).attr('id');
- id = $(this).attr('id');
$(this).find('ul').attr('aria-hidden', 'true').attr('aria-expanded', 'false');
$(this).find('ul').slideUp( { duration: 200, easing: 'swing' } );
diff --git a/include/themes/paper-plane/main.js b/include/themes/paper-plane/main.js
index a286eec5e..bdf4f160e 100644
--- a/include/themes/paper-plane/main.js
+++ b/include/themes/paper-plane/main.js
@@ -153,18 +153,14 @@ function themeReady() {
}
function setMenuVisibility() {
- storage=Storages.sessionStorage;
+ const storage = Storages.sessionStorage;
// Initialize the navigation settings
// This will setup the initial visibility of the menu
$('li.menuitem').each(function() {
- var id = $(this).attr('id');
+ const id = $(this).attr('id');
- if (storage.isSet(id)) {
- var active = storage.get(id);
- } else {
- var active = null;
- }
+ const active = storage.isSet(id) ? storage.get(id) : null;
if (active != null && active == 'active') {
$(this).find('ul').attr('aria-hidden', 'false').attr('aria-expanded', 'true').show();
@@ -190,7 +186,7 @@ function setMenuVisibility() {
$('#nav li:has(ul) a.active').rebind('click', function(event) {
event.preventDefault();
- id = $(this).closest('.menuitem').attr('id');
+ const id = $(this).closest('.menuitem').attr('id');
if ($(this).next().is(':visible')) {
$(this).next('ul').attr('aria-hidden', 'true').attr('aria-expanded', 'false');
@@ -207,8 +203,6 @@ function setMenuVisibility() {
}
$('li.menuitem').not('#'+id).each(function() {
- text = $(this).attr('id');
- id = $(this).attr('id');
$(this).find('ul').attr('aria-hidden', 'true').attr('aria-expanded', 'false');
$(this).find('ul').slideUp( { duration: 200, easing: 'swing' } );
diff --git a/include/themes/paw/main.js b/include/themes/paw/main.js
index ebacbbce6..c1c9c6ed2 100644
--- a/include/themes/paw/main.js
+++ b/include/themes/paw/main.js
@@ -135,18 +135,14 @@ function themeReady() {
}
function setMenuVisibility() {
- storage=Storages.sessionStorage;
+ const storage = Storages.sessionStorage;
// Initialize the navigation settings
// This will setup the initial visibility of the menu
$('li.menuitem').each(function() {
- var id = $(this).attr('id');
+ const id = $(this).attr('id');
- if (storage.isSet(id)) {
- var active = storage.get(id);
- } else {
- var active = null;
- }
+ const active = storage.isSet(id) ? storage.get(id) : null;
if (active != null && active == 'active') {
$(this).find('ul').attr('aria-hidden', 'false').attr('aria-expanded', 'true').show();
@@ -172,7 +168,7 @@ function setMenuVisibility() {
$('#nav li:has(ul) a.active').rebind('click', function(event) {
event.preventDefault();
- id = $(this).closest('.menuitem').attr('id');
+ const id = $(this).closest('.menuitem').attr('id');
if ($(this).next().is(':visible')) {
$(this).next('ul').attr('aria-hidden', 'true').attr('aria-expanded', 'false');
@@ -189,8 +185,6 @@ function setMenuVisibility() {
}
$('li.menuitem').not('#'+id).each(function() {
- text = $(this).attr('id');
- id = $(this).attr('id');
$(this).find('ul').attr('aria-hidden', 'true').attr('aria-expanded', 'false');
$(this).find('ul').slideUp( { duration: 200, easing: 'swing' } );
diff --git a/include/themes/raspberry/main.js b/include/themes/raspberry/main.js
index cd3da52b7..16abaf657 100644
--- a/include/themes/raspberry/main.js
+++ b/include/themes/raspberry/main.js
@@ -134,12 +134,12 @@ function themeReady() {
}
function setMenuVisibility() {
- storage=Storages.sessionStorage;
+ const storage = Storages.sessionStorage;
// Initialize the navigation settings
$('#navigation').hide();
$('li.menuitem').each(function() {
- active = storage.get($(this).attr('id'));
+ const active = storage.get($(this).attr('id'));
if (active != null && active == 'active') {
$(this).find('ul').attr('aria-hidden', 'false').attr('aria-expanded', 'true').show();
$(this).next('a').show();
@@ -155,7 +155,7 @@ function setMenuVisibility() {
$('#nav li:has(ul) a.active').rebind('click', function(event) {
event.preventDefault();
- id = $(this).closest('.menuitem').attr('id');
+ const id = $(this).closest('.menuitem').attr('id');
if ($(this).next().is(':visible')){
$(this).next('ul').attr('aria-hidden', 'true').attr('aria-expanded', 'false');
@@ -172,8 +172,6 @@ function setMenuVisibility() {
}
$('li.menuitem').not('#'+id).each(function() {
- text = $(this).attr('id');
- id = $(this).attr('id');
$(this).find('ul').attr('aria-hidden', 'true').attr('aria-expanded', 'false');
$(this).find('ul').slideUp( { duration: 200, easing: 'swing' } );
diff --git a/include/themes/sunrise/main.js b/include/themes/sunrise/main.js
index 5b87a0e4c..c2417e116 100644
--- a/include/themes/sunrise/main.js
+++ b/include/themes/sunrise/main.js
@@ -28,7 +28,7 @@ function themeReady() {
$('#navigation_right').rebind('scroll', function (event) {
var scroll_position_x = $('#navigation_right').scrollLeft();
var scroll_position_y = $('#navigation_right').scrollTop();
- $('.bottom_scroll_up').css({'color': ((scroll_position_x == 0 & scroll_position_y == 0) ? '' : '#93CEFF') });
+ $('.bottom_scroll_up').css({'color': ((scroll_position_x === 0 && scroll_position_y === 0) ? '' : '#93CEFF') });
});
// Add nice search filter to filters
@@ -158,18 +158,14 @@ function themeReady() {
}
function setMenuVisibility() {
- storage=Storages.sessionStorage;
+ const storage = Storages.sessionStorage;
// Initialize the navigation settings
// This will setup the initial visibility of the menu
$('li.menuitem').each(function() {
- var id = $(this).attr('id');
+ const id = $(this).attr('id');
- if (storage.isSet(id)) {
- var active = storage.get(id);
- } else {
- var active = null;
- }
+ const active = storage.isSet(id) ? storage.get(id) : null;
if (active != null && active == 'active') {
$(this).find('ul').attr('aria-hidden', 'false').attr('aria-expanded', 'true').show();
@@ -195,7 +191,7 @@ function setMenuVisibility() {
$('#nav li:has(ul) a.active').rebind('click', function(event) {
event.preventDefault();
- id = $(this).closest('.menuitem').attr('id');
+ const id = $(this).closest('.menuitem').attr('id');
if ($(this).next().is(':visible')) {
$(this).next('ul').attr('aria-hidden', 'true').attr('aria-expanded', 'false');
@@ -212,8 +208,6 @@ function setMenuVisibility() {
}
$('li.menuitem').not('#'+id).each(function() {
- text = $(this).attr('id');
- id = $(this).attr('id');
$(this).find('ul').attr('aria-hidden', 'true').attr('aria-expanded', 'false');
$(this).find('ul').slideUp( { duration: 200, easing: 'swing' } );
diff --git a/install/install.js b/install/install.js
index 2949918ca..09146d837 100644
--- a/install/install.js
+++ b/install/install.js
@@ -127,7 +127,7 @@ function setButtonData(buttonName, buttonData) {
button.button();
button.data('buttonData', buttonData);
if (buttonData != null) {
- var buttonCheck = button.data('buttonData');
+ button.data('buttonData');
if (buttonData.Enabled) {
button.button('enable');
} else {
@@ -231,7 +231,7 @@ function getDefaultInstallData() {
}
function toggleHeader(key, initial) {
- if (typeof initial === 'undefined') {
+ if (initial === undefined) {
initial = null;
}
@@ -254,7 +254,7 @@ function toggleHeader(key, initial) {
}
function toggleSection(key, initial) {
- if (typeof initial === 'undefined') {
+ if (initial === undefined) {
initial = null;
}
@@ -559,7 +559,7 @@ function prepareInstallData(installStep, stepOnly) {
}
// No installation step if we have never started.
- if (typeof installStep === 'undefined' && installData.Step == STEP_NONE) {
+ if (installStep === undefined && installData.Step == STEP_NONE) {
newData = [];
} else {
newData = getDefaultInstallData();
@@ -572,12 +572,12 @@ function prepareInstallData(installStep, stepOnly) {
}
}
- if (typeof installStep !== 'undefined') {
+ if (installStep !== undefined) {
step = installData.Step;
if (step == STEP_WELCOME) prepareStepWelcome(newData);
// Assume we want all data if stepOnly not set
- if (typeof stepOnly === 'undefined') {
+ if (stepOnly === undefined) {
if (step == STEP_INSTALL_TYPE) prepareStepInstallType(newData);
else if (step == STEP_BINARY_LOCATIONS) prepareStepBinaryLocations(newData);
else if (step == STEP_PROFILE_AND_AUTOMATION) prepareStepProfileAndAutomation(newData);
@@ -700,7 +700,7 @@ function performStep(installStep, suppressRefresh, forceReload, csrfRetry) {
$('#installContent').html(data.Html);
$('#installContent').show();
- if (typeof $('#installData').data('debug') !== 'undefined') {
+ if ($('#installData').data('debug') !== undefined) {
debugData = data;
debugData.Html = '';
debug = $('#installDebug');
@@ -822,7 +822,7 @@ function performTestConnection(csrfRetry) {
$('#installContent').removeClass('cactiInstallLoaderBlur');
var isSuccessful = false, statusText = testFailed;
- if (typeof data.status !== 'undefined') {
+ if (data.status !== undefined) {
if (data.status == 'true') {
isSuccessful = true;
statusText = testSuccessful;
diff --git a/lib/html.php b/lib/html.php
index 12984d7b3..13bf446e4 100644
--- a/lib/html.php
+++ b/lib/html.php
@@ -3200,7 +3200,8 @@ function html_common_header(string $title, string $selectedTheme = '') : void {
var showHideFilter = '';
var spikeKillResults = '';
var standardGraphicalUserInterface = '';
- var tableConstraints = '';
+ var tableConstraints = ;
var testFailed = '';
var testSuccessful = '';
var theme = '';
@@ -3245,7 +3246,8 @@ function html_common_header(string $title, string $selectedTheme = '') : void {
var zoom_i18n_zoom_out_factor = '';
var zoom_i18n_zoom_out_positioning = '';
var zoom_outOfRangeTitle='';
- var zoom_outOfRangeMessage='';
+ var zoom_outOfRangeMessage= ;
host = '';
}
- function __destruct() {
+ public function __destruct() {
}
- function ErrorHandler(int $level, string $message, string $file, int $line, array $context = []) : bool {
+ public function ErrorHandler(int $level, string $message, string $file, int $line, array $context = []) : bool {
return true;
}
- function SetLdapHandler() : void {
+ public function SetLdapHandler() : void {
// drop out of cactis error handler
restore_error_handler();
@@ -503,7 +503,7 @@ class Ldap {
cacti_session_close();
}
- function RestoreCactiHandler() : void {
+ public function RestoreCactiHandler() : void {
// drop out of ldaps error handler
restore_error_handler();
@@ -513,13 +513,13 @@ class Ldap {
cacti_session_start();
}
- function RecordError(array $output, string $section = 'LDAP') : void {
+ public function RecordError(array $output, string $section = 'LDAP') : void {
$logDN = empty($output['dn']) ? '' : (', DN: ' . $output['dn']);
cacti_log($section . ': ' . $output['error_text'] . $logDN, false, 'AUTH');
cacti_log($section . ': ' . $output['stack'], false, 'AUTH', $this->debug);
}
- function Connect() : array {
+ public function Connect() : array {
$output = [];
$ldap_conn = null;
@@ -698,7 +698,7 @@ class Ldap {
}
}
- function Authenticate() : array {
+ public function Authenticate() : array {
$output = [];
cacti_log('LDAP: Authentication Start', false, 'AUTH', $this->debug);
@@ -838,7 +838,7 @@ class Ldap {
return $output;
}
- function GetMask() : int {
+ public function GetMask() : int {
if (!defined('ENT_HTML401')) {
return ENT_COMPAT;
} else {
@@ -869,7 +869,7 @@ class Ldap {
* failure) so the caller can leave assignments untouched
* rather than revoking them on a transient outage.
*/
- function ResolveGroupMemberships(string $username, array $groupNames) : ?array {
+ public function ResolveGroupMemberships(string $username, array $groupNames) : ?array {
if (!cacti_sizeof($groupNames)) {
return [];
}
@@ -1136,7 +1136,7 @@ class Ldap {
return $queries;
}
- function Search() : array {
+ public function Search() : array {
$output = [];
// Determine connection method and create LDAP Object
@@ -1256,7 +1256,7 @@ class Ldap {
return $output;
}
- function Getcn() : array {
+ public function Getcn() : array {
$output = [];
// Determine connection method and create LDAP Object
@@ -1397,7 +1397,7 @@ class Ldap {
return $output;
}
- function isUserInLDAPGroup(object $ldapConn, string $ldapbasedn, string $groupDN, string $ldapUser) : bool {
+ public function isUserInLDAPGroup(object $ldapConn, string $ldapbasedn, string $groupDN, string $ldapUser) : bool {
$query = cacti_ldap_filter(
'(&(distinguishedName=
)(memberOf:1.2.840.113556.1.4.1941:=))',
['user' => $ldapUser, 'group' => $groupDN]
diff --git a/lib/mib_parser.php b/lib/mib_parser.php
index 27a2f032d..0a45f837b 100644
--- a/lib/mib_parser.php
+++ b/lib/mib_parser.php
@@ -56,13 +56,13 @@ class MibParser extends MibCache {
/**
* Constructor
*/
- function __construct() {
+ public function __construct() {
set_time_limit(0);
ini_set('memory_limit', '-1');
error_reporting(E_ALL);
}
- function add_mib(string $filename, string $mib_name): void {
+ public function add_mib(string $filename, string $mib_name): void {
$mibtext = file_get_contents($filename);
if ($mibtext === false) {
@@ -78,7 +78,7 @@ class MibParser extends MibCache {
* @param string $text
* @return array
*/
- function get_tokens($text) {
+ public function get_tokens($text) {
$in_quote = false;
$in_comment = false;
$token = '';
@@ -197,7 +197,7 @@ class MibParser extends MibCache {
* @param array $allowed
* @return array
*/
- function parse_simple_token($tokens, &$index, $allowed = null) {
+ public function parse_simple_token($tokens, &$index, $allowed = null) {
$index++;
if (is_array($allowed)) {
@@ -222,7 +222,7 @@ class MibParser extends MibCache {
* @param integer $index
* @return array
*/
- function parse_SYNTAX_token($tokens, &$index) {
+ public function parse_SYNTAX_token($tokens, &$index) {
$ret = null;
switch($tokens[$index + 1]) {
@@ -316,7 +316,7 @@ class MibParser extends MibCache {
* @param string $end
* @return array
*/
- function parse_bracket_token($tokens, &$index, $start, $end) {
+ public function parse_bracket_token($tokens, &$index, $start, $end) {
$begin = $index + 1;
while ($index + 1 < count($tokens) && $tokens[$index] != $end) {
@@ -338,7 +338,7 @@ class MibParser extends MibCache {
* @param boolean $full
* @param mixed $mib_name
*/
- function parse_mib($mibtext, $mib_name, $full = false): void {
+ public function parse_mib($mibtext, $mib_name, $full = false): void {
$tokens = MibParser::get_tokens($mibtext);
$cnt = count($tokens);
$rec = [];
@@ -424,7 +424,7 @@ class MibParser extends MibCache {
}
}
- function generate(): void {
+ public function generate(): void {
$this->oids['enterprises'] = ['oid' => '.1.3.6.1.4.1'];
foreach ($this->parsed as $object) {
diff --git a/lib/ping.php b/lib/ping.php
index 645f7abe5..b4e4fac7a 100644
--- a/lib/ping.php
+++ b/lib/ping.php
@@ -42,23 +42,23 @@ class Net_Ping {
public int $avail_method;
public int $ping_type;
- function __construct() {
+ public function __construct() {
$this->port = 33439;
}
- function __destruct() {
+ public function __destruct() {
}
- function close_socket() : void {
+ public function close_socket() : void {
@socket_shutdown($this->socket, 2);
socket_close($this->socket);
}
- function start_time() : void {
+ public function start_time() : void {
$this->timer_start_time = microtime(true);
}
- function get_time(int $acc = 2) : mixed {
+ public function get_time(int $acc = 2) : mixed {
// format start time
$start_time = $this->timer_start_time;
// get and format end time
@@ -67,7 +67,7 @@ class Net_Ping {
return number_format($end_time - $start_time, $acc);
}
- function build_udp_packet() : void {
+ public function build_udp_packet() : void {
$data = 'cacti-monitoring-system'; // the actual test data
// now lets build the actual UDP packet
@@ -75,19 +75,19 @@ class Net_Ping {
$this->request_len = strlen($this->request);
}
- function ping_error_handler(int $errno, string $errmsg, string $filename, int $linenum, array $vars = []) : bool {
+ public function ping_error_handler(int $errno, string $errmsg, string $filename, int $linenum, array $vars = []) : bool {
return true;
}
- function set_ping_error_handler() : void {
+ public function set_ping_error_handler() : void {
set_error_handler([$this, 'ping_error_handler']);
}
- function restore_cacti_error_handler() : void {
+ public function restore_cacti_error_handler() : void {
restore_error_handler();
}
- function build_icmp_packet() : void {
+ public function build_icmp_packet() : void {
$seq_low = random_int(0,255);
$seq_high = random_int(0,255);
@@ -107,7 +107,7 @@ class Net_Ping {
$this->request_len = strlen($this->request);
}
- function get_checksum(string $data) : string {
+ public function get_checksum(string $data) : string {
if (strlen($data) % 2) {
$data .= "\x00";
}
@@ -122,7 +122,7 @@ class Net_Ping {
return pack('n*', ~$sum);
}
- function ping_icmp() : bool {
+ public function ping_icmp() : bool {
// ping me
if ($this->host['hostname']) {
// initialize variables
@@ -299,7 +299,7 @@ class Net_Ping {
}
}
- function seteuid() : int {
+ public function seteuid() : int {
$cacti_user = '';
// if we are unix, set the effective userid to root and then create
@@ -312,7 +312,7 @@ class Net_Ping {
return $cacti_user;
}
- function setuid(int $cacti_poller_account) : void {
+ public function setuid(int $cacti_poller_account) : void {
// if we are unix, set the effective userid to root and then create
if ((CACTI_SERVER_OS == 'unix') &&
(function_exists('posix_getuid'))) {
@@ -320,7 +320,7 @@ class Net_Ping {
}
}
- function ping_snmp() : mixed {
+ public function ping_snmp() : mixed {
// initialize variables
$this->snmp_status = 'down';
$this->snmp_response = 'Device did not respond to SNMP';
@@ -352,7 +352,7 @@ class Net_Ping {
return $result;
}
- function get_snmp_result(string $oid) : bool {
+ public function get_snmp_result(string $oid) : bool {
$h = $this->host;
// getnext does not work in php versions less than 5
@@ -389,7 +389,7 @@ class Net_Ping {
}
} // ping_snmp
- function ping_udp() : bool {
+ public function ping_udp() : bool {
$this->set_ping_error_handler();
// hostname must be nonblank
@@ -519,7 +519,7 @@ class Net_Ping {
}
} // end ping_udp
- function ping_tcp() : bool {
+ public function ping_tcp() : bool {
$this->set_ping_error_handler();
// hostname must be nonblank
@@ -651,7 +651,7 @@ class Net_Ping {
}
} // end ping_tcp
- function ping(int $avail_method = AVAIL_SNMP_AND_PING, int $ping_type = PING_ICMP, int $timeout = 500, int $retries = 3) : bool {
+ public function ping(int $avail_method = AVAIL_SNMP_AND_PING, int $ping_type = PING_ICMP, int $timeout = 500, int $retries = 3) : bool {
$this->set_ping_error_handler();
// initialize variables
@@ -761,7 +761,7 @@ class Net_Ping {
};
} // end_ping
- function is_ipaddress(string $ip_address = '') : bool {
+ public function is_ipaddress(string $ip_address = '') : bool {
// check for ipv4/v6
if (function_exists('filter_var')) {
if (filter_var($ip_address, FILTER_VALIDATE_IP) !== false) {
@@ -776,7 +776,7 @@ class Net_Ping {
}
}
- function strip_ip_address(string $ip_address) : string {
+ public function strip_ip_address(string $ip_address) : string {
// clean up hostname if specifying snmp_transport
if (str_contains($ip_address, 'tcp6:')) {
$ip_address = str_replace('tcp6:', '', cacti_strtolower($ip_address));
diff --git a/settings.php b/settings.php
index 3e16aa5e5..b58d68a88 100644
--- a/settings.php
+++ b/settings.php
@@ -262,8 +262,13 @@ function display_settings() : void {
var currentTab = '';
var dataCollectors = '';
var permsTitle = '';
- var permsHeader = '';
- var permsMessage = '';
+ var permsHeader = ;
+ var permsMessage = ;
$(function() {
$('#filter').keyup(function() {
diff --git a/tests/Unit/Core/PublicMethodVisibilityTest.php b/tests/Unit/Core/PublicMethodVisibilityTest.php
new file mode 100644
index 000000000..b9f435718
--- /dev/null
+++ b/tests/Unit/Core/PublicMethodVisibilityTest.php
@@ -0,0 +1,59 @@
+ ['pipe', 'r'],
+ 1 => ['pipe', 'w'],
+ 2 => ['pipe', 'w'],
+ ], $pipes);
+
+ if (!is_resource($process)) {
+ throw new RuntimeException('Unable to start the public API probe.');
+ }
+
+ fclose($pipes[0]);
+ $output = stream_get_contents($pipes[1]);
+ $errors = stream_get_contents($pipes[2]);
+ fclose($pipes[1]);
+ fclose($pipes[2]);
+
+ if (proc_close($process) !== 0) {
+ throw new RuntimeException($errors);
+ }
+
+ $contracts = json_decode($output, true, 512, JSON_THROW_ON_ERROR);
+
+ return $contracts;
+}
+
+$baseline = json_decode(file_get_contents(
+ dirname(__DIR__, 2) . '/fixtures/Core/public-method-signatures.json'
+), true, 512, JSON_THROW_ON_ERROR);
+$cases = [];
+
+foreach ($baseline as $name => $contract) {
+ $cases[$name] = [$name, $contract];
+}
+
+test('the public method retains its complete Cacti develop call contract', function (string $name, array $expected) {
+ $actual = cacti_test_public_method_contracts();
+ expect($actual)->toHaveCount(46);
+ expect($actual[$name])->toBe($expected);
+})->with($cases);
diff --git a/tests/Unit/Security/Auth/LoginProviderSecretFieldsTest.php b/tests/Unit/Security/Auth/LoginProviderSecretFieldsTest.php
index 0ae8d4929..fb01d164f 100644
--- a/tests/Unit/Security/Auth/LoginProviderSecretFieldsTest.php
+++ b/tests/Unit/Security/Auth/LoginProviderSecretFieldsTest.php
@@ -127,7 +127,9 @@ test('form_cert_box() shows the expiration date of a pasted valid certificate',
form_cert_box('idp_x509cert', $pem, '', 6, 60);
$html = ob_get_clean();
- $expected = date('Y-m-d', strtotime('+30 days'));
+ $certificate = openssl_x509_parse($pem);
+ expect($certificate)->not->toBeFalse();
+ $expected = date('Y-m-d', $certificate['validTo_time_t']);
expect($html)->toContain('