Merge remote-tracking branch 'origin/develop' into ent-8676-consolas-visuales-en-consola-movil

This commit is contained in:
Daniel Barbero Martin 2022-03-15 11:47:55 +01:00
commit a310194f5d
22 changed files with 617 additions and 221 deletions

View File

@ -11,6 +11,9 @@
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
use PandoraFMS\Enterprise\Metaconsole\Node;
function dbmanager_query($sql, &$error, $dbconnection) function dbmanager_query($sql, &$error, $dbconnection)
{ {
global $config; global $config;
@ -88,6 +91,10 @@ function dbmgr_extension_main()
global $config; global $config;
if (is_metaconsole() === true) {
open_meta_frame();
}
if (!is_user_admin($config['id_user'])) { if (!is_user_admin($config['id_user'])) {
db_pandora_audit( db_pandora_audit(
AUDIT_LOG_ACL_VIOLATION, AUDIT_LOG_ACL_VIOLATION,
@ -98,11 +105,59 @@ function dbmgr_extension_main()
} }
$sql = (string) get_parameter('sql'); $sql = (string) get_parameter('sql');
$node_id = (int) get_parameter('node_id', -1);
ui_print_page_header(__('Database interface'), 'images/gm_db.png', false, false, true); ui_print_page_header(__('Database interface'), 'images/gm_db.png', false, false, true);
echo '<div class="notify">'; if (is_metaconsole() === true) {
echo __( $img = '../../images/warning_modern.png';
} else {
$img = 'images/warning_modern.png';
}
$msg = '<div id="err_msg_centralised">'.html_print_image(
$img,
true
);
$msg .= '<div>'.__(
'Warning, you are accessing the database directly. You can leave the system inoperative if you run an inappropriate SQL statement'
).'</div></div>';
$warning_message = '<script type="text/javascript">
$(document).ready(function () {
infoMessage({
title: \''.__('Warning').'\',
text: \''.$msg.'\' ,
simple: true,
})
})
</script>';
if (empty($sql) === true) {
echo $warning_message;
}
echo "<form method='post' action=''>";
$table = new stdClass();
$table->id = 'db_interface';
$table->class = 'databox';
$table->width = '100%';
$table->data = [];
$table->head = [];
$table->colspan = [];
$table->rowstyle = [];
$table->colspan[0][0] = 2;
$table->colspan[1][0] = 2;
$table->rowspan[2][0] = 3;
$table->rowclass[0] = 'notify';
$table->rowclass[3] = 'pdd_5px';
$table->rowclass[3] = 'flex-content-right';
$table->rowclass[4] = 'flex-content-right';
$data[0][0] = __(
"This is an advanced extension to interface with %s database directly from WEB console "This is an advanced extension to interface with %s database directly from WEB console
using native SQL sentences. Please note that <b>you can damage</b> your %s installation using native SQL sentences. Please note that <b>you can damage</b> your %s installation
if you don't know </b>exactly</b> what are you are doing, if you don't know </b>exactly</b> what are you are doing,
@ -113,19 +168,59 @@ function dbmgr_extension_main()
get_product_name(), get_product_name(),
get_product_name() get_product_name()
); );
echo '</div>';
echo '<br />'; $data[1][0] = "Some samples of usage: <blockquote><em>SHOW STATUS;<br />DESCRIBE tagente<br />SELECT * FROM tserver<br />UPDATE tagente SET id_grupo = 15 WHERE nombre LIKE '%194.179%'</em></blockquote>";
echo "Some samples of usage: <blockquote><em>SHOW STATUS;<br />DESCRIBE tagente<br />SELECT * FROM tserver<br />UPDATE tagente SET id_grupo = 15 WHERE nombre LIKE '%194.179%'</em></blockquote>";
echo '<br /><br />'; \enterprise_include_once('include/functions_metaconsole.php');
echo "<form method='post' action=''>"; $servers = \metaconsole_get_servers();
html_print_textarea('sql', 5, 50, html_entity_decode($sql, ENT_QUOTES)); if (is_array($servers) === true) {
echo '<br />'; $servers = array_reduce(
echo '<div class="action-buttons w100p">'; $servers,
echo '<br />'; function ($carry, $item) {
html_print_submit_button(__('Execute SQL'), '', false, 'class="sub next"'); $carry[$item['id']] = $item['server_name'];
echo '</div>'; return $carry;
}
);
} else {
$servers = [];
}
$data[2][0] = html_print_textarea(
'sql',
5,
50,
html_entity_decode($sql, ENT_QUOTES),
'',
true
);
if (is_metaconsole() === true) {
$data[3][2] = html_print_input(
[
'name' => 'node_id',
'type' => 'select',
'fields' => $servers,
'selected' => $node_id,
'nothing' => __('This metaconsole'),
'nothing_value' => -1,
'return' => true,
'label' => _('Select query target'),
]
);
}
$data[4][2] = '<div class="action-buttons w100p">';
$data[4][2] .= html_print_submit_button(
__('Execute SQL'),
'',
false,
'class="sub next"',
true
);
$data[4][2] .= '</div>';
$table->data = $data;
html_print_table($table);
echo '</form>'; echo '</form>';
// Processing SQL Code // Processing SQL Code
@ -137,10 +232,29 @@ function dbmgr_extension_main()
echo '<hr />'; echo '<hr />';
echo '<br />'; echo '<br />';
$dbconnection = $config['dbconnection']; try {
$error = ''; if (\is_metaconsole() === true && $node_id !== -1) {
$node = new Node($node_id);
$result = dbmanager_query($sql, $error, $dbconnection); $dbconnection = @get_dbconnection(
[
'dbhost' => $node->dbhost(),
'dbport' => $node->dbport(),
'dbname' => $node->dbname(),
'dbuser' => $node->dbuser(),
'dbpass' => $node->dbpass(),
]
);
$error = '';
$result = dbmanager_query($sql, $error, $dbconnection);
} else {
$dbconnection = $config['dbconnection'];
$error = '';
$result = dbmanager_query($sql, $error, $dbconnection);
}
} catch (\Exception $e) {
$error = __('Error querying database node');
$result = false;
}
if ($result === false) { if ($result === false) {
echo '<strong>An error has occured when querying the database.</strong><br />'; echo '<strong>An error has occured when querying the database.</strong><br />';
@ -181,9 +295,29 @@ function dbmgr_extension_main()
html_print_table($table); html_print_table($table);
echo '</div>'; echo '</div>';
if (is_metaconsole()) {
close_meta_frame();
}
} }
if (is_metaconsole() === true) {
// This adds a option in the operation menu.
extensions_add_meta_menu_option(
'DB interface',
'PM',
'gextensions',
'database.png',
'v1r1',
'gdbman'
);
extensions_add_meta_function('dbmgr_extension_main');
} else {
}
// This adds a option in the operation menu // This adds a option in the operation menu
extensions_add_godmode_menu_option(__('DB interface'), 'PM', 'gextensions', 'dbmanager/icon.png', 'v1r1', 'gdbman'); extensions_add_godmode_menu_option(__('DB interface'), 'PM', 'gextensions', 'dbmanager/icon.png', 'v1r1', 'gdbman');

View File

@ -119,4 +119,8 @@ godmode/admin_access_logs.php
enterprise/extensions/backup/main.php enterprise/extensions/backup/main.php
enterprise/extensions/backup.php enterprise/extensions/backup.php
mobile/include/javascript/jquery.mobile-1.4.5.js mobile/include/javascript/jquery.mobile-1.4.5.js
mobile/include/style/jquery.mobile-1.4.5.css mobile/include/style/jquery.mobile-1.4.5.css
enterprise/extensions/backup/backup.js
enterprise/extensions/backup/sql/backup.sql
enterprise/extensions/backup/sql/backup.oracle.sql
enterprise/extensions/backup/sql/backup.postgreSQL.sql

View File

@ -0,0 +1,17 @@
START TRANSACTION;
UPDATE `tuser_task` SET `parameters` = 'a:3:{i:0;a:2:{s:11:"description";s:11:"Description";s:4:"type";s:4:"text";}i:1;a:3:{s:11:"description";s:20:"Save to disk in path";s:4:"type";s:6:"string";s:13:"default_value";s:21:"_%_ATTACHMENT_PATH_%_";}i:2;a:3:{s:11:"description";s:14:"Active backups";s:4:"type";s:6:"number";s:13:"default_value";i:3;}}' WHERE `function_name` = 'cron_task_do_backup';
CREATE TABLE IF NOT EXISTS `tbackup` (
`id` SERIAL,
`utimestamp` BIGINT DEFAULT 0,
`filename` VARCHAR(512) DEFAULT '',
`id_user` VARCHAR(60) DEFAULT '',
`description` MEDIUMTEXT,
`pid` INT UNSIGNED DEFAULT 0,
`filepath` VARCHAR(512) DEFAULT '',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
COMMIT;

View File

@ -31,6 +31,7 @@ global $config;
enterprise_include('godmode/agentes/configurar_agente.php'); enterprise_include('godmode/agentes/configurar_agente.php');
enterprise_include_once('include/functions_modules.php'); enterprise_include_once('include/functions_modules.php');
enterprise_include_once('include/functions_config_agents.php');
enterprise_include('include/functions_policies.php'); enterprise_include('include/functions_policies.php');
require_once $config['homedir'].'/include/functions_agents.php'; require_once $config['homedir'].'/include/functions_agents.php';
require_once $config['homedir'].'/include/functions_cron.php'; require_once $config['homedir'].'/include/functions_cron.php';
@ -2001,6 +2002,7 @@ if ($disable_module) {
io_safe_output($module_name), io_safe_output($module_name),
] ]
); );
// Force disable. // Force disable.
$disabled = 1; $disabled = 1;

View File

@ -262,7 +262,8 @@ if ($filemanager) {
'index.php?sec=gservers&sec2=godmode/servers/plugin'.$chunck_url.'&plugin_command=[FILE_FULLPATH]&id_plugin='.$id_plugin, 'index.php?sec=gservers&sec2=godmode/servers/plugin'.$chunck_url.'&plugin_command=[FILE_FULLPATH]&id_plugin='.$id_plugin,
true, true,
0775, 0775,
false false,
['all' => true]
); );
} }

View File

@ -65,13 +65,22 @@ $real_directory = realpath($config['homedir'].'/'.$directory);
echo '<h4>'.__('Index of %s', $directory).'</h4>'; echo '<h4>'.__('Index of %s', $directory).'</h4>';
$upload_file_or_zip = (bool) get_parameter('upload_file_or_zip'); $upload_file = (bool) get_parameter('upload_file');
$create_text_file = (bool) get_parameter('create_text_file'); $create_text_file = (bool) get_parameter('create_text_file');
$default_real_directory = realpath($config['homedir'].'/'); $default_real_directory = realpath($config['homedir'].'/');
if ($upload_file_or_zip === true) { if ($upload_file === true) {
upload_file($upload_file_or_zip, $default_real_directory, $real_directory); upload_file(
$upload_file,
$default_real_directory,
$real_directory,
[
MIME_TYPES['jpg'],
MIME_TYPES['png'],
MIME_TYPES['gif'],
]
);
} }
if ($create_text_file === true) { if ($create_text_file === true) {
@ -89,5 +98,6 @@ filemanager_file_explorer(
false, false,
'', '',
false, false,
false false,
[]
); );

View File

@ -391,37 +391,29 @@ class TreeGroup extends Tree
$groups[$group['id']] = $group; $groups[$group['id']] = $group;
} }
// Build the module hierarchy // Build the module hierarchy.
foreach ($groups as $id => $group) { foreach ($groups as $id => $group) {
if (isset($groups[$id]['parent']) && ($groups[$id]['parent'] != 0)) { if (isset($groups[$id]['parent']) === true && ($groups[$id]['parent'] != 0)) {
$parent = $groups[$id]['parent']; $parent = $groups[$id]['parent'];
// Parent exists // Parent exists.
if (!isset($groups[$parent]['children'])) { if (isset($groups[$parent]['children']) === true) {
$groups[$parent]['children'] = []; $groups[$parent]['children'] = [];
} }
// Store a reference to the group into the parent // Store a reference to the group into the parent.
$groups[$parent]['children'][] = &$groups[$id]; $groups[$parent]['children'][] = &$groups[$id];
// This group was introduced into a parent // This group was introduced into a parent.
$groups[$id]['have_parent'] = true; $groups[$id]['have_parent'] = true;
} }
} }
// Sort the children groups // Sort the children groups.
foreach ($groups as $id => $group) { foreach ($groups as $id => $group) {
if (isset($groups[$id]['children'])) { if (isset($groups[$id]['children']) === true) {
usort($groups[$id]['children'], ['Tree', 'cmpSortNames']); usort($groups[$id]['children'], ['Tree', 'cmpSortNames']);
} }
} }
// Filter groups and eliminates the reference to children groups out of her parent
$groups = array_filter(
$groups,
function ($group) {
return !($group['have_parent'] ?? false);
}
);
return array_values($groups); return array_values($groups);
} }

View File

@ -788,6 +788,7 @@ define('AUDIT_LOG_MASSIVE_MANAGEMENT', 'Massive operation management');
define('AUDIT_LOG_POLICY_MANAGEMENT', 'Policy management'); define('AUDIT_LOG_POLICY_MANAGEMENT', 'Policy management');
define('AUDIT_LOG_AGENT_REMOTE_MANAGEMENT', 'Agent remote configuration'); define('AUDIT_LOG_AGENT_REMOTE_MANAGEMENT', 'Agent remote configuration');
define('AUDIT_LOG_FILE_COLLECTION', 'File collection'); define('AUDIT_LOG_FILE_COLLECTION', 'File collection');
define('AUDIT_LOG_FILE_MANAGER', 'File manager');
define('AUDIT_LOG_ALERT_MANAGEMENT', 'Alert management'); define('AUDIT_LOG_ALERT_MANAGEMENT', 'Alert management');
define('AUDIT_LOG_ALERT_CORRELATION_MANAGEMENT', 'Alert correlation management'); define('AUDIT_LOG_ALERT_CORRELATION_MANAGEMENT', 'Alert correlation management');
define('AUDIT_LOG_VISUAL_CONSOLE_MANAGEMENT', 'Visual Console Management'); define('AUDIT_LOG_VISUAL_CONSOLE_MANAGEMENT', 'Visual Console Management');
@ -796,3 +797,58 @@ define('AUDIT_LOG_SNMP_MANAGEMENT', 'SNMP management');
define('AUDIT_LOG_DASHBOARD_MANAGEMENT', 'Dashboard management'); define('AUDIT_LOG_DASHBOARD_MANAGEMENT', 'Dashboard management');
define('AUDIT_LOG_SERVICE_MANAGEMENT', 'Service management'); define('AUDIT_LOG_SERVICE_MANAGEMENT', 'Service management');
define('AUDIT_LOG_INCIDENT_MANAGEMENT', 'Incident management'); define('AUDIT_LOG_INCIDENT_MANAGEMENT', 'Incident management');
// MIMEs.
define(
'MIME_TYPES',
[
'txt' => 'text/plain',
'htm' => 'text/html',
'html' => 'text/html',
'php' => 'text/html',
'css' => 'text/css',
'js' => 'application/javascript',
'json' => 'application/json',
'xml' => 'application/xml',
'swf' => 'application/x-shockwave-flash',
'flv' => 'video/x-flv',
// Images.
'png' => 'image/png',
'jpe' => 'image/jpeg',
'jpeg' => 'image/jpeg',
'jpg' => 'image/jpeg',
'gif' => 'image/gif',
'bmp' => 'image/bmp',
'ico' => 'image/vnd.microsoft.icon',
'tiff' => 'image/tiff',
'tif' => 'image/tiff',
'svg' => 'image/svg+xml',
'svgz' => 'image/svg+xml',
// Archives.
'zip' => 'application/zip',
'rar' => 'application/x-rar-compressed',
'exe' => 'application/x-msdownload',
'msi' => 'application/x-msdownload',
'cab' => 'application/vnd.ms-cab-compressed',
'gz' => 'application/x-gzip',
'gz' => 'application/x-bzip2',
// Audio/Video.
'mp3' => 'audio/mpeg',
'qt' => 'video/quicktime',
'mov' => 'video/quicktime',
// Adobe.
'pdf' => 'application/pdf',
'psd' => 'image/vnd.adobe.photoshop',
'ai' => 'application/postscript',
'eps' => 'application/postscript',
'ps' => 'application/postscript',
// MS Office.
'doc' => 'application/msword',
'rtf' => 'application/rtf',
'xls' => 'application/vnd.ms-excel',
'ppt' => 'application/vnd.ms-powerpoint',
// Open Source Office files.
'odt' => 'application/vnd.oasis.opendocument.text',
'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
]
);

View File

@ -4187,6 +4187,28 @@ function events_get_response_target(
); );
} }
if (strpos($target, '_owner_username_') !== false) {
if (empty($event['owner_user']) === false) {
$fullname = users_get_user_by_id($event['owner_user']);
$target = str_replace(
'_owner_username_',
io_safe_output($fullname['fullname']),
$target
);
} else {
$target = str_replace('_owner_username_', __('N/A'), $target);
}
}
if (strpos($target, '_current_username_') !== false) {
$fullname = users_get_user_by_id($config['id_user']);
$target = str_replace(
'_current_username_',
io_safe_output($fullname['fullname']),
$target
);
}
return $target; return $target;
} }
@ -7588,6 +7610,28 @@ function events_get_field_value_by_event_id(
$value = str_replace('_current_user_', $config['id_user'], $value); $value = str_replace('_current_user_', $config['id_user'], $value);
} }
if (strpos($value, '_owner_username_') !== false) {
if (empty($event['owner_user']) === false) {
$fullname = users_get_user_by_id($event['owner_user']);
$value = str_replace(
'_owner_username_',
io_safe_output($fullname['fullname']),
$value
);
} else {
$value = str_replace('_owner_username_', __('N/A'), $value);
}
}
if (strpos($value, '_current_username_') !== false) {
$fullname = users_get_user_by_id($config['id_user']);
$value = str_replace(
'_current_username_',
io_safe_output($fullname['fullname']),
$value
);
}
return $value; return $value;
} }

View File

@ -14,7 +14,7 @@
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
* *
* ============================================================================ * ============================================================================
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas * Copyright (c) 2005-2022 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list * Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -48,69 +48,22 @@ if (function_exists('mime_content_type') === false) {
*/ */
function mime_content_type(string $filename) function mime_content_type(string $filename)
{ {
$mime_types = [
'txt' => 'text/plain',
'htm' => 'text/html',
'html' => 'text/html',
'php' => 'text/html',
'css' => 'text/css',
'js' => 'application/javascript',
'json' => 'application/json',
'xml' => 'application/xml',
'swf' => 'application/x-shockwave-flash',
'flv' => 'video/x-flv',
// Images.
'png' => 'image/png',
'jpe' => 'image/jpeg',
'jpeg' => 'image/jpeg',
'jpg' => 'image/jpeg',
'gif' => 'image/gif',
'bmp' => 'image/bmp',
'ico' => 'image/vnd.microsoft.icon',
'tiff' => 'image/tiff',
'tif' => 'image/tiff',
'svg' => 'image/svg+xml',
'svgz' => 'image/svg+xml',
// Archives.
'zip' => 'application/zip',
'rar' => 'application/x-rar-compressed',
'exe' => 'application/x-msdownload',
'msi' => 'application/x-msdownload',
'cab' => 'application/vnd.ms-cab-compressed',
'gz' => 'application/x-gzip',
'gz' => 'application/x-bzip2',
// Audio/Video.
'mp3' => 'audio/mpeg',
'qt' => 'video/quicktime',
'mov' => 'video/quicktime',
// Adobe.
'pdf' => 'application/pdf',
'psd' => 'image/vnd.adobe.photoshop',
'ai' => 'application/postscript',
'eps' => 'application/postscript',
'ps' => 'application/postscript',
// MS Office.
'doc' => 'application/msword',
'rtf' => 'application/rtf',
'xls' => 'application/vnd.ms-excel',
'ppt' => 'application/vnd.ms-powerpoint',
// Open Source Office files.
'odt' => 'application/vnd.oasis.opendocument.text',
'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
];
$ext_fields = explode('.', $filename); $ext_fields = explode('.', $filename);
$ext = array_pop($ext_fields); $ext = array_pop($ext_fields);
$ext = strtolower($ext); $ext = strtolower($ext);
if (array_key_exists($ext, $mime_types) === true) { if (array_key_exists($ext, MIME_TYPES) === true) {
return $mime_types[$ext]; return MIME_TYPES[$ext];
} else if (function_exists('finfo_open') === true) { } else if (function_exists('finfo_open') === true) {
$finfo = finfo_open(FILEINFO_MIME); $finfo = finfo_open(FILEINFO_MIME);
$mimetype = finfo_file($finfo, $filename); $mimetype = finfo_file($finfo, $filename);
finfo_close($finfo); finfo_close($finfo);
return $mimetype; return $mimetype;
} else { } else {
error_log('Warning: Cannot find finfo_open function. Fileinfo extension is not enabled. Please add "extension=fileinfo.so" or "extension=fileinfo.dll" in your php.ini'); db_pandora_audit(
AUDIT_LOG_FILE_MANAGER,
'Warning: Cannot find finfo_open function. Fileinfo extension is not enabled. Please add "extension=fileinfo.so" or "extension=fileinfo.dll" in your php.ini'
);
return 'unknown'; return 'unknown';
} }
} }
@ -129,10 +82,12 @@ require_once $config['homedir'].'/vendor/autoload.php';
* @param boolean $upload_file_or_zip Upload file or zip. * @param boolean $upload_file_or_zip Upload file or zip.
* @param string $default_real_directory String with default directory. * @param string $default_real_directory String with default directory.
* @param string $destination_directory String with destination directory. * @param string $destination_directory String with destination directory.
* @param array $filterFilesType If come filled, filter uploaded files with this extensions.
* *
* @throws Exception Exception.
* @return void * @return void
*/ */
function upload_file($upload_file_or_zip, $default_real_directory, $destination_directory) function upload_file($upload_file_or_zip, $default_real_directory, $destination_directory, $filterFilesType=[])
{ {
global $config; global $config;
$config['filemanager'] = []; $config['filemanager'] = [];
@ -179,13 +134,24 @@ function upload_file($upload_file_or_zip, $default_real_directory, $destination_
// controlled by corresponding .htaccess). // controlled by corresponding .htaccess).
$config['filemanager']['message'] = ui_print_error_message(__('Security error')); $config['filemanager']['message'] = ui_print_error_message(__('Security error'));
} else { } else {
$result = false;
// Copy file to directory and change name. // Copy file to directory and change name.
$nombre_archivo = sprintf('%s/%s', $real_directory, $filename); $nombre_archivo = sprintf('%s/%s', $real_directory, $filename);
try { try {
$result = copy($_FILES['file']['tmp_name'], $nombre_archivo); $mimeContentType = mime_content_type($_FILES['file']['tmp_name']);
if (empty($filterFilesType) === true || in_array($mimeContentType, $filterFilesType) === true) {
$result = copy($_FILES['file']['tmp_name'], $nombre_archivo);
} else {
$error_message = 'The uploaded file is not allowed. Only gif, png or jpg files can be uploaded.';
throw new Exception(__($error_message));
}
} catch (Exception $ex) { } catch (Exception $ex) {
$result = false; db_pandora_audit(
AUDIT_LOG_FILE_MANAGER,
'Error Uploading files: '.$ex->getMessage()
);
$config['filemanager']['message'] = ui_print_error_message(__('Upload error').': '.$ex->getMessage());
} }
if ($result === true) { if ($result === true) {
@ -203,8 +169,6 @@ function upload_file($upload_file_or_zip, $default_real_directory, $destination_
$config['filemanager']['correct_upload_file'] = 1; $config['filemanager']['correct_upload_file'] = 1;
// Delete temporal file. // Delete temporal file.
unlink($_FILES['file']['tmp_name']); unlink($_FILES['file']['tmp_name']);
} else {
$config['filemanager']['message'] = ui_print_error_message(__('Upload error'));
} }
} }
} }
@ -496,7 +460,7 @@ function filemanager_read_recursive_dir($dir, $relative_path='', $add_empty_dirs
* @param boolean $download_button The flag to show download button, by default false. * @param boolean $download_button The flag to show download button, by default false.
* @param string $umask The umask as hex values to set the new files or updload. * @param string $umask The umask as hex values to set the new files or updload.
* @param boolean $homedir_filemanager Homedir filemanager. * @param boolean $homedir_filemanager Homedir filemanager.
* @param boolean $allowCreateText If true, 'Create Text' button will be shown. * @param array $options Associative array. ['all' => true] will show all options. Check function for valid options.
*/ */
function filemanager_file_explorer( function filemanager_file_explorer(
$real_directory, $real_directory,
@ -509,7 +473,7 @@ function filemanager_file_explorer(
$download_button=false, $download_button=false,
$umask='', $umask='',
$homedir_filemanager=false, $homedir_filemanager=false,
$allowCreateText=true $options=[]
) { ) {
global $config; global $config;
@ -517,6 +481,9 @@ function filemanager_file_explorer(
$real_directory = str_replace('\\', '/', $real_directory); $real_directory = str_replace('\\', '/', $real_directory);
$relative_directory = str_replace('\\', '/', $relative_directory); $relative_directory = str_replace('\\', '/', $relative_directory);
$father = str_replace('\\', '/', $father); $father = str_replace('\\', '/', $father);
// Options.
$allowZipFiles = (isset($options['all']) === true) || ((isset($options['allowZipFiles']) === true) && ($options['allowZipFiles'] === true));
$allowCreateText = (isset($options['all']) === true) || ((isset($options['allowCreateText']) === true) && ($options['allowCreateText'] === true));
if ($homedir_filemanager === false) { if ($homedir_filemanager === false) {
$homedir_filemanager = $config['homedir']; $homedir_filemanager = $config['homedir'];
@ -530,7 +497,7 @@ function filemanager_file_explorer(
actions_dialog('create_folder'); actions_dialog('create_folder');
$("#create_folder").css("display", "block"); $("#create_folder").css("display", "block");
check_opened_dialog('create_folder'); check_opened_dialog('create_folder');
} }
<?php if ($allowCreateText === true) : ?> <?php if ($allowCreateText === true) : ?>
function show_create_text_file() { function show_create_text_file() {
actions_dialog('create_text_file'); actions_dialog('create_text_file');
@ -542,7 +509,7 @@ function filemanager_file_explorer(
actions_dialog('upload_file'); actions_dialog('upload_file');
$("#upload_file").css("display", "block"); $("#upload_file").css("display", "block");
check_opened_dialog('upload_file'); check_opened_dialog('upload_file');
} }
function check_opened_dialog(check_opened){ function check_opened_dialog(check_opened){
if(check_opened !== 'create_folder'){ if(check_opened !== 'create_folder'){
@ -579,11 +546,11 @@ function filemanager_file_explorer(
case 'upload_file': case 'upload_file':
title_action = "<?php echo __('Upload Files'); ?>"; title_action = "<?php echo __('Upload Files'); ?>";
break; break;
default: default:
break; break;
} }
$('#'+action) $('#'+action)
.dialog({ .dialog({
title: title_action, title: title_action,
@ -839,15 +806,86 @@ function filemanager_file_explorer(
$tabs_dialog .= '</ul>'; $tabs_dialog .= '</ul>';
echo '<div id="create_folder" class="invisible">'.$tabs_dialog.' // Create folder section.
<form method="post" action="'.$url.'">'.html_print_input_text('dirname', '', '', 30, 255, true).html_print_submit_button(__('Create'), 'crt', false, 'class="sub next"', true).html_print_input_hidden('directory', $relative_directory, true).html_print_input_hidden('create_dir', 1, true).html_print_input_hidden('hash', md5($relative_directory.$config['server_unique_identifier']), true).html_print_input_hidden('hash2', md5($relative_directory.$config['server_unique_identifier']), true).'</form></div>'; $createFolderElements = $tabs_dialog;
$createFolderElements .= sprintf('<form method="POST" action="%s">', $url);
$createFolderElements .= html_print_input_text('dirname', '', '', 30, 255, true);
$createFolderElements .= html_print_submit_button(__('Create'), 'crt', false, 'class="sub next"', true);
$createFolderElements .= html_print_input_hidden('directory', $relative_directory, true);
$createFolderElements .= html_print_input_hidden('create_dir', 1, true);
$createFolderElements .= html_print_input_hidden('hash', md5($relative_directory.$config['server_unique_identifier']), true);
$createFolderElements .= html_print_input_hidden('hash2', md5($relative_directory.$config['server_unique_identifier']), true);
$createFolderElements .= '</form>';
echo '<div id="upload_file" class="invisible"> '.$tabs_dialog.' html_print_div(
<form method="post" action="'.$url.'" enctype="multipart/form-data">'.ui_print_help_tip(__('The zip upload in this dir, easy to upload multiple files.'), true).html_print_input_file('file', true, false).html_print_input_hidden('umask', $umask, true).html_print_checkbox('decompress', 1, false, true).__('Decompress').html_print_submit_button(__('Go'), 'go', false, 'class="sub next"', true).html_print_input_hidden('real_directory', $real_directory, true).html_print_input_hidden('directory', $relative_directory, true).html_print_input_hidden('hash', md5($real_directory.$relative_directory.$config['server_unique_identifier']), true).html_print_input_hidden('hash2', md5($relative_directory.$config['server_unique_identifier']), true).html_print_input_hidden('upload_file_or_zip', 1, true).'</form></div>'; [
'id' => 'create_folder',
'class' => 'invisible',
'content' => $createFolderElements,
]
);
// Upload file section.
$uploadFileElements = $tabs_dialog;
$uploadFileElements .= sprintf('<form method="POST" action="%s" enctype="multipart/form-data">', $url);
$uploadFileElements .= html_print_input_hidden('umask', $umask, true);
if ($allowZipFiles === true) {
$uploadFileElements .= ui_print_help_tip(__('The zip upload in this dir, easy to upload multiple files.'), true);
$uploadFileElements .= html_print_input_file('file', true, false);
$uploadFileElements .= html_print_checkbox('decompress', 1, false, true).__('Decompress');
$uploadFileElements .= html_print_input_hidden('upload_file_or_zip', 1, true);
} else {
$uploadFileElements .= html_print_div(
[
'id' => 'upload_file_input_full',
'content' => html_print_input_file(
'file',
true,
[ 'style' => 'border:0; padding:0; width:100%' ]
),
],
true
);
$uploadFileElements .= html_print_input_hidden('upload_file', 1, true);
}
$uploadFileElements .= html_print_submit_button(__('Go'), 'go', false, 'class="sub next"', true);
$uploadFileElements .= html_print_input_hidden('real_directory', $real_directory, true);
$uploadFileElements .= html_print_input_hidden('directory', $relative_directory, true);
$uploadFileElements .= html_print_input_hidden('hash', md5($real_directory.$relative_directory.$config['server_unique_identifier']), true);
$uploadFileElements .= html_print_input_hidden('hash2', md5($relative_directory.$config['server_unique_identifier']), true);
$uploadFileElements .= '</form>';
html_print_div(
[
'id' => 'upload_file',
'class' => 'invisible',
'content' => $uploadFileElements,
]
);
// Create text section.
if ($allowCreateText === true) { if ($allowCreateText === true) {
echo ' <div id="create_text_file" class="invisible">'.$tabs_dialog.' $createTextElements = $tabs_dialog;
<form method="post" action="'.$url.'">'.html_print_input_text('name_file', '', '', 30, 50, true).html_print_submit_button(__('Create'), 'create', false, 'class="sub next"', true).html_print_input_hidden('real_directory', $real_directory, true).html_print_input_hidden('directory', $relative_directory, true).html_print_input_hidden('hash', md5($real_directory.$relative_directory.$config['server_unique_identifier']), true).html_print_input_hidden('umask', $umask, true).html_print_input_hidden('create_text_file', 1, true).'</form></div>'; $createTextElements .= '<form method="post" action="'.$url.'">';
$createTextElements .= html_print_input_text('name_file', '', '', 30, 50, true);
$createTextElements .= html_print_submit_button(__('Create'), 'create', false, 'class="sub next"', true);
$createTextElements .= html_print_input_hidden('real_directory', $real_directory, true);
$createTextElements .= html_print_input_hidden('directory', $relative_directory, true);
$createTextElements .= html_print_input_hidden('hash', md5($real_directory.$relative_directory.$config['server_unique_identifier']), true);
$createTextElements .= html_print_input_hidden('umask', $umask, true);
$createTextElements .= html_print_input_hidden('create_text_file', 1, true);
$createTextElements .= '</form>';
html_print_div(
[
'id' => 'create_text_file',
'class' => 'invisible',
'content' => $createTextElements,
]
);
} }
echo "<div style='width: ".$table->width.";' class='file_table_buttons'>"; echo "<div style='width: ".$table->width.";' class='file_table_buttons'>";

View File

@ -4267,6 +4267,10 @@ function html_print_input_file($name, $return=false, $options=false)
if (isset($options['onchange'])) { if (isset($options['onchange'])) {
$output .= ' onchange="'.$options['onchange'].'"'; $output .= ' onchange="'.$options['onchange'].'"';
} }
if (isset($options['style']) === true) {
$output .= ' style="'.$options['style'].'"';
}
} }
$output .= ' />'; $output .= ' />';

View File

@ -2713,16 +2713,15 @@ function ui_print_status_image(
$imagepath = $path; $imagepath = $path;
} }
if ($imagepath == 'images/status_sets/default') { if ($imagepath === 'images/status_sets/default') {
$image_with_css = true; $image_with_css = true;
} }
$imagepath .= '/'.$type;
if ($image_with_css === true) { if ($image_with_css === true) {
$shape_status = get_shape_status_set($type); $shape_status = get_shape_status_set($type);
return ui_print_status_sets($type, $title, $return, $shape_status, $extra_info); return ui_print_status_sets($type, $title, $return, $shape_status, $extra_info);
} else { } else {
$imagepath .= '/'.$type;
if ($options === false) { if ($options === false) {
$options = []; $options = [];
} }
@ -2871,7 +2870,7 @@ function ui_print_status_sets(
$options = []; $options = [];
} }
if (isset($options['style'])) { if (isset($options['style']) === true) {
$options['style'] .= ' display: inline-block;'; $options['style'] .= ' display: inline-block;';
} else { } else {
$options['style'] = 'display: inline-block;'; $options['style'] = 'display: inline-block;';
@ -2881,15 +2880,15 @@ function ui_print_status_sets(
$options['style'] .= ' background: '.modules_get_color_status($status).';'; $options['style'] .= ' background: '.modules_get_color_status($status).';';
} }
if (isset($options['class'])) { if (isset($options['class']) === true) {
$options['class'] = $options['class']; $options['class'] = $options['class'];
} }
if ($title != '') { if (empty($title) === false) {
$options['title'] = empty($extra_info) ? $title : $title.'&#10'.$extra_info; $options['title'] = (empty($extra_info) === true) ? $title : $title.'&#10'.$extra_info;
$options['data-title'] = empty($extra_info) ? $title : $title.'<br>'.$extra_info; $options['data-title'] = (empty($extra_info) === true) ? $title : $title.'<br>'.$extra_info;
$options['data-use_title_for_force_title'] = 1; $options['data-use_title_for_force_title'] = 1;
if (isset($options['class'])) { if (isset($options['class']) === true) {
$options['class'] .= ' forced_title'; $options['class'] .= ' forced_title';
} else { } else {
$options['class'] = 'forced_title'; $options['class'] = 'forced_title';
@ -2901,15 +2900,13 @@ function ui_print_status_sets(
$output .= $k.'="'.$v.'"'; $output .= $k.'="'.$v.'"';
} }
$output .= '>'; $output .= '>&nbsp;</div>';
$output .= '</div>';
if ($return === false) { if ($return === false) {
echo $output; echo $output;
} else {
return $output;
} }
return $output;
} }

View File

@ -5092,6 +5092,17 @@ input:checked + .p-slider:before {
margin-top: 10px; margin-top: 10px;
} }
#upload_file #upload_file_input_full {
width: 100%;
border: 1px solid #cbcbcb;
border-radius: 2px;
padding: 5px 0;
}
#upload_file_input_full input#file-file::-webkit-file-upload-button {
margin-left: 5px;
}
.file_table_modal_active { .file_table_modal_active {
background-color: #fff; background-color: #fff;
border: 1px solid #e6e6e6; border: 1px solid #e6e6e6;

View File

@ -1344,6 +1344,12 @@ span.nobold * {
border-radius: 50%; border-radius: 50%;
} }
.status_small_rectangles {
width: 20px;
height: 10px;
display: inline-block;
}
.ui-content .ui-listview, .ui-content .ui-listview,
.ui-panel-inner > .ui-listview { .ui-panel-inner > .ui-listview {
margin: 0 !important; margin: 0 !important;

View File

@ -790,12 +790,11 @@ class Ui
echo ' <title>'.$this->title."</title>\n"; echo ' <title>'.$this->title."</title>\n";
echo " <meta charset='UTF-8' />\n"; echo " <meta charset='UTF-8' />\n";
echo " <meta name='viewport' content='width=device-width, initial-scale=1'>\n"; echo " <meta name='viewport' content='width=device-width, initial-scale=1'>\n";
echo ' <link rel="icon" href="'.ui_get_full_url('/').ui_get_favicon().'" type="image/ico" />'."\n";
echo ' <link rel="shortcut icon" href="'.ui_get_full_url('/').ui_get_favicon().'" type="image/x-icon" />'."\n";
echo " <link rel='stylesheet' href='include/style/main.css' />\n"; echo " <link rel='stylesheet' href='include/style/main.css' />\n";
// echo " <link rel='stylesheet' href='include/style/jquery.mobile-1.4.5.css' />\n";
echo " <link rel='stylesheet' href='include/style/jquery.mobile-1.5.0-rc1.min.css' />\n"; echo " <link rel='stylesheet' href='include/style/jquery.mobile-1.5.0-rc1.min.css' />\n";
// echo " <script src='include/javascript/jquery.js.bakc'></script>\n";
echo " <script src='include/javascript/jquery.js'></script>\n"; echo " <script src='include/javascript/jquery.js'></script>\n";
// echo " <script src='include/javascript/jquery.mobile-1.4.5.js'></script>\n";
echo " <script src='include/javascript/jquery.mobile-1.5.0-rc1.js'></script>\n"; echo " <script src='include/javascript/jquery.mobile-1.5.0-rc1.js'></script>\n";
echo " <script src='../include/javascript/pandora.js'></script>\n"; echo " <script src='../include/javascript/pandora.js'></script>\n";
echo " <script src='../include/javascript/pandora_ui.js'></script>\n"; echo " <script src='../include/javascript/pandora_ui.js'></script>\n";

View File

@ -1,15 +1,33 @@
<?php <?php
// Pandora FMS - http://pandorafms.com // phpcs:disable Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
// ================================================== /**
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas * Agent view for mobile
// Please see http://pandorafms.org for full contribution list *
// This program is free software; you can redistribute it and/or * @category Mobile
// modify it under the terms of the GNU General Public License * @package Pandora FMS
// as published by the Free Software Foundation for version 2. * @subpackage Community
// This program is distributed in the hope that it will be useful, * @version 1.0.0
// but WITHOUT ANY WARRANTY; without even the implied warranty of * @license See below
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
// GNU General Public License for more details. * ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2022 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/
// Begin.
require_once '../include/functions_users.php'; require_once '../include/functions_users.php';
class Agent class Agent
@ -41,7 +59,7 @@ class Agent
var isgentoo = /Gentoo/i.test(navigator.userAgent); var isgentoo = /Gentoo/i.test(navigator.userAgent);
var iscentos = /CentOS/i.test(navigator.userAgent); var iscentos = /CentOS/i.test(navigator.userAgent);
var issuse = /SUSE/i.test(navigator.userAgent); var issuse = /SUSE/i.test(navigator.userAgent);
if(!(ismobile) && !(iswindows) && !(ismac) && !(isubuntu) && !(isfedora) && !(isredhat) && !(isdebian) && !(isgentoo) && !(iscentos) if(!(ismobile) && !(iswindows) && !(ismac) && !(isubuntu) && !(isfedora) && !(isredhat) && !(isdebian) && !(isgentoo) && !(iscentos)
&& !(issuse)){ && !(issuse)){
window.location.href = '".$config['homeurl'].'index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$this->id."'; window.location.href = '".$config['homeurl'].'index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$this->id."';
@ -256,10 +274,9 @@ class Agent
SECONDS_1DAY, SECONDS_1DAY,
'', '',
true, true,
false,
true, true,
1, 500,
'' 1
); );
$html .= '</div>'; $html .= '</div>';
$html .= '</div>'; $html .= '</div>';

View File

@ -1,15 +1,33 @@
<?php <?php
// Pandora FMS - http://pandorafms.com // phpcs:disable Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
// ================================================== /**
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas * Agents list view for mobile
// Please see http://pandorafms.org for full contribution list *
// This program is free software; you can redistribute it and/or * @category Mobile
// modify it under the terms of the GNU General Public License * @package Pandora FMS
// as published by the Free Software Foundation for version 2. * @subpackage Community
// This program is distributed in the hope that it will be useful, * @version 1.0.0
// but WITHOUT ANY WARRANTY; without even the implied warranty of * @license See below
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
// GNU General Public License for more details. * ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2022 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/
// Begin.
class Agents class Agents
{ {
@ -67,7 +85,7 @@ class Agents
$listAgents = $this->getListAgents($page, true); $listAgents = $this->getListAgents($page, true);
if (!empty($listAgents['agents'])) { if (empty($listAgents['agents']) === false) {
$end = 0; $end = 0;
$agents = []; $agents = [];
@ -96,7 +114,7 @@ class Agents
$system = System::getInstance(); $system = System::getInstance();
$user = User::getInstance(); $user = User::getInstance();
// Default // Default.
$filters = [ $filters = [
'free_search' => '', 'free_search' => '',
'status' => -1, 'status' => -1,
@ -104,7 +122,7 @@ class Agents
]; ];
$serialized_filters = (string) $system->getRequest('agents_filter'); $serialized_filters = (string) $system->getRequest('agents_filter');
if (!empty($serialized_filters)) { if (empty($serialized_filters) === true) {
$filters_unsafe = json_decode(base64_decode($serialized_filters, true), true); $filters_unsafe = json_decode(base64_decode($serialized_filters, true), true);
if ($filters_unsafe) { if ($filters_unsafe) {
$filters = $system->safeInput($filters_unsafe); $filters = $system->safeInput($filters_unsafe);
@ -144,8 +162,8 @@ class Agents
$filters['group'] = $this->group; $filters['group'] = $this->group;
} }
if (!empty($filters)) { if (empty($filters) === false) {
// Store the filter // Store the filter.
$this->serializedFilters = base64_encode(json_encode($system->safeOutput($filters))); $this->serializedFilters = base64_encode(json_encode($system->safeOutput($filters)));
} }
} }
@ -260,7 +278,7 @@ class Agents
$search_sql = ''; $search_sql = '';
if (!empty($this->free_search)) { if (empty($this->free_search) === false) {
$search_sql = " AND ( $search_sql = " AND (
alias LIKE '%".$this->free_search."%' alias LIKE '%".$this->free_search."%'
OR nombre LIKE '%".$this->free_search."%' OR nombre LIKE '%".$this->free_search."%'
@ -461,15 +479,13 @@ class Agents
"<script type=\"text/javascript\"> "<script type=\"text/javascript\">
var load_more_rows = 1; var load_more_rows = 1;
var page = 1; var page = 1;
function custom_scroll() { function custom_scroll() {
if (load_more_rows) { if (load_more_rows) {
if ($(this).scrollTop() + $(this).height() if ($(this).scrollTop() + $(this).height()
>= ($(document).height() - 100)) { >= ($(document).height() - 100)) {
load_more_rows = 0; load_more_rows = 0;
postvars = {}; postvars = {};
postvars[\"action\"] = \"ajax\"; postvars[\"action\"] = \"ajax\";
postvars[\"parameter1\"] = \"agents\"; postvars[\"parameter1\"] = \"agents\";
@ -479,7 +495,7 @@ class Agents
postvars[\"free_search\"] = $(\"input[name='free_search']\").val(); postvars[\"free_search\"] = $(\"input[name='free_search']\").val();
postvars[\"page\"] = page; postvars[\"page\"] = page;
page++; page++;
$.post(\"index.php\", $.post(\"index.php\",
postvars, postvars,
function (data) { function (data) {
@ -499,23 +515,26 @@ class Agents
\"<td class='cell_6'>\" + agent[8] + \"</td>\" + \"<td class='cell_6'>\" + agent[8] + \"</td>\" +
\"</tr>\"); \"</tr>\");
}); });
load_more_rows = 1; load_more_rows = 1;
refresh_link_listener_list_agents(); refresh_link_listener_list_agents();
} }
}, },
\"json\"); \"json\");
// Clean
$('#loading_rows').remove();
} }
} }
} }
$(document).ready(function() { $(document).ready(function() {
// Be sure of fill all of screen first.
custom_scroll();
$(window).bind(\"scroll\", function () { $(window).bind(\"scroll\", function () {
custom_scroll(); custom_scroll();
}); });
$(window).on(\"touchmove\", function(event) { $(window).on(\"touchmove\", function(event) {
custom_scroll(); custom_scroll();
}); });

View File

@ -1,15 +1,33 @@
<?php <?php
// Pandora FMS - http://pandorafms.com // phpcs:disable Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
// ================================================== /**
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas * Alerts list view for mobile
// Please see http://pandorafms.org for full contribution list *
// This program is free software; you can redistribute it and/or * @category Mobile
// modify it under the terms of the GNU General Public License * @package Pandora FMS
// as published by the Free Software Foundation for version 2. * @subpackage Community
// This program is distributed in the hope that it will be useful, * @version 1.0.0
// but WITHOUT ANY WARRANTY; without even the implied warranty of * @license See below
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
// GNU General Public License for more details. * ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2022 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/
// Begin.
class Alerts class Alerts
{ {

View File

@ -1,15 +1,33 @@
<?php <?php
// Pandora FMS - http://pandorafms.com // phpcs:disable Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
// ================================================== /**
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas * Modules list view for mobile
// Please see http://pandorafms.org for full contribution list *
// This program is free software; you can redistribute it and/or * @category Mobile
// modify it under the terms of the GNU General Public License * @package Pandora FMS
// as published by the Free Software Foundation for version 2. * @subpackage Community
// This program is distributed in the hope that it will be useful, * @version 1.0.0
// but WITHOUT ANY WARRANTY; without even the implied warranty of * @license See below
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
// GNU General Public License for more details. * ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2022 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/
// Begin.
class Modules class Modules
{ {
@ -106,7 +124,7 @@ class Modules
} }
if (isset($filters['status'])) { if (isset($filters['status'])) {
$this->status = $filters['status']; $this->status = (int) $filters['status'];
} }
if (isset($filters['name'])) { if (isset($filters['name'])) {
@ -143,7 +161,7 @@ class Modules
} }
$this->status = $system->getRequest('status', __('Status')); $this->status = $system->getRequest('status', __('Status'));
if (($this->status === __('Status')) || ($this->status == AGENT_MODULE_STATUS_ALL)) { if (($this->status === __('Status')) || ((int) $this->status === AGENT_MODULE_STATUS_ALL)) {
$this->status = AGENT_MODULE_STATUS_ALL; $this->status = AGENT_MODULE_STATUS_ALL;
} else { } else {
$this->default = false; $this->default = false;
@ -390,35 +408,28 @@ class Modules
} }
// Part SQL fro Status // Part SQL fro Status
if ($this->status == AGENT_MODULE_STATUS_NORMAL) { if ((int) $this->status == AGENT_MODULE_STATUS_NORMAL) {
// Normal // Normal.
$sql_conditions .= ' AND tagente_estado.estado = 0 $sql_conditions .= ' AND tagente_estado.estado = 0
AND (utimestamp > 0 OR (tagente_modulo.id_tipo_modulo IN(21,22,23,100))) '; AND (utimestamp > 0 OR (tagente_modulo.id_tipo_modulo IN(21,22,23,100))) ';
} else if ($this->status == AGENT_MODULE_STATUS_CRITICAL_BAD) { } else if ((int) $this->status === AGENT_MODULE_STATUS_CRITICAL_BAD) {
// Critical // Critical.
$sql_conditions .= ' AND tagente_estado.estado = 1 AND utimestamp > 0'; $sql_conditions .= ' AND tagente_estado.estado = 1 AND utimestamp > 0';
} else if ($this->status == AGENT_MODULE_STATUS_WARNING) { } else if ((int) $this->status === AGENT_MODULE_STATUS_WARNING) {
// Warning // Warning.
$sql_conditions .= ' AND tagente_estado.estado = 2 AND utimestamp > 0'; $sql_conditions .= ' AND tagente_estado.estado = 2 AND utimestamp > 0';
} else if ($this->status == AGENT_MODULE_STATUS_NOT_NORMAL) { } else if ((int) $this->status === AGENT_MODULE_STATUS_NOT_NORMAL) {
// Not normal // Not normal.
$sql_conditions .= ' AND tagente_estado.estado <> 0'; $sql_conditions .= ' AND tagente_estado.estado <> 0';
} else if ($this->status == AGENT_MODULE_STATUS_UNKNOWN) { } else if ((int) $this->status === AGENT_MODULE_STATUS_UNKNOWN) {
// Unknown // Unknown.
$sql_conditions .= ' AND tagente_estado.estado = 3 AND tagente_estado.utimestamp <> 0'; $sql_conditions .= ' AND tagente_estado.estado = 3 AND tagente_estado.utimestamp <> 0';
} else if ($this->status == AGENT_MODULE_STATUS_NOT_INIT) { } else if ((int) $this->status === AGENT_MODULE_STATUS_NOT_INIT) {
// Not init // Not init.
$sql_conditions .= ' AND tagente_estado.utimestamp = 0 $sql_conditions .= ' AND tagente_estado.utimestamp = 0
AND tagente_modulo.id_tipo_modulo NOT IN (21,22,23,100)'; AND tagente_modulo.id_tipo_modulo NOT IN (21,22,23,100)';
} }
if ($this->status != AGENT_MODULE_STATUS_NOT_INIT) {
// When filter is not "not init"
// Not show not init modules. It's only operation view
$sql_conditions .= ' AND (tagente_estado.utimestamp != 0
OR tagente_modulo.id_tipo_modulo IN (21,22,23,100))';
}
if ($this->tag > 0) { if ($this->tag > 0) {
$sql_conditions .= ' AND tagente_modulo.id_agente_modulo IN ( $sql_conditions .= ' AND tagente_modulo.id_agente_modulo IN (
SELECT ttag_module.id_agente_modulo SELECT ttag_module.id_agente_modulo
@ -435,7 +446,7 @@ class Modules
SELECT ttag_module.id_tag SELECT ttag_module.id_tag
FROM ttag_module FROM ttag_module
WHERE ttag_module.id_agente_modulo = tagente_modulo.id_agente_modulo)) WHERE ttag_module.id_agente_modulo = tagente_modulo.id_agente_modulo))
AS tags, AS tags,
tagente_modulo.id_agente_modulo, tagente_modulo.id_agente_modulo,
tagente.intervalo AS agent_interval, tagente.intervalo AS agent_interval,
tagente.nombre AS agent_name, tagente.nombre AS agent_name,
@ -476,6 +487,7 @@ class Modules
ON ttag_module.id_agente_modulo = tagente_modulo.id_agente_modulo'.$sql_conditions_all; ON ttag_module.id_agente_modulo = tagente_modulo.id_agente_modulo'.$sql_conditions_all;
$sql_limit = 'ORDER BY tagente.nombre ASC '; $sql_limit = 'ORDER BY tagente.nombre ASC ';
if (!$this->all_modules) { if (!$this->all_modules) {
$sql_limit = ' LIMIT '.(int) ($page * $system->getPageSize()).','.(int) $system->getPageSize(); $sql_limit = ' LIMIT '.(int) ($page * $system->getPageSize()).','.(int) $system->getPageSize();
} }

View File

@ -108,5 +108,6 @@ filemanager_file_explorer(
'', '',
false, false,
'', '',
false false,
['all' => true]
); );

View File

@ -329,7 +329,7 @@ html_print_image(
echo "<div id='tree-controller-recipient'>"; echo "<div id='tree-controller-recipient'>";
echo '</div>'; echo '</div>';
if (is_metaconsole()) { if (is_metaconsole() === true) {
echo '</div>'; echo '</div>';
} }
@ -337,7 +337,7 @@ enterprise_hook('close_meta_frame');
?> ?>
<?php if (!is_metaconsole()) { ?> <?php if (is_metaconsole() === false) { ?>
<script type="text/javascript" src="include/javascript/fixed-bottom-box.js"></script> <script type="text/javascript" src="include/javascript/fixed-bottom-box.js"></script>
<?php } else { ?> <?php } else { ?>
<script type="text/javascript" src="../../include/javascript/fixed-bottom-box.js"></script> <script type="text/javascript" src="../../include/javascript/fixed-bottom-box.js"></script>
@ -347,12 +347,12 @@ enterprise_hook('close_meta_frame');
var treeController = TreeController.getController(); var treeController = TreeController.getController();
processTreeSearch(); processTreeSearch();
$("form#tree_search").submit(function(e) { $("form#tree_search").submit(function(e) {
e.preventDefault(); e.preventDefault();
processTreeSearch(); processTreeSearch();
}); });
function processTreeSearch () { function processTreeSearch () {
// Clear the tree // Clear the tree
if (typeof treeController.recipient != 'undefined' && treeController.recipient.length > 0) if (typeof treeController.recipient != 'undefined' && treeController.recipient.length > 0)

View File

@ -4226,3 +4226,17 @@ CREATE TABLE IF NOT EXISTS `tncm_firmware` (
`path` TEXT, `path` TEXT,
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; ) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
-- ----------------------------------------------------------------------
-- Table `tbackup`
-- ----------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS `tbackup` (
`id` SERIAL,
`utimestamp` BIGINT DEFAULT 0,
`filename` VARCHAR(512) DEFAULT '',
`id_user` VARCHAR(60) DEFAULT '',
`description` MEDIUMTEXT,
`pid` INT UNSIGNED DEFAULT 0,
`filepath` VARCHAR(512) DEFAULT '',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;