[Gambas-user] gambas + cgi
Rob Kudla
sourceforge-raindog2 at ...94...
Mon Jan 30 14:45:50 CET 2006
On Mon January 30 2006 02:36, Matthias Laur wrote:
> Hi Daniel,
>
> that looks nice. I will try it soon. One little question: How
> can I decide the variables? In php by name, but if I reed them
> together in Buf?
The following two functions are what Benoit uses to do that in
the documentation system:
PRIVATE FUNCTION DecodeURL(sUrl AS String) AS String
DIM sRes AS String
DIM iPos AS Integer
DIM sCar AS String
FOR iPos = 1 TO Len(sUrl)
sCar = Mid$(sUrl, iPos, 1)
IF sCar = "+" THEN
sCar = " "
ELSE IF sCar = "%" THEN
sCar = Chr$(Val("&H" & Mid$(sUrl, iPos + 1, 2)))
iPos = iPos + 2
ENDIF
sRes = sRes & sCar
NEXT
sRes = Replace(sRes, "\r", "")
RETURN sRes
END
PRIVATE FUNCTION GetForm() AS Collection
DIM sLine AS String
DIM iPos AS Integer
DIM sVal AS String
DIM sName AS String
DIM cForm AS NEW Collection
DIM sForm AS String
READ #File.In, sForm, Val(Application.Env["CONTENT_LENGTH"])
FOR EACH sLine IN Split(sForm, "&")
iPos = InStr(sLine, "=")
IF iPos = 0 THEN CONTINUE
sVal = DecodeURL(Mid$(sLine, iPos + 1))
sName = Left$(sLine, iPos - 1)
cForm[sName] = sVal
NEXT
RETURN cForm
END
Rob
More information about the User
mailing list