diff options
Diffstat (limited to 'usr')
-rwxr-xr-x | usr/local/www/interfaces.php | 89 |
1 files changed, 46 insertions, 43 deletions
diff --git a/usr/local/www/interfaces.php b/usr/local/www/interfaces.php index 0ff69de..7e016f9 100755 --- a/usr/local/www/interfaces.php +++ b/usr/local/www/interfaces.php @@ -4,7 +4,7 @@ interfaces.php Copyright (C) 2004-2008 Scott Ullrich Copyright (C) 2006 Daniel S. Haischt. - Copyright (C) 2008 Ermal Luçi + Copyright (C) 2008-2010 Ermal Luçi All rights reserved. originally part of m0n0wall (http://m0n0.ch/wall) @@ -55,20 +55,15 @@ require_once("vpn.inc"); require_once("xmlparse_attr.inc"); // Get configured interface list -$ifdescrs = get_configured_interface_list(false, true); +$ifdescrs = get_configured_interface_with_descr(false, true); -if ($_REQUEST['if']) { +$if = "wan"; +if ($_REQUEST['if']) $if = $_REQUEST['if']; - $found = false; - foreach($ifdescrs as $descr => $ifdescr) - if($descr == $if) - $found = true; - if(!$found) { - Header("Location: interfaces.php"); - exit; - } -} else { - $if = "wan"; + +if (empty($ifdescrs[$if])) { + Header("Location: interfaces.php"); + exit; } define("CRON_MONTHLY_PATTERN", "0 0 1 * *"); @@ -87,10 +82,15 @@ function remove_bad_chars($string) { if (!is_array($config['gateways']['gateway_item'])) $config['gateways']['gateway_item'] = array(); - $a_gateways = &$config['gateways']['gateway_item']; $wancfg = &$config['interfaces'][$if]; +// Populate page descr if it does not exist. +if ($if == "wan" && !$wancfg['descr']) + $wancfg['descr'] = "WAN"; +else if ($if == "lan" && !$wancfg['descr']) + $wancfg['descr'] = "LAN"; + foreach ($a_ppps as $pppid => $ppp) { if ($wancfg['if'] == $ppp['if']) @@ -175,15 +175,7 @@ if ($wancfg['if'] == $a_ppps[$pppid]['if']) { $pconfig['dhcphostname'] = $wancfg['dhcphostname']; $pconfig['alias-address'] = $wancfg['alias-address']; $pconfig['alias-subnet'] = $wancfg['alias-subnet']; - -// Populate page descr if it does not exist. -if($if == "wan" && !$wancfg['descr']) { - $wancfg['descr'] = "WAN"; -} else if ($if == "lan" && !$wancfg['descr']) { - $wancfg['descr'] = "LAN"; -} $pconfig['descr'] = remove_bad_chars($wancfg['descr']); - $pconfig['enable'] = isset($wancfg['enable']); if (is_array($config['aliases']['alias'])) { @@ -213,9 +205,8 @@ switch($wancfg['ipaddr']) { $pconfig['ipaddr'] = $wancfg['ipaddr']; $pconfig['subnet'] = $wancfg['subnet']; $pconfig['gateway'] = $wancfg['gateway']; - } else { + } else $pconfig['type'] = "none"; - } break; } @@ -312,15 +303,18 @@ if ($_POST['apply']) { else { unlink_if_exists("{$g['tmp_path']}/config.cache"); clear_subsystem_dirty('interfaces'); - if ($pconfig['enable']) - interface_configure($if, true); - else - interface_bring_down($if); + if (file_exists("{$g['tmp_path']}/.interfaces.apply")) { + $toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply")); + foreach ($toapplylist as $ifapply) { + if (isset($config['interfaces'][$ifapply]['enable'])) + interface_configure($ifapply, true); + else + interface_bring_down($ifapply); + } + } /* restart snmp so that it binds to correct address */ services_snmpd_configure(); - if ($if == "lan") - $savemsg = gettext("The changes have been applied. You may need to correct your web browser's IP address."); /* sync filter configuration */ setup_gateways_monitor(); @@ -331,22 +325,25 @@ if ($_POST['apply']) { enable_rrd_graphing(); } + @unlink("{$g['tmp_path']}/.interfaces.apply"); header("Location: interfaces.php?if={$if}"); exit; -} else - -if ($_POST && $_POST['enable'] != "yes") { +} else if ($_POST && $_POST['enable'] != "yes") { unset($wancfg['enable']); - if (isset($wancfg['wireless'])) { + if (isset($wancfg['wireless'])) interface_sync_wireless_clones($wancfg, false); - } write_config("Interface {$_POST['descr']}({$if}) is now disabled."); mark_subsystem_dirty('interfaces'); + if (file_exists("{$g['tmp_path']}/.interfaces.apply")) + $toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply")); + else + $toapplylist = array(); + $toapplylist[$if] = $if; + file_put_contents("{$g['tmp_path']}/.interfaces.apply", serialize($toapplylist)); header("Location: interfaces.php?if={$if}"); exit; -} else +} else if ($_POST) { -if ($_POST) { unset($input_errors); $pconfig = $_POST; conf_mount_rw(); @@ -367,10 +364,8 @@ if ($_POST) { unset($_POST['pppoe_resetdate']); unset($_POST['pppoe_pr_preset_val']); } - /* optional interface if list */ - $iflist = get_configured_interface_with_descr(false, true); /* description unique? */ - foreach ($iflist as $ifent => $ifdescr) { + foreach ($ifdescrs as $ifent => $ifdescr) { if ($if != $ifent && $ifdescr == $_POST['descr']) { $input_errors[] = gettext("An interface with the specified description already exists."); break; @@ -697,17 +692,25 @@ if ($_POST) { handle_wireless_post(); } + conf_mount_ro(); write_config(); + + if (file_exists("{$g['tmp_path']}/.interfaces.apply")) + $toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply")); + else + $toapplylist = array(); + $toapplylist[$if] = $if; + file_put_contents("{$g['tmp_path']}/.interfaces.apply", serialize($toapplylist)); + mark_subsystem_dirty('interfaces'); + /* regenerate cron settings/crontab file */ configure_cron(); - conf_mount_ro(); + header("Location: interfaces.php?if={$if}"); exit; } - - } // end if($_POST) function handle_wireless_post() { |