mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-30 01:05:39 +02:00
2014-06-10 Miguel de Dios <miguel.dedios@artica.es>
* godmode/update_manager_xxx/update_manager.online.php, include/functions_update_manager.php, include/javascript/update_manager.js, include/ajax/update_manager.ajax.php: work in the first version of new update manager. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@10153 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
9ea05e5f6b
commit
1666cd187f
@ -1,3 +1,11 @@
|
|||||||
|
2014-06-10 Miguel de Dios <miguel.dedios@artica.es>
|
||||||
|
|
||||||
|
* godmode/update_manager_xxx/update_manager.online.php,
|
||||||
|
include/functions_update_manager.php,
|
||||||
|
include/javascript/update_manager.js,
|
||||||
|
include/ajax/update_manager.ajax.php: work in the first version of
|
||||||
|
new update manager.
|
||||||
|
|
||||||
2014-06-10 Mario Pulido <mario.pulido@artica.es>
|
2014-06-10 Mario Pulido <mario.pulido@artica.es>
|
||||||
|
|
||||||
* pandoradb_data.sql: Fixed bug in plugin exec #803
|
* pandoradb_data.sql: Fixed bug in plugin exec #803
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
ui_require_css_file('update_manager', 'godmode/update_manager_xxx/');
|
ui_require_css_file('update_manager', 'godmode/update_manager_xxx/');
|
||||||
|
require_once("include/functions_update_manager.php");
|
||||||
enterprise_include_once("include/functions_update_manager.php");
|
enterprise_include_once("include/functions_update_manager.php");
|
||||||
|
|
||||||
/* Translators: Do not translade Update Manager, it's the name of the program */
|
/* Translators: Do not translade Update Manager, it's the name of the program */
|
||||||
|
@ -31,6 +31,10 @@ $check_progress_enterprise_update = (boolean) get_parameter("check_progress_ente
|
|||||||
$install_package_step2 = (boolean)get_parameter("install_package_step2");
|
$install_package_step2 = (boolean)get_parameter("install_package_step2");
|
||||||
$enterprise_install_package = (boolean) get_parameter("enterprise_install_package");
|
$enterprise_install_package = (boolean) get_parameter("enterprise_install_package");
|
||||||
$enterprise_install_package_step2 = (boolean)get_parameter("enterprise_install_package_step2");
|
$enterprise_install_package_step2 = (boolean)get_parameter("enterprise_install_package_step2");
|
||||||
|
$check_online_free_packages = (bool)get_parameter('check_online_free_packages');
|
||||||
|
$update_last_free_package = (bool)get_parameter('update_last_free_package');
|
||||||
|
$check_update_free_package = (bool)get_parameter('check_update_free_package');
|
||||||
|
$install_free_package = (bool)get_parameter('install_free_package');
|
||||||
|
|
||||||
if ($upload_file) {
|
if ($upload_file) {
|
||||||
ob_clean();
|
ob_clean();
|
||||||
@ -318,4 +322,157 @@ if ($enterprise_install_package_step2) {
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($check_online_free_packages) {
|
||||||
|
|
||||||
|
update_manager_check_online_free_packages();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($update_last_free_package) {
|
||||||
|
|
||||||
|
$package = get_parameter('package', '');
|
||||||
|
$version = get_parameter('version', '');
|
||||||
|
$package_url = base64_decode($package);
|
||||||
|
|
||||||
|
$params = array('action' => 'get_package',
|
||||||
|
'license' => $license,
|
||||||
|
'limit_count' => $users,
|
||||||
|
'current_package' => $current_package,
|
||||||
|
'package' => $package,
|
||||||
|
'version' => $config['version'],
|
||||||
|
'build' => $config['build']);
|
||||||
|
|
||||||
|
$curlObj = curl_init();
|
||||||
|
//curl_setopt($curlObj, CURLOPT_URL, $config['url_updatemanager']);
|
||||||
|
curl_setopt($curlObj, CURLOPT_URL, $package_url);
|
||||||
|
curl_setopt($curlObj, CURLOPT_RETURNTRANSFER, 1);
|
||||||
|
curl_setopt($curlObj, CURLOPT_FOLLOWLOCATION, true);
|
||||||
|
//curl_setopt($curlObj, CURLOPT_POST, true);
|
||||||
|
//curl_setopt($curlObj, CURLOPT_POSTFIELDS, $params);
|
||||||
|
curl_setopt($curlObj, CURLOPT_SSL_VERIFYPEER, false);
|
||||||
|
$result = curl_exec($curlObj);
|
||||||
|
$http_status = curl_getinfo($curlObj, CURLINFO_HTTP_CODE);
|
||||||
|
|
||||||
|
curl_close($curlObj);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (empty($result)) {
|
||||||
|
echo json_encode(array(
|
||||||
|
'in_progress' => false,
|
||||||
|
'message' => __('Fail to update to the last package.')));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
file_put_contents(
|
||||||
|
$config['attachment_store'] . "/downloads/last_package.tgz" , $result);
|
||||||
|
|
||||||
|
echo json_encode(array(
|
||||||
|
'in_progress' => true,
|
||||||
|
'message' => __('Starting to update to the last package.')));
|
||||||
|
|
||||||
|
|
||||||
|
$progress_update_status = db_get_value(
|
||||||
|
'value', 'tconfig', 'token', 'progress_update_status');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (empty($progress_update_status)) {
|
||||||
|
db_process_sql_insert('tconfig',
|
||||||
|
array(
|
||||||
|
'value' => 0,
|
||||||
|
'token' => 'progress_update')
|
||||||
|
);
|
||||||
|
|
||||||
|
db_process_sql_insert('tconfig',
|
||||||
|
array(
|
||||||
|
'value' => json_encode(
|
||||||
|
array(
|
||||||
|
'status' => 'in_progress',
|
||||||
|
'message' => ''
|
||||||
|
)),
|
||||||
|
'token' => 'progress_update_status')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
db_process_sql_update('tconfig',
|
||||||
|
array('value' => 0),
|
||||||
|
array('token' => 'progress_update'));
|
||||||
|
|
||||||
|
db_process_sql_update('tconfig',
|
||||||
|
array('value' => json_encode(
|
||||||
|
array(
|
||||||
|
'status' => 'in_progress',
|
||||||
|
'message' => ''
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
array('token' => 'progress_update_status'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($check_update_free_package) {
|
||||||
|
|
||||||
|
|
||||||
|
$progress_update = db_get_value('value', 'tconfig',
|
||||||
|
'token', 'progress_update');
|
||||||
|
|
||||||
|
$progress_update_status = db_get_value('value', 'tconfig',
|
||||||
|
'token', 'progress_update_status');
|
||||||
|
$progress_update_status = json_decode($progress_update_status, true);
|
||||||
|
|
||||||
|
switch ($progress_update_status['status']) {
|
||||||
|
case 'in_progress':
|
||||||
|
$correct = true;
|
||||||
|
$end = false;
|
||||||
|
break;
|
||||||
|
case 'fail':
|
||||||
|
$correct = false;
|
||||||
|
$end = false;
|
||||||
|
break;
|
||||||
|
case 'end':
|
||||||
|
$correct = true;
|
||||||
|
$end = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$progressbar_tag = progressbar($progress_update, 400, 20,
|
||||||
|
__("progress"), $config['fontpath']);
|
||||||
|
preg_match("/src='(.*)'/", $progressbar_tag, $matches);
|
||||||
|
$progressbar = $matches[1];
|
||||||
|
|
||||||
|
echo json_encode(array(
|
||||||
|
'correct' => $correct,
|
||||||
|
'end' => $end,
|
||||||
|
'message' => $progress_update_status['message'],
|
||||||
|
'progressbar' => $progressbar
|
||||||
|
));
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($install_free_package) {
|
||||||
|
$version = get_parameter('version', '');
|
||||||
|
|
||||||
|
update_manager_starting_update();
|
||||||
|
|
||||||
|
|
||||||
|
db_process_sql_update('tconfig', array('`value`' => $version),
|
||||||
|
array('`token`' => "current_package"));
|
||||||
|
$config['current_package'] = $version;
|
||||||
|
|
||||||
|
sleep(3);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$return["status"] = "success";
|
||||||
|
$return["message"]= __("The package is installed.");
|
||||||
|
echo json_encode($return);
|
||||||
|
}
|
||||||
?>
|
?>
|
@ -36,7 +36,11 @@ function update_manager_get_config_values() {
|
|||||||
|
|
||||||
//TO DO
|
//TO DO
|
||||||
$license = "TESTMIGUEL00B0WAW9BU1QM0RZ2QM0MZ3QN5M41R35S5S1DP";
|
$license = "TESTMIGUEL00B0WAW9BU1QM0RZ2QM0MZ3QN5M41R35S5S1DP";
|
||||||
//$current_update = 11;
|
//~ $current_update = 9;
|
||||||
|
//~ $limit_count = 2;
|
||||||
|
$build_version = "140514";
|
||||||
|
$pandora_version = "4.1";
|
||||||
|
$license = "INTEGRIA-FREE";
|
||||||
|
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
@ -194,6 +198,185 @@ function update_manager_install_package_step2() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function update_manager_main() {
|
function update_manager_main() {
|
||||||
|
global $config;
|
||||||
|
|
||||||
|
?>
|
||||||
|
<script src="include/javascript/update_manager.js"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
var version_update = "";
|
||||||
|
var stop_check_progress = 0;
|
||||||
|
|
||||||
|
$(document).ready(function() {
|
||||||
|
check_online_free_packages();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function update_manager_check_online_free_packages ($is_ajax=true) {
|
||||||
|
global $config;
|
||||||
|
|
||||||
|
$update_message = '';
|
||||||
|
|
||||||
|
$um_config_values = update_manager_get_config_values();
|
||||||
|
|
||||||
|
$params = array('action' => 'newest_package',
|
||||||
|
'license' => $um_config_values['license'],
|
||||||
|
'limit_count' => $um_config_values['limit_count'],
|
||||||
|
'current_package' => $um_config_values['current_update'],
|
||||||
|
'version' => $um_config_values['version'],
|
||||||
|
'build' => $um_config_values['build']);
|
||||||
|
|
||||||
|
|
||||||
|
$curlObj = curl_init();
|
||||||
|
curl_setopt($curlObj, CURLOPT_URL, $config['url_update_manager']);
|
||||||
|
curl_setopt($curlObj, CURLOPT_RETURNTRANSFER, 1);
|
||||||
|
curl_setopt($curlObj, CURLOPT_POST, true);
|
||||||
|
curl_setopt($curlObj, CURLOPT_POSTFIELDS, $params);
|
||||||
|
curl_setopt($curlObj, CURLOPT_SSL_VERIFYPEER, false);
|
||||||
|
|
||||||
|
$result = curl_exec($curlObj);
|
||||||
|
$http_status = curl_getinfo($curlObj, CURLINFO_HTTP_CODE);
|
||||||
|
curl_close($curlObj);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if ($http_status >= 400 && $http_status < 500) {
|
||||||
|
if ($is_ajax) {
|
||||||
|
echo __("Server not found.");
|
||||||
|
} else {
|
||||||
|
$update_message = __("Server not found.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elseif ($http_status >= 500) {
|
||||||
|
if ($is_ajax) {
|
||||||
|
echo $result;
|
||||||
|
} else {
|
||||||
|
$update_message = $result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if ($is_ajax) {
|
||||||
|
$result = json_decode($result, true);
|
||||||
|
|
||||||
|
if (!empty($result)) {
|
||||||
|
echo "<p><b>There is a new version:</b> " . $result[0]['version'] . "</p>";
|
||||||
|
echo "<a href='javascript: update_last_package(\"" . base64_encode($result[0]["file_name"]) .
|
||||||
|
"\", \"" . $result[0]['version'] ."\");'>" .
|
||||||
|
__("Update to the last version") . "</a>";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
echo __("There is no update available.");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
if (!empty($result)) {
|
||||||
|
$result = json_decode($result, true);
|
||||||
|
$update_message = "There is a new version: " . $result[0]['version'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $update_message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The update copy entirire the tgz or fail (leave some parts copies and some part not).
|
||||||
|
* This does make any thing with the BD.
|
||||||
|
*/
|
||||||
|
function update_manager_starting_update() {
|
||||||
|
global $config;
|
||||||
|
|
||||||
|
$path_package = $config['attachment_store'] .
|
||||||
|
"/downloads/last_package.tgz";
|
||||||
|
|
||||||
|
try {
|
||||||
|
$phar = new PharData($path_package);
|
||||||
|
rrmdir($config['attachment_store'] . "/downloads/temp_update/trunk");
|
||||||
|
$phar->extractTo($config['attachment_store'] . "/downloads/temp_update");
|
||||||
|
}
|
||||||
|
catch (Exception $e) {
|
||||||
|
// handle errors
|
||||||
|
|
||||||
|
db_process_sql_update('tconfig',
|
||||||
|
array('value' => json_encode(
|
||||||
|
array(
|
||||||
|
'status' => 'fail',
|
||||||
|
'message' => __('Failed extracting the package to temp directory.')
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
array('token' => 'progress_update_status'));
|
||||||
|
}
|
||||||
|
|
||||||
|
db_process_sql_update('tconfig',
|
||||||
|
array('value' => 50),
|
||||||
|
array('token' => 'progress_update'));
|
||||||
|
|
||||||
|
$full_path = $config['attachment_store'] . "/downloads/temp_update/trunk";
|
||||||
|
|
||||||
|
$homedir = $config['homedir'];
|
||||||
|
|
||||||
|
$result = update_manager_recurse_copy($full_path, $homedir,
|
||||||
|
array('install.php'));
|
||||||
|
|
||||||
|
if (!$result) {
|
||||||
|
db_process_sql_update('tconfig',
|
||||||
|
array('value' => json_encode(
|
||||||
|
array(
|
||||||
|
'status' => 'fail',
|
||||||
|
'message' => __('Failed the copying of the files.')
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
array('token' => 'progress_update_status'));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
db_process_sql_update('tconfig',
|
||||||
|
array('value' => 100),
|
||||||
|
array('token' => 'progress_update'));
|
||||||
|
db_process_sql_update('tconfig',
|
||||||
|
array('value' => json_encode(
|
||||||
|
array(
|
||||||
|
'status' => 'end',
|
||||||
|
'message' => __('Package extracted successfully.')
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
array('token' => 'progress_update_status'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function update_manager_recurse_copy($src, $dst, $black_list) {
|
||||||
|
$dir = opendir($src);
|
||||||
|
@mkdir($dst);
|
||||||
|
@trigger_error("NONE");
|
||||||
|
|
||||||
|
//debugPrint("mkdir(" . $dst . ")", true);
|
||||||
|
while (false !== ( $file = readdir($dir)) ) {
|
||||||
|
if (( $file != '.' ) && ( $file != '..' ) && (!in_array($file, $black_list))) {
|
||||||
|
if ( is_dir($src . '/' . $file) ) {
|
||||||
|
if (!update_manager_recurse_copy($src . '/' . $file,$dst . '/' . $file, $black_list)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$result = copy($src . '/' . $file,$dst . '/' . $file);
|
||||||
|
$error = error_get_last();
|
||||||
|
|
||||||
|
if (strstr($error['message'], "copy(") ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
closedir($dir);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
?>
|
?>
|
@ -278,3 +278,124 @@ function check_install_package(package) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function check_online_free_packages() {
|
||||||
|
$("#box_online .checking_package").show();
|
||||||
|
|
||||||
|
var parameters = {};
|
||||||
|
parameters['page'] = 'include/ajax/update_manager.ajax';
|
||||||
|
parameters['check_online_free_packages'] = 1;
|
||||||
|
|
||||||
|
jQuery.post(
|
||||||
|
"ajax.php",
|
||||||
|
parameters,
|
||||||
|
function (data) {
|
||||||
|
$("#box_online .checking_package").hide();
|
||||||
|
|
||||||
|
$("#box_online .loading").hide();
|
||||||
|
$("#box_online .content").html(data);
|
||||||
|
},
|
||||||
|
"html"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function update_last_package(package, version) {
|
||||||
|
version_update = version;
|
||||||
|
|
||||||
|
$("#box_online .content").html("");
|
||||||
|
$("#box_online .loading").show();
|
||||||
|
$("#box_online .download_package").show();
|
||||||
|
|
||||||
|
|
||||||
|
var parameters = {};
|
||||||
|
parameters['page'] = 'include/ajax/update_manager.ajax';
|
||||||
|
parameters['update_last_free_package'] = 1;
|
||||||
|
parameters['package'] = package;
|
||||||
|
parameters['version'] = version;
|
||||||
|
|
||||||
|
jQuery.post(
|
||||||
|
"ajax.php",
|
||||||
|
parameters,
|
||||||
|
function (data) {
|
||||||
|
if (data['in_progress']) {
|
||||||
|
$("#box_online .loading").hide();
|
||||||
|
$("#box_online .download_package").hide();
|
||||||
|
|
||||||
|
$("#box_online .content").html(data['message']);
|
||||||
|
|
||||||
|
install_free_package(package,version);
|
||||||
|
setTimeout(check_progress_update, 1000);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$("#box_online .content").html(data['message']);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"json"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function check_progress_update() {
|
||||||
|
if (stop_check_progress) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var parameters = {};
|
||||||
|
parameters['page'] = 'include/ajax/update_manager.ajax';
|
||||||
|
parameters['check_update_free_package'] = 1;
|
||||||
|
|
||||||
|
jQuery.post(
|
||||||
|
"ajax.php",
|
||||||
|
parameters,
|
||||||
|
function (data) {
|
||||||
|
if (stop_check_progress) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data['correct']) {
|
||||||
|
if (data['end']) {
|
||||||
|
//$("#box_online .content").html(data['message']);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$("#box_online .progressbar").show();
|
||||||
|
|
||||||
|
$("#box_online .progressbar .progressbar_img").attr('src',
|
||||||
|
data['progressbar']);
|
||||||
|
|
||||||
|
setTimeout(check_progress_update, 1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//$("#box_online .content").html(data['message']);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"json"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function install_free_package(package,version) {
|
||||||
|
var parameters = {};
|
||||||
|
parameters['page'] = 'include/ajax/update_manager.ajax';
|
||||||
|
parameters['install_free_package'] = 1;
|
||||||
|
parameters['package'] = package;
|
||||||
|
parameters['version'] = version;
|
||||||
|
|
||||||
|
jQuery.post(
|
||||||
|
"ajax.php",
|
||||||
|
parameters,
|
||||||
|
function (data) {
|
||||||
|
if (data["status"] == "success") {
|
||||||
|
$("#box_online .loading").hide();
|
||||||
|
$("#box_online .progressbar").hide();
|
||||||
|
$("#box_online .content").html(data['message']);
|
||||||
|
stop_check_progress = 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$("#box_online .loading").hide();
|
||||||
|
$("#box_online .progressbar").hide();
|
||||||
|
$("#box_online .content").html(data['message']);
|
||||||
|
stop_check_progress = 1;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"json"
|
||||||
|
);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user