Subversion Repositories ALCASAR

Rev

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