Subversion Repositories ALCASAR

Rev

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