summaryrefslogtreecommitdiff
path: root/nzbget/search.pm
blob: 531498456b0dbdb656252854783c6d3bbc320789 (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
52
53
54
55
package nzbget::search;
use strict;
use Apache2::Const -compile => qw(OK);
use CGI qw(:standard);
use URI::Escape;
use local::params;
use local::nzbindex;
use local::menu;

sub handler
{
	print header;
	my $menu= new local::menu(%ENV);
	print $menu->start_html('nzbget search');

	print CGI::start_table();

	print CGI::start_form(-action=>'search');
	print
	 table({class=>'nohigh'},
		Tr(td(['Search',textfield({size=>100,name=>'q'}),])),
					Tr(td(['min Size',textfield({size=>5,name=>'minsize'}).' MB'])),
		Tr(td(['max Size',textfield({size=>5, name=>'maxsize'}).' MB'.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([qw/   /])),
	);
	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?url=".uri_escape_utf8($item->{url})."&name=".uri_escape_utf8(param('q'))."&description=".uri_escape_utf8($item->{description})."&title=".uri_escape_utf8($item->{title})},$item->{title}).' '.
					$item->{description}]));
			}
			print CGI::end_table();
		} else {
			print hr().'nothing found';
		}
	}
	print $menu->end_html;
  return Apache2::Const::OK;
}
1;