Subversion Repositories ALCASAR

Rev

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

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