From 5d41cf7d04e95c59ee6bab6e1143c964e8d87e05 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Wed, 27 Sep 2023 15:47:44 +0200 Subject: [PATCH 001/109] #12139 Fix new_agent api request --- pandora_console/include/functions_api.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 7e22befbee..068c5409f6 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -2014,7 +2014,7 @@ function api_set_new_agent($id_node, $thrash2, $other, $trhash3, $return=false, } returnError('No agent alias specified'); - } else if (agents_get_agent_id($nombre_agente)) { + } else if (agents_get_agent_id($agent->nombre())) { if ($message === true) { return 'The agent name already exists in DB.'; } @@ -2062,7 +2062,7 @@ function api_set_new_agent($id_node, $thrash2, $other, $trhash3, $return=false, } } - if ($return === false) { + if ($return !== true) { returnData( 'string', [ From 9a57cc550ec99fbe9b063124dbecdc46e7ec1233 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Wed, 11 Oct 2023 16:31:48 +0200 Subject: [PATCH 002/109] #12192 Fix pandora itsm url --- pandora_console/godmode/setup/setup_ITSM.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pandora_console/godmode/setup/setup_ITSM.php b/pandora_console/godmode/setup/setup_ITSM.php index 3196ef677c..50aee8631e 100644 --- a/pandora_console/godmode/setup/setup_ITSM.php +++ b/pandora_console/godmode/setup/setup_ITSM.php @@ -558,7 +558,7 @@ $table_cr_settings->data[4][0] = html_print_label_input_block( // Print. echo ''; From d389f9c3d19c688f1ada55714891717db5498fb0 Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Thu, 16 Nov 2023 11:15:01 +0100 Subject: [PATCH 003/109] #12439 Added Quiet icon to agent finder --- .../operation/search_agents.getdata.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/pandora_console/operation/search_agents.getdata.php b/pandora_console/operation/search_agents.getdata.php index bdeea391a1..f4c1fe0d76 100644 --- a/pandora_console/operation/search_agents.getdata.php +++ b/pandora_console/operation/search_agents.getdata.php @@ -169,12 +169,26 @@ if ($searchAgents) { } foreach ($agents as $key => $agent) { + $agent_quiet = ''; + if ((bool) $agent['quiet'] === true) { + $agent_quiet = html_print_image( + 'images/dot_blue.png', + true, + [ + 'border' => '0', + 'title' => __('Quiet'), + 'alt' => '', + 'class' => 'mrgn_lft_5px', + ] + ); + } + if ($agent['disabled']) { $agents[$key]['agent'] = ''.ucfirst(strtolower($agent['alias'])).''.ui_print_help_tip(__('Disabled'), true).''; + title="'.$agent['id_agente'].'">'.ucfirst(strtolower($agent['alias'])).''.ui_print_help_tip(__('Disabled'), true).''.$agent_quiet; } else { $agents[$key]['agent'] = ''.ucfirst(strtolower($agent['alias'])).''; + title='.$agent['nombre'].'>'.ucfirst(strtolower($agent['alias'])).''.$agent_quiet; } $agents[$key]['os'] = ui_print_os_icon($agent['id_os'], false, true); From b6582b7f7ea10588862856e007b63d81d5373cf2 Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Wed, 22 Nov 2023 13:30:44 +0100 Subject: [PATCH 004/109] #12202 added Asteroids game --- pandora_console/include/ajax/events.php | 13 + pandora_console/include/asteroids/LICENSE.txt | 25 + pandora_console/include/asteroids/README.rst | 46 + .../include/asteroids/asteroids.js | 840 ++++++++++++++++++ pandora_console/include/asteroids/index.html | 14 + pandora_console/include/asteroids/style.css | 46 + .../include/javascript/pandora_events.js | 45 + pandora_console/include/styles/asteroids.css | 65 ++ pandora_console/operation/menu.php | 1 + 9 files changed, 1095 insertions(+) create mode 100644 pandora_console/include/asteroids/LICENSE.txt create mode 100644 pandora_console/include/asteroids/README.rst create mode 100644 pandora_console/include/asteroids/asteroids.js create mode 100644 pandora_console/include/asteroids/index.html create mode 100644 pandora_console/include/asteroids/style.css create mode 100644 pandora_console/include/styles/asteroids.css diff --git a/pandora_console/include/ajax/events.php b/pandora_console/include/ajax/events.php index 7e8341c4a1..88e063b581 100644 --- a/pandora_console/include/ajax/events.php +++ b/pandora_console/include/ajax/events.php @@ -95,6 +95,8 @@ $parameters_modal = get_parameter('parameters', 0); // User private filter. $current_filter = get_parameter('current_filter', 0); $private_filter_event = get_parameter('private_filter_event', 0); +// Asteroids. +$playAsteroids = (bool) get_parameter('playAsteroids', false); if ($get_comments === true) { global $config; @@ -2751,3 +2753,14 @@ if ($draw_row_response_info === true) { echo $output; return; } + +// Asteroids. +if ($playAsteroids === true) { + echo ui_require_css_file('asteroids', 'include/styles/', true); + echo ui_require_javascript_file('asteroids', 'include/asteroids/', true); + + $output = '
Asteroids game goes here!
'; + + echo $output; + return; +} diff --git a/pandora_console/include/asteroids/LICENSE.txt b/pandora_console/include/asteroids/LICENSE.txt new file mode 100644 index 0000000000..0dc661d166 --- /dev/null +++ b/pandora_console/include/asteroids/LICENSE.txt @@ -0,0 +1,25 @@ +Copyright (c) 2023, James Socol +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + diff --git a/pandora_console/include/asteroids/README.rst b/pandora_console/include/asteroids/README.rst new file mode 100644 index 0000000000..c7465358c2 --- /dev/null +++ b/pandora_console/include/asteroids/README.rst @@ -0,0 +1,46 @@ +========= +ASTEROIDS +========= + +Last week, at work, we joked about creating an Asteroids clone where every +asteroid had a bug number in it, as a bit of a joke. (Ha ha, every bug you +kill spawns two more!) + +I was bored this afternoon, so here's a port of Asteroids to JS/Canvas. + +Now all I need to do is hook in the bug numbers. + + +Gameplay +======== + +You're the triangle in the middle. You want to destroy the circles. You have +a gun (spacebar), some thrusters to turn (left and right arrow keys) and an +engine (up arrow key). + +Remember, it's kill or be killed out there. + + +Rights +====== + +The name *Asteroids* is, as far as I know, still property of Atari. I mean no +ill-will towards Atari by releasing this code. Frankly, it's a poor +substitute for anything resembling a real game. I just wanted to see if I +could do it. + +If anyone from Atari asks, I will gladly rename and/or remove this code. But +since there are so many *Asteroids* clones as it is, and the original was +released in 1979, and it was kind of a copy of *Spacewar!*, I doubt they'll +mind too much. + + +Strikes me as funny... +====================== + +The original *Spacewar!*, one of the earliest (if not the original) computer +games, took `200 hours to code `_. + +This probably took me 6. + +I am so glad we've moved past the PDP-1. diff --git a/pandora_console/include/asteroids/asteroids.js b/pandora_console/include/asteroids/asteroids.js new file mode 100644 index 0000000000..d6e9a460f4 --- /dev/null +++ b/pandora_console/include/asteroids/asteroids.js @@ -0,0 +1,840 @@ +// Asteroids.js +// Copyright (c) 2010–2023 James Socol +// See LICENSE.txt for license terms. + +// Game settings +GAME_HEIGHT = 480; +GAME_WIDTH = 640; +FRAME_PERIOD = 60; // 1 frame / x frames/sec +LEVEL_TIMEOUT = 2000; // How long to wait after clearing a level. + +// Player settings +ROTATE_SPEED = Math.PI / 10; // How fast do players turn? (radians) +MAX_SPEED = 15; // Maximum player speed +THRUST_ACCEL = 1; +DEATH_TIMEOUT = 2000; // milliseconds +INVINCIBLE_TIMEOUT = 1500; // How long to stay invincible after resurrecting? +PLAYER_LIVES = 3; +POINTS_PER_SHOT = 1; // How many points does a shot cost? (Should be >= 0.) +POINTS_TO_EXTRA_LIFE = 1000; // How many points to get a 1-up? + +// Bullet settings +BULLET_SPEED = 20; +MAX_BULLETS = 3; +MAX_BULLET_AGE = 25; + +// Asteroid settings +ASTEROID_COUNT = 2; // This + current level = number of asteroids. +ASTEROID_GENERATIONS = 3; // How many times to they split before dying? +ASTEROID_CHILDREN = 2; // How many does each death create? +ASTEROID_SPEED = 3; +ASTEROID_SCORE = 10; // How many points is each one worth? + +var Asteroids = function(home) { + // Constructor + // Order matters. + + // Set up logging. + this.log_level = Asteroids.LOG_DEBUG; + this.log = Asteroids.logger(this); + + // Create the info pane, player, and playfield. + home.innerHTML = ""; + this.info = Asteroids.infoPane(this, home); + this.playfield = Asteroids.playfield(this, home); + this.player = Asteroids.player(this); + + // Set up the event listeners. + this.keyState = Asteroids.keyState(this); + this.listen = Asteroids.listen(this); + + // Useful functions. + this.asteroids = Asteroids.asteroids(this); + this.overlays = Asteroids.overlays(this); + this.highScores = Asteroids.highScores(this); + this.level = Asteroids.level(this); + this.gameOver = Asteroids.gameOver(this); + + // Play the game. + Asteroids.play(this); + return this; +}; + +Asteroids.infoPane = function(game, home) { + var pane = document.createElement("div"); + pane.innerHTML = "ASTEROIDS"; + + var lives = document.createElement("span"); + lives.className = "lives"; + lives.innerHTML = "LIVES: " + PLAYER_LIVES; + + var score = document.createElement("span"); + score.className = "score"; + score.innerHTML = "SCORE: 0"; + + var level = document.createElement("span"); + level.className = "level"; + level.innerHTML = "LEVEL: 1"; + + pane.appendChild(lives); + pane.appendChild(score); + pane.appendChild(level); + home.appendChild(pane); + + return { + setLives: function(game, l) { + lives.innerHTML = "LIVES: " + l; + }, + setScore: function(game, s) { + score.innerHTML = "SCORE: " + s; + }, + setLevel: function(game, _level) { + level.innerHTML = "LEVEL: " + _level; + }, + getPane: function() { + return pane; + } + }; +}; + +Asteroids.playfield = function(game, home) { + var canvas = document.createElement("canvas"); + canvas.width = GAME_WIDTH; + canvas.height = GAME_HEIGHT; + home.appendChild(canvas); + return canvas; +}; + +Asteroids.logger = function(game) { + if (typeof console != "undefined" && typeof console.log != "undefined") { + return { + info: function(msg) { + if (game.log_level <= Asteroids.LOG_INFO) console.log(msg); + }, + debug: function(msg) { + if (game.log_level <= Asteroids.LOG_DEBUG) console.log(msg); + }, + warning: function(msg) { + if (game.log_level <= Asteroids.LOG_WARNING) console.log(msg); + }, + error: function(msg) { + if (game.log_level <= Asteroids.LOG_ERROR) console.log(msg); + }, + critical: function(msg) { + if (game.log_level <= Asteroids.LOG_CRITICAL) console.log(msg); + } + }; + } else { + return { + info: function(msg) {}, + debug: function(msg) {}, + warning: function(msg) {}, + error: function(msg) {}, + critical: function(msg) {} + }; + } +}; + +Asteroids.asteroids = function(game) { + var asteroids = []; + + return { + push: function(obj) { + return asteroids.push(obj); + }, + pop: function() { + return asteroids.pop(); + }, + splice: function(i, j) { + return asteroids.splice(i, j); + }, + get length() { + return asteroids.length; + }, + getIterator: function() { + return asteroids; + }, + generationCount: function(_gen) { + var total = 0; + for (var i = 0; i < asteroids.length; i++) { + if (asteroids[i].getGeneration() == _gen) total++; + } + game.log.debug("Found " + total + " asteroids in generation " + _gen); + return total; + } + }; +}; + +/** + * Creates an overlays controller. + */ +Asteroids.overlays = function(game) { + var overlays = []; + + return { + draw: function(ctx) { + for (var i = 0; i < overlays.length; i++) { + overlays[i].draw(ctx); + } + }, + add: function(obj) { + if (-1 == overlays.indexOf(obj) && typeof obj.draw != "undefined") { + overlays.push(obj); + return true; + } + return false; + }, + remove: function(obj) { + var i = overlays.indexOf(obj); + if (-1 != i) { + overlays.splice(i, 1); + return true; + } + return false; + } + }; +}; + +/** + * Creates a player object. + */ +Asteroids.player = function(game) { + // implements IScreenObject + var position = [GAME_WIDTH / 2, GAME_HEIGHT / 2], + velocity = [0, 0], + direction = -Math.PI / 2, + dead = false, + invincible = false, + lastRez = null, + lives = PLAYER_LIVES, + score = 0, + radius = 3, + path = [ + [10, 0], + [-5, 5], + [-5, -5], + [10, 0] + ]; + + return { + getPosition: function() { + return position; + }, + getVelocity: function() { + return velocity; + }, + getSpeed: function() { + return Math.sqrt(Math.pow(velocity[0], 2) + Math.pow(velocity[1], 2)); + }, + getDirection: function() { + return direction; + }, + getRadius: function() { + return radius; + }, + getScore: function() { + return score; + }, + addScore: function(pts) { + score += pts; + }, + lowerScore: function(pts) { + score -= pts; + if (score < 0) { + score = 0; + } + }, + getLives: function() { + return lives; + }, + rotate: function(rad) { + if (!dead) { + direction += rad; + game.log.info(direction); + } + }, + thrust: function(force) { + if (!dead) { + velocity[0] += force * Math.cos(direction); + velocity[1] += force * Math.sin(direction); + + if (this.getSpeed() > MAX_SPEED) { + velocity[0] = MAX_SPEED * Math.cos(direction); + velocity[1] = MAX_SPEED * Math.sin(direction); + } + + game.log.info(velocity); + } + }, + move: function() { + Asteroids.move(position, velocity); + }, + draw: function(ctx) { + let color = "#fff"; + if (invincible) { + const dt = (new Date() - lastRez) / 200; + const c = Math.floor(Math.cos(dt) * 16).toString(16); + color = `#${c}${c}${c}`; + } + Asteroids.drawPath(ctx, position, direction, 1, path, color); + }, + isDead: function() { + return dead; + }, + isInvincible: function() { + return invincible; + }, + extraLife: function(game) { + game.log.debug("Woo, extra life!"); + lives++; + }, + die: function(game) { + if (!dead) { + game.log.info("You died!"); + dead = true; + invincible = true; + lives--; + position = [GAME_WIDTH / 2, GAME_HEIGHT / 2]; + velocity = [0, 0]; + direction = -Math.PI / 2; + if (lives > 0) { + setTimeout( + (function(player, _game) { + return function() { + player.resurrect(_game); + }; + })(this, game), + DEATH_TIMEOUT + ); + } else { + game.gameOver(); + } + } + }, + resurrect: function(game) { + if (dead) { + dead = false; + invincible = true; + lastRez = new Date(); + setTimeout(function() { + invincible = false; + game.log.debug("No longer invincible!"); + }, INVINCIBLE_TIMEOUT); + game.log.debug("You ressurrected!"); + } + }, + fire: function(game) { + if (!dead) { + game.log.debug("You fired!"); + var _pos = [position[0], position[1]], + _dir = direction; + + this.lowerScore(POINTS_PER_SHOT); + + return Asteroids.bullet(game, _pos, _dir); + } + } + }; +}; + +Asteroids.bullet = function(game, _pos, _dir) { + // implements IScreenObject + var position = [_pos[0], _pos[1]], + velocity = [0, 0], + direction = _dir, + age = 0, + radius = 1, + path = [ + [0, 0], + [-4, 0] + ]; + + velocity[0] = BULLET_SPEED * Math.cos(_dir); + velocity[1] = BULLET_SPEED * Math.sin(_dir); + + return { + getPosition: function() { + return position; + }, + getVelocity: function() { + return velocity; + }, + getSpeed: function() { + return Math.sqrt(Math.pow(velocity[0], 2) + Math.pow(velocity[1], 2)); + }, + getRadius: function() { + return radius; + }, + getAge: function() { + return age; + }, + birthday: function() { + age++; + }, + move: function() { + Asteroids.move(position, velocity); + }, + draw: function(ctx) { + Asteroids.drawPath(ctx, position, direction, 1, path); + } + }; +}; + +Asteroids.keyState = function(_) { + var state = { + [Asteroids.LEFT]: false, + [Asteroids.UP]: false, + [Asteroids.RIGHT]: false, + [Asteroids.DOWN]: false, + [Asteroids.FIRE]: false + }; + + return { + on: function(key) { + state[key] = true; + }, + off: function(key) { + state[key] = false; + }, + getState: function(key) { + if (typeof state[key] != "undefined") return state[key]; + return false; + } + }; +}; + +Asteroids.listen = function(game) { + const keyMap = { + ArrowLeft: Asteroids.LEFT, + KeyA: Asteroids.LEFT, + ArrowRight: Asteroids.RIGHT, + KeyD: Asteroids.RIGHT, + ArrowUp: Asteroids.UP, + KeyW: Asteroids.UP, + Space: Asteroids.FIRE + }; + + window.addEventListener( + "keydown", + function(e) { + const state = keyMap[e.code]; + if (state) { + e.preventDefault(); + e.stopPropagation(); + game.keyState.on(state); + return false; + } + return true; + }, + true + ); + + window.addEventListener( + "keyup", + function(e) { + const state = keyMap[e.code]; + if (state) { + e.preventDefault(); + e.stopPropagation(); + game.keyState.off(state); + return false; + } + return true; + }, + true + ); +}; + +Asteroids.asteroid = function(game, _gen) { + // implements IScreenObject + var position = [0, 0], + velocity = [0, 0], + direction = 0, + generation = _gen, + radius = 7, + path = [ + [1, 7], + [5, 5], + [7, 1], + [5, -3], + [7, -7], + [3, -9], + [-1, -5], + [-4, -2], + [-8, -1], + [-9, 3], + [-5, 5], + [-1, 3], + [1, 7] + ]; + + return { + getPosition: function() { + return position; + }, + setPosition: function(pos) { + position = pos; + }, + getVelocity: function() { + return velocity; + }, + setVelocity: function(vel) { + velocity = vel; + direction = Math.atan2(vel[1], vel[0]); + }, + getSpeed: function() { + return Math.sqrt(Math.pow(velocity[0], 2) + Math.pow(velocity[1], 2)); + }, + getRadius: function() { + return radius * generation; + }, + getGeneration: function() { + return generation; + }, + move: function() { + Asteroids.move(position, velocity); + }, + draw: function(ctx) { + Asteroids.drawPath(ctx, position, direction, generation, path); + // ctx.setTransform(1, 0, 0, 1, position[0], position[1]); + // ctx.beginPath(); + // ctx.arc(0, 0, radius*generation, 0, Math.PI*2, false); + // ctx.stroke(); + // ctx.closePath(); + } + }; +}; + +Asteroids.collision = function(a, b) { + // if a.getPosition() inside b.getBounds? + var a_pos = a.getPosition(), + b_pos = b.getPosition(); + + function sq(x) { + return Math.pow(x, 2); + } + + var distance = Math.sqrt(sq(a_pos[0] - b_pos[0]) + sq(a_pos[1] - b_pos[1])); + + if (distance <= a.getRadius() + b.getRadius()) return true; + return false; +}; + +Asteroids.level = function(game) { + var level = 0, + speed = ASTEROID_SPEED, + hspeed = ASTEROID_SPEED / 2; + + return { + getLevel: function() { + return level; + }, + levelUp: function(game) { + level++; + game.log.debug("Congrats! On to level " + level); + while ( + game.asteroids.generationCount(ASTEROID_GENERATIONS) < + level + ASTEROID_COUNT + ) { + var a = Asteroids.asteroid(game, ASTEROID_GENERATIONS); + a.setPosition([ + Math.random() * GAME_WIDTH, + Math.random() * GAME_HEIGHT + ]); + a.setVelocity([ + Math.random() * speed - hspeed, + Math.random() * speed - hspeed + ]); + game.asteroids.push(a); + } + } + }; +}; + +Asteroids.gameOver = function(game) { + return function() { + game.log.debug("Game over!"); + + if (game.player.getScore() > 0) { + game.highScores.addScore("Player", game.player.getScore()); + } + + game.overlays.add({ + // implements IOverlay + draw: function(ctx) { + ctx.font = "30px System, monospace"; + ctx.textAlign = "center"; + ctx.textBaseline = "middle"; + ctx.setTransform(1, 0, 0, 1, 0, 0); + ctx.fillText("GAME OVER", GAME_WIDTH / 2, GAME_HEIGHT / 2); + + var scores = game.highScores.getScores(); + ctx.font = "12px System, monospace"; + for (var i = 0; i < scores.length; i++) { + ctx.fillText( + scores[i].name + " " + scores[i].score, + GAME_WIDTH / 2, + GAME_HEIGHT / 2 + 20 + 14 * i + ); + } + } + }); + }; +}; + +Asteroids.highScores = function(game) { + var scores = []; + + if ((t = localStorage.getItem("high-scores"))) { + scores = JSON.parse(t); + } + + return { + getScores: function() { + return scores; + }, + addScore: function(_name, _score) { + scores.push({ name: _name, score: _score }); + scores.sort(function(a, b) { + return b.score - a.score; + }); + if (scores.length > 10) { + scores.length = 10; + } + game.log.debug("Saving high scores."); + var str = JSON.stringify(scores); + localStorage.setItem("high-scores", str); + } + }; +}; + +Asteroids.drawPath = function(ctx, position, direction, scale, path, color) { + if (!color) { + color = "#fff"; + } + ctx.strokeStyle = color; + ctx.setTransform( + Math.cos(direction) * scale, + Math.sin(direction) * scale, + -Math.sin(direction) * scale, + Math.cos(direction) * scale, + position[0], + position[1] + ); + + ctx.beginPath(); + ctx.moveTo(path[0][0], path[0][1]); + for (i = 1; i < path.length; i++) { + ctx.lineTo(path[i][0], path[i][1]); + } + ctx.stroke(); + ctx.closePath(); + ctx.strokeStyle = "#fff"; +}; + +Asteroids.move = function(position, velocity) { + position[0] += velocity[0]; + if (position[0] < 0) position[0] = GAME_WIDTH + position[0]; + else if (position[0] > GAME_WIDTH) position[0] -= GAME_WIDTH; + + position[1] += velocity[1]; + if (position[1] < 0) position[1] = GAME_HEIGHT + position[1]; + else if (position[1] > GAME_HEIGHT) position[1] -= GAME_HEIGHT; +}; + +Asteroids.stars = function() { + var stars = []; + for (var i = 0; i < 50; i++) { + stars.push([Math.random() * GAME_WIDTH, Math.random() * GAME_HEIGHT]); + } + + return { + draw: function(ctx) { + var ii = stars.length; + for (var i = 0; i < ii; i++) { + ctx.fillRect(stars[i][0], stars[i][1], 1, 1); + } + } + }; +}; + +Asteroids.play = function(game) { + var ctx = game.playfield.getContext("2d"); + ctx.fillStyle = "white"; + ctx.strokeStyle = "white"; + + var speed = ASTEROID_SPEED, + hspeed = ASTEROID_SPEED / 2; + + game.level.levelUp(game); + + var bullets = [], + last_fire_state = false, + last_asteroid_count = 0; + + var extra_lives = 0; + + // Add a star field. + game.overlays.add(Asteroids.stars()); + + game.pulse = setInterval(function() { + var kill_asteroids = [], + new_asteroids = [], + kill_bullets = []; + + ctx.save(); + ctx.clearRect(0, 0, GAME_WIDTH, GAME_HEIGHT); + + // Be nice and award extra lives first. + var t_extra_lives = game.player.getScore() / POINTS_TO_EXTRA_LIFE; + t_extra_lives = Math.floor(t_extra_lives); + if (t_extra_lives > extra_lives) { + game.player.extraLife(game); + } + extra_lives = t_extra_lives; + + if (game.keyState.getState(Asteroids.UP)) { + game.player.thrust(THRUST_ACCEL); + } + + if (game.keyState.getState(Asteroids.LEFT)) { + game.player.rotate(-ROTATE_SPEED); + } + + if (game.keyState.getState(Asteroids.RIGHT)) { + game.player.rotate(ROTATE_SPEED); + } + + var fire_state = game.keyState.getState(Asteroids.FIRE); + if ( + fire_state && + fire_state != last_fire_state && + bullets.length < MAX_BULLETS + ) { + var b = game.player.fire(game); + bullets.push(b); + } + last_fire_state = fire_state; + + if (!game.player.isDead()) { + game.player.move(); + game.player.draw(ctx); + } + + for (var k = 0; k < bullets.length; k++) { + if (!bullets[k]) continue; + + if (bullets[k].getAge() > MAX_BULLET_AGE) { + kill_bullets.push(k); + continue; + } + bullets[k].birthday(); + bullets[k].move(); + bullets[k].draw(ctx); + } + + for (var r = kill_bullets.length - 1; r >= 0; r--) { + bullets.splice(r, 1); + } + + var asteroids = game.asteroids.getIterator(); + for (var i = 0; i < game.asteroids.length; i++) { + var killit = false; + asteroids[i].move(); + asteroids[i].draw(ctx); + + // Destroy the asteroid + for (var j = 0; j < bullets.length; j++) { + if (!bullets[j]) continue; + if (Asteroids.collision(bullets[j], asteroids[i])) { + game.log.debug("You shot an asteroid!"); + // Destroy the bullet. + bullets.splice(j, 1); + killit = true; // JS doesn't have "continue 2;" + continue; + } + } + + // Kill the asteroid? + if (killit) { + var _gen = asteroids[i].getGeneration() - 1; + if (_gen > 0) { + // Create children ;) + for (var n = 0; n < ASTEROID_CHILDREN; n++) { + var a = Asteroids.asteroid(game, _gen); + var _pos = [ + asteroids[i].getPosition()[0], + asteroids[i].getPosition()[1] + ]; + a.setPosition(_pos); + a.setVelocity([ + Math.random() * speed - hspeed, + Math.random() * speed - hspeed + ]); + new_asteroids.push(a); + } + } + game.player.addScore(ASTEROID_SCORE); + kill_asteroids.push(i); + continue; + } + + // Kill the player? + if ( + !game.player.isDead() && + !game.player.isInvincible() && + Asteroids.collision(game.player, asteroids[i]) + ) { + game.player.die(game); + } + } + + kill_asteroids.sort(function(a, b) { + return a - b; + }); + for (var m = kill_asteroids.length - 1; m >= 0; m--) { + game.asteroids.splice(kill_asteroids[m], 1); + } + + for (var o = 0; o < new_asteroids.length; o++) { + game.asteroids.push(new_asteroids[o]); + } + + ctx.restore(); + + // Do we need to level up? + if (0 == game.asteroids.length && last_asteroid_count != 0) { + setTimeout(function() { + game.level.levelUp(game); + }, LEVEL_TIMEOUT); + } + + last_asteroid_count = game.asteroids.length; + + // Draw overlays. + game.overlays.draw(ctx); + + // Update the info pane. + game.info.setLives(game, game.player.getLives()); + game.info.setScore(game, game.player.getScore()); + game.info.setLevel(game, game.level.getLevel()); + }, FRAME_PERIOD); +}; + +// Some boring constants. +Asteroids.LOG_ALL = 0; +Asteroids.LOG_INFO = 1; +Asteroids.LOG_DEBUG = 2; +Asteroids.LOG_WARNING = 3; +Asteroids.LOG_ERROR = 4; +Asteroids.LOG_CRITICAL = 5; +Asteroids.LOG_NONE = 6; + +Asteroids.LEFT = 37; +Asteroids.UP = 38; +Asteroids.RIGHT = 39; +Asteroids.DOWN = 40; +Asteroids.FIRE = 32; + +// Load it up! +window.onload = Asteroids(document.getElementById("asteroids")); diff --git a/pandora_console/include/asteroids/index.html b/pandora_console/include/asteroids/index.html new file mode 100644 index 0000000000..3c1dfbd690 --- /dev/null +++ b/pandora_console/include/asteroids/index.html @@ -0,0 +1,14 @@ + + + + + Asteroids + + + + +
Asteroids game goes here!
+ + + + diff --git a/pandora_console/include/asteroids/style.css b/pandora_console/include/asteroids/style.css new file mode 100644 index 0000000000..ab877caa06 --- /dev/null +++ b/pandora_console/include/asteroids/style.css @@ -0,0 +1,46 @@ +/* Style for Asteroids.js + * Copyright (c) 2010 James Socol + * See LICENSE.txt for license. + */ + +body { + background-color: #000; + color: #fff; + font-family: "Calibri", "System", monospace; + font-size: 14px; +} + +div#asteroids { + margin: 50px auto; + width: 640px; + border: 1px solid #fff; + padding: 5px; +} + +div#asteroids > * { + color: #fff; +} + +div#asteroids > div { + font-family: "System", monospace; + font-size: 11px; + padding-bottom: 5px; +} + +div#asteroids > div > span { + float: right; + padding-left: 20px; +} + +div#instructions { + width: 640px; + margin: 20px auto; +} + +h1 { + font-size: 18px; +} + +h2 { + font-size: 16px; +} diff --git a/pandora_console/include/javascript/pandora_events.js b/pandora_console/include/javascript/pandora_events.js index 86b84376c5..f1453ce493 100644 --- a/pandora_console/include/javascript/pandora_events.js +++ b/pandora_console/include/javascript/pandora_events.js @@ -1739,3 +1739,48 @@ function loadModal() { } } window.onload = loadModal; + +// Load Asteroids game. +$(window).on("load", function() { + let counter = 0; + $("#button-sound_events_button") + .off("click") + .on("click", function(e) { + counter++; + if (counter == 12) { + $("#modal-asteroids") + .dialog({ + title: "Asteroids", + resizable: true, + modal: true, + width: 900, + height: 700, + open: function() { + $.ajax({ + method: "post", + url: getUrlAjax(), + data: { + page: "include/ajax/events", + playAsteroids: 1 + }, + dataType: "html", + success: function(data) { + $("#modal-asteroids").html(data); + $(".ui-widget-content").css("background", "#222"); + $(".ui-dialog-title").css("color", "#fff"); + }, + error: function(error) { + console.error(error); + } + }); + }, + close: function() { + counter = 0; + $(".ui-widget-content").css("background", "#fff"); + $(".ui-dialog-title").css("color", "rgb(51, 51, 51)"); + } + }) + .show(); + } + }); +}); diff --git a/pandora_console/include/styles/asteroids.css b/pandora_console/include/styles/asteroids.css new file mode 100644 index 0000000000..8b434b59ba --- /dev/null +++ b/pandora_console/include/styles/asteroids.css @@ -0,0 +1,65 @@ +/** + * + * Name: Default theme + * Pandora Stylesheet + * + * @category Stylesheet + * @package Pandora FMS + * @subpackage Community + * @version 1.0.0 + * @license See below + * + * ______ ___ _______ _______ ________ + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| + * + * ============================================================================ + * Copyright (c) 2005-2023 Pandora FMS + * Please see https://pandorafms.com 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. + * ============================================================================ + */ + +div#asteroids { + background-color: #000; + color: #fff; + margin: 50px auto; + width: 640px; + border: 1px solid #fff; + padding: 5px; +} + +div#asteroids > * { + color: #fff; +} + +div#asteroids > div { + font-family: "System", monospace; + font-size: 11px; + padding-bottom: 5px; +} + +div#asteroids > div > span { + float: right; + padding-left: 20px; +} + +div#instructions { + width: 640px; + margin: 20px auto; +} + +h1 { + font-size: 18px; +} + +h2 { + font-size: 16px; +} diff --git a/pandora_console/operation/menu.php b/pandora_console/operation/menu.php index 3794a30ae3..2ec659f51a 100644 --- a/pandora_console/operation/menu.php +++ b/pandora_console/operation/menu.php @@ -603,6 +603,7 @@ if ($access_console_node === true) { $sub[$javascript]['type'] = 'direct'; echo ''; + echo ''; ui_require_javascript_file('pandora_events'); From 51a152d86d50886b090d1908cf7a41cb1bbc32f6 Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Fri, 24 Nov 2023 13:25:42 +0100 Subject: [PATCH 005/109] #12202 Added setup flag for easter egg --- pandora_console/include/javascript/pandora_events.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pandora_console/include/javascript/pandora_events.js b/pandora_console/include/javascript/pandora_events.js index f1453ce493..a95ce68899 100644 --- a/pandora_console/include/javascript/pandora_events.js +++ b/pandora_console/include/javascript/pandora_events.js @@ -1747,7 +1747,8 @@ $(window).on("load", function() { .off("click") .on("click", function(e) { counter++; - if (counter == 12) { + let flagEasternEgg = $("#flagEasternEgg").val(); + if (counter == 12 && flagEasternEgg == true) { $("#modal-asteroids") .dialog({ title: "Asteroids", From 28820f4471f1812f6d8ff06d5b2c59f29bc5ef4e Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Wed, 29 Nov 2023 11:04:48 +0100 Subject: [PATCH 006/109] #12543 fixed pagination metaconsole --- pandora_console/include/functions_events.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index 2a91641315..7a106ead7f 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -1907,7 +1907,7 @@ function events_get_all( // -1 For pagination 'All'. ((int) $limit === -1) ? $end = count($data) - : $end = ((int) $offset !== 0) ? ($offset + $limit) : $limit; + : $end = $limit; $finally = array_slice($data, $offset, $end, true); $return = [ 'buffers' => $buffers, From 0d285802b17e0024f1b52cf63c43c2a59cc8e414 Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Wed, 29 Nov 2023 15:32:46 +0100 Subject: [PATCH 007/109] #12520 Fixed form --- pandora_console/include/javascript/pandora_dashboards.js | 6 +++--- pandora_console/include/styles/form.css | 2 +- pandora_console/views/dashboard/formDashboard.php | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pandora_console/include/javascript/pandora_dashboards.js b/pandora_console/include/javascript/pandora_dashboards.js index 283acf8005..c6620f18bf 100644 --- a/pandora_console/include/javascript/pandora_dashboards.js +++ b/pandora_console/include/javascript/pandora_dashboards.js @@ -43,14 +43,14 @@ function update_dashboard(data) { */ // eslint-disable-next-line no-unused-vars function showGroup() { - $("#li-group").removeClass("hidden"); + $("#li-group_form").removeClass("hidden"); var private = $("#private").prop("checked"); if (private) { $("#id_group").removeAttr("required"); - $("#li-group").hide(); + $("#li-group_form").hide(); } else { $("#id_group").attr("required", true); - $("#li-group").show(); + $("#li-group_form").show(); } } diff --git a/pandora_console/include/styles/form.css b/pandora_console/include/styles/form.css index c212d459f6..aebc10b821 100644 --- a/pandora_console/include/styles/form.css +++ b/pandora_console/include/styles/form.css @@ -255,7 +255,7 @@ ul.wizard li > textarea { } .hidden { - display: none; + display: none !important; } form.modal-dashboard ul.wizard li.hidden, diff --git a/pandora_console/views/dashboard/formDashboard.php b/pandora_console/views/dashboard/formDashboard.php index c36df6cf06..18068ae729 100644 --- a/pandora_console/views/dashboard/formDashboard.php +++ b/pandora_console/views/dashboard/formDashboard.php @@ -84,7 +84,7 @@ $inputs = [ ], ], [ - 'block_id' => 'group', + 'block_id' => 'group_form', 'direct' => 1, 'hidden' => $private, 'block_content' => [ From b6722214de2aa5cc3124d21f69ebef1e9bdfed90 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Wed, 29 Nov 2023 15:43:38 +0100 Subject: [PATCH 008/109] #12541 changes in graph analytics --- .../include/javascript/graph_analytics.js | 183 +++++++++++++++--- .../operation/reporting/graph_analytics.php | 99 ++++++++-- 2 files changed, 240 insertions(+), 42 deletions(-) diff --git a/pandora_console/include/javascript/graph_analytics.js b/pandora_console/include/javascript/graph_analytics.js index 6c14f3f8c8..742e43201e 100644 --- a/pandora_console/include/javascript/graph_analytics.js +++ b/pandora_console/include/javascript/graph_analytics.js @@ -1,3 +1,4 @@ +/* global $ */ // Droppable options. var droppableOptions = { accept: ".draggable", @@ -422,12 +423,38 @@ $("[data-button=new]").click(function(e) { }); }); +function updateSelect(element, fields, selected) { + if (typeof fields === "object") { + $(element) + .find("select option[value!=0]") + .remove(); + $(element) + .find(".select2-container .select2-selection__rendered") + .empty(); + Object.keys(fields).forEach(function(key) { + if (key === selected) { + $(element) + .find(".select2-container .select2-selection__rendered") + .append(`${fields[key]}`); + $(element) + .find("select") + .append(``); + } else { + $(element) + .find("select") + .append(``); + } + }); + } +} + // Save graps modal. $("[data-button=save]").click(function(e) { // Filter save mode selector $("#save_filter_row1").show(); $("#save_filter_row2").show(); $("#update_filter_row1").hide(); + $("#delete_filter_row2").hide(); $("#radiobtn0002").prop("checked", false); $("#radiobtn0001").prop("checked", true); $("#text-id_name").val(""); @@ -438,20 +465,43 @@ $("[data-button=save]").click(function(e) { $("#save_filter_row2").show(); $("#submit-save_filter").show(); $("#update_filter_row1").hide(); - } else { + $("#delete_filter_row2").hide(); + } else if ($(this).val() == "update") { $("#save_filter_row1").hide(); $("#save_filter_row2").hide(); $("#update_filter_row1").show(); $("#submit-save_filter").hide(); + $("#delete_filter_row2").hide(); + } else { + $("#save_filter_row1").hide(); + $("#save_filter_row2").hide(); + $("#update_filter_row1").hide(); + $("#submit-save_filter").hide(); + $("#delete_filter_row2").show(); } }); - $("#save-filter-select").dialog({ - resizable: true, - draggable: true, - modal: false, - closeOnEscape: true, - width: 350 + $.ajax({ + method: "POST", + url: "ajax.php", + dataType: "json", + data: { + page: "operation/reporting/graph_analytics", + load_list_filters: 1 + }, + success: function(data) { + if (data) { + updateSelect("#save_filter_form", data, 0); + $("#save-filter-select").dialog({ + resizable: true, + draggable: true, + modal: false, + closeOnEscape: true, + width: 350, + title: titleModalActions + }); + } + } }); }); @@ -535,14 +585,67 @@ function save_update_filter() { }); } +// Delete filter. +function delete_filter() { + confirmDialog({ + title: titleDelete, + message: messageDelete, + onAccept: function() { + $.ajax({ + method: "POST", + url: "ajax.php", + dataType: "html", + data: { + page: "operation/reporting/graph_analytics", + delete_filter: $("#delete_filter").val() + }, + success: function(data) { + if (data == "deleted") { + confirmDialog({ + title: titleDeleteConfirm, + message: messageDeleteConfirm, + hideCancelButton: true, + onAccept: function() { + $( + "button.ui-button.ui-corner-all.ui-widget.ui-button-icon-only.ui-dialog-titlebar-close" + ).click(); + } + }); + } else { + confirmDialog({ + title: titleDeleteError, + message: messageDeleteError, + hideCancelButton: true + }); + } + } + }); + } + }); +} + // Load graps modal. $("[data-button=load]").click(function(e) { - $("#load-filter-select").dialog({ - resizable: true, - draggable: true, - modal: false, - closeOnEscape: true, - width: "auto" + $.ajax({ + method: "POST", + url: "ajax.php", + dataType: "json", + data: { + page: "operation/reporting/graph_analytics", + load_list_filters: 1 + }, + success: function(data) { + if (data) { + updateSelect("#load_filter_form", data, 0); + $("#load-filter-select").dialog({ + resizable: true, + draggable: true, + modal: false, + closeOnEscape: true, + width: "auto" + }); + } + } }); }); @@ -618,12 +721,26 @@ function loadFilter(url, filterId, homeurl, id) { // Share button. $("[data-button=share]").click(function(e) { - $("#share-select").dialog({ - resizable: true, - draggable: true, - modal: false, - closeOnEscape: true, - width: "auto" + $.ajax({ + method: "POST", + url: "ajax.php", + dataType: "json", + data: { + page: "operation/reporting/graph_analytics", + load_list_filters: 1 + }, + success: function(data) { + if (data) { + updateSelect("#share_form-0-0", data, 0); + $("#share-select").dialog({ + resizable: true, + draggable: true, + modal: false, + closeOnEscape: true, + width: "auto" + }); + } + } }); }); @@ -643,13 +760,27 @@ $("#button-share-modal").click(function(e) { // Export button. $("[data-button=export]").click(function(e) { - $("#export-select").dialog({ - resizable: true, - draggable: true, - modal: false, - closeOnEscape: true, - width: "auto", - title: titleExport + $.ajax({ + method: "POST", + url: "ajax.php", + dataType: "json", + data: { + page: "operation/reporting/graph_analytics", + load_list_filters: 1 + }, + success: function(data) { + if (data) { + updateSelect("#export_form-0-0", data, 0); + $("#export-select").dialog({ + resizable: true, + draggable: true, + modal: false, + closeOnEscape: true, + width: "auto", + title: titleExport + }); + } + } }); }); diff --git a/pandora_console/operation/reporting/graph_analytics.php b/pandora_console/operation/reporting/graph_analytics.php index 8797376070..b85a0cb84d 100644 --- a/pandora_console/operation/reporting/graph_analytics.php +++ b/pandora_console/operation/reporting/graph_analytics.php @@ -45,8 +45,10 @@ if (is_ajax()) { $save_filter = get_parameter('save_filter'); $load_filter = get_parameter('load_filter'); $update_filter = get_parameter('update_filter'); + $delete_filter = get_parameter('delete_filter'); $get_new_values = get_parameter('get_new_values'); $export_filter = get_parameter('export_filter'); + $load_list_filters = get_parameter('load_list_filters'); if (empty($search_left) === false) { $output = []; @@ -289,6 +291,11 @@ if (is_ajax()) { return; } + if (empty($delete_filter) === false) { + $result = db_process_sql_delete('tgraph_analytics_filter', ['id' => $delete_filter]); + echo ((bool) $result === true) ? 'deleted' : ''; + } + // Get new values. if (empty($get_new_values) === false) { $data = []; @@ -322,19 +329,19 @@ if (is_ajax()) { $graphs = json_decode(db_get_value('graph_modules', 'tgraph_analytics_filter', 'id', $filter)); $interval = db_get_value('tgraph_analytics_filter.interval', 'tgraph_analytics_filter', 'id', $filter); - foreach ($graphs as $graph) { - $id_graph = db_process_sql_insert( - 'tgraph', - [ - 'id_user' => $config['id_user'], - 'id_group' => $group, - 'name' => $filter_name.' ('.__('Graph').' '.($counter + 1).')', - 'description' => __('Created from Graph analytics. Filter:').' '.$filter_name.'. '.__('Graph').' '.($counter + 1), - 'period' => $interval, - 'stacked' => 2, - ] - ); + $id_graph = db_process_sql_insert( + 'tgraph', + [ + 'id_user' => $config['id_user'], + 'id_group' => $group, + 'name' => $filter_name.' ('.__('Graph').') ', + 'description' => __('Created from Graph analytics. Filter:').' '.$filter_name.'. '.__('Graph'), + 'period' => $interval, + 'stacked' => 2, + ] + ); + foreach ($graphs as $graph) { if ($id_graph > 0) { $counter++; $field_order = 1; @@ -360,6 +367,11 @@ if (is_ajax()) { echo $counter; } + if (empty($load_list_filters) === false) { + $filters = graph_analytics_filter_select(); + echo json_encode($filters); + } + return; } @@ -384,7 +396,7 @@ if (check_acl($config['id_user'], 0, 'RW') === 1 || check_acl($config['id_user'] 'content' => html_print_radio_button( 'filter_mode', 'new', - __('New filter'), + __('Create'), true, true ), @@ -398,7 +410,21 @@ if (check_acl($config['id_user'], 0, 'RW') === 1 || check_acl($config['id_user'] 'content' => html_print_radio_button( 'filter_mode', 'update', - __('Update filter'), + __('Update'), + false, + true + ), + ], + true + ); + + $data[2] = html_print_div( + [ + 'style' => 'display: flex;', + 'content' => html_print_radio_button( + 'filter_mode', + 'delete', + __('Delete'), false, true ), @@ -466,7 +492,37 @@ if (check_acl($config['id_user'], 0, 'RW') === 1 || check_acl($config['id_user'] ); $table->data[] = $data; - $table->rowclass[] = ''; + $table->rowclass[] = 'display-grid'; + + $data = []; + $table->rowid[4] = 'delete_filter_row2'; + $data[0] = __('Delete filter'); + + $select_filters_delete = graph_analytics_filter_select(); + + $data[0] .= html_print_select( + $select_filters_delete, + 'delete_filter', + '', + '', + '', + 0, + true + ); + $data[1] = html_print_submit_button( + __('Delete filter'), + 'delete_filter', + false, + [ + 'class' => 'mini ', + 'icon' => 'delete', + 'style' => 'margin-left: 155px; width: 145px;', + 'onclick' => 'delete_filter();', + ], + true + ); + + $table->data[] = $data; html_print_table($table); } else { @@ -583,7 +639,7 @@ echo ''; echo '
+ '.__('Agents').'
'.ui_toggle( - '', - __('Agents'), - 'agents-toggle', - 'agents-toggle', - true, - true, - '', - 'white-box-content', - 'box-flat white_table_graph', - 'images/arrow@svg.svg', - 'images/arrow@svg.svg', - false, - false, - false, - '', - '', - null, - null, - false, - false, - 'static' + '', + __('Agents'), + 'agents-toggle', + 'agents-toggle', + true, + true, + '', + 'white-box-content', + 'box-flat white_table_graph', + 'images/arrow@svg.svg', + 'images/arrow@svg.svg', + false, + false, + false, + '', + '', + null, + null, + false, + false, + 'static' ).ui_toggle( '', __('Groups'), @@ -898,6 +903,7 @@ $left_content .= ' ).'
+ '.__('Modules').' @@ -1000,7 +1006,7 @@ const messageLoadConfirm = ""; const titleExport = ""; const titleExportConfirm = ""; -const messageExportConfirm = ""; +const messageExportConfirm = ""; const titleExportError = ""; const messageExportError = ""; From 6154ce725bbe25a4487a8182183b944c0ed357cd Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Thu, 30 Nov 2023 13:18:44 +0100 Subject: [PATCH 010/109] #12501 Fixed password field --- pandora_console/godmode/agentes/agent_manager.php | 11 +++-------- pandora_console/godmode/agentes/configure_field.php | 6 ++++++ pandora_console/include/styles/pandora.css | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php index 557b855e09..e469c3f155 100644 --- a/pandora_console/godmode/agentes/agent_manager.php +++ b/pandora_console/godmode/agentes/agent_manager.php @@ -986,17 +986,12 @@ foreach ($fields as $field) { } if ((bool) $field['is_password_type'] === true) { - $customContent = html_print_input_text_extended( + $customContent = html_print_input_password( 'customvalue_'.$field['id_field'], $custom_value, - 'customvalue_'.$field['id_field'], '', - 30, - 100, - $view_mode, - '', - '', - true, + 45, + 255, true ); } else if ($field['is_link_enabled']) { diff --git a/pandora_console/godmode/agentes/configure_field.php b/pandora_console/godmode/agentes/configure_field.php index 839040cb00..904b807bbd 100755 --- a/pandora_console/godmode/agentes/configure_field.php +++ b/pandora_console/godmode/agentes/configure_field.php @@ -275,21 +275,27 @@ $(document).ready (function () { $('#configure_field-3').show(); dialog_message("#message_no_set_password"); $('#configure_field-1').hide(); + $('#configure_field-2-0').hide(); } else{ $('#configure_field-3').hide(); $('#configure_field-1').show(); + $('#configure_field-2-0').show(); } }); $('input[type=checkbox][name=is_password_type]').change(function () { if( $('input[type=checkbox][name=is_password_type]').prop('checked')){ + $('#configure_field-1').hide(); dialog_message("#message_no_set_combo"); $('#configure_field-3').hide(); + $('#configure_field-2-1').hide(); } else{ if($('input[type=checkbox][name=is_combo_enable]').prop('checked') === true) { $('#configure_field-3').show(); } + $('#configure_field-1').show(); + $('#configure_field-2-1').show(); } }); }); diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 384048fa00..75dbb9a6ae 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -11810,7 +11810,7 @@ p.trademark-copyright { } .show-hide-pass { - position: fixed; + position: absolute; border: 0; outline: none; margin-left: -50px; From 24c8e606f48751d24ff8832d7ec16eb9bd232cbd Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Thu, 30 Nov 2023 16:29:18 +0100 Subject: [PATCH 011/109] #12569 fixed button credential boxes --- pandora_console/godmode/servers/modificar_server.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandora_console/godmode/servers/modificar_server.php b/pandora_console/godmode/servers/modificar_server.php index c51c0476d3..03863fb4f5 100644 --- a/pandora_console/godmode/servers/modificar_server.php +++ b/pandora_console/godmode/servers/modificar_server.php @@ -521,7 +521,7 @@ $(document).ready (function () { function (data) { $(".white-box-content").html(data); - $("#submit-add").click(function (e) { + $("#button-add").click(function (e) { add_credential_boxes(); }); @@ -550,7 +550,7 @@ $(document).ready (function () { $(".white-box-content").html(data2); // Insert credential - $("#submit-add").click(function (e) { + $("#button-add").click(function (e) { save_credential_boxes(); }) }, From 87f4a6e15fc66c6840afc1d1867f27df6e1158e7 Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Fri, 1 Dec 2023 10:08:25 +0100 Subject: [PATCH 012/109] #12384 Fixed acl --- .../javascript/functions_pandora_networkmap.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pandora_console/include/javascript/functions_pandora_networkmap.js b/pandora_console/include/javascript/functions_pandora_networkmap.js index c31216a2fc..44e3ba196c 100644 --- a/pandora_console/include/javascript/functions_pandora_networkmap.js +++ b/pandora_console/include/javascript/functions_pandora_networkmap.js @@ -806,6 +806,10 @@ function edit_node(data_node, dblClick) { var flag_edit_node = true; var edit_node = null; + if (networkmap_write === 0) { + return false; + } + //Only select one node var selection = d3_nm.selectAll(".node_selected"); var id; @@ -1950,6 +1954,10 @@ function init_minimap() { // Context menu //////////////////////////////////////////////////////////////////////// function show_menu(item, data) { + if (networkmap_write === 0) { + return false; + } + mouse = []; mouse[0] = d3_nm.event.pageX; mouse[1] = d3_nm.event.pageY; @@ -2819,6 +2827,10 @@ function cancel_set_parent() { // OWN CODE FOR TO DRAG //////////////////////////////////////////////////////////////////////// function init_drag_and_drop() { + if (networkmap_write === 0) { + return false; + } + window.dragables = svg.selectAll(".dragable_node"); window.drag_start = [0, 0]; From 5191739658e4dd3849d8090524a10697263f798a Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Fri, 1 Dec 2023 12:05:42 +0100 Subject: [PATCH 013/109] #12542 fixed local component module group --- pandora_console/include/javascript/pandora_modules.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pandora_console/include/javascript/pandora_modules.js b/pandora_console/include/javascript/pandora_modules.js index 4e2f73db28..a126bc36f5 100644 --- a/pandora_console/include/javascript/pandora_modules.js +++ b/pandora_console/include/javascript/pandora_modules.js @@ -159,7 +159,9 @@ function configure_modules_form() { period_select_update("module_interval", data["module_interval"]); } - $("#id_module_group").val(data["id_module_group"]); + $("#id_module_group") + .val(data["id_module_group"]) + .trigger("change"); if (data["history_data"]) $("#checkbox-history_data").check(); else $("#checkbox-history_data").uncheck(); From cc1c138552271abbcf2804f6bce13e46dc19df73 Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Mon, 4 Dec 2023 11:23:43 +0100 Subject: [PATCH 014/109] #12518 Fixed up custom field type link --- pandora_console/operation/agentes/estado_generalagente.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pandora_console/operation/agentes/estado_generalagente.php b/pandora_console/operation/agentes/estado_generalagente.php index dd4effe693..6e6615df51 100755 --- a/pandora_console/operation/agentes/estado_generalagente.php +++ b/pandora_console/operation/agentes/estado_generalagente.php @@ -298,8 +298,9 @@ foreach ($fields as $field) { if ($custom_value[0]['is_password_type']) { $data[1] = '••••••••'; } else if ($field['is_link_enabled'] === '1') { - list($link_text, $link_url) = json_decode($custom_value[0]['description'], true); - + $custom_link_type = io_safe_output($custom_value[0]['description']); + $custom_link_type = json_decode($custom_link_type); + list($link_text, $link_url) = $custom_link_type; if (json_last_error() !== JSON_ERROR_NONE) { $link_text = ''; $link_url = ''; @@ -309,7 +310,7 @@ foreach ($fields as $field) { $link_text = $link_url; } - $data[1] = ''.$link_text.''; + $data[1] = ''.$link_text.''; } else { $custom_value[0]['description'] = ui_bbcode_to_html($custom_value[0]['description']); $data[1] = $custom_value[0]['description']; From 706540f94733999a3aeb6a0feacf9189aa6000d6 Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Mon, 4 Dec 2023 15:12:33 +0100 Subject: [PATCH 015/109] #12598 Fixed event filter deleted and assigned as favorite --- pandora_console/godmode/events/event_filter.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pandora_console/godmode/events/event_filter.php b/pandora_console/godmode/events/event_filter.php index c4f1860e6f..fce8163ad0 100644 --- a/pandora_console/godmode/events/event_filter.php +++ b/pandora_console/godmode/events/event_filter.php @@ -88,7 +88,17 @@ if ($multiple_delete) { ['id_filter' => $id] ); - if ($result === false) { + if ($result !== false) { + db_process_sql_delete( + 'tfavmenu_user', + [ + 'id_element' => $id, + 'section' => 'Events', + 'id_user' => $config['id_user'], + ] + ); + $result = true; + } else { break; } } From c22525febc900abd3bc54ed291b03ebf6e735a19 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Mon, 4 Dec 2023 16:54:14 +0100 Subject: [PATCH 016/109] #12569 fixed actions credential boxes --- pandora_console/godmode/servers/modificar_server.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/godmode/servers/modificar_server.php b/pandora_console/godmode/servers/modificar_server.php index 03863fb4f5..8a78de9592 100644 --- a/pandora_console/godmode/servers/modificar_server.php +++ b/pandora_console/godmode/servers/modificar_server.php @@ -609,7 +609,7 @@ $(document).ready (function () { function (data) { $(".white-box-content").html(data); - $("#submit-update").click(function (e) { + $("#button-update").click(function (e) { update_credential_boxes(datas); }); }, From abfa08b6e0d7b6e699154f994bfd9b526f58b746 Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Thu, 7 Dec 2023 10:25:11 +0100 Subject: [PATCH 017/109] #12577 fixed visual error of the dynamic threshold ff threshold and cron from module containers --- .../agentes/module_manager_editor_common.php | 13 +++++++++---- pandora_console/include/styles/pandora.css | 8 ++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/pandora_console/godmode/agentes/module_manager_editor_common.php b/pandora_console/godmode/agentes/module_manager_editor_common.php index c396634f67..2cf295aabf 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_common.php +++ b/pandora_console/godmode/agentes/module_manager_editor_common.php @@ -1122,13 +1122,13 @@ if (isset($id_agente) === true && (int) $moduletype === MODULE_DATA) { $tableCron->data['cron_to_select'][0] = html_print_extended_select_for_cron($hour_to, $minute_to, $mday_to, $month_to, $wday_to, true, $disabledBecauseInPolicy, true); } -$table_advanced->rowclass['cron_section'] = 'table_section full_section'; +$table_advanced->rowclass['cron_section'] = 'table_section full_section mrgn_top_mod_0px'; $table_advanced->data['cron_section'] = html_print_table($tableCron, true); $table_advanced->data['title_3'] = html_print_subtitle_table(__('Thresholds and state changes')); $table_advanced->rowclass['caption_min_max_values'] = 'w50p pdd_t_10px'; -$table_advanced->rowclass['min_max_values'] = 'w50p'; +$table_advanced->rowclass['min_max_values'] = 'w50p pdd_b_10px'; $table_advanced->data['caption_min_max_values'][0] = __('Min. Value'); $table_advanced->data['caption_min_max_values'][1] = __('Max. Value'); @@ -1205,7 +1205,7 @@ $tableDynamicThreshold->data['adv_dynamic_threshold_twotailed'][0] = html_print_ $disabledBecauseInPolicy ); -$table_advanced->rowclass['dynamic_threshold_table'] = 'table_section full_section'; +$table_advanced->rowclass['dynamic_threshold_table'] = 'table_section full_section mrgn_top_mod_0px'; $table_advanced->data['dynamic_threshold_table'] = html_print_table($tableDynamicThreshold, true); $tableFFThreshold = new stdClass(); @@ -1295,10 +1295,15 @@ $tableFFThreshold->data['ff_thresholds_each'][2] = html_print_input_text( $classdisabledBecauseInPolicy ); +$table_advanced->rowclass['gap_flipflop'] = 'mrgn_top_btn_10px_imp'; +$table_advanced->data['gap_flipflop'] = html_print_input_hidden('gap_flipflop', 0); -$table_advanced->rowclass['flipflop_thresholds_table'] = 'table_section full_section'; +$table_advanced->rowclass['flipflop_thresholds_table'] = 'table_section full_section mrgn_top_mod_0px'; $table_advanced->data['flipflop_thresholds_table'] = html_print_table($tableFFThreshold, true); +$table_advanced->rowclass['gap_ff'] = 'mrgn_top_btn_10px_imp'; +$table_advanced->data['gap_ff'] = html_print_input_hidden('gap_ff', 0); + $table_advanced->rowclass['caption_ff_interval_timeout'] = 'w50p'; $table_advanced->rowclass['ff_interval_timeout'] = 'w50p'; $table_advanced->cellclass['caption_ff_interval_timeout'][0] = 'w50p'; diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index d8f7dd9416..3215aefabf 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -7056,6 +7056,10 @@ div.graph div.legend table { margin: 0 1em 0 2em; } +.mrgn_top_btn_10px_imp { + margin: 10px 0 10px 0 !important; +} + /* * MARGIN LEFT */ @@ -7217,6 +7221,10 @@ div.graph div.legend table { margin-top: 0px; } +.mrgn_top_mod_0px { + margin-top: 0px !important; +} + .mrgn_top_5px { margin-top: 5px; } From 8d4e3e78a30369be7b834a5ac8f0934e4a720eb1 Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Thu, 7 Dec 2023 16:00:42 +0100 Subject: [PATCH 018/109] #12579 fixed icons as buttons in action on satellite server agents --- .../include/class/SatelliteAgent.class.php | 40 ++++++++++++------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/pandora_console/include/class/SatelliteAgent.class.php b/pandora_console/include/class/SatelliteAgent.class.php index 29fa2e3b77..09b023958d 100644 --- a/pandora_console/include/class/SatelliteAgent.class.php +++ b/pandora_console/include/class/SatelliteAgent.class.php @@ -388,26 +388,38 @@ class SatelliteAgent extends HTML $tmp->actions = ''; if ($delete === false) { - $tmp->actions .= html_print_image( - ($disable === true) ? 'images/lightbulb_off.png' : 'images/lightbulb.png', - true, + $tmp->actions .= html_print_anchor( [ - 'border' => '0', - 'class' => 'main_menu_icon mrgn_lft_05em invert_filter', - 'onclick' => 'disable_agent(\''.$tmp->address.'\',\''.strip_tags($tmp->name).'\',\''.(int) $disable.'\',\''.$id_agente.'\')', - ] + 'href' => '#', + 'content' => html_print_image( + ($disable === true) ? 'images/lightbulb_off.png' : 'images/lightbulb.png', + true, + [ + 'border' => '0', + 'class' => 'main_menu_icon mrgn_lft_05em invert_filter', + 'onclick' => 'disable_agent(\''.$tmp->address.'\',\''.strip_tags($tmp->name).'\',\''.(int) $disable.'\',\''.$id_agente.'\')', + ] + ), + ], + true ); } if ($disable === false) { - $tmp->actions .= html_print_image( - ($delete === true) ? 'images/add.png' : 'images/delete.svg', - true, + $tmp->actions .= html_print_anchor( [ - 'border' => '0', - 'class' => 'main_menu_icon mrgn_lft_05em invert_filter', - 'onclick' => 'delete_agent(\''.$tmp->address.'\',\''.strip_tags($tmp->name).'\',\''.(int) $delete.'\',\''.$id_agente.'\')', - ] + 'href' => '#', + 'content' => html_print_image( + ($delete === true) ? 'images/add.png' : 'images/delete.svg', + true, + [ + 'border' => '0', + 'class' => 'main_menu_icon mrgn_lft_05em invert_filter', + 'onclick' => 'delete_agent(\''.$tmp->address.'\',\''.strip_tags($tmp->name).'\',\''.(int) $delete.'\',\''.$id_agente.'\')', + ] + ), + ], + true ); } From 7258188491d814791015a663c1396e7353d88417 Mon Sep 17 00:00:00 2001 From: daniel Date: Mon, 11 Dec 2023 11:01:53 +0100 Subject: [PATCH 019/109] remove agents bulk operation pandora_enterprise#12299 --- .../godmode/massive/massive_delete_agents.php | 16 ++++++++++------ pandora_console/include/functions_api.php | 10 +++++++++- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/pandora_console/godmode/massive/massive_delete_agents.php b/pandora_console/godmode/massive/massive_delete_agents.php index 1dc6397cc6..88d7e54ccb 100755 --- a/pandora_console/godmode/massive/massive_delete_agents.php +++ b/pandora_console/godmode/massive/massive_delete_agents.php @@ -46,6 +46,7 @@ require_once $config['homedir'].'/include/functions_alerts.php'; require_once $config['homedir'].'/include/functions_modules.php'; require_once $config['homedir'].'/include/functions_users.php'; require_once $config['homedir'].'/include/functions_massive_operations.php'; +enterprise_include_once('include/functions_agents.php'); /** @@ -71,12 +72,15 @@ function process_manage_delete($id_agents) $array_id = explode('|', $id_agent); try { $node = new Node((int) $array_id[0]); - $node->connect(); - - $agent = new Agent((int) $array_id[1]); - $success = $agent->delete(); - - $node->disconnect(); + $api_call_delete = $node->callApi( + 'delete_agent', + 'set', + (int) $array_id[1], + null, + ['2'], + null, + true + ); $success = agent_delete_from_metaconsole( $array_id[1], diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 8f5fb66f54..7a06156fb4 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -2266,9 +2266,12 @@ function api_set_delete_agent($id, $thrash1, $other, $returnType) } $agent_by_alias = false; + $agent_by_id = false; if ($other['data'][0] === '1') { $agent_by_alias = true; + } else if ($other['data'][0] === '2') { + $agent_by_id = true; } if (is_metaconsole()) { @@ -2331,7 +2334,12 @@ function api_set_delete_agent($id, $thrash1, $other, $returnType) } } } else { - $idAgent = agents_get_agent_id($id, false); + if ($agent_by_id === true) { + $idAgent = $id; + } else { + $idAgent = agents_get_agent_id($id, false); + } + if (!util_api_check_agent_and_print_error($idAgent, 'string', 'AD')) { return; } From 812e47603e5e08c492ed9b43c1af0150d2b07d4a Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Mon, 11 Dec 2023 18:05:58 +0100 Subject: [PATCH 020/109] some changes in audit view --- pandora_console/include/class/AuditLog.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pandora_console/include/class/AuditLog.class.php b/pandora_console/include/class/AuditLog.class.php index 261ffac531..ceb98875a1 100644 --- a/pandora_console/include/class/AuditLog.class.php +++ b/pandora_console/include/class/AuditLog.class.php @@ -123,7 +123,7 @@ class AuditLog extends HTML ], [ 'text' => 'action', - 'class' => 'w80px table_action_buttons show_extended_info', + 'class' => 'w80px show_extended_info', ] ); @@ -187,7 +187,7 @@ class AuditLog extends HTML 'no_sortable_columns' => [-1], 'order' => [ 'field' => 'date', - 'direction' => 'asc', + 'direction' => 'desc', ], 'search_button_class' => 'sub filter float-right', 'form' => [ @@ -441,7 +441,7 @@ class AuditLog extends HTML $(document).ready(function() { // Add event listener for opening and closing details - $('#audit_logs tbody').on('click', 'td.show_extended_info', function() { + $(document).on('click', '#audit_logs tbody tr:has(td.show_extended_info)', function() { var tr = $(this).closest('tr'); var table = $("#tableId; ?>").DataTable(); var row = table.row(tr); From 276cf73e49a113fbd3a80c5591c929c96f5695be Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Tue, 12 Dec 2023 10:23:47 +0100 Subject: [PATCH 021/109] #12575 fixed order columns in dashboard --- pandora_console/include/ajax/dashboard.ajax.php | 17 +++++++++++++++-- pandora_console/views/dashboard/list.php | 6 +++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/pandora_console/include/ajax/dashboard.ajax.php b/pandora_console/include/ajax/dashboard.ajax.php index 50a0e0b7a1..40497a2ebc 100644 --- a/pandora_console/include/ajax/dashboard.ajax.php +++ b/pandora_console/include/ajax/dashboard.ajax.php @@ -41,7 +41,20 @@ if ($method === 'draw') { $length = get_parameter('length', $config['block_size']); $orderBy = get_datatable_order(true); - $sort_field = $orderBy['field']; + switch ($orderBy['field']) { + case 'groups': + $sort_field = 'nombre'; + break; + + case 'favorite': + $sort_field = 'active'; + break; + + default: + $sort_field = $orderBy['field']; + break; + } + $order = $orderBy['direction']; $pagination = ''; @@ -121,7 +134,7 @@ if ($method === 'draw') { ); } - $sql = 'SELECT * FROM tdashboard '.$where.' ORDER BY id '.$pagination; + $sql = 'SELECT * FROM tdashboard LEFT JOIN tgrupo ON tgrupo.id_grupo = tdashboard.id_group '.$where.' ORDER BY '.$sort_field.' '.$order.$pagination; $dashboards = db_get_all_rows_sql($sql); $count = db_get_value_sql('SELECT COUNT(*) FROM tdashboard '.$where); foreach ($dashboards as $dashboard) { diff --git a/pandora_console/views/dashboard/list.php b/pandora_console/views/dashboard/list.php index aae6778f6d..aaf675e64a 100644 --- a/pandora_console/views/dashboard/list.php +++ b/pandora_console/views/dashboard/list.php @@ -112,7 +112,11 @@ if (empty($dashboards) === true) { 'manageDashboards' => $manageDashboards, ], 'default_pagination' => $config['block_size'], - 'no_sortable_columns' => [], + 'no_sortable_columns' => [ + 4, + 5, + 6, + ], 'order' => [ 'field' => 'name', 'direction' => 'desc', From e3fc6c13f5c143111aad2239caf94ebab69c2d6b Mon Sep 17 00:00:00 2001 From: "felix.suarez" Date: Tue, 12 Dec 2023 22:29:47 -0600 Subject: [PATCH 022/109] Change api_call to manage_api_call --- pandora_server/util/pandora_manage.pl | 56 +++++++++++++-------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index afcf8b9199..997e254737 100755 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -264,7 +264,7 @@ sub help_screen{ ######################################################################## # ######################################################################## -sub api_call($$$;$$$$) { +sub manage_api_call($$$;$$$$) { my ($pa_config, $op, $op2, $id, $id2, $other, $return_type) = @_; my $content = undef; @@ -400,7 +400,7 @@ sub pandora_disable_group ($$$) { foreach my $id_agent (@agents_bd) { # Call the API. - $result += api_call( + $result += manage_api_call( $conf, 'set', 'disabled_and_standby', $id_agent->{'id_agente'}, $server, '1|1' ); } @@ -2253,7 +2253,7 @@ sub cli_module_group_synch() { if ($return_type eq '') { $return_type = 'csv'; } - my $result = api_call(\%conf,'set', 'module_group_synch', undef, undef, "$other", $return_type); + my $result = manage_api_call(\%conf,'set', 'module_group_synch', undef, undef, "$other", $return_type); print "$result \n\n "; } @@ -2321,7 +2321,7 @@ sub cli_create_network_component() { my $other2 = join('|', @todo2); # Call the API. - my $result = api_call( $conf, 'set', 'new_network_component', $c_name, undef, "$c_type|$other|$c_group|$other2"); + my $result = manage_api_call( $conf, 'set', 'new_network_component', $c_name, undef, "$c_type|$other|$c_group|$other2"); print "$result \n\n "; } @@ -4322,7 +4322,7 @@ sub cli_get_alert_actions() { if ($return_type eq '') { $return_type = 'csv'; } - my $result = api_call(\%conf,'get', 'alert_actions', undef, undef, "$action_name|$separator",$return_type); + my $result = manage_api_call(\%conf,'get', 'alert_actions', undef, undef, "$action_name|$separator",$return_type); print "$result \n\n "; } @@ -4337,7 +4337,7 @@ sub cli_get_alert_actions_meta() { $return_type = 'csv'; } - my $result = api_call(\%conf,'get', 'alert_actions_meta', undef, undef, "$server_name|$action_name|$separator",$return_type); + my $result = manage_api_call(\%conf,'get', 'alert_actions_meta', undef, undef, "$server_name|$action_name|$separator",$return_type); print "$result \n\n "; } @@ -4557,7 +4557,7 @@ sub cli_create_event() { sub cli_update_event_custom_id() { my ($id_event, $event_custom_id) = @ARGV[2..3]; - my $result = api_call(\%conf, 'set', 'event_custom_id', $id_event, $event_custom_id); + my $result = manage_api_call(\%conf, 'set', 'event_custom_id', $id_event, $event_custom_id); print "\n$result\n"; } @@ -4849,7 +4849,7 @@ sub cli_apply_policy() { my ($id_policy, $id_agent, $name, $id_server) = @ARGV[2..5]; # Call the API. - my $result = api_call(\%conf, 'set', 'apply_policy', $id_policy, $id_agent, "$name|$id_server"); + my $result = manage_api_call(\%conf, 'set', 'apply_policy', $id_policy, $id_agent, "$name|$id_server"); print "\n$result\n"; } @@ -6022,7 +6022,7 @@ sub cli_policy_add_agent() { sub cli_policy_delete_agent() { my ($policy_id, $agent_id) = @ARGV[2..3]; - my $result = api_call(\%conf,'set', 'remove_agent_from_policy', $policy_id, $agent_id); + my $result = manage_api_call(\%conf,'set', 'remove_agent_from_policy', $policy_id, $agent_id); print "$result \n\n "; } @@ -6032,7 +6032,7 @@ sub cli_create_planned_downtime() { my @todo = @ARGV[3..21]; my $other = join('|', @todo); - my $result = api_call(\%conf,'set', 'planned_downtimes_created', $name, undef, "$other"); + my $result = manage_api_call(\%conf,'set', 'planned_downtimes_created', $name, undef, "$other"); print "$result \n\n "; } @@ -6046,7 +6046,7 @@ sub cli_add_item_planned_downtime() { my $other_modules = join(';', @modules); my $other = $other_agents . "|" . $other_modules; - my $result = api_call(\%conf,'set', 'planned_downtimes_additem', $id, undef, "$other"); + my $result = manage_api_call(\%conf,'set', 'planned_downtimes_additem', $id, undef, "$other"); print_log "$result \n\n"; } @@ -8645,7 +8645,7 @@ sub cli_create_tag() { my ($tag_name, $tag_description, $tag_url, $tag_email) = @ARGV[2..5]; # Call the API. - my $result = api_call(\%conf, 'set', 'create_tag', undef, undef, "$tag_name|$tag_description|$tag_url|$tag_email"); + my $result = manage_api_call(\%conf, 'set', 'create_tag', undef, undef, "$tag_name|$tag_description|$tag_url|$tag_email"); print "\n$result\n"; } @@ -8682,7 +8682,7 @@ sub cli_add_tag_to_user_profile() { exist_check($user_profile_id, 'given profile and group combination for user', $user_id); # Call the API. - my $result = api_call(\%conf, 'set', 'tag_user_profile', $user_id, $tag_id, "$group_id|$profile_id"); + my $result = manage_api_call(\%conf, 'set', 'tag_user_profile', $user_id, $tag_id, "$group_id|$profile_id"); print "\n$result\n"; } @@ -8706,7 +8706,7 @@ sub cli_add_tag_to_module() { exist_check($module_id, 'module name', $module_name); # Call the API. - my $result = api_call(\%conf, 'set', 'add_tag_module', $module_id, $tag_id); + my $result = manage_api_call(\%conf, 'set', 'add_tag_module', $module_id, $tag_id); print "\n$result\n"; } @@ -8725,7 +8725,7 @@ sub cli_migration_agent_queue() { } # Call the API. - my $result = api_call( $conf, 'set', 'migrate_agent', $id_agent, 0, "$source_name|$target_name|$only_db" ); + my $result = manage_api_call( $conf, 'set', 'migrate_agent', $id_agent, 0, "$source_name|$target_name|$only_db" ); print "\n$result\n"; } @@ -8740,7 +8740,7 @@ sub cli_migration_agent() { } # Call the API. - my $result = api_call( $conf, 'get', 'migrate_agent', $id_agent); + my $result = manage_api_call( $conf, 'get', 'migrate_agent', $id_agent); if( defined($result) && "$result" ne "" ){ print "\n1\n"; @@ -8849,7 +8849,7 @@ sub cli_new_cluster() { my ($cluster_name,$cluster_type,$description,$group_id) = @ARGV[2..5]; # Call the API. - my $result = api_call( $conf, 'set', 'new_cluster', undef, undef, "$cluster_name|$cluster_type|$description|$group_id"); + my $result = manage_api_call( $conf, 'set', 'new_cluster', undef, undef, "$cluster_name|$cluster_type|$description|$group_id"); if( defined($result) && "$result" ne "" ){ print "\n1\n"; @@ -8867,7 +8867,7 @@ sub cli_add_cluster_agent() { my ($other) = @ARGV[2..2]; # Call the API. - my $result = api_call( $conf, 'set', 'add_cluster_agent', undef, undef, $other); + my $result = manage_api_call( $conf, 'set', 'add_cluster_agent', undef, undef, $other); if( defined($result) && "$result" ne "" ){ print "\n1\n"; @@ -8885,7 +8885,7 @@ sub cli_add_cluster_item() { my ($other) = @ARGV[2..2]; # Call the API. - my $result = api_call( $conf, 'set', 'add_cluster_item', undef, undef, $other); + my $result = manage_api_call( $conf, 'set', 'add_cluster_item', undef, undef, $other); if( defined($result) && "$result" ne "" ){ print "\n1\n"; @@ -8903,7 +8903,7 @@ sub cli_delete_cluster() { my ($id) = @ARGV[2..2]; # Call the API. - my $result = api_call( $conf, 'set', 'delete_cluster', $id); + my $result = manage_api_call( $conf, 'set', 'delete_cluster', $id); if( defined($result) && "$result" ne "" ){ print "\n1\n"; @@ -8921,7 +8921,7 @@ sub cli_delete_cluster_agent() { my ($id_agent,$id_cluster) = @ARGV[2..3]; # Call the API. - my $result = api_call( $conf, 'set', 'delete_cluster_agent', undef, undef, "$id_agent|$id_cluster"); + my $result = manage_api_call( $conf, 'set', 'delete_cluster_agent', undef, undef, "$id_agent|$id_cluster"); if( defined($result) && "$result" ne "" ){ print "\n1\n"; @@ -8939,7 +8939,7 @@ sub cli_delete_cluster_item() { my ($id) = @ARGV[2..2]; # Call the API. - my $result = api_call( $conf, 'set', 'delete_cluster_item', $id); + my $result = manage_api_call( $conf, 'set', 'delete_cluster_item', $id); if( defined($result) && "$result" ne "" ){ print "\n1\n"; @@ -8958,7 +8958,7 @@ sub cli_get_cluster_status() { my ($id) = @ARGV[2..2]; # Call the API. - my $result = api_call( $conf, 'get', 'cluster_status', $id); + my $result = manage_api_call( $conf, 'get', 'cluster_status', $id); if( defined($result) && "$result" ne "" ){ print "\n1\n"; @@ -8979,7 +8979,7 @@ sub cli_set_disabled_and_standby() { $value = 1 unless defined($value); #Set to disabled by default # Call the API. - my $result = api_call( + my $result = manage_api_call( $conf, 'set', 'disabled_and_standby', $id, $id_node, $value ); @@ -8995,7 +8995,7 @@ sub cli_set_disabled_and_standby() { sub cli_reset_agent_counts() { my $agent_id = @ARGV[2]; - my $result = api_call(\%conf,'set', 'reset_agent_counts', $agent_id); + my $result = manage_api_call(\%conf,'set', 'reset_agent_counts', $agent_id); print "$result \n\n "; } @@ -9010,7 +9010,7 @@ sub cli_event_in_progress() { my $event_id = @ARGV[2]; # Call the API. - my $result = api_call( + my $result = manage_api_call( $conf, 'set', 'event_in_progress', $event_id ); @@ -9080,7 +9080,7 @@ sub cli_get_gis_agent(){ my $agent_id = @ARGV[2]; - my $result = api_call(\%conf,'get', 'gis_agent', $agent_id); + my $result = manage_api_call(\%conf,'get', 'gis_agent', $agent_id); print "$result \n\n "; } @@ -9096,7 +9096,7 @@ sub cli_insert_gis_data(){ my @position = @ARGV[3..5]; my $other = join('|', @position); - my $result = api_call(\%conf,'set', 'gis_agent_only_position', $agent_id, undef, "$other"); + my $result = manage_api_call(\%conf,'set', 'gis_agent_only_position', $agent_id, undef, "$other"); print "$result \n\n "; } From 7b6c14974d1bfee2a230b729f92998b1861a3147 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Wed, 13 Dec 2023 10:34:46 +0100 Subject: [PATCH 023/109] #12573 fixed number of cells in list dashboard --- pandora_console/include/lib/Dashboard/Manager.php | 9 +++++++++ pandora_console/pandoradb_data.sql | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/lib/Dashboard/Manager.php b/pandora_console/include/lib/Dashboard/Manager.php index 4430bfa253..bee64b7ba1 100644 --- a/pandora_console/include/lib/Dashboard/Manager.php +++ b/pandora_console/include/lib/Dashboard/Manager.php @@ -1056,6 +1056,7 @@ class Manager implements PublicLogin 'name' => $name, 'id_user' => $id_user, 'id_group' => $id_group, + 'cells' => 1, 'cells_slideshow' => $slideshow, 'active' => $favourite, 'date_range' => $dateRange, @@ -1367,6 +1368,7 @@ class Manager implements PublicLogin global $config; $items = \get_parameter('items', []); + $totalCells = 0; // Class Dashboard. if (empty($items) === false) { @@ -1398,8 +1400,15 @@ class Manager implements PublicLogin return false; } } + + if (is_array($items) === true) { + $totalCells = count($items); + } } + $values = ['cells' => $totalCells]; + $this->put($values); + echo json_encode($result); } diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index 70f9451932..a3f28d816a 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -2704,8 +2704,8 @@ INSERT INTO `treport_content` (`id_rc`,`id_report`,`id_gs`,`id_agent_module`,`ty (2,1,0,0,'top_n',28800,0,2,'Top CPU per agent','',0,'<p>This type of report implies loading a lot of data. Therefore it is recommended for scheduled reports, not real-time view.</p>',NULL,0,'','','','00:00:00','00:00:00',1,1,1,1,1,1,1,0,3,10,0,10,0,1,1,0,'{"show_in_same_row":0,"hide_notinit_agents":0,"priority_mode":"1","dyn_height":"250","text_agent":"Lio=","text_agent_module":"Y3B1Lio="}',0,0,'',0,0,300,0,0,NULL,NULL,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,NULL,NULL,1,0,0,NULL), (3,1,0,0,'event_report_group',21600,0,3,'General event report','This is a sample of not normal events for any agent available in the last 6 hours',0,'<p>This type of report implies loading a lot of data. Therefore it is recommended for scheduled reports, not real-time view.</p>',NULL,0,'','','','00:00:00','00:00:00',1,1,1,1,1,1,1,0,0,10,0,10,0,0,0,0,'{"show_in_same_row":0,"hide_notinit_agents":0,"priority_mode":"1","dyn_height":"250","server_multiple":"\"\"","show_summary_group":0,"filter_event_severity":"[\"20\"]","filter_event_type":"[\"all\"]","filter_event_status":"[\"-1\"]","event_graph_by_agent":"1","event_graph_by_user_validator":"1","event_graph_by_criticity":"1","event_graph_validated_vs_unvalidated":0,"event_filter_search":"","event_filter_exclude":"","custom_data_events":"1","label":""}',0,0,'',0,0,300,0,0,NULL,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,NULL,NULL,1,0,0,NULL); INSERT INTO `tdashboard` (`id`,`name`,`id_user`,`id_group`,`active`,`cells`,`cells_slideshow`) VALUES - (1,'Sample Dashboard #1','',0,0,0,0), - (2,'Sample Dashboard #2','',0,0,0,0); + (1,'Sample Dashboard #1','',0,0,7,0), + (2,'Sample Dashboard #2','',0,0,10,0); INSERT INTO `twidget_dashboard` (`id`,`position`,`options`,`order`,`id_dashboard`,`id_widget`,`prop_width`,`prop_height`) VALUES (1,'{\"x\":\"0\",\"y\":\"0\",\"width\":\"4\",\"height\":\"4\"}','{\"title\":\"Agents hive\",\"background\":\"#ffffff\",\"groups\":[\"12,8,4,9,2,10,13,11\"]}',0,1,1,0.32,0.32), (2,'{\"x\":\"4\",\"y\":\"0\",\"width\":\"3\",\"height\":\"4\"}','{\"title\":\"Clock\",\"background\":\"#ffffff\",\"clockType\":\"analogic\"}',1,1,12,0.32,0.32), From 6e246d5d2980dd83c5f300ae0ebc0892d0c449bf Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Wed, 13 Dec 2023 12:04:00 +0100 Subject: [PATCH 024/109] #12509 fixed status agents disabled --- pandora_console/include/functions_graph.php | 12 +- pandora_console/include/functions_groups.php | 3 +- .../lib/TacticalView/elements/Agents.php | 17 +- .../lib/TacticalView/elements/Groups.php | 204 +++++++++--------- 4 files changed, 124 insertions(+), 112 deletions(-) diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 58ed138259..de60bd8f7b 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -5115,7 +5115,8 @@ function graph_so_by_group($id_group, $width=300, $height=200, $recursive=true, FROM tagente a LEFT JOIN tagent_secondary_group g ON g.id_agent = a.id_agente LEFT JOIN tconfig_os os ON a.id_os = os.id_os - WHERE a.id_grupo IN (%s) OR g.id_group IN (%s) + WHERE (a.id_grupo IN (%s) OR g.id_group IN (%s)) + AND a.disabled = 0 GROUP BY os.id_os', implode(',', $id_groups), implode(',', $id_groups) @@ -5205,13 +5206,14 @@ function graph_events_agent_by_group($id_group, $width=300, $height=200, $noWate // with it and then the number of times it occured. GROUP BY statement // is required if both DISTINCT() and COUNT() are in the statement. $sql = sprintf( - 'SELECT DISTINCT(id_agente) AS id_agente, - COUNT(id_agente) AS count + 'SELECT DISTINCT(te.id_agente) AS id_agente, + COUNT(te.id_agente) AS count FROM tevento te + LEFT JOIN tagente a ON a.id_agente = te.id_agente LEFT JOIN tagent_secondary_group g ON g.id_agent = te.id_agente WHERE 1=1 AND estado = 0 - %s %s - GROUP BY id_agente + %s %s AND a.disabled = 0 + GROUP BY te.id_agente ORDER BY count DESC LIMIT 8', $tags_condition, $filter_groups diff --git a/pandora_console/include/functions_groups.php b/pandora_console/include/functions_groups.php index 78b0804c30..a09baf5d9f 100644 --- a/pandora_console/include/functions_groups.php +++ b/pandora_console/include/functions_groups.php @@ -2503,7 +2503,8 @@ function groups_get_heat_map_agents(array $id_group, float $width=0, float $heig $sql = 'SELECT * FROM tagente a LEFT JOIN tagent_secondary_group g ON g.id_agent = a.id_agente - WHERE a.id_grupo IN ('.implode(',', $id_group).') OR g.id_group IN ('.implode(',', $id_group).')'; + WHERE (a.id_grupo IN ('.implode(',', $id_group).') OR g.id_group IN ('.implode(',', $id_group).')) + AND a.disabled = 0'; $all_agents = db_get_all_rows_sql($sql); if (empty($all_agents)) { diff --git a/pandora_console/include/lib/TacticalView/elements/Agents.php b/pandora_console/include/lib/TacticalView/elements/Agents.php index a0e14313e0..d0349f26d3 100644 --- a/pandora_console/include/lib/TacticalView/elements/Agents.php +++ b/pandora_console/include/lib/TacticalView/elements/Agents.php @@ -352,6 +352,7 @@ class Agents extends Element */ public function getStatusGraph():string { + $data = []; $agents = agents_get_agents( false, [ @@ -435,13 +436,17 @@ class Agents extends Element // To avoid that if a value is too small it is not seen. $percentages = []; $total = array_sum($data); - foreach ($data as $key => $value) { - $percentage = (($value / $total) * 100); - if ($percentage < 1 && $percentage > 0) { - $percentage = 1; - } + if ($total > 0) { + foreach ($data as $key => $value) { + $percentage = (($value / $total) * 100); + if ($percentage < 1 && $percentage > 0) { + $percentage = 1; + } - $percentages[$key] = format_numeric($percentage, 0); + $percentages[$key] = format_numeric($percentage, 0); + } + } else { + $percentages = []; } $data = $percentages; diff --git a/pandora_console/include/lib/TacticalView/elements/Groups.php b/pandora_console/include/lib/TacticalView/elements/Groups.php index 4fe07b743a..a86b8465a4 100644 --- a/pandora_console/include/lib/TacticalView/elements/Groups.php +++ b/pandora_console/include/lib/TacticalView/elements/Groups.php @@ -113,116 +113,119 @@ class Groups extends Element $id_groups = implode(',', $id_groups); $modules = modules_get_modules_in_group($id_groups); - $total_groups = count($modules); - if ($total_groups === 0) { - return graph_nodata_image(['width' => '400']); - } - - // Best square. - $high = (float) max($width, $height); - $low = 0.0; - - while (abs($high - $low) > 0.000001) { - $mid = (($high + $low) / 2.0); - $midval = (floor($width / $mid) * floor($height / $mid)); - if ($midval >= $total_groups) { - $low = $mid; - } else { - $high = $mid; - } - } - - $square_length = min(($width / floor($width / $low)), ($height / floor($height / $low))); - // Print starmap. - $heatmap = sprintf( - '', - $width, - $height - ); - - $heatmap .= ''; - $row = 0; - $column = 0; - $x = 0; - $y = 0; - $cont = 1; - foreach ($modules as $key => $value) { - $module_id = $value['id_agente_modulo']; - $module_status = db_get_row( - 'tagente_estado', - 'id_agente_modulo', - $module_id, - ); - - $module_value = modules_get_last_value($module_id); - $status = ''; - $title = ''; - modules_get_status($module_id, $module_status['estado'], $module_value, $status, $title); - switch ($status) { - case STATUS_MODULE_NO_DATA: - // Not init status. - $status = 'notinit'; - break; - - case STATUS_MODULE_CRITICAL: - // Critical status. - $status = 'critical'; - break; - - case STATUS_MODULE_WARNING: - // Warning status. - $status = 'warning'; - break; - - case STATUS_MODULE_OK: - // Normal status. - $status = 'normal'; - break; - - case 3: - case -1: - default: - // Unknown status. - $status = 'unknown'; - break; + $heatmap = ''; + if (is_array($modules) === true) { + $total_groups = count($modules); + if ($total_groups === 0) { + return graph_nodata_image(['width' => '400']); } - $redirect = ''; - if (check_acl($config['id_user'], 0, 'AW')) { - $redirect = 'onclick="redirectHeatmap(\'module\', '.$module_id.', '.$value['id_agente'].')"'; + // Best square. + $high = (float) max($width, $height); + $low = 0.0; + + while (abs($high - $low) > 0.000001) { + $mid = (($high + $low) / 2.0); + $midval = (floor($width / $mid) * floor($height / $mid)); + if ($midval >= $total_groups) { + $low = $mid; + } else { + $high = $mid; + } } + $square_length = min(($width / floor($width / $low)), ($height / floor($height / $low))); + // Print starmap. $heatmap .= sprintf( - '', - 'rect_'.$cont, - $x, - $value['nombre'], - $y, - $row, - $column, - $square_length, - $square_length, - $status, - random_int(1, 10) + '', + $width, + $height ); - $y += $square_length; - $row++; - if ((int) ($y + $square_length) > (int) $height) { - $y = 0; - $x += $square_length; - $row = 0; - $column++; - } + $heatmap .= ''; + $row = 0; + $column = 0; + $x = 0; + $y = 0; + $cont = 1; + foreach ($modules as $key => $value) { + $module_id = $value['id_agente_modulo']; + $module_status = db_get_row( + 'tagente_estado', + 'id_agente_modulo', + $module_id, + ); + + $module_value = modules_get_last_value($module_id); + $status = ''; + $title = ''; + modules_get_status($module_id, $module_status['estado'], $module_value, $status, $title); + switch ($status) { + case STATUS_MODULE_NO_DATA: + // Not init status. + $status = 'notinit'; + break; + + case STATUS_MODULE_CRITICAL: + // Critical status. + $status = 'critical'; + break; + + case STATUS_MODULE_WARNING: + // Warning status. + $status = 'warning'; + break; + + case STATUS_MODULE_OK: + // Normal status. + $status = 'normal'; + break; + + case 3: + case -1: + default: + // Unknown status. + $status = 'unknown'; + break; + } + + $redirect = ''; + if (check_acl($config['id_user'], 0, 'AW')) { + $redirect = 'onclick="redirectHeatmap(\'module\', '.$module_id.', '.$value['id_agente'].')"'; + } + + $heatmap .= sprintf( + '', + 'rect_'.$cont, + $x, + $value['nombre'], + $y, + $row, + $column, + $square_length, + $square_length, + $status, + random_int(1, 10) + ); - if ((int) ($x + $square_length) > (int) $width) { - $x = 0; $y += $square_length; - $column = 0; $row++; - } + if ((int) ($y + $square_length) > (int) $height) { + $y = 0; + $x += $square_length; + $row = 0; + $column++; + } - $cont++; + if ((int) ($x + $square_length) > (int) $width) { + $x = 0; + $y += $square_length; + $column = 0; + $row++; + } + + $cont++; + } } $heatmap .= '
', $menuTypeClass); $modal_box .= ''.__('Join discord community').''; $modal_box .= '
'; - $modal_help = html_print_div( - [ - 'id' => 'modal-help-content', - 'content' => html_print_image( - 'images/help@header.svg', - true, - [ - 'title' => __('Help'), - 'class' => 'main_menu_icon bot invert_filter', - 'alt' => 'user', - ] - ).$modal_box, - ], - true, - ); + if ($config['activate_feedback'] === '1') { + $modal_help = html_print_div( + [ + 'id' => 'modal-help-content', + 'content' => html_print_image( + 'images/help@header.svg', + true, + [ + 'title' => __('Help'), + 'class' => 'main_menu_icon bot invert_filter', + 'alt' => 'user', + ] + ).$modal_box, + ], + true, + ); + } // User. From f5b4cf235968b32b2821f469fbc7c24caefcbe20 Mon Sep 17 00:00:00 2001 From: "felix.suarez" Date: Wed, 13 Dec 2023 10:45:48 -0600 Subject: [PATCH 027/109] CLI allow create events with event_custom_id --- pandora_server/lib/PandoraFMS/Core.pm | 8 +++++--- pandora_server/util/pandora_manage.pl | 13 +++++++------ 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index 84d3d51bd2..bcb492fa1e 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -4273,13 +4273,15 @@ Generate an event. =cut ########################################################################## -#sub pandora_event ($$$$$$$$$$;$$$$$$$$$$$$) { +#sub pandora_event ($$$$$$$$$$;$$$$$$$$$$$$$) { sub pandora_event { my ($pa_config, $evento, $id_grupo, $id_agente, $severity, $id_alert_am, $id_agentmodule, $event_type, $event_status, $dbh, $source, $user_name, $comment, $id_extra, $tags, $critical_instructions, $warning_instructions, $unknown_instructions, $custom_data, - $module_data, $module_status, $server_id) = @_; + $module_data, $module_status, $server_id, $event_custom_id) = @_; + + $event_custom_id //= ""; my $agent = undef; if (defined($id_agente) && $id_agente != 0) { @@ -4332,7 +4334,7 @@ sub pandora_event { my $utimestamp = time (); my $timestamp = strftime ("%Y-%m-%d %H:%M:%S", localtime ($utimestamp)); - my $event_custom_id = undef; + $id_agentmodule = 0 unless defined ($id_agentmodule); # Validate events with the same event id diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index afcf8b9199..f953baa24e 100755 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -200,7 +200,7 @@ sub help_screen{ help_screen_line('--enable_eacl', '', 'Enable enterprise ACL system'); help_screen_line('--disable_double_auth', '', 'Disable the double authentication for the specified user'); print "\nEVENTS:\n\n" unless $param ne ''; - help_screen_line('--create_event', " [ \n\t \n\t \n\t ]", 'Add event'); + help_screen_line('--create_event', " [ \n\t \n\t \n\t ]", 'Add event'); help_screen_line('--update_event_custom_id', " ", 'Update Event Custom ID'); help_screen_line('--validate_event', " \n\t []", 'Validate events'); help_screen_line('--validate_event_id', '', 'Validate event given a event id'); @@ -4439,7 +4439,7 @@ sub cli_delete_profile() { ############################################################################## sub cli_create_event() { - my ($event,$event_type,$group_name,$agent_name,$module_name,$event_status,$severity,$template_name, $user_name, $comment, $source, $id_extra, $tags, $custom_data,$force_create_agent,$c_instructions,$w_instructions,$u_instructions,$use_alias,$server_id) = @ARGV[2..21]; + my ($event,$event_type,$group_name,$agent_name,$module_name,$event_status,$severity,$template_name, $user_name, $comment, $source, $id_extra, $tags, $custom_data,$force_create_agent,$c_instructions,$w_instructions,$u_instructions,$use_alias,$server_id,$event_custom_id) = @ARGV[2..22]; $event_status = 0 unless defined($event_status); $severity = 0 unless defined($severity); @@ -4498,7 +4498,7 @@ sub cli_create_event() { print_log "[INFO] Adding event '$event' for agent '$agent_name' \n\n"; pandora_event ($conf, $event, $id_group, $id_agent, $severity, - $id_alert_agent_module, $id_agentmodule, $event_type, $event_status, $dbh, safe_input($source), $user_name, safe_input($comment), safe_input($id_extra), safe_input($tags), safe_input($c_instructions), safe_input($w_instructions), safe_input($u_instructions), $custom_data, undef, undef, $server_id); + $id_alert_agent_module, $id_agentmodule, $event_type, $event_status, $dbh, safe_input($source), $user_name, safe_input($comment), safe_input($id_extra), safe_input($tags), safe_input($c_instructions), safe_input($w_instructions), safe_input($u_instructions), $custom_data, undef, undef, $server_id, safe_input($event_custom_id)); } } else { if (! $agent_name) { @@ -4545,7 +4545,7 @@ sub cli_create_event() { print_log "[INFO] Adding event '$event' for agent '$agent_name' \n\n"; pandora_event ($conf, $event, $id_group, $id_agent, $severity, - $id_alert_agent_module, $id_agentmodule, $event_type, $event_status, $dbh, safe_input($source), $user_name, $comment, safe_input($id_extra), safe_input($tags), safe_input($c_instructions), safe_input($w_instructions), safe_input($u_instructions), $custom_data, undef, undef, $server_id); + $id_alert_agent_module, $id_agentmodule, $event_type, $event_status, $dbh, safe_input($source), $user_name, $comment, safe_input($id_extra), safe_input($tags), safe_input($c_instructions), safe_input($w_instructions), safe_input($u_instructions), $custom_data, undef, undef, $server_id, safe_input($event_custom_id)); } } @@ -7926,10 +7926,11 @@ sub pandora_manage_main ($$$) { {'name' => 'warning_instructions'}, {'name' => 'unknown_instructions'}, {'name' => 'use_alias'}, - {'name' => 'metaconsole'} + {'name' => 'metaconsole'}, + {'name' => 'event_custom_id'} ); - param_check($ltotal, 20, 17); + param_check($ltotal, 21, 18); check_values(\@fields); From ea935d3a9219305ce1d37ec61ed2c208c2cc10a9 Mon Sep 17 00:00:00 2001 From: "felix.suarez" Date: Wed, 13 Dec 2023 12:42:17 -0600 Subject: [PATCH 028/109] API allow create events with event_custom_id --- pandora_console/include/functions_api.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index bf1c1b3004..f6f522e6f1 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -13156,6 +13156,12 @@ function api_set_create_event($id, $trash1, $other, $returnType) $values['id_extra'] = ''; } + if ($other['data'][21] != '') { + $values['event_custom_id'] = $other['data'][21]; + }else{ + $values['event_custom_id'] = ''; + } + $custom_data = base64_decode($values['custom_data']); $custom_data = mysql_escape_string_sql($custom_data); @@ -13178,7 +13184,7 @@ function api_set_create_event($id, $trash1, $other, $returnType) $values['server_id'], $values['id_extra'], $ack_utimestamp, - $values['event_custom_id'] ?? null + $values['event_custom_id'] ); if ($other['data'][12] != '') { From 6e150c1bc2ab65dd2cba29aaa5f2919a206b8ad4 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Thu, 14 Dec 2023 08:59:13 +0100 Subject: [PATCH 029/109] #12560 alert update manager --- pandora_console/include/class/ConsoleSupervisor.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pandora_console/include/class/ConsoleSupervisor.php b/pandora_console/include/class/ConsoleSupervisor.php index 83208256fb..ae12f37772 100644 --- a/pandora_console/include/class/ConsoleSupervisor.php +++ b/pandora_console/include/class/ConsoleSupervisor.php @@ -928,7 +928,9 @@ class ConsoleSupervisor false ); - if ($prev !== false + if ($data['type'] === 'NOTIF.UPDATEMANAGER.REGISTRATION' && $prev !== false) { + return; + } else if ($prev !== false && (time() - $prev['timestamp']) > $max_age ) { // Clean previous notification. From 065b096f14515ebee793f85f097bcf02de63663c Mon Sep 17 00:00:00 2001 From: Jonathan Date: Thu, 14 Dec 2023 10:03:58 +0100 Subject: [PATCH 030/109] #12366 user list 5 users bug styles --- pandora_console/godmode/users/user_list.php | 65 +++++++-------------- pandora_console/include/styles/pandora.css | 11 ++++ 2 files changed, 31 insertions(+), 45 deletions(-) diff --git a/pandora_console/godmode/users/user_list.php b/pandora_console/godmode/users/user_list.php index d488b4faad..89607ced69 100644 --- a/pandora_console/godmode/users/user_list.php +++ b/pandora_console/godmode/users/user_list.php @@ -689,7 +689,7 @@ foreach ($info as $user_id => $user_info) { // User profiles. if ($user_is_admin || $user_id == $config['id_user'] || isset($group_um[0])) { $user_profiles = db_get_all_rows_sql( - 'SELECT * FROM tusuario_perfil where id_usuario LIKE "'.$user_id.'" LIMIT 5' + 'SELECT * FROM tusuario_perfil where id_usuario LIKE "'.$user_id.'"' ); } else { $user_profiles_aux = users_get_user_profile($user_id, 'LIMIT 5'); @@ -778,17 +778,24 @@ foreach ($info as $user_id => $user_info) { if ($user_profiles !== false) { $total_profile = 0; - $data[4] .= '
'; + $data[4] .= '
'; foreach ($user_profiles as $row) { + if ($total_profile > 5) { + $data[4] .= "'; + } + + if ($total_profile == 0 && count($user_profiles) > 5) { + $data[4] .= ''.html_print_image( 'images/zoom.png', true, [ @@ -804,8 +811,6 @@ foreach ($info as $user_id => $user_info) { ); } - $data[4] .= '
'; - $total_profile++; } @@ -1052,43 +1057,13 @@ if ($is_management_allowed === true) { ?> diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 53d559b1d0..65212bed73 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -985,6 +985,12 @@ select:-internal-list-box { justify-content: flex-start !important; } +.flex-column-start { + display: flex; + flex-direction: column; + align-items: flex-start; +} + .padding-2 { padding: 2em; } @@ -5530,6 +5536,11 @@ input:checked + .p-slider:before { color: #4d4d4d; } +.show-profiles { + position: absolute; + margin-left: 15%; +} + /* Tables to upload files */ #table_filemanager tr:first-child th span { font-weight: bold; From 9258de7edc976f940ce4383803f23077b51404a6 Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Thu, 14 Dec 2023 12:25:21 +0100 Subject: [PATCH 031/109] fix multiple selector --- pandora_console/godmode/modules/manage_nc_groups.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pandora_console/godmode/modules/manage_nc_groups.php b/pandora_console/godmode/modules/manage_nc_groups.php index d5540d2472..423008db82 100644 --- a/pandora_console/godmode/modules/manage_nc_groups.php +++ b/pandora_console/godmode/modules/manage_nc_groups.php @@ -63,7 +63,7 @@ if (is_metaconsole() === true) { ], [ 'link' => '', - 'label' => __('Component groups'), + 'label' => __('Component groups1221'), ], ] ); @@ -394,11 +394,11 @@ html_print_action_buttons( $('[id^=checkbox-all_delete]').change(function(){ if ($("#checkbox-all_delete").prop("checked")) { $('[id^=checkbox-delete_multiple]').parent().parent().addClass('checkselected'); - $(".check_delete").prop("checked", true); + $(".custom_checkbox_input").prop("checked", true); } else{ $('[id^=checkbox-delete_multiple]').parent().parent().removeClass('checkselected'); - $(".check_delete").prop("checked", false); + $(".custom_checkbox_input").prop("checked", false); } }); }); From 7398982912fac42ac2130ca9fae7bb9a8f4b607a Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Thu, 14 Dec 2023 12:27:00 +0100 Subject: [PATCH 032/109] fix multiple selector --- pandora_console/godmode/modules/manage_nc_groups.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/godmode/modules/manage_nc_groups.php b/pandora_console/godmode/modules/manage_nc_groups.php index 423008db82..e7ceff1f01 100644 --- a/pandora_console/godmode/modules/manage_nc_groups.php +++ b/pandora_console/godmode/modules/manage_nc_groups.php @@ -63,7 +63,7 @@ if (is_metaconsole() === true) { ], [ 'link' => '', - 'label' => __('Component groups1221'), + 'label' => __('Component groups'), ], ] ); From c6d29ea60ed57927d7ce3afbaeba80be084704a9 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Thu, 14 Dec 2023 16:59:39 +0100 Subject: [PATCH 033/109] #12435 external link users fix --- pandora_console/extras/mr/68.sql | 2 ++ pandora_console/godmode/users/configure_user.php | 4 ++-- pandora_console/godmode/users/user_management.php | 2 +- pandora_console/pandoradb.sql | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/pandora_console/extras/mr/68.sql b/pandora_console/extras/mr/68.sql index 3095941187..e988817a54 100644 --- a/pandora_console/extras/mr/68.sql +++ b/pandora_console/extras/mr/68.sql @@ -1,5 +1,7 @@ START TRANSACTION; +ALTER TABLE `tusuario` CHANGE COLUMN `metaconsole_data_section` `metaconsole_data_section` TEXT NOT NULL DEFAULT '' ; + DELETE FROM `twelcome_tip` WHERE `title` = 'Automatic agent provision system'; INSERT INTO `twelcome_tip` (`id_lang`,`id_profile`,`title`,`text`,`url`,`enable`) VALUES ('en_GB',0,'Automatic agent provision system','The agent self-provisioning system allows an agent recently entered into the system to automatically apply changes to their configuration (such as moving them from group, assigning them certain values in custom fields) and of course applying certain monitoring policies. It is one of the most powerful functionalities, aimed at managing very large system parks.','https://pandorafms.com/manual/start?id=en/documentation/02_installation/05_configuration_agents#conf',1); diff --git a/pandora_console/godmode/users/configure_user.php b/pandora_console/godmode/users/configure_user.php index 83e54f24c5..dbca522db4 100644 --- a/pandora_console/godmode/users/configure_user.php +++ b/pandora_console/godmode/users/configure_user.php @@ -427,7 +427,7 @@ if ($create_user === true) { } else if ($values['section'] === HOME_SCREEN_OTHER) { $values['data_section'] = get_parameter('data_section_other'); } else if (io_safe_output($values['section']) === HOME_SCREEN_EXTERNAL_LINK) { - $values['data_section'] = get_parameter('data_section_external'); + $values['data_section'] = get_parameter('data_section'); } // $values['section'] = $homeScreenValues[$values['section']]; @@ -727,7 +727,7 @@ if ($update_user) { } else if ($values['section'] === HOME_SCREEN_OTHER) { $values['data_section'] = get_parameter('data_section_other'); } else if (io_safe_output($values['section']) === HOME_SCREEN_EXTERNAL_LINK) { - $values['data_section'] = get_parameter('data_section_external'); + $values['data_section'] = get_parameter('data_section'); } // $values['section'] = $homeScreenValues[$values['section']]; diff --git a/pandora_console/godmode/users/user_management.php b/pandora_console/godmode/users/user_management.php index b1212c11ec..2f8aecd47e 100644 --- a/pandora_console/godmode/users/user_management.php +++ b/pandora_console/godmode/users/user_management.php @@ -118,7 +118,7 @@ $customHomeScreenAddition[HOME_SCREEN_EXTERNAL_LINK] = html_print_input_text( $user_info['data_section'], '', 60, - 255, + 999, true ); $customHomeScreenDataField = ''; diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 56e49ad467..a4df08742c 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -1292,7 +1292,7 @@ CREATE TABLE IF NOT EXISTS `tusuario` ( `section` TEXT, `data_section` TEXT, `metaconsole_section` VARCHAR(255) NOT NULL DEFAULT 'Default', - `metaconsole_data_section` VARCHAR(255) NOT NULL DEFAULT '', + `metaconsole_data_section` TEXT, `force_change_pass` TINYINT UNSIGNED NOT NULL DEFAULT 0, `last_pass_change` DATETIME, `last_failed_login` DATETIME, From a008c7486c4b543d1802d0813ba42bcbe86f90d8 Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Thu, 14 Dec 2023 17:28:34 +0100 Subject: [PATCH 034/109] #12026 Fixed widget --- .../lib/Dashboard/Widgets/inventory.php | 36 ++++++------------- 1 file changed, 10 insertions(+), 26 deletions(-) diff --git a/pandora_console/include/lib/Dashboard/Widgets/inventory.php b/pandora_console/include/lib/Dashboard/Widgets/inventory.php index a8fc01ee1c..8424d6cfbf 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/inventory.php +++ b/pandora_console/include/lib/Dashboard/Widgets/inventory.php @@ -177,6 +177,12 @@ class InventoryWidget extends Widget // Must be configured before using. $this->configurationRequired = false; + if (isset($this->values['inventoryModuleId']) + && $this->values['inventoryModuleId'] === 'basic' + && $this->values['agentId'] === 0 + ) { + $this->configurationRequired = true; + } } @@ -296,9 +302,12 @@ class InventoryWidget extends Widget ]; $fields = []; - array_unshift($fields, __('All')); + if (isset($values['inventoryModuleId']) === false) { + $values['inventoryModuleId'] = 0; + } + $inputs[] = [ 'label' => __('Module'), 'arguments' => [ @@ -316,31 +325,6 @@ class InventoryWidget extends Widget ], ]; - // Agent select. - if ($is_metaconsole === false) { - $agents = []; - $sql = 'SELECT id_agente, nombre FROM tagente'; - if ($inventory_id_group > 0) { - $sql .= ' WHERE id_grupo = '.$inventory_id_group; - } else { - $user_groups = implode(',', array_keys(users_get_groups($config['id_user']))); - - // Avoid errors if there are no groups. - if (empty($user_groups) === true) { - $user_groups = '"0"'; - } - - $sql .= ' WHERE id_grupo IN ('.$user_groups.')'; - } - - $result = db_get_all_rows_sql($sql); - if ($result) { - foreach ($result as $row) { - $agents[$row['id_agente']] = $row['nombre']; - } - } - } - // Date filter. if (is_metaconsole() === false) { $inputs[] = [ From 8df792f11b401ba84d851b73d9b8b03b4d1b3ae2 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Fri, 15 Dec 2023 10:41:21 +0100 Subject: [PATCH 035/109] #12571 custom graphs refactored --- .../reporting/graph_builder.graph_editor.php | 246 +++++++----------- .../godmode/reporting/graph_builder.php | 2 +- pandora_console/include/ajax/graph.ajax.php | 103 ++++++++ pandora_console/include/functions_html.php | 25 +- .../include/styles/custom_graph.css | 16 ++ 5 files changed, 235 insertions(+), 157 deletions(-) create mode 100644 pandora_console/include/styles/custom_graph.css diff --git a/pandora_console/godmode/reporting/graph_builder.graph_editor.php b/pandora_console/godmode/reporting/graph_builder.graph_editor.php index 0256c28f92..c4da379ebd 100644 --- a/pandora_console/godmode/reporting/graph_builder.graph_editor.php +++ b/pandora_console/godmode/reporting/graph_builder.graph_editor.php @@ -30,7 +30,7 @@ if (!$report_w && !$report_m) { require_once $config['homedir'].'/include/functions_agents.php'; require_once $config['homedir'].'/include/functions_modules.php'; require_once $config['homedir'].'/include/functions_groups.php'; - +ui_require_css_file('custom_graph'); $editGraph = (bool) get_parameter('edit_graph', 0); $action = get_parameter('action', ''); @@ -41,113 +41,6 @@ if (isset($_GET['get_agent'])) { } } -switch ($action) { - case 'sort_items': - $resultOperationDB = null; - $position_to_sort = (int) get_parameter('position_to_sort', 1); - $ids_serialize = (string) get_parameter('ids_items_to_sort', ''); - $move_to = (string) get_parameter('move_to', 'after'); - - $countItems = db_get_sql( - ' - SELECT COUNT(id_gs) - FROM tgraph_source - WHERE id_graph = '.$id_graph - ); - - if (($countItems < $position_to_sort) || ($position_to_sort < 1)) { - $resultOperationDB = false; - } else if (!empty($ids_serialize)) { - $ids = explode('|', $ids_serialize); - $items = db_get_all_rows_sql( - 'SELECT id_gs, `field_order` - FROM tgraph_source - WHERE id_graph = '.$id_graph.' - ORDER BY `field_order`' - ); - - if ($items === false) { - $items = []; - } - - - // Clean the repeated order values. - $order_temp = 1; - foreach ($items as $item) { - db_process_sql_update( - 'tgraph_source', - ['`field_order`' => $order_temp], - ['id_gs' => $item['id_rc']] - ); - - $order_temp++; - } - - $items = db_get_all_rows_sql( - 'SELECT id_gs, `field_order` - FROM tgraph_source - WHERE id_graph = '.$id_graph.' - ORDER BY `field_order`' - ); - - if ($items === false) { - $items = []; - } - - - - $temp = []; - - $temp = []; - foreach ($items as $item) { - // Remove the contents from the block to sort. - if (array_search($item['id_gs'], $ids) === false) { - $temp[$item['field_order']] = $item['id_gs']; - } - } - - $items = $temp; - - - - $sorted_items = []; - foreach ($items as $pos => $id_unsort) { - if ($pos == $position_to_sort) { - if ($move_to == 'after') { - $sorted_items[] = $id_unsort; - } - - foreach ($ids as $id) { - $sorted_items[] = $id; - } - - if ($move_to != 'after') { - $sorted_items[] = $id_unsort; - } - } else { - $sorted_items[] = $id_unsort; - } - } - - $items = $sorted_items; - - - - foreach ($items as $order => $id) { - db_process_sql_update( - 'tgraph_source', - ['`field_order`' => ($order + 1)], - ['id_gs' => $id] - ); - } - - $resultOperationDB = true; - } else { - $resultOperationDB = false; - } - break; -} - if ($editGraph) { $graphRows = db_get_all_rows_sql( 'SELECT t1.*, @@ -257,41 +150,6 @@ $table->data[0][1] = html_print_label_input_block( ); -$SortItems = "
"; -$SortItems .= html_print_table($table, true); -$SortItems .= html_print_input_hidden('action', 'sort_items', true); -$SortItems .= html_print_div( - [ - 'class' => 'action-buttons', - 'content' => html_print_submit_button( - __('Sort'), - 'srcbutton', - false, - [ - 'class' => 'mini', - 'icon' => 'search', - 'mode' => 'secondary', - ], - true - ), - ], - true -); -$SortItems .= '
'; - -ui_toggle( - $SortItems, - ''.__('Sort items').'', - '', - '', - false, - false, - '', - 'white-box-content no_border', - 'filter-datatable-main box-flat white_table_graph max_floating_element_size' -); - - // Configuration form. echo ''; echo "
"; @@ -300,10 +158,11 @@ echo "'; echo ''; echo ''; @@ -340,6 +199,7 @@ echo ''; // Modules table. if ($count_module_array > 0) { echo "
'.html_print_input( [ - 'type' => 'select_multiple_modules_filtered', - 'uniqId' => 'modules', - 'class' => 'flex flex-row', - 'searchBar' => true, + 'type' => 'select_multiple_modules_filtered', + 'uniqId' => 'modules', + 'class' => 'flex flex-row', + 'searchBar' => false, + 'placeholderAgents' => __('Search agent name'), ] ).'
"; + echo ''; echo ' @@ -348,6 +208,8 @@ if ($count_module_array > 0) { '; + echo ''; + echo ''; $color = 0; for ($a = 0; $a < $count_module_array; $a++) { // Calculate table line color. @@ -359,7 +221,7 @@ if ($count_module_array > 0) { $color = 1; } - echo ""; + echo ""; echo "'; echo "'; @@ -410,9 +272,30 @@ if ($count_module_array > 0) { echo ''; - echo ''; @@ -420,6 +303,8 @@ if ($count_module_array > 0) { echo ''; } + echo ''; + echo '
'.__('P.').' '.__('Agent').''.__('Weight').' '.__('Delete').' '.__('Sort').'
$position_array[$a]
$position_array[$a]".$agent_array[$a].'"; echo modules_get_agentmodule_name($module_array[$a]).''; + echo ''; - echo html_print_checkbox_extended('sorted_items[]', $idgs_array[$a], false, false, '', 'class="selected_check"', true); + echo html_print_input_image( + 'up', + 'images/arrow-up-white.png', + 'up', + ($config['style'] !== 'pandora_black') ? 'filter: invert(100%)' : '', + true, + [ + 'class' => 'invert_filter main_menu_icon', + 'onclick' => 'reorder(\'up\', \''.$idgs_array[$a].'\', this)', + ], + ); + echo html_print_input_image( + 'down', + 'images/arrow-down-white.png', + 'down', + ($config['style'] !== 'pandora_black') ? 'filter: invert(100%)' : '', + true, + [ + 'class' => 'invert_filter main_menu_icon', + 'onclick' => 'reorder(\'down\', \''.$idgs_array[$a].'\', this)', + ] + ); echo '
'; } @@ -482,4 +367,65 @@ function added_ids_sorted_items_to_hidden_input() { return true; } } + + +function reorder(action, idElement, element) { + var tr = $(element).parent().parent(); + switch (action) { + case "up": + changePosition(action, idElement) + .then((data) => { + if(data.success) { + $(tr).find('.position').html(parseInt($(tr).find('.position').html()) - 1); + $($(tr).prev()).find('.position').html(parseInt($($(tr).prev()).find('.position').html()) + 1); + $(tr).prev().insertAfter(tr); + } + }) + .catch((err) => { + console.log(err); + }) + break; + + case "down": + changePosition(action, idElement) + .then((data) => { + if(data.success) { + $(tr).find('.position').html(parseInt($(tr).find('.position').html()) + 1); + $($(tr).next()).find('.position').html(parseInt(($(tr).next()).find('.position').html()) - 1); + $(tr).next().insertBefore(tr); + } + }) + .catch((err) => { + console.log(err); + }) + break; + + default: + break; + } +} + +function changePosition(order, idElement) { + return new Promise(function(resolve, reject) { + $.ajax({ + method: "POST", + url: "", + dataType: "json", + data: { + page: "include/ajax/graph.ajax", + sort_items: 1, + order, + id_graph: , + id: idElement + }, + success: function(data) { + resolve(data); + }, + error: function(error) { + reject(error); + } + }); + }); +} + diff --git a/pandora_console/godmode/reporting/graph_builder.php b/pandora_console/godmode/reporting/graph_builder.php index 2e7b1f782e..e6aa119e84 100644 --- a/pandora_console/godmode/reporting/graph_builder.php +++ b/pandora_console/godmode/reporting/graph_builder.php @@ -237,7 +237,7 @@ if ($add_module === true) { ); $id_agent_modules = db_get_all_rows_sql( - 'SELECT id_agente_modulo FROM tagente_modulo WHERE id_agente IN ('.implode(',', $id_agents).") AND nombre IN ('".implode("','", $id_modules)."')" + 'SELECT id_agente_modulo FROM tagente_modulo WHERE id_agente IN ('.implode(',', $id_agents).") AND id_agente_modulo IN ('".implode("','", $id_modules)."')" ); if (count($id_agent_modules) > 0 && $id_agent_modules != '') { diff --git a/pandora_console/include/ajax/graph.ajax.php b/pandora_console/include/ajax/graph.ajax.php index 6ea76f373b..2db3a72912 100644 --- a/pandora_console/include/ajax/graph.ajax.php +++ b/pandora_console/include/ajax/graph.ajax.php @@ -17,6 +17,8 @@ $save_custom_graph = (bool) get_parameter('save_custom_graph'); $print_custom_graph = (bool) get_parameter('print_custom_graph', false); $print_sparse_graph = (bool) get_parameter('print_sparse_graph'); $get_graphs = (bool) get_parameter('get_graphs_container'); +$sort_items = (bool) get_parameter('sort_items'); + $width = get_parameter('width', 0); $height = get_parameter('height', 0); @@ -337,3 +339,104 @@ if ($get_graphs) { return; } } + + +if ($sort_items === true) { + $order = (string) get_parameter('order'); + $id = (string) get_parameter('id', ''); + $idGraph = (string) get_parameter('id_graph', ''); + $total = db_get_num_rows('SELECT * FROM tgraph_source WHERE id_graph = '.$idGraph.''); + $item = db_get_row_sql( + 'SELECT id_gs, field_order + FROM tgraph_source + WHERE id_gs = '.$id.' + ORDER BY field_order' + ); + + switch ($order) { + case 'up': + if (($item['field_order'] - 1) < 1) { + echo json_encode(['success' => false]); + return; + } + + $prevItem = db_get_row_sql( + 'SELECT id_gs, field_order + FROM tgraph_source + WHERE id_graph = '.$idGraph.' + AND field_order = '.($item['field_order'] - 1).' + ORDER BY field_order' + ); + + db_process_sql_begin(); + + $resultItem = db_process_sql_update( + 'tgraph_source', + ['field_order' => ($item['field_order'] - 1)], + ['id_gs' => $item['id_gs']], + false + ); + $resultPrevItem = db_process_sql_update( + 'tgraph_source', + ['field_order' => ($prevItem['field_order'] + 1)], + ['id_gs' => $prevItem['id_gs']], + false + ); + + if ($resultItem !== false && $resultPrevItem !== false) { + db_process_sql_commit(); + echo json_encode(['success' => true]); + return; + } else { + db_process_sql_rollback(); + echo json_encode(['success' => false]); + return; + } + break; + + case 'down': + if (($item['field_order'] + 1) > $total) { + echo json_encode(['success' => false]); + return; + } + + $nextItem = db_get_row_sql( + 'SELECT id_gs, field_order + FROM tgraph_source + WHERE id_graph = '.$idGraph.' + AND field_order = '.($item['field_order'] + 1).' + ORDER BY field_order' + ); + + + db_process_sql_begin(); + + $resultItem = db_process_sql_update( + 'tgraph_source', + ['field_order' => ($item['field_order'] + 1)], + ['id_gs' => $item['id_gs']], + false + ); + $resultNextItem = db_process_sql_update( + 'tgraph_source', + ['field_order' => ($nextItem['field_order'] - 1)], + ['id_gs' => $nextItem['id_gs']], + false + ); + + if ($resultItem !== false && $resultNextItem !== false) { + db_process_sql_commit(); + echo json_encode(['success' => true]); + return; + } else { + db_process_sql_rollback(); + echo json_encode(['success' => false]); + return; + } + break; + + default: + echo json_encode(['success' => false]); + break; + } +} diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 5b37dc51d2..eada8c4d90 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -774,7 +774,8 @@ function html_print_select( $select2_multiple_enable_all=false, $form='', $order=false, - $custom_id=null + $custom_id=null, + $placeholder='', ) { $output = "\n"; @@ -1013,7 +1014,8 @@ function html_print_select( $output .= ' diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index 3da403ef80..c2e3a2f4f6 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -102,7 +102,6 @@ $alias_as_name = 0; $direccion_agente = get_parameter('direccion', ''); $direccion_agente = trim(io_safe_output($direccion_agente)); $direccion_agente = io_safe_input($direccion_agente); -$unique_ip = 0; $intervalo = SECONDS_5MINUTES; $ff_interval = 0; $quiet_module = 0; @@ -186,7 +185,6 @@ if ($create_agent) { $alias = io_safe_input(trim(preg_replace('/[\/\\\|%#&$]/', '', $alias_safe_output))); $alias_as_name = (int) get_parameter_post('alias_as_name', 0); $direccion_agente = (string) get_parameter_post('direccion', ''); - $unique_ip = (int) get_parameter_post('unique_ip', 0); // Safe_output only validate ip. $direccion_agente = trim(io_safe_output($direccion_agente)); @@ -269,12 +267,7 @@ if ($create_agent) { $nombre_agente = $alias; } - if ($unique_ip && $direccion_agente != '') { - $sql = 'SELECT direccion FROM tagente WHERE direccion = "'.$direccion_agente.'"'; - $exists_ip = db_get_row_sql($sql); - } - - if (!$exists_alias && !$exists_ip) { + if (!$exists_alias) { $id_agente = db_process_sql_insert( 'tagente', [ @@ -371,8 +364,6 @@ if ($create_agent) { $agent_creation_error = __('Could not be created'); if ($exists_alias) { $agent_creation_error = __('Could not be created, because name already exists'); - } else if ($exists_ip) { - $agent_creation_error = __('Could not be created, because IP already exists'); } } } @@ -962,7 +953,6 @@ if ($update_agent) { $alias = io_safe_input(trim(preg_replace('/[\/\\\|%#&$]/', '', $alias_safe_output))); $alias_as_name = (int) get_parameter_post('alias_as_name', 0); $direccion_agente = (string) get_parameter_post('direccion', ''); - $unique_ip = (int) get_parameter_post('unique_ip', 0); // Safe_output only validate ip. $direccion_agente = trim(io_safe_output($direccion_agente)); @@ -1097,18 +1087,11 @@ if ($update_agent) { // If there is an agent with the same name, but a different ID. } - if ($direccion_agente !== $address_list && (bool) $unique_ip === true && $direccion_agente != '') { - $sql = 'SELECT direccion FROM tagente WHERE direccion = "'.$direccion_agente.'"'; - $exists_ip = db_get_row_sql($sql); - } - $old_group = agents_get_agent_group($id_agente); if ($grupo <= 0) { ui_print_error_message(__('The group id %d is incorrect.', $grupo)); } else if ($old_group !== $grupo && group_allow_more_agents($grupo, true, 'update') === false) { ui_print_error_message(__('Agent cannot be updated due to the maximum agent limit for this group')); - } else if ($exists_ip) { - ui_print_error_message(__('Duplicate main IP address')); } else { // If different IP is specified than previous, add the IP. if ($direccion_agente != '' diff --git a/pandora_console/include/ajax/agent.php b/pandora_console/include/ajax/agent.php index 65dcd96aef..b03a9e5b40 100644 --- a/pandora_console/include/ajax/agent.php +++ b/pandora_console/include/ajax/agent.php @@ -39,6 +39,7 @@ $get_agent_filters = get_parameter('get_agent_filters', 0); $save_agent_filter = get_parameter('save_agent_filter', 0); $update_agent_filter = get_parameter('update_agent_filter', 0); $delete_agent_filter = get_parameter('delete_agent_filter', 0); +$check_unique_ip = (bool) get_parameter('check_unique_ip', 0); if (https_is_running()) { header('Content-type: application/json'); @@ -1020,4 +1021,29 @@ $(document).ready(function() { return; } +if ($check_unique_ip === true) { + $direccion_agente = (string) get_parameter_post('direccion', ''); + $ip_all = get_parameter_post('ip_all', ''); + + if (empty($direccion_agente) === true) { + echo json_encode(['success' => false, 'message' => __('Please enter an IP address.')]); + return; + } + + $sql = 'SELECT direccion FROM tagente WHERE direccion = "'.$direccion_agente.'"'; + $exists_ip = db_get_row_sql($sql); + + if ($exists_ip !== false) { + if (is_array($ip_all) === true && in_array($direccion_agente, $ip_all) === true) { + echo json_encode(['success' => true, 'message' => __('Success! but this IP is already in the list.')]); + } else { + echo json_encode(['success' => false, 'message' => __('This IP is already being used'), 'exist_ip' => true]); + } + } else { + echo json_encode(['success' => true, 'message' => __('Success! this IP is available to be used.')]); + } + + return; +} + return; diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 94d337bdbe..78425214ec 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -481,6 +481,11 @@ select:-internal-list-box { max-width: 120px; } +.w130px { + width: 130px; + max-width: 130px; +} + .w200px { width: 200px; max-width: 200px; @@ -598,6 +603,10 @@ select:-internal-list-box { min-width: 120px; } +.mw130px { + min-width: 130px; +} + .mw180px { min-width: 180px; } From 3044ef482383b40434a685b7481a4db123bfabde Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Tue, 2 Jan 2024 10:26:36 +0100 Subject: [PATCH 056/109] #12419 fixed external url and changed size field --- pandora_console/godmode/users/configure_user.php | 12 ++++-------- pandora_console/godmode/users/user_management.php | 12 +----------- 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/pandora_console/godmode/users/configure_user.php b/pandora_console/godmode/users/configure_user.php index 83e54f24c5..7da3069e5a 100644 --- a/pandora_console/godmode/users/configure_user.php +++ b/pandora_console/godmode/users/configure_user.php @@ -424,10 +424,8 @@ if ($create_user === true) { $values['data_section'] = $dashboard; } else if (io_safe_output($values['section']) === HOME_SCREEN_VISUAL_CONSOLE) { $values['data_section'] = $visual_console; - } else if ($values['section'] === HOME_SCREEN_OTHER) { - $values['data_section'] = get_parameter('data_section_other'); - } else if (io_safe_output($values['section']) === HOME_SCREEN_EXTERNAL_LINK) { - $values['data_section'] = get_parameter('data_section_external'); + } else if ($values['section'] === HOME_SCREEN_OTHER || io_safe_output($values['section']) === HOME_SCREEN_EXTERNAL_LINK) { + $values['data_section'] = get_parameter('data_section'); } // $values['section'] = $homeScreenValues[$values['section']]; @@ -724,10 +722,8 @@ if ($update_user) { $values['data_section'] = $dashboard; } else if (io_safe_output($values['section']) === HOME_SCREEN_VISUAL_CONSOLE) { $values['data_section'] = $visual_console; - } else if ($values['section'] === HOME_SCREEN_OTHER) { - $values['data_section'] = get_parameter('data_section_other'); - } else if (io_safe_output($values['section']) === HOME_SCREEN_EXTERNAL_LINK) { - $values['data_section'] = get_parameter('data_section_external'); + } else if ($values['section'] === HOME_SCREEN_OTHER || io_safe_output($values['section']) === HOME_SCREEN_EXTERNAL_LINK) { + $values['data_section'] = get_parameter('data_section'); } // $values['section'] = $homeScreenValues[$values['section']]; diff --git a/pandora_console/godmode/users/user_management.php b/pandora_console/godmode/users/user_management.php index b1212c11ec..afb5a8b1f0 100644 --- a/pandora_console/godmode/users/user_management.php +++ b/pandora_console/godmode/users/user_management.php @@ -84,8 +84,7 @@ $customHomeScreenAddition[HOME_SCREEN_DASHBOARD] = html_print_select( // Home screen. Visual consoles. $customHomeScreenAddition[HOME_SCREEN_VISUAL_CONSOLE] = html_print_select($layouts_aux, 'visual_console', $user_info['data_section'], '', '', '', true, false, true, 'w100p', false, 'width: 100%'); // Home screen. External link and Other. -$customHomeScreenAddition[HOME_SCREEN_EXTERNAL_LINK] = html_print_input_text('data_section_external', $user_info['data_section'], '', 60, 255, true); -$customHomeScreenAddition[HOME_SCREEN_OTHER] = html_print_input_text('data_section_other', $user_info['data_section'], '', 60, 255, true); +$customHomeScreenAddition[HOME_SCREEN_EXTERNAL_LINK] = html_print_input_text('data_section', $user_info['data_section'], '', 60, 400, true); $layouts = visual_map_get_user_layouts($config['id_user'], true); $layouts_aux = []; @@ -112,15 +111,6 @@ $customHomeScreenAddition[HOME_SCREEN_VISUAL_CONSOLE] = html_print_select( false, 'width: 100%' ); -// Home screen. External link and Other. -$customHomeScreenAddition[HOME_SCREEN_EXTERNAL_LINK] = html_print_input_text( - 'data_section', - $user_info['data_section'], - '', - 60, - 255, - true -); $customHomeScreenDataField = ''; foreach ($customHomeScreenAddition as $key => $customField) { $customHomeScreenDataField .= html_print_div( From 70f213811ec045593b5d8c60500233137ed19b68 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Tue, 2 Jan 2024 11:18:53 +0100 Subject: [PATCH 057/109] #12716 fixed permission in monitor detail --- .../operation/agentes/status_monitor.php | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/pandora_console/operation/agentes/status_monitor.php b/pandora_console/operation/agentes/status_monitor.php index cbce3755ad..9978e94715 100644 --- a/pandora_console/operation/agentes/status_monitor.php +++ b/pandora_console/operation/agentes/status_monitor.php @@ -1061,19 +1061,20 @@ $buttons .= html_print_button( ], true ); - -$buttons .= html_print_button( - __('Manage filter'), - 'save-filter', - false, - '', - [ - 'icon' => 'wand', - 'mode' => 'mini secondary', - 'class' => 'float-left margin-right-2 sub wand', - ], - true -); +if (check_acl($config['id_user'], 0, 'AW')) { + $buttons .= html_print_button( + __('Manage filter'), + 'save-filter', + false, + '', + [ + 'icon' => 'wand', + 'mode' => 'mini secondary', + 'class' => 'float-left margin-right-2 sub wand', + ], + true + ); +} $filters .= html_print_div( [ From cb29cdb764e35f900ed69171410ad2d1fdb7c0fb Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Wed, 3 Jan 2024 11:32:41 +0100 Subject: [PATCH 058/109] #12624 change of style in dialog --- .../include/styles/js/jquery-ui_custom.css | 25 +++++++++++-------- .../include/styles/tips_window.css | 8 +++--- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/pandora_console/include/styles/js/jquery-ui_custom.css b/pandora_console/include/styles/js/jquery-ui_custom.css index 3c9104cba6..1c68f9783e 100644 --- a/pandora_console/include/styles/js/jquery-ui_custom.css +++ b/pandora_console/include/styles/js/jquery-ui_custom.css @@ -9,16 +9,19 @@ } .ui-dialog .ui-dialog-titlebar { - background-color: transparent; + background: linear-gradient(to right, #161628, #1b6a66); border-radius: 0; margin: 0; display: inherit; text-align: left; - padding: 0.4em 33px 0.4em 12px; + padding: 1.2em 33px 1.2em 12px; height: 30px; position: relative; overflow: hidden; text-overflow: ellipsis; + color: #fff; + border-top-left-radius: 10px !important; + border-top-right-radius: 10px !important; } /*center ui dialog center*/ @@ -35,14 +38,14 @@ color: #111; } .ui-dialog .ui-dialog-title { - color: rgb(51, 51, 51); + color: #fff; white-space: nowrap; width: 100%; overflow: hidden; text-overflow: ellipsis; position: relative; - font-size: 11pt; - top: 2px; + font-size: 13pt; + /* top: 2px; */ } .ui-dialog .ui-dialog-titlebar-minimize { @@ -214,7 +217,7 @@ a.ui-state-default > span:hover { height: fit-content !important; } .ui-dialog .ui-widget-header { - margin: 3px 3px 0px 3px; + /* margin: 3px 3px 0px 3px; */ } .ui_tpicker_hour, .ui_tpicker_minute, @@ -243,10 +246,10 @@ a.ui-state-default > span:hover { border-radius: 16px; } .ui-dialog { - border-top-left-radius: 16px !important; - border-top-right-radius: 16px !important; - border-bottom-left-radius: 16px !important; - border-bottom-right-radius: 16px !important; + border-top-left-radius: 10px !important; + border-top-right-radius: 10px !important; + border-bottom-left-radius: 10px !important; + border-bottom-right-radius: 10px !important; box-shadow: 0 10px 6px 0 rgb(0 0 0 / 13%); border: 1px solid #e5e9ed; padding: 0; @@ -266,7 +269,7 @@ a.ui-state-default > span:hover { } .ui-button.ui-corner-all.ui-widget.ui-button-icon-only.ui-dialog-titlebar-close, .ui-button.ui-corner-all.ui-widget.ui-button-icon-only.ui-dialog-titlebar-close:hover { - background-color: rgb(51, 51, 51); + background-color: #fff; mask: url(../../../images/close@svg.svg) no-repeat right / contain; -webkit-mask: url(../../../images/close@svg.svg) no-repeat right / contain; } diff --git a/pandora_console/include/styles/tips_window.css b/pandora_console/include/styles/tips_window.css index 53906401a8..5c6114f92a 100644 --- a/pandora_console/include/styles/tips_window.css +++ b/pandora_console/include/styles/tips_window.css @@ -23,12 +23,14 @@ justify-content: space-between; height: fit-content !important; background-color: white; - color: #161628; - border-top-left-radius: 25px !important; - border-top-right-radius: 25px !important; + color: #fff; + border-top-left-radius: 10px !important; + border-top-right-radius: 10px !important; } .tips_header .title { font-size: 15px; + color: #fff; + padding: 1.2em 33px 1.2em 12px !important; } .description { padding: 0px 20px 20px 20px; From 22baa453870587aa349c33dff075037814a1a2bd Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Wed, 3 Jan 2024 11:39:15 +0100 Subject: [PATCH 059/109] #12537 new icons for notifications --- pandora_console/extras/mr/68.sql | 5 + .../images/notification/congrats.svg | 21 + .../images/notification/disable.svg | 18 + pandora_console/images/notification/error.svg | 21 + .../images/notification/favorite.svg | 21 + .../images/notification/headsup.svg | 21 + .../images/notification/information.svg | 17 + .../images/notification/popular.svg | 18 + .../images/notification/question.svg | 18 + .../include/class/ConsoleSupervisor.php | 412 ++++++++++-------- .../include/functions_notifications.php | 9 +- pandora_console/include/styles/pandora.css | 6 +- pandora_console/pandoradb.sql | 1 + 13 files changed, 411 insertions(+), 177 deletions(-) create mode 100644 pandora_console/extras/mr/68.sql create mode 100644 pandora_console/images/notification/congrats.svg create mode 100644 pandora_console/images/notification/disable.svg create mode 100644 pandora_console/images/notification/error.svg create mode 100644 pandora_console/images/notification/favorite.svg create mode 100644 pandora_console/images/notification/headsup.svg create mode 100644 pandora_console/images/notification/information.svg create mode 100644 pandora_console/images/notification/popular.svg create mode 100644 pandora_console/images/notification/question.svg diff --git a/pandora_console/extras/mr/68.sql b/pandora_console/extras/mr/68.sql new file mode 100644 index 0000000000..efa1dd97ec --- /dev/null +++ b/pandora_console/extras/mr/68.sql @@ -0,0 +1,5 @@ +START TRANSACTION; + +ALTER TABLE `tmensajes` ADD COLUMN `icon_notification` VARCHAR(250) NULL DEFAULT NULL AFTER `url`; + +COMMIT; \ No newline at end of file diff --git a/pandora_console/images/notification/congrats.svg b/pandora_console/images/notification/congrats.svg new file mode 100644 index 0000000000..2f744df78d --- /dev/null +++ b/pandora_console/images/notification/congrats.svg @@ -0,0 +1,21 @@ + + + Icons/Dark/40/Alert icon congrats + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pandora_console/images/notification/disable.svg b/pandora_console/images/notification/disable.svg new file mode 100644 index 0000000000..ac34ab01b3 --- /dev/null +++ b/pandora_console/images/notification/disable.svg @@ -0,0 +1,18 @@ + + + Icons/Dark/40/Alert icon disable + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pandora_console/images/notification/error.svg b/pandora_console/images/notification/error.svg new file mode 100644 index 0000000000..05b07ebfb9 --- /dev/null +++ b/pandora_console/images/notification/error.svg @@ -0,0 +1,21 @@ + + + Icons/Dark/40/Alert icon error + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pandora_console/images/notification/favorite.svg b/pandora_console/images/notification/favorite.svg new file mode 100644 index 0000000000..eff171b67f --- /dev/null +++ b/pandora_console/images/notification/favorite.svg @@ -0,0 +1,21 @@ + + + Icons/Dark/40/Alert icon favorite + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pandora_console/images/notification/headsup.svg b/pandora_console/images/notification/headsup.svg new file mode 100644 index 0000000000..57e26bc4d9 --- /dev/null +++ b/pandora_console/images/notification/headsup.svg @@ -0,0 +1,21 @@ + + + Icons/Dark/40/Alert icon heads up + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pandora_console/images/notification/information.svg b/pandora_console/images/notification/information.svg new file mode 100644 index 0000000000..11319a4bb5 --- /dev/null +++ b/pandora_console/images/notification/information.svg @@ -0,0 +1,17 @@ + + + Icons/Dark/40/Alert icon information + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pandora_console/images/notification/popular.svg b/pandora_console/images/notification/popular.svg new file mode 100644 index 0000000000..20b00a83ad --- /dev/null +++ b/pandora_console/images/notification/popular.svg @@ -0,0 +1,18 @@ + + + Icons/Dark/40/Alert icon popular + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pandora_console/images/notification/question.svg b/pandora_console/images/notification/question.svg new file mode 100644 index 0000000000..5694e5d9b2 --- /dev/null +++ b/pandora_console/images/notification/question.svg @@ -0,0 +1,18 @@ + + + Icons/Dark/40/Alert icon question + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pandora_console/include/class/ConsoleSupervisor.php b/pandora_console/include/class/ConsoleSupervisor.php index 92552242f3..b1fcd80d7f 100644 --- a/pandora_console/include/class/ConsoleSupervisor.php +++ b/pandora_console/include/class/ConsoleSupervisor.php @@ -58,6 +58,18 @@ class ConsoleSupervisor */ public const MIN_SYNC_QUEUE_LENGTH = 200; + /** + * Icons for notifications. + */ + public const ICON_CONGRATS = 'images/notification/congrats.svg'; + public const ICON_DISABLE = 'images/notification/disable.svg'; + public const ICON_ERROR = 'images/notification/error.svg'; + public const ICON_FAVORITE = 'images/notification/favorite.svg'; + public const ICON_HEADSUP = 'images/notification/headsup.svg'; + public const ICON_INFORMATION = 'images/notification/information.svg'; + public const ICON_POPULAR = 'images/notification/popular.svg'; + public const ICON_QUESTION = 'images/notification/question.svg'; + /** * Show if console supervisor is enabled or not. * @@ -666,14 +678,15 @@ class ConsoleSupervisor $this->notify( [ - 'type' => 'NOTIF.VARIABLES.PERFORMANCE.'.$variable, - 'title' => __('Incorrect config value'), - 'message' => __( + 'type' => 'NOTIF.VARIABLES.PERFORMANCE.'.$variable, + 'title' => __('Incorrect config value'), + 'message' => __( $message, $names[$variable], $limit_value ), - 'url' => $url, + 'url' => $url, + 'icon_notification' => self::ICON_HEADSUP, ] ); } @@ -710,12 +723,13 @@ class ConsoleSupervisor db_process_sql_update('tconfig', ['value' => 0], ['token' => 'agentaccess']); $this->notify( [ - 'type' => 'NOTIF.ACCESSSTASTICS.PERFORMANCE', - 'title' => __('Access statistics performance'), - 'message' => __( + 'type' => 'NOTIF.ACCESSSTASTICS.PERFORMANCE', + 'title' => __('Access statistics performance'), + 'message' => __( 'Usage of agent access statistics IS NOT RECOMMENDED on systems with more than 200 agents due performance penalty' ), - 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=perf', + 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=perf', + 'icon_notification' => self::ICON_HEADSUP, ] ); } else { @@ -960,6 +974,9 @@ class ConsoleSupervisor $notification['subject'] = io_safe_input($data['title']); $notification['subtype'] = $data['type']; $notification['url'] = io_safe_input($data['url']); + if (isset($data['icon_notification']) === true) { + $notification['icon_notification'] = $data['icon_notification']; + } $id = db_process_sql_insert('tmensajes', $notification); @@ -1053,13 +1070,14 @@ class ConsoleSupervisor // Warn user if license is going to expire in 15 days or less. $this->notify( [ - 'type' => 'NOTIF.LICENSE.EXPIRATION', - 'title' => $title, - 'message' => __( + 'type' => 'NOTIF.LICENSE.EXPIRATION', + 'title' => $title, + 'message' => __( $msg, $days_to_expiry ), - 'url' => '__url__/index.php?sec=gsetup&sec2=godmode/setup/license', + 'url' => '__url__/index.php?sec=gsetup&sec2=godmode/setup/license', + 'icon_notification' => self::ICON_HEADSUP, ] ); } else if (($days_to_expiry <= 0) && ((is_user_admin($config['id_user'])) || (check_acl($config['id_user'], 0, 'PM')))) { @@ -1074,10 +1092,11 @@ class ConsoleSupervisor // Warn user, license has expired. $this->notify( [ - 'type' => 'NOTIF.LICENSE.EXPIRATION', - 'title' => $title, - 'message' => $msg, - 'url' => '__url__/index.php?sec=gsetup&sec2=godmode/setup/license', + 'type' => 'NOTIF.LICENSE.EXPIRATION', + 'title' => $title, + 'message' => $msg, + 'url' => '__url__/index.php?sec=gsetup&sec2=godmode/setup/license', + 'icon_notification' => self::ICON_HEADSUP, ] ); return false; @@ -1148,13 +1167,14 @@ class ConsoleSupervisor if (is_writable($config['attachment_store']) !== true) { $this->notify( [ - 'type' => 'NOTIF.WRITABLE.ATTACHMENT', - 'title' => __('Attachment directory is not writable'), - 'message' => __( + 'type' => 'NOTIF.WRITABLE.ATTACHMENT', + 'title' => __('Attachment directory is not writable'), + 'message' => __( 'Directory %s is not writable. Please, configure corresponding permissions.', $config['attachment_store'] ), - 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=general', + 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=general', + 'icon_notification' => self::ICON_ERROR, ] ); return; @@ -1204,13 +1224,14 @@ class ConsoleSupervisor if (is_readable($remote_config_dir) !== true) { $this->notify( [ - 'type' => 'NOTIF.PERMISSIONS.REMOTE_CONFIG', - 'title' => __('Remote configuration directory is not readable'), - 'message' => __( + 'type' => 'NOTIF.PERMISSIONS.REMOTE_CONFIG', + 'title' => __('Remote configuration directory is not readable'), + 'message' => __( 'Remote configuration directory %s is not readable. Please, adjust configuration.', $remote_config_dir ), - 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=general', + 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=general', + 'icon_notification' => self::ICON_ERROR, ] ); return; @@ -1223,13 +1244,14 @@ class ConsoleSupervisor if (is_writable($remote_config_dir.'/conf') !== true) { $this->notify( [ - 'type' => 'NOTIF.PERMISSIONS.REMOTE_CONFIG.CONF', - 'title' => __('Remote configuration directory is not writable'), - 'message' => __( + 'type' => 'NOTIF.PERMISSIONS.REMOTE_CONFIG.CONF', + 'title' => __('Remote configuration directory is not writable'), + 'message' => __( 'Remote configuration directory %s is not writable. Please, adjust configuration.', $remote_config_dir.'/conf' ), - 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=general', + 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=general', + 'icon_notification' => self::ICON_ERROR, ] ); } else { @@ -1241,13 +1263,14 @@ class ConsoleSupervisor if (is_writable($remote_config_dir.'/collections') !== true) { $this->notify( [ - 'type' => 'NOTIF.PERMISSIONS.REMOTE_CONFIG.COLLECTIONS', - 'title' => __('Remote collections directory is not writable'), - 'message' => __( + 'type' => 'NOTIF.PERMISSIONS.REMOTE_CONFIG.COLLECTIONS', + 'title' => __('Remote collections directory is not writable'), + 'message' => __( 'Collections directory %s is not writable. Please, adjust configuration.', $remote_config_dir.'/collections' ), - 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=general', + 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=general', + 'icon_notification' => self::ICON_ERROR, ] ); } else { @@ -1259,13 +1282,14 @@ class ConsoleSupervisor if (is_writable($remote_config_dir.'/md5') !== true) { $this->notify( [ - 'type' => 'NOTIF.PERMISSIONS.REMOTE_CONFIG.MD5', - 'title' => __('Remote md5 directory is not writable'), - 'message' => __( + 'type' => 'NOTIF.PERMISSIONS.REMOTE_CONFIG.MD5', + 'title' => __('Remote md5 directory is not writable'), + 'message' => __( 'MD5 directory %s is not writable. Please, adjust configuration.', $remote_config_dir.'/md5' ), - 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=general', + 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=general', + 'icon_notification' => self::ICON_ERROR, ] ); } else { @@ -1289,14 +1313,15 @@ class ConsoleSupervisor if ($filecount > $MAX_FILES_DATA_IN) { $this->notify( [ - 'type' => 'NOTIF.FILES.DATAIN', - 'title' => __('There are too much files in spool').'.', - 'message' => __( + 'type' => 'NOTIF.FILES.DATAIN', + 'title' => __('There are too much files in spool').'.', + 'message' => __( 'There are more than %d files in %s. Consider checking DataServer performance', $MAX_FILES_DATA_IN, $remote_config_dir ), - 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=perf', + 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=perf', + 'icon_notification' => self::ICON_HEADSUP, ] ); } else { @@ -1312,14 +1337,15 @@ class ConsoleSupervisor if ($filecount > $MAX_BADXML_FILES_DATA_IN) { $this->notify( [ - 'type' => 'NOTIF.FILES.DATAIN.BADXML', - 'title' => __('There are too many BADXML files in spool'), - 'message' => __( + 'type' => 'NOTIF.FILES.DATAIN.BADXML', + 'title' => __('There are too many BADXML files in spool'), + 'message' => __( 'There are more than %d files in %s. Consider checking software agents.', $MAX_BADXML_FILES_DATA_IN, $remote_config_dir ), - 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=perf', + 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=perf', + 'icon_notification' => self::ICON_HEADSUP, ] ); } else { @@ -1400,18 +1426,19 @@ class ConsoleSupervisor $this->notify( [ - 'type' => 'NOTIF.SERVER.QUEUE.'.$key, - 'title' => __( + 'type' => 'NOTIF.SERVER.QUEUE.'.$key, + 'title' => __( '%s (%s) is lacking performance.', servers_get_server_string_name($type), $queue['name'] ), - 'message' => __( + 'message' => __( $msg, $modules_queued, $queue['queued_modules'] ), - 'url' => '__url__/index.php?sec=gservers&sec2=godmode/servers/modificar_server&refr=60', + 'url' => '__url__/index.php?sec=gservers&sec2=godmode/servers/modificar_server&refr=60', + 'icon_notification' => self::ICON_HEADSUP, ] ); } else { @@ -1469,10 +1496,11 @@ class ConsoleSupervisor $this->notify( [ - 'type' => 'NOTIF.SERVER.STATUS', - 'title' => __('No servers available.'), - 'message' => __('There are no servers registered in this console. Please, check installation guide.'), - 'url' => $url, + 'type' => 'NOTIF.SERVER.STATUS', + 'title' => __('No servers available.'), + 'message' => __('There are no servers registered in this console. Please, check installation guide.'), + 'url' => $url, + 'icon_notification' => self::ICON_ERROR, ] ); } @@ -1513,6 +1541,7 @@ class ConsoleSupervisor } } + $icon_notification = self::ICON_QUESTION; if ($server['status'] == 1) { // Fatal error. Component has die. $msg = __( @@ -1526,6 +1555,8 @@ class ConsoleSupervisor servers_get_server_string_name($server['server_type']), $server['name'] ); + + $icon_notification = self::ICON_ERROR; } else { // Non-fatal error. Controlated exit. Component is not running. $msg = __( @@ -1542,10 +1573,11 @@ class ConsoleSupervisor $this->notify( [ - 'type' => 'NOTIF.SERVER.STATUS.'.$server['id_server'], - 'title' => $msg, - 'message' => $description, - 'url' => '__url__/index.php?sec=gservers&sec2=godmode/servers/modificar_server&refr=60', + 'type' => 'NOTIF.SERVER.STATUS.'.$server['id_server'], + 'title' => $msg, + 'message' => $description, + 'url' => '__url__/index.php?sec=gservers&sec2=godmode/servers/modificar_server&refr=60', + 'icon_notification' => $icon_notification, ] ); } @@ -1585,10 +1617,11 @@ class ConsoleSupervisor $this->notify( [ - 'type' => 'NOTIF.SERVER.MASTER', - 'title' => __('No master servers found.'), - 'message' => __('At least one server must be defined to run as master. Please, check documentation.'), - 'url' => $url, + 'type' => 'NOTIF.SERVER.MASTER', + 'title' => __('No master servers found.'), + 'message' => __('At least one server must be defined to run as master. Please, check documentation.'), + 'url' => $url, + 'icon_notification' => self::ICON_INFORMATION, ] ); } else { @@ -1641,10 +1674,11 @@ class ConsoleSupervisor $this->notify( [ - 'type' => 'NOTIF.PHP.SAFE_MODE', - 'title' => __('PHP safe mode is enabled. Some features may not work properly'), - 'message' => __('To disable it, go to your PHP configuration file (php.ini) and put safe_mode = Off (Do not forget to restart apache process after changes)'), - 'url' => $url, + 'type' => 'NOTIF.PHP.SAFE_MODE', + 'title' => __('PHP safe mode is enabled. Some features may not work properly'), + 'message' => __('To disable it, go to your PHP configuration file (php.ini) and put safe_mode = Off (Do not forget to restart apache process after changes)'), + 'url' => $url, + 'icon_notification' => self::ICON_HEADSUP, ] ); } else { @@ -1659,16 +1693,17 @@ class ConsoleSupervisor $this->notify( [ - 'type' => 'NOTIF.PHP.INPUT_TIME', - 'title' => sprintf( + 'type' => 'NOTIF.PHP.INPUT_TIME', + 'title' => sprintf( __('%s value in PHP configuration is not recommended'), 'max_input_time' ), - 'message' => sprintf( + 'message' => sprintf( __('Recommended value is %s'), '-1 ('.__('Unlimited').')' ).'

'.__('Please, change it on your PHP configuration file (php.ini) or contact with administrator (Do not forget to restart Apache process after)'), - 'url' => $url, + 'url' => $url, + 'icon_notification' => self::ICON_INFORMATION, ] ); } else { @@ -1683,16 +1718,17 @@ class ConsoleSupervisor $this->notify( [ - 'type' => 'NOTIF.PHP.EXECUTION_TIME', - 'title' => sprintf( + 'type' => 'NOTIF.PHP.EXECUTION_TIME', + 'title' => sprintf( __("Not recommended '%s' value in PHP configuration"), 'max_execution_time' ), - 'message' => sprintf( + 'message' => sprintf( __('Recommended value is: %s'), '0 ('.__('Unlimited').')' ).'

'.__('Please, change it on your PHP configuration file (php.ini) or contact with administrator (Dont forget restart apache process after changes)'), - 'url' => $url, + 'url' => $url, + 'icon_notification' => self::ICON_INFORMATION, ] ); } else { @@ -1707,16 +1743,17 @@ class ConsoleSupervisor $this->notify( [ - 'type' => 'NOTIF.PHP.UPLOAD_MAX_FILESIZE', - 'title' => sprintf( + 'type' => 'NOTIF.PHP.UPLOAD_MAX_FILESIZE', + 'title' => sprintf( __("Not recommended '%s' value in PHP configuration"), 'upload_max_filesize' ), - 'message' => sprintf( + 'message' => sprintf( __('Recommended value is: %s'), sprintf(__('%s or greater'), '800M') ).'

'.__('Please, change it on your PHP configuration file (php.ini) or contact with administrator (Dont forget restart apache process after changes)'), - 'url' => $url, + 'url' => $url, + 'icon_notification' => self::ICON_INFORMATION, ] ); } else { @@ -1736,16 +1773,17 @@ class ConsoleSupervisor $this->notify( [ - 'type' => 'NOTIF.PHP.MEMORY_LIMIT', - 'title' => sprintf( + 'type' => 'NOTIF.PHP.MEMORY_LIMIT', + 'title' => sprintf( __("Not recommended '%s' value in PHP configuration"), 'memory_limit' ), - 'message' => sprintf( + 'message' => sprintf( __('Recommended value is: %s'), sprintf(__('%s or greater'), $recommended_memory) ).'

'.__('Please, change it on your PHP configuration file (php.ini) or contact with administrator'), - 'url' => $url, + 'url' => $url, + 'icon_notification' => self::ICON_INFORMATION, ] ); } else { @@ -1760,10 +1798,11 @@ class ConsoleSupervisor $this->notify( [ - 'type' => 'NOTIF.PHP.DISABLE_FUNCTIONS', - 'title' => __('Problems with disable_functions in php.ini'), - 'message' => __('The variable disable_functions contains functions system() or exec() in PHP configuration file (php.ini)').'

'.__('Please, change it on your PHP configuration file (php.ini) or contact with administrator (Dont forget restart apache process after changes)'), - 'url' => $url, + 'type' => 'NOTIF.PHP.DISABLE_FUNCTIONS', + 'title' => __('Problems with disable_functions in php.ini'), + 'message' => __('The variable disable_functions contains functions system() or exec() in PHP configuration file (php.ini)').'

'.__('Please, change it on your PHP configuration file (php.ini) or contact with administrator (Dont forget restart apache process after changes)'), + 'url' => $url, + 'icon_notification' => self::ICON_HEADSUP, ] ); } else { @@ -1777,10 +1816,11 @@ class ConsoleSupervisor // } $this->notify( [ - 'type' => 'NOTIF.PHP.CHROMIUM', - 'title' => __('chromium is not installed'), - 'message' => __('To be able to create images of the graphs for PDFs, please install the chromium extension. For that, it is necessary to follow these steps:'), - 'url' => $url, + 'type' => 'NOTIF.PHP.CHROMIUM', + 'title' => __('chromium is not installed'), + 'message' => __('To be able to create images of the graphs for PDFs, please install the chromium extension. For that, it is necessary to follow these steps:'), + 'url' => $url, + 'icon_notification' => self::ICON_HEADSUP, ] ); } else { @@ -1838,10 +1878,11 @@ class ConsoleSupervisor $url = 'https://www.php.net/supported-versions.php'; $this->notify( [ - 'type' => 'NOTIF.PHP.VERSION.SUPPORT', - 'title' => __('PHP UPDATE REQUIRED'), - 'message' => __('You should update your PHP version because it will be out of official support').'
'.__('Current PHP version: ').PHP_VERSION, - 'url' => $url, + 'type' => 'NOTIF.PHP.VERSION.SUPPORT', + 'title' => __('PHP UPDATE REQUIRED'), + 'message' => __('You should update your PHP version because it will be out of official support').'
'.__('Current PHP version: ').PHP_VERSION, + 'url' => $url, + 'icon_notification' => self::ICON_HEADSUP, ] ); } else { @@ -1864,10 +1905,11 @@ class ConsoleSupervisor $url = 'https://www.mysql.com/support/eol-notice.html'; $this->notify( [ - 'type' => 'NOTIF.MYSQL.VERSION', - 'title' => __('MYSQL UPDATE REQUIRED'), - 'message' => __('You should update your MYSQL version because it will be out of official support').'
'.__('Current MYSQL version: ').$mysql_version, - 'url' => $url, + 'type' => 'NOTIF.MYSQL.VERSION', + 'title' => __('MYSQL UPDATE REQUIRED'), + 'message' => __('You should update your MYSQL version because it will be out of official support').'
'.__('Current MYSQL version: ').$mysql_version, + 'url' => $url, + 'icon_notification' => self::ICON_HEADSUP, ] ); } else { @@ -1906,10 +1948,11 @@ class ConsoleSupervisor if ($config['history_db_connection'] === false) { $this->notify( [ - 'type' => 'NOTIF.HISTORYDB', - 'title' => __('Historical database not available'), - 'message' => __('Historical database is enabled, though not accessible with the current configuration.'), - 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=hist_db', + 'type' => 'NOTIF.HISTORYDB', + 'title' => __('Historical database not available'), + 'message' => __('Historical database is enabled, though not accessible with the current configuration.'), + 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=hist_db', + 'icon_notification' => self::ICON_QUESTION, ] ); } else { @@ -1950,13 +1993,14 @@ class ConsoleSupervisor if ($last_maintance > 172800) { $this->notify( [ - 'type' => 'NOTIF.PANDORADB', - 'title' => __('Database maintenance problem'), - 'message' => __( + 'type' => 'NOTIF.PANDORADB', + 'title' => __('Database maintenance problem'), + 'message' => __( 'Your database hasn\'t been through maintenance for 48hrs. Please, check documentation on how to perform this maintenance process on %s and enable it as soon as possible.', io_safe_output(get_product_name()) ), - 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=perf', + 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=perf', + 'icon_notification' => self::ICON_HEADSUP, ] ); } else { @@ -2011,12 +2055,13 @@ class ConsoleSupervisor if ($last_maintance > 172800) { $this->notify( [ - 'type' => 'NOTIF.PANDORADB.HISTORY', - 'title' => __( + 'type' => 'NOTIF.PANDORADB.HISTORY', + 'title' => __( 'Historical database maintenance problem.' ), - 'message' => __('Your historical database hasn\'t been through maintenance for 48hrs. Please, check documentation on how to perform this maintenance process on %s and enable it as soon as possible.', get_product_name()), - 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=perf', + 'message' => __('Your historical database hasn\'t been through maintenance for 48hrs. Please, check documentation on how to perform this maintenance process on %s and enable it as soon as possible.', get_product_name()), + 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=perf', + 'icon_notification' => self::ICON_ERROR, ] ); } else { @@ -2052,10 +2097,11 @@ class ConsoleSupervisor if ($mrh_version != $config['MR']) { $this->notify( [ - 'type' => 'NOTIF.HISTORYDB.MR', - 'title' => __('Historical database MR mismatch'), - 'message' => __('Your historical database is not using the same schema as the main DB. This could produce anomalies while storing historical data.'), - 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=hist_db', + 'type' => 'NOTIF.HISTORYDB.MR', + 'title' => __('Historical database MR mismatch'), + 'message' => __('Your historical database is not using the same schema as the main DB. This could produce anomalies while storing historical data.'), + 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=hist_db', + 'icon_notification' => self::ICON_QUESTION, ] ); } else { @@ -2093,10 +2139,11 @@ class ConsoleSupervisor if ($elasticsearch === false) { $this->notify( [ - 'type' => 'NOTIF.EXT.ELASTICSEARCH', - 'title' => __('Log collector cannot connect to OpenSearch'), - 'message' => __('OpenSearch is not available using current configuration.'), - 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=log', + 'type' => 'NOTIF.EXT.ELASTICSEARCH', + 'title' => __('Log collector cannot connect to OpenSearch'), + 'message' => __('OpenSearch is not available using current configuration.'), + 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=log', + 'icon_notification' => self::ICON_ERROR, ] ); } else { @@ -2163,10 +2210,11 @@ class ConsoleSupervisor } else { $this->notify( [ - 'type' => 'NOTIF.METACONSOLE.DB_CONNECTION', - 'title' => __('Metaconsole DB is not available.'), - 'message' => __('Cannot connect with Metaconsole DB using current configuration.'), - 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=enterprise', + 'type' => 'NOTIF.METACONSOLE.DB_CONNECTION', + 'title' => __('Metaconsole DB is not available.'), + 'message' => __('Cannot connect with Metaconsole DB using current configuration.'), + 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=enterprise', + 'icon_notification' => self::ICON_ERROR, ] ); } @@ -2382,10 +2430,11 @@ class ConsoleSupervisor if (update_manager_verify_registration() === false) { $this->notify( [ - 'type' => 'NOTIF.UPDATEMANAGER.REGISTRATION', - 'title' => __('This instance is not registered in the Warp Update section'), - 'message' => __('Click here to start the registration process'), - 'url' => '__url__/index.php?sec=messages&sec2=godmode/update_manager/update_manager&tab=online', + 'type' => 'NOTIF.UPDATEMANAGER.REGISTRATION', + 'title' => __('This instance is not registered in the Warp Update section'), + 'message' => __('Click here to start the registration process'), + 'url' => '__url__/index.php?sec=messages&sec2=godmode/update_manager/update_manager&tab=online', + 'icon_notification' => self::ICON_QUESTION, ] ); } else { @@ -2412,9 +2461,10 @@ class ConsoleSupervisor if (update_manager_verify_api() === false) { $this->notify( [ - 'type' => 'NOTIF.API.ACCESS', - 'title' => __('Cannot access the Pandora FMS API '), - 'message' => __('Please check the configuration, some components may fail due to this misconfiguration in '.$server_name.' ('.$config['public_url'].')'), + 'type' => 'NOTIF.API.ACCESS', + 'title' => __('Cannot access the Pandora FMS API '), + 'message' => __('Please check the configuration, some components may fail due to this misconfiguration in '.$server_name.' ('.$config['public_url'].')'), + 'icon_notification' => self::ICON_ERROR, ] ); } else { @@ -2445,10 +2495,11 @@ class ConsoleSupervisor if ($admin_with_default_pass > 0) { $this->notify( [ - 'type' => 'NOTIF.SECURITY.DEFAULT_PASSWORD', - 'title' => __('Default password for "Admin" user has not been changed'), - 'message' => __('Please, change the default password since it is a commonly reported vulnerability.'), - 'url' => '__url__/index.php?sec=gusuarios&sec2=godmode/users/user_list', + 'type' => 'NOTIF.SECURITY.DEFAULT_PASSWORD', + 'title' => __('Default password for "Admin" user has not been changed'), + 'message' => __('Please, change the default password since it is a commonly reported vulnerability.'), + 'url' => '__url__/index.php?sec=gusuarios&sec2=godmode/users/user_list', + 'icon_notification' => self::ICON_HEADSUP, ] ); } else { @@ -2560,10 +2611,11 @@ class ConsoleSupervisor foreach ($_SESSION['return_installation_open']['text'] as $message) { $this->notify( [ - 'type' => 'NOTIF.UPDATEMANAGER.OPENSETUP', - 'title' => __('Failed to retrieve updates, please configure utility'), - 'message' => $message, - 'url' => '__url__/index.php?sec=gsetup&sec2=godmode/setup/setup§ion=general', + 'type' => 'NOTIF.UPDATEMANAGER.OPENSETUP', + 'title' => __('Failed to retrieve updates, please configure utility'), + 'message' => $message, + 'url' => '__url__/index.php?sec=gsetup&sec2=godmode/setup/setup§ion=general', + 'icon_notification' => self::ICON_ERROR, ] ); } @@ -2577,13 +2629,14 @@ class ConsoleSupervisor if ($_SESSION['new_update'] == 'new') { $this->notify( [ - 'type' => 'NOTIF.UPDATEMANAGER.UPDATE', - 'title' => __( + 'type' => 'NOTIF.UPDATEMANAGER.UPDATE', + 'title' => __( 'New %s Console update', get_product_name() ), - 'message' => __('There is a new update available. Please go to Administration:Setup:Update Manager for more details.'), - 'url' => '__url__/index.php?sec=gsetup&sec2=godmode/update_manager/update_manager&tab=online', + 'message' => __('There is a new update available. Please go to Administration:Setup:Update Manager for more details.'), + 'url' => '__url__/index.php?sec=gsetup&sec2=godmode/update_manager/update_manager&tab=online', + 'icon_notification' => self::ICON_CONGRATS, ] ); } else { @@ -2615,13 +2668,14 @@ class ConsoleSupervisor $this->notify( [ - 'type' => 'NOTIF.UPDATEMANAGER.MINOR', - 'title' => __('Minor release/s available'), - 'message' => __( + 'type' => 'NOTIF.UPDATEMANAGER.MINOR', + 'title' => __('Minor release/s available'), + 'message' => __( 'There is one or more minor releases available. .About minor release update.', $url ), - 'url' => '__url__/index.php?sec=messages&sec2=godmode/update_manager/update_manager&tab=online', + 'url' => '__url__/index.php?sec=messages&sec2=godmode/update_manager/update_manager&tab=online', + 'icon_notification' => self::ICON_CONGRATS, ] ); } else { @@ -2678,10 +2732,11 @@ class ConsoleSupervisor $this->notify( [ - 'type' => 'NOTIF.CRON.CONFIGURED', - 'title' => __('DiscoveryConsoleTasks is not configured.'), - 'message' => __($message_conf_cron), - 'url' => $url, + 'type' => 'NOTIF.CRON.CONFIGURED', + 'title' => __('DiscoveryConsoleTasks is not configured.'), + 'message' => __($message_conf_cron), + 'url' => $url, + 'icon_notification' => self::ICON_QUESTION, ] ); } else { @@ -2780,10 +2835,11 @@ class ConsoleSupervisor $this->notify( [ - 'type' => 'NOTIF.SERVER.MISALIGNED', - 'title' => __($title_ver_misaligned), - 'message' => __($message_ver_misaligned), - 'url' => '__url__/index.php?sec=messages&sec2=godmode/update_manager/update_manager&tab=online', + 'type' => 'NOTIF.SERVER.MISALIGNED', + 'title' => __($title_ver_misaligned), + 'message' => __($message_ver_misaligned), + 'url' => '__url__/index.php?sec=messages&sec2=godmode/update_manager/update_manager&tab=online', + 'icon_notification' => self::ICON_HEADSUP, ] ); @@ -2836,10 +2892,11 @@ class ConsoleSupervisor $is_none = true; $this->notify( [ - 'type' => 'NOTIF.ALLOWOVERRIDE.MESSAGE', - 'title' => __('AllowOverride is disabled'), - 'message' => __($message), - 'url' => '__url__/index.php', + 'type' => 'NOTIF.ALLOWOVERRIDE.MESSAGE', + 'title' => __('AllowOverride is disabled'), + 'message' => __($message), + 'url' => '__url__/index.php', + 'icon_notification' => self::ICON_HEADSUP, ] ); } @@ -2882,10 +2939,11 @@ class ConsoleSupervisor if ((int) $db_master !== (int) $cluster_master) { $this->notify( [ - 'type' => 'NOTIF.HAMASTER.MESSAGE', - 'title' => __('Desynchronized operation on the node '.$node['host']), - 'message' => __($message), - 'url' => '__url__/index.php?sec=gservers&sec2=enterprise/godmode/servers/HA_cluster', + 'type' => 'NOTIF.HAMASTER.MESSAGE', + 'title' => __('Desynchronized operation on the node '.$node['host']), + 'message' => __($message), + 'url' => '__url__/index.php?sec=gservers&sec2=enterprise/godmode/servers/HA_cluster', + 'icon_notification' => self::ICON_ERROR, ] ); } else { @@ -2922,10 +2980,11 @@ class ConsoleSupervisor $this->notify( [ - 'type' => 'NOTIF.PANDORACONSOLE.LOG.OLD', - 'title' => __($title_pandoraconsole_old_log), - 'message' => __($message_pandoraconsole_old_log), - 'url' => $url, + 'type' => 'NOTIF.PANDORACONSOLE.LOG.OLD', + 'title' => __($title_pandoraconsole_old_log), + 'message' => __($message_pandoraconsole_old_log), + 'url' => $url, + 'icon_notification' => self::ICON_QUESTION, ] ); } else { @@ -3006,15 +3065,16 @@ class ConsoleSupervisor $this->notify( [ - 'type' => 'NOTIF.SYNCQUEUE.LENGTH.'.$node_id, - 'title' => __('Node %s sync queue length exceeded, ', $node->server_name()), - 'message' => __( + 'type' => 'NOTIF.SYNCQUEUE.LENGTH.'.$node_id, + 'title' => __('Node %s sync queue length exceeded, ', $node->server_name()), + 'message' => __( 'Synchronization queue lenght for node %s is %d items, this value should be 0 or lower than %d, please check the queue status.', $node->server_name(), $count, $items_min ), - 'url' => $url, + 'url' => $url, + 'icon_notification' => self::ICON_HEADSUP, ] ); } catch (\Exception $e) { @@ -3061,14 +3121,15 @@ class ConsoleSupervisor $this->notify( [ - 'type' => 'NOTIF.SYNCQUEUE.STATUS.'.$node_id, - 'title' => __('Node %s sync queue failed, ', $node->server_name()), - 'message' => __( + 'type' => 'NOTIF.SYNCQUEUE.STATUS.'.$node_id, + 'title' => __('Node %s sync queue failed, ', $node->server_name()), + 'message' => __( 'Node %s cannot process synchronization queue due %s, please check the queue status.', $node->server_name(), $item->error() ), - 'url' => $url, + 'url' => $url, + 'icon_notification' => self::ICON_ERROR, ] ); } catch (\Exception $e) { @@ -3094,13 +3155,14 @@ class ConsoleSupervisor if ($error_dependecies > 0) { $this->notify( [ - 'type' => 'NOTIF.AGENT.LIBRARY', - 'title' => __('Agent dependency error'), - 'message' => __( + 'type' => 'NOTIF.AGENT.LIBRARY', + 'title' => __('Agent dependency error'), + 'message' => __( 'There are omnishell agents with dependency errors', ), - 'url' => '__url__/index.php?sec=gextensions&sec2=enterprise/tools/omnishell', + 'url' => '__url__/index.php?sec=gextensions&sec2=enterprise/tools/omnishell', + 'icon_notification' => self::ICON_ERROR, ] ); } diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php index c65c475550..c2de6fd53a 100644 --- a/pandora_console/include/functions_notifications.php +++ b/pandora_console/include/functions_notifications.php @@ -27,6 +27,7 @@ */ require_once $config['homedir'].'/include/functions_messages.php'; +require_once __DIR__.'/class/ConsoleSupervisor.php'; define('NOTIFICATIONS_POSTPONE_FOREVER', -1); @@ -1232,6 +1233,12 @@ function notifications_print_dropdown_element($message_info) $body_preview .= __('. Read More...'); } + $icon_notification = ConsoleSupervisor::ICON_INFORMATION; + + if (isset($message_info['icon_notification']) === true && empty($message_info['icon_notification']) === false) { + $icon_notification = $message_info['icon_notification']; + } + return sprintf( " 'height: 40px;margin-left: -20px;margin-top: -40px;']), + html_print_image($icon_notification, true, ['style' => 'height: 56px; padding: 0px;']), io_safe_output($message_info['subject']), $body_preview ); diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 94d337bdbe..07bcb4587f 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -4977,7 +4977,7 @@ div#dialog_messages table th:last-child { } .notification-item > * { - padding-left: 15px; + padding-left: 7px; pointer-events: none; } @@ -5003,6 +5003,10 @@ div#dialog_messages table th:last-child { margin: 0; } +.notification-subtitle { + margin-top: 2px; +} + .notification-subtitle, .color-black-grey { color: #373737; diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 697dd2a3d9..b0bc81ffa7 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -1395,6 +1395,7 @@ CREATE TABLE IF NOT EXISTS `tmensajes` ( `subject` VARCHAR(255) NOT NULL DEFAULT '', `estado` INT UNSIGNED NOT NULL DEFAULT 0, `url` TEXT, + `icon_notification` VARCHAR(250) DEFAULT NULL, `response_mode` VARCHAR(200) DEFAULT NULL, `citicity` INT UNSIGNED DEFAULT 0, `id_source` BIGINT UNSIGNED NOT NULL, From b80bfa2799c33f2aa6af2496b4e9fe4174176d04 Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Thu, 4 Jan 2024 15:39:27 +0100 Subject: [PATCH 060/109] #12624 change of style in dialog 2 --- .../include/functions_register.php | 2 +- .../include/javascript/pandora_ui.js | 4 +- .../include/styles/js/datatables.min.css | 2 +- .../include/styles/js/jquery-ui_custom.css | 38 +++++++++++++++++-- pandora_console/include/styles/pandora.css | 2 +- .../include/styles/tips_window.css | 9 ++++- .../operation/visual_console/view.php | 2 +- .../resources/styles/um.css | 3 -- .../update_manager_client/views/register.php | 2 +- .../views/dashboard/tipsWindow.php | 2 +- 10 files changed, 49 insertions(+), 17 deletions(-) diff --git a/pandora_console/include/functions_register.php b/pandora_console/include/functions_register.php index e9c74c8c9a..db1bc8bf21 100644 --- a/pandora_console/include/functions_register.php +++ b/pandora_console/include/functions_register.php @@ -293,7 +293,7 @@ function show_configuration_wizard() { buttons: [ { "text": "No", - "class": 'submit-cancel', + "class": 'submit-cancel secondaryButton', "click" : function() { $(this).dialog("close"); } diff --git a/pandora_console/include/javascript/pandora_ui.js b/pandora_console/include/javascript/pandora_ui.js index cd71ef51c3..2d84d60794 100644 --- a/pandora_console/include/javascript/pandora_ui.js +++ b/pandora_console/include/javascript/pandora_ui.js @@ -157,7 +157,7 @@ function load_modal(settings) { required_buttons.push({ class: - "ui-widget ui-state-default ui-corner-all ui-button-text-only sub upd submit-cancel", + "ui-widget ui-state-default ui-corner-all ui-button-text-only sub upd submit-cancel secondaryButton", id: settings.modal.cancel_button_id, text: settings.modal.cancel, click: function() { @@ -574,7 +574,7 @@ function confirmDialog(settings, idDialog = uniqId()) { : settings.strCancelButton, class: hideCancelButton + - "ui-widget ui-state-default ui-corner-all ui-button-text-only sub upd submit-cancel", + "ui-widget ui-state-default ui-corner-all ui-button-text-only sub upd submit-cancel secondaryButton", click: function() { if (typeof settings.notCloseOnDeny == "undefined") { $(this).dialog("close"); diff --git a/pandora_console/include/styles/js/datatables.min.css b/pandora_console/include/styles/js/datatables.min.css index c5a5598611..e06d28a60b 100644 --- a/pandora_console/include/styles/js/datatables.min.css +++ b/pandora_console/include/styles/js/datatables.min.css @@ -865,7 +865,7 @@ body .ui-tooltip { color: #333; } .ui-dialog .ui-widget-header { - margin: -3px -3px 0px -3px; + /* margin: -3px -3px 0px -3px; */ } .ui-state-default, .ui-widget-content .ui-state-default, diff --git a/pandora_console/include/styles/js/jquery-ui_custom.css b/pandora_console/include/styles/js/jquery-ui_custom.css index 1c68f9783e..440540ab05 100644 --- a/pandora_console/include/styles/js/jquery-ui_custom.css +++ b/pandora_console/include/styles/js/jquery-ui_custom.css @@ -14,7 +14,7 @@ margin: 0; display: inherit; text-align: left; - padding: 1.2em 33px 1.2em 12px; + padding: 1.2em 33px 1.2em 12px !important; height: 30px; position: relative; overflow: hidden; @@ -102,6 +102,36 @@ border: 1px solid #82b92e; height: 30px; width: 90px; + border: 2px solid var(--primary-color) !important; +} + +button.secondaryButton { + background-color: #fff !important; + color: var(--primary-color) !important; + border: 2px solid var(--primary-color) !important; + box-shadow: none; +} + +button.secondaryButton > div { + background-color: var(--primary-color) !important; +} + +button.secondaryButton:hover { + color: #1d7873 !important; + border-color: #1d7873 !important; +} + +button.secondaryButton:hover > div { + background-color: #1d7873 !important; +} + +button.secondaryButton:active { + color: #0d312f !important; + border-color: #0d312f !important; +} + +button.secondaryButton:active > div { + background-color: #0d312f !important; } .ui-datepicker-prev { @@ -252,7 +282,7 @@ a.ui-state-default > span:hover { border-bottom-right-radius: 10px !important; box-shadow: 0 10px 6px 0 rgb(0 0 0 / 13%); border: 1px solid #e5e9ed; - padding: 0; + padding: 0 !important; } .ui-dialog-titlebar { border: 0px; @@ -270,8 +300,8 @@ a.ui-state-default > span:hover { .ui-button.ui-corner-all.ui-widget.ui-button-icon-only.ui-dialog-titlebar-close, .ui-button.ui-corner-all.ui-widget.ui-button-icon-only.ui-dialog-titlebar-close:hover { background-color: #fff; - mask: url(../../../images/close@svg.svg) no-repeat right / contain; - -webkit-mask: url(../../../images/close@svg.svg) no-repeat right / contain; + mask: url(../../../images/close_dialog.svg) no-repeat right / contain; + -webkit-mask: url(../../../images/close_dialog.svg) no-repeat right / contain; } .ui-dialog-title { diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 94d337bdbe..75059d8370 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -10454,7 +10454,7 @@ button.submitButton { display: flex; justify-content: space-between; flex-direction: row; - min-width: 110px; + /* min-width: 110px; */ height: 45px; font-size: 14px; /*font-family: "lato";*/ diff --git a/pandora_console/include/styles/tips_window.css b/pandora_console/include/styles/tips_window.css index 5c6114f92a..4c50f7214c 100644 --- a/pandora_console/include/styles/tips_window.css +++ b/pandora_console/include/styles/tips_window.css @@ -28,9 +28,10 @@ border-top-right-radius: 10px !important; } .tips_header .title { - font-size: 15px; + font-size: 13pt !important; color: #fff; - padding: 1.2em 33px 1.2em 12px !important; + padding: 1em 33px 1em 12px !important; + margin: 0; } .description { padding: 0px 20px 20px 20px; @@ -91,6 +92,10 @@ width: 100%; justify-content: space-between; } + +.ui-dialog-titlebar > p { + display: flex; +} #tips_window_modal .ui-dialog-buttonset button.submit-cancel-tips, #tips_window_modal_preview .ui-dialog-buttonset button.submit-cancel-tips { border-radius: 6px; diff --git a/pandora_console/operation/visual_console/view.php b/pandora_console/operation/visual_console/view.php index 6f193c05c5..7d44c7b69b 100644 --- a/pandora_console/operation/visual_console/view.php +++ b/pandora_console/operation/visual_console/view.php @@ -901,7 +901,7 @@ if ($edit_capable === true) { draggable: true, modal: true, close: false, - height: 200, + height: 210, width: 480, overlay: { opacity: 0.5, diff --git a/pandora_console/update_manager_client/resources/styles/um.css b/pandora_console/update_manager_client/resources/styles/um.css index fe28eaa176..cd88b1d30d 100644 --- a/pandora_console/update_manager_client/resources/styles/um.css +++ b/pandora_console/update_manager_client/resources/styles/um.css @@ -321,9 +321,6 @@ a.update_manager_button:after { margin: 20px; } -.ui-widget.ui-widget-content { - border: none; -} #um-update-details { display: none; background: #fff; diff --git a/pandora_console/update_manager_client/views/register.php b/pandora_console/update_manager_client/views/register.php index 5c05d04678..bfc70570f3 100644 --- a/pandora_console/update_manager_client/views/register.php +++ b/pandora_console/update_manager_client/views/register.php @@ -156,7 +156,7 @@ $("#submit-cancel_registration").click(function(e) { buttons: [ { text: "No", - class: "submit-cancel", + class: "submit-cancel secondaryButton", click: function() { $(this).dialog("close"); } diff --git a/pandora_console/views/dashboard/tipsWindow.php b/pandora_console/views/dashboard/tipsWindow.php index 573a11abcc..d2714ae1f2 100644 --- a/pandora_console/views/dashboard/tipsWindow.php +++ b/pandora_console/views/dashboard/tipsWindow.php @@ -41,7 +41,7 @@ $output .= '

'.html_print_checkbox( false, '', ($preview === true) ? '' : 'checkbox_tips_startup' -).__('Show usage tips at startup').'

'; +).' '.__('Show usage tips at startup').'

'; $output .= '
'; $output .= '