[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: use a gambas web cgi in a phpBB forum
[Thread Prev] | [Thread Next]
- Subject: Re: use a gambas web cgi in a phpBB forum
- From: Bruce Steers <bsteers4@xxxxxxxxx>
- Date: Fri, 28 Nov 2025 09:58:23 +0000
- To: Gambas Mailing List <user@xxxxxxxxxxxxxxxxxxxxxx>
On Thu, 27 Nov 2025, 20:37 Lee, <t.lee.davidson@xxxxxxxxx> wrote: > 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 > Cheers Lee The main issue is with phpBB the token {TEXT} is used to insert the text but it has line feeds and can't be formatted another way. It is the text as it is written. So code like 'var txt = "{TEXT)"; Inputs exactly like.. var txt = "line 1 Line 2 Line 3"; That would work in a bash script but JavaScript can't do multiline strings like that. I've tried putting the text in a <label id="lbl">text here</label> and getting it with document.getElementById("lbl").innerText then writing the text back but still no joy. Yet I tried a hundred things yesterday. I'll try another bunch of things today. Respects BruceS >
| Re: use a gambas web cgi in a phpBB forum | Lee <t.lee.davidson@xxxxxxxxx> |
| use a gambas web cgi in a phpBB forum | Bruce Steers <bsteers4@xxxxxxxxx> |
| Re: use a gambas web cgi in a phpBB forum | Lee <t.lee.davidson@xxxxxxxxx> |