Subversion Repositories ALCASAR

Rev

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

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