Routino SVN Repository Browser

Check out the latest version of Routino: svn co http://routino.org/svn/trunk routino

ViewVC logotype

Contents of /branches/destination-access/web/www/routino/search.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1904 - (show annotations) (download)
Sun Mar 12 13:57:04 2017 UTC (8 years ago) by amb
File size: 2245 byte(s)
Merge the changes for version 3.2 into the branch.

1 #!/usr/bin/perl
2 #
3 # Routino search results retrieval CGI
4 #
5 # Part of the Routino routing software.
6 #
7 # This file Copyright 2012-2014, 2016 Andrew M. Bishop
8 #
9 # This program is free software: you can redistribute it and/or modify
10 # it under the terms of the GNU Affero General Public License as published by
11 # the Free Software Foundation, either version 3 of the License, or
12 # (at your option) any later version.
13 #
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU Affero General Public License for more details.
18 #
19 # You should have received a copy of the GNU Affero General Public License
20 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #
22
23 use strict;
24
25 # Use the generic search script
26 require "./search.pl";
27
28 # Use the perl CGI module
29 use CGI ':cgi';
30
31
32 # Create the query and get the parameters
33
34 my $query=new CGI;
35
36 my @rawparams=$query->param;
37
38 # Legal CGI parameters with regexp validity check
39
40 my %legalparams=(
41 "marker" => "[0-9]+",
42
43 "lonmin" => "[-0-9.]+",
44 "lonmax" => "[-0-9.]+",
45 "latmax" => "[-0-9.]+",
46 "latmin" => "[-0-9.]+",
47
48 "search" => ".+"
49 );
50
51 # Validate the CGI parameters, ignore invalid ones
52
53 my %cgiparams=();
54
55 foreach my $key (@rawparams)
56 {
57 foreach my $test (keys (%legalparams))
58 {
59 if($key =~ m%^$test$%)
60 {
61 my $value=$query->param($key);
62
63 if($value =~ m%^$legalparams{$test}$%)
64 {
65 $cgiparams{$key}=$value;
66 last;
67 }
68 }
69 }
70 }
71
72 # Parse the parameters
73
74 my $marker=$cgiparams{marker};
75 my $search=$cgiparams{search};
76
77 my $lonmin=$cgiparams{lonmin};
78 my $lonmax=$cgiparams{lonmax};
79 my $latmax=$cgiparams{latmax};
80 my $latmin=$cgiparams{latmin};
81
82 # Run the search
83
84 my($search_time,$search_message,@places)=RunSearch($search,$lonmin,$lonmax,$latmax,$latmin);
85
86 # Return the output
87
88 print header(-type=>'text/plain',-charset=>'utf-8');
89
90 print "$marker\n";
91 print "$search_time\n";
92 print "$search_message\n";
93 foreach my $place (@places)
94 {
95 print "$place\n";
96 }

Properties

Name Value
svn:executable *