61,6 → 61,28 |
echo $resultat[$i]."\n"; |
} |
} |
|
#maximum length for top-level DNS |
function max_tld() |
{ |
$url_tld = "http://data.iana.org/TLD/tlds-alpha-by-domain.txt"; |
$result_tld = file_get_contents($url_tld,false); |
$max_tld = 18; #valeur de base si le site ne répond plus |
if($result_tld !== FALSE){ |
foreach(explode("\n", $result_tld) as $line) |
{ |
if((strpos($line,'-') === false) and (strpos($line,'#') === false)) |
{ |
if(strlen($line) > $max_tld) |
{ |
$max_tld = strlen($line); |
} |
} |
} |
} |
return $max_tld; |
} |
|
# Choice of language |
$Language = 'en'; |
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){ |
68,6 → 90,7 |
$Language = strtolower(substr(chop($Langue[0]),0,2)); } |
if($Language == 'fr'){ |
$l_wl="Liste blanche"; |
$l_load="Chargement..."; |
$l_list_version="Version de la liste : "; |
$l_specific_filtering="Filtrage special"; |
$l_wl_categories="Sélectionnez les catégories à autoriser"; |
79,6 → 102,14 |
$l_record="Enregistrer les modifications"; |
$l_wait="Une fois validées, 10 secondes sont nécessaires pour traiter vos modifications"; |
$l_error_open_file="Erreur d'ouverture du fichier"; |
$l_additional_file_title="Fichiers de 'listes blanche' additionnels"; |
$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"; |
$l_file_name="Nom du fichier"; |
$l_file_remove="Supprimer"; |
$l_error_upload="Erreur d'envoi du fichier"; |
$l_remove="Supprimer"; |
$l_submit="Envoyer"; |
$l_nb_ip="Nombre d'IP"; |
$l_nb_domain_names="Nombre de noms de domaine"; |
87,12 → 118,13 |
$l_nbIp="Ip :"; |
$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 des moteurs de recherche : google, yahoo, bing, metacrawler et Youtube."; |
$l_safe_youtube="Pour Youtube sain, suivez les étapes ici pour chaque poste : "; |
$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>)"; |
$l_safe_youtube="Pour Youtube restreint, suivez les étapes ici pour chaque poste : "; |
$l_youtube_id="(<a href='https://support.google.com/youtube/answer/174084?hl=fr' target='cat_help' onclick=window.open('https://support.google.com/youtube/answer/174084?hl=fr','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>)"; |
|
} |
else { |
$l_wl="WhiteList"; |
$l_load="Loading..."; |
$l_list_version="List version : "; |
$l_wl_categories="Select the categories to allow"; |
$l_allowed_dns="Allowed domain names"; |
103,6 → 135,14 |
$l_record="Save changes"; |
$l_wait="Once validated, 10 seconds are necessary to compute your modifications"; |
$l_error_open_file="Error opening file"; |
$l_additional_file_title="Additional whitelist files"; |
$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"; |
$l_file_name="Filename"; |
$l_file_remove="Remove"; |
$l_error_upload="Error during the upload process"; |
$l_remove="Delete"; |
$l_submit="Submit"; |
$l_nb_ip="Number of IP"; |
$l_nb_domain_names="Number of domain names"; |
111,19 → 151,22 |
$l_nbIp="Ip :"; |
$l_ip_filtering="Filtering URLs that contain an IP address instead of a domain name (ie: http://25.56.58.59/index.htm)"; |
$l_specific_filtering="Specific filtering"; |
$l_safe_youtube="For Safe Youtube, follow steps here for each computer "; |
$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>)"; |
$l_safe_searching="Enabling school/parental control for the search engines google, yahoo, bing, metacrawler and Youtube."; |
$l_safe_youtube="For safe Youtube, follow steps here for each computer "; |
$l_youtube_id="(<a href='https://support.google.com/youtube/answer/174084?hl=en' target='cat_help' onclick=window.open('https://support.google.com/youtube/answer/174084?hl=en','cat_help','width=800,height=600,toolbar=no,scrollbars=yes,resizable=yes') title='Youtube for school'>link to create a Youtube Id</a>)"; |
$l_safe_searching="Enabling school/parental control for the search engines google."; |
|
} |
$dir_etc="/usr/local/etc/"; |
$dir_dg="/etc/dansguardian/lists/"; |
$file_wl_ip="/usr/local/share/ossi-ip-wl"; |
$file_wl_ip="/usr/local/share/iptables-wl-enabled/ossi"; |
$wl_categories=$dir_etc."alcasar-wl-categories"; |
$wl_categories_enabled=$dir_etc."alcasar-wl-categories-enabled"; |
$conf_file=$dir_etc."alcasar.conf"; |
$tinyproxy_conf="/etc/tinyproxy/tinyproxy.conf"; |
$dnsmasq_conf="/etc/dnsmasq-whitelist.conf"; |
$dir_tmp="/tmp/"; |
$upload_dir_ip = "/usr/local/share/iptables-wl-enabled/"; |
$upload_dir_domain_names = "/usr/local/share/dnsmasq-wl-enabled/"; |
# default values |
if (is_file ($conf_file)) |
{ |
133,11 → 176,9 |
foreach ($tab as $line) |
{ |
$field=explode("=", $line); |
if ($field[0] == "PRIVATE_IP") |
if ($field[0] == "DNS1") |
{ |
$PRIVATE_IP_MASK=trim($field[1]); |
$tmp = explode("/",$PRIVATE_IP_MASK); |
$PRIVATE_IP=$tmp[0]; |
$DNS1=trim($field[1]); |
} |
} |
} |
180,6 → 221,58 |
unset($_POST['OSSI_wl_ip']); |
exec ("sudo /usr/local/bin/alcasar-bl.sh --reload"); |
break; |
case 'MAJ_ip_file_delete' : |
foreach($_POST as $fichier => $value) |
{ |
if($fichier != "choix") |
{ |
exec("rm -rf $upload_dir_ip$fichier"); |
exec("rm -rf $upload_dir_domain_names$fichier"); |
exec ("sudo /usr/local/bin/alcasar-bl.sh --reload"); |
} |
} |
break; |
case 'MAJ_ip_file_upload' : |
$nom = str_replace (".", "_",basename($_FILES['fichier_ip']['name'])); |
# Si un fichier a été choisi |
if(!empty($nom)) |
{ |
# On l'upload |
if(move_uploaded_file($_FILES['fichier_ip']['tmp_name'], $upload_dir_ip.$nom)) |
{ |
|
# On extrait uniquement les ip du fichier |
exec("grep -Eo '([0-9]{1,3}\.){3}[0-9]{1,3}' $upload_dir_ip$nom > $upload_dir_ip\ossi_ip"); |
|
# Suppression des doublons |
exec("sort -u $upload_dir_ip\ossi_ip > $upload_dir_ip\ossi-$nom && rm -f $upload_dir_ip\ossi_ip"); |
|
# On adapte le fichier à la sauvegarde du set |
exec("sed -i \"s/^/add whitelist_ip_allowed /g\" $upload_dir_ip\ossi-$nom"); |
|
# On extrait uniquement les noms de domaine |
# max_tld() retourne le nombre max de charactere pour un top-level dns |
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"); |
|
# Suppression des doublons |
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"); |
|
# On adapte le fichier pour Dnsmasq |
exec("sed -i \"s/^/server=\//g\" $upload_dir_domain_names\ossi-$nom"); |
exec("sed -i \"s/$/\/$DNS1/g\" $upload_dir_domain_names\ossi-$nom"); |
|
# Suppression du fichier |
exec("rm -f $upload_dir_ip$nom"); |
|
} |
else |
{ |
echo $l_error_upload; |
} |
exec ("sudo /usr/local/bin/alcasar-bl.sh --reload"); |
exec ("sudo /usr/local/bin/alcasar-iptables.sh"); |
} |
break; |
} |
?> |
<table width="100%" border="0" cellspacing="0" cellpadding="0"> |
240,8 → 333,36 |
echo_ip_file ($file_wl_ip); |
echo "</textarea></td></tr>"; |
echo "<tr><td colspan=10>"; |
echo "<input type='submit' onClick=\"this.disabled=true; this.value='$l_load';\" value='$l_record'></form></td></tr>"; |
echo "</td></tr></table><br/>"; |
?> |
|
<table width="100%" border="0" cellspacing="0" cellpadding="0"> |
<tr><th><?php echo $l_additional_file_title; ?></th></tr> |
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr> |
</table> |
|
<table width="100%" border=1 cellspacing=0 cellpadding=1> |
<form action='wl_filter.php' method='POST'> |
<input type='hidden' name='choix' value='MAJ_ip_file_delete'> |
<?php |
echo "<tr><td width=50% colspan=5 align=center>"; |
echo "<H3>$l_file_list</H3>"; |
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>"; |
exec("cd $upload_dir_ip && ls ossi-*", $fichiersIp); |
foreach($fichiersIp as $fichier => $value) |
{ |
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' onClick=\"this.disabled=true; this.value='$l_load';\" name='$value' value='$l_remove'></center></td></tr></form>"; |
} |
echo "</table><br/></td></form><form action='wl_filter.php' method='POST' enctype='multipart/form-data'>"; |
echo "<input type='hidden' name='choix' value='MAJ_ip_file_upload'><td width=50% colspan=5 align=center>"; |
echo "<H3>$l_add_file</H3>"; |
echo "$l_add_file_explain"; |
echo "<input type='file' name='fichier_ip'>"; |
echo "<input type='submit' onClick=\"this.disabled=true; this.value='$l_load';\" value='$l_submit'>"; |
echo "</td></tr>"; |
echo "</form>"; |
echo "</table><br/>"; |
echo "<input type='submit' value='$l_record'></form></td></tr>"; |
?> |
|
<table width="100%" border="0" cellspacing="0" cellpadding="0"> |
277,7 → 398,7 |
echo "<br></br>$l_safe_youtube"; |
echo " $l_youtube_id<tr><td>"; |
|
echo "<input type='submit' value='$l_record'></form></td></tr>"; |
echo "<input type='submit' onClick=\"this.disabled=true; this.value='$l_load';\" value='$l_record'></form></td></tr>"; |
?> |
|
</TABLE><br/> |