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:
mdtrooper 2013-09-30 09:08:10 +00:00
parent e32a7e64aa
commit 76d8778797
5 changed files with 155 additions and 84 deletions

View File

@ -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

View File

@ -480,11 +480,18 @@ 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'));
switch ($extension) {
case '.oum':
case '.zip':
$tempDir = sys_get_temp_dir();
if ($extension == '.oum') {
$tempDir .= "/tmp_oum/";
}
else {
$tempDir = sys_get_temp_dir()."/tmp_oum/";
$tempDir .= "/tmp_zip";
}
delete_dir($tempDir);
$zip = new ZipArchive;
if ($zip->open($_FILES["fileloaded"]['tmp_name']) === TRUE) {
@ -495,6 +502,9 @@ function install_offline_enterprise_package(&$settings, $user_key) {
$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(
@ -512,8 +522,10 @@ function install_offline_enterprise_package(&$settings, $user_key) {
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_scaped = preg_replace('/\//',
'\/', $tempDir . "binary");
$binary_paths[$key][$index] = preg_replace(
'/^' . $tempDir_scaped . '/', ' ', $path);
}
}
@ -522,7 +534,8 @@ function install_offline_enterprise_package(&$settings, $user_key) {
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);
$code_paths[$key][$index] = preg_replace(
'/^' . $tempDir_scaped . '/', ' ', $path);
}
}
@ -540,13 +553,16 @@ function install_offline_enterprise_package(&$settings, $user_key) {
$updates_sql = array();
if (!empty($binary_paths)) {
$updates_binary = um_client_update_from_paths ($binary_paths, $tempDir, $package->id, 'binary');
$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');
$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');
$updates_sql = um_client_update_from_paths(
$sql_paths, $tempDir, $package->id, 'sql');
}
um_delete_directory($tempDir);
@ -569,6 +585,23 @@ function install_offline_enterprise_package(&$settings, $user_key) {
}
}
}
////////////////////////////////////////////////////
}
else {
$correct = copy_dir($tempDir, $config['homedir']);
if ($correct) {
ui_print_success_message(
__('Successfully upgraded'));
}
else {
ui_print_error_message(__('Cannot be upgraded'));
}
}
break;
default:
ui_print_error_message(__('Incorrect file extension'));
break;
}
}
else {

View File

@ -97,9 +97,12 @@ function main_view_enterprise($settings, $user_key) {
}
}
$upload_package = (bool)get_parameter('upload_package');
if ($upload_package) {
if (!empty($_FILES)) {
install_offline_enterprise_package($settings, $user_key);
}
}
echo '<h4>';
@ -172,7 +175,6 @@ function main_view_enterprise($settings, $user_key) {
<?php
echo '<h4>' . __('Offline') . '</h4>';
$table = null;
$table->width = '98%';

View File

@ -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);
}
/**