[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: use a gambas web cgi in a phpBB forum


On 11/27/25 12:50 PM, Bruce Steers wrote:
Hi all. I am trying to make a gambas highlighter in a web cgi script.

I am having problems with loosing the line feeds when using Request.Query in a phpBB custom bbcode so i need to use POST method instead.

on the forum side i can use javascript (and possibly php) in custom bbcode.

the cgi simply reads the Query string or Request.ContentLength and runs it through gb.highlight.
looks like this...

Public Sub MakeHtml() As String

   Dim iPos, iPos2 As Integer
   Dim sMode As String = "gambas"
   Dim s As String = FromUrl(Request.Query)

   If s Begins "mode=" Then ' check for mode= in Query string
     iPos = InStr(s, "=")
     iPos2 = InStr(s, "&")
     If Not iPos2 Then iPos2 = s.Len
     sMode = Mid(s, iPos + 1, iPos2 - iPos - 1)
     s = Mid(s, iPos2 + 1)
   Endif

' if string was not passed as Query then read POST
   If Not s And If Request.ContentLength Then s = Read Request.ContentLength

' write a table with gambas highlighted html.
  Print "<table width=100% height=100% border=1 cellpadding=10><tr height=3em><th height=3em align=left>" & sMode & " code</ th></tr><tr><td>"
   Print TextHighlighter[sMode].ToHTML(s)
   Print "</td></tt></table>"

End

I cannot get it to work though :(
My LFs are getting stripped :(
i can only add the text in the url and i think it needs to be a POST method instead but i can't figure it out.

My phpBB custom code is this..
<iframe width=100% height=200px% src="http://138.68.116.47/cgi-bin/GambasHighlight.gambas?{TEXT} <http://138.68.116.47/cgi-bin/ GambasHighlight.gambas?{TEXT}>">
</iframe>
that gives what the attached picture shows.

but it needs to be something like.
<script>
open "http://138.68.116.47/cgi-bin/GambasHighlight.gambas <http://138.68.116.47/cgi-bin/GambasHighlight.gambas>"
HTTP POST {TEXT}
Write response to page
</script>

Any advice on how to POST text to a cgi from javascript or php and write the data would be appreciated?

Thanks all
BruceS

The text you POST should be encoded so that LFs are represented as "%0A". You should be able to use Javascript's encodeURI() function for that. Then, you should also be able to use the Request.Post properties to read the data if the text as been assigned to a query parameter or you set Request.Debug to True and simply read Request.Post.Contents.

To post the data, you can use Fetch or XMLHttpRequest in JS:
https://www.freecodecamp.org/news/javascript-post-request-how-to-send-an-http-post-request-in-js/


--
Lee

--- Gambas User List Netiquette [https://gambaswiki.org/wiki/doc/netiquette] ----
--- Gambas User List Archive [https://lists.gambas-basic.org/archive/user] ----


Follow-Ups:
Re: use a gambas web cgi in a phpBB forumBruce Steers <bsteers4@xxxxxxxxx>
References:
use a gambas web cgi in a phpBB forumBruce Steers <bsteers4@xxxxxxxxx>