diff --git a/plugins/dynamix.plugin.manager/scripts/language b/plugins/dynamix.plugin.manager/scripts/language index 02b449396..52a31390f 100755 --- a/plugins/dynamix.plugin.manager/scripts/language +++ b/plugins/dynamix.plugin.manager/scripts/language @@ -101,7 +101,12 @@ function language($method, $xml_file, &$error) { exec("mkdir -p $path"); @unlink("$docroot/webGui/javascript/translate.$name.js"); foreach (glob("$path/*.dot",GLOB_NOSORT) as $dot) unlink($dot); - exec("unzip -qqLjo -d $path $local"); + exec("unzip -qqLjo -d $path $local", $dummy, $err); + if ($err > 1) { + exec("rm -rf $path"); + $error = "unzip failed. Error code $err"; + return false; + } return true; case 'remove': $url = $xml->LanguageURL; diff --git a/plugins/dynamix/include/FileUpload.php b/plugins/dynamix/include/FileUpload.php index ae12efa77..fa7b72d83 100644 --- a/plugins/dynamix/include/FileUpload.php +++ b/plugins/dynamix/include/FileUpload.php @@ -50,11 +50,15 @@ case 'delete': case 'add': $path = "$docroot/languages/$file"; exec("mkdir -p ".escapeshellarg($path)); - $result = file_put_contents("/$boot/$file.lang.zip",base64_decode(preg_replace('/^data:.*;base64,/','',$_POST['filedata']))); + $result = file_put_contents("$boot/$file.lang.zip",base64_decode(preg_replace('/^data:.*;base64,/','',$_POST['filedata']))); if ($result) { foreach (glob("$path/*.dot",GLOB_NOSORT) as $dot) unlink($dot); @unlink("$docroot/webGui/javascript/translate.$file.js"); - exec("unzip -qqjLo -d ".escapeshellarg($path)." ".escapeshellarg("$boot/$file.lang.zip")); + exec("unzip -qqjLo -d ".escapeshellarg($path)." ".escapeshellarg("$boot/$file.lang.zip"), $dummy, $err); + if ($err > 1) { + unlink("$boot/$file.lang.zip"); + exec("rm -rf ".escapeshellarg($path)); + } } $installed = []; foreach (glob("$docroot/languages/*",GLOB_ONLYDIR) as $dir) $installed[] = basename($dir);