diff options
author | Othmar Gsenger <otti@wirdorange.org> | 2011-01-15 01:17:15 +0000 |
---|---|---|
committer | Othmar Gsenger <otti@wirdorange.org> | 2011-01-15 01:17:15 +0000 |
commit | 04894ee3ea2768e34c1086b0012a095c32225dcb (patch) | |
tree | 45f32bc23fa899092a0883a145ec97402674a2a9 | |
parent | added ajax & navigation (diff) |
added cancel
-rwxr-xr-x | cancel.pl | 27 | ||||
-rwxr-xr-x | env.pl | 15 | ||||
-rwxr-xr-x | groups.pl | 15 | ||||
-rwxr-xr-x | menu.pl | 10 |
4 files changed, 61 insertions, 6 deletions
diff --git a/cancel.pl b/cancel.pl new file mode 100755 index 0000000..a342fc2 --- /dev/null +++ b/cancel.pl @@ -0,0 +1,27 @@ +#!/usr/bin/perl + +use strict; +use CGI qw(:standard); +use CGI::Carp 'fatalsToBrowser'; +use local::nzbget; +use local::db; +use local::user; + +my $user = new local::user($ENV{REMOTE_USER}); +my $del_id = param('id'); + +my ($download) = local::db::download->retrieve($del_id) or die 'Error in cancel'; +die "Not allowed" if not $download->owner->owner_id() eq $user->get_id(); + +my $cli = new local::nzbget; +my $row = $cli->send_request('listgroups') or die "Can't connect to nubget"; +foreach my $value ( @$row) +{ + my ($download) = local::db::download->retrieve($value->{NZBNicename}->value) or die ' Error in groups'; + if ($value->{NZBNicename}->value == $del_id) + { + my $status = $cli->send_request('editqueue','GroupDelete',0,"",[$value->{LastID}->value]) or die "Can't connect to nzbget"; + } +} + +print CGI::redirect('/cgi-bin/nzbget/groups.pl'); @@ -0,0 +1,15 @@ +#!/usr/bin/perl +use strict; +use CGI qw(:standard); +use CGI::Carp 'fatalsToBrowser'; + +print header; +print start_html('env'); + +print CGI::start_table(); +foreach my $row (keys %ENV) +{ + print Tr(td[$row,$ENV{$row}]); +} +print CGI::end_table(); +print end_html; @@ -5,6 +5,8 @@ use CGI qw(:standard); use CGI::Carp 'fatalsToBrowser'; use local::nzbget; use local::db; +use local::user; +my $user = new local::user($ENV{REMOTE_USER}); use CGI::Ajax; @@ -26,6 +28,7 @@ sub get_download_table my $html; my $cli = new local::nzbget; my $row = $cli->send_request('listgroups') or die "Can't connect to nubget"; + $html.= CGI::start_table(); foreach my $value ( @$row) { my ($download) = local::db::download->retrieve($value->{NZBNicename}->value) or die ' Error in groups'; @@ -34,12 +37,15 @@ sub get_download_table my $percent = int(100-100*$remaining/$total); $download->size($total); $download->update(); - $html.= Tr(td([$download->category->name,$download->name,$download->owner->name,$percent.'%'])); + my $cancel; + $cancel=a({href=>'/cgi-bin/nzbget/cancel.pl?id='.$value->{NZBNicename}->value},'Abbrechen') if ($download->owner->owner_id() eq $user->get_id()); + $html.= Tr(td([$download->category->name,$download->name,$download->owner->name,$percent.'%',$cancel])); #foreach my $key (keys %$value) #{ # $html.= Tr(td([$key,$value->{$key}->value])); #} } + $html.= CGI::end_table(); return $html; } @@ -51,8 +57,7 @@ sub Show_HTML $html.= <<LALALA <script type="text/javascript" language="JavaScript"><!-- - window.setInterval("get_download_speed( [], ['speed'] );", 2000); - window.setInterval("get_download_table( [], ['dltable'] );", 2000); + window.setInterval("get_download_speed( [], ['speed'] ); get_download_table( [], ['dls'] );", 2000); //--></script> LALALA ; @@ -62,9 +67,7 @@ LALALA $html.= CGI::end_table(); $html.= hr(); - $html.= CGI::start_table(id=>'dltable'); - $html.= get_download_table(); - $html.= CGI::end_table(); + $html.= div({id=>'dls'},get_download_table()); $html.= $menu->end_html(); return $html @@ -0,0 +1,10 @@ +#!/usr/bin/perl +use strict; +use CGI qw(:standard); +use CGI::Carp 'fatalsToBrowser'; +use local::menu; + +print header; +my $menu= new local::menu(%ENV); +print $menu->start_html('nzbget status'); +print $menu->end_html; |