2011-08-31 Miguel de Dios <miguel.dedios@artica.es>
* extensions/update_manager/lib/libupdate_manager_client.php, extensions/update_manager/main.php: fixed when the file is corrupted or empty. Fixes: #3400237 git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4861 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
1272ea9275
commit
149e5f5f57
|
@ -1,3 +1,11 @@
|
|||
2011-08-31 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* extensions/update_manager/lib/libupdate_manager_client.php,
|
||||
extensions/update_manager/main.php: fixed when the file is corrupted or
|
||||
empty.
|
||||
|
||||
Fixes: #3400237
|
||||
|
||||
2011-08-31 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* include/functions.php: fixed in function "string2image" when generate a
|
||||
|
|
|
@ -373,14 +373,20 @@ function um_client_print_update ($update, $settings) {
|
|||
}
|
||||
|
||||
function um_package_info_from_paths ($tmpDir) {
|
||||
$f = fopen($tmpDir.'info_package', "r");
|
||||
$f_content = fread($f, filesize($tmpDir.'info_package'));
|
||||
fclose($f);
|
||||
$f_array = array();
|
||||
$f = @fopen($tmpDir.'info_package', "r");
|
||||
|
||||
unset($f_content->status);
|
||||
if ($f !== false) {
|
||||
$f_content = fread($f, filesize($tmpDir.'info_package'));
|
||||
fclose($f);
|
||||
$f_array = array();
|
||||
|
||||
return json_decode($f_content);
|
||||
unset($f_content->status);
|
||||
|
||||
return json_decode($f_content);
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function um_client_update_from_paths ($file_paths, $tmpDir, $num_package, $type) {
|
||||
|
|
|
@ -71,68 +71,72 @@ if (isset($_FILES["fileloaded"]["error"]) && !$_FILES["fileloaded"]["error"]) {
|
|||
}
|
||||
|
||||
$package = um_package_info_from_paths ($tempDir);
|
||||
|
||||
$settings = um_db_load_settings ();
|
||||
|
||||
if($settings->current_update >= $package->id) {
|
||||
$error = '<h5 class="error">'.__('Your system version is higher or equal than the loaded package').'</h5>';
|
||||
if ($package === false) {
|
||||
$error = '<h5 class="error">'.__('Error, the file package is empty or corrupted.').'</h5>';
|
||||
}
|
||||
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;
|
||||
|
||||
else {
|
||||
$settings = um_db_load_settings ();
|
||||
|
||||
if(um_client_upgrade_to_package ($package, $settings, true)) {
|
||||
echo '<h5 class="suc">'.__('Successfully upgraded').'.</h5>';
|
||||
$settings = um_db_load_settings ();
|
||||
|
||||
if($settings->current_update >= $package->id) {
|
||||
$error = '<h5 class="error">'.__('Your system version is higher or equal than the loaded package').'</h5>';
|
||||
}
|
||||
else {
|
||||
echo '<h5 class="error">'.__('Cannot be upgraded').'</h5>';
|
||||
$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)) {
|
||||
echo '<h5 class="suc">'.__('Successfully upgraded').'.</h5>';
|
||||
$settings = um_db_load_settings ();
|
||||
}
|
||||
else {
|
||||
echo '<h5 class="error">'.__('Cannot be upgraded').'</h5>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue