Subversion Repositories ALCASAR

Rev

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

Rev 1951 Rev 1954
Line 1... Line 1...
1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2
<HTML><!-- written by Rexy -->
2
<HTML><!-- written by Rexy -->
3
<HEAD>
3
<HEAD>
4
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
4
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5
<TITLE>ALCASAR DNS filtering</TITLE>
5
<TITLE>ALCASAR DNS BL filtering</TITLE>
6
<link rel="stylesheet" href="/css/style.css" type="text/css">
6
<link rel="stylesheet" href="/css/style.css" type="text/css">
7
</HEAD>
7
</HEAD>
8
<body>
8
<body>
9
<?
9
<?
10
function form_filter ($form_content)
10
function form_filter ($form_content)
Line 135... Line 135...
135
	$l_disable="Désactiver";
135
	$l_disable="Désactiver";
136
	$l_enable="Activer";
136
	$l_enable="Activer";
137
	$l_file_state="Etat";
137
	$l_file_state="Etat";
138
}
138
}
139
else {
139
else {
140
	$l_bl="BlackList";
140
	$l_bl="General BlackList";
141
	$l_load="Loading...";
141
	$l_load="Loading...";
142
	$l_list_version="List version : ";
142
	$l_list_version="List version : ";
143
	$l_bl_categories="Select the categories to filter";
143
	$l_bl_categories="Select the categories to filter";
144
	$l_download_bl="Download the last version";
144
	$l_download_bl="Download the last version";
145
	$l_fingerprint="The digital fingerprint of the downloaded blacklist is : ";
145
	$l_fingerprint="The digital fingerprint of the downloaded blacklist is : ";
Line 186... Line 186...
186
}
186
}
187
$dir_etc="/usr/local/etc/";
187
$dir_etc="/usr/local/etc/";
188
$dir_dg="/etc/dansguardian/lists/";
188
$dir_dg="/etc/dansguardian/lists/";
189
$dir_blacklist=$dir_dg."blacklists/";
189
$dir_blacklist=$dir_dg."blacklists/";
190
$dir_bl_ip="/usr/local/share/iptables-bl/";
190
$dir_bl_ip="/usr/local/share/iptables-bl/";
-
 
191
$dir_bl_ip_enabled="/usr/local/share/iptables-bl-enabled/";
191
$dir_bl_dns="/usr/local/share/dnsmasq-bl/";
192
$dir_bl_domain_names="/usr/local/share/dnsmasq-bl/";
-
 
193
$dir_bl_domain_names_enabled="/usr/local/share/dnsmasq-bl-enabled/";
192
$bl_categories=$dir_etc."alcasar-bl-categories";
194
$bl_categories=$dir_etc."alcasar-bl-categories";
193
$bl_categories_enabled=$dir_etc."alcasar-bl-categories-enabled";
195
$bl_categories_enabled=$dir_etc."alcasar-bl-categories-enabled";
194
$conf_file=$dir_etc."alcasar.conf";
196
$conf_file=$dir_etc."alcasar.conf";
195
$urlregex_file=$dir_dg."urlregexplist";
197
$urlregex_file=$dir_dg."urlregexplist";
196
$bannedsite_file=$dir_dg."bannedsitelist";
198
$bannedsite_file=$dir_dg."bannedsitelist";
197
$dir_tmp="/tmp/blacklists";
199
$dir_tmp="/tmp/blacklists";
198
$dir_ip_enabled = "/usr/local/share/iptables-bl-enabled/";
-
 
199
$dir_domain_names_enabled = "/usr/local/share/dnsmasq-bl-enabled/";
-
 
200
$dir_ip = "/usr/local/share/iptables-bl/";
-
 
201
$dir_domain_names = "/usr/local/share/dnsmasq-bl/";
-
 
202
$update_file_cat="/usr/local/etc/update_cat.conf";
200
$update_file_cat="/usr/local/etc/update_cat.conf";
203
 
201
 
204
 
202
 
205
# default values
203
# default values
206
if (is_file ($conf_file))
204
if (is_file ($conf_file))
Line 284... Line 282...
284
		if($fichier != "choix")
282
		if($fichier != "choix")
285
		{
283
		{
286
			$action=$_POST[$fichier];
284
			$action=$_POST[$fichier];
287
			if($action == $l_remove) //delete
285
			if($action == $l_remove) //delete
288
			{
286
			{
-
 
287
				exec("/bin/sed -i \"/^$fichier$/d\" $bl_categories_enabled"); 
289
				exec("rm -rf $dir_blacklist$fichier");
288
				exec("rm -rf $dir_blacklist$fichier");
290
				exec ("sudo /usr/local/bin/alcasar-bl.sh --reload");
289
				exec ("sudo /usr/local/bin/alcasar-bl.sh --reload");
291
			}
290
			}
292
			if($action == $l_disable) //disable
291
			if($action == $l_disable) //disable
293
			{
292
			{
294
				echo "$fichier - $bl_categories_enabled";
-
 
295
				//exec("/bin/sed -i \"/^$fichier$/d\" $bl_categories_enabled"); 
293
				exec("/bin/sed -i \"/^$fichier$/d\" $bl_categories_enabled"); 
296
				//exec("sudo /usr/local/bin/alcasar-bl.sh --reload");
294
				exec("sudo /usr/local/bin/alcasar-bl.sh --reload");
297
			}
295
			}
298
			if($action == $l_enable) //enable
296
			if($action == $l_enable) //enable
299
			{
297
			{
300
				exec("ln -s $dir_ip$fichier $dir_ip_enabled$fichier");
298
				file_put_contents ($bl_categories_enabled, $fichier."\n", FILE_APPEND);
301
				exec("ln -s $dir_domain_names$fichier $dir_domain_names_enables$fichier");
-
 
302
				exec ("sudo /usr/local/bin/alcasar-bl.sh --reload");
299
				exec ("sudo /usr/local/bin/alcasar-bl.sh --reload");
303
			}
300
			}
304
		}
301
		}
305
	}
302
	}
306
	break;
303
	break;
307
case 'MAJ_ossi_file_upload' :
304
case 'MAJ_ossi_file_upload' :
308
	$nom = str_replace (".", "_",basename($_FILES['fichier_ip']['name']));
305
	$file_name = str_replace (".", "_",basename($_FILES['fichier_ip']['name']));
309
	if(!empty($nom))
306
	if(!empty($file_name))
310
	{	
307
	{	
311
		if(move_uploaded_file($_FILES['fichier_ip']['tmp_name'], $dir_blacklist."ossi-bl-".$nom))
308
		if(move_uploaded_file($_FILES['fichier_ip']['tmp_name'], $dir_blacklist."ossi-bl-".$file_name))
312
		{
309
		{
313
			exec ("sudo /usr/local/bin/alcasar-bl.sh --reload");
310
			exec ("sudo /usr/local/bin/alcasar-bl.sh --reload");
314
		}
311
		}
315
		else
312
		else
316
		{
313
		{
Line 341... Line 338...
341
	echo "<input type='submit' onClick=\"this.disabled=true; this.value='$l_load';\" value='$l_reject_bl'></form>";
338
	echo "<input type='submit' onClick=\"this.disabled=true; this.value='$l_load';\" value='$l_reject_bl'></form>";
342
	}
339
	}
343
else
340
else
344
	{
341
	{
345
	echo "<input type='hidden' name='choix' value='Download_list'>";
342
	echo "<input type='hidden' name='choix' value='Download_list'>";
346
	echo "<input type='submit' onClick=\"this.disabled=true; this.value='$l_load';\" value='$l_download_bl'>";
343
	echo "<input type='submit' onClick=\"this.disabled=true; this.value='$l_load';\" value='$l_download_bl'> ($l_warning)</form>";
347
	echo " ($l_warning)";
-
 
348
	}
344
	}
349
?>
345
?>
350
</FORM>
-
 
351
</td></tr>
346
</td></tr>
352
</table><br/>
347
</table><br/>
353
<table width="100%" border="0" cellspacing="0" cellpadding="0">
348
<table width="100%" border="0" cellspacing="0" cellpadding="0">
354
	<tr><th><?php echo $l_bl; ?></th></tr>
349
	<tr><th><?php echo $l_bl; ?></th></tr>
355
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
350
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
Line 358... Line 353...
358
<tr><td valign="middle" align="left" colspan=10>
353
<tr><td valign="middle" align="left" colspan=10>
359
<FORM action='bl_filter.php' method=POST>
354
<FORM action='bl_filter.php' method=POST>
360
<input type='hidden' name='choix' value='MAJ_cat_bl'>
355
<input type='hidden' name='choix' value='MAJ_cat_bl'>
361
<?php
356
<?php
362
echo "<center>";
357
echo "<center>";
363
// total nnumber of IP, DNS & URLs
358
// total number of IP, DNS & URLs
364
$nbDomainNames = exec ("wc -l /usr/local/share/dnsmasq-bl/* | tail -n 1 | awk '{print $1}'");
359
$nbDomainNames = exec ("wc -l /usr/local/share/dnsmasq-bl/* | tail -n 1 | awk '{print $1}'");
365
$nbUrl = exec ("for file in `find /etc/dansguardian/lists/blacklists/ -name 'urls'`; do nb=$((nb+$(wc -l \$file | awk '{print $1}'))); done; echo \$nb");
360
$nbUrl = exec ("for file in `find /etc/dansguardian/lists/blacklists/ -name 'urls'`; do nb=$((nb+$(wc -l \$file | awk '{print $1}'))); done; echo \$nb");
366
$nbIp = exec ("wc -l /usr/local/share/iptables-bl/* | tail -n 1 | awk '{print $1}'");
361
$nbIp = exec ("wc -l /usr/local/share/iptables-bl/* | tail -n 1 | awk '{print $1}'");
367
echo "<b>$l_nbDomainNames</b> $nbDomainNames, <b>$l_nbUrl</b> $nbUrl, <b>$l_nbIp</b> $nbIp<br/>";
362
echo "<b>$l_nbDomainNames</b> $nbDomainNames, <b>$l_nbUrl</b> $nbUrl, <b>$l_nbIp</b> $nbIp<br/>";
368
echo "$l_bl_categories</center></td></tr>";	
363
echo "$l_bl_categories</center></td></tr>";	
Line 376... Line 371...
376
		{
371
		{
377
		if ($cols == 1) { echo "<tr>";}
372
		if ($cols == 1) { echo "<tr>";}
378
		$categorie=trim(basename($value));
373
		$categorie=trim(basename($value));
379
		echo "<td><a href='bl_categories_help.php?liste=bl&cat=$categorie' target='cat_help' onclick=window.open('bl_categories_help.php','cat_help','width=600,height=450,toolbar=no,scrollbars=yes,resizable=yes') title='categories help page'>$categorie</a><br>";
374
		echo "<td><a href='bl_categories_help.php?liste=bl&cat=$categorie' target='cat_help' onclick=window.open('bl_categories_help.php','cat_help','width=600,height=450,toolbar=no,scrollbars=yes,resizable=yes') title='categories help page'>$categorie</a><br>";
380
		echo "<input type='checkbox' name='chk-$categorie'";
375
		echo "<input type='checkbox' name='chk-$categorie'";
381
		// si la ligne est commentée -> categorie non selectionnée
376
		// if the line is commented, the category is disable
382
		if (preg_match('/^#/',$value, $r)) { echo ">";}
377
		if (preg_match('/^#/',$value, $r)) { echo ">";}
383
		else { echo "checked>"; }
378
		else { echo "checked>"; }
384
		echo "</td>";
379
		echo "</td>";
385
		$cols++;
380
		$cols++;
386
		if ($cols > 10) {
381
		if ($cols > 10) {
Line 446... Line 441...
446
//list OSSI custom categories
441
//list OSSI custom categories
447
$fichiersbl = array_diff(scandir($dir_blacklist), array('..','.','ossi-bl','ossi-wl'));
442
$fichiersbl = array_diff(scandir($dir_blacklist), array('..','.','ossi-bl','ossi-wl'));
448
$fichiersbl = preg_grep("/^ossi-bl-/",$fichiersbl);
443
$fichiersbl = preg_grep("/^ossi-bl-/",$fichiersbl);
449
foreach($fichiersbl as $fichier => $value)
444
foreach($fichiersbl as $fichier => $value)
450
{
445
{
451
	echo "<tr><td><center><a href='bl_categories_help.php?liste=bl&cat=$value&filtre=domain' target='cat_help' onclick=window.open('bl_categories_help','cat_help','width=600,height=450,toolbar=no,scrollbars=yes,resizable=yes') title='categories help page'>".substr($value,8)."</a></center></td><td><center>".exec("wc -l $dir_ip$value | cut -d\" \" -f1")."</center></td><td><center>".exec("wc -l $dir_domain_names$value.conf | cut -d\" \" -f1")."</center></td><td><center><input type='submit' name='$value' value='$l_disable'></center></td><td><center><input type='submit' name='$value' value='$l_remove'></center></td></tr>";
446
	echo "<tr><td><center><a href='bl_categories_help.php?liste=bl&cat=$value&filtre=domain' target='cat_help' onclick=window.open('bl_categories_help','cat_help','width=600,height=450,toolbar=no,scrollbars=yes,resizable=yes') title='categories help page'>".substr($value,8)."</a></center></td><td><center>".exec("wc -l $dir_bl_ip$value | cut -d\" \" -f1")."</center></td><td><center>".exec("wc -l $dir_bl_domain_names$value.conf | cut -d\" \" -f1")."</center></td><td><center><input type='submit' name='$value'";
-
 
447
	if (file_exists ($dir_bl_domain_names_enabled.$value)) echo " value='$l_disable'>"; else echo " value='$l_enable'>";
-
 
448
	echo "</center></td><td><center><input type='submit' name='$value' value='$l_remove'></center></td></tr>";
452
}
449
}
453
echo "</table><br/></td></form><form action='bl_filter.php' method='POST' enctype='multipart/form-data'>";
450
echo "</table><br/></td></form><form action='bl_filter.php' method='POST' enctype='multipart/form-data'>";
454
echo "<input type='hidden' name='choix' value='MAJ_ossi_file_upload'><td width=50% colspan=5 align=center>";
451
echo "<input type='hidden' name='choix' value='MAJ_ossi_file_upload'><td width=50% colspan=5 align=center>";
455
echo "<H3>$l_add_file</H3>";
452
echo "<H3>$l_add_file</H3>";
456
echo "$l_add_file_explain";
453
echo "$l_add_file_explain";