<html>
<head>
<title>test</title>
</head>
<body>
test
</body>
</html>
<?php

$inetconf="/etc/network/interfaces";
$resolv_conf="/etc/resolv.conf";
exec("sudo echo \"#automatically generated by beroAri\" > ".$inetconf);
exec("sudo echo \"auto lo eth0\" >> ".$inetconf);
exec("sudo echo >> ".$inetconf);
exec("sudo echo \"iface lo inet loopback\" >> ".$inetconf);
exec("sudo echo >> ".$inetconf);
if ($_POST['mode']=='dhcp'){
	exec("sudo echo \"iface eth0 inet dhcp\" >> ".$inetconf);
	exec("sudo echo \"#automatically generated by beroAri\" > ".$resolv_conf);
}else{
	exec("sudo echo \"iface eth0 inet static\" >> ".$inetconf);
	exec("sudo echo \"  address \"".$_POST['ip']." >> ".$inetconf);
	exec("sudo echo \"  netmask \"".$_POST['netmask']." >> ".$inetconf);
	exec("sudo echo \"  gateway \"".$_POST['gateway']." >> ".$inetconf);
	exec("sudo echo \"#automatically generated by beroAri\" > ".$resolv_conf);
	exec("sudo echo \"nameserver \"".$_POST['primary']." >> ".$resolv_conf);
	if($_POST['secondary']) exec("sudo echo \"nameserver\"".$_POST['secondary']." >> ".$resolv_conf);
}
if ($_POST['mode']=='dhcp'){
echo "<script>window.location='../index.php?m=net_conf'</script>";
}else{
echo "<script>window.location='http://".$_POST['ip']."/index.php?m=net_conf'</script>";
}
exec("sudo /etc/init.d/networking restart");
?>

