blob: a25c47656826fd65f82090c1429bbdf440b49720 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
package nzbget::remove;
use strict;
use Apache2::Const -compile => qw(OK REDIRECT);
use CGI qw(:standard);
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() or $user->is_admin() );
my $owner = $dl->owner;
my $basedir = $config::config{files_dir} or die 'Missing files_dir in config';
File::Path::rmtree($basedir.'/'.$dl->category->name.'/'.$dl->download_id);
$owner->quota_used($owner->quota_used - $dl->size);
$owner->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;
|