Subversion Repositories ALCASAR

Rev

Details | Last modification | View Log

Rev Author Line No. Line
318 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
$services_list="/usr/local/etc/alcasar-services";
12
# Choice of language
13
$Language = 'en';
14
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
15
  $Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
16
  $Language = strtolower(substr(chop($Langue[0]),0,2)); }
17
if($Language == 'fr'){
18
  $l_title = "Filtrage de protocoles réseau";
19
  $l_antivir_on="L'antivirus de flux WEB est actuellement activé";
20
  $l_antivir_off="L'antivirus de flux WEB est actuellement désactivé";
21
  $l_switch_antivir_on="Activer l'antivirus";
22
  $l_switch_antivir_off="Désactiver l'antivirus";
23
  $l_netfilter_on="Le filtrage réseau est actuellement activé";
24
  $l_netfilter_off="Le filtrage réseau est actuellement désactivé";
25
  $l_switch_on="Activer le filtrage r&eacute;seau";
26
  $l_switch_off="Désactiver le filtrage réseau";
27
  $l_comment_on="&Agrave; l'exclusion du WEB (port 80), les protocoles r&eacute;seau sont interdits.<BR>Choisissez ci-dessous les protocoles que vous autorisez";
28
  $l_comment_off="(tous les protocoles réseau sont autorisés)";
29
  $l_protocols="Protocoles autorisés";
30
  $l_error_open_file="Erreur d'ouverture du fichier";
31
  $l_proto="Protocole";
32
  $l_enabled="Autorisé";
33
  $l_delete="Supprimer de la liste";
34
  $l_add_to_list="Ajouter &agrave; la liste";
35
  $l_save_modif="Enregistrer les modifications";
36
}
37
else {
38
  $l_title = "Network protocols filtering";
39
  $l_antivir_on="Actually, the antivirus is on";
40
  $l_antivir_off="Actually, the antivirus is off";
41
  $l_switch_antivir_on="Switch the antivirus on";
42
  $l_switch_antivir_off="Switch the antivirus off";
43
  $l_netfilter_on="Actually, the network filter is enable";
44
  $l_netfilter_off="Actually, the network filter is disable";
45
  $l_switch_on="Switch the Network Filter on";
46
  $l_switch_off="Switch the Network Filter off";
47
  $l_comment_on="(choose the authorized network protocols)";
48
  $l_comment_off="(all the network protocols are allowed for authenticated users)";
49
  $l_protocols="Authorize protocols";
50
  $l_error_open_file="Error opening the file";
51
  $l_proto="Protocol";
52
  $l_enabled="Enable";
53
  $l_delete="Delete from list";
54
  $l_add_to_list="Add to the list";
55
  $l_save_modif="Save modifications";
56
}
57
echo "
58
<tr><th>$l_title</th></tr>
59
<tr bgcolor=\"#FFCC66\"><td><img src=\"/images/pix.gif\" width=1 height=2></td></tr>
60
</TABLE>";
61
if (isset($_POST['choix'])){$choix=$_POST['choix'];} else {$choix="";}
62
switch ($choix)
63
{
64
case 'AV_On' :
65
	exec ("sudo /usr/local/sbin/alcasar-havp.sh -on");
66
	break;
67
case 'AV_Off' :
68
	exec ("sudo /usr/local/sbin/alcasar-havp.sh -off");
69
	break;
70
case 'NF_On' :
71
	exec ("sudo /usr/local/sbin/alcasar-nf.sh -on");
72
	break;
73
case 'NF_Off' :
74
	exec ("sudo /usr/local/sbin/alcasar-nf.sh -off");
75
	break;
76
case 'new_proto' :
77
	if ((trim($_POST['add_port']) != "80") and ($_POST['add_port'] != "") and ($_POST['add_proto'] != "") and (is_numeric($_POST['add_port'])))
78
		{
79
		$tab=file($services_list);
80
		if ($tab)
81
			{
82
			$pointeur=fopen($services_list,"r");
83
			//on teste si le port n'est pas déjà présent
84
			$insert = true;
85
			foreach ($tab as $ligne)
86
				{
87
				$proto_f=explode(" ", $ligne);
88
				if (trim($_POST['add_port']) == trim($proto_f[1])) {$insert = false;}
89
				}
90
			fclose($pointeur);
91
			if ($insert == true) 
92
				{
93
				$line = "#" . trim($_POST['add_proto']) . " " . trim($_POST['add_port']);
94
				$pointeur=fopen($services_list,"a");
95
				fwrite ($pointeur, $line);
96
				fclose ($pointeur);
97
				exec ("sudo /usr/local/sbin/alcasar-nf.sh -on");
98
				}
99
			}
100
		else {echo "$l_error_open_file $services_list";}
101
		}
102
	break;
103
case 'change' :
104
	$tab=file($services_list);
105
	if ($tab)
106
		{
107
//on active|désactive les protocoles
108
		$pointeur=fopen($services_list,"w+");
109
		foreach ($tab as $ligne)
110
			{
111
			$proto_f=explode(" ", $ligne);
112
			$name_svc1=trim($proto_f[0],"#");
113
			$actif = False; $remove_line = false;
114
			foreach ($_POST as $key => $value)
115
				{
116
				if (strstr($key,'del-'))
117
					{
118
					$name_svc2 = str_replace('del-','',$key);
119
					if ($name_svc1 == $name_svc2)
120
				       		{
121
						$remove_line = True;
122
						break;
123
						}
124
					}
125
				if (strstr($key,'chk-'))
126
					{
127
					$name_svc2 = str_replace('chk-','',$key);
128
					if ($name_svc1 == $name_svc2)
129
				       		{
130
						$actif = True;
131
						break;
132
						}
133
					}
134
				}
135
			if (! $remove_line)
136
				{
137
				if (! $actif) {	$line="#$name_svc1 $proto_f[1]";}
138
				else { $line="$name_svc1 $proto_f[1]";}
139
				fwrite($pointeur,$line);
140
				}
141
			}
142
		fclose($pointeur);
143
		}
144
	else {echo "$l_error_open_file $services_list";}
145
	exec ("sudo /usr/local/sbin/alcasar-nf.sh -on");
146
	break;
147
	}
148
?>
149
<TABLE width="100%" border=1 cellspacing=0 cellpadding=0>
150
	<tr><td valign="middle" align="left">
151
<?php
152
$pointeur = fopen("/etc/dansguardian/dansguardian.conf", "r");
153
$result_antivir = false; $result_filter = false; $out=0;
154
if ($pointeur)
155
	{
156
  	while (!feof($pointeur))
157
		{
158
    		$ligne = fgets($pointeur);
159
    		if (preg_match("/^proxyport = 8090/", $ligne, $r))
160
			{
161
			$result_antivir = true;
162
			$out++;
163
			}
164
    		if (preg_match("/^reportinglevel = 3/", $ligne, $r))
165
			{
166
			$result_filter = true;
167
			$out++;
168
			}
169
		if ($out == 2) break;
170
    		}
171
  	}
172
fclose($pointeur);
173
if ($result_antivir)
174
	{
175
	echo "<CENTER><H3>$l_antivir_on</H3></CENTER>";
176
 	echo "<FORM action='$_SERVER[PHP_SELF]' method=POST>";
177
	echo "<input type=hidden name='choix' value=\"AV_Off\">";
178
	echo "<input type=submit value=\"$l_switch_antivir_off\">";
179
}
180
else
181
	{
182
	echo "<CENTER><H3>$l_antivir_off</H3></CENTER>";
183
 	echo "<FORM action='$_SERVER[PHP_SELF]' method=POST>";
184
	echo "<input type=hidden name='choix' value=\"AV_On\">";
185
	echo "<input type=submit value=\"$l_switch_antivir_on\">";
186
	}
187
?>
188
</FORM>
189
</td></tr>
190
<tr><td valign="middle" align="left">
191
<?
192
$pointeur = fopen("/usr/local/bin/alcasar-iptables.sh", "r");
193
$result = False ;
194
if ($pointeur)
195
	{
196
  	while (!feof($pointeur))
197
		{
198
    		$ligne = fgets($pointeur);
199
    		if (preg_match('/^FILTERING="yes"/', $ligne, $r))
200
			{
201
			$result = True ;
202
			break;
203
			}
204
    		}
205
  	}
206
fclose($pointeur);
207
if ($result)
208
	{
209
	echo "<CENTER><H3>$l_netfilter_on</H3>$l_comment_on</CENTER>";
210
	echo "<FORM action='$_SERVER[PHP_SELF]' method=POST>";
211
	echo "<input type=hidden name='choix' value=\"NF_Off\">";
212
	echo "<input type=submit value=\"$l_switch_off\">";
213
	}
214
else
215
	{
216
	echo "<CENTER><H3>$l_netfilter_off</H3>$l_comment_off</CENTER>";
217
 	echo "<FORM action='$_SERVER[PHP_SELF]' method=POST>";
218
	echo "<input type=hidden name='choix' value=\"NF_On\">";
219
	echo "<input type=submit value=\"$l_switch_on\">";
220
	}
221
echo "</FORM>";
222
echo "</td></tr>";
223
echo "</TABLE>";
224
if ($result) require ('net_filter2.php');
225
?>
226
</BODY>
227
</HTML>