Subversion Repositories ALCASAR

Rev

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

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