| Line 13... |
Line 13... |
| 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']);
|
| Line 127... |
Line 142... |
| 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";
|
| Line 198... |
Line 214... |
| 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);
|
| Line 227... |
Line 243... |
| 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)
|
| Line 262... |
Line 278... |
| 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 |
}
|