Subversion Repositories ALCASAR

Rev

Go to most recent revision | Details | Last modification | View Log

Rev Author Line No. Line
504 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>ALCASAR Filter Exceptions</TITLE>
6
<link rel="stylesheet" href="/css/style.css" type="text/css">
7
</HEAD>
8
<body>
9
<?
10
# Choice of language
11
$Language = 'en';
12
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
13
  $Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
14
  $Language = strtolower(substr(chop($Langue[0]),0,2)); }
15
if($Language == 'fr'){
16
  $l_exception_IP = "Exception au filtrage";
17
  $l_exception_txt="Entrez ici les adresses IP des stations du réseau de consultation ne subissant ni filtrage WEB ni filtrage réseau<BR>Entrez une adresse IP par ligne";
18
  $l_submit = "Enregistrer";
19
}
20
else {
21
  $l_exception_IP = "Network filtering exceptions";
22
  $l_exception_txt="Put here the stations IP address that won't be neither WEB filtered nor network filtered<BR>Put one IP per row";
23
  $l_submit = "Submit";
24
}
25
if (isset($_POST['choix'])){ 
26
	switch ($_POST['choix'])
27
	{
28
	case 'IP_exceptions' :
29
		// réencodage iso + format unix + rc fin de ligne (ouf...)
30
		$ip_list = str_replace("\r\n", "\n", utf8_decode($_POST['exception_list']));
31
		if (strlen($ip_list) != 0){
32
			if ($ip_list[strlen($ip_list)-1] != "\n") { $ip_list[strlen($ip_list)]="\n";} ;} ;
33
		unset($_POST['exception_list']);
34
		// écriture exception pour Dansguardian
35
		$fichier=fopen("/etc/dansguardian/lists/exceptioniplist", "w+");
36
		fputs($fichier,$ip_list);
37
		fclose($fichier);
38
		// écriture exception pour filtrage réseau et filtrage DNS
39
		$fichier=fopen("/usr/local/etc/alcasar-filter-exceptions", "w+");
40
		fputs($fichier, $ip_list);
41
		fclose($fichier);
42
		// test si le filtrage Dansguardian est activé
43
		$pointeur = fopen("/etc/dansguardian/dansguardian.conf", "r");
44
		$result = false;
45
		if ($pointeur)
46
			{
47
			while (!feof($pointeur))
48
				{
49
				$ligne = fgets($pointeur);
50
				if (preg_match("/^reportinglevel = 3/", $ligne, $r))
51
					{
52
					$result = true;
53
					break;
54
					}
55
				}
56
			}
57
		fclose($pointeur);
58
		if ($result)
59
			{
60
			exec ("sudo service dansguardian restart");
61
			}
62
		// test si filtrage réseau activé
63
		$pointeur = fopen("/usr/local/bin/alcasar-iptables.sh", "r");
64
		$result = False ;
65
		if ($pointeur)
66
			{
67
			while (!feof($pointeur))
68
				{
69
				$ligne = fgets($pointeur);
70
				if (preg_match('/^FILTERING="yes"/', $ligne, $r))
71
					{
72
					$result = True ;
73
					break;
74
					}
75
				}
76
			}
77
		fclose($pointeur);
78
		if ($result)
79
			{
80
			exec ("sudo /usr/local/bin/alcasar-iptables.sh");
81
			}
82
	break;
83
	}	
84
}
85
?>
86
<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
87
	<tr><th><?php echo $l_exception_IP ;?></th></tr>
88
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
89
</TABLE>
90
<TABLE width="100%" border=1 cellspacing=0 cellpadding=1>
91
<tr><td valign="middle" align="left">
92
<TABLE width=70% border=0>
93
<?php
94
echo "<form action='$_SERVER[PHP_SELF]' method='POST'>";
95
echo " $l_exception_txt";
96
echo "<BR><textarea name='exception_list' rows=5 cols=40>";
97
$filename="/usr/local/etc/alcasar-filter-exceptions";
98
if (file_exists($filename))
99
	{
100
	if (filesize($filename) != 0)
101
		{
102
		$pointeur=fopen($filename,"r");
103
		$tampon = fread($pointeur, filesize($filename));
104
		fclose($pointeur);
105
		echo $tampon;
106
		}
107
	}
108
	else
109
	{
110
	echo "erreur d'ouverture du fichier $filename";
111
	}
112
echo "</textarea><BR>";
113
?>
114
<input type='hidden' name='choix' value='IP_exceptions'>
115
<input type='submit' value='Enregistrer les modifications'></CENTER>
116
</FORM>
117
</td></tr>
118
</TABLE>
119
</BODY>
120
</HTML>