Subversion Repositories ALCASAR

Rev

Details | Last modification | View Log

Rev Author Line No. Line
28 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
$services_list="/usr/local/etc/alcasar-services";
12
# Choice of language
13
$Language = 'en';
14
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
15
  $Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
16
  $Language = strtolower(substr(chop($Langue[0]),0,2)); }
17
if($Language == 'fr'){
18
  $l_title = "Filtrage réseau";
19
  $l_netfilter_on="Le filtrage réseau est actuellement activé";
20
  $l_netfilter_off="Le filtrage réseau est actuellement désactivé";
21
  $l_switch_on="Activer le filtrage r&eacute;seau";
22
  $l_switch_off="Désactiver le filtrage réseau";
23
  $l_comment_on="(choisissez les protocoles que vous voulez autoriser)";
24
  $l_comment_off="(les usagers authentifiés peuvent exploiter tous les protocoles réseau)";
25
  $l_protocols="Protocoles autorisés";
26
  $l_error_open_file="Erreur d'ouverture du fichier";
27
  $l_proto_port="Protocole / port";
28
  $l_enabled="Autorisé";
29
  $l_save_modif="Enregistrer les modifications";
30
}
31
else {
32
  $l_title = "Network Filter";
33
  $l_netfilter_on="Actually, the network filter is enable";
34
  $l_netfilter_off="Actually, the network filter is disable";
35
  $l_switch_on="Switch the Network Filter on";
36
  $l_switch_off="Switch the Network Filter off";
37
  $l_comment_on="(choose the authorized network protocols)";
38
  $l_comment_off="(all the network protocols are allowed for authenticated users)";
39
  $l_protocols="Authorize protocols";
40
  $l_error_open_file="Error opening the file";
41
  $l_proto_port="Protocol / port";
42
  $l_enabled="Enable";
43
  $l_save_modif="Save modifications";
44
}
45
echo "
46
<tr><th>$l_title</th></tr>
47
<tr bgcolor=\"#FFCC66\"><td><img src=\"/images/pix.gif\" width=1 height=2></td></tr>
48
</TABLE>";
49
if (isset($_POST['choix'])){$choix=$_POST['choix'];} else {$choix="";}
50
switch ($choix)
51
{
52
case 'NF_On' :
53
	exec ("sudo /usr/local/sbin/alcasar-nf.sh -on");
54
break;
55
case 'NF_Off' :
56
	exec ("sudo /usr/local/sbin/alcasar-nf.sh -off");
57
break;
58
case 'change' :
59
	$tab=file($services_list);
60
	if ($tab)
61
		{
62
//on active|désactive les protocoles
63
		$pointeur=fopen($services_list,"w+");
64
		foreach ($tab as $ligne)
65
			{
66
			$proto_f=explode(" ", $ligne);
67
			$name_svc1=trim($proto_f[0],"#");
68
			$actif = False;
69
			foreach ($_POST as $key => $value)
70
				{
71
				if (strstr($key,'chk-'))
72
					{
73
					$name_svc2 = str_replace('chk-','',$key);
74
					if ($name_svc1 == $name_svc2)
75
				       		{
76
						$actif = True;
77
						break;
78
						}
79
					}
80
				}
81
			if (! $actif)
82
				{
83
				$line="#$name_svc1 $proto_f[1]";
84
				}
85
			else { $line="$name_svc1 $proto_f[1]";}
86
			fputs($pointeur,$line);
87
			}
88
		fclose($pointeur);
89
		}
90
	else {echo "$l_error_open_file $services_list";}
91
	exec ("sudo /usr/local/sbin/alcasar-nf.sh -on");
92
break;
93
	}
94
echo "<TABLE width=\"100%\" border=1 cellspacing=0 cellpadding=1>";
95
echo "<tr><td valign=\"middle\" align=\"left\">";
96
$pointeur = fopen("/usr/local/bin/alcasar-iptables.sh", "r");
97
$result = False ;
98
if ($pointeur)
99
	{
100
  	while (!feof($pointeur))
101
		{
102
    		$ligne = fgets($pointeur);
103
    		if (preg_match('/^FILTERING="yes"/', $ligne, $r))
104
			{
105
			$result = True ;
106
			break;
107
			}
108
    		}
109
  	}
110
fclose($pointeur);
111
if ($result)
112
	{
113
	echo "<CENTER><H3>$l_netfilter_on</H3>$l_comment_on</CENTER>";
114
	echo "<FORM action='$_SERVER[PHP_SELF]' method=POST>";
115
	echo "<input type=hidden name='choix' value=\"NF_Off\">";
116
	echo "<input type=submit value=\"$l_switch_off\">";
117
	}
118
else
119
	{
120
	echo "<CENTER><H3>$l_netfilter_off</H3>$l_comment_off</CENTER>";
121
 	echo "<FORM action='$_SERVER[PHP_SELF]' method=POST>";
122
	echo "<input type=hidden name='choix' value=\"NF_On\">";
123
	echo "<input type=submit value=\"$l_switch_on\">";
124
	}
125
echo "</FORM>";
126
echo "</td></tr>";
127
echo "</TABLE>";
128
if ($result) require ('net_filter2.php');
129
?>
130
</BODY>
131
</HTML>