Subversion Repositories ALCASAR

Rev

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