Subversion Repositories ALCASAR

Compare Revisions

Ignore whitespace Rev 503 → Rev 504

/web/acc/admin/net_filter.php
34,7 → 34,6
$l_delete="Supprimer de la liste";
$l_add_to_list="Ajouter à la liste";
$l_save_modif="Enregistrer les modifications";
$l_exception_txt="Entrez ici les adresses IP des stations du réseau de consultation ne subissant ce filtrage de protocoles<BR>Entrez une adresse IP par ligne";
}
else {
$l_title_antivir = "WEB antivirus";
56,7 → 55,6
$l_delete="Delete from list";
$l_add_to_list="Add to the list";
$l_save_modif="Save modifications";
$l_exception_txt="Put here the stations IP address that won't be protocols filtered<BR>Put one IP adress per row";
}
echo "
<tr><th>$l_title_antivir</th></tr>
148,18 → 146,6
else {echo "$l_error_open_file $services_list";}
exec ("sudo /usr/local/sbin/alcasar-nf.sh -on");
break;
case 'IP_exceptions' :
// réencodage iso + format unix + rc fin de ligne (ouf...)
$ip_list = str_replace("\r\n", "\n", utf8_decode($_POST['exception_list']));
if (strlen($ip_list) != 0){
if ($ip_list[strlen($ip_list)-1] != "\n") { $ip_list[strlen($ip_list)]="\n";} ;} ;
unset($_POST['exception_list']);
// écriture exception pour filtrage réseau
$fichier=fopen("/usr/local/etc/alcasar-filter-exceptions", "w+");
fputs($fichier, $ip_list);
fclose($fichier);
exec ("sudo /usr/local/sbin/alcasar-nf.sh -on");
break;
}
?>
<TABLE width="100%" border=1 cellspacing=0 cellpadding=0>
/web/acc/admin/net_filter2.php
48,33 → 48,6
</tr></table>
</form>
</td></tr>
<tr><td colspan=2 valign="middle" align="center">
<B>Exceptions</B><br>
<form action='net_filter.php' method='POST'>
<?php
echo " $l_exception_txt";
echo "<BR><textarea name='exception_list' rows=5 cols=40>";
$filename="/usr/local/etc/alcasar-filter-exceptions";
if (file_exists($filename))
{
if (filesize($filename) != 0)
{
$pointeur=fopen($filename,"r");
$tampon = fread($pointeur, filesize($filename));
fclose($pointeur);
echo trim ($tampon);
}
}
else
{
echo "erreur d'ouverture du fichier $filename";
}
echo "</textarea><BR>";
?>
<input type='hidden' name='choix' value='IP_exceptions'>
<input type='submit' value='<?php echo "$l_save_modif"; ?>'>
</FORM>
</td></tr>
</TABLE>
</BODY>
</HTML>
/web/acc/admin/auth_exceptions.php
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 = "&Eacute;quipements de confiance";
$l_trusted_mac_explain = "Entrez ici les adresses MAC des &eacute;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>
/web/acc/admin/filter_exceptions.php
0,0 → 1,120
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><!-- written by Rexy -->
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<TITLE>ALCASAR Filter Exceptions</TITLE>
<link rel="stylesheet" href="/css/style.css" type="text/css">
</HEAD>
<body>
<?
# Choice of language
$Language = 'en';
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
$Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
$Language = strtolower(substr(chop($Langue[0]),0,2)); }
if($Language == 'fr'){
$l_exception_IP = "Exception au filtrage";
$l_exception_txt="Entrez ici les adresses IP des stations du réseau de consultation ne subissant ni filtrage WEB ni filtrage réseau<BR>Entrez une adresse IP par ligne";
$l_submit = "Enregistrer";
}
else {
$l_exception_IP = "Network filtering exceptions";
$l_exception_txt="Put here the stations IP address that won't be neither WEB filtered nor network filtered<BR>Put one IP per row";
$l_submit = "Submit";
}
if (isset($_POST['choix'])){
switch ($_POST['choix'])
{
case 'IP_exceptions' :
// réencodage iso + format unix + rc fin de ligne (ouf...)
$ip_list = str_replace("\r\n", "\n", utf8_decode($_POST['exception_list']));
if (strlen($ip_list) != 0){
if ($ip_list[strlen($ip_list)-1] != "\n") { $ip_list[strlen($ip_list)]="\n";} ;} ;
unset($_POST['exception_list']);
// écriture exception pour Dansguardian
$fichier=fopen("/etc/dansguardian/lists/exceptioniplist", "w+");
fputs($fichier,$ip_list);
fclose($fichier);
// écriture exception pour filtrage réseau et filtrage DNS
$fichier=fopen("/usr/local/etc/alcasar-filter-exceptions", "w+");
fputs($fichier, $ip_list);
fclose($fichier);
// test si le filtrage Dansguardian est activé
$pointeur = fopen("/etc/dansguardian/dansguardian.conf", "r");
$result = false;
if ($pointeur)
{
while (!feof($pointeur))
{
$ligne = fgets($pointeur);
if (preg_match("/^reportinglevel = 3/", $ligne, $r))
{
$result = true;
break;
}
}
}
fclose($pointeur);
if ($result)
{
exec ("sudo service dansguardian restart");
}
// test si filtrage réseau activé
$pointeur = fopen("/usr/local/bin/alcasar-iptables.sh", "r");
$result = False ;
if ($pointeur)
{
while (!feof($pointeur))
{
$ligne = fgets($pointeur);
if (preg_match('/^FILTERING="yes"/', $ligne, $r))
{
$result = True ;
break;
}
}
}
fclose($pointeur);
if ($result)
{
exec ("sudo /usr/local/bin/alcasar-iptables.sh");
}
break;
}
}
?>
<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><th><?php echo $l_exception_IP ;?></th></tr>
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
</TABLE>
<TABLE width="100%" border=1 cellspacing=0 cellpadding=1>
<tr><td valign="middle" align="left">
<TABLE width=70% border=0>
<?php
echo "<form action='$_SERVER[PHP_SELF]' method='POST'>";
echo " $l_exception_txt";
echo "<BR><textarea name='exception_list' rows=5 cols=40>";
$filename="/usr/local/etc/alcasar-filter-exceptions";
if (file_exists($filename))
{
if (filesize($filename) != 0)
{
$pointeur=fopen($filename,"r");
$tampon = fread($pointeur, filesize($filename));
fclose($pointeur);
echo $tampon;
}
}
else
{
echo "erreur d'ouverture du fichier $filename";
}
echo "</textarea><BR>";
?>
<input type='hidden' name='choix' value='IP_exceptions'>
<input type='submit' value='Enregistrer les modifications'></CENTER>
</FORM>
</td></tr>
</TABLE>
</BODY>
</HTML>
/web/acc/filtering.php
1,8 → 1,10
<?
$select[0]="$l_domains_filter";
$select[1]=$l_network;
$select[2]="Exceptions";
$fich[0]="admin/dns_filter.php";
$fich[1]="admin/net_filter.php";
$fich[2]="admin/filter_exceptions.php";
$j=0;
$nb=count($select);
while ($j != $nb)