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>
|
2013-09-29 Junichi Satoh <junichi@rworks.jp>
|
||||||
|
|
||||||
* include/ajax/events.php: Added timeout binary paths to execute
|
* include/ajax/events.php: Added timeout binary paths to execute
|
||||||
|
|
|
@ -480,11 +480,18 @@ function install_offline_enterprise_package(&$settings, $user_key) {
|
||||||
$extension = substr($_FILES["fileloaded"]["name"],
|
$extension = substr($_FILES["fileloaded"]["name"],
|
||||||
strlen($_FILES["fileloaded"]["name"])-4, 4);
|
strlen($_FILES["fileloaded"]["name"])-4, 4);
|
||||||
|
|
||||||
if ($extension != '.oum') {
|
switch ($extension) {
|
||||||
ui_print_error_message(__('Incorrect file extension'));
|
case '.oum':
|
||||||
|
case '.zip':
|
||||||
|
$tempDir = sys_get_temp_dir();
|
||||||
|
if ($extension == '.oum') {
|
||||||
|
$tempDir .= "/tmp_oum/";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$tempDir = sys_get_temp_dir()."/tmp_oum/";
|
$tempDir .= "/tmp_zip";
|
||||||
|
}
|
||||||
|
delete_dir($tempDir);
|
||||||
|
|
||||||
|
|
||||||
$zip = new ZipArchive;
|
$zip = new ZipArchive;
|
||||||
if ($zip->open($_FILES["fileloaded"]['tmp_name']) === TRUE) {
|
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'));
|
$error = ui_print_error_message(__('Update cannot be opened'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ($extension == '.oum') {
|
||||||
|
////////////////////////////////////////////////////
|
||||||
$package = um_package_info_from_paths ($tempDir);
|
$package = um_package_info_from_paths ($tempDir);
|
||||||
if ($package === false) {
|
if ($package === false) {
|
||||||
ui_print_error_message(
|
ui_print_error_message(
|
||||||
|
@ -508,21 +518,24 @@ function install_offline_enterprise_package(&$settings, $user_key) {
|
||||||
__('Your system version is higher or equal than the loaded package'));
|
__('Your system version is higher or equal than the loaded package'));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$binary_paths = um_client_get_files ($tempDir."binary/");
|
$binary_paths = um_client_get_files ($tempDir . "binary/");
|
||||||
|
|
||||||
foreach ($binary_paths as $key => $paths) {
|
foreach ($binary_paths as $key => $paths) {
|
||||||
foreach($paths as $index => $path) {
|
foreach($paths as $index => $path) {
|
||||||
$tempDir_scaped = preg_replace('/\//', '\/', $tempDir."binary");
|
$tempDir_scaped = preg_replace('/\//',
|
||||||
$binary_paths[$key][$index] = preg_replace('/^'.$tempDir_scaped.'/', ' ', $path);
|
'\/', $tempDir . "binary");
|
||||||
|
$binary_paths[$key][$index] = preg_replace(
|
||||||
|
'/^' . $tempDir_scaped . '/', ' ', $path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$code_paths = um_client_get_files ($tempDir."code/");
|
$code_paths = um_client_get_files ($tempDir . "code/");
|
||||||
|
|
||||||
foreach ($code_paths as $key => $paths) {
|
foreach ($code_paths as $key => $paths) {
|
||||||
foreach($paths as $index => $path) {
|
foreach($paths as $index => $path) {
|
||||||
$tempDir_scaped = preg_replace('/\//', '\/', $tempDir."code");
|
$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();
|
$updates_sql = array();
|
||||||
|
|
||||||
if (!empty($binary_paths)) {
|
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)) {
|
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)) {
|
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);
|
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 {
|
else {
|
||||||
|
|
|
@ -325,7 +325,7 @@ function um_client_decrypt ($data) {
|
||||||
// with the path of all files into directory //
|
// with the path of all files into directory //
|
||||||
///////////////////////////////////////////////
|
///////////////////////////////////////////////
|
||||||
function um_client_get_files ($dir_path) {
|
function um_client_get_files ($dir_path) {
|
||||||
if(!file_exists($dir_path)) {
|
if (!file_exists($dir_path)) {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -334,10 +334,10 @@ function um_client_get_files ($dir_path) {
|
||||||
$cont = 0;
|
$cont = 0;
|
||||||
while ($element = readdir($dir))
|
while ($element = readdir($dir))
|
||||||
{
|
{
|
||||||
if($element == '.' || $element == '..') {
|
if ($element == '.' || $element == '..') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(is_dir($dir_path.$element)) {
|
if (is_dir($dir_path.$element)) {
|
||||||
$file_temp = um_client_get_files ("$dir_path$element/");
|
$file_temp = um_client_get_files ("$dir_path$element/");
|
||||||
$files = array_merge((array)$files,(array)$file_temp);
|
$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) {
|
function um_client_print_update ($update, $settings) {
|
||||||
if(isset($update->id)) {
|
if (isset($update->id)) {
|
||||||
echo 'Update #'.$update->id;
|
echo 'Update #'.$update->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -97,9 +97,12 @@ function main_view_enterprise($settings, $user_key) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$upload_package = (bool)get_parameter('upload_package');
|
||||||
|
if ($upload_package) {
|
||||||
if (!empty($_FILES)) {
|
if (!empty($_FILES)) {
|
||||||
install_offline_enterprise_package($settings, $user_key);
|
install_offline_enterprise_package($settings, $user_key);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
echo '<h4>';
|
echo '<h4>';
|
||||||
|
@ -172,7 +175,6 @@ function main_view_enterprise($settings, $user_key) {
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
echo '<h4>' . __('Offline') . '</h4>';
|
echo '<h4>' . __('Offline') . '</h4>';
|
||||||
$table = null;
|
$table = null;
|
||||||
$table->width = '98%';
|
$table->width = '98%';
|
||||||
|
|
|
@ -1704,6 +1704,7 @@ function get_periods ($custom = true, $show_default = true) {
|
||||||
*/
|
*/
|
||||||
function copy_dir($src, $dst) {
|
function copy_dir($src, $dst) {
|
||||||
$dir = opendir($src);
|
$dir = opendir($src);
|
||||||
|
$return = true;
|
||||||
|
|
||||||
if (!$dir)
|
if (!$dir)
|
||||||
return false;
|
return false;
|
||||||
|
@ -1712,14 +1713,39 @@ function copy_dir($src, $dst) {
|
||||||
while (false !== ( $file = readdir($dir)) ) {
|
while (false !== ( $file = readdir($dir)) ) {
|
||||||
if (( $file != '.' ) && ( $file != '..' )) {
|
if (( $file != '.' ) && ( $file != '..' )) {
|
||||||
if ( is_dir($src . '/' . $file) ) {
|
if ( is_dir($src . '/' . $file) ) {
|
||||||
copy_dir($src . '/' . $file,$dst . '/' . $file);
|
$return = copy_dir($src . '/' . $file, $dst . '/' . $file);
|
||||||
|
|
||||||
|
if (!$return) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
copy($src . '/' . $file,$dst . '/' . $file);
|
$r = copy($src . '/' . $file, $dst . '/' . $file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
closedir($dir);
|
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