summaryrefslogtreecommitdiff
path: root/nzbget/search.pm
diff options
context:
space:
mode:
Diffstat (limited to 'nzbget/search.pm')
-rw-r--r--nzbget/search.pm56
1 files changed, 56 insertions, 0 deletions
diff --git a/nzbget/search.pm b/nzbget/search.pm
new file mode 100644
index 0000000..e1c181d
--- /dev/null
+++ b/nzbget/search.pm
@@ -0,0 +1,56 @@
+package nzbget::search;
+use strict;
+use Apache2::Const -compile => qw(OK);
+use CGI qw(:standard);
+use CGI::Carp 'fatalsToBrowser';
+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;