Commit 714f1521 authored by Franco Fichtner's avatar Franco Fichtner

openvpn: fix config handling on PHP 7.1 #1733

The day has come that this "bootstrap" logic broke horribly,
preventing us from upgrading to PHP 7.1 with the initial 17.7.

Add a config_read_array() function that emulates *all* potentially
required steps and grabs the array reference so that the code can
be migrated easily.

Hopefully this also works on PHP 7.0.  ;)

(cherry picked from commit 4c179c23)
parent 3b39d0fc
......@@ -278,6 +278,22 @@ function cleanup_backups()
}
}
function &config_read_array()
{
global $config;
$current = &$config;
foreach (func_get_args() as $key) {
if (!isset($current[$key]) || !is_array($current[$key])) {
$current[$key] = array();
}
$current = &$current[$key];
}
return $current;
}
function make_config_revision_entry($desc = '')
{
if (!empty($_SESSION['Username'])) {
......
......@@ -32,11 +32,7 @@ require_once("plugins.inc.d/openvpn.inc");
require_once("services.inc");
require_once("interfaces.inc");
if (!isset($config['openvpn']['openvpn-client'])) {
$config['openvpn']['openvpn-client'] = array();
}
$a_client = &$config['openvpn']['openvpn-client'];
$a_client = &config_read_array('openvpn', 'openvpn-client');
$vpnid = 0;
$act = null;
......
......@@ -32,7 +32,6 @@ require_once("plugins.inc.d/openvpn.inc");
require_once("services.inc");
require_once("interfaces.inc");
// define all fields used in this form
$all_form_fields = "custom_options,disable,common_name,block,description
,tunnel_network,tunnel_networkv6,local_network,local_networkv6,remote_network
,remote_networkv6,gwredir,push_reset,dns_domain,dns_server1
......@@ -40,11 +39,7 @@ $all_form_fields = "custom_options,disable,common_name,block,description
,netbios_enable,netbios_ntype,netbios_scope,wins_server1
,wins_server2,ovpn_servers";
// read config.
if (!isset($config['openvpn']['openvpn-csc'])) {
$config['openvpn']['openvpn-csc'] = array();
}
$a_csc = &$config['openvpn']['openvpn-csc'];
$a_csc = &config_read_array('openvpn', 'openvpn-csc');
$vpnid = 0;
$act=null;
......
......@@ -32,10 +32,7 @@ require_once("plugins.inc.d/openvpn.inc");
require_once("services.inc");
require_once("interfaces.inc");
if (!isset($config['openvpn']['openvpn-server'])) {
$config['openvpn']['openvpn-server'] = array();
}
$a_server = &$config['openvpn']['openvpn-server'];
$a_server = &config_read_array('openvpn', 'openvpn-server');
$act = null;
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment