2013-09-30 Miguel de Dios <miguel.dedios@artica.es>
* include/functions.php: added function "delete_dir" and improved the function "copy_dir". * extensions/update_manager/lib/libupdate_manager_client.php, extensions/update_manager/lib/functions.php, extensions/update_manager/main.php: added feature to upload zip archives to update. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8827 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
9639821051
commit
b2e0094f6b
|
@ -1,3 +1,13 @@
|
|||
2013-09-30 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* include/functions.php: added function "delete_dir" and improved
|
||||
the function "copy_dir".
|
||||
|
||||
* extensions/update_manager/lib/libupdate_manager_client.php,
|
||||
extensions/update_manager/lib/functions.php,
|
||||
extensions/update_manager/main.php: added feature to upload zip
|
||||
archives to update.
|
||||
|
||||
2013-09-29 Junichi Satoh <junichi@rworks.jp>
|
||||
|
||||
* include/ajax/events.php: Added timeout binary paths to execute
|
||||
|
|
|
@ -480,95 +480,128 @@ function install_offline_enterprise_package(&$settings, $user_key) {
|
|||
$extension = substr($_FILES["fileloaded"]["name"],
|
||||
strlen($_FILES["fileloaded"]["name"])-4, 4);
|
||||
|
||||
if ($extension != '.oum') {
|
||||
ui_print_error_message(__('Incorrect file extension'));
|
||||
}
|
||||
else {
|
||||
$tempDir = sys_get_temp_dir()."/tmp_oum/";
|
||||
|
||||
$zip = new ZipArchive;
|
||||
if ($zip->open($_FILES["fileloaded"]['tmp_name']) === TRUE) {
|
||||
$zip->extractTo($tempDir);
|
||||
$zip->close();
|
||||
}
|
||||
else {
|
||||
$error = ui_print_error_message(__('Update cannot be opened'));
|
||||
}
|
||||
|
||||
$package = um_package_info_from_paths ($tempDir);
|
||||
if ($package === false) {
|
||||
ui_print_error_message(
|
||||
__('Error, the file package is empty or corrupted.'));
|
||||
}
|
||||
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'));
|
||||
switch ($extension) {
|
||||
case '.oum':
|
||||
case '.zip':
|
||||
$tempDir = sys_get_temp_dir();
|
||||
if ($extension == '.oum') {
|
||||
$tempDir .= "/tmp_oum/";
|
||||
}
|
||||
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);
|
||||
}
|
||||
$tempDir .= "/tmp_zip";
|
||||
}
|
||||
delete_dir($tempDir);
|
||||
|
||||
|
||||
$zip = new ZipArchive;
|
||||
if ($zip->open($_FILES["fileloaded"]['tmp_name']) === TRUE) {
|
||||
$zip->extractTo($tempDir);
|
||||
$zip->close();
|
||||
}
|
||||
else {
|
||||
$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.'));
|
||||
}
|
||||
|
||||
$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);
|
||||
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'));
|
||||
}
|
||||
}
|
||||
|
||||
$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]);
|
||||
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'));
|
||||
}
|
||||
}
|
||||
}
|
||||
////////////////////////////////////////////////////
|
||||
}
|
||||
else {
|
||||
$correct = copy_dir($tempDir, $config['homedir']);
|
||||
|
||||
$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)) {
|
||||
if ($correct) {
|
||||
ui_print_success_message(
|
||||
__('Successfully upgraded'));
|
||||
|
||||
//Refresh the settings object.
|
||||
$settings = um_db_load_settings ();
|
||||
}
|
||||
else {
|
||||
ui_print_error_message(__('Cannot be upgraded'));
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ui_print_error_message(__('Incorrect file extension'));
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -325,7 +325,7 @@ function um_client_decrypt ($data) {
|
|||
// with the path of all files into directory //
|
||||
///////////////////////////////////////////////
|
||||
function um_client_get_files ($dir_path) {
|
||||
if(!file_exists($dir_path)) {
|
||||
if (!file_exists($dir_path)) {
|
||||
return array();
|
||||
}
|
||||
|
||||
|
@ -334,10 +334,10 @@ function um_client_get_files ($dir_path) {
|
|||
$cont = 0;
|
||||
while ($element = readdir($dir))
|
||||
{
|
||||
if($element == '.' || $element == '..') {
|
||||
if ($element == '.' || $element == '..') {
|
||||
continue;
|
||||
}
|
||||
if(is_dir($dir_path.$element)) {
|
||||
if (is_dir($dir_path.$element)) {
|
||||
$file_temp = um_client_get_files ("$dir_path$element/");
|
||||
$files = array_merge((array)$files,(array)$file_temp);
|
||||
}
|
||||
|
@ -353,7 +353,7 @@ function um_client_get_files ($dir_path) {
|
|||
}
|
||||
|
||||
function um_client_print_update ($update, $settings) {
|
||||
if(isset($update->id)) {
|
||||
if (isset($update->id)) {
|
||||
echo 'Update #'.$update->id;
|
||||
}
|
||||
|
||||
|
@ -554,7 +554,7 @@ function um_client_upgrade_to_package ($package, $settings, $force = true, $upda
|
|||
}
|
||||
|
||||
$tempDirServer = '/'.implode('/',$path_script).'/temp/';
|
||||
|
||||
|
||||
$package_name = 'package_'.$package->id.'.oum';
|
||||
$zipArchive = $tempDir . $package_name;
|
||||
$zipArchiveServer = $tempDirServer . $package_name;
|
||||
|
|
|
@ -97,8 +97,11 @@ function main_view_enterprise($settings, $user_key) {
|
|||
}
|
||||
}
|
||||
|
||||
if (!empty($_FILES)) {
|
||||
install_offline_enterprise_package($settings, $user_key);
|
||||
$upload_package = (bool)get_parameter('upload_package');
|
||||
if ($upload_package) {
|
||||
if (!empty($_FILES)) {
|
||||
install_offline_enterprise_package($settings, $user_key);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -172,7 +175,6 @@ function main_view_enterprise($settings, $user_key) {
|
|||
<?php
|
||||
|
||||
|
||||
|
||||
echo '<h4>' . __('Offline') . '</h4>';
|
||||
$table = null;
|
||||
$table->width = '98%';
|
||||
|
|
|
@ -1704,6 +1704,7 @@ function get_periods ($custom = true, $show_default = true) {
|
|||
*/
|
||||
function copy_dir($src, $dst) {
|
||||
$dir = opendir($src);
|
||||
$return = true;
|
||||
|
||||
if (!$dir)
|
||||
return false;
|
||||
|
@ -1712,14 +1713,39 @@ function copy_dir($src, $dst) {
|
|||
while (false !== ( $file = readdir($dir)) ) {
|
||||
if (( $file != '.' ) && ( $file != '..' )) {
|
||||
if ( is_dir($src . '/' . $file) ) {
|
||||
copy_dir($src . '/' . $file,$dst . '/' . $file);
|
||||
$return = copy_dir($src . '/' . $file, $dst . '/' . $file);
|
||||
|
||||
if (!$return) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
copy($src . '/' . $file,$dst . '/' . $file);
|
||||
$r = copy($src . '/' . $file, $dst . '/' . $file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
closedir($dir);
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
function delete_dir($dir) {
|
||||
if (!file_exists($dir))
|
||||
return true;
|
||||
|
||||
if (!is_dir($dir))
|
||||
return unlink($dir);
|
||||
|
||||
foreach (scandir($dir) as $item) {
|
||||
if ($item == '.' || $item == '..')
|
||||
continue;
|
||||
|
||||
if (!delete_dir($dir . "/" . $item))
|
||||
return false;
|
||||
}
|
||||
|
||||
return rmdir($dir);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue