Line 27... |
Line 27... |
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 wl_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 bl_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))
|
Line 189... |
Line 189... |
189 |
$urlregex_file=$dir_dg."urlregexplist";
|
189 |
$urlregex_file=$dir_dg."urlregexplist";
|
190 |
$bannedsite_file=$dir_dg."bannedsitelist";
|
190 |
$bannedsite_file=$dir_dg."bannedsitelist";
|
191 |
$dir_tmp="/tmp/blacklists";
|
191 |
$dir_tmp="/tmp/blacklists";
|
192 |
$upload_dir_ip = "/usr/local/share/iptables-bl-enabled/";
|
192 |
$upload_dir_ip = "/usr/local/share/iptables-bl-enabled/";
|
193 |
$upload_dir_domain_names = "/usr/local/share/dnsmasq-bl-enabled/";
|
193 |
$upload_dir_domain_names = "/usr/local/share/dnsmasq-bl-enabled/";
|
194 |
$cron_apache = "/etc/cron.d/alcasar-update-categories";
|
194 |
$cron_apache = "/etc/cron.d/alcasar-update-cat";
|
195 |
# default values
|
195 |
# default values
|
196 |
if (is_file ($conf_file))
|
196 |
if (is_file ($conf_file))
|
197 |
{
|
197 |
{
|
198 |
$tab=file($conf_file);
|
198 |
$tab=file($conf_file);
|
199 |
if ($tab)
|
199 |
if ($tab)
|
Line 233... |
Line 233... |
233 |
{
|
233 |
{
|
234 |
if (strstr($key,'chk-'))
|
234 |
if (strstr($key,'chk-'))
|
235 |
{
|
235 |
{
|
236 |
$line=str_replace('chk-','',$key)."\n";
|
236 |
$line=str_replace('chk-','',$key)."\n";
|
237 |
fwrite($pointeur,$line);
|
237 |
fwrite($pointeur,$line);
|
- |
|
238 |
if(trim($line) == 'malware')
|
238 |
|
239 |
{
|
- |
|
240 |
$cron_malware = 1;
|
- |
|
241 |
$fichier=fopen($cron_apache,"w+");
|
- |
|
242 |
fputs($fichier, "# update malware categories every 12 hours\n");
|
- |
|
243 |
fputs($fichier, "* 0-23/12 * * * /usr/local/bin/alcasar-bl.sh --update-cat malware rsync://ftp.ut-capitole.fr/blacklist/dest/malware\n");
|
- |
|
244 |
}
|
239 |
}
|
245 |
}
|
240 |
}
|
246 |
}
|
- |
|
247 |
if(!$cron_malware)
|
- |
|
248 |
{
|
- |
|
249 |
$fichier=fopen($cron_apache,"w+");
|
- |
|
250 |
fputs($fichier, "# malware updates disabled\n");
|
- |
|
251 |
}
|
241 |
|
252 |
|
242 |
fclose($pointeur);
|
253 |
fclose($pointeur);
|
243 |
}
|
254 |
}
|
244 |
else {echo "$l_error_open_file $bl_categories_enabled";}
|
255 |
else {echo "$l_error_open_file $bl_categories_enabled";}
|
245 |
$fichier=fopen($dir_dg."blacklists/ossi/domains","w+");
|
256 |
$fichier=fopen($dir_dg."blacklists/ossi/domains","w+");
|
Line 293... |
Line 304... |
293 |
|
304 |
|
294 |
# Suppression des doublons
|
305 |
# Suppression des doublons
|
295 |
exec("sort -u $upload_dir_ip\ossi_ip > $upload_dir_ip\ossi-$nom && rm -f $upload_dir_ip\ossi_ip");
|
306 |
exec("sort -u $upload_dir_ip\ossi_ip > $upload_dir_ip\ossi-$nom && rm -f $upload_dir_ip\ossi_ip");
|
296 |
|
307 |
|
297 |
# On adapte le fichier à la sauvegarde du set
|
308 |
# On adapte le fichier à la sauvegarde du set
|
298 |
exec("sed -i \"s/^/add blacklist_ip_blocked /g\" $upload_dir_ip\ossi-$nom");
|
309 |
exec("sed -i \"s/^/add bl_ip_blocked /g\" $upload_dir_ip\ossi-$nom");
|
299 |
|
310 |
|
300 |
|
311 |
|
301 |
# On extrait uniquement les noms de domaine
|
312 |
# On extrait uniquement les noms de domaine
|
302 |
# max_tld() retourne le nombre max de charactere pour un top-level dns
|
313 |
# max_tld() retourne le nombre max de charactere pour un top-level dns
|
303 |
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");
|
314 |
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");
|
Line 442... |
Line 453... |
442 |
echo "<H3>$l_file_list</H3>";
|
453 |
echo "<H3>$l_file_list</H3>";
|
443 |
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>";
|
454 |
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>";
|
444 |
exec("cd $upload_dir_ip && ls | grep ossi-", $fichiersIp);
|
455 |
exec("cd $upload_dir_ip && ls | grep ossi-", $fichiersIp);
|
445 |
foreach($fichiersIp as $fichier => $value)
|
456 |
foreach($fichiersIp as $fichier => $value)
|
446 |
{
|
457 |
{
|
447 |
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' name='$value' value='$l_remove'></center></td></tr>";
|
458 |
echo "<tr><td><center><a href='bl_categories_help.php?liste=bl&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_remove'></center></td></tr>";
|
448 |
}
|
459 |
}
|
449 |
echo "</table><br/></td></form><form action='bl_filter.php' method='POST' enctype='multipart/form-data'>";
|
460 |
echo "</table><br/></td></form><form action='bl_filter.php' method='POST' enctype='multipart/form-data'>";
|
450 |
echo "<input type='hidden' name='choix' value='MAJ_ip_file_upload'><td width=50% colspan=5 align=center>";
|
461 |
echo "<input type='hidden' name='choix' value='MAJ_ip_file_upload'><td width=50% colspan=5 align=center>";
|
451 |
echo "<H3>$l_add_file</H3>";
|
462 |
echo "<H3>$l_add_file</H3>";
|
452 |
echo "$l_add_file_explain";
|
463 |
echo "$l_add_file_explain";
|