commit 4476d4475167263b170ea831dece50426655398a
Author: Ermal Luçi <eri@pfsense.org>
Date:   Sun Sep 7 19:34:18 2008 +0000

    Merge lan configuration to the interfaces_wan.php page wich does the configuration of all
    other assigned interfaces.

diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc
index f95246adb2..620b4137da 100644
--- a/etc/inc/interfaces.inc
+++ b/etc/inc/interfaces.inc
@@ -412,79 +412,6 @@ function interface_gif_configure(&$gif) {
         return $gifif;
 }
 
-function interfaces_lan_configure() {
-	global $config, $g;
-
-	$lancfg = $config['interfaces']['lan'];
-
-	/* if user has removed ip address, clear it*/
-	if($lancfg['ipaddr'] == "")
-		mwexec("/sbin/ifconfig {$lancfg['if']} delete");
-
-	/* wireless configuration? */
-	if (is_array($lancfg['wireless']))
-		interfaces_wireless_configure($lancfg['if'], $lancfg['wireless']);
-
-	/* MAC spoofing? */
-	if ($lancfg['spoofmac']) {
-		mwexec("/sbin/ifconfig " . escapeshellarg($lancfg['if']) .
-			" link " . escapeshellarg($lancfg['spoofmac']));
-	} else {
-		$mac = get_interface_mac_address($lancfg['if']);
-		if($mac == "ff:ff:ff:ff:ff:ff") {
-			/*   this is not a valid mac address.  generate a
-			 *   temporary mac address so the machine can get online.
-			 */
-			echo "Generating new MAC address.";
-			$random_mac = generate_random_mac_address();
-			mwexec("/sbin/ifconfig " . escapeshellarg($lancfg['if']) .
-				" link " . escapeshellarg($random_mac));
-			$lancfg['spoofmac'] = $random_mac;
-			write_config();
-			file_notice("MAC Address altered", "The INVALID MAC address (ff:ff:ff:ff:ff:ff) on interface {$lancfg['if']} has been automatically replaced with {$random_mac}", "Interfaces");
-		}
-	}
-
-	/* media */
-	if ($lancfg['media'] || $lancfg['mediaopt']) {
-		$cmd = "/sbin/ifconfig " . escapeshellarg($lancfg['if']);
-		if ($lancfg['media'])
-			$cmd .= " media " . escapeshellarg($lancfg['media']);
-		if ($lancfg['mediaopt'])
-			$cmd .= " mediaopt " . escapeshellarg($lancfg['mediaopt']);
-		mwexec($cmd);
-	}
-
-	mwexec("/sbin/ifconfig " . escapeshellarg($lancfg['if']) . " " .
-		escapeshellarg($lancfg['ipaddr'] . "/" . $lancfg['subnet']));
-
-	if (!$g['booting']) {
-		/* make new hosts file */
-		system_hosts_generate();
-
-		/* reconfigure static routes (kernel may have deleted them) */
-		system_routing_configure();
-
-		/* set the reload filter dity flag */
-		touch("{$g['tmp_path']}/filter_dirty");
-
-		/* reload IPsec tunnels */
-		vpn_ipsec_configure();
-
-		/* reload dhcpd (gateway may have changed) */
-		services_dhcpd_configure();
-
-		/* reload dnsmasq */
-		services_dnsmasq_configure();
-
-		/* reload captive portal */
-		captiveportal_configure();
-
-	}
-
-	return 0;
-}
-
 function interfaces_configure() {
 	global $g;
 
@@ -496,10 +423,8 @@ function interfaces_configure() {
 		if($debug)
  	               log_error("Configuring {$ifname}");
 
-		if ($if == "lan")
-			interfaces_lan_configure();
-		else
-			interfaces_wan_configure($if);
+		interfaces_wan_configure($if);
+
 		if ($g['booting']) 
                 	echo "done.\n";
 	}
@@ -1189,6 +1114,11 @@ function interfaces_wan_configure($interface = "wan") {
 
 	/* XXX: Shouldn't the caller do this?! */
 	if (!$g['booting']) {
+		/* XXX */
+		if ($interface = "lan")
+			/* make new hosts file */
+                	system_hosts_generate();
+
 		/* reconfigure static routes (kernel may have deleted them) */
 		system_routing_configure();
 
@@ -1198,7 +1128,7 @@ function interfaces_wan_configure($interface = "wan") {
 		/* reload ipsec tunnels */
 		vpn_ipsec_configure();
 
-		/* restart ez-ipupdate */
+		/* update dyndns */
 		services_dyndns_configure();
 
 		/* force DNS update */
diff --git a/etc/inc/priv.defs.inc b/etc/inc/priv.defs.inc
index dcd81b6b85..c4a2d7ec4a 100644
--- a/etc/inc/priv.defs.inc
+++ b/etc/inc/priv.defs.inc
@@ -414,12 +414,6 @@ $priv_list['page-interfaces-gre-edit']['descr'] = "Allow access to the 'Interfac
 $priv_list['page-interfaces-gre-edit']['match'] = array();
 $priv_list['page-interfaces-gre-edit']['match'][] = "interfaces_gre_edit.php*";
 
-$priv_list['page-interfaces-lan'] = array();
-$priv_list['page-interfaces-lan']['name'] = "WebCfg - Interfaces: LAN page";
-$priv_list['page-interfaces-lan']['descr'] = "Allow access to the 'Interfaces: LAN' page.";
-$priv_list['page-interfaces-lan']['match'] = array();
-$priv_list['page-interfaces-lan']['match'][] = "interfaces_lan.php*";
-
 $priv_list['page-interfaces-ppp'] = array();
 $priv_list['page-interfaces-ppp']['name'] = "WebCfg - Interfaces: PPP page";
 $priv_list['page-interfaces-ppp']['descr'] = "Allow access to the 'Interfaces: PPP' page.";
diff --git a/etc/rc.initial.setlanip b/etc/rc.initial.setlanip
index 9eaaa3c1a1..609e72272c 100755
--- a/etc/rc.initial.setlanip
+++ b/etc/rc.initial.setlanip
@@ -206,7 +206,7 @@
 	$upperifname = strtoupper($interface);
 	echo "\nPlease wait, saving and activating your changes to {$upperifname}...";
 	write_config(gettext("{$interface} IP configuration from console menu"));
-	interfaces_lan_configure();
+	interfaces_wan_configure("lan");
 	echo " Reloading filter...";
 	filter_configure_sync();
 	echo "\n";
diff --git a/etc/rc.interfaces_lan_configure b/etc/rc.interfaces_lan_configure
index 7f4d36ec2b..0ee2d5b08f 100755
--- a/etc/rc.interfaces_lan_configure
+++ b/etc/rc.interfaces_lan_configure
@@ -32,6 +32,6 @@
 require_once("config.inc");
 require_once("filter.inc");
 
-interfaces_lan_configure();
+interfaces_wan_configure("lan");
 
 ?>
diff --git a/etc/rc.linkup b/etc/rc.linkup
index e948175cf8..262cc20790 100755
--- a/etc/rc.linkup
+++ b/etc/rc.linkup
@@ -79,24 +79,12 @@
 						exec("/usr/sbin/arp -d -i {$argument1} -a");
 						break;
 				}
-				switch ($iface) {
-					case "wan":
-						if($config['interfaces'][$iface]['ipaddr'] <> "pppoe" and
-							$config['interfaces'][$iface]['ipaddr'] <> "pptp") {
-							/* do not reconfigure on hotplug events when using pppoe or pptp */
-							log_error("HOTPLUG: Configuring wan interface {$argument1}");
-							interfaces_wan_configure();
-						}
-						break;
-					case "lan":
-						log_error("HOTPLUG: Configuring lan interface {$argument1}");
-						interfaces_lan_configure();
-						break;
-					default:
-						interfaces_wan_configure($interface);
-						echo "interfaces_wan_configure($interface);\n";
-						log_error("HOTPLUG: Configuring optional interface {$interface}");
-						break;
+
+				if($config['interfaces'][$iface]['ipaddr'] <> "pppoe" and
+					$config['interfaces'][$iface]['ipaddr'] <> "pptp") {
+					/* do not reconfigure on hotplug events when using pppoe or pptp */
+					log_error("HOTPLUG: Configuring wan interface {$argument1}");
+					interfaces_wan_configure($iface);
 				}
 			}
 		}
diff --git a/usr/local/www/fbegin.inc b/usr/local/www/fbegin.inc
index fe1aaa8954..7f8c0c1c4d 100755
--- a/usr/local/www/fbegin.inc
+++ b/usr/local/www/fbegin.inc
@@ -139,13 +139,7 @@ if ($_REQUEST['noticeaction'] == 'acknowledge') {
 							<?php if (!isset($config['system']['webgui']['noassigninterfaces'])): ?>
 							<?=output_menu_item("/interfaces_assign.php", "(assign)");?>								
 							<?php endif; ?>
-							<?=output_menu_item("/interfaces_wan.php?if=wan", "WAN");?>	
-							<?php
-							if($config['interfaces']['lan']) {
-								output_menu_item("/interfaces_lan.php", "LAN");
-							}
-							?>
-							<?php $opts = get_configured_interface_with_descr(true, true); 
+							<?php $opts = get_configured_interface_with_descr(false, true); 
 							foreach ($opts as $oif => $odescr): 
 								if (!isset($config['interfaces'][$oif]['ovpn'])): ?>
 							<?=output_menu_item("/interfaces_wan.php?if={$oif}", htmlspecialchars($odescr))?>
diff --git a/usr/local/www/guiconfig.inc b/usr/local/www/guiconfig.inc
index b80c62ff97..289787a9fd 100755
--- a/usr/local/www/guiconfig.inc
+++ b/usr/local/www/guiconfig.inc
@@ -975,4 +975,4 @@ function echo_array($array,$return_me=false){
 }
 
 
-?>
\ No newline at end of file
+?>
diff --git a/usr/local/www/interfaces.php b/usr/local/www/interfaces.php
index 9a5cbb0b89..cb82e0fc9b 100755
--- a/usr/local/www/interfaces.php
+++ b/usr/local/www/interfaces.php
@@ -150,7 +150,10 @@ $pconfig['dhcphostname'] = $wancfg['dhcphostname'];
 $pconfig['alias-address'] = $wancfg['alias-address'];
 $pconfig['alias-subnet'] = $wancfg['alias-subnet'];
 $pconfig['descr'] = remove_bad_chars($wancfg['descr']);
-$pconfig['enable'] = $if == "wan" ? true : isset($wancfg['enable']);
+if ($if == "wan" || $if == "lan")
+	$pconfig['enable'] = true;
+else
+	$pconfig['enable'] = isset($wancfg['enable']);
 
 if (is_array($config['aliases']['alias']))
 foreach($config['aliases']['alias'] as $alias)
@@ -190,12 +193,12 @@ if (isset($wancfg['wireless'])) {
 if ($_POST) {
 
 	unset($input_errors);
-//	$pconfig = $_POST;
+	$pconfig = $_POST;
   
 	/* filter out spaces from descriptions  */
         $_POST['descr'] = remove_bad_chars($_POST['descr']);
 
-	if ($_POST['enable'] || $if == "wan") {
+	if ($_POST['enable'] || $if == "wan" || $if = "lan") {
 		/* optional interface if list */
                 $iflist = get_configured_interface_with_descr(true);
 
@@ -356,7 +359,10 @@ n already exists.";
 		}
 
 		$wancfg['descr'] = remove_bad_chars($_POST['descr']);
-		$wancfg['enable'] = $if == "wan" ? true : $_POST['enable'] ? true : false;
+		if ($if == "wan" || $if == "lan")
+			$wancfg['enable'] = true;
+		else
+			$wancfg['enable'] =  $_POST['enable'] ? true : false;
 
 		if ($_POST['type'] == "static") {
 			$wancfg['ipaddr'] = $_POST['ipaddr'];
@@ -495,7 +501,7 @@ n already exists.";
 		$wancfg['mtu'] = $_POST['mtu'];
 
 		write_config();
-		
+	
 		if ($if = "lan") {
 			/* restart snmp so that it binds to correct address */
                 	services_snmpd_configure();
@@ -528,6 +534,8 @@ n already exists.";
 // 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";
 	
 $pgtitle = array("Interfaces", $wancfg['descr']);
 $closehead = false;
@@ -586,13 +594,14 @@ function show_mon_config() {
 <body link="#0000CC" vlink="#0000CC" alink="#0000CC">
 <?php include("fbegin.inc"); ?>
 <?php if ($input_errors) print_input_errors($input_errors); ?>
+
 <?php if ($savemsg) print_info_box($savemsg); ?>
             <form action="interfaces_wan.php?if=<?php echo "{$if}";?>" method="post" name="iform" id="iform">
               <table width="100%" border="0" cellpadding="6" cellspacing="0">
                 <tr>
                   <td colspan="2" valign="top" class="listtopic">General configuration</td>
                 </tr>
-<?php if ($if != "wan"): ?>
+<?php if ($if != "wan" || $if != "lan"): ?>
                 <tr>
                   <td width="22%" valign="top" class="vtable">&nbsp;</td>
                   <td width="78%" class="vtable">
@@ -939,7 +948,7 @@ seconds<br>If no qualifying outgoing packets are transmitted for the specified n
 <script language="JavaScript">
 <!--
 <?php
-if ($if == "wan")
+if ($if == "wan" || $if = "lan")
 	echo "\$('allcfg').appear();";
 else
 	echo "show_allcfg(document.iform.enable);";
diff --git a/usr/local/www/interfaces_vlan_edit.php b/usr/local/www/interfaces_vlan_edit.php
index 912a321329..ad8e7c8068 100755
--- a/usr/local/www/interfaces_vlan_edit.php
+++ b/usr/local/www/interfaces_vlan_edit.php
@@ -101,9 +101,7 @@ if ($_POST) {
                         write_config();
 
 			$confif = convert_real_interface_to_friendly_interface_name($vlan['vlanif']);
-			if ($confif == "lan") 
-				interfaces_lan_configure();
-			else if ($confif <> "")
+			if ($confif <> "")
 				interfaces_wan_configure($confif);
 				
 			header("Location: interfaces_vlan.php");
diff --git a/usr/local/www/interfaces_wan.php b/usr/local/www/interfaces_wan.php
index 9a5cbb0b89..cb82e0fc9b 100755
--- a/usr/local/www/interfaces_wan.php
+++ b/usr/local/www/interfaces_wan.php
@@ -150,7 +150,10 @@ $pconfig['dhcphostname'] = $wancfg['dhcphostname'];
 $pconfig['alias-address'] = $wancfg['alias-address'];
 $pconfig['alias-subnet'] = $wancfg['alias-subnet'];
 $pconfig['descr'] = remove_bad_chars($wancfg['descr']);
-$pconfig['enable'] = $if == "wan" ? true : isset($wancfg['enable']);
+if ($if == "wan" || $if == "lan")
+	$pconfig['enable'] = true;
+else
+	$pconfig['enable'] = isset($wancfg['enable']);
 
 if (is_array($config['aliases']['alias']))
 foreach($config['aliases']['alias'] as $alias)
@@ -190,12 +193,12 @@ if (isset($wancfg['wireless'])) {
 if ($_POST) {
 
 	unset($input_errors);
-//	$pconfig = $_POST;
+	$pconfig = $_POST;
   
 	/* filter out spaces from descriptions  */
         $_POST['descr'] = remove_bad_chars($_POST['descr']);
 
-	if ($_POST['enable'] || $if == "wan") {
+	if ($_POST['enable'] || $if == "wan" || $if = "lan") {
 		/* optional interface if list */
                 $iflist = get_configured_interface_with_descr(true);
 
@@ -356,7 +359,10 @@ n already exists.";
 		}
 
 		$wancfg['descr'] = remove_bad_chars($_POST['descr']);
-		$wancfg['enable'] = $if == "wan" ? true : $_POST['enable'] ? true : false;
+		if ($if == "wan" || $if == "lan")
+			$wancfg['enable'] = true;
+		else
+			$wancfg['enable'] =  $_POST['enable'] ? true : false;
 
 		if ($_POST['type'] == "static") {
 			$wancfg['ipaddr'] = $_POST['ipaddr'];
@@ -495,7 +501,7 @@ n already exists.";
 		$wancfg['mtu'] = $_POST['mtu'];
 
 		write_config();
-		
+	
 		if ($if = "lan") {
 			/* restart snmp so that it binds to correct address */
                 	services_snmpd_configure();
@@ -528,6 +534,8 @@ n already exists.";
 // 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";
 	
 $pgtitle = array("Interfaces", $wancfg['descr']);
 $closehead = false;
@@ -586,13 +594,14 @@ function show_mon_config() {
 <body link="#0000CC" vlink="#0000CC" alink="#0000CC">
 <?php include("fbegin.inc"); ?>
 <?php if ($input_errors) print_input_errors($input_errors); ?>
+
 <?php if ($savemsg) print_info_box($savemsg); ?>
             <form action="interfaces_wan.php?if=<?php echo "{$if}";?>" method="post" name="iform" id="iform">
               <table width="100%" border="0" cellpadding="6" cellspacing="0">
                 <tr>
                   <td colspan="2" valign="top" class="listtopic">General configuration</td>
                 </tr>
-<?php if ($if != "wan"): ?>
+<?php if ($if != "wan" || $if != "lan"): ?>
                 <tr>
                   <td width="22%" valign="top" class="vtable">&nbsp;</td>
                   <td width="78%" class="vtable">
@@ -939,7 +948,7 @@ seconds<br>If no qualifying outgoing packets are transmitted for the specified n
 <script language="JavaScript">
 <!--
 <?php
-if ($if == "wan")
+if ($if == "wan" || $if = "lan")
 	echo "\$('allcfg').appear();";
 else
 	echo "show_allcfg(document.iform.enable);";
diff --git a/usr/local/www/widgets/widgets/interfaces.widget.php b/usr/local/www/widgets/widgets/interfaces.widget.php
index e223f2e281..3d67744016 100644
--- a/usr/local/www/widgets/widgets/interfaces.widget.php
+++ b/usr/local/www/widgets/widgets/interfaces.widget.php
@@ -41,7 +41,7 @@ require_once("/usr/local/www/widgets/include/interfaces.inc");
 			
 	         <table bgcolor="#990000" width="100%" border="0" cellspacing="0" cellpadding="0">
 			<?php 
-			foreach ($ifdescrs as $ifdescr => $ifname){
+			foreach ($ifdescrs as $ifdescr => $ifname) {
 					$ifinfo = get_interface_info($ifdescr);
 					$iswireless = is_interface_wireless($ifdescr);
 				?>
@@ -57,16 +57,7 @@ require_once("/usr/local/www/widgets/include/interfaces.inc");
 		                  <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_cablenic.gif"/>
 		                  <? } ?>&nbsp; 
 				<strong><u>
-				<?php
-				if ($ifname == "WAN") { ?>
-					<span onClick="location.href='/interfaces_wan.php'" style="cursor:pointer">				
-				<? } else if ($ifname == "LAN") { ?>
-					<span onClick="location.href='/interfaces_lan.php'" style="cursor:pointer">
-				<? } else { ?>				
-					<span onClick="location.href='/interfaces_wan.php?optif=<?=$ifdescr; ?>'" style="cursor:pointer">
-				<? 
-				} ?>	
-				
+					<span onClick="location.href='/interfaces_wan.php?if=<?=$ifdescr; ?>'" style="cursor:pointer">
 				
 				<?=htmlspecialchars($ifname);?></span></u></strong>
 				
