• Photos

    From TinTino@1:103/705 to echicken on Tue Jan 24 15:03:16 2017
    Hi,
    I has made a private photo album, photo.xjs is in /pages and webctrl set to level 99.
    But how i protect my photos? if I put them in /photo, others can download them directly,
    and if I put a webctrl.ini in that dir, i get a extra login popup.
    How can I get rid of this extra login popup when I already logged in?

    /Tintino

    ---
    * Synchronet * Pepzi - Pepzi.se 500/100 Mbits
    * Origin: Vertrauen - vert.synchro.net (1:103/705)
  • From echicken@1:103/705 to TinTino on Tue Jan 24 13:13:16 2017
    Re: Photos
    By: TinTino to echicken on Tue Jan 24 2017 15:03:16

    I has made a private photo album, photo.xjs is in /pages and webctrl set to level 99.
    But how i protect my photos? if I put them in /photo, others can download them directly,
    and if I put a webctrl.ini in that dir, i get a extra login popup.
    How can I get rid of this extra login popup when I already logged in?

    I don't have a good solution for this at the moment. When a user tries to directly access a file that is restricted by webctrl.ini, the server itself enforces the use of HTTP authentication.

    One option would be to embed the username and password in the src URL in your img tags. I don't think this is a great idea.

    <?xjs
    var p = user.alias + ':' + user.security.password + '@' + http_request.host;

    <img src="//<?xjs write(p); ?>/photos/photo.jpg">

    Another option would be to read and dump the image data rather than having the user's browser request the files directly:

    <?xjs
    function readPhoto(file) {
    var f = new File(file);
    if (!f.open('r')) return '';
    var p = base64_encode(f.read());
    f.close();
    return p;
    }
    var photos = directory('/sbbs/web/root/photos/*.jpg');


    <?xjs for (var p = 0; p < photos.length; p++) { ?>
    <img src="data:image/jpg;base64,<?xjs write(readPhoto(photos[p])); ?>">
    <?xjs } ?>

    ---
    echicken
    electronic chicken bbs - bbs.electronicchicken.com - 416-273-7230
    * Synchronet * electronic chicken bbs - bbs.electronicchicken.com
    * Origin: Vertrauen - vert.synchro.net (1:103/705)
  • From TinTino@1:103/705 to echicken on Tue Jan 24 20:33:08 2017
    Hi,

    Thanks for the solutions. I will test them and see if I find something that works well.

    /tintino

    ---
    * Synchronet * Pepzi - Pepzi.se 500/100 Mbits
    * Origin: Vertrauen - vert.synchro.net (1:103/705)
  • From echicken@1:103/705 to TinTino on Tue Jan 24 15:11:30 2017
    Re: Photos
    By: TinTino to echicken on Tue Jan 24 2017 20:33:08

    Thanks for the solutions. I will test them and see if I find something that works well.

    The second option is probably best. It also has the benefit of letting you store the files wherever you like; there's no need for them to be inside of your web server's document root.

    Note that a couple of '?>' closers were missing from the examples I posted; I think the editor stripped them out since they look like quote markers at the beginning of a line.

    ---
    echicken
    electronic chicken bbs - bbs.electronicchicken.com - 416-273-7230
    * Synchronet * electronic chicken bbs - bbs.electronicchicken.com
    * Origin: Vertrauen - vert.synchro.net (1:103/705)
  • From TinTino@1:103/705 to echicken on Sun Jan 29 19:18:44 2017
    The second option is probably best. It also has the benefit of letting you store the files wherever you like; there's no need for them to be inside of your web server's document root.

    The second i cant get to work. It say data error in all pictures.

    But first exempel works fine.

    Thanks.

    /Tintino

    ---
    * Synchronet * Pepzi - Pepzi.se 500/100 Mbits
    * Origin: Vertrauen - vert.synchro.net (1:103/705)
  • From echicken@1:103/705 to TinTino on Sun Jan 29 13:54:46 2017
    Re: Photos
    By: TinTino to echicken on Sun Jan 29 2017 19:18:44

    The second i cant get to work. It say data error in all pictures.

    But first exempel works fine.

    The first example is very poor, since it embeds the current username and password all over the place in the page.

    If you want to send me your script or post it somewhere, I can take a look at why the second method may not be working. It works fine for me here.

    ---
    echicken
    electronic chicken bbs - bbs.electronicchicken.com - 416-273-7230
    * Synchronet * electronic chicken bbs - bbs.electronicchicken.com
    * Origin: Vertrauen - vert.synchro.net (1:103/705)