2012-04-02 17:57:48 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
// Pandora FMS - http://pandorafms.com
|
|
|
|
// ==================================================
|
|
|
|
// Copyright (c) 2005-2011 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; 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 update_pandora_check_installation() {
|
|
|
|
global $config;
|
|
|
|
|
|
|
|
$conf_update_pandora = db_get_row('tconfig', 'token', 'update_pandora_conf_url');
|
|
|
|
|
|
|
|
$dir = $config['attachment_store'] . '/update_pandora/';
|
|
|
|
|
|
|
|
if (empty($conf_update_pandora) || !is_dir($dir))
|
|
|
|
return false;
|
|
|
|
else
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
function update_pandora_get_conf() {
|
|
|
|
global $config;
|
|
|
|
|
|
|
|
$conf = array();
|
|
|
|
$row = db_get_row('tconfig', 'token', 'update_pandora_conf_url');
|
|
|
|
$conf['url'] = $row['value'];
|
|
|
|
$row = db_get_row('tconfig', 'token', 'update_pandora_conf_last_installed');
|
|
|
|
$conf['last_installed'] = $row['value'];
|
|
|
|
$row = db_get_row('tconfig', 'token', 'update_pandora_conf_last_contact');
|
|
|
|
$conf['last_contact'] = $row['value'];
|
2012-04-12 13:31:45 +02:00
|
|
|
$row = db_get_row('tconfig', 'token', 'update_pandora_conf_download_mode');
|
|
|
|
$conf['download_mode'] = $row['value'];
|
2012-04-02 17:57:48 +02:00
|
|
|
|
|
|
|
$conf['dir'] = $config['attachment_store'] . '/update_pandora/';
|
|
|
|
|
|
|
|
return $conf;
|
|
|
|
}
|
|
|
|
|
|
|
|
function update_pandora_installation() {
|
|
|
|
global $config;
|
|
|
|
|
2012-04-18 20:39:58 +02:00
|
|
|
$return_var = array('return' => true, 'text' => null);
|
|
|
|
|
2012-04-02 17:57:48 +02:00
|
|
|
$row = db_get_row_filter('tconfig', array('token' => 'update_pandora_conf_url'));
|
|
|
|
|
|
|
|
if (empty($row)) {
|
|
|
|
//The url of update manager.
|
2012-05-24 11:55:56 +02:00
|
|
|
$conf_update_pandora = array('url' => '',
|
2012-04-02 17:57:48 +02:00
|
|
|
'last_installed' => '',
|
2012-04-12 13:31:45 +02:00
|
|
|
'last_contact' => '',
|
2012-05-24 11:55:56 +02:00
|
|
|
'download_mode' => 'wget');
|
2012-04-02 17:57:48 +02:00
|
|
|
|
|
|
|
$values = array('token' => 'update_pandora_conf_url',
|
|
|
|
'value' => $conf_update_pandora['url']);
|
|
|
|
$return = db_process_sql_insert('tconfig', $values);
|
|
|
|
$values = array('token' => 'update_pandora_conf_last_installed',
|
|
|
|
'value' => $conf_update_pandora['last_installed']);
|
|
|
|
$return = db_process_sql_insert('tconfig', $values);
|
|
|
|
$values = array('token' => 'update_pandora_conf_last_contact',
|
|
|
|
'value' => $conf_update_pandora['last_contact']);
|
|
|
|
$return = db_process_sql_insert('tconfig', $values);
|
2012-04-12 13:31:45 +02:00
|
|
|
$values = array('token' => 'update_pandora_conf_download_mode',
|
|
|
|
'value' => $conf_update_pandora['download_mode']);
|
|
|
|
$return = db_process_sql_insert('tconfig', $values);
|
2012-04-02 17:57:48 +02:00
|
|
|
|
2012-04-18 20:39:58 +02:00
|
|
|
if (!$return) {
|
|
|
|
$return_var['return'] = false;
|
|
|
|
$return_var['text'][] = __('Unsuccesful store conf data in DB.');
|
|
|
|
}
|
2012-04-02 17:57:48 +02:00
|
|
|
}
|
|
|
|
|
2012-05-24 11:55:56 +02:00
|
|
|
$dir = $config['attachment_store'] . '/update_pandora/';
|
2012-05-11 13:39:50 +02:00
|
|
|
|
2012-04-02 17:57:48 +02:00
|
|
|
if (!is_dir($dir)) {
|
2012-05-11 13:39:50 +02:00
|
|
|
$return = mkdir($dir);
|
2012-04-02 17:57:48 +02:00
|
|
|
|
2012-04-18 20:39:58 +02:00
|
|
|
if (!$return) {
|
|
|
|
$return_var['return'] = false;
|
|
|
|
$return_var['text'][] = __('Unsuccesful create a dir to save package in Pandora Console');
|
|
|
|
}
|
2012-04-02 17:57:48 +02:00
|
|
|
}
|
2012-04-18 20:39:58 +02:00
|
|
|
|
|
|
|
return $return_var;
|
2012-04-02 17:57:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function update_pandora_update_conf() {
|
|
|
|
global $config;
|
|
|
|
global $conf_update_pandora;
|
|
|
|
|
|
|
|
$values = array('value' => $conf_update_pandora['last_installed']);
|
|
|
|
$return = db_process_sql_update('tconfig', $values,
|
|
|
|
array('token' => 'update_pandora_conf_last_installed'));
|
|
|
|
$values = array('value' => $conf_update_pandora['last_contact']);
|
2012-04-09 17:23:51 +02:00
|
|
|
$return = db_process_sql_update('tconfig', $values,
|
2012-04-02 17:57:48 +02:00
|
|
|
array('token' => 'update_pandora_conf_last_contact'));
|
2012-04-12 13:31:45 +02:00
|
|
|
$values = array('value' => $conf_update_pandora['download_mode']);
|
|
|
|
$return = db_process_sql_update('tconfig', $values,
|
|
|
|
array('token' => 'update_pandora_conf_download_mode'));
|
2012-04-02 17:57:48 +02:00
|
|
|
|
|
|
|
return $return;
|
|
|
|
}
|
|
|
|
|
|
|
|
function update_pandora_get_list_downloaded_packages($mode = 'operation') {
|
|
|
|
global $config;
|
|
|
|
global $conf_update_pandora;
|
|
|
|
|
|
|
|
$dir = dir($conf_update_pandora['dir']);
|
2012-05-11 13:39:50 +02:00
|
|
|
if ($dir === false) {
|
|
|
|
ui_print_error_message(sprintf(
|
|
|
|
__('Error reading the dir of packages in "%s".'), $conf_update_pandora['dir']));
|
|
|
|
return;
|
|
|
|
}
|
2012-04-02 17:57:48 +02:00
|
|
|
|
|
|
|
$packages = array();
|
|
|
|
while (false !== ($entry = $dir->read())) {
|
|
|
|
if (is_file($conf_update_pandora['dir'] . $entry)
|
|
|
|
&& is_readable($conf_update_pandora['dir'] . $entry)) {
|
|
|
|
if (strstr($entry, '.tar.gz') !== false) {
|
|
|
|
if ($mode == 'operation') {
|
|
|
|
$packages[] = $entry;
|
|
|
|
}
|
|
|
|
else {
|
2012-04-12 13:31:45 +02:00
|
|
|
$time_file = date($config["date_format"],
|
|
|
|
filemtime($conf_update_pandora['dir'] . $entry));
|
|
|
|
|
2012-04-02 17:57:48 +02:00
|
|
|
if ($conf_update_pandora['last_installed'] == $entry) {
|
|
|
|
$packages[] = array('name' => $entry,
|
2012-04-12 13:31:45 +02:00
|
|
|
'current' => true,
|
|
|
|
'time' => $time_file);
|
2012-04-02 17:57:48 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
$packages[] = array('name' => $entry,
|
2012-04-12 13:31:45 +02:00
|
|
|
'current' => false,
|
|
|
|
'time' => $time_file);
|
2012-04-02 17:57:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (empty($packages)) {
|
|
|
|
if ($mode == 'operation') {
|
|
|
|
$packages[] = array('name' =>
|
2012-04-13 12:39:28 +02:00
|
|
|
__('There are not downloaded packages in your Pandora Console.'),
|
|
|
|
'time' => '');
|
2012-04-02 17:57:48 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
$packages[] = array('empty' => true, 'name' =>
|
2012-04-13 12:39:28 +02:00
|
|
|
__('There are not downloaded packages in your Pandora Console.'),
|
|
|
|
'time' => '');
|
2012-04-02 17:57:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $packages;
|
|
|
|
}
|
|
|
|
|
|
|
|
function update_pandora_print_javascript() {
|
|
|
|
$extension_php_file = 'extensions/update_pandora';
|
|
|
|
|
|
|
|
?>
|
|
|
|
<script type="text/javascript">
|
|
|
|
var last = 0;
|
|
|
|
$(document).ready(function() {
|
|
|
|
ajax_get_online_package_list();
|
|
|
|
});
|
|
|
|
|
|
|
|
function ajax_get_online_package_list() {
|
|
|
|
var parameters = {};
|
|
|
|
parameters['page'] = "<?php echo $extension_php_file;?>";
|
|
|
|
parameters['get_packages_online'] = 1;
|
|
|
|
parameters['last'] = last;
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
type: 'POST',
|
|
|
|
url: 'ajax.php',
|
|
|
|
data: parameters,
|
|
|
|
dataType: "json",
|
|
|
|
success: function(data) {
|
|
|
|
if (data['correct'] == 1) {
|
|
|
|
var row = $("<tr class='package'></tr>")
|
|
|
|
.append().html('<td>' + data['package'] + '</td>');
|
|
|
|
$("tbody", "#online_packages").append($(row));
|
|
|
|
|
|
|
|
last = data['last'];
|
|
|
|
|
|
|
|
if (data['end'] == 1) {
|
|
|
|
$(".spinner_row", "#online_packages").remove();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ajax_get_online_package_list();
|
|
|
|
}
|
|
|
|
}
|
2012-04-09 17:23:51 +02:00
|
|
|
else {
|
|
|
|
$(".spinner_row", "#online_packages").remove();
|
|
|
|
}
|
2012-04-02 17:57:48 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
|
|
|
|
function update_pandora_print_javascript_admin() {
|
2012-04-09 17:23:51 +02:00
|
|
|
$extension_php_file = 'extensions/update_manager/update_pandora';
|
2012-04-02 17:57:48 +02:00
|
|
|
|
|
|
|
?>
|
|
|
|
<script type="text/javascript">
|
2012-04-12 13:31:45 +02:00
|
|
|
var disabled_download_package = false;
|
2012-04-02 17:57:48 +02:00
|
|
|
var last = 0;
|
2012-04-12 13:31:45 +02:00
|
|
|
|
2012-04-02 17:57:48 +02:00
|
|
|
$(document).ready(function() {
|
|
|
|
ajax_get_online_package_list_admin();
|
|
|
|
|
|
|
|
$("#submit-hide_download_dialog").click (function () {
|
|
|
|
//Better than fill the downloaded packages
|
|
|
|
location.reload();
|
|
|
|
//$("#dialog_download" ).dialog('close');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2012-04-12 13:31:45 +02:00
|
|
|
function delete_package(package) {
|
|
|
|
url = window.location + "&delete_package=1"
|
|
|
|
+ '&package=' + package;
|
|
|
|
|
|
|
|
window.location.replace(url);
|
|
|
|
}
|
|
|
|
|
2012-04-02 17:57:48 +02:00
|
|
|
function ajax_start_install_package(package) {
|
|
|
|
$(".package_name").html(package);
|
|
|
|
|
|
|
|
$("#dialog_download").dialog({
|
|
|
|
resizable: false,
|
|
|
|
draggable: false,
|
|
|
|
modal: true,
|
|
|
|
height: 400,
|
2012-04-13 12:39:28 +02:00
|
|
|
width: 650,
|
2012-04-02 17:57:48 +02:00
|
|
|
overlay: {
|
|
|
|
opacity: 0.5,
|
|
|
|
background: "black"
|
2013-01-31 Miguel de Dios <miguel.dedios@artica.es>
* include/styles/jquery-ui-1.10.0.custom.css,
include/styles/images/ui-*,
include/javascript/jquery.jquery-ui-1.10.0.custom.js,
include/javascript/jquery-1.9.0.js: added the last version of
jquery and jqueryUI.
* godmode/reporting/visual_console_builder.editor.js,
include/ajax/events.php, include/functions_events.php,
include/functions_reporting.php,
include/javascript/pandora_events.js,
include/javascript/jquery.scrollTo.js,
include/javascript/jquery.tablesorter.pager.js,
include/javascript/jquery.tablesorter.js, include/functions_ui.php,
extensions/update_manager/lib/functions.php,
extensions/update_manager/main.php, extensions/agents_alerts.php,
operation/events/events.php, general/login_page.php,
general/logoff.php, general/header.php,
general/login_help_dialog.php: fixes about the new jquery and
jqueryUI version.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7554 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2013-01-31 17:49:08 +01:00
|
|
|
}
|
2012-04-02 17:57:48 +02:00
|
|
|
});
|
|
|
|
$(".ui-dialog-titlebar-close").hide();
|
|
|
|
$("#dialog_download").show();
|
|
|
|
|
|
|
|
$("#title_downloading_update_pandora").hide();
|
2012-04-12 13:31:45 +02:00
|
|
|
$("#title_downloaded_update_pandora").show();
|
2012-04-02 17:57:48 +02:00
|
|
|
$("#title_installing_update_pandora").show();
|
|
|
|
|
|
|
|
install_package(package, package);
|
|
|
|
}
|
|
|
|
|
|
|
|
function ajax_start_download_package(package) {
|
|
|
|
$(".package_name").html(package);
|
|
|
|
|
|
|
|
$("#dialog_download").dialog({
|
|
|
|
resizable: false,
|
2012-04-12 13:31:45 +02:00
|
|
|
draggable: true,
|
2012-04-02 17:57:48 +02:00
|
|
|
modal: true,
|
|
|
|
height: 400,
|
2012-04-13 12:39:28 +02:00
|
|
|
width: 650,
|
2012-04-02 17:57:48 +02:00
|
|
|
overlay: {
|
|
|
|
opacity: 0.5,
|
|
|
|
background: "black"
|
2013-01-31 Miguel de Dios <miguel.dedios@artica.es>
* include/styles/jquery-ui-1.10.0.custom.css,
include/styles/images/ui-*,
include/javascript/jquery.jquery-ui-1.10.0.custom.js,
include/javascript/jquery-1.9.0.js: added the last version of
jquery and jqueryUI.
* godmode/reporting/visual_console_builder.editor.js,
include/ajax/events.php, include/functions_events.php,
include/functions_reporting.php,
include/javascript/pandora_events.js,
include/javascript/jquery.scrollTo.js,
include/javascript/jquery.tablesorter.pager.js,
include/javascript/jquery.tablesorter.js, include/functions_ui.php,
extensions/update_manager/lib/functions.php,
extensions/update_manager/main.php, extensions/agents_alerts.php,
operation/events/events.php, general/login_page.php,
general/logoff.php, general/header.php,
general/login_help_dialog.php: fixes about the new jquery and
jqueryUI version.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7554 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2013-01-31 17:49:08 +01:00
|
|
|
}
|
2012-04-02 17:57:48 +02:00
|
|
|
});
|
|
|
|
$(".ui-dialog-titlebar-close").hide();
|
|
|
|
$("#dialog_download").show();
|
|
|
|
|
|
|
|
var parameters = {};
|
|
|
|
parameters['page'] = "<?php echo $extension_php_file;?>";
|
|
|
|
parameters['download_package'] = 1;
|
|
|
|
parameters['package'] = package;
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
type: 'POST',
|
|
|
|
url: 'ajax.php',
|
|
|
|
data: parameters,
|
|
|
|
dataType: "json",
|
|
|
|
success: function(data) {
|
2012-04-12 13:31:45 +02:00
|
|
|
if (data['correct'] == 1) {
|
|
|
|
if (data['mode'] == 'wget') {
|
|
|
|
disabled_download_package = true;
|
|
|
|
$("#progress_bar_img img").show();
|
|
|
|
install_package(package, data['filename']);
|
|
|
|
}
|
|
|
|
}
|
2012-04-02 17:57:48 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
check_download_package(package);
|
|
|
|
}
|
|
|
|
|
|
|
|
function check_download_package(package) {
|
|
|
|
var parameters = {};
|
|
|
|
parameters['page'] = "<?php echo $extension_php_file;?>";
|
|
|
|
parameters['check_download_package'] = 1;
|
|
|
|
parameters['package'] = package;
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
type: 'POST',
|
|
|
|
url: 'ajax.php',
|
|
|
|
data: parameters,
|
|
|
|
dataType: "json",
|
|
|
|
success: function(data) {
|
2012-04-12 13:31:45 +02:00
|
|
|
if (disabled_download_package)
|
|
|
|
return;
|
|
|
|
|
2012-04-02 17:57:48 +02:00
|
|
|
if (data['correct'] == 1) {
|
2012-04-12 13:31:45 +02:00
|
|
|
if (data['mode'] == 'wget') {
|
|
|
|
$("#info_text").show();
|
|
|
|
$("#info_text").html(data['info_download']);
|
|
|
|
$("#progress_bar_img img").hide();
|
2012-04-02 17:57:48 +02:00
|
|
|
}
|
|
|
|
else {
|
2012-04-12 13:31:45 +02:00
|
|
|
$("#info_text").show();
|
|
|
|
$("#info_text").html(data['info_download']);
|
|
|
|
|
|
|
|
$("#progress_bar_img img").attr('src', data['progres_bar_src']);
|
|
|
|
$("#progress_bar_img img").attr('alt', data['progres_bar_alt']);
|
|
|
|
$("#progress_bar_img img").attr('title', data['progres_bar_title']);
|
|
|
|
|
|
|
|
if (data['percent'] < 100) {
|
|
|
|
check_download_package(package);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
install_package(package, data['filename']);
|
|
|
|
}
|
2012-04-02 17:57:48 +02:00
|
|
|
}
|
|
|
|
}
|
2012-04-09 17:23:51 +02:00
|
|
|
else {
|
|
|
|
$("#title_downloading_update_pandora").hide();
|
|
|
|
$("#title_error_update_pandora").show();
|
|
|
|
$("#progress_bar_img").hide();
|
|
|
|
|
|
|
|
$("#info_text").html('');
|
|
|
|
|
2012-04-13 12:39:28 +02:00
|
|
|
$("#button_close_download_disabled").hide();
|
2012-04-09 17:23:51 +02:00
|
|
|
$("#button_close_download").show();
|
|
|
|
}
|
2012-04-02 17:57:48 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function install_package(package, filename) {
|
|
|
|
var parameters = {};
|
|
|
|
parameters['page'] = "<?php echo $extension_php_file;?>";
|
|
|
|
parameters['install_package'] = 1;
|
|
|
|
parameters['package'] = package;
|
|
|
|
parameters['filename'] = filename;
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
type: 'POST',
|
|
|
|
url: 'ajax.php',
|
|
|
|
data: parameters,
|
|
|
|
dataType: "json",
|
|
|
|
success: function(data) {
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#title_downloading_update_pandora").hide();
|
2012-04-12 13:31:45 +02:00
|
|
|
$("#title_downloaded_update_pandora").show();
|
2012-04-02 17:57:48 +02:00
|
|
|
$("#title_installing_update_pandora").show();
|
|
|
|
|
|
|
|
check_install_package(package, filename);
|
|
|
|
}
|
|
|
|
|
|
|
|
function check_install_package(package, filename) {
|
|
|
|
var parameters = {};
|
|
|
|
parameters['page'] = "<?php echo $extension_php_file;?>";
|
|
|
|
parameters['check_install_package'] = 1;
|
|
|
|
parameters['package'] = package;
|
|
|
|
parameters['filename'] = filename;
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
type: 'POST',
|
|
|
|
url: 'ajax.php',
|
|
|
|
data: parameters,
|
|
|
|
dataType: "json",
|
|
|
|
success: function(data) {
|
|
|
|
if (data['correct'] == 1) {
|
|
|
|
$("#info_text").show();
|
|
|
|
$("#info_text").html(data['info']);
|
|
|
|
$("#list_files_install").scrollTop(
|
|
|
|
$("#list_files_install").attr("scrollHeight"));
|
|
|
|
|
|
|
|
$("#progress_bar_img img").attr('src', data['src']);
|
|
|
|
$("#progress_bar_img img").attr('alt', data['alt']);
|
|
|
|
$("#progress_bar_img img").attr('title', data['title']);
|
|
|
|
|
|
|
|
if (data['percent'] < 100) {
|
|
|
|
check_install_package(package, filename);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$("#title_installing_update_pandora").hide();
|
|
|
|
$("#title_installed_update_pandora").show();
|
2012-04-13 12:39:28 +02:00
|
|
|
$("#button_close_download_disabled").hide();
|
2012-04-02 17:57:48 +02:00
|
|
|
$("#button_close_download").show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
function ajax_get_online_package_list_admin() {
|
2012-04-12 13:31:45 +02:00
|
|
|
var buttonUpdateTemplate = '<?php
|
|
|
|
html_print_button(__('Update'), 'update', false,
|
|
|
|
'ajax_start_download_package(\\\'pandoraFMS\\\');', 'class="sub upd"');
|
|
|
|
?>';
|
|
|
|
|
2012-04-02 17:57:48 +02:00
|
|
|
var parameters = {};
|
|
|
|
parameters['page'] = "<?php echo $extension_php_file;?>";
|
|
|
|
parameters['get_packages_online'] = 1;
|
|
|
|
parameters['last'] = last;
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
type: 'POST',
|
|
|
|
url: 'ajax.php',
|
|
|
|
data: parameters,
|
|
|
|
dataType: "json",
|
|
|
|
success: function(data) {
|
|
|
|
if (data['correct'] == 1) {
|
2012-04-12 13:31:45 +02:00
|
|
|
buttonUpdate = buttonUpdateTemplate.replace('pandoraFMS', data['package']);
|
|
|
|
|
2012-04-02 17:57:48 +02:00
|
|
|
$("tbody", "#online_packages").append(
|
|
|
|
'<tr class="package_' + data['package'] + '">' +
|
2012-04-13 12:39:28 +02:00
|
|
|
'<td style=" text-align:left; width:50%;" valign="top" class="name_package">' +
|
|
|
|
'<?php echo '<b>' . __('There is a new version:') . '</b><br><br> '; ?>' +
|
2012-04-02 17:57:48 +02:00
|
|
|
data['package'] +
|
|
|
|
'</td>' +
|
2012-04-13 12:39:28 +02:00
|
|
|
'<td style=" text-align:left; width:30%;" valign="bottom" class="timestamp_package">' +
|
2012-04-12 13:31:45 +02:00
|
|
|
data['timestamp'] +
|
|
|
|
'</td>' +
|
2012-04-13 12:39:28 +02:00
|
|
|
'<td style=" text-align:center; width:50px;" valign="bottom">' +
|
2012-04-12 13:31:45 +02:00
|
|
|
buttonUpdate +
|
2012-04-02 17:57:48 +02:00
|
|
|
'</td>' +
|
|
|
|
'</tr>');
|
|
|
|
|
|
|
|
last = data['last'];
|
|
|
|
|
|
|
|
if (data['end'] == 1) {
|
|
|
|
$(".spinner_row", "#online_packages").remove();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ajax_get_online_package_list_admin();
|
|
|
|
}
|
|
|
|
}
|
2012-04-09 17:23:51 +02:00
|
|
|
else {
|
|
|
|
$(".spinner_row", "#online_packages").remove();
|
2012-04-12 13:31:45 +02:00
|
|
|
row_html = '<tr class="package_' + data['package'] + '">' +
|
|
|
|
'<td style=" text-align:left; width:80%;" class="name_package">' +
|
|
|
|
data['package'] +
|
|
|
|
'</td>' +
|
|
|
|
'<td style=" text-align:center; width:50px;"></td>' +
|
|
|
|
'</tr>';
|
|
|
|
$("tbody", "#online_packages").append(row_html); return;
|
|
|
|
$("tbody", "#online_packages").append(
|
|
|
|
);
|
2012-04-09 17:23:51 +02:00
|
|
|
}
|
2012-04-02 17:57:48 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
<?php
|
|
|
|
}
|
2012-04-12 13:31:45 +02:00
|
|
|
|
|
|
|
function install_offline_enterprise_package(&$settings, $user_key) {
|
|
|
|
global $config;
|
|
|
|
|
|
|
|
if (isset($_FILES["fileloaded"]["error"])
|
|
|
|
&& !$_FILES["fileloaded"]["error"]) {
|
|
|
|
$extension = substr($_FILES["fileloaded"]["name"],
|
|
|
|
strlen($_FILES["fileloaded"]["name"])-4, 4);
|
|
|
|
|
2013-09-30 11:08:10 +02:00
|
|
|
switch ($extension) {
|
|
|
|
case '.oum':
|
|
|
|
case '.zip':
|
|
|
|
$tempDir = sys_get_temp_dir();
|
|
|
|
if ($extension == '.oum') {
|
|
|
|
$tempDir .= "/tmp_oum/";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$tempDir .= "/tmp_zip";
|
|
|
|
}
|
|
|
|
delete_dir($tempDir);
|
2012-04-12 13:31:45 +02:00
|
|
|
|
2013-09-30 11:08:10 +02:00
|
|
|
|
|
|
|
$zip = new ZipArchive;
|
|
|
|
if ($zip->open($_FILES["fileloaded"]['tmp_name']) === TRUE) {
|
|
|
|
$zip->extractTo($tempDir);
|
|
|
|
$zip->close();
|
2012-04-12 13:31:45 +02:00
|
|
|
}
|
|
|
|
else {
|
2013-09-30 11:08:10 +02:00
|
|
|
$error = ui_print_error_message(__('Update cannot be opened'));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ($extension == '.oum') {
|
|
|
|
////////////////////////////////////////////////////
|
|
|
|
$package = um_package_info_from_paths ($tempDir);
|
|
|
|
if ($package === false) {
|
|
|
|
ui_print_error_message(
|
|
|
|
__('Error, the file package is empty or corrupted.'));
|
2012-04-12 13:31:45 +02:00
|
|
|
}
|
2013-09-30 11:08:10 +02:00
|
|
|
else {
|
|
|
|
$settings = um_db_load_settings ();
|
|
|
|
|
|
|
|
if ($settings->current_update >= $package->id) {
|
|
|
|
ui_print_error_message(
|
|
|
|
__('Your system version is higher or equal than the loaded package'));
|
2012-04-12 13:31:45 +02:00
|
|
|
}
|
2013-09-30 11:08:10 +02:00
|
|
|
else {
|
|
|
|
$binary_paths = um_client_get_files ($tempDir . "binary/");
|
|
|
|
|
|
|
|
foreach ($binary_paths as $key => $paths) {
|
|
|
|
foreach($paths as $index => $path) {
|
|
|
|
$tempDir_scaped = preg_replace('/\//',
|
|
|
|
'\/', $tempDir . "binary");
|
|
|
|
$binary_paths[$key][$index] = preg_replace(
|
|
|
|
'/^' . $tempDir_scaped . '/', ' ', $path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$code_paths = um_client_get_files ($tempDir . "code/");
|
|
|
|
|
|
|
|
foreach ($code_paths as $key => $paths) {
|
|
|
|
foreach($paths as $index => $path) {
|
|
|
|
$tempDir_scaped = preg_replace('/\//', '\/', $tempDir . "code");
|
|
|
|
$code_paths[$key][$index] = preg_replace(
|
|
|
|
'/^' . $tempDir_scaped . '/', ' ', $path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$sql_paths = um_client_get_files ($tempDir);
|
|
|
|
foreach ($sql_paths as $key => $paths) {
|
|
|
|
foreach ($paths as $index => $path) {
|
|
|
|
if ($path != $tempDir || ($key == 'info_package' && $path == $tempDir)) {
|
|
|
|
unset($sql_paths[$key]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$updates_binary = array();
|
|
|
|
$updates_code = array();
|
|
|
|
$updates_sql = array();
|
|
|
|
|
|
|
|
if (!empty($binary_paths)) {
|
|
|
|
$updates_binary = um_client_update_from_paths(
|
|
|
|
$binary_paths, $tempDir, $package->id, 'binary');
|
|
|
|
}
|
|
|
|
if (!empty($code_paths)) {
|
|
|
|
$updates_code = um_client_update_from_paths(
|
|
|
|
$code_paths, $tempDir, $package->id, 'code');
|
|
|
|
}
|
|
|
|
if (!empty($sql_paths)) {
|
|
|
|
$updates_sql = um_client_update_from_paths(
|
|
|
|
$sql_paths, $tempDir, $package->id, 'sql');
|
|
|
|
}
|
|
|
|
|
|
|
|
um_delete_directory($tempDir);
|
|
|
|
|
|
|
|
$updates= array_merge((array) $updates_binary, (array) $updates_code, (array) $updates_sql);
|
|
|
|
|
|
|
|
$package->updates = $updates;
|
|
|
|
|
|
|
|
$settings = um_db_load_settings ();
|
|
|
|
|
|
|
|
if (um_client_upgrade_to_package($package, $settings, true)) {
|
|
|
|
ui_print_success_message(
|
|
|
|
__('Successfully upgraded'));
|
|
|
|
|
|
|
|
//Refresh the settings object.
|
|
|
|
$settings = um_db_load_settings ();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ui_print_error_message(__('Cannot be upgraded'));
|
2012-04-12 13:31:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-09-30 11:08:10 +02:00
|
|
|
////////////////////////////////////////////////////
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$correct = copy_dir($tempDir, $config['homedir']);
|
2012-04-12 13:31:45 +02:00
|
|
|
|
2013-09-30 11:08:10 +02:00
|
|
|
if ($correct) {
|
2012-04-12 13:31:45 +02:00
|
|
|
ui_print_success_message(
|
|
|
|
__('Successfully upgraded'));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ui_print_error_message(__('Cannot be upgraded'));
|
|
|
|
}
|
|
|
|
}
|
2013-09-30 11:08:10 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ui_print_error_message(__('Incorrect file extension'));
|
|
|
|
break;
|
2012-04-12 13:31:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2013-09-25 14:21:58 +02:00
|
|
|
//Check if the file is biggest than the limit in PHP
|
|
|
|
if ($_FILES["fileloaded"]["error"] === 1) {
|
|
|
|
$upload_max_filesize = ini_get('upload_max_filesize');
|
|
|
|
|
|
|
|
ui_print_error_message(
|
|
|
|
sprintf(
|
|
|
|
__('File is more biggest than the PHP limit (%s). Please change it in PHP configuration.'),
|
|
|
|
$upload_max_filesize));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ui_print_error_message(__('File cannot be uploaded'));
|
|
|
|
}
|
2012-04-12 13:31:45 +02:00
|
|
|
}
|
|
|
|
}
|
2012-04-02 17:57:48 +02:00
|
|
|
?>
|