Extract lha files.
authorJamie Cameron <jcameron@webmin.com>
Mon, 16 Nov 2009 08:17:39 +0000 (00:17 -0800)
committerJamie Cameron <jcameron@webmin.com>
Mon, 16 Nov 2009 08:17:39 +0000 (00:17 -0800)
updown/CHANGELOG
updown/lang/en
updown/upload.cgi

index c4e6b32..ae2fb0e 100644 (file)
@@ -10,3 +10,5 @@ Converted all user interface code to use the new Webmin UI library.
 The download from server form can be used to fetch an entire directory, which is then returned as a ZIP file.
 ---- Changes since 1.410 ----
 Added fields for sending an email notification when a background download or file upload completes.
+---- Changes since 1.490 ----
+Added support for extracting LHArc format files when uploading.
index 2616319..6fee16a 100644 (file)
@@ -25,7 +25,7 @@ index_upto=$1 of $2
 index_done=Download complete
 index_imm=Immediately
 index_asuser=As user
-index_zip=Extract ZIP or TAR files?
+index_zip=Extract archive or compressed files?
 index_zipyes=Yes, then delete
 index_header3=Download file from server to PC
 index_fetch=File to download
@@ -120,6 +120,7 @@ email_extdone_zip=ZIP file extracted
 email_extdone_tar=TAR file extracted
 email_extdone_tgz=Gzipped TAR file extracted
 email_extdone_tbz2=Bzipped TAR file extracted
+email_extdone_lha=LHArc file extracted
 email_upfile=Original filename: $1
 email_uppath=Destination filename: $1
 email_upsize=Uploaded size: $1
index 059fc03..8c8e144 100755 (executable)
@@ -78,6 +78,7 @@ for($i=0; defined($d = $in{"upload$i"}); $i++) {
                local @files;
                &switch_uid_back();
                if ($path =~ /\.zip$/i) {
+                       # ZIP file
                        if (!&has_command("unzip")) {
                                $err = &text('upload_ecmd', "unzip");
                                }
@@ -95,6 +96,7 @@ for($i=0; defined($d = $in{"upload$i"}); $i++) {
                        $fmt = "zip";
                        }
                elsif ($path =~ /\.tar$/i) {
+                       # Un-compressed tar file
                        if (!&has_command("tar")) {
                                $err = &text('upload_ecmd', "tar");
                                }
@@ -111,7 +113,26 @@ for($i=0; defined($d = $in{"upload$i"}); $i++) {
                                }
                        $fmt = "tar";
                        }
+               elsif ($path =~ /\.(lha|lhz)$/i) {
+                       # LHAarc file
+                       if (!&has_command("lha")) {
+                               $err = &text('upload_ecmd', "lha");
+                               }
+                       else {
+                               open(OUT, &command_as_user($uinfo[0], 0, "(cd $qdir && lha xf $qpath)")." 2>&1 </dev/null |");
+                               while(<OUT>) {
+                                       $out .= $_;
+                                       if (/(\S[^\t]*\S)\s+\-\s+/) {
+                                               push(@files, "/".$1);
+                                               }
+                                       }
+                               close(OUT);
+                               $err = $out if ($?);
+                               }
+                       $fmt = "lha";
+                       }
                elsif ($path =~ /\.(tar\.gz|tgz|tar\.bz|tbz|tar\.bz2|tbz2)$/i) {
+                       # Compressed tar file
                        local $zipper = $path =~ /bz(2?)$/i ? "bunzip2"
                                                            : "gunzip";
                        if (!&has_command("tar")) {