Subversion Repositories ALCASAR

Rev

Rev 161 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log

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