Subversion Repositories ALCASAR

Rev

Rev 28 | Go to most recent revision | Details | Compare with Previous | 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>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 pas de filtrage<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 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' :
30 richard 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 ($ip_list[strlen($ip_list)-1] != "\n") { $ip_list[strlen($ip_list)]="\n";} ;
28 richard 32
		unset($_POST['exception_list']);
33
		$pointeur = fopen("/etc/dansguardian/dansguardian.conf", "r");
34
		$result = false;
35
		if ($pointeur)
36
			{
37
			while (!feof($pointeur))
38
				{
39
				$ligne = fgets($pointeur);
40
				if (preg_match("/^reportinglevel = 3/", $ligne, $r))
41
					{
42
					$result = true;
43
					break;
44
					}
45
				}
46
			}
47
		fclose($pointeur);
48
		if ($result)
49
			{
50
			$fichier=fopen("/etc/dansguardian/lists/exceptioniplist", "w+");
51
			fputs($fichier,$ip_list);
52
			fclose($fichier);
53
			exec ("sudo /usr/local/sbin/alcasar-bl.sh -reload");
54
			}
55
		$pointeur = fopen("/usr/local/bin/alcasar-iptables.sh", "r");
56
		$result = False ;
57
		if ($pointeur)
58
			{
59
			while (!feof($pointeur))
60
				{
61
				$ligne = fgets($pointeur);
62
				if (preg_match('/^FILTERING="yes"/', $ligne, $r))
63
					{
64
					$result = True ;
65
					break;
66
					}
67
				}
68
			}
69
		fclose($pointeur);
70
		if ($result)
71
			{
72
			$fichier=fopen("/usr/local/etc/alcasar-filter-exceptions", "w+");
73
			fputs($fichier, $ip_list);
74
			fclose($fichier);
75
			exec ("sudo /usr/local/sbin/alcasar-nf.sh -on");
76
			}
77
	break;
78
	}	
79
}
80
?>
81
<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
82
	<tr><th><?php echo $l_exception_IP ;?></th></tr>
83
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
84
</TABLE>
85
<TABLE width="100%" border=1 cellspacing=0 cellpadding=1>
86
<tr><td valign="middle" align="left">
87
<TABLE width=70% border=0>
88
<?php
89
echo "<form action='$_SERVER[PHP_SELF]' method='POST'>";
90
echo " $l_exception_txt";
91
echo "<BR><textarea name='exception_list' rows=5 cols=40>";
92
$filename="/usr/local/etc/alcasar-filter-exceptions";
93
if (file_exists($filename))
94
	{
95
	if (filesize($filename) != 0)
96
		{
97
		$pointeur=fopen($filename,"r");
98
		$tampon = fread($pointeur, filesize($filename));
99
		fclose($pointeur);
100
		echo $tampon;
101
		}
102
	}
103
	else
104
	{
105
	echo "erreur d'ouverture du fichier $filename";
106
	}
107
echo "</textarea><BR>";
108
?>
109
<input type='hidden' name='choix' value='IP_exceptions'>
110
<input type='submit' value='Enregistrer les modifications'></CENTER>
111
</FORM>
112
</td></tr>
113
</TABLE>
114
</BODY>
115
</HTML>