Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Custom CaptivePortal page with PHP/MySQL data capture

    Captive Portal
    4
    9
    8.7k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • P
      pmcweb
      last edited by

      Hello there,

      Firstly apologies if this has been asked before, I have searched on the Wiki and beyond with no success.

      Anyway, I want to set up a CaptivePortal page that firstly captures some data to a MySQL database via PHP. I'm perfectly comfortable doing this on a web server but can someone explain if this is possible on PFSense and how it fits into the architecture of the system. Would I have to install mySQL?

      Any help/advice you could give would be much appreciated.

      Regards

      1 Reply Last reply Reply Quote 0
      • H
        hoba
        last edited by

        You can use php pages for captive portal (just upload them instead of an ordinary html page as login page through the webgui). However you should run the database part on a different system.

        1 Reply Last reply Reply Quote 0
        • C
          cybrsrfr
          last edited by

          For security reasons running MySQL on PFSense Firewall is not recommended and should be run from a different machine. With that in mind you could send the information to PHP on another machine that is running PHP/MySQL by using CURL, or POST/GET over HTTP/HTTPS (https is possible since openssl is installed).

          To get access to the files you can use Diagnostics->Edit File or use sftp (ftp over ssh) to connect into the PFSense file system. To do this you have to enable secure shell from the PFSense web inteface.
          System -> Advanced -> Enable Secure Shell

          Captive Portal Paths that may be useful.

          PFSense GUI forms for captive portal
          /usr/local/captiveportal

          database it is as actually a text file
          /var/db/captiveportal.db

          captive portal functions
          /etc/inc/captiveportal.inc

          1 Reply Last reply Reply Quote 0
          • A
            asidz13
            last edited by

            mcrane… did you know where is freeradius database file? i install freeradius using pfsense package

            1 Reply Last reply Reply Quote 0
            • A
              asidz13
              last edited by

              can anyone tell me where is database real text file situated. Because var/db/captiveportal.db is when users had login.but not users that are not login yet. where http://192.168.xx.xx/services_captiveportal_users.php fetch the data.. thanks in advance

              1 Reply Last reply Reply Quote 0
              • C
                cybrsrfr
                last edited by

                //main directory for Freeradius
                /usr/local/etc/raddb/users

                //user database for Freeradius
                /usr/local/etc/raddb/users

                //Package directory for PFSense packages including Freeradius
                /usr/local/pkg

                However the above users file in the /usr/local/etc/raddb folder is likely to be overwritten by PFSense.

                1 Reply Last reply Reply Quote 0
                • A
                  asidz13
                  last edited by

                  overwritten by PFSense. can u tell me what that mean?

                  1 Reply Last reply Reply Quote 0
                  • H
                    hoba
                    last edited by

                    On bootup or guichanges regarding the radiusserver pfSense will regenrate these files from scratch using the data from config.xml and restart the service.

                    1 Reply Last reply Reply Quote 0
                    • A
                      asidz13
                      last edited by

                      thank hoba for information

                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post
                      Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.