Merge branch 'develop' into 'ent-1175-copyright-actualizados'

# Conflicts:
#   pandora_agents/pc/Win32/pandora_agent.conf
#   pandora_agents/win32/bin/pandora_agent.conf
#   pandora_console/extensions/realtime_graphs.php
#   pandora_console/godmode/snmpconsole/snmp_alert.php
#   pandora_console/include/functions_ui.php
#   pandora_console/install.php
#   pandora_console/operation/agentes/realtime_win.php
This commit is contained in:
José González 2020-12-14 11:10:35 +01:00
commit 623b729001
143 changed files with 33136 additions and 1708 deletions

View File

@ -3,309 +3,321 @@ var isFetching = null;
var storedEvents = new Array();
var notVisited = {};
$(window).on('load', function() {
initilise();
// Wait some ms to throw main function
var delay = setTimeout(main, 100);
resetInterval();
$(window).on("load", function() {
initilise();
// Wait some ms to throw main function
var delay = setTimeout(main, 100);
resetInterval();
});
function fetchEvents() {
return storedEvents;
return storedEvents;
}
function fetchNotVisited() {
return notVisited;
return notVisited;
}
function removeNotVisited(eventId) {
if (notVisited[eventId] === true) delete notVisited[eventId];
if (notVisited[eventId] === true) delete notVisited[eventId];
}
function main() {
chrome.runtime.sendMessage({ text: "FETCH_EVENTS" });
// Do not fetch if is fetching now
if (isFetching) return;
isFetching = true;
chrome.runtime.sendMessage({text: "FETCH_EVENTS"});
// Do not fetch if is fetching now
if (isFetching) return;
isFetching = true;
var url =
localStorage["ip_address"] +
"/include/api.php?op=get&op2=events&return_type=json";
var feedUrl = url;
var data = new FormData();
var feedUrl = localStorage["ip_address"]+'/include/api.php?op=get&op2=events&return_type=json&apipass='+localStorage["api_pass"]+'&user='+localStorage["user_name"]+'&pass='+localStorage["pass"];
data.append("apipass", localStorage["api_pass"]);
data.append("user", localStorage["user_name"]);
data.append("pass", localStorage["pass"]);
req = new XMLHttpRequest();
req.onload = handleResponse;
req.onerror = handleError;
req.open("GET", feedUrl, true);
req.withCredentials = true
req.send(null);
req = new XMLHttpRequest();
req.onload = handleResponse;
req.onerror = handleError;
req.open("POST", feedUrl, true);
req.withCredentials = true;
req.send(data);
}
function handleError() {
chrome.runtime.sendMessage({text: "FETCH_EVENTS_URL_ERROR"});
isFetching = false;
chrome.runtime.sendMessage({ text: "FETCH_EVENTS_URL_ERROR" });
isFetching = false;
}
function handleResponse() {
var doc = req.responseText;
if (doc=="auth error") {
chrome.runtime.sendMessage({text: "FETCH_EVENTS_URL_ERROR"});
} else {
var n = doc.search("404 Not Found");
if (n>0) {
chrome.runtime.sendMessage({text: "FETCH_EVENTS_DATA_ERROR"});
} else {
getEvents(doc);
chrome.runtime.sendMessage({text: "FETCH_EVENTS_SUCCESS"});
}
}
isFetching = false;
var doc = req.responseText;
if (doc == "auth error") {
chrome.runtime.sendMessage({ text: "FETCH_EVENTS_URL_ERROR" });
} else {
var n = doc.search("404 Not Found");
if (n > 0) {
chrome.runtime.sendMessage({ text: "FETCH_EVENTS_DATA_ERROR" });
} else {
getEvents(doc);
chrome.runtime.sendMessage({ text: "FETCH_EVENTS_SUCCESS" });
}
}
isFetching = false;
}
function getEvents(reply){
var fetchedEvents = parseReplyEvents(reply);
function getEvents(reply) {
var fetchedEvents = parseReplyEvents(reply);
// If there is no events requested, mark all as visited
if (storedEvents.length == 0) {
notVisited = {};
storedEvents = fetchedEvents;
return;
}
// If there is no events requested, mark all as visited
if (typeof storedEvents != "undefined" && storedEvents.length == 0) {
notVisited = {};
storedEvents = fetchedEvents;
return;
}
// Discriminate the new events
newEvents=fetchNewEvents(fetchedEvents,storedEvents);
var newNotVisited = {};
var notVisitedCount = 0;
// Check if popup is displayed to make some actions
var views = chrome.extension.getViews({ type: "popup" });
for(var k=0;k<newEvents.length;k++){
newNotVisited[newEvents[k]['id']] = true;
if (views.length == 0) {
notVisitedCount++;
displayNotification (newEvents[k])
alertsSound(newEvents[k]);
}
}
// Discriminate the new events
newEvents = fetchNewEvents(fetchedEvents, storedEvents);
var newNotVisited = {};
var notVisitedCount = 0;
// Make that the old events marked as not visited remains with the
// same status
for(var k=0;k<fetchedEvents.length;k++){
if (notVisited[fetchedEvents[k]['id']] === true) {
newNotVisited[fetchedEvents[k]['id']] = true;
notVisitedCount++;
}
}
notVisited = newNotVisited;
// Check if popup is displayed to make some actions
var views = chrome.extension.getViews({ type: "popup" });
for (var k = 0; k < newEvents.length; k++) {
newNotVisited[newEvents[k]["id"]] = true;
if (views.length == 0) {
notVisitedCount++;
displayNotification(newEvents[k]);
alertsSound(newEvents[k]);
}
}
// Update the number
localStorage["new_events"] = (views.length == 0) ? notVisitedCount : 0;
updateBadge();
// Make that the old events marked as not visited remains with the
// same status
for (var k = 0; k < fetchedEvents.length; k++) {
if (notVisited[fetchedEvents[k]["id"]] === true) {
newNotVisited[fetchedEvents[k]["id"]] = true;
notVisitedCount++;
}
}
notVisited = newNotVisited;
// Store the requested events
storedEvents = fetchedEvents;
// Update the number
localStorage["new_events"] = views.length == 0 ? notVisitedCount : 0;
updateBadge();
// Store the requested events
storedEvents = fetchedEvents;
}
function updateBadge() {
if (localStorage["new_events"] != 0) {
chrome.browserAction.setBadgeBackgroundColor({color:[0,200,0,255]});
chrome.browserAction.setBadgeText({ text: localStorage["new_events"] });
} else {
chrome.browserAction.setBadgeText({ text: "" });
}
if (localStorage["new_events"] != 0) {
chrome.browserAction.setBadgeBackgroundColor({ color: [0, 200, 0, 255] });
chrome.browserAction.setBadgeText({ text: localStorage["new_events"] });
} else {
chrome.browserAction.setBadgeText({ text: "" });
}
}
function fetchNewEvents(A,B){
var arrDiff = new Array();
for(var i = 0; i < A.length; i++) {
var id = false;
for(var j = 0; j < B.length; j++) {
if(A[i]['id'] == B[j]['id']) {
id = true;
break;
}
}
if(!id) {
arrDiff.push(A[i]);
}
}
return arrDiff;
function fetchNewEvents(A, B) {
var arrDiff = new Array();
for (var i = 0; i < A.length; i++) {
var id = false;
for (var j = 0; j < B.length; j++) {
if (A[i]["id"] == B[j]["id"]) {
id = true;
break;
}
}
if (!id) {
arrDiff.push(A[i]);
}
}
return arrDiff;
}
function parseReplyEvents(reply) {
// Split the API response
var data;
try {
data = JSON.parse(reply);
} catch (error) {
console.log(error);
return [];
}
var e_array = JSON.parse(reply).data;
function parseReplyEvents (reply) {
// Split the API response
var data = JSON.parse(reply)
var e_array = JSON.parse(reply).data;
// Form a properly object
var fetchedEvents=new Array();
for(var i=0;i<e_array.length;i++){
var event=e_array[i];
fetchedEvents.push({
'id' : event.id_evento,
'agent_name' : event.agent_name,
'agent' : event.id_agente,
'date' : event.timestamp,
'title' : event.evento,
'module' : event.id_agentmodule,
'type' : event.event_type,
'source' : event.source,
'severity' : event.criticity_name,
'visited' : false
});
}
// Return the events
return fetchedEvents;
// Form a properly object
var fetchedEvents = new Array();
for (var i = 0; i < e_array.length; i++) {
var event = e_array[i];
fetchedEvents.push({
id: event.id_evento,
agent_name: event.agent_name,
agent: event.id_agente,
date: event.timestamp,
title: event.evento,
module: event.id_agentmodule,
type: event.event_type,
source: event.source,
severity: event.criticity_name,
visited: false
});
}
// Return the events
return fetchedEvents;
}
function alertsSound(pEvent){
if(localStorage["sound_alert"]!="on"){
return;
}
function alertsSound(pEvent) {
if (localStorage["sound_alert"] != "on") {
return;
}
switch (pEvent['severity']) {
case "Critical":
playSound(localStorage["critical"]);
break;
case "Informational":
playSound(localStorage["informational"]);
break;
case "Maintenance":
playSound(localStorage["maintenance"]);
break;
case "Normal":
playSound(localStorage["normal"]);
break;
case "Warning":
playSound(localStorage["warning"]);
break;
}
switch (pEvent["severity"]) {
case "Critical":
playSound(localStorage["critical"]);
break;
case "Informational":
playSound(localStorage["informational"]);
break;
case "Maintenance":
playSound(localStorage["maintenance"]);
break;
case "Normal":
playSound(localStorage["normal"]);
break;
case "Warning":
playSound(localStorage["warning"]);
break;
}
}
function displayNotification (pEvent) {
function displayNotification(pEvent) {
// Check if the user is okay to get some notification
if (Notification.permission === "granted") {
// If it's okay create a notification
getNotification(pEvent);
}
// Check if the user is okay to get some notification
if (Notification.permission === "granted") {
// If it's okay create a notification
getNotification(pEvent);
}
// Otherwise, we need to ask the user for permission
// Note, Chrome does not implement the permission static property
// So we have to check for NOT 'denied' instead of 'default'
else if (Notification.permission !== 'denied') {
Notification.requestPermission(function (permission) {
// Whatever the user answers, we make sure we store the information
if(!('permission' in Notification)) {
Notification.permission = permission;
}
// If the user is okay, let's create a notification
if (permission === "granted") getNotification(pEvent);
});
}
// Otherwise, we need to ask the user for permission
// Note, Chrome does not implement the permission static property
// So we have to check for NOT 'denied' instead of 'default'
else if (Notification.permission !== "denied") {
Notification.requestPermission(function(permission) {
// Whatever the user answers, we make sure we store the information
if (!("permission" in Notification)) {
Notification.permission = permission;
}
// If the user is okay, let's create a notification
if (permission === "granted") getNotification(pEvent);
});
}
}
function getNotification(pEvent){
// Build the event text
var even = pEvent['type'];
if (pEvent['source'] != '') even += " : " + pEvent['source'];
even += ". Event occured at " + pEvent['date'];
if(pEvent['module'] != 0) even += " in the module with Id "+ pEvent['module'];
even += ".";
function getNotification(pEvent) {
// Build the event text
var even = pEvent["type"];
if (pEvent["source"] != "") even += " : " + pEvent["source"];
even += ". Event occured at " + pEvent["date"];
if (pEvent["module"] != 0)
even += " in the module with Id " + pEvent["module"];
even += ".";
var url = (pEvent['agent'] == 0)
? localStorage["ip_address"]+"/index.php?sec=eventos&sec2=operation/events/events"
: localStorage["ip_address"]+"/index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=" + pEvent['agent'];
var url =
pEvent["agent"] == 0
? localStorage["ip_address"] +
"/index.php?sec=eventos&sec2=operation/events/events"
: localStorage["ip_address"] +
"/index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=" +
pEvent["agent"];
var notification = new Notification(
pEvent['title'],
{
body: even,
icon: "images/icon.png"
}
);
var notification = new Notification(pEvent["title"], {
body: even,
icon: "images/icon.png"
});
// Add the link
notification.onclick = function (event) {
event.preventDefault();
window.open(url, '_blank');
}
// Add the link
notification.onclick = function(event) {
event.preventDefault();
window.open(url, "_blank");
};
// Close notification after 10 secs
setTimeout(function() {notification.close()}, 10000);
// Close notification after 10 secs
setTimeout(function() {
notification.close();
}, 10000);
}
function resetInterval () {
if (refreshTimer) clearInterval(refreshTimer);
refreshTimer = setInterval(main, localStorage["refresh"]*1000);
function resetInterval() {
if (refreshTimer) clearInterval(refreshTimer);
refreshTimer = setInterval(main, localStorage["refresh"] * 1000);
}
function initilise(){
function initilise() {
if (isFetching == null) isFetching = false;
if (localStorage["ip_address"] == undefined) {
localStorage["ip_address"] = "http://firefly.artica.es/pandora_demo";
}
if (isFetching == null) isFetching = false;
if(localStorage["ip_address"]==undefined){
localStorage["ip_address"]="http://firefly.artica.es/pandora_demo";
}
if(localStorage["api_pass"]==undefined){
localStorage["api_pass"]="doreik0";
}
if(localStorage["user_name"]==undefined){
localStorage["user_name"]="demo";
}
if(localStorage["pass"]==undefined){
localStorage["pass"]="demo";
}
if(localStorage["critical"]==null){
localStorage["critical"]="11";
}
if(localStorage["informational"]==null){
localStorage["informational"]="1";
}
if(localStorage["maintenance"]==null){
localStorage["maintenance"]="10";
}
if(localStorage["normal"]==null){
localStorage["normal"]="6";
}
if(localStorage["warning"]==null){
localStorage["warning"]="2";
}
if(localStorage["events"]==null){
localStorage["events"]=20;
}
if(localStorage["refresh"]==null){
localStorage["refresh"]="10";
}
if(localStorage["ip_address"]==null){
localStorage["ip_address"]="http://firefly.artica.es/pandora_demo";
}
if(localStorage["api_pass"]==null){
localStorage["api_pass"]="doreik0";
}
if(localStorage["user_name"]==null){
localStorage["user_name"]="demo";
}
if(localStorage["pass"]==null){
localStorage["pass"]="demo";
}
if(localStorage["sound_alert"]==null){
localStorage["sound_alert"]="on";
}
if(localStorage["changed"]==null){
localStorage["changed"]="false";
}
if(localStorage["new_events"]==null){
localStorage["new_events"]=parseInt(localStorage["events"]);
}
if(localStorage["error"]==null) {
localStorage["error"] = true;
}
if (localStorage["api_pass"] == undefined) {
localStorage["api_pass"] = "doreik0";
}
if (localStorage["user_name"] == undefined) {
localStorage["user_name"] = "demo";
}
if (localStorage["pass"] == undefined) {
localStorage["pass"] = "demo";
}
if (localStorage["critical"] == null) {
localStorage["critical"] = "11";
}
if (localStorage["informational"] == null) {
localStorage["informational"] = "1";
}
if (localStorage["maintenance"] == null) {
localStorage["maintenance"] = "10";
}
if (localStorage["normal"] == null) {
localStorage["normal"] = "6";
}
if (localStorage["warning"] == null) {
localStorage["warning"] = "2";
}
if (localStorage["events"] == null) {
localStorage["events"] = 20;
}
if (localStorage["refresh"] == null) {
localStorage["refresh"] = "10";
}
if (localStorage["ip_address"] == null) {
localStorage["ip_address"] = "http://firefly.artica.es/pandora_demo";
}
if (localStorage["api_pass"] == null) {
localStorage["api_pass"] = "doreik0";
}
if (localStorage["user_name"] == null) {
localStorage["user_name"] = "demo";
}
if (localStorage["pass"] == null) {
localStorage["pass"] = "demo";
}
if (localStorage["sound_alert"] == null) {
localStorage["sound_alert"] = "on";
}
if (localStorage["changed"] == null) {
localStorage["changed"] = "false";
}
if (localStorage["new_events"] == null) {
localStorage["new_events"] = parseInt(localStorage["events"]);
}
if (localStorage["error"] == null) {
localStorage["error"] = true;
}
}

View File

@ -8,7 +8,10 @@ $(document).ready(function() {
bg = chrome.extension.getBackgroundPage();
// Display the information
if (bg.fetchEvents().length == 0) {
var events = bg.fetchEvents();
if (!events) {
showError("Failed to retrieve events, please retry");
} else if (events.length == 0) {
showError("No events");
} else {
showEvents();

View File

@ -1,6 +1,6 @@
{
"name": "__MSG_name__",
"version": "2.2",
"version": "2.3",
"manifest_version": 2,
"description": "Pandora FMS Event viewer Chrome extension",
"homepage_url": "http://pandorafms.com",

View File

@ -1,245 +1,262 @@
if ("undefined" == typeof(PandoraChrome)) {
var PandoraChrome = {};
var prefManager = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch("pandora.");
/* globals Components, req */
if ("undefined" == typeof PandoraChrome) {
var PandoraChrome = {};
var prefManager = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefService)
.getBranch("pandora.");
var timer = null;
var allEvents=new Array();
var newEvents=new Array();
var oldEvents=new Array();
var api_div_numbers=21;
};
PandoraChrome.fn = function(){
return {
displaySideBar: function(){
PandoraChrome.fn.hideNotification();
PandoraChrome.fn.hideBadge();
toggleSidebar('viewPandoraSidebar');
},
displayDialog : function(){
window.openDialog("chrome://pandorasidebar/content/options.xul", "","chrome, centerscreen, dialog, modal, resizable=no", null).focus();
},
handleClick: function(e){
if(e.button == 0){
toggleSidebar('viewPandoraSidebar');
PandoraChrome.fn.setIcon('icon16');
}
},
Onloading: function () {
if(prefManager.getBoolPref("firstLoad")){
prefManager.setIntPref("new_events",prefManager.getIntPref("events"));
prefManager.setBoolPref("firstLoad",false);
}
var timer = null;
var allEvents = new Array();
var newEvents = new Array();
var oldEvents = new Array();
var api_div_numbers = 21;
}
if(timer) {
clearTimeout(timer);
}
timer =setTimeout(PandoraChrome.fn.main , 100 );
},
PandoraChrome.fn = (function() {
return {
displaySideBar: function() {
PandoraChrome.fn.hideNotification();
PandoraChrome.fn.hideBadge();
toggleSidebar("viewPandoraSidebar");
},
displayDialog: function() {
window
.openDialog(
"chrome://pandorasidebar/content/options.xul",
"",
"chrome, centerscreen, dialog, modal, resizable=no",
null
)
.focus();
},
handleClick: function(e) {
if (e.button == 0) {
toggleSidebar("viewPandoraSidebar");
PandoraChrome.fn.setIcon("icon16");
}
},
Onloading: function() {
if (prefManager.getBoolPref("firstLoad")) {
prefManager.setIntPref("new_events", prefManager.getIntPref("events"));
prefManager.setBoolPref("firstLoad", false);
}
main: function() {
// alert('test_main');
var url=prefManager.getCharPref("ip_address")+'/include/api.php?op=get&op2=events&return_type=csv&apipass='+prefManager.getCharPref("api_pass")+'&user='+prefManager.getCharPref("user_name")+'&pass='+prefManager.getCharPref("pass");
var feedUrl = url;
prefManager.setBoolPref("data_check", true);
req = new XMLHttpRequest();
req.onload = PandoraChrome.fn.handleResponse;
req.onerror = PandoraChrome.fn.handleError;
req.open("GET", feedUrl, true);
req.send(null);
},
if (timer) {
clearTimeout(timer);
}
timer = setTimeout(PandoraChrome.fn.main, 100);
},
handleError: function() {
//alert("error");
prefManager.setCharPref("data",null);
prefManager.setBoolPref("data_check", false);
if(timer) {
clearTimeout(timer);
}
timer =setTimeout(PandoraChrome.fn.main , 1000);
},
main: function() {
// alert('test_main');
var url =
prefManager.getCharPref("ip_address") +
"/include/api.php?op=get&op2=events&return_type=json";
var feedUrl = url;
var data = new FormData();
handleResponse: function () {
var doc = req.responseText;
if (doc=="auth error") {
prefManager.setCharPref("data",null);
prefManager.setBoolPref("data_check", false);
if(timer) {
clearTimeout(timer);
}
timer =setTimeout(PandoraChrome.fn.main , 1000);
data.append("apipass", prefManager.getCharPref("api_pass"));
data.append("user", prefManager.getCharPref("user_name"));
data.append("pass", prefManager.getCharPref("pass"));
}
else{
var n=doc.search("404 Not Found");
if(n>0){
prefManager.setBoolPref("data_check", true);
req = new XMLHttpRequest();
req.onload = PandoraChrome.fn.handleResponse;
req.onerror = PandoraChrome.fn.handleError;
req.open("POST", feedUrl, true);
req.send(data);
},
prefManager.setCharPref("data",null);
prefManager.setBoolPref("data_check", false);
if(timer) {
clearTimeout(timer);
}
timer =setTimeout(PandoraChrome.fn.main , 1000);
}
else{
prefManager.setBoolPref("data_check", true);
handleError: function() {
//alert("error");
prefManager.setCharPref("data", null);
prefManager.setBoolPref("data_check", false);
if (timer) {
clearTimeout(timer);
}
timer = setTimeout(PandoraChrome.fn.main, 1000);
},
prefManager.setCharPref("data",doc);
PandoraChrome.fn.getEvents(doc);
}
}
},
handleResponse: function() {
var doc = req.responseText;
if (doc == "auth error") {
prefManager.setCharPref("data", null);
prefManager.setBoolPref("data_check", false);
if (timer) {
clearTimeout(timer);
}
timer = setTimeout(PandoraChrome.fn.main, 1000);
} else {
var n = doc.search("404 Not Found");
if (n > 0) {
prefManager.setCharPref("data", null);
prefManager.setBoolPref("data_check", false);
if (timer) {
clearTimeout(timer);
}
timer = setTimeout(PandoraChrome.fn.main, 1000);
} else {
prefManager.setBoolPref("data_check", true);
getEvents: function (reply){
if(reply.length>100){
all_event_array=reply.split("\n");
allEvents=PandoraChrome.fn.divideArray(all_event_array);
if(oldEvents.length==0){
oldEvents=allEvents;
}
prefManager.setCharPref("data", doc);
PandoraChrome.fn.getEvents(doc);
}
}
},
newEvents=PandoraChrome.fn.fetchNewEvents(allEvents,oldEvents);
if(newEvents.length!=0){
for(var k=0;k<newEvents.length;k++){
var temp=prefManager.getIntPref("new_events")+1;
prefManager.setIntPref("new_events",temp);
PandoraChrome.fn.showNotification(k);
PandoraChrome.fn.showBadge(prefManager.getIntPref("new_events"));
}
}
oldEvents=allEvents;
if(prefManager.getIntPref("new_events")>0){
PandoraChrome.fn.showBadge(prefManager.getIntPref("new_events"));
}
else{
PandoraChrome.fn.hideBadge();
}
if(timer) {
clearTimeout(timer);
}
timer =setTimeout(PandoraChrome.fn.main , prefManager.getIntPref("refresh")*1000 );
}
},
showNotification: function(eventId){
//alert("notify"+eventId);
if(prefManager.getBoolPref("sound_alert")){
if(newEvents[eventId][19]=="Critical"){
Sounds.playSound(prefManager.getIntPref("critical"));
}
if(newEvents[eventId][19]=="Informational"){
Sounds.playSound(prefManager.getIntPref("informational"));
}
if(newEvents[eventId][19]=="Maintenance"){
Sounds.playSound(prefManager.getIntPref("maintenance"));
}
if(newEvents[eventId][19]=="Normal"){
Sounds.playSound(prefManager.getIntPref("normal"));
}
if(newEvents[eventId][19]=="Warning"){
Sounds.playSound(prefManager.getIntPref("warning"));
}
}
var newEve = document.getElementById('newEvent');
newEve.label="Last Event : "+newEvents[eventId][6];
var id;
if(newEvents[eventId][9]==0){
id=".";
}
else {
id= " in the module with Id "+ newEvents[eventId][9] + ".";
}
var event = newEvents[eventId][14]+" : "+newEvents[eventId][17]+". Event occured at "+ newEvents[eventId][5]+id;
newEve.tooltipText=event;
$('#newEvent').show();
return;
},
hideNotification:function(){
//alert("Hide Notif");
$('#newEvent').hide();
},
showBadge: function (txt) {
//alert(txt);
var updateCount = document.getElementById('temp');
updateCount.setAttribute("style","cursor:pointer; font-size:11px; color:#123863; font-weight:bold; display:none;") ;
updateCount.label=txt;
$('#temp').show();
},
hideBadge: function () {
var updateCount = document.getElementById('temp');
//alert("hide B");
$('#temp').hide();
},
divideArray: function (e_array){
var Events=new Array();
for(var i=0;i<e_array.length;i++){
var event=e_array[i].split(";");
Events.push(event);
}
return Events;
},
fetchNewEvents: function (A,B){
var arrDiff = new Array();
// alert(A.length);
//alert(B.length);
for(var i = 0; i < A.length; i++) {
var id = false;
for(var j = 0; j < B.length; j++) {
if(A[i][0] == B[j][0]) {
id = true;
break;
}
}
if(!id) {
arrDiff.push(A[i]);
}
}
return arrDiff;
},
getNotification:function (eventId){
var title=newEvents[eventId][6];
var id;
if(newEvents[eventId][9]==0){
id=".";
}
else {
id= " in the module with Id "+ newEvents[eventId][9] + ".";
}
var event = newEvents[eventId][14]+" : "+newEvents[eventId][17]+". Event occured at "+ newEvents[eventId][5]+id;
//var event=newEvents[eventId][14]+' '+newEvents[eventId][17]+' Event occured at:'+ newEvents[eventId][5] +'in the module with Id '+ newEvents[eventId][9];
return '<a>' + title + '</a> <br/> <span style="font-size:80%">' + event + '</span>';
getEvents: function(reply) {
if (reply.length > 100) {
all_event_array = reply.split("\n");
allEvents = PandoraChrome.fn.divideArray(all_event_array);
if (oldEvents.length == 0) {
oldEvents = allEvents;
}
};
}();
newEvents = PandoraChrome.fn.fetchNewEvents(allEvents, oldEvents);
if (newEvents.length != 0) {
for (var k = 0; k < newEvents.length; k++) {
var temp = prefManager.getIntPref("new_events") + 1;
prefManager.setIntPref("new_events", temp);
PandoraChrome.fn.showNotification(k);
PandoraChrome.fn.showBadge(prefManager.getIntPref("new_events"));
}
}
oldEvents = allEvents;
if (prefManager.getIntPref("new_events") > 0) {
PandoraChrome.fn.showBadge(prefManager.getIntPref("new_events"));
} else {
PandoraChrome.fn.hideBadge();
}
if (timer) {
clearTimeout(timer);
}
timer = setTimeout(
PandoraChrome.fn.main,
prefManager.getIntPref("refresh") * 1000
);
}
},
showNotification: function(eventId) {
//alert("notify"+eventId);
if (prefManager.getBoolPref("sound_alert")) {
if (newEvents[eventId][19] == "Critical") {
Sounds.playSound(prefManager.getIntPref("critical"));
}
if (newEvents[eventId][19] == "Informational") {
Sounds.playSound(prefManager.getIntPref("informational"));
}
if (newEvents[eventId][19] == "Maintenance") {
Sounds.playSound(prefManager.getIntPref("maintenance"));
}
if (newEvents[eventId][19] == "Normal") {
Sounds.playSound(prefManager.getIntPref("normal"));
}
if (newEvents[eventId][19] == "Warning") {
Sounds.playSound(prefManager.getIntPref("warning"));
}
}
var newEve = document.getElementById("newEvent");
newEve.label = "Last Event : " + newEvents[eventId][6];
var id;
if (newEvents[eventId][9] == 0) {
id = ".";
} else {
id = " in the module with Id " + newEvents[eventId][9] + ".";
}
var event =
newEvents[eventId][14] +
" : " +
newEvents[eventId][17] +
". Event occured at " +
newEvents[eventId][5] +
id;
newEve.tooltipText = event;
$("#newEvent").show();
return;
},
hideNotification: function() {
//alert("Hide Notif");
$("#newEvent").hide();
},
showBadge: function(txt) {
//alert(txt);
var updateCount = document.getElementById("temp");
updateCount.setAttribute(
"style",
"cursor:pointer; font-size:11px; color:#123863; font-weight:bold; display:none;"
);
updateCount.label = txt;
$("#temp").show();
},
hideBadge: function() {
var updateCount = document.getElementById("temp");
//alert("hide B");
$("#temp").hide();
},
divideArray: function(e_array) {
var Events = new Array();
for (var i = 0; i < e_array.length; i++) {
var event = e_array[i].split(";");
Events.push(event);
}
return Events;
},
fetchNewEvents: function(A, B) {
var arrDiff = new Array();
// alert(A.length);
//alert(B.length);
for (var i = 0; i < A.length; i++) {
var id = false;
for (var j = 0; j < B.length; j++) {
if (A[i][0] == B[j][0]) {
id = true;
break;
}
}
if (!id) {
arrDiff.push(A[i]);
}
}
return arrDiff;
},
getNotification: function(eventId) {
var title = newEvents[eventId][6];
var id;
if (newEvents[eventId][9] == 0) {
id = ".";
} else {
id = " in the module with Id " + newEvents[eventId][9] + ".";
}
var event =
newEvents[eventId][14] +
" : " +
newEvents[eventId][17] +
". Event occured at " +
newEvents[eventId][5] +
id;
//var event=newEvents[eventId][14]+' '+newEvents[eventId][17]+' Event occured at:'+ newEvents[eventId][5] +'in the module with Id '+ newEvents[eventId][9];
return (
"<a>" +
title +
'</a> <br/> <span style="font-size:80%">' +
event +
"</span>"
);
}
};
})();
/* Add Event Listener */
window.addEventListener("load", PandoraChrome.fn.Onloading(), false);

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.750, AIX version
# Version 7.0NG.751, AIX version
# Licensed under GPL license v2,
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.750, FreeBSD Version
# Version 7.0NG.751, FreeBSD Version
# Licensed under GPL license v2,
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.750, HP-UX Version
# Version 7.0NG.751, HP-UX Version
# Licensed under GPL license v2,
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.750, GNU/Linux
# Version 7.0NG.751, GNU/Linux
# Licensed under GPL license v2,
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.750, GNU/Linux
# Version 7.0NG.751, GNU/Linux
# Licensed under GPL license v2,
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.750, Solaris Version
# Version 7.0NG.751, Solaris Version
# Licensed under GPL license v2,
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

View File

@ -1,7 +1,6 @@
# Base config file for Pandora FMS Windows Agent
# (c) 2006-2021 Artica Soluciones Tecnologicas
# Version 7.0NG.750
# Version 7.0NG.751
# This program is Free Software, you can redistribute it and/or modify it
# under the terms of the GNU General Public Licence as published by the Free Software
# Foundation; either version 2 of the Licence or any later version

View File

@ -1,6 +1,6 @@
# Fichero de configuracion base de agentes de Pandora
# Base config file for Pandora agents
# Version 7.0NG.750, AIX version
# Version 7.0NG.751, AIX version
# General Parameters
# ==================

View File

@ -1,6 +1,6 @@
# Fichero de configuracion base de agentes de Pandora
# Base config file for Pandora agents
# Version 7.0NG.750
# Version 7.0NG.751
# FreeBSD/IPSO version
# Licenced under GPL licence, 2003-2007 Sancho Lerena

View File

@ -1,6 +1,6 @@
# Fichero de configuracion base de agentes de Pandora
# Base config file for Pandora agents
# Version 7.0NG.750, HPUX Version
# Version 7.0NG.751, HPUX Version
# General Parameters
# ==================

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.750
# Version 7.0NG.751
# Licensed under GPL license v2,
# (c) 2003-2021 Artica Soluciones Tecnologicas
# please visit http://pandora.sourceforge.net

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.750
# Version 7.0NG.751
# Licensed under GPL license v2,
# (c) 2003-2021 Artica Soluciones Tecnologicas
# please visit http://pandora.sourceforge.net

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.750
# Version 7.0NG.751
# Licensed under GPL license v2,
# please visit http://pandora.sourceforge.net

View File

@ -1,6 +1,6 @@
# Fichero de configuracion base de agentes de Pandora
# Base config file for Pandora agents
# Version 7.0NG.750, Solaris version
# Version 7.0NG.751, Solaris version
# General Parameters
# ==================

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.750, AIX version
# Version 7.0NG.751, AIX version
# Licensed under GPL license v2,
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix
Version: 7.0NG.750-201127
Version: 7.0NG.751-201214
Architecture: all
Priority: optional
Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
pandora_version="7.0NG.750-201127"
pandora_version="7.0NG.751-201214"
echo "Test if you has the tools for to make the packages."
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null

View File

@ -24,7 +24,7 @@ fi
if [ "$#" -ge 2 ]; then
VERSION="$2"
else
VERSION="7.0NG.750"
VERSION="7.0NG.751"
fi
# Path for the generated DMG file

View File

@ -19,11 +19,11 @@
<choice id="com.pandorafms.pandorafms_src" visible="false">
<pkg-ref id="com.pandorafms.pandorafms_src"/>
</choice>
<pkg-ref id="com.pandorafms.pandorafms_src" version="7.0NG.750" onConclusion="none">pandorafms_src.pdk</pkg-ref>
<pkg-ref id="com.pandorafms.pandorafms_src" version="7.0NG.751" onConclusion="none">pandorafms_src.pdk</pkg-ref>
<choice id="com.pandorafms.pandorafms_uninstall" visible="true" customLocation="/Applications">
<pkg-ref id="com.pandorafms.pandorafms_uninstall"/>
</choice>
<pkg-ref id="com.pandorafms.pandorafms_uninstall" version="7.0NG.750" onConclusion="none">pandorafms_uninstall.pdk</pkg-ref>
<pkg-ref id="com.pandorafms.pandorafms_uninstall" version="7.0NG.751" onConclusion="none">pandorafms_uninstall.pdk</pkg-ref>
<!-- <installation-check script="check()" />
<script>
<![CDATA[

View File

@ -5,9 +5,9 @@
<key>CFBundleIconFile</key> <string>pandorafms.icns</string>
<key>CFBundleIdentifier</key> <string>com.pandorafms.pandorafms_uninstall</string>
<key>CFBundleVersion</key> <string>7.0NG.750</string>
<key>CFBundleGetInfoString</key> <string>7.0NG.750 Pandora FMS Agent uninstaller for MacOS by Artica ST on Aug 2020</string>
<key>CFBundleShortVersionString</key> <string>7.0NG.750</string>
<key>CFBundleVersion</key> <string>7.0NG.751</string>
<key>CFBundleGetInfoString</key> <string>7.0NG.751 Pandora FMS Agent uninstaller for MacOS by Artica ST on Aug 2020</string>
<key>CFBundleShortVersionString</key> <string>7.0NG.751</string>
<key>NSPrincipalClass</key><string>NSApplication</string>
<key>NSMainNibFile</key><string>MainMenu</string>

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.750, GNU/Linux
# Version 7.0NG.751, GNU/Linux
# Licensed under GPL license v2,
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.750, FreeBSD Version
# Version 7.0NG.751, FreeBSD Version
# Licensed under GPL license v2,
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.750, HP-UX Version
# Version 7.0NG.751, HP-UX Version
# Licensed under GPL license v2,
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.750, GNU/Linux
# Version 7.0NG.751, GNU/Linux
# Licensed under GPL license v2,
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.750, GNU/Linux
# Version 7.0NG.751, GNU/Linux
# Licensed under GPL license v2,
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.750, NetBSD Version
# Version 7.0NG.751, NetBSD Version
# Licensed under GPL license v2,
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.750, Solaris Version
# Version 7.0NG.751, Solaris Version
# Licensed under GPL license v2,
# Copyright (c) 2003-2021 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

View File

@ -33,17 +33,8 @@ use IO::Socket;
use Sys::Syslog;
use Time::Local;
my $YAML = 0;
# Dynamic load. Avoid unwanted behaviour.
eval {
eval 'require YAML::Tiny;1' or die('YAML::Tiny lib not found, commands feature won\'t be available');
};
if ($@) {
$YAML = 0;
print STDERR $@;
} else {
$YAML = 1;
}
use lib '/usr/lib/perl5';
use PandoraFMS::Omnishell;
# Agent XML data
my $Xml;
@ -54,8 +45,8 @@ my $Sem = undef;
# Semaphore used to control the number of threads
my $ThreadSem = undef;
use constant AGENT_VERSION => '7.0NG.750';
use constant AGENT_BUILD => '201127';
use constant AGENT_VERSION => '7.0NG.751';
use constant AGENT_BUILD => '201214';
# Agent log default file size maximum and instances
use constant DEFAULT_MAX_LOG_SIZE => 600000;
@ -285,20 +276,6 @@ sub error ($) {
exit 1;
}
################################################################################
# Try to load extra libraries.c
################################################################################
sub load_libraries() {
# Dynamic load. Avoid unwanted behaviour.
eval {eval 'require YAML::Tiny;1' or die('YAML::Tiny lib not found, commands feature won\'t be available');};
if ($@) {
$YAML = 0;
print STDERR $@;
} else {
$YAML = 1;
}
}
################################################################################
# Erase blank spaces before and after the string
################################################################################
@ -1084,8 +1061,6 @@ sub fix_directory ($) {
return $dir . $char;
}
################################################################################
# Sends a file to the server.
################################################################################
@ -1488,336 +1463,6 @@ sub check_collections () {
}
}
################################################################################
# Check for remote commands defined.
################################################################################
sub prepare_commands {
if ($YAML == 0) {
log_message(
'error',
'Cannot use commands without YAML dependency, please install it.'
);
return;
}
# Force configuration file read.
my @commands = read_config('cmd_file');
if (empty(\@commands)) {
$Conf{'commands'} = {};
} else {
foreach my $rcmd (@commands) {
$Conf{'commands'}->{trim($rcmd)} = {};
}
}
# Cleanup old commands. Not registered.
cleanup_old_commands();
foreach my $ref (keys %{$Conf{'commands'}}) {
my $file_content;
my $download = 0;
my $rcmd_file = $ConfDir.'/commands/'.$ref.'.rcmd';
# Check for local .rcmd.done files
if (-e $rcmd_file.'.done') {
# Ignore.
delete $Conf{'commands'}->{$ref};
next;
}
# Search for local .rcmd file
if (-e $rcmd_file) {
my $remote_md5_file = $Conf{'temporal'}.'/'.$ref.'.md5';
$file_content = read_file($rcmd_file);
if (recv_file($ref.'.md5', $remote_md5_file) != 0) {
# Remote file could not be retrieved, skip.
delete $Conf{'commands'}->{$ref};
next;
}
my $local_md5 = md5($file_content);
my $remote_md5 = md5(read_file($remote_md5_file));
if ($local_md5 ne $remote_md5) {
# Must be downloaded again.
$download = 1;
}
} else {
$download = 1;
}
# Search for remote .rcmd file
if ($download == 1) {
# Download .rcmd file
if (recv_file($ref.'.rcmd') != 0) {
# Remote file could not be retrieved, skip.
delete $Conf{'commands'}->{$ref};
next;
} else {
# Success
move($Conf{'temporal'}.'/'.$ref.'.rcmd', $rcmd_file);
}
}
# Parse and prepare in memory skel.
eval {
$Conf{'commands'}->{$ref} = YAML::Tiny->read($rcmd_file);
};
if ($@) {
# Failed.
log_message('error', 'Failed to decode command. ' . "\n".$@);
delete $Conf{'commands'}->{$ref};
next;
}
}
}
################################################################################
# Command report.
################################################################################
sub report_command {
my ($ref, $err_level) = @_;
# Retrieve content from .stdout and .stderr
my $stdout_file = $Conf{'temporal'}.'/'.$ref.'.stdout';
my $stderr_file = $Conf{'temporal'}.'/'.$ref.'.stderr';
my $return;
eval {
$return = {
'error_level' => $err_level,
'stdout' => read_file($stdout_file),
'stderr' => read_file($stderr_file),
};
$return->{'name'} = $Conf{'commands'}->{$ref}->[0]->{'name'};
};
if ($@) {
log_message('error', 'Failed to report command output. ' . $@);
}
# Cleanup
unlink($stdout_file) if (-e $stdout_file);
unlink($stderr_file) if (-e $stderr_file);
# Mark command as done.
open (my $R_FILE, '> '.$ConfDir.'/commands/'.$ref.'.rcmd.done');
print $R_FILE $err_level;
close($R_FILE);
$return->{'stdout'} = '' unless defined ($return->{'stdout'});
$return->{'stderr'} = '' unless defined ($return->{'stderr'});
return $return;
}
################################################################################
# Cleanup unreferenced rcmd and rcmd.done files.
################################################################################
sub cleanup_old_commands {
# Cleanup old .rcmd and .rcmd.done files.
my %registered = map { $_.'.rcmd' => 1 } keys %{$Conf{'commands'}};
if(opendir(my $dir, $ConfDir.'/commands/')) {
while (my $item = readdir($dir)) {
# Skip other files.
next if ($item !~ /\.rcmd$/);
# Clean .rcmd.done file if its command is not referenced in conf.
if (!defined($registered{$item})) {
if (-e $ConfDir.'/commands/'.$item) {
unlink($ConfDir.'/commands/'.$item);
}
if (-e $ConfDir.'/commands/'.$item.'.done') {
unlink($ConfDir.'/commands/'.$item.'.done');
}
}
}
# Close dir.
closedir($dir);
}
}
################################################################################
# Executes a command using defined timeout.
################################################################################
sub execute_command_timeout {
my ($cmd, $timeout) = @_;
if (!defined($timeout)
|| !looks_like_number($timeout)
|| $timeout <= 0
) {
`$cmd`;
return $?>>8;
}
my $remaining_timeout = $timeout;
my $RET;
my $output;
my $pid = open ($RET, "-|");
if (!defined($pid)) {
# Failed to fork.
log_message('error', '[command] Failed to fork.');
return undef;
}
if ($pid == 0) {
# Child.
my $ret;
eval {
local $SIG{ALRM} = sub { die "timeout\n" };
alarm $timeout;
`$cmd`;
alarm 0;
};
my $result = ($?>>8);
return $result;
# Exit child.
# Child finishes.
exit;
} else {
# Parent waiting.
while( --$remaining_timeout > 0 ){
if (wait == -1) {
last;
}
# Wait child up to timeout seconds.
sleep 1;
}
}
if ($remaining_timeout > 0) {
# Retrieve output from child.
$output = do { local $/; <$RET> };
$output = $output>>8;
}
else {
# Timeout expired.
return 124;
}
close($RET);
return $output;
}
################################################################################
# Executes a block of commands, returns error level, leaves output in
# redirection set by $std_files. E.g:
# $std_files = ' >> /tmp/stdout 2>> /tmp/stderr
################################################################################
sub execute_command_block {
my ($commands, $std_files, $timeout, $retry) = @_;
return 0 unless defined($commands);
my $retries = $retry;
$retries = 1 unless looks_like_number($retries) && $retries > 0;
my $err_level = 0;
$std_files = '' unless defined ($std_files);
if (ref($commands) ne "ARRAY") {
return 0 if $commands eq '';
do {
$err_level = execute_command_timeout(
"($commands) $std_files",
$timeout
);
# Do not retry if success.
last if looks_like_number($err_level) && $err_level == 0;
} while ((--$retries) > 0);
} else {
foreach my $comm (@{$commands}) {
next unless defined($comm);
$retries = $retry;
$retries = 1 unless looks_like_number($retries) && $retries > 0;
do {
$err_level = execute_command_timeout(
"($comm) $std_files",
$timeout
);
# Do not retry if success.
$retries = 0 if looks_like_number($err_level) && $err_level == 0;
} while ((--$retries) > 0);
# Do not continue evaluating block if failed.
last unless ($err_level == 0);
}
}
return $err_level;
}
################################################################################
# Evalate given command.
################################################################################
sub evaluate_command {
my ($ref) = @_;
# Not found.
return unless defined $Conf{'commands'}->{$ref};
# Already completed.
return if (-e $ConfDir.'/commands/'.$ref.'.rcmd.done');
# [0] because how library works.
my $cmd = $Conf{'commands'}->{$ref}->[0];
my $std_files = ' >> '.$Conf{'temporal'}.'/'.$ref.'.stdout ';
$std_files .= ' 2>> '.$Conf{'temporal'}.'/'.$ref.'.stderr ';
# Check preconditions
my $err_level;
$err_level = execute_command_block(
$cmd->{'preconditions'},
$std_files,
$cmd->{'timeout'}
);
# Precondition not satisfied.
return report_command($ref, $err_level) unless ($err_level == 0);
# Main run.
$err_level = execute_command_block(
$cmd->{'script'},
$std_files,
$cmd->{'timeout'}
);
# Script not success.
return report_command($ref, $err_level) unless ($err_level == 0);
# Check postconditions
$err_level = execute_command_block(
$cmd->{'postconditions'},
$std_files,
$cmd->{'timeout'}
);
# Return results.
return report_command($ref, $err_level);
}
################################################################################
# Sleep function
################################################################################
@ -3435,9 +3080,10 @@ my $main_agent = -1;
# base time to start eatch iteration with the same interval.
my $iter_base_time = time();
$LogFileIdx = -1;
# Loop
while (1) {
load_libraries();
my $omnishell;
if (-e $Conf{'logfile'} && (stat($Conf{'logfile'}))[7] > $Conf{'logsize'}) {
rotate_log();
@ -3453,8 +3099,18 @@ while (1) {
# Check file collections
check_collections () unless ($Conf{'debug'} eq '1');
# Check scheduled commands
prepare_commands() unless ($Conf{'debug'} eq '1');
eval {
# Omnishell controller.
$omnishell = new PandoraFMS::Omnishell(
{
%Conf,
'ConfDir' => $ConfDir
}
);
};
if ($@) {
log_message('error', "Omnishell process error: ".$@);
}
# Launch broker agents
@BrokerPid = ();
@ -3587,18 +3243,22 @@ while (1) {
if (ref ($Conf{'commands'}) eq "HASH") {
foreach my $command (keys %{$Conf{'commands'}}) {
my $result = evaluate_command($command);
if (ref($result) eq "HASH") {
# Process command result.
$Xml .= "<cmd_report>\n";
$Xml .= " <cmd_response>\n";
$Xml .= " <cmd_name><![CDATA[".$result->{'name'}."]]></cmd_name>\n";
$Xml .= " <cmd_key><![CDATA[".$command."]]></cmd_key>\n";
$Xml .= " <cmd_errorlevel><![CDATA[".$result->{'error_level'}."]]></cmd_errorlevel>\n";
$Xml .= " <cmd_stdout><![CDATA[".$result->{'stdout'}."]]></cmd_stdout>\n";
$Xml .= " <cmd_stderr><![CDATA[".$result->{'stderr'}."]]></cmd_stderr>\n";
$Xml .= " </cmd_response>\n";
$Xml .= "</cmd_report>\n";
eval {
if ($Conf{'debug'} eq '1') {
log_message('debug', 'Running omnishell commmand ['.$command.']');
}
my $output = $omnishell->runCommand($command, 'xml');
if (!empty($output)) {
$Xml .= $output;
} else {
if ($Conf{'debug'} eq '1') {
log_message('error', 'Omnishell result: '.$omnishell->get_last_error());
}
}
};
if ($@) {
log_message('error', 'Omnishell error: '.$@);
}
}
}

View File

@ -2,8 +2,8 @@
#Pandora FMS Linux Agent
#
%define name pandorafms_agent_unix
%define version 7.0NG.750
%define release 201127
%define version 7.0NG.751
%define release 201214
Summary: Pandora FMS Linux agent, PERL version
Name: %{name}

View File

@ -2,8 +2,8 @@
#Pandora FMS Linux Agent
#
%define name pandorafms_agent_unix
%define version 7.0NG.750
%define release 201127
%define version 7.0NG.751
%define release 201214
Summary: Pandora FMS Linux agent, PERL version
Name: %{name}

View File

@ -9,8 +9,8 @@
# Please see http://www.pandorafms.org. This code is licensed under GPL 2.0 license.
# **********************************************************************
PI_VERSION="7.0NG.750"
PI_BUILD="201127"
PI_VERSION="7.0NG.751"
PI_BUILD="201214"
OS_NAME=`uname -s`
FORCE=0

View File

@ -1,7 +1,6 @@
# Base config file for Pandora FMS Windows Agent
# (c) 2006-2021 Artica Soluciones Tecnologicas
# Version 7.0NG.750
# Version 7.0NG.751
# This program is Free Software, you can redistribute it and/or modify it
# under the terms of the GNU General Public Licence as published by the Free Software
# Foundation; either version 2 of the Licence or any later version

Binary file not shown.

View File

@ -3,7 +3,7 @@ AllowLanguageSelection
{Yes}
AppName
{Pandora FMS Windows Agent v7.0NG.750}
{Pandora FMS Windows Agent v7.0NG.751}
ApplicationID
{17E3D2CF-CA02-406B-8A80-9D31C17BD08F}
@ -186,7 +186,7 @@ UpgradeApplicationID
{}
Version
{201127}
{201214}
ViewReadme
{Yes}

View File

@ -0,0 +1,93 @@
#!/usr/bin/perl
################################################################################
# Pandora FMS Omnishell client.
#
# (c) Fco de Borja Sánchez <fborja.sanchez@pandorafms.com>
#
# Usage: omnishell_client "C:\Program Files\pandora_agent\pandora_agent.conf"
#
################################################################################
use strict;
use warnings;
use File::Basename;
use lib '/usr/lib/perl5';
use PandoraFMS::PluginTools;
use PandoraFMS::Omnishell;
################################################################################
# Definitions
################################################################################
my $HELP=<<EO_H;
Pandora FMS Omnishell client.
Usage:
$0 <configuration_file> [-debug 1]
Where <configuration_file> is your Pandora FMS Agent configuration.
*Recommended: use full path.
Use -debug 1 to get information extra in STDERR
EO_H
################################################################################
# Parse commands.
################################################################################
sub read_commands {
my ($config, $exp, $line, $file) = @_;
if (empty($config->{'commands'})) {
$config->{'commands'} = {};
}
my ($ref) = $line =~ /$exp\s+(.*)/;
$config->{'commands'}->{trim($ref)} = {};
return $config;
}
################################################################################
# MAIN
################################################################################
my $ConfFile = $ARGV[0];
my $config = read_configuration({},' ', [
{
'exp' => 'cmd_file',
'target' => \&read_commands
},
]);
if (!defined($ConfFile) || !-e $ConfFile) {
print $HELP;
exit 1;
}
if(!-d dirname($ConfFile).'\commands') {
mkdir(dirname($ConfFile).'\commands');
}
eval {
# Check scheduled commands
my $omnishell = new PandoraFMS::Omnishell(
{
%{$config},
'ConfDir' => dirname($ConfFile)
}
);
if (empty($omnishell->run('xml')) && is_enabled($config->{'debug'}) ) {
print STDERR $omnishell->get_last_error()."\n";
}
};
if ($@) {
if (is_enabled($config->{'debug'})) {
print STDERR $@."\n";
}
exit 1;
}
exit 0;

View File

@ -30,7 +30,7 @@ using namespace Pandora;
using namespace Pandora_Strutils;
#define PATH_SIZE _MAX_PATH+1
#define PANDORA_VERSION ("7.0NG.750(Build 201127)")
#define PANDORA_VERSION ("7.0NG.751(Build 201214)")
string pandora_path;
string pandora_dir;

View File

@ -1704,7 +1704,7 @@ Pandora_Windows_Service::checkConfig (string file) {
}
int
Pandora_Windows_Service::sendXml (Pandora_Module_List *modules) {
Pandora_Windows_Service::sendXml (Pandora_Module_List *modules, string extra /* = ""*/) {
int rc = 0, rc_sec = 0, xml_buffer;
string data_xml;
string xml_filename, random_integer;
@ -1785,10 +1785,13 @@ Pandora_Windows_Service::sendXml (Pandora_Module_List *modules) {
modules->goNext ();
}
}
/* Write extra content (omnishell, for instance) */
data_xml += extra;
/* Close the XML header */
data_xml += "</agent_data>";
/* Generate temporal filename */
random_integer = inttostr (rand());
tmp_filename = conf->getValue ("agent_name");
@ -2018,7 +2021,7 @@ Pandora_Windows_Service::pandora_run () {
void
Pandora_Windows_Service::pandora_run (int forced_run) {
Pandora_Agent_Conf *conf = NULL;
string server_addr, conf_file, *all_conf;
string server_addr, conf_file, *all_conf, omnishell_output, omnishell_path;
int startup_delay = 0;
int i, num;
static bool startup = true;
@ -2055,6 +2058,15 @@ Pandora_Windows_Service::pandora_run (int forced_run) {
this->checkCollections ();
}
/* Execute omnishell commands */
omnishell_path = '"'+Pandora::getPandoraInstallDir ();
omnishell_path += "util\\omnishell_client.exe\" \"" + conf_file+"\"";
if (getPandoraDebug () != false) {
pandoraLog ("Omnishell: Running");
}
omnishell_output = getValueFromCmdExec(omnishell_path.c_str(), 6000000);
server_addr = conf->getValue ("server_ip");
execution_number++;
@ -2126,7 +2138,7 @@ Pandora_Windows_Service::pandora_run (int forced_run) {
// Send the XML
if (!server_addr.empty ()) {
this->sendXml (this->modules);
this->sendXml (this->modules, omnishell_output);
}
}

View File

@ -117,7 +117,7 @@ namespace Pandora {
const char *svc_description);
void start ();
int sendXml (Pandora_Module_List *modules);
int sendXml (Pandora_Module_List *modules, string extra = "");
void sendBufferedXml (string path, copy_func_p copy_func, bool secondary_buffer);
Pandora_Agent_Conf *getConf ();
string getEHKey (string ehorus_conf);

View File

@ -11,7 +11,7 @@ BEGIN
VALUE "LegalCopyright", "Artica ST"
VALUE "OriginalFilename", "PandoraAgent.exe"
VALUE "ProductName", "Pandora FMS Windows Agent"
VALUE "ProductVersion", "(7.0NG.750(Build 201127))"
VALUE "ProductVersion", "(7.0NG.751(Build 201214))"
VALUE "FileVersion", "1.0.0.0"
END
END

View File

@ -1,5 +1,5 @@
package: pandorafms-console
Version: 7.0NG.750-201127
Version: 7.0NG.751-201214
Architecture: all
Priority: optional
Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
pandora_version="7.0NG.750-201127"
pandora_version="7.0NG.751-201214"
package_pear=0
package_pandora=1

View File

@ -1,22 +1,42 @@
<?php
/**
* Funtions real time.
*
* @category Realtime
* @package Pandora FMS
* @subpackage Community
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* 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 for version 2.
* 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.
* ============================================================================
*/
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// 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; version 2
// 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.
global $config;
require_once $config['homedir'].'/include/graphs/fgraph.php';
require_once $config['homedir'].'/include/functions_snmp_browser.php';
/**
* Real time charts.
*
* @return void
*/
function pandora_realtime_graphs()
{
global $config;
@ -28,7 +48,7 @@ function pandora_realtime_graphs()
$onheader = [];
$hide_header = get_parameter('hide_header', 0);
if (!$hide_header) {
if ($hide_header === 0) {
ui_print_page_header(
__('Realtime graphs'),
'images/extensions.png',
@ -96,18 +116,42 @@ function pandora_realtime_graphs()
$table->data = [];
$graph_fields['cpu_load'] = __('%s Server CPU', get_product_name());
$graph_fields['pending_packets'] = __('Pending packages from %s Server', get_product_name());
$graph_fields['disk_io_wait'] = __('%s Server Disk IO Wait', get_product_name());
$graph_fields['apache_load'] = __('%s Server Apache load', get_product_name());
$graph_fields['mysql_load'] = __('%s Server MySQL load', get_product_name());
$graph_fields['server_load'] = __('%s Server load', get_product_name());
$graph_fields['pending_packets'] = __(
'Pending packages from %s Server',
get_product_name()
);
$graph_fields['disk_io_wait'] = __(
'%s Server Disk IO Wait',
get_product_name()
);
$graph_fields['apache_load'] = __(
'%s Server Apache load',
get_product_name()
);
$graph_fields['mysql_load'] = __(
'%s Server MySQL load',
get_product_name()
);
$graph_fields['server_load'] = __(
'%s Server load',
get_product_name()
);
$graph_fields['snmp_interface'] = __('SNMP Interface throughput');
$graph = get_parameter('graph', 'cpu_load');
$refresh = get_parameter('refresh', '1000');
if ($graph != 'snmp_module') {
$data['graph'] = __('Graph').'&nbsp;&nbsp;'.html_print_select($graph_fields, 'graph', $graph, '', '', 0, true);
$data['graph'] = __('Graph').'&nbsp;&nbsp;';
$data['graph'] .= html_print_select(
$graph_fields,
'graph',
$graph,
'',
'',
0,
true
);
}
$refresh_fields[1000] = human_time_description_raw(1, true, 'large');
@ -119,10 +163,14 @@ function pandora_realtime_graphs()
$agent_alias = io_safe_output(get_parameter('agent_alias', ''));
$module_name = io_safe_output(get_parameter('module_name', ''));
$module_incremental = get_parameter('incremental', 0);
$data['module_info'] = "$agent_alias: <b>$module_name</b>";
$data['module_info'] = $agent_alias.': <b>'.$module_name.'</b>';
// Append all the hidden in this cell
$data['module_info'] .= html_print_input_hidden('incremental', $module_incremental, true);
// Append all the hidden in this cell.
$data['module_info'] .= html_print_input_hidden(
'incremental',
$module_incremental,
true
);
$data['module_info'] .= html_print_select(
['snmp_module' => '-'],
'graph',
@ -139,76 +187,72 @@ function pandora_realtime_graphs()
);
}
$data['refresh'] = __('Refresh interval').'&nbsp;&nbsp;'.html_print_select($refresh_fields, 'refresh', $refresh, '', '', 0, true);
$data['refresh'] = __('Refresh interval').'&nbsp;&nbsp;';
$data['refresh'] .= html_print_select(
$refresh_fields,
'refresh',
$refresh,
'',
'',
0,
true
);
if ($graph != 'snmp_module') {
$data['incremental'] = __('Incremental').'&nbsp;&nbsp;'.html_print_checkbox('incremental', 1, 0, true);
$data['incremental'] = __('Incremental').'&nbsp;&nbsp;';
$data['incremental'] .= html_print_checkbox('incremental', 1, 0, true);
}
$data['reset'] = html_print_button(__('Clear graph'), 'reset', false, 'javascript:realtimeGraphs.clearGraph();', 'class="sub delete" style="margin-top:0px;"', true);
$data['reset'] = html_print_button(
__('Clear graph'),
'reset',
false,
'javascript:realtimeGraphs.clearGraph();',
'class="sub delete" style="margin-top:0px;"',
true
);
$table->data[] = $data;
if ($graph == 'snmp_interface' || $graph == 'snmp_module') {
$snmp_address = get_parameter('snmp_address', '');
$snmp_community = get_parameter('snmp_community', '');
$snmp_oid = get_parameter('snmp_oid', '');
$snmp_ver = get_parameter('snmp_ver', '');
$data = [];
$data['snmp_address'] = __('Target IP').'&nbsp;&nbsp;'.html_print_input_text('ip_target', $snmp_address, '', 50, 255, true);
$table->colspan[1]['snmp_address'] = 2;
$data['snmp_community'] = __('Community').'&nbsp;&nbsp;'.html_print_input_text('snmp_community', $snmp_community, '', 50, 255, true);
$table->colspan[1]['snmp_community'] = 2;
$table->data[] = $data;
$snmp_versions = [];
$snmp_versions['1'] = '1';
$snmp_versions['2'] = '2';
$snmp_versions['2c'] = '2c';
$data = [];
$data['snmp_oid'] = __('OID').'&nbsp;&nbsp;'.html_print_input_text('snmp_oid', $snmp_oid, '', 100, 255, true);
$table->colspan[2]['snmp_oid'] = 2;
$data['snmp_ver'] = __('Version').'&nbsp;&nbsp;'.html_print_select($snmp_versions, 'snmp_version', $snmp_ver, '', '', 0, true);
$data['snmp_ver'] .= '&nbsp;&nbsp;'.html_print_button(__('SNMP walk'), 'snmp_walk', false, 'javascript:snmpBrowserWindow();', 'class="sub next"', true);
$table->colspan[2]['snmp_ver'] = 2;
$table->data[] = $data;
// Hide some options in snmp_module graphs
if ($graph == 'snmp_module') {
$table->rowstyle[1] = 'display: none;';
$table->rowstyle[2] = 'display: none;';
}
snmp_browser_print_container(false, '100%', '60%', 'none');
echo snmp_browser_print_container(true, '100%', '60%', 'none');
}
// Print the relative path to AJAX calls:
// Print the relative path to AJAX calls.
html_print_input_hidden('rel_path', get_parameter('rel_path', ''));
// Print the form
// Print the form.
echo '<form id="realgraph" method="post">';
html_print_table($table);
echo '</form>';
// Define a custom action to save the OID selected in the SNMP browser to the form
html_print_input_hidden('custom_action', urlencode(base64_encode('&nbsp;<a href="javascript:realtimeGraphs.setOID();"><img src="'.ui_get_full_url('images').'/input_filter.disabled.png" title="'.__('Use this OID').'" style="vertical-align: middle;"></img></a>')), false);
// Define a custom action to save
// the OID selected in the SNMP browser to the form.
html_print_input_hidden(
'custom_action',
urlencode(
base64_encode(
'&nbsp;<a href="javascript:realtimeGraphs.setOID();"><img src="'.ui_get_full_url('images').'/input_filter.disabled.png" title="'.__('Use this OID').'" style="vertical-align: middle;"></img></a>'
)
),
false
);
html_print_input_hidden('incremental_base', '0');
echo '<script type="text/javascript" src="'.ui_get_full_url('include/javascript/pandora_snmp_browser.js').'"></script>';
echo '<script type="text/javascript" src="'.ui_get_full_url('extensions/realtime_graphs/realtime_graphs.js').'"></script>';
echo '<link rel="stylesheet" type="text/css" href="'.ui_get_full_url('extensions/realtime_graphs/realtime_graphs.css').'"></style>';
// Store servers timezone offset to be retrieved from js
// Store servers timezone offset to be retrieved from js.
set_js_value('timezone_offset', date('Z', time()));
}
extensions_add_operation_menu_option(__('Realtime graphs'), 'estado', null, 'v1r1', 'view');
extensions_add_operation_menu_option(
__('Realtime graphs'),
'estado',
null,
'v1r1',
'view'
);
extensions_add_main_function('pandora_realtime_graphs');
$db = null;

View File

@ -69,15 +69,34 @@ switch ($graph) {
case 'snmp_interface':
case 'snmp_module':
$snmp_address = $_POST['snmp_address'];
$snmp_community = $_POST['snmp_community'];
$snmp_ver = $_POST['snmp_ver'];
$snmp_oid = $_POST['snmp_oid'];
$snmp_address = get_parameter('snmp_address', '');
$snmp_community = get_parameter('snmp_community', '');
$snmp_ver = get_parameter('snmp_ver', '');
$snmp_oid = get_parameter('snmp_oid', '');
$snmp3_auth_user = get_parameter('snmp3_auth_user', '');
$snmp3_security_level = get_parameter('snmp3_security_level', '');
$snmp3_auth_method = get_parameter('snmp3_auth_method', '');
$snmp3_auth_pass = get_parameter('snmp3_auth_pass', '');
$snmp3_privacy_method = get_parameter('snmp3_privacy_method', '');
$snmp3_privacy_pass = get_parameter('snmp3_privacy_pass', '');
if (empty($snmp_address) || empty($snmp_oid)) {
$data = 0;
} else {
$data = get_snmpwalk($snmp_address, $snmp_ver, $snmp_community, '', '', '', '', '', '', 0, $snmp_oid);
$data = get_snmpwalk(
$snmp_address,
$snmp_ver,
$snmp_community,
$snmp3_auth_user,
$snmp3_security_level,
$snmp3_auth_method,
$snmp3_auth_pass,
$snmp3_privacy_method,
$snmp3_privacy_pass,
0,
$snmp_oid,
$snmp_port
);
$data_index = array_keys($data);
$graph_title = $data_index[0];
if (!empty($data)) {

View File

@ -1,3 +1,4 @@
/* global $, get_php_value */
(function() {
var numberOfPoints = 100;
var refresh = parseInt($("#refresh").val());
@ -14,7 +15,7 @@
container: $("#chartLegend")
},
xaxis: {
tickFormatter: function(timestamp, axis) {
tickFormatter: function(timestamp) {
var date = new Date(timestamp * 1000);
var server_timezone_offset = get_php_value("timezone_offset");
@ -39,7 +40,7 @@
}
},
yaxis: {
tickFormatter: function(value, axis) {
tickFormatter: function(value) {
return shortNumber(roundToTwo(value));
}
},
@ -66,10 +67,16 @@
data: {
graph: $("#graph :selected").val(),
graph_title: $("#graph :selected").html(),
snmp_community: $("#text-snmp_community").val(),
snmp_oid: $("#text-snmp_oid").val(),
snmp_ver: $("#snmp_version :selected").val(),
snmp_address: $("#text-ip_target").val(),
snmp_community: $("#text-community").val(),
snmp_oid: $("#text-starting_oid").val(),
snmp_ver: $("#snmp_browser_version").val(),
snmp_address: $("#text-target_ip").val(),
snmp3_auth_user: $("#text-snmp3_browser_auth_user").val(),
snmp3_security_level: $("#snmp3_browser_security_level").val(),
snmp3_auth_method: $("#snmp3_browser_auth_method").val(),
snmp3_auth_pass: $("#password-snmp3_browser_auth_pass").val(),
snmp3_privacy_method: $("#snmp3_browser_privacy_method").val(),
snmp3_privacy_pass: $("#password-snmp3_browser_privacy_pass").val(),
refresh: refresh
},
success: function(serie) {
@ -87,7 +94,7 @@
}
if (data.length === 0) {
for (i = 0; i < numberOfPoints; i++) {
for (var i = 0; i < numberOfPoints; i++) {
var step = i * (refresh / 1000);
serie.data.unshift([timestamp - step, 0]);
}
@ -123,7 +130,7 @@
var data = plot.getData();
if (data.length === 0) return;
for (i = 0; i < data[0].data.length; i++) {
for (var i = 0; i < data[0].data.length; i++) {
data[0].data[i][1] = 0;
}
if (incremental) lastIncVal = null;

View File

@ -0,0 +1,31 @@
START TRANSACTION;
CREATE TABLE `tinventory_alert`(
`id` int UNSIGNED NOT NULL auto_increment,
`id_module_inventory` int(10) NOT NULL,
`actions` text NOT NULL default '',
`id_group` mediumint(8) unsigned NULL default 0,
`condition` enum('WHITE_LIST', 'BLACK_LIST', 'MATCH') NOT NULL default 'WHITE_LIST',
`value` text NOT NULL default '',
`name` tinytext NOT NULL default '',
`description` text NOT NULL default '',
`time_threshold` int(10) NOT NULL default '0',
`last_fired` text NOT NULL default '',
`disable_event` tinyint(1) UNSIGNED default 0,
`enabled` tinyint(1) UNSIGNED default 1,
PRIMARY KEY (`id`),
FOREIGN KEY (`id_module_inventory`) REFERENCES tmodule_inventory(`id_module_inventory`)
ON DELETE CASCADE ON UPDATE CASCADE
) engine=InnoDB DEFAULT CHARSET=utf8;
ALTER TABLE `tagente_modulo` ADD COLUMN `debug_content` varchar(200);
INSERT IGNORE INTO tuser_task VALUES (8, 'cron_task_generate_csv_log', 'a:1:{i:0;a:2:{s:11:"description";s:14:"Send to e-mail";s:4:"type";s:4:"text";}}', 'Send csv log');
ALTER TABLE `talert_snmp` ADD COLUMN `al_field16` TEXT NOT NULL AFTER `al_field15`;
ALTER TABLE `talert_snmp` ADD COLUMN `al_field17` TEXT NOT NULL AFTER `al_field16`;
ALTER TABLE `talert_snmp` ADD COLUMN `al_field18` TEXT NOT NULL AFTER `al_field17`;
ALTER TABLE `talert_snmp` ADD COLUMN `al_field19` TEXT NOT NULL AFTER `al_field18`;
ALTER TABLE `talert_snmp` ADD COLUMN `al_field20` TEXT NOT NULL AFTER `al_field19`;
COMMIT;

View File

@ -347,6 +347,27 @@ CREATE TABLE IF NOT EXISTS `tagente_datos_inventory` (
KEY `idx_utimestamp` USING BTREE (`utimestamp`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- -----------------------------------------------------
-- Table `tinventory_alert`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `tinventory_alert`(
`id` int UNSIGNED NOT NULL auto_increment,
`id_module_inventory` int(10) NOT NULL,
`actions` text NOT NULL default '',
`id_group` mediumint(8) unsigned NULL default 0,
`condition` enum('WHITE_LIST', 'BLACK_LIST', 'MATCH') NOT NULL default 'WHITE_LIST',
`value` text NOT NULL default '',
`name` tinytext NOT NULL default '',
`description` text NOT NULL default '',
`time_threshold` int(10) NOT NULL default '0',
`last_fired` text NOT NULL default '',
`disable_event` tinyint(1) UNSIGNED default 0,
`enabled` tinyint(1) UNSIGNED default 1,
PRIMARY KEY (`id`),
FOREIGN KEY (`id_module_inventory`) REFERENCES tmodule_inventory(`id_module_inventory`)
ON DELETE CASCADE ON UPDATE CASCADE
) engine=InnoDB DEFAULT CHARSET=utf8;
-- -----------------------------------------------------
-- Table `ttrap_custom_values`
-- -----------------------------------------------------
@ -1256,11 +1277,16 @@ ALTER TABLE `talert_templates` ADD COLUMN `disable_event` tinyint(1) DEFAULT 0;
-- ---------------------------------------------------------------------
-- Table `talert_snmp`
-- ---------------------------------------------------------------------
ALTER TABLE talert_snmp ADD COLUMN `al_field11` TEXT NOT NULL DEFAULT "";
ALTER TABLE talert_snmp ADD COLUMN `al_field12` TEXT NOT NULL DEFAULT "";
ALTER TABLE talert_snmp ADD COLUMN `al_field13` TEXT NOT NULL DEFAULT "";
ALTER TABLE talert_snmp ADD COLUMN `al_field14` TEXT NOT NULL DEFAULT "";
ALTER TABLE talert_snmp ADD COLUMN `al_field15` TEXT NOT NULL DEFAULT "";
ALTER TABLE `talert_snmp` ADD COLUMN `al_field11` TEXT NOT NULL DEFAULT "";
ALTER TABLE `talert_snmp` ADD COLUMN `al_field12` TEXT NOT NULL DEFAULT "";
ALTER TABLE `talert_snmp` ADD COLUMN `al_field13` TEXT NOT NULL DEFAULT "";
ALTER TABLE `talert_snmp` ADD COLUMN `al_field14` TEXT NOT NULL DEFAULT "";
ALTER TABLE `talert_snmp` ADD COLUMN `al_field15` TEXT NOT NULL DEFAULT "";
ALTER TABLE `talert_snmp` ADD COLUMN `al_field16` TEXT NOT NULL DEFAULT "";
ALTER TABLE `talert_snmp` ADD COLUMN `al_field17` TEXT NOT NULL DEFAULT "";
ALTER TABLE `talert_snmp` ADD COLUMN `al_field18` TEXT NOT NULL DEFAULT "";
ALTER TABLE `talert_snmp` ADD COLUMN `al_field19` TEXT NOT NULL DEFAULT "";
ALTER TABLE `talert_snmp` ADD COLUMN `al_field20` TEXT NOT NULL DEFAULT "";
ALTER TABLE `talert_snmp` ADD COLUMN `disable_event` tinyint(1) DEFAULT 0;
ALTER TABLE `talert_snmp` MODIFY COLUMN `al_field11` text NOT NULL,
MODIFY COLUMN `al_field12` text NOT NULL,
@ -1268,6 +1294,7 @@ ALTER TABLE `talert_snmp` MODIFY COLUMN `al_field11` text NOT NULL,
MODIFY COLUMN `al_field14` text NOT NULL,
MODIFY COLUMN `al_field15` text NOT NULL;
-- ---------------------------------------------------------------------
-- Table `talert_snmp_action`
-- ---------------------------------------------------------------------
@ -1482,6 +1509,7 @@ ALTER TABLE `tagente_modulo` DROP COLUMN `ff_normal`,
MODIFY COLUMN `dynamic_next` bigint(20) NOT NULL DEFAULT '0',
MODIFY COLUMN `dynamic_two_tailed` tinyint(1) unsigned NULL DEFAULT '0';
ALTER TABLE tagente_modulo MODIFY COLUMN `custom_string_1` MEDIUMTEXT;
ALTER TABLE `tagente_modulo` ADD COLUMN `debug_content` varchar(200);
-- ---------------------------------------------------------------------
-- Table `tagente_datos`
@ -2486,6 +2514,7 @@ ALTER TABLE `tnetflow_filter` MODIFY COLUMN `router_ip` text NOT NULL;
-- Update table `tuser_task`
-- ----------------------------------------------------------------------
UPDATE tuser_task set parameters = 'a:5:{i:0;a:6:{s:11:\"description\";s:28:\"Report pending to be created\";s:5:\"table\";s:7:\"treport\";s:8:\"field_id\";s:9:\"id_report\";s:10:\"field_name\";s:4:\"name\";s:4:\"type\";s:3:\"int\";s:9:\"acl_group\";s:8:\"id_group\";}i:1;a:2:{s:11:\"description\";s:46:\"Send to email addresses (separated by a comma)\";s:4:\"type\";s:4:\"text\";}i:2;a:2:{s:11:\"description\";s:7:\"Subject\";s:8:\"optional\";i:1;}i:3;a:3:{s:11:\"description\";s:7:\"Message\";s:4:\"type\";s:4:\"text\";s:8:\"optional\";i:1;}i:4;a:2:{s:11:\"description\";s:11:\"Report Type\";s:4:\"type\";s:11:\"report_type\";}}' where function_name = "cron_task_generate_report";
INSERT IGNORE INTO tuser_task VALUES (8, 'cron_task_generate_csv_log', 'a:1:{i:0;a:2:{s:11:"description";s:14:"Send to e-mail";s:4:"type";s:4:"text";}}', 'Send csv log');
-- ----------------------------------------------------------------------
-- ADD message in table 'tnews'

View File

@ -114,12 +114,6 @@ foreach ($custom_fields as $field) {
}
}
// Connection lost alert.
ui_require_css_file('register', 'include/styles/', true);
ui_require_javascript_file('connection_check');
$conn_title = __('Connection with server has been lost');
$conn_text = __('Connection to the server has been lost. Please check your internet connection or contact with administrator.');
ui_print_message_dialog($conn_title, $conn_text, 'connection', '/images/error_1.png');
// Get the custom icons.
$docs_logo = ui_get_docs_logo();

View File

@ -186,6 +186,88 @@ try {
$welcome = false;
}
$double_auth_enabled = (bool) db_get_value('id', 'tuser_double_auth', 'id_user', $config['id_user']);
if (!$double_auth_enabled && $config['2FA_all_users'] != ''
&& $config['2Fa_auth'] != '1'
&& $config['double_auth_enabled']
) {
echo '<div id="doble_auth_window" style="display: none"; >';
?>
<script type="text/javascript">
var userID = "<?php echo $config['id_user']; ?>";
var $loadingSpinner = $("<img src=\"<?php echo $config['homeurl']; ?>/images/spinner.gif\" />");
var $dialogContainer = $("div#doble_auth_window");
$dialogContainer.html($loadingSpinner);
// Load the info page
var request = $.ajax({
url: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
type: 'POST',
dataType: 'html',
data: {
page: 'include/ajax/double_auth.ajax',
id_user: userID,
get_double_auth_info_page: 1,
containerID: $dialogContainer.prop('id')
},
complete: function (xhr, textStatus) {
},
success: function (data, textStatus, xhr) {
// isNaN = is not a number
if (isNaN(data)) {
$dialogContainer.html(data);
}
// data is a number, convert it to integer to do the compare
else if (Number(data) === -1) {
$dialogContainer.html("<?php echo '<b><div class=\"red\">'.__('Authentication error').'</div></b>'; ?>");
}
else {
$dialogContainer.html("<?php echo '<b><div class=\"red\">'.__('Error').'</div></b>'; ?>");
}
},
error: function (xhr, textStatus, errorThrown) {
$dialogContainer.html("<?php echo '<b><div class=\"red\">'.__('There was an error loading the data').'</div></b>'; ?>");
}
});
$("div#doble_auth_window").dialog({
<?php config_update_value('2Fa_auth', ''); ?>
resizable: true,
draggable: true,
modal: true,
title: "<?php echo __('Double autentication activation'); ?>",
overlay: {
opacity: 0.5,
background: "black"
},
width: 500,
height: 400,
close: function (event, ui) {
<?php
if (!$double_auth_enabled) {
config_update_value('2Fa_auth', '1');
}
?>
// Abort the ajax request
if (typeof request != 'undefined'){
request.abort();
}
// Remove the contained html
$dialogContainer.empty();
//document.location.reload();
}
})
.show(); </script>
<?php
echo '</div>';
}
$newsletter = null;
?>

View File

@ -464,7 +464,7 @@ $data[1] = html_print_select(
$disabledBecauseInPolicy
);
$data[1] .= '<br> <br><a class="info_cell" href="'.ui_get_full_url('index.php?sec=gagente&sec2=godmode/groups/group_list&tab=credbox').'">'.__('Manage credentials').'</a>';
$data[1] .= '<br> <br><a class="info_cell" href="'.ui_get_full_url('index.php?sec=gmodules&sec2=godmode/groups/group_list&tab=credbox').'">'.__('Manage credentials').'</a>';
$array_os = [
'inherited' => __('Inherited'),

View File

@ -248,17 +248,30 @@ if (is_ajax()) {
return;
}
if (! check_acl($config['id_user'], 0, 'PM')) {
$tab = (string) get_parameter('tab', 'groups');
if ($tab != 'credbox' && ! check_acl($config['id_user'], 0, 'PM')) {
db_pandora_audit(
'ACL Violation',
'Trying to access Group Management'
);
include 'general/noaccess.php';
return;
} else if ($tab == 'credbox'
&& !check_acl($config['id_user'], 0, 'UM')
&& !check_acl($config['id_user'], 0, 'PM')
) {
db_pandora_audit(
'ACL Violation',
'Trying to access Credential Store'
);
include 'general/noaccess.php';
return;
}
$sec = defined('METACONSOLE') ? 'advanced' : 'gagente';
$url_credbox = 'index.php?sec='.$sec.'&sec2=godmode/groups/group_list&tab=credbox';
$url_credbox = 'index.php?sec=gmodules&sec2=godmode/groups/group_list&tab=credbox';
$url_tree = 'index.php?sec='.$sec.'&sec2=godmode/groups/group_list&tab=tree';
$url_groups = 'index.php?sec='.$sec.'&sec2=godmode/groups/group_list&tab=groups';
@ -295,8 +308,6 @@ $buttons['credbox'] = [
).'</a>',
];
$tab = (string) get_parameter('tab', 'groups');
$title = __('Groups defined in %s', get_product_name());
// Marks correct tab.
switch ($tab) {

View File

@ -197,6 +197,11 @@ if (check_acl($config['id_user'], 0, 'AW')) {
$sub['gmassive']['sub2'] = $sub2;
}
if (check_acl($config['id_user'], 0, 'PM') || check_acl($config['id_user'], 0, 'UM')) {
$sub['godmode/groups/group_list&tab=credbox']['text'] = __('Credential store');
$sub['godmode/groups/group_list&tab=credbox']['id'] = 'credential store';
}
if (!empty($sub)) {
$menu_godmode['gmodules']['text'] = __('Configuration');
$menu_godmode['gmodules']['sec2'] = 'godmode/modules/manage_network_templates';
@ -235,6 +240,7 @@ if (check_acl($config['id_user'], 0, 'LW')
enterprise_hook('eventalerts_submenu');
$sub['godmode/snmpconsole/snmp_alert']['text'] = __('SNMP alerts');
$sub['godmode/snmpconsole/snmp_alert']['id'] = 'SNMP alerts';
enterprise_hook('alert_inventory_submenu');
}
$menu_godmode['galertas']['sub'] = $sub;

View File

@ -156,6 +156,14 @@ $agent_max_value = true;
$agent_min_value = true;
$uncompressed_module = true;
// Users.
$id_users = [];
$users_groups = [];
$select_by_group = false;
$nothing = __('Local metaconsole');
$nothing_value = 0;
$graph_render = (empty($config['type_mode_graph']) === true) ? 0 : $config['type_mode_graph'];
switch ($action) {
@ -726,6 +734,8 @@ switch ($action) {
case 'group_configuration':
$group = $item['id_group'];
$recursion = $item['recursion'];
$nothing = '';
$nothing_value = 0;
break;
case 'netflow_area':
@ -747,6 +757,22 @@ switch ($action) {
$top_n_value = $item['top_n_value'];
break;
case 'permissions_report':
$description = $item['description'];
$es = json_decode($item['external_source'], true);
$id_users = array_combine(
array_values($es['id_users']),
array_values($es['id_users'])
);
if (isset($id_users[0]) && $id_users[0] == 0) {
$id_users[0] = __('None');
}
$users_groups = $es['users_groups'];
$select_by_group = $es['select_by_group'];
break;
default:
// It's not possible.
break;
@ -934,8 +960,8 @@ $class = 'databox filters';
'combo_server',
$server_name,
'',
__('Local metaconsole'),
0
$nothing,
$nothing_value
);
?>
</td>
@ -1041,23 +1067,6 @@ $class = 'databox filters';
</td>
</tr>
<tr id="row_resolution" style="" class="datos">
<td style="font-weight:bold;">
<?php
echo __('Resolution');
?>
</td>
<td style="">
<?php
html_print_select(
netflow_resolution_select_params(),
'resolution',
$resolution
);
?>
</td>
</tr>
<tr id="row_period1" style="" class="datos">
<td style="font-weight:bold;">
<?php
@ -1896,7 +1905,14 @@ $class = 'databox filters';
</tr>
<tr id="row_query" style="" class="datos">
<td style="font-weight:bold;"><?php echo __('SQL query'); ?></td>
<td style="font-weight:bold;">
<?php
echo __('SQL query').ui_print_help_tip(
__('The entities of the fields that contain them must be included.'),
true
);
?>
</td>
<td style="" id="sql_entry">
<?php
html_print_textarea('sql', 5, 25, $sql_query_report);
@ -2846,7 +2862,102 @@ $class = 'databox filters';
?>
</td>
</tr>
<tr id="row_profiles_group" style="" class="datos">
<td style="font-weight:bold;">
<?php
echo __('Group');
?>
</td>
<td>
<?php
$user_groups = users_get_groups();
// Add a selector for users without assigned group.
$user_groups[''] = __('Unassigned group');
html_print_select(
$user_groups,
'users_groups[]',
$users_groups,
'',
false,
'',
false,
true,
false,
'',
false,
'min-width: 180px'
);
?>
</td>
</tr>
<tr id="row_users" style="" class="datos">
<td style="font-weight:bold;">
<?php
echo __('User');
?>
</td>
<td style="">
<?php
$tmp_users = db_get_all_rows_filter('tusuario', [], 'id_user');
foreach ($tmp_users as $key => $user) {
$select_users[$user['id_user']] = $user['id_user'];
}
$input_data = [
'type' => 'select_multiple_filtered',
'class' => 'w80p mw600px',
'name' => 'id_users',
'return' => 0,
'available' => array_diff(
$select_users,
$id_users
),
'selected' => $id_users,
'group_filter' => [
'page' => 'godmode/users/user_list',
'method' => 'get_users_by_group',
'nothing' => __('Unnasigned group'),
'nothing_value' => -1,
'id' => $id_users,
],
'texts' => [
'title-left' => 'Available users',
'title-right' => 'Selected users',
'filter-item' => 'Filter user name',
],
'sections' => [
'filters' => 1,
'item-selected-filters' => 0,
],
];
html_print_input($input_data, 'div', true);
?>
</td>
</tr>
<tr id="row_select_by_group" style="" class="datos">
<td style="font-weight:bold;">
<?php
echo __('Select by group');
?>
</td>
<td>
<?php
html_print_checkbox_switch(
'select_by_group',
1,
$select_by_group,
false
);
?>
</td>
</tr>
<tr id="row_landscape" style="" class="datos">
<td style="font-weight:bold;">
<?php
@ -3707,6 +3818,14 @@ echo "<div id='message_no_interval_option' title='".__('Item Editor Information
echo "<p style='text-align: center;font-weight: bold;'>".__('Please checked a custom interval option.').'</p>';
echo '</div>';
echo "<div id='message_no_user' title='".__('Item Editor Information')."' style='display:none;'>";
echo "<p style='text-align: center;font-weight: bold;'>".__('Please select a user.').'</p>';
echo '</div>';
echo "<div id='message_no_group' title='".__('Item Editor Information')."' style='display:none;'>";
echo "<p style='text-align: center;font-weight: bold;'>".__('Please select a group.').'</p>';
echo '</div>';
ui_require_javascript_file(
'pandora_inventory',
ENTERPRISE_DIR.'/include/javascript/'
@ -3931,6 +4050,20 @@ $(document).ready (function () {
});
});
$("#checkbox-select_by_group").change(function () {
var select_by_group = $('#checkbox-select_by_group').prop('checked');
if(select_by_group == true) {
$("#row_users").hide();
$("#row_profiles_group").show();
} else {
$("#row_users").show();
$("#row_profiles_group").hide();
}
});
$("#checkbox-fullscale").change(function(e){
if(e.target.checked === true) {
$("#graph_render").prop('disabled', 'disabled');
@ -3994,6 +4127,16 @@ $(document).ready (function () {
return false;
}
break;
case 'permissions_report':
if ($("#checkbox-select_by_group").prop("checked") && $("select#users_groups>option:selected").val() == undefined) {
dialog_message('#message_no_group');
return false;
}
if ($("#checkbox-select_by_group").prop("checked") == false && $("select#selected-select-id_users>option:selected").val() == 0) {
dialog_message('#message_no_user');
return false;
}
break;
default:
break;
}
@ -4115,6 +4258,18 @@ $(document).ready (function () {
return false;
}
break;
case 'permissions_report':
if ($("#checkbox-select_by_group").prop("checked") && $("select#users_groups>option:selected").val() == undefined) {
dialog_message('#message_no_group');
return false;
}
if ($("#checkbox-select_by_group").prop("checked") == false && $("select#selected-select-id_users>option:selected").val() == 0) {
dialog_message('#message_no_user');
return false;
}
break;
default:
break;
}
@ -5001,6 +5156,10 @@ function chooseType() {
$("#row_select_fields2").hide();
$("#row_select_fields3").hide();
$("#row_uncompressed_module").hide();
$("#row_users").hide();
$("#row_profiles_group").hide();
$("#row_select_by_group").hide();
// SLA list default state.
$("#sla_list").hide();
@ -5647,6 +5806,7 @@ function chooseType() {
$("#row_group").show();
$("#row_servers").show();
$("#row_historical_db_check").hide();
$("#combo_server option[value='0']").remove();
break;
case 'netflow_area':
@ -5684,7 +5844,21 @@ function chooseType() {
$("#row_period").show();
$("#row_quantity").show();
break;
case 'permissions_report':
$("#row_description").show();
$("#row_users").show();
$("#row_profiles_group").show();
$("#row_select_by_group").show();
if($("#checkbox-select_by_group").prop("checked")) {
$("#row_users").hide();
} else {
$("#row_profiles_group").hide();
}
}
switch (type) {
case 'event_report_agent':
case 'simple_graph':
@ -5773,4 +5947,5 @@ function dialog_message(message_id) {
}
});
}
</script>

View File

@ -1432,10 +1432,7 @@ switch ($action) {
'module_description' => $module_description,
];
$values['name'] = reporting_label_macro(
$items_label,
$name_it
);
$values['name'] = $name_it;
$values['landscape'] = get_parameter('landscape');
$values['pagebreak'] = get_parameter('pagebreak');
@ -2054,6 +2051,14 @@ switch ($action) {
}
break;
case 'permissions_report':
$es['id_users'] = get_parameter('selected-select-id_users', 0);
$es['users_groups'] = get_parameter('users_groups', 0);
$es['select_by_group'] = get_parameter('select_by_group', 0);
$description = get_parameter('description');
$values['external_source'] = json_encode($es);
break;
default:
// Default.
break;
@ -2134,10 +2139,7 @@ switch ($action) {
'module_description' => $module_description,
];
$values['name'] = reporting_label_macro(
$items_label,
$name_it
);
$values['name'] = $name_it;
$values['landscape'] = get_parameter('landscape');
$values['pagebreak'] = get_parameter('pagebreak');
@ -2669,6 +2671,14 @@ switch ($action) {
}
break;
case 'permissions_report':
$es['id_users'] = get_parameter('selected-select-id_users');
$es['users_groups'] = get_parameter('users_groups', 0);
$es['select_by_group'] = get_parameter('select_by_group', 0);
$description = get_parameter('description');
$values['external_source'] = json_encode($es);
break;
default:
// Default.
break;

View File

@ -242,6 +242,19 @@ if ($filemanager) {
$chunck_url = '&create=1';
}
$upload_file_or_zip = (bool) get_parameter('upload_file_or_zip');
$create_text_file = (bool) get_parameter('create_text_file');
$default_real_directory = realpath($config['homedir'].'/'.$fallback_directory);
if ($upload_file_or_zip) {
upload_file($upload_file_or_zip, $default_real_directory);
}
if ($create_text_file) {
create_text_file($default_real_directory);
}
filemanager_file_explorer(
$real_directory,
$directory,

View File

@ -66,6 +66,19 @@ $real_directory = realpath($config['homedir'].'/'.$directory);
echo '<h4>'.__('Index of %s', $directory).'</h4>';
$upload_file_or_zip = (bool) get_parameter('upload_file_or_zip');
$create_text_file = (bool) get_parameter('create_text_file');
$default_real_directory = realpath($config['homedir'].'/'.$fallback_directory);
if ($upload_file_or_zip) {
upload_file($upload_file_or_zip, $default_real_directory);
}
if ($create_text_file) {
create_text_file($default_real_directory);
}
filemanager_file_explorer(
$real_directory,
$directory,

View File

@ -642,6 +642,16 @@ $table_other->data[13][1] = html_print_input_text(
true
);
$table_other->data[14][0] = __('Row limit in csv log');
$table_other->data[14][1] = html_print_input_text(
'row_limit_csv',
$config['row_limit_csv'],
'',
5,
10,
true
);
echo '<form id="form_setup" method="post">';
echo '<fieldset>';

View File

@ -221,10 +221,33 @@ if (is_ajax()) {
'double_auth_enabled',
1,
$config['double_auth_enabled'],
true
true,
false,
'showAndHide()'
);
$table->data['double_auth_enabled'] = $row;
// Enable 2FA for all users.
// Set default value.
set_unless_defined($config['2FA_all_users'], false);
$row = [];
$row['name'] = __('Force 2FA for all users is enabled');
$row['control'] .= html_print_checkbox_switch(
'2FA_all_users',
1,
$config['2FA_all_users'],
true
);
if (!$config['double_auth_enabled']) {
$table->rowclass['2FA_all_users'] = 'invisible';
} else {
$table->rowclass['2FA_all_users'] = '';
}
$table->data['2FA_all_users'] = $row;
// Session timeout.
// Default session timeout.
set_when_empty($config['session_timeout'], 90);
@ -317,6 +340,22 @@ echo '</form>';
?>
<script type="text/javascript">
function showAndHide() {
if ($('input[type=checkbox][name=double_auth_enabled]:checked').val() == 1) {
$('#table1-2FA_all_users').removeClass('invisible');
$('#table1-2FA_all_users-name').removeClass('invisible');
$('#table1-2FA_all_users-control').removeClass('invisible');
$('#table1-2FA_all_users').show();
} else {
$('#table1-2FA_all_users').hide();
}
}
$( document ).ready(function() {
});
//For change autocreate remote users
$('#auth').on('change', function(){
type_auth = $('#auth').val();
$.ajax({

View File

@ -1482,7 +1482,7 @@ $row++;
'.' => '.',
',' => ',',
];
$table_other->data[$row][0] = __('CSV decimal separator').ui_print_help_tip(__('Only for csv reports'), true);
$table_other->data[$row][0] = __('CSV decimal separator');
$table_other->data[$row][1] = html_print_select($decimal_separator, 'csv_decimal_separator', $config['csv_decimal_separator'], '', '', '', true, false, false);
$row++;

View File

@ -1,16 +1,18 @@
<?php
/**
* Pandora FMS - http://pandorafms.com
* ==================================================
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* 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 for version 2.
* 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.
*/
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// 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 for version 2.
// 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.
// Load global vars
if (! check_acl($config['id_user'], 0, 'LW')) {
db_pandora_audit(
@ -61,6 +63,11 @@ if ($add_action) {
$values[db_escape_key_identifier('al_field13')] = get_parameter('field13_value');
$values[db_escape_key_identifier('al_field14')] = get_parameter('field14_value');
$values[db_escape_key_identifier('al_field15')] = get_parameter('field15_value');
$values[db_escape_key_identifier('al_field16')] = get_parameter('field16_value');
$values[db_escape_key_identifier('al_field17')] = get_parameter('field17_value');
$values[db_escape_key_identifier('al_field18')] = get_parameter('field18_value');
$values[db_escape_key_identifier('al_field19')] = get_parameter('field19_value');
$values[db_escape_key_identifier('al_field20')] = get_parameter('field20_value');
$result = db_process_sql_insert('talert_snmp_action', $values);
}
@ -123,6 +130,11 @@ if ($save_alert || $modify_alert) {
$al_field13 = (string) get_parameter_post('field13_value');
$al_field14 = (string) get_parameter_post('field14_value');
$al_field15 = (string) get_parameter_post('field15_value');
$al_field16 = (string) get_parameter_post('field16_value');
$al_field17 = (string) get_parameter_post('field17_value');
$al_field18 = (string) get_parameter_post('field18_value');
$al_field19 = (string) get_parameter_post('field19_value');
$al_field20 = (string) get_parameter_post('field20_value');
$max_alerts = (int) get_parameter_post('max_alerts', 1);
$min_alerts = (int) get_parameter_post('min_alerts', 0);
$priority = (int) get_parameter_post('priority', 0);
@ -195,6 +207,11 @@ if ($save_alert || $modify_alert) {
'al_field13' => $al_field13,
'al_field14' => $al_field14,
'al_field15' => $al_field15,
'al_field16' => $al_field16,
'al_field17' => $al_field17,
'al_field18' => $al_field18,
'al_field19' => $al_field19,
'al_field20' => $al_field20,
'description' => $description,
'agent' => $source_ip,
'custom_oid' => $custom_value,
@ -267,7 +284,9 @@ if ($save_alert || $modify_alert) {
al_field5 = '%s', al_field6 = '%s',al_field7 = '%s',
al_field8 = '%s', al_field9 = '%s',al_field10 = '%s',
al_field11 = '%s', al_field12 = '%s', al_field13 = '%s',
al_field14 = '%s', al_field15 = '%s',
al_field14 = '%s', al_field15 = '%s', al_field16 = '%s',
al_field17 = '%s', al_field18 = '%s', al_field19 = '%s',
al_field20 = '%s',
description = '%s',
agent = '%s', custom_oid = '%s', oid = '%s',
time_threshold = %d, max_alerts = %d, min_alerts = %d,
@ -318,6 +337,11 @@ if ($save_alert || $modify_alert) {
$al_field13,
$al_field14,
$al_field15,
$al_field16,
$al_field17,
$al_field18,
$al_field19,
$al_field20,
$description,
$source_ip,
$custom_value,
@ -417,6 +441,11 @@ if ($update_alert || $duplicate_alert) {
$al_field13 = $alert['al_field13'];
$al_field14 = $alert['al_field14'];
$al_field15 = $alert['al_field15'];
$al_field16 = $alert['al_field16'];
$al_field17 = $alert['al_field17'];
$al_field18 = $alert['al_field18'];
$al_field19 = $alert['al_field19'];
$al_field20 = $alert['al_field20'];
$max_alerts = $alert['max_alerts'];
$min_alerts = $alert['min_alerts'];
$priority = $alert['priority'];
@ -490,6 +519,11 @@ if ($update_alert || $duplicate_alert) {
$al_field13 = '';
$al_field14 = '';
$al_field15 = '';
$al_field16 = '';
$al_field17 = '';
$al_field18 = '';
$al_field19 = '';
$al_field20 = '';
$max_alerts = 1;
$min_alerts = 0;
$priority = 0;
@ -547,10 +581,11 @@ if ($duplicate_alert) {
id_alert, al_field1, al_field2, al_field3,
al_field4, al_field5, al_field6, al_field7,
al_field8, al_field9, al_field10, al_field11,
al_field12, al_field13, al_field14, al_field15,
description, alert_type, agent, custom_oid, oid, time_threshold,
times_fired, last_fired, max_alerts, min_alerts,
internal_counter, priority,
al_field12, al_field13, al_field14, al_field15,
al_field16, al_field17, al_field18, al_field19,
al_field20, description, alert_type, agent, custom_oid,
oid, time_threshold, times_fired, last_fired,
max_alerts, min_alerts, internal_counter, priority,
'.db_escape_key_identifier('_snmp_f1_').',
'.db_escape_key_identifier('_snmp_f2_').',
'.db_escape_key_identifier('_snmp_f3_').',
@ -597,6 +632,11 @@ if ($duplicate_alert) {
$al_field13,
$al_field14,
$al_field15,
$al_field16,
$al_field17,
$al_field18,
$al_field19,
$al_field20,
$description,
$alert_type,
$source_ip,
@ -998,6 +1038,11 @@ if ($create_alert || $update_alert) {
'al_field13' => $al_field13,
'al_field14' => $al_field14,
'al_field15' => $al_field15,
'al_field16' => $al_field16,
'al_field17' => $al_field17,
'al_field18' => $al_field18,
'al_field19' => $al_field19,
'al_field20' => $al_field20,
];
// Hidden div with help hint to fill with javascript
@ -1421,6 +1466,11 @@ if ($create_alert || $update_alert) {
'al_field13' => $al_field13,
'al_field14' => $al_field14,
'al_field15' => $al_field15,
'al_field16' => $al_field16,
'al_field17' => $al_field17,
'al_field18' => $al_field18,
'al_field19' => $al_field19,
'al_field20' => $al_field20,
];
for ($i = 1; $i <= $config['max_macro_fields']; $i++) {

View File

@ -196,6 +196,8 @@ if (is_ajax()) {
}
}
$tab = get_parameter('tab', 'user');
if ($id) {
@ -757,13 +759,13 @@ if (!users_is_admin() && $config['id_user'] != $id && !$new_user) {
$sql = sprintf(
"SELECT tusuario_perfil.* FROM tusuario_perfil
INNER JOIN tperfil ON tperfil.id_perfil = tusuario_perfil.id_perfil
WHERE id_usuario like '%s' AND id_grupo IN (%s) AND user_management = 0",
$id,
WHERE id_usuario like '%s' AND id_grupo IN (%s) AND user_management = 1",
$config['id_user'],
$group_um_string
);
$result = db_get_all_rows_sql($sql);
if ($result == false || $user_info['is_admin']) {
if ($result == false && $user_info['is_admin'] == false) {
db_pandora_audit(
'ACL Violation',
'Trying to access User Management'
@ -1128,6 +1130,28 @@ if ($config['ehorus_user_level_conf']) {
$ehorus .= '</div>';
}
$double_auth_enabled = (bool) db_get_value('id', 'tuser_double_auth', 'id_user', $id);
if ($config['double_auth_enabled'] && check_acl($config['id_user'], 0, 'PM')) {
$double_authentication = '<div class="label_select_simple"><p class="edit_user_labels">'.__('Double authentication').'</p>';
if (($config['2FA_all_users'] == '' && !$double_auth_enabled)
|| ($config['double_auth_enabled'] == '' && $double_auth_enabled)
|| check_acl($config['id_user'], 0, 'PM')
) {
$double_authentication .= html_print_checkbox_switch('double_auth', 1, $double_auth_enabled, true);
}
// Dialog.
$double_authentication .= '<div id="dialog-double_auth" style="display:none"><div id="dialog-double_auth-container"></div></div>';
}
if ($double_auth_enabled && $config['double_auth_enabled'] && $config['2FA_all_users'] != '') {
$double_authentication .= html_print_button(__('Show information'), 'show_info', false, 'javascript:show_double_auth_info();', '', true);
}
if (isset($double_authentication)) {
$double_authentication .= '</div>';
}
if ($meta) {
enterprise_include_once('include/functions_metaconsole.php');
@ -1179,7 +1203,7 @@ echo '<div id="user_form">
<div class="edit_user_autorefresh white_box"><p style="font-weight:bold;">Extra info</p>'.$email.$phone.$not_login.$session_time.'</div>
</div>
<div class="user_edit_second_row white_box">
<div class="edit_user_options">'.$language.$access_or_pagination.$skin.$home_screen.$default_event_filter.$newsletter.'</div>
<div class="edit_user_options">'.$language.$access_or_pagination.$skin.$home_screen.$default_event_filter.$newsletter.$double_authentication.'</div>
<div class="edit_user_timezone">'.$timezone;
if (!is_metaconsole()) {
@ -1278,6 +1302,15 @@ if (!is_metaconsole()) {
var json_profile = $('#hidden-json_profile');
/* <![CDATA[ */
$(document).ready (function () {
$("input#checkbox-double_auth").change(function (e) {
e.preventDefault();
if (this.checked) {
show_double_auth_activation();
} else {
show_double_auth_deactivation();
}
});
$('input:radio[name="is_admin"]').change(function() {
if($('#radiobtn0002').prop('checked')) {
$('#metaconsole_agents_manager_div').show();
@ -1495,5 +1528,216 @@ function switch_ehorus_conf()
}
function show_double_auth_info () {
var userID = '<?php echo io_safe_output($id); ?>';
var $loadingSpinner = $("<img src=\"<?php echo $config['homeurl']; ?>/images/spinner.gif\" />");
var $dialogContainer = $("div#dialog-double_auth-container");
$dialogContainer.html($loadingSpinner);
console.log(userID);
// Load the info page
var request = $.ajax({
url: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
type: 'POST',
dataType: 'html',
data: {
page: 'include/ajax/double_auth.ajax',
id_user: userID,
get_double_auth_data_page: 1,
FA_forced: 1,
containerID: $dialogContainer.prop('id')
},
complete: function(xhr, textStatus) {
},
success: function(data, textStatus, xhr) {
// isNaN = is not a number
if (isNaN(data)) {
$dialogContainer.html(data);
}
// data is a number, convert it to integer to do the compare
else if (Number(data) === -1) {
$dialogContainer.html("<?php echo '<b><div class=\"red\">'.__('Authentication error').'</div></b>'; ?>");
}
else {
$dialogContainer.html("<?php echo '<b><div class=\"red\">'.__('Error').'</div></b>'; ?>");
}
},
error: function(xhr, textStatus, errorThrown) {
$dialogContainer.html("<?php echo '<b><div class=\"red\">'.__('There was an error loading the data').'</div></b>'; ?>");
}
});
$("div#dialog-double_auth")
.css('display','block')
.append($dialogContainer)
.dialog({
resizable: true,
draggable: true,
modal: true,
title: "<?php echo __('Double autentication information'); ?>",
overlay: {
opacity: 0.5,
background: "black"
},
width: 400,
height: 375,
close: function(event, ui) {
// Abort the ajax request
if (typeof request != 'undefined')
request.abort();
// Remove the contained html
$dialogContainer.empty();
}
})
.show();
}
function show_double_auth_activation () {
var userID = '<?php echo io_safe_output($id); ?>';
var $loadingSpinner = $("<img src=\"<?php echo $config['homeurl']; ?>/images/spinner.gif\" />");
var $dialogContainer = $("div#dialog-double_auth-container");
$dialogContainer.html($loadingSpinner);
// Load the info page
var request = $.ajax({
url: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
type: 'POST',
dataType: 'html',
data: {
page: 'include/ajax/double_auth.ajax',
id_user: userID,
FA_forced: 1,
get_double_auth_info_page: 1,
containerID: $dialogContainer.prop('id')
},
complete: function(xhr, textStatus) {
},
success: function(data, textStatus, xhr) {
// isNaN = is not a number
if (isNaN(data)) {
$dialogContainer.html(data);
}
// data is a number, convert it to integer to do the compare
else if (Number(data) === -1) {
$dialogContainer.html("<?php echo '<b><div class=\"red\">'.__('Authentication error').'</div></b>'; ?>");
}
else {
$dialogContainer.html("<?php echo '<b><div class=\"red\">'.__('Error').'</div></b>'; ?>");
}
},
error: function(xhr, textStatus, errorThrown) {
$dialogContainer.html("<?php echo '<b><div class=\"red\">'.__('There was an error loading the data').'</div></b>'; ?>");
}
});
$("div#dialog-double_auth").dialog({
resizable: true,
draggable: true,
modal: true,
title: "<?php echo __('Double autentication activation'); ?>",
overlay: {
opacity: 0.5,
background: "black"
},
width: 500,
height: 400,
close: function(event, ui) {
// Abort the ajax request
if (typeof request != 'undefined')
request.abort();
// Remove the contained html
$dialogContainer.empty();
document.location.reload();
}
})
.show();
}
function show_double_auth_deactivation () {
var userID = '<?php echo io_safe_output($id); ?>';
console.log(userID);
var $loadingSpinner = $("<img src=\"<?php echo $config['homeurl']; ?>/images/spinner.gif\" />");
var $dialogContainer = $("div#dialog-double_auth-container");
var message = "<p><?php echo __('Are you sure?').'<br>'.__('The double authentication will be deactivated'); ?></p>";
var $button = $("<input type=\"button\" value=\"<?php echo __('Deactivate'); ?>\" />");
$dialogContainer
.empty()
.append(message)
.append($button);
var request;
$button.click(function(e) {
e.preventDefault();
$dialogContainer.html($loadingSpinner);
// Deactivate the double auth
request = $.ajax({
url: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
type: 'POST',
dataType: 'json',
data: {
page: 'include/ajax/double_auth.ajax',
id_user: userID,
FA_forced: 1,
deactivate_double_auth: 1
},
complete: function(xhr, textStatus) {
},
success: function(data, textStatus, xhr) {
console.log(data);
if (data === -1) {
$dialogContainer.html("<?php echo '<b><div class=\"red\">'.__('Authentication error').'</div></b>'; ?>");
}
else if (data) {
$dialogContainer.html("<?php echo '<b><div class=\"green\">'.__('The double autentication was deactivated successfully').'</div></b>'; ?>");
}
else {
$dialogContainer.html("<?php echo '<b><div class=\"red\">'.__('There was an error deactivating the double autentication').'</div></b>'; ?>");
}
},
error: function(xhr, textStatus, errorThrown) {
$dialogContainer.html("<?php echo '<b><div class=\"red\">'.__('There was an error deactivating the double autentication').'</div></b>'; ?>");
}
});
});
$("div#dialog-double_auth").dialog({
resizable: true,
draggable: true,
modal: true,
title: "<?php echo __('Double autentication activation'); ?>",
overlay: {
opacity: 0.5,
background: "black"
},
width: 300,
height: 150,
close: function(event, ui) {
// Abort the ajax request
if (typeof request != 'undefined')
request.abort();
// Remove the contained html
$dialogContainer.empty();
document.location.reload();
}
})
.show();
}
/* ]]> */
</script>

View File

@ -33,6 +33,53 @@ if (! check_acl($config['id_user'], 0, 'UM')) {
exit;
}
if (is_ajax()) {
$method = get_parameter('method');
$group_id = get_parameter('group_id');
$group_recursion = (bool) get_parameter('group_recursion', 0);
$return_all = false;
if ($group_id == -1) {
$sql = 'SELECT tusuario.id_user FROM tusuario
LEFT OUTER JOIN tusuario_perfil
ON tusuario.id_user = tusuario_perfil.id_usuario
WHERE tusuario_perfil.id_usuario IS NULL';
$users = io_safe_output(db_get_all_rows_sql($sql));
foreach ($users as $key => $user) {
$ret_user[$user['id_user']] = $user['id_user'];
}
echo json_encode($ret_user);
return;
}
if ($group_id == 0) {
$users = io_safe_output(db_get_all_rows_filter('tusuario', [], 'id_user'));
foreach ($users as $key => $user) {
$ret_user[$user['id_user']] = $user['id_user'];
}
echo json_encode($ret_user);
return;
}
if ($method === 'get_users_by_group') {
if ($group_recursion === true) {
$group_id = groups_get_children_ids($group_id);
}
$users_id = io_safe_output(users_get_user_users(false, 'AR', false, null, $group_id));
foreach ($users_id as $key => $user_id) {
$ret_id[$user_id] = $user_id;
}
echo json_encode($ret_id);
return;
}
}
$sortField = get_parameter('sort_field');
$sort = get_parameter('sort', 'none');
$tab = get_parameter('tab', 'user');
@ -444,12 +491,6 @@ foreach ($info as $user_id => $user_info) {
foreach ($group_um as $key => $value) {
if (isset($user_profiles_aux[$key])) {
$user_profiles[$key] = $user_profiles_aux[$key];
if ($user_profiles_aux[$key]['user_management'] == 1) {
$user_info['edit'] = 0;
} else {
$user_info['edit'] = 1;
}
unset($user_profiles_aux[$key]);
}
}
@ -547,7 +588,11 @@ foreach ($info as $user_id => $user_info) {
$total_profile++;
}
$data[4] .= '</div>';
if (isset($user_info['not_delete'])) {
$data[4] .= __('Other profiles are also assigned.').ui_print_help_tip(__('Other profiles you cannot manage are also assigned. These profiles are not shown. You cannot enable/disable or delete this user.'), true);
}
$data[4] .= '</div>';
} else {
$data[4] .= __('The user doesn\'t have any assigned profile/group');
}

View File

@ -1202,7 +1202,10 @@ class DiscoveryTaskList extends HTML
$output = '';
// Header information.
if ((int) $task['status'] <= 0 && empty($summary)) {
if ((int) $task['status'] <= 0
&& empty($summary)
&& $task['id_recon_script'] == 0
) {
$output .= ui_print_info_message(
__('This task has never executed'),
'',
@ -1250,6 +1253,17 @@ class DiscoveryTaskList extends HTML
],
]
);
if (count($map->nodes) <= 1) {
// No nodes detected in current task definition.
$task = db_get_row('trecon_task', 'id_rt', $id_task);
if ((int) $task['type'] === DISCOVERY_CLOUD_GCP_COMPUTE_ENGINE) {
ui_print_info_message(
__('Please ensure instances or regions are being monitorized and \'scan and general monitoring\' is enabled.')
);
}
}
$map->printMap();
}

View File

@ -1427,9 +1427,9 @@ class HostDevices extends Wizard
include_once $config['homedir'].'/include/class/CredentialStore.class.php';
$available_keys = CredentialStore::getKeys('CUSTOM');
if (check_acl($config['id_user'], 0, 'PM')) {
if (check_acl($config['id_user'], 0, 'UM')) {
$link_to_cs = '<a class="ext_link" href="'.ui_get_full_url(
'index.php?sec=gagente&sec2=godmode/groups/group_list&tab=credbox'
'index.php?sec=gmodules&sec2=godmode/groups/group_list&tab=credbox'
).'" >';
$link_to_cs .= __('No credentials available').', ';
$link_to_cs .= strtolower(__('Manage credentials')).'</a>';

View File

@ -17,7 +17,9 @@ check_login();
// Security check
$id_user = (string) get_parameter('id_user');
if ($id_user !== $config['id_user']) {
$FA_forced = (int) get_parameter('FA_forced');
if ($id_user !== $config['id_user'] && $FA_forced != 1) {
db_pandora_audit(
'ACL Violation',
'Trying to access Double Authentication'

View File

@ -55,8 +55,6 @@ $password = get_parameter('pass', '');
$user = get_parameter('user', '');
$info = get_parameter('info', '');
$other = parseOtherParameter($otherSerialize, $otherMode);
$other = parseOtherParameter($otherSerialize, $otherMode);
$apiPassword = io_output_password(
db_get_value_filter(

View File

@ -385,6 +385,8 @@ class CredentialStore extends Wizard
// Decrypt content.
$key['username'] = io_output_password($key['username']);
$key['password'] = io_output_password($key['password']);
$key['extra_1'] = io_output_password($key['extra_1']);
$key['extra_2'] = io_output_password($key['extra_2']);
return $key;
}
@ -425,6 +427,8 @@ class CredentialStore extends Wizard
function ($carry, $item) {
$item['username'] = io_output_password($item['username']);
$item['password'] = io_output_password($item['password']);
$item['extra_1'] = io_output_password($item['extra_1']);
$item['extra_2'] = io_output_password($item['extra_2']);
$carry[$item['identifier']] = $item['identifier'];
return $carry;
}
@ -451,6 +455,18 @@ class CredentialStore extends Wizard
$start = get_parameter('start', 0);
$length = get_parameter('length', $config['block_size']);
$order = get_datatable_order(true);
if ((bool) users_is_admin() === false) {
$all = users_can_manage_group_all('UM');
$filter['group_list'] = array_keys(
users_get_groups(
$config['id_user'],
'UM',
(bool) $all
)
);
}
try {
ob_start();
@ -561,13 +577,28 @@ class CredentialStore extends Wizard
$extra_1 = get_parameter('extra_1', null);
$extra_2 = get_parameter('extra_2', null);
if (empty($identifier)) {
if ($product === 'GOOGLE') {
$google_creds = json_decode(io_safe_output($extra_1));
if (json_last_error() !== JSON_ERROR_NONE) {
$this->ajaxMsg(
'error',
__('Not a valid JSON: %s', json_last_error_msg())
);
exit;
}
$username = $google_creds->client_email;
$password = $google_creds->private_key_id;
}
if (empty($identifier) === true) {
$error = __('Key identifier is required');
} else if ($id_group === null) {
$error = __('You must select a group where store this key!');
} else if (empty($product)) {
} else if (empty($product) === true) {
$error = __('You must specify a product type');
} else if (empty($username) && (empty($password))) {
} else if (empty($username) === true && (empty($password) === true)) {
$error = __('You must specify a username and/or password');
}
@ -581,10 +612,10 @@ class CredentialStore extends Wizard
'identifier' => $identifier,
'id_group' => $id_group,
'product' => $product,
'username' => io_input_password($username),
'password' => io_input_password($password),
'extra_1' => $extra_1,
'extra_2' => $extra_2,
'username' => io_input_password(io_safe_output($username)),
'password' => io_input_password(io_safe_output($password)),
'extra_1' => io_input_password(io_safe_output($extra_1)),
'extra_2' => io_input_password(io_safe_output($extra_2)),
];
// Spaces are not allowed.
@ -875,7 +906,7 @@ class CredentialStore extends Wizard
'AWS' => __('Aws'),
'AZURE' => __('Azure'),
'SAP' => __('SAP'),
// 'GOOGLE' => __('Google'),
'GOOGLE' => __('Google'),
],
'selected' => (isset($values['product']) ? $values['product'] : 'CUSTOM'),
'disabled' => (bool) $values['product'],
@ -887,6 +918,9 @@ class CredentialStore extends Wizard
$pass_label = __('Password');
$extra_1_label = __('Extra');
$extra_2_label = __('Extra (2)');
$extra1_type = 'text';
$user = true;
$pass = true;
$extra1 = true;
$extra2 = true;
@ -907,7 +941,14 @@ class CredentialStore extends Wizard
break;
case 'GOOGLE':
// Need further investigation.
$extra_1_label = __('Auth JSON');
$user = false;
$pass = false;
$extra1 = true;
$extra2 = false;
$extra1_type = 'textarea';
break;
case 'CUSTOM':
case 'SAP':
$user_label = __('Account ID');
@ -919,29 +960,33 @@ class CredentialStore extends Wizard
break;
}
$inputs[] = [
'label' => $user_label,
'id' => 'div-username',
'arguments' => [
'name' => 'username',
'input_class' => 'flex-row',
'type' => 'text',
'value' => $values['username'],
'return' => true,
],
];
if ($user) {
$inputs[] = [
'label' => $user_label,
'id' => 'div-username',
'arguments' => [
'name' => 'username',
'input_class' => 'flex-row',
'type' => 'text',
'value' => $values['username'],
'return' => true,
],
];
}
$inputs[] = [
'label' => $pass_label,
'id' => 'div-password',
'arguments' => [
'name' => 'password',
'input_class' => 'flex-row',
'type' => 'password',
'value' => $values['password'],
'return' => true,
],
];
if ($pass) {
$inputs[] = [
'label' => $pass_label,
'id' => 'div-password',
'arguments' => [
'name' => 'password',
'input_class' => 'flex-row',
'type' => 'password',
'value' => $values['password'],
'return' => true,
],
];
}
if ($extra1) {
$inputs[] = [
@ -949,8 +994,9 @@ class CredentialStore extends Wizard
'id' => 'div-extra_1',
'arguments' => [
'name' => 'extra_1',
'id' => 'text-extra_1',
'input_class' => 'flex-row',
'type' => 'text',
'type' => $extra1_type,
'value' => $values['extra_1'],
'return' => true,
],
@ -1031,14 +1077,30 @@ class CredentialStore extends Wizard
* Handles inputs visibility based on selected product.
*/
function calculate_inputs() {
if ($('#product :selected').val() != "GOOGLE") {
// Restore text-extra_1.
var val = $('#text-extra_1').val();
if(typeof val == 'undefined') {
val = '';
}
$('#text-extra_1').remove();
$('#div-extra_1').append(
$('<input type="text" name="extra_1" id="text-extra_1" size="50" value="'+val+'"></input>')
);
}
if ($('#product :selected').val() == "CUSTOM") {
$('#div-username label').text('<?php echo __('User'); ?>');
$('#div-password label').text('<?php echo __('Password'); ?>');
$('#div-username').show();
$('#div-password').show();
$('#div-extra_1').hide();
$('#div-extra_2').hide();
} else if ($('#product :selected').val() == "AWS") {
$('#div-username label').text('<?php echo __('Access key ID'); ?>');
$('#div-password label').text('<?php echo __('Secret access key'); ?>');
$('#div-username').show();
$('#div-password').show();
$('#div-extra_1').hide();
$('#div-extra_2').hide();
} else if ($('#product :selected').val() == "AZURE") {
@ -1046,13 +1108,32 @@ class CredentialStore extends Wizard
$('#div-password label').text('<?php echo __('Application secret'); ?>');
$('#div-extra_1 label').text('<?php echo __('Tenant or domain name'); ?>');
$('#div-extra_2 label').text('<?php echo __('Subscription id'); ?>');
$('#div-username').show();
$('#div-password').show();
$('#div-extra_1').show();
$('#div-extra_2').show();
} else if ($('#product :selected').val() == "SAP") {
$('#div-username label').text('<?php echo __('Account ID.'); ?>');
$('#div-password label').text('<?php echo __('Password'); ?>');
$('#div-username').show();
$('#div-password').show();
$('#div-extra_1').hide();
$('#div-extra_2').hide();
} else if ($('#product :selected').val() == "GOOGLE") {
$('#div-username').hide();
$('#div-password').hide();
$('#div-extra_2').hide();
$('#div-extra_1 label').text('<?php echo __('Auth JSON'); ?>');
var val = $('#text-extra_1').val();
if(typeof val == 'undefined') {
val = '';
}
$('#text-extra_1').remove();
$('#div-extra_1').append(
$('<textarea name="extra_1" id="text-extra_1">'+val+'</textarea>')
);
$('#div-extra_1').show();
}
}

View File

@ -409,6 +409,8 @@ class ModuleTemplates extends HTML
case 'export':
global $config;
enterprise_include_once('include/functions_reporting_csv.php');
$id_network_profile = safe_int($this->id_np);
if (empty($id_network_profile)) {
return false;
@ -500,7 +502,7 @@ class ModuleTemplates extends HTML
}
// Then print the first line (row names)
echo '"'.implode('","', $row_names).'"';
echo '"'.implode('"'.$config['csv_divider'].'"', $row_names).'"';
echo "\n";
// Then print the rest of the data. Encapsulate in quotes in case we have comma's in any of the descriptions
@ -509,7 +511,19 @@ class ModuleTemplates extends HTML
unset($row[$bad_key]);
}
echo '"'.implode('","', $row).'"';
if ($config['csv_decimal_separator'] !== '.') {
foreach ($row as $name => $data) {
if (is_numeric($data)) {
// Get the number of decimals, if > 0, format dec comma.
$decimals = strlen(substr(strrchr($data, '.'), 1));
if ($decimals !== 0) {
$row[$name] = csv_format_numeric((float) $data, $decimals, true);
}
}
}
}
echo '"'.implode('"'.$config['csv_divider'].'"', $row).'"';
echo "\n";
}
@ -845,7 +859,7 @@ class ModuleTemplates extends HTML
$row['id_np'],
'',
true,
['title' => 'Export to CSV']
['title' => 'Export tdaso CSV']
);
$data[3] = '<a href="'.$this->baseUrl.'&action=delete&id_np='.$row['id_np'].'" onclick="if (!confirm(\''.__('Are you sure?').'\')) return false;">'.html_print_image('images/cross.png', true, ['title' => __('Delete')]).'</a>';
$data[3] .= '<a href="'.$this->baseUrl.'&action=export&id_np='.$row['id_np'].'">'.html_print_image('images/csv.png', true, ['title' => __('Export to CSV')]).'</a>';

View File

@ -2890,14 +2890,12 @@ class NetworkMap
$list_networkmaps = [];
}
$output .= '<div id="open_version_dialog" style="display: none;">';
$output .= __(
'In the Open version of %s can not be edited nodes or map',
get_product_name()
);
$output .= '</div>';
$id = 'dialog_node_edit';
if (!enterprise_installed()) {
$id = 'open_version_dialog';
}
$output .= '<div id="dialog_node_edit" style="display: none;" title="';
$output .= '<div id="'.$id.'" style="display: none;" title="';
$output .= __('Edit node').'">';
$output .= '<div style="text-align: left; width: 100%;">';
@ -3016,14 +3014,16 @@ class NetworkMap
true
);
$output .= ui_toggle(
html_print_table($table, true),
__('Node options'),
__('Node options'),
'',
true,
true
);
if (enterprise_installed()) {
$output .= ui_toggle(
html_print_table($table, true),
__('Node options'),
__('Node options'),
'',
true,
true
);
}
$table = new StdClass();
$table->id = 'relations_table';
@ -3077,14 +3077,16 @@ class NetworkMap
true
);
$output .= ui_toggle(
html_print_table($table, true),
__('Relations'),
__('Relations'),
'',
true,
true
);
if (enterprise_installed()) {
$output .= ui_toggle(
html_print_table($table, true),
__('Relations'),
__('Relations'),
'',
true,
true
);
}
$output .= '</div></div>';

View File

@ -565,7 +565,6 @@ class Tree
$module['id_module_type'] = (int) $module['id_tipo_modulo'];
$module['server_type'] = (int) $module['id_modulo'];
$module['status'] = $module['estado'];
$module['value'] = modules_get_agentmodule_data_for_humans($module);
if (is_metaconsole()) {
$module['serverID'] = $this->serverID;
@ -575,6 +574,8 @@ class Tree
$module['serverID'] = false;
}
$module['value'] = modules_get_agentmodule_data_for_humans($module);
if (!isset($module['value'])) {
$module['value'] = modules_get_last_value($module['id']);
}

View File

@ -20,8 +20,8 @@
/**
* Pandora build version and version
*/
$build_version = 'PC201127';
$pandora_version = 'v7.0NG.750';
$build_version = 'PC201214';
$pandora_version = 'v7.0NG.751';
// Do not overwrite default timezone set if defined.
$script_tz = @date_default_timezone_get();

View File

@ -0,0 +1,23 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// 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; version 2
// 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.
require_once 'functions.php';
if (check_login(false)) {
$return = true;
} else {
$return = false;
}
echo json_encode($return);

View File

@ -457,6 +457,9 @@ define('REPORT_OLD_TYPE_SUMATORY', 10);
define('REPORT_GENERAL_NOT_GROUP_BY_AGENT', 0);
define('REPORT_GENERAL_GROUP_BY_AGENT', 1);
define('REPORT_PERMISSIONS_NOT_GROUP_BY_GROUP', 0);
define('REPORT_PERMISSIONS_GROUP_BY_GROUP', 1);
define('REPORTING_CUSTOM_GRAPH_LEGEND_EACH_MODULE_VERTICAL_SIZE', 15);
// POLICIES.
@ -619,7 +622,8 @@ define('DISCOVERY_CLOUD_AZURE_COMPUTE', 8);
define('DISCOVERY_DEPLOY_AGENTS', 9);
define('DISCOVERY_APP_SAP', 10);
define('DISCOVERY_APP_DB2', 11);
define('DISCOVERY_APP_MICROSOFT_SQL_SERVER', 12);
define('DISCOVERY_CLOUD_GCP_COMPUTE_ENGINE', 13);
// Force task build tmp results.
define('DISCOVERY_REVIEW', 0);
@ -638,6 +642,7 @@ define('DISCOVERY_SCRIPT_IPMI_RECON', 4);
// Discovery task descriptions.
define('CLOUDWIZARD_AZURE_DESCRIPTION', 'Discovery.Cloud.Azure.Compute');
define('CLOUDWIZARD_AWS_DESCRIPTION', 'Discovery.Cloud.AWS.EC2');
define('CLOUDWIZARD_GOOGLE_DESCRIPTION', 'Discovery.Cloud.GCP');
define('CLOUDWIZARD_VMWARE_DESCRIPTION', 'Discovery.App.VMware');
// Background options.

View File

@ -3904,17 +3904,23 @@ function series_type_graph_array($data, $show_elements_graph)
$data_return['legend'][$key] .= __('Min:').remove_right_zeros(
number_format(
$value['min'],
$config['graph_precision']
$config['graph_precision'],
$config['csv_decimal_separator'],
$config['csv_decimal_separator'] == ',' ? '.' : ','
)
).' '.__('Max:').remove_right_zeros(
number_format(
$value['max'],
$config['graph_precision']
$config['graph_precision'],
$config['csv_decimal_separator'],
$config['csv_decimal_separator'] == ',' ? '.' : ','
)
).' '._('Avg:').remove_right_zeros(
number_format(
$value['avg'],
$config['graph_precision']
$config['graph_precision'],
$config['csv_decimal_separator'],
$config['csv_decimal_separator'] == ',' ? '.' : ','
)
).' '.$str;
@ -3978,7 +3984,8 @@ function series_type_graph_array($data, $show_elements_graph)
$data_return['legend'][$key] .= remove_right_zeros(
number_format(
$value['avg'],
$config['graph_precision']
$config['graph_precision'],
$config['csv_decimal_separator']
)
).' '.$str;
}
@ -5911,4 +5918,5 @@ function send_test_email(
}
return $result;
}

View File

@ -13766,12 +13766,19 @@ function api_get_module_graph($id_module, $thrash2, $other, $thrash4)
return;
}
$graph_seconds = (!empty($other) && isset($other['data'][0])) ? $other['data'][0] : SECONDS_1HOUR;
// 1 hour by default.
$graph_threshold = (!empty($other) && isset($other['data'][2]) && $other['data'][2]) ? $other['data'][2] : 0;
if (is_array($other['data']) === true) {
$graph_seconds = (!empty($other) && isset($other['data'][0])) ? $other['data'][0] : SECONDS_1HOUR;
// 1 hour by default.
$graph_threshold = (!empty($other) && isset($other['data'][2]) && $other['data'][2]) ? $other['data'][2] : 0;
// Graph height when send email by alert
$height = (!empty($other) && isset($other['data'][3]) && $other['data'][3]) ? $other['data'][3] : null;
// Graph height when send email by alert
$height = (!empty($other) && isset($other['data'][3]) && $other['data'][3]) ? $other['data'][3] : 225;
} else {
$graph_seconds = $other['data'];
$graph_threshold = 0;
$other['data'][1] = 0;
$height = 225;
}
if (is_nan($graph_seconds) || $graph_seconds <= 0) {
// returnError('error_module_graph', __(''));

View File

@ -721,6 +721,10 @@ function config_update_config()
$error_update[] = __('Double authentication');
}
if (!config_update_value('2FA_all_users', get_parameter('2FA_all_users'))) {
$error_update[] = __('2FA all users');
}
if (!config_update_value('session_timeout', get_parameter('session_timeout'))) {
$error_update[] = __('Session timeout');
}
@ -848,6 +852,10 @@ function config_update_config()
if (!config_update_value('max_execution_event_response', get_parameter('max_execution_event_response'))) {
$error_update[] = __('Max execution event response');
}
if (!config_update_value('row_limit_csv', get_parameter('row_limit_csv'))) {
$error_update[] = __('Row limit in csv log');
}
break;
case 'vis':
@ -1848,6 +1856,10 @@ function config_process_config()
config_update_value('max_macro_fields', 10);
}
if (!isset($config['row_limit_csv'])) {
config_update_value('row_limit_csv', 10000);
}
if (!isset($config['event_purge'])) {
config_update_value('event_purge', 15);
}
@ -2008,6 +2020,10 @@ function config_process_config()
config_update_value('welcome_state', WELCOME_STARTED);
}
if (!isset($config['2Fa_auth'])) {
config_update_value('2Fa_auth', '');
}
/*
* Parse the ACL IP list for access API
*/

View File

@ -117,33 +117,17 @@ if (!function_exists('mime_content_type')) {
global $config;
$homedir_filemanager = trim($config['homedir']);
$sec2 = get_parameter('sec2');
if ($sec2 == 'enterprise/godmode/agentes/collections' || $sec2 == 'advanced/collections') {
$homedir_filemanager .= '/attachment/collection/';
}
$upload_file_or_zip = (bool) get_parameter('upload_file_or_zip');
if ($upload_file_or_zip) {
$decompress = get_parameter('decompress');
if (!$decompress) {
$upload_file = true;
$upload_zip = false;
} else {
$upload_file = false;
$upload_zip = true;
}
} else {
$upload_file = (bool) get_parameter('upload_file');
$upload_zip = (bool) get_parameter('upload_zip');
}
// Upload file
if ($upload_file) {
// Load global vars
function upload_file($upload_file_or_zip, $default_real_directory)
{
global $config;
$homedir_filemanager = trim($config['homedir']);
$sec2 = get_parameter('sec2');
if ($sec2 == 'enterprise/godmode/agentes/collections' || $sec2 == 'advanced/collections') {
$homedir_filemanager .= '/attachment/collection/';
}
$config['filemanager'] = [];
$config['filemanager']['correct_upload_file'] = 0;
$config['filemanager']['message'] = null;
@ -156,43 +140,102 @@ if ($upload_file) {
return;
}
if (isset($_FILES['file']) && $_FILES['file']['name'] != '') {
$filename = $_FILES['file']['name'];
$filesize = $_FILES['file']['size'];
$real_directory = io_safe_output((string) get_parameter('real_directory'));
$directory = io_safe_output((string) get_parameter('directory'));
$umask = io_safe_output((string) get_parameter('umask', ''));
$hash = get_parameter('hash', '');
$testHash = md5($real_directory.$directory.$config['dbpass']);
if ($hash != $testHash) {
$config['filemanager']['message'] = ui_print_error_message(__('Security error'), '', true);
if ($upload_file_or_zip) {
$decompress = get_parameter('decompress');
if (!$decompress) {
$upload_file = true;
$upload_zip = false;
} else {
// Copy file to directory and change name
if ($directory == '') {
$nombre_archivo = $real_directory.'/'.$filename;
} else {
$nombre_archivo = $homedir_filemanager.'/'.$directory.'/'.$filename;
}
$upload_file = false;
$upload_zip = true;
}
} else {
$upload_file = (bool) get_parameter('upload_file');
$upload_zip = (bool) get_parameter('upload_zip');
}
if (! @copy($_FILES['file']['tmp_name'], $nombre_archivo)) {
$config['filemanager']['message'] = ui_print_error_message(__('Upload error'), '', true);
// Upload file
if ($upload_file) {
if (isset($_FILES['file']) && $_FILES['file']['name'] != '') {
$filename = $_FILES['file']['name'];
$filesize = $_FILES['file']['size'];
$real_directory = io_safe_output((string) get_parameter('real_directory'));
$directory = io_safe_output((string) get_parameter('directory'));
$umask = io_safe_output((string) get_parameter('umask', ''));
if (strpos($real_directory, $default_real_directory) !== 0) {
// Perform security check to determine whether received upload directory is part of the default path for caller uploader and user is not trying to access an external path (avoid execution of PHP files in directories that are not explicitly controlled by corresponding .htaccess).
ui_print_error_message(__('Security error'));
} else {
if ($umask !== '') {
chmod($nombre_archivo, $umask);
// Copy file to directory and change name
if ($directory == '') {
$nombre_archivo = $real_directory.'/'.$filename;
} else {
$nombre_archivo = $homedir_filemanager.'/'.$directory.'/'.$filename;
}
$config['filemanager']['correct_upload_file'] = 1;
$config['filemanager']['message'] = ui_print_success_message(__('Upload correct'), '', true);
if (! @copy($_FILES['file']['tmp_name'], $nombre_archivo)) {
$config['filemanager']['message'] = ui_print_error_message(__('Upload error'));
} else {
if ($umask !== '') {
chmod($nombre_archivo, $umask);
}
// Delete temporal file
unlink($_FILES['file']['tmp_name']);
$config['filemanager']['correct_upload_file'] = 1;
ui_print_success_message(__('Upload correct'));
// Delete temporal file
unlink($_FILES['file']['tmp_name']);
}
}
}
}
// Upload zip
if ($upload_zip) {
if (isset($_FILES['file']) && $_FILES['file']['name'] != '') {
$filename = $_FILES['file']['name'];
$filesize = $_FILES['file']['size'];
$real_directory = (string) get_parameter('real_directory');
$real_directory = io_safe_output($real_directory);
$directory = (string) get_parameter('directory');
$directory = io_safe_output($directory);
if (strpos($real_directory, $default_real_directory) !== 0) {
// Perform security check to determine whether received upload directory is part of the default path for caller uploader and user is not trying to access an external path (avoid execution of PHP files in directories that are not explicitly controlled by corresponding .htaccess).
ui_print_error_message(__('Security error'));
} else {
// Copy file to directory and change name
if ($directory == '') {
$nombre_archivo = $real_directory.'/'.$filename;
} else {
$nombre_archivo = $homedir_filemanager.'/'.$directory.'/'.$filename;
}
if (! @copy($_FILES['file']['tmp_name'], $nombre_archivo)) {
ui_print_error_message(__('Attach error'));
} else {
// Delete temporal file
unlink($_FILES['file']['tmp_name']);
// Extract the zip file
$zip = new ZipArchive;
$pathname = $homedir_filemanager.'/'.$directory.'/';
if ($zip->open($nombre_archivo) === true) {
$zip->extractTo($pathname);
unlink($nombre_archivo);
}
ui_print_success_message(__('Upload correct'));
$config['filemanager']['correct_upload_file'] = 1;
}
}
}
}
}
if (isset($_SERVER['CONTENT_LENGTH'])) {
// Control the max_post_size exceed
if (intval($_SERVER['CONTENT_LENGTH']) > 0 && empty($_POST) and empty($_FILES)) {
@ -201,12 +244,18 @@ if (isset($_SERVER['CONTENT_LENGTH'])) {
}
}
// Create text file
$create_text_file = (bool) get_parameter('create_text_file');
if ($create_text_file) {
// Load global vars
function create_text_file($default_real_directory)
{
global $config;
$homedir_filemanager = trim($config['homedir']);
$sec2 = get_parameter('sec2');
if ($sec2 == 'enterprise/godmode/agentes/collections' || $sec2 == 'advanced/collections') {
$homedir_filemanager .= '/attachment/collection/';
}
$config['filemanager'] = [];
$config['filemanager']['correct_upload_file'] = 0;
$config['filemanager']['message'] = null;
@ -228,11 +277,9 @@ if ($create_text_file) {
$directory = io_safe_output($directory);
$umask = (string) get_parameter('umask', '');
$hash = get_parameter('hash', '');
$testHash = md5($real_directory.$directory.$config['dbpass']);
if ($hash != $testHash) {
ui_print_error_message(__('Security error'), '', true);
if (strpos($real_directory, $default_real_directory) !== 0) {
// Perform security check to determine whether received upload directory is part of the default path for caller uploader and user is not trying to access an external path (avoid execution of PHP files in directories that are not explicitly controlled by corresponding .htaccess).
ui_print_error_message(__('Security error'));
} else {
if ($directory == '') {
$nombre_archivo = $real_directory.'/'.$filename;
@ -241,79 +288,27 @@ if ($create_text_file) {
}
if (! @touch($nombre_archivo)) {
$config['filemanager']['message'] = ui_print_error_message(__('Error creating file'), '', true);
$config['filemanager']['message'] = ui_print_error_message(__('Error creating file'));
} else {
if ($umask !== '') {
chmod($nombre_archivo, $umask);
}
$config['filemanager']['message'] = ui_print_success_message(__('Upload correct'), '', true);
ui_print_success_message(__('Upload correct'));
$config['filemanager']['correct_upload_file'] = 1;
}
}
} else {
$config['filemanager']['message'] = ui_print_error_message(__('Error creating file with empty name'), '', true);
ui_print_error_message(__('Error creating file with empty name'));
}
}
// Upload zip
if ($upload_zip) {
// Load global vars
global $config;
$config['filemanager'] = [];
$config['filemanager']['correct_upload_file'] = 0;
$config['filemanager']['message'] = null;
check_login();
if (! check_acl($config['id_user'], 0, 'AW')) {
db_pandora_audit('ACL Violation', 'Trying to access File manager');
include 'general/noaccess.php';
return;
}
if (isset($_FILES['file']) && $_FILES['file']['name'] != '') {
$filename = $_FILES['file']['name'];
$filesize = $_FILES['file']['size'];
$real_directory = (string) get_parameter('real_directory');
$real_directory = io_safe_output($real_directory);
$directory = (string) get_parameter('directory');
$directory = io_safe_output($directory);
$hash = get_parameter('hash', '');
$testHash = md5($real_directory.$directory.$config['dbpass']);
if ($hash != $testHash) {
$config['filemanager']['message'] = ui_print_error_message(__('Security error'), '', true);
} else {
// Copy file to directory and change name
if ($directory == '') {
$nombre_archivo = $real_directory.'/'.$filename;
} else {
$nombre_archivo = $homedir_filemanager.'/'.$directory.'/'.$filename;
}
if (! @copy($_FILES['file']['tmp_name'], $nombre_archivo)) {
$config['filemanager']['message'] = ui_print_error_message(__('Attach error'), '', true);
} else {
// Delete temporal file
unlink($_FILES['file']['tmp_name']);
// Extract the zip file
$zip = new ZipArchive;
$pathname = $homedir_filemanager.'/'.$directory.'/';
if ($zip->open($nombre_archivo) === true) {
$zip->extractTo($pathname);
unlink($nombre_archivo);
}
$config['filemanager']['message'] = ui_print_success_message(__('Upload correct'), '', true);
$config['filemanager']['correct_upload_file'] = 1;
}
}
}
$homedir_filemanager = trim($config['homedir']);
$sec2 = get_parameter('sec2');
if ($sec2 == 'enterprise/godmode/agentes/collections' || $sec2 == 'advanced/collections') {
$homedir_filemanager .= '/attachment/collection/';
}
// CREATE DIR

View File

@ -913,28 +913,45 @@ function html_print_select_multiple_filtered(
$sections = [];
}
if (empty($sections['filters']) === true) {
if (isset($sections['filters']) === false) {
$sections['filters'] = 1;
}
if (empty($sections['group-filter']) === true) {
// Show/hide all left/rigth sfilters.
if (isset($sections['item-selected-filters']) === false) {
$sections['item-selected-filters'] = 1;
}
if (isset($sections['item-available-filters']) === false) {
$sections['item-available-filters'] = 1;
}
if (isset($sections['group-filter']) == false) {
$sections['group-filter'] = 1;
}
if (empty($sections['item-available-filter']) === true) {
if (isset($sections['item-available-filter']) === false) {
$sections['item-available-filter'] = 1;
}
if (empty($sections['item-selected-filter']) === true) {
if (isset($sections['item-selected-filter']) === false) {
$sections['item-selected-filter'] = 1;
}
if (empty($group_filter) === true) {
if (isset($group_filter) === false) {
$sections['group-filter'] = 0;
}
if (isset($group_filter['nothing']) === false) {
$group_filter['nothing'] = '';
}
if (isset($group_filter['nothing_value']) === false) {
$group_filter['nothing_value'] = 0;
}
// Main container.
$output = '<div class="multi-select flex-row-vcenter '.$class.'">';
$output = '<div class="multi-select flex-row-end '.$class.'">';
// Left box.
$output .= '<div class="multi-select-container flex-column">';
@ -943,6 +960,7 @@ function html_print_select_multiple_filtered(
// Filtering.
if (isset($sections['filters']) === true
&& $sections['filters'] === 1
&& $sections['item-available-filters'] === 1
) {
// Filtering.
if (isset($sections['group-filter']) === true
@ -962,6 +980,7 @@ function html_print_select_multiple_filtered(
$output .= html_print_input(
[
'input_class' => 'flex-row-vcenter',
'label' => __('Filter group'),
'name' => 'id-group-available-select-'.$rid,
'returnAllGroup' => true,
@ -969,16 +988,20 @@ function html_print_select_multiple_filtered(
'type' => 'select_groups',
'return' => true,
'script' => $reload_content,
'nothing' => $group_filter['nothing'],
'nothing_value' => $group_filter['nothing_value'],
]
);
$output .= html_print_input(
[
'label' => __('Group recursion'),
'name' => 'id-group-recursion-available-select-'.$rid,
'type' => 'checkbox',
'script' => $reload_content,
'return' => true,
'label' => __('Group recursion'),
'input_class' => 'flex-row-vcenter',
'name' => 'id-group-recursion-available-select-'.$rid,
'id' => 'checkbox-id-group-recursion-available-select-'.$rid,
'type' => 'switch',
'onchange' => $reload_content,
'return' => true,
]
);
@ -1087,6 +1110,7 @@ function html_print_select_multiple_filtered(
// Filtering.
if (isset($sections['filters']) === true
&& $sections['filters'] === 1
&& $sections['item-selected-filters']
) {
if (isset($sections['group-filter']) === true
&& $sections['group-filter'] === 1
@ -1105,6 +1129,7 @@ function html_print_select_multiple_filtered(
$output .= html_print_input(
[
'input_class' => 'flex-row-vcenter',
'label' => __('Filter group'),
'name' => 'id-group-selected-select-'.$rid,
'returnAllGroup' => true,
@ -1117,11 +1142,12 @@ function html_print_select_multiple_filtered(
$output .= html_print_input(
[
'label' => __('Group recursion'),
'name' => 'id-group-recursion-selected-select-'.$rid,
'type' => 'checkbox',
'script' => $reload_content,
'return' => true,
'input_class' => 'flex-row-vcenter',
'label' => __('Group recursion'),
'name' => 'id-group-recursion-selected-select-'.$rid,
'type' => 'checkbox',
'script' => $reload_content,
'return' => true,
]
);
@ -1152,7 +1178,7 @@ function html_print_select_multiple_filtered(
'label' => __($texts['filter-item']),
'name' => 'filter-item-selected-'.$rid,
'onKeyUp' => $f,
'input_class' => 'filter w100p',
'input_class' => 'flex-row-vcenter filter w100p',
'size' => 20,
'type' => 'text',
'return' => true,
@ -1368,6 +1394,7 @@ function html_print_select_multiple_modules_filtered(array $data):string
* @param mixed $size Max elements showed in select or default (size=10)
* @param integer $truncante_size Truncate size of the element, by default is set to GENERIC_SIZE_TEXT constant
* @param integer $class Class to apply.
* @param boolean $required Select is required or not.
*
* @return string HTML code if return parameter is true.
*/
@ -1385,7 +1412,8 @@ function html_print_select_from_sql(
$style=false,
$size=false,
$trucate_size=GENERIC_SIZE_TEXT,
$class=''
$class='',
$required=false
) {
global $config;
@ -1421,7 +1449,17 @@ function html_print_select_from_sql(
$disabled,
$style,
'',
$size
$size,
// Modal.
false,
// Message.
'',
// Select_all.
false,
// Simple_multiple_options.
false,
// Required.
$required
);
}
@ -1734,7 +1772,7 @@ function html_print_extended_select_for_time(
ob_start();
// Use the no_meta parameter because this image is only in the base console.
echo '<div id="'.$uniq_name.'_default" style="width:100%;display:inline">';
echo '<div id="'.$uniq_name.'_default" style="width:auto;display:inline">';
html_print_select(
$fields,
$uniq_name.'_select',
@ -2872,13 +2910,17 @@ function html_print_textarea(
$attributes='',
$return=false,
$class='',
$disable=false
$disable=false,
$id=false
) {
$disabled = ($disable) ? 'disabled' : '';
$output = '<textarea id="textarea_'.$name.'" name="'.$name.'" cols="'.$columns.'" rows="'.$rows.'" '.$attributes.' class="'.$class.'" '.$disabled.'>';
if ($id === false) {
$id = 'textarea_'.$name;
}
$output = '<textarea id="'.$id.'" name="'.$name.'" cols="'.$columns.'" rows="'.$rows.'" '.$attributes.' class="'.$class.'" '.$disabled.'>';
$output .= ($value);
$output .= '</textarea>';
if ($return) {
return $output;
}
@ -4445,7 +4487,8 @@ function html_print_input($data, $wrapper='div', $input_only=false)
((isset($data['style']) === true) ? $data['style'] : false),
((isset($data['size']) === true) ? $data['size'] : false),
((isset($data['trucate_size']) === true) ? $data['trucate_size'] : GENERIC_SIZE_TEXT),
((isset($data['class']) === true) ? $data['class'] : '')
((isset($data['class']) === true) ? $data['class'] : ''),
((isset($data['required']) === true) ? $data['required'] : false)
);
break;
@ -4563,7 +4606,8 @@ function html_print_input($data, $wrapper='div', $input_only=false)
((isset($data['attributes']) === true) ? $data['attributes'] : ''),
((isset($data['return']) === true) ? $data['return'] : false),
((isset($data['class']) === true) ? $data['class'] : ''),
((isset($data['disabled']) === true) ? $data['disabled'] : false)
((isset($data['disabled']) === true) ? $data['disabled'] : false),
((isset($data['id']) === true) ? $data['id'] : false)
);
break;

View File

@ -55,6 +55,11 @@ function menu_print_menu(&$menu)
} else if ($sec2 == 'godmode/servers/discovery') {
$wiz = (string) get_parameter('wiz');
$sec2 = 'godmode/servers/discovery&wiz='.$wiz;
} else if ($sec2 == 'godmode/groups/group_list') {
$tab = (string) get_parameter('tab');
if ($tab === 'credbox') {
$sec2 = 'godmode/groups/group_list&tab='.$tab;
}
} else {
$sec2 = (string) get_parameter('sec2');
}
@ -147,6 +152,7 @@ function menu_print_menu(&$menu)
$first_sub_sec2 = '';
foreach ($main['sub'] as $subsec2 => $sub) {
// hd($sub, true);
$count_sub++;
// Init some variables.

View File

@ -2359,9 +2359,10 @@ function modules_get_agentmodule_data_for_humans($module)
} else {
$salida = ui_print_module_string_value(
$module['datos'],
$module['id_agente_modulo'],
$module['id'],
$module['current_interval'],
$module['module_name']
$module['module_name'],
$module['serverID'] ? $module['serverID'] : 0
);
}
}
@ -3395,16 +3396,16 @@ function recursive_get_dt_from_modules_tree(&$f_modules, $modules, $deep)
/**
* @brief Get the button with the link to open realtime stats into a new window
* Only to native (not satellite discovered) snmp modules.
* Only to native (not satellite discovered) snmp modules.
*
* @param array With all the module info
* @return string All the HTML code to paint the button
* @param array $module With all the module info.
* @return string Link to chart.
*/
function get_module_realtime_link_graph($module)
{
global $config;
// Sometimes some parameters are renamed
// Sometimes some parameters are renamed.
if (!isset($module['id_tipo_modulo'])) {
$module['id_tipo_modulo'] = $module['module_type'];
}
@ -3413,36 +3414,51 @@ function get_module_realtime_link_graph($module)
$module['nombre'] = $module['module_name'];
}
// Avoid to show on metaconsole
// Avoid to show on metaconsole.
if (is_metaconsole()) {
return '';
}
// Realtime graph is an extension and it should be enabled
// Realtime graph is an extension and it should be enabled.
if (!extensions_is_enabled_extension('realtime_graphs.php')) {
return '';
}
// Only to remote_snmp, remote_snmp_proc. snmp_snmp_inc
if ($module['id_tipo_modulo'] != 15 && $module['id_tipo_modulo'] != 16 && $module['id_tipo_modulo'] != 18) {
// Only to remote_snmp, remote_snmp_proc. snmp_snmp_inc.
if ($module['id_tipo_modulo'] != 15
&& $module['id_tipo_modulo'] != 16
&& $module['id_tipo_modulo'] != 18
) {
return '';
}
// Only version 1, 2 and 2c
if ($module['tcp_send'] != '1' && $module['tcp_send'] != '2' && $module['tcp_send'] != '2c') {
// Only version 1, 2, 2c and 3
if ($module['tcp_send'] != '1'
&& $module['tcp_send'] != '2'
&& $module['tcp_send'] != '2c'
&& $module['tcp_send'] != '3'
) {
return '';
}
$params = [
'graph' => 'snmp_module',
'agent_alias' => urlencode(modules_get_agentmodule_agent_alias($module['id_agente_modulo'])),
'module_name' => urlencode($module['nombre']),
'snmp_address' => $module['ip_target'],
'snmp_community' => urlencode($module['snmp_community']),
'snmp_oid' => $module['snmp_oid'],
'snmp_ver' => $module['tcp_send'],
'hide_header' => 1,
'rel_path' => '../../',
'graph' => 'snmp_module',
'agent_alias' => urlencode(
modules_get_agentmodule_agent_alias($module['id_agente_modulo'])
),
'module_name' => urlencode($module['nombre']),
'target_ip' => $module['ip_target'],
'community' => urlencode($module['snmp_community']),
'starting_oid' => urlencode($module['snmp_oid']),
'snmp_browser_version' => urlencode($module['tcp_send']),
'snmp3_auth_user' => urlencode($module['plugin_user']),
'snmp3_security_level' => urlencode($module['custom_string_3']),
'snmp3_auth_method' => urlencode($module['plugin_parameters']),
'snmp3_auth_pass' => urlencode($module['plugin_pass']),
'snmp3_privacy_method' => urlencode($module['custom_string_1']),
'snmp3_privacy_pass' => urlencode($module['custom_string_2']),
'hide_header' => 1,
'rel_path' => '../../',
];
// Incremental type
if ($module['id_tipo_modulo'] == 16) {
@ -3456,9 +3472,13 @@ function get_module_realtime_link_graph($module)
$link = substr($link, 0, -1);
$win_handle = 'realtime_'.dechex(crc32($module['id_agente_modulo'].$module['nombre']));
$win_handle = 'realtime_';
$win_handle .= dechex(
crc32($module['id_agente_modulo'].$module['nombre'])
);
$link_button = '<a href="javascript:winopeng_var(\''.$link.'\',\''.$win_handle.'\', 900, 480)">'.html_print_image(
$link_button = '<a href="javascript:winopeng_var(\''.$link.'\',\''.$win_handle.'\', 900, 480)">';
$link_button .= html_print_image(
'images/realtime_shortcut.png',
true,
[
@ -3466,7 +3486,8 @@ function get_module_realtime_link_graph($module)
'alt' => '',
'title' => __('Realtime SNMP graph'),
]
).'</a>';
);
$link_button .= '</a>';
return $link_button;
}

View File

@ -234,7 +234,7 @@ function profile_print_profile_table($id)
$sql = sprintf(
"SELECT tusuario_perfil.* FROM tusuario_perfil
INNER JOIN tperfil ON tperfil.id_perfil = tusuario_perfil.id_perfil
WHERE id_usuario like '%s' AND id_grupo IN (%s) AND user_management = 0",
WHERE id_usuario like '%s' AND id_grupo IN (%s)",
$id,
$group_um_string
);

View File

@ -694,6 +694,13 @@ function reporting_make_reporting_data(
);
break;
case 'permissions_report':
$report['contents'][] = reporting_permissions(
$report,
$content
);
break;
case 'group_report':
$report['contents'][] = reporting_group_report(
$report,
@ -1840,10 +1847,23 @@ function reporting_event_report_group(
$history = true;
}
$return['title'] = $content['name'];
$group_name = groups_get_name($content['id_group'], true);
$items_label = ['agent_group' => $group_name];
// Apply macros.
$title = (isset($content['name'])) ? $content['name'] : '';
if ($title != '') {
$title = reporting_label_macro(
$items_label,
$title
);
}
$return['title'] = $title;
$return['landscape'] = $content['landscape'];
$return['pagebreak'] = $content['pagebreak'];
$return['subtitle'] = groups_get_name($content['id_group'], true);
$return['subtitle'] = $group_name;
if (!empty($content['style']['event_filter_search'])) {
$return['subtitle'] .= ' ('.$content['style']['event_filter_search'].')';
}
@ -2122,7 +2142,16 @@ function reporting_event_report_module(
'module_description' => $module_description,
];
$return['title'] = $content['name'];
// Apply macros.
$title = (isset($content['name'])) ? $content['name'] : '';
if ($title != '') {
$title = reporting_label_macro(
$items_label,
$title
);
}
$return['title'] = $title;
$return['landscape'] = $content['landscape'];
$return['pagebreak'] = $content['pagebreak'];
$return['subtitle'] = $agent_alias.' - '.io_safe_output($module_name);
@ -2230,18 +2259,44 @@ function reporting_inventory_changes($report, $content, $type)
metaconsole_connect($server);
}
$return['title'] = $content['name'];
$es = json_decode($content['external_source'], true);
$id_agent = $es['id_agents'];
$module_name = $es['inventory_modules'];
$id_agent_module = modules_get_agentmodule_id($module_name, $id_agent);
$agent_description = agents_get_description($id_agent);
$agent_group = agents_get_agent_group($id_agent);
$agent_address = agents_get_address($id_agent);
$agent_alias = agents_get_alias($id_agent);
$module_description = modules_get_agentmodule_descripcion(
$id_agent_module
);
$items_label = [
'id_agent' => $id_agent,
'id_agent_module' => $id_agent_module,
'agent_description' => $agent_description,
'agent_group' => $agent_group,
'agent_address' => $agent_address,
'agent_alias' => $agent_alias,
];
// Apply macros.
$title = (isset($content['name'])) ? $content['name'] : '';
if ($title != '') {
$title = reporting_label_macro(
$items_label,
$title
);
}
$return['title'] = $title;
$return['landscape'] = $content['landscape'];
$return['pagebreak'] = $content['pagebreak'];
$return['subtitle'] = agents_get_alias($content['id_agent']);
$return['description'] = $content['description'];
$return['date'] = reporting_get_date_text($report, $content);
$es = json_decode($content['external_source'], true);
$id_agent = $es['id_agents'];
$module_name = $es['inventory_modules'];
switch ($type) {
case 'data':
$inventory_changes = inventory_get_changes(
@ -2299,12 +2354,6 @@ function reporting_inventory($report, $content, $type)
metaconsole_connect($server);
}
$return['title'] = $content['name'];
$return['landscape'] = $content['landscape'];
$return['pagebreak'] = $content['pagebreak'];
$return['description'] = $content['description'];
$return['date'] = reporting_get_date_text($report, $content);
$es = json_decode($content['external_source'], true);
$id_agent = $es['id_agents'];
@ -2313,6 +2362,35 @@ function reporting_inventory($report, $content, $type)
$module_name = [0 => 0];
}
$agent_description = agents_get_description($id_agent);
$agent_group = agents_get_agent_group($id_agent);
$agent_address = agents_get_address($id_agent);
$agent_alias = agents_get_alias($id_agent);
$items_label = [
'type' => $return['type'],
'id_agent' => $id_agent,
'agent_description' => $agent_description,
'agent_group' => $agent_group,
'agent_address' => $agent_address,
'agent_alias' => $agent_alias,
];
// Apply macros.
$title = (isset($content['name'])) ? $content['name'] : '';
if ($title != '') {
$title = reporting_label_macro(
$items_label,
$title
);
}
$return['title'] = $title;
$return['landscape'] = $content['landscape'];
$return['pagebreak'] = $content['pagebreak'];
$return['description'] = $content['description'];
$return['date'] = reporting_get_date_text($report, $content);
$date = $es['date'];
$description = $content['description'];
@ -2942,8 +3020,21 @@ function reporting_group_report($report, $content)
$connection = metaconsole_get_connection($server);
}
$items_label = [
'agent_group' => groups_get_name($content['id_group'], true),
];
// Apply macros
$title = (isset($content['name'])) ? $content['name'] : '';
if ($title != '') {
$title = reporting_label_macro(
$items_label,
$title
);
}
$return['server_name'] = $server[0];
$return['title'] = io_safe_output($content['name']);
$return['title'] = $title;
$return['landscape'] = $content['landscape'];
$return['pagebreak'] = $content['pagebreak'];
$return['subtitle'] = groups_get_name($content['id_group'], true);
@ -3038,6 +3129,15 @@ function reporting_event_report_agent(
'agent_alias' => $agent_alias,
];
// Apply macros.
$title = (isset($content['name'])) ? $content['name'] : '';
if ($title != '') {
$title = reporting_label_macro(
$items_label,
$title
);
}
if ($config['metaconsole']) {
metaconsole_restore_db();
}
@ -3051,7 +3151,7 @@ function reporting_event_report_agent(
}
$return['label'] = $label;
$return['title'] = io_safe_output($content['name']);
$return['title'] = $title;
$return['landscape'] = $content['landscape'];
$return['pagebreak'] = $content['pagebreak'];
$return['subtitle'] = io_safe_output($agent_alias);
@ -3262,7 +3362,16 @@ function reporting_historical_data($report, $content)
'module_description' => $module_description,
];
$return['title'] = $content['name'];
// Apply macros.
$title = (isset($content['name'])) ? $content['name'] : '';
if ($title != '') {
$title = reporting_label_macro(
$items_label,
$title
);
}
$return['title'] = $title;
$return['landscape'] = $content['landscape'];
$return['pagebreak'] = $content['pagebreak'];
$return['subtitle'] = $agent_alias.' - '.$module_name;
@ -3387,7 +3496,16 @@ function reporting_database_serialized($report, $content)
'module_description' => $module_description,
];
$return['title'] = $content['name'];
// Apply macros.
$title = (isset($content['name'])) ? $content['name'] : '';
if ($title != '') {
$title = reporting_label_macro(
$items_label,
$title
);
}
$return['title'] = $title;
$return['landscape'] = $content['landscape'];
$return['pagebreak'] = $content['pagebreak'];
$return['subtitle'] = $agent_alias.' - '.$module_name;
@ -3541,7 +3659,37 @@ function reporting_last_value($report, $content)
$content['id_agent_module']
);
$return['title'] = $content['name'];
$id_agent_module = $content['id_agent_module'];
$agent_description = agents_get_description($id_agent);
$agent_group = agents_get_agent_group($id_agent);
$agent_address = agents_get_address($id_agent);
$module_description = modules_get_agentmodule_descripcion(
$id_agent_module
);
$items_label = [
'type' => $return['type'],
'id_agent' => $id_agent,
'id_agent_module' => $id_agent_module,
'agent_description' => $agent_description,
'agent_group' => $agent_group,
'agent_address' => $agent_address,
'agent_alias' => $agent_alias,
'module_name' => $module_name,
'module_description' => $module_description,
];
// Apply macros
$title = (isset($content['name'])) ? $content['name'] : '';
if ($title != '') {
$title = reporting_label_macro(
$items_label,
$title
);
}
$return['title'] = $title;
$return['landscape'] = $content['landscape'];
$return['pagebreak'] = $content['pagebreak'];
$return['subtitle'] = $agent_alias.' - '.$module_name;
@ -3577,6 +3725,128 @@ function reporting_last_value($report, $content)
}
function reporting_permissions($report, $content)
{
global $config;
$return['type'] = 'permissions_report';
if (empty($content['name'])) {
$content['name'] = __('Permissions report');
}
$return['title'] = $content['name'];
$return['landscape'] = $content['landscape'];
$return['pagebreak'] = $content['pagebreak'];
$return['description'] = $content['description'];
$return['date'] = reporting_get_date_text($report, $content);
$external_source = io_safe_input(json_decode($content['external_source'], true));
$id_users = $external_source['id_users'];
$id_groups = $external_source['users_groups'];
// Select subtype: group by user or by group.
$select_by_group = $external_source['select_by_group'];
$return['subtype'] = (int) $select_by_group;
if ($select_by_group === REPORT_PERMISSIONS_NOT_GROUP_BY_GROUP) {
foreach ($id_users as $id_user) {
$user_name = db_get_value_filter('fullname', 'tusuario', ['id_user' => $id_user]);
$sql = sprintf(
"SELECT name, id_grupo FROM tusuario_perfil
INNER JOIN tperfil ON tperfil.id_perfil = tusuario_perfil.id_perfil
WHERE tusuario_perfil.id_usuario like '%s'",
$id_user
);
$profiles = db_get_all_rows_sql($sql);
$user_profiles = [];
if (empty($profiles)) {
$user_profiles[] = __('The user doesn\'t have any assigned profile/group');
} else {
foreach ($profiles as $user_profile) {
$user_profiles[] = $user_profile['name'].' / '.groups_get_name($user_profile['id_grupo'], true);
}
}
$data[] = [
'user_id' => io_safe_output($id_user),
'user_name' => io_safe_output($user_name),
'user_profiles' => io_safe_output($user_profiles),
];
}
} else {
$group_users = [];
foreach ($id_groups as $id_group) {
if ($id_group === '') {
$group_name = __('Unnasigned group');
$sql = 'SELECT tusuario.id_user, tusuario.fullname FROM tusuario
LEFT OUTER JOIN tusuario_perfil
ON tusuario.id_user = tusuario_perfil.id_usuario
WHERE tusuario_perfil.id_usuario IS NULL';
$group_users = db_get_all_rows_sql($sql);
$group_name = __('Unassigned group');
} else {
$group_name = groups_get_name($id_group, true);
$group_users = users_get_user_users(
$id_group,
'AR',
false,
[
'id_user',
'fullname',
],
[$id_group]
);
}
$row['users'] = [];
foreach ($group_users as $user) {
$id_user = $user['id_user'];
// Get user fullanme.
$row['users'][$id_user]['fullname'] = $user['fullname'];
if ($id_group === '') {
$row['users'][$id_user]['profiles'][] = __('The user doesn\'t have any assigned profile/group');
} else {
// Incluide id group = 0 for 'All' profile.
$sql = sprintf(
"SELECT id_perfil FROM tusuario_perfil
WHERE id_usuario LIKE '%s'
AND (
id_grupo LIKE '%s'
OR id_grupo LIKE '0'
)",
$id_user,
$id_group
);
$user_profiles_id = db_get_all_rows_sql($sql);
foreach ($user_profiles_id as $profile_id) {
$row['users'][$id_user]['profiles'][] = profile_get_name($profile_id['id_perfil']);
}
}
}
$data[] = [
'group_name' => $group_name,
'users' => $row['users'],
];
}
}
$return['data'] = [];
$return['data'] = $data;
return reporting_check_structure_content($return);
}
function reporting_group_configuration($report, $content)
{
global $config;
@ -3596,7 +3866,18 @@ function reporting_group_configuration($report, $content)
$group_name = groups_get_name($content['id_group'], true);
$return['title'] = $content['name'];
$items_label = ['agent_group' => $group_name];
// Apply macros.
$title = (isset($content['name'])) ? $content['name'] : '';
if ($title != '') {
$title = reporting_label_macro(
$items_label,
$title
);
}
$return['title'] = $title;
$return['landscape'] = $content['landscape'];
$return['pagebreak'] = $content['pagebreak'];
$return['subtitle'] = $group_name;
@ -3671,7 +3952,18 @@ function reporting_network_interfaces_report($report, $content, $type='dinamic',
$group_name = groups_get_name($content['id_group']);
$return['title'] = $content['name'];
$items_label = ['_agentgroup_' => $group_name];
// Apply macros
$title = (isset($content['name'])) ? $content['name'] : '';
if ($title != '') {
$title = reporting_label_macro(
$items_label,
$title
);
}
$return['title'] = $title;
$return['landscape'] = $content['landscape'];
$return['pagebreak'] = $content['pagebreak'];
$return['subtitle'] = $group_name;
@ -3907,7 +4199,18 @@ function reporting_alert_report_group($report, $content)
$group_name = groups_get_name($content['id_group'], true);
$return['title'] = $content['name'];
$items_label = ['agent_group' => $group_name];
// Apply macros.
$title = (isset($content['name'])) ? $content['name'] : '';
if ($title != '') {
$title = reporting_label_macro(
$items_label,
$title
);
}
$return['title'] = $title;
$return['landscape'] = $content['landscape'];
$return['pagebreak'] = $content['pagebreak'];
$return['subtitle'] = $group_name;
@ -4090,7 +4393,16 @@ function reporting_alert_report_agent($report, $content)
'agent_alias' => $agent_alias,
];
$return['title'] = $content['name'];
// Apply macros.
$title = (isset($content['name'])) ? $content['name'] : '';
if ($title != '') {
$title = reporting_label_macro(
$items_label,
$title
);
}
$return['title'] = $title;
$return['landscape'] = $content['landscape'];
$return['pagebreak'] = $content['pagebreak'];
$return['subtitle'] = $agent_alias;
@ -4260,7 +4572,16 @@ function reporting_alert_report_module($report, $content)
'module_description' => $module_description,
];
$return['title'] = $content['name'];
// Apply macros.
$title = (isset($content['name'])) ? $content['name'] : '';
if ($title != '') {
$title = reporting_label_macro(
$items_label,
$title
);
}
$return['title'] = $title;
$return['landscape'] = $content['landscape'];
$return['pagebreak'] = $content['pagebreak'];
$return['subtitle'] = $agent_alias.' - '.$module_name;
@ -4543,7 +4864,16 @@ function reporting_monitor_report($report, $content)
'module_description' => $module_description,
];
$return['title'] = $content['name'];
// Apply macros.
$title = (isset($content['name'])) ? $content['name'] : '';
if ($title != '') {
$title = reporting_label_macro(
$items_label,
$title
);
}
$return['title'] = $title;
$return['landscape'] = $content['landscape'];
$return['pagebreak'] = $content['pagebreak'];
$return['subtitle'] = $agent_alias.' - '.$module_name;
@ -4735,11 +5065,57 @@ function reporting_prediction_date($report, $content)
);
$agent_name_db = io_safe_output(modules_get_agentmodule_agent_name($content['id_agent_module']));
$return['title'] = $content['name'];
$id_agent = agents_get_module_id(
$content['id_agent_module']
);
$id_agent_module = $content['id_agent_module'];
$agent_description = agents_get_description($id_agent);
$agent_group = agents_get_agent_group($id_agent);
$agent_address = agents_get_address($id_agent);
$agent_alias = agents_get_alias($id_agent);
$module_name = modules_get_agentmodule_name(
$id_agent_module
);
$module_description = modules_get_agentmodule_descripcion(
$id_agent_module
);
$items_label = [
'type' => $return['type'],
'id_agent' => $id_agent,
'id_agent_module' => $id_agent_module,
'agent_description' => $agent_description,
'agent_group' => $agent_group,
'agent_address' => $agent_address,
'agent_alias' => $agent_alias,
'module_name' => $module_name,
'module_description' => $module_description,
];
// Apply macros
$title = (isset($content['name'])) ? $content['name'] : '';
if ($title != '') {
$title = reporting_label_macro(
$items_label,
$title
);
}
$description = (isset($content['description'])) ? $content['description'] : '';
if ($description != '') {
$description = reporting_label_macro(
$items_label,
$description
);
}
$return['title'] = $title;
$return['landscape'] = $content['landscape'];
$return['pagebreak'] = $content['pagebreak'];
$return['subtitle'] = $agent_name.' - '.$module_name;
$return['description'] = $content['description'];
$return['description'] = $description;
$return['date'] = reporting_get_date_text($report, $content);
$return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : '';
@ -4790,7 +5166,45 @@ function reporting_projection_graph(
$agent_name = io_safe_output(modules_get_agentmodule_agent_alias($content['id_agent_module']));
$agent_name_db = io_safe_output(modules_get_agentmodule_agent_name($content['id_agent_module']));
$return['title'] = $content['name'];
$id_agent = agents_get_module_id(
$content['id_agent_module']
);
$id_agent_module = $content['id_agent_module'];
$agent_description = agents_get_description($id_agent);
$agent_group = agents_get_agent_group($id_agent);
$agent_address = agents_get_address($id_agent);
$agent_alias = agents_get_alias($id_agent);
$module_name = modules_get_agentmodule_name(
$id_agent_module
);
$module_description = modules_get_agentmodule_descripcion(
$id_agent_module
);
$items_label = [
'type' => $return['type'],
'id_agent' => $id_agent,
'id_agent_module' => $id_agent_module,
'agent_description' => $agent_description,
'agent_group' => $agent_group,
'agent_address' => $agent_address,
'agent_alias' => $agent_alias,
'module_name' => $module_name,
'module_description' => $module_description,
];
// Apply macros
$title = (isset($content['name'])) ? $content['name'] : '';
if ($title != '') {
$title = reporting_label_macro(
$items_label,
$title
);
}
$return['title'] = $title;
$return['subtitle'] = $agent_name.' - '.$module_name;
$return['description'] = $content['description'];
$return['date'] = reporting_get_date_text($report, $content);
@ -4869,7 +5283,36 @@ function reporting_agent_configuration($report, $content)
$content['name'] = __('Agent configuration');
}
$return['title'] = $content['name'];
$sql = '
SELECT *
FROM tagente
WHERE id_agente='.$content['id_agent'];
$agent_data = db_get_row_sql($sql);
$id_agent = $content['id_agent'];
$agent_alias = $agent_data['alias'];
$agent_group = groups_get_name($agent_data['id_grupo']);
$agent_description = $agent_data['comentarios'];
$agent_address = $agent_data['direccion'];
$items_label = [
'id_agent' => $id_agent,
'agent_description' => $agent_description,
'agent_group' => $agent_group,
'agent_address' => $agent_address,
'agent_alias' => $agent_alias,
];
// Apply macros.
$title = (isset($content['name'])) ? $content['name'] : '';
if ($title != '') {
$title = reporting_label_macro(
$items_label,
$title
);
}
$return['title'] = $title;
$return['landscape'] = $content['landscape'];
$return['pagebreak'] = $content['pagebreak'];
$return['description'] = $content['description'];
@ -4883,20 +5326,14 @@ function reporting_agent_configuration($report, $content)
metaconsole_connect($server);
}
$sql = '
SELECT *
FROM tagente
WHERE id_agente='.$content['id_agent'];
$agent_data = db_get_row_sql($sql);
$agent_configuration = [];
$agent_configuration['name'] = $agent_data['alias'];
$agent_configuration['group'] = groups_get_name($agent_data['id_grupo']);
$agent_configuration['name'] = $agent_alias;
$agent_configuration['group'] = $agent_group;
$agent_configuration['group_icon'] = ui_print_group_icon($agent_data['id_grupo'], true, '', '', false);
$agent_configuration['os'] = os_get_name($agent_data['id_os']);
$agent_configuration['os_icon'] = ui_print_os_icon($agent_data['id_os'], true, true);
$agent_configuration['address'] = $agent_data['direccion'];
$agent_configuration['description'] = $agent_data['comentarios'];
$agent_configuration['address'] = $agent_address;
$agent_configuration['description'] = $agent_description;
$agent_configuration['enabled'] = (int) !$agent_data['disabled'];
$agent_configuration['group'] = $report['group'];
$modules = agents_get_modules($content['id_agent']);
@ -5061,13 +5498,59 @@ function reporting_value($report, $content, $type, $pdf=false)
$content['id_agent_module']
);
$return['title'] = $content['name'];
$id_agent = agents_get_module_id(
$content['id_agent_module']
);
$id_agent_module = $content['id_agent_module'];
$agent_description = agents_get_description($id_agent);
$agent_group = agents_get_agent_group($id_agent);
$agent_address = agents_get_address($id_agent);
$agent_alias = agents_get_alias($id_agent);
$module_name = modules_get_agentmodule_name(
$id_agent_module
);
$module_description = modules_get_agentmodule_descripcion(
$id_agent_module
);
$items_label = [
'type' => $return['type'],
'id_agent' => $id_agent,
'id_agent_module' => $id_agent_module,
'agent_description' => $agent_description,
'agent_group' => $agent_group,
'agent_address' => $agent_address,
'agent_alias' => $agent_alias,
'module_name' => $module_name,
'module_description' => $module_description,
];
// Apply macros
$title = (isset($content['name'])) ? $content['name'] : '';
if ($title != '') {
$title = reporting_label_macro(
$items_label,
$title
);
}
$label = (isset($content['name'])) ? $content['name'] : '';
if ($label != '') {
$label = reporting_label_macro(
$items_label,
$label
);
}
$return['title'] = $title;
$return['landscape'] = $content['landscape'];
$return['pagebreak'] = $content['pagebreak'];
$return['subtitle'] = $agent_name.' - '.$module_name;
$return['description'] = $content['description'];
$return['date'] = reporting_get_date_text($report, $content);
$return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : '';
$return['label'] = $label;
$return['agents'] = [$content['id_agent']];
$return['id_agent'] = $content['id_agent'];
$return['id_agent_module'] = $content['id_agent_module'];
@ -5421,7 +5904,7 @@ function reporting_sql($report, $content)
)
);
} else {
$sql = io_safe_output($content['external_source']);
$sql = $content['external_source'];
}
// Check if exist sql macro
@ -7693,7 +8176,42 @@ function reporting_increment($report, $content)
$content['name'] = __('Increment');
}
$return['title'] = $content['name'];
$id_agent = $content['id_agent'];
$id_agent_module = $content['id_agent_module'];
$agent_description = agents_get_description($id_agent);
$agent_group = agents_get_agent_group($id_agent);
$agent_address = agents_get_address($id_agent);
$agent_alias = agents_get_alias($id_agent);
$module_name = modules_get_agentmodule_name(
$id_agent_module
);
$module_description = modules_get_agentmodule_descripcion(
$id_agent_module
);
$items_label = [
'type' => $return['type'],
'id_agent' => $id_agent,
'id_agent_module' => $id_agent_module,
'agent_description' => $agent_description,
'agent_group' => $agent_group,
'agent_address' => $agent_address,
'agent_alias' => $agent_alias,
'module_name' => $module_name,
'module_description' => $module_description,
];
// Apply macros
$title = (isset($content['name'])) ? $content['name'] : '';
if ($title != '') {
$title = reporting_label_macro(
$items_label,
$title
);
}
$return['title'] = $title;
$return['landscape'] = $content['landscape'];
$return['pagebreak'] = $content['pagebreak'];
$return['description'] = $content['description'];
@ -8317,6 +8835,10 @@ function reporting_custom_graph(
$content['name'] = __('Simple graph');
}
$id_agent = agents_get_module_id(
$content['id_agent_module']
);
$agent_description = agents_get_description($id_agent);
$agent_group = agents_get_agent_group($id_agent);
$agent_address = agents_get_address($id_agent);
@ -8329,13 +8851,42 @@ function reporting_custom_graph(
$id_agent_module
);
$return['title'] = $content['name'];
$items_label = [
'type' => $return['type'],
'id_agent' => $id_agent,
'id_agent_module' => $id_agent_module,
'agent_description' => $agent_description,
'agent_group' => $agent_group,
'agent_address' => $agent_address,
'agent_alias' => $agent_alias,
'module_name' => $module_name,
'module_description' => $module_description,
];
// Apply macros
$title = (isset($content['name'])) ? $content['name'] : '';
if ($title != '') {
$title = reporting_label_macro(
$items_label,
$title
);
}
$description = (isset($content['description'])) ? $content['description'] : '';
if ($description != '') {
$description = reporting_label_macro(
$items_label,
$description
);
}
$return['title'] = $title;
$return['landscape'] = $content['landscape'];
$return['pagebreak'] = $content['pagebreak'];
$return['subtitle'] = $graphs[0]['name'];
$return['agent_name'] = $agent_alias;
$return['module_name'] = $module_name;
$return['description'] = $content['description'];
$return['description'] = $description;
$return['date'] = reporting_get_date_text(
$report,
$content
@ -8479,6 +9030,23 @@ function reporting_simple_graph(
'module_description' => $module_description,
];
// Apply macros
$title = (isset($content['name'])) ? $content['name'] : '';
if ($title != '') {
$title = reporting_label_macro(
$items_label,
$title
);
}
$description = (isset($content['description'])) ? $content['description'] : '';
if ($description != '') {
$description = reporting_label_macro(
$items_label,
$description
);
}
$label = (isset($content['style']['label'])) ? $content['style']['label'] : '';
if ($label != '') {
$label = reporting_label_macro(
@ -8487,14 +9055,14 @@ function reporting_simple_graph(
);
}
$return['title'] = io_safe_output($content['name']);
$return['title'] = $title;
$return['landscape'] = $content['landscape'];
$return['pagebreak'] = $content['pagebreak'];
$return['subtitle'] = $agent_alias.' - '.$module_name;
$return['agent_name_db'] = agents_get_name($id_agent);
$return['agent_name'] = $agent_alias;
$return['module_name'] = $module_name;
$return['description'] = io_safe_output($content['description']);
$return['description'] = $description;
$return['date'] = reporting_get_date_text(
$report,
$content
@ -12976,11 +13544,57 @@ function reporting_module_histogram_graph($report, $content, $pdf=0)
)
);
$return['title'] = $content['name'];
$id_agent = agents_get_module_id(
$content['id_agent_module']
);
$id_agent_module = $content['id_agent_module'];
$agent_description = agents_get_description($id_agent);
$agent_group = agents_get_agent_group($id_agent);
$agent_address = agents_get_address($id_agent);
$agent_alias = agents_get_alias($id_agent);
$module_name = modules_get_agentmodule_name(
$id_agent_module
);
$module_description = modules_get_agentmodule_descripcion(
$id_agent_module
);
$items_label = [
'type' => $return['type'],
'id_agent' => $id_agent,
'id_agent_module' => $id_agent_module,
'agent_description' => $agent_description,
'agent_group' => $agent_group,
'agent_address' => $agent_address,
'agent_alias' => $agent_alias,
'module_name' => $module_name,
'module_description' => $module_description,
];
// Apply macros
$title = (isset($content['name'])) ? $content['name'] : '';
if ($title != '') {
$title = reporting_label_macro(
$items_label,
$title
);
}
$description = (isset($content['description'])) ? $content['description'] : '';
if ($description != '') {
$description = reporting_label_macro(
$items_label,
$description
);
}
$return['title'] = $title;
$return['landscape'] = $content['landscape'];
$return['pagebreak'] = $content['pagebreak'];
$return['subtitle'] = $agent_name.' - '.$module_name;
$return['description'] = $content['description'];
$return['description'] = $description;
$return['date'] = reporting_get_date_text(
$report,
$content

View File

@ -236,6 +236,10 @@ function reporting_html_print_report($report, $mini=false, $report_info=1)
reporting_html_log($table, $item);
break;
case 'permissions_report':
reporting_html_permissions($table, $item);
break;
case 'availability_graph':
reporting_html_availability_graph($table, $item);
break;
@ -5649,3 +5653,117 @@ function reporting_html_planned_downtimes_table($planned_downtimes)
return $downtimes_table;
}
function reporting_html_permissions($table, $item, $pdf=0)
{
global $config;
$table1 = new stdClass();
$table1->width = '100%';
$table1->style[0] = 'text-align: left;vertical-align: top;min-width: 100px;';
$table1->class = 'databox data';
$table1->cellpadding = 1;
$table1->cellspacing = 1;
$table1->styleTable = 'overflow: wrap; table-layout: fixed;';
if ($item['subtype'] === REPORT_PERMISSIONS_NOT_GROUP_BY_GROUP) {
$table1->style[0] = 'text-align: left;vertical-align: top;min-width: 100px;';
$table1->style[1] = 'text-align: left;vertical-align: top;min-width: 100px;';
$table1->style[2] = 'text-align: left;vertical-align: top; min-width: 100px';
$table1->head = [
__('User ID'),
__('Full name'),
__('Permissions'),
];
$table1->headstyle[0] = 'text-align: left';
$table1->headstyle[1] = 'text-align: left';
$table1->headstyle[2] = 'text-align: left';
}
if ($item['subtype'] === REPORT_PERMISSIONS_GROUP_BY_GROUP) {
$table1->style[0] = 'text-align: left;vertical-align: top;min-width: 150px;';
$table1->style[1] = 'text-align: left;vertical-align: top;min-width: 150px;';
$table1->style[2] = 'text-align: left;vertical-align: top;min-width: 150px;';
$table1->style[3] = 'text-align: left;vertical-align: top;min-width: 150px;';
$table1->headstyle[0] = 'text-align: left';
$table1->headstyle[1] = 'text-align: left';
$table1->headstyle[2] = 'text-align: left';
$table1->headstyle[3] = 'text-align: left';
$table1->head = [
__('Group'),
__('User ID'),
__('Full name'),
__('Permissions'),
];
}
$table1->data = [];
foreach ($item['data'] as $data) {
if ($item['subtype'] === REPORT_PERMISSIONS_NOT_GROUP_BY_GROUP) {
$profile_group_name = '';
foreach ($data['user_profiles'] as $user_profile) {
$profile_group_name .= $user_profile.'<br />';
}
$row = [
$data['user_id'],
$data['user_name'],
$profile_group_name,
];
}
if ($item['subtype'] === REPORT_PERMISSIONS_GROUP_BY_GROUP) {
$user_profile_id_users = '';
$user_profile_name = '';
$user_profile_users_name = '';
$group_name = $data['group_name'].'<br />';
foreach ($data['users'] as $user => $user_data) {
$user_profile_id_users .= $user.'<br />';
$user_profile_users_name .= $user_data['fullname'].'<br />';
foreach ($user_data['profiles'] as $profile) {
$user_profile_id_users .= '<br />';
$user_profile_users_name .= '<br />';
$user_profile_name .= $profile.'<br />';
}
$user_profile_name .= '<br />';
}
$row = [
$group_name,
$user_profile_id_users,
$user_profile_users_name,
$user_profile_name,
];
}
$table1->data[] = $row;
if ($pdf !== 0) {
$table1->data[] = '<br />';
}
}
if ($pdf === 0) {
$table->colspan['permissions']['cell'] = 3;
$table->cellstyle['permissions']['cell'] = 'text-align: center;';
$table->data['permissions']['cell'] = html_print_table(
$table1,
true
);
} else {
return html_print_table(
$table1,
true
);
}
}

View File

@ -54,7 +54,7 @@ function reports_get_report($id_report, $filter=false, $fields=false)
return false;
}
if (! is_array($filter)) {
if (!is_array($filter)) {
$filter = [];
}
@ -72,7 +72,7 @@ function reports_get_report($id_report, $filter=false, $fields=false)
$report = db_get_row_filter('treport', $filter, $fields);
if (! check_acl($config['id_user'], $report['id_group'], 'RR')) {
if (!check_acl($config['id_user'], $report['id_group'], 'RR')) {
return false;
}
@ -104,16 +104,16 @@ function reports_get_reports(
) {
global $config;
if (! is_array($filter)) {
if (!is_array($filter)) {
$filter = [];
}
/*
if (!is_user_admin ($config["id_user"]))
/*
if (!is_user_admin ($config["id_user"]))
$filter[] = sprintf ('private = 0 OR (private = 1 AND id_user = "%s")',
$config['id_user']);
*/
$filter['hidden'] = 0;
*/
$filter['hidden'] = 0;
if (is_array($fields)) {
$fields[] = 'id_group';
$fields[] = 'id_user';
@ -146,7 +146,7 @@ function reports_get_reports(
}
if ($config['id_user'] != $report['id_user']
&& ! check_acl($config['id_user'], $report['id_group'], $privileges)
&& !check_acl($config['id_user'], $report['id_group'], $privileges)
) {
continue;
}
@ -173,7 +173,7 @@ function reports_create_report($name, $id_group, $values=false)
{
global $config;
if (! is_array($values)) {
if (!is_array($values)) {
$values = [];
}
@ -246,7 +246,7 @@ function reports_get_content($id_report_content, $filter=false, $fields=false)
return false;
}
if (! is_array($filter)) {
if (!is_array($filter)) {
$filter = [];
}
@ -293,7 +293,7 @@ function reports_create_content($id_report, $values)
return false;
}
if (! is_array($values)) {
if (!is_array($values)) {
return false;
}
@ -341,7 +341,7 @@ function reports_get_contents($id_report, $filter=false, $fields=false)
return [];
}
if (! is_array($filter)) {
if (!is_array($filter)) {
$filter = [];
}
@ -546,7 +546,7 @@ function reports_delete_content($id_report_content)
function get_report_name($type, $template=false)
{
$types = reports_get_report_types($template);
if (! isset($types[$type])) {
if (!isset($types[$type])) {
return __('Unknown');
}
@ -890,5 +890,10 @@ function reports_get_report_types($template=false, $not_editor=false)
];
}
$types['permissions_report'] = [
'optgroup' => __('Permissions report'),
'name' => __('Permissions report'),
];
return $types;
}

View File

@ -86,6 +86,7 @@ function snmp_browser_get_html_tree(
$count = 0;
$total = (count(array_keys($tree['__LEAVES__'])) - 1);
$last_array[$depth] = $last;
$class = 'item_'.$depth;
if ($depth > 0) {
$output .= '<ul id="ul_'.$id.'" style="margin: 0; padding: 0; display: none;">';
@ -97,7 +98,7 @@ function snmp_browser_get_html_tree(
// Id used to expand leafs.
$sub_id = time().rand(0, getrandmax());
// Display the branch.
$output .= '<li id="li_'.$sub_id.'" style="margin: 0; padding: 0;">';
$output .= '<li id="li_'.$sub_id.'" class="'.$class.'" style="margin: 0; padding: 0;">';
// Indent sub branches.
for ($i = 1; $i <= $depth; $i++) {
@ -669,18 +670,29 @@ function snmp_browser_print_oid(
/**
* Print the div that contains the SNMP browser.
* Print browser container.
*
* @param bool return The result is printed if set to true or returned if set to false.
* @param string width Width of the SNMP browser. Units must be specified.
* @param string height Height of the SNMP browser. Units must be specified.
* @param string display CSS display value for the container div. Set to none to hide the div.
* @param boolean $return The result is printed
* if set to true or returned if set to false.
* @param string $width Width of the SNMP browser.
* Units must be specified.
* @param string $height Height of the SNMP browser.
* Units must be specified.
* @param string $display CSS display value for the
* container div. Set to none to hide the div.
* @param boolean $show_massive_buttons Massive buttons.
*
* @return string The container div.
* @return string html.
*/
function snmp_browser_print_container($return=false, $width='100%', $height='60%', $display='', $show_massive_buttons=false)
{
// Target selection
function snmp_browser_print_container(
$return=false,
$width='100%',
$height='60%',
$display='',
$show_massive_buttons=false
) {
$snmp_version = get_parameter('snmp_browser_version', '2c');
// Target selection.
$table = new stdClass();
$table->width = '100%';
$table->class = 'databox filters';
@ -754,12 +766,36 @@ function snmp_browser_print_container($return=false, $width='100%', $height='60%
}
}
$table->data[1][1] = '<strong>'.__('Server to execute').'</strong> &nbsp;&nbsp;';
$table->data[1][1] .= html_print_select($servers_to_exec, 'server_to_exec', '', '', '', '', true);
$table->data[1][1] = '<strong>';
$table->data[1][1] .= __('Server to execute');
$table->data[1][1] .= '</strong> &nbsp;&nbsp;';
$table->data[1][1] .= html_print_select(
$servers_to_exec,
'server_to_exec',
'',
'',
'',
'',
true
);
$table->data[1][2] = html_print_button(__('Browse'), 'browse', false, 'snmpBrowse()', 'class="sub search" style="margin-top:0px;"', true);
$table->data[1][2] = html_print_button(
__('Browse'),
'browse',
false,
'snmpBrowse()',
'class="sub search" style="margin-top:0px;"',
true
);
// SNMP v3 options.
$snmp3_auth_user = get_parameter('snmp3_auth_user', '');
$snmp3_security_level = get_parameter('snmp3_security_level', 'authNoPriv');
$snmp3_auth_method = get_parameter('snmp3_auth_method', 'MD5');
$snmp3_auth_pass = get_parameter('snmp3_auth_pass', '');
$snmp3_privacy_method = get_parameter('snmp3_privacy_method', 'AES');
$snmp3_privacy_pass = get_parameter('snmp3_privacy_pass', '');
// SNMP v3 options
$table3 = new stdClass();
$table3->width = '100%';
@ -767,18 +803,69 @@ function snmp_browser_print_container($return=false, $width='100%', $height='60%
$table3->valign[1] = '';
$table3->data[2][1] = '<b>'.__('Auth user').'</b>';
$table3->data[2][2] = html_print_input_text('snmp3_browser_auth_user', '', '', 15, 60, true);
$table3->data[2][2] = html_print_input_text(
'snmp3_browser_auth_user',
$snmp3_auth_user,
'',
15,
60,
true
);
$table3->data[2][3] = '<b>'.__('Auth password').'</b>';
$table3->data[2][4] = html_print_input_password('snmp3_browser_auth_pass', '', '', 15, 60, true);
$table3->data[2][4] .= html_print_input_hidden_extended('active_snmp_v3', 0, 'active_snmp_v3_fsb', true);
$table3->data[2][4] = html_print_input_password(
'snmp3_browser_auth_pass',
$snmp3_auth_pass,
'',
15,
60,
true
);
$table3->data[2][4] .= html_print_input_hidden_extended(
'active_snmp_v3',
0,
'active_snmp_v3_fsb',
true
);
$table3->data[5][0] = '<b>'.__('Privacy method').'</b>';
$table3->data[5][1] = html_print_select(['DES' => __('DES'), 'AES' => __('AES')], 'snmp3_browser_privacy_method', '', '', '', '', true);
$table3->data[5][1] = html_print_select(
[
'DES' => __('DES'),
'AES' => __('AES'),
],
'snmp3_browser_privacy_method',
$snmp3_privacy_method,
'',
'',
'',
true
);
$table3->data[5][2] = '<b>'.__('Privacy pass').'</b>';
$table3->data[5][3] = html_print_input_password('snmp3_browser_privacy_pass', '', '', 15, 60, true);
$table3->data[5][3] = html_print_input_password(
'snmp3_browser_privacy_pass',
$snmp3_privacy_pass,
'',
15,
60,
true
);
$table3->data[6][0] = '<b>'.__('Auth method').'</b>';
$table3->data[6][1] = html_print_select(['MD5' => __('MD5'), 'SHA' => __('SHA')], 'snmp3_browser_auth_method', '', '', '', '', true);
$table3->data[6][1] = html_print_select(
[
'MD5' => __('MD5'),
'SHA' => __('SHA'),
],
'snmp3_browser_auth_method',
$snmp3_auth_method,
'',
'',
'',
true
);
$table3->data[6][2] = '<b>'.__('Security level').'</b>';
$table3->data[6][3] = html_print_select(
[
@ -787,29 +874,92 @@ function snmp_browser_print_container($return=false, $width='100%', $height='60%
'authPriv' => __('Auth and privacy method'),
],
'snmp3_browser_security_level',
'',
$snmp3_security_level,
'',
'',
'',
true
);
// Search tools
// Search tools.
$table2 = new stdClass();
$table2->width = '100%';
$table2->class = 'databox filters';
$table2->size = [];
$table2->data = [];
$table2->data[0][0] = html_print_input_text('search_text', '', '', 25, 0, true);
$table2->data[0][0] .= '<a href="javascript:">'.html_print_image('images/zoom.png', true, ['title' => __('Search'), 'style' => 'vertical-align: middle;', 'onclick' => 'searchText();']).'</a>';
$table2->data[0][1] = '&nbsp;'.'<a href="javascript:">'.html_print_image('images/go_first.png', true, ['title' => __('First match'), 'style' => 'vertical-align: middle;', 'onclick' => 'searchFirstMatch();']).'</a>';
$table2->data[0][1] .= '&nbsp;'.'<a href="javascript:">'.html_print_image('images/go_previous.png', true, ['title' => __('Previous match'), 'style' => 'vertical-align: middle;', 'onclick' => 'searchPrevMatch();']).'</a>';
$table2->data[0][1] .= '&nbsp;'.'<a href="javascript:">'.html_print_image('images/go_next.png', true, ['title' => __('Next match'), 'style' => 'vertical-align: middle;', 'onclick' => 'searchNextMatch();']).'</a>';
$table2->data[0][1] .= '&nbsp;'.'<a href="javascript:">'.html_print_image('images/go_last.png', true, ['title' => __('Last match'), 'style' => 'vertical-align: middle;', 'onclick' => 'searchLastMatch();']).'</a>';
$table2->data[0][0] = html_print_input_text(
'search_text',
'',
'',
25,
0,
true
);
$table2->data[0][0] .= '<a href="javascript:">';
$table2->data[0][0] .= html_print_image(
'images/zoom.png',
true,
[
'title' => __('Search'),
'style' => 'vertical-align: middle;',
'onclick' => 'searchText();',
]
);
$table2->data[0][0] .= '</a>';
$table2->data[0][1] = '&nbsp;';
$table2->data[0][1] .= '<a href="javascript:">';
$table2->data[0][1] .= html_print_image(
'images/go_first.png',
true,
[
'title' => __('First match'),
'style' => 'vertical-align: middle;',
'onclick' => 'searchFirstMatch();',
]
);
$table2->data[0][1] .= '</a>';
$table2->data[0][1] .= '&nbsp;';
$table2->data[0][1] .= '<a href="javascript:">';
$table2->data[0][1] .= html_print_image(
'images/go_previous.png',
true,
[
'title' => __('Previous match'),
'style' => 'vertical-align: middle;',
'onclick' => 'searchPrevMatch();',
]
);
$table2->data[0][1] .= '</a>';
$table2->data[0][1] .= '&nbsp;';
$table2->data[0][1] .= '<a href="javascript:">';
$table2->data[0][1] .= html_print_image(
'images/go_next.png',
true,
[
'title' => __('Next match'),
'style' => 'vertical-align: middle;',
'onclick' => 'searchNextMatch();',
]
);
$table2->data[0][1] .= '</a>';
$table2->data[0][1] .= '&nbsp;';
$table2->data[0][1] .= '<a href="javascript:">';
$table2->data[0][1] .= html_print_image(
'images/go_last.png',
true,
[
'title' => __('Last match'),
'style' => 'vertical-align: middle;',
'onclick' => 'searchLastMatch();',
]
);
$table2->data[0][1] .= '</a>';
$table2->cellstyle[0][1] = 'text-align:center;';
$table2->data[0][2] = '&nbsp;'.'<a href="javascript:">'.html_print_image(
$table2->data[0][2] = '&nbsp;';
$table2->data[0][2] .= '<a href="javascript:">'.html_print_image(
'images/expand.png',
true,
[
@ -817,8 +967,20 @@ function snmp_browser_print_container($return=false, $width='100%', $height='60%
'style' => 'vertical-align: middle;',
'onclick' => 'expandAll();',
]
).'</a>';
$table2->data[0][2] .= '&nbsp;'.'<a href="javascript:">'.html_print_image('images/collapse.png', true, ['title' => __('Collapse the tree'), 'style' => 'vertical-align: middle;', 'onclick' => 'collapseAll();']).'</a>';
);
$table2->data[0][2] .= '</a>';
$table2->data[0][2] .= '&nbsp;';
$table2->data[0][2] .= '<a href="javascript:">';
$table2->data[0][2] .= html_print_image(
'images/collapse.png',
true,
[
'title' => __('Collapse the tree'),
'style' => 'vertical-align: middle;',
'onclick' => 'collapseAll();',
]
);
$table2->data[0][2] .= '</a>';
$table2->cellstyle[0][2] = 'text-align:center;';
// This extra div that can be handled by jquery's dialog.
@ -828,7 +990,7 @@ function snmp_browser_print_container($return=false, $width='100%', $height='60%
$output .= html_print_table($table, true);
$output .= '</div>';
if (!isset($snmp_version)) {
if (isset($snmp_version) === false) {
$snmp_version = null;
}
@ -838,40 +1000,61 @@ function snmp_browser_print_container($return=false, $width='100%', $height='60%
$output .= '<div id="snmp3_browser_options" style="display: none;">';
}
$output .= ui_toggle(html_print_table($table3, true), __('SNMP v3 options'), '', '', true, true);
$output .= ui_toggle(
html_print_table($table3, true),
__('SNMP v3 options'),
'',
'',
true,
true
);
$output .= '</div>';
$output .= '<div style="width: 100%; padding-top: 10px;">';
$output .= ui_toggle(html_print_table($table2, true), __('Search options'), '', '', true, true);
$output .= ui_toggle(
html_print_table($table2, true),
__('Search options'),
'',
'',
true,
true
);
$output .= '</div>';
// SNMP tree container
// SNMP tree container.
$output .= '<div style="width: 100%; height: 100%; margin-top: 5px; position: relative;">';
$output .= html_print_input_hidden('search_count', 0, true);
$output .= html_print_input_hidden('search_index', -1, true);
// Save some variables for javascript functions
$output .= html_print_input_hidden('ajax_url', ui_get_full_url('ajax.php'), true);
$output .= html_print_input_hidden('search_matches_translation', __('Search matches'), true);
// Save some variables for javascript functions.
$output .= html_print_input_hidden(
'ajax_url',
ui_get_full_url('ajax.php'),
true
);
$output .= html_print_input_hidden(
'search_matches_translation',
__('Search matches'),
true
);
$output .= '<div id="search_results" style="display: none; padding: 5px; background-color: #EAEAEA; border: 1px solid #E2E2E2; border-radius: 4px;"></div>';
$output .= '<div id="spinner" style="position: absolute; top:0; left:0px; display:none; padding: 5px;">'.html_print_image('images/spinner.gif', true).'</div>';
$output .= '<div id="snmp_browser">';
$output .= '</div>';
$output .= '<div class="databox" id="snmp_data" style="margin: 5px; display: none"></div>';
$output .= '<div class="databox" id="snmp_data" style="margin: 5px; display: none"></div>';
$output .= '</div>';
$output .= '</div>';
$output .= '</div>';
if ($show_massive_buttons) {
$output .= '<div id="snmp_create_buttons" style="display:none">';
$output .= html_print_submit_button(
__('Create agent modules'),
'create_modules_agent',
false,
['class' => 'sub add'],
true
);
$output .= html_print_submit_button(
__('Create agent modules'),
'create_modules_agent',
false,
['class' => 'sub add'],
true
);
if (enterprise_installed()) {
$output .= html_print_submit_button(
@ -883,15 +1066,15 @@ function snmp_browser_print_container($return=false, $width='100%', $height='60%
);
}
$output .= html_print_submit_button(
__('Create network components'),
'create_modules_network_component',
false,
['class' => 'sub add'],
true
);
$output .= html_print_submit_button(
__('Create network components'),
'create_modules_network_component',
false,
['class' => 'sub add'],
true
);
$output .= '</div>';
$output .= '</div>';
}
if ($return) {

View File

@ -5617,7 +5617,8 @@ function ui_print_module_string_value(
$value,
$id_agente_module,
$current_interval,
$module_name=null
$module_name=null,
$server_id=0
) {
global $config;
@ -5662,6 +5663,7 @@ function ui_print_module_string_value(
'last_data' => $value,
'interval' => $current_interval,
'module_name' => $module_name,
'id_node' => $server_id ? $server_id : 0,
]
);
$salida = ui_get_snapshot_image($link, $is_snapshot).'&nbsp;&nbsp;';
@ -5769,7 +5771,7 @@ function ui_get_snapshot_link($params, $only_params=false)
$params = array_merge($default_params, $params);
// First parameter of js winopeng_var.
$page = $config['homeurl'].'/operation/agentes/snapshot_view.php';
$page = ui_get_full_url('operation/agentes/snapshot_view.php', false, false, false);
$url = $page.'?id='.$params['id_module'].'&label='.rawurlencode(urlencode(io_safe_output($params['module_name']))).'&id_node='.$params['id_node'];
@ -6134,6 +6136,105 @@ function ui_print_message_dialog($title, $text, $id='', $img='', $text_button=''
}
/**
* Build a Query-Result editor structure
*
* @param string $name Name of the structure
*
* @return null
*/
function ui_query_result_editor($name='default')
{
$editorSubContainer = html_print_div(
[
'id' => $name.'_editor_title',
'content' => '<p>'.__('Query').'</p>',
],
true
);
$editorSubContainer .= html_print_div(
[
'id' => $name.'_editor',
'class' => 'query_result_editor',
],
true
);
$editorSubContainer .= html_print_div(
[
'class' => 'action-buttons edit-button',
'content' => html_print_submit_button(
__('Execute query'),
'execute_query',
false,
'class="sub next"',
true
),
],
true
);
$editorContainer = html_print_div(
[
'id' => $name.'_editor_container',
'class' => 'query_result_editor_container',
'content' => $editorSubContainer,
],
true
);
$viewSubContainer = html_print_div(
[
'id' => $name.'_view_title',
'content' => '<p>'.__('Results').'</p>',
],
true
);
$viewSubContainer .= html_print_div(
[
'id' => $name.'_view',
'class' => 'query_result_view',
],
true
);
$viewSubContainer .= html_print_div(
[
'class' => 'action-buttons',
'content' => '',
],
true
);
$viewContainer = html_print_div(
[
'id' => $name.'_view_container',
'class' => 'query_result_view_container',
'content' => $viewSubContainer,
],
true
);
html_print_div(
[
'id' => 'query_result_container',
'class' => 'databox',
'content' => $editorContainer.$viewContainer,
]
);
// This is needed for Javascript
html_print_div(
[
'id' => 'pandora_full_url',
'hidden' => true,
'content' => ui_get_full_url(false, false, false, false),
]
);
}
/**
* Generate a button for reveal the content of the password field.
*

View File

@ -616,7 +616,8 @@ function users_get_user_users(
$id_user=false,
$privilege='AR',
$returnAllGroup=true,
$fields=null
$fields=null,
$filter_group=[]
) {
global $config;
@ -625,8 +626,12 @@ function users_get_user_users(
$user_users = [];
$array_user_group = [];
foreach ($user_groups as $id_user_group => $name_user_group) {
$array_user_group[] = $id_user_group;
if (empty($filter_group)) {
foreach ($user_groups as $id_user_group => $name_user_group) {
$array_user_group[] = $id_user_group;
}
} else {
$array_user_group = $filter_group;
}
$group_users = groups_get_users($array_user_group, false, $returnAllGroup);
@ -747,6 +752,11 @@ function users_get_groups_UM($id_user)
foreach ($groups as $key => $group) {
if (!isset($return[$group['id_grupo']]) || (isset($return[$group['id_grupo']]) && $group['user_management'] != 0)) {
$return[$group['id_grupo']] = $group['user_management'];
$children = groups_get_children($group['id_grupo'], false, 'UM', false);
foreach ($children as $key => $child_group) {
$return[$child_group['id_grupo']] = $group['user_management'];
}
if ($group['id_grupo'] == '0') {
$return['group_all'] = $group['id_grupo'];
}
@ -831,3 +841,25 @@ function users_get_user_profile($id_user)
return $user_profiles;
}
/**
* Obtiene una matriz con la informacion de cada usuario que pertenece a un grupo
*
* @param string User id
* @return array Return .
*/
function users_get_users_group_by_group($id_group)
{
$sql = sprintf(
"SELECT tusuario.* FROM tusuario
LEFT JOIN tusuario_perfil ON tusuario_perfil.id_usuario = tusuario.id_user
AND tusuario_perfil.id_grupo = '%s'
GROUP BY tusuario_perfil.id_usuario",
$id_group
);
$users = db_get_all_rows_sql($sql);
return $users;
}

View File

@ -15,6 +15,7 @@
// This file only uses data retrieved in a request.
require_once '../../include/config.php';
require_once '../../include/functions.php';
enterprise_include_once('include/functions_reporting_csv.php');
global $config;
@ -49,7 +50,10 @@ $filename = io_safe_output($filename);
* );
*/
$output_csv = function ($data, $filename) {
$separator = (string) get_parameter('separator', ';');
global $config;
$separator = (string) $config['csv_divider'];
$excel_encoding = (bool) get_parameter('excel_encoding', false);
// CSV Output
@ -68,9 +72,15 @@ $output_csv = function ($data, $filename) {
throw new Exception(__('An error occured exporting the data'));
}
// Get key for item value.
$value_key = array_search('value', $items['head']);
$head_line = implode($separator, $items['head']);
echo $head_line."\n";
foreach ($items['data'] as $item) {
// Find value and replace csv decimal separator.
$item[$value_key] = csv_format_numeric($item[$value_key]);
$item = str_replace('--> '.__('Selected'), '', $item);
$line = implode($separator, $item);

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,396 @@
ace.define(
"ace/mode/json_highlight_rules",
[
"require",
"exports",
"module",
"ace/lib/oop",
"ace/mode/text_highlight_rules"
],
function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var TextHighlightRules = require("./text_highlight_rules")
.TextHighlightRules;
var JsonHighlightRules = function() {
this.$rules = {
start: [
{
token: "variable", // single line
regex: '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]\\s*(?=:)'
},
{
token: "string", // single line
regex: '"',
next: "string"
},
{
token: "constant.numeric", // hex
regex: "0[xX][0-9a-fA-F]+\\b"
},
{
token: "constant.numeric", // float
regex: "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
},
{
token: "constant.language.boolean",
regex: "(?:true|false)\\b"
},
{
token: "text", // single quoted strings are not allowed
regex: "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
},
{
token: "comment", // comments are not allowed, but who cares?
regex: "\\/\\/.*$"
},
{
token: "comment.start", // comments are not allowed, but who cares?
regex: "\\/\\*",
next: "comment"
},
{
token: "paren.lparen",
regex: "[[({]"
},
{
token: "paren.rparen",
regex: "[\\])}]"
},
{
token: "text",
regex: "\\s+"
}
],
string: [
{
token: "constant.language.escape",
regex: /\\(?:x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|["\\\/bfnrt])/
},
{
token: "string",
regex: '"|$',
next: "start"
},
{
defaultToken: "string"
}
],
comment: [
{
token: "comment.end", // comments are not allowed, but who cares?
regex: "\\*\\/",
next: "start"
},
{
defaultToken: "comment"
}
]
};
};
oop.inherits(JsonHighlightRules, TextHighlightRules);
exports.JsonHighlightRules = JsonHighlightRules;
}
);
ace.define(
"ace/mode/matching_brace_outdent",
["require", "exports", "module", "ace/range"],
function(require, exports, module) {
"use strict";
var Range = require("../range").Range;
var MatchingBraceOutdent = function() {};
(function() {
this.checkOutdent = function(line, input) {
if (!/^\s+$/.test(line)) return false;
return /^\s*\}/.test(input);
};
this.autoOutdent = function(doc, row) {
var line = doc.getLine(row);
var match = line.match(/^(\s*\})/);
if (!match) return 0;
var column = match[1].length;
var openBracePos = doc.findMatchingBracket({
row: row,
column: column
});
if (!openBracePos || openBracePos.row == row) return 0;
var indent = this.$getIndent(doc.getLine(openBracePos.row));
doc.replace(new Range(row, 0, row, column - 1), indent);
};
this.$getIndent = function(line) {
return line.match(/^\s*/)[0];
};
}.call(MatchingBraceOutdent.prototype));
exports.MatchingBraceOutdent = MatchingBraceOutdent;
}
);
ace.define(
"ace/mode/folding/cstyle",
[
"require",
"exports",
"module",
"ace/lib/oop",
"ace/range",
"ace/mode/folding/fold_mode"
],
function(require, exports, module) {
"use strict";
var oop = require("../../lib/oop");
var Range = require("../../range").Range;
var BaseFoldMode = require("./fold_mode").FoldMode;
var FoldMode = (exports.FoldMode = function(commentRegex) {
if (commentRegex) {
this.foldingStartMarker = new RegExp(
this.foldingStartMarker.source.replace(
/\|[^|]*?$/,
"|" + commentRegex.start
)
);
this.foldingStopMarker = new RegExp(
this.foldingStopMarker.source.replace(
/\|[^|]*?$/,
"|" + commentRegex.end
)
);
}
});
oop.inherits(FoldMode, BaseFoldMode);
(function() {
this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/;
this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
this._getFoldWidgetBase = this.getFoldWidget;
this.getFoldWidget = function(session, foldStyle, row) {
var line = session.getLine(row);
if (this.singleLineBlockCommentRe.test(line)) {
if (
!this.startRegionRe.test(line) &&
!this.tripleStarBlockCommentRe.test(line)
)
return "";
}
var fw = this._getFoldWidgetBase(session, foldStyle, row);
if (!fw && this.startRegionRe.test(line)) return "start"; // lineCommentRegionStart
return fw;
};
this.getFoldWidgetRange = function(
session,
foldStyle,
row,
forceMultiline
) {
var line = session.getLine(row);
if (this.startRegionRe.test(line))
return this.getCommentRegionBlock(session, line, row);
var match = line.match(this.foldingStartMarker);
if (match) {
var i = match.index;
if (match[1])
return this.openingBracketBlock(session, match[1], row, i);
var range = session.getCommentFoldRange(row, i + match[0].length, 1);
if (range && !range.isMultiLine()) {
if (forceMultiline) {
range = this.getSectionRange(session, row);
} else if (foldStyle != "all") range = null;
}
return range;
}
if (foldStyle === "markbegin") return;
var match = line.match(this.foldingStopMarker);
if (match) {
var i = match.index + match[0].length;
if (match[1])
return this.closingBracketBlock(session, match[1], row, i);
return session.getCommentFoldRange(row, i, -1);
}
};
this.getSectionRange = function(session, row) {
var line = session.getLine(row);
var startIndent = line.search(/\S/);
var startRow = row;
var startColumn = line.length;
row = row + 1;
var endRow = row;
var maxRow = session.getLength();
while (++row < maxRow) {
line = session.getLine(row);
var indent = line.search(/\S/);
if (indent === -1) continue;
if (startIndent > indent) break;
var subRange = this.getFoldWidgetRange(session, "all", row);
if (subRange) {
if (subRange.start.row <= startRow) {
break;
} else if (subRange.isMultiLine()) {
row = subRange.end.row;
} else if (startIndent == indent) {
break;
}
}
endRow = row;
}
return new Range(
startRow,
startColumn,
endRow,
session.getLine(endRow).length
);
};
this.getCommentRegionBlock = function(session, line, row) {
var startColumn = line.search(/\s*$/);
var maxRow = session.getLength();
var startRow = row;
var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
var depth = 1;
while (++row < maxRow) {
line = session.getLine(row);
var m = re.exec(line);
if (!m) continue;
if (m[1]) depth--;
else depth++;
if (!depth) break;
}
var endRow = row;
if (endRow > startRow) {
return new Range(startRow, startColumn, endRow, line.length);
}
};
}.call(FoldMode.prototype));
}
);
ace.define(
"ace/mode/json",
[
"require",
"exports",
"module",
"ace/lib/oop",
"ace/mode/text",
"ace/mode/json_highlight_rules",
"ace/mode/matching_brace_outdent",
"ace/mode/behaviour/cstyle",
"ace/mode/folding/cstyle",
"ace/worker/worker_client"
],
function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var TextMode = require("./text").Mode;
var HighlightRules = require("./json_highlight_rules").JsonHighlightRules;
var MatchingBraceOutdent = require("./matching_brace_outdent")
.MatchingBraceOutdent;
var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
var WorkerClient = require("../worker/worker_client").WorkerClient;
var Mode = function() {
this.HighlightRules = HighlightRules;
this.$outdent = new MatchingBraceOutdent();
this.$behaviour = new CstyleBehaviour();
this.foldingRules = new CStyleFoldMode();
};
oop.inherits(Mode, TextMode);
(function() {
this.lineCommentStart = "//";
this.blockComment = { start: "/*", end: "*/" };
this.getNextLineIndent = function(state, line, tab) {
var indent = this.$getIndent(line);
if (state == "start") {
var match = line.match(/^.*[\{\(\[]\s*$/);
if (match) {
indent += tab;
}
}
return indent;
};
this.checkOutdent = function(state, line, input) {
return this.$outdent.checkOutdent(line, input);
};
this.autoOutdent = function(state, doc, row) {
this.$outdent.autoOutdent(doc, row);
};
this.createWorker = function(session) {
var worker = new WorkerClient(
["ace"],
"ace/mode/json_worker",
"JsonWorker"
);
worker.attachToDocument(session.getDocument());
worker.on("annotate", function(e) {
session.setAnnotations(e.data);
});
worker.on("terminate", function() {
session.clearAnnotations();
});
return worker;
};
this.$id = "ace/mode/json";
}.call(Mode.prototype));
exports.Mode = Mode;
}
);
(function() {
ace.require(["ace/mode/json"], function(m) {
if (typeof module == "object" && typeof exports == "object" && module) {
module.exports = m;
}
});
})();

View File

@ -0,0 +1,154 @@
.ace-tm .ace_gutter {
background: #f0f0f0;
color: #333;
}
.ace-tm .ace_print-margin {
width: 1px;
background: #e8e8e8;
}
.ace-tm .ace_fold {
background-color: #6b72e6;
}
.ace-tm {
background-color: #ffffff;
color: black;
}
.ace-tm .ace_cursor {
color: black;
}
.ace-tm .ace_invisible {
color: rgb(191, 191, 191);
}
.ace-tm .ace_storage,
.ace-tm .ace_keyword {
color: blue;
}
.ace-tm .ace_constant {
color: rgb(197, 6, 11);
}
.ace-tm .ace_constant.ace_buildin {
color: rgb(88, 72, 246);
}
.ace-tm .ace_constant.ace_language {
color: rgb(88, 92, 246);
}
.ace-tm .ace_constant.ace_library {
color: rgb(6, 150, 14);
}
.ace-tm .ace_invalid {
background-color: rgba(255, 0, 0, 0.1);
color: red;
}
.ace-tm .ace_support.ace_function {
color: rgb(60, 76, 114);
}
.ace-tm .ace_support.ace_constant {
color: rgb(6, 150, 14);
}
.ace-tm .ace_support.ace_type,
.ace-tm .ace_support.ace_class {
color: rgb(109, 121, 222);
}
.ace-tm .ace_keyword.ace_operator {
color: rgb(104, 118, 135);
}
.ace-tm .ace_string {
color: rgb(3, 106, 7);
}
.ace-tm .ace_comment {
color: rgb(76, 136, 107);
}
.ace-tm .ace_comment.ace_doc {
color: rgb(0, 102, 255);
}
.ace-tm .ace_comment.ace_doc.ace_tag {
color: rgb(128, 159, 191);
}
.ace-tm .ace_constant.ace_numeric {
color: rgb(0, 0, 205);
}
.ace-tm .ace_variable {
color: rgb(49, 132, 149);
}
.ace-tm .ace_xml-pe {
color: rgb(104, 104, 91);
}
.ace-tm .ace_entity.ace_name.ace_function {
color: #0000a2;
}
.ace-tm .ace_heading {
color: rgb(12, 7, 255);
}
.ace-tm .ace_list {
color: rgb(185, 6, 144);
}
.ace-tm .ace_meta.ace_tag {
color: rgb(0, 22, 142);
}
.ace-tm .ace_string.ace_regex {
color: rgb(255, 0, 0);
}
.ace-tm .ace_marker-layer .ace_selection {
background: rgb(181, 213, 255);
}
.ace-tm.ace_multiselect .ace_selection.ace_start {
box-shadow: 0 0 3px 0px white;
}
.ace-tm .ace_marker-layer .ace_step {
background: rgb(252, 255, 0);
}
.ace-tm .ace_marker-layer .ace_stack {
background: rgb(164, 229, 101);
}
.ace-tm .ace_marker-layer .ace_bracket {
margin: -1px 0 0 -1px;
border: 1px solid rgb(192, 192, 192);
}
.ace-tm .ace_marker-layer .ace_active-line {
background: rgba(0, 0, 0, 0.07);
}
.ace-tm .ace_gutter-active-line {
background-color: #dcdcdc;
}
.ace-tm .ace_marker-layer .ace_selected-word {
background: rgb(250, 250, 255);
border: 1px solid rgb(200, 200, 250);
}
.ace-tm .ace_indent-guide {
background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAE0lEQVQImWP4////f4bLly//BwAmVgd1/w11/gAAAABJRU5ErkJggg==")
right repeat-y;
}

View File

@ -0,0 +1,41 @@
/* ***** BEGIN LICENSE BLOCK *****
* Distributed under the BSD license:
*
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
exports.isDark = false;
exports.cssClass = "ace-tm";
exports.cssText = require("../requirejs/text!./textmate.css");
exports.$id = "ace/theme/textmate";
var dom = require("../lib/dom");
dom.importCssString(exports.cssText, exports.cssClass);
});

File diff suppressed because it is too large Load Diff

View File

@ -29,22 +29,30 @@ function handleConnection() {
var connected;
var msg = "online";
var homeurl = getServerUrl();
if (homeurl == null || homeurl == "") {
return;
}
if (navigator.onLine) {
isReachable(getServerUrl())
.then(function(online) {
if (online) {
// handle online status
connected = true;
showConnectionMessage(connected, msg);
} else {
connected = false;
msg = "No connectivity with server";
showConnectionMessage(connected, msg);
}
$.ajax({
url: homeurl + "include/connection_check.php",
type: "post",
dataType: "json"
})
.done(function(response) {
connected = true;
showConnectionMessage(connected, msg);
})
.catch(function(err) {
connected = false;
msg = err;
.fail(function(err) {
// If test connection file is not found, do not show message.
if (err.status != 404) {
connected = false;
msg = err;
} else {
connected = true;
}
showConnectionMessage(connected, msg);
});
} else {
@ -55,38 +63,17 @@ function handleConnection() {
}
}
/**
* Test server reachibilty and get response.
*
* @param {String} url
*
* Return {promise}
*/
function isReachable(url) {
/**
* Note: fetch() still "succeeds" for 404s on subdirectories,
* which is ok when only testing for domain reachability.
*
* Example:
* https://google.com/noexist does not throw
* https://noexist.com/noexist does throw
*/
return fetch(url, { method: "HEAD", mode: "no-cors" })
.then(function(resp) {
return resp && (resp.ok || resp.type === "opaque");
})
.catch(function(error) {
console.warn("[conn test failure]:", error);
});
}
/**
* Gets server origin url
*/
function getServerUrl() {
var server_url;
server_url = window.location.origin;
try {
server_url = get_php_value("absolute_homeurl");
} catch (error) {
return "";
}
return server_url;
}
@ -99,7 +86,7 @@ function getServerUrl() {
*/
function showConnectionMessage(conn = true, msg = "") {
var data = {};
if (conn) {
if (conn && closed == false) {
$("div#message_dialog_connection")
.closest(".ui-dialog-content")
.dialog("close");
@ -164,6 +151,7 @@ function infoMessage(data, idMsg) {
},
close: function(event, ui) {
$(".ui-widget-overlay").removeClass("error-modal-opened");
closed = true;
}
})
.show();

View File

@ -0,0 +1,69 @@
var editor = ace.edit("elasticsearch_editor");
editor.setValue(`GET _search \n{\n "query": {\n "match_all": {}\n }\n}`);
editor.clearSelection();
var view = ace.edit("elasticsearch_view");
view.setTheme("ace/theme/textmate");
view.session.setMode("ace/mode/json");
view.renderer.setShowGutter(false);
view.setReadOnly(true);
view.setShowPrintMargin(false);
$("#submit-execute_query").click(function() {
view.setValue("");
let selectText = editor.getSelectedText();
if (selectText === "") {
let allText = editor.getValue();
if (allText === "") {
return;
}
allText = allText.split("\n").join("");
allText = allText.concat("\n");
var text = allText.match("(GET|PUT|POST)(.*?)({.*?}.*?)?(GET|POST|PUT|\n)");
} else {
selectText = selectText.split("\n").join("");
selectText = selectText.concat("\n");
var text = selectText.match("(GET|PUT|POST)(.*?)({.*?}.*?)?(\n)");
}
if (
text === null ||
text === undefined ||
text[2] === "" ||
text[2] === undefined
) {
view.setValue(`Syntax error`);
view.clearSelection();
return;
}
const head = text[1];
let index = text[2].trim();
if (index.match("^/") === null) {
index = `/${index}`;
}
let json = text[3];
if (json !== "" && json !== undefined) {
json = json.match("^{.*}")[0];
}
jQuery.post(
$("#pandora_full_url").text() + "ajax.php",
{
page: "enterprise/include/ajax/log_viewer.ajax",
elasticsearch_curl: 1,
head: head,
index: index,
json: json
},
function(data) {
view.setValue(data);
view.clearSelection();
forced_title_callback();
},
"html"
);
});

View File

@ -771,139 +771,137 @@ function move_to_networkmap(node) {
}
function edit_node(data_node, dblClick) {
if (enterprise_installed) {
var flag_edit_node = true;
var edit_node = null;
var flag_edit_node = true;
var edit_node = null;
//Only select one node
var selection = d3.selectAll(".node_selected");
var id;
//Only select one node
var selection = d3.selectAll(".node_selected");
var id;
if (selection[0].length == 1) {
edit_node = selection[0].pop();
} else if (selection[0].length > 1) {
edit_node = selection[0].pop();
} else if (dblClick) {
edit_node = d3.select("#id_node_" + data_node["id"] + networkmap_id);
edit_node = edit_node[0][0];
} else {
flag_edit_node = false;
if (selection[0].length == 1) {
edit_node = selection[0].pop();
} else if (selection[0].length > 1) {
edit_node = selection[0].pop();
} else if (dblClick) {
edit_node = d3.select("#id_node_" + data_node["id"] + networkmap_id);
edit_node = edit_node[0][0];
} else {
flag_edit_node = false;
}
if (flag_edit_node) {
d3.selectAll(".node_selected").classed("node_selected", false);
d3.select(edit_node).classed("node_selected", true);
id = d3
.select(edit_node)
.attr("id")
.replace("id_node_", "");
var id_networkmap_lenght = networkmap_id.toString().length;
var id_node_length = id.length - id_networkmap_lenght;
id = id.substring(0, id_node_length);
var index_node = $.inArray(data_node, graph.nodes);
var node_selected = graph.nodes[index_node];
var selected_links = get_relations(node_selected);
$("select[name='shape'] option[value='" + node_selected.shape + "']").prop(
"selected",
true
);
$("select[name='shape']").attr(
"onchange",
"javascript: change_shape(" + node_selected.id_db + ");"
);
$("#node_options-fictional_node_update_button-1 input").attr(
"onclick",
"update_fictional_node(" + node_selected.id_db + ");"
);
$("#node_options-node_name-2 input").attr(
"onclick",
"update_node_name(" + node_selected.id_db + ");"
);
var params = [];
params.push("get_agent_info=1");
params.push("id_agent=" + node_selected["id_agent"]);
params.push("page=enterprise/operation/agentes/pandora_networkmap.view");
if (!enterprise_installed) {
params.push("page=operation/agentes/pandora_networkmap.view");
}
if (flag_edit_node) {
d3.selectAll(".node_selected").classed("node_selected", false);
d3.select(edit_node).classed("node_selected", true);
id = d3
.select(edit_node)
.attr("id")
.replace("id_node_", "");
var id_networkmap_lenght = networkmap_id.toString().length;
var id_node_length = id.length - id_networkmap_lenght;
id = id.substring(0, id_node_length);
var index_node = $.inArray(data_node, graph.nodes);
var node_selected = graph.nodes[index_node];
var selected_links = get_relations(node_selected);
$(
"select[name='shape'] option[value='" + node_selected.shape + "']"
).prop("selected", true);
$("select[name='shape']").attr(
"onchange",
"javascript: change_shape(" + node_selected.id_db + ");"
);
$("#node_options-fictional_node_update_button-1 input").attr(
"onclick",
"update_fictional_node(" + node_selected.id_db + ");"
);
$("#node_options-node_name-2 input").attr(
"onclick",
"update_node_name(" + node_selected.id_db + ");"
);
var params = [];
params.push("get_agent_info=1");
params.push("id_agent=" + node_selected["id_agent"]);
params.push("page=enterprise/operation/agentes/pandora_networkmap.view");
jQuery.ajax({
data: params.join("&"),
dataType: "json",
type: "POST",
url: window.base_url_homedir + "/ajax.php",
success: function(data) {
$("#node_details-0-1").html(
'<a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=' +
node_selected["id_agent"] +
'">' +
data["alias"] +
"</a>"
);
var addresses = "";
if (data["adressess"] instanceof Array) {
for (var i; i < data["adressess"].length; i++) {
addresses += data["adressess"][i] + "<br>";
}
} else {
for (var address in data["adressess"]) {
addresses += address + "<br>";
}
}
$("#node_details-1-1").html(addresses);
$("#node_details-2-1").html(data["os"]);
$("#node_details-3-1").html(data["group"]);
$("[aria-describedby=dialog_node_edit]").css({ top: "200px" });
$("#foot").css({
top: parseInt(
$("[aria-describedby=dialog_node_edit]").css("height") +
$("[aria-describedby=dialog_node_edit]").css("top")
),
position: "relative"
});
get_interface_data_to_table(node_selected, selected_links);
}
});
$("#dialog_node_edit").dialog(
"option",
"title",
dialog_node_edit_title.replace(
"%s",
ellipsize(node_selected["text"], 40)
)
); // It doesn't eval the possible XSS so it's ok
$("#dialog_node_edit").dialog("open");
if (node_selected.id_agent == undefined || node_selected.type == 3) {
//Fictional node
$("#node_options-fictional_node_name").css("display", "");
$("input[name='edit_name_fictional_node']").val(node_selected.text); // It doesn't eval the possible XSS so it's ok
$("#node_options-fictional_node_networkmap_link").css("display", "");
$("#edit_networkmap_to_link").val(node_selected.networkmap_id);
$("#node_options-fictional_node_update_button").css("display", "");
$("#node_options-node_name").css("display", "none");
$("#node_options-node_update_button").css("display", "none");
} else {
$("input[name='edit_name_node']").val(node_selected.text); // It doesn't eval the possible XSS so it's ok
$("#node_options-fictional_node_name").css("display", "none");
$("#node_options-fictional_node_networkmap_link").css(
"display",
"none"
jQuery.ajax({
data: params.join("&"),
dataType: "json",
type: "POST",
url: window.base_url_homedir + "/ajax.php",
success: function(data) {
$("#node_details-0-1").html(
'<a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=' +
node_selected["id_agent"] +
'">' +
data["alias"] +
"</a>"
);
$("#node_options-fictional_node_update_button").css("display", "none");
$("#node_options-node_name").css("display", "");
}
//Clean
$("#relations_table .relation_link_row").remove();
//Show the no relations
$("#relations_table-loading").css("display", "none");
$("#relations_table-no_relations").css("display", "");
var addresses = "";
if (data["adressess"] instanceof Array) {
for (var i; i < data["adressess"].length; i++) {
addresses += data["adressess"][i] + "<br>";
}
} else {
for (var address in data["adressess"]) {
addresses += address + "<br>";
}
}
$("#node_details-1-1").html(addresses);
$("#node_details-2-1").html(data["os"]);
$("#node_details-3-1").html(data["group"]);
$("[aria-describedby=dialog_node_edit]").css({ top: "200px" });
$("#foot").css({
top: parseInt(
$("[aria-describedby=dialog_node_edit]").css("height") +
$("[aria-describedby=dialog_node_edit]").css("top")
),
position: "relative"
});
get_interface_data_to_table(node_selected, selected_links);
}
});
$("#dialog_node_edit").dialog(
"option",
"title",
dialog_node_edit_title.replace("%s", ellipsize(node_selected["text"], 40))
); // It doesn't eval the possible XSS so it's ok
$("#dialog_node_edit").dialog("open");
$("#open_version_dialog").dialog();
if (node_selected.id_agent == undefined || node_selected.type == 3) {
//Fictional node
$("#node_options-fictional_node_name").css("display", "");
$("input[name='edit_name_fictional_node']").val(node_selected.text); // It doesn't eval the possible XSS so it's ok
$("#node_options-fictional_node_networkmap_link").css("display", "");
$("#edit_networkmap_to_link").val(node_selected.networkmap_id);
$("#node_options-fictional_node_update_button").css("display", "");
$("#node_options-node_name").css("display", "none");
$("#node_options-node_update_button").css("display", "none");
} else {
$("input[name='edit_name_node']").val(node_selected.text); // It doesn't eval the possible XSS so it's ok
$("#node_options-fictional_node_name").css("display", "none");
$("#node_options-fictional_node_networkmap_link").css("display", "none");
$("#node_options-fictional_node_update_button").css("display", "none");
$("#node_options-node_name").css("display", "");
}
//Clean
$("#relations_table .relation_link_row").remove();
//Show the no relations
$("#relations_table-loading").css("display", "none");
$("#relations_table-no_relations").css("display", "");
}
}
@ -2871,18 +2869,35 @@ function init_drag_and_drop() {
});
});
} else {
var params = [];
params.push("update_node_alert=1");
params.push("map_id=" + networkmap_id);
params.push("page=operation/agentes/pandora_networkmap.view");
jQuery.ajax({
data: params.join("&"),
dataType: "json",
type: "POST",
url: window.base_url_homedir + "/ajax.php",
data: {
node: JSON.stringify(d),
update_node: 1,
page: "operation/agentes/pandora_networkmap.view"
},
success: function(data) {
if (data["correct"]) {
$("#open_version_dialog").dialog();
if (d.state == "holding_area") {
//It is out the holding area
if (data["state"] == "") {
//Remove the style of nodes and links
//in holding area
d3.select("#id_node_" + d.id + networkmap_id).classed(
"holding_area",
false
);
d3.select(".source_" + d.id + networkmap_id).classed(
"holding_area_link",
false
);
d3.select(".target_" + d.id + networkmap_id).classed(
"holding_area_link",
false
);
graph.nodes[d.id].state = "";
}
}
}
});

View File

@ -113,7 +113,9 @@ function reloadContent(id, url, options, side, noneStr) {
data.side = side;
data.group_recursion = $("#checkbox-id-group-recursion-" + current).prop(
"checked"
);
)
? 1
: 0;
data.group_id = $("#id-group-" + current).val();
$.ajax({
@ -139,8 +141,8 @@ function reloadContent(id, url, options, side, noneStr) {
for (var [value, label] of items) {
if (
$("#" + opposite + " option[value=" + value + "]").length == 0 &&
$("#tmp-" + current + " option[value=" + value + "]").length == 0
$("#" + opposite + " option[value='" + value + "']").length == 0 &&
$("#tmp-" + current + " option[value='" + value + "']").length == 0
) {
// Does not exist in opposite box nor is filtered.
$("#" + current).append(new Option(label, value));

Some files were not shown because too many files have changed in this diff Show More