• SBBS + PHP and URL paths

    From alterego@VERT/ALTERANT to All on Wed Aug 12 13:44:59 2020
    Howdy,

    I know reading the wiki you can have SBBS call php either via CGI or FPM.

    Is there a way to have FPM called, when the suffix is not ending with .php?

    EG: Lets say I have a url http://mysite/foo/bar - I actually want a nominated file (let say index.php) to be called with /foo/bar.

    So instead of writing the URL as http://mysite/index.php/foo/bar (which works), how can I have http://mysite/foo/bar resolve to index.php being called?

    Is it possible?

    (I know I can have nginx doing this - and that might be what I need to do, if I cant get sbbs's web server doing it...)

    ...δεσ∩

    ... Witch! Witch! They'll burn ya! Hag, stardate unknown.

    ---
    ■ Synchronet ■ Alterant | an SBBS in Docker on Pi!
  • From Digital Man@VERT to alterego on Tue Aug 11 23:42:34 2020
    Re: SBBS + PHP and URL paths
    By: alterego to All on Wed Aug 12 2020 01:44 pm

    Howdy,

    I know reading the wiki you can have SBBS call php either via CGI or FPM.

    Is there a way to have FPM called, when the suffix is not ending with .php?

    EG: Lets say I have a url http://mysite/foo/bar - I actually want a nominated file (let say index.php) to be called with /foo/bar.

    So instead of writing the URL as http://mysite/index.php/foo/bar (which works), how can I have http://mysite/foo/bar resolve to index.php being called?

    Is it possible?

    Yeah, look at wiki.synchro.net. It's a dokuwiki.php served up via Synchronet web server.

    (I know I can have nginx doing this - and that might be what I need to do, if I cant get sbbs's web server doing it...)

    $ cat webctrl.ini
    ;Realm=Enter your BBS QWK ID:
    PathInfoIndex=yes
    JSPreExec=load(js.startup_dir+'/doku_rewrite.js');
    Rewrite=doku_rewrite();
    [*.php]
    FastCGISocket=127.0.0.1:9000

    $ cat doku_rewrite.js
    function doku_rewrite()
    {
    var n=http_request.request_string;

    // Simple replacements...
    n=n.replace(/^([^\?]*\/)_media\/(.*)/,"$1lib/exe/fetch.php?media=$2");
    n=n.replace(/^([^\?]*\/)_detail\/(.*)/,"$1lib/exe/detail.php?media=$2");
    n=n.replace(/^([^\?]*\/)_export\/([^\/]+)\/(.*)/,"$1doku.php?do=export_$ 2&id=$3");

    // This handles adding doku.php to the index bit of the URI
    var pi = http_request.path_info;
    if (pi[0]=='/') {
    pi=pi.substr(1).replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, " \\$&");;
    n=n.replace(new RegExp('^(.*)('+pi+'(?:\\?.*)?)$'), "$1doku.php? id=$2");
    }

    // If the URI ends with a slash, stuff in doku.php at the end.
    n=n.replace(/^([^\?]*\/)(\?.*)?$/,"$1doku.php$2");

    // index.php becomes doku.php
    n=n.replace(/^([^\?]*\/)index.php/,"$1doku.php");

    // Handle it.
    if (n != http_request.request_string) {
    // Replace all but the first '?' with '&'
    n=n.replace(/(^.*\?[^\?]*)\?/g,'$1&');
    http_request.request_string = n;
    return true;
    }
    return false;
    }

    If you have questions, best to ask Deuce in #synchronet at irc.synchro.net

    digital man

    Synchronet "Real Fact" #4:
    Synchronet version 3 is written mostly in C, with some C++, x86 ASM, and Pascal.
    Norco, CA WX: 68.5°F, 56.0% humidity, 0 mph S wind, 0.00 inches rain/24hrs
    ---
    ■ Synchronet ■ Vertrauen ■ Home of Synchronet ■ [vert/cvs/bbs].synchro.net
  • From alterego@VERT/ALTERANT to Digital Man on Wed Aug 12 23:24:31 2020
    Re: SBBS + PHP and URL paths
    By: Digital Man to alterego on Tue Aug 11 2020 11:42 pm

    Yeah, look at wiki.synchro.net. It's a dokuwiki.php served up via Synchronet web server.
    $ cat webctrl.ini
    PathInfoIndex=yes

    Perfect, thanks.

    Turned out I only needed PathInfoIndex - sweet...

    ...δεσ∩

    ... When I was crossing the border into Canada, they asked if I had any firearms with me. I said, "What do you need?"

    ---
    ■ Synchronet ■ Alterant | an SBBS in Docker on Pi!
  • From Digital Man@VERT to alterego on Wed Aug 12 10:20:56 2020
    Re: SBBS + PHP and URL paths
    By: alterego to Digital Man on Wed Aug 12 2020 11:24 pm

    Re: SBBS + PHP and URL paths
    By: Digital Man to alterego on Tue Aug 11 2020 11:42 pm

    Yeah, look at wiki.synchro.net. It's a dokuwiki.php served up via Synchronet web server.
    $ cat webctrl.ini
    PathInfoIndex=yes

    Perfect, thanks.

    Turned out I only needed PathInfoIndex - sweet...

    Awesome. I expected the answer was in there somewhere. :-)

    digital man

    Sling Blade quote #10:
    Morris: I stand on the hill, not for thrill, but for the breath of a fresh kill Norco, CA WX: 83.9°F, 38.0% humidity, 0 mph W wind, 0.00 inches rain/24hrs
    ---
    ■ Synchronet ■ Vertrauen ■ Home of Synchronet ■ [vert/cvs/bbs].synchro.net