Subversion Repositories ALCASAR

Rev

Rev 1852 | Rev 1874 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log

Rev Author Line No. Line
318 richard 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
<?
6
$bl_dir="/etc/dansguardian/lists/blacklists/";
1332 richard 7
$bl_iptables_dir="/usr/local/share/iptables-bl/";
1377 richard 8
$wl_iptables_dir="/usr/local/share/iptables-wl/";
1332 richard 9
$bl_dnsmasq_dir="/usr/local/share/dnsmasq-bl/";
10
$wl_dnsmasq_dir="/usr/local/share/dnsmasq-wl/";
1867 raphael.pi 11
if(isset($_GET['ossi'])) $ossi = $_GET['ossi'];
318 richard 12
# Choice of language
13
$Language = 'en';
1332 richard 14
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE']))
15
{
16
	 $Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
17
	 $Language = strtolower(substr(chop($Langue[0]),0,2));
318 richard 18
}
1332 richard 19
if($Language == 'fr')
20
{
1852 raphael.pi 21
	$l_title = "Catégories de la liste noire";
22
	$l_error_open_file="Erreur d'ouverture du fichier";
23
	$l_close="Fermer";
24
	$l_description_cat="Cette catégorie n'est pas décrite";
25
	$l_name_cat ="Cette catégorie n'a pas de nom";
26
	$l_nb_domains="Nombre de noms de domaine filtrés :";
27
	$l_nb_urls="Nombre d'URL filtrés :";
28
	$l_nb_ip="Nombre d'IP filtrées :";
29
	$l_example="Exemple(s) : ";
30
	$l_error_cat = "Erreur de categorie";
31
	$l_error_list = "Erreur de listing";
318 richard 32
}
33
else
1332 richard 34
{
35
	$l_title = "Blacklist categories";
36
	$l_error_open_file="Error opening the file";
37
	$l_close="Close";
38
	$l_description_cat="This category isn't describe";
1852 raphael.pi 39
	$l_name_cat ="This category has not name";
1332 richard 40
	$l_nb_domains="Number of filtered domain names :";
41
	$l_nb_urls="Number of filtered URL :";
42
	$l_nb_ip="Number of filtered IP :";
43
	$l_example="Example(s) : ";
1852 raphael.pi 44
	$l_error_cat = "Error category";
45
	$l_error_list = "Error listing";
46
 
1332 richard 47
}
48
if(isset($_GET['cat']))
49
{
50
	$categorie = $_GET['cat'];
51
} 
1852 raphael.pi 52
else
53
{
54
	$categorie = $l_error_cat;
55
}
1332 richard 56
if(isset($_GET['liste']))
57
{
58
	$liste = $_GET['liste'];
59
}
1852 raphael.pi 60
else
61
{
62
	$liste = $l_error_list;
63
}
1332 richard 64
if($liste == "bl")
65
{
1867 raphael.pi 66
	if(isset($ossi))
67
	{
68
	$bl_categorie_domain_file = $bl_dnsmasq_dir."-enabled/".$categorie;
69
	$bl_categorie_ip_file = $bl_iptables_dir.$categorie;
70
	if(isset($_GET['nb_domains']) && isset($_GET['nb_urls']) && isset($_GET['nb_ip']))
71
	{
72
		$nb_domains = $_GET['nb_domains'];
73
		$nb_ip = $_GET['nb_ip'];
74
	}
75
	else
76
	{
77
		if (file_exists($bl_categorie_domain_file))
78
			$nb_domains = exec("wc -l $bl_categorie_domain_file | cut -d ' ' -f1");
79
		else
80
			$nb_domains = $l_error_open_file." ".$bl_categorie_domain_file;
81
		if(file_exists($bl_categorie_ip_file))
82
			$nb_ip = exec("wc -l $bl_categorie_ip_file | cut -d ' ' -f1");
83
		else
84
			$nb_ip = $l_error_open_file." ".$bl_categorie_ip_file;
85
	}
86
	}
87
	else
88
	{
89
 
90
 
1332 richard 91
	$bl_categorie_domain_file = $bl_dnsmasq_dir.$categorie.".conf";
92
	$bl_categorie_url_file = $bl_dir.$categorie."/urls";
93
	$bl_categorie_ip_file = $bl_iptables_dir.$categorie;
94
	if(isset($_GET['nb_domains']) && isset($_GET['nb_urls']) && isset($_GET['nb_ip']))
95
	{
96
		$nb_domains = $_GET['nb_domains'];
97
		$nb_urls = $_GET['nb_urls'];
98
		$nb_ip = $_GET['nb_ip'];
99
	}
100
	else
101
	{
102
		if (file_exists($bl_categorie_domain_file))
103
			$nb_domains = exec("wc -l $bl_categorie_domain_file | cut -d ' ' -f1");
104
		else
105
			$nb_domains = $l_error_open_file." ".$bl_categorie_domain_file;
106
		if (file_exists($bl_categorie_url_file))
107
			$nb_urls = exec ("wc -l $bl_categorie_url_file | cut -d ' ' -f1");
108
		else
109
			$nb_urls = $l_error_open_file." ".$bl_categorie_url_file;
110
		if(file_exists($bl_categorie_ip_file))
111
			$nb_ip = exec("wc -l $bl_categorie_ip_file | cut -d ' ' -f1");
112
		else
113
			$nb_ip = $l_error_open_file." ".$bl_categorie_ip_file;
114
	}
1867 raphael.pi 115
	}
1332 richard 116
}
318 richard 117
else
1332 richard 118
{
1867 raphael.pi 119
 
120
	if(isset($ossi))
121
	{
122
	$wl_categorie_domain_file = "/usr/local/share/dnsmasq-wl-enabled/".$categorie;
123
	$wl_categorie_ip_file = "/usr/local/share/iptables-wl-enabled/".$categorie;
124
	if(isset($_GET['nb_domains']) && isset($_GET['nb_urls']) && isset($_GET['nb_ip']))
125
	{
126
		$nb_domains = $_GET['nb_domains'];
127
		$nb_ip = $_GET['nb_ip'];
128
	}
129
	else
130
	{
131
		if (file_exists($wl_categorie_domain_file))
132
			$nb_domains = exec("wc -l $wl_categorie_domain_file | cut -d ' ' -f1");
133
		else
134
			$nb_domains = $l_error_open_file." ".$wl_categorie_domain_file;
135
		if(file_exists($wl_categorie_ip_file))
136
			$nb_ip = exec("wc -l $wl_categorie_ip_file | cut -d ' ' -f1");
137
		else
138
			$nb_ip = $l_error_open_file." ".$wl_categorie_ip_file;
139
	}
140
	}
141
	else
142
	{	
1332 richard 143
	$wl_categorie_domain_file = $wl_dnsmasq_dir.$categorie.".conf";
1377 richard 144
	$wl_categorie_ip_file = $wl_iptables_dir.$categorie;
1390 richard 145
	if(isset($_GET['nb_domains']))
1377 richard 146
	{
147
		$nb_domains = $_GET['nb_domains'];
148
		$nb_urls = 0;
1390 richard 149
		$nb_ip = 0;
1377 richard 150
	}
1332 richard 151
	else
1377 richard 152
	{
153
		if (file_exists($wl_categorie_domain_file))
154
			$nb_domains = exec("wc -l $wl_categorie_domain_file | cut -d ' ' -f1");
155
		else
156
			$nb_domains = $l_error_open_file." ".$wl_categorie_domain_file;
157
		$nb_urls = 0;
1390 richard 158
		$nb_ip = 0;
1377 richard 159
	}
1867 raphael.pi 160
	}
1332 richard 161
}
1325 richard 162
$global_usage = file($bl_dir."global_usage");
163
$langue = strtoupper($Language);
1867 raphael.pi 164
if(isset($categorie) && !isset($ossi))
1325 richard 165
{
1852 raphael.pi 166
	$fin1 = 0; $fin2 = 0;
167
	foreach($global_usage as $line)
1325 richard 168
	{
1852 raphael.pi 169
		if(preg_match("#^NAME:.$categorie$#", $line) == 1)
170
			$fin1 = 1;
171
		if($fin1 && preg_match("#^DESC.$langue:.#", $line) == 1)
172
			$l_description_cat = preg_replace("#^DESC.$langue:.#", "", $line);
173
		if($fin1 && preg_match("#^NAME.$langue:.#", $line) == 1)
1332 richard 174
		{
1852 raphael.pi 175
			$l_name_cat = preg_replace("#^NAME.$langue:.#", "", $line);
176
			$fin2 = 1;
1332 richard 177
		}
1852 raphael.pi 178
		if($fin2) break;
179
 
1325 richard 180
	}
181
}
318 richard 182
echo "<TITLE>$l_title</TITLE>";
183
?>
184
<link rel="stylesheet" href="/css/style.css" type="text/css">
185
</HEAD>
186
<body>
187
<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
1852 raphael.pi 188
	<tr><th><?php if(isset($categorie)){echo $categorie ;}else{echo $l_error_cat;}?></th></tr>
318 richard 189
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
190
</TABLE>
191
<TABLE width="100%" border=1 cellspacing=0 cellpadding=1>
1332 richard 192
	<tr><td valign="middle" align="left">
193
		<?php
194
		if(isset($_GET["filtre"]))
195
		{
196
			$filtre = $_GET["filtre"];
197
		}
198
		else
199
		{
200
			$filtre = $liste == "bl" ? $bl_categorie_domain_file : $wl_categorie_domain_file;
201
		}
202
		$filtre_domain = $liste == "bl" ? $bl_categorie_domain_file : $wl_categorie_domain_file;
1852 raphael.pi 203
		$filtre_url = $liste == "bl" ? $bl_categorie_url_file : "";
1332 richard 204
		$filtre_ip = $liste == "bl" ? $bl_categorie_ip_file : $wl_categorie_ip_file;
205
		$compat_categorie=strtr($categorie,"-","_");
1867 raphael.pi 206
		if(!isset($ossi))
207
		{
1852 raphael.pi 208
		echo "<br><center><b>$l_name_cat</b></center>";
209
		echo "<center><b>$l_description_cat</b></center><br>";
1332 richard 210
		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>";
211
		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>";
212
		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>";
1867 raphael.pi 213
		}
214
		else
215
		{
216
 
217
		echo "$l_nb_domains <b><a href='?liste=$liste&cat=$categorie&filtre=$filtre_domain&titre=domain&nb_domains=$nb_domains&nb_ip=$nb_ip&ossi=yes'>$nb_domains</a></b><br>";
218
		echo "$l_nb_ip <b><a href='?liste=$liste&cat=$categorie&filtre=$filtre_ip&titre=ip&nb_domains=$nb_domains&nb_ip=$nb_ip&ossi=yes'>$nb_ip</a></b><br>";
219
		}
1332 richard 220
		?>
221
	</td></tr>
318 richard 222
</TABLE>
223
<br>
1332 richard 224
<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
225
	<tr><th>
226
		<?php
227
		if(isset($_GET["titre"]))
228
		{
229
			$titre = $_GET["titre"];
230
		}
231
		else
232
		{
233
			$titre = "domain";
234
		}
235
		echo $l_example.$titre;
236
		?>
237
	</th></tr>
238
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
239
</TABLE>
240
<TABLE width="100%" border=1 cellspacing=0 cellpadding=1>
241
	<tr><td valign="middle" align="left">
1867 raphael.pi 242
<?php
1332 richard 243
		if($titre == "domain")
244
		{
1867 raphael.pi 245
 
246
			$filtre = $liste == "bl" ? $bl_categorie_domain_file : $wl_categorie_domain_file;
1332 richard 247
			exec("head -n 15 $filtre | cut -d '/' -f2", $resultat);
248
		}
249
		elseif($titre == "ip")
250
		{
1867 raphael.pi 251
			$filtre = $liste == "bl" ? $bl_categorie_ip_file : $wl_categorie_ip_file;
1332 richard 252
			exec("head -n 15 $filtre | cut -d ' ' -f3", $resultat);
253
		}
254
		else
255
		{
256
			exec("head -n 15 $filtre", $resultat);
257
		}
1845 raphael.pi 258
		for($i=0; $i<count($resultat); $i++)
1332 richard 259
			echo $resultat[$i]."<br/>";
260
		?>
261
	</td></tr>
262
</TABLE>
318 richard 263
<center><a href="javascript:window.close();"><b><?php echo "$l_close"; ?></b></a></center>
264
</BODY>
265
</HTML>