Subversion Repositories ALCASAR

Rev

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

Rev 1339 Rev 1377
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
# Choice of language
11
# Choice of language
12
$Language = 'en';
12
$Language = 'en';
13
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
13
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
14
  $Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
14
  $Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
15
  $Language = strtolower(substr(chop($Langue[0]),0,2)); }
15
  $Language = strtolower(substr(chop($Langue[0]),0,2)); }
16
if($Language == 'fr'){
16
if($Language == 'fr'){
17
  $l_title_antivir = "Antivirus de flux WEB";
-
 
18
  $l_antivir_on="L'antivirus de flux WEB est actuellement activ&eacute;";
-
 
19
  $l_antivir_off="L'antivirus de flux WEB est actuellement désactiv&eacute;";
-
 
20
  $l_switch_antivir_on="Activer l'antivirus";
-
 
21
  $l_switch_antivir_off="D&eacute;sactiver l'antivirus";
-
 
22
  $l_remove="Retirer de la liste";
17
  $l_remove="Retirer de la liste";
23
  $l_title_proto = "Filtrage de protocoles r&eacute;seau";
18
  $l_title_proto = "Filtrage de protocoles r&eacute;seau";
24
  $l_netfilter_on="Le filtrage de protocoles r&eacute;seau est actuellement activ&eacute;";
19
  $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";
20
  $l_netfilter_off="Le filtrage de protocoles réseau est actuellement désactiv&eacute";
26
  $l_switch_on="Activer le filtrage";
21
  $l_switch_on="Activer le filtrage";
27
  $l_switch_off="D&eacute;sactiver le filtrage";
22
  $l_switch_off="D&eacute;sactiver le filtrage";
28
  $l_comment_on="&Agrave; l'exclusion du WEB (port 80), les protocoles r&eacute;seaux 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;seaux sont interdits.<BR>Choisissez ci-dessous les protocoles que vous autorisez";
29
  $l_comment_off="(tous les protocoles réseau sont autoris&eacute;s)";
24
  $l_comment_off="(tous les protocoles réseau sont autoris&eacute;s)";
30
  $l_protocols="Protocoles autoris&eacute;s";
25
  $l_protocols="Protocoles autoris&eacute;s";
31
  $l_error_open_file="Erreur d'ouverture du fichier";
26
  $l_error_open_file="Erreur d'ouverture du fichier";
32
  $l_port="Numéro de port";
27
  $l_port="Numéro de port";
33
  $l_proto="Nom du protocole";
28
  $l_proto="Nom du protocole";
34
  $l_enabled="Autoris&eacute;";
29
  $l_enabled="Autoris&eacute;";
35
  $l_add_to_list="Ajouter &agrave; la liste";
30
  $l_add_to_list="Ajouter &agrave; la liste";
36
  $l_save="Enregistrer les modifications";
31
  $l_save="Enregistrer les modifications";
37
}
32
}
38
else {
33
else {
39
  $l_title_antivir = "WEB antivirus";
-
 
40
  $l_antivir_on="Actually, the WEB antivirus is on";
-
 
41
  $l_antivir_off="Actually, the WEB antivirus is off";
-
 
42
  $l_switch_antivir_on="Switch the antivirus on";
-
 
43
  $l_switch_antivir_off="Switch the antivirus off";
-
 
44
  $l_remove="Remove from list";
34
  $l_remove="Remove from list";
45
  $l_title_proto = "Network protocols filter";
35
  $l_title_proto = "Network protocols filter";
46
  $l_netfilter_on="Actually, the network protocols filter is enable";
36
  $l_netfilter_on="Actually, the network protocols filter is enable";
47
  $l_netfilter_off="Actually, the network protocols filter is disable";
37
  $l_netfilter_off="Actually, the network protocols filter is disable";
48
  $l_switch_on="Switch the Filter on";
38
  $l_switch_on="Switch the Filter on";
49
  $l_switch_off="Switch the Filter off";
39
  $l_switch_off="Switch the Filter off";
50
  $l_comment_on="(choose the authorized network protocols)";
40
  $l_comment_on="(choose the authorized network protocols)";
51
  $l_comment_on="Except for the WEB (port 80), all protocols are blocked.<BR>Choose in the list below, the protocols you want authorize";
41
  $l_comment_on="Except for the WEB (port 80), all protocols are blocked.<BR>Choose in the list below, the protocols you want authorize";
52
  $l_comment_off="(all the network protocols are allowed for authenticated users)";
42
  $l_comment_off="(all the network protocols are allowed for authenticated users)";
53
  $l_protocols="Authorize protocols";
43
  $l_protocols="Authorize protocols";
54
  $l_error_open_file="Error opening the file";
44
  $l_error_open_file="Error opening the file";
55
  $l_port="Port number";
45
  $l_port="Port number";
56
  $l_proto="protocol name";
46
  $l_proto="protocol name";
57
  $l_enabled="Authorized";
47
  $l_enabled="Authorized";
58
  $l_add_to_list="Add to the list";
48
  $l_add_to_list="Add to the list";
59
  $l_save="Save changes";
49
  $l_save="Save changes";
60
}
50
}
61
/********************
51
/********************
62
*  TEST CONF FILES  *
52
*  TEST CONF FILES  *
63
*********************/
53
*********************/
64
define ("SERVICES_LIST", "/usr/local/etc/alcasar-services");
54
define ("SERVICES_LIST", "/usr/local/etc/alcasar-services");
65
define ("CONF_FILE", "/usr/local/etc/alcasar.conf");
55
define ("CONF_FILE", "/usr/local/etc/alcasar.conf");
66
$conf_files=array(SERVICES_LIST,CONF_FILE);
56
$conf_files=array(SERVICES_LIST,CONF_FILE);
67
foreach ($conf_files as $file){
57
foreach ($conf_files as $file){
68
if (!file_exists($file)){
58
if (!file_exists($file)){
69
	exit("Requested file ".$file." isn't present");}
59
	exit("Requested file ".$file." isn't present");}
70
if (!is_readable($file)){
60
if (!is_readable($file)){
71
	exit("Can't read the file ".$file);}
61
	exit("Can't read the file ".$file);}
72
}
62
}
73
/**********************************
63
/**********************************
74
*	Read ALCASAR CONF_FILE    *
64
*	Read ALCASAR CONF_FILE    *
75
***********************************/
65
***********************************/
76
$ouvre=fopen(CONF_FILE,"r");
66
$ouvre=fopen(CONF_FILE,"r");
77
if ($ouvre){
67
if ($ouvre){
78
	while (!feof ($ouvre))
68
	while (!feof ($ouvre))
79
	{
69
	{
80
		$tampon = fgets($ouvre, 4096);
70
		$tampon = fgets($ouvre, 4096);
81
		if (strpos($tampon,"=")!==false){
71
		if (strpos($tampon,"=")!==false){
82
			$tmp = explode("=",$tampon);
72
			$tmp = explode("=",$tampon);
83
			$conf[$tmp[0]] = $tmp[1];
73
			$conf[$tmp[0]] = $tmp[1];
84
		}
74
		}
85
	}
75
	}
86
	fclose($ouvre);
76
	fclose($ouvre);
87
}
77
}
88
 
78
 
89
if (isset($_POST['choix'])){$choix=$_POST['choix'];} else {$choix="";}
79
if (isset($_POST['choix'])){$choix=$_POST['choix'];} else {$choix="";}
90
switch ($choix)
80
switch ($choix)
91
{
81
{
92
case 'AV_On' :
-
 
93
	exec ("sudo /usr/local/sbin/alcasar-havp.sh -on");
-
 
94
	break;
-
 
95
case 'AV_Off' :
-
 
96
	exec ("sudo /usr/local/sbin/alcasar-havp.sh -off");
-
 
97
	break;
-
 
98
case 'NF_On' :
82
case 'NF_On' :
99
	exec ("sudo /usr/local/sbin/alcasar-nf.sh -on");
83
	exec ("sudo /usr/local/sbin/alcasar-nf.sh -on");
100
	break;
84
	break;
101
case 'NF_Off' :
85
case 'NF_Off' :
102
	exec ("sudo /usr/local/sbin/alcasar-nf.sh -off");
86
	exec ("sudo /usr/local/sbin/alcasar-nf.sh -off");
103
	break;
87
	break;
104
case 'new_port' :
88
case 'new_port' :
105
	if ((trim($_POST['add_port']) != "80") and ($_POST['add_port'] != "") and ($_POST['add_proto'] != "") and (is_numeric($_POST['add_port'])))
89
	if ((trim($_POST['add_port']) != "80") and ($_POST['add_port'] != "") and ($_POST['add_proto'] != "") and (is_numeric($_POST['add_port'])))
106
		{
90
		{
107
		$_POST['add_proto'] = str_replace (CHR(32),"-",$_POST['add_proto']);
91
		$_POST['add_proto'] = str_replace (CHR(32),"-",$_POST['add_proto']);
108
		$tab=file(SERVICES_LIST);
92
		$tab=file(SERVICES_LIST);
109
		$insert = true;
93
		$insert = true;
110
		if ($tab) // file isn't empty
94
		if ($tab) // file isn't empty
111
			{
95
			{
112
			foreach ($tab as $line)  //test if port doesn't already exist
96
			foreach ($tab as $line)  //test if port doesn't already exist
113
				{
97
				{
114
				$proto_f=explode(" ", $line);
98
				$proto_f=explode(" ", $line);
115
				if (trim($_POST['add_port']) == trim($proto_f[1])) {$insert = false;}
99
				if (trim($_POST['add_port']) == trim($proto_f[1])) {$insert = false;}
116
				}
100
				}
117
			}
101
			}
118
		if ($insert == true) 
102
		if ($insert == true) 
119
			{
103
			{
120
			$line = "\n" . "#" . trim($_POST['add_proto']) . " " . trim($_POST['add_port']);
104
			$line = "\n" . "#" . trim($_POST['add_proto']) . " " . trim($_POST['add_port']);
121
			$pointeur=fopen(SERVICES_LIST,"a");
105
			$pointeur=fopen(SERVICES_LIST,"a");
122
			fwrite ($pointeur, $line);
106
			fwrite ($pointeur, $line);
123
			fclose ($pointeur);
107
			fclose ($pointeur);
124
			exec ("sudo /usr/local/bin/alcasar-file-clean.sh");
108
			exec ("sudo /usr/local/bin/alcasar-file-clean.sh");
125
			}
109
			}
126
		}
110
		}
127
	break;
111
	break;
128
case 'change_port' :
112
case 'change_port' :
129
	$tab=file(SERVICES_LIST);
113
	$tab=file(SERVICES_LIST);
130
	if ($tab)
114
	if ($tab)
131
		{
115
		{
132
// authorize/block protocols
116
// authorize/block protocols
133
		$pointeur=fopen(SERVICES_LIST,"w+");
117
		$pointeur=fopen(SERVICES_LIST,"w+");
134
		foreach ($tab as $ligne)
118
		foreach ($tab as $ligne)
135
			{
119
			{
136
			$proto_f=explode(" ", $ligne);
120
			$proto_f=explode(" ", $ligne);
137
			$name_svc1=trim($proto_f[0],"#");
121
			$name_svc1=trim($proto_f[0],"#");
138
			$actif = False; $remove_line = false;
122
			$actif = False; $remove_line = false;
139
			foreach ($_POST as $key => $value)
123
			foreach ($_POST as $key => $value)
140
				{
124
				{
141
				if (strstr($key,'del-'))
125
				if (strstr($key,'del-'))
142
					{
126
					{
143
					$name_svc2 = str_replace('del-','',$key);
127
					$name_svc2 = str_replace('del-','',$key);
144
					if ($name_svc1 == $name_svc2)
128
					if ($name_svc1 == $name_svc2)
145
				       		{
129
				       		{
146
						$remove_line = True;
130
						$remove_line = True;
147
						}
131
						}
148
					}
132
					}
149
				if (strstr($key,'chk-'))
133
				if (strstr($key,'chk-'))
150
					{
134
					{
151
					$name_svc2 = str_replace('chk-','',$key);
135
					$name_svc2 = str_replace('chk-','',$key);
152
					if ($name_svc1 == $name_svc2)
136
					if ($name_svc1 == $name_svc2)
153
				       		{
137
				       		{
154
						$actif = True;
138
						$actif = True;
155
						break;
139
						break;
156
						}
140
						}
157
					}
141
					}
158
				}
142
				}
159
			if (! $remove_line)
143
			if (! $remove_line)
160
				{
144
				{
161
				if (! $actif) {	$line="#$name_svc1 $proto_f[1]";}
145
				if (! $actif) {	$line="#$name_svc1 $proto_f[1]";}
162
				else { $line="$name_svc1 $proto_f[1]";}
146
				else { $line="$name_svc1 $proto_f[1]";}
163
				fwrite($pointeur,$line);
147
				fwrite($pointeur,$line);
164
				}
148
				}
165
			}
149
			}
166
		fclose($pointeur);
150
		fclose($pointeur);
167
		}
151
		}
168
	exec ("sudo /usr/local/bin/alcasar-iptables.sh -on");
152
	exec ("sudo /usr/local/bin/alcasar-iptables.sh -on");
169
	break;
153
	break;
170
	}
154
	}
171
# default values
155
# default values
172
if (is_file (CONF_FILE))
156
if (is_file (CONF_FILE))
173
	{
157
	{
174
	$tab=file(CONF_FILE);
158
	$tab=file(CONF_FILE);
175
	if ($tab)
159
	if ($tab)
176
		{
160
		{
177
		foreach ($tab as $line)
161
		foreach ($tab as $line)
178
			{
162
			{
179
			$field=explode("=", $line);
163
			$field=explode("=", $line);
180
			if ($field[0] == "PROTOCOLS_FILTERING")	{$PROTOCOLS_FILTERING=trim($field[1]);}
164
			if ($field[0] == "PROTOCOLS_FILTERING")	{$PROTOCOLS_FILTERING=trim($field[1]);}
181
			if ($field[0] == "WEB_ANTIVIRUS")	{$WEB_ANTIVIRUS=trim($field[1]);}
-
 
182
			}
165
			}
183
		}
166
		}
184
	}
167
	}
185
echo "<tr><th>$l_title_antivir</th></tr>";
-
 
186
?>
-
 
187
<tr bgcolor=#FFCC66><td><img src=/images/pix.gif width=1 height=2></td></tr>
-
 
188
</TABLE>
-
 
189
<TABLE width="100%" border=1 cellspacing=0 cellpadding=0>
-
 
190
	<tr><td valign="middle" align="left">
-
 
191
<?php
-
 
192
if ($WEB_ANTIVIRUS == "on")
-
 
193
	{
-
 
194
	echo "<CENTER><H3>$l_antivir_on</H3></CENTER>";
-
 
195
 	echo "<FORM action='$_SERVER[PHP_SELF]' method=POST>";
-
 
196
	echo "<input type=hidden name='choix' value=\"AV_Off\">";
-
 
197
	echo "<input type=submit value=\"$l_switch_antivir_off\">";
-
 
198
}
-
 
199
else
-
 
200
	{
-
 
201
	echo "<CENTER><H3>$l_antivir_off</H3></CENTER>";
-
 
202
 	echo "<FORM action='$_SERVER[PHP_SELF]' method=POST>";
-
 
203
	echo "<input type=hidden name='choix' value=\"AV_On\">";
-
 
204
	echo "<input type=submit value=\"$l_switch_antivir_on\">";
-
 
205
	}
-
 
206
?>
168
?>
207
</FORM>
-
 
208
</td></tr>
-
 
209
</table>
-
 
210
<TABLE width="100%" border=0 cellspacing=0 cellpadding=0>
169
<TABLE width="100%" border=0 cellspacing=0 cellpadding=0>
211
<tr><th><?echo "$l_title_proto";?></th></tr>
170
<tr><th><?echo "$l_title_proto";?></th></tr>
212
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
171
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
213
</table>
172
</table>
214
<TABLE width="100%" border=1 cellspacing=0 cellpadding=0>
173
<TABLE width="100%" border=1 cellspacing=0 cellpadding=0>
215
<tr>
174
<tr>
216
<?
175
<?
217
if ($PROTOCOLS_FILTERING == "on")
176
if ($PROTOCOLS_FILTERING == "on")
218
	{
177
	{
219
	echo "<td colspan=\"2\" valign=\"middle\" align=\"left\">";
178
	echo "<td colspan=\"2\" valign=\"middle\" align=\"left\">";
220
	echo "<CENTER><H3>$l_netfilter_on</H3>$l_comment_on</CENTER>";
179
	echo "<CENTER><H3>$l_netfilter_on</H3>$l_comment_on</CENTER>";
221
	echo "<FORM action='$_SERVER[PHP_SELF]' method=POST>";
180
	echo "<FORM action='$_SERVER[PHP_SELF]' method=POST>";
222
	echo "<input type=hidden name='choix' value=\"NF_Off\">";
181
	echo "<input type=hidden name='choix' value=\"NF_Off\">";
223
	echo "<input type=submit value=\"$l_switch_off\">";
182
	echo "<input type=submit value=\"$l_switch_off\">";
224
	echo "</FORM></td></tr>";
183
	echo "</FORM></td></tr>";
225
	require ('net_filter2.php');
184
	require ('net_filter2.php');
226
	}
185
	}
227
else
186
else
228
	{
187
	{
229
	echo "<td valign=\"middle\" align=\"left\">";
188
	echo "<td valign=\"middle\" align=\"left\">";
230
	echo "<CENTER><H3>$l_netfilter_off</H3>$l_comment_off</CENTER>";
189
	echo "<CENTER><H3>$l_netfilter_off</H3>$l_comment_off</CENTER>";
231
 	echo "<FORM action='$_SERVER[PHP_SELF]' method=POST>";
190
 	echo "<FORM action='$_SERVER[PHP_SELF]' method=POST>";
232
	echo "<input type=hidden name='choix' value=\"NF_On\">";
191
	echo "<input type=hidden name='choix' value=\"NF_On\">";
233
	echo "<input type=submit value=\"$l_switch_on\">";
192
	echo "<input type=submit value=\"$l_switch_on\">";
234
	echo "</FORM></td></tr>";
193
	echo "</FORM></td></tr>";
235
	echo "</table></body></html>";
194
	echo "</table></body></html>";
236
	}
195
	}
237
?>
196
?>
238
 
197