Subversion Repositories ALCASAR

Rev

Rev 3028 | Rev 3179 | 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">
1954 richard 5
<TITLE>ALCASAR DNS BL filtering</TITLE>
2817 rexy 6
<link rel="stylesheet" href="/css/acc.css" type="text/css">
318 richard 7
</HEAD>
8
<body>
3028 rexy 9
<div id="ldoverlay" class="overlay">
10
	<div class="lds-spinner" id="spinner"><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div></div>
11
</div>
318 richard 12
<?
449 richard 13
function form_filter ($form_content)
14
{
15
// réencodage iso + format unix + rc fin de ligne (ouf...)
16
	$list = str_replace("\r\n", "\n", utf8_decode($form_content));
17
	if (strlen($list) != 0){
18
		if ($list[strlen($list)-1] != "\n") { $list[strlen($list)]="\n";} ;} ;
19
	return $list;
20
}
1344 richard 21
function form_filter_ip($form_content, $color)
1339 richard 22
{
1344 richard 23
	//# reconstruction des ip
24
	$list = explode("\n", form_filter($form_content));
25
	$new_list = "";
3173 rexy 26
	foreach ($list as &$value)
1344 richard 27
	{
28
		if(preg_match('/([0-9]{1,3}.){3}[0-9]{1,3}/', $value))
29
		{
30
			$new_list = $new_list.$value."\n";
31
		}
32
	}
33
	if($color == "white")
34
	{
1867 raphael.pi 35
		return preg_replace("/(.*)\n/", "add wl_ip_allowed $1\n", $new_list);
1344 richard 36
	}
37
	else
38
	{
1867 raphael.pi 39
		return preg_replace("/(.*)\n/", "add bl_ip_blocked $1\n", $new_list);
1344 richard 40
	}
1339 richard 41
}
1488 richard 42
function echo_file ($filename)
2688 lucas.echa 43
{
44
	if (file_exists($filename))
1488 richard 45
	{
2688 lucas.echa 46
		if (filesize($filename) != 0)
1488 richard 47
		{
48
			$pointeur=fopen($filename,"r");
49
			$tampon = fread($pointeur, filesize($filename));
50
			fclose($pointeur);
51
			echo $tampon;
52
		}
2688 lucas.echa 53
	}
1488 richard 54
	else
2688 lucas.echa 55
	{
1488 richard 56
		echo "$filename doesn't exist";
57
	}
2688 lucas.echa 58
}
1488 richard 59
function echo_ip_file ($filename)
60
{
2299 tom.houday 61
	$filename = escapeshellarg($filename);
1488 richard 62
	exec("cat $filename | cut -d ' ' -f3", $resultat);
63
	for($i=0; $i<exec("wc -l $filename"); $i++)
64
	{
65
		echo $resultat[$i]."\n";
66
	}
67
}
1818 raphael.pi 68
 
318 richard 69
# Choice of language
70
$Language = 'en';
71
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
1899 raphael.pi 72
	$Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
2648 lucas.echa 73
	$Language = strtolower(substr(chop($Langue[0]),0,2));
2688 lucas.echa 74
}
318 richard 75
if($Language == 'fr'){
2769 rexy 76
	$l_bl="Liste noire principale";
1899 raphael.pi 77
	$l_load="Chargement...";
78
	$l_list_version="Version de la liste : ";
79
	$l_bl_categories="Sélectionnez les catégories à filtrer";
80
	$l_download_bl="Télécharger la dernière version";
81
	$l_fingerprint="L'empreinte numérique du fichier téléchargé est : ";
82
	$l_fingerprint2="Vérifiez-là en suivant ce lien (ligne 'blacklists.tar.gz') : ";
83
	$l_activate_bl="Activer la nouvelle version";
84
	$l_reject_bl="Rejeter";
2150 richard 85
	$l_warning="Temps estimé : une minute";
1899 raphael.pi 86
	$l_specific_filtering="Filtrage special";
1958 richard 87
	$l_maj_rehabilitated="Noms de domaine ou adresses IP réhabilités";
1899 raphael.pi 88
	$l_rehabilitated_dns="Noms de domaine réhabilités";
89
	$l_rehabilitated_dns_explain="Entrez ici des noms de domaine bloqués par la liste noire <BR> que vous souhaitez réhabiliter.";
1925 richard 90
	$l_add_to_bl="Noms de domaine ou adresses IP à ajouter à la liste noire";
1958 richard 91
	$l_rehabilitated_ip="Adresses IP réhabilitées";
1899 raphael.pi 92
	$l_rehabilitated_ip_explain="Entrez ici des IP bloquées par la liste noire <BR> que vous souhaitez réhabiliter.";
1936 richard 93
	$l_one_dns="Entrez une adresse DNS par ligne (exemple : www.domaine.com)";
1899 raphael.pi 94
	$l_one_ip="Entrez une IP par ligne (exemple : 123.123.123.123)";
2953 rexy 95
	$l_one_dns_ip="Entrez un nom de domaine ou une adresse IP ou une adresse de réseau par ligne";
1899 raphael.pi 96
	$l_record="Enregistrer les modifications";
97
	$l_wait="Une fois validées, 10 secondes sont nécessaires pour traiter vos modifications";
98
	$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)";
2662 lucas.echa 99
	$l_safe_searching="Activer le contrôle scolaire/parental pour 'YouTube' et pour les moteurs de recherche 'Google', 'Bing' et 'Qwant'.";
1899 raphael.pi 100
	$l_error_open_file="Erreur d'ouverture du fichier";
2769 rexy 101
	$l_additional_file_title="Listes noires additionnelles";
1899 raphael.pi 102
	$l_file_list="Liste des fichiers";
103
	$l_add_file="Ajouter un fichier";
2953 rexy 104
	$l_add_file_explain="Chaque ligne du fichier peut être un nom de domaine ou une adresse IP ou une adresse de réseau";
105
	$l_add_example="exemple (domaine) : domaine.org. - exemple (ip) : 61.54.52.56 - exemple (réseau) : 172.16.0.0/16";
1899 raphael.pi 106
	$l_file_name="Nom du fichier";
1938 richard 107
	$l_file_action="Action";
1899 raphael.pi 108
	$l_error_upload="Erreur d'envoi du fichier";
109
	$l_remove="Supprimer";
110
	$l_submit="Envoyer";
111
	$l_nb_ip="Nombre d'IP";
112
	$l_nb_domain_names="Nombre de noms de domaine";
113
	$l_nbDomainNames="Noms de domaine :";
114
	$l_nbUrl="Url :";
115
	$l_nbIp="Ip :";
2769 rexy 116
	$l_update_cat="Blacklist principale (catégorie 'malware' uniquement)";
117
	$l_update_cat_header="Mise à jour automatique des Blacklists";
2853 rexy 118
	$l_update_success="Échec de la mise à jour";
2769 rexy 119
	$l_update_failed="Mise à jour réussie";
1899 raphael.pi 120
	$l_disable="Désactiver";
121
	$l_enable="Activer";
2769 rexy 122
	$l_update="Mise a jour";
2853 rexy 123
	$l_no_update_configured="Aucun script de mise à jour trouvé";
1899 raphael.pi 124
	$l_file_state="Etat";
2853 rexy 125
} else if ($Language == 'es'){
126
	$l_bl="Lista negra general";
127
	$l_load="Cargando...";
128
	$l_list_version="Version de la lista : ";
129
	$l_bl_categories="Seleccione las categorías para filtrar";
130
	$l_download_bl="Descargar la última versión";
131
	$l_fingerprint="La huella digital de la lista negra descargada es: ";
132
	$l_fingerprint2="Verifíquelo con este enlace (línea 'blacklists.tar.gz') : ";
133
	$l_activate_bl="Activar la nueva versión";
134
	$l_reject_bl="Rechazar";
135
	$l_warning="Tiempo estimado: un minuto";
136
	$l_specific_filtering="Specific filtering";
137
	$l_allowed_dns="Sitios permitidos";
138
	$l_maj_rehabilitated="Nombres de dominio o direcciones IP para rehabilitar";
139
	$l_rehabilitated_dns="Nombres de dominio para rehabilitar";
140
	$l_rehabilitated_dns_explain="Ingrese aquí los nombres de dominio que están bloqueados por la lista negra <BR> y que desea rehabilitar.";
141
	$l_add_to_bl="Nombres de dominio o direcciones IP para agregar a la lista negra";
142
	$l_rehabilitated_ip="Direcciones IP para rehabilitar";
143
	$l_rehabilitated_ip_explain="Ingrese aquí las IP que están bloqueadas por la lista negra <BR> y que desea rehabilitar.";
144
	$l_one_dns="Ingrese un DNS por línea (ejemplo: www.dominio.com)";
145
	$l_one_ip="Ingrese una IP por línea (ejemplo: 123.123.123.123)";
2953 rexy 146
	$l_one_dns_ip="Ingrese un nombre de dominio o una dirección IP o una dirección de red por línea";
2853 rexy 147
	$l_record="Guardar cambios";
148
	$l_wait="Una vez validado, son necesarios 10 segundos para aplicar sus modificaciones";
149
	$l_ip_filtering="Filtrado de URL que contienen una dirección IP en lugar de un nombre de dominio (es decir: http://25.56.58.59/index.htm)";
150
	$l_safe_searching="Habilitación del control escolar / parental para 'YouTube' y para los motores de búsqueda 'Google', 'Bing' y 'Qwant'";
151
	$l_error_open_file="Error al abrir el archivo";
152
	$l_additional_file_title="Archivos de lista negra adicionales";
153
	$l_file_list="Lista de archivos";
154
	$l_add_file="Agregar un archivo";
155
	$l_add_file_explain="Cada línea del archivo debe ser una dirección IP o un nombre de dominio";
2953 rexy 156
	$l_add_example="ejemplo (dominio): domain.org. - ejemplo (ip): 61.54.56.52 - ejemplo (red): 172.16.0.0/16";
2853 rexy 157
	$l_file_name="Nombre de archivo";
158
	$l_file_action="Acción";
159
	$l_error_upload="Error durante el proceso de carga";
160
	$l_remove="Borrar";
161
	$l_submit="Enviar";
162
	$l_nb_ip="Números de IP";
163
	$l_nb_domain_names="Números de sitios";
164
	$l_nbDomainNames="Domain names: ";
165
	$l_nbUrl="Url :";
166
	$l_nbIp="Ip :";
167
	$l_update_cat="¿Actualizar automáticamente las categorías cada 12 horas (solo 'malware' por ahora)?";
168
	$l_update_cat_header="Actualización automática de la lista negra";
169
	$l_update_success="actualización fallida";
170
	$l_update_failed="actualización exitosa";
171
	$l_disable="Desactivar";
172
	$l_enable="Activar";
173
	$l_update="actualizando";
174
	$l_no_update_configured="No se encontró ningún script de actualización";
175
	$l_file_state="Estado";
176
} else {
2864 rexy 177
	$l_bl="Main BlackList";
1899 raphael.pi 178
	$l_load="Loading...";
179
	$l_list_version="List version : ";
180
	$l_bl_categories="Select the categories to filter";
181
	$l_download_bl="Download the last version";
182
	$l_fingerprint="The digital fingerprint of the downloaded blacklist is : ";
183
	$l_fingerprint2="Verify it with this link (line 'blacklists.tar.gz') : ";
184
	$l_activate_bl="Activate the new version";
185
	$l_reject_bl="Reject";
2150 richard 186
	$l_warning="Estimated time : one minute";
1899 raphael.pi 187
	$l_specific_filtering="Specific filtering";
188
	$l_allowed_dns="Allowed domain names";
1958 richard 189
	$l_maj_rehabilitated="Domain names or IP addresses to rehabilitated";
190
	$l_rehabilitated_dns="Domain names to rehabilitated";
1899 raphael.pi 191
	$l_rehabilitated_dns_explain="Enter here domain names that are blocked by the blacklist <BR> and you want to rehabilitate.";
1925 richard 192
	$l_add_to_bl="Domain names or IP addresses to add to the blacklist";
1958 richard 193
	$l_rehabilitated_ip="IP addresses to rehabilitated";
1899 raphael.pi 194
	$l_rehabilitated_ip_explain="Enter here IP that are blocked by the blacklist <BR> and you want to rehabilitate.";
2688 lucas.echa 195
	$l_one_dns="Enter one DNS per row (example : www.domain.com)";
1899 raphael.pi 196
	$l_one_ip="Enter one IP per row (example : 123.123.123.123)";
2953 rexy 197
	$l_one_dns_ip="Enter one domain name or one IP address or one network address per row";
1899 raphael.pi 198
	$l_record="Save changes";
199
	$l_wait="Once validated, 10 seconds are necessary to compute your modifications";
200
	$l_ip_filtering="Filtering URLs that contain an IP address instead of a domain name (ie: http://25.56.58.59/index.htm)";
2662 lucas.echa 201
	$l_safe_searching="Enabling school/parental control for 'YouTube' and for the search engines 'Google', 'Bing' and 'Qwant'";
1899 raphael.pi 202
	$l_error_open_file="Error opening file";
2769 rexy 203
	$l_additional_file_title="Additional blacklists";
1899 raphael.pi 204
	$l_file_list="Files list";
205
	$l_add_file="Add a file";
2648 lucas.echa 206
	$l_add_file_explain="Each line of the file must be an IP address or a domain name";
2953 rexy 207
	$l_add_example="example (domain): domain.org. - example (ip): 61.54.56.52 - example (network) : 172.16.0.0/16";
1899 raphael.pi 208
	$l_file_name="Filename";
1938 richard 209
	$l_file_action="Action";
1899 raphael.pi 210
	$l_error_upload="Error during the upload process";
211
	$l_remove="Delete";
212
	$l_submit="Submit";
213
	$l_nb_ip="Number of IP";
214
	$l_nb_domain_names="Number of domain names";
215
	$l_nbDomainNames="Domain names :";
216
	$l_nbUrl="Url :";
217
	$l_nbIp="Ip :";
2769 rexy 218
	$l_update_cat="Main Blacklist (only 'malware' category)";
219
	$l_update_cat_header="Automatic Update of Blacklists";
220
	$l_update_success="Update succeeded";
221
	$l_update_failed="Update failed";
1899 raphael.pi 222
	$l_disable="Disable";
223
	$l_enable="Enable";
2769 rexy 224
	$l_update="Update";
225
	$l_no_update_configured="No update script configured";
1899 raphael.pi 226
	$l_file_state="State";
318 richard 227
}
1041 richard 228
$dir_etc="/usr/local/etc/";
2521 armand.ito 229
$dir_dg="/etc/e2guardian/lists/";
1936 richard 230
$dir_blacklist=$dir_dg."blacklists/";
1339 richard 231
$dir_bl_ip="/usr/local/share/iptables-bl/";
1954 richard 232
$dir_bl_ip_enabled="/usr/local/share/iptables-bl-enabled/";
2688 lucas.echa 233
$dir_bl_domain_names="/usr/local/share/unbound-bl/";
234
$dir_bl_domain_names_enabled="/usr/local/share/unbound-bl-enabled/";
1041 richard 235
$bl_categories=$dir_etc."alcasar-bl-categories";
236
$bl_categories_enabled=$dir_etc."alcasar-bl-categories-enabled";
237
$conf_file=$dir_etc."alcasar.conf";
2688 lucas.echa 238
$domainfilter_file="/etc/unbound/conf.d/blacklist/domainfilter.conf";
1041 richard 239
$bannedsite_file=$dir_dg."bannedsitelist";
885 richard 240
$dir_tmp="/tmp/blacklists";
1870 raphael.pi 241
$update_file_cat="/usr/local/etc/update_cat.conf";
2769 rexy 242
$update_file_ossi_cat="/usr/local/etc/update_ossi_cat.conf";
2688 lucas.echa 243
$bl_safesearch="off";
244
$bl_pureip="off";
2769 rexy 245
$updateable_ossi_bls=["ossi-bl-candc"];
1870 raphael.pi 246
 
885 richard 247
# default values
248
if (is_file ($conf_file))
2688 lucas.echa 249
{
885 richard 250
	$tab=file($conf_file);
251
	if ($tab)
2688 lucas.echa 252
	{
253
		foreach ($tab as $line)
885 richard 254
		{
255
			$field=explode("=", $line);
2688 lucas.echa 256
			switch ($field[0]) {
257
				case 'PRIVATE_IP':
258
					$PRIVATE_IP_MASK=trim($field[1]);
259
					$tmp = explode("/",$PRIVATE_IP_MASK);
260
					$PRIVATE_IP=$tmp[0];
261
					break;
262
 
263
				case 'BL_SAFESEARCH':
264
					if (strtolower(trim($field[1])) == 'on') {
265
						$bl_safesearch='on';
266
					}
267
					break;
268
 
269
				case 'BL_PUREIP':
270
					if (strtolower(trim($field[1])) == 'on') {
271
						$bl_pureip='on';
272
					}
273
					break;
885 richard 274
			}
275
		}
2648 lucas.echa 276
	}
2688 lucas.echa 277
}
885 richard 278
else { echo "$l_error_open_file $conf_file";}
318 richard 279
if (isset($_POST['choix'])){ $choix=$_POST['choix']; } else { $choix=""; }
280
switch ($choix)
281
{
2688 lucas.echa 282
	case 'Download_list' :
283
		exec ("sudo /usr/local/bin/alcasar-bl.sh --download");
284
		break;
285
	case 'Active_list' :
286
		exec ("sudo /usr/local/bin/alcasar-bl.sh --adapt");
287
		exec ("sudo /usr/local/bin/alcasar-bl.sh --reload");
288
		break;
289
	case 'Reject_list' :
290
		unlink ("$dir_tmp/blacklists.tar.gz"); unlink ("$dir_tmp/md5sum");
291
		break;
292
	case 'MAJ_cat_bl' :
293
		if (file_exists($bl_categories_enabled))
1940 richard 294
		{
2688 lucas.echa 295
			exec("/bin/sed -i \"/^ossi-/!d\" $bl_categories_enabled"); // keep ossi custom categories
296
			$pointeur=fopen($bl_categories_enabled, "a+");
297
			foreach ($_POST as $key => $value)
2648 lucas.echa 298
			{
2688 lucas.echa 299
				if (strstr($key,'chk-'))
1867 raphael.pi 300
				{
2688 lucas.echa 301
					$line=str_replace('chk-','',$key)."\n";
302
					fwrite($pointeur,$line);
1867 raphael.pi 303
				}
318 richard 304
			}
2688 lucas.echa 305
			fclose($pointeur);
1940 richard 306
		}
2688 lucas.echa 307
		else {echo "$l_error_open_file $bl_categories_enabled";}
308
		$fichier=fopen($dir_blacklist."ossi-bl/domains","w+");
309
		fputs($fichier, form_filter($_POST['OSSI_bl']));
1957 richard 310
		fclose($fichier);
2688 lucas.echa 311
		unset($_POST['OSSI_bl']);
312
		$fichier=fopen($dir_dg."exceptionsitelist","w+");
313
		fputs($fichier, form_filter($_POST['BL_rehabilited_domains']));
314
		fclose($fichier);
315
		unset($_POST['BL_rehabilited_domains']);
316
		$fichier=fopen($dir_dg."exceptioniplist","w+");
317
		fputs($fichier, form_filter($_POST['BL_rehabilited_ip']));
318
		fclose($fichier);
319
		unset($_POST['BL_rehabilited_ip']);
320
		exec ("sudo /usr/local/bin/alcasar-bl.sh --reload");
321
		break;
322
	case 'Specific_filtering':
323
		$bl_pureip='off';
324
		$bl_safesearch='off';
325
		foreach ($_POST as $key => $value)
1339 richard 326
		{
2688 lucas.echa 327
			if (strstr($key,'chk-ip')) $bl_pureip="on";
328
			if (strstr($key,'chk-safesearch')) $bl_safesearch="on";
329
		}
330
		exec ("sudo /usr/local/bin/alcasar-url_filter_bl.sh -safesearch_$bl_safesearch -pureip_$bl_pureip");
331
		break;
332
	case 'MAJ_ossi_file' :
3173 rexy 333
		foreach ($_POST as $fichier => $value)
2688 lucas.echa 334
		{
2769 rexy 335
			if($fichier != "choix" && $fichier != "update_cat")
1899 raphael.pi 336
			{
2688 lucas.echa 337
				$action=$_POST[$fichier];
338
				if($action == $l_remove) //delete
339
				{
340
					exec("/bin/sed -i ".escapeshellarg("/^$fichier\$/d")." $bl_categories_enabled");
341
					exec("/bin/sed -i ".escapeshellarg("/$fichier\$/d")." $bl_categories");
342
					exec("rm -rf $dir_blacklist".escapeshellarg($fichier));
343
					exec("sudo /usr/local/bin/alcasar-bl.sh --reload");
344
				}
345
				if($action == $l_disable) //disable
346
				{
2769 rexy 347
 
2688 lucas.echa 348
					exec("/bin/sed -i ".escapeshellarg("/^$fichier\$/d")." $bl_categories_enabled");
349
					exec("sudo /usr/local/bin/alcasar-bl.sh --reload");
350
				}
351
				if($action == $l_enable) //enable
352
				{
2769 rexy 353
					file_put_contents($bl_categories_enabled, $fichier."\n", FILE_APPEND);
354
					exec("sudo /usr/local/bin/alcasar-bl.sh --reload 2>&1", $out, $ret);
2688 lucas.echa 355
				}
2769 rexy 356
				if($action == $l_update) //update
357
				{
358
				    if ($fichier == ossi-bl-candc)
359
                    {
360
					    exec("sudo /usr/local/bin/alcasar-bl-autoupdate.sh --update_ossi-bl-candc 2>&1", $out, $ret);
361
				        if ($ret == 0)
362
				        {
363
					        echo "<p>".$l_update_success."</p>";
364
				        }
365
				        else
366
				        {
367
					        echo "<p>".$l_update_failed.":</p>";
3173 rexy 368
					        foreach ($out as $line)
2769 rexy 369
					        {
370
						        echo "<p>".$line."</p>";
371
					        }
372
				        }
373
                    }
374
				}
375
			}	
376
		}
377
        break;
378
	case 'Autoupdate' :
379
		// Reset updatelists, truncate files
380
		$f = fopen($update_file_ossi_cat, 'w');
381
		fclose($f);
382
        $f = fopen($update_file_ossi_cat, 'w');
383
		fclose($f);
384
 
3173 rexy 385
        foreach ($_POST as $fichier => $value)
2769 rexy 386
		{
387
			// General BL
388
			if ($fichier == 'update_cat' && $value == 1)
389
			{
390
				if (file_exists($bl_categories_enabled))
391
				{
392
					file_put_contents($update_file_cat, "malware rsync://ftp.ut-capitole.fr/blacklist/dest/malware\n", FILE_APPEND);
393
				}
1899 raphael.pi 394
			}
2769 rexy 395
		    // C&C Server List
396
		    if ($fichier == 'ossi-bl-candc' && $value == 1)
397
		    {
398
	            file_put_contents($update_file_ossi_cat, "alcasar-bl-autoupdate.sh --update_ossi-bl-candc\n", FILE_APPEND);
399
		    }
2688 lucas.echa 400
		}
401
		break;
402
	case 'MAJ_ossi_file_upload' :
2898 rexy 403
		$bad_char = array(" ", ".");
404
		$file_name = str_replace ($bad_char, "_",basename($_FILES['fichier_ip']['name']));
2688 lucas.echa 405
		$dest_dir = $dir_blacklist."ossi-bl-".$file_name; # /etc/e2guardian/list/blacklist/ossi-bl-XXXXXXXX
406
		if((!empty($file_name)) && (!file_exists($dest_dir)))
407
		{
408
			exec("mkdir ".escapeshellarg($dest_dir));
409
			$file=$_FILES['fichier_ip']['tmp_name'];
410
			exec('/usr/bin/dos2unix '.escapeshellarg($file));
411
			if(move_uploaded_file($_FILES['fichier_ip']['tmp_name'], $dest_dir."/domains")) // copy in the file "domains" (containing @ip & domain names (like over Toulouse categories))
1899 raphael.pi 412
			{
2688 lucas.echa 413
				touch ($dest_dir."/urls"); // create the URL file even if it isn't used
2769 rexy 414
				file_put_contents ($bl_categories, $dest_dir."\n", FILE_APPEND); // add to the categories list
2688 lucas.echa 415
				file_put_contents ($bl_categories_enabled, "ossi-bl-".$file_name."\n", FILE_APPEND); //Enabled by default
1954 richard 416
				exec("sudo /usr/local/bin/alcasar-bl.sh --reload");
1899 raphael.pi 417
			}
2688 lucas.echa 418
			else
1899 raphael.pi 419
			{
2688 lucas.echa 420
				exec("rm -rf ".escapeshellarg($dest_dir));
421
				echo $l_error_upload;
1899 raphael.pi 422
			}
1416 richard 423
		}
2688 lucas.echa 424
		break;
318 richard 425
}
426
?>
1488 richard 427
<table width="100%" border="0" cellspacing="0" cellpadding="0">
428
	<tr><th>
2521 armand.ito 429
	<?php echo $l_list_version; echo date ("F d Y", filemtime ('/etc/e2guardian/lists/blacklists/README'));?>
1488 richard 430
	</th></tr>
431
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
432
</table>
433
<TABLE width="100%" border=1 cellspacing=0 cellpadding=1>
434
<tr><td valign="middle" align="left" colspan=10>
435
<FORM action='bl_filter.php' method=POST>
318 richard 436
<?php
1488 richard 437
if ((file_exists("$dir_tmp/blacklists.tar.gz")) && (file_exists("$dir_tmp/md5sum")))
2688 lucas.echa 438
{
1488 richard 439
	echo "$l_fingerprint"; echo_file ("$dir_tmp/md5sum");
2150 richard 440
	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>";
1488 richard 441
	echo "<input type='hidden' name='choix' value='Active_list'>";
3028 rexy 442
	echo "<input type='submit' onClick=\"this.disabled=true; document.getElementById('ldoverlay').style.display='block'; this.value='$l_load';submit();\" value='$l_activate_bl'> ($l_warning)</FORM>";
1488 richard 443
	echo "<FORM action='bl_filter.php' method=POST>";
444
	echo "<input type='hidden' name='choix' value='Reject_list'>";
3028 rexy 445
	echo "<input type='submit' onClick=\"this.disabled=true; document.getElementById('ldoverlay').style.display='block'; this.value='$l_load';submit();\" value='$l_reject_bl'></form>";
2688 lucas.echa 446
}
1488 richard 447
else
2688 lucas.echa 448
{
1488 richard 449
	echo "<input type='hidden' name='choix' value='Download_list'>";
3028 rexy 450
	echo "<input type='submit' onClick=\"this.disabled=true; document.getElementById('ldoverlay').style.display='block'; this.value='$l_load';submit();\" value='$l_download_bl'> ($l_warning)</form>";
2688 lucas.echa 451
}
318 richard 452
?>
1488 richard 453
</td></tr>
2150 richard 454
</table><br>
1488 richard 455
<table width="100%" border="0" cellspacing="0" cellpadding="0">
456
	<tr><th><?php echo $l_bl; ?></th></tr>
457
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
458
</table>
2150 richard 459
<FORM action='bl_filter.php' method=POST>
460
<input type='hidden' name='choix' value='MAJ_cat_bl'>
1488 richard 461
<table width="100%" border=1 cellspacing=0 cellpadding=1>
462
<tr><td valign="middle" align="left" colspan=10>
463
<?php
464
echo "<center>";
1954 richard 465
// total number of IP, DNS & URLs
2688 lucas.echa 466
$nbDomainNames = exec("wc -l /usr/local/share/unbound-bl/* | tail -n 1 | awk '{print $1}'") / 2;
2521 armand.ito 467
$nbUrl = exec("for file in `find /etc/e2guardian/lists/blacklists/ -name 'urls'`; do nb=$((nb+$(wc -l \$file | awk '{print $1}'))); done; echo \$nb");
2299 tom.houday 468
$nbIp = exec("wc -l /usr/local/share/iptables-bl/* | tail -n 1 | awk '{print $1}'");
1488 richard 469
echo "<b>$l_nbDomainNames</b> $nbDomainNames, <b>$l_nbUrl</b> $nbUrl, <b>$l_nbIp</b> $nbIp<br/>";
2648 lucas.echa 470
echo "$l_bl_categories</center></td></tr>";
1936 richard 471
//read & display all BL categories (checked or not)
2648 lucas.echa 472
$cols=1;
1488 richard 473
if (file_exists($bl_categories))
2688 lucas.echa 474
{
1936 richard 475
	$bl_files = file($bl_categories);
476
	$bl_files = preg_grep("/ossi-/", $bl_files, 1); // don't display ossi custom categories
3173 rexy 477
	foreach ($bl_files as $fichier => $value)
2688 lucas.echa 478
	{
1936 richard 479
		if ($cols == 1) { echo "<tr>";}
480
		$categorie=trim(basename($value));
2150 richard 481
		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>";
1936 richard 482
		echo "<input type='checkbox' name='chk-$categorie'";
1954 richard 483
		// if the line is commented, the category is disable
1936 richard 484
		if (preg_match('/^#/',$value, $r)) { echo ">";}
2150 richard 485
		else { echo " checked>"; }
1936 richard 486
		echo "</td>";
487
		$cols++;
488
		if ($cols > 10) {
2150 richard 489
			echo "</tr>\n";
2688 lucas.echa 490
			$cols=1;
1488 richard 491
		}
492
	}
2688 lucas.echa 493
}
494
else {
1488 richard 495
	echo "$l_error_open_file $bl_categories";
1870 raphael.pi 496
}
497
 
2150 richard 498
echo "</tr>\n";
1488 richard 499
echo "<tr><td valign='middle' align='left' colspan=10>";
2769 rexy 500
echo "<center>
1870 raphael.pi 501
	<input type='submit' value='$l_record'></center>";
502
echo "</td></tr>";
503
echo "<tr><td valign='middle' align='left' colspan=10>";
1488 richard 504
echo "<center><b>$l_maj_rehabilitated</b></center></td></tr>";
505
echo "<tr><td width=50% colspan=5 align=center>";
506
echo "<H3>$l_rehabilitated_dns</H3>$l_rehabilitated_dns_explain<BR>$l_one_dns<BR>";
507
echo "<textarea name='BL_rehabilited_domains' rows=3 cols=40>";
508
echo_file ($dir_dg."exceptionsitelist");
509
echo "</textarea></td>";
510
echo "<td width=50% colspan=5 align=center>";
511
echo "<H3>$l_rehabilitated_ip</H3>$l_rehabilitated_ip_explain<BR>$l_one_ip<BR>";
512
echo "<textarea name='BL_rehabilited_ip' rows=3 cols=40>";
513
echo_file ($dir_dg."exceptioniplist");
1936 richard 514
echo "</textarea></td></tr>";
1488 richard 515
echo "<tr><td valign='middle' align='left' colspan=10>";
516
echo "<center><b>$l_add_to_bl</b></center></td></tr>";
1925 richard 517
echo "<tr><td width=100% colspan=10 align=center>";
2953 rexy 518
echo "$l_one_dns_ip<br>$l_add_example<br>";
1936 richard 519
echo "<textarea name='OSSI_bl' rows=3 cols=40>";
520
echo_file ($dir_blacklist."ossi-bl/domains");
1488 richard 521
echo "</textarea></td>";
1925 richard 522
echo "</tr><tr><td colspan=10>";
3028 rexy 523
echo "<input type='submit' onClick=\"this.disabled=true; document.getElementById('ldoverlay').style.display='block'; this.value='$l_load';submit();\" value='$l_record'>";
2150 richard 524
echo "</td></tr></table><br>";
1488 richard 525
echo "</form> ($l_wait)";
526
?>
527
<table width="100%" border="0" cellspacing="0" cellpadding="0">
1665 richard 528
	<tr><th><?php echo $l_additional_file_title; ?></th></tr>
1488 richard 529
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
530
</table>
531
<table width="100%" border=1 cellspacing=0 cellpadding=1>
532
<?php
533
echo "<tr><td width=50% colspan=5 align=center>";
534
echo "<H3>$l_file_list</H3>";
2150 richard 535
echo "<form action='bl_filter.php' method='POST'>";
536
echo "<input type='hidden' name='choix' value='MAJ_ossi_file'>";
2769 rexy 537
echo "<table cellspacing=2 cellpadding=3 border=1><tr><th>$l_file_name<th>$l_nb_ip<th>$l_nb_domain_names<th colspan=3>$l_file_action</tr>";
1936 richard 538
//list OSSI custom categories
539
$fichiersbl = array_diff(scandir($dir_blacklist), array('..','.','ossi-bl','ossi-wl'));
1940 richard 540
$fichiersbl = preg_grep("/^ossi-bl-/",$fichiersbl);
3173 rexy 541
foreach ($fichiersbl as $fichier => $value)
1488 richard 542
{
2150 richard 543
	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'";
1954 richard 544
	if (file_exists ($dir_bl_domain_names_enabled.$value)) echo " value='$l_disable'>"; else echo " value='$l_enable'>";
2769 rexy 545
	echo "</center></td><td><center><input type='submit' name='$value' value='$l_remove'></center></td>";
546
	if (in_array($value,$updateable_ossi_bls)) echo "<td><center><input type='submit' name='$value' value='$l_update'></center></td>"; else echo "<td><center>$l_no_update_configured</center></td>";
547
	echo "</tr>";
1488 richard 548
}
2769 rexy 549
 
550
echo "</table>";
551
echo "</form><br></td>";
2150 richard 552
echo "<td width=50% colspan=5 align=center><H3>$l_add_file</H3>";
2953 rexy 553
echo "$l_add_file_explain<br>$l_add_example";
2150 richard 554
echo "<form action='bl_filter.php' method='POST' enctype='multipart/form-data'>";
555
echo "<input type='hidden' name='choix' value='MAJ_ossi_file_upload'>";
1488 richard 556
echo "<input type='file' name='fichier_ip'>";
3028 rexy 557
echo "<input type='submit' onClick=\"this.disabled=true; document.getElementById('ldoverlay').style.display='block'; this.value='$l_load';submit();\" value='$l_submit'>";
2150 richard 558
echo "</form>";
1488 richard 559
echo "</td></tr>";
2150 richard 560
echo "</table><br>";
2769 rexy 561
 
562
// Autoupdate Section
563
// ----------------------
564
echo '<table width="100%" border="0" cellspacing="0" cellpadding="0">';
565
echo '  <tr><th>'.$l_update_cat_header.'</th></tr>';
566
echo '	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>';
567
echo '</table>';
568
 
569
echo "<form action='bl_filter.php' method='POST'>";
570
echo "<input type='hidden' name='choix' value='Autoupdate'>";
1488 richard 571
?>
2769 rexy 572
<table width="100%" border=1 cellspacing=0 cellpadding=1>
573
<tr><td>
574
<?php
575
echo "<table cellspacing=2 cellpadding=3 border=1>";
576
echo "<tr>";
577
 
578
// general BL
579
$update_select = ["", ""];
580
if ( 0 == filesize( $update_file_cat ) ) $update_select[0] = "checked";
581
else $update_select[1] = "checked";
582
echo "<td>".$l_update_cat."</td>";
583
echo "<td><input type='radio' name='update_cat' value=0 ".$update_select[0]." >".$l_disable;
584
echo "<input type='radio' name='update_cat' value=1 ".$update_select[1]." >".$l_enable;
585
echo "</td>";
586
// Display update checkbox for each updateable ossi-bl
3173 rexy 587
foreach ($updateable_ossi_bls as $value)
2769 rexy 588
{
589
    //check if autoupdate is enabled
590
    $update_ossi_select = ["", ""];
591
    if ( strpos(file_get_contents($update_file_ossi_cat),$value) !== false ) $update_ossi_select[1] = "checked";
592
    else $update_ossi_select[0] = "checked";
593
    echo "<tr><td>".$value."</td>";
594
	echo "<td><input type='radio' name='".$value."' value=0 ".$update_ossi_select[0]." >".$l_disable;
595
	echo "<input type='radio' name='".$value."' value=1 ".$update_ossi_select[1]." >".$l_enable."</td>";
596
    echo "</tr>";
597
}
598
echo "</tr></td><br />";
599
echo "</table>";
600
echo "<input type='submit' value='$l_record'></center>";
601
echo "</table>";
602
echo "</form>";
603
?>
1488 richard 604
<table width="100%" border="0" cellspacing="0" cellpadding="0">
605
	<tr><th><?php echo $l_specific_filtering; ?></th></tr>
606
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
607
</table>
608
<FORM action='bl_filter.php' method='POST'>
609
<input type='hidden' name='choix' value='Specific_filtering'>
2150 richard 610
<table width="100%" border=1 cellspacing=0 cellpadding=1>
1488 richard 611
<tr><td>
2688 lucas.echa 612
<input type='checkbox' name='chk-ip' <?= $bl_pureip == 'on' ? 'checked' : ''; ?>><?= $l_ip_filtering; ?>
1488 richard 613
</td></tr>
614
<tr><td>
2688 lucas.echa 615
<input type='checkbox' name='chk-safesearch' <?= $bl_safesearch == 'on' ? 'checked' : ''; ?>><?= $l_safe_searching; ?>
616
</tr></td>
617
<tr><td>
3028 rexy 618
<?= "<input type='submit' onClick=\"this.disabled=true; document.getElementById('ldoverlay').style.display='block'; this.value='$l_load';submit();\" value='$l_record'>"; ?>
2688 lucas.echa 619
</td></tr>
2150 richard 620
</table>
2648 lucas.echa 621
</form>
318 richard 622
</BODY>
623
</HTML>