diff --git a/contrib/handle_archive/main.php b/contrib/handle_archive/main.php
index 47a4881e..635a2b33 100644
--- a/contrib/handle_archive/main.php
+++ b/contrib/handle_archive/main.php
@@ -7,9 +7,28 @@
class ArchiveFileHandler extends Extension {
public function receive_event($event) {
+ if(is_a($event, 'InitExtEvent')) {
+ global $config;
+ $config->set_default_string('archive_tmp_dir', "/tmp");
+ $config->set_default_string('archive_extract_command', 'unzip -d "%d" "%f"');
+ }
+
+ if(is_a($event, 'SetupBuildingEvent')) {
+ $sb = new SetupBlock("Archive Handler Options");
+ $sb->add_text_option("archive_tmp_dir", "Temporary folder: ");
+ $sb->add_text_option("archive_extract_command", "
Extraction command: ");
+ $sb->add_label("
%f for archive, %d for temporary directory");
+ $event->panel->add_block($sb);
+ }
+
if(is_a($event, 'DataUploadEvent') && $this->supported_ext($event->type)) {
- $tmpdir = "/tmp/shimmie-archive-{$event->hash}";
- system("unzip -d $tmpdir {$event->tmpname}");
+ global $config;
+ $tmp = $config->get_string('archive_tmp_dir');
+ $tmpdir = "$tmp/shimmie-archive-{$event->hash}";
+ $cmd = $config->get_string('archive_extract_command');
+ $cmd = str_replace('%f', $event->tmpfile);
+ $cmd = str_replace('%d', $tmpdir);
+ system($cmd);
$this->add_dir($tmpdir);
unlink($tmpdir);
}