Subversion Repositories ALCASAR

Rev

Rev 1925 | Rev 1938 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log

Rev 1925 Rev 1936
1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2
<HTML><!-- written by Rexy -->
2
<HTML><!-- written by Rexy -->
3
<HEAD>
3
<HEAD>
4
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
4
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5
<TITLE>ALCASAR DNS filtering</TITLE>
5
<TITLE>ALCASAR DNS filtering</TITLE>
6
<link rel="stylesheet" href="/css/style.css" type="text/css">
6
<link rel="stylesheet" href="/css/style.css" type="text/css">
7
</HEAD>
7
</HEAD>
8
<body>
8
<body>
9
<?
9
<?
10
function form_filter ($form_content)
10
function form_filter ($form_content)
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
	exec("cat $filename | cut -d ' ' -f3", $resultat);
58
	exec("cat $filename | cut -d ' ' -f3", $resultat);
59
	for($i=0; $i<exec("wc -l $filename"); $i++)
59
	for($i=0; $i<exec("wc -l $filename"); $i++)
60
	{
60
	{
61
		echo $resultat[$i]."\n";
61
		echo $resultat[$i]."\n";
62
	}
62
	}
63
}
63
}
64
 
64
 
65
#maximum length for top-level DNS
65
#maximum length for top-level DNS
66
function max_tld()
66
function max_tld()
67
{
67
{
68
	$url_tld = "http://data.iana.org/TLD/tlds-alpha-by-domain.txt";
68
	$url_tld = "http://data.iana.org/TLD/tlds-alpha-by-domain.txt";
69
	$result_tld = file_get_contents($url_tld,false);
69
	$result_tld = file_get_contents($url_tld,false);
70
	$max_tld = 18; 							#valeur de base si le site ne répond plus
70
	$max_tld = 18; 							#valeur de base si le site ne répond plus
71
	if($result_tld !== FALSE){
71
	if($result_tld !== FALSE){
72
		foreach(explode("\n", $result_tld) as $line)
72
		foreach(explode("\n", $result_tld) as $line)
73
		{
73
		{
74
			if((strpos($line,'-') === false) and (strpos($line,'#') === false))
74
			if((strpos($line,'-') === false) and (strpos($line,'#') === false))
75
			{
75
			{
76
				if(strlen($line) > $max_tld)
76
				if(strlen($line) > $max_tld)
77
				{
77
				{
78
					$max_tld = strlen($line);
78
					$max_tld = strlen($line);
79
				}
79
				}
80
			}
80
			}
81
		}
81
		}
82
	}
82
	}
83
	return $max_tld;
83
	return $max_tld;
84
}
84
}
85
 
85
 
86
# Choice of language
86
# Choice of language
87
$Language = 'en';
87
$Language = 'en';
88
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
88
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
89
	$Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
89
	$Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
90
	$Language = strtolower(substr(chop($Langue[0]),0,2)); 
90
	$Language = strtolower(substr(chop($Langue[0]),0,2)); 
91
	}
91
	}
92
if($Language == 'fr'){
92
if($Language == 'fr'){
93
	$l_bl="Liste noire générale";
93
	$l_bl="Liste noire générale";
94
	$l_load="Chargement...";
94
	$l_load="Chargement...";
95
	$l_list_version="Version de la liste : ";
95
	$l_list_version="Version de la liste : ";
96
	$l_bl_categories="Sélectionnez les catégories à filtrer";
96
	$l_bl_categories="Sélectionnez les catégories à filtrer";
97
	$l_download_bl="Télécharger la dernière version";
97
	$l_download_bl="Télécharger la dernière version";
98
	$l_fingerprint="L'empreinte numérique du fichier téléchargé est : ";
98
	$l_fingerprint="L'empreinte numérique du fichier téléchargé est : ";
99
	$l_fingerprint2="Vérifiez-là en suivant ce lien (ligne 'blacklists.tar.gz') : ";
99
	$l_fingerprint2="Vérifiez-là en suivant ce lien (ligne 'blacklists.tar.gz') : ";
100
	$l_activate_bl="Activer la nouvelle version";
100
	$l_activate_bl="Activer la nouvelle version";
101
	$l_reject_bl="Rejeter";
101
	$l_reject_bl="Rejeter";
102
	$l_warning="Temps estimé : une minute.";
102
	$l_warning="Temps estimé : une minute.";
103
	$l_specific_filtering="Filtrage special";
103
	$l_specific_filtering="Filtrage special";
104
	$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";
-
 
105
	$l_maj_rehabilitated="Noms de domaine ou IP réhabilités";
104
	$l_maj_rehabilitated="Noms de domaine ou IP réhabilités";
106
	$l_rehabilitated_dns="Noms de domaine réhabilités";
105
	$l_rehabilitated_dns="Noms de domaine réhabilités";
107
	$l_rehabilitated_dns_explain="Entrez ici des noms de domaine bloqués par la liste noire <BR> que vous souhaitez réhabiliter.";
106
	$l_rehabilitated_dns_explain="Entrez ici des noms de domaine bloqués par la liste noire <BR> que vous souhaitez réhabiliter.";
108
	$l_add_to_bl="Noms de domaine ou adresses IP à ajouter à la liste noire";
107
	$l_add_to_bl="Noms de domaine ou adresses IP à ajouter à la liste noire";
109
	$l_rehabilitated_ip="IP réhabilitées";
108
	$l_rehabilitated_ip="IP réhabilitées";
110
	$l_rehabilitated_ip_explain="Entrez ici des IP bloquées par la liste noire <BR> que vous souhaitez réhabiliter.";
109
	$l_rehabilitated_ip_explain="Entrez ici des IP bloquées par la liste noire <BR> que vous souhaitez réhabiliter.";
-
 
110
	$l_one_dns="Entrez une adresse DNS par ligne (exemple : www.domaine.com)";
111
	$l_one_ip="Entrez une IP par ligne (exemple : 123.123.123.123)";
111
	$l_one_ip="Entrez une IP par ligne (exemple : 123.123.123.123)";
-
 
112
	$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";
112
	$l_record="Enregistrer les modifications";
113
	$l_record="Enregistrer les modifications";
113
	$l_wait="Une fois validées, 10 secondes sont nécessaires pour traiter vos modifications";
114
	$l_wait="Une fois validées, 10 secondes sont nécessaires pour traiter vos modifications";
114
	$l_ip_filtering="Filtrer les URLs contenant une adresse IP au lieu d'un nom de domaine (ex: http://25.56.58.59/index.htm)";
115
	$l_ip_filtering="Filtrer les URLs contenant une adresse IP au lieu d'un nom de domaine (ex: http://25.56.58.59/index.htm)";
115
	$l_safe_searching="Activer le contrôle scolaire/parental des moteurs de recherche google.";
116
	$l_safe_searching="Activer le contrôle scolaire/parental des moteurs de recherche google.";
116
	$l_safe_youtube="Pour un contrôle parental sur Youtube, suivez les étapes ici : "; 
117
	$l_safe_youtube="Pour un contrôle parental sur Youtube, suivez les étapes ici : "; 
117
	$l_youtube_id="(<a href='https://support.google.com/youtube/answer/174084?hl=fr' target='cat_help' onclick=window.open('https://support.google.com/youtube/answer/174084?hl=fr','cat_help','width=800,height=600,toolbar=no,scrollbars=yes,resizable=yes') title='Youtube for school'>lien pour créer un identifiant Youtube (Id)</a>)";
118
	$l_youtube_id="(<a href='https://support.google.com/youtube/answer/174084?hl=fr' target='cat_help' onclick=window.open('https://support.google.com/youtube/answer/174084?hl=fr','cat_help','width=800,height=600,toolbar=no,scrollbars=yes,resizable=yes') title='Youtube for school'>lien pour créer un identifiant Youtube (Id)</a>)";
118
	$l_error_open_file="Erreur d'ouverture du fichier";
119
	$l_error_open_file="Erreur d'ouverture du fichier";
119
	$l_additional_file_title="Fichiers de 'listes noires' additionnels";
120
	$l_additional_file_title="Fichiers de 'listes noires' additionnels";
120
	$l_file_list="Liste des fichiers";
121
	$l_file_list="Liste des fichiers";
121
	$l_add_file="Ajouter un fichier";
122
	$l_add_file="Ajouter un fichier";
122
	$l_add_file_explain="Chaque ligne du fichier doit être une adresse IP ou un nom de domaine"; 
123
	$l_add_file_explain="Chaque ligne du fichier doit être une adresse IP ou un nom de domaine"; 
123
	$l_file_name="Nom du fichier";
124
	$l_file_name="Nom du fichier";
124
	$l_file_remove="Supprimer";
125
	$l_file_remove="Supprimer";
125
	$l_error_upload="Erreur d'envoi du fichier";
126
	$l_error_upload="Erreur d'envoi du fichier";
126
	$l_remove="Supprimer";
127
	$l_remove="Supprimer";
127
	$l_submit="Envoyer";
128
	$l_submit="Envoyer";
128
	$l_nb_ip="Nombre d'IP";
129
	$l_nb_ip="Nombre d'IP";
129
	$l_nb_domain_names="Nombre de noms de domaine";
130
	$l_nb_domain_names="Nombre de noms de domaine";
130
	$l_nbDomainNames="Noms de domaine :";
131
	$l_nbDomainNames="Noms de domaine :";
131
	$l_nbUrl="Url :";
132
	$l_nbUrl="Url :";
132
	$l_nbIp="Ip :";
133
	$l_nbIp="Ip :";
133
	$l_update_cat="Mise a jour des catégories automatiquement toutes les 12h (seulement 'malware' actuellement)?";
134
	$l_update_cat="Mise a jour des catégories automatiquement toutes les 12h (seulement 'malware' actuellement)?";
134
	$l_disable="Désactiver";
135
	$l_disable="Désactiver";
135
	$l_enable="Activer";
136
	$l_enable="Activer";
136
	$l_file_state="Etat";
137
	$l_file_state="Etat";
137
}
138
}
138
else {
139
else {
139
	$l_bl="BlackList";
140
	$l_bl="BlackList";
140
	$l_load="Loading...";
141
	$l_load="Loading...";
141
	$l_list_version="List version : ";
142
	$l_list_version="List version : ";
142
	$l_bl_categories="Select the categories to filter";
143
	$l_bl_categories="Select the categories to filter";
143
	$l_download_bl="Download the last version";
144
	$l_download_bl="Download the last version";
144
	$l_fingerprint="The digital fingerprint of the downloaded blacklist is : ";
145
	$l_fingerprint="The digital fingerprint of the downloaded blacklist is : ";
145
	$l_fingerprint2="Verify it with this link (line 'blacklists.tar.gz') : ";
146
	$l_fingerprint2="Verify it with this link (line 'blacklists.tar.gz') : ";
146
	$l_activate_bl="Activate the new version";
147
	$l_activate_bl="Activate the new version";
147
	$l_reject_bl="Reject";
148
	$l_reject_bl="Reject";
148
	$l_warning="Estimated time : one minute.";
149
	$l_warning="Estimated time : one minute.";
149
	$l_specific_filtering="Specific filtering";
150
	$l_specific_filtering="Specific filtering";
150
	$l_allowed_dns="Allowed domain names";
151
	$l_allowed_dns="Allowed domain names";
151
	$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";
-
 
152
	$l_maj_rehabilitated="Domain names or IP rehabilitated";
152
	$l_maj_rehabilitated="Domain names or IP rehabilitated";
153
	$l_rehabilitated_dns="Rehabilitated domain names";
153
	$l_rehabilitated_dns="Rehabilitated domain names";
154
	$l_rehabilitated_dns_explain="Enter here domain names that are blocked by the blacklist <BR> and you want to rehabilitate.";
154
	$l_rehabilitated_dns_explain="Enter here domain names that are blocked by the blacklist <BR> and you want to rehabilitate.";
155
	$l_add_to_bl="Domain names or IP addresses to add to the blacklist";
155
	$l_add_to_bl="Domain names or IP addresses to add to the blacklist";
156
	$l_rehabilitated_ip="Rehabilitated IP";
156
	$l_rehabilitated_ip="Rehabilitated IP";
157
	$l_rehabilitated_ip_explain="Enter here IP that are blocked by the blacklist <BR> and you want to rehabilitate.";
157
	$l_rehabilitated_ip_explain="Enter here IP that are blocked by the blacklist <BR> and you want to rehabilitate.";
-
 
158
	$l_one_dns="Enter one DNS per row (example : www.domaine.com)";
158
	$l_one_ip="Enter one IP per row (example : 123.123.123.123)";
159
	$l_one_ip="Enter one IP per row (example : 123.123.123.123)";
-
 
160
	$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";
159
	$l_record="Save changes";
161
	$l_record="Save changes";
160
	$l_wait="Once validated, 10 seconds are necessary to compute your modifications";
162
	$l_wait="Once validated, 10 seconds are necessary to compute your modifications";
161
	$l_ip_filtering="Filtering URLs that contain an IP address instead of a domain name (ie: http://25.56.58.59/index.htm)";
163
	$l_ip_filtering="Filtering URLs that contain an IP address instead of a domain name (ie: http://25.56.58.59/index.htm)";
162
	$l_safe_searching="Enabling school/parental control for the search engines google"; 
164
	$l_safe_searching="Enabling school/parental control for the search engines google"; 
163
	$l_safe_youtube="For a safe Youtube search, follow these steps : "; 
165
	$l_safe_youtube="For a safe Youtube search, follow these steps : "; 
164
	$l_youtube_id="(<a href='https://support.google.com/youtube/answer/174084?hl=en' target='cat_help' onclick=window.open('https://support.google.com/youtube/answer/174084?hl=en','cat_help','width=800,height=600,toolbar=no,scrollbars=yes,resizable=yes') title='Youtube for school'>link to create a Youtube Id</a>)";
166
	$l_youtube_id="(<a href='https://support.google.com/youtube/answer/174084?hl=en' target='cat_help' onclick=window.open('https://support.google.com/youtube/answer/174084?hl=en','cat_help','width=800,height=600,toolbar=no,scrollbars=yes,resizable=yes') title='Youtube for school'>link to create a Youtube Id</a>)";
165
	$l_error_open_file="Error opening file";
167
	$l_error_open_file="Error opening file";
166
	$l_additional_file_title="Additional blacklist files";
168
	$l_additional_file_title="Additional blacklist files";
167
	$l_file_list="Files list";
169
	$l_file_list="Files list";
168
	$l_add_file="Add a file";
170
	$l_add_file="Add a file";
169
	$l_add_file_explain="Each line of the file must be an IP address or a domain name"; 
171
	$l_add_file_explain="Each line of the file must be an IP address or a domain name"; 
170
	$l_file_name="Filename";
172
	$l_file_name="Filename";
171
	$l_file_remove="Remove";
173
	$l_file_remove="Remove";
172
	$l_error_upload="Error during the upload process";
174
	$l_error_upload="Error during the upload process";
173
	$l_remove="Delete";
175
	$l_remove="Delete";
174
	$l_submit="Submit";
176
	$l_submit="Submit";
175
	$l_nb_ip="Number of IP";
177
	$l_nb_ip="Number of IP";
176
	$l_nb_domain_names="Number of domain names";
178
	$l_nb_domain_names="Number of domain names";
177
	$l_nbDomainNames="Domain names :";
179
	$l_nbDomainNames="Domain names :";
178
	$l_nbUrl="Url :";
180
	$l_nbUrl="Url :";
179
	$l_nbIp="Ip :";
181
	$l_nbIp="Ip :";
180
	$l_update_cat="Update automaticly categories every 12 hours (only 'malware' for now)?";
182
	$l_update_cat="Update automaticly categories every 12 hours (only 'malware' for now)?";
181
	$l_disable="Disable";
183
	$l_disable="Disable";
182
	$l_enable="Enable";
184
	$l_enable="Enable";
183
	$l_file_state="State";
185
	$l_file_state="State";
184
}
186
}
185
$dir_etc="/usr/local/etc/";
187
$dir_etc="/usr/local/etc/";
186
$dir_dg="/etc/dansguardian/lists/";
188
$dir_dg="/etc/dansguardian/lists/";
-
 
189
$dir_blacklist=$dir_dg."blacklists/";
187
$dir_bl_ip="/usr/local/share/iptables-bl/";
190
$dir_bl_ip="/usr/local/share/iptables-bl/";
188
$dir_bl_dns="/usr/local/share/dnsmasq-bl/";
191
$dir_bl_dns="/usr/local/share/dnsmasq-bl/";
189
$bl_categories=$dir_etc."alcasar-bl-categories";
192
$bl_categories=$dir_etc."alcasar-bl-categories";
190
$bl_categories_enabled=$dir_etc."alcasar-bl-categories-enabled";
193
$bl_categories_enabled=$dir_etc."alcasar-bl-categories-enabled";
191
$conf_file=$dir_etc."alcasar.conf";
194
$conf_file=$dir_etc."alcasar.conf";
192
$dir_blacklist=$dir_dg."blacklists/";
-
 
193
$urlregex_file=$dir_dg."urlregexplist";
195
$urlregex_file=$dir_dg."urlregexplist";
194
$bannedsite_file=$dir_dg."bannedsitelist";
196
$bannedsite_file=$dir_dg."bannedsitelist";
195
$dir_tmp="/tmp/blacklists";
197
$dir_tmp="/tmp/blacklists";
196
$upload_dir_ip = "/usr/local/share/iptables-bl-enabled/";
198
$dir_ip_enabled = "/usr/local/share/iptables-bl-enabled/";
197
$upload_dir_domain_names = "/usr/local/share/dnsmasq-bl-enabled/";
199
$dir_domain_names_enabled = "/usr/local/share/dnsmasq-bl-enabled/";
198
$dir_ip = "/usr/local/share/iptables-bl/";
200
$dir_ip = "/usr/local/share/iptables-bl/";
199
$dir_domain_names = "/usr/local/share/dnsmasq-bl/";
201
$dir_domain_names = "/usr/local/share/dnsmasq-bl/";
200
$update_file_cat="/usr/local/etc/update_cat.conf";
202
$update_file_cat="/usr/local/etc/update_cat.conf";
201
 
203
 
202
 
204
 
203
# default values
205
# default values
204
if (is_file ($conf_file))
206
if (is_file ($conf_file))
205
	{
207
	{
206
	$tab=file($conf_file);
208
	$tab=file($conf_file);
207
	if ($tab)
209
	if ($tab)
208
		{
210
		{
209
		foreach ($tab as $line)
211
		foreach ($tab as $line)
210
			{
212
			{
211
			$field=explode("=", $line);
213
			$field=explode("=", $line);
212
			if ($field[0] == "PRIVATE_IP")
214
			if ($field[0] == "PRIVATE_IP")
213
				{
215
				{
214
				$PRIVATE_IP_MASK=trim($field[1]);
216
				$PRIVATE_IP_MASK=trim($field[1]);
215
				$tmp = explode("/",$PRIVATE_IP_MASK);
217
				$tmp = explode("/",$PRIVATE_IP_MASK);
216
				$PRIVATE_IP=$tmp[0];
218
				$PRIVATE_IP=$tmp[0];
217
				}
219
				}
218
			}
220
			}
219
		}
221
		}
220
	}	
222
	}	
221
else { echo "$l_error_open_file $conf_file";}
223
else { echo "$l_error_open_file $conf_file";}
222
if (isset($_POST['choix'])){ $choix=$_POST['choix']; } else { $choix=""; }
224
if (isset($_POST['choix'])){ $choix=$_POST['choix']; } else { $choix=""; }
223
switch ($choix)
225
switch ($choix)
224
{
226
{
225
case 'Download_list' :
227
case 'Download_list' :
226
	exec ("sudo /usr/local/bin/alcasar-bl.sh --download");
228
	exec ("sudo /usr/local/bin/alcasar-bl.sh --download");
227
	break;
229
	break;
228
case 'Active_list' :
230
case 'Active_list' :
229
	exec ("sudo /usr/local/bin/alcasar-bl.sh --adapt");
231
	exec ("sudo /usr/local/bin/alcasar-bl.sh --adapt");
230
	exec ("sudo /usr/local/bin/alcasar-bl.sh --reload");
232
	exec ("sudo /usr/local/bin/alcasar-bl.sh --reload");
231
	break;
233
	break;
232
case 'Reject_list' :
234
case 'Reject_list' :
233
	unlink ("$dir_tmp/blacklists.tar.gz"); unlink ("$dir_tmp/md5sum");
235
	unlink ("$dir_tmp/blacklists.tar.gz"); unlink ("$dir_tmp/md5sum");
234
	break;
236
	break;
235
case 'MAJ_cat_bl' :
237
case 'MAJ_cat_bl' :
236
	if (file_exists($bl_categories_enabled))
238
	if (file_exists($bl_categories_enabled))
237
	{
239
	{
238
		$fichier=fopen($update_file_cat,"w+");
240
		$fichier=fopen($update_file_cat,"w+");
239
		$pointeur=fopen($bl_categories_enabled, "w+");
241
		$pointeur=fopen($bl_categories_enabled, "w+");
240
		foreach ($_POST as $key => $value)
242
		foreach ($_POST as $key => $value)
241
			{
243
			{
242
			if (strstr($key,'chk-'))
244
			if (strstr($key,'chk-'))
243
			{	
245
			{	
244
				$line=str_replace('chk-','',$key)."\n";
246
				$line=str_replace('chk-','',$key)."\n";
245
				fwrite($pointeur,$line);
247
				fwrite($pointeur,$line);
246
				if(trim($line) == 'malware' && $_POST['update_cat'] == 1)
248
				if(trim($line) == 'malware' && $_POST['update_cat'] == 1)
247
				{
249
				{
248
					fputs($fichier, "malware rsync://ftp.ut-capitole.fr/blacklist/dest/malware\n");
250
					fputs($fichier, "malware rsync://ftp.ut-capitole.fr/blacklist/dest/malware\n");
249
				}
251
				}
250
			}
252
			}
251
			}
253
			}
252
			
254
			
253
		fclose($pointeur);
255
		fclose($pointeur);
254
		}
256
		}
255
	else {echo "$l_error_open_file $bl_categories_enabled";}
257
	else {echo "$l_error_open_file $bl_categories_enabled";}
256
	$fichier=fopen($dir_bl_dns."ossi.conf","w+");
258
	$fichier=fopen($dir_blacklist."ossi-bl/domains","w+");
257
	fputs($fichier, form_filter($_POST['OSSI_bl_domains']));
259
	fputs($fichier, form_filter($_POST['OSSI_bl']));
258
	fclose($fichier);
260
	fclose($fichier);
259
	unset($_POST['OSSI_bl_domains']);
261
	unset($_POST['OSSI_bl']);
260
	$fichier=fopen($dir_dg."exceptionsitelist","w+");
262
	$fichier=fopen($dir_dg."exceptionsitelist","w+");
261
	fputs($fichier, form_filter($_POST['BL_rehabilited_domains']));
263
	fputs($fichier, form_filter($_POST['BL_rehabilited_domains']));
262
	fclose($fichier);
264
	fclose($fichier);
263
	unset($_POST['BL_rehabilited_domains']);
265
	unset($_POST['BL_rehabilited_domains']);
264
	$fichier=fopen($dir_bl_ip."ossi","w+");
-
 
265
	fputs($fichier, form_filter_ip($_POST['OSSI_bl_ip'], "black"));
-
 
266
	fclose($fichier);
-
 
267
	unset($_POST['OSSI_bl_ip']);
-
 
268
	$fichier=fopen($dir_dg."exceptioniplist","w+");
266
	$fichier=fopen($dir_dg."exceptioniplist","w+");
269
	fputs($fichier, form_filter($_POST['BL_rehabilited_ip']));
267
	fputs($fichier, form_filter($_POST['BL_rehabilited_ip']));
270
	fclose($fichier);
268
	fclose($fichier);
271
	unset($_POST['BL_rehabilited_ip']);
269
	unset($_POST['BL_rehabilited_ip']);
272
	exec ("sudo /usr/local/bin/alcasar-bl.sh --reload");
270
	exec ("sudo /usr/local/bin/alcasar-bl.sh --reload");
273
	break;
271
	break;
274
case 'Specific_filtering' :
272
case 'Specific_filtering' :
275
	$pureip="-pureip_off"; $safesearch="-safesearch_off"; ;
273
	$pureip="-pureip_off"; $safesearch="-safesearch_off"; ;
276
	foreach ($_POST as $key => $value)
274
	foreach ($_POST as $key => $value)
277
	{
275
	{
278
		if (strstr($key,'chk-ip')) $pureip="-pureip_on";
276
		if (strstr($key,'chk-ip')) $pureip="-pureip_on";
279
		if (strstr($key,'chk-safesearch')) $safesearch="-safesearch_on";
277
		if (strstr($key,'chk-safesearch')) $safesearch="-safesearch_on";
280
	}
278
	}
281
	exec ("sudo /usr/local/bin/alcasar-url_filter_bl.sh $safesearch $pureip");
279
	exec ("sudo /usr/local/bin/alcasar-url_filter_bl.sh $safesearch $pureip");
282
	break;
280
	break;
283
case 'MAJ_ip_file' :
281
case 'MAJ_ossi_file' :
284
	foreach($_POST as $fichier => $value)
282
	foreach($_POST as $fichier => $value)
285
	{
283
	{
286
		if($fichier != "choix")
284
		if($fichier != "choix")
287
		{
285
		{
288
			$action=$_POST[$fichier];
286
			$action=$_POST[$fichier];
289
			if($action == $l_remove) //delete
287
			if($action == $l_remove) //delete
290
			{
288
			{
291
				exec("rm -rf $upload_dir_ip$fichier");
289
				exec("rm -f $dir_ip_enabled$fichier");
292
				exec("rm -rf $upload_dir_domain_names$fichier");
290
				exec("rm -f $dir_domain_names_enabled$fichier");
293
				exec("rm -rf $dir_ip$fichier");
291
				exec("rm -f $dir_ip$fichier");
294
				exec("rm -rf $dir_domain_names$fichier");
292
				exec("rm -f $dir_domain_names$fichier");
-
 
293
				exec("rm -rf $dir_dg$fichier");
295
				exec ("sudo /usr/local/bin/alcasar-bl.sh --reload");
294
				exec ("sudo /usr/local/bin/alcasar-bl.sh --reload");
296
			}
295
			}
297
			if($action == $l_disable) //disable
296
			if($action == $l_disable) //disable
298
			{
297
			{
299
				exec("mv -f $upload_dir_ip$fichier $dir_ip$fichier");
298
				exec("rm -f $dir_ip_enabled$fichier");
300
				if($fichier!='ossi-tor_node_ip')
-
 
301
					exec("mv -f $upload_dir_domain_names$fichier $dir_domain_names$fichier");
299
				exec("rm -f $dir_domain_names_enabled$fichier");
302
				exec("sudo /usr/local/bin/alcasar-bl.sh --reload");
300
				exec("sudo /usr/local/bin/alcasar-bl.sh --reload");
303
			}
301
			}
304
			if($action == $l_enable) //enable
302
			if($action == $l_enable) //enable
305
			{
303
			{
306
				exec("mv -f $dir_ip$fichier $upload_dir_ip$fichier");
304
				exec("ln -s $dir_ip$fichier $dir_ip_enabled$fichier");
307
				if($fichier!='ossi-tor_node_ip')
-
 
308
					exec("mv -f $dir_domain_names$fichier $upload_dir_domain_names$fichier");
305
				exec("ln -s $dir_domain_names$fichier $dir_domain_names_enables$fichier");
309
				exec ("sudo /usr/local/bin/alcasar-bl.sh --reload");
306
				exec ("sudo /usr/local/bin/alcasar-bl.sh --reload");
310
			}
307
			}
311
		}
308
		}
312
	}
309
	}
313
	break;
310
	break;
314
case 'MAJ_ip_file_upload' :
311
case 'MAJ_ossi_file_upload' :
315
	$nom = str_replace (".", "_",basename($_FILES['fichier_ip']['name']));
312
	$nom = str_replace (".", "_",basename($_FILES['fichier_ip']['name']));
316
	# Si un fichier a été choisi
313
	# Si un fichier a été choisi
317
	if(!empty($nom))
314
	if(!empty($nom))
318
	{	
315
	{	
319
		# On l'upload
316
		# On l'upload
320
		if(move_uploaded_file($_FILES['fichier_ip']['tmp_name'], $blacklist_dir."ossi-bl-".$nom))
317
		if(move_uploaded_file($_FILES['fichier_ip']['tmp_name'], $blacklist_dir."ossi-bl-".$nom))
321
		{
318
		{
322
			# On extrait uniquement les ip du fichier
-
 
323
//			exec("grep -Eo '([0-9]{1,3}\.){3}[0-9]{1,3}' $upload_dir_ip$nom > $upload_dir_ip\ossi_ip");
-
 
324
 
-
 
325
			# Suppression des doublons
-
 
326
//			exec("sort -u $upload_dir_ip\ossi_ip > $upload_dir_ip\ossi-$nom && rm -f $upload_dir_ip\ossi_ip");
-
 
327
 
-
 
328
			# On adapte le fichier à la sauvegarde du set
-
 
329
//			exec("sed -i \"s/^/add bl_ip_blocked /g\" $upload_dir_ip\ossi-$nom"); 
-
 
330
			
-
 
331
 
-
 
332
			# On extrait uniquement les noms de domaine
-
 
333
			# max_tld() retourne le nombre max de charactere pour un top-level dns
-
 
334
//			exec("grep -Eo '([a-zA-Z0-9_-]+\.){1,2}[a-zA-Z]{2,".max_tld()."}' $upload_dir_ip$nom > $upload_dir_domain_names\ossi_domain_names");
-
 
335
 
-
 
336
			# Suppression des doublons
-
 
337
//			exec("sort -u $upload_dir_domain_names\ossi_domain_names > $upload_dir_domain_names\ossi-$nom && rm -f $upload_dir_domain_names\ossi_domain_names");
-
 
338
 
-
 
339
			# On adapte le fichier pour Dnsmasq
-
 
340
//			exec("sed -i \"s/^/address=\//g\" $upload_dir_domain_names\ossi-$nom");
-
 
341
//			exec("sed -i \"s/$/\/$PRIVATE_IP/g\" $upload_dir_domain_names\ossi-$nom");
-
 
342
 
-
 
343
			# Suppression du fichier
-
 
344
//			exec("rm -f $upload_dir_ip$nom");
-
 
345
			exec ("sudo /usr/local/bin/alcasar-bl.sh --reload");
319
			exec ("sudo /usr/local/bin/alcasar-bl.sh --reload");
346
			exec ("sudo /usr/local/bin/alcasar-iptables.sh ");
320
			exec ("sudo /usr/local/bin/alcasar-iptables.sh ");
347
		}
321
		}
348
		else
322
		else
349
		{
323
		{
350
			echo $l_error_upload;
324
			echo $l_error_upload;
351
		}
325
		}
352
	}
326
	}
353
	break;
327
	break;
354
}
328
}
355
?>
329
?>
356
<table width="100%" border="0" cellspacing="0" cellpadding="0">
330
<table width="100%" border="0" cellspacing="0" cellpadding="0">
357
	<tr><th>
331
	<tr><th>
358
	<?php echo $l_list_version; echo date ("F d Y", filemtime ('/etc/dansguardian/lists/blacklists/README'));?>
332
	<?php echo $l_list_version; echo date ("F d Y", filemtime ('/etc/dansguardian/lists/blacklists/README'));?>
359
	</th></tr>
333
	</th></tr>
360
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
334
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
361
</table>
335
</table>
362
<TABLE width="100%" border=1 cellspacing=0 cellpadding=1>
336
<TABLE width="100%" border=1 cellspacing=0 cellpadding=1>
363
<tr><td valign="middle" align="left" colspan=10>
337
<tr><td valign="middle" align="left" colspan=10>
364
<FORM action='bl_filter.php' method=POST>
338
<FORM action='bl_filter.php' method=POST>
365
<?php
339
<?php
366
if ((file_exists("$dir_tmp/blacklists.tar.gz")) && (file_exists("$dir_tmp/md5sum")))
340
if ((file_exists("$dir_tmp/blacklists.tar.gz")) && (file_exists("$dir_tmp/md5sum")))
367
	{
341
	{
368
	echo "$l_fingerprint"; echo_file ("$dir_tmp/md5sum");
342
	echo "$l_fingerprint"; echo_file ("$dir_tmp/md5sum");
369
	echo "<br>$l_fingerprint2<a href='http://dsi.ut-capitole.fr/blacklists/download/MD5SUM.LST' target='cat_help' onclick=window.open('http://dsi.ut-capitole.fr/blacklists/download/MD5SUM.LST','cat_help','width=600,height=150,toolbar=no,scrollbars=yes,resizable=yes') title='verify fingerprint'>dsi.ut-capitole.fr/blacklists/download/MD5SUM.LST</a><br>";
343
	echo "<br>$l_fingerprint2<a href='http://dsi.ut-capitole.fr/blacklists/download/MD5SUM.LST' target='cat_help' onclick=window.open('http://dsi.ut-capitole.fr/blacklists/download/MD5SUM.LST','cat_help','width=600,height=150,toolbar=no,scrollbars=yes,resizable=yes') title='verify fingerprint'>dsi.ut-capitole.fr/blacklists/download/MD5SUM.LST</a><br>";
370
	echo "<input type='hidden' name='choix' value='Active_list'>";
344
	echo "<input type='hidden' name='choix' value='Active_list'>";
371
	echo "<input type='submit' onClick=\"this.disabled=true; this.value='$l_load';\" value='$l_activate_bl'> ($l_warning)</FORM>";
345
	echo "<input type='submit' onClick=\"this.disabled=true; this.value='$l_load';\" value='$l_activate_bl'> ($l_warning)</FORM>";
372
	echo "<FORM action='bl_filter.php' method=POST>";
346
	echo "<FORM action='bl_filter.php' method=POST>";
373
	echo "<input type='hidden' name='choix' value='Reject_list'>";
347
	echo "<input type='hidden' name='choix' value='Reject_list'>";
374
	echo "<input type='submit' onClick=\"this.disabled=true; this.value='$l_load';\" value='$l_reject_bl'></form>";
348
	echo "<input type='submit' onClick=\"this.disabled=true; this.value='$l_load';\" value='$l_reject_bl'></form>";
375
	}
349
	}
376
else
350
else
377
	{
351
	{
378
	echo "<input type='hidden' name='choix' value='Download_list'>";
352
	echo "<input type='hidden' name='choix' value='Download_list'>";
379
	echo "<input type='submit' onClick=\"this.disabled=true; this.value='$l_load';\" value='$l_download_bl'>";
353
	echo "<input type='submit' onClick=\"this.disabled=true; this.value='$l_load';\" value='$l_download_bl'>";
380
	echo " ($l_warning)";
354
	echo " ($l_warning)";
381
	}
355
	}
382
?>
356
?>
383
</FORM>
357
</FORM>
384
</td></tr>
358
</td></tr>
385
</table><br/>
359
</table><br/>
386
<table width="100%" border="0" cellspacing="0" cellpadding="0">
360
<table width="100%" border="0" cellspacing="0" cellpadding="0">
387
	<tr><th><?php echo $l_bl; ?></th></tr>
361
	<tr><th><?php echo $l_bl; ?></th></tr>
388
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
362
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
389
</table>
363
</table>
390
<table width="100%" border=1 cellspacing=0 cellpadding=1>
364
<table width="100%" border=1 cellspacing=0 cellpadding=1>
391
<tr><td valign="middle" align="left" colspan=10>
365
<tr><td valign="middle" align="left" colspan=10>
392
<FORM action='bl_filter.php' method=POST>
366
<FORM action='bl_filter.php' method=POST>
393
<input type='hidden' name='choix' value='MAJ_cat_bl'>
367
<input type='hidden' name='choix' value='MAJ_cat_bl'>
394
<?php
368
<?php
395
echo "<center>";
369
echo "<center>";
-
 
370
// total nnumber of IP, DNS & URLs
396
$nbDomainNames = exec ("wc -l /usr/local/share/dnsmasq-bl/* | tail -n 1 | awk '{print $1}'");
371
$nbDomainNames = exec ("wc -l /usr/local/share/dnsmasq-bl/* | tail -n 1 | awk '{print $1}'");
397
$nbUrl = exec ("for file in `find /etc/dansguardian/lists/blacklists/ -name 'urls'`; do nb=$((nb+$(wc -l \$file | awk '{print $1}'))); done; echo \$nb");
372
$nbUrl = exec ("for file in `find /etc/dansguardian/lists/blacklists/ -name 'urls'`; do nb=$((nb+$(wc -l \$file | awk '{print $1}'))); done; echo \$nb");
398
$nbIp = exec ("wc -l /usr/local/share/iptables-bl/* | tail -n 1 | awk '{print $1}'");
373
$nbIp = exec ("wc -l /usr/local/share/iptables-bl/* | tail -n 1 | awk '{print $1}'");
399
echo "<b>$l_nbDomainNames</b> $nbDomainNames, <b>$l_nbUrl</b> $nbUrl, <b>$l_nbIp</b> $nbIp<br/>";
374
echo "<b>$l_nbDomainNames</b> $nbDomainNames, <b>$l_nbUrl</b> $nbUrl, <b>$l_nbIp</b> $nbIp<br/>";
400
echo "$l_bl_categories</center></td></tr>";	
375
echo "$l_bl_categories</center></td></tr>";	
401
//on lit et on interprete le fichier de catégories
376
//read & display all BL categories (checked or not)
402
$cols=1; 
377
$cols=1; 
403
if (file_exists($bl_categories))
378
if (file_exists($bl_categories))
404
	{
379
	{
405
	$pointeur=fopen($bl_categories,"r");
380
	$bl_files = file($bl_categories);
406
	while (!feof ($pointeur))
381
	$bl_files = preg_grep("/ossi-/", $bl_files, 1); // don't display ossi custom categories
407
		{
-
 
408
		$ligne=fgets($pointeur, 4096);
382
	foreach($bl_files as $fichier => $value)
409
		if ($ligne)
-
 
410
			{
383
		{
411
			if ($cols == 1) { echo "<tr>";}
384
		if ($cols == 1) { echo "<tr>";}
412
				$categorie=trim(basename($ligne));
385
		$categorie=trim(basename($value));
413
			if($categorie != "ossi") // don't display ossi
-
 
414
			{
-
 
415
				echo "<td><a href='bl_categories_help.php?liste=bl&cat=$categorie' target='cat_help' onclick=window.open('bl_categories_help.php','cat_help','width=600,height=450,toolbar=no,scrollbars=yes,resizable=yes') title='categories help page'>$categorie</a><br>";
386
		echo "<td><a href='bl_categories_help.php?liste=bl&cat=$categorie' target='cat_help' onclick=window.open('bl_categories_help.php','cat_help','width=600,height=450,toolbar=no,scrollbars=yes,resizable=yes') title='categories help page'>$categorie</a><br>";
416
				echo "<input type='checkbox' name='chk-$categorie'";
387
		echo "<input type='checkbox' name='chk-$categorie'";
417
				// si la ligne est commentée -> categorie non selectionnée
388
		// si la ligne est commentée -> categorie non selectionnée
418
				if (preg_match('/^#/',$ligne, $r)) { echo ">";}
389
		if (preg_match('/^#/',$value, $r)) { echo ">";}
419
				else { echo "checked>"; }
390
		else { echo "checked>"; }
420
				echo "</td>";
391
		echo "</td>";
421
				$cols++;
392
		$cols++;
422
			}
-
 
423
			if ($cols > 10) {
393
		if ($cols > 10) {
424
				echo "</tr>";
394
			echo "</tr>";
425
				$cols=1; }
395
			$cols=1; }
426
			}
396
		}
427
		}
397
	}
428
	fclose($pointeur);
-
 
429
	}
-
 
430
else	{
398
else	{
431
	echo "$l_error_open_file $bl_categories";
399
	echo "$l_error_open_file $bl_categories";
432
}
400
}
433
 
401
 
434
#update categories via rsync
402
//update categories with rsync
435
$update_select = array();
403
$update_select = array();
436
$update_select[0] = "";
404
$update_select[0] = "";
437
$update_select[1] = "";
405
$update_select[1] = "";
438
 
406
 
439
if ( 0 == filesize( $update_file_cat ) ) $update_select[0] = "checked";
407
if ( 0 == filesize( $update_file_cat ) ) $update_select[0] = "checked";
440
else $update_select[1] = "checked";
408
else $update_select[1] = "checked";
441
	
409
	
442
echo "</td></tr>";
410
echo "</td></tr>";
443
echo "<tr><td valign='middle' align='left' colspan=10>";
411
echo "<tr><td valign='middle' align='left' colspan=10>";
444
echo "<center>$l_update_cat 
412
echo "<center>$l_update_cat 
445
	<input type='radio' name='update_cat' value=0 $update_select[0]> $l_disable 
413
	<input type='radio' name='update_cat' value=0 $update_select[0]> $l_disable 
446
	<input type='radio' name='update_cat' value=1 $update_select[1]> $l_enable 
414
	<input type='radio' name='update_cat' value=1 $update_select[1]> $l_enable 
447
	<input type='submit' value='$l_record'></center>";
415
	<input type='submit' value='$l_record'></center>";
448
echo "</td></tr>";
416
echo "</td></tr>";
449
echo "<tr><td valign='middle' align='left' colspan=10>";
417
echo "<tr><td valign='middle' align='left' colspan=10>";
450
echo "<center><b>$l_maj_rehabilitated</b></center></td></tr>";
418
echo "<center><b>$l_maj_rehabilitated</b></center></td></tr>";
451
echo "<tr><td width=50% colspan=5 align=center>";
419
echo "<tr><td width=50% colspan=5 align=center>";
452
echo "<H3>$l_rehabilitated_dns</H3>$l_rehabilitated_dns_explain<BR>$l_one_dns<BR>";
420
echo "<H3>$l_rehabilitated_dns</H3>$l_rehabilitated_dns_explain<BR>$l_one_dns<BR>";
453
echo "<textarea name='BL_rehabilited_domains' rows=3 cols=40>";
421
echo "<textarea name='BL_rehabilited_domains' rows=3 cols=40>";
454
echo_file ($dir_dg."exceptionsitelist");
422
echo_file ($dir_dg."exceptionsitelist");
455
echo "</textarea></td>";
423
echo "</textarea></td>";
456
echo "<td width=50% colspan=5 align=center>";
424
echo "<td width=50% colspan=5 align=center>";
457
echo "<H3>$l_rehabilitated_ip</H3>$l_rehabilitated_ip_explain<BR>$l_one_ip<BR>";
425
echo "<H3>$l_rehabilitated_ip</H3>$l_rehabilitated_ip_explain<BR>$l_one_ip<BR>";
458
echo "<textarea name='BL_rehabilited_ip' rows=3 cols=40>";
426
echo "<textarea name='BL_rehabilited_ip' rows=3 cols=40>";
459
echo_file ($dir_dg."exceptioniplist");
427
echo_file ($dir_dg."exceptioniplist");
460
echo "</textarea></td></tr><tr><td width=50% colspan=10>";
428
echo "</textarea></td></tr>";
461
echo "<tr><td valign='middle' align='left' colspan=10>";
429
echo "<tr><td valign='middle' align='left' colspan=10>";
462
echo "<center><b>$l_add_to_bl</b></center></td></tr>";
430
echo "<center><b>$l_add_to_bl</b></center></td></tr>";
463
echo "<tr><td width=100% colspan=10 align=center>";
431
echo "<tr><td width=100% colspan=10 align=center>";
464
echo "$l_one_dns_ip<BR>";
432
echo "$l_one_dns_ip<BR>";
465
echo "<textarea name='OSSI_bl_domains' rows=3 cols=40>";
433
echo "<textarea name='OSSI_bl' rows=3 cols=40>";
466
echo_file ($dir_blacklist."ossi-bl/domain");
434
echo_file ($dir_blacklist."ossi-bl/domains");
467
echo "</textarea></td>";
435
echo "</textarea></td>";
468
//echo "<td width=50% colspan=5 align=center>";
-
 
469
//echo "<H3>$l_forbidden_ip</H3>$l_forbidden_ip_explain<BR>";
-
 
470
//echo "<textarea name='OSSI_bl_ip' rows=3 cols=40>";
-
 
471
//echo_ip_file ($dir_blacklist."ossi");
-
 
472
//echo "</textarea></td></tr>;
-
 
473
echo "</tr><tr><td colspan=10>";
436
echo "</tr><tr><td colspan=10>";
474
echo "<input type='submit' onClick=\"this.disabled=true; this.value='$l_load';\" value='$l_record'>";
437
echo "<input type='submit' onClick=\"this.disabled=true; this.value='$l_load';\" value='$l_record'>";
475
echo "</form> ($l_wait)";
438
echo "</form> ($l_wait)";
476
echo "</td></tr></table><br/>";
439
echo "</td></tr></table><br/>";
477
?>
440
?>
478
 
-
 
479
 
-
 
480
<table width="100%" border="0" cellspacing="0" cellpadding="0">
441
<table width="100%" border="0" cellspacing="0" cellpadding="0">
481
	<tr><th><?php echo $l_additional_file_title; ?></th></tr>
442
	<tr><th><?php echo $l_additional_file_title; ?></th></tr>
482
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
443
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
483
</table>
444
</table>
484
<table width="100%" border=1 cellspacing=0 cellpadding=1>
445
<table width="100%" border=1 cellspacing=0 cellpadding=1>
485
<form action='bl_filter.php' method='POST'>
446
<form action='bl_filter.php' method='POST'>
486
<input type='hidden' name='choix' value='MAJ_ip_file'>
447
<input type='hidden' name='choix' value='MAJ_ossi_file'>
487
<?php
448
<?php
488
echo "<tr><td width=50% colspan=5 align=center>";
449
echo "<tr><td width=50% colspan=5 align=center>";
489
echo "<H3>$l_file_list</H3>";
450
echo "<H3>$l_file_list</H3>";
490
echo "<table cellspacing=2 cellpadding=3 border=1><tr><th>$l_file_name<th>$l_nb_ip<th>$l_nb_domain_names<th>$l_file_state<th>$l_file_remove</tr>";
451
echo "<table cellspacing=2 cellpadding=3 border=1><tr><th>$l_file_name<th>$l_nb_ip<th>$l_nb_domain_names<th>$l_file_state<th>$l_file_remove</tr>";
491
 
452
 
492
//liste des fichiers activés
453
//list OSSI custom categories
493
$fichiersbl = array_diff(scandir($dir_blacklist), array('..','.'));
454
$fichiersbl = array_diff(scandir($dir_blacklist), array('..','.','ossi-bl','ossi-wl'));
494
$fichiersbl = preg_grep("/^ossi-bl",$fichiersbl);
455
$fichiersbl = preg_grep("/^ossi-/",$fichiersbl);
495
foreach($fichiersbl as $fichier => $value)
456
foreach($fichiersbl as $fichier => $value)
496
{
457
{
497
	if($value=='ossi-tor_node_ip')
-
 
498
		echo "<tr><td><center><a href='bl_categories_help.php?liste=bl&cat=$value&ossi=yes&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'>".exec("sed 's/^.....//g' <<< $value")."</a></center></td><td><center>".exec("wc -l $upload_dir_ip$value | awk '{print $1}'")."</center></td><td><center>".exec("wc -l $upload_dir_domain_names$value | awk '{print $1}'")."</center></td><td><center><input type='submit' name='$value' value='$l_disable'></center></td><td><center><input type='submit' name='$value' value='$l_remove' disabled></center></td></tr>";
-
 
499
	else
-
 
500
		echo "<tr><td><center><a href='bl_categories_help.php?liste=bl&cat=$value&ossi=yes&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'>".exec("sed 's/^.....//g' <<< $value")."</a></center></td><td><center>".exec("wc -l $upload_dir_ip$value | awk '{print $1}'")."</center></td><td><center>".exec("wc -l $upload_dir_domain_names$value | awk '{print $1}'")."</center></td><td><center><input type='submit' name='$value' value='$l_disable'></center></td><td><center><input type='submit' name='$value' value='$l_remove'></center></td></tr>";
458
	echo "<tr><td><center><a href='bl_categories_help.php?liste=bl&cat=$value&filtre=domain' target='cat_help' onclick=window.open('bl_categories_help','cat_help','width=600,height=450,toolbar=no,scrollbars=yes,resizable=yes') title='categories help page'>".exec("sed 's/^.....//g' <<< $value")."</a></center></td><td><center>".exec("wc -l $dir_ip_enabled$value | awk '{print $1}'")."</center></td><td><center>".exec("wc -l $dir_domain_names_enabled$value | awk '{print $1}'")."</center></td><td><center><input type='submit' name='$value' value='$l_disable'></center></td><td><center><input type='submit' name='$value' value='$l_remove'></center></td></tr>";
501
		
-
 
502
}
-
 
503
//liste des fichiers desactivés
-
 
504
$fichiersIp = array_diff(scandir($dir_ip), array('ossi','ossi-ip-safesearch','..','.'));
-
 
505
$fichiersIp = preg_grep("/^ossi-/",$fichiersIp);
-
 
506
foreach($fichiersIp as $fichier => $value)
-
 
507
{
-
 
508
	if($value=='ossi-tor_node_ip')
-
 
509
		echo "<tr><td bgcolor='BEBEBE'><center><a href='bl_categories_help.php?liste=bl&cat=$value&ossi=yes&filtre=domain&state=disable' 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'>".exec("sed 's/^.....//g' <<< $value")."</a></center></td><td bgcolor='BEBEBE'><center>".exec("wc -l $dir_ip$value | awk '{print $1}'")."</center></td><td bgcolor='BEBEBE'><center>".exec("wc -l $dir_domain_names$value | awk '{print $1}'")."</center></td><td bgcolor='BEBEBE'><center><input type='submit' name='$value' value='$l_enable'></center></td><td bgcolor='BEBEBE'><center><input type='submit' name='$value' value='$l_remove' disabled></center></td></tr>";
-
 
510
	else
-
 
511
		echo "<tr><td bgcolor='BEBEBE'><center><a href='bl_categories_help.php?liste=bl&cat=$value&ossi=yes&filtre=domain&state=disable' 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'>".exec("sed 's/^.....//g' <<< $value")."</a></center></td><td bgcolor='BEBEBE'><center>".exec("wc -l $dir_ip$value | awk '{print $1}'")."</center></td><td bgcolor='BEBEBE'><center>".exec("wc -l $dir_domain_names$value | awk '{print $1}'")."</center></td><td bgcolor='BEBEBE'><center><input type='submit' name='$value' value='$l_enable'></center></td><td bgcolor='BEBEBE'><center><input type='submit' name='$value' value='$l_remove'></center></td></tr>";
-
 
512
}
459
}
513
 
-
 
514
echo "</table><br/></td></form><form action='bl_filter.php' method='POST' enctype='multipart/form-data'>";
460
echo "</table><br/></td></form><form action='bl_filter.php' method='POST' enctype='multipart/form-data'>";
515
echo "<input type='hidden' name='choix' value='MAJ_ip_file_upload'><td width=50% colspan=5 align=center>";
461
echo "<input type='hidden' name='choix' value='MAJ_ossi_file_upload'><td width=50% colspan=5 align=center>";
516
echo "<H3>$l_add_file</H3>";
462
echo "<H3>$l_add_file</H3>";
517
echo "$l_add_file_explain";
463
echo "$l_add_file_explain";
518
echo "<input type='file' name='fichier_ip'>";
464
echo "<input type='file' name='fichier_ip'>";
519
echo "<input type='submit' onClick=\"this.disabled=true; this.value='$l_load';\" value='$l_submit'>";
465
echo "<input type='submit' onClick=\"this.disabled=true; this.value='$l_load';\" value='$l_submit'>";
520
echo "</td></tr>";
466
echo "</td></tr>";
521
echo "</form>";
467
echo "</form>";
522
echo "</table><br/>";
468
echo "</table><br/>";
523
?>
469
?>
524
 
470
 
525
<table width="100%" border="0" cellspacing="0" cellpadding="0">
471
<table width="100%" border="0" cellspacing="0" cellpadding="0">
526
	<tr><th><?php echo $l_specific_filtering; ?></th></tr>
472
	<tr><th><?php echo $l_specific_filtering; ?></th></tr>
527
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
473
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
528
</table>
474
</table>
529
 
475
 
530
 
476
 
531
<TABLE width="100%" border=1 cellspacing=0 cellpadding=1>
477
<TABLE width="100%" border=1 cellspacing=0 cellpadding=1>
532
<FORM action='bl_filter.php' method='POST'>
478
<FORM action='bl_filter.php' method='POST'>
533
<input type='hidden' name='choix' value='Specific_filtering'>
479
<input type='hidden' name='choix' value='Specific_filtering'>
534
<tr><td>
480
<tr><td>
535
<input type='checkbox' name='chk-ip'
481
<input type='checkbox' name='chk-ip'
536
<?php
482
<?php
537
// verify "pureip" filtering state
483
// verify "pureip" filtering state
538
if (file_exists($bannedsite_file))
484
if (file_exists($bannedsite_file))
539
	{
485
	{
540
	$pointeur=fopen($bannedsite_file,"r");
486
	$pointeur=fopen($bannedsite_file,"r");
541
	while (!feof ($pointeur))
487
	while (!feof ($pointeur))
542
		{
488
		{
543
		$ligne=fgets($pointeur, 4096);
489
		$ligne=fgets($pointeur, 4096);
544
		if ($ligne)
490
		if ($ligne)
545
			{
491
			{
546
			if (preg_match('/^\*ip$/',$ligne, $r)) 
492
			if (preg_match('/^\*ip$/',$ligne, $r)) 
547
				{
493
				{
548
				echo " checked";
494
				echo " checked";
549
				break;
495
				break;
550
				}
496
				}
551
			}
497
			}
552
		}
498
		}
553
	fclose($pointeur);
499
	fclose($pointeur);
554
	}
500
	}
555
else	{
501
else	{
556
	echo "$l_error_open_file $bannedsite_file";
502
	echo "$l_error_open_file $bannedsite_file";
557
	}
503
	}
558
echo "> $l_ip_filtering";
504
echo "> $l_ip_filtering";
559
?>
505
?>
560
</td></tr>
506
</td></tr>
561
<tr><td>
507
<tr><td>
562
<input type='checkbox' name='chk-safesearch'
508
<input type='checkbox' name='chk-safesearch'
563
<?php
509
<?php
564
// verify "safesearch" filtering state
510
// verify "safesearch" filtering state
565
if (file_exists($urlregex_file))
511
if (file_exists($urlregex_file))
566
	{
512
	{
567
	$pointeur=fopen($urlregex_file,"r");
513
	$pointeur=fopen($urlregex_file,"r");
568
	while (!feof ($pointeur))
514
	while (!feof ($pointeur))
569
		{
515
		{
570
		$ligne=fgets($pointeur, 4096);
516
		$ligne=fgets($pointeur, 4096);
571
		if ($ligne)
517
		if ($ligne)
572
			{
518
			{
573
			if (preg_match('/^\"\(\^http\:\/\/\[0\-9a\-z\]\+\\\.google/',$ligne, $r))
519
			if (preg_match('/^\"\(\^http\:\/\/\[0\-9a\-z\]\+\\\.google/',$ligne, $r))
574
				{
520
				{
575
				echo " checked";
521
				echo " checked";
576
				break;
522
				break;
577
				}
523
				}
578
			}
524
			}
579
		}
525
		}
580
	fclose($pointeur);
526
	fclose($pointeur);
581
	}
527
	}
582
else	{
528
else	{
583
	echo "$l_error_open_file $urlregex_file";
529
	echo "$l_error_open_file $urlregex_file";
584
	}
530
	}
585
echo "> $l_safe_searching";
531
echo "> $l_safe_searching";
586
echo "<br>$l_safe_youtube";
532
echo "<br>$l_safe_youtube";
587
echo " $l_youtube_id<tr><td>";
533
echo " $l_youtube_id<tr><td>";
588
echo "<input type='submit' onClick=\"this.disabled=true; this.value='$l_load';\" value='$l_record'></td></tr>";
534
echo "<input type='submit' onClick=\"this.disabled=true; this.value='$l_load';\" value='$l_record'></td></tr>";
589
?>
535
?>
590
</FORM> 
536
</FORM> 
591
</TABLE>
537
</TABLE>
592
</BODY>
538
</BODY>
593
</HTML>
539
</HTML>
594
 
540
 
595
 
541
 
596
 
542