Subversion Repositories ALCASAR

Rev

Rev 1031 | Rev 1042 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log

Rev Author Line No. Line
318 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
<?
449 richard 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
}
318 richard 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'){
1041 richard 24
  $l_title1="Filtrage de noms de domaine et d'URL";
318 richard 25
  $l_dnsfilter_on="Le filtrage de noms de domaine et d'URL est actuellement activé";
26
  $l_dnsfilter_off="Le filtrage de noms de domaine et d'URL est actuellement désactivé";
27
  $l_switch_filtering_on="Activer le filtrage";
28
  $l_switch_filtering_off="Désactiver le filtrage";
1041 richard 29
  $l_bl="Liste noire";
30
  $l_wl="Liste blanche";
31
  $l_list_version="Version de la liste : ";
32
  $l_bl_categories="Sélectionnez les catégories à filtrer";
33
  $l_wl_categories="Sélectionnez les catégories à autoriser";
878 richard 34
  $l_download_bl="Télécharger la dernière version";
35
  $l_fingerprint="L'empreinte numérique du fichier téléchargé est : ";
36
  $l_fingerprint2="Vérifiez-là en suivant ce lien (ligne 'blacklists.tar.gz') : ";
885 richard 37
  $l_activate_bl="Activer la nouvelle version";
38
  $l_reject_bl="Rejeter";
878 richard 39
  $l_warning="Temps estimé : une minute.";
40
  $l_specific_filtering="Filtrage special";
318 richard 41
  $l_forbidden_dns="Noms de domaine filtrés";
441 franck 42
  $l_forbidden_dns_explain="Entrez un nom de domaine par ligne (exemple : .domaine.org)";
1041 richard 43
  $l_allowed_dns="Noms de domaine autorisés";
441 franck 44
  $l_one_dns="Entrez un nom de domaine par ligne (exemple : .domaine.org)";
878 richard 45
  $l_maj_rehabilitated="Noms de domaine ou URLs réhabilités";
318 richard 46
  $l_rehabilitated_dns="Noms de domaine réhabilités";
878 richard 47
  $l_rehabilitated_dns_explain="Entrez ici des noms de domaine bloqués par la liste noire <BR> que vous souhaitez réhabiliter.";
48
  $l_add_to_bl="Noms de domaine ou URLs ajoutés à la liste noire";
1041 richard 49
  $l_add_to_wl="Noms de domaine ou URLs ajoutés à la liste blanche";
318 richard 50
  $l_forbidden_url="URL filtrés";
688 richard 51
  $l_forbidden_url_explain="Entrez une URL par ligne (exemple : www.domaine.org/perso/index.htm)";
1041 richard 52
  $l_allowed_url="URL authorisés";
318 richard 53
  $l_rehabilitated_url="URL réhabilités";
878 richard 54
  $l_rehabilitated_url_explain="Entrez ici des URL bloquées par la liste noire <BR> que vous souhaitez réhabiliter.";
688 richard 55
  $l_one_url="Entrez une URL par ligne (exemple : www.domaine.org/perso/index.htm)";
318 richard 56
  $l_record="Enregistrer les modifications";
601 franck 57
  $l_wait="Une fois validées, 30 secondes sont nécessaires pour traiter vos modifications";
934 franck 58
  $l_ip_filtering="Filtrer les URLs contenant une adresse IP au lieu d'un nom de domaine (ex: http://25.56.58.59/index.htm)";
59
  $l_safe_searching="Activer le contrôle scolaire/parental des moteurs de recherche : google, yahoo, bing, metacrawler et Youtube.";
885 richard 60
  $l_safe_youtube="Pour Youtube, entrez votre identifiant ici : "; 
61
  $l_youtube_id="(<a href='http://www.youtube.com/education_signup' target='cat_help' onclick=window.open('http://www.youtube.com/education_signup','cat_help','width=800,height=600,toolbar=no,scrollbars=yes,resizable=yes') title='Youtube for school'>lien pour créer un identifiant Youtube (Id)</a>)";
318 richard 62
}
63
else {
1041 richard 64
  $l_title1="Domain names and URL filtering";
318 richard 65
  $l_dnsfilter_on="Actually, the Domain name and URL filter is on";
66
  $l_dnsfilter_off="Actually, the Domain name and URL filter is off";
67
  $l_switch_filtering_on="Switch the Filter on";
68
  $l_switch_filtering_off="Switch the Filter off";
1041 richard 69
  $l_bl="BlackList";
70
  $l_wl="WhiteList";
71
  $l_list_version="List version : ";
72
  $l_bl_categories="Select the categories to filter";
73
  $l_wl_categories="Select the categories to allow";
878 richard 74
  $l_download_bl="Download the last version";
75
  $l_fingerprint="The digital fingerprint of the downloaded blacklist is : ";
76
  $l_fingerprint2="Verify it with this link (line 'blacklists.tar.gz') : ";
885 richard 77
  $l_activate_bl="Activate the new version";
78
  $l_reject_bl="Reject";
878 richard 79
  $l_warning="Estimated time : one minute.";
80
  $l_specific_filtering="Specific filtering";
318 richard 81
  $l_forbidden_dns="Filtered domain names";
441 franck 82
  $l_forbidden_dns_explain="Enter one domain name per row (exemple : .domain.org)";
1041 richard 83
  $l_allowed_dns="Allowed domain names";
441 franck 84
  $l_one_dns="Enter one domain name per row (example : .domain.org)";
878 richard 85
  $l_maj_rehabilitated="Domain names or URLs rehabilitated";
318 richard 86
  $l_rehabilitated_dns="Rehabilitated domain names";
878 richard 87
  $l_rehabilitated_dns_explain="Enter here domain names that are blocked by the blacklist <BR> and you want to rehabilitate.";
88
  $l_add_to_bl="Domain names or URLs to add to blacklist";
1041 richard 89
  $l_add_to_wl="Domain names or URLs to add to whitelist";
318 richard 90
  $l_forbidden_url="Filtered URL";
441 franck 91
  $l_forbidden_url_explain="Enter one URL per row (example : www.domaine.org/perso/index.htm)";
1041 richard 92
  $l_allowed_url="Allowed URL";
318 richard 93
  $l_rehabilitated_url="Rehabilitated URL";
878 richard 94
  $l_rehabilitated_url_explain="Enter here URL that are blocked by the blacklist <BR> and you want to rehabilitate.";
441 franck 95
  $l_one_url="Enter one URL per row (example : www.domaine.org/perso/index.htm)";
318 richard 96
  $l_record="Save changes";
470 richard 97
  $l_wait="Once validated, 30 seconds is necessary to compute your modifications";
878 richard 98
  $l_ip_filtering="Filtering URLs that contain an IP address instead of a domain name (ie: http://25.56.58.59/index.htm)";
885 richard 99
  $l_safe_searching="Enabling school/parental control for the search engines google, yahoo, bing, metacrawler and Youtube."; 
100
  $l_safe_youtube="For Youtube, enter your ID here : "; 
101
  $l_youtube_id="(<a href='http://www.youtube.com/education_signup' target='cat_help' onclick=window.open('http://www.youtube.com/education_signup','cat_help','width=800,height=600,toolbar=no,scrollbars=yes,resizable=yes') title='Youtube for school'>link to create a Youtube Id</a>)";
318 richard 102
}
1041 richard 103
$dir_etc="/usr/local/etc/";
104
$dir_dg="/etc/dansguardian/lists/";
105
$bl_categories=$dir_etc."alcasar-bl-categories";
106
$bl_categories_enabled=$dir_etc."alcasar-bl-categories-enabled";
107
$wl_categories=$dir_etc."alcasar-wl-categories";
108
$wl_categories_enabled=$dir_etc."alcasar-wl-categories-enabled";
109
$conf_file=$dir_etc."alcasar.conf";
110
$dir_blacklist=$dir_dg."blacklist/";
111
$urlregex_file=$dir_dg."urlregexplist";
112
$bannedsite_file=$dir_dg."bannedsitelist";
885 richard 113
$dir_tmp="/tmp/blacklists";
114
# default values
115
if (is_file ($conf_file))
116
	{
117
	$tab=file($conf_file);
118
	if ($tab)
119
		{
120
		foreach ($tab as $line)
121
			{
122
			$field=explode("=", $line);
123
			if ($field[0] == "DNS_FILTERING")	{$DNS_FILTERING=trim($field[1]);}
124
			if ($field[0] == "YOUTUBE_ID")		{$YOUTUBE_ID=trim($field[1]);}
125
			}
126
		}
127
	}
128
else { echo "$l_error_open_file $conf_file";}
318 richard 129
if (isset($_POST['choix'])){ $choix=$_POST['choix']; } else { $choix=""; }
130
switch ($choix)
131
{
132
case 'BL_On' :
389 franck 133
	exec ("sudo /usr/local/sbin/alcasar-bl.sh --on");
1031 richard 134
	$DNS_FILTERING="on";
318 richard 135
	break;
136
case 'BL_Off' :
389 franck 137
	exec ("sudo /usr/local/sbin/alcasar-bl.sh --off");
1031 richard 138
	$DNS_FILTERING="off";
318 richard 139
	break;
1041 richard 140
case 'Download_list' :
389 franck 141
	exec ("sudo /usr/local/sbin/alcasar-bl.sh --download");
878 richard 142
	break;
1041 richard 143
case 'Active_list' :
878 richard 144
	exec ("sudo /usr/local/sbin/alcasar-bl.sh --adapt");
389 franck 145
	exec ("sudo /usr/local/sbin/alcasar-bl.sh --reload");
318 richard 146
	break;
1041 richard 147
case 'Reject_list' :
885 richard 148
	unlink ("$dir_tmp/blacklists.tar.gz"); unlink ("$dir_tmp/md5sum");
149
	break;
1041 richard 150
case 'MAJ_cat_bl' :
318 richard 151
	$tab=file($bl_categories_enabled);	
152
	if ($tab)
153
		{
154
		$pointeur=fopen($bl_categories_enabled, "w+");
155
		foreach ($_POST as $key => $value)
156
			{
157
			if (strstr($key,'chk-'))
158
				{	
159
				$line=str_replace('chk-','',$key)."\n";
160
				fwrite($pointeur,$line);
161
				}
162
			}
163
		fclose($pointeur);
164
		}
165
	else {echo "$l_error_open_file $bl_categories_enabled";}
1041 richard 166
	$fichier=fopen($dir_dg."blacklists/ossi/domains","w+");
449 richard 167
	fputs($fichier, form_filter($_POST['OSSI_bl_domains']));
318 richard 168
	fclose($fichier);
169
	unset($_POST['OSSI_bl_domains']);
1041 richard 170
	$fichier=fopen($dir_dg."exceptionsitelist","w+");
171
	fputs($fichier, form_filter($_POST['BL_rehabilited_domains']));
318 richard 172
	fclose($fichier);
1041 richard 173
	unset($_POST['BL_rehabilited_domains']);
174
	$fichier=fopen($dir_dg."blacklists/ossi/urls","w+");
449 richard 175
	fputs($fichier, form_filter($_POST['OSSI_bl_urls']));
318 richard 176
	fclose($fichier);
177
	unset($_POST['OSSI_bl_urls']);
1041 richard 178
	$fichier=fopen($dir_dg."exceptionurllist","w+");
179
	fputs($fichier, form_filter($_POST['BL_rehabilited_urls']));
180
	fclose($fichier);
181
	unset($_POST['BL_rehabilited_urls']);
182
	exec ("sudo /usr/local/sbin/alcasar-bl.sh --reload");
183
	break;
184
case 'MAJ_cat_wl' :
185
	$tab=file($wl_categories_enabled);	
186
	if ($tab)
187
		{
188
		$pointeur=fopen($wl_categories_enabled, "w+");
189
		foreach ($_POST as $key => $value)
190
			{
191
			if (strstr($key,'chk-'))
192
				{	
193
				$line=str_replace('chk-','',$key)."\n";
194
				fwrite($pointeur,$line);
195
				}
196
			}
197
		fclose($pointeur);
198
		}
199
	else {echo "$l_error_open_file $wl_categories_enabled";}
200
	$fichier=fopen($dir_dg."blacklists/ossi/domains_wl","w+");
201
	fputs($fichier, form_filter($_POST['OSSI_wl_domains']));
202
	fclose($fichier);
203
	unset($_POST['OSSI_wl_domains']);
204
	$fichier=fopen($dir_dg."blacklists/ossi/urls_wl","w+");
449 richard 205
	fputs($fichier, form_filter($_POST['OSSI_wl_urls']));
318 richard 206
	fclose($fichier);
207
	unset($_POST['OSSI_wl_urls']);
208
	break;
878 richard 209
case 'Specific_filtering' :
882 richard 210
	$pureip="-pureip_off"; $safesearch="-safesearch_off"; ;
211
	foreach ($_POST as $key => $value)
212
	{
213
		if (strstr($key,'chk-ip')) $pureip="-pureip_on";
214
		if (strstr($key,'chk-safesearch')) $safesearch="-safesearch_on";
215
	}
885 richard 216
	if ($_POST['Youtube_ID'] == '') { $New_ID="ABCD1234567890abcdef";} // default ID (no action) 
217
	else {$New_ID=$_POST['Youtube_ID'];}
218
	file_put_contents($conf_file, str_replace("YOUTUBE_ID=$YOUTUBE_ID", "YOUTUBE_ID=$New_ID", file_get_contents($conf_file)));
219
	$YOUTUBE_ID=$New_ID;
220
	exec ("sudo /usr/local/sbin/alcasar-url_filter.sh $safesearch $pureip");
221
       	break;
318 richard 222
}
223
?>
224
<TABLE width="100%" border=0 cellspacing=0 cellpadding=0>
225
<tr><th><?php echo "$l_title1"; ?></th></tr>
226
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width=1 height=2></td></tr>
227
</TABLE>
228
<TABLE width="100%" border=1 cellspacing=0 cellpadding=0>
229
	<tr><td valign="middle" align="left">
230
<?php
612 richard 231
if ($DNS_FILTERING == "on")
318 richard 232
	{
233
	echo "<CENTER><H3>$l_dnsfilter_on</H3></CENTER>";
234
 	echo "<FORM action='$_SERVER[PHP_SELF]' method=POST>";
235
	echo "<input type=hidden name='choix' value=\"BL_Off\">";
236
	echo "<input type=submit value=\"$l_switch_filtering_off\">";
237
}
238
else
239
	{
240
	echo "<CENTER><H3>$l_dnsfilter_off</H3></CENTER>";
241
 	echo "<FORM action='$_SERVER[PHP_SELF]' method=POST>";
242
	echo "<input type=hidden name='choix' value=\"BL_On\">";
243
	echo "<input type=submit value=\"$l_switch_filtering_on\">";
244
	}
245
echo "</FORM>";
246
echo "</td></tr>";
247
echo "</TABLE>";
1015 richard 248
if ($DNS_FILTERING == "on") require ('bl_filter2.php');
318 richard 249
?>
250
</BODY>
251
</HTML>