Subversion Repositories ALCASAR

Rev

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

Rev 2054 Rev 2099
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/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
-
 
66
function max_tld()
-
 
67
{
-
 
68
	$url_tld = "http://data.iana.org/TLD/tlds-alpha-by-domain.txt";
-
 
69
	$result_tld = file_get_contents($url_tld,false);
-
 
70
	$max_tld = 18; 							#valeur de base si le site ne répond plus
-
 
71
	if($result_tld !== FALSE){
-
 
72
		foreach(explode("\n", $result_tld) as $line)
-
 
73
		{
-
 
74
			if((strpos($line,'-') === false) and (strpos($line,'#') === false))
-
 
75
			{
-
 
76
				if(strlen($line) > $max_tld)
-
 
77
				{
-
 
78
					$max_tld = strlen($line);
-
 
79
				}
-
 
80
			}
-
 
81
		}
-
 
82
	}
-
 
83
	return $max_tld;
-
 
84
}
-
 
85
 
-
 
86
# Choice of language
65
# Choice of language
87
$Language = 'en';
66
$Language = 'en';
88
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
67
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
89
	$Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
68
	$Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
90
	$Language = strtolower(substr(chop($Langue[0]),0,2)); 
69
	$Language = strtolower(substr(chop($Langue[0]),0,2)); 
91
	}
70
	}
92
if($Language == 'fr'){
71
if($Language == 'fr'){
93
	$l_wl="Liste blanche générale";
72
	$l_wl="Liste blanche générale";
94
	$l_load="Chargement...";
73
	$l_load="Chargement...";
95
	$l_list_version="Version de la liste : ";
74
	$l_list_version="Version de la liste : ";
96
	$l_wl_categories="Sélectionnez les catégories à autoriser";
75
	$l_wl_categories="Sélectionnez les catégories à autoriser";
97
	$l_specific_filtering="Filtrage special";
76
	$l_specific_filtering="Filtrage special";
98
	$l_add_to_wl="Noms de domaine ou adresses IP à ajouter à la liste blanche";
77
	$l_add_to_wl="Noms de domaine ou adresses IP à ajouter à la liste blanche";
99
	$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";
78
	$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";
100
	$l_record="Enregistrer les modifications";
79
	$l_record="Enregistrer les modifications";
101
	$l_wait="Une fois validées, 10 secondes sont nécessaires pour traiter vos modifications";
80
	$l_wait="Une fois validées, 10 secondes sont nécessaires pour traiter vos modifications";
102
	$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)";
81
	$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)";
103
	$l_safe_searching="Activer le contrôle scolaire/parental des moteurs de recherche google.";
82
	$l_safe_searching="Activer le contrôle scolaire/parental des moteurs de recherche google.";
104
	$l_safe_youtube="Pour un contrôle parental sur Youtube, suivez les étapes ici : "; 
83
	$l_safe_youtube="Pour un contrôle parental sur Youtube, suivez les étapes ici : "; 
105
	$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>)";
84
	$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>)";
106
	$l_error_open_file="Erreur d'ouverture du fichier";
85
	$l_error_open_file="Erreur d'ouverture du fichier";
107
	$l_additional_file_title="Fichiers de 'listes blanches' additionnels";
86
	$l_additional_file_title="Fichiers de 'listes blanches' additionnels";
108
	$l_file_list="Liste des fichiers";
87
	$l_file_list="Liste des fichiers";
109
	$l_add_file="Ajouter un fichier";
88
	$l_add_file="Ajouter un fichier";
110
	$l_add_file_explain="Chaque ligne du fichier doit être une adresse IP ou un nom de domaine"; 
89
	$l_add_file_explain="Chaque ligne du fichier doit être une adresse IP ou un nom de domaine"; 
111
	$l_file_name="Nom du fichier";
90
	$l_file_name="Nom du fichier";
112
	$l_file_action="Action";
91
	$l_file_action="Action";
113
	$l_error_upload="Erreur d'envoi du fichier";
92
	$l_error_upload="Erreur d'envoi du fichier";
114
	$l_remove="Supprimer";
93
	$l_remove="Supprimer";
115
	$l_submit="Envoyer";
94
	$l_submit="Envoyer";
116
	$l_nb_ip="Nombre d'IP";
95
	$l_nb_ip="Nombre d'IP";
117
	$l_nb_domain_names="Nombre de noms de domaine";
96
	$l_nb_domain_names="Nombre de noms de domaine";
118
	$l_nbDomainNames="Noms de domaine :";
97
	$l_nbDomainNames="Noms de domaine :";
119
	$l_nbUrl="Url :";
98
	$l_nbUrl="Url :";
120
	$l_nbIp="Ip :";
99
	$l_nbIp="Ip :";
121
	$l_disable="Désactiver";
100
	$l_disable="Désactiver";
122
	$l_enable="Activer";
101
	$l_enable="Activer";
123
	$l_file_state="Etat";
102
	$l_file_state="Etat";
124
}
103
}
125
else {
104
else {
126
	$l_wl="General WhiteList";
105
	$l_wl="General WhiteList";
127
	$l_load="Loading...";
106
	$l_load="Loading...";
128
	$l_list_version="List version : ";
107
	$l_list_version="List version : ";
129
	$l_wl_categories="Select the allowed categories";
108
	$l_wl_categories="Select the allowed categories";
130
	$l_specific_filtering="Specific filtering";
109
	$l_specific_filtering="Specific filtering";
131
	$l_allowed_dns="Allowed domain names";
110
	$l_allowed_dns="Allowed domain names";
132
	$l_add_to_wl="Domain names or IP addresses to add to the whitelist";
111
	$l_add_to_wl="Domain names or IP addresses to add to the whitelist";
133
	$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";
112
	$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_record="Save changes";
113
	$l_record="Save changes";
135
	$l_wait="Once validated, 10 seconds are necessary to compute your modifications";
114
	$l_wait="Once validated, 10 seconds are necessary to compute your modifications";
136
	$l_ip_filtering="Filtering URLs that contain an IP address instead of a domain name (ie: http://25.56.58.59/index.htm)";
115
	$l_ip_filtering="Filtering URLs that contain an IP address instead of a domain name (ie: http://25.56.58.59/index.htm)";
137
	$l_safe_searching="Enabling school/parental control for the search engines google"; 
116
	$l_safe_searching="Enabling school/parental control for the search engines google"; 
138
	$l_safe_youtube="For a safe Youtube search, follow these steps : "; 
117
	$l_safe_youtube="For a safe Youtube search, follow these steps : "; 
139
	$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>)";
118
	$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>)";
140
	$l_error_open_file="Error opening file";
119
	$l_error_open_file="Error opening file";
141
	$l_additional_file_title="Additional WhiteList files";
120
	$l_additional_file_title="Additional WhiteList files";
142
	$l_file_list="Files list";
121
	$l_file_list="Files list";
143
	$l_add_file="Add a file";
122
	$l_add_file="Add a file";
144
	$l_add_file_explain="Each line of the file must be an IP address or a domain name"; 
123
	$l_add_file_explain="Each line of the file must be an IP address or a domain name"; 
145
	$l_file_name="Filename";
124
	$l_file_name="Filename";
146
	$l_file_action="Action";
125
	$l_file_action="Action";
147
	$l_error_upload="Error during the upload process";
126
	$l_error_upload="Error during the upload process";
148
	$l_remove="Delete";
127
	$l_remove="Delete";
149
	$l_submit="Submit";
128
	$l_submit="Submit";
150
	$l_nb_ip="Number of IP";
129
	$l_nb_ip="Number of IP";
151
	$l_nb_domain_names="Number of domain names";
130
	$l_nb_domain_names="Number of domain names";
152
	$l_nbDomainNames="Domain names :";
131
	$l_nbDomainNames="Domain names :";
153
	$l_nbUrl="Url :";
132
	$l_nbUrl="Url :";
154
	$l_nbIp="Ip :";
133
	$l_nbIp="Ip :";
155
	$l_disable="Disable";
134
	$l_disable="Disable";
156
	$l_enable="Enable";
135
	$l_enable="Enable";
157
	$l_file_state="State";
136
	$l_file_state="State";
158
}
137
}
159
$dir_etc="/usr/local/etc/";
138
$dir_etc="/usr/local/etc/";
160
$dir_dg="/etc/dansguardian/lists/";
139
$dir_dg="/etc/dansguardian/lists/";
161
$dir_blacklist=$dir_dg."blacklists/";
140
$dir_blacklist=$dir_dg."blacklists/";
162
$dir_wl_ip="/usr/local/share/iptables-wl/";
141
$dir_wl_ip="/usr/local/share/iptables-wl/";
163
$dir_wl_ip_enabled= "/usr/local/share/iptables-wl-enabled/";
142
$dir_wl_ip_enabled= "/usr/local/share/iptables-wl-enabled/";
164
$dir_wl_domain_names= "/usr/local/share/dnsmasq-wl/";
143
$dir_wl_domain_names= "/usr/local/share/dnsmasq-wl/";
165
$dir_wl_domain_names_enabled= "/usr/local/share/dnsmasq-wl-enabled/";
144
$dir_wl_domain_names_enabled= "/usr/local/share/dnsmasq-wl-enabled/";
166
$wl_categories=$dir_etc."alcasar-wl-categories";
145
$wl_categories=$dir_etc."alcasar-wl-categories";
167
$wl_categories_enabled=$dir_etc."alcasar-wl-categories-enabled";
146
$wl_categories_enabled=$dir_etc."alcasar-wl-categories-enabled";
168
$conf_file=$dir_etc."alcasar.conf";
147
$conf_file=$dir_etc."alcasar.conf";
169
$urlregex_file=$dir_dg."urlregexplist";
148
$urlregex_file=$dir_dg."urlregexplist";
170
$bannedsite_file=$dir_dg."bannedsitelist";
149
$bannedsite_file=$dir_dg."bannedsitelist";
171
$dir_tmp="/tmp/blacklists";
150
$dir_tmp="/tmp/blacklists";
172
 
151
 
173
 
152
 
174
# default values
153
# default values
175
if (is_file ($conf_file))
154
if (is_file ($conf_file))
176
	{
155
	{
177
	$tab=file($conf_file);
156
	$tab=file($conf_file);
178
	if ($tab)
157
	if ($tab)
179
		{
158
		{
180
		foreach ($tab as $line)
159
		foreach ($tab as $line)
181
			{
160
			{
182
			$field=explode("=", $line);
161
			$field=explode("=", $line);
183
			if ($field[0] == "PRIVATE_IP")
162
			if ($field[0] == "PRIVATE_IP")
184
				{
163
				{
185
				$PRIVATE_IP_MASK=trim($field[1]);
164
				$PRIVATE_IP_MASK=trim($field[1]);
186
				$tmp = explode("/",$PRIVATE_IP_MASK);
165
				$tmp = explode("/",$PRIVATE_IP_MASK);
187
				$PRIVATE_IP=$tmp[0];
166
				$PRIVATE_IP=$tmp[0];
188
				}
167
				}
189
			}
168
			}
190
		}
169
		}
191
	}	
170
	}	
192
else { echo "$l_error_open_file $conf_file";}
171
else { echo "$l_error_open_file $conf_file";}
193
if (isset($_POST['choix'])){ $choix=$_POST['choix']; } else { $choix=""; }
172
if (isset($_POST['choix'])){ $choix=$_POST['choix']; } else { $choix=""; }
194
switch ($choix)
173
switch ($choix)
195
{
174
{
196
case 'Download_list' :
175
case 'Download_list' :
197
	exec ("sudo /usr/local/bin/alcasar-bl.sh --download");
176
	exec ("sudo /usr/local/bin/alcasar-bl.sh --download");
198
	break;
177
	break;
199
case 'Active_list' :
178
case 'Active_list' :
200
	exec ("sudo /usr/local/bin/alcasar-bl.sh --adapt");
179
	exec ("sudo /usr/local/bin/alcasar-bl.sh --adapt");
201
	exec ("sudo /usr/local/bin/alcasar-bl.sh --reload");
180
	exec ("sudo /usr/local/bin/alcasar-bl.sh --reload");
202
	break;
181
	break;
203
case 'Reject_list' :
182
case 'Reject_list' :
204
	unlink ("$dir_tmp/blacklists.tar.gz"); unlink ("$dir_tmp/md5sum");
183
	unlink ("$dir_tmp/blacklists.tar.gz"); unlink ("$dir_tmp/md5sum");
205
	break;
184
	break;
206
case 'MAJ_cat_wl' :
185
case 'MAJ_cat_wl' :
207
	if (file_exists($wl_categories_enabled))
186
	if (file_exists($wl_categories_enabled))
208
	{
187
	{
209
		exec("/bin/sed -i \"/^ossi-/!d\" $wl_categories_enabled"); // keep ossi custom categories
188
		exec("/bin/sed -i \"/^ossi-/!d\" $wl_categories_enabled"); // keep ossi custom categories
210
		$pointeur=fopen($wl_categories_enabled, "a+");
189
		$pointeur=fopen($wl_categories_enabled, "a+");
211
		foreach ($_POST as $key => $value)
190
		foreach ($_POST as $key => $value)
212
		{
191
		{
213
			if (strstr($key,'chk-'))
192
			if (strstr($key,'chk-'))
214
			{	
193
			{	
215
				$line=str_replace('chk-','',$key)."\n";
194
				$line=str_replace('chk-','',$key)."\n";
216
				fwrite($pointeur,$line);
195
				fwrite($pointeur,$line);
217
			}
196
			}
218
		}
197
		}
219
			
198
			
220
		fclose($pointeur);
199
		fclose($pointeur);
221
	}
200
	}
222
	else {echo "$l_error_open_file $wl_categories_enabled";}
201
	else {echo "$l_error_open_file $wl_categories_enabled";}
223
	$fichier=fopen($dir_blacklist."ossi-wl/domains","w+");
202
	$fichier=fopen($dir_blacklist."ossi-wl/domains","w+");
224
	fputs($fichier, form_filter($_POST['OSSI_wl']));
203
	fputs($fichier, form_filter($_POST['OSSI_wl']));
225
	fclose($fichier);
204
	fclose($fichier);
226
	unset($_POST['OSSI_wl']);
205
	unset($_POST['OSSI_wl']);
227
	exec ("sudo /usr/local/bin/alcasar-bl.sh --reload");
206
	exec ("sudo /usr/local/bin/alcasar-bl.sh --reload");
228
	break;
207
	break;
229
case 'Specific_filtering' :
208
case 'Specific_filtering' :
230
	$pureip="-pureip_off"; $safesearch="-safesearch_off"; ;
209
	$pureip="-pureip_off"; $safesearch="-safesearch_off"; ;
231
	foreach ($_POST as $key => $value)
210
	foreach ($_POST as $key => $value)
232
	{
211
	{
233
		if (strstr($key,'chk-ip')) $pureip="-pureip_on";
212
		if (strstr($key,'chk-ip')) $pureip="-pureip_on";
234
		if (strstr($key,'chk-safesearch')) $safesearch="-safesearch_on";
213
		if (strstr($key,'chk-safesearch')) $safesearch="-safesearch_on";
235
	}
214
	}
236
	exec ("sudo /usr/local/bin/alcasar-url_filter_bl.sh $safesearch $pureip");
215
	exec ("sudo /usr/local/bin/alcasar-url_filter_bl.sh $safesearch $pureip");
237
	break;
216
	break;
238
case 'MAJ_ossi_file' :
217
case 'MAJ_ossi_file' :
239
	foreach($_POST as $fichier => $value)
218
	foreach($_POST as $fichier => $value)
240
	{
219
	{
241
		if($fichier != "choix")
220
		if($fichier != "choix")
242
		{
221
		{
243
			$action=$_POST[$fichier];
222
			$action=$_POST[$fichier];
244
			if($action == $l_remove) //delete
223
			if($action == $l_remove) //delete
245
			{
224
			{
246
				exec("/bin/sed -i \"/^$fichier$/d\" $wl_categories_enabled"); 
225
				exec("/bin/sed -i \"/^$fichier$/d\" $wl_categories_enabled"); 
247
				exec("rm -rf $dir_blacklist$fichier");
226
				exec("rm -rf $dir_blacklist$fichier");
248
				exec ("sudo /usr/local/bin/alcasar-bl.sh --reload");
227
				exec ("sudo /usr/local/bin/alcasar-bl.sh --reload");
249
			}
228
			}
250
			if($action == $l_disable) //disable
229
			if($action == $l_disable) //disable
251
			{
230
			{
252
				exec("/bin/sed -i \"/^$fichier$/d\" $wl_categories_enabled"); 
231
				exec("/bin/sed -i \"/^$fichier$/d\" $wl_categories_enabled"); 
253
				exec("sudo /usr/local/bin/alcasar-bl.sh --reload");
232
				exec("sudo /usr/local/bin/alcasar-bl.sh --reload");
254
			}
233
			}
255
			if($action == $l_enable) //enable
234
			if($action == $l_enable) //enable
256
			{
235
			{
257
				file_put_contents ($wl_categories_enabled, $fichier."/n", FILE_APPEND);
236
				file_put_contents ($wl_categories_enabled, $fichier."/n", FILE_APPEND);
258
				exec ("sudo /usr/local/bin/alcasar-bl.sh --reload");
237
				exec ("sudo /usr/local/bin/alcasar-bl.sh --reload");
259
			}
238
			}
260
		}
239
		}
261
	}
240
	}
262
	break;
241
	break;
263
case 'MAJ_ossi_file_upload' :
242
case 'MAJ_ossi_file_upload' :
264
	$file_name = str_replace (".", "_",basename($_FILES['fichier_ip']['name']));
243
	$file_name = str_replace (".", "_",basename($_FILES['fichier_ip']['name']));
265
	if(!empty($file_name))
244
	if(!empty($file_name))
266
	{	
245
	{	
267
		$dest_dir = $dir_blacklist."ossi-wl-".$file_name;
246
		$dest_dir = $dir_blacklist."ossi-wl-".$file_name;
268
		exec ("mkdir $dest_dir");
247
		exec ("mkdir $dest_dir");
269
		$file=$_FILES['fichier_ip']['tmp_name'];
248
		$file=$_FILES['fichier_ip']['tmp_name'];
270
                exec("/usr/bin/dos2unix $file $file");
249
                exec("/usr/bin/dos2unix $file $file");
271
		if(move_uploaded_file($_FILES['fichier_ip']['tmp_name'], $dest_dir."/domains"))
250
		if(move_uploaded_file($_FILES['fichier_ip']['tmp_name'], $dest_dir."/domains"))
272
		{
251
		{
273
			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
274
			file_put_contents ($wl_categories, $dest_dir."\n", FILE_APPEND);
253
			file_put_contents ($wl_categories, $dest_dir."\n", FILE_APPEND);
275
			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
276
			exec ("sudo /usr/local/bin/alcasar-bl.sh --reload");
255
			exec ("sudo /usr/local/bin/alcasar-bl.sh --reload");
277
		}
256
		}
278
		else
257
		else
279
		{
258
		{
280
			exec("rm -rf $dest_dir");
259
			exec("rm -rf $dest_dir");
281
			echo $l_error_upload;
260
			echo $l_error_upload;
282
		}
261
		}
283
	}
262
	}
284
	break;
263
	break;
285
}
264
}
286
?>
265
?>
287
<table width="100%" border="0" cellspacing="0" cellpadding="0">
266
<table width="100%" border="0" cellspacing="0" cellpadding="0">
288
	<tr><th><?php echo $l_wl; ?></th></tr>
267
	<tr><th><?php echo $l_wl; ?></th></tr>
289
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
268
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
290
</table>
269
</table>
291
<table width="100%" border=1 cellspacing=0 cellpadding=1>
270
<table width="100%" border=1 cellspacing=0 cellpadding=1>
292
<tr><td valign="middle" align="left" colspan=10>
271
<tr><td valign="middle" align="left" colspan=10>
293
<FORM action='wl_filter.php' method=POST>
272
<FORM action='wl_filter.php' method=POST>
294
<input type='hidden' name='choix' value='MAJ_cat_wl'>
273
<input type='hidden' name='choix' value='MAJ_cat_wl'>
295
<?php
274
<?php
296
echo "<center>";
275
echo "<center>";
297
// total number of IP, DNS & URLs
276
// total number of IP, DNS & URLs
298
$nbDomainNames = exec ("wc -l /usr/local/share/dnsmasq-wl/* | tail -n 1 | awk '{print $1}'");
277
$nbDomainNames = exec ("wc -l /usr/local/share/dnsmasq-wl/* | tail -n 1 | awk '{print $1}'");
299
$nbUrl = "0";
278
$nbUrl = "0";
300
$nbIp = exec ("wc -l /usr/local/share/iptables-wl/* | tail -n 1 | awk '{print $1}'");
279
$nbIp = exec ("wc -l /usr/local/share/iptables-wl/* | tail -n 1 | awk '{print $1}'");
301
echo "<b>$l_nbDomainNames</b> $nbDomainNames, <b>$l_nbUrl</b> $nbUrl, <b>$l_nbIp</b> $nbIp<br/>";
280
echo "<b>$l_nbDomainNames</b> $nbDomainNames, <b>$l_nbUrl</b> $nbUrl, <b>$l_nbIp</b> $nbIp<br/>";
302
echo "$l_wl_categories</center></td></tr>";	
281
echo "$l_wl_categories</center></td></tr>";	
303
//read & display all WL categories (checked or not)
282
//read & display all WL categories (checked or not)
304
$cols=1; 
283
$cols=1; 
305
if (file_exists($wl_categories))
284
if (file_exists($wl_categories))
306
	{
285
	{
307
	$wl_files = file($wl_categories);
286
	$wl_files = file($wl_categories);
308
	$wl_files = preg_grep("/ossi-/", $wl_files, 1); // don't display ossi custom categories
287
	$wl_files = preg_grep("/ossi-/", $wl_files, 1); // don't display ossi custom categories
309
	foreach($wl_files as $fichier => $value)
288
	foreach($wl_files as $fichier => $value)
310
		{
289
		{
311
		if ($cols == 1) { echo "<tr>";}
290
		if ($cols == 1) { echo "<tr>";}
312
		$categorie=trim(basename($value));
291
		$categorie=trim(basename($value));
313
		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>";
292
		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>";
314
		echo "<input type='checkbox' name='chk-$categorie'";
293
		echo "<input type='checkbox' name='chk-$categorie'";
315
		// if the line is commented, the category is disable
294
		// if the line is commented, the category is disable
316
		if (preg_match('/^#/',$value, $r)) { echo ">";}
295
		if (preg_match('/^#/',$value, $r)) { echo ">";}
317
		else { echo "checked>"; }
296
		else { echo "checked>"; }
318
		echo "</td>";
297
		echo "</td>";
319
		$cols++;
298
		$cols++;
320
		if ($cols > 10) {
299
		if ($cols > 10) {
321
			echo "</tr>";
300
			echo "</tr>";
322
			$cols=1; }
301
			$cols=1; }
323
		}
302
		}
324
	}
303
	}
325
else	{
304
else	{
326
	echo "$l_error_open_file $wl_categories";
305
	echo "$l_error_open_file $wl_categories";
327
}
306
}
328
echo "<tr><td valign='middle' align='left' colspan=10>";
307
echo "<tr><td valign='middle' align='left' colspan=10>";
329
echo "<center><b>$l_add_to_wl</b></center></td></tr>";
308
echo "<center><b>$l_add_to_wl</b></center></td></tr>";
330
echo "<tr><td width=100% colspan=10 align=center>";
309
echo "<tr><td width=100% colspan=10 align=center>";
331
echo "$l_one_dns_ip<BR>";
310
echo "$l_one_dns_ip<BR>";
332
echo "<textarea name='OSSI_wl' rows=3 cols=40>";
311
echo "<textarea name='OSSI_wl' rows=3 cols=40>";
333
echo_file ($dir_blacklist."ossi-wl/domains");
312
echo_file ($dir_blacklist."ossi-wl/domains");
334
echo "</textarea></td>";
313
echo "</textarea></td>";
335
echo "</tr><tr><td colspan=10>";
314
echo "</tr><tr><td colspan=10>";
336
echo "<input type='submit' onClick=\"this.disabled=true; this.value='$l_load';submit();\" value='$l_record'>";
315
echo "<input type='submit' onClick=\"this.disabled=true; this.value='$l_load';submit();\" value='$l_record'>";
337
echo "</form> ($l_wait)";
316
echo "</form> ($l_wait)";
338
echo "</td></tr></table><br/>";
317
echo "</td></tr></table><br/>";
339
?>
318
?>
340
<table width="100%" border="0" cellspacing="0" cellpadding="0">
319
<table width="100%" border="0" cellspacing="0" cellpadding="0">
341
	<tr><th><?php echo $l_additional_file_title; ?></th></tr>
320
	<tr><th><?php echo $l_additional_file_title; ?></th></tr>
342
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
321
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
343
</table>
322
</table>
344
<table width="100%" border=1 cellspacing=0 cellpadding=1>
323
<table width="100%" border=1 cellspacing=0 cellpadding=1>
345
<form action='wl_filter.php' method='POST'>
324
<form action='wl_filter.php' method='POST'>
346
<input type='hidden' name='choix' value='MAJ_ossi_file'>
325
<input type='hidden' name='choix' value='MAJ_ossi_file'>
347
<?php
326
<?php
348
echo "<tr><td width=50% colspan=5 align=center>";
327
echo "<tr><td width=50% colspan=5 align=center>";
349
echo "<H3>$l_file_list</H3>";
328
echo "<H3>$l_file_list</H3>";
350
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
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>";
351
 
330
 
352
//list OSSI custom categories
331
//list OSSI custom categories
353
$fichierswl = array_diff(scandir($dir_blacklist), array('..','.','ossi-bl','ossi-wl'));
332
$fichierswl = array_diff(scandir($dir_blacklist), array('..','.','ossi-bl','ossi-wl'));
354
$fichierswl = preg_grep("/^ossi-wl-/",$fichierswl);
333
$fichierswl = preg_grep("/^ossi-wl-/",$fichierswl);
355
foreach($fichierswl as $fichier => $value)
334
foreach($fichierswl as $fichier => $value)
356
{
335
{
357
	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'";
336
	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'";
358
	if (file_exists ($dir_wl_domain_names_enabled.$value)) echo " value='$l_disable'>"; else echo " value='$l_enable'>";
337
	if (file_exists ($dir_wl_domain_names_enabled.$value)) echo " value='$l_disable'>"; else echo " value='$l_enable'>";
359
	echo "</center></td><td><center><input type='submit' name='$value' value='$l_remove'></center></td></tr>";
338
	echo "</center></td><td><center><input type='submit' name='$value' value='$l_remove'></center></td></tr>";
360
}
339
}
361
echo "</table><br/></td></form><form action='wl_filter.php' method='POST' enctype='multipart/form-data'>";
340
echo "</table><br/></td></form><form action='wl_filter.php' method='POST' enctype='multipart/form-data'>";
362
echo "<input type='hidden' name='choix' value='MAJ_ossi_file_upload'><td width=50% colspan=5 align=center>";
341
echo "<input type='hidden' name='choix' value='MAJ_ossi_file_upload'><td width=50% colspan=5 align=center>";
363
echo "<H3>$l_add_file</H3>";
342
echo "<H3>$l_add_file</H3>";
364
echo "$l_add_file_explain";
343
echo "$l_add_file_explain";
365
echo "<input type='file' name='fichier_ip'>";
344
echo "<input type='file' name='fichier_ip'>";
366
echo "<input type='submit' onClick=\"this.disabled=true; this.value='$l_load';submit();\" value='$l_submit'>";
345
echo "<input type='submit' onClick=\"this.disabled=true; this.value='$l_load';submit();\" value='$l_submit'>";
367
echo "</td></tr>";
346
echo "</td></tr>";
368
echo "</form>";
347
echo "</form>";
369
echo "</table><br/>";
348
echo "</table><br/>";
370
?>
349
?>
371
<table width="100%" border="0" cellspacing="0" cellpadding="0">
350
<table width="100%" border="0" cellspacing="0" cellpadding="0">
372
	<tr><th><?php echo $l_specific_filtering; ?></th></tr>
351
	<tr><th><?php echo $l_specific_filtering; ?></th></tr>
373
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
352
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
374
</table>
353
</table>
375
<TABLE width="100%" border=1 cellspacing=0 cellpadding=1>
354
<TABLE width="100%" border=1 cellspacing=0 cellpadding=1>
376
<FORM action='wl_filter.php' method='POST'>
355
<FORM action='wl_filter.php' method='POST'>
377
<input type='hidden' name='choix' value='Specific_filtering'>
356
<input type='hidden' name='choix' value='Specific_filtering'>
378
<tr><td>
357
<tr><td>
379
<input type='checkbox' name='chk-ip'
358
<input type='checkbox' name='chk-ip'
380
<?php
359
<?php
381
// verify "pureip" filtering state
360
// verify "pureip" filtering state
382
if (file_exists($bannedsite_file))
361
if (file_exists($bannedsite_file))
383
	{
362
	{
384
	$pointeur=fopen($bannedsite_file,"r");
363
	$pointeur=fopen($bannedsite_file,"r");
385
	while (!feof ($pointeur))
364
	while (!feof ($pointeur))
386
		{
365
		{
387
		$ligne=fgets($pointeur, 4096);
366
		$ligne=fgets($pointeur, 4096);
388
		if ($ligne)
367
		if ($ligne)
389
			{
368
			{
390
			if (preg_match('/^\*ip$/',$ligne, $r)) 
369
			if (preg_match('/^\*ip$/',$ligne, $r)) 
391
				{
370
				{
392
				echo " checked";
371
				echo " checked";
393
				break;
372
				break;
394
				}
373
				}
395
			}
374
			}
396
		}
375
		}
397
	fclose($pointeur);
376
	fclose($pointeur);
398
	}
377
	}
399
else	{
378
else	{
400
	echo "$l_error_open_file $bannedsite_file";
379
	echo "$l_error_open_file $bannedsite_file";
401
	}
380
	}
402
echo "> $l_ip_filtering";
381
echo "> $l_ip_filtering";
403
?>
382
?>
404
</td></tr>
383
</td></tr>
405
<tr><td>
384
<tr><td>
406
<input type='checkbox' name='chk-safesearch'
385
<input type='checkbox' name='chk-safesearch'
407
<?php
386
<?php
408
// verify "safesearch" filtering state
387
// verify "safesearch" filtering state
409
if (file_exists($urlregex_file))
388
if (file_exists($urlregex_file))
410
	{
389
	{
411
	$pointeur=fopen($urlregex_file,"r");
390
	$pointeur=fopen($urlregex_file,"r");
412
	while (!feof ($pointeur))
391
	while (!feof ($pointeur))
413
		{
392
		{
414
		$ligne=fgets($pointeur, 4096);
393
		$ligne=fgets($pointeur, 4096);
415
		if ($ligne)
394
		if ($ligne)
416
			{
395
			{
417
			if (preg_match('/^\"\(\^http\:\/\/\[0\-9a\-z\]\+\\\.google/',$ligne, $r))
396
			if (preg_match('/^\"\(\^http\:\/\/\[0\-9a\-z\]\+\\\.google/',$ligne, $r))
418
				{
397
				{
419
				echo " checked";
398
				echo " checked";
420
				break;
399
				break;
421
				}
400
				}
422
			}
401
			}
423
		}
402
		}
424
	fclose($pointeur);
403
	fclose($pointeur);
425
	}
404
	}
426
else	{
405
else	{
427
	echo "$l_error_open_file $urlregex_file";
406
	echo "$l_error_open_file $urlregex_file";
428
	}
407
	}
429
echo "> $l_safe_searching";
408
echo "> $l_safe_searching";
430
echo "<br>$l_safe_youtube";
409
echo "<br>$l_safe_youtube";
431
echo " $l_youtube_id<tr><td>";
410
echo " $l_youtube_id<tr><td>";
432
echo "<input type='submit' onClick=\"this.disabled=true; this.value='$l_load';submit();\" value='$l_record'></td></tr>";
411
echo "<input type='submit' onClick=\"this.disabled=true; this.value='$l_load';submit();\" value='$l_record'></td></tr>";
433
?>
412
?>
434
</FORM> 
413
</FORM> 
435
</TABLE>
414
</TABLE>
436
</BODY>
415
</BODY>
437
</HTML>
416
</HTML>
438
 
417
 
439
 
418
 
440
 
419