summaryrefslogtreecommitdiff
path: root/nzbget/remove.pm
diff options
context:
space:
mode:
Diffstat (limited to 'nzbget/remove.pm')
-rw-r--r--nzbget/remove.pm31
1 files changed, 31 insertions, 0 deletions
diff --git a/nzbget/remove.pm b/nzbget/remove.pm
new file mode 100644
index 0000000..71334bd
--- /dev/null
+++ b/nzbget/remove.pm
@@ -0,0 +1,31 @@
+package nzbget::remove;
+use strict;
+use Apache2::Const -compile => qw(OK REDIRECT);
+use CGI qw(:standard);
+use CGI::Carp 'fatalsToBrowser';
+use local::db;
+use local::user;
+use File::Path;
+use config;
+
+
+sub handler
+{
+ my $user = new local::user(%ENV);
+ my $del_id = param('id');
+
+ my ($dl) = local::db::download->retrieve($del_id) or die 'Error in cancel';
+ die "Not allowed" if not $dl->owner->owner_id() eq $user->get_id();
+
+ my $basedir = $config::config{files_dir} or die 'Missing files_dir in config';
+ File::Path::rmtree($basedir.'/'.$dl->category->name.'/'.$dl->download_id);
+ $user->obj->quota_used($user->obj->quota_used - $dl->size);
+ $user->obj->update;
+ my @seens = local::db::seen->search(download=>$del_id);
+ map {$_->delete()} @seens;
+ $dl->delete();
+
+ print CGI::redirect('download_2');
+ return Apache2::Const::REDIRECT;
+}
+1;