Merge branch 'ent-12333-anadir-tablas-dinamicas-a-pandoradb-sql' into 'develop'
move extension translate_string and file_repo pandora_enterprise#12333 See merge request artica/pandorafms!6706
This commit is contained in:
commit
9158b43945
|
@ -1,286 +0,0 @@
|
|||
<?php
|
||||
|
||||
// Pandora FMS - https://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2023 Pandora FMS
|
||||
// Please see https://pandorafms.com/community/ for full contribution list
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; version 2
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
function pandora_files_repo_install()
|
||||
{
|
||||
global $config;
|
||||
|
||||
if (isset($config['files_repo_installed']) && $config['files_repo_installed'] == 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
$full_extensions_dir = $config['homedir'].'/'.EXTENSIONS_DIR.'/';
|
||||
$full_sql_dir = $full_extensions_dir.'files_repo/sql/';
|
||||
|
||||
$file_path = '';
|
||||
switch ($config['dbtype']) {
|
||||
case 'mysql':
|
||||
$file_path = $full_sql_dir.'files_repo.sql';
|
||||
break;
|
||||
|
||||
case 'postgresql':
|
||||
$file_path = $full_sql_dir.'files_repo.postgreSQL.sql';
|
||||
break;
|
||||
|
||||
case 'oracle':
|
||||
$file_path = $full_sql_dir.'files_repo.oracle.sql';
|
||||
break;
|
||||
}
|
||||
|
||||
if (!empty($file_path)) {
|
||||
$result = db_process_file($file_path);
|
||||
|
||||
if ($result) {
|
||||
// Configuration values
|
||||
$values = [
|
||||
'token' => 'files_repo_installed',
|
||||
'value' => 1,
|
||||
];
|
||||
db_process_sql_insert('tconfig', $values);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function pandora_files_repo_uninstall()
|
||||
{
|
||||
global $config;
|
||||
|
||||
switch ($config['dbtype']) {
|
||||
case 'mysql':
|
||||
db_process_sql('DROP TABLE `tfiles_repo_group`');
|
||||
db_process_sql('DROP TABLE `tfiles_repo`');
|
||||
db_process_sql(
|
||||
'DELETE FROM `tconfig`
|
||||
WHERE `token` LIKE "files_repo_%"'
|
||||
);
|
||||
break;
|
||||
|
||||
case 'postgresql':
|
||||
db_process_sql('DROP TABLE "tfiles_repo_group"');
|
||||
db_process_sql('DROP TABLE "tfiles_repo"');
|
||||
db_process_sql(
|
||||
'DELETE FROM "tconfig"
|
||||
WHERE "token" LIKE \'files_repo_%\''
|
||||
);
|
||||
break;
|
||||
|
||||
case 'oracle':
|
||||
db_process_sql('DROP TRIGGER "tfiles_repo_group_inc"');
|
||||
db_process_sql('DROP SEQUENCE "tfiles_repo_group_s"');
|
||||
db_process_sql('DROP TABLE "tfiles_repo_group"');
|
||||
db_process_sql('DROP TRIGGER "tfiles_repo_inc"');
|
||||
db_process_sql('DROP SEQUENCE "tfiles_repo_s"');
|
||||
db_process_sql('DROP TABLE "tfiles_repo"');
|
||||
db_process_sql(
|
||||
'DELETE FROM tconfig
|
||||
WHERE token LIKE \'files_repo_%\''
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!empty($config['attachment_store'])) {
|
||||
delete_dir($config['attachment_store'].'/files_repo');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function pandora_files_repo_godmode()
|
||||
{
|
||||
global $config;
|
||||
|
||||
if (!isset($config['files_repo_installed']) || !$config['files_repo_installed']) {
|
||||
ui_print_error_message(__('Extension not installed'));
|
||||
}
|
||||
|
||||
// ACL Check
|
||||
check_login();
|
||||
if (! check_acl($config['id_user'], 0, 'PM')) {
|
||||
db_pandora_audit(
|
||||
AUDIT_LOG_ACL_VIOLATION,
|
||||
'Trying to access to Files repository'
|
||||
);
|
||||
include 'general/noaccess.php';
|
||||
return;
|
||||
}
|
||||
|
||||
// Header tabs.
|
||||
$godmode['text'] = '<a href="index.php?sec=godmode/extensions&sec2=extensions/files_repo">'.html_print_image('images/configuration@svg.svg', true, ['title' => __('Administration view'), 'class' => 'main_menu_icon invert_filter']).'</a>';
|
||||
$godmode['godmode'] = 1;
|
||||
$godmode['active'] = 1;
|
||||
|
||||
$operation['text'] = '<a href="index.php?sec=extensions&sec2=extensions/files_repo">'.html_print_image('images/see-details@svg.svg', true, ['title' => __('Operation view'), 'class' => 'main_menu_icon invert_filter']).'</a>';
|
||||
$operation['operation'] = 1;
|
||||
|
||||
$onheader = [
|
||||
'godmode' => $godmode,
|
||||
'operation' => $operation,
|
||||
];
|
||||
|
||||
// Header.
|
||||
ui_print_standard_header(
|
||||
__('Extensions'),
|
||||
'images/extensions.png',
|
||||
false,
|
||||
'',
|
||||
true,
|
||||
$onheader,
|
||||
[
|
||||
[
|
||||
'link' => '',
|
||||
'label' => __('Admin tools'),
|
||||
],
|
||||
[
|
||||
'link' => '',
|
||||
'label' => __('Extension manager'),
|
||||
],
|
||||
[
|
||||
'link' => '',
|
||||
'label' => __('Files repository manager'),
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$full_extensions_dir = $config['homedir'].'/'.EXTENSIONS_DIR.'/';
|
||||
include_once $full_extensions_dir.'files_repo/functions_files_repo.php';
|
||||
|
||||
// Directory files_repo check.
|
||||
if (!files_repo_check_directory(true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$server_content_length = 0;
|
||||
if (isset($_SERVER['CONTENT_LENGTH'])) {
|
||||
$server_content_length = $_SERVER['CONTENT_LENGTH'];
|
||||
}
|
||||
|
||||
// Check for an anoying error that causes the $_POST and $_FILES arrays.
|
||||
// were empty if the file is larger than the post_max_size.
|
||||
if (intval($server_content_length) > 0 && empty($_POST)) {
|
||||
ui_print_error_message(__('Problem uploading. Please check this PHP runtime variable values: <pre> post_max_size (currently '.ini_get('post_max_size').')</pre>'));
|
||||
}
|
||||
|
||||
// GET and POST parameters.
|
||||
$file_id = (int) get_parameter('file_id');
|
||||
$add_file = (bool) get_parameter('add_file');
|
||||
$update_file = (bool) get_parameter('update_file');
|
||||
$delete_file = (bool) get_parameter('delete');
|
||||
|
||||
// File add or update.
|
||||
if ($add_file || ($update_file && $file_id > 0)) {
|
||||
$groups = get_parameter('groups', []);
|
||||
$public = (bool) get_parameter('public');
|
||||
$description = io_safe_output((string) get_parameter('description'));
|
||||
if (mb_strlen($description, 'UTF-8') > 200) {
|
||||
$description = mb_substr($description, 0, 200, 'UTF-8');
|
||||
}
|
||||
|
||||
$description = io_safe_input($description);
|
||||
|
||||
if ($add_file) {
|
||||
$result = files_repo_add_file('upfile', $description, $groups, $public);
|
||||
} else if ($update_file) {
|
||||
$result = files_repo_update_file($file_id, $description, $groups, $public);
|
||||
$file_id = 0;
|
||||
}
|
||||
|
||||
if ($result['status'] == false) {
|
||||
ui_print_error_message($result['message']);
|
||||
}
|
||||
}
|
||||
|
||||
// File delete.
|
||||
if ($delete_file && $file_id > 0) {
|
||||
$result = files_repo_delete_file($file_id);
|
||||
if ($result !== -1) {
|
||||
ui_print_result_message($result, __('Successfully deleted'), __('Could not be deleted'));
|
||||
}
|
||||
|
||||
$file_id = 0;
|
||||
}
|
||||
|
||||
// FORM.
|
||||
include $full_extensions_dir.'files_repo/files_repo_form.php';
|
||||
if (!$file_id) {
|
||||
// LIST.
|
||||
$manage = true;
|
||||
include $full_extensions_dir.'files_repo/files_repo_list.php';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function pandora_files_repo_operation()
|
||||
{
|
||||
global $config;
|
||||
|
||||
// Header tabs.
|
||||
$onheader = [];
|
||||
if (check_acl($config['id_user'], 0, 'PM')) {
|
||||
$godmode['text'] = '<a href="index.php?sec=godmode/extensions&sec2=extensions/files_repo">'.html_print_image('images/configuration@svg.svg', true, ['title' => __('Administration view'), 'class' => 'main_menu_icon invert_filter']).'</a>';
|
||||
$godmode['godmode'] = 1;
|
||||
|
||||
$operation['text'] = '<a href="index.php?sec=extensions&sec2=extensions/files_repo">'.html_print_image('images/see-details@svg.svg', true, ['title' => __('Operation view'), 'class' => 'main_menu_icon invert_filter']).'</a>';
|
||||
$operation['operation'] = 1;
|
||||
$operation['active'] = 1;
|
||||
|
||||
$onheader = [
|
||||
'godmode' => $godmode,
|
||||
'operation' => $operation,
|
||||
];
|
||||
}
|
||||
|
||||
// Header.
|
||||
ui_print_standard_header(
|
||||
__('Files repository'),
|
||||
'images/extensions.png',
|
||||
false,
|
||||
'',
|
||||
false,
|
||||
$onheader,
|
||||
[
|
||||
[
|
||||
'link' => '',
|
||||
'label' => __('Admin tools'),
|
||||
],
|
||||
[
|
||||
'link' => '',
|
||||
'label' => __('Extension manager'),
|
||||
],
|
||||
[
|
||||
'link' => '',
|
||||
'label' => __('Files repository'),
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$full_extensions_dir = $config['homedir'].'/'.EXTENSIONS_DIR.'/';
|
||||
include_once $full_extensions_dir.'files_repo/functions_files_repo.php';
|
||||
|
||||
// Directory files_repo check.
|
||||
if (!files_repo_check_directory(true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// LIST.
|
||||
$full_extensions_dir = $config['homedir'].'/'.EXTENSIONS_DIR.'/';
|
||||
|
||||
include $full_extensions_dir.'files_repo/files_repo_list.php';
|
||||
}
|
||||
|
||||
|
||||
extensions_add_operation_menu_option(__('Files repository'), null, null, 'v1r1');
|
||||
extensions_add_main_function('pandora_files_repo_operation');
|
||||
extensions_add_godmode_menu_option(__('Files repository manager'), 'PM', null, null, 'v1r1');
|
||||
extensions_add_godmode_function('pandora_files_repo_godmode');
|
||||
|
||||
pandora_files_repo_install();
|
|
@ -1,168 +0,0 @@
|
|||
<?php
|
||||
|
||||
// Pandora FMS - https://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2023 Pandora FMS
|
||||
// Please see https://pandorafms.com/community/ for full contribution list
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; version 2
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
global $config;
|
||||
|
||||
$full_extensions_dir = $config['homedir'].'/'.EXTENSIONS_DIR.'/';
|
||||
require_once $full_extensions_dir.'files_repo/functions_files_repo.php';
|
||||
|
||||
|
||||
|
||||
$offset = (int) get_parameter('offset');
|
||||
$filter = [];
|
||||
$filter['limit'] = $config['block_size'];
|
||||
$filter['offset'] = $offset;
|
||||
$filter['order'] = [
|
||||
'field' => 'id',
|
||||
'order' => 'DESC',
|
||||
];
|
||||
|
||||
$files = files_repo_get_files($filter);
|
||||
|
||||
|
||||
if (!empty($files)) {
|
||||
if (!isset($manage)) {
|
||||
$manage = false;
|
||||
}
|
||||
|
||||
// Pagination
|
||||
if ($manage) {
|
||||
$url = ui_get_full_url('index.php?sec=godmode/extensions&sec2=extensions/files_repo');
|
||||
} else {
|
||||
$url = ui_get_full_url('index.php?sec=extensions&sec2=extensions/files_repo');
|
||||
}
|
||||
|
||||
$total_files = files_repo_get_files(false, true);
|
||||
ui_pagination($total_files, $url, $offset);
|
||||
|
||||
$table = new stdClass();
|
||||
$table->width = '100%';
|
||||
$table->class = 'info_table';
|
||||
$table->style = [];
|
||||
$table->style[1] = 'max-width: 200px;';
|
||||
$table->style[4] = 'text-align: center;';
|
||||
$table->head = [];
|
||||
$table->head[0] = __('Name');
|
||||
$table->head[1] = __('Description');
|
||||
$table->head[2] = __('Size');
|
||||
$table->head[3] = __('Last modification');
|
||||
$table->head[4] = '';
|
||||
$table->data = [];
|
||||
|
||||
foreach ($files as $file_id => $file) {
|
||||
$data = [];
|
||||
|
||||
// Prepare the filename for the get_file.php script
|
||||
$document_root = str_replace(
|
||||
'\\',
|
||||
'/',
|
||||
io_safe_output($_SERVER['DOCUMENT_ROOT'])
|
||||
);
|
||||
$file['location'] = str_replace(
|
||||
'\\',
|
||||
'/',
|
||||
io_safe_output($file['location'])
|
||||
);
|
||||
$relative_path = str_replace($document_root, '', $file['location']);
|
||||
$file_name = explode('/', $file['location']);
|
||||
$file_decoded = $file_name[(count($file_name) - 1)];
|
||||
$file_path = base64_encode($file_decoded);
|
||||
$hash = md5($file_path.$config['server_unique_identifier']);
|
||||
$url = ui_get_full_url(
|
||||
'include/get_file.php?file='.urlencode($file_path).'&hash='.$hash
|
||||
);
|
||||
$date_format = ($config['date_format']) ? io_safe_output($config['date_format']) : 'F j, Y - H:m';
|
||||
|
||||
$data[0] = "<a href=\"$url\" target=\"_blank\">".$file['name'].'</a>';
|
||||
// Name
|
||||
$data[1] = ui_print_truncate_text(
|
||||
$file['description'],
|
||||
'description',
|
||||
true,
|
||||
true
|
||||
);
|
||||
// Description
|
||||
$data[2] = ui_format_filesize($file['size']);
|
||||
// Size
|
||||
$data[3] = date($date_format, $file['mtime']);
|
||||
// Last modification
|
||||
// Public URL
|
||||
$data[4] = '';
|
||||
$table->cellclass[][4] = 'table_action_buttons';
|
||||
if (!empty($file['hash'])) {
|
||||
$public_url = ui_get_full_url(
|
||||
EXTENSIONS_DIR.'/files_repo/files_repo_get_file.php?file='.$file['hash']
|
||||
);
|
||||
$message = __('Copy to clipboard').': Ctrl+C -> Enter';
|
||||
$action = "window.prompt('$message', '$public_url');";
|
||||
$data[4] .= "<a href=\"javascript:;\" onclick=\"$action\">";
|
||||
$data[4] .= html_print_image(
|
||||
'images/world.png',
|
||||
true,
|
||||
['title' => __('Public link')]
|
||||
);
|
||||
// Public link image
|
||||
$data[4] .= '</a> ';
|
||||
}
|
||||
|
||||
$data[4] .= "<a href=\"$url\" target=\"_blank\">";
|
||||
$data[4] .= html_print_image(
|
||||
'images/download.png',
|
||||
true,
|
||||
[
|
||||
'title' => __('Download'),
|
||||
'style' => 'padding:3px',
|
||||
]
|
||||
);
|
||||
// Download image
|
||||
$data[4] .= '</a>';
|
||||
|
||||
if ($manage) {
|
||||
$config_url = ui_get_full_url(
|
||||
'index.php?sec=godmode/extensions&sec2=extensions/files_repo&file_id='.$file_id
|
||||
);
|
||||
$data[4] .= "<a href=\"$config_url\">";
|
||||
$data[4] .= html_print_image(
|
||||
'images/edit.svg',
|
||||
true,
|
||||
[
|
||||
'title' => __('Edit'),
|
||||
'class' => 'main_menu_icon invert_filter',
|
||||
]
|
||||
);
|
||||
// Edit image
|
||||
$data[4] .= '</a>';
|
||||
|
||||
$delete_url = ui_get_full_url(
|
||||
'index.php?sec=godmode/extensions&sec2=extensions/files_repo&delete=1&file_id='.$file_id
|
||||
);
|
||||
$data[4] .= " <a href=\"$delete_url\" onClick=\"if (!confirm('".__('Are you sure?')."')) return false;\">";
|
||||
$data[4] .= html_print_image(
|
||||
'images/delete.svg',
|
||||
true,
|
||||
[
|
||||
'title' => __('Delete'),
|
||||
'class' => 'main_menu_icon invert_filter',
|
||||
]
|
||||
);
|
||||
// Delete image
|
||||
$data[4] .= '</a>';
|
||||
}
|
||||
|
||||
$table->data[] = $data;
|
||||
}
|
||||
|
||||
html_print_table($table);
|
||||
} else {
|
||||
ui_print_info_message(__('No items'));
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
CREATE TABLE tfiles_repo (
|
||||
id NUMBER(5, 0) NOT NULL PRIMARY KEY,
|
||||
name VARCHAR2(255) NOT NULL,
|
||||
description VARCHAR2(500) NULL,
|
||||
hash VARCHAR2(8) NULL
|
||||
);
|
||||
CREATE SEQUENCE tfiles_repo_s INCREMENT BY 1 START WITH 1;
|
||||
CREATE OR REPLACE TRIGGER tfiles_repo_inc BEFORE INSERT ON tfiles_repo REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tfiles_repo_s.nextval INTO :NEW.ID FROM dual; END;;
|
||||
|
||||
CREATE TABLE tfiles_repo_group (
|
||||
id NUMBER(10, 0) NOT NULL PRIMARY KEY,
|
||||
id_file NUMBER(5, 0) NOT NULL REFERENCES tfiles_repo(id) ON DELETE CASCADE,
|
||||
id_group NUMBER(4, 0) NOT NULL
|
||||
);
|
||||
CREATE SEQUENCE tfiles_repo_group_s INCREMENT BY 1 START WITH 1;
|
||||
CREATE OR REPLACE TRIGGER tfiles_repo_group_inc BEFORE INSERT ON tfiles_repo_group REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tfiles_repo_group_s.nextval INTO :NEW.ID FROM dual; END;;
|
|
@ -1,2 +0,0 @@
|
|||
CREATE TABLE "tfiles_repo" ("id" SERIAL NOT NULL PRIMARY KEY, "name" VARCHAR(255) NOT NULL, "description" VARCHAR(500) NULL default '', "hash" VARCHAR(8) NULL default '');
|
||||
CREATE TABLE "tfiles_repo_group" ("id" SERIAL NOT NULL PRIMARY KEY, "id_file" INTEGER NOT NULL REFERENCES tfiles_repo("id") ON DELETE CASCADE, "id_group" INTEGER NOT NULL);
|
|
@ -1,15 +0,0 @@
|
|||
CREATE TABLE IF NOT EXISTS `tfiles_repo` (
|
||||
`id` int(5) unsigned NOT NULL auto_increment,
|
||||
`name` varchar(255) NOT NULL,
|
||||
`description` varchar(500) NULL default '',
|
||||
`hash` varchar(8) NULL default '',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `tfiles_repo_group` (
|
||||
`id` int(10) unsigned NOT NULL auto_increment,
|
||||
`id_file` int(5) unsigned NOT NULL,
|
||||
`id_group` int(4) unsigned NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
FOREIGN KEY (`id_file`) REFERENCES tfiles_repo(`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
|
@ -1720,4 +1720,19 @@ include/functions_integriaims.php
|
|||
include/ajax/integria_incidents.ajax.php
|
||||
enterprise/operation/log/log_source.php
|
||||
enterprise/include/class/LogSource.class.php
|
||||
include/chart_generator.php
|
||||
include/chart_generator.php
|
||||
enterprise/extensions/translate_string.php
|
||||
enterprise/extensions/translate_string/functions.php
|
||||
enterprise/extensions/translate_string/translate_string.oracle.sql
|
||||
enterprise/extensions/translate_string/translate_string.postgresql.sql
|
||||
enterprise/extensions/translate_string/translate_string.sql
|
||||
enterprise/extensions/translate_string
|
||||
extensions/files_repo.php
|
||||
extensions/files_repo/files_repo_form.php
|
||||
extensions/files_repo/files_repo_get_file.php
|
||||
extensions/files_repo/files_repo_list.php
|
||||
extensions/files_repo/functions_files_repo.php
|
||||
extensions/files_repo/sql/files_repo.oracle.sql
|
||||
extensions/files_repo/sql/files_repo.postgreSQL.sql
|
||||
extensions/files_repo/sql/files_repo.sql
|
||||
extensions/files_repo
|
||||
|
|
|
@ -1,5 +1,34 @@
|
|||
START TRANSACTION;
|
||||
|
||||
DELETE FROM `tconfig` WHERE `token` LIKE 'translate_string_extension_installed';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `textension_translate_string` (
|
||||
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`lang` VARCHAR(10) NOT NULL ,
|
||||
`string` TEXT ,
|
||||
`translation` TEXT ,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `lang_index` (`lang`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
|
||||
|
||||
DELETE FROM `tconfig` WHERE `token` LIKE 'files_repo_installed';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `tfiles_repo` (
|
||||
`id` int(5) unsigned NOT NULL auto_increment,
|
||||
`name` varchar(255) NOT NULL,
|
||||
`description` varchar(500) NULL default '',
|
||||
`hash` varchar(8) NULL default '',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `tfiles_repo_group` (
|
||||
`id` int(10) unsigned NOT NULL auto_increment,
|
||||
`id_file` int(5) unsigned NOT NULL,
|
||||
`id_group` int(4) unsigned NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
FOREIGN KEY (`id_file`) REFERENCES tfiles_repo(`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
|
||||
|
||||
ALTER TABLE `tncm_queue`
|
||||
ADD COLUMN `id_agent_data` bigint unsigned AFTER `id_script`;
|
||||
|
||||
|
|
|
@ -0,0 +1,167 @@
|
|||
<?php
|
||||
/**
|
||||
* File repository
|
||||
*
|
||||
* @category Files repository
|
||||
* @package Pandora FMS
|
||||
* @subpackage Enterprise
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2007-2023 Artica Soluciones Tecnologicas, http://www.artica.es
|
||||
* This code is NOT free software. This code is NOT licenced under GPL2 licence
|
||||
* You cannnot redistribute it without written permission of copyright holder.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
global $config;
|
||||
|
||||
// ACL Check.
|
||||
check_login();
|
||||
if (check_acl($config['id_user'], 0, 'PM') === false) {
|
||||
db_pandora_audit(
|
||||
AUDIT_LOG_ACL_VIOLATION,
|
||||
'Trying to access to Files repository'
|
||||
);
|
||||
include 'general/noaccess.php';
|
||||
return;
|
||||
}
|
||||
|
||||
$tab = get_parameter('tab', '');
|
||||
|
||||
$url = 'index.php?sec=extensions&sec2=godmode/files_repo/files_repo';
|
||||
|
||||
// Header tabs.
|
||||
$godmode['text'] = '<a href="'.$url.'&tab=configuration">';
|
||||
$godmode['text'] .= html_print_image(
|
||||
'images/configuration@svg.svg',
|
||||
true,
|
||||
[
|
||||
'title' => __('Administration view'),
|
||||
'class' => 'main_menu_icon invert_filter',
|
||||
]
|
||||
);
|
||||
$godmode['text'] .= '</a>';
|
||||
$godmode['godmode'] = 1;
|
||||
|
||||
$operation['text'] = '<a href="'.$url.'">';
|
||||
$operation['text'] .= html_print_image(
|
||||
'images/see-details@svg.svg',
|
||||
true,
|
||||
[
|
||||
'title' => __('Operation view'),
|
||||
'class' => 'main_menu_icon invert_filter',
|
||||
]
|
||||
);
|
||||
$operation['text'] .= '</a>';
|
||||
$operation['operation'] = 1;
|
||||
|
||||
$operation['active'] = 1;
|
||||
$godmode['active'] = 0;
|
||||
if ($tab === 'configuration') {
|
||||
$godmode['active'] = 1;
|
||||
$operation['active'] = 0;
|
||||
}
|
||||
|
||||
$onheader = [
|
||||
'godmode' => $godmode,
|
||||
'operation' => $operation,
|
||||
];
|
||||
|
||||
// Header.
|
||||
ui_print_standard_header(
|
||||
__('Extensions'),
|
||||
'images/extensions.png',
|
||||
false,
|
||||
'',
|
||||
true,
|
||||
$onheader,
|
||||
[
|
||||
[
|
||||
'link' => '',
|
||||
'label' => __('Tools'),
|
||||
],
|
||||
[
|
||||
'link' => '',
|
||||
'label' => __('Files repository'),
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
require_once __DIR__.'/../../include/functions_files_repository.php';
|
||||
|
||||
// Directory files_repo check.
|
||||
if (files_repo_check_directory() === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
$server_content_length = 0;
|
||||
if (isset($_SERVER['CONTENT_LENGTH'])) {
|
||||
$server_content_length = $_SERVER['CONTENT_LENGTH'];
|
||||
}
|
||||
|
||||
// Check for an anoying error that causes the $_POST and $_FILES arrays.
|
||||
// were empty if the file is larger than the post_max_size.
|
||||
if (intval($server_content_length) > 0 && empty($_POST)) {
|
||||
ui_print_error_message(
|
||||
__('Problem uploading. Please check this PHP runtime variable values: <pre> post_max_size (currently '.ini_get('post_max_size').')</pre>')
|
||||
);
|
||||
}
|
||||
|
||||
// GET and POST parameters.
|
||||
$file_id = (int) get_parameter('file_id');
|
||||
$add_file = (bool) get_parameter('add_file');
|
||||
$update_file = (bool) get_parameter('update_file');
|
||||
$delete_file = (bool) get_parameter('delete');
|
||||
|
||||
// File add or update.
|
||||
if ($add_file === true || ($update_file === true && $file_id > 0)) {
|
||||
$groups = get_parameter('groups', []);
|
||||
$public = (bool) get_parameter('public');
|
||||
$description = io_safe_output((string) get_parameter('description'));
|
||||
if (mb_strlen($description, 'UTF-8') > 200) {
|
||||
$description = mb_substr($description, 0, 200, 'UTF-8');
|
||||
}
|
||||
|
||||
$description = io_safe_input($description);
|
||||
|
||||
if ($add_file === true) {
|
||||
$result = files_repo_add_file('upfile', $description, $groups, $public);
|
||||
} else if ($update_file === true) {
|
||||
$result = files_repo_update_file($file_id, $description, $groups, $public);
|
||||
$file_id = 0;
|
||||
}
|
||||
|
||||
if ($result['status'] == false) {
|
||||
ui_print_error_message($result['message']);
|
||||
} else {
|
||||
if ($add_file === true) {
|
||||
ui_print_success_message(__('Successfully created'));
|
||||
} else if ($update_file === true) {
|
||||
ui_print_success_message(__('Successfully updated'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// File delete.
|
||||
if ($delete_file === true && $file_id > 0) {
|
||||
$result = files_repo_delete_file($file_id);
|
||||
if ($result !== -1) {
|
||||
ui_print_result_message($result, __('Successfully deleted'), __('Could not be deleted'));
|
||||
}
|
||||
|
||||
$file_id = 0;
|
||||
}
|
||||
|
||||
$operation['active'] = 1;
|
||||
if ($tab === 'configuration') {
|
||||
include_once __DIR__.'/files_repo_form.php';
|
||||
} else {
|
||||
include_once __DIR__.'/files_repo_list.php';
|
||||
}
|
|
@ -1,20 +1,27 @@
|
|||
<?php
|
||||
/**
|
||||
* File repository Form
|
||||
*
|
||||
* @category Files repository
|
||||
* @package Pandora FMS
|
||||
* @subpackage Enterprise
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2007-2023 Artica Soluciones Tecnologicas, http://www.artica.es
|
||||
* This code is NOT free software. This code is NOT licenced under GPL2 licence
|
||||
* You cannnot redistribute it without written permission of copyright holder.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
// Pandora FMS - https://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2023 Pandora FMS
|
||||
// Please see https://pandorafms.com/community/ for full contribution list
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; version 2
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
global $config;
|
||||
|
||||
$full_extensions_dir = $config['homedir'].'/'.EXTENSIONS_DIR.'/';
|
||||
require_once $full_extensions_dir.'files_repo/functions_files_repo.php';
|
||||
|
||||
$file = [];
|
||||
$file['name'] = '';
|
||||
|
@ -117,6 +124,10 @@ if ($file_id > 0) {
|
|||
'file_id',
|
||||
$file_id,
|
||||
true
|
||||
).html_print_input_hidden(
|
||||
'update_file',
|
||||
1,
|
||||
true
|
||||
)
|
||||
);
|
||||
} else {
|
||||
|
@ -150,8 +161,8 @@ if ($file_id > 0) {
|
|||
|
||||
$table->data[] = $row;
|
||||
|
||||
$url = ui_get_full_url('index.php?sec=godmode/extensions&sec2=extensions/files_repo');
|
||||
echo "<form method='post' action='$url' enctype='multipart/form-data'>";
|
||||
$url = ui_get_full_url('index.php?sec=extensions&sec2=godmode/files_repo/files_repo');
|
||||
echo '<form method="post" action="'.$url.'" enctype="multipart/form-data">';
|
||||
html_print_table($table);
|
||||
html_print_action_buttons($submit_button);
|
||||
echo '</form>';
|
|
@ -1,54 +1,60 @@
|
|||
<?php
|
||||
/**
|
||||
* Get public file repository.
|
||||
*
|
||||
* @category Files repository
|
||||
* @package Pandora FMS
|
||||
* @subpackage Enterprise
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2007-2023 Artica Soluciones Tecnologicas, http://www.artica.es
|
||||
* This code is NOT free software. This code is NOT licenced under GPL2 licence
|
||||
* You cannnot redistribute it without written permission of copyright holder.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
// Pandora FMS - https://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2023 Pandora FMS
|
||||
// Please see https://pandorafms.com/community/ for full contribution list
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public License
|
||||
// as published by the Free Software Foundation; version 2
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
require_once '../../include/config.php';
|
||||
|
||||
$file_hash = (string) get_parameter('file');
|
||||
|
||||
// Only allow 1 parameter in the request
|
||||
// Only allow 1 parameter in the request.
|
||||
$check_request = (count($_REQUEST) === 1) ? true : false;
|
||||
$check_get = (count($_GET) === 1) ? true : false;
|
||||
$check_post = (count($_POST) === 0) ? true : false;
|
||||
// Only allow the parameter 'file'
|
||||
$check_parameter = (!empty($file_hash)) ? true : false;
|
||||
|
||||
// Only allow the parameter 'file'.
|
||||
$check_parameter = (empty($file_hash) === false) ? true : false;
|
||||
$check_string = (preg_match('/^[0-9a-zA-Z]{8}$/', $file_hash) === 1) ? true : false;
|
||||
|
||||
$checks = ($check_request && $check_get && $check_post && $check_parameter && $check_string);
|
||||
if (!$checks) {
|
||||
throw_error(15);
|
||||
// ERROR
|
||||
}
|
||||
|
||||
// Get the db file row
|
||||
// Get the db file row.
|
||||
$file = db_get_row_filter('tfiles_repo', ['hash' => $file_hash]);
|
||||
if (!$file) {
|
||||
throw_error(10);
|
||||
// ERROR
|
||||
}
|
||||
|
||||
// Case sensitive check
|
||||
// Case sensitive check.
|
||||
$check_hash = ($file['hash'] == $file_hash) ? true : false;
|
||||
if (!$check_hash) {
|
||||
throw_error(10);
|
||||
// ERROR
|
||||
}
|
||||
|
||||
// Get the location
|
||||
// Get the location.
|
||||
$files_repo_path = io_safe_output($config['attachment_store']).'/files_repo';
|
||||
$location = $files_repo_path.'/'.$file['id'].'_'.$file['name'];
|
||||
if (!file_exists($location) || !is_readable($location) || !is_file($location)) {
|
||||
throw_error(5);
|
||||
// ERROR
|
||||
}
|
||||
|
||||
// All checks are fine. Download the file!
|
||||
|
@ -58,6 +64,13 @@ header('Content-Disposition: attachment; filename="'.$file['name'].'"');
|
|||
readfile($location);
|
||||
|
||||
|
||||
/**
|
||||
* Show errors
|
||||
*
|
||||
* @param integer $time Sleep.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function throw_error($time=15)
|
||||
{
|
||||
sleep($time);
|
|
@ -0,0 +1,157 @@
|
|||
<?php
|
||||
/**
|
||||
* File repository List
|
||||
*
|
||||
* @category Files repository
|
||||
* @package Pandora FMS
|
||||
* @subpackage Enterprise
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2007-2023 Artica Soluciones Tecnologicas, http://www.artica.es
|
||||
* This code is NOT free software. This code is NOT licenced under GPL2 licence
|
||||
* You cannnot redistribute it without written permission of copyright holder.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
global $config;
|
||||
|
||||
$offset = (int) get_parameter('offset');
|
||||
$filter = [];
|
||||
$filter['limit'] = $config['block_size'];
|
||||
$filter['offset'] = $offset;
|
||||
$filter['order'] = [
|
||||
'field' => 'id',
|
||||
'order' => 'DESC',
|
||||
];
|
||||
|
||||
$files = files_repo_get_files($filter);
|
||||
|
||||
if (empty($files) === false) {
|
||||
$url = ui_get_full_url('index.php?sec=extensions&sec2=godmode/files_repo/files_repo');
|
||||
|
||||
$total_files = files_repo_get_files(false, true);
|
||||
ui_pagination($total_files, $url, $offset);
|
||||
|
||||
$table = new stdClass();
|
||||
$table->width = '100%';
|
||||
$table->class = 'info_table';
|
||||
$table->style = [];
|
||||
$table->style[1] = 'max-width: 200px;';
|
||||
$table->style[4] = 'text-align: center;';
|
||||
$table->head = [];
|
||||
$table->head[0] = __('Name');
|
||||
$table->head[1] = __('Description');
|
||||
$table->head[2] = __('Size');
|
||||
$table->head[3] = __('Last modification');
|
||||
$table->head[4] = '';
|
||||
$table->data = [];
|
||||
|
||||
foreach ($files as $file_id => $file) {
|
||||
$data = [];
|
||||
// Prepare the filename for the get_file.php script.
|
||||
$document_root = str_replace(
|
||||
'\\',
|
||||
'/',
|
||||
io_safe_output($_SERVER['DOCUMENT_ROOT'])
|
||||
);
|
||||
$file['location'] = str_replace(
|
||||
'\\',
|
||||
'/',
|
||||
io_safe_output($file['location'])
|
||||
);
|
||||
$relative_path = str_replace($document_root, '', $file['location']);
|
||||
$file_name = explode('/', $file['location']);
|
||||
$file_decoded = $file_name[(count($file_name) - 1)];
|
||||
$file_path = base64_encode($file_decoded);
|
||||
$hash = md5($file_path.$config['server_unique_identifier']);
|
||||
$url_get_file = ui_get_full_url(
|
||||
'include/get_file.php?file='.urlencode($file_path).'&hash='.$hash
|
||||
);
|
||||
|
||||
$date_format = (isset($config['date_format']) === true) ? io_safe_output($config['date_format']) : 'F j, Y - H:m';
|
||||
|
||||
$data[0] = '<a href="'.$url_get_file.'" target="_blank">'.$file['name'].'</a>';
|
||||
// Name.
|
||||
$data[1] = ui_print_truncate_text(
|
||||
$file['description'],
|
||||
'description',
|
||||
true,
|
||||
true
|
||||
);
|
||||
// Description.
|
||||
$data[2] = ui_format_filesize($file['size']);
|
||||
// Size.
|
||||
$data[3] = date($date_format, $file['mtime']);
|
||||
// Last modification.
|
||||
// Public URL.
|
||||
$data[4] = '';
|
||||
$table->cellclass[][4] = 'table_action_buttons';
|
||||
if (empty($file['hash']) === false) {
|
||||
$url_get_public_file = ui_get_full_url(
|
||||
'godmode/files_repo/files_repo_get_file.php?file='.$file['hash']
|
||||
);
|
||||
|
||||
$message = __('Copy to clipboard').': Ctrl+C -> Enter';
|
||||
$action = 'window.prompt(\''.$message.'\', \''.$url_get_public_file.'\');';
|
||||
$data[4] .= '<a href="javascript:;" onclick="'.$action.'">';
|
||||
$data[4] .= html_print_image(
|
||||
'images/world.png',
|
||||
true,
|
||||
['title' => __('Public link')]
|
||||
);
|
||||
// Public link image.
|
||||
$data[4] .= '</a> ';
|
||||
}
|
||||
|
||||
$data[4] .= '<a href="'.$url_get_file.'" target="_blank">';
|
||||
$data[4] .= html_print_image(
|
||||
'images/download.png',
|
||||
true,
|
||||
[
|
||||
'title' => __('Download'),
|
||||
'style' => 'padding:3px',
|
||||
]
|
||||
);
|
||||
// Download image.
|
||||
$data[4] .= '</a>';
|
||||
|
||||
$config_url = $url.'&tab=configuration&file_id='.$file_id;
|
||||
$data[4] .= '<a href="'.$config_url.'">';
|
||||
$data[4] .= html_print_image(
|
||||
'images/edit.svg',
|
||||
true,
|
||||
[
|
||||
'title' => __('Edit'),
|
||||
'class' => 'main_menu_icon invert_filter',
|
||||
]
|
||||
);
|
||||
// Edit image.
|
||||
$data[4] .= '</a>';
|
||||
|
||||
$delete_url = $url.'&delete=1&file_id='.$file_id;
|
||||
$data[4] .= '<a href="'.$delete_url.'" onClick="if (!confirm(\''.__('Are you sure?').'\')) return false;">';
|
||||
$data[4] .= html_print_image(
|
||||
'images/delete.svg',
|
||||
true,
|
||||
[
|
||||
'title' => __('Delete'),
|
||||
'class' => 'main_menu_icon invert_filter',
|
||||
]
|
||||
);
|
||||
// Delete image.
|
||||
$data[4] .= '</a>';
|
||||
|
||||
$table->data[] = $data;
|
||||
}
|
||||
|
||||
html_print_table($table);
|
||||
} else {
|
||||
ui_print_info_message(__('No items'));
|
||||
}
|
|
@ -508,6 +508,8 @@ if ($access_console_node === true) {
|
|||
|
||||
enterprise_hook('skins_submenu');
|
||||
|
||||
enterprise_hook('translate_string_submenu');
|
||||
|
||||
$menu_godmode['gsetup']['sub'] = $sub;
|
||||
}
|
||||
}
|
||||
|
@ -711,15 +713,25 @@ if ($access_console_node === true) {
|
|||
}
|
||||
|
||||
if ($access_console_node === true) {
|
||||
// Tools
|
||||
// Tools.
|
||||
$menu_godmode['tools']['text'] = __('Tools');
|
||||
$menu_godmode['tools']['sec2'] = 'operation/extensions';
|
||||
$menu_godmode['tools']['id'] = 'oper-extensions';
|
||||
$sub = [];
|
||||
$sub['operation/agentes/exportdata']['text'] = __('Export data');
|
||||
$sub['operation/agentes/exportdata']['id'] = 'export_data';
|
||||
$sub['extensions/files_repo']['text'] = __('File repository');
|
||||
$sub['extensions/files_repo']['id'] = 'file_repository';
|
||||
|
||||
if (check_acl($config['id_user'], 0, 'RR')
|
||||
|| check_acl($config['id_user'], 0, 'RW')
|
||||
|| check_acl($config['id_user'], 0, 'RM')
|
||||
) {
|
||||
$sub['operation/agentes/exportdata']['text'] = __('Export data');
|
||||
$sub['operation/agentes/exportdata']['id'] = 'export_data';
|
||||
}
|
||||
|
||||
if ((bool) check_acl($config['id_user'], 0, 'PM') === true) {
|
||||
$sub['godmode/files_repo/files_repo']['text'] = __('File repository');
|
||||
$sub['godmode/files_repo/files_repo']['id'] = 'file_repository';
|
||||
}
|
||||
|
||||
$menu_godmode['tools']['sub'] = $sub;
|
||||
|
||||
// About.
|
||||
|
|
|
@ -169,13 +169,21 @@ function extensions_get_extensions($enterprise=false, $rel_path='')
|
|||
$file = readdir($handle);
|
||||
}
|
||||
|
||||
// Load extensions in enterprise directory
|
||||
if (! $enterprise && file_exists($master_dir)) {
|
||||
return array_merge($extensions, extensions_get_extensions(true, $rel_path));
|
||||
if (isset($extensions['ipam.php']) === true) {
|
||||
unset($extensions['ipam.php']);
|
||||
}
|
||||
|
||||
if (isset($extensions['ipam.php'])) {
|
||||
unset($extensions['ipam.php']);
|
||||
if (isset($extensions['translate_string.php']) === true) {
|
||||
unset($extensions['translate_string.php']);
|
||||
}
|
||||
|
||||
if (isset($extensions['files_repo.php']) === true) {
|
||||
unset($extensions['files_repo.php']);
|
||||
}
|
||||
|
||||
// Load extensions in enterprise directory.
|
||||
if (! $enterprise && file_exists($master_dir)) {
|
||||
return array_merge($extensions, extensions_get_extensions(true, $rel_path));
|
||||
}
|
||||
|
||||
return $extensions;
|
||||
|
|
|
@ -1,17 +1,34 @@
|
|||
<?php
|
||||
/**
|
||||
* Functions File repository
|
||||
*
|
||||
* @category Files repository
|
||||
* @package Pandora FMS
|
||||
* @subpackage Enterprise
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2007-2023 Artica Soluciones Tecnologicas, http://www.artica.es
|
||||
* This code is NOT free software. This code is NOT licenced under GPL2 licence
|
||||
* You cannnot redistribute it without written permission of copyright holder.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
// Pandora FMS - https://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2023 Pandora FMS
|
||||
// Please see https://pandorafms.com/community/ for full contribution list
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; version 2
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
function files_repo_check_directory($print_messages=false)
|
||||
global $config;
|
||||
|
||||
|
||||
/**
|
||||
* Check repository writable.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
function files_repo_check_directory()
|
||||
{
|
||||
global $config;
|
||||
|
||||
|
@ -21,11 +38,18 @@ function files_repo_check_directory($print_messages=false)
|
|||
$result = false;
|
||||
$messages = '';
|
||||
|
||||
// attachment/ check
|
||||
if (!is_writable($attachment_path)) {
|
||||
$msg_error = __('Attachment directory is not writable by HTTP Server');
|
||||
$msg_error .= '</h3><p>';
|
||||
$msg_error .= sprintf(
|
||||
__('Please check that the web server has write rights on the %s directory'),
|
||||
$attachment_path
|
||||
);
|
||||
|
||||
// Attachment/ check.
|
||||
if (is_writable($attachment_path) === false) {
|
||||
$messages .= ui_print_error_message(
|
||||
[
|
||||
'message' => __('Attachment directory is not writable by HTTP Server').'</h3>'.'<p>'.sprinf(__('Please check that the web server has write rights on the %s directory'), $attachment_path),
|
||||
'message' => $msg_error,
|
||||
'no_close' => true,
|
||||
'force_style' => 'color: #000000 !important',
|
||||
],
|
||||
|
@ -33,17 +57,17 @@ function files_repo_check_directory($print_messages=false)
|
|||
true
|
||||
);
|
||||
} else {
|
||||
// attachment/agent_packages/ check
|
||||
if (!file_exists($files_repo_path) || !is_writable($files_repo_path)) {
|
||||
// Create the directoty if not exist
|
||||
if (!file_exists($files_repo_path)) {
|
||||
// Attachment/agent_packages/ check.
|
||||
if (file_exists($files_repo_path) === false || is_writable($files_repo_path) === false) {
|
||||
// Create the directoty if not exist.
|
||||
if (file_exists($files_repo_path) === false) {
|
||||
mkdir($files_repo_path);
|
||||
}
|
||||
|
||||
if (!is_writable($files_repo_path)) {
|
||||
if (is_writable($files_repo_path) === false) {
|
||||
$messages .= ui_print_error_message(
|
||||
[
|
||||
'message' => __('Attachment directory is not writable by HTTP Server').'</h3>'.'<p>'.sprintf(__('Please check that the web server has write rights on the %s directory'), $attachment_path),
|
||||
'message' => $msg_error,
|
||||
'no_close' => true,
|
||||
'force_style' => 'color: #000000 !important',
|
||||
],
|
||||
|
@ -58,48 +82,60 @@ function files_repo_check_directory($print_messages=false)
|
|||
}
|
||||
}
|
||||
|
||||
if ($print_messages) {
|
||||
echo $messages;
|
||||
}
|
||||
echo $messages;
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
function files_repo_check_file_acl($file_id, $user_id=false, $file_groups=false, $user_groups=false)
|
||||
{
|
||||
/**
|
||||
* Check acl file
|
||||
*
|
||||
* @param integer $file_id ID.
|
||||
* @param boolean $user_id Users.
|
||||
* @param boolean $file_groups File Groups.
|
||||
* @param boolean $user_groups User Groups.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function files_repo_check_file_acl(
|
||||
$file_id,
|
||||
$user_id=false,
|
||||
$file_groups=false,
|
||||
$user_groups=false
|
||||
) {
|
||||
global $config;
|
||||
|
||||
$result = false;
|
||||
if (!$user_id) {
|
||||
if (empty($user_id) === true) {
|
||||
$user_id = $config['id_user'];
|
||||
}
|
||||
|
||||
if (is_user_admin($user_id)) {
|
||||
if (is_user_admin($user_id) === true) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!$file_groups) {
|
||||
$file_groups = files_repo_get_file_groups($file_id);
|
||||
if (empty($file_groups)) {
|
||||
if (empty($file_groups) === true) {
|
||||
$file_groups = [];
|
||||
}
|
||||
}
|
||||
|
||||
if (in_array(0, $file_groups)) {
|
||||
if (in_array(0, $file_groups) === true) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!$user_groups) {
|
||||
$user_groups = users_get_groups($user_id, false, true);
|
||||
if (empty($user_groups)) {
|
||||
if (empty($user_groups) === true) {
|
||||
$user_groups = [];
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($file_groups as $group_id) {
|
||||
// $user_groups has the id in the array keys
|
||||
if (in_array($group_id, $user_groups)) {
|
||||
// $user_groups has the id in the array keys.
|
||||
if (in_array($group_id, $user_groups) === true) {
|
||||
$result = true;
|
||||
break;
|
||||
}
|
||||
|
@ -109,13 +145,19 @@ function files_repo_check_file_acl($file_id, $user_id=false, $file_groups=false,
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* File groups.
|
||||
*
|
||||
* @param integer $file_id File.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function files_repo_get_file_groups($file_id)
|
||||
{
|
||||
$groups = [];
|
||||
$filter = ['id_file' => $file_id];
|
||||
$result = db_get_all_rows_filter('tfiles_repo_group', $filter, 'id_group');
|
||||
|
||||
if (!empty($result)) {
|
||||
if (empty($result) === false) {
|
||||
foreach ($result as $key => $value) {
|
||||
$groups[] = $value['id_group'];
|
||||
}
|
||||
|
@ -125,13 +167,19 @@ function files_repo_get_file_groups($file_id)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* File user groups.
|
||||
*
|
||||
* @param string $user_id User id.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function files_repo_get_user_groups($user_id)
|
||||
{
|
||||
$groups = [];
|
||||
$filter = ['id_usuario' => $user_id];
|
||||
$result = db_get_all_rows_filter('tusuario_perfil', $filter, 'id_grupo');
|
||||
|
||||
if (!empty($result)) {
|
||||
if (empty($result) === false) {
|
||||
foreach ($result as $key => $value) {
|
||||
$groups[] = $value['id_grupo'];
|
||||
}
|
||||
|
@ -141,7 +189,15 @@ function files_repo_get_user_groups($user_id)
|
|||
}
|
||||
|
||||
|
||||
function files_repo_get_files($filter=false, $count=false)
|
||||
/**
|
||||
* Get files.
|
||||
*
|
||||
* @param array $filter Filters.
|
||||
* @param boolean $count Count.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function files_repo_get_files($filter=[], $count=false)
|
||||
{
|
||||
global $config;
|
||||
|
||||
|
@ -171,9 +227,9 @@ function files_repo_get_files($filter=false, $count=false)
|
|||
$data['name'] = $file['name'];
|
||||
$data['description'] = $file['description'];
|
||||
$data['location'] = $files_repo_path.'/'.$file['id'].'_'.$data['name'];
|
||||
// Size in bytes
|
||||
// Size in bytes.
|
||||
$data['size'] = filesize($data['location']);
|
||||
// Last modification time in unix timestamp
|
||||
// Last modification time in unix timestamp.
|
||||
$data['mtime'] = filemtime($data['location']);
|
||||
$data['groups'] = $file_groups;
|
||||
$data['hash'] = $file['hash'];
|
||||
|
@ -188,6 +244,16 @@ function files_repo_get_files($filter=false, $count=false)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add file.
|
||||
*
|
||||
* @param string $file_input_name Name.
|
||||
* @param string $description Description.
|
||||
* @param array $groups Groups.
|
||||
* @param boolean $public Mode.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function files_repo_add_file($file_input_name='upfile', $description='', $groups=[], $public=false)
|
||||
{
|
||||
global $config;
|
||||
|
@ -210,10 +276,10 @@ function files_repo_add_file($file_input_name='upfile', $description='', $groups
|
|||
$invalid_extensions = '/^(php|php1|php2|php3|php4|php5|php7|php8|phar|phptml|phps)$/i';
|
||||
|
||||
if (preg_match($invalid_extensions, $extension) === 0) {
|
||||
// Replace conflictive characters
|
||||
// Replace conflictive characters.
|
||||
$filename = str_replace([' ', '=', '?', '&'], '_', $filename);
|
||||
$filename = filter_var($filename, FILTER_SANITIZE_URL);
|
||||
// The filename should not be larger than 200 characters
|
||||
// The filename should not be larger than 200 characters.
|
||||
if (mb_strlen($filename, 'UTF-8') > 200) {
|
||||
$filename = mb_substr($filename, 0, 200, 'UTF-8');
|
||||
}
|
||||
|
@ -267,6 +333,16 @@ function files_repo_add_file($file_input_name='upfile', $description='', $groups
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update file.
|
||||
*
|
||||
* @param string $file_id File Name.
|
||||
* @param string $description Description.
|
||||
* @param array $groups Groups.
|
||||
* @param boolean $public Mode.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function files_repo_update_file($file_id, $description='', $groups=[], $public=false)
|
||||
{
|
||||
global $config;
|
||||
|
@ -308,6 +384,13 @@ function files_repo_update_file($file_id, $description='', $groups=[], $public=f
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete File
|
||||
*
|
||||
* @param string $file_id File Name.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
function files_repo_delete_file($file_id)
|
||||
{
|
||||
global $config;
|
|
@ -410,32 +410,14 @@ function __($string /*, variable arguments */)
|
|||
|
||||
global $config;
|
||||
|
||||
if (defined('METACONSOLE')) {
|
||||
enterprise_include_once('meta/include/functions_meta.php');
|
||||
enterprise_include_once('include/functions_setup.php');
|
||||
$tranlateString = call_user_func_array(
|
||||
'get_defined_translation',
|
||||
array_values(func_get_args())
|
||||
);
|
||||
|
||||
$tranlateString = call_user_func_array(
|
||||
'meta_get_defined_translation',
|
||||
array_values(func_get_args())
|
||||
);
|
||||
|
||||
if ($tranlateString !== false) {
|
||||
return $tranlateString;
|
||||
}
|
||||
} else if (enterprise_installed()
|
||||
&& isset($config['translate_string_extension_installed'])
|
||||
&& $config['translate_string_extension_installed'] == 1
|
||||
&& array_key_exists('translate_string.php', $extensions)
|
||||
) {
|
||||
enterprise_include_once('extensions/translate_string/functions.php');
|
||||
|
||||
$tranlateString = call_user_func_array(
|
||||
'get_defined_translation',
|
||||
array_values(func_get_args())
|
||||
);
|
||||
|
||||
if ($tranlateString !== false) {
|
||||
return $tranlateString;
|
||||
}
|
||||
if ($tranlateString !== false) {
|
||||
return $tranlateString;
|
||||
}
|
||||
|
||||
if ($string == '') {
|
||||
|
|
|
@ -82,10 +82,9 @@ if (empty($file) === true || empty($hash) === true || $hash !== md5($file_raw.$c
|
|||
$downloadable_file = $_SERVER['DOCUMENT_ROOT'].'/pandora_console/'.$file;
|
||||
break;
|
||||
|
||||
case 'extensions/files_repo':
|
||||
case 'godmode/files_repo/files_repo':
|
||||
$attachment_path = io_safe_output($config['attachment_store']);
|
||||
$downloadable_file = $attachment_path.'/files_repo/'.$file;
|
||||
// $downloadable_file = $_SERVER['DOCUMENT_ROOT'].'/pandora_console/attachment/files_repo/'.$file;
|
||||
break;
|
||||
|
||||
case 'godmode/servers/plugin':
|
||||
|
|
|
@ -734,24 +734,8 @@ if ($access_console_node === true) {
|
|||
}
|
||||
|
||||
if ($access_console_node === true) {
|
||||
// Rest of options, all with AR privilege (or should events be with incidents?)
|
||||
// ~ if (check_acl ($config['id_user'], 0, "AR")) {
|
||||
// Extensions menu additions.
|
||||
if (is_array($config['extensions'])) {
|
||||
$sub = [];
|
||||
$sub2 = [];
|
||||
|
||||
if (check_acl($config['id_user'], 0, 'RR') || check_acl($config['id_user'], 0, 'RW') || check_acl($config['id_user'], 0, 'RM')) {
|
||||
$sub['operation/agentes/exportdata']['text'] = __('Export data');
|
||||
$sub['operation/agentes/exportdata']['id'] = 'Export_data';
|
||||
$sub['operation/agentes/exportdata']['subsecs'] = ['operation/agentes/exportdata'];
|
||||
}
|
||||
|
||||
if (check_acl($config['id_user'], 0, 'AR') || check_acl($config['id_user'], 0, 'AD') || check_acl($config['id_user'], 0, 'AW')) {
|
||||
$sub['godmode/agentes/planned_downtime.list']['text'] = __('Scheduled downtime');
|
||||
$sub['godmode/agentes/planned_downtime.list']['id'] = 'Scheduled_downtime';
|
||||
}
|
||||
|
||||
foreach ($config['extensions'] as $extension) {
|
||||
// If no operation_menu is a godmode extension.
|
||||
if ($extension['operation_menu'] == '') {
|
||||
|
@ -772,39 +756,19 @@ if ($access_console_node === true) {
|
|||
continue;
|
||||
}
|
||||
|
||||
// Check if was displayed inside other menu.
|
||||
if ($extension['operation_menu']['fatherId'] == '') {
|
||||
if ($extension_menu['name'] == 'Warp update') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$sub[$extension_menu['sec2']]['text'] = $extension_menu['name'];
|
||||
$sub[$extension_menu['sec2']]['id'] = str_replace(' ', '_', $extension_menu['name']);
|
||||
$sub[$extension_menu['sec2']]['refr'] = 0;
|
||||
} else {
|
||||
if (array_key_exists('fatherId', $extension_menu)) {
|
||||
// Check that extension father ID exists previously on the menu.
|
||||
if ((strlen($extension_menu['fatherId']) > 0)) {
|
||||
if (array_key_exists('subfatherId', $extension_menu) && empty($extension_menu['subfatherId']) === false) {
|
||||
if ((strlen($extension_menu['subfatherId']) > 0)) {
|
||||
$menu_operation[$extension_menu['fatherId']]['sub'][$extension_menu['subfatherId']]['sub2'][$extension_menu['sec2']]['text'] = __($extension_menu['name']);
|
||||
$menu_operation[$extension_menu['fatherId']]['sub'][$extension_menu['subfatherId']]['sub2'][$extension_menu['sec2']]['id'] = str_replace(' ', '_', $extension_menu['name']);
|
||||
$menu_operation[$extension_menu['fatherId']]['sub'][$extension_menu['subfatherId']]['sub2'][$extension_menu['sec2']]['refr'] = 0;
|
||||
$menu_operation[$extension_menu['fatherId']]['sub'][$extension_menu['subfatherId']]['sub2'][$extension_menu['sec2']]['icon'] = $extension_menu['icon'];
|
||||
$menu_operation[$extension_menu['fatherId']]['sub'][$extension_menu['subfatherId']]['sub2'][$extension_menu['sec2']]['sec'] = 'extensions';
|
||||
$menu_operation[$extension_menu['fatherId']]['sub'][$extension_menu['subfatherId']]['sub2'][$extension_menu['sec2']]['extension'] = true;
|
||||
$menu_operation[$extension_menu['fatherId']]['sub'][$extension_menu['subfatherId']]['sub2'][$extension_menu['sec2']]['enterprise'] = $extension['enterprise'];
|
||||
$menu_operation[$extension_menu['fatherId']]['hasExtensions'] = true;
|
||||
} else {
|
||||
$menu_operation[$extension_menu['fatherId']]['sub'][$extension_menu['sec2']]['text'] = __($extension_menu['name']);
|
||||
$menu_operation[$extension_menu['fatherId']]['sub'][$extension_menu['sec2']]['id'] = str_replace(' ', '_', $extension_menu['name']);
|
||||
$menu_operation[$extension_menu['fatherId']]['sub'][$extension_menu['sec2']]['refr'] = 0;
|
||||
$menu_operation[$extension_menu['fatherId']]['sub'][$extension_menu['sec2']]['icon'] = $extension_menu['icon'];
|
||||
$menu_operation[$extension_menu['fatherId']]['sub'][$extension_menu['sec2']]['sec'] = 'extensions';
|
||||
$menu_operation[$extension_menu['fatherId']]['sub'][$extension_menu['sec2']]['extension'] = true;
|
||||
$menu_operation[$extension_menu['fatherId']]['sub'][$extension_menu['sec2']]['enterprise'] = $extension['enterprise'];
|
||||
$menu_operation[$extension_menu['fatherId']]['hasExtensions'] = true;
|
||||
}
|
||||
if (array_key_exists('fatherId', $extension_menu)) {
|
||||
// Check that extension father ID exists previously on the menu.
|
||||
if ((strlen($extension_menu['fatherId']) > 0)) {
|
||||
if (array_key_exists('subfatherId', $extension_menu) && empty($extension_menu['subfatherId']) === false) {
|
||||
if ((strlen($extension_menu['subfatherId']) > 0)) {
|
||||
$menu_operation[$extension_menu['fatherId']]['sub'][$extension_menu['subfatherId']]['sub2'][$extension_menu['sec2']]['text'] = __($extension_menu['name']);
|
||||
$menu_operation[$extension_menu['fatherId']]['sub'][$extension_menu['subfatherId']]['sub2'][$extension_menu['sec2']]['id'] = str_replace(' ', '_', $extension_menu['name']);
|
||||
$menu_operation[$extension_menu['fatherId']]['sub'][$extension_menu['subfatherId']]['sub2'][$extension_menu['sec2']]['refr'] = 0;
|
||||
$menu_operation[$extension_menu['fatherId']]['sub'][$extension_menu['subfatherId']]['sub2'][$extension_menu['sec2']]['icon'] = $extension_menu['icon'];
|
||||
$menu_operation[$extension_menu['fatherId']]['sub'][$extension_menu['subfatherId']]['sub2'][$extension_menu['sec2']]['sec'] = 'extensions';
|
||||
$menu_operation[$extension_menu['fatherId']]['sub'][$extension_menu['subfatherId']]['sub2'][$extension_menu['sec2']]['extension'] = true;
|
||||
$menu_operation[$extension_menu['fatherId']]['sub'][$extension_menu['subfatherId']]['sub2'][$extension_menu['sec2']]['enterprise'] = $extension['enterprise'];
|
||||
$menu_operation[$extension_menu['fatherId']]['hasExtensions'] = true;
|
||||
} else {
|
||||
$menu_operation[$extension_menu['fatherId']]['sub'][$extension_menu['sec2']]['text'] = __($extension_menu['name']);
|
||||
$menu_operation[$extension_menu['fatherId']]['sub'][$extension_menu['sec2']]['id'] = str_replace(' ', '_', $extension_menu['name']);
|
||||
|
@ -815,13 +779,20 @@ if ($access_console_node === true) {
|
|||
$menu_operation[$extension_menu['fatherId']]['sub'][$extension_menu['sec2']]['enterprise'] = $extension['enterprise'];
|
||||
$menu_operation[$extension_menu['fatherId']]['hasExtensions'] = true;
|
||||
}
|
||||
} else {
|
||||
$menu_operation[$extension_menu['fatherId']]['sub'][$extension_menu['sec2']]['text'] = __($extension_menu['name']);
|
||||
$menu_operation[$extension_menu['fatherId']]['sub'][$extension_menu['sec2']]['id'] = str_replace(' ', '_', $extension_menu['name']);
|
||||
$menu_operation[$extension_menu['fatherId']]['sub'][$extension_menu['sec2']]['refr'] = 0;
|
||||
$menu_operation[$extension_menu['fatherId']]['sub'][$extension_menu['sec2']]['icon'] = $extension_menu['icon'];
|
||||
$menu_operation[$extension_menu['fatherId']]['sub'][$extension_menu['sec2']]['sec'] = 'extensions';
|
||||
$menu_operation[$extension_menu['fatherId']]['sub'][$extension_menu['sec2']]['extension'] = true;
|
||||
$menu_operation[$extension_menu['fatherId']]['sub'][$extension_menu['sec2']]['enterprise'] = $extension['enterprise'];
|
||||
$menu_operation[$extension_menu['fatherId']]['hasExtensions'] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ~ }
|
||||
}
|
||||
|
||||
$menu_operation['about_operation']['text'] = __('About');
|
||||
|
|
|
@ -4555,4 +4555,26 @@ CREATE TABLE IF NOT EXISTS `tpandora_cve` (
|
|||
`cvss_score` DOUBLE DEFAULT NULL,
|
||||
`cvss_vector` VARCHAR(255) DEFAULT NULL,
|
||||
PRIMARY KEY (`cve_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- Table `tfiles_repo`
|
||||
-- ---------------------------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `tfiles_repo` (
|
||||
`id` int(5) unsigned NOT NULL auto_increment,
|
||||
`name` varchar(255) NOT NULL,
|
||||
`description` varchar(500) NULL default '',
|
||||
`hash` varchar(8) NULL default '',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- Table `tfiles_repo_group`
|
||||
-- ---------------------------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `tfiles_repo_group` (
|
||||
`id` int(10) unsigned NOT NULL auto_increment,
|
||||
`id_file` int(5) unsigned NOT NULL,
|
||||
`id_group` int(4) unsigned NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
FOREIGN KEY (`id_file`) REFERENCES tfiles_repo(`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
|
@ -125,10 +125,10 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES
|
|||
('custom_report_front_logo', 'images/pandora_logo_white.jpg'),
|
||||
('custom_report_front_header', ''),
|
||||
('custom_report_front_footer', ''),
|
||||
('MR', 66),
|
||||
('MR', 67),
|
||||
('identification_reminder', 1),
|
||||
('identification_reminder_timestamp', 0),
|
||||
('current_package', 774),
|
||||
('current_package', 775),
|
||||
('post_process_custom_values', '{"0.00000038580247":"Seconds to months","0.00000165343915":"Seconds to weeks","0.00001157407407":"Seconds to days","0.01666666666667":"Seconds to minutes","0.00000000093132":"Bytes to Gigabytes","0.00000095367432":"Bytes to Megabytes","0.00097656250000":"Bytes to Kilobytes","0.00000001653439":"Timeticks to weeks","0.00000011574074":"Timeticks to days"}'),
|
||||
('custom_docs_logo', 'default_docs.png'),
|
||||
('custom_support_logo', 'default_support.png'),
|
||||
|
|
Loading…
Reference in New Issue