Subversion Repositories ALCASAR

Rev

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

Rev 2006 Rev 2134
1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
1
<!DOCTYPE html "-//W3C//DTD HTML 4.01 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>
-
 
10
<?
9
<?
11
# Choice of language
10
# Choice of language
12
$Language = 'en';
11
$Language = 'en';
13
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
12
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
14
  $Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
13
  $Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
15
  $Language = strtolower(substr(chop($Langue[0]),0,2)); }
14
  $Language = strtolower(substr(chop($Langue[0]),0,2)); }
16
if($Language == 'fr'){
15
if($Language == 'fr'){
17
  $l_remove="Retirer de la liste";
16
  $l_remove="Retirer de la liste";
18
  $l_title_proto = "Filtrage de protocoles r&eacute;seau";
17
  $l_title_proto = "Filtrage prersonnalisée de protocoles réseau";
19
  $l_protocolsfilter="Vous pouvez personnaliser le profile de filtrage protocole 'personnalisable' ici. Vous pouvez ensuite l'attribuer à des utilisateurs via l'éditeur ou la création d'utilisateur.";
18
  $l_comment="Définissez ici la liste personalisée de protocoles réseau filtrés. Vous pouvez ensuite l'attribuer à des utilisateurs lors de leur création ou modification.";
20
  $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";
-
 
21
  $l_comment_off="(tous les protocoles réseau sont autoris&eacute;s)";
-
 
22
  $l_protocols="Protocoles autoris&eacute;s";
19
  $l_protocols="Protocoles autorisés";
23
  $l_error_open_file="Erreur d'ouverture du fichier";
20
  $l_error_open_file="Erreur d'ouverture du fichier";
24
  $l_port="Numéro de port";
21
  $l_port="Numéro de port";
25
  $l_proto="Nom du protocole";
22
  $l_proto="Nom du protocole";
26
  $l_enabled="Autoris&eacute;";
23
  $l_enabled="Autorisé";
27
  $l_add_to_list="Ajouter &agrave; la liste";
24
  $l_add_to_list="Ajouter à la liste";
28
  $l_save="Enregistrer les modifications";
25
  $l_save="Enregistrer les modifications";
29
}
26
}
30
else {
27
else {
31
  $l_remove="Remove from list";
28
  $l_remove="Remove from list";
32
  $l_title_proto = "Network protocols filter";
29
  $l_title_proto = "Custom network protocols filter";
33
  $l_protocolsfilter="You can change your \"custom\" protocol filtering here. You can set it to a user from ACC (create user / edit user)";
30
  $l_comment="You can custom the network protocol filtering here. You can assign it to a user (create/edit a user)";
34
  $l_comment_on="(choose the authorized network protocols)";
-
 
35
  $l_comment_on="Except for the WEB (port 80), all protocols are blocked.<BR>Choose in the list below, the protocols you want authorize";
-
 
36
  $l_comment_off="(all the network protocols are allowed for authenticated users)";
-
 
37
  $l_protocols="Authorize protocols";
31
  $l_protocols="Authorize protocols";
38
  $l_error_open_file="Error opening the file";
32
  $l_error_open_file="Error opening the file";
39
  $l_port="Port number";
33
  $l_port="Port number";
40
  $l_proto="protocol name";
34
  $l_proto="protocol name";
41
  $l_enabled="Authorized";
35
  $l_enabled="Authorized";
42
  $l_add_to_list="Add to the list";
36
  $l_add_to_list="Add to the list";
43
  $l_save="Save changes";
37
  $l_save="Save changes";
44
}
38
}
45
/********************
39
/********************
46
*  TEST CONF FILES  *
40
*  TEST CONF FILES  *
47
*********************/
41
*********************/
48
define ("SERVICES_LIST", "/usr/local/etc/alcasar-services");
42
define ("SERVICES_LIST", "/usr/local/etc/alcasar-services");
49
define ("CONF_FILE", "/usr/local/etc/alcasar.conf");
43
define ("CONF_FILE", "/usr/local/etc/alcasar.conf");
50
$conf_files=array(SERVICES_LIST,CONF_FILE);
44
$conf_files=array(SERVICES_LIST,CONF_FILE);
51
foreach ($conf_files as $file){
45
foreach ($conf_files as $file){
52
if (!file_exists($file)){
46
if (!file_exists($file)){
53
	exit("Requested file ".$file." isn't present");}
47
	exit("Requested file ".$file." isn't present");}
54
if (!is_readable($file)){
48
if (!is_readable($file)){
55
	exit("Can't read the file ".$file);}
49
	exit("Can't read the file ".$file);}
56
}
50
}
57
/**********************************
51
/**********************************
58
*	Read ALCASAR CONF_FILE    *
52
*	Read ALCASAR CONF_FILE    *
59
***********************************/
53
***********************************/
60
$ouvre=fopen(CONF_FILE,"r");
54
$ouvre=fopen(CONF_FILE,"r");
61
if ($ouvre){
55
if ($ouvre){
62
	while (!feof ($ouvre))
56
	while (!feof ($ouvre))
63
	{
57
	{
64
		$tampon = fgets($ouvre, 4096);
58
		$tampon = fgets($ouvre, 4096);
65
		if (strpos($tampon,"=")!==false){
59
		if (strpos($tampon,"=")!==false){
66
			$tmp = explode("=",$tampon);
60
			$tmp = explode("=",$tampon);
67
			$conf[$tmp[0]] = $tmp[1];
61
			$conf[$tmp[0]] = $tmp[1];
68
		}
62
		}
69
	}
63
	}
70
	fclose($ouvre);
64
	fclose($ouvre);
71
}
65
}
72
 
66
 
73
if (isset($_POST['choix'])){$choix=$_POST['choix'];} else {$choix="";}
67
if (isset($_POST['choix'])){$choix=$_POST['choix'];} else {$choix="";}
74
switch ($choix)
68
switch ($choix)
75
{
69
{
76
case 'new_port' :
70
case 'new_port' :
77
	if ((trim($_POST['add_port']) != "80") and ($_POST['add_port'] != "") and ($_POST['add_proto'] != "") and (is_numeric($_POST['add_port'])))
71
	if ((trim($_POST['add_port']) != "80") and ($_POST['add_port'] != "") and ($_POST['add_proto'] != "") and (is_numeric($_POST['add_port'])))
78
		{
72
		{
79
		$_POST['add_proto'] = str_replace (CHR(32),"-",$_POST['add_proto']);
73
		$_POST['add_proto'] = str_replace (CHR(32),"-",$_POST['add_proto']);
80
		$tab=file(SERVICES_LIST);
74
		$tab=file(SERVICES_LIST);
81
		$insert = true;
75
		$insert = true;
82
		if ($tab) // file isn't empty
76
		if ($tab) // file isn't empty
83
			{
77
			{
84
			foreach ($tab as $line)  //test if port doesn't already exist
78
			foreach ($tab as $line)  //test if port doesn't already exist
85
				{
79
				{
86
				$proto_f=explode(" ", $line);
80
				$proto_f=explode(" ", $line);
87
				if (trim($_POST['add_port']) == trim($proto_f[1])) {$insert = false;}
81
				if (trim($_POST['add_port']) == trim($proto_f[1])) {$insert = false;}
88
				}
82
				}
89
			}
83
			}
90
		if ($insert == true) 
84
		if ($insert == true) 
91
			{
85
			{
92
			$line = "\n" . "#" . trim($_POST['add_proto']) . " " . trim($_POST['add_port']);
86
			$line = "\n" . "#" . trim($_POST['add_proto']) . " " . trim($_POST['add_port']);
93
			$pointeur=fopen(SERVICES_LIST,"a");
87
			$pointeur=fopen(SERVICES_LIST,"a");
94
			fwrite ($pointeur, $line);
88
			fwrite ($pointeur, $line);
95
			fclose ($pointeur);
89
			fclose ($pointeur);
96
			exec ("sudo /usr/local/bin/alcasar-file-clean.sh");
90
			exec ("sudo /usr/local/bin/alcasar-file-clean.sh");
97
			}
91
			}
98
		}
92
		}
99
	break;
93
	break;
100
case 'change_port' :
94
case 'change_port' :
101
	$tab=file(SERVICES_LIST);
95
	$tab=file(SERVICES_LIST);
102
	if ($tab)
96
	if ($tab)
103
		{
97
		{
104
// authorize/block protocols
98
// authorize/block protocols
105
		$pointeur=fopen(SERVICES_LIST,"w+");
99
		$pointeur=fopen(SERVICES_LIST,"w+");
106
		foreach ($tab as $ligne)
100
		foreach ($tab as $ligne)
107
			{
101
			{
108
			$proto_f=explode(" ", $ligne);
102
			$proto_f=explode(" ", $ligne);
109
			$name_svc1=trim($proto_f[0],"#");
103
			$name_svc1=trim($proto_f[0],"#");
110
			$actif = False; $remove_line = false;
104
			$actif = False; $remove_line = false;
111
			foreach ($_POST as $key => $value)
105
			foreach ($_POST as $key => $value)
112
				{
106
				{
113
				if (strstr($key,'del-'))
107
				if (strstr($key,'del-'))
114
					{
108
					{
115
					$name_svc2 = str_replace('del-','',$key);
109
					$name_svc2 = str_replace('del-','',$key);
116
					if ($name_svc1 == $name_svc2)
110
					if ($name_svc1 == $name_svc2)
117
				       		{
111
				       		{
118
						$remove_line = True;
112
						$remove_line = True;
119
						}
113
						}
120
					}
114
					}
121
				if (strstr($key,'chk-'))
115
				if (strstr($key,'chk-'))
122
					{
116
					{
123
					$name_svc2 = str_replace('chk-','',$key);
117
					$name_svc2 = str_replace('chk-','',$key);
124
					if ($name_svc1 == $name_svc2)
118
					if ($name_svc1 == $name_svc2)
125
				       		{
119
				       		{
126
						$actif = True;
120
						$actif = True;
127
						break;
121
						break;
128
						}
122
						}
129
					}
123
					}
130
				}
124
				}
131
			if (! $remove_line)
125
			if (! $remove_line)
132
				{
126
				{
133
				if (! $actif) {	$line="#$name_svc1 $proto_f[1]";}
127
				if (! $actif) {	$line="#$name_svc1 $proto_f[1]";}
134
				else { $line="$name_svc1 $proto_f[1]";}
128
				else { $line="$name_svc1 $proto_f[1]";}
135
				fwrite($pointeur,$line);
129
				fwrite($pointeur,$line);
136
				}
130
				}
137
			}
131
			}
138
		fclose($pointeur);
132
		fclose($pointeur);
139
		}
133
		}
140
	exec ("sudo /usr/local/bin/alcasar-iptables.sh -on");
134
	exec ("sudo /usr/local/bin/alcasar-iptables.sh -on");
141
	break;
135
	break;
142
	}
136
	}
143
?>
137
?>
144
<TABLE width="100%" border=0 cellspacing=0 cellpadding=0>
138
<TABLE width="100%" border=0 cellspacing=0 cellpadding=0>
145
<tr><th><?echo "$l_title_proto";?></th></tr>
139
<tr><th><?echo "$l_title_proto";?></th></tr>
146
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
140
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
147
</table>
141
</table>
148
<TABLE width="100%" border=1 cellspacing=0 cellpadding=0>
142
<TABLE width="100%" border=1 cellspacing=0 cellpadding=0>
-
 
143
<tr><td colspan="2" valign="middle" align="left">
-
 
144
<? echo "<CENTER>$l_comment</CENTER>";?>
149
<tr>
145
<tr><td valign="middle" align="center">
150
 
-
 
-
 
146
<form action='protocols_filter.php' method='POST'>
-
 
147
<table cellspacing=2 cellpadding=3 border=1>
151
<?
148
<?
-
 
149
echo "<tr><th>$l_port<th>$l_proto<th>$l_enabled<th>$l_remove</tr>";
-
 
150
// Read and compute the protocols list
-
 
151
$tab=file(SERVICES_LIST);
-
 
152
if ($tab) # the file isn't empty
152
 
153
	{
-
 
154
	foreach ($tab as $line)
-
 
155
		{
-
 
156
		if (trim($line) != '') # the line isn't empty
-
 
157
			{
-
 
158
			$proto=explode(" ", $line);
-
 
159
			$name_svc=trim($proto[0],"#");
-
 
160
			echo "<tr><td>$proto[1]<td>$name_svc";
153
echo "<td colspan=\"2\" valign=\"middle\" align=\"left\">";
161
			echo "<td><input type='checkbox' name='chk-$name_svc'";
154
echo "<CENTER><H3>$l_protocolsfilter_on</H3>$l_comment_on</CENTER>";
162
			// if the line is commented -> protocol is not allowed
-
 
163
			if (preg_match('/^#/',$line, $r)) {
-
 
164
				echo ">";}
-
 
165
			else {
-
 
166
				echo "checked>";}
-
 
167
			echo "<td>";
155
require ('protocols_filter2.php');
168
			if ($name_svc != "icmp") {
-
 
169
				echo "<input type='checkbox' name='del-$name_svc'>";}
-
 
170
			else {
-
 
171
				echo "&nbsp;";}		
-
 
172
			echo "</tr>";
-
 
173
			}
-
 
174
		}
156
 
175
	}
157
?>
176
?>
-
 
177
</table>
-
 
178
<input type='hidden' name='choix' value='change_port'>
-
 
179
<input type='submit' value='<?echo"$l_save";?>'>
-
 
180
</form></td><td valign='middle' align='center'>
-
 
181
<form action='protocols_filter.php' method='POST'>
-
 
182
<table cellspacing=2 cellpadding=3 border=1>
-
 
183
<tr><th><?echo"$l_port<th>$l_proto"?></tr>
-
 
184
<tr><td><input type='text' name='add_port' size='5'></td>
-
 
185
<td><input type='text' name='add_proto' size='10'></td>
-
 
186
<td><input type='hidden' name='choix' value='new_port'>
-
 
187
<input type='submit' value='<?echo"$l_add_to_list";?>'></td>
-
 
188
</tr></table>
-
 
189
</form>
-
 
190
</td></tr>
-
 
191
</TABLE>
-
 
192
</BODY>
-
 
193
</HTML>
158
 
194
 
159
 
195