From 2f381b82fa67ad262c391d96230696a4f66f6653 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Sat, 5 Jan 2008 05:04:57 +0000 Subject: Reapply patches from ticket #1532 --- etc/inc/pfsense-utils.inc | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) (limited to 'etc/inc/pfsense-utils.inc') diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc index 38228bd..bfc3808 100644 --- a/etc/inc/pfsense-utils.inc +++ b/etc/inc/pfsense-utils.inc @@ -2452,21 +2452,15 @@ function cleanup_opt_interfaces_after_removal($opt_interface_num) { unlink_if_exists("{$g['tmp_path']}/config.cache"); $config_file = file_get_contents("/cf/conf/config.xml"); /* loop through and reassign deleted items */ - for ($i = 500; isset ($config['interfaces']['opt' . $i]); $i--) { - if ($i < $opt_interface_num) - break; - if ($i == $opt_interface_num) { - /* item should be deleted */ - str_replace("opt" . $i, "optXXXX", $config_file); - } - } - /* loop through and reassign optional items */ - for ($i = 500; isset ($config['interfaces']['opt' . $i]); $i--) { - if ($i < $opt_interface_num) - break; - /* replace opt$i with $i -1 */ - str_replace("opt" . $i, "opt" . ($i -1), $config_file); - } + $orig = array('opt'.$opt_interface_num,'OPT'.$opt_interface_num); + $repl = array('optXXXX','OPTXXXX'); + for ($i = $opt_interface_num+1; isset ($config['interfaces']['opt' . $i]); $i++) { + array_push($orig,'opt'.$i); + array_push($repl,'opt'.($i -1)); + array_push($orig,'OPT'.$i); + array_push($repl,'OPT'.($i -1)); + } + $config_file = str_replace($orig, $repl, $config_file); $fd = fopen("/cf/conf/config.xml", "w"); fwrite($fd, $config_file); fclose($fd); @@ -2490,6 +2484,7 @@ function cleanup_opt_interfaces_after_removal($opt_interface_num) { if($config['nat']['rule'][$x]['interface'] == "optXXXX") unset($config['nat']['rule'][$x]['interface']); } + write_config(); conf_mount_ro(); config_unlock(); return true; @@ -3622,4 +3617,4 @@ function is_wan_interface_up($interface) { return false; } -?> \ No newline at end of file +?> -- cgit v1.1