Subversion Repositories ALCASAR

Rev

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

Rev 40 Rev 152
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="(choisissez les protocoles que vous voulez autoriser)";
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 autoriser";
24
  $l_comment_off="(les usagers authentifiés peuvent exploiter tous les protocoles réseau)";
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_port="Protocole / port";
27
  $l_proto="Protocole";
28
  $l_enabled="Autorisé";
28
  $l_enabled="Autorisé";
-
 
29
  $l_delete="Supprimer de la liste";
-
 
30
  $l_add_to_list="Ajouter &agrave; la liste";
29
  $l_save_modif="Enregistrer les modifications";
31
  $l_save_modif="Enregistrer les modifications";
30
}
32
}
31
else {
33
else {
32
  $l_title = "Network Filter";
34
  $l_title = "Network Filter";
33
  $l_netfilter_on="Actually, the network filter is enable";
35
  $l_netfilter_on="Actually, the network filter is enable";
34
  $l_netfilter_off="Actually, the network filter is disable";
36
  $l_netfilter_off="Actually, the network filter is disable";
35
  $l_switch_on="Switch the Network Filter on";
37
  $l_switch_on="Switch the Network Filter on";
36
  $l_switch_off="Switch the Network Filter off";
38
  $l_switch_off="Switch the Network Filter off";
37
  $l_comment_on="(choose the authorized network protocols)";
39
  $l_comment_on="(choose the authorized network protocols)";
38
  $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)";
39
  $l_protocols="Authorize protocols";
41
  $l_protocols="Authorize protocols";
40
  $l_error_open_file="Error opening the file";
42
  $l_error_open_file="Error opening the file";
41
  $l_proto_port="Protocol / port";
43
  $l_proto="Protocol";
42
  $l_enabled="Enable";
44
  $l_enabled="Enable";
-
 
45
  $l_delete="Delete from list";
-
 
46
  $l_add_to_list="Add to the list";
43
  $l_save_modif="Save modifications";
47
  $l_save_modif="Save modifications";
44
}
48
}
45
echo "
49
echo "
46
<tr><th>$l_title</th></tr>
50
<tr><th>$l_title</th></tr>
47
<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>
48
</TABLE>";
52
</TABLE>";
49
if (isset($_POST['choix'])){$choix=$_POST['choix'];} else {$choix="";}
53
if (isset($_POST['choix'])){$choix=$_POST['choix'];} else {$choix="";}
50
switch ($choix)
54
switch ($choix)
51
{
55
{
52
case 'NF_On' :
56
case 'NF_On' :
53
	exec ("sudo /usr/local/sbin/alcasar-nf.sh -on");
57
	exec ("sudo /usr/local/sbin/alcasar-nf.sh -on");
54
break;
58
break;
55
case 'NF_Off' :
59
case 'NF_Off' :
56
	exec ("sudo /usr/local/sbin/alcasar-nf.sh -off");
60
	exec ("sudo /usr/local/sbin/alcasar-nf.sh -off");
57
break;
61
break;
-
 
62
case 'new_proto' :
-
 
63
	if ((trim($_POST['add_port']) != "80") and ($_POST['add_port'] != "") and ($_POST['add_proto'] != "") and (is_numeric($_POST['add_port'])))
-
 
64
		{
-
 
65
		$tab=file($services_list);
-
 
66
		if ($tab)
-
 
67
			{
-
 
68
			$pointeur=fopen($services_list,"r");
-
 
69
			//on teste si le port n'est pas déjà présent
-
 
70
			$insert = true;
-
 
71
			foreach ($tab as $ligne)
-
 
72
				{
-
 
73
				$proto_f=explode(" ", $ligne);
-
 
74
				if (trim($_POST['add_port']) == trim($proto_f[1])) {$insert = false;}
-
 
75
				}
-
 
76
			fclose($pointeur);
-
 
77
			if ($insert == true) 
-
 
78
				{
-
 
79
				$line = "#" . trim($_POST['add_proto']) . " " . trim($_POST['add_port']);
-
 
80
				$pointeur=fopen($services_list,"a");
-
 
81
				fwrite ($pointeur, $line);
-
 
82
				fclose ($pointeur);
-
 
83
				exec ("sudo /usr/local/sbin/alcasar-nf.sh -on");
-
 
84
				}
-
 
85
			}
-
 
86
		else {echo "$l_error_open_file $services_list";}
-
 
87
		}
-
 
88
break;
58
case 'change' :
89
case 'change' :
59
	$tab=file($services_list);
90
	$tab=file($services_list);
60
	if ($tab)
91
	if ($tab)
61
		{
92
		{
62
//on active|désactive les protocoles
93
//on active|désactive les protocoles
63
		$pointeur=fopen($services_list,"w+");
94
		$pointeur=fopen($services_list,"w+");
64
		foreach ($tab as $ligne)
95
		foreach ($tab as $ligne)
65
			{
96
			{
66
			$proto_f=explode(" ", $ligne);
97
			$proto_f=explode(" ", $ligne);
67
			$name_svc1=trim($proto_f[0],"#");
98
			$name_svc1=trim($proto_f[0],"#");
68
			$actif = False;
99
			$actif = False; $remove_line = false;
69
			foreach ($_POST as $key => $value)
100
			foreach ($_POST as $key => $value)
70
				{
101
				{
-
 
102
				if (strstr($key,'del-'))
-
 
103
					{
-
 
104
					$name_svc2 = str_replace('del-','',$key);
-
 
105
					if ($name_svc1 == $name_svc2)
-
 
106
				       		{
-
 
107
						$remove_line = True;
-
 
108
						break;
-
 
109
						}
-
 
110
					}
71
				if (strstr($key,'chk-'))
111
				if (strstr($key,'chk-'))
72
					{
112
					{
73
					$name_svc2 = str_replace('chk-','',$key);
113
					$name_svc2 = str_replace('chk-','',$key);
74
					if ($name_svc1 == $name_svc2)
114
					if ($name_svc1 == $name_svc2)
75
				       		{
115
				       		{
76
						$actif = True;
116
						$actif = True;
77
						break;
117
						break;
78
						}
118
						}
79
					}
119
					}
80
				}
120
				}
81
			if (! $actif)
121
			if (! $remove_line)
82
				{
122
				{
-
 
123
				if (! $actif) {	$line="#$name_svc1 $proto_f[1]";}
83
				$line="#$name_svc1 $proto_f[1]";
124
				else { $line="$name_svc1 $proto_f[1]";}
-
 
125
				fwrite($pointeur,$line);
84
				}
126
				}
85
			else { $line="$name_svc1 $proto_f[1]";}
-
 
86
			fputs($pointeur,$line);
-
 
87
			}
127
			}
88
		fclose($pointeur);
128
		fclose($pointeur);
89
		}
129
		}
90
	else {echo "$l_error_open_file $services_list";}
130
	else {echo "$l_error_open_file $services_list";}
91
	exec ("sudo /usr/local/sbin/alcasar-nf.sh -on");
131
	exec ("sudo /usr/local/sbin/alcasar-nf.sh -on");
92
break;
132
break;
93
	}
133
	}
94
echo "<TABLE width=\"100%\" border=1 cellspacing=0 cellpadding=1>";
134
echo "<TABLE width=\"100%\" border=1 cellspacing=0 cellpadding=1>";
95
echo "<tr><td valign=\"middle\" align=\"left\">";
135
echo "<tr><td valign=\"middle\" align=\"left\">";
96
$pointeur = fopen("/usr/local/bin/alcasar-iptables.sh", "r");
136
$pointeur = fopen("/usr/local/bin/alcasar-iptables.sh", "r");
97
$result = False ;
137
$result = False ;
98
if ($pointeur)
138
if ($pointeur)
99
	{
139
	{
100
  	while (!feof($pointeur))
140
  	while (!feof($pointeur))
101
		{
141
		{
102
    		$ligne = fgets($pointeur);
142
    		$ligne = fgets($pointeur);
103
    		if (preg_match('/^FILTERING="yes"/', $ligne, $r))
143
    		if (preg_match('/^FILTERING="yes"/', $ligne, $r))
104
			{
144
			{
105
			$result = True ;
145
			$result = True ;
106
			break;
146
			break;
107
			}
147
			}
108
    		}
148
    		}
109
  	}
149
  	}
110
fclose($pointeur);
150
fclose($pointeur);
111
if ($result)
151
if ($result)
112
	{
152
	{
113
	echo "<CENTER><H3>$l_netfilter_on</H3>$l_comment_on</CENTER>";
153
	echo "<CENTER><H3>$l_netfilter_on</H3>$l_comment_on</CENTER>";
114
	echo "<FORM action='$_SERVER[PHP_SELF]' method=POST>";
154
	echo "<FORM action='$_SERVER[PHP_SELF]' method=POST>";
115
	echo "<input type=hidden name='choix' value=\"NF_Off\">";
155
	echo "<input type=hidden name='choix' value=\"NF_Off\">";
116
	echo "<input type=submit value=\"$l_switch_off\">";
156
	echo "<input type=submit value=\"$l_switch_off\">";
117
	}
157
	}
118
else
158
else
119
	{
159
	{
120
	echo "<CENTER><H3>$l_netfilter_off</H3>$l_comment_off</CENTER>";
160
	echo "<CENTER><H3>$l_netfilter_off</H3>$l_comment_off</CENTER>";
121
 	echo "<FORM action='$_SERVER[PHP_SELF]' method=POST>";
161
 	echo "<FORM action='$_SERVER[PHP_SELF]' method=POST>";
122
	echo "<input type=hidden name='choix' value=\"NF_On\">";
162
	echo "<input type=hidden name='choix' value=\"NF_On\">";
123
	echo "<input type=submit value=\"$l_switch_on\">";
163
	echo "<input type=submit value=\"$l_switch_on\">";
124
	}
164
	}
125
echo "</FORM>";
165
echo "</FORM>";
126
echo "</td></tr>";
166
echo "</td></tr>";
127
echo "</TABLE>";
167
echo "</TABLE>";
128
if ($result) require ('net_filter2.php');
168
if ($result) require ('net_filter2.php');
129
?>
169
?>
130
</BODY>
170
</BODY>
131
</HTML>
171
</HTML>
132
 
172