/web/acc/admin/bl_categories_help.php |
---|
10,13 → 10,11 |
$wl_unbound_dir="/usr/local/share/unbound-wl/"; |
# Choice of language |
$Language = 'en'; |
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) |
{ |
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){ |
$Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']); |
$Language = strtolower(substr(chop($Langue[0]),0,2)); |
} |
if($Language == 'fr') |
{ |
if($Language == 'fr'){ |
$l_title = "Catégories de la liste noire"; |
$l_error_open_file="Erreur d'ouverture du fichier"; |
$l_close="Fermer"; |
53,107 → 51,54 |
$l_error_cat = "Error category"; |
$l_error_list = "Error listing"; |
} |
if(isset($_GET['cat'])) |
{ |
if(isset($_GET['cat'])){ |
$categorie = $_GET['cat']; |
} |
else |
{ |
else { |
$categorie = $l_error_cat; |
} |
if(isset($_GET['liste'])) |
{ |
$liste = $_GET['liste']; |
$bl_categorie_domain_file = $bl_unbound_dir.$categorie.".conf"; |
$bl_categorie_url_file = $bl_dir.$categorie."/urls"; |
$bl_categorie_ip_file = $bl_iptables_dir.$categorie; |
//don't calc again on reload (click on the number of domain/urls/ip) |
if (isset ($_GET['nb_domains']) && isset($_GET['nb_urls']) && isset($_GET['nb_ip'])){ |
$nb_domains = $_GET['nb_domains']; |
$nb_urls = $_GET['nb_urls']; |
$nb_ip = $_GET['nb_ip']; |
} |
else |
{ |
$liste = $l_error_list; |
} |
if($liste == "bl") |
{ |
$bl_categorie_domain_file = $bl_unbound_dir.$categorie.".conf"; |
$bl_categorie_url_file = $bl_dir.$categorie."/urls"; |
$bl_categorie_ip_file = $bl_iptables_dir.$categorie; |
//don't calc again on reload (click on the number of domain/urls/ip) |
if (isset ($_GET['nb_domains']) && isset($_GET['nb_urls']) && isset($_GET['nb_ip'])) |
{ |
$nb_domains = $_GET['nb_domains']; |
$nb_urls = $_GET['nb_urls']; |
$nb_ip = $_GET['nb_ip']; |
} |
else |
{ |
if (file_exists($bl_categorie_domain_file)) |
{ |
else { |
if (file_exists($bl_categorie_domain_file)){ |
# two lines per domain |
$nb_domains = exec("wc -l $bl_categorie_domain_file | cut -d ' ' -f1") / 2; |
} |
else |
{ |
else { |
$nb_domains = $l_error_open_file." ".$bl_categorie_domain_file; |
} |
if (file_exists($bl_categorie_url_file)) |
{ |
if (file_exists($bl_categorie_url_file)){ |
$nb_urls = exec ("wc -l $bl_categorie_url_file | cut -d ' ' -f1"); |
} |
else |
{ |
else { |
$nb_urls = $l_error_open_file." ".$bl_categorie_url_file; |
} |
if(file_exists($bl_categorie_ip_file)) |
{ |
if(file_exists($bl_categorie_ip_file)){ |
$nb_ip = exec("wc -l $bl_categorie_ip_file | cut -d ' ' -f1"); |
} |
else |
{ |
else { |
$nb_ip = $l_error_open_file." ".$bl_categorie_ip_file; |
} |
} |
} |
else |
{ |
$wl_categorie_domain_file = $wl_unbound_dir.$categorie.".conf"; |
$wl_categorie_ip_file = $wl_iptables_dir.$categorie; |
if (file_exists($wl_categorie_domain_file)) |
{ |
$nb_domains = exec("wc -l $wl_categorie_domain_file | cut -d ' ' -f1"); |
} |
else |
{ |
$nb_domains = $l_error_open_file." ".$wl_categorie_domain_file; |
} |
if (file_exists($wl_categorie_ip_file)) |
{ |
$nb_ip = exec("wc -l $wl_categorie_ip_file | cut -d ' ' -f1"); |
} |
else |
{ |
$nb_ip = 0; |
//$nb_ip = $l_error_open_file." ".$wl_categorie_ip_file; |
} |
$nb_urls = 0; //no urls in WL |
} |
$global_usage = file($bl_dir."global_usage"); |
$langue = strtoupper($Language); |
if(isset($categorie)) |
{ |
if(isset($categorie)){ |
$fin1 = 0; $fin2 = 0; |
foreach ($global_usage as $line) |
{ |
if(preg_match("#^NAME:.$categorie$#", $line) == 1) |
{ |
foreach ($global_usage as $line){ |
if(preg_match("#^NAME:.$categorie$#", $line) == 1){ |
$fin1 = 1; |
} |
if($fin1 && preg_match("#^DESC.$langue:.#", $line) == 1) |
{ |
if($fin1 && preg_match("#^DESC.$langue:.#", $line) == 1){ |
$l_description_cat = preg_replace("#^DESC.$langue:.#", "", $line); |
} |
if($fin1 && preg_match("#^NAME.$langue:.#", $line) == 1) |
{ |
if($fin1 && preg_match("#^NAME.$langue:.#", $line) == 1){ |
$l_name_cat = preg_replace("#^NAME.$langue:.#", "", $line); |
$fin2 = 1; |
} |
172,23 → 117,12 |
<TABLE width="100%" border=1 cellspacing=0 cellpadding=1> |
<tr><td valign="middle" align="left"> |
<?php |
if(isset($_GET["filtre"])) |
{ |
$filtre = $_GET["filtre"]; |
} |
else |
{ |
$filtre = $liste == "bl" ? $bl_categorie_domain_file : $wl_categorie_domain_file; |
} |
$filtre_domain = $liste == "bl" ? $bl_categorie_domain_file : $wl_categorie_domain_file; |
$filtre_ip = $liste == "bl" ? $bl_categorie_ip_file : $wl_categorie_ip_file; |
$filtre_url = $liste == "bl" ? $bl_categorie_url_file : ""; |
$compat_categorie=strtr($categorie,"-","_"); |
echo "<br><center><b>$l_name_cat</b></center>"; |
echo "<center><b>$l_description_cat</b></center><br>"; |
echo "$l_nb_domains <b><a href='?liste=$liste&cat=$categorie&filtre=$filtre_domain&titre=domain&nb_domains=$nb_domains&nb_urls=$nb_urls&nb_ip=$nb_ip'>$nb_domains</a></b><br>"; |
echo "$l_nb_urls <b><a href='?liste=$liste&cat=$categorie&filtre=$filtre_url&titre=url&nb_domains=$nb_domains&nb_urls=$nb_urls&nb_ip=$nb_ip'>$nb_urls</a></b><br>"; |
echo "$l_nb_ip <b><a href='?liste=$liste&cat=$categorie&filtre=$filtre_ip&titre=ip&nb_domains=$nb_domains&nb_urls=$nb_urls&nb_ip=$nb_ip'>$nb_ip</a></b><br>"; |
echo "$l_nb_domains <b><a href='?cat=$categorie&filtre=$bl_categorie_domain_file&titre=domain&nb_domains=$nb_domains&nb_urls=$nb_urls&nb_ip=$nb_ip'>$nb_domains</a></b><br>"; |
echo "$l_nb_urls <b><a href='?cat=$categorie&filtre=$bl_categorie_url_file&titre=url&nb_domains=$nb_domains&nb_urls=$nb_urls&nb_ip=$nb_ip'>$nb_urls</a></b><br>"; |
echo "$l_nb_ip <b><a href='?cat=$categorie&filtre=$bl_categorie_ip_file&titre=ip&nb_domains=$nb_domains&nb_urls=$nb_urls&nb_ip=$nb_ip'>$nb_ip</a></b><br>"; |
?> |
</td></tr> |
</TABLE> |
196,12 → 130,10 |
<TABLE width="100%" border="0" cellspacing="0" cellpadding="0"> |
<tr><th> |
<?php |
if(isset($_GET["titre"])) |
{ |
if(isset($_GET["titre"])){ |
$titre = $_GET["titre"]; |
} |
else |
{ |
else { |
$titre = "domain"; |
} |
echo $l_example.$titre; |
212,23 → 144,16 |
<TABLE width="100%" border=1 cellspacing=0 cellpadding=1> |
<tr><td valign="middle" align="left"> |
<?php |
if($titre == "domain") |
{ |
$filtre = $liste == "bl" ? $bl_categorie_domain_file : $wl_categorie_domain_file; |
exec("head -n 15 ".escapeshellarg($filtre)." | grep 'transparent' | awk '{ print $2 }'", $resultat); |
if($titre == "domain"){ |
exec("head -n 15 ".escapeshellarg($bl_categorie_domain_file)." | grep 'transparent' | awk '{ print $2 }'", $resultat); |
} |
elseif($titre == "ip") |
{ |
$filtre = $liste == "bl" ? $bl_categorie_ip_file : $wl_categorie_ip_file; |
exec("head -n 15 ".escapeshellarg($filtre)." | cut -d ' ' -f3", $resultat); |
elseif($titre == "ip"){ |
exec("head -n 15 ".escapeshellarg($bl_categorie_ip_file)." | cut -d ' ' -f3", $resultat); |
} |
else |
{ |
exec("head -n 15 ".escapeshellarg($filtre), $resultat); |
else { |
exec("head -n 15 ".escapeshellarg($bl_categorie_ip_file), $resultat); |
} |
for($i=0; $i<count($resultat); $i++) |
{ |
for($i=0; $i<count($resultat); $i++){ |
echo $resultat[$i]."<br/>"; |
} |
?> |
/web/acc/admin/bl_filter.php |
---|
10,41 → 10,34 |
<div class="lds-spinner" id="spinner"><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div></div> |
</div> |
<? |
function form_filter ($form_content) |
{ |
// réencodage iso + format unix + rc fin de ligne (ouf...) |
function form_filter ($form_content){ |
// Re-encoding : ISO + unix format + end-of-line |
$list = str_replace("\r\n", "\n", utf8_decode($form_content)); |
if (strlen($list) != 0){ |
if ($list[strlen($list)-1] != "\n") { $list[strlen($list)]="\n";} ;} ; |
return $list; |
} |
function form_filter_ip($form_content, $color) |
{ |
//# reconstruction des ip |
function form_filter_ip($form_content, $color){ |
// IP reconstruction |
$list = explode("\n", form_filter($form_content)); |
$new_list = ""; |
foreach ($list as &$value) |
{ |
if(preg_match('/([0-9]{1,3}.){3}[0-9]{1,3}/', $value)) |
{ |
foreach ($list as &$value){ |
if(preg_match('/([0-9]{1,3}.){3}[0-9]{1,3}/', $value)){ |
$new_list = $new_list.$value."\n"; |
} |
} |
if($color == "white") |
{ |
if($color == "white"){ |
return preg_replace("/(.*)\n/", "add wl_ip_allowed $1\n", $new_list); |
} |
else |
{ |
else { |
return preg_replace("/(.*)\n/", "add bl_ip_blocked $1\n", $new_list); |
} |
} |
function echo_file ($filename) |
{ |
if (file_exists($filename)) |
{ |
if (filesize($filename) != 0) |
{ |
function echo_file ($filename){ |
if (file_exists($filename)){ |
if (filesize($filename) != 0){ |
$pointeur=fopen($filename,"r"); |
$tampon = fread($pointeur, filesize($filename)); |
fclose($pointeur); |
51,17 → 44,14 |
echo $tampon; |
} |
} |
else |
{ |
else { |
echo "$filename doesn't exist"; |
} |
} |
function echo_ip_file ($filename) |
{ |
function echo_ip_file ($filename){ |
$filename = escapeshellarg($filename); |
exec("cat $filename | cut -d ' ' -f3", $resultat); |
for($i=0; $i<exec("wc -l $filename"); $i++) |
{ |
for($i=0; $i<exec("wc -l $filename"); $i++){ |
echo $resultat[$i]."\n"; |
} |
} |
74,6 → 64,7 |
} |
if($Language == 'fr'){ |
$l_bl="Liste noire principale"; |
$l_state="Sont actuellement bloqués : "; |
$l_load="Chargement..."; |
$l_list_version="Version de la liste : "; |
$l_bl_categories="Sélectionnez les catégories à filtrer"; |
110,9 → 101,9 |
$l_submit="Envoyer"; |
$l_nb_ip="Nombre d'IP"; |
$l_nb_domain_names="Nombre de noms de domaine"; |
$l_nbDomainNames="Noms de domaine :"; |
$l_nbUrl="Url :"; |
$l_nbIp="Ip :"; |
$l_nbDomainNames="noms de domaine"; |
$l_nbUrl="URL"; |
$l_nbIp="@Ip"; |
$l_update_cat="Blacklist principale (catégorie 'malware' uniquement)"; |
$l_update_cat_header="Mise à jour automatique des Blacklists"; |
$l_update_success="Échec de la mise à jour"; |
161,9 → 152,9 |
$l_submit="Enviar"; |
$l_nb_ip="Números de IP"; |
$l_nb_domain_names="Números de sitios"; |
$l_nbDomainNames="Domain names: "; |
$l_nbUrl="Url :"; |
$l_nbIp="Ip :"; |
$l_nbDomainNames="sitios"; |
$l_nbUrl="URL"; |
$l_nbIp="IP@"; |
$l_update_cat="¿Actualizar automáticamente las categorías cada 12 horas (solo 'malware' por ahora)?"; |
$l_update_cat_header="Actualización automática de la lista negra"; |
$l_update_success="actualización fallida"; |
245,29 → 236,24 |
$updateable_ossi_bls=["ossi-bl-candc"]; |
# default values |
if (is_file ($conf_file)) |
{ |
if (is_file ($conf_file)){ |
$tab=file($conf_file); |
if ($tab) |
{ |
foreach ($tab as $line) |
{ |
if ($tab){ |
foreach ($tab as $line){ |
$field=explode("=", $line); |
switch ($field[0]) { |
switch ($field[0]){ |
case 'PRIVATE_IP': |
$PRIVATE_IP_MASK=trim($field[1]); |
$tmp = explode("/",$PRIVATE_IP_MASK); |
$PRIVATE_IP=$tmp[0]; |
break; |
case 'BL_SAFESEARCH': |
if (strtolower(trim($field[1])) == 'on') { |
if (strtolower(trim($field[1])) == 'on'){ |
$bl_safesearch='on'; |
} |
break; |
case 'BL_PUREIP': |
if (strtolower(trim($field[1])) == 'on') { |
if (strtolower(trim($field[1])) == 'on'){ |
$bl_pureip='on'; |
} |
break; |
277,8 → 263,7 |
} |
else { echo "$l_error_open_file $conf_file";} |
if (isset($_POST['choix'])){ $choix=$_POST['choix']; } else { $choix=""; } |
switch ($choix) |
{ |
switch ($choix){ |
case 'Download_list' : |
exec ("sudo /usr/local/bin/alcasar-bl.sh --download"); |
break; |
290,14 → 275,11 |
unlink ("$dir_tmp/blacklists.tar.gz"); unlink ("$dir_tmp/md5sum"); |
break; |
case 'MAJ_cat_bl' : |
if (file_exists($bl_categories_enabled)) |
{ |
if (file_exists($bl_categories_enabled)){ |
exec("/bin/sed -i \"/^ossi-/!d\" $bl_categories_enabled"); // keep ossi custom categories |
$pointeur=fopen($bl_categories_enabled, "a+"); |
foreach ($_POST as $key => $value) |
{ |
if (strstr($key,'chk-')) |
{ |
foreach ($_POST as $key => $value){ |
if (strstr($key,'chk-')){ |
$line=str_replace('chk-','',$key)."\n"; |
fwrite($pointeur,$line); |
} |
322,8 → 304,7 |
case 'Specific_filtering': |
$bl_pureip='off'; |
$bl_safesearch='off'; |
foreach ($_POST as $key => $value) |
{ |
foreach ($_POST as $key => $value){ |
if (strstr($key,'chk-ip')) $bl_pureip="on"; |
if (strstr($key,'chk-safesearch')) $bl_safesearch="on"; |
} |
330,43 → 311,32 |
exec ("sudo /usr/local/bin/alcasar-url_filter_bl.sh -safesearch_$bl_safesearch -pureip_$bl_pureip"); |
break; |
case 'MAJ_ossi_file' : |
foreach ($_POST as $fichier => $value) |
{ |
if($fichier != "choix" && $fichier != "update_cat") |
{ |
foreach ($_POST as $fichier => $value){ |
if($fichier != "choix" && $fichier != "update_cat"){ |
$action=$_POST[$fichier]; |
if($action == $l_remove) //delete |
{ |
if($action == $l_remove){ //delete |
exec("/bin/sed -i ".escapeshellarg("/^$fichier\$/d")." $bl_categories_enabled"); |
exec("/bin/sed -i ".escapeshellarg("/$fichier\$/d")." $bl_categories"); |
exec("rm -rf $dir_blacklist".escapeshellarg($fichier)); |
exec("sudo /usr/local/bin/alcasar-bl.sh --reload"); |
} |
if($action == $l_disable) //disable |
{ |
if($action == $l_disable){ //disable |
exec("/bin/sed -i ".escapeshellarg("/^$fichier\$/d")." $bl_categories_enabled"); |
exec("sudo /usr/local/bin/alcasar-bl.sh --reload"); |
} |
if($action == $l_enable) //enable |
{ |
if($action == $l_enable){ //enable |
file_put_contents($bl_categories_enabled, $fichier."\n", FILE_APPEND); |
exec("sudo /usr/local/bin/alcasar-bl.sh --reload 2>&1", $out, $ret); |
} |
if($action == $l_update) //update |
{ |
if ($fichier == ossi-bl-candc) |
{ |
if($action == $l_update){ //update |
if ($fichier == ossi-bl-candc){ |
exec("sudo /usr/local/bin/alcasar-bl-autoupdate.sh --update_ossi-bl-candc 2>&1", $out, $ret); |
if ($ret == 0) |
{ |
if ($ret == 0){ |
echo "<p>".$l_update_success."</p>"; |
} |
else |
{ |
else { |
echo "<p>".$l_update_failed.":</p>"; |
foreach ($out as $line) |
{ |
foreach ($out as $line){ |
echo "<p>".$line."</p>"; |
} |
} |
381,20 → 351,13 |
fclose($f); |
$f = fopen($update_file_ossi_cat, 'w'); |
fclose($f); |
foreach ($_POST as $fichier => $value) |
{ |
// General BL |
if ($fichier == 'update_cat' && $value == 1) |
{ |
if (file_exists($bl_categories_enabled)) |
{ |
foreach ($_POST as $fichier => $value){ // General BL |
if ($fichier == 'update_cat' && $value == 1){ |
if (file_exists($bl_categories_enabled)){ |
file_put_contents($update_file_cat, "malware rsync://ftp.ut-capitole.fr/blacklist/dest/malware\n", FILE_APPEND); |
} |
} |
// C&C Server List |
if ($fichier == 'ossi-bl-candc' && $value == 1) |
{ |
if ($fichier == 'ossi-bl-candc' && $value == 1){ // C&C Server List |
file_put_contents($update_file_ossi_cat, "alcasar-bl-autoupdate.sh --update_ossi-bl-candc\n", FILE_APPEND); |
} |
} |
403,20 → 366,17 |
$bad_char = array(" ", "."); |
$file_name = str_replace ($bad_char, "_",basename($_FILES['fichier_ip']['name'])); |
$dest_dir = $dir_blacklist."ossi-bl-".$file_name; # /etc/e2guardian/list/blacklist/ossi-bl-XXXXXXXX |
if((!empty($file_name)) && (!file_exists($dest_dir))) |
{ |
if((!empty($file_name)) && (!file_exists($dest_dir))){ |
exec("mkdir ".escapeshellarg($dest_dir)); |
$file=$_FILES['fichier_ip']['tmp_name']; |
exec('/usr/bin/dos2unix '.escapeshellarg($file)); |
if(move_uploaded_file($_FILES['fichier_ip']['tmp_name'], $dest_dir."/domains")) // copy in the file "domains" (containing @ip & domain names (like over Toulouse categories)) |
{ |
if(move_uploaded_file($_FILES['fichier_ip']['tmp_name'], $dest_dir."/domains")){ // copy in the file "domains" (containing @ip & domain names (like over Toulouse categories)) |
touch ($dest_dir."/urls"); // create the URL file even if it isn't used |
file_put_contents ($bl_categories, $dest_dir."\n", FILE_APPEND); // add to the categories list |
file_put_contents ($bl_categories_enabled, "ossi-bl-".$file_name."\n", FILE_APPEND); //Enabled by default |
exec("sudo /usr/local/bin/alcasar-bl.sh --reload"); |
} |
else |
{ |
else { |
exec("rm -rf ".escapeshellarg($dest_dir)); |
echo $l_error_upload; |
} |
463,22 → 423,20 |
<?php |
echo "<center>"; |
// total number of IP, DNS & URLs |
$nbDomainNames = exec("wc -l /usr/local/share/unbound-bl/* | tail -n 1 | awk '{print $1}'") / 2; |
$nbDomainNames = exec("wc -l $dir_bl_domain_names_enabled* | tail -n 1 | awk '{print $1}'2") / 2; |
$nbUrl = exec("for file in `find /etc/e2guardian/lists/blacklists/ -name 'urls'`; do nb=$((nb+$(wc -l \$file | awk '{print $1}'))); done; echo \$nb"); |
$nbIp = exec("wc -l /usr/local/share/iptables-bl/* | tail -n 1 | awk '{print $1}'"); |
echo "<b>$l_nbDomainNames</b> $nbDomainNames, <b>$l_nbUrl</b> $nbUrl, <b>$l_nbIp</b> $nbIp<br/>"; |
$nbIp = exec("wc -l $dir_bl_ip_enabled* | tail -n 1 | awk '{print $1}'"); |
echo "$l_state $nbDomainNames <b>$l_nbDomainNames</b>, $nbUrl <b>$l_nbUrl</b>, $nbIp <b>$l_nbIp</b><br/>"; |
echo "$l_bl_categories</center></td></tr>"; |
//read & display all BL categories (checked or not) |
//read & display all categories (checked or not) |
$cols=1; |
if (file_exists($bl_categories)) |
{ |
if (file_exists($bl_categories)){ |
$bl_files = file($bl_categories); |
$bl_files = preg_grep("/ossi-/", $bl_files, 1); // don't display ossi custom categories |
foreach ($bl_files as $fichier => $value) |
{ |
foreach ($bl_files as $fichier => $value){ |
if ($cols == 1) { echo "<tr>";} |
$categorie=trim(basename($value)); |
echo "<td><a href='bl_categories_help.php?liste=bl&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>"; |
echo "<td><a href='bl_categories_help.php?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>"; |
echo "<input type='checkbox' name='chk-$categorie'"; |
// if the line is commented, the category is disable |
if (preg_match('/^#/',$value, $r)) { echo ">";} |
485,7 → 443,7 |
else { echo " checked>"; } |
echo "</td>"; |
$cols++; |
if ($cols > 10) { |
if ($cols > 10){ |
echo "</tr>\n"; |
$cols=1; |
} |
494,7 → 452,6 |
else { |
echo "$l_error_open_file $bl_categories"; |
} |
echo "</tr>\n"; |
echo "<tr><td valign='middle' align='left' colspan=10>"; |
echo "<center> |
538,15 → 495,13 |
//list OSSI custom categories |
$fichiersbl = array_diff(scandir($dir_blacklist), array('..','.','ossi-bl','ossi-wl')); |
$fichiersbl = preg_grep("/^ossi-bl-/",$fichiersbl); |
foreach ($fichiersbl as $fichier => $value) |
{ |
echo "<tr><td><center><a href='bl_categories_help.php?liste=bl&cat=$value&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'>".substr($value,8)."</a></center></td><td><center>".exec("wc -l $dir_bl_ip$value | cut -d\" \" -f1")."</center></td><td><center>".exec("wc -l $dir_bl_domain_names$value.conf | cut -d\" \" -f1")."</center></td><td><center><input type='submit' name='$value'"; |
foreach ($fichiersbl as $fichier => $value){ |
echo "<tr><td><center><a href='bl_categories_help.php?cat=$value&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'>".substr($value,8)."</a></center></td><td><center>".exec("wc -l $dir_bl_ip$value | cut -d\" \" -f1")."</center></td><td><center>".exec("wc -l $dir_bl_domain_names$value.conf | cut -d\" \" -f1")."</center></td><td><center><input type='submit' name='$value'"; |
if (file_exists ($dir_bl_domain_names_enabled.$value)) echo " value='$l_disable'>"; else echo " value='$l_enable'>"; |
echo "</center></td><td><center><input type='submit' name='$value' value='$l_remove'></center></td>"; |
if (in_array($value,$updateable_ossi_bls)) echo "<td><center><input type='submit' name='$value' value='$l_update'></center></td>"; else echo "<td><center>$l_no_update_configured</center></td>"; |
echo "</tr>"; |
} |
echo "</table>"; |
echo "</form><br></td>"; |
echo "<td width=50% colspan=5 align=center><H3>$l_add_file</H3>"; |
584,9 → 539,7 |
echo "<input type='radio' name='update_cat' value=1 ".$update_select[1]." >".$l_enable; |
echo "</td>"; |
// Display update checkbox for each updateable ossi-bl |
foreach ($updateable_ossi_bls as $value) |
{ |
//check if autoupdate is enabled |
foreach ($updateable_ossi_bls as $value){ //check if autoupdate is enabled |
$update_ossi_select = ["", ""]; |
if ( strpos(file_get_contents($update_file_ossi_cat),$value) !== false ) $update_ossi_select[1] = "checked"; |
else $update_ossi_select[0] = "checked"; |
/web/acc/admin/wl_filter.php |
---|
10,41 → 10,34 |
<div class="lds-spinner" id="spinner"><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div></div> |
</div> |
<? |
function form_filter ($form_content) |
{ |
// réencodage iso + format unix + rc fin de ligne (ouf...) |
function form_filter ($form_content){ |
// Re-encoding : ISO + unix format + end-of-line |
$list = str_replace("\r\n", "\n", utf8_decode($form_content)); |
if (strlen($list) != 0){ |
if ($list[strlen($list)-1] != "\n") { $list[strlen($list)]="\n";} ;} ; |
return $list; |
} |
function form_filter_ip($form_content, $color) |
{ |
//# reconstruction des ip |
function form_filter_ip($form_content, $color){ |
// IP reconstruction |
$list = explode("\n", form_filter($form_content)); |
$new_list = ""; |
foreach ($list as &$value) |
{ |
if(preg_match('/([0-9]{1,3}.){3}[0-9]{1,3}/', $value)) |
{ |
foreach ($list as &$value){ |
if(preg_match('/([0-9]{1,3}.){3}[0-9]{1,3}/', $value)){ |
$new_list = $new_list.$value."\n"; |
} |
} |
if($color == "white") |
{ |
if($color == "white"){ |
return preg_replace("/(.*)\n/", "add wl_ip_allowed $1\n", $new_list); |
} |
else |
{ |
else { |
return preg_replace("/(.*)\n/", "add bl_ip_blocked $1\n", $new_list); |
} |
} |
function echo_file ($filename) |
{ |
if (file_exists($filename)) |
{ |
if (filesize($filename) != 0) |
{ |
function echo_file ($filename){ |
if (file_exists($filename)){ |
if (filesize($filename) != 0){ |
$pointeur=fopen($filename,"r"); |
$tampon = fread($pointeur, filesize($filename)); |
fclose($pointeur); |
51,17 → 44,15 |
echo $tampon; |
} |
} |
else |
{ |
else { |
echo "$filename doesn't exist"; |
} |
} |
function echo_ip_file ($filename) |
{ |
function echo_ip_file ($filename){ |
$filename = escapeshellarg($filename); |
exec("cat $filename | cut -d ' ' -f3", $resultat); |
for($i=0; $i<exec("wc -l $filename"); $i++) |
{ |
for($i=0; $i<exec("wc -l $filename"); $i++){ |
echo $resultat[$i]."\n"; |
} |
} |
74,6 → 65,7 |
} |
if($Language == 'fr'){ |
$l_wl="Liste blanche principale"; |
$l_state="Sont actuellement autorisés : "; |
$l_load="Chargement..."; |
$l_list_version="Version de la liste : "; |
$l_wl_categories="Sélectionnez les catégories à autoriser"; |
95,14 → 87,15 |
$l_submit="Envoyer"; |
$l_nb_ip="Nombre d'IP"; |
$l_nb_domain_names="Nombre de noms de domaine"; |
$l_nbDomainNames="Noms de domaine :"; |
$l_nbUrl="Url :"; |
$l_nbIp="Ip :"; |
$l_nbDomainNames="noms de domaine"; |
$l_nbUrl="URL"; |
$l_nbIp="@IP"; |
$l_disable="Désactiver"; |
$l_enable="Activer"; |
$l_file_state="Etat"; |
} else if($Language == 'es') { |
} else if($Language == 'es'){ |
$l_wl="Lista blanca principal"; |
$l_state="The following are currently authorized : "; |
$l_load="Cargando..."; |
$l_list_version="Versión de la lista: "; |
$l_wl_categories="Seleccione las categorías permitidas"; |
124,14 → 117,15 |
$l_submit="Enviar"; |
$l_nb_ip="Número de IPs"; |
$l_nb_domain_names="Número de sitios"; |
$l_nbDomainNames="Sitios:"; |
$l_nbUrl="Url :"; |
$l_nbIp="Ip :"; |
$l_nbDomainNames="sitios"; |
$l_nbUrl="URL"; |
$l_nbIp="IP@"; |
$l_disable="Desactivar"; |
$l_enable="Activar"; |
$l_file_state="Estado"; |
} else { |
$l_wl="Main WhiteList"; |
$l_state="Actualmente están autorizados los siguientes : "; |
$l_load="Loading..."; |
$l_list_version="List version : "; |
$l_wl_categories="Select the allowed categories"; |
153,9 → 147,9 |
$l_submit="Submit"; |
$l_nb_ip="Number of IP"; |
$l_nb_domain_names="Number of domain names"; |
$l_nbDomainNames="Domain names :"; |
$l_nbUrl="Url :"; |
$l_nbIp="Ip :"; |
$l_nbDomainNames="domain names"; |
$l_nbUrl="URL"; |
$l_nbIp="IP@"; |
$l_disable="Disable"; |
$l_enable="Enable"; |
$l_file_state="State"; |
164,9 → 158,9 |
$dir_dg="/etc/e2guardian/lists/"; |
$dir_blacklist=$dir_dg."blacklists/"; |
$dir_wl_ip="/usr/local/share/iptables-wl/"; |
$dir_wl_ip_enabled= "/usr/local/share/iptables-wl-enabled/"; |
$dir_wl_domain_names= "/usr/local/share/unbound-wl/"; |
$dir_wl_domain_names_enabled= "/usr/local/share/unbound-wl-enabled/"; |
$dir_wl_ip_enabled="/usr/local/share/iptables-wl-enabled/"; |
$dir_wl_domain_names="/usr/local/share/unbound-wl/"; |
$dir_wl_domain_names_enabled="/usr/local/share/unbound-wl-enabled/"; |
$wl_categories=$dir_etc."alcasar-wl-categories"; |
$wl_categories_enabled=$dir_etc."alcasar-wl-categories-enabled"; |
$conf_file=$dir_etc."alcasar.conf"; |
173,27 → 167,22 |
$domainfilter_file="/etc/unbound/conf.d/whitelist/domainfilter.conf"; |
$bannedsite_file=$dir_dg."bannedsitelist"; |
$dir_tmp="/tmp/blacklists"; |
$wl_safesearch="off"; |
# default values |
if (is_file ($conf_file)) |
{ |
if (is_file ($conf_file)){ |
$tab=file($conf_file); |
if ($tab) |
{ |
foreach ($tab as $line) |
{ |
if ($tab){ |
foreach ($tab as $line){ |
$field=explode("=", $line); |
switch ($field[0]) { |
switch ($field[0]){ |
case 'PRIVATE_IP': |
$PRIVATE_IP_MASK=trim($field[1]); |
$tmp = explode("/",$PRIVATE_IP_MASK); |
$PRIVATE_IP=$tmp[0]; |
break; |
case 'WL_SAFESEARCH': |
if (strtolower(trim($field[1])) == 'on') { |
if (strtolower(trim($field[1])) == 'on'){ |
$wl_safesearch='on'; |
} |
break; |
203,32 → 192,17 |
} |
else { echo "$l_error_open_file $conf_file";} |
if (isset($_POST['choix'])){ $choix=$_POST['choix']; } else { $choix=""; } |
switch ($choix) |
{ |
case 'Download_list' : |
exec ("sudo /usr/local/bin/alcasar-bl.sh --download"); |
break; |
case 'Active_list' : |
exec ("sudo /usr/local/bin/alcasar-bl.sh --adapt"); |
exec ("sudo /usr/local/bin/alcasar-bl.sh --reload"); |
break; |
case 'Reject_list' : |
unlink ("$dir_tmp/blacklists.tar.gz"); unlink ("$dir_tmp/md5sum"); |
break; |
switch ($choix){ |
case 'MAJ_cat_wl' : |
if (file_exists($wl_categories_enabled)) |
{ |
if (file_exists($wl_categories_enabled)){ |
exec("/bin/sed -i \"/^ossi-/!d\" $wl_categories_enabled"); // keep ossi custom categories |
$pointeur=fopen($wl_categories_enabled, "a+"); |
foreach ($_POST as $key => $value) |
{ |
if (strstr($key,'chk-')) |
{ |
foreach ($_POST as $key => $value){ |
if (strstr($key,'chk-')){ |
$line=str_replace('chk-','',$key)."\n"; |
fwrite($pointeur,$line); |
} |
} |
fclose($pointeur); |
} |
else {echo "$l_error_open_file $wl_categories_enabled";} |
240,9 → 214,8 |
break; |
case 'Specific_filtering' : |
$wl_safesearch='off'; |
foreach ($_POST as $key => $value) |
{ |
if (strstr($key,'chk-safesearch')) { |
foreach ($_POST as $key => $value){ |
if (strstr($key,'chk-safesearch')){ |
$wl_safesearch='on'; |
} |
} |
249,25 → 222,20 |
exec ("sudo /usr/local/bin/alcasar-url_filter_wl.sh -safesearch_$wl_safesearch"); |
break; |
case 'MAJ_ossi_file' : |
foreach ($_POST as $fichier => $value) |
{ |
if($fichier != "choix") |
{ |
foreach ($_POST as $fichier => $value){ |
if($fichier != "choix"){ |
$action=$_POST[$fichier]; |
if($action == $l_remove) //delete |
{ |
if($action == $l_remove){ //delete |
exec("/bin/sed -i ".escapeshellarg("/^$fichier\$/d")." $wl_categories_enabled"); |
exec("/bin/sed -i ".escapeshellarg("/^$fichier\$/d")." $wl_categories"); |
exec("rm -rf ".escapeshellarg("$dir_blacklist$fichier")); |
exec("sudo /usr/local/bin/alcasar-bl.sh --reload"); |
} |
if($action == $l_disable) //disable |
{ |
if($action == $l_disable){ //disable |
exec("/bin/sed -i ".escapeshellarg("/^$fichier\$/d")." $wl_categories_enabled"); |
exec("sudo /usr/local/bin/alcasar-bl.sh --reload"); |
} |
if($action == $l_enable) //enable |
{ |
if($action == $l_enable){ //enable |
file_put_contents($wl_categories_enabled, $fichier."\n", FILE_APPEND); |
exec("sudo /usr/local/bin/alcasar-bl.sh --reload"); |
} |
276,21 → 244,18 |
break; |
case 'MAJ_ossi_file_upload' : |
$file_name = str_replace (".", "_",basename($_FILES['fichier_ip']['name'])); |
if(!empty($file_name)) |
{ |
if(!empty($file_name)){ |
$dest_dir = $dir_blacklist."ossi-wl-".$file_name; |
exec("mkdir ".escapeshellarg($dest_dir)); |
$file=$_FILES['fichier_ip']['tmp_name']; |
exec('/usr/bin/dos2unix '.escapeshellarg($file)); |
if(move_uploaded_file($_FILES['fichier_ip']['tmp_name'], $dest_dir."/domains")) |
{ |
if(move_uploaded_file($_FILES['fichier_ip']['tmp_name'], $dest_dir."/domains")){ |
touch ($dest_dir."/urls"); // create the URL file even if it isn't used |
file_put_contents ($wl_categories, $dest_dir."\n", FILE_APPEND); |
file_put_contents ($wl_categories_enabled, "ossi-wl-".$file_name."\n", FILE_APPEND); //Enabled by default |
exec ("sudo /usr/local/bin/alcasar-bl.sh --reload"); |
} |
else |
{ |
else { |
exec("rm -rf ".escapeshellarg($dest_dir)); |
echo $l_error_upload; |
} |
309,22 → 274,20 |
<?php |
echo "<center>"; |
// total number of IP, DNS & URLs |
$nbDomainNames = exec("wc -l $dir_wl_domain_names* | tail -n 1 | awk '{print $1}'"); |
$nbDomainNames = exec("wc -l $dir_wl_domain_names_enabled* | tail -n 1 | awk '{print $1}'"); |
$nbUrl = "0"; |
$nbIp = exec("wc -l $dir_wl_ip* | tail -n 1 | awk '{print $1}'"); |
echo "<b>$l_nbDomainNames</b> $nbDomainNames, <b>$l_nbUrl</b> $nbUrl, <b>$l_nbIp</b> $nbIp<br/>"; |
$nbIp = exec("wc -l $dir_wl_ip_enabled* | tail -n 1 | awk '{print $1}'"); |
echo "$l_state $nbDomainNames <b>$l_nbDomainNames</b>, $nbUrl <b>$l_nbUrl</b>, $nbIp <b>$l_nbIp</b><br/>"; |
echo "$l_wl_categories</center></td></tr>"; |
//read & display all WL categories (checked or not) |
//read & display all categories (checked or not) |
$cols=1; |
if (file_exists($wl_categories)) |
{ |
if (file_exists($wl_categories)){ |
$wl_files = file($wl_categories); |
$wl_files = preg_grep("/ossi-/", $wl_files, 1); // don't display ossi custom categories |
foreach ($wl_files as $fichier => $value) |
{ |
foreach ($wl_files as $fichier => $value){ |
if ($cols == 1) { echo "<tr>";} |
$categorie=trim(basename($value)); |
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>"; |
echo "<td><a href='bl_categories_help.php?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>"; |
echo "<input type='checkbox' name='chk-$categorie'"; |
// if the line is commented, the category is disable |
if (preg_match('/^#/',$value, $r)) { echo ">";} |
331,7 → 294,7 |
else { echo "checked>"; } |
echo "</td>"; |
$cols++; |
if ($cols > 10) { |
if ($cols > 10){ |
echo "</tr>"; |
$cols=1; |
} |
367,9 → 330,8 |
//list OSSI custom categories |
$fichierswl = array_diff(scandir($dir_blacklist), array('..','.','ossi-bl','ossi-wl')); |
$fichierswl = preg_grep("/^ossi-wl-/",$fichierswl); |
foreach ($fichierswl as $fichier => $value) |
{ |
echo "<tr><td><center><a href='bl_categories_help.php?liste=wl&cat=$value&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'>".substr($value,8)."</a></center></td><td><center>".exec("wc -l $dir_wl_ip$value | cut -d\" \" -f1")."</center></td><td><center>".exec("wc -l $dir_wl_domain_names$value.conf | cut -d\" \" -f1")."</center></td><td><center><input type='submit' name='$value'"; |
foreach ($fichierswl as $fichier => $value){ |
echo "<tr><td><center><a href='bl_categories_help.php?cat=$value&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'>".substr($value,8)."</a></center></td><td><center>".exec("wc -l $dir_wl_ip$value | cut -d\" \" -f1")."</center></td><td><center>".exec("wc -l $dir_wl_domain_names$value.conf | cut -d\" \" -f1")."</center></td><td><center><input type='submit' name='$value'"; |
if (file_exists ($dir_wl_domain_names_enabled.$value)) echo " value='$l_disable'>"; else echo " value='$l_enable'>"; |
echo "</center></td><td><center><input type='submit' name='$value' value='$l_remove'></center></td></tr>"; |
} |