1521 |
richard |
1 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
|
|
2 |
<HTML><!-- written by Rexy -->
|
|
|
3 |
<HEAD>
|
|
|
4 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
|
5 |
<TITLE>Network Filter</TITLE>
|
|
|
6 |
<link rel="stylesheet" href="/css/style.css" type="text/css">
|
|
|
7 |
</HEAD>
|
|
|
8 |
<body>
|
|
|
9 |
<TABLE width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
|
10 |
<?
|
|
|
11 |
# Choice of language
|
|
|
12 |
$Language = 'en';
|
|
|
13 |
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
|
|
|
14 |
$Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
|
|
|
15 |
$Language = strtolower(substr(chop($Langue[0]),0,2)); }
|
|
|
16 |
if($Language == 'fr'){
|
|
|
17 |
$l_remove="Retirer de la liste";
|
|
|
18 |
$l_title_proto = "Filtrage de protocoles réseau";
|
2006 |
raphael.pi |
19 |
$l_protocolsfilter="Vous pouvez personnaliser le profile de filtrage protocole 'personnalisable' ici. Vous pouvez ensuite l'attribuer à des utilisateurs via l'éditeur ou la création d'utilisateur.";
|
1521 |
richard |
20 |
$l_comment_on="À l'exclusion du WEB (port 80), les protocoles réseaux sont interdits.<BR>Choisissez ci-dessous les protocoles que vous autorisez";
|
|
|
21 |
$l_comment_off="(tous les protocoles réseau sont autorisés)";
|
|
|
22 |
$l_protocols="Protocoles autorisés";
|
|
|
23 |
$l_error_open_file="Erreur d'ouverture du fichier";
|
|
|
24 |
$l_port="Numéro de port";
|
|
|
25 |
$l_proto="Nom du protocole";
|
|
|
26 |
$l_enabled="Autorisé";
|
|
|
27 |
$l_add_to_list="Ajouter à la liste";
|
|
|
28 |
$l_save="Enregistrer les modifications";
|
|
|
29 |
}
|
|
|
30 |
else {
|
|
|
31 |
$l_remove="Remove from list";
|
|
|
32 |
$l_title_proto = "Network protocols filter";
|
2006 |
raphael.pi |
33 |
$l_protocolsfilter="You can change your \"custom\" protocol filtering here. You can set it to a user from ACC (create user / edit user)";
|
1521 |
richard |
34 |
$l_comment_on="(choose the authorized network protocols)";
|
|
|
35 |
$l_comment_on="Except for the WEB (port 80), all protocols are blocked.<BR>Choose in the list below, the protocols you want authorize";
|
|
|
36 |
$l_comment_off="(all the network protocols are allowed for authenticated users)";
|
|
|
37 |
$l_protocols="Authorize protocols";
|
|
|
38 |
$l_error_open_file="Error opening the file";
|
|
|
39 |
$l_port="Port number";
|
|
|
40 |
$l_proto="protocol name";
|
|
|
41 |
$l_enabled="Authorized";
|
|
|
42 |
$l_add_to_list="Add to the list";
|
|
|
43 |
$l_save="Save changes";
|
|
|
44 |
}
|
|
|
45 |
/********************
|
|
|
46 |
* TEST CONF FILES *
|
|
|
47 |
*********************/
|
|
|
48 |
define ("SERVICES_LIST", "/usr/local/etc/alcasar-services");
|
|
|
49 |
define ("CONF_FILE", "/usr/local/etc/alcasar.conf");
|
|
|
50 |
$conf_files=array(SERVICES_LIST,CONF_FILE);
|
|
|
51 |
foreach ($conf_files as $file){
|
|
|
52 |
if (!file_exists($file)){
|
|
|
53 |
exit("Requested file ".$file." isn't present");}
|
|
|
54 |
if (!is_readable($file)){
|
|
|
55 |
exit("Can't read the file ".$file);}
|
|
|
56 |
}
|
|
|
57 |
/**********************************
|
|
|
58 |
* Read ALCASAR CONF_FILE *
|
|
|
59 |
***********************************/
|
|
|
60 |
$ouvre=fopen(CONF_FILE,"r");
|
|
|
61 |
if ($ouvre){
|
|
|
62 |
while (!feof ($ouvre))
|
|
|
63 |
{
|
|
|
64 |
$tampon = fgets($ouvre, 4096);
|
|
|
65 |
if (strpos($tampon,"=")!==false){
|
|
|
66 |
$tmp = explode("=",$tampon);
|
|
|
67 |
$conf[$tmp[0]] = $tmp[1];
|
|
|
68 |
}
|
|
|
69 |
}
|
|
|
70 |
fclose($ouvre);
|
|
|
71 |
}
|
|
|
72 |
|
|
|
73 |
if (isset($_POST['choix'])){$choix=$_POST['choix'];} else {$choix="";}
|
|
|
74 |
switch ($choix)
|
|
|
75 |
{
|
|
|
76 |
case 'new_port' :
|
|
|
77 |
if ((trim($_POST['add_port']) != "80") and ($_POST['add_port'] != "") and ($_POST['add_proto'] != "") and (is_numeric($_POST['add_port'])))
|
|
|
78 |
{
|
|
|
79 |
$_POST['add_proto'] = str_replace (CHR(32),"-",$_POST['add_proto']);
|
|
|
80 |
$tab=file(SERVICES_LIST);
|
|
|
81 |
$insert = true;
|
|
|
82 |
if ($tab) // file isn't empty
|
|
|
83 |
{
|
|
|
84 |
foreach ($tab as $line) //test if port doesn't already exist
|
|
|
85 |
{
|
|
|
86 |
$proto_f=explode(" ", $line);
|
|
|
87 |
if (trim($_POST['add_port']) == trim($proto_f[1])) {$insert = false;}
|
|
|
88 |
}
|
|
|
89 |
}
|
|
|
90 |
if ($insert == true)
|
|
|
91 |
{
|
|
|
92 |
$line = "\n" . "#" . trim($_POST['add_proto']) . " " . trim($_POST['add_port']);
|
|
|
93 |
$pointeur=fopen(SERVICES_LIST,"a");
|
|
|
94 |
fwrite ($pointeur, $line);
|
|
|
95 |
fclose ($pointeur);
|
|
|
96 |
exec ("sudo /usr/local/bin/alcasar-file-clean.sh");
|
|
|
97 |
}
|
|
|
98 |
}
|
|
|
99 |
break;
|
|
|
100 |
case 'change_port' :
|
|
|
101 |
$tab=file(SERVICES_LIST);
|
|
|
102 |
if ($tab)
|
|
|
103 |
{
|
|
|
104 |
// authorize/block protocols
|
|
|
105 |
$pointeur=fopen(SERVICES_LIST,"w+");
|
|
|
106 |
foreach ($tab as $ligne)
|
|
|
107 |
{
|
|
|
108 |
$proto_f=explode(" ", $ligne);
|
|
|
109 |
$name_svc1=trim($proto_f[0],"#");
|
|
|
110 |
$actif = False; $remove_line = false;
|
|
|
111 |
foreach ($_POST as $key => $value)
|
|
|
112 |
{
|
|
|
113 |
if (strstr($key,'del-'))
|
|
|
114 |
{
|
|
|
115 |
$name_svc2 = str_replace('del-','',$key);
|
|
|
116 |
if ($name_svc1 == $name_svc2)
|
|
|
117 |
{
|
|
|
118 |
$remove_line = True;
|
|
|
119 |
}
|
|
|
120 |
}
|
|
|
121 |
if (strstr($key,'chk-'))
|
|
|
122 |
{
|
|
|
123 |
$name_svc2 = str_replace('chk-','',$key);
|
|
|
124 |
if ($name_svc1 == $name_svc2)
|
|
|
125 |
{
|
|
|
126 |
$actif = True;
|
|
|
127 |
break;
|
|
|
128 |
}
|
|
|
129 |
}
|
|
|
130 |
}
|
|
|
131 |
if (! $remove_line)
|
|
|
132 |
{
|
|
|
133 |
if (! $actif) { $line="#$name_svc1 $proto_f[1]";}
|
|
|
134 |
else { $line="$name_svc1 $proto_f[1]";}
|
|
|
135 |
fwrite($pointeur,$line);
|
|
|
136 |
}
|
|
|
137 |
}
|
|
|
138 |
fclose($pointeur);
|
|
|
139 |
}
|
|
|
140 |
exec ("sudo /usr/local/bin/alcasar-iptables.sh -on");
|
|
|
141 |
break;
|
|
|
142 |
}
|
|
|
143 |
?>
|
|
|
144 |
<TABLE width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
|
145 |
<tr><th><?echo "$l_title_proto";?></th></tr>
|
|
|
146 |
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
|
|
|
147 |
</table>
|
|
|
148 |
<TABLE width="100%" border=1 cellspacing=0 cellpadding=0>
|
|
|
149 |
<tr>
|
2006 |
raphael.pi |
150 |
|
1521 |
richard |
151 |
<?
|
2006 |
raphael.pi |
152 |
|
|
|
153 |
echo "<td colspan=\"2\" valign=\"middle\" align=\"left\">";
|
|
|
154 |
echo "<CENTER><H3>$l_protocolsfilter_on</H3>$l_comment_on</CENTER>";
|
|
|
155 |
require ('protocols_filter2.php');
|
|
|
156 |
|
1521 |
richard |
157 |
?>
|
2006 |
raphael.pi |
158 |
|