From 448cc756b110d2334a8db25e60c5cf322609fda5 Mon Sep 17 00:00:00 2001 From: jim-p Date: Wed, 3 Aug 2011 12:35:17 -0400 Subject: Work around the fact that get_configured_interface_list re-parses the config and kills the reference made before it, which was making it impossible to delete a pppoe instance. --- usr/local/www/interfaces_ppps.php | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'usr/local/www/interfaces_ppps.php') diff --git a/usr/local/www/interfaces_ppps.php b/usr/local/www/interfaces_ppps.php index 1e22bd0..2b5329a 100644 --- a/usr/local/www/interfaces_ppps.php +++ b/usr/local/www/interfaces_ppps.php @@ -43,16 +43,14 @@ require("guiconfig.inc"); require_once("functions.inc"); -if (!is_array($config['ppps']['ppp'])) - $config['ppps']['ppp'] = array(); - -$a_ppps = &$config['ppps']['ppp'] ; - function ppp_inuse($num) { - global $config, $g, $a_ppps; + global $config, $g; $iflist = get_configured_interface_list(false, true); + if (!is_array($config['ppps']['ppp'])) + return false; + foreach ($iflist as $if) { - if ($config['interfaces'][$if]['if'] == $a_ppps[$num]['if']) + if ($config['interfaces'][$if]['if'] == $config['ppps']['ppp'][$num]['if']) return true; } return false; @@ -62,16 +60,21 @@ if ($_GET['act'] == "del") { /* check if still in use */ if (ppp_inuse($_GET['id'])) { $input_errors[] = gettext("This point-to-point link cannot be deleted because it is still being used as an interface."); - } else { - unset($a_ppps[$_GET['id']]['pppoe-reset-type']); - handle_pppoe_reset($a_ppps[$_GET['id']]); - unset($a_ppps[$_GET['id']]); + } elseif (is_array($config['ppps']['ppp']) && is_array($config['ppps']['ppp'][$_GET['id']])) { + + unset($config['ppps']['ppp'][$_GET['id']]['pppoe-reset-type']); + handle_pppoe_reset($config['ppps']['ppp'][$_GET['id']]); + unset($config['ppps']['ppp'][$_GET['id']]); write_config(); header("Location: interfaces_ppps.php"); exit; } } +if (!is_array($config['ppps']['ppp'])) + $config['ppps']['ppp'] = array(); +$a_ppps = $config['ppps']['ppp']; + $pgtitle = gettext("Interfaces: PPPs"); include("head.inc"); -- cgit v1.1