Subversion Repositories ALCASAR

Rev

Rev 1843 | Rev 1854 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 1843 Rev 1852
Line 65... Line 65...
65
#maximum length for top-level DNS
65
#maximum length for top-level DNS
66
function max_tld()
66
function max_tld()
67
{
67
{
68
	$url_tld = "http://data.iana.org/TLD/tlds-alpha-by-domain.txt";
68
	$url_tld = "http://data.iana.org/TLD/tlds-alpha-by-domain.txt";
69
	$result_tld = file_get_contents($url_tld,false);
69
	$result_tld = file_get_contents($url_tld,false);
70
	$max_tld = 18; 																											#valeur de base si le site ne répond plus
70
	$max_tld = 18; 							#valeur de base si le site ne répond plus
71
	if($result_tld !== FALSE){
71
	if($result_tld !== FALSE){
72
		foreach(explode("\n", $result_tld) as $line)
72
		foreach(explode("\n", $result_tld) as $line)
73
		{
73
		{
74
			if((strpos($line,'-') === false) and (strpos($line,'#') === false))
74
			if((strpos($line,'-') === false) and (strpos($line,'#') === false))
75
			{
75
			{
Line 88... Line 88...
88
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
88
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
89
  $Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
89
  $Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
90
  $Language = strtolower(substr(chop($Langue[0]),0,2)); }
90
  $Language = strtolower(substr(chop($Langue[0]),0,2)); }
91
if($Language == 'fr'){
91
if($Language == 'fr'){
92
  $l_bl="Liste noire générale";
92
  $l_bl="Liste noire générale";
-
 
93
  $l_load="Chargement...";
93
  $l_list_version="Version de la liste : ";
94
  $l_list_version="Version de la liste : ";
94
  $l_bl_categories="Sélectionnez les catégories à filtrer";
95
  $l_bl_categories="Sélectionnez les catégories à filtrer";
95
  $l_download_bl="Télécharger la dernière version";
96
  $l_download_bl="Télécharger la dernière version";
96
  $l_fingerprint="L'empreinte numérique du fichier téléchargé est : ";
97
  $l_fingerprint="L'empreinte numérique du fichier téléchargé est : ";
97
  $l_fingerprint2="Vérifiez-là en suivant ce lien (ligne 'blacklists.tar.gz') : ";
98
  $l_fingerprint2="Vérifiez-là en suivant ce lien (ligne 'blacklists.tar.gz') : ";
Line 111... Line 112...
111
  $l_rehabilitated_ip_explain="Entrez ici des IP bloquées par la liste noire <BR> que vous souhaitez réhabiliter.";
112
  $l_rehabilitated_ip_explain="Entrez ici des IP bloquées par la liste noire <BR> que vous souhaitez réhabiliter.";
112
  $l_one_ip="Entrez une IP par ligne (exemple : 123.123.123.123)";
113
  $l_one_ip="Entrez une IP par ligne (exemple : 123.123.123.123)";
113
  $l_record="Enregistrer les modifications";
114
  $l_record="Enregistrer les modifications";
114
  $l_wait="Une fois validées, 10 secondes sont nécessaires pour traiter vos modifications";
115
  $l_wait="Une fois validées, 10 secondes sont nécessaires pour traiter vos modifications";
115
  $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)";
116
  $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)";
116
  $l_safe_searching="Activer le contrôle scolaire/parental des moteurs de recherche : google, yahoo, bing, metacrawler et Youtube.";
117
  $l_safe_searching="Activer le contrôle scolaire/parental des moteurs de recherche google.";
117
  $l_safe_youtube="Pour Youtube, suivez les étapes ici : "; 
118
  $l_safe_youtube="Pour un Youtube restreint, suivez les étapes ici : "; 
118
  $l_youtube_id="(<a href='https://support.google.com/youtube/answer/174084?hl=fr' 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>)";
119
  $l_youtube_id="(<a href='https://support.google.com/youtube/answer/174084?hl=fr' target='cat_help' onclick=window.open('https://support.google.com/youtube/answer/174084?hl=fr','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>)";
119
  $l_error_open_file="Erreur d'ouverture du fichier";
120
  $l_error_open_file="Erreur d'ouverture du fichier";
120
  $l_additional_file_title="Fichiers de 'listes noires' additionnels";
121
  $l_additional_file_title="Fichiers de 'listes noires' additionnels";
121
  $l_file_list="Liste des fichiers";
122
  $l_file_list="Liste des fichiers";
122
  $l_add_file="Ajouter un fichier";
123
  $l_add_file="Ajouter un fichier";
123
  $l_add_file_explain="Chaque ligne du fichier doit être une adresse IP ou un nom de domaine"; 
124
  $l_add_file_explain="Chaque ligne du fichier doit être une adresse IP ou un nom de domaine"; 
Line 132... Line 133...
132
  $l_nbUrl="Url :";
133
  $l_nbUrl="Url :";
133
  $l_nbIp="Ip :";
134
  $l_nbIp="Ip :";
134
}
135
}
135
else {
136
else {
136
  $l_bl="BlackList";
137
  $l_bl="BlackList";
-
 
138
  $l_load="Loading...";
137
  $l_list_version="List version : ";
139
  $l_list_version="List version : ";
138
  $l_bl_categories="Select the categories to filter";
140
  $l_bl_categories="Select the categories to filter";
139
  $l_download_bl="Download the last version";
141
  $l_download_bl="Download the last version";
140
  $l_fingerprint="The digital fingerprint of the downloaded blacklist is : ";
142
  $l_fingerprint="The digital fingerprint of the downloaded blacklist is : ";
141
  $l_fingerprint2="Verify it with this link (line 'blacklists.tar.gz') : ";
143
  $l_fingerprint2="Verify it with this link (line 'blacklists.tar.gz') : ";
Line 157... Line 159...
157
  $l_one_ip="Enter one IP per row (example : 123.123.123.123)";
159
  $l_one_ip="Enter one IP per row (example : 123.123.123.123)";
158
  $l_record="Save changes";
160
  $l_record="Save changes";
159
  $l_wait="Once validated, 10 seconds are necessary to compute your modifications";
161
  $l_wait="Once validated, 10 seconds are necessary to compute your modifications";
160
  $l_ip_filtering="Filtering URLs that contain an IP address instead of a domain name (ie: http://25.56.58.59/index.htm)";
162
  $l_ip_filtering="Filtering URLs that contain an IP address instead of a domain name (ie: http://25.56.58.59/index.htm)";
161
  $l_safe_searching="Enabling school/parental control for the search engines google, yahoo, bing, metacrawler and Youtube."; 
163
  $l_safe_searching="Enabling school/parental control for the search engines google, yahoo, bing, metacrawler and Youtube."; 
162
  $l_safe_youtube="For Youtube, follow these steps : "; 
164
  $l_safe_youtube="For safe Youtube, follow these steps : "; 
163
  $l_youtube_id="(<a href='https://support.google.com/youtube/answer/174084?hl=en' 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>)";
165
  $l_youtube_id="(<a href='https://support.google.com/youtube/answer/174084?hl=en' target='cat_help' onclick=window.open('https://support.google.com/youtube/answer/174084?hl=en','cat_help','width=800,height=600,toolbar=no,scrollbars=yes,resizable=yes') title='Youtube for school'>link to create a Youtube Id</a>)";
164
  $l_error_open_file="Error opening file";
166
  $l_error_open_file="Error opening file";
165
  $l_additional_file_title="Additional blacklist files";
167
  $l_additional_file_title="Additional blacklist files";
166
  $l_file_list="Files list";
168
  $l_file_list="Files list";
167
  $l_add_file="Add a file";
169
  $l_add_file="Add a file";
168
  $l_add_file_explain="Each line of the file must be an IP address or a domain name"; 
170
  $l_add_file_explain="Each line of the file must be an IP address or a domain name"; 
Line 196... Line 198...
196
	if ($tab)
198
	if ($tab)
197
		{
199
		{
198
		foreach ($tab as $line)
200
		foreach ($tab as $line)
199
			{
201
			{
200
			$field=explode("=", $line);
202
			$field=explode("=", $line);
201
			if ($field[0] == "YOUTUBE_ID")
-
 
202
				{
-
 
203
				$YOUTUBE_ID=trim($field[1]);
-
 
204
				}
-
 
205
			if ($field[0] == "PRIVATE_IP")
203
			if ($field[0] == "PRIVATE_IP")
206
				{
204
				{
207
				$PRIVATE_IP_MASK=trim($field[1]);
205
				$PRIVATE_IP_MASK=trim($field[1]);
208
				$tmp = explode("/",$PRIVATE_IP_MASK);
206
				$tmp = explode("/",$PRIVATE_IP_MASK);
209
				$PRIVATE_IP=$tmp[0];
207
				$PRIVATE_IP=$tmp[0];
Line 285... Line 283...
285
	{	
283
	{	
286
		# On l'upload
284
		# On l'upload
287
		if(move_uploaded_file($_FILES['fichier_ip']['tmp_name'], $upload_dir_ip.$nom))
285
		if(move_uploaded_file($_FILES['fichier_ip']['tmp_name'], $upload_dir_ip.$nom))
288
		{
286
		{
289
			# On extrait uniquement les ip du fichier
287
			# On extrait uniquement les ip du fichier
290
			exec("grep -Eo '([0-9]{1,3}\.){3}[0-9]{1,3}' $upload_dir_ip$nom > $upload_dir_ip\ossi-ip");
288
			exec("grep -Eo '([0-9]{1,3}\.){3}[0-9]{1,3}' $upload_dir_ip$nom > $upload_dir_ip\ossi_ip");
291
 
289
 
292
			# Suppression des doublons
290
			# Suppression des doublons
293
			exec("sort -u $upload_dir_ip\ossi-ip > $upload_dir_ip\ossi-$nom && rm -f $upload_dir_ip\ossi-ip");
291
			exec("sort -u $upload_dir_ip\ossi_ip > $upload_dir_ip\ossi-$nom && rm -f $upload_dir_ip\ossi_ip");
294
 
292
 
295
			# On adapte le fichier à la sauvegarde du set
293
			# On adapte le fichier à la sauvegarde du set
296
			exec("sed -i \"s/^/add blacklist_ip_blocked /g\" $upload_dir_ip\ossi-$nom"); 
294
			exec("sed -i \"s/^/add blacklist_ip_blocked /g\" $upload_dir_ip\ossi-$nom"); 
297
			
295
			
298
 
296
 
299
			# On extrait uniquement les noms de domaine
297
			# On extrait uniquement les noms de domaine
300
			# max_tld() retourne le nombre max de charactere pour un top-level dns
298
			# max_tld() retourne le nombre max de charactere pour un top-level dns
301
			exec("grep -Eo '([a-zA-Z0-9_-]+\.){1,2}[a-zA-Z]{2,".max_tld()."}' $upload_dir_ip$nom > $upload_dir_domain_names\ossi-domain_names");
299
			exec("grep -Eo '([a-zA-Z0-9_-]+\.){1,2}[a-zA-Z]{2,".max_tld()."}' $upload_dir_ip$nom > $upload_dir_domain_names\ossi_domain_names");
302
 
300
 
303
			# Suppression des doublons
301
			# Suppression des doublons
304
			exec("sort -u $upload_dir_domain_names\ossi-domain_names > $upload_dir_domain_names\ossi-$nom && rm -f $upload_dir_domain_names\ossi-domain_names");
302
			exec("sort -u $upload_dir_domain_names\ossi_domain_names > $upload_dir_domain_names\ossi-$nom && rm -f $upload_dir_domain_names\ossi_domain_names");
305
 
303
 
306
			# On adapte le fichier pour Dnsmasq
304
			# On adapte le fichier pour Dnsmasq
307
			exec("sed -i \"s/^/address=\//g\" $upload_dir_domain_names\ossi-$nom");
305
			exec("sed -i \"s/^/address=\//g\" $upload_dir_domain_names\ossi-$nom");
308
			exec("sed -i \"s/$/\/$PRIVATE_IP/g\" $upload_dir_domain_names\ossi-$nom");
306
			exec("sed -i \"s/$/\/$PRIVATE_IP/g\" $upload_dir_domain_names\ossi-$nom");
309
 
307
 
Line 313... Line 311...
313
		else
311
		else
314
		{
312
		{
315
			echo $l_error_upload;
313
			echo $l_error_upload;
316
		}
314
		}
317
		exec ("sudo /usr/local/bin/alcasar-bl.sh --reload");
315
		exec ("sudo /usr/local/bin/alcasar-bl.sh --reload");
-
 
316
		exec ("sudo /usr/local/bin/alcasar-iptables.sh ");
318
	}
317
	}
319
	break;
318
	break;
320
}
319
}
321
?>
320
?>
322
<table width="100%" border="0" cellspacing="0" cellpadding="0">
321
<table width="100%" border="0" cellspacing="0" cellpadding="0">
Line 332... Line 331...
332
if ((file_exists("$dir_tmp/blacklists.tar.gz")) && (file_exists("$dir_tmp/md5sum")))
331
if ((file_exists("$dir_tmp/blacklists.tar.gz")) && (file_exists("$dir_tmp/md5sum")))
333
	{
332
	{
334
	echo "$l_fingerprint"; echo_file ("$dir_tmp/md5sum");
333
	echo "$l_fingerprint"; echo_file ("$dir_tmp/md5sum");
335
	echo "<br>$l_fingerprint2<a href='http://dsi.ut-capitole.fr/blacklists/download/MD5SUM.LST' target='cat_help' onclick=window.open('http://dsi.ut-capitole.fr/blacklists/download/MD5SUM.LST','cat_help','width=600,height=150,toolbar=no,scrollbars=yes,resizable=yes') title='verify fingerprint'>dsi.ut-capitole.fr/blacklists/download/MD5SUM.LST</a><br>";
334
	echo "<br>$l_fingerprint2<a href='http://dsi.ut-capitole.fr/blacklists/download/MD5SUM.LST' target='cat_help' onclick=window.open('http://dsi.ut-capitole.fr/blacklists/download/MD5SUM.LST','cat_help','width=600,height=150,toolbar=no,scrollbars=yes,resizable=yes') title='verify fingerprint'>dsi.ut-capitole.fr/blacklists/download/MD5SUM.LST</a><br>";
336
	echo "<input type='hidden' name='choix' value='Active_list'>";
335
	echo "<input type='hidden' name='choix' value='Active_list'>";
337
	echo "<input type='submit' value='$l_activate_bl'> ($l_warning)</FORM>";
336
	echo "<input type='submit' onClick=\"this.disabled=true; this.value='$l_load';\" value='$l_activate_bl'> ($l_warning)</FORM>";
338
	echo "<FORM action='bl_filter.php' method=POST>";
337
	echo "<FORM action='bl_filter.php' method=POST>";
339
	echo "<input type='hidden' name='choix' value='Reject_list'>";
338
	echo "<input type='hidden' name='choix' value='Reject_list'>";
340
	echo "<input type='submit' value='$l_reject_bl'></form>";
339
	echo "<input type='submit' onClick=\"this.disabled=true; this.value='$l_load';\" value='$l_reject_bl'></form>";
341
	}
340
	}
342
else
341
else
343
	{
342
	{
344
	echo "<input type='hidden' name='choix' value='Download_list'>";
343
	echo "<input type='hidden' name='choix' value='Download_list'>";
345
	echo "<input type='submit' value='$l_download_bl'>";
344
	echo "<input type='submit' onClick=\"this.disabled=true; this.value='$l_load';\" value='$l_download_bl'>";
346
	echo " ($l_warning)";
345
	echo " ($l_warning)";
347
	}
346
	}
348
?>
347
?>
349
</FORM>
348
</FORM>
350
</td></tr>
349
</td></tr>
Line 419... Line 418...
419
echo "<td width=50% colspan=5 align=center>";
418
echo "<td width=50% colspan=5 align=center>";
420
echo "<H3>$l_forbidden_ip</H3>$l_forbidden_ip_explain<BR>";
419
echo "<H3>$l_forbidden_ip</H3>$l_forbidden_ip_explain<BR>";
421
echo "<textarea name='OSSI_bl_ip' rows=3 cols=40>";
420
echo "<textarea name='OSSI_bl_ip' rows=3 cols=40>";
422
echo_ip_file ($dir_bl_ip."ossi");
421
echo_ip_file ($dir_bl_ip."ossi");
423
echo "</textarea></td></tr><tr><td colspan=10>";
422
echo "</textarea></td></tr><tr><td colspan=10>";
424
echo "<input type='submit' value='$l_record'>";
423
echo "<input type='submit' onClick=\"this.disabled=true; this.value='$l_load';\" value='$l_record'>";
425
echo "</form> ($l_wait)";
424
echo "</form> ($l_wait)";
426
echo "</td></tr></table><br/>";
425
echo "</td></tr></table><br/>";
427
?>
426
?>
-
 
427
 
-
 
428
 
428
<table width="100%" border="0" cellspacing="0" cellpadding="0">
429
<table width="100%" border="0" cellspacing="0" cellpadding="0">
429
	<tr><th><?php echo $l_additional_file_title; ?></th></tr>
430
	<tr><th><?php echo $l_additional_file_title; ?></th></tr>
430
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
431
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
431
</table>
432
</table>
432
<table width="100%" border=1 cellspacing=0 cellpadding=1>
433
<table width="100%" border=1 cellspacing=0 cellpadding=1>
Line 437... Line 438...
437
echo "<H3>$l_file_list</H3>";
438
echo "<H3>$l_file_list</H3>";
438
echo "<table cellspacing=2 cellpadding=3 border=1><tr><th>$l_file_name<th>$l_nb_ip<th>$l_nb_domain_names<th>$l_file_remove</tr>";
439
echo "<table cellspacing=2 cellpadding=3 border=1><tr><th>$l_file_name<th>$l_nb_ip<th>$l_nb_domain_names<th>$l_file_remove</tr>";
439
exec("cd $upload_dir_ip && ls ossi-*", $fichiersIp);
440
exec("cd $upload_dir_ip && ls ossi-*", $fichiersIp);
440
foreach($fichiersIp as $fichier => $value)
441
foreach($fichiersIp as $fichier => $value)
441
{
442
{
442
	echo "<tr><td><center>".exec("sed 's/^.....//g' <<< $value")."</center></td><td><center>".exec("wc -l $upload_dir_ip$value | awk '{print $1}'")."</center></td><td><center>".exec("wc -l $upload_dir_domain_names$value | awk '{print $1}'")."</center></td><td><center><input type='submit' name='$value' value='$l_remove'></center></td></tr>";
443
	echo "<tr><td><center>".exec("sed 's/^.....//g' <<< $value")."</center></td><td><center>".exec("wc -l $upload_dir_ip$value | awk '{print $1}'")."</center></td><td><center>".exec("wc -l $upload_dir_domain_names$value | awk '{print $1}'")."</center></td><td><center><input type='submit' onClick=\"this.disabled=true; this.value='$l_load';\" name='$value' value='$l_remove'></center></td></tr>";
443
}
444
}
444
echo "</table><br/></td></form><form action='bl_filter.php' method='POST' enctype='multipart/form-data'>";
445
echo "</table><br/></td></form><form action='bl_filter.php' method='POST' enctype='multipart/form-data'>";
445
echo "<input type='hidden' name='choix' value='MAJ_ip_file_upload'><td width=50% colspan=5 align=center>";
446
echo "<input type='hidden' name='choix' value='MAJ_ip_file_upload'><td width=50% colspan=5 align=center>";
446
echo "<H3>$l_add_file</H3>";
447
echo "<H3>$l_add_file</H3>";
447
echo "$l_add_file_explain";
448
echo "$l_add_file_explain";
448
echo "<input type='file' name='fichier_ip'>";
449
echo "<input type='file' name='fichier_ip'>";
449
echo "<input type='submit' value='$l_submit'>";
450
echo "<input type='submit' onClick=\"this.disabled=true; this.value='$l_load';\" value='$l_submit'>";
450
echo "</td></tr>";
451
echo "</td></tr>";
451
echo "</form>";
452
echo "</form>";
452
echo "</table><br/>";
453
echo "</table><br/>";
453
?>
454
?>
-
 
455
 
454
<table width="100%" border="0" cellspacing="0" cellpadding="0">
456
<table width="100%" border="0" cellspacing="0" cellpadding="0">
455
	<tr><th><?php echo $l_specific_filtering; ?></th></tr>
457
	<tr><th><?php echo $l_specific_filtering; ?></th></tr>
456
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
458
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
457
</table>
459
</table>
-
 
460
 
-
 
461
 
458
<TABLE width="100%" border=1 cellspacing=0 cellpadding=1>
462
<TABLE width="100%" border=1 cellspacing=0 cellpadding=1>
459
<FORM action='bl_filter.php' method='POST'>
463
<FORM action='bl_filter.php' method='POST'>
460
<input type='hidden' name='choix' value='Specific_filtering'>
464
<input type='hidden' name='choix' value='Specific_filtering'>
461
<tr><td>
465
<tr><td>
462
<input type='checkbox' name='chk-ip'
466
<input type='checkbox' name='chk-ip'
Line 510... Line 514...
510
	echo "$l_error_open_file $urlregex_file";
514
	echo "$l_error_open_file $urlregex_file";
511
	}
515
	}
512
echo "> $l_safe_searching";
516
echo "> $l_safe_searching";
513
echo "<br>$l_safe_youtube";
517
echo "<br>$l_safe_youtube";
514
echo " $l_youtube_id<tr><td>";
518
echo " $l_youtube_id<tr><td>";
515
echo "<input type='submit' value='$l_record'></td></tr>";
519
echo "<input type='submit' onClick=\"this.disabled=true; this.value='$l_load';\" value='$l_record'></td></tr>";
516
?>
520
?>
517
</FORM> 
521
</FORM> 
518
</TABLE>
522
</TABLE>
519
</BODY>
523
</BODY>
520
</HTML>
524
</HTML>