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

Re: [StrongED] sending PHP file to browser

In message <538a0009-169d-5447-d613-da3adaa7599a@xxxxxxxxxxxxxxxxxx>
          Vince M Hudd <atdotcodotuk@xxxxxxxxxxxxxxxxxx> wrote:

> On 14/08/2018 19:24, Jim Nagel wrote:
> > In other words, the first part of the file's pathname needs to be
> > replaced by http://localhost/ , but determining exactly how much of
> > the path to change might be tricky to program, since some sites have
> > more deeply nested directories than this one.
> This, however, is the more interesting bit - it needs to be dealt with 
> before the star command, and therefore probably needs some knowledge of 
> how StrongED works.

Doing it straight from StrongED is out of the question IMO. For example
there are no provisions to munge pathnames.

> OTOH, another alternative would be to issue a star command to invoke an 
> external program that handles changing the file path to a URL, then 
> calls either *URIdispatch or the equivalent SWI.

Yes, that would seem to be the best way to achieve what Jim wants.

> A program that does that shouldn't be difficult to knock together.

Here's what I threw together. Bit rough but it seems to do the job.

REM -------------------------------------------------------------------
DIM Block% 256

REM read location of website root
SYS "OS_ReadVarVal","webjames-thissite$dir",Block%,256,0,0 TO ,,Length%
Block%?Length% = 13 : Site$ = $Block%

REM read name of file to launch
SYS "OS_ReadVarVal","StrongED$Tmp_FileName",Block%,256,0,0 TO ,,Length%
Block%?Length% = 13 : File$ = $Block%

REM if file is part of site, launch it
IF LEFT$(File$,LEN(Site$)) = Site$ THEN

  REM get location relative to root
  Local$ = MID$(File$,LEN(Site$)+2)

  REM unixify local file name
  FOR I% = 1 TO LEN(Local$)
    CASE MID$(Local$,I%,1) OF
    WHEN "." : MID$(Local$,I%,1) = "/"
    WHEN "/" : MID$(Local$,I%,1) = "."

  REM create full webaddress and launch it
  Url$ = "http://localhost/"; + Local$ + CHR$(0)
  SYS "URI_Dispatch",0,Url$,0

REM -------------------------------------------------------------------


StrongED Developer

To unsubscribe send a mail to StrongED+unsubscribe@xxxxxxxxxxx
List archives and instructions at