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

Different portal page per location

Scheduled Pinned Locked Moved Captive Portal
10 Posts 3 Posters 33.8k Views
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.
  • M
    mlemmo
    last edited by Jun 30, 2007, 5:59 AM

    Hi,

    Great work, latest snapshot (FreeBSD6/RELENG_1_2) is looking good!

    Any idea on what needs to be done and how difficult it would be to display a specific portal page based on the users subnet/ location?

    Or some other way get the users location and show them a custom portal page.

    I was thinking of getting the client Ip and checking it against a table of know subnets and if there is a match, display the custom page tied to that subnet and a catch-all for unknown subnets.

    I realize this is not foolproof but for wireless client we give out the address, and for the odd case we will have a generic page.

    here is some code I dug up to try and get the correct address:

    function getIP() {
    $ip;

    if (getenv("HTTP_CLIENT_IP")) $ip = getenv("HTTP_CLIENT_IP");
    else if(getenv("HTTP_X_FORWARDED_FOR")) $ip = getenv("HTTP_X_FORWARDED_FOR");
    else if(getenv("REMOTE_ADDR")) $ip = getenv("REMOTE_ADDR");
    else $ip = "UNKNOWN";

    return $ip;

    }

    Thanks

    -Mark

    1 Reply Last reply Reply Quote 0
    • S
      sullrich
      last edited by Jun 30, 2007, 6:20 AM

      See this post:

      http://forum.pfsense.org/index.php/topic,5335.msg32093.html#msg32093

      Basically follow the instructions on how to add a new .php page then redirect from the primary captive portal page to the custom page where you can then show a page per IP address or subnet.

      1 Reply Last reply Reply Quote 0
      • J
        jeroen234
        last edited by Jun 30, 2007, 11:08 PM

        or see this page
        http://forum.pfsense.org/index.php/topic,4937.0.html

        the codes in there make a normal portal page that jumps to a custum .php page that shows youre ipadress

        1 Reply Last reply Reply Quote 0
        • M
          mlemmo
          last edited by Jul 1, 2007, 7:45 AM

          Thanks for the quick replies,

          I did notice the redirect by time thread….

          I tried it but the user experience is not the best, the initial load of index.php plus 2 redirects before the user sees the login page shows as a slow load (too much delay):

          here is the logic:
          User browser is opened, tries to go to site "X" and is redirected to the pfsense lighthttpd index.php page which reads the users ip address etc, and based on config, loads captiveportal.html, which redirects to the script below (redir.php) with then redirects to the correct page.

          I am thinking I could embed the code below directly in the first index.php page and bypass extra redirects.

          $apm = "192.168.99..";
          $pdx = "192.168.100..
          ";
          $ip = $_SERVER['REMOTE_ADDR'];
          if (ereg($apm,$ip)) {
                header('Location: https://phc.hdn.net/apm.html');
          } elseif (ereg($pdx,$ip)) {
                header('Location: https://phc.hdn.net/pdx.html');
          } else {
                header('Location: https://phc.hdn.net/default.html');
          };
          ?>

          comments?

          Thanks
          -M

          1 Reply Last reply Reply Quote 0
          • J
            jeroen234
            last edited by Jul 1, 2007, 5:38 PM

            yust skip 1 more redirect:
            and include the pages on load time by the ip

            
            $apm = "192.168.99..*";
            $pdx = "192.168.100..*";
            $ip = $_SERVER['REMOTE_ADDR'];
            if (ereg($apm,$ip)) {
                  include("https://phc.hdn.net/apm.html");
             } elseif (ereg($pdx,$ip)) {
                  include("https://phc.hdn.net/pdx.html");
             } else {
                  include("https://phc.hdn.net/default.html");
             };
            ?>
            
            
            1 Reply Last reply Reply Quote 0
            • M
              mlemmo
              last edited by Jul 1, 2007, 8:13 PM Jul 1, 2007, 6:14 PM

              Thanks…. getting closer!

              Good catch on using the include instead of the header...

              Now the redirect works but the user login does not redirect to the original requested URL, it just reloads the login page...
              however if I add a hard location in using GUI that location is OK.

              here is what I am using:

              portal page:  (this redirects with the following URL in the client browser)

              https://phc.hdn.net:8001/captiveportal-redir.php?portal_action=https://phc.hdn.net:8001/&portal_redirurl=http://www.craigslist.org/

              The php code to show ip based login page:

              Here I got rid of the Location as a straight include seems fine.

              $test = "192.168.99..*";
              $pdx = "192.168.100..*";
              $apm = "10.10.60..*";
              $ip = $_SERVER['REMOTE_ADDR'];
              if (ereg($apm,$ip)) {
                    include('captiveportal-apm.html');
               } elseif (ereg($pdx,$ip)) {
                    include('captiveportal-pdx.html');
               } else {
                    include('captiveportal-index.html');
               };
              ?>
              
              1 Reply Last reply Reply Quote 0
              • J
                jeroen234
                last edited by Jul 8, 2007, 11:43 AM

                do you have lines to use the entery of the user ?
                like this:

                
                ">
                
                   ">
                
                | 
                
                ### usernaam
                
                 |  |
                | 
                
                ### wachtwoord 
                
                 |  |
                |  |  |
                
                
                1 Reply Last reply Reply Quote 0
                • M
                  mlemmo
                  last edited by Jul 9, 2007, 5:07 AM

                  my form is as such:

                  the only difference is the embedded php for the vars…

                  I will try it with the embedded php...

                  I need to pull this first url the user tries to go to, it seems to use the second , which is the login page...

                  
                  <form name="form1" method="post" action="$PORTAL_ACTION$">
                  
                        Username:
                  
                  Thanks!
                  
                  </form>
                  
                  
                  1 Reply Last reply Reply Quote 0
                  • J
                    jeroen234
                    last edited by Jul 9, 2007, 5:57 AM Jul 9, 2007, 5:20 AM

                    $PORTAL_REDIRURL$ and $PORTAL_ACTION$
                    are only on the first page before the redirect to youre php page
                    with

                    you send them as get variables to youre php page
                    so you need to use $_GET["name of get variable"] to get them in youre php page

                    make redir.php like this:

                    
                    $test = "192.168.99..*";
                    $pdx = "192.168.100..*";
                    $apm = "10.10.60..*";
                    $ip = $_SERVER['REMOTE_ADDR'];
                    if (ereg($apm,$ip)) {
                          include('captiveportal-apm.html');
                     } elseif (ereg($pdx,$ip)) {
                          include('captiveportal-pdx.html');
                     } else {
                          include('captiveportal-index.html');
                     };
                    ?>
                    
                    ">
                    
                       ">
                    
                    | 
                       Username:  
                     | 
                       Password:  
                     |   
                    
                     |
                    
                    
                    1 Reply Last reply Reply Quote 0
                    • M
                      mlemmo
                      last edited by Jul 9, 2007, 7:04 PM

                      That seems to have worked great,.

                      Redirects work!
                      Per Ip subnet redirect to custom login page works also

                      Thanks!

                      -Mark

                      1 Reply Last reply Reply Quote 0
                      10 out of 10
                      • First post
                        10/10
                        Last post
                      Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.
                        This community forum collects and processes your personal information.
                        consent.not_received