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

    captive portal

    Scheduled Pinned Locked Moved CE 2.7.0 Development Snapshots (Retired)
    5 Posts 4 Posters 663 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.
    • W
      warning31
      last edited by warning31

      Hello

      I am trying to set captive portal with php shell. but when I import it I get the following error.
      pfsense version 2.7

      Fatal error: Uncaught TypeError: Cannot access offset of type string on string in /usr/local/sbin/pfSsh.php(374) : eval()'d code:16
      Stack trace:
      #0 /usr/local/sbin/pfSsh.php(374): eval()
      #1 /usr/local/sbin/pfSsh.php(379): playback_text('global $config,...')
      #2 /usr/local/sbin/pfSsh.php(232): playback_file('captiveportalco...')
      #3 {main}
      thrown in /usr/local/sbin/pfSsh.php(374) : eval()'d code on line 16
      PHP ERROR: Type: 1, File: /usr/local/sbin/pfSsh.php(374) : eval()'d code, Line: 16, Message: Uncaught TypeError: Cannot access offset of type string on string in /usr/local/sbin/pfSsh.php(374) : eval()'d code:16
      Stack trace:
      #0 /usr/local/sbin/pfSsh.php(374): eval()
      #1 /usr/local/sbin/pfSsh.php(379): playback_text('global $config,...')
      #2 /usr/local/sbin/pfSsh.php(232): playback_file('captiveportalco...')
      #3 {main}

      @warning31

      php shell file

      global $config;
      $config = parse_config(true);

      $config["captiveportal"]["{H_ZONE_NAME}"] = [
      "zone" => "h",
      "descr" => "Hotspot Captive Portal",
      "zoneid" => 3,
      "interface" => "h",
      "maxproc" => null,
      "timeout" => null,
      "idletimeout" => null,
      "freelogins_count" => null,
      "freelogins_resettimeout" => null,
      "enable" => null,
      "auth_method" => "radius",
      "radacct_enable" => null,
      "reauthenticateacct" => "stopstartfreeradius",
      "httpsname" => null,
      "preauthurl" => null,
      "blockedmacsurl" => null,
      "bwdefaultdn" => null,
      "bwdefaultup" => null,
      "certref" => $config["cert"][0]["refid"],
      "radius_protocol" => "PAP",
      "redirurl" => "ggggg",
      "radiusip" => $config["interfaces"]["{H_LAN_INTERFACES}"]["ipaddr"],
      "radiusip2" => null,
      "radiusip3" => null,
      "radiusip4" => null,
      "radiusport" => "1812",
      "radiusport2" => null,
      "radiusport3" => null,
      "radiusport4" => null,
      "radiusacctport" => "1813",
      "radiuskey" => "hotspot",
      "radiuskey2" => null,
      "radiuskey3" => null,
      "radiuskey4" => null,
      "radiusvendor" => "default",
      "radiussrcip_attribute" => "wan",
      "radmac_format" => "default",
      "radiusnasid" => null,
      "page" => null,
      "auth_server" => "radius - LocalRadius",
      "radacct_server" => "LocalRadius"

      ];
      write_config("Captive Portal ");

      1 Reply Last reply Reply Quote 0
      • jimpJ jimp moved this topic from Development on
      • L
        Luanhes
        last edited by

        Hi @warning31 retro bowl,
        Did you find a way to fix this error?

        1 Reply Last reply Reply Quote 0
        • W
          warning31
          last edited by

          no

          GertjanG 1 Reply Last reply Reply Quote 0
          • GertjanG
            Gertjan @warning31
            last edited by

            @warning31

            The playback file should now respect PHP 8.1 syntax.
            Are you sure your playback file is compatible ?
            I can't tell. For me, right now, "7.4" is good enough, I don't use the bleeding edge technology yet.

            It looks like that the eval complains about the very first line, "global $config;" but I'm not sure as it looks fine to me. eval is never clear about what it doesn't like.

            And who knows : maybe "/usr/local/sbin/pfSsh.php" isn't 8.1 ready yet neither ....

            No "help me" PM's please. Use the forum, the community will thank you.
            Edit : and where are the logs ??

            1 Reply Last reply Reply Quote 0
            • jimpJ
              jimp Rebel Alliance Developer Netgate
              last edited by

              pfSsh.php is fine on PHP 8.1, the problem is in that code.

              You can't blindly access multi-level arrays without initializing them properly anymore in PHP.

              https://docs.netgate.com/pfsense/en/latest/development/php-config-arrays.html

              Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

              Need help fast? Netgate Global Support!

              Do not Chat/PM for help!

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