<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=iso-8859-1"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";
mso-fareast-language:EN-US;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=NO-BOK link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span lang=EN-US>Hi there,<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>We are running a service where the access to mapfiles needs to be password protected. I’m using PHP Session for that, and until recently I’ve used a wrapper which looked like this:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>session_start();</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>$oParams = </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>new </span></b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>HawkSoftware\URL\REQUESTParameters();<o:p></o:p></span></p><p class=MsoNormal style='text-indent:35.4pt;text-autospace:none'><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>try </span></b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>{</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> $oParams->RemoveKey(</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>"MAP"</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>, </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>false</span></b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>);</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> } </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>catch </span></b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>(Exception $e) {</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> }</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> $oParams-></span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>Items</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>[</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>'map'</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>] = $_SESSION[</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>'MAPFILE'</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>];<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>$strURL = </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>"C:/ms4w/Apache/cgi-bin-hidden/mapserv.exe QUERY_STRING=\"" </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>. $oParams->GetUTF8DecodedString() . </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>"\""</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>if </span></b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>($oParams-></span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>Items</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>[</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>'encode'</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>] == </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>'true'</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>) {</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>echo </span></b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>utf8_encode(HawkSoftware\Execution\Util::<i>GetOutput</i>($strURL));</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>} </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>else </span></b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>{</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>echo </span></b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>HawkSoftware\Execution\Util::<i>GetOutput</i>($strURL);</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>}</span><span lang=EN-US><o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>The GetOutput-function uses passthru(). The only problem with that one is the command line restriction (of somewhat 8k characters) in windows, which sometimes becomes a limitation for requesting over 70 ID’s on a WFS request (those Filter strings become very long!!). Also, I don’t think it’s the most efficient way to fetch data from mapserv.exe .<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>So I saw the <a href="http://mapserver.org/ogc/mapscript.html">http://mapserver.org/ogc/mapscript.html</a> and made a script like this:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal style='text-indent:35.4pt;text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>$oMap = </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>new </span></b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>\mapObj($_SESSION[</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>'MAPFILE'</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>]);</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> $oRequest = </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>new </span></b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>OWSRequestObj();</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> $oRequest->loadparams();</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> ms_ioinstallstdouttobuffer();</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> $oMap->owsdispatch($oRequest);</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> $strContType = ms_iostripstdoutbuffercontenttype();</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>if </span></b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>($strContType == </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>'image/png'</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>) {</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> header(</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>'Content-type: image/png'</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>);</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> }</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>if</span></b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>($_REQUEST[</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>'encode'</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>]) {</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>echo </span></b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>utf8_encode(ms_iogetstdoutbufferstring());</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> } </span><b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>else </span></b><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'>{</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> ms_iogetStdoutBufferBytes();</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> }</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:10.0pt;font-family:"Courier New";color:black'> ms_ioresethandlers();</span><span lang=EN-US><o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>This one works great on GET requests. However, it does not work on POST requests, it will print “Post body is short” (I really need the post requests, as GET does not carry enough data). This is a known issue, but I can’t say I know what to do about it. Some say it’s problem with the fastcgi module, and it will run fine on cgi. But how do I get mapscript to run on CGI? Or is this the wrong approach?<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>I am running ms4w on Windows Server 2008 .<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>Best regards,<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>Håkon<o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p></div></body></html>