Subversion Repositories ALCASAR

Rev

Rev 1903 | Rev 1955 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log

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