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