Subversion Repositories ALCASAR

Rev

Details | Last modification | View Log

Rev Author Line No. Line
1015 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 DNS filtering</TITLE>
6
<link rel="stylesheet" href="/css/style.css" type="text/css">
7
</HEAD>
8
<body>
9
<?
10
function form_filter ($form_content)
11
{
12
// réencodage iso + format unix + rc fin de ligne (ouf...)
13
	$list = str_replace("\r\n", "\n", utf8_decode($form_content));
14
	if (strlen($list) != 0){
15
		if ($list[strlen($list)-1] != "\n") { $list[strlen($list)]="\n";} ;} ;
16
	return $list;
17
}
18
# Choice of language
19
$Language = 'en';
20
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
21
  $Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
22
  $Language = strtolower(substr(chop($Langue[0]),0,2)); }
23
if($Language == 'fr'){
24
  $l_error_open_file="Erreur d'ouverture du fichier";
25
  $l_main_wl="Liste blanche";
26
  $l_bl_version="Version actuelle :";
27
  $l_wl_categories="Choix des catégories à autoriser";
28
  $l_forbidden_dns="Noms de domaine filtrés";
29
  $l_forbidden_dns_explain="Entrez un nom de domaine par ligne (exemple : .domaine.org)";
30
  $l_one_dns="Entrez un nom de domaine par ligne (exemple : .domaine.org)";
31
  $l_add_to_bl="Noms de domaine ou URLs ajoutés à la liste noire";
32
  $l_forbidden_url="URL filtrés";
33
  $l_forbidden_url_explain="Entrez une URL par ligne (exemple : www.domaine.org/perso/index.htm)";
34
  $l_record="Enregistrer les modifications";
35
  $l_wait="Une fois validées, 30 secondes sont nécessaires pour traiter vos modifications";
36
}
37
else {
38
  $l_error_open_file="Error opening the file";
39
  $l_main_wl="Whitelist";
40
  $l_bl_version="Current version : ";
41
  $l_wl_categories="Choice of authorized categories";
42
  $l_forbidden_dns="Filtered domain names";
43
  $l_forbidden_dns_explain="Enter one domain name per row (exemple : .domain.org)";
44
  $l_one_dns="Enter one domain name per row (example : .domain.org)";
45
  $l_add_to_bl="Domain names or URLs to add to blacklist";
46
  $l_forbidden_url="Filtered URL";
47
  $l_forbidden_url_explain="Enter one URL per row (example : www.domaine.org/perso/index.htm)";
48
  $l_record="Save changes";
49
  $l_wait="Once validated, 30 seconds is necessary to compute your modifications";
50
}
51
$wl_categories="/usr/local/etc/alcasar-wl-categories";
52
$wl_categories_enabled="/usr/local/etc/alcasar-wl-categories-enabled";
53
$dir_blacklist="/etc/dansguardian/lists/blacklist/";
54
$conf_file="/usr/local/etc/alcasar.conf";
55
$urlregex_file="/etc/dansguardian/lists/urlregexplist";
56
$bannedsite_file="/etc/dansguardian/lists/bannedsitelist";
57
$dir_tmp="/tmp/blacklists";
58
# default values
59
if (is_file ($conf_file))
60
	{
61
	$tab=file($conf_file);
62
	if ($tab)
63
		{
64
		foreach ($tab as $line)
65
			{
66
			$field=explode("=", $line);
67
			if ($field[0] == "DNS_FILTERING")	{$DNS_FILTERING=trim($field[1]);}
68
			}
69
		}
70
	}
71
else { echo "$l_error_open_file $conf_file";}
72
if (isset($_POST['choix'])){ $choix=$_POST['choix']; } else { $choix=""; }
73
switch ($choix)
74
{
75
case 'MAJ_cat' :
76
	$tab=file($wl_categories_enabled);	
77
	if ($tab)
78
		{
79
		$pointeur=fopen($wl_categories_enabled, "w+");
80
		foreach ($_POST as $key => $value)
81
			{
82
			if (strstr($key,'chk-'))
83
				{	
84
				$line=str_replace('chk-','',$key)."\n";
85
				fwrite($pointeur,$line);
86
				}
87
			}
88
		fclose($pointeur);
89
		}
90
	else {echo "$l_error_open_file $wl_categories_enabled";}
91
	$fichier=fopen("/etc/dansguardian/lists/blacklists/ossi/domains","w+");
92
	fputs($fichier, form_filter($_POST['OSSI_bl_domains']));
93
	fclose($fichier);
94
	unset($_POST['OSSI_bl_domains']);
95
	$fichier=fopen("/etc/dansguardian/lists/exceptionsitelist","w+");
96
	fputs($fichier, form_filter($_POST['OSSI_wl_domains']));
97
	fclose($fichier);
98
	unset($_POST['OSSI_wl_domains']);
99
	$fichier=fopen("/etc/dansguardian/lists/blacklists/ossi/urls","w+");
100
	fputs($fichier, form_filter($_POST['OSSI_bl_urls']));
101
	fclose($fichier);
102
	unset($_POST['OSSI_bl_urls']);
103
	$fichier=fopen("/etc/dansguardian/lists/exceptionurllist","w+");
104
	fputs($fichier, form_filter($_POST['OSSI_wl_urls']));
105
	fclose($fichier);
106
	unset($_POST['OSSI_wl_urls']);
107
	exec ("sudo /usr/local/sbin/alcasar-bl.sh --reload");
108
	break;
109
}
110
 
111
function echo_file ($filename)
112
	{
113
	if (file_exists($filename))
114
		{
115
		if (filesize($filename) != 0)
116
			{
117
			$pointeur=fopen($filename,"r");
118
			$tampon = fread($pointeur, filesize($filename));
119
			fclose($pointeur);
120
			echo $tampon;
121
			}
122
		}
123
	else
124
		{
125
		echo "$l_error_openfile $filename";
126
		}
127
	}
128
?>
129
<table width="100%" border="0" cellspacing="0" cellpadding="0">
130
	<tr><th><?php echo $l_main_wl; ?></th></tr>
131
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
132
</table>
133
<TABLE width="100%" border=1 cellspacing=0 cellpadding=1>
134
<tr><td valign="middle" align="left" colspan=10>
135
<FORM action='dns_filter.php' method=POST>
136
<input type='hidden' name='choix' value='MAJ_cat'>
137
<?php
138
echo "<center>$l_wl_categories</center></td></tr>";
139
//on lit et on interprete le fichier de catégories
140
$cols=1; 
141
if (file_exists($wl_categories))
142
	{
143
	$pointeur=fopen($wl_categories,"r");
144
	while (!feof ($pointeur))
145
		{
146
		$ligne=fgets($pointeur, 4096);
147
		if ($ligne)
148
			{
149
			if ($cols == 1) { echo "<tr>";}
150
			$categorie=trim(basename($ligne));
151
			echo "<td><a href='bl_categories_help.php?cat=$categorie' target='cat_help' onclick=window.open('bl_categories_help.php','cat_help','width=600,height=150,toolbar=no,scrollbars=no,resizable=yes') title='categories help page'>$categorie</a><br>";
152
			echo "<input type='checkbox' name='chk-$categorie'";
153
			// si la ligne est commentée -> categorie non selectionnée
154
			if (preg_match('/^#/',$ligne, $r)) { echo ">";}
155
			else { echo "checked>"; }
156
			echo "</td>";
157
			$cols++;
158
			if ($cols > 10) {
159
				echo "</tr>";
160
				$cols=1; }
161
			}
162
		}
163
	fclose($pointeur);
164
	}
165
else	{
166
	echo "$l_error_open_file $wl_categories";
167
	}
168
echo "<tr><td valign='middle' align='left' colspan=10>";
169
echo "<center><b>$l_add_to_bl</b></center></td></tr>";
170
echo "<tr><td colspan=5 align=center>";
171
echo "<H3>$l_forbidden_dns</H3>$l_forbidden_dns_explain<BR>";
172
echo "<textarea name='OSSI_bl_domains' rows=5 cols=40>";
173
echo_file ("/etc/dansguardian/lists/blacklists/ossi/domains");
174
echo "</textarea></td>";
175
echo "<td colspan=5 align=center>";
176
echo "<H3>$l_forbidden_url</H3>$l_forbidden_url_explain<BR>";
177
echo "<textarea name='OSSI_bl_urls' rows=5 cols=40>";
178
echo_file ("/etc/dansguardian/lists/blacklists/ossi/urls");
179
echo "</textarea></td></tr><tr><td colspan=10>";
180
echo "<input type='submit' value='$l_record'>";
181
echo "</form> ($l_wait)";
182
?>
183
</td></tr>
184
</TABLE>
185
</BODY>
186
</HTML>