Subversion Repositories ALCASAR

Rev

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

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><!-- written by Rexy - 3abtux -->
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<TITLE>Exceptions</TITLE>
<link rel="stylesheet" href="/css/style.css" type="text/css">
</HEAD>
<body>
<?
$mac_allowed_list="/usr/local/etc/alcasar-macallowed";
$domain_allowed_list="/usr/local/etc/alcasar-uamdomain";
$url_allowed_list="/usr/local/etc/alcasar-uamallowed";
# 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_error_open_file = "Erreur d'ouverture du fichier";
  $l_trusted_sites = "Domaines Internet et adresses IP de confiance";
  $l_trusted_sites_explain1 = "Entrez ici les noms de domaine Internet ou les adresses IP pouvant &ecirc;tre joints sans authentification";
  $l_trusted_sites_explain2 = "Entrez un nom de domaine ou une adresse IP par ligne";
  $l_trusted_sites_list = "Liste de nom de domaine de confiance";
  $l_trusted_urls_list = "Liste d'adresses IP ou d'adresses de réseau de confiance";
  $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 d'adresses MAC de confiance";
  $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_submit2 = "Appliquer";
  $l_add_to_list = "Ajouter";
}
else {
  $l_error_open_file = "File open error";
  $l_trusted_sites = "Trusted Internet domain and IP addresses";
  $l_trusted_sites_explain1 = "Enter Internet domain name or IP addresses that could be joined without authentication";
  $l_trusted_sites_explain2 = "Enter one domain name ou one IP address per line";
  $l_trusted_sites_list = "Trusted Internet domain list";
  $l_trusted_urls_list = "Trusted IP addresses or networks addresses list";
  $l_trusted_mac = "Trusted Equipments";
  $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"; 
  $l_trusted_mac_info = "Equipment information";
  $l_trusted_mac_del = "Delete from list";
  $l_submit = "Submit";
  $l_submit2 = "Apply";
  $l_add_to_list = "Add";
}
if (isset($_POST['choix'])){ 
        switch ($_POST['choix'])
        {
        case 'MAJ_UAMALLOWED' :
                $tab_domains = explode ("\n", $_POST['trusted_domains']);
                $fichier=fopen($domain_allowed_list,"w+");
                foreach ($tab_domains as $domain ){
                        $tr_domain=trim($domain);
                        if ($tr_domain != ""){
                                fputs ($fichier, "uamdomain=\"".$tr_domain."\"\n");}
                        }       
                fclose($fichier);
                unset($_POST['trusted_domains']);
                $tab_urls = explode ("\n", $_POST['trusted_urls']);
                $fichier=fopen($url_allowed_list,"w+");
                foreach ($tab_urls as $url ){
                        $tr_url=trim($url);
                        if ($tr_url != ""){
                                fputs ($fichier, "uamallowed=\"".$tr_url."\"\n");}
                        }
                fclose($fichier);
                unset($_POST['trusted_urls']);
                exec ("sudo service chilli restart");
                unset ($_POST['choix']);
                break;
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");
                                }
                        }
                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");
                }
        else {echo "$l_error_open_file $mac_allowed_list";}
        break;
        }       
}
?>
<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr><th><?php echo $l_trusted_sites ;?></th></tr>
        <tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></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_sites_explain1 <BR>";
                echo "$l_trusted_sites_explain2" ;
                echo "<FORM action='$_SERVER[PHP_SELF]' method='POST'>";?>
                <TABLE cellspacing=2 cellpadding=3 border=1>
                <tr><td width=50% height=100% align=center>
                        <H3><?php echo $l_trusted_sites_list ;?></H3>
                        exemple1 : www.domain1.org<BR>
                        exemple2 : domain2.net<BR>
                        <?php
                                echo "<textarea name='trusted_domains' rows=5 cols=40>";
                                $ouvre=fopen($domain_allowed_list,"r");
                                if ($ouvre)
                                        {
                                        while (!feof ($ouvre))
                                                {
                                                $tampon = fgets($ouvre, 4096);
                                                $domain_list_l = substr($tampon,10);
                                                $domain_list = trim ($domain_list_l,"\"\n\t ");
                                                $tab_domains = explode (",", $domain_list);
                                                foreach ($tab_domains as $domain ){
                                                        if ($domain) { echo $domain."\n";}
                                                        }
                                                }
                                        }
                                else    {
                                        echo "failed to open $domain_allowed_list";
                                        }
                                fclose($ouvre);
                                echo "</textarea>";
                        ?>
                </td>
                <td  width=50% height=100% align=center>
                        <H3><?php echo $l_trusted_urls_list ;?></H3>
                        exemple1 : 192.168.0.10<BR>
                        exemple2 : 172.16.20.0/24<BR>
                        <?php
                                echo "<textarea name='trusted_urls' rows=5 cols=40>";
                                $ouvre=fopen($url_allowed_list,"r");
                                if ($ouvre)
                                        {
                                        while (!feof ($ouvre))
                                                {
                                                $tampon = fgets($ouvre, 4096);
                                                $url_list_l = substr($tampon,11);
                                                $url_list = trim ($url_list_l,"\"\n\t ");
                                                $tab_urls = explode (",", $url_list);
                                                foreach ($tab_urls as $url ){
                                                        if ($url) echo $url."\n";
                                                        }
                                                }
                                        }
                                else    {
                                        echo "failed to open $url_allowed_list";
                                        }
                                fclose($ouvre);
                                echo "</textarea>";
                        ?>
                </td></tr>
                </TABLE>
                <input type='hidden' name='choix' value='MAJ_UAMALLOWED'>
                <input type='submit' value='<?php echo $l_submit ;?>'>
                </FORM>
        </td></tr>
        </TABLE>
</TABLE>
<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr><th><?php echo $l_trusted_mac ;?></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 colspan=2 align="center">
<?
echo "$l_trusted_mac_explain</td></tr>";
echo "<tr><td align='center' valign='middle'>";
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 affiche le fichier d'exception
$display_form = true;
if (is_file ($mac_allowed_list))
        {
        $tab=file($mac_allowed_list);
        if ($tab)  # le fichier n'est pas vide
                {
                foreach ($tab as $line)
                        {
                        $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='$mac_addr'>";
                        echo "</tr>";
                        }
                }
        else { $display_form = false;}
        }
else    {
        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_submit2'>";
        }
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";
?>
<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>
</BODY>
</HTML>