Subversion Repositories ALCASAR

Rev

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

Rev 1339 Rev 1344
1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2
<HTML><!-- written by Rexy -->
2
<HTML><!-- written by Rexy -->
3
<HEAD>
3
<HEAD>
4
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
4
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5
<TITLE>ALCASAR DNS filtering</TITLE>
5
<TITLE>ALCASAR DNS 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)
18
function form_filter_ip($form_content, $color)
19
{
19
{
-
 
20
	//# reconstruction des ip
20
	$list = form_filter($form_content);
21
	$list = explode("\n", form_filter($form_content));
-
 
22
	$new_list = "";
-
 
23
	foreach($list as &$value)
-
 
24
	{
-
 
25
		if(preg_match('/([0-9]{1,3}.){3}[0-9]{1,3}/', $value))
-
 
26
		{
-
 
27
			$new_list = $new_list.$value."\n";
-
 
28
		}
-
 
29
	}
-
 
30
	if($color == "white")
-
 
31
	{
21
	$list = preg_replace("/(.*)\n/", "add blacklist_ip_blocked $1\n", $list);
32
		return preg_replace("/(.*)\n/", "add whitelist_ip_allowed $1\n", $new_list);
-
 
33
	}
22
	return $list;
34
	else
-
 
35
	{
-
 
36
		return preg_replace("/(.*)\n/", "add blacklist_ip_blocked $1\n", $new_list);
-
 
37
	}
23
}
38
}
24
# Choice of language
39
# Choice of language
25
$Language = 'en';
40
$Language = 'en';
26
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
41
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
27
  $Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
42
  $Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
28
  $Language = strtolower(substr(chop($Langue[0]),0,2)); }
43
  $Language = strtolower(substr(chop($Langue[0]),0,2)); }
29
if($Language == 'fr'){
44
if($Language == 'fr'){
30
  $l_title1="Filtrage de noms de domaine et d'URL";
45
  $l_title1="Filtrage de noms de domaine et d'URL";
31
  $l_dnsfilter_on="Le filtrage de noms de domaine et d'URL est actuellement activé";
46
  $l_dnsfilter_on="Le filtrage de noms de domaine et d'URL est actuellement activé";
32
  $l_dnsfilter_off="Le filtrage de noms de domaine et d'URL est actuellement désactivé";
47
  $l_dnsfilter_off="Le filtrage de noms de domaine et d'URL est actuellement désactivé";
33
  $l_switch_filtering_on="Activer le filtrage";
48
  $l_switch_filtering_on="Activer le filtrage";
34
  $l_switch_filtering_off="Désactiver le filtrage";
49
  $l_switch_filtering_off="Désactiver le filtrage";
35
  $l_bl="Liste noire";
50
  $l_bl="Liste noire";
36
  $l_wl="Liste blanche";
51
  $l_wl="Liste blanche";
37
  $l_list_version="Version de la liste : ";
52
  $l_list_version="Version de la liste : ";
38
  $l_bl_categories="Sélectionnez les catégories à filtrer";
53
  $l_bl_categories="Sélectionnez les catégories à filtrer";
39
  $l_wl_categories="Sélectionnez les catégories à autoriser";
54
  $l_wl_categories="Sélectionnez les catégories à autoriser";
40
  $l_download_bl="Télécharger la dernière version";
55
  $l_download_bl="Télécharger la dernière version";
41
  $l_fingerprint="L'empreinte numérique du fichier téléchargé est : ";
56
  $l_fingerprint="L'empreinte numérique du fichier téléchargé est : ";
42
  $l_fingerprint2="Vérifiez-là en suivant ce lien (ligne 'blacklists.tar.gz') : ";
57
  $l_fingerprint2="Vérifiez-là en suivant ce lien (ligne 'blacklists.tar.gz') : ";
43
  $l_activate_bl="Activer la nouvelle version";
58
  $l_activate_bl="Activer la nouvelle version";
44
  $l_reject_bl="Rejeter";
59
  $l_reject_bl="Rejeter";
45
  $l_warning="Temps estimé : une minute.";
60
  $l_warning="Temps estimé : une minute.";
46
  $l_specific_filtering="Filtrage special";
61
  $l_specific_filtering="Filtrage special";
47
  $l_forbidden_dns="Noms de domaine filtrés";
62
  $l_forbidden_dns="Noms de domaine filtrés";
48
  $l_forbidden_dns_explain="Entrez un nom de domaine par ligne (exemple : .domaine.org)";
63
  $l_forbidden_dns_explain="Entrez un nom de domaine par ligne (exemple : .domaine.org)";
49
  $l_allowed_dns="Noms de domaine autorisés";
64
  $l_allowed_dns="Noms de domaine autorisés";
50
  $l_one_dns="Entrez un nom de domaine par ligne (exemple : .domaine.org)";
65
  $l_one_dns="Entrez un nom de domaine par ligne (exemple : .domaine.org)";
51
  $l_maj_rehabilitated="Noms de domaine ou IP réhabilités";
66
  $l_maj_rehabilitated="Noms de domaine ou IP réhabilités";
52
  $l_rehabilitated_dns="Noms de domaine réhabilités";
67
  $l_rehabilitated_dns="Noms de domaine réhabilités";
53
  $l_rehabilitated_dns_explain="Entrez ici des noms de domaine bloqués par la liste noire <BR> que vous souhaitez réhabiliter.";
68
  $l_rehabilitated_dns_explain="Entrez ici des noms de domaine bloqués par la liste noire <BR> que vous souhaitez réhabiliter.";
54
  $l_add_to_bl="Noms de domaine ou IP ajoutés à la liste noire";
69
  $l_add_to_bl="Noms de domaine ou IP ajoutés à la liste noire";
55
  $l_add_to_wl="Noms de domaine ou IP ajoutés à la liste blanche";
70
  $l_add_to_wl="Noms de domaine ou IP ajoutés à la liste blanche";
56
  $l_forbidden_ip="IP filtrés";
71
  $l_forbidden_ip="IP filtrés";
57
  $l_forbidden_ip_explain="Entrez une IP par ligne (exemple : 123.123.123.123)<br/>ou une ADRESSE RESEAU (exemple : 123.123.0.0/16)";
72
  $l_forbidden_ip_explain="Entrez une IP par ligne (exemple : 123.123.123.123)<br/>ou une ADRESSE RESEAU (exemple : 123.123.0.0/16)";
58
  $l_allowed_ip="IP authorisées";
73
  $l_allowed_ip="IP authorisées";
59
  $l_rehabilitated_ip="IP réhabilitées";
74
  $l_rehabilitated_ip="IP réhabilitées";
60
  $l_rehabilitated_ip_explain="Entrez ici des IP bloquées par la liste noire <BR> que vous souhaitez réhabiliter.";
75
  $l_rehabilitated_ip_explain="Entrez ici des IP bloquées par la liste noire <BR> que vous souhaitez réhabiliter.";
61
  $l_one_ip="Entrez une IP par ligne (exemple : 123.123.123.123)";
76
  $l_one_ip="Entrez une IP par ligne (exemple : 123.123.123.123)";
62
  $l_record="Enregistrer les modifications";
77
  $l_record="Enregistrer les modifications";
63
  $l_wait="Une fois validées, 10 secondes sont nécessaires pour traiter vos modifications";
78
  $l_wait="Une fois validées, 10 secondes sont nécessaires pour traiter vos modifications";
64
  $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)";
79
  $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)";
65
  $l_safe_searching="Activer le contrôle scolaire/parental des moteurs de recherche : google, yahoo, bing, metacrawler et Youtube.";
80
  $l_safe_searching="Activer le contrôle scolaire/parental des moteurs de recherche : google, yahoo, bing, metacrawler et Youtube.";
66
  $l_safe_youtube="Pour Youtube, entrez votre identifiant ici : "; 
81
  $l_safe_youtube="Pour Youtube, entrez votre identifiant ici : "; 
67
  $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>)";
82
  $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>)";
68
  $l_error_open_file="Erreur d'ouverture du fichier";
83
  $l_error_open_file="Erreur d'ouverture du fichier";
69
  $l_ip_file_title="Fichier d'IP";
84
  $l_ip_file_title="Fichier d'IP";
70
  $l_file_list="Liste des fichiers IP";
85
  $l_file_list="Liste des fichiers IP";
71
  $l_add_ip_file="Ajouter un fichier d'IP (une IP par ligne)";
86
  $l_add_ip_file="Ajouter un fichier d'IP (une IP par ligne)";
72
  $l_file_name="Nom du fichier";
87
  $l_file_name="Nom du fichier";
73
  $l_file_remove="Supprimer";
88
  $l_file_remove="Supprimer";
74
  $l_error_upload="Erreur d'envoi du fichier d'ip";
89
  $l_error_upload="Erreur d'envoi du fichier d'ip";
75
  $l_remove="Supprimer";
90
  $l_remove="Supprimer";
76
  $l_submit="Envoyer";
91
  $l_submit="Envoyer";
77
  $l_nb_ip="Nombre d'IP";
92
  $l_nb_ip="Nombre d'IP";
78
}
93
}
79
else {
94
else {
80
  $l_title1="Domain names and URL filtering";
95
  $l_title1="Domain names and URL filtering";
81
  $l_dnsfilter_on="Actually, the Domain name and URL filter is on";
96
  $l_dnsfilter_on="Actually, the Domain name and URL filter is on";
82
  $l_dnsfilter_off="Actually, the Domain name and URL filter is off";
97
  $l_dnsfilter_off="Actually, the Domain name and URL filter is off";
83
  $l_switch_filtering_on="Switch the Filter on";
98
  $l_switch_filtering_on="Switch the Filter on";
84
  $l_switch_filtering_off="Switch the Filter off";
99
  $l_switch_filtering_off="Switch the Filter off";
85
  $l_bl="BlackList";
100
  $l_bl="BlackList";
86
  $l_wl="WhiteList";
101
  $l_wl="WhiteList";
87
  $l_list_version="List version : ";
102
  $l_list_version="List version : ";
88
  $l_bl_categories="Select the categories to filter";
103
  $l_bl_categories="Select the categories to filter";
89
  $l_wl_categories="Select the categories to allow";
104
  $l_wl_categories="Select the categories to allow";
90
  $l_download_bl="Download the last version";
105
  $l_download_bl="Download the last version";
91
  $l_fingerprint="The digital fingerprint of the downloaded blacklist is : ";
106
  $l_fingerprint="The digital fingerprint of the downloaded blacklist is : ";
92
  $l_fingerprint2="Verify it with this link (line 'blacklists.tar.gz') : ";
107
  $l_fingerprint2="Verify it with this link (line 'blacklists.tar.gz') : ";
93
  $l_activate_bl="Activate the new version";
108
  $l_activate_bl="Activate the new version";
94
  $l_reject_bl="Reject";
109
  $l_reject_bl="Reject";
95
  $l_warning="Estimated time : one minute.";
110
  $l_warning="Estimated time : one minute.";
96
  $l_specific_filtering="Specific filtering";
111
  $l_specific_filtering="Specific filtering";
97
  $l_forbidden_dns="Filtered domain names";
112
  $l_forbidden_dns="Filtered domain names";
98
  $l_forbidden_dns_explain="Enter one domain name per row (exemple : .domain.org)";
113
  $l_forbidden_dns_explain="Enter one domain name per row (exemple : .domain.org)";
99
  $l_allowed_dns="Allowed domain names";
114
  $l_allowed_dns="Allowed domain names";
100
  $l_one_dns="Enter one domain name per row (example : .domain.org)";
115
  $l_one_dns="Enter one domain name per row (example : .domain.org)";
101
  $l_maj_rehabilitated="Domain names or IP rehabilitated";
116
  $l_maj_rehabilitated="Domain names or IP rehabilitated";
102
  $l_rehabilitated_dns="Rehabilitated domain names";
117
  $l_rehabilitated_dns="Rehabilitated domain names";
103
  $l_rehabilitated_dns_explain="Enter here domain names that are blocked by the blacklist <BR> and you want to rehabilitate.";
118
  $l_rehabilitated_dns_explain="Enter here domain names that are blocked by the blacklist <BR> and you want to rehabilitate.";
104
  $l_add_to_bl="Domain names or IP to add to blacklist";
119
  $l_add_to_bl="Domain names or IP to add to blacklist";
105
  $l_add_to_wl="Domain names or IP to add to whitelist";
120
  $l_add_to_wl="Domain names or IP to add to whitelist";
106
  $l_forbidden_ip="Filtered IP";
121
  $l_forbidden_ip="Filtered IP";
107
  $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)";
122
  $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)";
108
  $l_allowed_ip="Allowed IP";
123
  $l_allowed_ip="Allowed IP";
109
  $l_rehabilitated_ip="Rehabilitated IP";
124
  $l_rehabilitated_ip="Rehabilitated IP";
110
  $l_rehabilitated_ip_explain="Enter here IP that are blocked by the blacklist <BR> and you want to rehabilitate.";
125
  $l_rehabilitated_ip_explain="Enter here IP that are blocked by the blacklist <BR> and you want to rehabilitate.";
111
  $l_one_ip="Enter one IP per row (example : 123.123.123.123)";
126
  $l_one_ip="Enter one IP per row (example : 123.123.123.123)";
112
  $l_record="Save changes";
127
  $l_record="Save changes";
113
  $l_wait="Once validated, 10 seconds is necessary to compute your modifications";
128
  $l_wait="Once validated, 10 seconds is necessary to compute your modifications";
114
  $l_ip_filtering="Filtering URLs that contain an IP address instead of a domain name (ie: http://25.56.58.59/index.htm)";
129
  $l_ip_filtering="Filtering URLs that contain an IP address instead of a domain name (ie: http://25.56.58.59/index.htm)";
115
  $l_safe_searching="Enabling school/parental control for the search engines google, yahoo, bing, metacrawler and Youtube."; 
130
  $l_safe_searching="Enabling school/parental control for the search engines google, yahoo, bing, metacrawler and Youtube."; 
116
  $l_safe_youtube="For Youtube, enter your ID here : "; 
131
  $l_safe_youtube="For Youtube, enter your ID here : "; 
117
  $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>)";
132
  $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>)";
118
  $l_error_open_file="Error opening file";
133
  $l_error_open_file="Error opening file";
119
  $l_ip_file_title="IP files";
134
  $l_ip_file_title="IP files";
120
  $l_file_list="IP files list";
135
  $l_file_list="IP files list";
121
  $l_add_ip_file="Add a file of IP (one IP per line)";
136
  $l_add_ip_file="Add a file of IP (one IP per line)";
122
  $l_file_name="Filename";
137
  $l_file_name="Filename";
123
  $l_file_remove="Remove";
138
  $l_file_remove="Remove";
124
  $l_error_upload="Error during the upload process";
139
  $l_error_upload="Error during the upload process";
125
  $l_remove="Delete";
140
  $l_remove="Delete";
126
  $l_submit="Submit";
141
  $l_submit="Submit";
127
  $l_nb_ip="Number of IP";
142
  $l_nb_ip="Number of IP";
128
}
143
}
129
$dir_etc="/usr/local/etc/";
144
$dir_etc="/usr/local/etc/";
130
$dir_dg="/etc/dansguardian/lists/";
145
$dir_dg="/etc/dansguardian/lists/";
131
$dir_bl_ip="/usr/local/share/iptables-bl/";
146
$dir_bl_ip="/usr/local/share/iptables-bl/";
-
 
147
$file_wl_ip="/usr/local/share/ossi_wl";
132
$bl_categories=$dir_etc."alcasar-bl-categories";
148
$bl_categories=$dir_etc."alcasar-bl-categories";
133
$bl_categories_enabled=$dir_etc."alcasar-bl-categories-enabled";
149
$bl_categories_enabled=$dir_etc."alcasar-bl-categories-enabled";
134
$wl_categories=$dir_etc."alcasar-wl-categories";
150
$wl_categories=$dir_etc."alcasar-wl-categories";
135
$wl_categories_enabled=$dir_etc."alcasar-wl-categories-enabled";
151
$wl_categories_enabled=$dir_etc."alcasar-wl-categories-enabled";
136
$conf_file=$dir_etc."alcasar.conf";
152
$conf_file=$dir_etc."alcasar.conf";
137
$dir_blacklist=$dir_dg."blacklist/";
153
$dir_blacklist=$dir_dg."blacklist/";
138
$urlregex_file=$dir_dg."urlregexplist";
154
$urlregex_file=$dir_dg."urlregexplist";
139
$bannedsite_file=$dir_dg."bannedsitelist";
155
$bannedsite_file=$dir_dg."bannedsitelist";
140
$dir_tmp="/tmp/blacklists";
156
$dir_tmp="/tmp/blacklists";
141
$upload_dir = "/usr/local/share/iptables-bl-enabled/";
157
$upload_dir = "/usr/local/share/iptables-bl-enabled/";
142
# default values
158
# default values
143
if (is_file ($conf_file))
159
if (is_file ($conf_file))
144
	{
160
	{
145
	$tab=file($conf_file);
161
	$tab=file($conf_file);
146
	if ($tab)
162
	if ($tab)
147
		{
163
		{
148
		foreach ($tab as $line)
164
		foreach ($tab as $line)
149
			{
165
			{
150
			$field=explode("=", $line);
166
			$field=explode("=", $line);
151
			if ($field[0] == "DNS_FILTERING")	{$DNS_FILTERING=trim($field[1]);}
167
			if ($field[0] == "DNS_FILTERING")	{$DNS_FILTERING=trim($field[1]);}
152
			if ($field[0] == "YOUTUBE_ID")		{$YOUTUBE_ID=trim($field[1]);}
168
			if ($field[0] == "YOUTUBE_ID")		{$YOUTUBE_ID=trim($field[1]);}
153
			}
169
			}
154
		}
170
		}
155
	}
171
	}
156
else { echo "$l_error_open_file $conf_file";}
172
else { echo "$l_error_open_file $conf_file";}
157
if (isset($_POST['choix'])){ $choix=$_POST['choix']; } else { $choix=""; }
173
if (isset($_POST['choix'])){ $choix=$_POST['choix']; } else { $choix=""; }
158
switch ($choix)
174
switch ($choix)
159
{
175
{
160
case 'BL_On' :
176
case 'BL_On' :
161
	exec ("sudo /usr/local/sbin/alcasar-bl.sh --on");
177
	exec ("sudo /usr/local/sbin/alcasar-bl.sh --on");
162
	$DNS_FILTERING="on";
178
	$DNS_FILTERING="on";
163
	break;
179
	break;
164
case 'BL_Off' :
180
case 'BL_Off' :
165
	exec ("sudo /usr/local/sbin/alcasar-bl.sh --off");
181
	exec ("sudo /usr/local/sbin/alcasar-bl.sh --off");
166
	$DNS_FILTERING="off";
182
	$DNS_FILTERING="off";
167
	break;
183
	break;
168
case 'Download_list' :
184
case 'Download_list' :
169
	exec ("sudo /usr/local/sbin/alcasar-bl.sh --download");
185
	exec ("sudo /usr/local/sbin/alcasar-bl.sh --download");
170
	break;
186
	break;
171
case 'Active_list' :
187
case 'Active_list' :
172
	exec ("sudo /usr/local/sbin/alcasar-bl.sh --adapt");
188
	exec ("sudo /usr/local/sbin/alcasar-bl.sh --adapt");
173
	exec ("sudo /usr/local/sbin/alcasar-bl.sh --reload");
189
	exec ("sudo /usr/local/sbin/alcasar-bl.sh --reload");
174
	break;
190
	break;
175
case 'Reject_list' :
191
case 'Reject_list' :
176
	unlink ("$dir_tmp/blacklists.tar.gz"); unlink ("$dir_tmp/md5sum");
192
	unlink ("$dir_tmp/blacklists.tar.gz"); unlink ("$dir_tmp/md5sum");
177
	break;
193
	break;
178
case 'MAJ_cat_bl' :
194
case 'MAJ_cat_bl' :
179
	$tab=file($bl_categories_enabled);
195
	$tab=file($bl_categories_enabled);
180
	if ($tab)
196
	if ($tab)
181
		{
197
		{
182
		$pointeur=fopen($bl_categories_enabled, "w+");
198
		$pointeur=fopen($bl_categories_enabled, "w+");
183
		foreach ($_POST as $key => $value)
199
		foreach ($_POST as $key => $value)
184
			{
200
			{
185
			if (strstr($key,'chk-'))
201
			if (strstr($key,'chk-'))
186
				{	
202
				{	
187
				$line=str_replace('chk-','',$key)."\n";
203
				$line=str_replace('chk-','',$key)."\n";
188
				fwrite($pointeur,$line);
204
				fwrite($pointeur,$line);
189
				}
205
				}
190
			}
206
			}
191
		fclose($pointeur);
207
		fclose($pointeur);
192
		}
208
		}
193
	else {echo "$l_error_open_file $bl_categories_enabled";}
209
	else {echo "$l_error_open_file $bl_categories_enabled";}
194
	$fichier=fopen($dir_dg."blacklists/ossi/domains","w+");
210
	$fichier=fopen($dir_dg."blacklists/ossi/domains","w+");
195
	fputs($fichier, form_filter($_POST['OSSI_bl_domains']));
211
	fputs($fichier, form_filter($_POST['OSSI_bl_domains']));
196
	fclose($fichier);
212
	fclose($fichier);
197
	unset($_POST['OSSI_bl_domains']);
213
	unset($_POST['OSSI_bl_domains']);
198
	$fichier=fopen($dir_dg."exceptionsitelist","w+");
214
	$fichier=fopen($dir_dg."exceptionsitelist","w+");
199
	fputs($fichier, form_filter($_POST['BL_rehabilited_domains']));
215
	fputs($fichier, form_filter($_POST['BL_rehabilited_domains']));
200
	fclose($fichier);
216
	fclose($fichier);
201
	unset($_POST['BL_rehabilited_domains']);
217
	unset($_POST['BL_rehabilited_domains']);
202
	$fichier=fopen($dir_bl_ip."ossi","w+");
218
	$fichier=fopen($dir_bl_ip."ossi","w+");
203
	fputs($fichier, form_filter_ip($_POST['OSSI_bl_ip']));
219
	fputs($fichier, form_filter_ip($_POST['OSSI_bl_ip'], "black"));
204
	fclose($fichier);
220
	fclose($fichier);
205
	unset($_POST['OSSI_bl_ip']);
221
	unset($_POST['OSSI_bl_ip']);
206
	$fichier=fopen($dir_dg."exceptioniplist","w+");
222
	$fichier=fopen($dir_dg."exceptioniplist","w+");
207
	fputs($fichier, form_filter($_POST['BL_rehabilited_ip']));
223
	fputs($fichier, form_filter($_POST['BL_rehabilited_ip']));
208
	fclose($fichier);
224
	fclose($fichier);
209
	unset($_POST['BL_rehabilited_ip']);
225
	unset($_POST['BL_rehabilited_ip']);
210
	exec ("sudo /usr/local/sbin/alcasar-bl.sh --reload");
226
	exec ("sudo /usr/local/sbin/alcasar-bl.sh --reload");
211
	break;
227
	break;
212
case 'MAJ_cat_wl' :
228
case 'MAJ_cat_wl' :
213
	$tab=file($wl_categories_enabled);	
229
	$tab=file($wl_categories_enabled);	
214
	if ($tab)
230
	if ($tab)
215
		{
231
		{
216
		$pointeur=fopen($wl_categories_enabled, "w+");
232
		$pointeur=fopen($wl_categories_enabled, "w+");
217
		foreach ($_POST as $key => $value)
233
		foreach ($_POST as $key => $value)
218
			{
234
			{
219
			if (strstr($key,'chk-'))
235
			if (strstr($key,'chk-'))
220
				{	
236
				{	
221
				$line=str_replace('chk-','',$key)."\n";
237
				$line=str_replace('chk-','',$key)."\n";
222
				fwrite($pointeur,$line);
238
				fwrite($pointeur,$line);
223
				}
239
				}
224
			}
240
			}
225
		fclose($pointeur);
241
		fclose($pointeur);
226
		}
242
		}
227
	else {echo "$l_error_open_file $wl_categories_enabled";}
243
	else {echo "$l_error_open_file $wl_categories_enabled";}
228
	$fichier=fopen($dir_dg."blacklists/ossi/domains_wl","w+");
244
	$fichier=fopen($dir_dg."blacklists/ossi/domains_wl","w+");
229
	fputs($fichier, form_filter($_POST['OSSI_wl_domains']));
245
	fputs($fichier, form_filter($_POST['OSSI_wl_domains']));
230
	fclose($fichier);
246
	fclose($fichier);
231
	unset($_POST['OSSI_wl_domains']);
247
	unset($_POST['OSSI_wl_domains']);
232
	$fichier=fopen($dir_dg."blacklists/ossi/urls_wl","w+");
248
	$fichier=fopen($file_wl_ip, "w+");
233
	fputs($fichier, form_filter($_POST['OSSI_wl_urls']));
249
	fputs($fichier, form_filter_ip($_POST['OSSI_wl_ip'], "white"));
234
	fclose($fichier);
250
	fclose($fichier);
235
	unset($_POST['OSSI_wl_urls']);
251
	unset($_POST['OSSI_wl_ip']);
236
	exec ("sudo /usr/local/sbin/alcasar-bl.sh --reload");
252
	exec ("sudo /usr/local/sbin/alcasar-bl.sh --reload");
237
	break;
253
	break;
238
case 'Specific_filtering' :
254
case 'Specific_filtering' :
239
	$pureip="-pureip_off"; $safesearch="-safesearch_off"; ;
255
	$pureip="-pureip_off"; $safesearch="-safesearch_off"; ;
240
	foreach ($_POST as $key => $value)
256
	foreach ($_POST as $key => $value)
241
	{
257
	{
242
		if (strstr($key,'chk-ip')) $pureip="-pureip_on";
258
		if (strstr($key,'chk-ip')) $pureip="-pureip_on";
243
		if (strstr($key,'chk-safesearch')) $safesearch="-safesearch_on";
259
		if (strstr($key,'chk-safesearch')) $safesearch="-safesearch_on";
244
	}
260
	}
245
	if ($_POST['Youtube_ID'] == '') { $New_ID="ABCD1234567890abcdef";} // default ID (no action) 
261
	if ($_POST['Youtube_ID'] == '') { $New_ID="ABCD1234567890abcdef";} // default ID (no action) 
246
	else {$New_ID=$_POST['Youtube_ID'];}
262
	else {$New_ID=$_POST['Youtube_ID'];}
247
	file_put_contents($conf_file, str_replace("YOUTUBE_ID=$YOUTUBE_ID", "YOUTUBE_ID=$New_ID", file_get_contents($conf_file)));
263
	file_put_contents($conf_file, str_replace("YOUTUBE_ID=$YOUTUBE_ID", "YOUTUBE_ID=$New_ID", file_get_contents($conf_file)));
248
	$YOUTUBE_ID=$New_ID;
264
	$YOUTUBE_ID=$New_ID;
249
	exec ("sudo /usr/local/sbin/alcasar-url_filter.sh $safesearch $pureip");
265
	exec ("sudo /usr/local/sbin/alcasar-url_filter.sh $safesearch $pureip");
250
	break;
266
	break;
251
case 'MAJ_ip_file_delete' :
267
case 'MAJ_ip_file_delete' :
252
	foreach($_POST as $fichier => $value)
268
	foreach($_POST as $fichier => $value)
253
	{
269
	{
254
		if($fichier != "choix")
270
		if($fichier != "choix")
255
		{
271
		{
256
			exec("rm -rf $upload_dir$fichier");
272
			exec("rm -rf $upload_dir$fichier");
257
		}	
273
		}	
258
	}
274
	}
259
	exec ("sudo /usr/local/bin/alcasar-iptables.sh");
275
	exec ("sudo /usr/local/bin/alcasar-iptables.sh");
260
	break;
276
	break;
261
case 'MAJ_ip_file_upload' :
277
case 'MAJ_ip_file_upload' :
262
	$nom = basename($_FILES['fichier_ip']['name']);
278
	$nom = basename($_FILES['fichier_ip']['name']);
263
	# Si un fichier a été choisi
279
	# Si un fichier a été choisi
264
	if(!empty($nom))
280
	if(!empty($nom))
265
	{	
281
	{	
266
		# On l'upload
282
		# On l'upload
267
		if(move_uploaded_file($_FILES['fichier_ip']['tmp_name'], $upload_dir."ossi-".$nom))
283
		if(move_uploaded_file($_FILES['fichier_ip']['tmp_name'], $upload_dir.$nom))
268
		{
284
		{
-
 
285
			# On extrait uniquement les ip du fichier
-
 
286
			exec("grep -Eo '([0-9]{1,3}\.){3}[0-9]{1,3}' $upload_dir$nom > $upload_dir\ossi-$nom");
-
 
287
		       	# On crée la sauvegarde du set
269
			exec("sed -i \"s/^/add blacklist_ip_blocked /g\" $upload_dir\ossi-$nom"); # On crée la sauvegarde du set
288
			exec("sed -i \"s/^/add blacklist_ip_blocked /g\" $upload_dir\ossi-$nom && rm -f $upload_dir$nom");
270
		}
289
		}
271
		else
290
		else
272
		{
291
		{
273
			echo $l_error_upload;
292
			echo $l_error_upload;
274
		}
293
		}
275
	}
294
	}
276
	exec ("sudo /usr/local/bin/alcasar-iptables.sh");
295
	exec ("sudo /usr/local/bin/alcasar-iptables.sh");
277
	break;
296
	break;
278
}
297
}
279
?>
298
?>
280
<TABLE width="100%" border=0 cellspacing=0 cellpadding=0>
299
<TABLE width="100%" border=0 cellspacing=0 cellpadding=0>
281
<tr><th><?php echo "$l_title1"; ?></th></tr>
300
<tr><th><?php echo "$l_title1"; ?></th></tr>
282
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width=1 height=2></td></tr>
301
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width=1 height=2></td></tr>
283
</TABLE>
302
</TABLE>
284
<TABLE width="100%" border=1 cellspacing=0 cellpadding=0>
303
<TABLE width="100%" border=1 cellspacing=0 cellpadding=0>
285
	<tr><td valign="middle" align="left">
304
	<tr><td valign="middle" align="left">
286
<?php
305
<?php
287
if ($DNS_FILTERING == "on")
306
if ($DNS_FILTERING == "on")
288
	{
307
	{
289
	echo "<CENTER><H3>$l_dnsfilter_on</H3></CENTER>";
308
	echo "<CENTER><H3>$l_dnsfilter_on</H3></CENTER>";
290
 	echo "<FORM action='$_SERVER[PHP_SELF]' method=POST>";
309
 	echo "<FORM action='$_SERVER[PHP_SELF]' method=POST>";
291
	echo "<input type=hidden name='choix' value=\"BL_Off\">";
310
	echo "<input type=hidden name='choix' value=\"BL_Off\">";
292
	echo "<input type=submit value=\"$l_switch_filtering_off\">";
311
	echo "<input type=submit value=\"$l_switch_filtering_off\">";
293
}
312
}
294
else
313
else
295
	{
314
	{
296
	echo "<CENTER><H3>$l_dnsfilter_off</H3></CENTER>";
315
	echo "<CENTER><H3>$l_dnsfilter_off</H3></CENTER>";
297
 	echo "<FORM action='$_SERVER[PHP_SELF]' method=POST>";
316
 	echo "<FORM action='$_SERVER[PHP_SELF]' method=POST>";
298
	echo "<input type=hidden name='choix' value=\"BL_On\">";
317
	echo "<input type=hidden name='choix' value=\"BL_On\">";
299
	echo "<input type=submit value=\"$l_switch_filtering_on\">";
318
	echo "<input type=submit value=\"$l_switch_filtering_on\">";
300
	}
319
	}
301
echo "</FORM>";
320
echo "</FORM>";
302
echo "</td></tr>";
321
echo "</td></tr>";
303
echo "</TABLE>";
322
echo "</TABLE>";
304
if ($DNS_FILTERING == "on") require ('bl_filter2.php');
323
if ($DNS_FILTERING == "on") require ('bl_filter2.php');
305
?>
324
?>
306
</BODY>
325
</BODY>
307
</HTML>
326
</HTML>
308
 
327