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

    Custom Captive Portal index.php on 2.0.3 - code 99% complete need final 1%

    Scheduled Pinned Locked Moved Bounties
    3 Posts 1 Posters 9.5k 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 Offline
      mercato
      last edited by

      hello. this should be an easy $50 for someone who is more familiar with pfsense than us… I hope

      this is urgently needed so if you think you can do it please reply. I hope there is enough info here but i will update the post if not

      what we are trying to do seems very simple - a custom CP login page in a hotel
      No Authentication
      index.php with 3 fields for user data - name, email address and "reason for visiting" (with some JS validation) and a Submit button

      1. write the above data to customportal-data.csv when the user hits the Submit button
      2. redirect the user to the hotel's website when the user hits the Submit button
      3. email the csv file on a weekly basis to a fixed email address

      where we have got to... see the index.php below

      if we omit [value="Continue"] from the line [however if we omit [value="Continue"] then the redirect does not work

      if we include [value="Continue"] then the line is like this [
      finally we have tried sendmail and pear for the weekly email to attach csv with no success at all - ran into errors with both

      the only options configured in the GUI for CP are
      Enable
      LAN interface
      Idle timeout 60 mins
      After authentication redirection URL
      No Authentication

      index.php to follow … javascript validation has been removed for testing purposes... hotel name changed to xxxxxxxx

      if (isset($_POST) && !empty($_POST)) {
        $csv = $_POST;
        unset($csv['redirurl'], $csv['accept_x'], $csv['accept_y']);
        list($fname, $lname) = explode(' ', $csv['name']);
        unset($csv['name']);
        array_unshift($csv, $fname, $lname);
        $f = fopen('captiveportal-data.csv', 'a');
        fputcsv($f, $csv);
        fclose($f);
        header("Location: http://www.xxxxxxxxxx.com/wifi-landing-page?user=$fname");
        exit();
      }

      ?>

      <title>Hayfield Manor Wi-Fi Login</title>

      XXXXX

      Wi-Fi Login

      <form method="post" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>">

      Your Name

      Your Email Address

      Reason for your visit to XXXX?

      <select name="reason" id="reason">  <option value="">Please choose from the list below…</option>  <option>Leisure Accomodation Guest</option>  <option>Corporate Accomodation Guest</option>  <option>Conference Attendee</option>  <option>Dining at XXXXX</option>  <option>Meeting People at XXXXX</option></select>

      </form>

      1 Reply Last reply Reply Quote 0
      • M Offline
        mercato
        last edited by

        URL after Submit if [value="Continue"] is omitted

        http://192.168.1.1:8000/index.php?redirurl=http%3A%2F%2Fwww.xxxxx.ie%2Fwifi-landing-page%3Fuser%3DZiggy

        I realise that [value="Continue"] is mandatory for the redirect but i hope the above helps

        1 Reply Last reply Reply Quote 0
        • M Offline
          mercato
          last edited by

          still editing the redirect URL to hide the hotel name so please ignore the difference between xxxxxxxxxx.com in the php code and xxxxxx.ie in the previous post

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