7,6 → 7,7 |
</HEAD> |
<body> |
<? |
$mac_allowed_list="/usr/local/etc/alcasar-macallowed"; |
# Choice of language |
$Language = 'en'; |
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){ |
22,10 → 23,11 |
$l_trusted_mac = "Équipements de confiance"; |
$l_trusted_mac_explain = "Entrez ici les adresses MAC des équipements autorisés à joindre Internet sans authentification"; |
$l_trusted_mac_list = "Liste des adresses MAC de confiance"; |
$l_trusted_mac_address = "Adresse MAC autorisées"; |
$l_trusted_mac_address = "Adresses MAC autorisées"; |
$l_trusted_mac_info = "Information équipement"; |
$l_trusted_mac_del = "Supprimer de la liste"; |
$l_submit = "Enregistrer"; |
$l_add_to_list = "Ajouter"; |
} |
else { |
$l_error_open_file = "File open error"; |
35,13 → 37,13 |
$l_trusted_sites_list = "Trusted Internet sites list"; |
$l_trusted_urls_list = "Trusted Internet URLs list"; |
$l_trusted_mac = "Trusted Equipments"; |
$l_trusted_mac_explain = "Enter MAC address of equipments that could contact Internet without authentification"; |
$l_trusted_mac_explain = "Enter MAC address of equipments that could contact Internet without authentication"; |
$l_trusted_mac_list = "Trusted MAC addresses list"; |
$l_trusted_mac_address = "Allowed MAC adress MAC"; |
$l_trusted_mac_address = "Allowed MAC adress"; |
$l_trusted_mac_info = "Equipment information"; |
$l_trusted_mac_del = "Delete from list"; |
$l_submit = "Submit"; |
|
$l_add_to_list = "Add"; |
} |
if (isset($_POST['choix'])){ |
switch ($_POST['choix']) |
82,26 → 84,63 |
exec ("sudo service chilli restart"); |
unset ($_POST['choix']); |
break; |
case 'MAJ_MACALLOWED' : |
$nb_mac=0; |
$tab_macs = explode ("\n", $_POST['trusted_macs']); |
$fichier=fopen("/usr/local/etc/alcasar-macallowed","w+"); |
fputs ($fichier, "macallowed=\""); |
foreach ($tab_macs as $macs ){ |
$tr_macs=trim($macs); |
$nb_mac++; |
if ($tr_macs != ""){ |
if ($nb_mac>1) fputs ($fichier, ",".$tr_macs); |
else fputs ($fichier, $tr_macs); |
case 'new_mac' : |
if (trim($_POST['add_mac']) != "") |
{ |
if (is_file ($mac_allowed_list)) # le fichier existe |
{ |
$tab=file($mac_allowed_list); |
$insert = true; |
if ($tab) # le fichier n'est pas vide |
{ |
foreach ($tab as $line) # on teste si l'adresse mac n'est pas déjà présente |
{ |
$field=explode("#", $line); |
$mac_addr=trim($field[0],"macallowed="); |
if (trim($_POST['add_mac']) == trim ($mac_addr)) |
{ |
$insert = false;; |
break; |
} |
} |
} |
if ($insert == true) |
{ |
$line = "macallowed=" . trim($_POST['add_mac']) . " #" . trim($_POST['add_comment']) . "\n"; |
$pointeur=fopen($mac_allowed_list,"a"); |
fwrite ($pointeur, $line); |
fclose ($pointeur); |
exec ("sudo service chilli restart"); |
} |
} |
fputs($fichier, "\""); |
fclose($fichier); |
unset($_POST['trusted_macs']); |
unset($nb_mac); |
else {echo "$l_error_open_file $mac_allowed_list";} |
} |
break; |
case 'del_mac' : |
$tab=file($mac_allowed_list); |
if ($tab) |
{ |
$pointeur=fopen($mac_allowed_list,"w+"); |
foreach ($tab as $line) |
{ |
$field=explode("#", $line); |
$mac_addr=trim(trim($field[0],"macallowed=")); |
$remove_line = false; |
foreach ($_POST as $key => $value) |
{ |
if ($mac_addr == $key) |
{ |
$remove_line = True; |
break; |
} |
} |
if (! $remove_line) {fwrite($pointeur,$line);} |
} |
fclose($pointeur); |
exec ("sudo service chilli restart"); |
unset ($_POST['choix']); |
break; |
} |
else {echo "$l_error_open_file $mac_allowed_list";} |
break; |
} |
} |
?> |
194,89 → 233,50 |
echo "<FORM action='$_SERVER[PHP_SELF]' method='POST'>"; |
echo "<table cellspacing=2 cellpadding=3 border=1>"; |
echo "<tr><th>$l_trusted_mac_address<th>$l_trusted_mac_info<th>$l_trusted_mac_del</tr>"; |
// On lit et on interprète le fichier de filtrage de protocoles |
$trusted_mac_file="/usr/local/etc/alcasar-macallowed"; |
if (file_exists($trusted_mac_file)) |
// On lit et on affiche le fichier d'exception |
$display_form = true; |
if (is_file ($mac_allowed_list)) |
{ |
$pointeur=fopen($trusted_mac_file,"r"); |
while (!feof ($pointeur)) |
$tab=file($mac_allowed_list); |
if ($tab) # le fichier n'est pas vide |
{ |
$ligne=fgets($pointeur, 4096); |
if ($ligne) |
foreach ($tab as $line) |
{ |
$field=explode(" ", $ligne); |
$mac_info=trim($field[2],"#"); |
echo "<tr><td>$field[1]"; |
$field=explode("#", $line); |
$mac_addr=trim(trim($field[0],"macallowed=")); |
$mac_info=trim($field[1],"#"); |
echo "<tr><td>$mac_addr"; |
echo "<td>$mac_info"; |
echo "<td><input type='checkbox' name='del-$field[1]'>"; |
echo "<td><input type='checkbox' name='$mac_addr'>"; |
echo "</tr>"; |
} |
} |
fclose($pointeur); |
else { $display_form = false;} |
} |
else { |
echo "$l_error_open_file $trusted_mac_file"; |
echo "$l_error_open_file $mac_allowed_list"; |
$display_form = false; |
} |
echo "</table>"; |
if ($display_form) |
{ |
echo "<input type='hidden' name='choix' value='del_mac'>"; |
echo "<input type='submit' value='$l_submit'>"; |
} |
echo "</form></td><td valign='middle' align='center'>"; |
echo "<FORM action='$_SERVER[PHP_SELF]' method='POST'>"; |
echo "<table cellspacing=2 cellpadding=3 border=1>"; |
echo "<tr><th>$l_trusted_mac_address<th>$l_trusted_mac_info"; |
?> |
</table> |
<input type='hidden' name='choix' value='change'> |
<input type='submit' value='<?echo"$l_submit";?>'> |
</form> |
</td> |
<td valign='middle' align='center'> |
<form action='net_filter.php' method='POST'> |
<table cellspacing=2 cellpadding=3 border=1> |
<tr><th><?echo"$l_trusted_mac_address<th>$l_trusted_mac_info";?></tr> |
<tr><td><input type='text' name='add_proto' size='10'></td> |
<td><input type='text' name='add_port' size='5'></td> |
<input type='hidden' name='choix' value='new_proto'> |
<td></td></tr> |
<tr><td>exemple : 12-2f-36-a4-df-43</td><td>exemple : PC of the boss</td><td></td></tr> |
<tr><td><input type='text' name='add_mac' size='17'></td> |
<td><input type='text' name='add_comment' size='10'></td> |
<input type='hidden' name='choix' value='new_mac'> |
<td><input type='submit' value='<?echo"$l_add_to_list";?>'></td> |
</tr></table> |
</form> |
</td></tr> |
</table> |
|
<TABLE width="100%" border=0 cellspacing=0 cellpadding=1> |
<tr bgcolor="#666666"><td> |
<TABLE width="100%" border=0 cellspacing=0 cellpadding=2> |
<tr><td valign="middle" align="left"> |
<center><?php |
echo "$l_trusted_mac_explain1 <BR>"; |
echo "$l_trusted_mac_explain2"; |
echo "<FORM action='$_SERVER[PHP_SELF]' method='POST'>";?> |
<TABLE cellspacing=2 cellpadding=3 border=1> |
<tr><td width=60% height=100% align=center> |
<H3><?php echo $l_trusted_mac_list ;?></H3> |
exemple : 12-2f-36-a4-df-43<BR> |
<?php |
echo "<textarea name='trusted_macs' rows=5 cols=40>"; |
$trusted_macs_file="/usr/local/etc/alcasar-macallowed"; |
$ouvre=fopen($trusted_macs_file,"r"); |
if ($ouvre) |
{ |
while (!feof ($ouvre)) |
{ |
$tampon = fgets($ouvre, 4096); |
$mac_list_l = substr($tampon,11); |
$mac_list = trim ($mac_list_l,"\"\n\t "); |
$tab_macs = explode (",", $mac_list); |
foreach ($tab_macs as $macs ){ |
if ($macs) echo $macs."\n"; |
} |
} |
} |
else { |
echo "failed to open $trusted_macs_file"; |
} |
fclose($ouvre); |
echo "</textarea>"; |
?> |
</td></tr> |
</TABLE> |
<input type='hidden' name='choix' value='MAJ_MACALLOWED'> |
<input type='submit' value='<?php echo $l_submit ;?>'> |
</FORM> |
</td></tr> |
</TABLE> |
</BODY> |
</HTML> |