/[nn.old]/trunk/search/nn2-search.cgi
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/search/nn2-search.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 60 - (show annotations)
Tue Feb 12 19:25:41 2002 UTC (18 years, 4 months ago) by dpavlin
File MIME type: application/octet-stream
File size: 2045 byte(s)
Unable to calculate annotation data on binary file contents.
nuke cro chars in search too!

1 #!/usr/bin/perl -w
2
3 use strict;
4 use CGI qw/:standard -no_xhtml/;
5 use DBI;
6 use Text::Query;
7 use CGI::Carp qw(fatalsToBrowser);
8
9 my $url="http://www.nn.hr/CijeliBrojS.asp?god=%d&br=%d&mid=%d#%d";
10
11 my %labels = ('Simple'=>'jednostavnim', 'Advanced'=>'naprednim');
12
13 my $hits=0;
14
15 print header(-charset=>'iso-8859-2'),start_html(-title=>'NN pretrazivanje',-lang=>'hr'),start_form;
16 print "Tra¾i zakon: ",textfield('search')," sa ";
17 print popup_menu(-name=>'type',-values=>[ keys %labels ],-labels=>\%labels);
18 print submit(-value=>'pretra¾ivanjem');
19 print end_form,hr;
20
21 if (param('search') && param('type')) {
22 my $question;
23 my ($query) = Text::Query->new('blurk', # param('search'),
24 -parse => 'Text::Query::Parse'.param('type') || 'Advanced',
25 -build => 'Text::Query::BuildSQLPg',
26 -fields_searched => 'title_czs',
27 -select => 'select br,god,aname,nr,title from nn where __WHERE__ order by god desc,br desc,nr asc'
28 );
29
30 my $s=param('search');
31 $s=~tr/ššžčꊩŽČĘ/¹š¾čę©Š®ČĘ/; # 1250 -> iso8859-2
32 $s=~tr/¹©šŠčČęĘ¾®/sSdDcCcCzZ/;
33 $query->prepare($s);
34
35 # print "--",$query->matchstring();
36
37 my $dbh = DBI->connect("DBI:Pg:dbname=nn","dpavlin","") || die $DBI::errstr;
38 my $sth=$dbh->prepare($query->matchstring()) || die $dbh->errstr();
39 $sth->execute() || die $dbh->errstr();
40 while (my $row = $sth->fetchrow_hashref()) {
41 print br,"<tt><a href=\"",sprintf($url,$row->{god},$row->{br},$row->{nr},$row->{aname}),"\">NN",$row->{god},"/",$row->{br},"</a> ",$row->{nr},"</tt> ",$row->{title},"\n";
42 $hits++;
43 }
44 if ($hits > 0) {
45 print p,hr,"Našeno je $hits zakona...";
46 } else {
47 print p,"Nije našen niti jedan zakon...";
48 }
49 } else {
50 print p('U jednostavnom pretra¾ivanju pretra¾ivač pronalazi sve zakone u kojima se pojavljuje <b>bilo koja</b> od tih riječi. Da bi na¹li sve zakone u kojima se pojavljuju <b>sve upisane riječi</b>, upi¹ite ispred svake riječi znak plus (+). Npr: <tt>+zakon +kava</tt>',br,'Ako ispred riječi upi¹ete minus (-) neęe se prikazivati zakoni koji imaju takvu riječ. Npr. <tt>+kava +zakon -dopunama</tt>');
51 }

Properties

Name Value
cvs2svn:cvs-rev 1.6
svn:executable *
svn:mime-type application/octet-stream

  ViewVC Help
Powered by ViewVC 1.1.26