Subversion Repositories ALCASAR

Rev

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