From faee7b7b14ab699b5e9674d7fb17515c37d8f60a Mon Sep 17 00:00:00 2001
From: "marcos.alconada" <marcos.alconada@artica.es>
Date: Wed, 13 Mar 2019 16:32:58 +0100
Subject: [PATCH 01/37] Pending Q&A

Former-commit-id: f41aafc6077f1b725cf7c9f360974ba62609eedd
---
 pandora_console/godmode/agentes/modificar_agente.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pandora_console/godmode/agentes/modificar_agente.php b/pandora_console/godmode/agentes/modificar_agente.php
index 4673bf2f46..dfaf6bcba8 100644
--- a/pandora_console/godmode/agentes/modificar_agente.php
+++ b/pandora_console/godmode/agentes/modificar_agente.php
@@ -162,7 +162,7 @@ echo '<td>';
 
 echo __('Group').'&nbsp;';
 $own_info = get_user_info($config['id_user']);
-if (!$own_info['is_admin'] && !check_acl($config['id_user'], 0, 'AW')) {
+if (!$own_info['is_admin'] && !check_acl($config['id_user'], 0, 'AR')) {
     $return_all_group = false;
 } else {
     $return_all_group = true;

From 97df41245e4b77efedd6659faa6b249b1698a3d9 Mon Sep 17 00:00:00 2001
From: "marcos.alconada" <marcos.alconada@artica.es>
Date: Wed, 13 Mar 2019 16:36:30 +0100
Subject: [PATCH 02/37] Para revision

Former-commit-id: 5823cfd9976382ad8074d2ed8cf0340e24181693
---
 pandora_console/godmode/agentes/modificar_agente.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pandora_console/godmode/agentes/modificar_agente.php b/pandora_console/godmode/agentes/modificar_agente.php
index dfaf6bcba8..3094c2fdc8 100644
--- a/pandora_console/godmode/agentes/modificar_agente.php
+++ b/pandora_console/godmode/agentes/modificar_agente.php
@@ -162,7 +162,7 @@ echo '<td>';
 
 echo __('Group').'&nbsp;';
 $own_info = get_user_info($config['id_user']);
-if (!$own_info['is_admin'] && !check_acl($config['id_user'], 0, 'AR')) {
+if (!$own_info['is_admin'] && check_acl($config['id_user'], 0, 'AW')) {
     $return_all_group = false;
 } else {
     $return_all_group = true;

From 4c95a160defd8039fa345c36e361537b29c867bf Mon Sep 17 00:00:00 2001
From: Luis Calvo <luis.calvo@artica.es>
Date: Mon, 1 Apr 2019 17:57:22 +0200
Subject: [PATCH 03/37] Changed Jquery .text for .html for html conversion

Former-commit-id: 9dd9c63e637e504ff51e38165687bacfae59ed38
---
 pandora_console/godmode/alerts/configure_alert_action.php | 4 ++--
 pandora_console/include/javascript/pandora_alerts.js      | 5 ++---
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/pandora_console/godmode/alerts/configure_alert_action.php b/pandora_console/godmode/alerts/configure_alert_action.php
index c29cda623b..e7927a2a3a 100644
--- a/pandora_console/godmode/alerts/configure_alert_action.php
+++ b/pandora_console/godmode/alerts/configure_alert_action.php
@@ -318,9 +318,9 @@ $(document).ready (function () {
         jQuery.post (<?php echo "'".ui_get_full_url('ajax.php', false, false, false)."'"; ?>,
             values,
             function (data, status) {
-                original_command = js_html_entity_decode (data["command"]);
+                original_command = data["command"];
                 render_command_preview (original_command);
-                command_description = js_html_entity_decode (data["description"]);
+                command_description = data["description"];
                 render_command_description(command_description);
                 
                 var max_fields = parseInt('<?php echo $config['max_macro_fields']; ?>');
diff --git a/pandora_console/include/javascript/pandora_alerts.js b/pandora_console/include/javascript/pandora_alerts.js
index 41f8d20ad8..668950ce9c 100644
--- a/pandora_console/include/javascript/pandora_alerts.js
+++ b/pandora_console/include/javascript/pandora_alerts.js
@@ -1,5 +1,4 @@
 var original_command = "";
-
 function parse_alert_command(command, classs) {
   if (classs == "recovery") {
     classs = "fields_recovery";
@@ -28,13 +27,13 @@ function parse_alert_command(command, classs) {
 }
 
 function render_command_preview(original_command) {
-  $("#textarea_command_preview").text(
+  $("#textarea_command_preview").html(
     parse_alert_command(original_command, "")
   );
 }
 
 function render_command_recovery_preview(original_command) {
-  $("#textarea_command_recovery_preview").text(
+  $("#textarea_command_recovery_preview").html(
     parse_alert_command(original_command, "recovery")
   );
 }

From 9c3d26f12030f683f8e7e32a13fe3aafd819ec22 Mon Sep 17 00:00:00 2001
From: Luis Calvo <luis.calvo@artica.es>
Date: Wed, 3 Apr 2019 11:22:20 +0200
Subject: [PATCH 04/37] Deleted Servers menu option for operator(read)

Former-commit-id: 89723d23cb2199152cfc9f3d72997ddcd7b31796
---
 pandora_console/godmode/menu.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pandora_console/godmode/menu.php b/pandora_console/godmode/menu.php
index ac3154b657..6224d361c9 100644
--- a/pandora_console/godmode/menu.php
+++ b/pandora_console/godmode/menu.php
@@ -208,7 +208,7 @@ if (!empty($sub)) {
 }
 
 
-if (check_acl($config['id_user'], 0, 'AW') || check_acl($config['id_user'], 0, 'PM') || check_acl($config['id_user'], 0, 'RR')) {
+if (check_acl($config['id_user'], 0, 'AW') || check_acl($config['id_user'], 0, 'PM')) {
     // Servers
     $menu_godmode['gservers']['text'] = __('Servers');
     $menu_godmode['gservers']['sec2'] = 'godmode/servers/modificar_server';

From 9df4cb86dc496c8aecd56be96f785695da16b25d Mon Sep 17 00:00:00 2001
From: Luis Calvo <luis.calvo@artica.es>
Date: Thu, 4 Apr 2019 09:45:29 +0200
Subject: [PATCH 05/37] Added inline-block and fixed size to label

Former-commit-id: 40c1ca6d5c06fb771eb7e8d1ac81dde6e7012cfb
---
 pandora_console/include/styles/login.css | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/pandora_console/include/styles/login.css b/pandora_console/include/styles/login.css
index bffcda19d5..648eadb503 100644
--- a/pandora_console/include/styles/login.css
+++ b/pandora_console/include/styles/login.css
@@ -407,6 +407,8 @@ div.form_message_alert ul li input {
 }
 
 div.form_message_alert ul li label {
+  display: inline-block;
+  width: 145px;
   font-size: 10pt;
   padding-right: 20px;
 }

From 1b6a01cfd5ac0f97266abd35471788ef32cca8fb Mon Sep 17 00:00:00 2001
From: Luis Calvo <luis.calvo@artica.es>
Date: Thu, 4 Apr 2019 14:11:44 +0200
Subject: [PATCH 06/37] Changed modal size to fit err. msg

Former-commit-id: 2676ac1d217cc5245ce09277b8b76d1d562cdf5f
---
 .../include/javascript/jquery.pandora.js      | 697 +++++++++---------
 1 file changed, 358 insertions(+), 339 deletions(-)

diff --git a/pandora_console/include/javascript/jquery.pandora.js b/pandora_console/include/javascript/jquery.pandora.js
index 9e0b3447af..ed75400386 100644
--- a/pandora_console/include/javascript/jquery.pandora.js
+++ b/pandora_console/include/javascript/jquery.pandora.js
@@ -1,386 +1,405 @@
 (function($) {
-	$.fn.check = function () {
-		return this.each (function () {
-			this.checked = true;
-		});};
+  $.fn.check = function() {
+    return this.each(function() {
+      this.checked = true;
+    });
+  };
 
-	$.fn.uncheck = function () {
-		return this.each (function () {
-			this.checked = false;
-		});};
+  $.fn.uncheck = function() {
+    return this.each(function() {
+      this.checked = false;
+    });
+  };
 
-	$.fn.enable = function () {
-		return $(this).removeAttr ("disabled");
-		};
+  $.fn.enable = function() {
+    return $(this).removeAttr("disabled");
+  };
 
-	$.fn.disable = function () {
-		return $(this).attr ("disabled", "disabled");
-		};
+  $.fn.disable = function() {
+    return $(this).attr("disabled", "disabled");
+  };
 
-	$.fn.pulsate = function () {
-		var i = 0;
-		for (i = 0; i <= 2; i++) {
-			$(this).fadeOut ("slow").fadeIn ("slow");
-		}
-	};
+  $.fn.pulsate = function() {
+    var i = 0;
+    for (i = 0; i <= 2; i++) {
+      $(this)
+        .fadeOut("slow")
+        .fadeIn("slow");
+    }
+  };
 
-	$.fn.showMessage = function (msg) {
-		return $(this).hide ().empty ()
-		// here, previously .text (msg)
-				.html (msg)
-				.slideDown ();
-		};
-}) (jQuery);
+  $.fn.showMessage = function(msg) {
+    return (
+      $(this)
+        .hide()
+        .empty()
+        // here, previously .text (msg)
+        .html(msg)
+        .slideDown()
+    );
+  };
+})(jQuery);
 
-$(document).ready (function () {
-	$("a#show_messages_dialog").click (function () {
-		jQuery.post ("ajax.php",
-			{
-				"page": "operation/messages/message_list"
-			},
-			function (data, status) {
-				$("#dialog_messages").hide ()
-					.empty ()
-					.append (data)
-					.dialog ({
-						title: $("a#show_messages_dialog").attr ("title"),
-						resizable: false,
-						modal: true,
-						overlay: {
-							opacity: 0.5,
-							background: "black"
-						},
-						width: 700,
-						height: 300
-					}).show ();
-				},
-			"html"
-		);
+$(document).ready(function() {
+  $("a#show_messages_dialog").click(function() {
+    jQuery.post(
+      "ajax.php",
+      {
+        page: "operation/messages/message_list"
+      },
+      function(data, status) {
+        $("#dialog_messages")
+          .hide()
+          .empty()
+          .append(data)
+          .dialog({
+            title: $("a#show_messages_dialog").attr("title"),
+            resizable: false,
+            modal: true,
+            overlay: {
+              opacity: 0.5,
+              background: "black"
+            },
+            width: 700,
+            height: 300
+          })
+          .show();
+      },
+      "html"
+    );
 
-		return false;
-	});
+    return false;
+  });
 
-	$("a.show_systemalert_dialog").click (function () {
-		$('body').append( "<div id='opacidad' style='position:fixed;background:black;z-index:1'></div>" );
-		$("#opacidad").css('opacity', 0.5);
+  $("a.show_systemalert_dialog").click(function() {
+    $("body").append(
+      "<div id='opacidad' style='position:fixed;background:black;z-index:1'></div>"
+    );
+    $("#opacidad").css("opacity", 0.5);
 
-		jQuery.post ("ajax.php",
-			{
-				"page": "operation/system_alert"},
-				function (data, status) {
-					$("#alert_messages").show();
-					$("#alert_messages").empty ().append (data);
-					$("#alert_messages").css('opacity', 1);
+    jQuery.post(
+      "ajax.php",
+      {
+        page: "operation/system_alert"
+      },
+      function(data, status) {
+        $("#alert_messages").show();
+        $("#alert_messages")
+          .empty()
+          .append(data);
+        $("#alert_messages").css("opacity", 1);
+      },
+      "html"
+    );
+  });
 
-			},
-			"html"
-		);
-	});
-	
-	$("a.modalpopup").click (function () {
-		var elem = $(this).attr("id");
-		$('body').append( "<div id='opacidad' style='position:fixed;background:black;z-index:1'></div>" );
-		$("#opacidad").css('opacity', 0.5);
+  $("a.modalpopup").click(function() {
+    var elem = $(this).attr("id");
+    $("body").append(
+      "<div id='opacidad' style='position:fixed;background:black;z-index:1'></div>"
+    );
+    $("#opacidad").css("opacity", 0.5);
 
-		jQuery.post ("ajax.php",
-			{
-				"page": "general/alert_enterprise",
-				"message": elem
-			},
-			function (data, status) {
-				$("#alert_messages").show();
-				$("#alert_messages").empty ().append (data);
-				$("#alert_messages").css('opacity', 1);
-			},
-			"html"
-		);
-		return false;
-	});
+    jQuery.post(
+      "ajax.php",
+      {
+        page: "general/alert_enterprise",
+        message: elem
+      },
+      function(data, status) {
+        $("#alert_messages").show();
+        $("#alert_messages")
+          .empty()
+          .append(data);
+        $("#alert_messages").css("opacity", 1);
+      },
+      "html"
+    );
+    return false;
+  });
 
-	// Creacion de ventana modal y botones
-	$(".publienterprise").click (function () {
-		var elem = $(this).attr("id");
-		$('body').append( "<div id='opacidad' style='position:fixed;background:black;z-index:1'></div>" );
-		$("#opacidad").css('opacity', 0.5);
+  // Creacion de ventana modal y botones
+  $(".publienterprise").click(function() {
+    var elem = $(this).attr("id");
+    $("body").append(
+      "<div id='opacidad' style='position:fixed;background:black;z-index:1'></div>"
+    );
+    $("#opacidad").css("opacity", 0.5);
 
-		jQuery.post ("ajax.php",
-			{
-				"page": "general/alert_enterprise",
-				"message": elem
-			},
-			function (data, status) {
-				$("#alert_messages").show();
-				$("#alert_messages").empty ().append (data);
-				$("#alert_messages").css('opacity', 1);
-			},
-			"html"
-		);
-		return false;
-	});
-	
-	
-	$(".publienterprisehide").click (function () {
-		var elem = $(this).attr("id");
-		$('body').append( "<div id='opacidad' style='position:fixed;background:black;z-index:1'></div>" );
-		$("#opacidad").css('opacity', 0.5);
+    jQuery.post(
+      "ajax.php",
+      {
+        page: "general/alert_enterprise",
+        message: elem
+      },
+      function(data, status) {
+        $("#alert_messages").show();
+        $("#alert_messages")
+          .empty()
+          .append(data);
+        $("#alert_messages").css("opacity", 1);
+      },
+      "html"
+    );
+    return false;
+  });
 
-		jQuery.post ("ajax.php",
-			{
-				"page": "general/alert_enterprise",
-				"message": elem
-			},
-			function (data, status) {
-				$("#alert_messages").show();
-				$("#alert_messages").empty ().append (data);
-				$("#alert_messages").css('opacity', 1);
-			},
-			"html"
-		);
-		return false;
-	});
+  $(".publienterprisehide").click(function() {
+    var elem = $(this).attr("id");
+    $("body").append(
+      "<div id='opacidad' style='position:fixed;background:black;z-index:1'></div>"
+    );
+    $("#opacidad").css("opacity", 0.5);
 
+    jQuery.post(
+      "ajax.php",
+      {
+        page: "general/alert_enterprise",
+        message: elem
+      },
+      function(data, status) {
+        $("#alert_messages").show();
+        $("#alert_messages")
+          .empty()
+          .append(data);
+        $("#alert_messages").css("opacity", 1);
+      },
+      "html"
+    );
+    return false;
+  });
 
+  if ($("#license_error_msg_dialog").length) {
+    if (typeof process_login_ok == "undefined") process_login_ok = 0;
 
-	if ($('#license_error_msg_dialog').length) {
-		if (typeof(process_login_ok) == "undefined")
-			process_login_ok = 0;
+    if (typeof show_error_license == "undefined") show_error_license = 0;
 
-		if (typeof(show_error_license) == "undefined")
-			show_error_license = 0;
+    if (process_login_ok || show_error_license) {
+      $("#license_error_msg_dialog").dialog({
+        dialogClass: "no-close",
+        closeOnEscape: false,
+        resizable: false,
+        draggable: true,
+        modal: true,
+        height: 470,
+        width: 850,
+        overlay: {
+          opacity: 0.5,
+          background: "black"
+        },
+        open: function() {
+          var remaining = 30;
 
-		if (process_login_ok || show_error_license) {
+          // Timeout counter.
+          var count = function() {
+            if (remaining > 0) {
+              $("#license_error_remaining").text(remaining);
+              remaining -= 1;
+            } else {
+              $("#license_error_remaining").hide();
+              $("#ok_buttom").show();
+              clearInterval(count);
+            }
+          };
 
-			$( "#license_error_msg_dialog" ).dialog({
-				dialogClass: "no-close",
-				closeOnEscape: false,
-				resizable: false,
-				draggable: true,
-				modal: true,
-				height: 450,
-				width: 850,
-				overlay: {
-					opacity: 0.5,
-					background: "black"
-				},
-				open: function() {
-					var remaining = 30;
+          setInterval(count, 1000);
+        }
+      });
 
-					// Timeout counter.
-					var count = function() {
-						if (remaining > 0) {
-							$("#license_error_remaining").text(remaining);
-							remaining -= 1;
-						} else {
-							$("#license_error_remaining").hide();
-							$("#ok_buttom").show();
-							clearInterval(count);
-						}
-					}
+      $("#submit-hide-license-error-msg").click(function() {
+        $("#license_error_msg_dialog").dialog("close");
+      });
+    }
+  }
 
-					setInterval(count, 1000);
-				}
-			});
+  if ($("#msg_change_password").length) {
+    $("#msg_change_password").dialog({
+      resizable: false,
+      draggable: true,
+      modal: true,
+      height: 450,
+      width: 620,
+      overlay: {
+        opacity: 0.5,
+        background: "black"
+      }
+    });
+  }
 
-			$("#submit-hide-license-error-msg").click (function () {
-				$("#license_error_msg_dialog" ).dialog('close')
-			});
+  if ($("#login_blocked").length) {
+    $("#login_blocked").dialog({
+      resizable: true,
+      draggable: true,
+      modal: true,
+      height: 200,
+      width: 520,
+      overlay: {
+        opacity: 0.5,
+        background: "black"
+      }
+    });
+  }
 
-		}
-	}
+  if ($("#login_correct_pass").length) {
+    $("#login_correct_pass").dialog({
+      resizable: true,
+      draggable: true,
+      modal: true,
+      height: 200,
+      width: 520,
+      overlay: {
+        opacity: 0.5,
+        background: "black"
+      }
+    });
+  }
 
+  forced_title_callback();
 
-	if ($('#msg_change_password').length) {
+  $(document).on("scroll", function() {
+    if (
+      document.documentElement.scrollTop != 0 ||
+      document.body.scrollTop != 0
+    ) {
+      if ($("#head").css("position") == "fixed") {
+        if ($("#menu").css("position") == "fixed") {
+          $("#menu").css("top", "80px");
+        } else {
+          $("#menu").css("top", "60px");
+        }
+      } else {
+        if ($("#menu").css("position") == "fixed") {
+          $("#menu").css("top", "20px");
+        } else {
+          $("#menu").css("top", "80px");
+        }
+      }
+    } else {
+      if ($("#head").css("position") == "fixed") {
+        if ($("#menu").css("position") == "fixed") {
+          $("#menu").css("top", "80px");
+        } else {
+          $("#menu").css("top", "60px");
+        }
+      } else {
+        if ($("#menu").css("position") == "fixed") {
+          $("#menu").css("top", "80px");
+        } else {
+          $("#menu").css("top", "80px");
+        }
+      }
+    }
 
-		$( "#msg_change_password" ).dialog({
-			resizable: false,
-			draggable: true,
-			modal: true,
-			height: 350,
-			width: 620,
-			overlay: {
-				opacity: 0.5,
-				background: "black"
-			}
-		});
+    // if((document.documentElement.scrollTop != 0 || document.body.scrollTop != 0) && $('#menu').css('position') =='fixed'){
+    // 	if($('#head').css('position') =='fixed'){
+    // 		$('#menu').css('top','80px');
+    // 	}
+    // 	else{
+    // 		$('#menu').css('top','20px');
+    // 	}
+    // }
+    // else{
+    // 	if($('#head').css('position') =='fixed'){
+    // 		if(document.documentElement.scrollTop != 0 || document.body.scrollTop != 0){
+    // 			$('#menu').css('top','60px');
+    // 		}else{
+    // 			$('#menu').css('top','80px');
+    // 		}
+    //
+    // 	}
+    // 	else{
+    // 		$('#menu').css('top','60px');
+    // 	}
+    // }
+  });
 
-	}
-
-	if ($('#login_blocked').length) {
-
-		$( "#login_blocked" ).dialog({
-			resizable: true,
-			draggable: true,
-			modal: true,
-			height: 200,
-			width: 520,
-			overlay: {
-				opacity: 0.5,
-				background: "black"
-			}
-		});
-
-	}
-
-	if ($('#login_correct_pass').length) {
-
-		$( "#login_correct_pass" ).dialog({
-			resizable: true,
-			draggable: true,
-			modal: true,
-			height: 200,
-			width: 520,
-			overlay: {
-				opacity: 0.5,
-				background: "black"
-			}
-		});
-
-	}
-
-	forced_title_callback();
-	
-	
-	$(document).on("scroll", function(){
-		
-		if(document.documentElement.scrollTop != 0 || document.body.scrollTop != 0){
-			if($('#head').css('position') =='fixed'){
-				if($('#menu').css('position') =='fixed'){
-					$('#menu').css('top','80px');
-				} else {
-					$('#menu').css('top','60px');
-				}	
-			} else {
-				if($('#menu').css('position') =='fixed'){
-					$('#menu').css('top','20px');
-				} else {
-					$('#menu').css('top','80px');
-				}	
-			}
-		} else {
-			if($('#head').css('position') =='fixed'){
-				if($('#menu').css('position') =='fixed'){
-					$('#menu').css('top','80px');
-				} else {
-					$('#menu').css('top','60px');
-				}
-			} else {
-				if($('#menu').css('position') =='fixed'){
-					$('#menu').css('top','80px');
-				} else {
-					$('#menu').css('top','80px');
-				}	
-			}
-		}
-		
-		// if((document.documentElement.scrollTop != 0 || document.body.scrollTop != 0) && $('#menu').css('position') =='fixed'){
-		// 	if($('#head').css('position') =='fixed'){
-		// 		$('#menu').css('top','80px');
-		// 	}
-		// 	else{
-		// 		$('#menu').css('top','20px');
-		// 	}	
-		// }
-		// else{
-		// 	if($('#head').css('position') =='fixed'){
-		// 		if(document.documentElement.scrollTop != 0 || document.body.scrollTop != 0){
-		// 			$('#menu').css('top','60px');
-		// 		}else{
-		// 			$('#menu').css('top','80px');
-		// 		}
-		// 		
-		// 	}
-		// 	else{
-		// 		$('#menu').css('top','60px');
-		// 	}	
-		// }
-	});
-
-	$("#alert_messages").draggable();
-	$("#alert_messages").css({'left':+parseInt(screen.width/2)-parseInt($("#alert_messages").css('width'))/2+'px'});
-	
+  $("#alert_messages").draggable();
+  $("#alert_messages").css({
+    left:
+      +parseInt(screen.width / 2) -
+      parseInt($("#alert_messages").css("width")) / 2 +
+      "px"
+  });
 });
 
-
-
-
 function forced_title_callback() {
-	// Forced title code
-	$('body').on('mouseenter', '.forced_title', function() {
-		///////////////////////////////////////////
-		// Put the layer in the left-top corner to fill it
-		///////////////////////////////////////////
-		$('#forced_title_layer').css('left', 0);
-		$('#forced_title_layer').css('top', 0);
+  // Forced title code
+  $("body").on("mouseenter", ".forced_title", function() {
+    ///////////////////////////////////////////
+    // Put the layer in the left-top corner to fill it
+    ///////////////////////////////////////////
+    $("#forced_title_layer").css("left", 0);
+    $("#forced_title_layer").css("top", 0);
 
-		///////////////////////////////////////////
-		// Get info of the image
-		///////////////////////////////////////////
+    ///////////////////////////////////////////
+    // Get info of the image
+    ///////////////////////////////////////////
 
-		var img_top = $(this).offset().top;
-		var img_width = $(this).width();
-		var img_height = $(this).height();
-		var img_id = $(this).attr('id');
-		var img_left_mid = $(this).offset().left + (img_width / 2);
+    var img_top = $(this).offset().top;
+    var img_width = $(this).width();
+    var img_height = $(this).height();
+    var img_id = $(this).attr("id");
+    var img_left_mid = $(this).offset().left + img_width / 2;
 
-		///////////////////////////////////////////
-		// Put title in the layer
-		///////////////////////////////////////////
+    ///////////////////////////////////////////
+    // Put title in the layer
+    ///////////////////////////////////////////
 
-		// If the '.forced_title' element has 'use_title_for_force_title' = 1
-		// into their 'data' prop, the element title will be used for the
-		// content.
-		if ($(this).data("use_title_for_force_title")) {
-			var title = $(this).data("title");
-		}
-		else {
-			var title = $('#forced_title_'+img_id).html();
-		}
+    // If the '.forced_title' element has 'use_title_for_force_title' = 1
+    // into their 'data' prop, the element title will be used for the
+    // content.
+    if ($(this).data("use_title_for_force_title")) {
+      var title = $(this).data("title");
+    } else {
+      var title = $("#forced_title_" + img_id).html();
+    }
 
-		$('#forced_title_layer').html(title);
+    $("#forced_title_layer").html(title);
 
-		///////////////////////////////////////////
-		// Get info of the layer
-		///////////////////////////////////////////
+    ///////////////////////////////////////////
+    // Get info of the layer
+    ///////////////////////////////////////////
 
-		var layer_width = $('#forced_title_layer').width();
-		var layer_height = $('#forced_title_layer').height();
+    var layer_width = $("#forced_title_layer").width();
+    var layer_height = $("#forced_title_layer").height();
 
-		///////////////////////////////////////////
-		// Obtain the new position of the layer
-		///////////////////////////////////////////
+    ///////////////////////////////////////////
+    // Obtain the new position of the layer
+    ///////////////////////////////////////////
 
-		// Jquery doesnt know the padding of the layer
-		var layer_padding = 4;
+    // Jquery doesnt know the padding of the layer
+    var layer_padding = 4;
 
-		// Deduct padding of both sides
-		var layer_top = img_top - layer_height - (layer_padding * 2) - 5;
-		if (layer_top < 0) {
-			layer_top = img_top + img_height + (layer_padding * 2);
-		}
+    // Deduct padding of both sides
+    var layer_top = img_top - layer_height - layer_padding * 2 - 5;
+    if (layer_top < 0) {
+      layer_top = img_top + img_height + layer_padding * 2;
+    }
 
-		// Deduct padding of one side
-		var layer_left = img_left_mid - (layer_width / 2) - layer_padding;
-		if (layer_left < 0) {
-			layer_left = 0;
-		}
+    // Deduct padding of one side
+    var layer_left = img_left_mid - layer_width / 2 - layer_padding;
+    if (layer_left < 0) {
+      layer_left = 0;
+    }
 
-		var real_layer_width = layer_width + (layer_padding * 2) + 5;
-		var layer_right = layer_left + real_layer_width;
-		var screen_width = $(window).width();
-		if (screen_width < layer_right) {
-			layer_left = screen_width - real_layer_width;
-		}
+    var real_layer_width = layer_width + layer_padding * 2 + 5;
+    var layer_right = layer_left + real_layer_width;
+    var screen_width = $(window).width();
+    if (screen_width < layer_right) {
+      layer_left = screen_width - real_layer_width;
+    }
 
-		///////////////////////////////////////////
-		// Set the layer position and show
-		///////////////////////////////////////////
+    ///////////////////////////////////////////
+    // Set the layer position and show
+    ///////////////////////////////////////////
 
-		$('#forced_title_layer').css('left', layer_left);
-		$('#forced_title_layer').css('top', layer_top);
-		$('#forced_title_layer').show();
-	});
-	$('body').on('mouseout', '.forced_title', function () {
-		$('#forced_title_layer').hide().empty();
-	});
+    $("#forced_title_layer").css("left", layer_left);
+    $("#forced_title_layer").css("top", layer_top);
+    $("#forced_title_layer").show();
+  });
+  $("body").on("mouseout", ".forced_title", function() {
+    $("#forced_title_layer")
+      .hide()
+      .empty();
+  });
 }
-

From 553ec48f5451a331f33e292ee37ff14bbe88bc57 Mon Sep 17 00:00:00 2001
From: "marcos.alconada" <marcos.alconada@artica.es>
Date: Mon, 15 Apr 2019 15:21:07 +0200
Subject: [PATCH 07/37] changed title plugin creation to plugin registration

Former-commit-id: bd5ee299d91c52d3064eafa85b092b525b70381a
---
 pandora_console/godmode/servers/plugin.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pandora_console/godmode/servers/plugin.php b/pandora_console/godmode/servers/plugin.php
index b04643e1c3..5ff8022afa 100644
--- a/pandora_console/godmode/servers/plugin.php
+++ b/pandora_console/godmode/servers/plugin.php
@@ -281,7 +281,7 @@ if (($create != '') || ($view != '')) {
     } else {
         if ($create != '') {
             ui_print_page_header(
-                __('Plugin creation'),
+                __('Plugin registration'),
                 'images/gm_servers.png',
                 false,
                 'plugin_definition',

From d5ac57064bf3deceef1c99cdcc229afe7029c480 Mon Sep 17 00:00:00 2001
From: "marcos.alconada" <marcos.alconada@artica.es>
Date: Wed, 29 May 2019 11:34:23 +0200
Subject: [PATCH 08/37] Condition is added to keep the selection color in the
 main menu

---
 pandora_console/include/functions_menu.php | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/pandora_console/include/functions_menu.php b/pandora_console/include/functions_menu.php
index 0dbe1049bc..e26acd5cac 100644
--- a/pandora_console/include/functions_menu.php
+++ b/pandora_console/include/functions_menu.php
@@ -50,6 +50,12 @@ function menu_print_menu(&$menu)
 
     $sec = (string) get_parameter('sec');
     $sec2 = (string) get_parameter('sec2');
+    if ($sec2 == 'operation/agentes/ver_agente') {
+        $sec2 = 'godmode/agentes/configurar_agente';
+    } else {
+        $sec2 = (string) get_parameter('sec2');
+    }
+
     $menu_selected = false;
 
     $allsec2 = explode('sec2=', $_SERVER['REQUEST_URI']);

From f1787c7920a54bd04b2cf4235184d11868291ddd Mon Sep 17 00:00:00 2001
From: Tatiana Llorente <tatiana.llorente@artica.es>
Date: Thu, 13 Jun 2019 10:11:03 +0200
Subject: [PATCH 09/37] Removed empty help in unknown modules - #4208

---
 pandora_console/include/help/clippy/module_unknow.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pandora_console/include/help/clippy/module_unknow.php b/pandora_console/include/help/clippy/module_unknow.php
index 28656c9ba2..d3a6245032 100644
--- a/pandora_console/include/help/clippy/module_unknow.php
+++ b/pandora_console/include/help/clippy/module_unknow.php
@@ -32,7 +32,7 @@ function clippy_module_unknow()
     $return_tours['tours']['module_unknow']['steps'] = [];
     $return_tours['tours']['module_unknow']['steps'][] = [
         'init_step_context' => true,
-        'intro'             => '<table>'.'<tr>'.'<td class="context_help_title">'.__('You have unknown modules in this agent.').'</td>'.'</tr>'.'<tr>'.'<td class="context_help_body">'.__('Unknown modules are modules which receive data normally at least in one occassion, but at this time are not receving data. Please check our troubleshoot help page to help you determine why you have unknown modules.').ui_print_help_icon('context_module_unknow', true, '', 'images/help.png').'</td>'.'</tr>'.'</table>',
+        'intro'             => '<table>'.'<tr>'.'<td class="context_help_title">'.__('You have unknown modules in this agent.').'</td>'.'</tr>'.'<tr>'.'<td class="context_help_body">'.__('Unknown modules are modules which receive data normally at least in one occassion, but at this time are not receving data. Please check our troubleshoot help page to help you determine why you have unknown modules.').'</td>'.'</tr>'.'</table>',
     ];
     $return_tours['tours']['module_unknow']['conf'] = [];
     $return_tours['tours']['module_unknow']['conf']['autostart'] = false;

From 018c942ecb0e84f94f5e90008a5ac6c100ad3978 Mon Sep 17 00:00:00 2001
From: Tatiana Llorente <tatiana.llorente@artica.es>
Date: Thu, 13 Jun 2019 15:04:39 +0200
Subject: [PATCH 10/37] Added meta option in function ui_print_os_icon - #3999

---
 pandora_console/include/functions_ui.php | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php
index c81148b9c9..f9a8e784e3 100755
--- a/pandora_console/include/functions_ui.php
+++ b/pandora_console/include/functions_ui.php
@@ -760,6 +760,12 @@ function ui_print_os_icon(
         $subfolder .= '/so_big_icons';
     }
 
+    if (is_metaconsole()) {
+        $no_in_meta = true;
+    } else {
+        $no_in_meta = false;
+    }
+
     $icon = (string) db_get_value('icon_name', 'tconfig_os', 'id_os', (int) $id_os);
     $os_name = get_os_name($id_os);
     if (empty($icon)) {
@@ -770,7 +776,7 @@ function ui_print_os_icon(
                 $options,
                 true,
                 $relative,
-                false,
+                $no_in_meta,
                 true
             );
         } else {
@@ -778,13 +784,13 @@ function ui_print_os_icon(
         }
     } else if ($apply_skin) {
         if ($only_src) {
-            $output = html_print_image('images/'.$subfolder.'/'.$icon, true, $options, true, $relative, false, true);
+            $output = html_print_image('images/'.$subfolder.'/'.$icon, true, $options, true, $relative, $no_in_meta, true);
         } else {
             if (!isset($options['title'])) {
                 $options['title'] = $os_name;
             }
 
-            $output = html_print_image('images/'.$subfolder.'/'.$icon, true, $options, false, $relative, false, true);
+            $output = html_print_image('images/'.$subfolder.'/'.$icon, true, $options, false, $relative, $no_in_meta, true);
         }
     } else {
         // $output = "<img src='images/os_icons/" . $icon . "' alt='" . $os_name . "' title='" . $os_name . "'>";

From 524575171a8360968cf28fdca5ea1b8a6917aef8 Mon Sep 17 00:00:00 2001
From: fbsanchez <fborja.sanchez@artica.es>
Date: Wed, 19 Jun 2019 12:56:16 +0200
Subject: [PATCH 11/37] event history viewer

---
 pandora_console/include/functions_ui.php    |  6 +-
 pandora_console/operation/events/events.php | 73 ++++++++++++---------
 2 files changed, 45 insertions(+), 34 deletions(-)

diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php
index ea07c20d6a..c18ef5a52b 100755
--- a/pandora_console/include/functions_ui.php
+++ b/pandora_console/include/functions_ui.php
@@ -2936,15 +2936,15 @@ function ui_print_datatable(array $parameters)
         }
 
         if (!isset($parameters['order']['field'])) {
-            $order = 1;
+            $order = 0;
         } else {
             $order = array_search(
                 $parameters['order']['field'],
                 $parameters['columns']
             );
 
-            if (empty($order)) {
-                $order = 1;
+            if ($order === false) {
+                $order = 0;
             }
         }
 
diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php
index 7e8ce16ec3..88621b7711 100644
--- a/pandora_console/operation/events/events.php
+++ b/pandora_console/operation/events/events.php
@@ -109,6 +109,8 @@ $date_to = get_parameter('filter[date_to]');
 $source = get_parameter('filter[source]');
 $id_extra = get_parameter('filter[id_extra]');
 $user_comment = get_parameter('filter[user_comment]');
+$history = get_parameter('history', false);
+$section = get_parameter('section', false);
 
 // Ajax responses.
 if (is_ajax()) {
@@ -155,7 +157,9 @@ if (is_ajax()) {
             }
 
             $events = events_get_all(
+                // Fields.
                 $fields,
+                // Filter.
                 $filter,
                 // Offset.
                 $start,
@@ -164,7 +168,9 @@ if (is_ajax()) {
                 // Order.
                 $order['direction'],
                 // Sort field.
-                $order['field']
+                $order['field'],
+                // History.
+                $history
             );
             $count = events_get_all(
                 'count',
@@ -1227,7 +1233,10 @@ try {
             'class'               => 'info_table events',
             'style'               => 'width: 100%;',
             'ajax_url'            => 'operation/events/events',
-            'ajax_data'           => ['get_events' => 1],
+            'ajax_data'           => [
+                'get_events' => 1,
+                'history'    => (int) $history,
+            ],
             'form'                => [
                 'id'            => 'events_form',
                 'class'         => 'flex-row',
@@ -1280,39 +1289,41 @@ try {
 $sql_event_resp = "SELECT id, name FROM tevent_response WHERE type LIKE 'command'";
 $event_responses = db_get_all_rows_sql($sql_event_resp);
 
-if (check_acl($config['id_user'], 0, 'EW') == 1 && !$readonly) {
-    $array_events_actions['in_progress_selected'] = __('In progress selected');
-    $array_events_actions['validate_selected'] = __('Validate selected');
-}
+if ($config['event_replication'] != 1) {
+    if (check_acl($config['id_user'], 0, 'EW') == 1 && !$readonly) {
+        $array_events_actions['in_progress_selected'] = __('In progress selected');
+        $array_events_actions['validate_selected'] = __('Validate selected');
+    }
 
-if (check_acl($config['id_user'], 0, 'EM') == 1 && !$readonly) {
-    $array_events_actions['delete_selected'] = __('Delete selected');
+    if (check_acl($config['id_user'], 0, 'EM') == 1 && !$readonly) {
+        $array_events_actions['delete_selected'] = __('Delete selected');
+    }
 }
 
 foreach ($event_responses as $val) {
     $array_events_actions[$val['id']] = $val['name'];
 }
 
-if ($config['event_replication'] != 1) {
-    echo '<div class="multi-response-buttons">';
-    echo '<form method="post" id="form_event_response">';
-    echo '<input type="hidden" id="max_execution_event_response" value="'.$config['max_execution_event_response'].'" />';
-    html_print_select($array_events_actions, 'response_id', '', '', '', 0, false, false, false);
-    echo '&nbsp&nbsp';
-    html_print_button(__('Execute event response'), 'submit_event_response', false, 'execute_event_response(true);', 'class="sub next"');
-    echo "<span id='response_loading_dialog' style='display:none'>".html_print_image('images/spinner.gif', true).'</span>';
-    echo '</form>';
-    echo '<span id="max_custom_event_resp_msg" style="display:none; color:#e63c52; line-height: 200%;">';
-    echo __(
-        'A maximum of %s event custom responses can be selected',
-        $config['max_execution_event_response']
-    ).'</span>';
-    echo '<span id="max_custom_selected" style="display:none; color:#e63c52; line-height: 200%;">';
-    echo __(
-        'Please, select an event'
-    ).'</span>';
-    echo '</div>';
-}
+
+echo '<div class="multi-response-buttons">';
+echo '<form method="post" id="form_event_response">';
+echo '<input type="hidden" id="max_execution_event_response" value="'.$config['max_execution_event_response'].'" />';
+html_print_select($array_events_actions, 'response_id', '', '', '', 0, false, false, false);
+echo '&nbsp&nbsp';
+html_print_button(__('Execute event response'), 'submit_event_response', false, 'execute_event_response(true);', 'class="sub next"');
+echo "<span id='response_loading_dialog' style='display:none'>".html_print_image('images/spinner.gif', true).'</span>';
+echo '</form>';
+echo '<span id="max_custom_event_resp_msg" style="display:none; color:#e63c52; line-height: 200%;">';
+echo __(
+    'A maximum of %s event custom responses can be selected',
+    $config['max_execution_event_response']
+).'</span>';
+echo '<span id="max_custom_selected" style="display:none; color:#e63c52; line-height: 200%;">';
+echo __(
+    'Please, select an event'
+).'</span>';
+echo '</div>';
+
 
 // Close viewer.
 enterprise_hook('close_meta_frame');
@@ -1658,6 +1669,9 @@ function process_datatables_item(item) {
             item.options += '<?php echo html_print_image('images/cross.png', true, ['title' => __('Delete event')]); ?></a>';
         }
     }
+        <?php
+    }
+    ?>
 
     // Multi select.
     item.m = '<input name="checkbox-multi[]" type="checkbox" value="';
@@ -1668,9 +1682,6 @@ function process_datatables_item(item) {
         item.m += ' event_rep="0" ';
     }
     item.m += 'class="candeleted chk_val">';
-        <?php
-    }
-    ?>
 
     /* Status */
     img = '<?php echo html_print_image('images/star.png', true, ['title' => __('Unknown'), 'class' => 'forced-title']); ?>';

From 44d8b977cbc8948867eb1573ea57a6d1d178a2a8 Mon Sep 17 00:00:00 2001
From: fbsanchez <fborja.sanchez@artica.es>
Date: Wed, 19 Jun 2019 16:52:14 +0200
Subject: [PATCH 12/37] event advanced filter fixes

---
 pandora_console/include/ajax/events.php      | 24 +++++---
 pandora_console/include/functions_events.php | 56 +++++++++++------
 pandora_console/include/functions_groups.php | 47 ++++++++++++++
 pandora_console/operation/events/events.php  | 64 ++++++++++----------
 4 files changed, 131 insertions(+), 60 deletions(-)

diff --git a/pandora_console/include/ajax/events.php b/pandora_console/include/ajax/events.php
index ce173898b2..12f86c4852 100644
--- a/pandora_console/include/ajax/events.php
+++ b/pandora_console/include/ajax/events.php
@@ -1079,29 +1079,37 @@ if ($get_extended_event) {
     }
 
     // Check ACLs.
+    $access = false;
     if (is_user_admin($config['id_user'])) {
         // Do nothing if you're admin, you get full access.
-        $__ignored_line = 0;
+        $access = true;
     } else if ($config['id_user'] == $event['owner_user']) {
         // Do nothing if you're the owner user, you get access.
-        $__ignored_line = 0;
+        $access = true;
     } else if ($event['id_grupo'] == 0) {
         // If the event has access to all groups, you get access.
-        $__ignored_line = 0;
+        $access = true;
     } else {
         // Get your groups.
         $groups = users_get_groups($config['id_user'], 'ER');
 
         if (in_array($event['id_grupo'], array_keys($groups))) {
             // If event group is among the groups of the user, you get access.
-            $__ignored_line = 0;
-        } else {
-            // If all the access types fail, abort.
-            echo 'Access denied';
-            return false;
+            $access = true;
+        } else if ($event['id_agente']
+            && agents_check_access_agent($event['id_agente'], 'ER')
+        ) {
+            // Secondary group, indirect access.
+            $access = true;
         }
     }
 
+    if (!$access) {
+        // If all the access types fail, abort.
+        echo 'Access denied';
+        return false;
+    }
+
     // Print group_rep in a hidden field to recover it from javascript.
     html_print_input_hidden('group_rep', (int) $group_rep);
 
diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php
index 9339322a7d..da2efa1bd1 100644
--- a/pandora_console/include/functions_events.php
+++ b/pandora_console/include/functions_events.php
@@ -641,32 +641,37 @@ function events_get_all(
         }
     }
 
-    if (isset($filter['id_group_filter']) && $filter['id_group_filter'] > 0) {
+    $groups = $filter['id_group_filter'];
+    if (isset($groups) && $groups > 0) {
         $propagate = db_get_value(
             'propagate',
             'tgrupo',
             'id_grupo',
-            $filter['id_group_filter']
+            $groups
         );
 
         if (!$propagate) {
             $sql_filters[] = sprintf(
-                ' AND te.id_grupo = %d ',
-                $filter['id_group_filter']
+                ' AND (te.id_grupo = %d OR tasg.id_group = %d)',
+                $groups
             );
         } else {
-            $groups = [ $filter['id_group_filter'] ];
-            $childrens = groups_get_childrens($id_group, null, true);
-            if (!empty($childrens)) {
-                foreach ($childrens as $child) {
-                    $groups[] = (int) $child['id_grupo'];
+            $children = groups_get_children($groups);
+            $_groups = [];
+            if (!empty($children)) {
+                foreach ($children as $child) {
+                    $_groups[] = (int) $child['id_grupo'];
                 }
+
+                $groups = $_groups;
+            } else {
+                $groups = [ $groups ];
             }
 
-            $filter['id_group_filter'] = $groups;
             $sql_filters[] = sprintf(
-                ' AND id_group IN (%s) ',
-                join(',', $filter['id_group_filter'])
+                ' AND (te.id_grupo IN (%s) OR tasg.id_group IN (%s)',
+                join(',', array_keys($groups)),
+                join(',', array_keys($groups))
             );
         }
     }
@@ -702,8 +707,6 @@ function events_get_all(
         }
     }
 
-    $sg_active = enterprise_hook('agents_is_using_secondary_groups');
-
     if (!$user_is_admin) {
         $ER_groups = users_get_groups($config['id_user'], 'ER', false);
         $EM_groups = users_get_groups($config['id_user'], 'EM', false, true);
@@ -713,7 +716,8 @@ function events_get_all(
     if (!$user_is_admin && !users_can_manage_group_all('ER')) {
         // Get groups where user have ER grants.
         $sql_filters[] = sprintf(
-            ' AND te.id_grupo IN ( %s )',
+            ' AND (te.id_grupo IN ( %s ) OR tasg.id_group IN (%s))',
+            join(', ', array_keys($ER_groups)),
             join(', ', array_keys($ER_groups))
         );
     }
@@ -1036,12 +1040,24 @@ function events_get_all(
 
     $tgrupo_join = 'LEFT';
     $tgrupo_join_filters = [];
-    if (isset($filter['id_group_filter']) && $filter['id_group_filter'] > 0) {
+    if (isset($groups)
+        && (is_array($groups)
+        || $groups > 0)
+    ) {
         $tgrupo_join = 'INNER';
-        $tgrupo_join_filters[] = sprintf(
-            ' AND tg.id_grupo = %s',
-            $filter['id_group_filter']
-        );
+        if (is_array($groups)) {
+            $tgrupo_join_filters[] = sprintf(
+                ' AND (tg.id_grupo IN (%s) OR tasg.id_group IN (%s))',
+                join(', ', array_keys($groups)),
+                join(', ', array_keys($groups))
+            );
+        } else {
+            $tgrupo_join_filters[] = sprintf(
+                ' AND (tg.id_grupo = %s OR tasg.id_group = %s)',
+                $groups,
+                $groups
+            );
+        }
     }
 
     // Secondary groups.
diff --git a/pandora_console/include/functions_groups.php b/pandora_console/include/functions_groups.php
index 8fe37c0e48..0e88d86004 100644
--- a/pandora_console/include/functions_groups.php
+++ b/pandora_console/include/functions_groups.php
@@ -298,6 +298,53 @@ function groups_get_childrens_ids($parent, $groups=null)
 
 
 /**
+ * Return a array of id_group of children of given parent.
+ *
+ * @param integer $parent          The id_grupo parent to search its children.
+ * @param array   $ignorePropagate Ignore propagate.
+ */
+function groups_get_children($parent, $ignorePropagate=false)
+{
+    static $groups;
+
+    if (empty($groups)) {
+        $groups = db_get_all_rows_in_table('tgrupo');
+        $groups = array_reduce(
+            $groups,
+            function ($carry, $item) {
+                $carry[$item['id_grupo']] = $item;
+                return $carry;
+            }
+        );
+    }
+
+    $return = [];
+    foreach ($groups as $key => $g) {
+        if ($g['id_grupo'] == 0) {
+            continue;
+        }
+
+        if ($ignorePropagate || $parent == 0 || $groups[$parent]['propagate']) {
+            if ($g['parent'] == $parent) {
+                $return += [$g['id_grupo'] => $g];
+                if ($g['propagate'] || $ignorePropagate) {
+                    $return += groups_get_children(
+                        $g['id_grupo'],
+                        $ignorePropagate
+                    )
+                    );
+                }
+            }
+        }
+    }
+
+    return $return;
+}
+
+
+/**
+ * XXX: This is not working. Expects 'propagate' on CHILD not on PARENT!!!
+ *
  * Return a array of id_group of childrens (to branches down)
  *
  * @param integer $parent The id_group parent to search the childrens.
diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php
index 88621b7711..95ac221164 100644
--- a/pandora_console/operation/events/events.php
+++ b/pandora_console/operation/events/events.php
@@ -1591,38 +1591,6 @@ function process_datatables_item(item) {
     module_status = '<div class="criticity" style="background: ';
     module_status += color + '">' + text + "</div>";
 
-
-    /* Agent name link */
-    if (item.id_agente > 0) {
-        item.agent_name = '<a href="<?php echo ui_get_full_url('index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='); ?>' +item.id_agente+'">' + item.agent_name + '</a>';
-    } else {
-        item.agent_name = '';
-    }
-
-    /* Agent ID link */
-    if (item.id_agente > 0) {
-        <?php
-        if (in_array('agent_name', $fields)) {
-            ?>
-            item.id_agente = '<a href="<?php echo ui_get_full_url('index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='); ?>'+item.id_agente+'">' + item.id_agente + '</a>';
-            <?php
-        } else {
-            ?>
-            item.id_agente = '<a href="<?php echo ui_get_full_url('index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='); ?>'+item.id_agente+'">' + item.agent_name + '</a>';
-            <?php
-        }
-        ?>
-    } else {
-        item.id_agente = '';
-    }
-
-    /* Group name */
-    if (item.id_grupo == "0") {
-        item.id_grupo = "<?php echo __('All'); ?>";
-    } else {
-        item.id_grupo = item.group_name;
-    }
-
     /* Options */
     // Show more.
     item.options = '<a href="javascript:" onclick="show_event_dialog(\'';
@@ -1700,6 +1668,31 @@ function process_datatables_item(item) {
     }
 
     /* Update column content now to avoid json poisoning. */
+
+    /* Agent name link */
+    if (item.id_agente > 0) {
+        item.agent_name = '<a href="<?php echo ui_get_full_url('index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='); ?>' +item.id_agente+'">' + item.agent_name + '</a>';
+    } else {
+        item.agent_name = '';
+    }
+
+    /* Agent ID link */
+    if (item.id_agente > 0) {
+        <?php
+        if (in_array('agent_name', $fields)) {
+            ?>
+            item.id_agente = '<a href="<?php echo ui_get_full_url('index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='); ?>'+item.id_agente+'">' + item.id_agente + '</a>';
+            <?php
+        } else {
+            ?>
+            item.id_agente = '<a href="<?php echo ui_get_full_url('index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='); ?>'+item.id_agente+'">' + item.agent_name + '</a>';
+            <?php
+        }
+        ?>
+    } else {
+        item.id_agente = '';
+    }
+
     item.estado = '<div>';
     item.estado += img;
     item.estado += '</div>';
@@ -1719,6 +1712,13 @@ function process_datatables_item(item) {
     // Add event severity format to itself.
     item.evento = evn;
 
+    /* Group name */
+    if (item.id_grupo == "0") {
+        item.id_grupo = "<?php echo __('All'); ?>";
+    } else {
+        item.id_grupo = item.group_name;
+    }
+
 }
 
 /* Datatables auxiliary functions ends */

From 6b944ead9735241fa50e550f816f0691708fe9c6 Mon Sep 17 00:00:00 2001
From: fbsanchez <fborja.sanchez@artica.es>
Date: Wed, 19 Jun 2019 17:08:18 +0200
Subject: [PATCH 13/37] minor fix

---
 pandora_console/include/functions_groups.php | 1 -
 1 file changed, 1 deletion(-)

diff --git a/pandora_console/include/functions_groups.php b/pandora_console/include/functions_groups.php
index 0e88d86004..a1448e37f2 100644
--- a/pandora_console/include/functions_groups.php
+++ b/pandora_console/include/functions_groups.php
@@ -331,7 +331,6 @@ function groups_get_children($parent, $ignorePropagate=false)
                     $return += groups_get_children(
                         $g['id_grupo'],
                         $ignorePropagate
-                    )
                     );
                 }
             }

From 275261e6b3ce2777f7c19eea5419de706dffd3be Mon Sep 17 00:00:00 2001
From: fbsanchez <fborja.sanchez@artica.es>
Date: Wed, 19 Jun 2019 17:30:32 +0200
Subject: [PATCH 14/37] wip csv export events

---
 pandora_console/operation/events/events.php   | 26 ++++++++++++++-----
 .../operation/events/export_csv.php           | 15 +++++++++++
 2 files changed, 34 insertions(+), 7 deletions(-)

diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php
index 95ac221164..400f3e9d6d 100644
--- a/pandora_console/operation/events/events.php
+++ b/pandora_console/operation/events/events.php
@@ -111,11 +111,11 @@ $id_extra = get_parameter('filter[id_extra]');
 $user_comment = get_parameter('filter[user_comment]');
 $history = get_parameter('history', false);
 $section = get_parameter('section', false);
+$filter = get_parameter('filter', []);
 
 // Ajax responses.
 if (is_ajax()) {
     $get_events = get_parameter('get_events', 0);
-    $filter = get_parameter('filter', []);
     // Datatables offset, limit.
     $start = get_parameter('start', 0);
     $length = get_parameter('length', $config['block_size']);
@@ -493,27 +493,27 @@ if ($pure) {
 
     // Fullscreen.
     $fullscreen['active'] = false;
-    $fullscreen['text'] = '<a href="'.$url.'&amp;pure=1">'.html_print_image('images/full_screen.png', true, ['title' => __('Full screen')]).'</a>';
+    $fullscreen['text'] = '<a class="events_link" href="'.$url.'&amp;pure=1">'.html_print_image('images/full_screen.png', true, ['title' => __('Full screen')]).'</a>';
 
     // Event list.
     $list['active'] = false;
-    $list['text'] = '<a href="index.php?sec=eventos&sec2=operation/events/events&amp;pure='.$config['pure'].'">'.html_print_image('images/events_list.png', true, ['title' => __('Event list')]).'</a>';
+    $list['text'] = '<a class="events_link" href="index.php?sec=eventos&sec2=operation/events/events&amp;pure='.$config['pure'].'">'.html_print_image('images/events_list.png', true, ['title' => __('Event list')]).'</a>';
 
     // History event list.
     $history_list['active'] = false;
-    $history_list['text'] = '<a href="index.php?sec=eventos&sec2=operation/events/events&amp;pure='.$config['pure'].'&amp;section=history&amp;history=1">'.html_print_image('images/books.png', true, ['title' => __('History event list')]).'</a>';
+    $history_list['text'] = '<a class="events_link" href="index.php?sec=eventos&sec2=operation/events/events&amp;pure='.$config['pure'].'&amp;section=history&amp;history=1">'.html_print_image('images/books.png', true, ['title' => __('History event list')]).'</a>';
 
     // RSS.
     $rss['active'] = false;
-    $rss['text'] = '<a href="operation/events/events_rss.php?user='.$config['id_user'].'&hashup='.$hashup.'&'.$params.'">'.html_print_image('images/rss.png', true, ['title' => __('RSS Events')]).'</a>';
+    $rss['text'] = '<a class="events_link" href="operation/events/events_rss.php?user='.$config['id_user'].'&hashup='.$hashup.'&'.$params.'">'.html_print_image('images/rss.png', true, ['title' => __('RSS Events')]).'</a>';
 
     // Marquee.
     $marquee['active'] = false;
-    $marquee['text'] = '<a href="operation/events/events_marquee.php">'.html_print_image('images/heart.png', true, ['title' => __('Marquee display')]).'</a>';
+    $marquee['text'] = '<a class="events_link" href="operation/events/events_marquee.php">'.html_print_image('images/heart.png', true, ['title' => __('Marquee display')]).'</a>';
 
     // CSV.
     $csv['active'] = false;
-    $csv['text'] = '<a href="operation/events/export_csv.php?'.$params.'">'.html_print_image('images/csv_mc.png', true, ['title' => __('Export to CSV file')]).'</a>';
+    $csv['text'] = '<a class="events_link" href="operation/events/export_csv.php?fb64='.$filter_b64.'">'.html_print_image('images/csv_mc.png', true, ['title' => __('Export to CSV file')]).'</a>';
 
     // Sound events.
     $sound_event['active'] = false;
@@ -1969,6 +1969,18 @@ function reorder_tags_inputs() {
 /* Tag management ends */
 $(document).ready( function() {
 
+    /* Filter to a href */
+    $('.events_link').on('click', function(e) {
+        e.preventDefault();
+
+        console.log(e.currentTarget);
+
+        
+
+
+
+    });
+
     /* Multi select handler */
     $('#checkbox-all_validate_box').on('change', function() {
         if($('#checkbox-all_validate_box').is(":checked")) {
diff --git a/pandora_console/operation/events/export_csv.php b/pandora_console/operation/events/export_csv.php
index dbc20abb6a..be0bb52b71 100644
--- a/pandora_console/operation/events/export_csv.php
+++ b/pandora_console/operation/events/export_csv.php
@@ -27,6 +27,21 @@ if (! check_acl($config['id_user'], 0, 'ER') && ! check_acl($config['id_user'],
     exit;
 }
 
+hd($_REQUEST);
+
+$fb64 = get_parameter('fb64', '');
+
+
+try {
+    $filter = json_decode(base64_decode($fb64), true);
+} catch (Exception $e) {
+    echo $e;
+    exit;
+}
+
+hd($filter);
+
+die();
 global $config;
 
 // loading l10n tables, because of being invoked not through index.php.

From e828fd6690f744b46b5efa021dff247a69658364 Mon Sep 17 00:00:00 2001
From: Daniel Maya <daniel.maya@artica.es>
Date: Thu, 20 Jun 2019 09:49:54 +0200
Subject: [PATCH 15/37] Fixed Advanced Permissions LDAP

---
 pandora_console/include/auth/mysql.php | 109 ++++++++++---------------
 1 file changed, 42 insertions(+), 67 deletions(-)

diff --git a/pandora_console/include/auth/mysql.php b/pandora_console/include/auth/mysql.php
index 5ef2fed828..ed5e56782a 100644
--- a/pandora_console/include/auth/mysql.php
+++ b/pandora_console/include/auth/mysql.php
@@ -1257,11 +1257,8 @@ function fill_permissions_ldap($sr)
     global $config;
     $permissions = [];
     $permissions_profile = [];
-    if (defined('METACONSOLE')) {
-        $meta = true;
-    }
 
-    if ($meta && (bool) $config['ldap_save_profile'] === false && $config['ldap_advanced_config'] == 0) {
+    if ((bool) $config['ldap_save_profile'] === false && ($config['ldap_advanced_config'] == 0 || $config['ldap_advanced_config'] == '')) {
         $result = 0;
         $result = db_get_all_rows_filter(
             'tusuario_perfil',
@@ -1287,43 +1284,9 @@ function fill_permissions_ldap($sr)
         return $permissions_profile;
     }
 
-    if ((bool) $config['ldap_save_profile'] === false && $config['ldap_advanced_config'] == '') {
-        $result = db_get_all_rows_filter(
-            'tusuario_perfil',
-            ['id_usuario' => $sr['uid'][0]]
-        );
-        if ($result == false) {
-            $permissions[0]['profile'] = $config['default_remote_profile'];
-            $permissions[0]['groups'][] = $config['default_remote_group'];
-            $permissions[0]['tags'] = $config['default_assign_tags'];
-            $permissions[0]['no_hierarchy'] = $config['default_no_hierarchy'];
-            return $permissions;
-        }
-
-        foreach ($result as $perms) {
-               $permissions_profile[] = [
-                   'profile'      => $perms['id_perfil'],
-                   'groups'       => [$perms['id_grupo']],
-                   'tags'         => $perms['tags'],
-                   'no_hierarchy' => (bool) $perms['no_hierarchy'] ? 1 : 0,
-               ];
-        }
-
-        return $permissions_profile;
-    }
-
     if ($config['ldap_advanced_config'] == 1 && $config['ldap_save_profile'] == 1) {
         $ldap_adv_perms = json_decode(io_safe_output($config['ldap_adv_perms']), true);
-        foreach ($ldap_adv_perms as $ldap_adv_perm) {
-            $permissions[] = [
-                'profile'      => $ldap_adv_perm['profile'],
-                'groups'       => $ldap_adv_perm['group'],
-                'tags'         => implode(',', $ldap_adv_perm['tags']),
-                'no_hierarchy' => (bool) $ldap_adv_perm['no_hierarchy'] ? 1 : 0,
-            ];
-        }
-
-        return $permissions;
+        return get_advanced_permissions($ldap_adv_perms, $sr);
     }
 
     if ($config['ldap_advanced_config'] == 1 && $config['ldap_save_profile'] == 0) {
@@ -1333,25 +1296,16 @@ function fill_permissions_ldap($sr)
         );
         if ($result == false) {
             $ldap_adv_perms = json_decode(io_safe_output($config['ldap_adv_perms']), true);
-            foreach ($ldap_adv_perms as $ldap_adv_perm) {
-                $permissions[] = [
-                    'profile'      => $ldap_adv_perm['profile'],
-                    'groups'       => $ldap_adv_perm['group'],
-                    'tags'         => implode(',', $ldap_adv_perm['tags']),
-                    'no_hierarchy' => (bool) $ldap_adv_perm['no_hierarchy'] ? 1 : 0,
-                ];
-            }
-
-            return $permissions;
+            return get_advanced_permissions($ldap_adv_perms, $sr);
         }
 
         foreach ($result as $perms) {
-               $permissions_profile[] = [
-                   'profile'      => $perms['id_perfil'],
-                   'groups'       => [$perms['id_grupo']],
-                   'tags'         => $perms['tags'],
-                   'no_hierarchy' => (bool) $perms['no_hierarchy'] ? 1 : 0,
-               ];
+            $permissions_profile[] = [
+                'profile'      => $perms['id_perfil'],
+                'groups'       => [$perms['id_grupo']],
+                'tags'         => $perms['tags'],
+                'no_hierarchy' => (bool) $perms['no_hierarchy'] ? 1 : 0,
+            ];
         };
 
         return $permissions_profile;
@@ -1365,22 +1319,43 @@ function fill_permissions_ldap($sr)
         return $permissions;
     }
 
-    // Decode permissions in advanced mode
-    $ldap_adv_perms = json_decode(io_safe_output($config['ldap_adv_perms']), true);
+    return $permissions;
+}
+
+
+/**
+ * Get permissions in advanced mode.
+ *
+ * @param array ldap_adv_perms
+ *
+ * @return array
+ */
+function get_advanced_permissions($ldap_adv_perms, $sr)
+{
+    $permissions = [];
     foreach ($ldap_adv_perms as $ldap_adv_perm) {
         $attributes = $ldap_adv_perm['groups_ldap'];
-        foreach ($attributes as $attr) {
-            $attr = explode('=', $attr, 2);
-            foreach ($sr[$attr[0]] as $s_attr) {
-                if (preg_match('/'.$attr[1].'/', $s_attr)) {
-                    $permissions[] = [
-                        'profile'      => $ldap_adv_perm['profile'],
-                        'groups'       => $ldap_adv_perm['group'],
-                        'tags'         => implode(',', $ldap_adv_perm['tags']),
-                        'no_hierarchy' => (bool) $ldap_adv_perm['no_hierarchy'] ? 1 : 0,
-                    ];
+        if (!empty($attributes[0])) {
+            foreach ($attributes as $attr) {
+                $attr = explode('=', $attr, 2);
+                foreach ($sr[$attr[0]] as $s_attr) {
+                    if (preg_match('/'.$attr[1].'/', $s_attr)) {
+                        $permissions[] = [
+                            'profile'      => $ldap_adv_perm['profile'],
+                            'groups'       => $ldap_adv_perm['group'],
+                            'tags'         => implode(',', $ldap_adv_perm['tags']),
+                            'no_hierarchy' => (bool) $ldap_adv_perm['no_hierarchy'] ? 1 : 0,
+                        ];
+                    }
                 }
             }
+        } else {
+            $permissions[] = [
+                'profile'      => $ldap_adv_perm['profile'],
+                'groups'       => $ldap_adv_perm['group'],
+                'tags'         => implode(',', $ldap_adv_perm['tags']),
+                'no_hierarchy' => (bool) $ldap_adv_perm['no_hierarchy'] ? 1 : 0,
+            ];
         }
     }
 

From cfe16ee8c342564934bbba50c130bc0776450fd1 Mon Sep 17 00:00:00 2001
From: fbsanchez <fborja.sanchez@artica.es>
Date: Thu, 20 Jun 2019 11:46:01 +0200
Subject: [PATCH 16/37] minor fixes

---
 pandora_console/include/functions_events.php  | 141 +++++++-
 pandora_console/operation/events/events.php   |  39 ++-
 .../operation/events/export_csv.php           | 312 ++++++++++--------
 3 files changed, 331 insertions(+), 161 deletions(-)

diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php
index da2efa1bd1..a958a3a957 100644
--- a/pandora_console/include/functions_events.php
+++ b/pandora_console/include/functions_events.php
@@ -34,6 +34,143 @@ enterprise_include_once('meta/include/functions_agents_meta.php');
 enterprise_include_once('meta/include/functions_modules_meta.php');
 
 
+/**
+ * Translates a numeric value module_status into descriptive text.
+ *
+ * @param integer $status Module status.
+ *
+ * @return string Descriptive text.
+ */
+function events_translate_module_status($status)
+{
+    switch ($status) {
+        case AGENT_MODULE_STATUS_NORMAL:
+        return __('NORMAL');
+
+        case AGENT_MODULE_STATUS_CRITICAL_BAD:
+        return __('CRITICAL');
+
+        case AGENT_MODULE_STATUS_NO_DATA:
+        return __('NOT INIT');
+
+        case AGENT_MODULE_STATUS_CRITICAL_ALERT:
+        case AGENT_MODULE_STATUS_NORMAL_ALERT:
+        case AGENT_MODULE_STATUS_WARNING_ALERT:
+        return __('ALERT');
+
+        case AGENT_MODULE_STATUS_WARNING:
+        return __('WARNING');
+
+        default:
+        return __('UNKNOWN');
+    }
+}
+
+
+/**
+ * Translates a numeric value event_type into descriptive text.
+ *
+ * @param integer $event_type Event type.
+ *
+ * @return string Descriptive text.
+ */
+function events_translate_event_type($event_type)
+{
+    // Event type prepared.
+    switch ($event_type) {
+        case EVENTS_ALERT_FIRED:
+        case EVENTS_ALERT_RECOVERED:
+        case EVENTS_ALERT_CEASED:
+        case EVENTS_ALERT_MANUAL_VALIDATION:
+        return __('ALERT');
+
+        case EVENTS_RECON_HOST_DETECTED:
+        case EVENTS_SYSTEM:
+        case EVENTS_ERROR:
+        case EVENTS_NEW_AGENT:
+        case EVENTS_CONFIGURATION_CHANGE:
+        return __('SYSTEM');
+
+        case EVENTS_GOING_UP_WARNING:
+        case EVENTS_GOING_DOWN_WARNING:
+        return __('WARNING');
+
+        case EVENTS_GOING_DOWN_NORMAL:
+        case EVENTS_GOING_UP_NORMAL:
+        return __('NORMAL');
+
+        case EVENTS_GOING_DOWN_CRITICAL:
+        case EVENTS_GOING_UP_CRITICAL:
+        return __('CRITICAL');
+
+        case EVENTS_UNKNOWN:
+        case EVENTS_GOING_UNKNOWN:
+        default:
+        return __('UNKNOWN');
+    }
+}
+
+
+/**
+ * Translates a numeric value event_status into descriptive text.
+ *
+ * @param integer $status Event status.
+ *
+ * @return string Descriptive text.
+ */
+function events_translate_event_status($status)
+{
+    switch ($status) {
+        case EVENT_STATUS_NEW:
+        default:
+        return __('NEW');
+
+        case EVENT_STATUS_INPROCESS:
+        return __('IN PROCESS');
+
+        case EVENT_STATUS_VALIDATED:
+        return __('VALIDATED');
+    }
+}
+
+
+/**
+ * Translates a numeric value criticity into descriptive text.
+ *
+ * @param integer $criticity Event criticity.
+ *
+ * @return string Descriptive text.
+ */
+function events_translate_event_criticity($criticity)
+{
+    switch ($criticity) {
+        case EVENT_CRIT_CRITICAL:
+        return __('CRITICAL');
+
+        case EVENT_CRIT_MAINTENANCE:
+        return __('MAINTENANCE');
+
+        case EVENT_CRIT_INFORMATIONAL:
+        return __('INFORMATIONAL');
+
+        case EVENT_CRIT_MAJOR:
+        return __('MAJOR');
+
+        case EVENT_CRIT_MINOR:
+        return __('MINOR');
+
+        case EVENT_CRIT_NORMAL:
+        return __('NORMAL');
+
+        case EVENT_CRIT_WARNING:
+        return __('WARNING');
+
+        default:
+        return __('UNKNOWN');
+    }
+}
+
+
 /**
  * Return all header string for each event field.
  *
@@ -6465,10 +6602,6 @@ function events_get_sql_order($sort_field='timestamp', $sort='DESC', $group_rep=
  */
 function events_get_secondary_groups_left_join($table)
 {
-    if (users_is_admin()) {
-        return '';
-    }
-
     if ($table == 'tevento') {
         return 'LEFT JOIN tagent_secondary_group tasg ON te.id_agente = tasg.id_agent';
     }
diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php
index 400f3e9d6d..ec073082bf 100644
--- a/pandora_console/operation/events/events.php
+++ b/pandora_console/operation/events/events.php
@@ -1,7 +1,6 @@
 <?php
 /**
- * Extension to manage a list of gateways and the node address where they should
- * point to.
+ * Event list.
  *
  * @category   Events
  * @package    Pandora FMS
@@ -493,27 +492,27 @@ if ($pure) {
 
     // Fullscreen.
     $fullscreen['active'] = false;
-    $fullscreen['text'] = '<a class="events_link" href="'.$url.'&amp;pure=1">'.html_print_image('images/full_screen.png', true, ['title' => __('Full screen')]).'</a>';
+    $fullscreen['text'] = '<a class="events_link" href="'.$url.'&amp;pure=1&">'.html_print_image('images/full_screen.png', true, ['title' => __('Full screen')]).'</a>';
 
     // Event list.
     $list['active'] = false;
-    $list['text'] = '<a class="events_link" href="index.php?sec=eventos&sec2=operation/events/events&amp;pure='.$config['pure'].'">'.html_print_image('images/events_list.png', true, ['title' => __('Event list')]).'</a>';
+    $list['text'] = '<a class="events_link" href="index.php?sec=eventos&sec2=operation/events/events&amp;pure='.$config['pure'].'&">'.html_print_image('images/events_list.png', true, ['title' => __('Event list')]).'</a>';
 
     // History event list.
     $history_list['active'] = false;
-    $history_list['text'] = '<a class="events_link" href="index.php?sec=eventos&sec2=operation/events/events&amp;pure='.$config['pure'].'&amp;section=history&amp;history=1">'.html_print_image('images/books.png', true, ['title' => __('History event list')]).'</a>';
+    $history_list['text'] = '<a class="events_link" href="index.php?sec=eventos&sec2=operation/events/events&amp;pure='.$config['pure'].'&amp;section=history&amp;history=1&">'.html_print_image('images/books.png', true, ['title' => __('History event list')]).'</a>';
 
     // RSS.
     $rss['active'] = false;
-    $rss['text'] = '<a class="events_link" href="operation/events/events_rss.php?user='.$config['id_user'].'&hashup='.$hashup.'&'.$params.'">'.html_print_image('images/rss.png', true, ['title' => __('RSS Events')]).'</a>';
+    $rss['text'] = '<a class="events_link" href="operation/events/events_rss.php?user='.$config['id_user'].'&hashup='.$hashup.'&">'.html_print_image('images/rss.png', true, ['title' => __('RSS Events')]).'</a>';
 
     // Marquee.
     $marquee['active'] = false;
-    $marquee['text'] = '<a class="events_link" href="operation/events/events_marquee.php">'.html_print_image('images/heart.png', true, ['title' => __('Marquee display')]).'</a>';
+    $marquee['text'] = '<a class="events_link" href="operation/events/events_marquee.php?">'.html_print_image('images/heart.png', true, ['title' => __('Marquee display')]).'</a>';
 
     // CSV.
     $csv['active'] = false;
-    $csv['text'] = '<a class="events_link" href="operation/events/export_csv.php?fb64='.$filter_b64.'">'.html_print_image('images/csv_mc.png', true, ['title' => __('Export to CSV file')]).'</a>';
+    $csv['text'] = '<a class="events_link" href="operation/events/export_csv.php?'.$filter_b64.'">'.html_print_image('images/csv_mc.png', true, ['title' => __('Export to CSV file')]).'</a>';
 
     // Sound events.
     $sound_event['active'] = false;
@@ -1225,6 +1224,7 @@ try {
     $active_filters_div .= '</div>';
 
     $table_id = 'events';
+    $form_id = 'events_form';
 
     // Print datatable.
     ui_print_datatable(
@@ -1238,7 +1238,7 @@ try {
                 'history'    => (int) $history,
             ],
             'form'                => [
-                'id'            => 'events_form',
+                'id'            => $form_id,
                 'class'         => 'flex-row',
                 'html'          => $filter,
                 'inputs'        => [],
@@ -1528,7 +1528,7 @@ function process_datatables_item(item) {
 
         case "<?php echo EVENTS_GOING_UP_WARNING; ?>":
         case "<?php echo EVENTS_GOING_DOWN_WARNING; ?>":
-        $tex = "<?php echo __('WARNING'); ?>";
+            text = "<?php echo __('WARNING'); ?>";
             color = "<?php echo COL_WARNING; ?>";
         break;
 
@@ -1654,15 +1654,15 @@ function process_datatables_item(item) {
     /* Status */
     img = '<?php echo html_print_image('images/star.png', true, ['title' => __('Unknown'), 'class' => 'forced-title']); ?>';
     switch (item.estado) {
-        case "0":
+        case "<?php echo EVENT_STATUS_NEW; ?>":
             img = '<?php echo html_print_image('images/star.png', true, ['title' => __('New event'), 'class' => 'forced-title']); ?>';
         break;
 
-        case "1":
+        case "<?php echo EVENT_STATUS_VALIDATED; ?>":
             img = '<?php echo html_print_image('images/tick.png', true, [ 'title' => __('Event validated'), 'class' => 'forced-title']); ?>';
         break;
 
-        case "2":
+        case "<?php echo EVENT_STATUS_INPROCESS; ?>":
             img = '<?php echo html_print_image('images/hourglass.png', true, [ 'title' => __('Event in process'), 'class' => 'forced-title']); ?>';
         break;
     }
@@ -1968,16 +1968,21 @@ function reorder_tags_inputs() {
 }
 /* Tag management ends */
 $(document).ready( function() {
-
     /* Filter to a href */
     $('.events_link').on('click', function(e) {
         e.preventDefault();
 
-        console.log(e.currentTarget);
-
-        
+        inputs = $("#<?php echo $form_id; ?> :input");
+        values = {};
+        inputs.each(function() {
+            values[this.name] = $(this).val();
+        })
 
+        values['history'] = "<?php echo (int) $history; ?>";
 
+        var url = e.currentTarget.href;
+        url += 'fb64=' + btoa(JSON.stringify(values));
+        document.location = url;
 
     });
 
diff --git a/pandora_console/operation/events/export_csv.php b/pandora_console/operation/events/export_csv.php
index be0bb52b71..0c16a16f9d 100644
--- a/pandora_console/operation/events/export_csv.php
+++ b/pandora_console/operation/events/export_csv.php
@@ -1,18 +1,34 @@
 <?php
+/**
+ * Event CSV exporter.
+ *
+ * @category   Event CSV export
+ * @package    Pandora FMS
+ * @subpackage Community
+ * @version    1.0.0
+ * @license    See below
+ *
+ *    ______                 ___                    _______ _______ ________
+ *   |   __ \.-----.--.--.--|  |.-----.----.-----. |    ___|   |   |     __|
+ *  |    __/|  _  |     |  _  ||  _  |   _|  _  | |    ___|       |__     |
+ * |___|   |___._|__|__|_____||_____|__| |___._| |___|   |__|_|__|_______|
+ *
+ * ============================================================================
+ * Copyright (c) 2005-2019 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.
+global $config;
 
-// Pandora FMS - http://pandorafms.com
-// ==================================================
-// Copyright (c) 2005-2009 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.
-// Don't start a session before this import.
-// The session is configured and started inside the config process.
 require_once '../../include/config.php';
 require_once '../../include/auth/mysql.php';
 require_once '../../include/functions.php';
@@ -23,149 +39,165 @@ require_once '../../include/functions_groups.php';
 
 $config['id_user'] = $_SESSION['id_usuario'];
 
-if (! check_acl($config['id_user'], 0, 'ER') && ! check_acl($config['id_user'], 0, 'EW') && ! check_acl($config['id_user'], 0, 'EM')) {
+if (! check_acl($config['id_user'], 0, 'ER')
+    && ! check_acl($config['id_user'], 0, 'EW')
+    && ! check_acl($config['id_user'], 0, 'EM')
+) {
     exit;
 }
 
-hd($_REQUEST);
-
-$fb64 = get_parameter('fb64', '');
-
-
-try {
-    $filter = json_decode(base64_decode($fb64), true);
-} catch (Exception $e) {
-    echo $e;
-    exit;
-}
-
-hd($filter);
-
-die();
-global $config;
-
-// loading l10n tables, because of being invoked not through index.php.
+// Loading l10n tables, because of being invoked not through index.php.
 $l10n = null;
 if (file_exists($config['homedir'].'/include/languages/'.$user_language.'.mo')) {
-    $l10n = new gettext_reader(new CachedFileReader($config['homedir'].'/include/languages/'.$user_language.'.mo'));
+    $cfr = new CachedFileReader(
+        $config['homedir'].'/include/languages/'.$user_language.'.mo'
+    );
+    $l10n = new gettext_reader($cfr);
     $l10n->load_tables();
 }
 
-$offset = (int) get_parameter('offset');
-$id_group = (int) get_parameter('id_group');
-// group
-$event_type = (string) get_parameter('event_type', 'all');
-// 0 all
-$severity = (int) get_parameter('severity', -1);
-// -1 all
-$status = (int) get_parameter('status', -1);
-// -1 all, 0 only red, 1 only green
-$id_agent = (int) get_parameter('id_agent', -1);
+$column_names = [
+    'id_evento',
+    'evento',
+    'timestamp',
+    'estado',
+    'event_type',
+    'utimestamp',
+    'id_agente',
+    'agent_name',
+    'id_usuario',
+    'id_grupo',
+    'id_agentmodule',
+    'id_alert_am',
+    'criticity',
+    'user_comment',
+    'tags',
+    'source',
+    'id_extra',
+    'critical_instructions',
+    'warning_instructions',
+    'unknown_instructions',
+    'owner_user',
+    'ack_utimestamp',
+    'custom_data',
+    'data',
+    'module_status',
+];
 
-$id_event = (int) get_parameter('id_event', -1);
-$event_view_hr = (int) get_parameter('event_view_hr', $config['event_view_hr']);
-$id_user_ack = get_parameter('id_user_ack', 0);
-$search = io_safe_output(preg_replace('/&([A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/', '&', rawurldecode(get_parameter('search'))));
-$text_agent = (string) get_parameter('text_agent', __('All'));
-
-$tag_with_json = base64_decode(get_parameter('tag_with', ''));
-$tag_with_json_clean = io_safe_output($tag_with_json);
-$tag_with_base64 = base64_encode($tag_with_json_clean);
-$tag_with = json_decode($tag_with_json_clean, true);
-if (empty($tag_with)) {
-    $tag_with = [];
-}
-
-$tag_with = array_diff($tag_with, [0 => 0]);
-
-$tag_without_json = base64_decode(get_parameter('tag_without', ''));
-$tag_without_json_clean = io_safe_output($tag_without_json);
-$tag_without_base64 = base64_encode($tag_without_json_clean);
-$tag_without = json_decode($tag_without_json_clean, true);
-if (empty($tag_without)) {
-    $tag_without = [];
-}
-
-$tag_without = array_diff($tag_without, [0 => 0]);
-
-$filter_only_alert = (int) get_parameter('filter_only_alert', -1);
-
-//
-// Build the condition of the events query
-$sql_post = '';
-$meta = false;
-
-$id_user = $config['id_user'];
-
-require 'events.build_query.php';
-
-// Now $sql_post have all the where condition
-//
-switch ($config['dbtype']) {
-    case 'mysql':
-    case 'postgresql':
-    case 'oracle':
-        $sql = 'SELECT *
-			FROM tevento te
-			LEFT JOIN tagent_secondary_group tasg
-				ON te.id_grupo = tasg.id_group
-			WHERE 1=1 '.$sql_post.'
-			ORDER BY utimestamp DESC';
-    break;
-}
+$fields = [
+    'te.id_evento',
+    'te.evento',
+    'te.timestamp',
+    'te.estado',
+    'te.event_type',
+    'te.utimestamp',
+    'te.id_agente',
+    'ta.alias as agent_name',
+    'te.id_usuario',
+    'te.id_grupo',
+    'te.id_agentmodule',
+    'am.nombre as module_name',
+    'te.id_alert_am',
+    'te.criticity',
+    'te.user_comment',
+    'te.tags',
+    'te.source',
+    'te.id_extra',
+    'te.critical_instructions',
+    'te.warning_instructions',
+    'te.unknown_instructions',
+    'te.owner_user',
+    'te.ack_utimestamp',
+    'te.custom_data',
+    'te.data',
+    'te.module_status',
+    'tg.nombre as group_name',
+];
 
 $now = date('Y-m-d');
 
-// Show contentype header
+// Download header.
 header('Content-type: text/txt');
 header('Content-Disposition: attachment; filename="pandora_export_event'.$now.'.csv"');
 
-echo 'timestamp';
-echo $config['csv_divider'];
-echo 'agent';
-echo $config['csv_divider'];
-echo 'group';
-echo $config['csv_divider'];
-echo 'event';
-echo $config['csv_divider'];
-echo 'status';
-echo $config['csv_divider'];
-echo 'user';
-echo $config['csv_divider'];
-echo 'event_type';
-echo $config['csv_divider'];
-echo 'severity';
-echo $config['csv_divider'];
-echo 'id';
-echo chr(13);
-
-$new = true;
-while ($event = db_get_all_row_by_steps_sql($new, $result, $sql)) {
-    $new = false;
-    $alias = db_get_value('alias', 'tagente', 'id_agente', $event['id_agente']);
-    if ((!check_acl($config['id_user'], $event['id_grupo'], 'ER')
-        && !check_acl($config['id_user'], $event['id_grupo'], 'EW') && !check_acl($config['id_user'], $event['id_grupo'], 'EM') )
-        || (!check_acl($config['id_user'], 0, 'PM') && $event['event_type'] == 'system')
-    ) {
-        continue;
+try {
+    $fb64 = get_parameter('fb64', null);
+    $plain_filter = base64_decode($fb64);
+    $filter = json_decode($plain_filter, true);
+    if (json_last_error() != JSON_ERROR_NONE) {
+        throw new Exception('Invalid filter. ['.$plain_filter.']');
+    }
+
+    $names = events_get_column_names($column_names);
+
+    // Dump headers.
+    foreach ($names as $n) {
+        echo io_safe_output($n).$config['csv_divider'];
     }
 
-    echo date($config['date_format'], $event['utimestamp']);
-    echo $config['csv_divider'];
-    echo io_safe_output($alias);
-    echo $config['csv_divider'];
-    echo io_safe_output(groups_get_name($event['id_grupo']));
-    echo $config['csv_divider'];
-    echo io_safe_output($event['evento']);
-    echo $config['csv_divider'];
-    echo io_safe_output($event['estado']);
-    echo $config['csv_divider'];
-    echo io_safe_output($event['id_usuario']);
-    echo $config['csv_divider'];
-    echo io_safe_output($event['event_type']);
-    echo $config['csv_divider'];
-    echo $event['criticity'];
-    echo $config['csv_divider'];
-    echo $event['id_evento'];
     echo chr(13);
+
+    // Dump events.
+    $events_per_step = 1000;
+    $step = 0;
+    while (1) {
+        $events = events_get_all(
+            $fields,
+            $filter,
+            (($step++) * $events_per_step),
+            $events_per_step,
+            'desc',
+            'timestamp',
+            $filter['history']
+        );
+
+        if ($events === false) {
+            break;
+        }
+
+        foreach ($events as $row) {
+            foreach ($column_names as $val) {
+                $key = $val;
+                if ($val == 'id_grupo') {
+                    $key = 'group_name';
+                } else if ($val == 'id_agentmodule') {
+                    $key = 'module_name';
+                }
+
+                switch ($key) {
+                    case 'module_status':
+                        echo events_translate_module_status(
+                            $row[$key]
+                        );
+                    break;
+
+                    case 'event_type':
+                        echo events_translate_event_type(
+                            $row[$key]
+                        );
+                    break;
+
+                    case 'criticity':
+                        echo events_translate_event_criticity(
+                            $row[$key]
+                        );
+                    break;
+
+                    default:
+                        echo io_safe_output($row[$key]);
+                    break;
+                }
+
+                echo $config['csv_divider'];
+            }
+
+            echo chr(13);
+        }
+    }
+} catch (Exception $e) {
+    echo 'ERROR'.chr(13);
+    echo $e->getMessage();
+    exit;
 }
+
+exit;

From aa238165d97964a67047dda592e9f56bae9a0735 Mon Sep 17 00:00:00 2001
From: fbsanchez <fborja.sanchez@artica.es>
Date: Thu, 20 Jun 2019 13:33:37 +0200
Subject: [PATCH 17/37] events rss

---
 .../operation/events/events_rss.php           | 492 +++++++++++-------
 1 file changed, 299 insertions(+), 193 deletions(-)

diff --git a/pandora_console/operation/events/events_rss.php b/pandora_console/operation/events/events_rss.php
index 2a38643a9c..95ce7cd07b 100644
--- a/pandora_console/operation/events/events_rss.php
+++ b/pandora_console/operation/events/events_rss.php
@@ -1,18 +1,37 @@
 <?php
+/**
+ * Event RSS exporter.
+ *
+ * @category   Event RSS export
+ * @package    Pandora FMS
+ * @subpackage Community
+ * @version    1.0.0
+ * @license    See below
+ *
+ *    ______                 ___                    _______ _______ ________
+ *   |   __ \.-----.--.--.--|  |.-----.----.-----. |    ___|   |   |     __|
+ *  |    __/|  _  |     |  _  ||  _  |   _|  _  | |    ___|       |__     |
+ * |___|   |___._|__|__|_____||_____|__| |___._| |___|   |__|_|__|_______|
+ *
+ * ============================================================================
+ * Copyright (c) 2005-2019 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.
+global $config;
+
+// Don't display other errors, messes up XML.
+ini_set('display_errors', E_ALL);
 
-// Pandora FMS - http://pandorafms.com
-// ==================================================
-// Copyright (c) 2005-2009 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.
-ini_set('display_errors', 0);
-// Don't display other errors, messes up XML
 require_once '../../include/config.php';
 require_once '../../include/functions.php';
 require_once '../../include/functions_db.php';
@@ -22,65 +41,115 @@ require_once '../../include/functions_users.php';
 require_once '../../include/functions_tags.php';
 require_once '../../include/functions_groups.php';
 
-$ipOrigin = $_SERVER['REMOTE_ADDR'];
 
-// Uncoment this to activate ACL on RSS Events
-if (!isInACL($ipOrigin)) {
-    rss_error_handler(
-        null,
-        null,
-        null,
-        null,
-        __('Your IP is not into the IP list with API access.')
-    );
-
-    exit;
+/**
+ * Generates an xml entry.
+ *
+ * @param string $key   Key.
+ * @param string $value Value.
+ *
+ * @return string XML entry.
+ */
+function xml_entry($key, $value)
+{
+    $output = '<'.xml_entities($key).'>';
+    $output .= '<![CDATA['.io_safe_output($value).']]>';
+    $output .= '</'.xml_entities($key).'>';
+    return $output."\n";
 }
 
-// Check user credentials
-$user = get_parameter('user');
-$hashup = get_parameter('hashup');
 
-$pss = get_user_info($user);
-$hashup2 = md5($user.$pss['password']);
+/**
+ * Escape entities for XML.
+ *
+ * @param string $str String.
+ *
+ * @return string Escaped string.
+ */
+function xml_entities($str)
+{
+    if (!is_string($str)) {
+        return '';
+    }
 
-if ($hashup != $hashup2) {
-    rss_error_handler(
-        null,
-        null,
-        null,
-        null,
-        __('The URL of your feed has bad hash.')
-    );
+    if (preg_match_all('/(&[^;]+;)/', $str, $matches) != 0) {
+        $matches = $matches[0];
 
-    exit;
+        foreach ($matches as $entity) {
+            $char = html_entity_decode($entity, (ENT_COMPAT | ENT_HTML401), 'UTF-8');
+
+            $html_entity_numeric = '&#'.uniord($char).';';
+
+            $str = str_replace($entity, $html_entity_numeric, $str);
+        }
+    }
+
+    return $str;
 }
 
-header('Content-Type: application/xml; charset=UTF-8');
-// Send header before starting to output
+
+/**
+ * Undocumented function.
+ *
+ * @param string $u U.
+ *
+ * @return integer Ord.
+ */
+function uniord($u)
+{
+    $k = mb_convert_encoding($u, 'UCS-2LE', 'UTF-8');
+    $k1 = ord(substr($k, 0, 1));
+    $k2 = ord(substr($k, 1, 1));
+
+    return ($k2 * 256 + $k1);
+}
+
+
+/**
+ * Generate RSS header.
+ *
+ * @param integer $lastbuild Date, last build.
+ *
+ * @return string RSS header.
+ */
+function rss_header($lastbuild=0)
+{
+    $selfurl = ui_get_full_url('?'.$_SERVER['QUERY_STRING'], false, true);
+
+    // ' <?php ' -- Fixes highlighters thinking that the closing tag is PHP
+    $rss_feed = '<?xml version="1.0" encoding="utf-8" ?>'."\n";
+    $rss_feed .= '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">'."\n";
+    $rss_feed .= '<channel>'."\n";
+    $rss_feed .= '<title>'.io_safe_output(get_product_name()).' Events Feed</title>'."\n";
+    $rss_feed .= '<description>Latest events on '.get_product_name().'</description>'."\n";
+    $rss_feed .= '<lastBuildDate>'.date(DATE_RFC822, $lastbuild).'</lastBuildDate>'."\n";
+    // Last build date is the last event - that way readers won't mark it as having new posts.
+    $rss_feed .= '<link>'.$url.'</link>'."\n";
+    // Link back to the main Pandora page.
+    $rss_feed .= '<atom:link href="'.xml_entities(io_safe_input($selfurl)).'" rel="self" type="application/rss+xml" />'."\n";
+
+    return $rss_feed;
+}
+
+
+/**
+ * RSS error handler.
+ *
+ * @param string $errno                   Errno.
+ * @param string $errstr                  Errstr.
+ * @param string $errfile                 Errfile.
+ * @param string $errline                 Errline.
+ * @param string $error_human_description Error_human_description.
+ *
+ * @return void
+ */
 function rss_error_handler($errno, $errstr, $errfile, $errline, $error_human_description=null)
 {
     $url = ui_get_full_url(false);
     $selfurl = ui_get_full_url('?'.$_SERVER['QUERY_STRING'], false, true);
 
-    $rss_feed = '<?xml version="1.0" encoding="utf-8" ?>';
-    // ' Fixes certain highlighters freaking out on the PHP closing tag
-    $rss_feed .= "\n";
-    $rss_feed .= '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">';
-    $rss_feed .= "\n";
-    $rss_feed .= '<channel>';
-    $rss_feed .= "\n";
-    $rss_feed .= '<title>'.get_product_name().' RSS Feed</title>';
-    $rss_feed .= "\n";
-    $rss_feed .= '<description>Latest events on '.get_product_name().'</description>';
-    $rss_feed .= "\n";
-    $rss_feed .= '<lastBuildDate>'.date(DATE_RFC822, 0).'</lastBuildDate>';
-    $rss_feed .= "\n";
-    $rss_feed .= '<link>'.$url.'</link>';
-    // Link back to the main Pandora page
-    $rss_feed .= "\n";
-    $rss_feed .= '<atom:link href="'.xml_entities(io_safe_input($selfurl)).'" rel="self" type="application/rss+xml" />';
-    // Alternative for Atom feeds. It's the same.
+    // ' Fixes certain highlighters freaking out on the PHP closing tag.
+    $rss_feed = rss_header(0);
     $rss_feed .= "\n";
     $rss_feed .= '<item>';
     $rss_feed .= "\n";
@@ -104,169 +173,206 @@ function rss_error_handler($errno, $errstr, $errfile, $errline, $error_human_des
     $rss_feed .= "\n";
     $rss_feed .= '</rss>';
 
-    exit($rss_feed);
-    // Exit by displaying the feed
+    echo $rss_feed;
 }
 
 
+// Errors output as RSS.
 set_error_handler('rss_error_handler', E_ERROR);
-// Errors output as RSS
-$id_group = get_parameter('id_group', 0);
-// group
-$event_type = get_parameter('event_type', '');
-// 0 all
-$severity = (int) get_parameter('severity', -1);
-// -1 all
-$status = (int) get_parameter('status', 0);
-// -1 all, 0 only red, 1 only green
-$id_agent = (int) get_parameter('id_agent', -1);
 
-$id_event = (int) get_parameter('id_event', -1);
-// This will allow to select only 1 event (eg. RSS)
-$event_view_hr = (int) get_parameter('event_view_hr', 0);
-$id_user_ack = get_parameter('id_user_ack', 0);
-$search = io_safe_output(preg_replace('/&([A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/', '&', rawurldecode(get_parameter('search'))));
-$text_agent = (string) get_parameter('text_agent', __('All'));
+// Send header before starting to output.
+header('Content-Type: application/xml; charset=UTF-8');
 
-$tag_with_json = base64_decode(get_parameter('tag_with', ''));
-$tag_with_json_clean = io_safe_output($tag_with_json);
-$tag_with_base64 = base64_encode($tag_with_json_clean);
-$tag_with = json_decode($tag_with_json_clean, true);
-if (empty($tag_with)) {
-    $tag_with = [];
+$ipOrigin = $_SERVER['REMOTE_ADDR'];
+
+// Uncoment this to activate ACL on RSS Events.
+if (!isInACL($ipOrigin)) {
+    rss_error_handler(
+        null,
+        null,
+        null,
+        null,
+        __('Your IP is not into the IP list with API access.')
+    );
+
+    exit;
 }
 
-$tag_with = array_diff($tag_with, [0 => 0]);
+// Check user credentials.
+$user = get_parameter('user');
+$hashup = get_parameter('hashup');
 
-$tag_without_json = base64_decode(get_parameter('tag_without', ''));
-$tag_without_json_clean = io_safe_output($tag_without_json);
-$tag_without_base64 = base64_encode($tag_without_json_clean);
-$tag_without = json_decode($tag_without_json_clean, true);
-if (empty($tag_without)) {
-    $tag_without = [];
+$pss = get_user_info($user);
+$hashup2 = md5($user.$pss['password']);
+
+if ($hashup != $hashup2) {
+    rss_error_handler(
+        null,
+        null,
+        null,
+        null,
+        __('The URL of your feed has bad hash.')
+    );
+
+    exit;
 }
 
-$tag_without = array_diff($tag_without, [0 => 0]);
-
-$filter_only_alert = (int) get_parameter('filter_only_alert', -1);
-
-//
-// Build the condition of the events query
-$sql_post = '';
-$meta = false;
-
-$id_user = $user;
-
-require 'events.build_query.php';
-
-// Now $sql_post have all the where condition
-//
-$sql = 'SELECT *
-	FROM tevento te LEFT JOIN tagent_secondary_group tasg
-		ON te.id_grupo = tasg.id_group
-	WHERE 1=1 '.$sql_post.'
-	ORDER BY utimestamp DESC';
-
-$result = db_get_all_rows_sql($sql);
-
-$url = ui_get_full_url(false);
-$selfurl = ui_get_full_url('?'.$_SERVER['QUERY_STRING'], false, true);
-
-if (empty($result)) {
-    $lastbuild = 0;
-    // Last build in 1970
-} else {
-    $lastbuild = (int) $result[0]['utimestamp'];
+$reset_session = false;
+if (empty($config['id_user'])) {
+    $config['id_user'] = $user;
+    $reset_session = true;
 }
 
-$rss_feed = '<?xml version="1.0" encoding="utf-8" ?>'."\n";
-// ' <?php ' -- Fixes highlighters thinking that the closing tag is PHP
-$rss_feed .= '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">'."\n";
-$rss_feed .= '<channel>'."\n";
-$rss_feed .= '<title>'.get_product_name().' RSS Feed</title>'."\n";
-$rss_feed .= '<description>Latest events on '.get_product_name().'</description>'."\n";
-$rss_feed .= '<lastBuildDate>'.date(DATE_RFC822, $lastbuild).'</lastBuildDate>'."\n";
-// Last build date is the last event - that way readers won't mark it as having new posts
-$rss_feed .= '<link>'.$url.'</link>'."\n";
-// Link back to the main Pandora page
-$rss_feed .= '<atom:link href="'.xml_entities(io_safe_input($selfurl)).'" rel="self" type="application/rss+xml" />'."\n";
-;
-// Alternative for Atom feeds. It's the same.
-if (empty($result)) {
-    $result = [];
-    $rss_feed .= '<item><guid>'.xml_entities(io_safe_input($url.'/index.php?sec=eventos&sec2=operation/events/events')).'</guid><title>No results</title>';
-    $rss_feed .= '<description>There are no results. Click on the link to see all Pending events</description>';
-    $rss_feed .= '<link>'.xml_entities(io_safe_input($url.'/index.php?sec=eventos&sec2=operation/events/events')).'</link></item>'."\n";
-}
+$column_names = [
+    'id_evento',
+    'evento',
+    'timestamp',
+    'estado',
+    'event_type',
+    'utimestamp',
+    'id_agente',
+    'agent_name',
+    'id_usuario',
+    'id_grupo',
+    'id_agentmodule',
+    'id_alert_am',
+    'criticity',
+    'user_comment',
+    'tags',
+    'source',
+    'id_extra',
+    'critical_instructions',
+    'warning_instructions',
+    'unknown_instructions',
+    'owner_user',
+    'ack_utimestamp',
+    'custom_data',
+    'data',
+    'module_status',
+];
 
-foreach ($result as $row) {
-    if (!check_acl($user, $row['id_grupo'], 'ER')) {
-        continue;
+$fields = [
+    'te.id_evento',
+    'te.evento',
+    'te.timestamp',
+    'te.estado',
+    'te.event_type',
+    'te.utimestamp',
+    'te.id_agente',
+    'ta.alias as agent_name',
+    'te.id_usuario',
+    'te.id_grupo',
+    'te.id_agentmodule',
+    'am.nombre as module_name',
+    'te.id_alert_am',
+    'te.criticity',
+    'te.user_comment',
+    'te.tags',
+    'te.source',
+    'te.id_extra',
+    'te.critical_instructions',
+    'te.warning_instructions',
+    'te.unknown_instructions',
+    'te.owner_user',
+    'te.ack_utimestamp',
+    'te.custom_data',
+    'te.data',
+    'te.module_status',
+    'tg.nombre as group_name',
+];
+
+
+try {
+    $fb64 = get_parameter('fb64', null);
+    $plain_filter = base64_decode($fb64);
+    $filter = json_decode($plain_filter, true);
+    if (json_last_error() != JSON_ERROR_NONE) {
+        throw new Exception('Invalid filter. ['.$plain_filter.']');
     }
 
-    if ($row['event_type'] == 'system') {
-        $agent_name = __('System');
-    } else if ($row['id_agente'] > 0) {
-        // Agent name
-        $agent_name = agents_get_alias($row['id_agente']);
-    } else {
-        $agent_name = __('Alert').__('SNMP');
+    // Dump events.
+    $limit = get_parameter('limit', 20);
+    $offset = get_parameter('offset', 0);
+    $events = events_get_all(
+        $fields,
+        $filter,
+        $offset,
+        $limit,
+        'desc',
+        'timestamp',
+        $filter['history']
+    );
+
+    $last_timestamp = 0;
+    if (is_array($events)) {
+        $last_timestamp = $events[0]['utimestamp'];
     }
 
-    // This is mandatory
-    $rss_feed .= '<item><guid>';
-    $rss_feed .= xml_entities(io_safe_input($url.'/index.php?sec=eventos&sec2=operation/events/events&id_event='.$row['id_evento']));
-    $rss_feed .= '</guid><title>';
-    $rss_feed .= xml_entities($agent_name);
-    $rss_feed .= '</title><description>';
-    $rss_feed .= xml_entities($row['evento']);
-    if ($row['estado'] == 1) {
-        $rss_feed .= xml_entities(io_safe_input('<br /><br />'.'Validated by '.$row['id_usuario']));
-    }
+    // Dump headers.
+    $rss = rss_header($last_timestamp);
+    $url = ui_get_full_url(false);
 
-    $rss_feed .= '</description><link>';
-    $rss_feed .= xml_entities(io_safe_input($url.'/index.php?sec=eventos&sec2=operation/events/events&id_event='.$row['id_evento']));
-    $rss_feed .= '</link>';
+    if (is_array($events)) {
+        foreach ($events as $row) {
+            $rss .= '<item>';
+            $rss .= xml_entry('title', $row['evento']);
+            if (!empty($row['id_agente'])) {
+                $rss .= xml_entry('link', $url.'index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$row['id_agente']);
+            }
 
-    // The rest is optional
-    $rss_feed .= '<pubDate>'.date(DATE_RFC822, $row['utimestamp']).'</pubDate>';
+            $rss .= xml_entry('comments', $row['']);
+            $rss .= xml_entry('pubDate', $row['timestamp']);
+            $rss .= xml_entry('category', $row['source']);
+            foreach ($column_names as $val) {
+                $key = $val;
+                if ($val == 'id_grupo') {
+                    $key = 'group_name';
+                } else if ($val == 'id_agentmodule') {
+                    $key = 'module_name';
+                }
 
-    // This is mandatory again
-    $rss_feed .= '</item>'."\n";
-}
+                switch ($key) {
+                    case 'module_status':
+                        $value = events_translate_module_status(
+                            $row[$key]
+                        );
+                    break;
 
-$rss_feed .= "</channel>\n</rss>\n";
+                    case 'event_type':
+                        $value = events_translate_event_type(
+                            $row[$key]
+                        );
+                    break;
 
-echo $rss_feed;
+                    case 'criticity':
+                        $value = events_translate_event_criticity(
+                            $row[$key]
+                        );
+                    break;
 
+                    default:
+                        $value = $row[$key];
+                    break;
+                }
 
-function xml_entities($str)
-{
-    if (!is_string($str)) {
-        return '';
-    }
+                $rss .= xml_entry($key, $value);
+            }
 
-    if (preg_match_all('/(&[^;]+;)/', $str, $matches) != 0) {
-        $matches = $matches[0];
-
-        foreach ($matches as $entity) {
-            $char = html_entity_decode($entity, (ENT_COMPAT | ENT_HTML401), 'UTF-8');
-
-            $html_entity_numeric = '&#'.uniord($char).';';
-
-            $str = str_replace($entity, $html_entity_numeric, $str);
+            $rss .= '</item>';
         }
+    } else {
+        $rss .= '<item><guid>'.xml_entities(io_safe_input($url.'/index.php?sec=eventos&sec2=operation/events/events')).'</guid><title>No results</title>';
+        $rss .= '<description>There are no results. Click on the link to see all Pending events</description>';
+        $rss .= '<link>'.xml_entities(io_safe_input($url.'/index.php?sec=eventos&sec2=operation/events/events')).'</link></item>'."\n";
     }
 
-    return $str;
+    $rss .= "</channel>\n</rss>\n";
+
+    echo $rss;
+} catch (Exception $e) {
+    echo rss_error_handler(200, 'Controlled error', '', '', $e->getMessage());
 }
 
-
-function uniord($u)
-{
-    $k = mb_convert_encoding($u, 'UCS-2LE', 'UTF-8');
-    $k1 = ord(substr($k, 0, 1));
-    $k2 = ord(substr($k, 1, 1));
-
-    return ($k2 * 256 + $k1);
+if ($reset_session) {
+    unset($config['id_user']);
 }

From 2c5cd007d247bcc1e275f4b38acb7d58c7fbf5db Mon Sep 17 00:00:00 2001
From: fbsanchez <fborja.sanchez@artica.es>
Date: Thu, 20 Jun 2019 14:18:49 +0200
Subject: [PATCH 18/37] reset form on load filter none

---
 pandora_console/include/ajax/events.php     |  11 ++
 pandora_console/operation/events/events.php | 130 ++++++++++++++++----
 2 files changed, 118 insertions(+), 23 deletions(-)

diff --git a/pandora_console/include/ajax/events.php b/pandora_console/include/ajax/events.php
index 12f86c4852..d6b4e61eaa 100644
--- a/pandora_console/include/ajax/events.php
+++ b/pandora_console/include/ajax/events.php
@@ -267,6 +267,17 @@ if ($get_filter_values) {
 
     $event_filter = events_get_event_filter($id_filter);
 
+    if ($event_filter === false) {
+        $event_filter = [
+            'status'        => EVENT_NO_VALIDATED,
+            'event_view_hr' => $config['event_view_hr'],
+            'group_rep'     => 1,
+            'tag_with'      => [],
+            'tag_without'   => [],
+            'history'       => false,
+        ];
+    }
+
     $event_filter['search'] = io_safe_output($event_filter['search']);
     $event_filter['id_name'] = io_safe_output($event_filter['id_name']);
     $event_filter['tag_with'] = base64_encode(
diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php
index ec073082bf..3f730325d8 100644
--- a/pandora_console/operation/events/events.php
+++ b/pandora_console/operation/events/events.php
@@ -87,30 +87,114 @@ if (is_metaconsole()) {
 ui_require_javascript_file('pandora_events');
 
 // Get requests.
-$id_group = get_parameter('filter[id_group]');
-$event_type = get_parameter('filter[event_type]');
-$severity = get_parameter('filter[severity]');
-$status = get_parameter('filter[status]', EVENT_NO_VALIDATED);
-$search = get_parameter('filter[search]');
-$text_agent = get_parameter('filter[text_agent]');
-$id_agent = get_parameter('filter[id_agent]');
-$id_agent_module = get_parameter('filter[id_agent_module]');
-$pagination = get_parameter('filter[pagination]');
-$event_view_hr = get_parameter('filter[event_view_hr]', $config['event_view_hr']);
-$id_user_ack = get_parameter('filter[id_user_ack]');
-$group_rep = get_parameter('filter[group_rep]', 1);
-$tag_with = get_parameter('filter[tag_with]', []);
-$tag_without = get_parameter('filter[tag_without]', []);
-$filter_only_alert = get_parameter('filter[filter_only_alert]');
-$id_group_filter = get_parameter('filter[id_group_filter]');
-$date_from = get_parameter('filter[date_from]');
-$date_to = get_parameter('filter[date_to]');
-$source = get_parameter('filter[source]');
-$id_extra = get_parameter('filter[id_extra]');
-$user_comment = get_parameter('filter[user_comment]');
-$history = get_parameter('history', false);
+$default_filter = [
+    'status'        => EVENT_NO_VALIDATED,
+    'event_view_hr' => $config['event_view_hr'],
+    'group_rep'     => 1,
+    'tag_with'      => [],
+    'tag_without'   => [],
+    'history'       => false,
+];
+
+$fb64 = get_parameter('fb64', null);
+if (isset($fb64)) {
+    $filter = json_decode(base64_decode($fb64), true);
+} else {
+    $filter = get_parameter(
+        'filter',
+        $default_filter
+    );
+}
+
+$id_group = get_parameter(
+    'filter[id_group]',
+    $filter['id_group']
+);
+$event_type = get_parameter(
+    'filter[event_type]',
+    $filter['event_type']
+);
+$severity = get_parameter(
+    'filter[severity]',
+    $filter['severity']
+);
+$status = get_parameter(
+    'filter[status]',
+    $filter['status']
+);
+$search = get_parameter(
+    'filter[search]',
+    $filter['search']
+);
+$text_agent = get_parameter(
+    'filter[text_agent]',
+    $filter['text_agent']
+);
+$id_agent = get_parameter(
+    'filter[id_agent]',
+    $filter['id_agent']
+);
+$id_agent_module = get_parameter(
+    'filter[id_agent_module]',
+    $filter['id_agent_module']
+);
+$pagination = get_parameter(
+    'filter[pagination]',
+    $filter['pagination']
+);
+$event_view_hr = get_parameter(
+    'filter[event_view_hr]',
+    $filter['event_view_hr']
+);
+$id_user_ack = get_parameter(
+    'filter[id_user_ack]',
+    $filter['id_user_ack']
+);
+$group_rep = get_parameter(
+    'filter[group_rep]',
+    $filter['group_rep']
+);
+$tag_with = get_parameter(
+    'filter[tag_with]',
+    $filter['tag_with']
+);
+$tag_without = get_parameter(
+    'filter[tag_without]',
+    $filter['tag_without']
+);
+$filter_only_alert = get_parameter(
+    'filter[filter_only_alert]',
+    $filter['filter_only_alert']
+);
+$id_group_filter = get_parameter(
+    'filter[id_group_filter]',
+    $filter['id_group_filter']
+);
+$date_from = get_parameter(
+    'filter[date_from]',
+    $filter['date_from']
+);
+$date_to = get_parameter(
+    'filter[date_to]',
+    $filter['date_to']
+);
+$source = get_parameter(
+    'filter[source]',
+    $filter['source']
+);
+$id_extra = get_parameter(
+    'filter[id_extra]',
+    $filter['id_extra']
+);
+$user_comment = get_parameter(
+    'filter[user_comment]',
+    $filter['user_comment']
+);
+$history = get_parameter(
+    'history',
+    $filter['history']
+);
 $section = get_parameter('section', false);
-$filter = get_parameter('filter', []);
 
 // Ajax responses.
 if (is_ajax()) {

From 8671c7c88c97b9793b1d20e46ee7b5b956dbbcfa Mon Sep 17 00:00:00 2001
From: fbsanchez <fborja.sanchez@artica.es>
Date: Thu, 20 Jun 2019 19:23:13 +0200
Subject: [PATCH 19/37] events qa adjustments

---
 pandora_console/godmode/events/events.php    | 15 +++-----
 pandora_console/include/ajax/events.php      | 15 +++++---
 pandora_console/include/functions_events.php | 15 ++++++++
 pandora_console/operation/events/events.php  | 36 ++++++++++++--------
 4 files changed, 51 insertions(+), 30 deletions(-)

diff --git a/pandora_console/godmode/events/events.php b/pandora_console/godmode/events/events.php
index c937ad281c..72ae001fe1 100644
--- a/pandora_console/godmode/events/events.php
+++ b/pandora_console/godmode/events/events.php
@@ -50,17 +50,10 @@ if (check_acl($config['id_user'], 0, 'PM')) {
         'text'   => '<a href="index.php?sec=eventos&sec2=godmode/events/events&amp;section=responses&amp;pure='.$config['pure'].'">'.html_print_image('images/event_responses.png', true, ['title' => __('Event responses')]).'</a>',
     ];
 
-    if (!is_metaconsole()) {
-        $buttons['fields'] = [
-            'active' => false,
-            'text'   => '<a href="index.php?sec=eventos&sec2=godmode/events/events&amp;section=fields&amp;pure='.$config['pure'].'">'.html_print_image('images/custom_columns.png', true, ['title' => __('Custom fields')]).'</a>',
-        ];
-    } else {
-        $buttons['fields'] = [
-            'active' => false,
-            'text'   => '<a href="index.php?sec=eventos&sec2=event/custom_events&amp;section=fields&amp;pure='.$config['pure'].'">'.html_print_image('images/custom_columns.png', true, ['title' => __('Custom fields')]).'</a>',
-        ];
-    }
+    $buttons['fields'] = [
+        'active' => false,
+        'text'   => '<a href="index.php?sec=eventos&sec2=godmode/events/events&amp;section=fields&amp;pure='.$config['pure'].'">'.html_print_image('images/custom_columns.png', true, ['title' => __('Custom fields')]).'</a>',
+    ];
 }
 
 switch ($section) {
diff --git a/pandora_console/include/ajax/events.php b/pandora_console/include/ajax/events.php
index d6b4e61eaa..05a6e3ad07 100644
--- a/pandora_console/include/ajax/events.php
+++ b/pandora_console/include/ajax/events.php
@@ -75,13 +75,20 @@ $graphic_event_group = (bool) get_parameter('graphic_event_group');
 $get_table_response_command = (bool) get_parameter('get_table_response_command');
 $save_filter_modal = get_parameter('save_filter_modal', 0);
 $load_filter_modal = get_parameter('load_filter_modal', 0);
-$save_filter = get_parameter('save_filter', 0);
 $get_filter_values = get_parameter('get_filter_values', 0);
 $update_event_filter = get_parameter('update_event_filter', 0);
 $save_event_filter = get_parameter('save_event_filter', 0);
 $in_process_event = get_parameter('in_process_event', 0);
 $validate_event = get_parameter('validate_event', 0);
 $delete_event = get_parameter('delete_event', 0);
+$get_event_filters = get_parameter('get_event_filters', 0);
+
+
+if ($get_event_filters) {
+    $event_filter = events_get_event_filter_select();
+
+    echo io_json_mb_encode($event_filter);
+}
 
 // Delete event (filtered or not).
 if ($delete_event) {
@@ -601,7 +608,7 @@ function save_new_filter() {
     
     jQuery.post ("<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
         {
-            "page" : "operation/events/events_list",
+            "page" : "include/ajax/events",
             "save_event_filter" : 1,
             "id_name" : $("#text-id_name").val(),
             "id_group" : $("select#id_group").val(),
@@ -670,7 +677,7 @@ function save_update_filter() {
     var name_filter_update = $("#overwrite_filter option[value='"+id_filter_update+"']").text();
     
     jQuery.post ("<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
-        {"page" : "operation/events/events_list",
+        {"page" : "include/ajax/events",
         "update_event_filter" : 1,
         "id" : $("#overwrite_filter").val(),
         "id_group" : $("select#id_group").val(),
@@ -723,7 +730,7 @@ function save_update_filter() {
         $('#filter_id').append ($('<option></option>').html ( <?php echo "'".__('none')."'"; ?> ).attr ("value", 0));    
         // Reload filters select
         jQuery.post ("<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
-            {"page" : "operation/events/events_list",
+            {"page" : "include/ajax/events",
                 "get_event_filters" : 1
             },
             function (data) {
diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php
index a958a3a957..0f72e0b55c 100644
--- a/pandora_console/include/functions_events.php
+++ b/pandora_console/include/functions_events.php
@@ -1197,6 +1197,19 @@ function events_get_all(
         }
     }
 
+    $server_join = '';
+    if (is_metaconsole()) {
+        $server_join = ' LEFT JOIN tmetaconsole_setup ts
+            ON ts.id = te.server_id';
+        if (!empty($filter['server_id'])) {
+            $server_join = sprintf(
+                ' LEFT JOIN tmetaconsole_setup ts
+                  ON ts.id = te.server_id AND ts.id= %d',
+                $filter['server_id']
+            );
+        }
+    }
+
     // Secondary groups.
     db_process_sql('SET group_concat_max_len = 9999999');
     $event_lj = events_get_secondary_groups_left_join($table);
@@ -1229,6 +1242,7 @@ function events_get_all(
          %s JOIN tgrupo tg
            ON te.id_grupo = tg.id_grupo
            %s
+         %s
          WHERE 1=1
          %s
          %s
@@ -1247,6 +1261,7 @@ function events_get_all(
         join(' ', $agent_join_filters),
         $tgrupo_join,
         join(' ', $tgrupo_join_filters),
+        $server_join,
         join(' ', $sql_filters),
         $group_by,
         $order_by,
diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php
index 3f730325d8..2ee276c820 100644
--- a/pandora_console/operation/events/events.php
+++ b/pandora_console/operation/events/events.php
@@ -44,9 +44,13 @@ require_once $config['homedir'].'/include/functions_ui.php';
 // Check access.
 check_login();
 
-if (! check_acl($config['id_user'], 0, 'ER')
-    && ! check_acl($config['id_user'], 0, 'EW')
-    && ! check_acl($config['id_user'], 0, 'EM')
+$event_a = check_acl($config['id_user'], 0, 'ER');
+$event_w = check_acl($config['id_user'], 0, 'EW');
+$event_m = check_acl($config['id_user'], 0, 'EM');
+
+if (! $event_a
+    && ! $event_w
+    && ! $event_m
 ) {
     db_pandora_audit(
         'ACL Violation',
@@ -61,9 +65,6 @@ if (! check_acl($config['id_user'], 0, 'ER')
 }
 
 
-$event_a = check_acl($config['id_user'], 0, 'ER');
-$event_w = check_acl($config['id_user'], 0, 'EW');
-$event_m = check_acl($config['id_user'], 0, 'EM');
 $access = ($event_a == true) ? 'ER' : (($event_w == true) ? 'EW' : (($event_m == true) ? 'EM' : 'ER'));
 
 
@@ -237,6 +238,9 @@ if (is_ajax()) {
             ];
             if (!is_metaconsole()) {
                 $fields[] = 'am.nombre as id_agentmodule';
+                $fields[] = 'ta.server_name as server_name';
+            } else {
+                $fields[] = 'ts.server_name as server_name';
             }
 
             $events = events_get_all(
@@ -603,7 +607,7 @@ if ($pure) {
     $sound_event['text'] = '<a href="javascript: openSoundEventWindow();">'.html_print_image('images/sound.png', true, ['title' => __('Sound events')]).'</a>';
 
     // If the user has administrator permission display manage tab.
-    if (check_acl($config['id_user'], 0, 'EW') || check_acl($config['id_user'], 0, 'EM')) {
+    if ($event_w || $event_m) {
         // Manage events.
         $manage_events['active'] = false;
         $manage_events['text'] = '<a href="index.php?sec=eventos&sec2=godmode/events/events&amp;section=filter&amp;pure='.$config['pure'].'">'.html_print_image('images/setup.png', true, ['title' => __('Manage events')]).'</a>';
@@ -880,12 +884,14 @@ $buttons[] = [
     'onclick' => '',
 ];
 
-$buttons[] = [
-    'id'      => 'save-filter',
-    'class'   => 'float-left margin-right-2 sub wand',
-    'text'    => __('Save filter'),
-    'onclick' => '',
-];
+if ($event_w || $event_m) {
+    $buttons[] = [
+        'id'      => 'save-filter',
+        'class'   => 'float-left margin-right-2 sub wand',
+        'text'    => __('Save filter'),
+        'onclick' => '',
+    ];
+}
 
 /*
  * Advanced filter.
@@ -1374,12 +1380,12 @@ $sql_event_resp = "SELECT id, name FROM tevent_response WHERE type LIKE 'command
 $event_responses = db_get_all_rows_sql($sql_event_resp);
 
 if ($config['event_replication'] != 1) {
-    if (check_acl($config['id_user'], 0, 'EW') == 1 && !$readonly) {
+    if ($event_w && !$readonly) {
         $array_events_actions['in_progress_selected'] = __('In progress selected');
         $array_events_actions['validate_selected'] = __('Validate selected');
     }
 
-    if (check_acl($config['id_user'], 0, 'EM') == 1 && !$readonly) {
+    if ($event_m == 1 && !$readonly) {
         $array_events_actions['delete_selected'] = __('Delete selected');
     }
 }

From 526ebdebd9f2ca8dc1f0008245b4af84ad81bb26 Mon Sep 17 00:00:00 2001
From: fbsanchez <fborja.sanchez@artica.es>
Date: Thu, 20 Jun 2019 21:11:56 +0200
Subject: [PATCH 20/37] ajax comments

---
 pandora_console/include/ajax/events.php       | 100 +++++++++-
 pandora_console/include/functions_events.php  | 178 +++++++++---------
 .../include/javascript/pandora_events.js      |   5 +-
 pandora_console/operation/events/events.php   |  10 +-
 4 files changed, 194 insertions(+), 99 deletions(-)

diff --git a/pandora_console/include/ajax/events.php b/pandora_console/include/ajax/events.php
index 05a6e3ad07..a7d23ca015 100644
--- a/pandora_console/include/ajax/events.php
+++ b/pandora_console/include/ajax/events.php
@@ -82,12 +82,65 @@ $in_process_event = get_parameter('in_process_event', 0);
 $validate_event = get_parameter('validate_event', 0);
 $delete_event = get_parameter('delete_event', 0);
 $get_event_filters = get_parameter('get_event_filters', 0);
+$get_comments = get_parameter('get_comments', 0);
 
+if ($get_comments) {
+    $event = get_parameter('event', false);
+    $filter = get_parameter('filter', false);
+
+    if ($event === false) {
+        return __('Failed to retrieve comments');
+    }
+
+    if ($filter['group_rep'] == 1) {
+        $events = events_get_all(
+            ['te.*'],
+            // Filter.
+            $filter,
+            // Offset.
+            null,
+            // Limit.
+            null,
+            // Order.
+            null,
+            // Sort_field.
+            null,
+            // History.
+            $filter['history'],
+            // Return_sql.
+            false,
+            // Having.
+            sprintf(
+                ' HAVING max_id_evento = %d',
+                $event['id_evento']
+            )
+        );
+        if ($events !== false) {
+            $event = $events[0];
+        }
+    } else {
+        $events = events_get_event(
+            $event['id_evento'],
+            false,
+            $meta,
+            $history
+        );
+
+        if ($events !== false) {
+            $event = $events[0];
+        }
+    }
+
+    echo events_page_comments($event, true);
+
+    return;
+}
 
 if ($get_event_filters) {
     $event_filter = events_get_event_filter_select();
 
     echo io_json_mb_encode($event_filter);
+    return;
 }
 
 // Delete event (filtered or not).
@@ -1058,6 +1111,7 @@ if ($get_extended_event) {
     global $config;
 
     $event = get_parameter('event', false);
+    $filter = get_parameter('filter', false);
 
     if ($event === false) {
         return;
@@ -1253,7 +1307,7 @@ if ($get_extended_event) {
 
     $general = events_page_general($event);
 
-    $comments = events_page_comments($event);
+    $comments = '<div id="extended_event_comments_page" class="extended_event_pages"></div>';
 
     $notifications = '<div id="notification_comment_error" style="display:none">'.ui_print_error_message(__('Error adding comment'), '', true).'</div>';
     $notifications .= '<div id="notification_comment_success" style="display:none">'.ui_print_success_message(__('Comment added successfully'), '', true).'</div>';
@@ -1264,6 +1318,18 @@ if ($get_extended_event) {
 
     $loading = '<div id="response_loading" style="display:none">'.html_print_image('images/spinner.gif', true).'</div>';
 
+    $i = 0;
+    $tab['general'] = $i++;
+    $tab['details'] = $i++;
+    if (!empty($related)) {
+        $tab['related'] = $i++;
+    }
+
+    $tab['custom_fields'] = $i++;
+    $tab['comments'] = $i++;
+    $tab['responses'] = $i++;
+    $tab['custom_data'] = $i++;
+
     $out = '<div id="tabs">'.$tabs.$notifications.$loading.$general.$details.$related.$custom_fields.$comments.$responses.$custom_data.html_print_input_hidden('id_event', $event['id_evento']).'</div>';
 
     $js = '<script>
@@ -1275,31 +1341,31 @@ if ($get_extended_event) {
     // Load the required tab.
     switch ($dialog_page) {
         case 'general':
-            $js .= '$tabs.tabs( "option", "active", 0);';
+            $js .= '$tabs.tabs( "option", "active", '.$tab['general'].');';
         break;
 
         case 'details':
-            $js .= '$tabs.tabs( "option", "active", 1);';
+            $js .= '$tabs.tabs( "option", "active", '.$tab['details'].');';
         break;
 
         case 'related':
-            $js .= '$tabs.tabs( "option", "active", 2);';
+            $js .= '$tabs.tabs( "option", "active", '.$tab['related'].');';
         break;
 
         case 'custom_fields':
-            $js .= '$tabs.tabs( "option", "active", 3);';
+            $js .= '$tabs.tabs( "option", "active", '.$tab['custom_fields'].');';
         break;
 
         case 'comments':
-            $js .= '$tabs.tabs( "option", "active", 4);';
+            $js .= '$tabs.tabs( "option", "active", '.$tab['comments'].');';
         break;
 
         case 'responses':
-            $js .= '$tabs.tabs( "option", "active", 5);';
+            $js .= '$tabs.tabs( "option", "active", '.$tab['responses'].');';
         break;
 
         case 'custom_data':
-            $js .= '$tabs.tabs( "option", "active", 6);';
+            $js .= '$tabs.tabs( "option", "active", '.$tab['custom_data'].');';
         break;
 
         default:
@@ -1309,6 +1375,24 @@ if ($get_extended_event) {
 
     $js .= '});';
 
+    $js .= '
+        $("#link_comments").click(function (){
+          $.post ({
+                url : "ajax.php",
+                data : {
+                    page: "include/ajax/events",
+                    get_comments: 1,
+                    event: '.json_encode($event).',
+                    filter: '.json_encode($filter).'
+                },
+                dataType : "html",
+                success: function (data) {
+                    $("#extended_event_comments_page").empty();
+                    $("#extended_event_comments_page").html(data);
+                }
+            });
+        });';
+
     if (events_has_extended_info($event['id_evento']) === true) {
         $js .= '
         $("#link_related").click(function (){
diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php
index 0f72e0b55c..3963c172b7 100644
--- a/pandora_console/include/functions_events.php
+++ b/pandora_console/include/functions_events.php
@@ -4531,7 +4531,7 @@ function events_page_general($event)
  *
  * @return string HTML.
  */
-function events_page_comments($event)
+function events_page_comments($event, $ajax=false)
 {
     // Comments.
     global $config;
@@ -4540,7 +4540,7 @@ function events_page_comments($event)
 
     $comments = $event['user_comment'];
     if (isset($event['comments'])) {
-        $comments = $event['comments'];
+        $comments = explode('<br>', $event['comments']);
     }
 
     $table_comments = new stdClass;
@@ -4551,100 +4551,102 @@ function events_page_comments($event)
 
     $comments = str_replace(["\n", '&#x0a;'], '<br>', $comments);
 
-    // If comments are not stored in json, the format is old.
-    $comments_array = json_decode(io_safe_output($comments), true);
-    if (!empty($comments) && json_last_error() != JSON_ERROR_NONE) {
-        $comments_array = [
-            [
-                'comment'    => 'Error retrieving comments',
-                'action'     => 'Internal message',
-                'id_user'    => 'SYSTEM',
-                'utimestamp' => time(),
-            ],
-        ];
-    }
+    if (is_array($comments)) {
+        foreach ($comments as $comm) {
+            if (empty($comm)) {
+                continue;
+            }
 
-    // Show the comments more recent first.
-    if (is_array($comments_array)) {
-        $comments_array = array_reverse($comments_array);
-    }
-
-    if (empty($comments_array)) {
-        $comments_format = 'old';
+            $comments_array[] = json_decode(io_safe_output($comm), true);
+        }
     } else {
-        $comments_format = 'new';
+        // If comments are not stored in json, the format is old.
+        $comments_array = json_decode(io_safe_output($comments), true);
     }
 
-    switch ($comments_format) {
-        case 'new':
-            if (empty($comments_array)) {
-                $table_comments->style[0] = 'text-align:center;';
-                $table_comments->colspan[0][0] = 2;
-                $data = [];
-                $data[0] = __('There are no comments');
-                $table_comments->data[] = $data;
-            }
+    foreach ($comments_array as $comm) {
+        // Show the comments more recent first.
+        if (is_array($comm)) {
+            $comm = array_reverse($comm);
+        }
 
-            if (isset($comments_array) === true
-                && is_array($comments_array) === true
-            ) {
-                foreach ($comments_array as $c) {
-                    $data[0] = '<b>'.$c['action'].' by '.$c['id_user'].'</b>';
-                    $data[0] .= '<br><br><i>'.date($config['date_format'], $c['utimestamp']).'</i>';
-                    $data[1] = $c['comment'];
-                    $table_comments->data[] = $data;
-                }
-            }
-        break;
+        if (empty($comm)) {
+            $comments_format = 'old';
+        } else {
+            $comments_format = 'new';
+        }
 
-        case 'old':
-            $comments_array = explode('<br>', $comments);
-
-            // Split comments and put in table.
-            $col = 0;
-            $data = [];
-
-            foreach ($comments_array as $c) {
-                switch ($col) {
-                    case 0:
-                        $row_text = preg_replace('/\s*--\s*/', '', $c);
-                        $row_text = preg_replace('/\<\/b\>/', '</i>', $row_text);
-                        $row_text = preg_replace('/\[/', '</b><br><br><i>[', $row_text);
-                        $row_text = preg_replace('/[\[|\]]/', '', $row_text);
-                    break;
-
-                    case 1:
-                        $row_text = preg_replace("/[\r\n|\r|\n]/", '<br>', io_safe_output(strip_tags($c)));
-                    break;
-
-                    default:
-                        // Ignore.
-                    break;
-                }
-
-                $data[$col] = $row_text;
-
-                $col++;
-
-                if ($col == 2) {
-                    $col = 0;
-                    $table_comments->data[] = $data;
+        switch ($comments_format) {
+            case 'new':
+                if (empty($comm)) {
+                    $table_comments->style[0] = 'text-align:center;';
+                    $table_comments->colspan[0][0] = 2;
                     $data = [];
+                    $data[0] = __('There are no comments');
+                    $table_comments->data[] = $data;
                 }
-            }
 
-            if (count($comments_array) == 1 && $comments_array[0] == '') {
-                $table_comments->style[0] = 'text-align:center;';
-                $table_comments->colspan[0][0] = 2;
+                if (isset($comm) === true
+                    && is_array($comm) === true
+                ) {
+                    foreach ($comm as $c) {
+                        $data[0] = '<b>'.$c['action'].' by '.$c['id_user'].'</b>';
+                        $data[0] .= '<br><br><i>'.date($config['date_format'], $c['utimestamp']).'</i>';
+                        $data[1] = $c['comment'];
+                        $table_comments->data[] = $data;
+                    }
+                }
+            break;
+
+            case 'old':
+                $comm = explode('<br>', $comments);
+
+                // Split comments and put in table.
+                $col = 0;
                 $data = [];
-                $data[0] = __('There are no comments');
-                $table_comments->data[] = $data;
-            }
-        break;
 
-        default:
-            // Ignore.
-        break;
+                foreach ($comm as $c) {
+                    switch ($col) {
+                        case 0:
+                            $row_text = preg_replace('/\s*--\s*/', '', $c);
+                            $row_text = preg_replace('/\<\/b\>/', '</i>', $row_text);
+                            $row_text = preg_replace('/\[/', '</b><br><br><i>[', $row_text);
+                            $row_text = preg_replace('/[\[|\]]/', '', $row_text);
+                        break;
+
+                        case 1:
+                            $row_text = preg_replace("/[\r\n|\r|\n]/", '<br>', io_safe_output(strip_tags($c)));
+                        break;
+
+                        default:
+                            // Ignore.
+                        break;
+                    }
+
+                    $data[$col] = $row_text;
+
+                    $col++;
+
+                    if ($col == 2) {
+                        $col = 0;
+                        $table_comments->data[] = $data;
+                        $data = [];
+                    }
+                }
+
+                if (count($comm) == 1 && $comm[0] == '') {
+                    $table_comments->style[0] = 'text-align:center;';
+                    $table_comments->colspan[0][0] = 2;
+                    $data = [];
+                    $data[0] = __('There are no comments');
+                    $table_comments->data[] = $data;
+                }
+            break;
+
+            default:
+                // Ignore.
+            break;
+        }
     }
 
     if (((tags_checks_event_acl(
@@ -4687,9 +4689,11 @@ function events_page_comments($event)
         );
     }
 
-    $comments = '<div id="extended_event_comments_page" class="extended_event_pages">'.$comments_form.html_print_table($table_comments, true).'</div>';
+    if ($ajax) {
+        return $comments_form.html_print_table($table_comments, true);
+    }
 
-    return $comments;
+    return '<div id="extended_event_comments_page" class="extended_event_pages">'.$comments_form.html_print_table($table_comments, true).'</div>';
 }
 
 
diff --git a/pandora_console/include/javascript/pandora_events.js b/pandora_console/include/javascript/pandora_events.js
index d0a83bd6e8..406cffe243 100644
--- a/pandora_console/include/javascript/pandora_events.js
+++ b/pandora_console/include/javascript/pandora_events.js
@@ -557,9 +557,8 @@ function event_comment() {
     dataType: "html",
     success: function(data) {
       $("#button-comment_button").removeAttr("disabled");
-      $("#response_loading").show();
-      dt_events.draw(false);
-      show_event_dialog(current_event, "comments", data);
+      $("#response_loading").hide();
+      $("#link_comments").click();
     }
   });
 
diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php
index 2ee276c820..a4a347ba90 100644
--- a/pandora_console/operation/events/events.php
+++ b/pandora_console/operation/events/events.php
@@ -237,7 +237,8 @@ if (is_ajax()) {
                 'tg.nombre as group_name',
             ];
             if (!is_metaconsole()) {
-                $fields[] = 'am.nombre as id_agentmodule';
+                $fields[] = 'am.nombre as module_name';
+                $fields[] = 'am.id_agente_modulo as id_agentmodule';
                 $fields[] = 'ta.server_name as server_name';
             } else {
                 $fields[] = 'ts.server_name as server_name';
@@ -274,6 +275,11 @@ if (is_ajax()) {
                     function ($carry, $item) {
                         $tmp = (object) $item;
                         $tmp->evento = io_safe_output($tmp->evento);
+                        if ($tmp->module_name) {
+                            $tmp->module_name = io_safe_output($tmp->module_name);
+                        }
+
+                        $tmp->agent_name = io_safe_output($tmp->agent_name);
                         $tmp->ack_utimestamp = ui_print_timestamp(
                             $tmp->ack_utimestamp,
                             true
@@ -1809,6 +1815,8 @@ function process_datatables_item(item) {
         item.id_grupo = item.group_name;
     }
 
+    /* Module name */
+    item.id_agentmodule = item.module_name;
 }
 
 /* Datatables auxiliary functions ends */

From 7a425e7e965e9f2af832dfdd2ef1a26a0c5dcb64 Mon Sep 17 00:00:00 2001
From: fbsanchez <fborja.sanchez@artica.es>
Date: Thu, 20 Jun 2019 21:33:38 +0200
Subject: [PATCH 21/37] qa event viewer latest fixes

---
 pandora_console/include/functions_events.php | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php
index 3963c172b7..892cf22077 100644
--- a/pandora_console/include/functions_events.php
+++ b/pandora_console/include/functions_events.php
@@ -794,21 +794,19 @@ function events_get_all(
             );
         } else {
             $children = groups_get_children($groups);
-            $_groups = [];
+            $_groups = [ $groups ];
             if (!empty($children)) {
                 foreach ($children as $child) {
                     $_groups[] = (int) $child['id_grupo'];
                 }
-
-                $groups = $_groups;
-            } else {
-                $groups = [ $groups ];
             }
 
+            $groups = $_groups;
+
             $sql_filters[] = sprintf(
-                ' AND (te.id_grupo IN (%s) OR tasg.id_group IN (%s)',
-                join(',', array_keys($groups)),
-                join(',', array_keys($groups))
+                ' AND (te.id_grupo IN (%s) OR tasg.id_group IN (%s))',
+                join(',', $groups),
+                join(',', $groups)
             );
         }
     }
@@ -1185,8 +1183,8 @@ function events_get_all(
         if (is_array($groups)) {
             $tgrupo_join_filters[] = sprintf(
                 ' AND (tg.id_grupo IN (%s) OR tasg.id_group IN (%s))',
-                join(', ', array_keys($groups)),
-                join(', ', array_keys($groups))
+                join(', ', $groups),
+                join(', ', $groups)
             );
         } else {
             $tgrupo_join_filters[] = sprintf(

From 3616d6e8714f0b3be5a516370bf82708dddf1fb6 Mon Sep 17 00:00:00 2001
From: fbsanchez <fborja.sanchez@artica.es>
Date: Mon, 24 Jun 2019 10:00:16 +0200
Subject: [PATCH 22/37] Added get_lock/release_lock functions to functions_db

---
 pandora_console/include/functions_db.php | 55 ++++++++++++++++++++++++
 1 file changed, 55 insertions(+)

diff --git a/pandora_console/include/functions_db.php b/pandora_console/include/functions_db.php
index 2061ab215c..0028c44c8d 100644
--- a/pandora_console/include/functions_db.php
+++ b/pandora_console/include/functions_db.php
@@ -2023,3 +2023,58 @@ function db_check_minor_relase_available_to_um($package, $ent, $offline)
         return false;
     }
 }
+
+
+/**
+ * Tries to get a lock with current name.
+ *
+ * @param string  $lockname        Lock name.
+ * @param integer $expiration_time Expiration time.
+ *
+ * @return integer 1 - lock OK, able to continue executing
+ *                 0 - already locked by another process.
+ *                 NULL: something really bad happened
+ */
+function db_get_lock($lockname, $expiration_time=86400)
+{
+    $lock_status = db_get_value_sql(
+        sprintf(
+            'SELECT IS_FREE_LOCK("%s")',
+            $lockname
+        )
+    );
+
+    if ($lock_status === 1) {
+        $lock_status = db_get_value_sql(
+            sprintf(
+                'SELECT GET_LOCK("%s", %d)',
+                $lockname,
+                $expiration_time
+            )
+        );
+
+        return $lock_status;
+    }
+
+    return 0;
+}
+
+
+/**
+ * Release a previously defined lock.
+ *
+ * @param string $lockname Lock name.
+ *
+ * @return integer 1 Lock released.
+ *                 0 cannot release (not owned).
+ *                 NULL lock does not exist.
+ */
+function db_release_lock($lockname)
+{
+    return db_get_value_sql(
+        sprintf(
+            'SELECT RELEASE_LOCK("%s")',
+            $lockname
+        )
+    );
+}

From d6cb1bc2077ea4e44cf3545b7853e0f46257f30f Mon Sep 17 00:00:00 2001
From: fbsanchez <fborja.sanchez@artica.es>
Date: Mon, 24 Jun 2019 10:13:47 +0200
Subject: [PATCH 23/37] minor fix in type check

---
 pandora_console/include/functions_db.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pandora_console/include/functions_db.php b/pandora_console/include/functions_db.php
index 0028c44c8d..3efbf59628 100644
--- a/pandora_console/include/functions_db.php
+++ b/pandora_console/include/functions_db.php
@@ -2044,7 +2044,7 @@ function db_get_lock($lockname, $expiration_time=86400)
         )
     );
 
-    if ($lock_status === 1) {
+    if ($lock_status == 1) {
         $lock_status = db_get_value_sql(
             sprintf(
                 'SELECT GET_LOCK("%s", %d)',

From 3fe4256743d7ec01e59e0411b428d343f171c455 Mon Sep 17 00:00:00 2001
From: Ramon Novoa <rnovoa@artica.es>
Date: Wed, 12 Jun 2019 11:23:39 +0200
Subject: [PATCH 24/37] HA related fixes to the Recon Server.

---
 .../lib/PandoraFMS/DiscoveryServer.pm         | 21 +++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/pandora_server/lib/PandoraFMS/DiscoveryServer.pm b/pandora_server/lib/PandoraFMS/DiscoveryServer.pm
index e15511de44..86283d67dc 100644
--- a/pandora_server/lib/PandoraFMS/DiscoveryServer.pm
+++ b/pandora_server/lib/PandoraFMS/DiscoveryServer.pm
@@ -141,12 +141,21 @@ sub data_producer ($) {
     # Manual tasks are "forced" like the other, setting the utimestamp to 1
     # By default, after create a tasks it takes the utimestamp to 0
     # Status -1 means "done".
-    
-    my @rows = get_db_rows ($dbh, 'SELECT * FROM trecon_task 
-        WHERE id_recon_server = ?
-        AND disabled = 0
-        AND ((utimestamp = 0 AND interval_sweep != 0 OR status = 1)
-            OR (status = -1 AND interval_sweep > 0 AND (utimestamp + interval_sweep) < UNIX_TIMESTAMP()))', $server_id);
+    my @rows;
+    if (pandora_is_master($pa_config) == 0) {
+        @rows = get_db_rows ($dbh, 'SELECT * FROM trecon_task 
+            WHERE id_recon_server = ?
+            AND disabled = 0
+            AND ((utimestamp = 0 AND interval_sweep != 0 OR status = 1)
+                OR (status = -1 AND interval_sweep > 0 AND (utimestamp + interval_sweep) < UNIX_TIMESTAMP()))', $server_id);
+    } else {
+        @rows = get_db_rows ($dbh, 'SELECT * FROM trecon_task 
+            WHERE (id_recon_server = ? OR id_recon_server = ANY(SELECT id_server FROM tserver WHERE status = 0 AND server_type = ?))
+            AND disabled = 0
+            AND ((utimestamp = 0 AND interval_sweep != 0 OR status = 1)
+                OR (status = -1 AND interval_sweep > 0 AND (utimestamp + interval_sweep) < UNIX_TIMESTAMP()))', $server_id, DISCOVERYSERVER);
+    }
+
     foreach my $row (@rows) {
         
         # Update task status

From 13ecec40c2e8c1804f322322d1a2246653e3ff0b Mon Sep 17 00:00:00 2001
From: Tatiana Llorente <tatiana.llorente@artica.es>
Date: Mon, 24 Jun 2019 17:08:21 +0200
Subject: [PATCH 25/37] Fixed visual bug in snmp browser - #4160

---
 pandora_console/include/functions_snmp_browser.php | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/pandora_console/include/functions_snmp_browser.php b/pandora_console/include/functions_snmp_browser.php
index 8e916166df..dded175af5 100644
--- a/pandora_console/include/functions_snmp_browser.php
+++ b/pandora_console/include/functions_snmp_browser.php
@@ -597,7 +597,7 @@ function snmp_browser_print_oid(
  *
  * @return string The container div.
  */
-function snmp_browser_print_container($return=false, $width='100%', $height='500px', $display='')
+function snmp_browser_print_container($return=false, $width='100%', $height='60%', $display='')
 {
     // Target selection
     $table = new stdClass();
@@ -773,7 +773,7 @@ function snmp_browser_print_container($return=false, $width='100%', $height='500
 
     $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" style="height: 100%; overflow: auto; background-color: #F4F5F4; border: 1px solid #E2E2E2; border-radius: 4px; padding: 5px;"></div>';
+    $output .= '<div id="snmp_browser" style="height: 100%; min-height:100px; overflow: auto; background-color: #F4F5F4; border: 1px solid #E2E2E2; border-radius: 4px; padding: 5px;"></div>';
     $output .= '<div class="databox" id="snmp_data" style="margin: 5px;"></div>';
     $output .= '</div>';
     $output .= '</div>';

From 0ed382c42c3b978a5462b02600fe336840fdb53b Mon Sep 17 00:00:00 2001
From: fbsanchez <fborja.sanchez@artica.es>
Date: Mon, 24 Jun 2019 18:48:44 +0200
Subject: [PATCH 26/37] SQLerror tasg reference

---
 pandora_console/include/functions_tags.php | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/pandora_console/include/functions_tags.php b/pandora_console/include/functions_tags.php
index 6d0211f89d..c4ecc81277 100644
--- a/pandora_console/include/functions_tags.php
+++ b/pandora_console/include/functions_tags.php
@@ -935,7 +935,7 @@ function tags_get_acl_tags_event_condition(
 
         // Group condition (The module belongs to an agent of the group X)
         // $group_condition = sprintf('id_grupo IN (%s)', implode(',', array_values(groups_get_id_recursive($group_id, true))));.
-        $group_condition = '('.$id_grupo_table_pretag.'id_grupo = '.$group_id.' OR id_group = '.$group_id.')';
+        $group_condition = '('.$id_grupo_table_pretag.'id_grupo = '.$group_id.' OR tasg.d_group = '.$group_id.')';
 
         // Tags condition (The module has at least one of the restricted tags).
         $tags_condition = '';
@@ -971,7 +971,7 @@ function tags_get_acl_tags_event_condition(
         }
 
         $in_group = implode(',', $without_tags);
-        $condition .= sprintf('('.$id_grupo_table_pretag.'id_grupo IN (%s) OR id_group IN (%s))', $in_group, $in_group);
+        $condition .= sprintf('('.$id_grupo_table_pretag.'id_grupo IN (%s) OR tasg.id_group IN (%s))', $in_group, $in_group);
     }
 
     $condition = !empty($condition) ? "($condition)" : '';

From 0ea8904e0aa1b0af363eab041d2c76da5667e240 Mon Sep 17 00:00:00 2001
From: fbsanchez <fborja.sanchez@artica.es>
Date: Mon, 24 Jun 2019 18:52:38 +0200
Subject: [PATCH 27/37] SQLerror tasg reference

---
 pandora_console/include/functions_events.php |  8 ++++++--
 pandora_console/include/functions_tags.php   | 13 ++++++++-----
 2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php
index 892cf22077..35529a941f 100644
--- a/pandora_console/include/functions_events.php
+++ b/pandora_console/include/functions_events.php
@@ -1075,7 +1075,9 @@ function events_get_all(
             // Force_group_and_tag.
             true,
             // Table tag for id_grupo.
-            'te.'
+            'te.',
+            // Alt table tag for id_grupo.
+            'tasg.'
         );
         // FORCE CHECK SQL "(TAG = tag1 AND id_grupo = 1)".
     } else if (check_acl($config['id_user'], 0, 'EM')) {
@@ -1099,7 +1101,9 @@ function events_get_all(
             // Force_group_and_tag.
             true,
             // Table tag for id_grupo.
-            'te.'
+            'te.',
+            // Alt table tag for id_grupo.
+            'tasg.'
         );
         // FORCE CHECK SQL "(TAG = tag1 AND id_grupo = 1)".
     }
diff --git a/pandora_console/include/functions_tags.php b/pandora_console/include/functions_tags.php
index c4ecc81277..aad6d78efd 100644
--- a/pandora_console/include/functions_tags.php
+++ b/pandora_console/include/functions_tags.php
@@ -745,7 +745,8 @@ function tags_get_acl_tags(
     $meta=false,
     $childrens_ids=[],
     $force_group_and_tag=false,
-    $id_grupo_table_pretag=''
+    $id_grupo_table_pretag='',
+    $alt_id_grupo_table_pretag=''
 ) {
     global $config;
 
@@ -820,7 +821,8 @@ function tags_get_acl_tags(
                 $meta,
                 $force_group_and_tag,
                 false,
-                $id_grupo_table_pretag
+                $id_grupo_table_pretag,
+                $alt_id_grupo_table_pretag
             );
 
             if (!empty($condition)) {
@@ -917,7 +919,8 @@ function tags_get_acl_tags_event_condition(
     $meta=false,
     $force_group_and_tag=false,
     $force_equal=false,
-    $id_grupo_table_pretag=''
+    $id_grupo_table_pretag='',
+    $alt_id_grupo_table_pretag=''
 ) {
     global $config;
     $condition = [];
@@ -935,7 +938,7 @@ function tags_get_acl_tags_event_condition(
 
         // Group condition (The module belongs to an agent of the group X)
         // $group_condition = sprintf('id_grupo IN (%s)', implode(',', array_values(groups_get_id_recursive($group_id, true))));.
-        $group_condition = '('.$id_grupo_table_pretag.'id_grupo = '.$group_id.' OR tasg.d_group = '.$group_id.')';
+        $group_condition = '('.$id_grupo_table_pretag.'id_grupo = '.$group_id.' OR '.$alt_id_grupo_table_pretag.'id_group = '.$group_id.')';
 
         // Tags condition (The module has at least one of the restricted tags).
         $tags_condition = '';
@@ -971,7 +974,7 @@ function tags_get_acl_tags_event_condition(
         }
 
         $in_group = implode(',', $without_tags);
-        $condition .= sprintf('('.$id_grupo_table_pretag.'id_grupo IN (%s) OR tasg.id_group IN (%s))', $in_group, $in_group);
+        $condition .= sprintf('('.$id_grupo_table_pretag.'id_grupo IN (%s) OR '.$alt_id_grupo_table_pretag.'id_group IN (%s))', $in_group, $in_group);
     }
 
     $condition = !empty($condition) ? "($condition)" : '';

From c85965d7933f2016ea31a5e92f308f86f1184ce6 Mon Sep 17 00:00:00 2001
From: fbsanchez <fborja.sanchez@artica.es>
Date: Mon, 24 Jun 2019 19:05:46 +0200
Subject: [PATCH 28/37] SQLerror tasg reference

---
 pandora_console/include/functions_events.php | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php
index 35529a941f..c974251170 100644
--- a/pandora_console/include/functions_events.php
+++ b/pandora_console/include/functions_events.php
@@ -1051,7 +1051,9 @@ function events_get_all(
             // Force_group_and_tag.
             true,
             // Table tag for id_grupo.
-            'te.'
+            'te.',
+            // Alt table tag for id_grupo.
+            'tasg.'
         );
         // FORCE CHECK SQL "(TAG = tag1 AND id_grupo = 1)".
     } else if (check_acl($config['id_user'], 0, 'EW')) {

From c1ac6b7ed64f54fbd3e22efa45ab24256795cc4c Mon Sep 17 00:00:00 2001
From: fbsanchez <fborja.sanchez@artica.es>
Date: Mon, 24 Jun 2019 19:23:41 +0200
Subject: [PATCH 29/37] mini_severity virtual column added

---
 .../godmode/events/custom_events.php          |  2 ++
 pandora_console/include/functions_events.php  |  3 +++
 pandora_console/operation/events/events.php   | 25 +++++++++++++++----
 3 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/pandora_console/godmode/events/custom_events.php b/pandora_console/godmode/events/custom_events.php
index bfb0e8c64d..cfdf50cf17 100644
--- a/pandora_console/godmode/events/custom_events.php
+++ b/pandora_console/godmode/events/custom_events.php
@@ -113,6 +113,8 @@ $fields_available['instructions'] = __('Instructions');
 $fields_available['server_name'] = __('Server Name');
 $fields_available['data'] = __('Data');
 $fields_available['module_status'] = __('Module Status');
+$fields_available['mini_severity'] = __('Severity mini');
+
 
 // Remove fields already selected.
 foreach ($fields_available as $key => $available) {
diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php
index c974251170..5f83669b4b 100644
--- a/pandora_console/include/functions_events.php
+++ b/pandora_console/include/functions_events.php
@@ -288,6 +288,9 @@ function events_get_column_name($field)
         case 'options':
         return __('Options');
 
+        case 'mini_severity':
+        return 'S';
+
         default:
         return __($field);
     }
diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php
index a4a347ba90..ee44713385 100644
--- a/pandora_console/operation/events/events.php
+++ b/pandora_console/operation/events/events.php
@@ -209,6 +209,10 @@ if (is_ajax()) {
             ob_start();
             $order = get_datatable_order(true);
 
+            if (is_array($order) && $order['field'] == 'mini_severity') {
+                $order['field'] = 'te.criticity';
+            }
+
             $fields = [
                 'te.id_evento',
                 'te.id_agente',
@@ -1168,6 +1172,10 @@ try {
             'text'  => 'evento',
             'class' => 'mw120px',
         ],
+        [
+            'text'  => 'mini_severity',
+            'class' => 'no-padding',
+        ],
         'id_evento',
             // 'id_agente',
             // 'id_usuario',
@@ -1213,6 +1221,12 @@ try {
         $fields = $default_fields;
     }
 
+    if (in_array('mini_severity', $fields) > 0) {
+        $fields[array_search('mini_severity', $fields)] = [
+            'text'  => 'mini_severity',
+            'class' => 'no-padding-imp',
+        ];
+    }
 
     $evento_id = array_search('evento', $fields);
     if ($evento_id !== false) {
@@ -1584,16 +1598,17 @@ function process_datatables_item(item) {
     output += '</div>';
 
     // Add event severity to end of text.
-    evn = '<div class="event flex-row h100p nowrap">';
-    evn += '<div><a href="javascript:" onclick="show_event_dialog(\'';
+    evn = '<a href="javascript:" onclick="show_event_dialog(\'';
     evn += btoa(JSON.stringify(item))+'\','+$("#group_rep").val()+');">';
     // Grouped events.
     if(item.event_rep && item.event_rep > 1) {
         evn += '('+item.event_rep+') ';
     }
-    evn += item.evento+'</a></div>';
-    evn += output;
-    evn += '</div>'
+    evn += item.evento+'</a>';
+
+    item.mini_severity = '<div class="event flex-row h100p nowrap">';
+    item.mini_severity += output;
+    item.mini_severity += '</div>';
 
     criticity = '<div class="criticity" style="background: ';
     criticity += color + '">' + text + "</div>";

From a469ff29daf2b8f4ce88b1e4cf140e88e9341ec4 Mon Sep 17 00:00:00 2001
From: artica <artica.devel@gmail.com>
Date: Tue, 25 Jun 2019 00:01:09 +0200
Subject: [PATCH 30/37] Auto-updated build strings.

---
 pandora_agents/unix/DEBIAN/control             | 2 +-
 pandora_agents/unix/DEBIAN/make_deb_package.sh | 2 +-
 pandora_agents/unix/pandora_agent              | 2 +-
 pandora_agents/unix/pandora_agent.redhat.spec  | 2 +-
 pandora_agents/unix/pandora_agent.spec         | 2 +-
 pandora_agents/unix/pandora_agent_installer    | 2 +-
 pandora_agents/win32/installer/pandora.mpi     | 2 +-
 pandora_agents/win32/pandora.cc                | 2 +-
 pandora_agents/win32/versioninfo.rc            | 2 +-
 pandora_console/DEBIAN/control                 | 2 +-
 pandora_console/DEBIAN/make_deb_package.sh     | 2 +-
 pandora_console/include/config_process.php     | 2 +-
 pandora_console/install.php                    | 2 +-
 pandora_console/pandora_console.redhat.spec    | 2 +-
 pandora_console/pandora_console.rhel7.spec     | 2 +-
 pandora_console/pandora_console.spec           | 2 +-
 pandora_server/DEBIAN/control                  | 2 +-
 pandora_server/DEBIAN/make_deb_package.sh      | 2 +-
 pandora_server/lib/PandoraFMS/Config.pm        | 2 +-
 pandora_server/lib/PandoraFMS/PluginTools.pm   | 2 +-
 pandora_server/pandora_server.redhat.spec      | 2 +-
 pandora_server/pandora_server.spec             | 2 +-
 pandora_server/pandora_server_installer        | 2 +-
 pandora_server/util/pandora_db.pl              | 2 +-
 pandora_server/util/pandora_manage.pl          | 2 +-
 25 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control
index 740ea789c5..6771606f50 100644
--- a/pandora_agents/unix/DEBIAN/control
+++ b/pandora_agents/unix/DEBIAN/control
@@ -1,5 +1,5 @@
 package: pandorafms-agent-unix
-Version: 7.0NG.735-190624
+Version: 7.0NG.735-190625
 Architecture: all
 Priority: optional
 Section: admin
diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh
index 170c5bcee5..fe7628e999 100644
--- a/pandora_agents/unix/DEBIAN/make_deb_package.sh
+++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh
@@ -14,7 +14,7 @@
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 
-pandora_version="7.0NG.735-190624"
+pandora_version="7.0NG.735-190625"
 
 echo "Test if you has the tools for to make the packages."
 whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null
diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent
index 8b00991b4a..6bbb463b49 100755
--- a/pandora_agents/unix/pandora_agent
+++ b/pandora_agents/unix/pandora_agent
@@ -42,7 +42,7 @@ my $Sem = undef;
 my $ThreadSem = undef;
 
 use constant AGENT_VERSION => '7.0NG.735';
-use constant AGENT_BUILD => '190624';
+use constant AGENT_BUILD => '190625';
 
 # Agent log default file size maximum and instances
 use constant DEFAULT_MAX_LOG_SIZE => 600000;
diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec
index fabb18238b..8f580504eb 100644
--- a/pandora_agents/unix/pandora_agent.redhat.spec
+++ b/pandora_agents/unix/pandora_agent.redhat.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_agent_unix
 %define version     7.0NG.735
-%define release     190624
+%define release     190625
 
 Summary:            Pandora FMS Linux agent, PERL version
 Name:               %{name}
diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec
index 9a8f15d4f6..28023a28f3 100644
--- a/pandora_agents/unix/pandora_agent.spec
+++ b/pandora_agents/unix/pandora_agent.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_agent_unix
 %define version     7.0NG.735
-%define release     190624
+%define release     190625
 
 Summary:            Pandora FMS Linux agent, PERL version
 Name:               %{name}
diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer
index d315e8ea8f..879ff79eac 100755
--- a/pandora_agents/unix/pandora_agent_installer
+++ b/pandora_agents/unix/pandora_agent_installer
@@ -10,7 +10,7 @@
 # **********************************************************************
 
 PI_VERSION="7.0NG.735"
-PI_BUILD="190624"
+PI_BUILD="190625"
 OS_NAME=`uname -s`
 
 FORCE=0
diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi
index 0bfbced120..21e38fb13b 100644
--- a/pandora_agents/win32/installer/pandora.mpi
+++ b/pandora_agents/win32/installer/pandora.mpi
@@ -186,7 +186,7 @@ UpgradeApplicationID
 {}
 
 Version
-{190624}
+{190625}
 
 ViewReadme
 {Yes}
diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc
index 44997b04a5..2194b622ac 100644
--- a/pandora_agents/win32/pandora.cc
+++ b/pandora_agents/win32/pandora.cc
@@ -30,7 +30,7 @@ using namespace Pandora;
 using namespace Pandora_Strutils;
 
 #define PATH_SIZE    _MAX_PATH+1
-#define PANDORA_VERSION ("7.0NG.735(Build 190624)")
+#define PANDORA_VERSION ("7.0NG.735(Build 190625)")
 
 string pandora_path;
 string pandora_dir;
diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc
index 3ad4771da2..f328ab299c 100644
--- a/pandora_agents/win32/versioninfo.rc
+++ b/pandora_agents/win32/versioninfo.rc
@@ -11,7 +11,7 @@ BEGIN
       VALUE "LegalCopyright", "Artica ST"
       VALUE "OriginalFilename", "PandoraAgent.exe"
       VALUE "ProductName", "Pandora FMS Windows Agent"
-      VALUE "ProductVersion", "(7.0NG.735(Build 190624))"
+      VALUE "ProductVersion", "(7.0NG.735(Build 190625))"
       VALUE "FileVersion", "1.0.0.0"
     END
   END
diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control
index 532200a913..8a166990ab 100644
--- a/pandora_console/DEBIAN/control
+++ b/pandora_console/DEBIAN/control
@@ -1,5 +1,5 @@
 package: pandorafms-console
-Version: 7.0NG.735-190624
+Version: 7.0NG.735-190625
 Architecture: all
 Priority: optional
 Section: admin
diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh
index 17b872cf03..2d45e0aa49 100644
--- a/pandora_console/DEBIAN/make_deb_package.sh
+++ b/pandora_console/DEBIAN/make_deb_package.sh
@@ -14,7 +14,7 @@
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 
-pandora_version="7.0NG.735-190624"
+pandora_version="7.0NG.735-190625"
 
 package_pear=0
 package_pandora=1
diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php
index de7af03832..60a348e138 100644
--- a/pandora_console/include/config_process.php
+++ b/pandora_console/include/config_process.php
@@ -20,7 +20,7 @@
 /**
  * Pandora build version and version
  */
-$build_version = 'PC190624';
+$build_version = 'PC190625';
 $pandora_version = 'v7.0NG.735';
 
 // Do not overwrite default timezone set if defined.
diff --git a/pandora_console/install.php b/pandora_console/install.php
index 56e6c61d3c..2e3074241c 100644
--- a/pandora_console/install.php
+++ b/pandora_console/install.php
@@ -129,7 +129,7 @@
         <div style='height: 10px'>
             <?php
             $version = '7.0NG.735';
-            $build = '190624';
+            $build = '190625';
             $banner = "v$version Build $build";
 
             error_reporting(0);
diff --git a/pandora_console/pandora_console.redhat.spec b/pandora_console/pandora_console.redhat.spec
index 7d301595f1..a181733e7d 100644
--- a/pandora_console/pandora_console.redhat.spec
+++ b/pandora_console/pandora_console.redhat.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_console
 %define version     7.0NG.735
-%define release     190624
+%define release     190625
 
 # User and Group under which Apache is running
 %define httpd_name  httpd
diff --git a/pandora_console/pandora_console.rhel7.spec b/pandora_console/pandora_console.rhel7.spec
index 00d58afec8..2bf8d0c433 100644
--- a/pandora_console/pandora_console.rhel7.spec
+++ b/pandora_console/pandora_console.rhel7.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_console
 %define version     7.0NG.735
-%define release     190624
+%define release     190625
 
 # User and Group under which Apache is running
 %define httpd_name  httpd
diff --git a/pandora_console/pandora_console.spec b/pandora_console/pandora_console.spec
index 8fc10f81e3..14a500325d 100644
--- a/pandora_console/pandora_console.spec
+++ b/pandora_console/pandora_console.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_console
 %define version     7.0NG.735
-%define release     190624
+%define release     190625
 %define httpd_name      httpd
 # User and Group under which Apache is running
 %define httpd_name  apache2
diff --git a/pandora_server/DEBIAN/control b/pandora_server/DEBIAN/control
index 5ac459b77c..906e793d8e 100644
--- a/pandora_server/DEBIAN/control
+++ b/pandora_server/DEBIAN/control
@@ -1,5 +1,5 @@
 package: pandorafms-server
-Version: 7.0NG.735-190624
+Version: 7.0NG.735-190625
 Architecture: all
 Priority: optional
 Section: admin
diff --git a/pandora_server/DEBIAN/make_deb_package.sh b/pandora_server/DEBIAN/make_deb_package.sh
index 9ee69248e5..7fff838f35 100644
--- a/pandora_server/DEBIAN/make_deb_package.sh
+++ b/pandora_server/DEBIAN/make_deb_package.sh
@@ -14,7 +14,7 @@
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 
-pandora_version="7.0NG.735-190624"
+pandora_version="7.0NG.735-190625"
 
 package_cpan=0
 package_pandora=1
diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm
index 22bf22db0f..60b50d2552 100644
--- a/pandora_server/lib/PandoraFMS/Config.pm
+++ b/pandora_server/lib/PandoraFMS/Config.pm
@@ -45,7 +45,7 @@ our @EXPORT = qw(
 
 # version: Defines actual version of Pandora Server for this module only
 my $pandora_version = "7.0NG.735";
-my $pandora_build = "190624";
+my $pandora_build = "190625";
 our $VERSION = $pandora_version." ".$pandora_build;
 
 # Setup hash
diff --git a/pandora_server/lib/PandoraFMS/PluginTools.pm b/pandora_server/lib/PandoraFMS/PluginTools.pm
index 998f562753..3b0caf9619 100644
--- a/pandora_server/lib/PandoraFMS/PluginTools.pm
+++ b/pandora_server/lib/PandoraFMS/PluginTools.pm
@@ -32,7 +32,7 @@ our @ISA = qw(Exporter);
 
 # version: Defines actual version of Pandora Server for this module only
 my $pandora_version = "7.0NG.735";
-my $pandora_build = "190624";
+my $pandora_build = "190625";
 our $VERSION = $pandora_version." ".$pandora_build;
 
 our %EXPORT_TAGS = ( 'all' => [ qw() ] );
diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec
index 4536349a29..d6b4578521 100644
--- a/pandora_server/pandora_server.redhat.spec
+++ b/pandora_server/pandora_server.redhat.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_server
 %define version     7.0NG.735
-%define release     190624
+%define release     190625
 
 Summary:            Pandora FMS Server
 Name:               %{name}
diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec
index 7f9d84c9d3..f3758822ff 100644
--- a/pandora_server/pandora_server.spec
+++ b/pandora_server/pandora_server.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_server
 %define version     7.0NG.735
-%define release     190624
+%define release     190625
 
 Summary:            Pandora FMS Server
 Name:               %{name}
diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer
index 5b6f79452d..b63386d7df 100755
--- a/pandora_server/pandora_server_installer
+++ b/pandora_server/pandora_server_installer
@@ -9,7 +9,7 @@
 # **********************************************************************
 
 PI_VERSION="7.0NG.735"
-PI_BUILD="190624"
+PI_BUILD="190625"
 
 MODE=$1
 if [ $# -gt 1 ]; then
diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl
index a8bcb0e5f5..875f8f51dd 100644
--- a/pandora_server/util/pandora_db.pl
+++ b/pandora_server/util/pandora_db.pl
@@ -34,7 +34,7 @@ use PandoraFMS::Config;
 use PandoraFMS::DB;
 
 # version: define current version
-my $version = "7.0NG.735 PS190624";
+my $version = "7.0NG.735 PS190625";
 
 # Pandora server configuration
 my %conf;
diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl
index 49beaa79bb..e00e964276 100644
--- a/pandora_server/util/pandora_manage.pl
+++ b/pandora_server/util/pandora_manage.pl
@@ -36,7 +36,7 @@ use Encode::Locale;
 Encode::Locale::decode_argv;
 
 # version: define current version
-my $version = "7.0NG.735 PS190624";
+my $version = "7.0NG.735 PS190625";
 
 # save program name for logging
 my $progname = basename($0);

From 86600ca4542fa3fff050c51f2783140ffe5f0be0 Mon Sep 17 00:00:00 2001
From: fbsanchez <fborja.sanchez@artica.es>
Date: Tue, 25 Jun 2019 12:21:18 +0200
Subject: [PATCH 31/37] RSS menu filter loaded

---
 pandora_console/operation/menu.php | 32 +++++++++++++++++++++++++++---
 1 file changed, 29 insertions(+), 3 deletions(-)

diff --git a/pandora_console/operation/menu.php b/pandora_console/operation/menu.php
index 5daf40d310..936cb6a814 100644
--- a/pandora_console/operation/menu.php
+++ b/pandora_console/operation/menu.php
@@ -373,10 +373,36 @@ if (check_acl($config['id_user'], 0, 'ER')
         $pss = get_user_info($config['id_user']);
         $hashup = md5($config['id_user'].$pss['password']);
 
+        $user_filter = db_get_row_sql(
+            sprintf(
+                'SELECT f.id_filter, f.id_name
+                FROM tevent_filter f
+                INNER JOIN tusuario u
+                    ON u.default_event_filter=f.id_filter
+                WHERE u.id_user = "%s" ',
+                $config['id_user']
+            )
+        );
+        if ($user_filter !== false) {
+            $filter = events_get_event_filter($user_filter['id_filter']);
+        } else {
+            // Default.
+            $filter = [
+                'status'        => EVENT_NO_VALIDATED,
+                'event_view_hr' => $config['event_view_hr'],
+                'group_rep'     => 1,
+                'tag_with'      => [],
+                'tag_without'   => [],
+                'history'       => false,
+            ];
+        }
+
+        $fb64 = base64_encode(json_encode($filter));
+
         // RSS.
-        $sub['operation/events/events_rss.php?user='.$config['id_user'].'&amp;hashup='.$hashup.'&search=&event_type=&severity=-1&status=3&id_group=0&refr=0&id_agent=0&pagination=20&group_rep=1&event_view_hr=8&id_user_ack=0&tag_with=&tag_without=&filter_only_alert-1&offset=0&toogle_filter=no&filter_id=0&id_name=&id_group=0&history=0&section=list&open_filter=0&pure=']['text'] = __('RSS');
-        $sub['operation/events/events_rss.php?user='.$config['id_user'].'&amp;hashup='.$hashup.'&search=&event_type=&severity=-1&status=3&id_group=0&refr=0&id_agent=0&pagination=20&group_rep=1&event_view_hr=8&id_user_ack=0&tag_with=&tag_without=&filter_only_alert-1&offset=0&toogle_filter=no&filter_id=0&id_name=&id_group=0&history=0&section=list&open_filter=0&pure=']['id'] = 'RSS';
-        $sub['operation/events/events_rss.php?user='.$config['id_user'].'&amp;hashup='.$hashup.'&search=&event_type=&severity=-1&status=3&id_group=0&refr=0&id_agent=0&pagination=20&group_rep=1&event_view_hr=8&id_user_ack=0&tag_with=&tag_without=&filter_only_alert-1&offset=0&toogle_filter=no&filter_id=0&id_name=&id_group=0&history=0&section=list&open_filter=0&pure=']['type'] = 'direct';
+        $sub['operation/events/events_rss.php?user='.$config['id_user'].'&amp;hashup='.$hashup.'&fb64='.$fb64]['text'] = __('RSS');
+        $sub['operation/events/events_rss.php?user='.$config['id_user'].'&amp;hashup='.$hashup.'&fb64='.$fb64]['id'] = 'RSS';
+        $sub['operation/events/events_rss.php?user='.$config['id_user'].'&amp;hashup='.$hashup.'&fb64='.$fb64]['type'] = 'direct';
 
         // Marquee.
         $sub['operation/events/events_marquee.php']['text'] = __('Marquee');

From 674c68bd2bb6dac2bc4c6f520bd33871c01565b6 Mon Sep 17 00:00:00 2001
From: fbsanchez <fborja.sanchez@artica.es>
Date: Tue, 25 Jun 2019 12:49:17 +0200
Subject: [PATCH 32/37] avoided issue latin1 btoa javascript event transfer

---
 pandora_console/operation/events/events.php | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php
index ee44713385..da7123e728 100644
--- a/pandora_console/operation/events/events.php
+++ b/pandora_console/operation/events/events.php
@@ -294,6 +294,9 @@ if (is_ajax()) {
                         );
 
                         $tmp->data = format_numeric($tmp->data, 1);
+
+                        $tmp->b64 = base64_encode(json_encode($tmp));
+
                         $carry[] = $tmp;
                         return $carry;
                     }
@@ -1599,7 +1602,7 @@ function process_datatables_item(item) {
 
     // Add event severity to end of text.
     evn = '<a href="javascript:" onclick="show_event_dialog(\'';
-    evn += btoa(JSON.stringify(item))+'\','+$("#group_rep").val()+');">';
+    evn += item.b64+'\','+$("#group_rep").val()+');">';
     // Grouped events.
     if(item.event_rep && item.event_rep > 1) {
         evn += '('+item.event_rep+') ';
@@ -1705,7 +1708,7 @@ function process_datatables_item(item) {
     /* Options */
     // Show more.
     item.options = '<a href="javascript:" onclick="show_event_dialog(\'';
-    item.options += btoa(JSON.stringify(item))+'\','+$("#group_rep").val();
+    item.options += item.b64+'\','+$("#group_rep").val();
     item.options += ')" ><?php echo html_print_image('images/eye.png', true, ['title' => __('Show more')]); ?></a>';
 
     <?php

From 004eb1104897c3bad1bcc169c4eb53d92ff8ca0b Mon Sep 17 00:00:00 2001
From: fbsanchez <fborja.sanchez@artica.es>
Date: Tue, 25 Jun 2019 15:24:15 +0200
Subject: [PATCH 33/37] MR29

---
 pandora_console/extras/mr/29.sql | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/pandora_console/extras/mr/29.sql b/pandora_console/extras/mr/29.sql
index 032dd407b1..5b88329fbf 100644
--- a/pandora_console/extras/mr/29.sql
+++ b/pandora_console/extras/mr/29.sql
@@ -1,5 +1,7 @@
 START TRANSACTION;
 
+ALTER TABLE `tmetaconsole_agent` ADD INDEX `id_tagente_idx` (`id_tagente`);
+
 DELETE FROM `ttipo_modulo` WHERE `nombre` LIKE 'log4x';
 
 

From c5675ded4c4a24c3fcb482a2716f40eb45ab7cfa Mon Sep 17 00:00:00 2001
From: fbsanchez <fborja.sanchez@artica.es>
Date: Tue, 25 Jun 2019 15:24:42 +0200
Subject: [PATCH 34/37] fixed alert color

---
 pandora_console/include/constants.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pandora_console/include/constants.php b/pandora_console/include/constants.php
index 8a67ba1111..69e867bb40 100644
--- a/pandora_console/include/constants.php
+++ b/pandora_console/include/constants.php
@@ -146,7 +146,7 @@ define('COL_NOTINIT', '#4a83f3');
 define('COL_UNKNOWN', '#B2B2B2');
 define('COL_DOWNTIME', '#976DB1');
 define('COL_IGNORED', '#DDD');
-define('COL_ALERTFIRED', '#FFA631');
+define('COL_ALERTFIRED', '#F36201');
 define('COL_MINOR', '#B2B2B2');
 define('COL_MAJOR', '#C97A4A');
 define('COL_INFORMATIONAL', '#E4E4E4');

From 96ca26dc97e9cb47c524b1feff9de7d136f98e7a Mon Sep 17 00:00:00 2001
From: fbsanchez <fborja.sanchez@artica.es>
Date: Tue, 25 Jun 2019 16:05:56 +0200
Subject: [PATCH 35/37] minor fix in event mass response process

---
 .../include/javascript/pandora_events.js           | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/pandora_console/include/javascript/pandora_events.js b/pandora_console/include/javascript/pandora_events.js
index 406cffe243..afd9fbe573 100644
--- a/pandora_console/include/javascript/pandora_events.js
+++ b/pandora_console/include/javascript/pandora_events.js
@@ -231,7 +231,6 @@ function get_response(response_id) {
     type: "POST",
     url: $("#hidden-ajax_file").val(),
     async: false,
-    timeout: 10000,
     dataType: "json",
     success: function(data) {
       response = data;
@@ -255,7 +254,6 @@ function get_response_params(response_id) {
     type: "POST",
     url: $("#hidden-ajax_file").val(),
     async: false,
-    timeout: 10000,
     dataType: "json",
     success: function(data) {
       response_params = data;
@@ -279,7 +277,6 @@ function get_response_description(response_id) {
     type: "POST",
     url: $("#hidden-ajax_file").val(),
     async: false,
-    timeout: 10000,
     dataType: "html",
     success: function(data) {
       response_description = data;
@@ -305,7 +302,6 @@ function get_event_name(event_id, meta, history) {
     type: "POST",
     url: $("#hidden-ajax_file").val(),
     async: false,
-    timeout: 10000,
     dataType: "html",
     success: function(data) {
       name = data;
@@ -349,7 +345,6 @@ function get_response_target(
     type: "POST",
     url: $("#hidden-ajax_file").val(),
     async: false,
-    timeout: 10000,
     dataType: "html",
     success: function(data) {
       target = data;
@@ -394,7 +389,6 @@ function perform_response(target, response_id) {
     type: "POST",
     url: $("#hidden-ajax_file").val(),
     async: true,
-    timeout: 10000,
     dataType: "html",
     success: function(data) {
       var out = data.replace(/[\n|\r]/g, "<br>");
@@ -424,7 +418,6 @@ function perform_response_massive(target, response_id, out_iterator) {
     type: "POST",
     url: $("#hidden-ajax_file").val(),
     async: true,
-    timeout: 10000,
     dataType: "html",
     success: function(data) {
       var out = data.replace(/[\n|\r]/g, "<br>");
@@ -460,7 +453,6 @@ function event_change_status(event_ids) {
     type: "POST",
     url: $("#hidden-ajax_file").val(),
     async: true,
-    timeout: 10000,
     dataType: "html",
     success: function(data) {
       $("#button-status_button").removeAttr("disabled");
@@ -499,7 +491,6 @@ function event_change_owner() {
     type: "POST",
     url: $("#hidden-ajax_file").val(),
     async: true,
-    timeout: 10000,
     dataType: "html",
     success: function(data) {
       $("#button-owner_button").removeAttr("disabled");
@@ -553,7 +544,6 @@ function event_comment() {
     type: "POST",
     url: $("#hidden-ajax_file").val(),
     async: true,
-    timeout: 10000,
     dataType: "html",
     success: function(data) {
       $("#button-comment_button").removeAttr("disabled");
@@ -680,7 +670,6 @@ function update_event(table, id_evento, type, event_rep, row) {
   // Update events matching current filters and id_evento selected.
   $.ajax({
     async: true,
-    timeout: 10000,
     type: "POST",
     url: $("#hidden-ajax_file").val(),
     data: {
@@ -721,6 +710,7 @@ function validate_event(table, id_evento, event_rep, row) {
   var button = document.getElementById("val-" + id_evento);
   if (!button) {
     // Button does not exist. Ignore.
+    processed += 1;
     return;
   }
 
@@ -733,6 +723,7 @@ function in_process_event(table, id_evento, event_rep, row) {
   var button = document.getElementById("proc-" + id_evento);
   if (!button) {
     // Button does not exist. Ignore.
+    processed += 1;
     return;
   }
 
@@ -751,6 +742,7 @@ function delete_event(table, id_evento, event_rep, row) {
   var button = document.getElementById("del-" + id_evento);
   if (!button) {
     // Button does not exist. Ignore.
+    processed += 1;
     return;
   }
 

From 8f914b69a601538b76954c61d4644e3c16e2fe19 Mon Sep 17 00:00:00 2001
From: fbsanchez <fborja.sanchez@artica.es>
Date: Tue, 25 Jun 2019 17:24:16 +0200
Subject: [PATCH 36/37] Minor fixes

---
 pandora_console/include/javascript/pandora_events.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pandora_console/include/javascript/pandora_events.js b/pandora_console/include/javascript/pandora_events.js
index afd9fbe573..94dadb6fbb 100644
--- a/pandora_console/include/javascript/pandora_events.js
+++ b/pandora_console/include/javascript/pandora_events.js
@@ -688,7 +688,7 @@ function update_event(table, id_evento, type, event_rep, row) {
       var diff_s = diff_g / 1000;
       if (processed >= $(".chk_val:checked").length) {
         // If operation takes less than 2 seconds, redraw.
-        if (diff_s < 2) {
+        if (diff_s < 2 || $(".chk_val:checked").length > 1) {
           redraw = true;
         }
         if (redraw) {

From 9a65d8188a2cc67375a46a8e552e859524d0aad5 Mon Sep 17 00:00:00 2001
From: artica <artica.devel@gmail.com>
Date: Wed, 26 Jun 2019 00:01:09 +0200
Subject: [PATCH 37/37] Auto-updated build strings.

---
 pandora_agents/unix/DEBIAN/control             | 2 +-
 pandora_agents/unix/DEBIAN/make_deb_package.sh | 2 +-
 pandora_agents/unix/pandora_agent              | 2 +-
 pandora_agents/unix/pandora_agent.redhat.spec  | 2 +-
 pandora_agents/unix/pandora_agent.spec         | 2 +-
 pandora_agents/unix/pandora_agent_installer    | 2 +-
 pandora_agents/win32/installer/pandora.mpi     | 2 +-
 pandora_agents/win32/pandora.cc                | 2 +-
 pandora_agents/win32/versioninfo.rc            | 2 +-
 pandora_console/DEBIAN/control                 | 2 +-
 pandora_console/DEBIAN/make_deb_package.sh     | 2 +-
 pandora_console/include/config_process.php     | 2 +-
 pandora_console/install.php                    | 2 +-
 pandora_console/pandora_console.redhat.spec    | 2 +-
 pandora_console/pandora_console.rhel7.spec     | 2 +-
 pandora_console/pandora_console.spec           | 2 +-
 pandora_server/DEBIAN/control                  | 2 +-
 pandora_server/DEBIAN/make_deb_package.sh      | 2 +-
 pandora_server/lib/PandoraFMS/Config.pm        | 2 +-
 pandora_server/lib/PandoraFMS/PluginTools.pm   | 2 +-
 pandora_server/pandora_server.redhat.spec      | 2 +-
 pandora_server/pandora_server.spec             | 2 +-
 pandora_server/pandora_server_installer        | 2 +-
 pandora_server/util/pandora_db.pl              | 2 +-
 pandora_server/util/pandora_manage.pl          | 2 +-
 25 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control
index 6771606f50..2faf21c47a 100644
--- a/pandora_agents/unix/DEBIAN/control
+++ b/pandora_agents/unix/DEBIAN/control
@@ -1,5 +1,5 @@
 package: pandorafms-agent-unix
-Version: 7.0NG.735-190625
+Version: 7.0NG.735-190626
 Architecture: all
 Priority: optional
 Section: admin
diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh
index fe7628e999..7521094eba 100644
--- a/pandora_agents/unix/DEBIAN/make_deb_package.sh
+++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh
@@ -14,7 +14,7 @@
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 
-pandora_version="7.0NG.735-190625"
+pandora_version="7.0NG.735-190626"
 
 echo "Test if you has the tools for to make the packages."
 whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null
diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent
index 6bbb463b49..3cf1d22126 100755
--- a/pandora_agents/unix/pandora_agent
+++ b/pandora_agents/unix/pandora_agent
@@ -42,7 +42,7 @@ my $Sem = undef;
 my $ThreadSem = undef;
 
 use constant AGENT_VERSION => '7.0NG.735';
-use constant AGENT_BUILD => '190625';
+use constant AGENT_BUILD => '190626';
 
 # Agent log default file size maximum and instances
 use constant DEFAULT_MAX_LOG_SIZE => 600000;
diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec
index 8f580504eb..725d5abaa2 100644
--- a/pandora_agents/unix/pandora_agent.redhat.spec
+++ b/pandora_agents/unix/pandora_agent.redhat.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_agent_unix
 %define version     7.0NG.735
-%define release     190625
+%define release     190626
 
 Summary:            Pandora FMS Linux agent, PERL version
 Name:               %{name}
diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec
index 28023a28f3..970291a4c3 100644
--- a/pandora_agents/unix/pandora_agent.spec
+++ b/pandora_agents/unix/pandora_agent.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_agent_unix
 %define version     7.0NG.735
-%define release     190625
+%define release     190626
 
 Summary:            Pandora FMS Linux agent, PERL version
 Name:               %{name}
diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer
index 879ff79eac..2b9cf3b68c 100755
--- a/pandora_agents/unix/pandora_agent_installer
+++ b/pandora_agents/unix/pandora_agent_installer
@@ -10,7 +10,7 @@
 # **********************************************************************
 
 PI_VERSION="7.0NG.735"
-PI_BUILD="190625"
+PI_BUILD="190626"
 OS_NAME=`uname -s`
 
 FORCE=0
diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi
index 21e38fb13b..7aecb7cff2 100644
--- a/pandora_agents/win32/installer/pandora.mpi
+++ b/pandora_agents/win32/installer/pandora.mpi
@@ -186,7 +186,7 @@ UpgradeApplicationID
 {}
 
 Version
-{190625}
+{190626}
 
 ViewReadme
 {Yes}
diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc
index 2194b622ac..f655faabc6 100644
--- a/pandora_agents/win32/pandora.cc
+++ b/pandora_agents/win32/pandora.cc
@@ -30,7 +30,7 @@ using namespace Pandora;
 using namespace Pandora_Strutils;
 
 #define PATH_SIZE    _MAX_PATH+1
-#define PANDORA_VERSION ("7.0NG.735(Build 190625)")
+#define PANDORA_VERSION ("7.0NG.735(Build 190626)")
 
 string pandora_path;
 string pandora_dir;
diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc
index f328ab299c..3d3a2ebf4a 100644
--- a/pandora_agents/win32/versioninfo.rc
+++ b/pandora_agents/win32/versioninfo.rc
@@ -11,7 +11,7 @@ BEGIN
       VALUE "LegalCopyright", "Artica ST"
       VALUE "OriginalFilename", "PandoraAgent.exe"
       VALUE "ProductName", "Pandora FMS Windows Agent"
-      VALUE "ProductVersion", "(7.0NG.735(Build 190625))"
+      VALUE "ProductVersion", "(7.0NG.735(Build 190626))"
       VALUE "FileVersion", "1.0.0.0"
     END
   END
diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control
index 8a166990ab..5fc2731073 100644
--- a/pandora_console/DEBIAN/control
+++ b/pandora_console/DEBIAN/control
@@ -1,5 +1,5 @@
 package: pandorafms-console
-Version: 7.0NG.735-190625
+Version: 7.0NG.735-190626
 Architecture: all
 Priority: optional
 Section: admin
diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh
index 2d45e0aa49..44d78e12ac 100644
--- a/pandora_console/DEBIAN/make_deb_package.sh
+++ b/pandora_console/DEBIAN/make_deb_package.sh
@@ -14,7 +14,7 @@
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 
-pandora_version="7.0NG.735-190625"
+pandora_version="7.0NG.735-190626"
 
 package_pear=0
 package_pandora=1
diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php
index 60a348e138..95f6595032 100644
--- a/pandora_console/include/config_process.php
+++ b/pandora_console/include/config_process.php
@@ -20,7 +20,7 @@
 /**
  * Pandora build version and version
  */
-$build_version = 'PC190625';
+$build_version = 'PC190626';
 $pandora_version = 'v7.0NG.735';
 
 // Do not overwrite default timezone set if defined.
diff --git a/pandora_console/install.php b/pandora_console/install.php
index 2e3074241c..00a940965b 100644
--- a/pandora_console/install.php
+++ b/pandora_console/install.php
@@ -129,7 +129,7 @@
         <div style='height: 10px'>
             <?php
             $version = '7.0NG.735';
-            $build = '190625';
+            $build = '190626';
             $banner = "v$version Build $build";
 
             error_reporting(0);
diff --git a/pandora_console/pandora_console.redhat.spec b/pandora_console/pandora_console.redhat.spec
index a181733e7d..46d3f0e098 100644
--- a/pandora_console/pandora_console.redhat.spec
+++ b/pandora_console/pandora_console.redhat.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_console
 %define version     7.0NG.735
-%define release     190625
+%define release     190626
 
 # User and Group under which Apache is running
 %define httpd_name  httpd
diff --git a/pandora_console/pandora_console.rhel7.spec b/pandora_console/pandora_console.rhel7.spec
index 2bf8d0c433..c5493a1a4c 100644
--- a/pandora_console/pandora_console.rhel7.spec
+++ b/pandora_console/pandora_console.rhel7.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_console
 %define version     7.0NG.735
-%define release     190625
+%define release     190626
 
 # User and Group under which Apache is running
 %define httpd_name  httpd
diff --git a/pandora_console/pandora_console.spec b/pandora_console/pandora_console.spec
index 14a500325d..f3c1b5346d 100644
--- a/pandora_console/pandora_console.spec
+++ b/pandora_console/pandora_console.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_console
 %define version     7.0NG.735
-%define release     190625
+%define release     190626
 %define httpd_name      httpd
 # User and Group under which Apache is running
 %define httpd_name  apache2
diff --git a/pandora_server/DEBIAN/control b/pandora_server/DEBIAN/control
index 906e793d8e..96de3bd6eb 100644
--- a/pandora_server/DEBIAN/control
+++ b/pandora_server/DEBIAN/control
@@ -1,5 +1,5 @@
 package: pandorafms-server
-Version: 7.0NG.735-190625
+Version: 7.0NG.735-190626
 Architecture: all
 Priority: optional
 Section: admin
diff --git a/pandora_server/DEBIAN/make_deb_package.sh b/pandora_server/DEBIAN/make_deb_package.sh
index 7fff838f35..914781e99a 100644
--- a/pandora_server/DEBIAN/make_deb_package.sh
+++ b/pandora_server/DEBIAN/make_deb_package.sh
@@ -14,7 +14,7 @@
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 
-pandora_version="7.0NG.735-190625"
+pandora_version="7.0NG.735-190626"
 
 package_cpan=0
 package_pandora=1
diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm
index 60b50d2552..e4e2eca7ee 100644
--- a/pandora_server/lib/PandoraFMS/Config.pm
+++ b/pandora_server/lib/PandoraFMS/Config.pm
@@ -45,7 +45,7 @@ our @EXPORT = qw(
 
 # version: Defines actual version of Pandora Server for this module only
 my $pandora_version = "7.0NG.735";
-my $pandora_build = "190625";
+my $pandora_build = "190626";
 our $VERSION = $pandora_version." ".$pandora_build;
 
 # Setup hash
diff --git a/pandora_server/lib/PandoraFMS/PluginTools.pm b/pandora_server/lib/PandoraFMS/PluginTools.pm
index 3b0caf9619..6392f0aeda 100644
--- a/pandora_server/lib/PandoraFMS/PluginTools.pm
+++ b/pandora_server/lib/PandoraFMS/PluginTools.pm
@@ -32,7 +32,7 @@ our @ISA = qw(Exporter);
 
 # version: Defines actual version of Pandora Server for this module only
 my $pandora_version = "7.0NG.735";
-my $pandora_build = "190625";
+my $pandora_build = "190626";
 our $VERSION = $pandora_version." ".$pandora_build;
 
 our %EXPORT_TAGS = ( 'all' => [ qw() ] );
diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec
index d6b4578521..14abd0603d 100644
--- a/pandora_server/pandora_server.redhat.spec
+++ b/pandora_server/pandora_server.redhat.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_server
 %define version     7.0NG.735
-%define release     190625
+%define release     190626
 
 Summary:            Pandora FMS Server
 Name:               %{name}
diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec
index f3758822ff..3e53f83626 100644
--- a/pandora_server/pandora_server.spec
+++ b/pandora_server/pandora_server.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_server
 %define version     7.0NG.735
-%define release     190625
+%define release     190626
 
 Summary:            Pandora FMS Server
 Name:               %{name}
diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer
index b63386d7df..97459cff2f 100755
--- a/pandora_server/pandora_server_installer
+++ b/pandora_server/pandora_server_installer
@@ -9,7 +9,7 @@
 # **********************************************************************
 
 PI_VERSION="7.0NG.735"
-PI_BUILD="190625"
+PI_BUILD="190626"
 
 MODE=$1
 if [ $# -gt 1 ]; then
diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl
index 875f8f51dd..b9f0bfa2d2 100644
--- a/pandora_server/util/pandora_db.pl
+++ b/pandora_server/util/pandora_db.pl
@@ -34,7 +34,7 @@ use PandoraFMS::Config;
 use PandoraFMS::DB;
 
 # version: define current version
-my $version = "7.0NG.735 PS190625";
+my $version = "7.0NG.735 PS190626";
 
 # Pandora server configuration
 my %conf;
diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl
index e00e964276..c6c88c7139 100644
--- a/pandora_server/util/pandora_manage.pl
+++ b/pandora_server/util/pandora_manage.pl
@@ -36,7 +36,7 @@ use Encode::Locale;
 Encode::Locale::decode_argv;
 
 # version: define current version
-my $version = "7.0NG.735 PS190625";
+my $version = "7.0NG.735 PS190626";
 
 # save program name for logging
 my $progname = basename($0);