Subversion Repositories ALCASAR

Rev

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'){
715 richard 16
  $l_error_open_file="Erreur d'ouverture du fichier";
504 richard 17
  $l_exception_IP = "Exception au filtrage";
18
  $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";
19
  $l_submit = "Enregistrer";
20
}
21
else {
715 richard 22
  $l_error_open_file="Error opening the file";
504 richard 23
  $l_exception_IP = "Network filtering exceptions";
24
  $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";
25
  $l_submit = "Submit";
26
}
715 richard 27
$conf_file="/usr/local/etc/alcasar.conf";
504 richard 28
if (isset($_POST['choix'])){ 
29
	switch ($_POST['choix'])
30
	{
31
	case 'IP_exceptions' :
773 richard 32
		// ISO encode + unix format 
504 richard 33
		$ip_list = str_replace("\r\n", "\n", utf8_decode($_POST['exception_list']));
34
		unset($_POST['exception_list']);
773 richard 35
		// write exception IP for Dansguardian (URL filter)
504 richard 36
		$fichier=fopen("/etc/dansguardian/lists/exceptioniplist", "w+");
773 richard 37
		if (strlen($ip_list) > 7) { fputs($fichier,$ip_list);} //only if not empty
504 richard 38
		fclose($fichier);
773 richard 39
		// write exception IP for DnsMasq (DNS blackholl)
504 richard 40
		$fichier=fopen("/usr/local/etc/alcasar-filter-exceptions", "w+");
773 richard 41
		if (strlen($ip_list) > 7) { fputs($fichier, $ip_list);} // only if not empty
504 richard 42
		fclose($fichier);
773 richard 43
		// test if Dansguardian filter is enabled
715 richard 44
		if (is_file ($conf_file))
504 richard 45
			{
715 richard 46
			$tab=file($conf_file);
47
			if ($tab)
504 richard 48
				{
715 richard 49
				foreach ($tab as $line)
504 richard 50
					{
715 richard 51
					$field=explode("=", $line);
52
					if ($field[0] == "DNS_FILTERING")	{$DNS_FILTERING=trim($field[1]);}
53
					if ($field[0] == "PROTOCOLS_FILTERING")	{$PROTOCOLS_FILTERING=trim($field[1]);}
504 richard 54
					}
55
				}
56
			}
715 richard 57
		else { echo "$l_error_open_file $conf_file";}
58
		if ($DNS_FILTERING == "on")
504 richard 59
			{
60
			exec ("sudo service dansguardian restart");
61
			}
715 richard 62
		if (($DNS_FILTERING == "on")||($PROTOCOLS_FILTERING == "on"))
63
			{
64
			exec ("sudo /usr/local/bin/alcasar-iptables.sh"); 
65
			}
504 richard 66
	break;
67
	}	
68
}
69
?>
70
<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
71
	<tr><th><?php echo $l_exception_IP ;?></th></tr>
72
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
73
</TABLE>
74
<TABLE width="100%" border=1 cellspacing=0 cellpadding=1>
75
<tr><td valign="middle" align="left">
76
<TABLE width=70% border=0>
77
<?php
78
echo "<form action='$_SERVER[PHP_SELF]' method='POST'>";
79
echo " $l_exception_txt";
80
echo "<BR><textarea name='exception_list' rows=5 cols=40>";
81
$filename="/usr/local/etc/alcasar-filter-exceptions";
82
if (file_exists($filename))
83
	{
84
	if (filesize($filename) != 0)
85
		{
86
		$pointeur=fopen($filename,"r");
87
		$tampon = fread($pointeur, filesize($filename));
88
		fclose($pointeur);
89
		echo $tampon;
90
		}
91
	}
92
	else
93
	{
94
	echo "erreur d'ouverture du fichier $filename";
95
	}
96
echo "</textarea><BR>";
97
?>
98
<input type='hidden' name='choix' value='IP_exceptions'>
99
<input type='submit' value='Enregistrer les modifications'></CENTER>
100
</FORM>
101
</td></tr>
102
</TABLE>
103
</BODY>
104
</HTML>