Subversion Repositories ALCASAR

Rev

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

Rev 1899 Rev 1903
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 Whitelist filtering</TITLE>
5
<TITLE>ALCASAR Whitelist 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
			$line = split("\n", $tampon);
47
			$line = split("\n", $tampon);
48
			foreach( $line as $x)
48
			foreach( $line as $x)
49
			{
49
			{
50
				if(isset(split('/',$x)[1]))
50
				if(isset(split('/',$x)[1]))
51
				echo split('/',$x)[1]."\n";
51
				echo split('/',$x)[1]."\n";
52
			}
52
			}
53
			fclose($pointeur);
53
			fclose($pointeur);
54
			}
54
			}
55
		}
55
		}
56
	else
56
	else
57
		{
57
		{
58
		echo "$filename doesn't exist";
58
		echo "$filename doesn't exist";
59
		}
59
		}
60
	}
60
	}
61
function echo_ip_file ($filename)
61
function echo_ip_file ($filename)
62
{
62
{
63
	exec("cat $filename | cut -d ' ' -f3", $resultat);
63
	exec("cat $filename | cut -d ' ' -f3", $resultat);
64
	for($i=0; $i<exec("wc -l $filename"); $i++)
64
	for($i=0; $i<exec("wc -l $filename"); $i++)
65
	{
65
	{
66
		echo $resultat[$i]."\n";
66
		echo $resultat[$i]."\n";
67
	}
67
	}
68
}
68
}
69
 
69
 
70
#maximum length for top-level DNS
70
#maximum length for top-level DNS
71
function max_tld()
71
function max_tld()
72
{
72
{
73
	$url_tld = "http://data.iana.org/TLD/tlds-alpha-by-domain.txt";
73
	$url_tld = "http://data.iana.org/TLD/tlds-alpha-by-domain.txt";
74
	$result_tld = file_get_contents($url_tld,false);
74
	$result_tld = file_get_contents($url_tld,false);
75
	$max_tld = 18; 							#valeur de base si le site ne répond plus
75
	$max_tld = 18; 							#valeur de base si le site ne répond plus
76
	if($result_tld !== FALSE){
76
	if($result_tld !== FALSE){
77
		foreach(explode("\n", $result_tld) as $line)
77
		foreach(explode("\n", $result_tld) as $line)
78
		{
78
		{
79
			if((strpos($line,'-') === false) and (strpos($line,'#') === false))
79
			if((strpos($line,'-') === false) and (strpos($line,'#') === false))
80
			{
80
			{
81
				if(strlen($line) > $max_tld)
81
				if(strlen($line) > $max_tld)
82
				{
82
				{
83
					$max_tld = strlen($line);
83
					$max_tld = strlen($line);
84
				}
84
				}
85
			}
85
			}
86
		}
86
		}
87
	}
87
	}
88
	return $max_tld;
88
	return $max_tld;
89
}
89
}
90
 
90
 
91
# Choice of language
91
# Choice of language
92
$Language = 'en';
92
$Language = 'en';
93
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
93
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
94
	$Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
94
	$Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
95
	$Language = strtolower(substr(chop($Langue[0]),0,2)); }
95
	$Language = strtolower(substr(chop($Langue[0]),0,2)); }
96
if($Language == 'fr'){
96
if($Language == 'fr'){
97
	$l_wl="Liste blanche";
97
	$l_wl="Liste blanche";
98
	$l_load="Chargement...";
98
	$l_load="Chargement...";
99
	$l_list_version="Version de la liste : ";
99
	$l_list_version="Version de la liste : ";
100
	$l_specific_filtering="Filtrage special";
100
	$l_specific_filtering="Filtrage special";
101
	$l_wl_categories="Sélectionnez les catégories à autoriser";
101
	$l_wl_categories="Sélectionnez les catégories à autoriser";
102
	$l_allowed_dns="Noms de domaine autorisés";
102
	$l_allowed_dns="Noms de domaine autorisés";
103
	$l_one_dns="Entrez un nom de domaine par ligne (exemple : .domaine.org)";
103
	$l_one_dns="Entrez un nom de domaine par ligne (exemple : .domaine.org)";
104
	$l_add_to_wl="Noms de domaine ou IP ajoutés à la liste blanche";
104
	$l_add_to_wl="Noms de domaine ou IP ajoutés à la liste blanche";
105
	$l_forbidden_ip_explain="Entrez une IP par ligne (exemple : 123.123.123.123)<br/>ou une adresse de réseau (exemple : 123.123.0.0/16)";
105
	$l_forbidden_ip_explain="Entrez une IP par ligne (exemple : 123.123.123.123)<br/>ou une adresse de réseau (exemple : 123.123.0.0/16)";
106
	$l_allowed_ip="IP autorisées";
106
	$l_allowed_ip="IP autorisées";
107
	$l_record="Enregistrer les modifications";
107
	$l_record="Enregistrer les modifications";
108
	$l_wait="Une fois validées, 10 secondes sont nécessaires pour traiter vos modifications";
108
	$l_wait="Une fois validées, 10 secondes sont nécessaires pour traiter vos modifications";
109
	$l_error_open_file="Erreur d'ouverture du fichier";
109
	$l_error_open_file="Erreur d'ouverture du fichier";
110
	$l_additional_file_title="Fichiers de 'listes blanche' additionnels";
110
	$l_additional_file_title="Fichiers de 'listes blanche' additionnels";
111
	$l_file_list="Liste des fichiers";
111
	$l_file_list="Liste des fichiers";
112
	$l_add_file="Ajouter un fichier";
112
	$l_add_file="Ajouter un fichier";
113
	$l_add_file_explain="Chaque ligne du fichier doit être une adresse IP ou un nom de domaine"; 
113
	$l_add_file_explain="Chaque ligne du fichier doit être une adresse IP ou un nom de domaine"; 
114
	$l_file_name="Nom du fichier";
114
	$l_file_name="Nom du fichier";
115
	$l_file_remove="Supprimer";
115
	$l_file_remove="Supprimer";
116
	$l_error_upload="Erreur d'envoi du fichier";
116
	$l_error_upload="Erreur d'envoi du fichier";
117
	$l_remove="Supprimer";
117
	$l_remove="Supprimer";
118
	$l_submit="Envoyer";
118
	$l_submit="Envoyer";
119
	$l_nb_ip="Nombre d'IP";
119
	$l_nb_ip="Nombre d'IP";
120
	$l_nb_domain_names="Nombre de noms de domaine";
120
	$l_nb_domain_names="Nombre de noms de domaine";
121
	$l_nbDomainNames="Noms de domaine :";
121
	$l_nbDomainNames="Noms de domaine :";
122
	$l_nbUrl="Url :";
122
	$l_nbUrl="Url :";
123
	$l_nbIp="Ip :";
123
	$l_nbIp="Ip :";
124
	$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)";
124
	$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)";
125
	$l_safe_searching="Activer le contrôle scolaire/parental des moteurs de recherche : google, yahoo, bing, metacrawler et Youtube.";
125
	$l_safe_searching="Activer le contrôle scolaire/parental des moteurs de recherche : google, yahoo, bing, metacrawler et Youtube.";
126
	$l_safe_youtube="Pour Youtube restreint, suivez les étapes ici pour chaque poste : "; 
126
	$l_safe_youtube="Pour Youtube restreint, suivez les étapes ici pour chaque poste : "; 
127
	$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>)";
127
	$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>)";
128
	$l_disable="Désactiver";
128
	$l_disable="Désactiver";
129
	$l_enable="Activer";
129
	$l_enable="Activer";
130
	$l_file_state="Etat";
130
	$l_file_state="Etat";
131
}
131
}
132
else {
132
else {
133
	$l_wl="WhiteList";
133
	$l_wl="WhiteList";
134
	$l_load="Loading...";
134
	$l_load="Loading...";
135
	$l_list_version="List version : ";
135
	$l_list_version="List version : ";
136
	$l_wl_categories="Select the categories to allow";
136
	$l_wl_categories="Select the categories to allow";
137
	$l_allowed_dns="Allowed domain names";
137
	$l_allowed_dns="Allowed domain names";
138
	$l_one_dns="Enter one domain name per row (example : .domain.org)";
138
	$l_one_dns="Enter one domain name per row (example : .domain.org)";
139
	$l_add_to_wl="Domain names or IP to add to whitelist";
139
	$l_add_to_wl="Domain names or IP to add to whitelist";
140
	$l_forbidden_ip_explain="Enter one IP per row (example : 123.123.123.123)<br/>or a network address (example : 123.123.0.0/16)";
140
	$l_forbidden_ip_explain="Enter one IP per row (example : 123.123.123.123)<br/>or a network address (example : 123.123.0.0/16)";
141
	$l_allowed_ip="Allowed IP";
141
	$l_allowed_ip="Allowed IP";
142
	$l_record="Save changes";
142
	$l_record="Save changes";
143
	$l_wait="Once validated, 10 seconds are necessary to compute your modifications";
143
	$l_wait="Once validated, 10 seconds are necessary to compute your modifications";
144
	$l_error_open_file="Error opening file";
144
	$l_error_open_file="Error opening file";
145
	$l_additional_file_title="Additional whitelist files";
145
	$l_additional_file_title="Additional whitelist files";
146
	$l_file_list="Files list";
146
	$l_file_list="Files list";
147
	$l_add_file="Add a file";
147
	$l_add_file="Add a file";
148
	$l_add_file_explain="Each line of the file must be an IP address or a domain name"; 
148
	$l_add_file_explain="Each line of the file must be an IP address or a domain name"; 
149
	$l_file_name="Filename";
149
	$l_file_name="Filename";
150
	$l_file_remove="Remove";
150
	$l_file_remove="Remove";
151
	$l_error_upload="Error during the upload process";
151
	$l_error_upload="Error during the upload process";
152
	$l_remove="Delete";
152
	$l_remove="Delete";
153
	$l_submit="Submit";
153
	$l_submit="Submit";
154
	$l_nb_ip="Number of IP";
154
	$l_nb_ip="Number of IP";
155
	$l_nb_domain_names="Number of domain names";
155
	$l_nb_domain_names="Number of domain names";
156
	$l_nbDomainNames="Domain names :";
156
	$l_nbDomainNames="Domain names :";
157
	$l_nbUrl="Url :";
157
	$l_nbUrl="Url :";
158
	$l_nbIp="Ip :";
158
	$l_nbIp="Ip :";
159
	$l_ip_filtering="Filtering URLs that contain an IP address instead of a domain name (ie: http://25.56.58.59/index.htm)";
159
	$l_ip_filtering="Filtering URLs that contain an IP address instead of a domain name (ie: http://25.56.58.59/index.htm)";
160
	$l_specific_filtering="Specific filtering";
160
	$l_specific_filtering="Specific filtering";
161
	$l_safe_youtube="For safe Youtube, follow steps here for each computer "; 
161
	$l_safe_youtube="For safe Youtube, follow steps here for each computer "; 
162
	$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>)";
162
	$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>)";
163
	$l_safe_searching="Enabling school/parental control for the search engines google."; 
163
	$l_safe_searching="Enabling school/parental control for the search engines google."; 
164
	$l_disable="Disable";
164
	$l_disable="Disable";
165
	$l_enable="Enable";
165
	$l_enable="Enable";
166
	$l_file_state="State";
166
	$l_file_state="State";
167
}
167
}
168
$dir_etc="/usr/local/etc/";
168
$dir_etc="/usr/local/etc/";
169
$dir_dg="/etc/dansguardian/lists/";
169
$dir_dg="/etc/dansguardian/lists/";
170
$file_wl_domains="/usr/local/share/dnsmasq-wl/ossi.conf";
170
$file_wl_domains="/usr/local/share/dnsmasq-wl/ossi.conf";
171
$file_wl_ip="/usr/local/share/iptables-wl-enabled/ossi";
171
$file_wl_ip="/usr/local/share/iptables-wl-enabled/ossi";
172
$wl_categories=$dir_etc."alcasar-wl-categories";
172
$wl_categories=$dir_etc."alcasar-wl-categories";
173
$wl_categories_enabled=$dir_etc."alcasar-wl-categories-enabled";
173
$wl_categories_enabled=$dir_etc."alcasar-wl-categories-enabled";
174
$conf_file=$dir_etc."alcasar.conf";
174
$conf_file=$dir_etc."alcasar.conf";
175
$tinyproxy_conf="/etc/tinyproxy/tinyproxy.conf";
175
$tinyproxy_conf="/etc/tinyproxy/tinyproxy.conf";
176
$dnsmasq_conf="/etc/dnsmasq-whitelist.conf";
176
$dnsmasq_conf="/etc/dnsmasq-whitelist.conf";
177
$dir_tmp="/tmp/";
177
$dir_tmp="/tmp/";
178
$upload_dir_ip = "/usr/local/share/iptables-wl-enabled/";
178
$upload_dir_ip = "/usr/local/share/iptables-wl-enabled/";
179
$upload_dir_domain_names = "/usr/local/share/dnsmasq-wl-enabled/";
179
$upload_dir_domain_names = "/usr/local/share/dnsmasq-wl-enabled/";
180
$dir_ip = "/usr/local/share/iptables-wl/";
180
$dir_ip = "/usr/local/share/iptables-wl/";
181
$dir_domain_names = "/usr/local/share/dnsmasq-wl/";
181
$dir_domain_names = "/usr/local/share/dnsmasq-wl/";
182
# default values
182
# default values
183
if (is_file ($conf_file))
183
if (is_file ($conf_file))
184
	{
184
	{
185
	$tab=file($conf_file);
185
	$tab=file($conf_file);
186
	if ($tab)
186
	if ($tab)
187
		{
187
		{
188
		foreach ($tab as $line)
188
		foreach ($tab as $line)
189
			{
189
			{
190
			$field=explode("=", $line);
190
			$field=explode("=", $line);
191
			if ($field[0] == "DNS1")
191
			if ($field[0] == "DNS1")
192
				{
192
				{
193
					$DNS1=trim($field[1]);
193
					$DNS1=trim($field[1]);
194
				}
194
				}
195
			}
195
			}
196
		}
196
		}
197
	}
197
	}
198
else { echo "$l_error_open_file $conf_file";}
198
else { echo "$l_error_open_file $conf_file";}
199
 
199
 
200
if (isset($_POST['choix'])){ $choix=$_POST['choix']; } else { $choix=""; }
200
if (isset($_POST['choix'])){ $choix=$_POST['choix']; } else { $choix=""; }
201
switch ($choix)
201
switch ($choix)
202
{
202
{
203
case 'Specific_filtering' :
203
case 'Specific_filtering' :
204
	$safesearch="-safesearch_off"; ;
204
	$safesearch="-safesearch_off"; ;
205
	foreach ($_POST as $key => $value)
205
	foreach ($_POST as $key => $value)
206
	{
206
	{
207
		if (strstr($key,'chk-safesearch')) $safesearch="-safesearch_on";
207
		if (strstr($key,'chk-safesearch')) $safesearch="-safesearch_on";
208
	}
208
	}
209
	exec ("sudo /usr/local/bin/alcasar-url_filter_wl.sh $safesearch");
209
	exec ("sudo /usr/local/bin/alcasar-url_filter_wl.sh $safesearch");
210
	break;
210
	break;
211
case 'MAJ_cat_wl' :
211
case 'MAJ_cat_wl' :
212
	if (file_exists($wl_categories_enabled))
212
	if (file_exists($wl_categories_enabled))
213
		{
213
		{
214
		$pointeur=fopen($wl_categories_enabled, "w+");
214
		$pointeur=fopen($wl_categories_enabled, "w+");
215
		foreach ($_POST as $key => $value)
215
		foreach ($_POST as $key => $value)
216
			{
216
			{
217
			if (strstr($key,'chk-'))
217
			if (strstr($key,'chk-'))
218
				{	
218
				{	
219
				$line=str_replace('chk-','',$key)."\n";
219
				$line=str_replace('chk-','',$key)."\n";
220
				fwrite($pointeur,$line);
220
				fwrite($pointeur,$line);
221
				}
221
				}
222
			}
222
			}
223
		fclose($pointeur);
223
		fclose($pointeur);
224
		}
224
		}
225
	else {echo "$l_error_open_file $wl_categories_enabled";}
225
	else {echo "$l_error_open_file $wl_categories_enabled";}
226
	$fichier=fopen($file_wl_domains,"w+");
226
	$fichier=fopen($file_wl_domains,"w+");
227
	fputs($fichier, form_filter($_POST['OSSI_wl_domains']));
227
	fputs($fichier, form_filter($_POST['OSSI_wl_domains']));
228
	fclose($fichier);
228
	fclose($fichier);
229
	unset($_POST['OSSI_wl_domains']);
229
	unset($_POST['OSSI_wl_domains']);
230
	$fichier=fopen($file_wl_ip, "w+");
230
	$fichier=fopen($file_wl_ip, "w+");
231
	fputs($fichier, form_filter_ip($_POST['OSSI_wl_ip'], "white"));
231
	fputs($fichier, form_filter_ip($_POST['OSSI_wl_ip'], "white"));
232
	fclose($fichier);
232
	fclose($fichier);
233
	unset($_POST['OSSI_wl_ip']);
233
	unset($_POST['OSSI_wl_ip']);
234
	exec ("sudo /usr/local/bin/alcasar-bl.sh --reload");
234
	exec ("sudo /usr/local/bin/alcasar-bl.sh --reload");
235
	break;
235
	break;
236
	case 'MAJ_ip_file_delete' :
236
	case 'MAJ_ip_file_delete' :
237
	foreach($_POST as $fichier => $value)
237
	foreach($_POST as $fichier => $value)
238
	{
238
	{
239
		if($fichier != "choix")
239
		if($fichier != "choix")
240
		{
240
		{
241
			$action=$_POST[$fichier];
241
			$action=$_POST[$fichier];
242
			if($action == $l_remove) //delete
242
			if($action == $l_remove) //delete
243
			{
243
			{
244
				exec("rm -rf $upload_dir_ip$fichier");
244
				exec("rm -rf $upload_dir_ip$fichier");
245
				exec("rm -rf $upload_dir_domain_names$fichier");
245
				exec("rm -rf $upload_dir_domain_names$fichier");
-
 
246
				exec("rm -rf $dir_ip$fichier");
-
 
247
				exec("rm -rf $dir_domain_names$fichier");
246
				exec ("sudo /usr/local/bin/alcasar-bl.sh --reload");
248
				exec ("sudo /usr/local/bin/alcasar-bl.sh --reload");
247
			}
249
			}
248
			if($action == $l_disable) //disable
250
			if($action == $l_disable) //disable
249
			{
251
			{
250
				exec("mv -f $upload_dir_ip$fichier $dir_ip$fichier");
252
				exec("mv -f $upload_dir_ip$fichier $dir_ip$fichier");
251
				exec("mv -f $upload_dir_domain_names$fichier $dir_domain_names$fichier");
253
				exec("mv -f $upload_dir_domain_names$fichier $dir_domain_names$fichier");
252
				exec("sudo /usr/local/bin/alcasar-bl.sh --reload");
254
				exec("sudo /usr/local/bin/alcasar-bl.sh --reload");
253
			}
255
			}
254
			if($action == $l_enable) //enable
256
			if($action == $l_enable) //enable
255
			{
257
			{
256
				exec("mv -f $dir_ip$fichier $upload_dir_ip$fichier");
258
				exec("mv -f $dir_ip$fichier $upload_dir_ip$fichier");
257
				exec("mv -f $dir_domain_names$fichier $upload_dir_domain_names$fichier");
259
				exec("mv -f $dir_domain_names$fichier $upload_dir_domain_names$fichier");
258
				exec ("sudo /usr/local/bin/alcasar-bl.sh --reload");
260
				exec ("sudo /usr/local/bin/alcasar-bl.sh --reload");
259
			}
261
			}
260
		}
262
		}
261
	}
263
	}
262
	break;
264
	break;
263
case 'MAJ_ip_file_upload' :
265
case 'MAJ_ip_file_upload' :
264
	$nom = str_replace (".", "_",basename($_FILES['fichier_ip']['name']));
266
	$nom = str_replace (".", "_",basename($_FILES['fichier_ip']['name']));
265
	# Si un fichier a été choisi
267
	# Si un fichier a été choisi
266
	if(!empty($nom))
268
	if(!empty($nom))
267
	{	
269
	{	
268
		# On l'upload
270
		# On l'upload
269
		if(move_uploaded_file($_FILES['fichier_ip']['tmp_name'], $upload_dir_ip.$nom))
271
		if(move_uploaded_file($_FILES['fichier_ip']['tmp_name'], $upload_dir_ip.$nom))
270
		{
272
		{
271
		
273
		
272
		# On extrait uniquement les ip du fichier
274
		# On extrait uniquement les ip du fichier
273
		exec("grep -Eo '([0-9]{1,3}\.){3}[0-9]{1,3}' $upload_dir_ip$nom > $upload_dir_ip\ossi_ip");
275
		exec("grep -Eo '([0-9]{1,3}\.){3}[0-9]{1,3}' $upload_dir_ip$nom > $upload_dir_ip\ossi_ip");
274
 
276
 
275
		# Suppression des doublons
277
		# Suppression des doublons
276
		exec("sort -u $upload_dir_ip\ossi_ip > $upload_dir_ip\ossi-$nom && rm -f $upload_dir_ip\ossi_ip");
278
		exec("sort -u $upload_dir_ip\ossi_ip > $upload_dir_ip\ossi-$nom && rm -f $upload_dir_ip\ossi_ip");
277
 
279
 
278
		# On adapte le fichier à la sauvegarde du set
280
		# On adapte le fichier à la sauvegarde du set
279
		exec("sed -i \"s/^/add wl_ip_allowed /g\" $upload_dir_ip\ossi-$nom"); 
281
		exec("sed -i \"s/^/add wl_ip_allowed /g\" $upload_dir_ip\ossi-$nom"); 
280
		
282
		
281
		# On extrait uniquement les noms de domaine
283
		# On extrait uniquement les noms de domaine
282
		# max_tld() retourne le nombre max de charactere pour un top-level dns
284
		# max_tld() retourne le nombre max de charactere pour un top-level dns
283
		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");
285
		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");
284
 
286
 
285
		# Suppression des doublons
287
		# Suppression des doublons
286
		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");
288
		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");
287
 
289
 
288
		# On adapte le fichier pour Dnsmasq
290
		# On adapte le fichier pour Dnsmasq
289
		exec("sed -i \"s/^/server=\//g\" $upload_dir_domain_names\ossi-$nom");
291
		exec("sed -i \"s/^/server=\//g\" $upload_dir_domain_names\ossi-$nom");
290
		exec("sed -i \"s/$/\/$DNS1/g\" $upload_dir_domain_names\ossi-$nom");
292
		exec("sed -i \"s/$/\/$DNS1/g\" $upload_dir_domain_names\ossi-$nom");
291
 
293
 
292
		# Suppression du fichier
294
		# Suppression du fichier
293
		exec("rm -f $upload_dir_ip$nom");
295
		exec("rm -f $upload_dir_ip$nom");
294
		
296
		
295
		}
297
		}
296
		else
298
		else
297
		{
299
		{
298
			echo $l_error_upload;
300
			echo $l_error_upload;
299
		}
301
		}
300
		exec ("sudo /usr/local/bin/alcasar-bl.sh --reload");
302
		exec ("sudo /usr/local/bin/alcasar-bl.sh --reload");
301
	}
303
	}
302
	break;
304
	break;
303
}
305
}
304
?>
306
?>
305
<table width="100%" border="0" cellspacing="0" cellpadding="0">
307
<table width="100%" border="0" cellspacing="0" cellpadding="0">
306
	<tr><th><?php echo $l_wl; ?></th></tr>
308
	<tr><th><?php echo $l_wl; ?></th></tr>
307
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
309
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
308
</table>
310
</table>
309
 
311
 
310
<TABLE width="100%" border=1 cellspacing=0 cellpadding=1>
312
<TABLE width="100%" border=1 cellspacing=0 cellpadding=1>
311
<tr><td valign="middle" align="left" colspan=10>
313
<tr><td valign="middle" align="left" colspan=10>
312
<FORM action='wl_filter.php' method=POST>
314
<FORM action='wl_filter.php' method=POST>
313
<input type='hidden' name='choix' value='MAJ_cat_wl'>
315
<input type='hidden' name='choix' value='MAJ_cat_wl'>
314
<?php
316
<?php
315
echo "<center>";
317
echo "<center>";
316
$nbDomainNames = exec ("wc -l /usr/local/share/dnsmasq-wl/* | tail -n 1 | awk '{print $1}'");
318
$nbDomainNames = exec ("wc -l /usr/local/share/dnsmasq-wl/* | tail -n 1 | awk '{print $1}'");
317
$nbUrl = 0;
319
$nbUrl = 0;
318
$nbIp = 0;
320
$nbIp = 0;
319
echo "<b>$l_nbDomainNames</b> $nbDomainNames, <b>$l_nbUrl</b> $nbUrl, <b>$l_nbIp</b> $nbIp<br/>";
321
echo "<b>$l_nbDomainNames</b> $nbDomainNames, <b>$l_nbUrl</b> $nbUrl, <b>$l_nbIp</b> $nbIp<br/>";
320
echo "$l_wl_categories</center></td></tr>";
322
echo "$l_wl_categories</center></td></tr>";
321
//on lit et on interprete le fichier de catégories
323
//on lit et on interprete le fichier de catégories
322
$cols=1; 
324
$cols=1; 
323
if (file_exists($wl_categories))
325
if (file_exists($wl_categories))
324
	{
326
	{
325
	$pointeur=fopen($wl_categories,"r");
327
	$pointeur=fopen($wl_categories,"r");
326
	while (!feof ($pointeur))
328
	while (!feof ($pointeur))
327
		{
329
		{
328
		$ligne=fgets($pointeur, 4096);
330
		$ligne=fgets($pointeur, 4096);
329
		if ($ligne)
331
		if ($ligne)
330
			{
332
			{
331
			if ($cols == 1) { echo "<tr>";}
333
			if ($cols == 1) { echo "<tr>";}
332
			$categorie=trim(basename($ligne));
334
			$categorie=trim(basename($ligne));
333
			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>";
335
			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>";
334
			echo "<input type='checkbox' name='chk-$categorie'";
336
			echo "<input type='checkbox' name='chk-$categorie'";
335
			// si la ligne est commentée -> categorie non selectionnée
337
			// si la ligne est commentée -> categorie non selectionnée
336
			if (preg_match('/^#/',$ligne, $r)) { echo ">";}
338
			if (preg_match('/^#/',$ligne, $r)) { echo ">";}
337
			else { echo "checked>"; }
339
			else { echo "checked>"; }
338
			echo "</td>";
340
			echo "</td>";
339
			$cols++;
341
			$cols++;
340
			if ($cols > 10) {
342
			if ($cols > 10) {
341
				echo "</tr>";
343
				echo "</tr>";
342
				$cols=1; }
344
				$cols=1; }
343
			}
345
			}
344
		}
346
		}
345
	fclose($pointeur);
347
	fclose($pointeur);
346
	}
348
	}
347
else	{
349
else	{
348
	echo "$l_error_open_file $wl_categories";
350
	echo "$l_error_open_file $wl_categories";
349
	}
351
	}
350
echo "<tr><td valign='middle' align='left' colspan=10>";
352
echo "<tr><td valign='middle' align='left' colspan=10>";
351
echo "<center><b>$l_add_to_wl</b></center></td></tr>";
353
echo "<center><b>$l_add_to_wl</b></center></td></tr>";
352
echo "<tr><td width=50% colspan=5 align=center>";
354
echo "<tr><td width=50% colspan=5 align=center>";
353
echo "<H3>$l_allowed_dns</H3>$l_one_dns<BR>";
355
echo "<H3>$l_allowed_dns</H3>$l_one_dns<BR>";
354
echo "<textarea name='OSSI_wl_domains' rows=3 cols=40>";
356
echo "<textarea name='OSSI_wl_domains' rows=3 cols=40>";
355
echo_file ($file_wl_domains);
357
echo_file ($file_wl_domains);
356
echo "</textarea></td>";
358
echo "</textarea></td>";
357
echo "<td width=50% colspan=5 align=center>";
359
echo "<td width=50% colspan=5 align=center>";
358
echo "<H3>$l_allowed_ip</H3>$l_forbidden_ip_explain<BR>";
360
echo "<H3>$l_allowed_ip</H3>$l_forbidden_ip_explain<BR>";
359
echo "<textarea name='OSSI_wl_ip' rows=3 cols=40>";
361
echo "<textarea name='OSSI_wl_ip' rows=3 cols=40>";
360
echo_ip_file ($file_wl_ip);
362
echo_ip_file ($file_wl_ip);
361
echo "</textarea></td></tr>";
363
echo "</textarea></td></tr>";
362
echo "<tr><td colspan=10>";
364
echo "<tr><td colspan=10>";
363
echo "<input type='submit' onClick=\"this.disabled=true; this.value='$l_load';\" value='$l_record'></form></td></tr>";
365
echo "<input type='submit' onClick=\"this.disabled=true; this.value='$l_load';\" value='$l_record'></form></td></tr>";
364
echo "</td></tr></table><br/>";
366
echo "</td></tr></table><br/>";
365
?>
367
?>
366
 
368
 
367
<table width="100%" border="0" cellspacing="0" cellpadding="0">
369
<table width="100%" border="0" cellspacing="0" cellpadding="0">
368
	<tr><th><?php echo $l_additional_file_title; ?></th></tr>
370
	<tr><th><?php echo $l_additional_file_title; ?></th></tr>
369
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
371
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
370
</table>
372
</table>
371
 
373
 
372
<table width="100%" border=1 cellspacing=0 cellpadding=1>
374
<table width="100%" border=1 cellspacing=0 cellpadding=1>
373
<form action='wl_filter.php' method='POST'>
375
<form action='wl_filter.php' method='POST'>
374
<input type='hidden' name='choix' value='MAJ_ip_file_delete'>
376
<input type='hidden' name='choix' value='MAJ_ip_file_delete'>
375
<?php
377
<?php
376
echo "<tr><td width=50% colspan=5 align=center>";
378
echo "<tr><td width=50% colspan=5 align=center>";
377
echo "<H3>$l_file_list</H3>";
379
echo "<H3>$l_file_list</H3>";
378
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>";
380
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>";
379
 
381
 
380
//liste des fichiers activés
382
//liste des fichiers activés
381
$fichiersIp = array_diff(scandir($upload_dir_ip), array('ossi','ossi-ip-safesearch','..','.'));
383
$fichiersIp = array_diff(scandir($upload_dir_ip), array('ossi','ossi-ip-safesearch','..','.'));
382
$fichiersIp = preg_grep("/^ossi-/",$fichiersIp);
384
$fichiersIp = preg_grep("/^ossi-/",$fichiersIp);
383
foreach($fichiersIp as $fichier => $value)
385
foreach($fichiersIp as $fichier => $value)
384
{
386
{
385
	echo "<tr><td><center><a href='bl_categories_help.php?liste=wl&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>";
387
	echo "<tr><td><center><a href='bl_categories_help.php?liste=wl&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>";
386
}
388
}
387
//liste des fichiers desactivés
389
//liste des fichiers desactivés
388
$fichiersIp = array_diff(scandir($dir_ip), array('ossi','ossi-ip-safesearch','..','.'));
390
$fichiersIp = array_diff(scandir($dir_ip), array('ossi','ossi-ip-safesearch','..','.'));
389
$fichiersIp = preg_grep("/^ossi-/",$fichiersIp);
391
$fichiersIp = preg_grep("/^ossi-/",$fichiersIp);
390
foreach($fichiersIp as $fichier => $value)
392
foreach($fichiersIp as $fichier => $value)
391
{
393
{
392
	echo "<tr><td bgcolor='BEBEBE'><center><a href='bl_categories_help.php?liste=wl&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 $upload_dir_ip$value | awk '{print $1}'")."</center></td><td bgcolor='BEBEBE'><center>".exec("wc -l $upload_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>";
394
	echo "<tr><td bgcolor='BEBEBE'><center><a href='bl_categories_help.php?liste=wl&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>";
393
}
395
}
394
 
396
 
395
 
397
 
396
echo "</table><br/></td></form><form action='wl_filter.php' method='POST' enctype='multipart/form-data'>";
398
echo "</table><br/></td></form><form action='wl_filter.php' method='POST' enctype='multipart/form-data'>";
397
echo "<input type='hidden' name='choix' value='MAJ_ip_file_upload'><td width=50% colspan=5 align=center>";
399
echo "<input type='hidden' name='choix' value='MAJ_ip_file_upload'><td width=50% colspan=5 align=center>";
398
echo "<H3>$l_add_file</H3>";
400
echo "<H3>$l_add_file</H3>";
399
echo "$l_add_file_explain";
401
echo "$l_add_file_explain";
400
echo "<input type='file' name='fichier_ip'>";
402
echo "<input type='file' name='fichier_ip'>";
401
echo "<input type='submit' onClick=\"this.disabled=true; this.value='$l_load';\" value='$l_submit'>";
403
echo "<input type='submit' onClick=\"this.disabled=true; this.value='$l_load';\" value='$l_submit'>";
402
echo "</td></tr>";
404
echo "</td></tr>";
403
echo "</form>";
405
echo "</form>";
404
echo "</table><br/>";
406
echo "</table><br/>";
405
?>
407
?>
406
 
408
 
407
<table width="100%" border="0" cellspacing="0" cellpadding="0">
409
<table width="100%" border="0" cellspacing="0" cellpadding="0">
408
	<tr><th><?php echo $l_specific_filtering; ?></th></tr>
410
	<tr><th><?php echo $l_specific_filtering; ?></th></tr>
409
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
411
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
410
</table>
412
</table>
411
<TABLE width="100%" border=1 cellspacing=0 cellpadding=1>
413
<TABLE width="100%" border=1 cellspacing=0 cellpadding=1>
412
<FORM action='wl_filter.php' method='POST'>
414
<FORM action='wl_filter.php' method='POST'>
413
<input type='hidden' name='choix' value='Specific_filtering'>
415
<input type='hidden' name='choix' value='Specific_filtering'>
414
<tr><td>
416
<tr><td>
415
 
417
 
416
<input type='checkbox' name='chk-safesearch'
418
<input type='checkbox' name='chk-safesearch'
417
<?php
419
<?php
418
//verification du safesearch
420
//verification du safesearch
419
if(file_exists($dnsmasq_conf))
421
if(file_exists($dnsmasq_conf))
420
{
422
{
421
	$f=fopen($dnsmasq_conf, 'r');
423
	$f=fopen($dnsmasq_conf, 'r');
422
	while(!feof($f))
424
	while(!feof($f))
423
	{
425
	{
424
		$line=fgets($f,4096);
426
		$line=fgets($f,4096);
425
		if($line && preg_match('/^address=\/\.google/',$line,$r))
427
		if($line && preg_match('/^address=\/\.google/',$line,$r))
426
		{
428
		{
427
			echo "checked";
429
			echo "checked";
428
			break;
430
			break;
429
		}
431
		}
430
	}
432
	}
431
	fclose($f);
433
	fclose($f);
432
}
434
}
433
else
435
else
434
	echo "$l_error_open_file $dnsmasq_conf";
436
	echo "$l_error_open_file $dnsmasq_conf";
435
echo "> $l_safe_searching";
437
echo "> $l_safe_searching";
436
 
438
 
437
echo "<br></br>$l_safe_youtube";
439
echo "<br></br>$l_safe_youtube";
438
echo " $l_youtube_id<tr><td>";
440
echo " $l_youtube_id<tr><td>";
439
 
441
 
440
echo "<input type='submit' onClick=\"this.disabled=true; this.value='$l_load';\" value='$l_record'></form></td></tr>";
442
echo "<input type='submit' onClick=\"this.disabled=true; this.value='$l_load';\" value='$l_record'></form></td></tr>";
441
?>
443
?>
442
 
444
 
443
</TABLE><br/>
445
</TABLE><br/>
444
</BODY>
446
</BODY>
445
</HTML>
447
</HTML>
446
 
448