Subversion Repositories ALCASAR

Rev

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

Rev 1827 Rev 2006
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_remove="Retirer de la liste";
17
  $l_remove="Retirer de la liste";
18
  $l_title_proto = "Filtrage de protocoles r&eacute;seau";
18
  $l_title_proto = "Filtrage de protocoles r&eacute;seau";
19
  $l_protocolsfilter_on="Le filtrage de protocoles r&eacute;seau est actuellement activ&eacute;";
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.";
20
  $l_protocolsfilter_off="Le filtrage de protocoles réseau est actuellement désactiv&eacute";
-
 
21
  $l_switch_on="Activer le filtrage";
-
 
22
  $l_switch_off="D&eacute;sactiver le filtrage";
-
 
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";
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";
24
  $l_comment_off="(tous les protocoles réseau sont autoris&eacute;s)";
21
  $l_comment_off="(tous les protocoles réseau sont autoris&eacute;s)";
25
  $l_protocols="Protocoles autoris&eacute;s";
22
  $l_protocols="Protocoles autoris&eacute;s";
26
  $l_error_open_file="Erreur d'ouverture du fichier";
23
  $l_error_open_file="Erreur d'ouverture du fichier";
27
  $l_port="Numéro de port";
24
  $l_port="Numéro de port";
28
  $l_proto="Nom du protocole";
25
  $l_proto="Nom du protocole";
29
  $l_enabled="Autoris&eacute;";
26
  $l_enabled="Autoris&eacute;";
30
  $l_add_to_list="Ajouter &agrave; la liste";
27
  $l_add_to_list="Ajouter &agrave; la liste";
31
  $l_save="Enregistrer les modifications";
28
  $l_save="Enregistrer les modifications";
32
}
29
}
33
else {
30
else {
34
  $l_remove="Remove from list";
31
  $l_remove="Remove from list";
35
  $l_title_proto = "Network protocols filter";
32
  $l_title_proto = "Network protocols filter";
36
  $l_protocolsfilter_on="Actually, the network protocols filter is enable";
-
 
37
  $l_protocolsfilter_off="Actually, the network protocols filter is disable";
33
  $l_protocolsfilter="You can change your \"custom\" protocol filtering here. You can set it to a user from ACC (create user / edit user)";
38
  $l_switch_on="Switch the Filter on";
-
 
39
  $l_switch_off="Switch the Filter off";
-
 
40
  $l_comment_on="(choose the authorized network protocols)";
34
  $l_comment_on="(choose the authorized network protocols)";
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";
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";
42
  $l_comment_off="(all the network protocols are allowed for authenticated users)";
36
  $l_comment_off="(all the network protocols are allowed for authenticated users)";
43
  $l_protocols="Authorize protocols";
37
  $l_protocols="Authorize protocols";
44
  $l_error_open_file="Error opening the file";
38
  $l_error_open_file="Error opening the file";
45
  $l_port="Port number";
39
  $l_port="Port number";
46
  $l_proto="protocol name";
40
  $l_proto="protocol name";
47
  $l_enabled="Authorized";
41
  $l_enabled="Authorized";
48
  $l_add_to_list="Add to the list";
42
  $l_add_to_list="Add to the list";
49
  $l_save="Save changes";
43
  $l_save="Save changes";
50
}
44
}
51
/********************
45
/********************
52
*  TEST CONF FILES  *
46
*  TEST CONF FILES  *
53
*********************/
47
*********************/
54
define ("SERVICES_LIST", "/usr/local/etc/alcasar-services");
48
define ("SERVICES_LIST", "/usr/local/etc/alcasar-services");
55
define ("CONF_FILE", "/usr/local/etc/alcasar.conf");
49
define ("CONF_FILE", "/usr/local/etc/alcasar.conf");
56
$conf_files=array(SERVICES_LIST,CONF_FILE);
50
$conf_files=array(SERVICES_LIST,CONF_FILE);
57
foreach ($conf_files as $file){
51
foreach ($conf_files as $file){
58
if (!file_exists($file)){
52
if (!file_exists($file)){
59
	exit("Requested file ".$file." isn't present");}
53
	exit("Requested file ".$file." isn't present");}
60
if (!is_readable($file)){
54
if (!is_readable($file)){
61
	exit("Can't read the file ".$file);}
55
	exit("Can't read the file ".$file);}
62
}
56
}
63
/**********************************
57
/**********************************
64
*	Read ALCASAR CONF_FILE    *
58
*	Read ALCASAR CONF_FILE    *
65
***********************************/
59
***********************************/
66
$ouvre=fopen(CONF_FILE,"r");
60
$ouvre=fopen(CONF_FILE,"r");
67
if ($ouvre){
61
if ($ouvre){
68
	while (!feof ($ouvre))
62
	while (!feof ($ouvre))
69
	{
63
	{
70
		$tampon = fgets($ouvre, 4096);
64
		$tampon = fgets($ouvre, 4096);
71
		if (strpos($tampon,"=")!==false){
65
		if (strpos($tampon,"=")!==false){
72
			$tmp = explode("=",$tampon);
66
			$tmp = explode("=",$tampon);
73
			$conf[$tmp[0]] = $tmp[1];
67
			$conf[$tmp[0]] = $tmp[1];
74
		}
68
		}
75
	}
69
	}
76
	fclose($ouvre);
70
	fclose($ouvre);
77
}
71
}
78
 
72
 
79
if (isset($_POST['choix'])){$choix=$_POST['choix'];} else {$choix="";}
73
if (isset($_POST['choix'])){$choix=$_POST['choix'];} else {$choix="";}
80
switch ($choix)
74
switch ($choix)
81
{
75
{
82
case 'NF_On' :
-
 
83
	exec ("sudo /usr/local/bin/alcasar-nf.sh -on");
-
 
84
	break;
-
 
85
case 'NF_Off' :
-
 
86
	exec ("sudo /usr/local/bin/alcasar-nf.sh -off");
-
 
87
	break;
-
 
88
case 'new_port' :
76
case 'new_port' :
89
	if ((trim($_POST['add_port']) != "80") and ($_POST['add_port'] != "") and ($_POST['add_proto'] != "") and (is_numeric($_POST['add_port'])))
77
	if ((trim($_POST['add_port']) != "80") and ($_POST['add_port'] != "") and ($_POST['add_proto'] != "") and (is_numeric($_POST['add_port'])))
90
		{
78
		{
91
		$_POST['add_proto'] = str_replace (CHR(32),"-",$_POST['add_proto']);
79
		$_POST['add_proto'] = str_replace (CHR(32),"-",$_POST['add_proto']);
92
		$tab=file(SERVICES_LIST);
80
		$tab=file(SERVICES_LIST);
93
		$insert = true;
81
		$insert = true;
94
		if ($tab) // file isn't empty
82
		if ($tab) // file isn't empty
95
			{
83
			{
96
			foreach ($tab as $line)  //test if port doesn't already exist
84
			foreach ($tab as $line)  //test if port doesn't already exist
97
				{
85
				{
98
				$proto_f=explode(" ", $line);
86
				$proto_f=explode(" ", $line);
99
				if (trim($_POST['add_port']) == trim($proto_f[1])) {$insert = false;}
87
				if (trim($_POST['add_port']) == trim($proto_f[1])) {$insert = false;}
100
				}
88
				}
101
			}
89
			}
102
		if ($insert == true) 
90
		if ($insert == true) 
103
			{
91
			{
104
			$line = "\n" . "#" . trim($_POST['add_proto']) . " " . trim($_POST['add_port']);
92
			$line = "\n" . "#" . trim($_POST['add_proto']) . " " . trim($_POST['add_port']);
105
			$pointeur=fopen(SERVICES_LIST,"a");
93
			$pointeur=fopen(SERVICES_LIST,"a");
106
			fwrite ($pointeur, $line);
94
			fwrite ($pointeur, $line);
107
			fclose ($pointeur);
95
			fclose ($pointeur);
108
			exec ("sudo /usr/local/bin/alcasar-file-clean.sh");
96
			exec ("sudo /usr/local/bin/alcasar-file-clean.sh");
109
			}
97
			}
110
		}
98
		}
111
	break;
99
	break;
112
case 'change_port' :
100
case 'change_port' :
113
	$tab=file(SERVICES_LIST);
101
	$tab=file(SERVICES_LIST);
114
	if ($tab)
102
	if ($tab)
115
		{
103
		{
116
// authorize/block protocols
104
// authorize/block protocols
117
		$pointeur=fopen(SERVICES_LIST,"w+");
105
		$pointeur=fopen(SERVICES_LIST,"w+");
118
		foreach ($tab as $ligne)
106
		foreach ($tab as $ligne)
119
			{
107
			{
120
			$proto_f=explode(" ", $ligne);
108
			$proto_f=explode(" ", $ligne);
121
			$name_svc1=trim($proto_f[0],"#");
109
			$name_svc1=trim($proto_f[0],"#");
122
			$actif = False; $remove_line = false;
110
			$actif = False; $remove_line = false;
123
			foreach ($_POST as $key => $value)
111
			foreach ($_POST as $key => $value)
124
				{
112
				{
125
				if (strstr($key,'del-'))
113
				if (strstr($key,'del-'))
126
					{
114
					{
127
					$name_svc2 = str_replace('del-','',$key);
115
					$name_svc2 = str_replace('del-','',$key);
128
					if ($name_svc1 == $name_svc2)
116
					if ($name_svc1 == $name_svc2)
129
				       		{
117
				       		{
130
						$remove_line = True;
118
						$remove_line = True;
131
						}
119
						}
132
					}
120
					}
133
				if (strstr($key,'chk-'))
121
				if (strstr($key,'chk-'))
134
					{
122
					{
135
					$name_svc2 = str_replace('chk-','',$key);
123
					$name_svc2 = str_replace('chk-','',$key);
136
					if ($name_svc1 == $name_svc2)
124
					if ($name_svc1 == $name_svc2)
137
				       		{
125
				       		{
138
						$actif = True;
126
						$actif = True;
139
						break;
127
						break;
140
						}
128
						}
141
					}
129
					}
142
				}
130
				}
143
			if (! $remove_line)
131
			if (! $remove_line)
144
				{
132
				{
145
				if (! $actif) {	$line="#$name_svc1 $proto_f[1]";}
133
				if (! $actif) {	$line="#$name_svc1 $proto_f[1]";}
146
				else { $line="$name_svc1 $proto_f[1]";}
134
				else { $line="$name_svc1 $proto_f[1]";}
147
				fwrite($pointeur,$line);
135
				fwrite($pointeur,$line);
148
				}
136
				}
149
			}
137
			}
150
		fclose($pointeur);
138
		fclose($pointeur);
151
		}
139
		}
152
	exec ("sudo /usr/local/bin/alcasar-iptables.sh -on");
140
	exec ("sudo /usr/local/bin/alcasar-iptables.sh -on");
153
	break;
141
	break;
154
	}
142
	}
155
# default values
-
 
156
if (is_file (CONF_FILE))
-
 
157
	{
-
 
158
	$tab=file(CONF_FILE);
-
 
159
	if ($tab)
-
 
160
		{
-
 
161
		foreach ($tab as $line)
-
 
162
			{
-
 
163
			$field=explode("=", $line);
-
 
164
			if ($field[0] == "PROTOCOLS_FILTERING")	{$PROTOCOLS_FILTERING=trim($field[1]);}
-
 
165
			}
-
 
166
		}
-
 
167
	}
-
 
168
?>
143
?>
169
<TABLE width="100%" border=0 cellspacing=0 cellpadding=0>
144
<TABLE width="100%" border=0 cellspacing=0 cellpadding=0>
170
<tr><th><?echo "$l_title_proto";?></th></tr>
145
<tr><th><?echo "$l_title_proto";?></th></tr>
171
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
146
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
172
</table>
147
</table>
173
<TABLE width="100%" border=1 cellspacing=0 cellpadding=0>
148
<TABLE width="100%" border=1 cellspacing=0 cellpadding=0>
174
<tr>
149
<tr>
-
 
150
 
175
<?
151
<?
176
if ($PROTOCOLS_FILTERING == "on")
-
 
177
	{
152
 
178
	echo "<td colspan=\"2\" valign=\"middle\" align=\"left\">";
153
echo "<td colspan=\"2\" valign=\"middle\" align=\"left\">";
179
	echo "<CENTER><H3>$l_protocolsfilter_on</H3>$l_comment_on</CENTER>";
154
echo "<CENTER><H3>$l_protocolsfilter_on</H3>$l_comment_on</CENTER>";
180
	echo "<FORM action='$_SERVER[PHP_SELF]' method=POST>";
-
 
181
	echo "<input type=hidden name='choix' value=\"NF_Off\">";
-
 
182
	echo "<input type=submit value=\"$l_switch_off\">";
-
 
183
	echo "</FORM></td></tr>";
-
 
184
	require ('protocols_filter2.php');
155
require ('protocols_filter2.php');
185
	}
-
 
186
else
-
 
187
	{
-
 
188
	echo "<td valign=\"middle\" align=\"left\">";
-
 
189
	echo "<CENTER><H3>$l_protocolsfilter_off</H3>$l_comment_off</CENTER>";
-
 
190
 	echo "<FORM action='$_SERVER[PHP_SELF]' method=POST>";
-
 
191
	echo "<input type=hidden name='choix' value=\"NF_On\">";
-
 
192
	echo "<input type=submit value=\"$l_switch_on\">";
-
 
193
	echo "</FORM></td></tr>";
-
 
194
	echo "</table></body></html>";
-
 
195
	}
156
 
196
?>
157
?>
-
 
158
 
197
 
159