Subversion Repositories ALCASAR

Rev

Rev 3028 | Rev 3179 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 3028 Rev 3173
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 WL filtering</TITLE>
5
<TITLE>ALCASAR DNS WL filtering</TITLE>
6
<link rel="stylesheet" href="/css/acc.css" type="text/css">
6
<link rel="stylesheet" href="/css/acc.css" type="text/css">
7
</HEAD>
7
</HEAD>
8
<body>
8
<body>
9
<div id="ldoverlay" class="overlay">
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>
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>
11
</div>
12
<?
12
<?
13
function form_filter ($form_content)
13
function form_filter ($form_content)
14
{
14
{
15
	// réencodage iso + format unix + rc fin de ligne (ouf...)
15
	// réencodage iso + format unix + rc fin de ligne (ouf...)
16
	$list = str_replace("\r\n", "\n", utf8_decode($form_content));
16
	$list = str_replace("\r\n", "\n", utf8_decode($form_content));
17
	if (strlen($list) != 0){
17
	if (strlen($list) != 0){
18
		if ($list[strlen($list)-1] != "\n") { $list[strlen($list)]="\n";} ;} ;
18
		if ($list[strlen($list)-1] != "\n") { $list[strlen($list)]="\n";} ;} ;
19
	return $list;
19
	return $list;
20
}
20
}
21
function form_filter_ip($form_content, $color)
21
function form_filter_ip($form_content, $color)
22
{
22
{
23
	//# reconstruction des ip
23
	//# reconstruction des ip
24
	$list = explode("\n", form_filter($form_content));
24
	$list = explode("\n", form_filter($form_content));
25
	$new_list = "";
25
	$new_list = "";
26
	foreach($list as &$value)
26
	foreach ($list as &$value)
27
	{
27
	{
28
		if(preg_match('/([0-9]{1,3}.){3}[0-9]{1,3}/', $value))
28
		if(preg_match('/([0-9]{1,3}.){3}[0-9]{1,3}/', $value))
29
		{
29
		{
30
			$new_list = $new_list.$value."\n";
30
			$new_list = $new_list.$value."\n";
31
		}
31
		}
32
	}
32
	}
33
	if($color == "white")
33
	if($color == "white")
34
	{
34
	{
35
		return preg_replace("/(.*)\n/", "add wl_ip_allowed $1\n", $new_list);
35
		return preg_replace("/(.*)\n/", "add wl_ip_allowed $1\n", $new_list);
36
	}
36
	}
37
	else
37
	else
38
	{
38
	{
39
		return preg_replace("/(.*)\n/", "add bl_ip_blocked $1\n", $new_list);
39
		return preg_replace("/(.*)\n/", "add bl_ip_blocked $1\n", $new_list);
40
	}
40
	}
41
}
41
}
42
function echo_file ($filename)
42
function echo_file ($filename)
43
{
43
{
44
	if (file_exists($filename))
44
	if (file_exists($filename))
45
	{
45
	{
46
		if (filesize($filename) != 0)
46
		if (filesize($filename) != 0)
47
		{
47
		{
48
			$pointeur=fopen($filename,"r");
48
			$pointeur=fopen($filename,"r");
49
			$tampon = fread($pointeur, filesize($filename));
49
			$tampon = fread($pointeur, filesize($filename));
50
			fclose($pointeur);
50
			fclose($pointeur);
51
			echo $tampon;
51
			echo $tampon;
52
		}
52
		}
53
	}
53
	}
54
	else
54
	else
55
	{
55
	{
56
		echo "$filename doesn't exist";
56
		echo "$filename doesn't exist";
57
	}
57
	}
58
}
58
}
59
function echo_ip_file ($filename)
59
function echo_ip_file ($filename)
60
{
60
{
61
	$filename = escapeshellarg($filename);
61
	$filename = escapeshellarg($filename);
62
	exec("cat $filename | cut -d ' ' -f3", $resultat);
62
	exec("cat $filename | cut -d ' ' -f3", $resultat);
63
	for($i=0; $i<exec("wc -l $filename"); $i++)
63
	for($i=0; $i<exec("wc -l $filename"); $i++)
64
	{
64
	{
65
		echo $resultat[$i]."\n";
65
		echo $resultat[$i]."\n";
66
	}
66
	}
67
}
67
}
68
 
68
 
69
# Choice of language
69
# Choice of language
70
$Language = 'en';
70
$Language = 'en';
71
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
71
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
72
	$Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
72
	$Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
73
	$Language = strtolower(substr(chop($Langue[0]),0,2));
73
	$Language = strtolower(substr(chop($Langue[0]),0,2));
74
}
74
}
75
if($Language == 'fr'){
75
if($Language == 'fr'){
76
	$l_wl="Liste blanche principale";
76
	$l_wl="Liste blanche principale";
77
	$l_load="Chargement...";
77
	$l_load="Chargement...";
78
	$l_list_version="Version de la liste : ";
78
	$l_list_version="Version de la liste : ";
79
	$l_wl_categories="Sélectionnez les catégories à autoriser";
79
	$l_wl_categories="Sélectionnez les catégories à autoriser";
80
	$l_specific_filtering="Filtrage special";
80
	$l_specific_filtering="Filtrage special";
81
	$l_add_to_wl="Noms de domaine ou adresses IP à ajouter à la liste blanche";
81
	$l_add_to_wl="Noms de domaine ou adresses IP à ajouter à la liste blanche";
82
	$l_one_dns_ip="Entrez un nom de domaine ou une adresse IP ou une adresse de réseau par ligne<br>exemple (domaine) : domaine.org. - exemple (ip) : 61.54.52.56 - exemple (réseau) : 172.16.0.0/16";
82
	$l_one_dns_ip="Entrez un nom de domaine ou une adresse IP ou une adresse de réseau par ligne<br>exemple (domaine) : domaine.org. - exemple (ip) : 61.54.52.56 - exemple (réseau) : 172.16.0.0/16";
83
	$l_record="Enregistrer les modifications";
83
	$l_record="Enregistrer les modifications";
84
	$l_wait="Une fois validées, 10 secondes sont nécessaires pour traiter vos modifications";
84
	$l_wait="Une fois validées, 10 secondes sont nécessaires pour traiter vos modifications";
85
	$l_safe_searching="Activer le contrôle scolaire/parental pour 'YouTube' et pour les moteurs de recherche 'Google', 'Bing' et 'Qwant'.";
85
	$l_safe_searching="Activer le contrôle scolaire/parental pour 'YouTube' et pour les moteurs de recherche 'Google', 'Bing' et 'Qwant'.";
86
	$l_error_open_file="Erreur d'ouverture du fichier";
86
	$l_error_open_file="Erreur d'ouverture du fichier";
87
	$l_additional_file_title="Fichiers de 'listes blanches' additionnels";
87
	$l_additional_file_title="Fichiers de 'listes blanches' additionnels";
88
	$l_file_list="Liste des fichiers";
88
	$l_file_list="Liste des fichiers";
89
	$l_add_file="Ajouter un fichier";
89
	$l_add_file="Ajouter un fichier";
90
	$l_add_file_explain="Chaque ligne du fichier doit être une adresse IP ou un nom de domaine";
90
	$l_add_file_explain="Chaque ligne du fichier doit être une adresse IP ou un nom de domaine";
91
	$l_file_name="Nom du fichier";
91
	$l_file_name="Nom du fichier";
92
	$l_file_action="Action";
92
	$l_file_action="Action";
93
	$l_error_upload="Erreur d'envoi du fichier";
93
	$l_error_upload="Erreur d'envoi du fichier";
94
	$l_remove="Supprimer";
94
	$l_remove="Supprimer";
95
	$l_submit="Envoyer";
95
	$l_submit="Envoyer";
96
	$l_nb_ip="Nombre d'IP";
96
	$l_nb_ip="Nombre d'IP";
97
	$l_nb_domain_names="Nombre de noms de domaine";
97
	$l_nb_domain_names="Nombre de noms de domaine";
98
	$l_nbDomainNames="Noms de domaine :";
98
	$l_nbDomainNames="Noms de domaine :";
99
	$l_nbUrl="Url :";
99
	$l_nbUrl="Url :";
100
	$l_nbIp="Ip :";
100
	$l_nbIp="Ip :";
101
	$l_disable="Désactiver";
101
	$l_disable="Désactiver";
102
	$l_enable="Activer";
102
	$l_enable="Activer";
103
	$l_file_state="Etat";
103
	$l_file_state="Etat";
104
} else if($Language == 'es') {
104
} else if($Language == 'es') {
105
	$l_wl="Lista blanca principal";
105
	$l_wl="Lista blanca principal";
106
	$l_load="Cargando...";
106
	$l_load="Cargando...";
107
	$l_list_version="Versión de la lista: ";
107
	$l_list_version="Versión de la lista: ";
108
	$l_wl_categories="Seleccione las categorías permitidas";
108
	$l_wl_categories="Seleccione las categorías permitidas";
109
	$l_specific_filtering="Filtrado específico";
109
	$l_specific_filtering="Filtrado específico";
110
	$l_add_to_wl="Nombres de dominio o direcciones IP para agregar a la lista blanca";
110
	$l_add_to_wl="Nombres de dominio o direcciones IP para agregar a la lista blanca";
111
	$l_one_dns_ip="Ingrese un nombre de dominio o una dirección IP o una dirección de red por línea <br> ejemplo (dominio): dominio.org. - ejemplo (IP): 61.54.56.52 - ejemplo (red): 172.16.0.0/16";
111
	$l_one_dns_ip="Ingrese un nombre de dominio o una dirección IP o una dirección de red por línea <br> ejemplo (dominio): dominio.org. - ejemplo (IP): 61.54.56.52 - ejemplo (red): 172.16.0.0/16";
112
	$l_record="Guardar cambios";
112
	$l_record="Guardar cambios";
113
	$l_wait="Una vez validado, son necesarios 10 segundos para aplicar sus modificaciones";
113
	$l_wait="Una vez validado, son necesarios 10 segundos para aplicar sus modificaciones";
114
	$l_safe_searching="Habilitación del control escolar / parental para 'YouTube' y para los motores de búsqueda 'Google', 'Bing' y 'Qwant'";
114
	$l_safe_searching="Habilitación del control escolar / parental para 'YouTube' y para los motores de búsqueda 'Google', 'Bing' y 'Qwant'";
115
	$l_error_open_file="Error abriendo el archivo";
115
	$l_error_open_file="Error abriendo el archivo";
116
	$l_additional_file_title="Archivos adicionales de Lista Blanca";
116
	$l_additional_file_title="Archivos adicionales de Lista Blanca";
117
	$l_file_list="Lista de archivos";
117
	$l_file_list="Lista de archivos";
118
	$l_add_file="Agregar un archivo";
118
	$l_add_file="Agregar un archivo";
119
	$l_add_file_explain="Cada línea del archivo debe ser una dirección IP o un nombre de dominio";
119
	$l_add_file_explain="Cada línea del archivo debe ser una dirección IP o un nombre de dominio";
120
	$l_file_name="Nombre de archivo";
120
	$l_file_name="Nombre de archivo";
121
	$l_file_action="Acción";
121
	$l_file_action="Acción";
122
	$l_error_upload="Error durante el proceso de carga";
122
	$l_error_upload="Error durante el proceso de carga";
123
	$l_remove="Borrar";
123
	$l_remove="Borrar";
124
	$l_submit="Enviar";
124
	$l_submit="Enviar";
125
	$l_nb_ip="Número de IPs";
125
	$l_nb_ip="Número de IPs";
126
	$l_nb_domain_names="Número de sitios";
126
	$l_nb_domain_names="Número de sitios";
127
	$l_nbDomainNames="Sitios:";
127
	$l_nbDomainNames="Sitios:";
128
	$l_nbUrl="Url :";
128
	$l_nbUrl="Url :";
129
	$l_nbIp="Ip :";
129
	$l_nbIp="Ip :";
130
	$l_disable="Desactivar";
130
	$l_disable="Desactivar";
131
	$l_enable="Activar";
131
	$l_enable="Activar";
132
	$l_file_state="Estado";
132
	$l_file_state="Estado";
133
} else {
133
} else {
134
	$l_wl="Main WhiteList";
134
	$l_wl="Main WhiteList";
135
	$l_load="Loading...";
135
	$l_load="Loading...";
136
	$l_list_version="List version : ";
136
	$l_list_version="List version : ";
137
	$l_wl_categories="Select the allowed categories";
137
	$l_wl_categories="Select the allowed categories";
138
	$l_specific_filtering="Specific filtering";
138
	$l_specific_filtering="Specific filtering";
139
	$l_add_to_wl="Domain names or IP addresses to add to the whitelist";
139
	$l_add_to_wl="Domain names or IP addresses to add to the whitelist";
140
	$l_one_dns_ip="Enter one domain name or one IP address or one network address per row <br>example (domain): domain.org. - example (ip): 61.54.56.52 - example (network) : 172.16.0.0/16";
140
	$l_one_dns_ip="Enter one domain name or one IP address or one network address per row <br>example (domain): domain.org. - example (ip): 61.54.56.52 - example (network) : 172.16.0.0/16";
141
	$l_record="Save changes";
141
	$l_record="Save changes";
142
	$l_wait="Once validated, 10 seconds are necessary to compute your modifications";
142
	$l_wait="Once validated, 10 seconds are necessary to compute your modifications";
143
	$l_safe_searching="Enabling school/parental control for 'YouTube' and for the search engines 'Google', 'Bing' and 'Qwant'";
143
	$l_safe_searching="Enabling school/parental control for 'YouTube' and for the search engines 'Google', 'Bing' and 'Qwant'";
144
	$l_error_open_file="Error opening file";
144
	$l_error_open_file="Error opening file";
145
	$l_additional_file_title="Additional WhiteList files";
145
	$l_additional_file_title="Additional WhiteList files";
146
	$l_file_list="Files list";
146
	$l_file_list="Files list";
147
	$l_add_file="Add a file";
147
	$l_add_file="Add a file";
148
	$l_add_file_explain="Each line of the file must be an IP address or a domain name";
148
	$l_add_file_explain="Each line of the file must be an IP address or a domain name";
149
	$l_file_name="Filename";
149
	$l_file_name="Filename";
150
	$l_file_action="Action";
150
	$l_file_action="Action";
151
	$l_error_upload="Error during the upload process";
151
	$l_error_upload="Error during the upload process";
152
	$l_remove="Delete";
152
	$l_remove="Delete";
153
	$l_submit="Submit";
153
	$l_submit="Submit";
154
	$l_nb_ip="Number of IP";
154
	$l_nb_ip="Number of IP";
155
	$l_nb_domain_names="Number of domain names";
155
	$l_nb_domain_names="Number of domain names";
156
	$l_nbDomainNames="Domain names :";
156
	$l_nbDomainNames="Domain names :";
157
	$l_nbUrl="Url :";
157
	$l_nbUrl="Url :";
158
	$l_nbIp="Ip :";
158
	$l_nbIp="Ip :";
159
	$l_disable="Disable";
159
	$l_disable="Disable";
160
	$l_enable="Enable";
160
	$l_enable="Enable";
161
	$l_file_state="State";
161
	$l_file_state="State";
162
}
162
}
163
$dir_etc="/usr/local/etc/";
163
$dir_etc="/usr/local/etc/";
164
$dir_dg="/etc/e2guardian/lists/";
164
$dir_dg="/etc/e2guardian/lists/";
165
$dir_blacklist=$dir_dg."blacklists/";
165
$dir_blacklist=$dir_dg."blacklists/";
166
$dir_wl_ip="/usr/local/share/iptables-wl/";
166
$dir_wl_ip="/usr/local/share/iptables-wl/";
167
$dir_wl_ip_enabled= "/usr/local/share/iptables-wl-enabled/";
167
$dir_wl_ip_enabled= "/usr/local/share/iptables-wl-enabled/";
168
$dir_wl_domain_names= "/usr/local/share/unbound-wl/";
168
$dir_wl_domain_names= "/usr/local/share/unbound-wl/";
169
$dir_wl_domain_names_enabled= "/usr/local/share/unbound-wl-enabled/";
169
$dir_wl_domain_names_enabled= "/usr/local/share/unbound-wl-enabled/";
170
$wl_categories=$dir_etc."alcasar-wl-categories";
170
$wl_categories=$dir_etc."alcasar-wl-categories";
171
$wl_categories_enabled=$dir_etc."alcasar-wl-categories-enabled";
171
$wl_categories_enabled=$dir_etc."alcasar-wl-categories-enabled";
172
$conf_file=$dir_etc."alcasar.conf";
172
$conf_file=$dir_etc."alcasar.conf";
173
$domainfilter_file="/etc/unbound/conf.d/whitelist/domainfilter.conf";
173
$domainfilter_file="/etc/unbound/conf.d/whitelist/domainfilter.conf";
174
$bannedsite_file=$dir_dg."bannedsitelist";
174
$bannedsite_file=$dir_dg."bannedsitelist";
175
$dir_tmp="/tmp/blacklists";
175
$dir_tmp="/tmp/blacklists";
176
 
176
 
177
$wl_safesearch="off";
177
$wl_safesearch="off";
178
 
178
 
179
# default values
179
# default values
180
if (is_file ($conf_file))
180
if (is_file ($conf_file))
181
{
181
{
182
	$tab=file($conf_file);
182
	$tab=file($conf_file);
183
	if ($tab)
183
	if ($tab)
184
	{
184
	{
185
		foreach ($tab as $line)
185
		foreach ($tab as $line)
186
		{
186
		{
187
			$field=explode("=", $line);
187
			$field=explode("=", $line);
188
			switch ($field[0]) {
188
			switch ($field[0]) {
189
				case 'PRIVATE_IP':
189
				case 'PRIVATE_IP':
190
					$PRIVATE_IP_MASK=trim($field[1]);
190
					$PRIVATE_IP_MASK=trim($field[1]);
191
					$tmp = explode("/",$PRIVATE_IP_MASK);
191
					$tmp = explode("/",$PRIVATE_IP_MASK);
192
					$PRIVATE_IP=$tmp[0];
192
					$PRIVATE_IP=$tmp[0];
193
					break;
193
					break;
194
 
194
 
195
				case 'WL_SAFESEARCH':
195
				case 'WL_SAFESEARCH':
196
					if (strtolower(trim($field[1])) == 'on') {
196
					if (strtolower(trim($field[1])) == 'on') {
197
						$wl_safesearch='on';
197
						$wl_safesearch='on';
198
					}
198
					}
199
					break;
199
					break;
200
			}
200
			}
201
		}
201
		}
202
	}
202
	}
203
}
203
}
204
else { echo "$l_error_open_file $conf_file";}
204
else { echo "$l_error_open_file $conf_file";}
205
if (isset($_POST['choix'])){ $choix=$_POST['choix']; } else { $choix=""; }
205
if (isset($_POST['choix'])){ $choix=$_POST['choix']; } else { $choix=""; }
206
switch ($choix)
206
switch ($choix)
207
{
207
{
208
	case 'Download_list' :
208
	case 'Download_list' :
209
		exec ("sudo /usr/local/bin/alcasar-bl.sh --download");
209
		exec ("sudo /usr/local/bin/alcasar-bl.sh --download");
210
		break;
210
		break;
211
	case 'Active_list' :
211
	case 'Active_list' :
212
		exec ("sudo /usr/local/bin/alcasar-bl.sh --adapt");
212
		exec ("sudo /usr/local/bin/alcasar-bl.sh --adapt");
213
		exec ("sudo /usr/local/bin/alcasar-bl.sh --reload");
213
		exec ("sudo /usr/local/bin/alcasar-bl.sh --reload");
214
		break;
214
		break;
215
	case 'Reject_list' :
215
	case 'Reject_list' :
216
		unlink ("$dir_tmp/blacklists.tar.gz"); unlink ("$dir_tmp/md5sum");
216
		unlink ("$dir_tmp/blacklists.tar.gz"); unlink ("$dir_tmp/md5sum");
217
		break;
217
		break;
218
	case 'MAJ_cat_wl' :
218
	case 'MAJ_cat_wl' :
219
		if (file_exists($wl_categories_enabled))
219
		if (file_exists($wl_categories_enabled))
220
		{
220
		{
221
			exec("/bin/sed -i \"/^ossi-/!d\" $wl_categories_enabled"); // keep ossi custom categories
221
			exec("/bin/sed -i \"/^ossi-/!d\" $wl_categories_enabled"); // keep ossi custom categories
222
			$pointeur=fopen($wl_categories_enabled, "a+");
222
			$pointeur=fopen($wl_categories_enabled, "a+");
223
			foreach ($_POST as $key => $value)
223
			foreach ($_POST as $key => $value)
224
			{
224
			{
225
				if (strstr($key,'chk-'))
225
				if (strstr($key,'chk-'))
226
				{
226
				{
227
					$line=str_replace('chk-','',$key)."\n";
227
					$line=str_replace('chk-','',$key)."\n";
228
					fwrite($pointeur,$line);
228
					fwrite($pointeur,$line);
229
				}
229
				}
230
			}
230
			}
231
 
231
 
232
			fclose($pointeur);
232
			fclose($pointeur);
233
		}
233
		}
234
		else {echo "$l_error_open_file $wl_categories_enabled";}
234
		else {echo "$l_error_open_file $wl_categories_enabled";}
235
		$fichier=fopen($dir_blacklist."ossi-wl/domains","w+");
235
		$fichier=fopen($dir_blacklist."ossi-wl/domains","w+");
236
		fputs($fichier, form_filter($_POST['OSSI_wl']));
236
		fputs($fichier, form_filter($_POST['OSSI_wl']));
237
		fclose($fichier);
237
		fclose($fichier);
238
		unset($_POST['OSSI_wl']);
238
		unset($_POST['OSSI_wl']);
239
		exec ("sudo /usr/local/bin/alcasar-bl.sh --reload");
239
		exec ("sudo /usr/local/bin/alcasar-bl.sh --reload");
240
		break;
240
		break;
241
	case 'Specific_filtering' :
241
	case 'Specific_filtering' :
242
		$wl_safesearch='off';
242
		$wl_safesearch='off';
243
		foreach ($_POST as $key => $value)
243
		foreach ($_POST as $key => $value)
244
		{
244
		{
245
			if (strstr($key,'chk-safesearch')) {
245
			if (strstr($key,'chk-safesearch')) {
246
				$wl_safesearch='on';
246
				$wl_safesearch='on';
247
			}
247
			}
248
		}
248
		}
249
		exec ("sudo /usr/local/bin/alcasar-url_filter_wl.sh -safesearch_$wl_safesearch");
249
		exec ("sudo /usr/local/bin/alcasar-url_filter_wl.sh -safesearch_$wl_safesearch");
250
		break;
250
		break;
251
	case 'MAJ_ossi_file' :
251
	case 'MAJ_ossi_file' :
252
		foreach($_POST as $fichier => $value)
252
		foreach ($_POST as $fichier => $value)
253
		{
253
		{
254
			if($fichier != "choix")
254
			if($fichier != "choix")
255
			{
255
			{
256
				$action=$_POST[$fichier];
256
				$action=$_POST[$fichier];
257
				if($action == $l_remove) //delete
257
				if($action == $l_remove) //delete
258
				{
258
				{
259
					exec("/bin/sed -i ".escapeshellarg("/^$fichier\$/d")." $wl_categories_enabled");
259
					exec("/bin/sed -i ".escapeshellarg("/^$fichier\$/d")." $wl_categories_enabled");
260
					exec("/bin/sed -i ".escapeshellarg("/^$fichier\$/d")." $wl_categories");
260
					exec("/bin/sed -i ".escapeshellarg("/^$fichier\$/d")." $wl_categories");
261
					exec("rm -rf ".escapeshellarg("$dir_blacklist$fichier"));
261
					exec("rm -rf ".escapeshellarg("$dir_blacklist$fichier"));
262
					exec("sudo /usr/local/bin/alcasar-bl.sh --reload");
262
					exec("sudo /usr/local/bin/alcasar-bl.sh --reload");
263
				}
263
				}
264
				if($action == $l_disable) //disable
264
				if($action == $l_disable) //disable
265
				{
265
				{
266
					exec("/bin/sed -i ".escapeshellarg("/^$fichier\$/d")." $wl_categories_enabled");
266
					exec("/bin/sed -i ".escapeshellarg("/^$fichier\$/d")." $wl_categories_enabled");
267
					exec("sudo /usr/local/bin/alcasar-bl.sh --reload");
267
					exec("sudo /usr/local/bin/alcasar-bl.sh --reload");
268
				}
268
				}
269
				if($action == $l_enable) //enable
269
				if($action == $l_enable) //enable
270
				{
270
				{
271
					file_put_contents($wl_categories_enabled, $fichier."\n", FILE_APPEND);
271
					file_put_contents($wl_categories_enabled, $fichier."\n", FILE_APPEND);
272
					exec("sudo /usr/local/bin/alcasar-bl.sh --reload");
272
					exec("sudo /usr/local/bin/alcasar-bl.sh --reload");
273
				}
273
				}
274
			}
274
			}
275
		}
275
		}
276
		break;
276
		break;
277
	case 'MAJ_ossi_file_upload' :
277
	case 'MAJ_ossi_file_upload' :
278
		$file_name = str_replace (".", "_",basename($_FILES['fichier_ip']['name']));
278
		$file_name = str_replace (".", "_",basename($_FILES['fichier_ip']['name']));
279
		if(!empty($file_name))
279
		if(!empty($file_name))
280
		{
280
		{
281
			$dest_dir = $dir_blacklist."ossi-wl-".$file_name;
281
			$dest_dir = $dir_blacklist."ossi-wl-".$file_name;
282
			exec("mkdir ".escapeshellarg($dest_dir));
282
			exec("mkdir ".escapeshellarg($dest_dir));
283
			$file=$_FILES['fichier_ip']['tmp_name'];
283
			$file=$_FILES['fichier_ip']['tmp_name'];
284
			exec('/usr/bin/dos2unix '.escapeshellarg($file));
284
			exec('/usr/bin/dos2unix '.escapeshellarg($file));
285
			if(move_uploaded_file($_FILES['fichier_ip']['tmp_name'], $dest_dir."/domains"))
285
			if(move_uploaded_file($_FILES['fichier_ip']['tmp_name'], $dest_dir."/domains"))
286
			{
286
			{
287
				touch ($dest_dir."/urls"); // create the URL file even if it isn't used
287
				touch ($dest_dir."/urls"); // create the URL file even if it isn't used
288
				file_put_contents ($wl_categories, $dest_dir."\n", FILE_APPEND);
288
				file_put_contents ($wl_categories, $dest_dir."\n", FILE_APPEND);
289
				file_put_contents ($wl_categories_enabled, "ossi-wl-".$file_name."\n", FILE_APPEND); //Enabled by default
289
				file_put_contents ($wl_categories_enabled, "ossi-wl-".$file_name."\n", FILE_APPEND); //Enabled by default
290
				exec ("sudo /usr/local/bin/alcasar-bl.sh --reload");
290
				exec ("sudo /usr/local/bin/alcasar-bl.sh --reload");
291
			}
291
			}
292
			else
292
			else
293
			{
293
			{
294
				exec("rm -rf ".escapeshellarg($dest_dir));
294
				exec("rm -rf ".escapeshellarg($dest_dir));
295
				echo $l_error_upload;
295
				echo $l_error_upload;
296
			}
296
			}
297
		}
297
		}
298
		break;
298
		break;
299
}
299
}
300
?>
300
?>
301
<table width="100%" border="0" cellspacing="0" cellpadding="0">
301
<table width="100%" border="0" cellspacing="0" cellpadding="0">
302
	<tr><th><?php echo $l_wl; ?></th></tr>
302
	<tr><th><?php echo $l_wl; ?></th></tr>
303
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
303
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
304
</table>
304
</table>
305
<table width="100%" border=1 cellspacing=0 cellpadding=1>
305
<table width="100%" border=1 cellspacing=0 cellpadding=1>
306
<tr><td valign="middle" align="left" colspan=10>
306
<tr><td valign="middle" align="left" colspan=10>
307
<FORM action='wl_filter.php' method=POST>
307
<FORM action='wl_filter.php' method=POST>
308
<input type='hidden' name='choix' value='MAJ_cat_wl'>
308
<input type='hidden' name='choix' value='MAJ_cat_wl'>
309
<?php
309
<?php
310
echo "<center>";
310
echo "<center>";
311
// total number of IP, DNS & URLs
311
// total number of IP, DNS & URLs
312
$nbDomainNames = exec("wc -l $dir_wl_domain_names* | tail -n 1 | awk '{print $1}'");
312
$nbDomainNames = exec("wc -l $dir_wl_domain_names* | tail -n 1 | awk '{print $1}'");
313
$nbUrl = "0";
313
$nbUrl = "0";
314
$nbIp = exec("wc -l $dir_wl_ip* | tail -n 1 | awk '{print $1}'");
314
$nbIp = exec("wc -l $dir_wl_ip* | tail -n 1 | awk '{print $1}'");
315
echo "<b>$l_nbDomainNames</b> $nbDomainNames, <b>$l_nbUrl</b> $nbUrl, <b>$l_nbIp</b> $nbIp<br/>";
315
echo "<b>$l_nbDomainNames</b> $nbDomainNames, <b>$l_nbUrl</b> $nbUrl, <b>$l_nbIp</b> $nbIp<br/>";
316
echo "$l_wl_categories</center></td></tr>";
316
echo "$l_wl_categories</center></td></tr>";
317
//read & display all WL categories (checked or not)
317
//read & display all WL categories (checked or not)
318
$cols=1;
318
$cols=1;
319
if (file_exists($wl_categories))
319
if (file_exists($wl_categories))
320
{
320
{
321
	$wl_files = file($wl_categories);
321
	$wl_files = file($wl_categories);
322
	$wl_files = preg_grep("/ossi-/", $wl_files, 1); // don't display ossi custom categories
322
	$wl_files = preg_grep("/ossi-/", $wl_files, 1); // don't display ossi custom categories
323
	foreach($wl_files as $fichier => $value)
323
	foreach ($wl_files as $fichier => $value)
324
	{
324
	{
325
		if ($cols == 1) { echo "<tr>";}
325
		if ($cols == 1) { echo "<tr>";}
326
		$categorie=trim(basename($value));
326
		$categorie=trim(basename($value));
327
		echo "<td><a href='bl_categories_help.php?liste=wl&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>";
327
		echo "<td><a href='bl_categories_help.php?liste=wl&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>";
328
		echo "<input type='checkbox' name='chk-$categorie'";
328
		echo "<input type='checkbox' name='chk-$categorie'";
329
		// if the line is commented, the category is disable
329
		// if the line is commented, the category is disable
330
		if (preg_match('/^#/',$value, $r)) { echo ">";}
330
		if (preg_match('/^#/',$value, $r)) { echo ">";}
331
		else { echo "checked>"; }
331
		else { echo "checked>"; }
332
		echo "</td>";
332
		echo "</td>";
333
		$cols++;
333
		$cols++;
334
		if ($cols > 10) {
334
		if ($cols > 10) {
335
			echo "</tr>";
335
			echo "</tr>";
336
			$cols=1;
336
			$cols=1;
337
		}
337
		}
338
	}
338
	}
339
}
339
}
340
else {
340
else {
341
	echo "$l_error_open_file $wl_categories";
341
	echo "$l_error_open_file $wl_categories";
342
}
342
}
343
echo "<tr><td valign='middle' align='left' colspan=10>";
343
echo "<tr><td valign='middle' align='left' colspan=10>";
344
echo "<center><b>$l_add_to_wl</b></center></td></tr>";
344
echo "<center><b>$l_add_to_wl</b></center></td></tr>";
345
echo "<tr><td width=100% colspan=10 align=center>";
345
echo "<tr><td width=100% colspan=10 align=center>";
346
echo "$l_one_dns_ip<BR>";
346
echo "$l_one_dns_ip<BR>";
347
echo "<textarea name='OSSI_wl' rows=3 cols=40>";
347
echo "<textarea name='OSSI_wl' rows=3 cols=40>";
348
echo_file ($dir_blacklist."ossi-wl/domains");
348
echo_file ($dir_blacklist."ossi-wl/domains");
349
echo "</textarea></td>";
349
echo "</textarea></td>";
350
echo "</tr><tr><td colspan=10>";
350
echo "</tr><tr><td colspan=10>";
351
echo "<input type='submit' onClick=\"this.disabled=true; document.getElementById('ldoverlay').style.display='block'; this.value='$l_load';submit();\" value='$l_record'>";
351
echo "<input type='submit' onClick=\"this.disabled=true; document.getElementById('ldoverlay').style.display='block'; this.value='$l_load';submit();\" value='$l_record'>";
352
echo "</form> ($l_wait)";
352
echo "</form> ($l_wait)";
353
echo "</td></tr></table><br/>";
353
echo "</td></tr></table><br/>";
354
?>
354
?>
355
<table width="100%" border="0" cellspacing="0" cellpadding="0">
355
<table width="100%" border="0" cellspacing="0" cellpadding="0">
356
	<tr><th><?php echo $l_additional_file_title; ?></th></tr>
356
	<tr><th><?php echo $l_additional_file_title; ?></th></tr>
357
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
357
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
358
</table>
358
</table>
359
<table width="100%" border=1 cellspacing=0 cellpadding=1>
359
<table width="100%" border=1 cellspacing=0 cellpadding=1>
360
<form action='wl_filter.php' method='POST'>
360
<form action='wl_filter.php' method='POST'>
361
<input type='hidden' name='choix' value='MAJ_ossi_file'>
361
<input type='hidden' name='choix' value='MAJ_ossi_file'>
362
<?php
362
<?php
363
echo "<tr><td width=50% colspan=5 align=center>";
363
echo "<tr><td width=50% colspan=5 align=center>";
364
echo "<H3>$l_file_list</H3>";
364
echo "<H3>$l_file_list</H3>";
365
echo "<table cellspacing=2 cellpadding=3 border=1><tr><th>$l_file_name<th>$l_nb_ip<th>$l_nb_domain_names<th colspan=2>$l_file_action</tr>";
365
echo "<table cellspacing=2 cellpadding=3 border=1><tr><th>$l_file_name<th>$l_nb_ip<th>$l_nb_domain_names<th colspan=2>$l_file_action</tr>";
366
 
366
 
367
//list OSSI custom categories
367
//list OSSI custom categories
368
$fichierswl = array_diff(scandir($dir_blacklist), array('..','.','ossi-bl','ossi-wl'));
368
$fichierswl = array_diff(scandir($dir_blacklist), array('..','.','ossi-bl','ossi-wl'));
369
$fichierswl = preg_grep("/^ossi-wl-/",$fichierswl);
369
$fichierswl = preg_grep("/^ossi-wl-/",$fichierswl);
370
foreach($fichierswl as $fichier => $value)
370
foreach ($fichierswl as $fichier => $value)
371
{
371
{
372
	echo "<tr><td><center><a href='bl_categories_help.php?liste=wl&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_wl_ip$value | cut -d\" \" -f1")."</center></td><td><center>".exec("wc -l $dir_wl_domain_names$value.conf | cut -d\" \" -f1")."</center></td><td><center><input type='submit' name='$value'";
372
	echo "<tr><td><center><a href='bl_categories_help.php?liste=wl&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_wl_ip$value | cut -d\" \" -f1")."</center></td><td><center>".exec("wc -l $dir_wl_domain_names$value.conf | cut -d\" \" -f1")."</center></td><td><center><input type='submit' name='$value'";
373
	if (file_exists ($dir_wl_domain_names_enabled.$value)) echo " value='$l_disable'>"; else echo " value='$l_enable'>";
373
	if (file_exists ($dir_wl_domain_names_enabled.$value)) echo " value='$l_disable'>"; else echo " value='$l_enable'>";
374
	echo "</center></td><td><center><input type='submit' name='$value' value='$l_remove'></center></td></tr>";
374
	echo "</center></td><td><center><input type='submit' name='$value' value='$l_remove'></center></td></tr>";
375
}
375
}
376
echo "</table><br/></td></form><form action='wl_filter.php' method='POST' enctype='multipart/form-data'>";
376
echo "</table><br/></td></form><form action='wl_filter.php' method='POST' enctype='multipart/form-data'>";
377
echo "<input type='hidden' name='choix' value='MAJ_ossi_file_upload'><td width=50% colspan=5 align=center>";
377
echo "<input type='hidden' name='choix' value='MAJ_ossi_file_upload'><td width=50% colspan=5 align=center>";
378
echo "<H3>$l_add_file</H3>";
378
echo "<H3>$l_add_file</H3>";
379
echo "$l_add_file_explain";
379
echo "$l_add_file_explain";
380
echo "<input type='file' name='fichier_ip'>";
380
echo "<input type='file' name='fichier_ip'>";
381
echo "<input type='submit' onClick=\"this.disabled=true; document.getElementById('ldoverlay').style.display='block'; this.value='$l_load';submit();\" value='$l_submit'>";
381
echo "<input type='submit' onClick=\"this.disabled=true; document.getElementById('ldoverlay').style.display='block'; this.value='$l_load';submit();\" value='$l_submit'>";
382
echo "</td></tr>";
382
echo "</td></tr>";
383
echo "</form>";
383
echo "</form>";
384
echo "</table><br/>";
384
echo "</table><br/>";
385
?>
385
?>
386
<table width="100%" border="0" cellspacing="0" cellpadding="0">
386
<table width="100%" border="0" cellspacing="0" cellpadding="0">
387
	<tr><th><?php echo $l_specific_filtering; ?></th></tr>
387
	<tr><th><?php echo $l_specific_filtering; ?></th></tr>
388
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
388
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
389
</table>
389
</table>
390
<TABLE width="100%" border=1 cellspacing=0 cellpadding=1>
390
<TABLE width="100%" border=1 cellspacing=0 cellpadding=1>
391
<FORM action='wl_filter.php' method='POST'>
391
<FORM action='wl_filter.php' method='POST'>
392
<input type='hidden' name='choix' value='Specific_filtering'>
392
<input type='hidden' name='choix' value='Specific_filtering'>
393
<tr><td>
393
<tr><td>
394
<input type='checkbox' name='chk-safesearch' <?= $wl_safesearch == 'on' ? 'checked' : ''; ?>><?= $l_safe_searching; ?>
394
<input type='checkbox' name='chk-safesearch' <?= $wl_safesearch == 'on' ? 'checked' : ''; ?>><?= $l_safe_searching; ?>
395
</tr></td>
395
</tr></td>
396
<tr><td>
396
<tr><td>
397
<?= "<input type='submit' onClick=\"this.disabled=true; document.getElementById('ldoverlay').style.display='block'; this.value='$l_load';submit();\" value='$l_record'>"; ?>
397
<?= "<input type='submit' onClick=\"this.disabled=true; document.getElementById('ldoverlay').style.display='block'; this.value='$l_load';submit();\" value='$l_record'>"; ?>
398
</td></tr></FORM>
398
</td></tr></FORM>
399
</TABLE>
399
</TABLE>
400
</BODY>
400
</BODY>
401
</HTML>
401
</HTML>
402
 
402