Subversion Repositories ALCASAR

Rev

Rev 40 | Go to most recent revision | Blame | Last modification | View Log

<!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
                $fichier=fopen("/usr/local/etc/alcasar-filter-exceptions", "w+");
                fputs($fichier, $ip_list);
                fclose($fichier);
                // test si Dansguardian 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 /usr/local/sbin/alcasar-bl.sh -reload");
                        }
                // 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/sbin/alcasar-nf.sh -on");
                        }
        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>