Ola!
Continuando com os estudos em CGI, temos diversas maneiras de conversar com paginas em HTML + Apache2 + Harbour essa é mais uma que estou aprendendo.
#!/usr/local/bin/hbrun
REQUEST HB_CODEPAGE_UTF8
function main(...)
LOCAL cEOL := + hb_eol() + hb_eol()
LOCAL cTemp, nRead, nLen, aList, xValue
hb_cdpSelect( "UTF8" )
OutStd('Content-type: text/html' + cEOL )
OutStd('<!DOCTYPE html>' + hb_eol() )
OutStd('<html>' + hb_eol() )
OutStd('<head>' + hb_eol() )
OutStd('<meta charset="UTF-8"/>' + hb_eol())
OutStd('</head>' + hb_eol() )
IF "POST" $ Upper( hb_GetEnv( "REQUEST_METHOD" ) ) //aqui retirada da hbtip
nLen := val(hb_getenv("CONTENT_LENGTH"))
cTemp := Space( nLen )
IF ( nRead := FRead( hb_GetStdIn(), @cTemp, nLen ) ) != nLen
OutStd("<p>Post error read " + hb_ntos( nRead ) + " instead of " + hb_ntos( nLen ) + hb_eol() )
ELSE
OutStd("<p>Post string is: " , HtmlDecodeUrl(cTemp) + hb_eol())
ENDIF
ENDIF
OutStd('<br>')
aList := hb_RegExSplit( "&", cTemp )
FOR EACH xValue IN aList
xValue := hb_RegExSplit( "=", xValue )
xValue[ 2 ] := StrTran( xValue[ 2 ], "+", " " )
OutStd( xValue[ 1 ], HtmlDecodeUrl(xValue[ 2 ]) + "<br>"+ hb_eol())
NEXT
OutStd("</body></html>" + hb_eol())
Return Nil
FUNCTION HtmlDecodeUrl( cString ) //Acrescentei alguns caracteres acentuados nesta função. Retirada de uma classe da xhb.hbc
RETURN hb_StrReplace( cString, { ;
"%26" => "&", ;
"%2B" => "+", ;
"%20" => " ", ;
"%27" => "'", ;
"+" => " ", ;
"%2C" => ",", ;
"%21" => "!", ;
"%7E" => "~", ;
"%23" => "#", ;
"%24" => "!", ;
"%25" => "%", ;
"%5E" => "^", ;
"%28" => "(", ;
"%29" => ")", ;
"%60" => "`", ;
"%2F" => "/", ;
"%C3%A0" => "à",;
"%C3%A1" => "á",;
"%C3%A2" => "â",;
"%C3%A3" => "ã",;
"%C3%80" => "À",;
"%C3%81" => "Á",;
"%C3%82" => "Â",;
"%C3%83" => "Ã",;
"%C3%A8" => "è",;
"%C3%A9" => "é",;
"%C3%AA" => "ê",;
"%E1%BA%BD" => "ẽ",;
"%C3%89" => "É",;
"%C3%88" => "È",;
"%C3%A7" => "ç",;
"%C3%87" => "Ç",;
"%C3%8A" => "Ê",;
"%E1%BA%BC" => "Ẽ",;
"%C3%8C" => "Ì",;
"%C3%8D" => "Í",;
"%C3%8E" => "Î",;
"%C4%A8" => "Ĩ",;
"%C3%B2" => "ò",;
"%C3%B3" => "ó",;
"%C3%B4" => "ô",;
"%C3%B5" => "õ",;
"%C3%92" => "Ò",;
"%C3%93" => "Ó",;
"%C3%94" => "Ô",;
"%C3%95" => "Õ",;
"%C3%BA" => "ú",;
"%C3%B9" => "ù",;
"%C5%A9" => "ũ",;
"%C3%BB" => "û",;
"%C3%9A" => "Ú",;
"%C3%99" => "Ù",;
"%C5%A8" => "Ũ",;
"%C3%9B" => "Û"})
Isso é um estudo de como pegar os dados da pagina HTML, temos hb_tip, hbhttpd... com funções básicas para essa finalidade.
Saudações,
Itamar M. Lins Jr.