summaryrefslogtreecommitdiff
path: root/groups.pl
diff options
context:
space:
mode:
authorOthmar Gsenger <otti@wirdorange.org>2011-03-31 19:05:23 +0000
committerOthmar Gsenger <otti@wirdorange.org>2011-03-31 19:05:23 +0000
commitd26fa8c1e0886c813de5364ee6570c860c6ce12c (patch)
tree418120693100150b0443d3d880f945aaa45a0d22 /groups.pl
parentadded support for browsing by category (diff)
hopfully repaired this after backup loss
Diffstat (limited to 'groups.pl')
-rwxr-xr-xgroups.pl77
1 files changed, 0 insertions, 77 deletions
diff --git a/groups.pl b/groups.pl
deleted file mode 100755
index 908b2d5..0000000
--- a/groups.pl
+++ /dev/null
@@ -1,77 +0,0 @@
-#!/usr/bin/perl
-
-use strict;
-use CGI qw(:standard);
-use CGI::Carp 'fatalsToBrowser';
-use local::nzbget;
-use local::db;
-use local::user;
-use utf8;
-my $user = new local::user(%ENV);
-
-use CGI::Ajax;
-
-my $cgi = new CGI;
-my $pjx = new CGI::Ajax( 'get_download_speed' => \&get_download_speed,
- 'get_download_table' => \&get_download_table
- );
-print $pjx->build_html( $cgi, \&Show_HTML);
-
-sub get_download_speed
-{
- my $cli = new local::nzbget;
- my $status = $cli->send_request('status') or die "Can't connect to nzbget";
- my $speed = int($status->{DownloadRate}->value/(1024*1024));
- return $speed?$speed.'MB/s':int($status->{DownloadRate}->value/1024).'KB/s';
-}
-
-sub get_download_table
-{
- my $html;
- my $cli = new local::nzbget;
- my $row = $cli->send_request('listgroups') or die "Can't connect to nzbget";
- $html.= CGI::start_table();
- $html.= Tr(th([qw/Kategorie Name Besitzer Größe(MB) Fortschritt Abbrechen/]));
- foreach my $value ( @$row)
- {
- my ($download) = local::db::download->retrieve($value->{NZBNicename}->value) or die ' Error in groups';
- my $remaining=$value->{RemainingSizeMB}->value;
- my $total=$value->{FileSizeMB}->value;
- my $percent = int(100-100*$remaining/$total);
- if (not $download->size)
- {
- $download->size($total);
- $download->update();
- $user->obj->quota_used($user->obj->quota_used+$total);
- $user->obj->update();
- }
- 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,$total,$percent.'%',$cancel]));
- #foreach my $key (keys %$value)
- #{
- # $html.= Tr(td([$key,$value->{$key}->value]));
- #}
- }
- $html.= CGI::end_table();
- return $html;
-}
-
-sub Show_HTML
-{
- use local::menu;
- my $menu= new local::menu(%ENV);
- my $html= $menu->start_html('nzbget status');
-
- $html.= <<LALALA
- <script type="text/javascript" language="JavaScript"><!--
- window.setInterval("get_download_speed( [], ['speed'] ); get_download_table( [], ['dls'] );", 1000);
- //--></script>
-LALALA
- ;
- $html.= table({class=>'nohigh'},Tr(td['download speed &nbsp; '. span({id=>'speed'},get_download_speed())]),Tr(td(['&nbsp;'])));
- $html.= div({id=>'dls'},get_download_table());
-
- $html.= $menu->end_html();
- return $html
-}