[mapserver-users] CGI wrapper scripts

David Hildebrand David.Hildebrand at afsc.ca
Wed Nov 17 16:35:05 PST 2010


Thanks to those that helped.  I now have a wrapper which not only hides
the 'map' parameter but also hides 'service' and 'version' (for
OGC-compliant queries).  The PERL source is listed below.  Feel free to
use it and send me feedback.

 

# A CGI wrapper for mapserv.exe to hide constant URL parameters for
OGC-compliant queries.  

# The mapname, service and version are obtained from the name of this
file.

#

#   mapenv - name of environment variable holding the full path name of
the MapServer map file

#            defined in the http server configuration

#   service - type of service (WMS, WFS or WCS)

#   version - OGC version number with dots omitted (eg., 1.1.1 is shown
as 111)

#

# Original coding:        David Hildebrand
November, 2010

 

use CGI;

use File::Spec;

my $query = CGI->new;

if ($query->request_method() !~ /GET/i) {die "Not a GET request\n";}

 

# Parse file name.

 

my (undef,undef,$fn) = File::Spec->splitpath($0);

my ($mapenv,$service,$version,undef) = split(/\./,$fn);

if (!exists($ENV{"\U$mapenv\E"})) {die "\U$mapenv\E environment variable
not set\n";}

if ($service !~ /\AWMS\Z|\AWFS\Z|\AWCS\Z/i) {die "\U$service\E not
supported\n";}

$version = substr($version,0,1) . '.' . substr($version,1,1) . '.' .
substr($version,2,1); 

 

# Reset MAP, SERVICE and VERSION.

 

$query->delete('map','service','version');

$query->param(-name=>'map',-value=>$ENV{"\U$mapenv\E"});

$query->param(-name=>'service',-value=>"\U$service\E");

$query->param(-name=>'version',-value=>$version);

 

# Reconstruct CGI query.

 

my @elements = ();

foreach my $pname ($query->param()) {

  my @values = $query->param($pname);

  if (scalar(@values) > 1) {push @elements, "\U$pname=\E" .
join(',', at values);}

  if (scalar(@values) == 1) {push @elements, "\U$pname=\E" .
$values[0];}

  if (scalar(@values) == 0) {push @elements, "\U$pname=\E"}

}

 

# Invoke mapserv.exe and never return.

 

$ENV{QUERY_STRING} = join('&', at elements);

exec 'mapserv.exe';

 

exit;

 

 

===========================

David V. Hildebrand

Agriculture Financial Services Corporation

(403) 782-8239   

 

www.afsc.ca <http://www.afsc.ca>

This communication is intended for the use of the recipient to which it
is addressed, and may contain confidential, personal and/or privileged
information. Please contact Agriculture Financial Services Corporation
immediately if you are not the intended recipient of this communication,
and do not copy, distribute, or take action relying on it. Any
communication received in error, or subsequent reply, should be deleted
or destroyed. Please consider the environment before printing this
email.

 

 

-----Original Message-----
From: mapserver-users-bounces at lists.osgeo.org
[mailto:mapserver-users-bounces at lists.osgeo.org] On Behalf Of David
Hildebrand
Sent: Wednesday, November 17, 2010 10:20 AM
To: mapserver-users at lists.osgeo.org
Subject: [mapserver-users] CGI wrapper scripts

 

The MapServer documentation has an example of CGI wrapper scripts for a

UNIX environment.  Would there be an equivalent Windows form I could

use?  I was thinking of using PERL.

 

 

===========================

David V. Hildebrand

Agriculture Financial Services Corporation

(403) 782-8239   

 

www.afsc.ca <http://www.afsc.ca>

This communication is intended for the use of the recipient to which it

is addressed, and may contain confidential, personal and/or privileged

information. Please contact Agriculture Financial Services Corporation

immediately if you are not the intended recipient of this communication,

and do not copy, distribute, or take action relying on it. Any

communication received in error, or subsequent reply, should be deleted

or destroyed. Please consider the environment before printing this

email.

 

 

_______________________________________________

mapserver-users mailing list

mapserver-users at lists.osgeo.org

http://lists.osgeo.org/mailman/listinfo/mapserver-users

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20101117/f9a4f174/attachment.htm>


More information about the MapServer-users mailing list