Subversion Repositories ALCASAR

Rev

Rev 3179 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log

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