From 3d04e6799abee0b1c3ef5cc7fd630a9ca6d33267 Mon Sep 17 00:00:00 2001 From: Bill Marquette Date: Wed, 16 Mar 2005 06:46:54 +0000 Subject: rearrange some code so we only load files that actually exist keeping inline with the filename $trafficshaper == $shaper --- packages/carp_sync_server.php | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/packages/carp_sync_server.php b/packages/carp_sync_server.php index df9f429c..dbdf45b0 100644 --- a/packages/carp_sync_server.php +++ b/packages/carp_sync_server.php @@ -35,26 +35,34 @@ require_once("xmlparse_pkg.inc"); require_once("filter.inc"); if($config['installedpackages']['carpsettings']['config'] != "") { - $rules = return_filename_as_string("{$g['tmp_path']}/filter_section.txt"); - $aliases = return_filename_as_string("{$g['tmp_path']}/aliases_section.txt"); - $nat = return_filename_as_string("{$g['tmp_path']}/nat_section.txt"); - $trafficshaper = return_filename_as_string("{$g['tmp_path']}/shaper_section.txt"); - if($rules <> "") { - restore_config_section("filter", $rules); - unlink("{$g['tmp_path']}/filter_section.txt"); + + /* load and restore all files */ + if (file_exists("{$g['tmp_path']}/filter_section.txt")) { + $rules = return_filename_as_string("{$g['tmp_path']}/filter_section.txt"); + if($rules <> "") + restore_config_section("filter", $rules); + unlink("{$g['tmp_path']}/filter_section.txt"); } - if($aliases <> "") { - restore_config_section("aliases", $aliases); - unlink("{$g['tmp_path']}/aliases_section.txt"); + if (file_exists("{$g['tmp_path']}/aliases_section.txt")) { + $aliases = return_filename_as_string("{$g['tmp_path']}/aliases_section.txt"); + if($aliases <> "") + restore_config_section("aliases", $aliases); + unlink("{$g['tmp_path']}/aliases_section.txt"); } - if($nat <> "") { - restore_config_section("nat", $nat); - unlink("{$g['tmp_path']}/nat_section.txt"); + if (file_exists("{$g['tmp_path']}/nat_section.txt")) { + $nat = return_filename_as_string("{$g['tmp_path']}/nat_section.txt"); + if($nat <> "") + restore_config_section("nat", $nat); + unlink("{$g['tmp_path']}/nat_section.txt"); } - if($trafficshaper <> "") { - restore_config_section("shaper", $trafficshaper); - unlink("{$g['tmp_path']}/shaper_section.txt"); + if (file_exists("{$g['tmp_path']}/shaper_section.txt")) { + $shaper = return_filename_as_string("{$g['tmp_path']}/shaper_section.txt"); + if($shaper <> "") + restore_config_section("shaper", $shaper); + unlink("{$g['tmp_path']}/shaper_section.txt"); } + + /* reconfigure */ filter_configure(); } -- cgit v1.2.3