Subversion Repositories ALCASAR

Rev

Rev 303 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log

Rev Author Line No. Line
28 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'){
305 richard 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";
28 richard 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";
161 richard 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";
152 richard 28
  $l_comment_off="(tous les protocoles réseau sont autorisés)";
28 richard 29
  $l_protocols="Protocoles autorisés";
30
  $l_error_open_file="Erreur d'ouverture du fichier";
152 richard 31
  $l_proto="Protocole";
28 richard 32
  $l_enabled="Autorisé";
152 richard 33
  $l_delete="Supprimer de la liste";
34
  $l_add_to_list="Ajouter &agrave; la liste";
28 richard 35
  $l_save_modif="Enregistrer les modifications";
36
}
37
else {
305 richard 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";
28 richard 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";
152 richard 51
  $l_proto="Protocol";
28 richard 52
  $l_enabled="Enable";
152 richard 53
  $l_delete="Delete from list";
54
  $l_add_to_list="Add to the list";
28 richard 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
{
303 richard 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;
28 richard 70
case 'NF_On' :
71
	exec ("sudo /usr/local/sbin/alcasar-nf.sh -on");
305 richard 72
	break;
28 richard 73
case 'NF_Off' :
74
	exec ("sudo /usr/local/sbin/alcasar-nf.sh -off");
305 richard 75
	break;
152 richard 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
		}
305 richard 102
	break;
28 richard 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],"#");
152 richard 113
			$actif = False; $remove_line = false;
28 richard 114
			foreach ($_POST as $key => $value)
115
				{
152 richard 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
					}
28 richard 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
				}
152 richard 135
			if (! $remove_line)
28 richard 136
				{
152 richard 137
				if (! $actif) {	$line="#$name_svc1 $proto_f[1]";}
138
				else { $line="$name_svc1 $proto_f[1]";}
139
				fwrite($pointeur,$line);
28 richard 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");
305 richard 146
	break;
28 richard 147
	}
303 richard 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
</TABLE>
305 richard 191
<TABLE width="100%" border=1 cellspacing=0 cellpadding=1>
192
<tr><td valign="middle" align="left">
303 richard 193
<?
28 richard 194
$pointeur = fopen("/usr/local/bin/alcasar-iptables.sh", "r");
195
$result = False ;
196
if ($pointeur)
197
	{
198
  	while (!feof($pointeur))
199
		{
200
    		$ligne = fgets($pointeur);
201
    		if (preg_match('/^FILTERING="yes"/', $ligne, $r))
202
			{
203
			$result = True ;
204
			break;
205
			}
206
    		}
207
  	}
208
fclose($pointeur);
209
if ($result)
210
	{
211
	echo "<CENTER><H3>$l_netfilter_on</H3>$l_comment_on</CENTER>";
212
	echo "<FORM action='$_SERVER[PHP_SELF]' method=POST>";
213
	echo "<input type=hidden name='choix' value=\"NF_Off\">";
214
	echo "<input type=submit value=\"$l_switch_off\">";
215
	}
216
else
217
	{
218
	echo "<CENTER><H3>$l_netfilter_off</H3>$l_comment_off</CENTER>";
219
 	echo "<FORM action='$_SERVER[PHP_SELF]' method=POST>";
220
	echo "<input type=hidden name='choix' value=\"NF_On\">";
221
	echo "<input type=submit value=\"$l_switch_on\">";
222
	}
223
echo "</FORM>";
224
echo "</td></tr>";
225
echo "</TABLE>";
226
if ($result) require ('net_filter2.php');
227
?>
228
</BODY>
229
</HTML>