Subversion Repositories ALCASAR

Compare Revisions

Ignore whitespace Rev 2768 → Rev 2769

/web/acc/admin/bl_filter.php
70,7 → 70,7
$Language = strtolower(substr(chop($Langue[0]),0,2));
}
if($Language == 'fr'){
$l_bl="Liste noire générale";
$l_bl="Liste noire principale";
$l_load="Chargement...";
$l_list_version="Version de la liste : ";
$l_bl_categories="Sélectionnez les catégories à filtrer";
95,7 → 95,7
$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)";
$l_safe_searching="Activer le contrôle scolaire/parental pour 'YouTube' et pour les moteurs de recherche 'Google', 'Bing' et 'Qwant'.";
$l_error_open_file="Erreur d'ouverture du fichier";
$l_additional_file_title="Fichiers de 'listes noires' additionnels";
$l_additional_file_title="Listes noires additionnelles";
$l_file_list="Liste des fichiers";
$l_add_file="Ajouter un fichier";
$l_add_file_explain="Chaque ligne du fichier doit être une adresse IP ou un nom de domaine";
109,13 → 109,18
$l_nbDomainNames="Noms de domaine :";
$l_nbUrl="Url :";
$l_nbIp="Ip :";
$l_update_cat="Mise a jour des catégories automatiquement toutes les 12h (seulement 'malware' actuellement)?";
$l_update_cat="Blacklist principale (catégorie 'malware' uniquement)";
$l_update_cat_header="Mise à jour automatique des Blacklists";
$l_update_success="Mise à jour ratée";
$l_update_failed="Mise à jour réussie";
$l_disable="Désactiver";
$l_enable="Activer";
$l_update="Mise a jour";
$l_no_update_configured="Aucun script de mise à jour trouvée";
$l_file_state="Etat";
}
else {
$l_bl="General BlackList";
$l_bl="Main BlackList";
$l_load="Loading...";
$l_list_version="List version : ";
$l_bl_categories="Select the categories to filter";
141,7 → 146,7
$l_ip_filtering="Filtering URLs that contain an IP address instead of a domain name (ie: http://25.56.58.59/index.htm)";
$l_safe_searching="Enabling school/parental control for 'YouTube' and for the search engines 'Google', 'Bing' and 'Qwant'";
$l_error_open_file="Error opening file";
$l_additional_file_title="Additional blacklist files";
$l_additional_file_title="Additional blacklists";
$l_file_list="Files list";
$l_add_file="Add a file";
$l_add_file_explain="Each line of the file must be an IP address or a domain name";
155,9 → 160,14
$l_nbDomainNames="Domain names :";
$l_nbUrl="Url :";
$l_nbIp="Ip :";
$l_update_cat="Update automaticly categories every 12 hours (only 'malware' for now)?";
$l_update_cat="Main Blacklist (only 'malware' category)";
$l_update_cat_header="Automatic Update of Blacklists";
$l_update_success="Update succeeded";
$l_update_failed="Update failed";
$l_disable="Disable";
$l_enable="Enable";
$l_update="Update";
$l_no_update_configured="No update script configured";
$l_file_state="State";
}
$dir_etc="/usr/local/etc/";
174,9 → 184,10
$bannedsite_file=$dir_dg."bannedsitelist";
$dir_tmp="/tmp/blacklists";
$update_file_cat="/usr/local/etc/update_cat.conf";
 
$update_file_ossi_cat="/usr/local/etc/update_ossi_cat.conf";
$bl_safesearch="off";
$bl_pureip="off";
$updateable_ossi_bls=["ossi-bl-candc"];
 
# default values
if (is_file ($conf_file))
228,7 → 239,6
{
exec("/bin/sed -i \"/^ossi-/!d\" $bl_categories_enabled"); // keep ossi custom categories
$pointeur=fopen($bl_categories_enabled, "a+");
$fichier=fopen($update_file_cat,"w+");
foreach ($_POST as $key => $value)
{
if (strstr($key,'chk-'))
235,14 → 245,9
{
$line=str_replace('chk-','',$key)."\n";
fwrite($pointeur,$line);
if(trim($line) == 'malware' && $_POST['update_cat'] == 1) //auto-update of malware
{
fputs($fichier, "malware rsync://ftp.ut-capitole.fr/blacklist/dest/malware\n");
}
}
}
fclose($pointeur);
fclose($fichier);
}
else {echo "$l_error_open_file $bl_categories_enabled";}
$fichier=fopen($dir_blacklist."ossi-bl/domains","w+");
272,7 → 277,7
case 'MAJ_ossi_file' :
foreach($_POST as $fichier => $value)
{
if($fichier != "choix")
if($fichier != "choix" && $fichier != "update_cat")
{
$action=$_POST[$fichier];
if($action == $l_remove) //delete
284,15 → 289,59
}
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
{
file_put_contents ($bl_categories_enabled, $fichier."\n", FILE_APPEND);
exec("sudo /usr/local/bin/alcasar-bl.sh --reload");
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)
{
exec("sudo /usr/local/bin/alcasar-bl-autoupdate.sh --update_ossi-bl-candc 2>&1", $out, $ret);
if ($ret == 0)
{
echo "<p>".$l_update_success."</p>";
}
else
{
echo "<p>".$l_update_failed.":</p>";
foreach($out as $line)
{
echo "<p>".$line."</p>";
}
}
}
}
}
}
break;
case 'Autoupdate' :
// Reset updatelists, truncate files
$f = fopen($update_file_ossi_cat, 'w');
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))
{
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)
{
file_put_contents($update_file_ossi_cat, "alcasar-bl-autoupdate.sh --update_ossi-bl-candc\n", FILE_APPEND);
}
}
break;
case 'MAJ_ossi_file_upload' :
306,7 → 355,7
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, $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");
}
390,19 → 439,9
echo "$l_error_open_file $bl_categories";
}
 
//update categories with rsync
$update_select = array();
$update_select[0] = "";
$update_select[1] = "";
 
if ( 0 == filesize( $update_file_cat ) ) $update_select[0] = "checked";
else $update_select[1] = "checked";
 
echo "</tr>\n";
echo "<tr><td valign='middle' align='left' colspan=10>";
echo "<center>$l_update_cat
<input type='radio' name='update_cat' value=0 $update_select[0]> $l_disable
<input type='radio' name='update_cat' value=1 $update_select[1]> $l_enable
echo "<center>
<input type='submit' value='$l_record'></center>";
echo "</td></tr>";
echo "<tr><td valign='middle' align='left' colspan=10>";
439,7 → 478,7
echo "<H3>$l_file_list</H3>";
echo "<form action='bl_filter.php' method='POST'>";
echo "<input type='hidden' name='choix' value='MAJ_ossi_file'>";
echo "<table cellspacing=2 cellpadding=3 border=1><tr><th>$l_file_name<th>$l_nb_ip<th>$l_nb_domain_names<th colspan=2>$l_file_action</tr>";
echo "<table cellspacing=2 cellpadding=3 border=1><tr><th>$l_file_name<th>$l_nb_ip<th>$l_nb_domain_names<th colspan=3>$l_file_action</tr>";
//list OSSI custom categories
$fichiersbl = array_diff(scandir($dir_blacklist), array('..','.','ossi-bl','ossi-wl'));
$fichiersbl = preg_grep("/^ossi-bl-/",$fichiersbl);
447,9 → 486,13
{
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'";
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></tr>";
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></form><br></td>";
 
echo "</table>";
echo "</form><br></td>";
echo "<td width=50% colspan=5 align=center><H3>$l_add_file</H3>";
echo "$l_add_file_explain";
echo "<form action='bl_filter.php' method='POST' enctype='multipart/form-data'>";
459,7 → 502,49
echo "</form>";
echo "</td></tr>";
echo "</table><br>";
 
// Autoupdate Section
// ----------------------
echo '<table width="100%" border="0" cellspacing="0" cellpadding="0">';
echo ' <tr><th>'.$l_update_cat_header.'</th></tr>';
echo ' <tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>';
echo '</table>';
 
echo "<form action='bl_filter.php' method='POST'>";
echo "<input type='hidden' name='choix' value='Autoupdate'>";
?>
<table width="100%" border=1 cellspacing=0 cellpadding=1>
<tr><td>
<?php
echo "<table cellspacing=2 cellpadding=3 border=1>";
echo "<tr>";
 
// general BL
$update_select = ["", ""];
if ( 0 == filesize( $update_file_cat ) ) $update_select[0] = "checked";
else $update_select[1] = "checked";
echo "<td>".$l_update_cat."</td>";
echo "<td><input type='radio' name='update_cat' value=0 ".$update_select[0]." >".$l_disable;
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
$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";
echo "<tr><td>".$value."</td>";
echo "<td><input type='radio' name='".$value."' value=0 ".$update_ossi_select[0]." >".$l_disable;
echo "<input type='radio' name='".$value."' value=1 ".$update_ossi_select[1]." >".$l_enable."</td>";
echo "</tr>";
}
echo "</tr></td><br />";
echo "</table>";
echo "<input type='submit' value='$l_record'></center>";
echo "</table>";
echo "</form>";
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><th><?php echo $l_specific_filtering; ?></th></tr>
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>