7,6 → 7,9 |
define ("CONF_FILE", "/usr/local/etc/alcasar.conf"); |
define ("ETHERS_FILE", "/usr/local/etc/alcasar-ethers"); |
$conf_files=array(CONF_FILE,ETHERS_FILE); |
$reg_ip = '/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/'; |
$reg_ip_cidr = '/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$/'; |
$network_modification=0; |
foreach ($conf_files as $file){ |
if (!file_exists($file)){ |
exit("Requested file ".$file." isn't present");} |
14,6 → 17,7 |
exit("Can't read the file ".$file);} |
} |
|
|
# Choice of language |
$Language = 'en'; |
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){ |
164,10 → 168,13 |
return true; |
} |
} |
/*********************************** |
* Update ALCASAR_CONF_FILE * |
***********************************/ |
|
/*********************************** |
* Read ALCASAR_CONF_FILE * |
************************************/ |
/******************************************* |
* Read ALCASAR_CONF_FILE Before * |
********************************************/ |
$ouvre=fopen(CONF_FILE,"r"); |
if ($ouvre){ |
while (!feof ($ouvre)) |
180,7 → 187,61 |
} |
fclose($ouvre); |
} |
|
|
if(isset($_POST['dns1']) && preg_match($reg_ip,$_POST['dns1'])) |
{ |
file_put_contents(CONF_FILE, str_replace('DNS1='.$conf['DNS1'],'DNS1='.$_POST['dns1']."\n",file_get_contents(CONF_FILE))); |
$network_modification=1; |
} |
if(isset($_POST['dns2']) && preg_match($reg_ip,$_POST['dns2'])) |
{ |
file_put_contents(CONF_FILE, str_replace('DNS2='.$conf['DNS2'],'DNS2='.$_POST['dns2']."\n",file_get_contents(CONF_FILE))); |
$network_modification=1; |
} |
|
if(isset($_POST['ip_public']) && preg_match($reg_ip_cidr,$_POST['ip_public'])) |
{ |
file_put_contents(CONF_FILE, str_replace('PUBLIC_IP='.$conf['PUBLIC_IP'],'PUBLIC_IP='.$_POST['ip_public']."\n",file_get_contents(CONF_FILE))); |
$network_modification=1; |
} |
|
if(isset($_POST['ip_gw']) && preg_match($reg_ip,$_POST['ip_gw'])) |
{ |
file_put_contents(CONF_FILE, str_replace('GW='.$conf['GW'],'GW='.$_POST['ip_gw']."\n",file_get_contents(CONF_FILE))); |
$network_modification=1; |
} |
|
if(isset($_POST['ip_private']) && preg_match($reg_ip_cidr,$_POST['ip_private'])) |
{ |
file_put_contents(CONF_FILE, str_replace('PRIVATE_IP='.$conf['PRIVATE_IP'],'PRIVATE_IP='.$_POST['ip_private']."\n",file_get_contents(CONF_FILE))); |
$network_modification=1; |
} |
if($network_modification) |
{ |
exec("sudo /usr/local/bin/alcasar-conf.sh -apply"); |
|
} |
|
|
|
|
/******************************************* |
* Read ALCASAR_CONF_FILE Updated * |
********************************************/ |
$ouvre=fopen(CONF_FILE,"r"); |
if ($ouvre){ |
while (!feof ($ouvre)) |
{ |
$tampon = fgets($ouvre, 4096); |
if (strpos($tampon,"=")!==false){ |
$tmp = explode("=",$tampon); |
$conf[$tmp[0]] = $tmp[1]; |
} |
} |
fclose($ouvre); |
} |
|
/************************ |
* TO DO * |
*************************/ |
207,6 → 268,8 |
} |
</script> |
</head> |
|
|
<body> |
<table width="100%" border="0" cellspacing="0" cellpadding="0"> |
<tr><th><?php echo $l_network_title; ?></th></tr> |
225,8 → 288,11 |
?></legend> |
<table> |
<tr><td><?php echo $l_ip_public." : </td><td>".$IP_PUB;?></td></tr> |
<tr><td><?php echo $l_ip_dns1." : </td><td>".$conf["DNS1"];?></td></tr> |
<tr><td><?php echo $l_ip_dns2." : </td><td>".$conf["DNS2"];?></td></tr> |
<?php |
echo "<form action=".$_SERVER['PHP_SELF']." method='post'>"; |
echo "<tr><td>".$l_ip_dns1." <input style='width:120px' type='text' name='dns1' value=".$conf["DNS1"]."/></td></tr>"; |
echo "<tr><td>".$l_ip_dns2." <input style='width:120px' type='text' name='dns2' value=".$conf["DNS2"]."/></td></tr>"; |
?> |
</table> |
</fieldset> |
</td><td> |
233,8 → 299,11 |
<fieldset> |
<legend><?php echo $conf["EXTIF"].$l_extif_legend; ?></legend> |
<table> |
<tr><td><?php echo $l_ip_adr." : </td><td>".$conf["PUBLIC_IP"];?></td></tr> |
<tr><td><?php echo $l_ip_router." : </td><td>".$conf["GW"];?></td></tr> |
<?php |
echo "<form action=".$_SERVER['PHP_SELF']." method='post'>"; |
echo "<tr><td>".$l_ip_adr." <input style='width:150px' type='text' name='ip_public' value=".$conf['PUBLIC_IP']."/></td></tr>"; |
echo "<tr><td>".$l_ip_router." <input style='width:120px' type='text' name='ip_gw' value=".$conf['GW']."/></td></tr>"; |
?> |
</table> |
</fieldset> |
</td><td> |
241,11 → 310,19 |
<fieldset> |
<legend><?php echo $conf["INTIF"].$l_intif_legend; ?></legend> |
<table> |
<tr><td><?php echo $l_ip_adr." : </td><td>".$conf["PRIVATE_IP"];?></td></tr> |
<?php |
echo "<form action=".$_SERVER['PHP_SELF']." method='post'>"; |
echo "<tr><td>".$l_ip_adr."</td><td> <input style='width:150px' type='text' name='ip_private' value=".$conf['PRIVATE_IP']." /></td></tr>"; |
?> |
</table> |
</fieldset> |
</td></tr> |
<?php |
echo "<td><input type='submit' value='$l_apply' disabled></td>"; |
echo "</form>"; |
?> |
</table> |
|
<table width="100%" border="0" cellspacing="0" cellpadding="0"> |
<tr><th><?php echo $l_dhcp_title;?></th></tr> |
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr> |