summaryrefslogtreecommitdiff
path: root/search.pl
blob: aefec96fd51eaba2688d196ff0b468d865189c2c (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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/perl
use strict;
use CGI qw(:standard);
use CGI::Carp 'fatalsToBrowser';
use URI::Escape;
use local::params;
use local::nzbindex;
use local::menu;

print header;
my $menu= new local::menu(%ENV);
print $menu->start_html('nzbget status');

print CGI::start_table();

print CGI::start_form(-action=>'/cgi-bin/nzbget/search.pl');
print
 table({class=>'nohigh'},
	Tr(td(['Search',textfield('q'),])),
        Tr(td(['min Size',textfield('minsize')])),
	Tr(td(['max Size',textfield('maxsize').hidden('more',1)])),
	Tr(td(['results',CGI::popup_menu(
				 -name => 'max',
				  -values => ['25','100','500'],
				   -default => '25',
				    -labels => {25=>'25',100=>'100',500=>500}
				     ) ])),
	Tr(td(['',submit()])),
  Tr(td([' '])),
);
print CGI::end_form;
my $param_obj=new local::params;
if ($param_obj->has_params())
{
  my $nzbindex=new local::nzbindex;
  my @search = $nzbindex->search($param_obj->get_as_hash());
  if (@search)
  {
    print CGI::start_table();
    foreach my $item (@search) {
      print Tr(td([
        a({href=>"./pre_enqueue.pl?url=".uri_escape($item->{url})."&name=".uri_escape(param('q'))."&description=".uri_escape($item->{description})."&title=".uri_escape($item->{title})},$item->{title}).' '.
        $item->{description}]));
    }
    print CGI::end_table();
  } else {
    print hr().'nothing found';
  }
}
print $menu->end_html;