Captive Portal - How to manually upload (SFTP) files so it still shows in browse



  • I'm trying to make an interface for users to customize their captive portal with ease.

    A picture file, say captiveportal-myfile.jpg, will then be uploaded via SFTP to /var/db/cpelements

    It shows up np

    Then, after, I browse to http://myserver:8000/captiveportal-myfile.jpg and nothing shows up (HEAD check also fails)! If I upload it using services_captiveportal_filemanager.php it shows up just fine.

    I also noticed there is a link from /usr/local/captiveportal, so tried making a link there, but didn't seem to effect anything.

    So that said, my questions:

    1. How can I upload a file via SFTP for captive portal and have it show up relatively? Alternately, I bet I can workaround by uploading to /www (PFS admin) for public pictures, although this would be a bit bad, structurally, so would only use as last resort.

    2. What actually happens to files uploaded properly to grant/prevent others (from) seeing it?

    		if (!$input_errors) {
    			$element = array();
    			$element['name'] = $name;
    			$element['size'] = $size;
    			$element['content'] = base64_encode(file_get_contents($_FILES['new']['tmp_name']));
    
    			$a_element[] = $element;
    			cpelements_sort();
    
    			write_config();
    			captiveportal_write_elements();
    			header("Location: services_captiveportal_filemanager.php?zone={$cpzone}");
    			exit;
    		}
    

    Thanks.


  • Banned

    1/ You don't do any similar thing. The files are saved in config.xml to not get lost.
    2/ CP is not intended to be used as a webserver. It's a damn simple login page for authentication.
    3/ Also, your port is wrong with 2.2.x

    May I suggest to focus your completely misdirected efforts elsewhere? There's vHosts package, for starters.



  • @doktornotor:

    1/ You don't do any similar thing. The files are saved in config.xml to not get lost.
    2/ CP is not intended to be used as a webserver. It's a damn simple login page for authentication.

    May I suggest to focus your completely misdirected efforts elsewhere? There's vHosts package, for starters.

    I am experimenting with a branch that makes PFsense NOT a simple web server. And every post I've ever had where you told me it can't be done, I've done it. So thanks for the config.xml heads up - and I am going to do it - I can do this programatically by editing the XML file

    This is the developers thread, isn't it? Keep an open mind. My branch is 99% focused on captive portal with VB.NET, JS, and JQuery. You should know by now that I'll find a way, so may as well offer a better solution than my last resort, that we both know sucks



  • afaik port is 8002 for first cp-zone, 8003 for second, n so on

    Default lighttpd daemon port for a Captive Portal zone is based on the zone ID. For example, zone ID 2 uses port 8002. There may not be a daemon on port 8000.



  • @heper:

    afaik port is 8002 for first cp-zone, 8003 for second, n so on

    Hm? I think you may have misunderstood my answer - looking for a way to upload directly to PFS via SFTP where the files will be seen from browser (right now, it has to be uploaded via the pfs admin control panel – it adds a prefix "captiveportal-" to the file name and adds a link to a different section. Even when replicated the same via SFTP, the file will still not show upin browser.


  • Banned

    Of course it won't show in browser when your port is wrong. https://doc.pfsense.org/index.php/2.2_New_Features_and_Changes#Captive_Portal



  • @doktornotor:

    Of course it won't show in browser when your port is wrong. https://doc.pfsense.org/index.php/2.2_New_Features_and_Changes#Captive_Portal

    This branch is based off PFS 2.1.5


  • Banned

    Good that you tell us after ~10 posts on this thread. Reminds me why I did put you on my forum ignore list. And back there you go.



  • @doktornotor:

    Good that you tell us after ~10 posts on this thread. Reminds me why I did put you on my forum ignore list. And back there you go.

    LOL your 1st troll reply had NOTHING to do with my port, so therefore what you say is 100% moot point. How are you a mod again when you only troll? Name 1 post where you only post 100% relevant info without trolling. Find one, I'll paypal you.



  • @dylanh724:

    @doktornotor:

    Of course it won't show in browser when your port is wrong. https://doc.pfsense.org/index.php/2.2_New_Features_and_Changes#Captive_Portal

    This branch is based off PFS 2.1.5

    well even if i wanted to help figure it out … i won't bother with unsupported / old releases. you might have better luck if you try this on a current release.



  • @heper:

    @dylanh724:

    @doktornotor:

    Of course it won't show in browser when your port is wrong. https://doc.pfsense.org/index.php/2.2_New_Features_and_Changes#Captive_Portal

    This branch is based off PFS 2.1.5

    well even if i wanted to help figure it out … i won't bother with unsupported / old releases. you might have better luck if you try this on a current release.

    Fairly confident I didn't see in patch notes any changes even remotely relative to what I want done between your version and mine. If i got the latest version I would have the same issue.

    If you don't know how to resolve it you don't have to respond or just say "I don't know how". There's no shame here sir.

    Edit: latest branch experiences same issue. Happy? Like isaid there's no shame in simply not knowing the answer.

    What's with these toxic users that offer no assistance but spam?


  • LAYER 8 Netgate

    If you upload it to /usr/local/captiveportal or upload it somewhere and link to it from /usr/local/captiveportal it will be available if it includes "captiveportal" in the name.  http://portal_ip:8002/captiveportal-image-asset.png

    There is a rewrite in the lighttpd config that disallows the web server from serving any files directly referenced that do not include the string "captiveportal" in its filename (the name of the link in /usr/local/captiveportal)

    url.rewrite-once = ( "(.captiveportal.)" => "$1", "(.*)" => "/index.php?zone=guest_zone&redirurl=$1" )

    My suggestion is to use one of the many available control panels or CMS to upload assets used in your captive portal page on a separate web server, which is where all but the most basic of portal pages belongs anyway.




  • Banned



  • @Derelict:

    If you upload it to /usr/local/captiveportal or upload it somewhere and link to it from /usr/local/captiveportal it will be available if it includes "captiveportal" in the Nain me.  http://portal_ip:8002/captiveportal-image-asset.png

    There is a rewrite in the lighttpd config that disallows the web server from serving any files directly referenced that do not include the string "captiveportal" in its filename (the name of the link in /usr/local/captiveportal)

    url.rewrite-once = ( "(.captiveportal.)" => "$1", "(.*)" => "/index.php?zone=guest_zone&redirurl=$1" )

    My suggestion is to use one of the many available control panels or CMS to upload assets used in your captive portal page on a separate web server, which is where all but the most basic of portal pages belongs anyway.

    Thanks mate this us perfect and 100% relevant.

    I ended up doing just this - the /usr/local/www/ folder is public so made a /cportal folder and uploaded everything there and direct link. Works fantastic. Only had to change some code for this to work. Users can now upload from .NET software and set custom values to skin the UI with ease.

    This is what the dev forum is about! Whooo


Log in to reply