Somewhat Off-Topic Javascript question

Kieran Ames kames at erols.com
Thu Nov 11 11:40:35 EST 1999


I see in the example advanced templates that JavaScript is being used to
set/validate some of the form variables that are sent to MapServ. I'd
like to capitalize on this (if I can) by defining some layers as a
function of the user's identity.
Example:
My users have to authenticate when they connect to my server. In the cgi
world, their username is available to my Perl scripts as
"$ENV{'REMOTE_USER'}". In my case, $ENV{'REMOTE_USER'}would translate to
"kieran".

Let's say that I include in the HTML template, a form that allows the
user to kick-off a process that retreives data from an external data
source (ODBC) and that I use the shaplib utilities to create the
associated shp, shx and dbf files. I'd want to specify the username
($ENV{'REMOTE_USER'}) as part of the shape file naming conventions so
that one user wouldn't over-write the data created by another.
(In cgi/Perl, I'd say something like $filename = "shape_" .
$ENV{'REMOTE_USER'} and then create  $filename.shp, $filename.dbf . I'd
then have files like shape_kieran.shp, shape_kieran.dbf)

Issues:
1. Can JavaScript access the $ENV{'REMOTE_USER'}variable?
2. The layer I would just have created was not defined in the map file.
How could I accomplish this substitution?
The functional result I'm trying to achieve would be something like
this.....

LAYER
     NAME "ODBC_data"
     DATA shape_$ENV{'REMOTE_USER'} #This would resolve to shape_kieran
     STATUS DEFAULT
     TYPE POINT
     CLASS
          NAME "Point Results"
          COLOR 0 0 0
     END # Class
END # Layer

I might reaching for the sky with this one!
TIA for any thoughts.

Kieran

PS. I've been looking for shapelib utilities that work in an NT world.
Doug Nebert provided me with a wonderful Perl script and I got a friend
of mine to compile the shapelib c code for me. I tried out a revised
version of Doug's script with the resulting executables and got what I
needed! I still need to do some more testing, but thought I'd pass this
info on to the group.

...K




More information about the mapserver-users mailing list