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

    Custom scripts in 25.11 Getting Parse_config() Crash

    Scheduled Pinned Locked Moved General pfSense Questions
    3 Posts 2 Posters 183 Views 2 Watching
    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.
    • T Offline
      townsenk64
      last edited by

      In 25.7 I had used a couple custom scripts to change a gateway rule via local ssh
      the script looks like this```
      code_text

      <?php
      require_once("globals.inc");
      require_once("filter.inc");
      require_once("util.inc");
      require_once("config.inc");
      
      global $config;
      
      $config = parse_config(true);
      foreach ($config['filter']['rule'] as &$value) {
          if (strpos(strtolower($value['descr']), 'allow access') !== false) {
              if (strpos(strtolower($value['gateway']), 'wan') !== false) {
      		$value['gateway'] = 'vpnbalance';
      		}
      		else
      		{
      		$value['gateway'] = 'WAN';
      		}
          }
      }
      write_config("Configuration Changed");
      $retval |= filter_configure();
      ?>
      
      Now with 25.11 I get a Crash Report with the following error. 
      
      ---
      
      Crash report details:
      
      PHP Errors:
      [13-Dec-2025 12:01:50 America/Chicago] PHP Fatal error:  Uncaught Error: Call to undefined function parse_config() in /usr/local/bin/kvpn.php:12
      Stack trace:
      #0 {main}
        thrown in /usr/local/bin/kvpn.php on line 12
      ___
      
      
      It appears that the parse_config() function has been moved or no longer exists.
      Any ideas?
      dennypageD 1 Reply Last reply Reply Quote 0
      • dennypageD Offline
        dennypage @townsenk64
        last edited by

        @townsenk64 You need to use the config_* functions. The documentation on the switch to PHP 8 (back in 23.01) should get you going:

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

        T 1 Reply Last reply Reply Quote 1
        • T Offline
          townsenk64 @dennypage
          last edited by

          @dennypage Thanks that sure enough did get me started and AI had me a working script in less that a minute.

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