2010-11-23 12:40:24 +01:00
|
|
|
<?php
|
2011-03-22 23:11:57 +01:00
|
|
|
|
2021-11-04 16:28:15 +01:00
|
|
|
// Pandora FMS - http://pandorafms.com
|
2010-11-23 12:40:24 +01:00
|
|
|
// ==================================================
|
2020-11-27 13:52:35 +01:00
|
|
|
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
2010-11-23 12:40:24 +01:00
|
|
|
// Please see http://pandorafms.org for full contribution list
|
|
|
|
// This program is free software; you can redistribute it and/or
|
2011-03-23 Raul Mateos <raulofpandora@gmail.com>
* extensions/ssh_console.php, extensions/vnc_view.php,
extensions/update_manager.php, extensions/users_connected.php,
extensions/extension_uploader.php, extensions/insert_data.php,
extensions/module_groups.php, extensions/plugin_registration.php,
extensions/agent_modules.php, extensions/resource_registration.php,
extensions/resource_exportation.php, extensions/dbmanager.php,
extensions/pandora_logs.php, general/*.php, ajax.php,
operation/search_*.php, operation/menu.php, operation/extensions.php,
godmode/menu.php, godmode/extensions.php, godmode/admin_access_logs.php:
CReverted unwanted license changes.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4126 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2011-03-23 17:13:28 +01:00
|
|
|
// modify it under the terms of the GNU General Public License
|
2011-03-22 23:11:57 +01:00
|
|
|
// as published by the Free Software Foundation; version 2
|
2010-11-23 12:40:24 +01:00
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2011-03-22 23:11:57 +01:00
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2010-11-23 12:40:24 +01:00
|
|
|
// GNU General Public License for more details.
|
2019-01-30 16:18:44 +01:00
|
|
|
function extension_uploader_extensions()
|
|
|
|
{
|
|
|
|
global $config;
|
|
|
|
|
|
|
|
if (!check_acl($config['id_user'], 0, 'PM')) {
|
|
|
|
db_pandora_audit(
|
2022-01-20 10:55:23 +01:00
|
|
|
AUDIT_LOG_ACL_VIOLATION,
|
2019-01-30 16:18:44 +01:00
|
|
|
'Trying to access Group Management'
|
|
|
|
);
|
|
|
|
include 'general/noaccess.php';
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-03-09 15:14:47 +01:00
|
|
|
// Header.
|
|
|
|
ui_print_standard_header(
|
|
|
|
__('Extensions'),
|
2019-01-30 16:18:44 +01:00
|
|
|
'images/extensions.png',
|
|
|
|
false,
|
|
|
|
'',
|
|
|
|
true,
|
2023-03-09 15:14:47 +01:00
|
|
|
[],
|
|
|
|
[
|
|
|
|
[
|
|
|
|
'link' => '',
|
|
|
|
'label' => __('Admin tools'),
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'link' => '',
|
|
|
|
'label' => __('Extension manager'),
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'link' => '',
|
|
|
|
'label' => __('Uploader extension'),
|
|
|
|
],
|
|
|
|
]
|
2019-01-30 16:18:44 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
$upload = (bool) get_parameter('upload', 0);
|
|
|
|
$upload_enteprise = (bool) get_parameter('upload_enterprise', 0);
|
|
|
|
|
|
|
|
if ($upload) {
|
|
|
|
$error = $_FILES['extension']['error'];
|
|
|
|
|
|
|
|
if ($error == 0) {
|
|
|
|
$zip = new ZipArchive;
|
2010-11-23 12:40:24 +01:00
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
$tmpName = $_FILES['extension']['tmp_name'];
|
|
|
|
|
|
|
|
if ($upload_enteprise) {
|
|
|
|
$pathname = $config['homedir'].'/'.ENTERPRISE_DIR.'/'.EXTENSIONS_DIR.'/';
|
|
|
|
} else {
|
|
|
|
$pathname = $config['homedir'].'/'.EXTENSIONS_DIR.'/';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($zip->open($tmpName) === true) {
|
|
|
|
$result = $zip->extractTo($pathname);
|
|
|
|
} else {
|
|
|
|
$result = false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$result = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($result) {
|
2022-01-20 10:55:23 +01:00
|
|
|
db_pandora_audit(
|
|
|
|
AUDIT_LOG_EXTENSION_MANAGER,
|
|
|
|
'Upload extension '.$_FILES['extension']['name']
|
|
|
|
);
|
2019-01-30 16:18:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ui_print_result_message(
|
|
|
|
$result,
|
|
|
|
__('Success to upload extension'),
|
|
|
|
__('Fail to upload extension')
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-01-12 14:22:16 +01:00
|
|
|
$table = new stdClass();
|
2019-01-30 16:18:44 +01:00
|
|
|
|
|
|
|
$table->width = '100%';
|
2023-03-09 15:14:47 +01:00
|
|
|
$table->class = 'databox filters filter-table-adv';
|
|
|
|
$table->size[0] = '20%';
|
|
|
|
$table->size[1] = '20%';
|
|
|
|
$table->size[2] = '60%';
|
2019-01-30 16:18:44 +01:00
|
|
|
$table->data = [];
|
2023-03-09 15:14:47 +01:00
|
|
|
|
|
|
|
$table->data[0][0] = html_print_label_input_block(
|
|
|
|
__('Upload extension').ui_print_help_tip(__('Upload the extension as a zip file.'), true),
|
|
|
|
html_print_input_file(
|
|
|
|
'extension',
|
|
|
|
true,
|
|
|
|
[
|
|
|
|
'required' => true,
|
|
|
|
'accept' => '.zip',
|
|
|
|
]
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
if (enterprise_installed()) {
|
2023-03-09 15:14:47 +01:00
|
|
|
$table->data[0][1] = html_print_label_input_block(
|
|
|
|
__('Upload enterprise extension'),
|
|
|
|
html_print_checkbox(
|
|
|
|
'upload_enterprise',
|
|
|
|
1,
|
|
|
|
false,
|
|
|
|
true
|
|
|
|
)
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
$table->data[0][1] = '';
|
2019-01-30 16:18:44 +01:00
|
|
|
}
|
|
|
|
|
2023-03-09 15:14:47 +01:00
|
|
|
$table->data[0][2] = '';
|
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
echo "<form method='post' enctype='multipart/form-data'>";
|
|
|
|
html_print_table($table);
|
|
|
|
html_print_input_hidden('upload', 1);
|
2023-03-09 15:14:47 +01:00
|
|
|
html_print_action_buttons(
|
|
|
|
html_print_submit_button(
|
|
|
|
__('Upload'),
|
|
|
|
'submit',
|
|
|
|
false,
|
|
|
|
['icon' => 'wand'],
|
|
|
|
true
|
|
|
|
)
|
|
|
|
);
|
2019-01-30 16:18:44 +01:00
|
|
|
echo '</form>';
|
2010-11-23 12:40:24 +01:00
|
|
|
}
|
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
|
|
|
|
extensions_add_godmode_menu_option(__('Extension uploader'), 'PM', null, null, 'v1r1');
|
2011-05-11 14:15:14 +02:00
|
|
|
extensions_add_godmode_function('extension_uploader_extensions');
|