1843 |
raphael.pi |
1 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
|
|
2 |
<HTML><!-- written by Rexy -->
|
|
|
3 |
<HEAD>
|
|
|
4 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
|
5 |
<TITLE>ALCASAR Whitelist filtering</TITLE>
|
|
|
6 |
<link rel="stylesheet" href="/css/style.css" type="text/css">
|
|
|
7 |
</HEAD>
|
|
|
8 |
<body>
|
|
|
9 |
<?
|
|
|
10 |
function form_filter ($form_content)
|
|
|
11 |
{
|
|
|
12 |
// réencodage iso + format unix + rc fin de ligne (ouf...)
|
|
|
13 |
$list = str_replace("\r\n", "\n", utf8_decode($form_content));
|
|
|
14 |
if (strlen($list) != 0){
|
|
|
15 |
if ($list[strlen($list)-1] != "\n") { $list[strlen($list)]="\n";} ;} ;
|
|
|
16 |
return $list;
|
|
|
17 |
}
|
|
|
18 |
function form_filter_ip($form_content, $color)
|
|
|
19 |
{
|
|
|
20 |
//# reconstruction des ip
|
|
|
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 |
{
|
|
|
32 |
return preg_replace("/(.*)\n/", "add whitelist_ip_allowed $1\n", $new_list);
|
|
|
33 |
}
|
|
|
34 |
else
|
|
|
35 |
{
|
|
|
36 |
return preg_replace("/(.*)\n/", "add blacklist_ip_blocked $1\n", $new_list);
|
|
|
37 |
}
|
|
|
38 |
}
|
|
|
39 |
function echo_file ($filename)
|
|
|
40 |
{
|
|
|
41 |
if (file_exists($filename))
|
|
|
42 |
{
|
|
|
43 |
if (filesize($filename) != 0)
|
|
|
44 |
{
|
|
|
45 |
$pointeur=fopen($filename,"r");
|
|
|
46 |
$tampon = fread($pointeur, filesize($filename));
|
|
|
47 |
fclose($pointeur);
|
|
|
48 |
echo $tampon;
|
|
|
49 |
}
|
|
|
50 |
}
|
|
|
51 |
else
|
|
|
52 |
{
|
|
|
53 |
echo "$filename doesn't exist";
|
|
|
54 |
}
|
|
|
55 |
}
|
|
|
56 |
function echo_ip_file ($filename)
|
|
|
57 |
{
|
|
|
58 |
exec("cat $filename | cut -d ' ' -f3", $resultat);
|
|
|
59 |
for($i=0; $i<exec("wc -l $filename"); $i++)
|
|
|
60 |
{
|
|
|
61 |
echo $resultat[$i]."\n";
|
|
|
62 |
}
|
|
|
63 |
}
|
|
|
64 |
# Choice of language
|
|
|
65 |
$Language = 'en';
|
|
|
66 |
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
|
|
|
67 |
$Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
|
|
|
68 |
$Language = strtolower(substr(chop($Langue[0]),0,2)); }
|
|
|
69 |
if($Language == 'fr'){
|
|
|
70 |
$l_wl="Liste blanche";
|
|
|
71 |
$l_list_version="Version de la liste : ";
|
|
|
72 |
$l_specific_filtering="Filtrage special";
|
|
|
73 |
$l_wl_categories="Sélectionnez les catégories à autoriser";
|
|
|
74 |
$l_allowed_dns="Noms de domaine autorisés";
|
|
|
75 |
$l_one_dns="Entrez un nom de domaine par ligne (exemple : .domaine.org)";
|
|
|
76 |
$l_add_to_wl="Noms de domaine ou IP ajoutés à la liste blanche";
|
|
|
77 |
$l_forbidden_ip_explain="Entrez une IP par ligne (exemple : 123.123.123.123)<br/>ou une adresse de réseau (exemple : 123.123.0.0/16)";
|
|
|
78 |
$l_allowed_ip="IP autorisées";
|
|
|
79 |
$l_record="Enregistrer les modifications";
|
|
|
80 |
$l_wait="Une fois validées, 10 secondes sont nécessaires pour traiter vos modifications";
|
|
|
81 |
$l_error_open_file="Erreur d'ouverture du fichier";
|
|
|
82 |
$l_submit="Envoyer";
|
|
|
83 |
$l_nb_ip="Nombre d'IP";
|
|
|
84 |
$l_nb_domain_names="Nombre de noms de domaine";
|
|
|
85 |
$l_nbDomainNames="Noms de domaine :";
|
|
|
86 |
$l_nbUrl="Url :";
|
|
|
87 |
$l_nbIp="Ip :";
|
|
|
88 |
$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)";
|
|
|
89 |
$l_safe_searching="Activer le contrôle scolaire/parental des moteurs de recherche : google, yahoo, bing, metacrawler et Youtube.";
|
|
|
90 |
$l_safe_youtube="Pour Youtube sain, suivez les étapes ici pour chaque poste : ";
|
|
|
91 |
$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>)";
|
|
|
92 |
|
|
|
93 |
}
|
|
|
94 |
else {
|
|
|
95 |
$l_wl="WhiteList";
|
|
|
96 |
$l_list_version="List version : ";
|
|
|
97 |
$l_wl_categories="Select the categories to allow";
|
|
|
98 |
$l_allowed_dns="Allowed domain names";
|
|
|
99 |
$l_one_dns="Enter one domain name per row (example : .domain.org)";
|
|
|
100 |
$l_add_to_wl="Domain names or IP to add to whitelist";
|
|
|
101 |
$l_forbidden_ip_explain="Enter one IP per row (example : 123.123.123.123)<br/>or a network address (example : 123.123.0.0/16)";
|
|
|
102 |
$l_allowed_ip="Allowed IP";
|
|
|
103 |
$l_record="Save changes";
|
|
|
104 |
$l_wait="Once validated, 10 seconds are necessary to compute your modifications";
|
|
|
105 |
$l_error_open_file="Error opening file";
|
|
|
106 |
$l_submit="Submit";
|
|
|
107 |
$l_nb_ip="Number of IP";
|
|
|
108 |
$l_nb_domain_names="Number of domain names";
|
|
|
109 |
$l_nbDomainNames="Domain names :";
|
|
|
110 |
$l_nbUrl="Url :";
|
|
|
111 |
$l_nbIp="Ip :";
|
|
|
112 |
$l_ip_filtering="Filtering URLs that contain an IP address instead of a domain name (ie: http://25.56.58.59/index.htm)";
|
|
|
113 |
$l_specific_filtering="Specific filtering";
|
|
|
114 |
$l_safe_youtube="For Safe Youtube, follow steps here for each computer ";
|
|
|
115 |
$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>)";
|
|
|
116 |
$l_safe_searching="Enabling school/parental control for the search engines google, yahoo, bing, metacrawler and Youtube.";
|
|
|
117 |
|
|
|
118 |
}
|
|
|
119 |
$dir_etc="/usr/local/etc/";
|
|
|
120 |
$dir_dg="/etc/dansguardian/lists/";
|
|
|
121 |
$file_wl_ip="/usr/local/share/ossi-ip-wl";
|
|
|
122 |
$wl_categories=$dir_etc."alcasar-wl-categories";
|
|
|
123 |
$wl_categories_enabled=$dir_etc."alcasar-wl-categories-enabled";
|
|
|
124 |
$conf_file=$dir_etc."alcasar.conf";
|
|
|
125 |
$tinyproxy_conf="/etc/tinyproxy/tinyproxy.conf";
|
|
|
126 |
$dnsmasq_conf="/etc/dnsmasq-whitelist.conf";
|
|
|
127 |
# default values
|
|
|
128 |
if (is_file ($conf_file))
|
|
|
129 |
{
|
|
|
130 |
$tab=file($conf_file);
|
|
|
131 |
if ($tab)
|
|
|
132 |
{
|
|
|
133 |
foreach ($tab as $line)
|
|
|
134 |
{
|
|
|
135 |
$field=explode("=", $line);
|
|
|
136 |
if ($field[0] == "PRIVATE_IP")
|
|
|
137 |
{
|
|
|
138 |
$PRIVATE_IP_MASK=trim($field[1]);
|
|
|
139 |
$tmp = explode("/",$PRIVATE_IP_MASK);
|
|
|
140 |
$PRIVATE_IP=$tmp[0];
|
|
|
141 |
}
|
|
|
142 |
}
|
|
|
143 |
}
|
|
|
144 |
}
|
|
|
145 |
else { echo "$l_error_open_file $conf_file";}
|
|
|
146 |
|
|
|
147 |
if (isset($_POST['choix'])){ $choix=$_POST['choix']; } else { $choix=""; }
|
|
|
148 |
switch ($choix)
|
|
|
149 |
{
|
|
|
150 |
case 'Specific_filtering' :
|
|
|
151 |
$safesearch="-safesearch_off"; ;
|
|
|
152 |
foreach ($_POST as $key => $value)
|
|
|
153 |
{
|
|
|
154 |
if (strstr($key,'chk-safesearch')) $safesearch="-safesearch_on";
|
|
|
155 |
}
|
|
|
156 |
exec ("sudo /usr/local/bin/alcasar-url_filter_wl.sh $safesearch");
|
|
|
157 |
break;
|
|
|
158 |
case 'MAJ_cat_wl' :
|
|
|
159 |
if (file_exists($wl_categories_enabled))
|
|
|
160 |
{
|
|
|
161 |
$pointeur=fopen($wl_categories_enabled, "w+");
|
|
|
162 |
foreach ($_POST as $key => $value)
|
|
|
163 |
{
|
|
|
164 |
if (strstr($key,'chk-'))
|
|
|
165 |
{
|
|
|
166 |
$line=str_replace('chk-','',$key)."\n";
|
|
|
167 |
fwrite($pointeur,$line);
|
|
|
168 |
}
|
|
|
169 |
}
|
|
|
170 |
fclose($pointeur);
|
|
|
171 |
}
|
|
|
172 |
else {echo "$l_error_open_file $wl_categories_enabled";}
|
|
|
173 |
$fichier=fopen($dir_dg."blacklists/ossi/domains_wl","w+");
|
|
|
174 |
fputs($fichier, form_filter($_POST['OSSI_wl_domains']));
|
|
|
175 |
fclose($fichier);
|
|
|
176 |
unset($_POST['OSSI_wl_domains']);
|
|
|
177 |
$fichier=fopen($file_wl_ip, "w+");
|
|
|
178 |
fputs($fichier, form_filter_ip($_POST['OSSI_wl_ip'], "white"));
|
|
|
179 |
fclose($fichier);
|
|
|
180 |
unset($_POST['OSSI_wl_ip']);
|
|
|
181 |
exec ("sudo /usr/local/bin/alcasar-bl.sh --reload");
|
|
|
182 |
break;
|
|
|
183 |
}
|
|
|
184 |
?>
|
|
|
185 |
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
|
|
186 |
<tr><th><?php echo $l_wl; ?></th></tr>
|
|
|
187 |
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
|
|
|
188 |
</table>
|
|
|
189 |
|
|
|
190 |
<TABLE width="100%" border=1 cellspacing=0 cellpadding=1>
|
|
|
191 |
<tr><td valign="middle" align="left" colspan=10>
|
|
|
192 |
<FORM action='wl_filter.php' method=POST>
|
|
|
193 |
<input type='hidden' name='choix' value='MAJ_cat_wl'>
|
|
|
194 |
<?php
|
|
|
195 |
echo "<center>";
|
|
|
196 |
$nbDomainNames = exec ("wc -l /usr/local/share/dnsmasq-wl/* | tail -n 1 | awk '{print $1}'");
|
|
|
197 |
$nbUrl = 0;
|
|
|
198 |
$nbIp = 0;
|
|
|
199 |
echo "<b>$l_nbDomainNames</b> $nbDomainNames, <b>$l_nbUrl</b> $nbUrl, <b>$l_nbIp</b> $nbIp<br/>";
|
|
|
200 |
echo "$l_wl_categories</center></td></tr>";
|
|
|
201 |
//on lit et on interprete le fichier de catégories
|
|
|
202 |
$cols=1;
|
|
|
203 |
if (file_exists($wl_categories))
|
|
|
204 |
{
|
|
|
205 |
$pointeur=fopen($wl_categories,"r");
|
|
|
206 |
while (!feof ($pointeur))
|
|
|
207 |
{
|
|
|
208 |
$ligne=fgets($pointeur, 4096);
|
|
|
209 |
if ($ligne)
|
|
|
210 |
{
|
|
|
211 |
if ($cols == 1) { echo "<tr>";}
|
|
|
212 |
$categorie=trim(basename($ligne));
|
|
|
213 |
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>";
|
|
|
214 |
echo "<input type='checkbox' name='chk-$categorie'";
|
|
|
215 |
// si la ligne est commentée -> categorie non selectionnée
|
|
|
216 |
if (preg_match('/^#/',$ligne, $r)) { echo ">";}
|
|
|
217 |
else { echo "checked>"; }
|
|
|
218 |
echo "</td>";
|
|
|
219 |
$cols++;
|
|
|
220 |
if ($cols > 10) {
|
|
|
221 |
echo "</tr>";
|
|
|
222 |
$cols=1; }
|
|
|
223 |
}
|
|
|
224 |
}
|
|
|
225 |
fclose($pointeur);
|
|
|
226 |
}
|
|
|
227 |
else {
|
|
|
228 |
echo "$l_error_open_file $wl_categories";
|
|
|
229 |
}
|
|
|
230 |
echo "<tr><td valign='middle' align='left' colspan=10>";
|
|
|
231 |
echo "<center><b>$l_add_to_wl</b></center></td></tr>";
|
|
|
232 |
echo "<tr><td width=50% colspan=5 align=center>";
|
|
|
233 |
echo "<H3>$l_allowed_dns</H3>$l_one_dns<BR>";
|
|
|
234 |
echo "<textarea name='OSSI_wl_domains' rows=3 cols=40>";
|
|
|
235 |
echo_file ($dir_dg."blacklists/ossi/domains_wl");
|
|
|
236 |
echo "</textarea></td>";
|
|
|
237 |
echo "<td width=50% colspan=5 align=center>";
|
|
|
238 |
echo "<H3>$l_allowed_ip</H3>$l_forbidden_ip_explain<BR>";
|
|
|
239 |
echo "<textarea name='OSSI_wl_ip' rows=3 cols=40>";
|
|
|
240 |
echo_ip_file ($file_wl_ip);
|
|
|
241 |
echo "</textarea></td></tr>";
|
|
|
242 |
echo "<tr><td colspan=10>";
|
|
|
243 |
echo "</table><br/>";
|
|
|
244 |
echo "<input type='submit' value='$l_record'></form></td></tr>";
|
|
|
245 |
?>
|
|
|
246 |
|
|
|
247 |
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
|
|
248 |
<tr><th><?php echo $l_specific_filtering; ?></th></tr>
|
|
|
249 |
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
|
|
|
250 |
</table>
|
|
|
251 |
<TABLE width="100%" border=1 cellspacing=0 cellpadding=1>
|
|
|
252 |
<FORM action='wl_filter.php' method='POST'>
|
|
|
253 |
<input type='hidden' name='choix' value='Specific_filtering'>
|
|
|
254 |
<tr><td>
|
|
|
255 |
|
|
|
256 |
<input type='checkbox' name='chk-safesearch'
|
|
|
257 |
<?php
|
|
|
258 |
//verification du safesearch
|
|
|
259 |
if(file_exists($dnsmasq_conf))
|
|
|
260 |
{
|
|
|
261 |
$f=fopen($dnsmasq_conf, 'r');
|
|
|
262 |
while(!feof($f))
|
|
|
263 |
{
|
|
|
264 |
$line=fgets($f,4096);
|
|
|
265 |
if($line && preg_match('/^address=\/\.google/',$line,$r))
|
|
|
266 |
{
|
|
|
267 |
echo "checked";
|
|
|
268 |
break;
|
|
|
269 |
}
|
|
|
270 |
}
|
|
|
271 |
fclose($f);
|
|
|
272 |
}
|
|
|
273 |
else
|
|
|
274 |
echo "$l_error_open_file $dnsmasq_conf";
|
|
|
275 |
echo "> $l_safe_searching";
|
|
|
276 |
|
|
|
277 |
echo "<br></br>$l_safe_youtube";
|
|
|
278 |
echo " $l_youtube_id<tr><td>";
|
|
|
279 |
|
|
|
280 |
echo "<input type='submit' value='$l_record'></form></td></tr>";
|
|
|
281 |
?>
|
|
|
282 |
|
|
|
283 |
</TABLE><br/>
|
|
|
284 |
</BODY>
|
|
|
285 |
</HTML>
|