home *** CD-ROM | disk | FTP | other *** search
-
- <HTML>
- <HEAD>
- <TITLE>CGI::Imagemap.pm - imagemap behavior for CGI programs</TITLE>
- <LINK REL="stylesheet" HREF="../../../Active.css" TYPE="text/css">
- <LINK REV="made" HREF="mailto:">
- </HEAD>
-
- <BODY>
- <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
- <TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
- <STRONG><P CLASS=block> CGI::Imagemap.pm - imagemap behavior for CGI programs</P></STRONG>
- </TD></TR>
- </TABLE>
-
- <A NAME="__index__"></A>
- <!-- INDEX BEGIN -->
-
- <UL>
-
- <LI><A HREF="#name">NAME</A></LI><LI><A HREF="#supportedplatforms">SUPPORTED PLATFORMS</A></LI>
-
- <LI><A HREF="#synopsis">SYNOPSIS</A></LI>
- <LI><A HREF="#description">DESCRIPTION</A></LI>
- <UL>
-
- <LI><A HREF="#static methods">Static Methods</A></LI>
- <LI><A HREF="#class methods">Class Methods</A></LI>
- </UL>
-
- <LI><A HREF="#example">EXAMPLE</A></LI>
- <LI><A HREF="#bugs">BUGS</A></LI>
- <LI><A HREF="#author">AUTHOR</A></LI>
- <LI><A HREF="#credits">CREDITS</A></LI>
- </UL>
- <!-- INDEX END -->
-
- <HR>
- <P>
- <H1><A NAME="name">NAME</A></H1>
- <P>CGI::Imagemap.pm - imagemap behavior for CGI programs</P>
- <P>
- <HR>
- <H1><A NAME="supportedplatforms">SUPPORTED PLATFORMS</A></H1>
- <UL>
- <LI>Linux</LI>
- <LI>Solaris</LI>
- <LI>Windows</LI>
- </UL>
- <HR>
- <H1><A NAME="synopsis">SYNOPSIS</A></H1>
- <PRE>
- use CGI::Imagemap;
- </PRE>
- <PRE>
-
- $map = new CGI::Imagemap;
- $map->setmap(@map);
- $action = $map->action($x,$y);</PRE>
- <PRE>
-
- -- or --</PRE>
- <PRE>
- use CGI::Imagemap 'action_map';
- </PRE>
- <PRE>
-
- $action = action_map($x,$y,@map);</PRE>
- <P>
- <HR>
- <H1><A NAME="description">DESCRIPTION</A></H1>
- <P>CGI::Imagemap allows CGI programmers to place TYPE=IMAGE form fields on
- their HTML fill-out forms, with either client-side or server-side maps
- emulated.</P>
- <P>The imagemap file follows that of the NCSA imagemap program. Each point
- is an x,y tuple. Each line in the map consists of
- one of the following formats. Comment lines start with ``#''.</P>
- <PRE>
- circle action center edgepoint
- rect action upperleft lowerright
- point action point
- poly action point1 point2 ... pointN
- default action</PRE>
- <P>Using ``point'' and ``default'' in the same map makes no sense. If ``point''
- is used, the action for the closest one is selected.</P>
- <P>To use CGI::Imagemap, define an image submit map on your form with
- something like:</P>
- <PRE>
- <input type=image name=mv_todo
- SRC="image_url"></PRE>
- <P>You can pass a ``client-side'' imagemap like this:</P>
- <PRE>
- <input type="hidden" name="todo.map"
- value="rect action1 0,0 25,20">
- <input type="hidden" name="todo.map"
- value="rect action2 26,0 50,20">
- <input type="hidden" name="todo.map"
- value="rect action3 51,0 75,20">
- <input type="hidden" name="todo.map"
- value="default action0"></PRE>
- <P>If the @map passed parameter contains a NUL (\0) in the first array
- position, the map is assumed to be null-separated and @map is built
- by splitting it. This allows a null-separated todo.map with
- multiple values (parsed by a cgi-lib.pl or the like) to be
- referenced.</P>
- <P>All of the following examples assume the above definitions in your
- form.</P>
- <P>
- <H2><A NAME="static methods">Static Methods</A></H2>
- <P>CGI::Imagemap allows the export of two routines, <EM>action_map</EM> and
- <EM>map_untaint</EM>. If you choose to use CGI::Imagemap statically, call the
- module with:</P>
- <PRE>
- use CGI::Imagemap qw(action_map map_untaint);</PRE>
- <DL>
- <DT><STRONG><A NAME="item_action_map"><CODE>action_map(x,y,map)</CODE></A></STRONG><BR>
- <DD>
- We are assuming the map definition above, with the <EM>type=image</EM>
- variable named <EM>todo</EM>, and the map in <EM>todo.map</EM>. You can pass the map
- in one of two ways. The first is compatible with the CGI.pm (or CGI::*)
- modules, and passes the map as an array:
- <PRE>
- $query = new CGI;
- my $x = $query->param('todo.x');
- my $y = $query->param('todo.y');
- my $map = $query->param('todo.map');
- $action = action_map($x, $y, $map);</PRE>
- <P>If you are using the old <EM>cgi-lib.pl</EM> library, which places multiple
- instances of the same form variable in a scalar, separated by null (\0)
- characters, you can do this:</P>
- <PRE>
- ReadParse(*FORM);
- my $x = $FORM{'todo.x'};
- my $y = $FORM{'todo.y'};
- my $map = $FORM{'todo.map'};
- $action = action_map($x, $y, $map);</PRE>
- <P></P>
- <DT><STRONG><A NAME="item_map_untaint"><CODE>map_untaint($untaint)</CODE></A></STRONG><BR>
- <DD>
- If you are running with taint checking, as is suggested for CGI programs,
- you can use <A HREF="#item_map_untaint"><CODE>map_untaint(1)</CODE></A> to set map untainting on a global basis.
- (If using class methods, each has its own instance of untainting).
- <P>It ensures all characters in the action fit pattern of [-\w.+@]+,
- meaning alphnumerics, underscores, dashes (-), periods, and the @ sign.
- It also checks the methods (rect,poly,point,default,circle) and ensures
- that points/tuples are only integers. Once that is done, it untaints
- the passed form variables.</P>
- <PRE>
- map_untaint(1); # Turns on untainting
- map_untaint('yes');# Same as above</PRE>
- <PRE>
- map_untaint(0); # Disable untainting
- map_untaint('no'); # Same as above
- </PRE>
- <PRE>
-
- $status = map_untaint(); # Get status</PRE>
- <P>Default is no untainting.</P>
- <P></P></DL>
- <P>
- <H2><A NAME="class methods">Class Methods</A></H2>
- <P>The class methods for CGI::Imagemap are much the same as above, with the
- exception that multiple imagemaps are then maintained by the module, with
- full independence. The following method definitions assume the CGI::Form
- module is being used, like this:</P>
- <PRE>
- use CGI::Form;
- use CGI::Imagemap;</PRE>
- <PRE>
- $query = new CGI::Form;
- $map = new CGI::Imagemap;</PRE>
- <DL>
- <DT><STRONG><A NAME="item_setmap"><CODE>setmap(@map)</CODE></A></STRONG><BR>
- <DD>
- This sets the map for the instance.
- <PRE>
- $map = new CGI::Imagemap;
- $map->setmap($query->param('todo.map'));</PRE>
- <P></P>
- <DT><STRONG><A NAME="item_addmap"><CODE>addmap(@map)</CODE></A></STRONG><BR>
- <DD>
- This adds a new map action specification <EM>to the current map</EM>.
- <PRE>
- $map->addmap('point action5 3,9'));</PRE>
- <P></P>
- <DT><STRONG><A NAME="item_action"><CODE>action(x,y)</CODE></A></STRONG><BR>
- <DD>
- This finds the action, based on the active map and the values of x and y,
- <PRE>
- $x = $query->param('todo.x');
- $y = $query->param('todo.y');
- $action = $map->action($x, $y);</PRE>
- <P></P>
- <DT><STRONG><A NAME="item_untaint"><CODE>untaint()</CODE></A></STRONG><BR>
- <DD>
- Sets, unsets, or returns the taint status for the instance.
- <PRE>
- $map->untaint(1); # Turns on untainting
- $map->untaint('yes'); # Same as above
- $map->untaint(1); # Disables untainting
- $map->untaint('yes'); # Same as above
- $status = $map->untaint(); # Get status</PRE>
- <P></P>
- <DT><STRONG><A NAME="item_version"><CODE>version()</CODE></A></STRONG><BR>
- <DD>
- Returns the version number of the module.
- <P></P></DL>
- <P>
- <HR>
- <H1><A NAME="example">EXAMPLE</A></H1>
- <P>A couple of self-contained examples are included in the CGI::Imagemap
- package. They are:</P>
- <PRE>
- testmap - Uses the CGI::Form module
- testmap.old - Uses the old cgi-lib.pl</PRE>
- <P>
- <HR>
- <H1><A NAME="bugs">BUGS</A></H1>
- <P>The untainting stuff is not totally independent -- threading might
- not work very well. This can be fixed if it is important -- in the
- CGI world, I doubt it.</P>
- <P>
- <HR>
- <H1><A NAME="author">AUTHOR</A></H1>
- <P>Mike Heins, Internet Robotics, <<A HREF="mailto:mikeh@iac.net">mikeh@iac.net</A>></P>
- <P>
- <HR>
- <H1><A NAME="credits">CREDITS</A></H1>
- <P>This work is heavily kited from the Perl imagemap program originally
- written by V. Khera <<A HREF="mailto:khera@kciLink.com">khera@kciLink.com</A>>.</P>
- <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
- <TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
- <STRONG><P CLASS=block> CGI::Imagemap.pm - imagemap behavior for CGI programs</P></STRONG>
- </TD></TR>
- </TABLE>
-
- </BODY>
-
- </HTML>
-