Subversion Repositories ALCASAR

Rev

Rev 3173 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 3173 Rev 3179
Line 8... Line 8...
8
$wl_iptables_dir="/usr/local/share/iptables-wl/";
8
$wl_iptables_dir="/usr/local/share/iptables-wl/";
9
$bl_unbound_dir="/usr/local/share/unbound-bl/";
9
$bl_unbound_dir="/usr/local/share/unbound-bl/";
10
$wl_unbound_dir="/usr/local/share/unbound-wl/";
10
$wl_unbound_dir="/usr/local/share/unbound-wl/";
11
# Choice of language
11
# Choice of language
12
$Language = 'en';
12
$Language = 'en';
13
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE']))
13
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
14
{
-
 
15
	 $Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
14
	 $Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
16
	 $Language = strtolower(substr(chop($Langue[0]),0,2));
15
	 $Language = strtolower(substr(chop($Langue[0]),0,2));
17
}
16
}
18
if($Language == 'fr')
17
if($Language == 'fr'){
19
{
-
 
20
	$l_title = "Catégories de la liste noire";
18
	$l_title = "Catégories de la liste noire";
21
	$l_error_open_file="Erreur d'ouverture du fichier";
19
	$l_error_open_file="Erreur d'ouverture du fichier";
22
	$l_close="Fermer";
20
	$l_close="Fermer";
23
	$l_description_cat="Cette catégorie n'est pas décrite";
21
	$l_description_cat="Cette catégorie n'est pas décrite";
24
	$l_name_cat ="Cette catégorie n'a pas de nom";
22
	$l_name_cat ="Cette catégorie n'a pas de nom";
Line 51... Line 49...
51
	$l_nb_ip="Number of IP addresses :";
49
	$l_nb_ip="Number of IP addresses :";
52
	$l_example="Example(s) : ";
50
	$l_example="Example(s) : ";
53
	$l_error_cat = "Error category";
51
	$l_error_cat = "Error category";
54
	$l_error_list = "Error listing";
52
	$l_error_list = "Error listing";
55
}
53
}
56
if(isset($_GET['cat']))
54
if(isset($_GET['cat'])){
57
{
-
 
58
	$categorie = $_GET['cat'];
55
	$categorie = $_GET['cat'];
59
}
56
}
60
else
57
else {
61
{
-
 
62
	$categorie = $l_error_cat;
58
	$categorie = $l_error_cat;
63
}
59
}
64
if(isset($_GET['liste']))
-
 
65
{
-
 
66
	$liste = $_GET['liste'];
-
 
67
}
-
 
68
else
-
 
69
{
-
 
70
	$liste = $l_error_list;
-
 
71
}
-
 
72
if($liste == "bl")
-
 
73
{
-
 
74
	$bl_categorie_domain_file = $bl_unbound_dir.$categorie.".conf";
60
$bl_categorie_domain_file = $bl_unbound_dir.$categorie.".conf";
75
	$bl_categorie_url_file = $bl_dir.$categorie."/urls";
61
$bl_categorie_url_file = $bl_dir.$categorie."/urls";
76
	$bl_categorie_ip_file = $bl_iptables_dir.$categorie;
62
$bl_categorie_ip_file = $bl_iptables_dir.$categorie;
77
	//don't calc again on reload (click on the number of domain/urls/ip)
63
//don't calc again on reload (click on the number of domain/urls/ip)
78
	if (isset ($_GET['nb_domains']) && isset($_GET['nb_urls']) && isset($_GET['nb_ip']))
64
if (isset ($_GET['nb_domains']) && isset($_GET['nb_urls']) && isset($_GET['nb_ip'])){
79
	{
-
 
80
		$nb_domains = $_GET['nb_domains'];
65
	$nb_domains = $_GET['nb_domains'];
81
		$nb_urls = $_GET['nb_urls'];
66
	$nb_urls = $_GET['nb_urls'];
82
		$nb_ip = $_GET['nb_ip'];
67
	$nb_ip = $_GET['nb_ip'];
83
	}
68
}
84
	else
69
	else {
85
	{
-
 
86
		if (file_exists($bl_categorie_domain_file))
70
		if (file_exists($bl_categorie_domain_file)){
87
		{
-
 
88
			# two lines per domain
71
			# two lines per domain
89
			$nb_domains = exec("wc -l $bl_categorie_domain_file | cut -d ' ' -f1") / 2;
72
			$nb_domains = exec("wc -l $bl_categorie_domain_file | cut -d ' ' -f1") / 2;
90
		}
73
		}
91
		else
74
		else {
92
		{
-
 
93
			$nb_domains = $l_error_open_file." ".$bl_categorie_domain_file;
75
			$nb_domains = $l_error_open_file." ".$bl_categorie_domain_file;
94
		}
76
		}
95
 
-
 
96
		if (file_exists($bl_categorie_url_file))
77
		if (file_exists($bl_categorie_url_file)){
97
		{
-
 
98
			$nb_urls = exec ("wc -l $bl_categorie_url_file | cut -d ' ' -f1");
78
			$nb_urls = exec ("wc -l $bl_categorie_url_file | cut -d ' ' -f1");
99
		}
79
		}
100
		else
80
		else {
101
		{
-
 
102
			$nb_urls = $l_error_open_file." ".$bl_categorie_url_file;
81
			$nb_urls = $l_error_open_file." ".$bl_categorie_url_file;
103
		}
82
		}
104
 
-
 
105
		if(file_exists($bl_categorie_ip_file))
83
		if(file_exists($bl_categorie_ip_file)){
106
		{
-
 
107
			$nb_ip = exec("wc -l $bl_categorie_ip_file | cut -d ' ' -f1");
84
			$nb_ip = exec("wc -l $bl_categorie_ip_file | cut -d ' ' -f1");
108
		}
85
		}
109
		else
86
		else {
110
		{
-
 
111
			$nb_ip = $l_error_open_file." ".$bl_categorie_ip_file;
87
			$nb_ip = $l_error_open_file." ".$bl_categorie_ip_file;
112
		}
88
		}
113
	}
89
	}
114
}
-
 
115
else
-
 
116
{
-
 
117
	$wl_categorie_domain_file = $wl_unbound_dir.$categorie.".conf";
-
 
118
	$wl_categorie_ip_file = $wl_iptables_dir.$categorie;
-
 
119
	if (file_exists($wl_categorie_domain_file))
-
 
120
	{
-
 
121
		$nb_domains = exec("wc -l $wl_categorie_domain_file | cut -d ' ' -f1");
-
 
122
	}
-
 
123
	else
-
 
124
	{
-
 
125
		$nb_domains = $l_error_open_file." ".$wl_categorie_domain_file;
-
 
126
	}
-
 
127
 
-
 
128
	if (file_exists($wl_categorie_ip_file))
-
 
129
	{
-
 
130
		$nb_ip = exec("wc -l $wl_categorie_ip_file | cut -d ' ' -f1");
-
 
131
	}
-
 
132
	else
-
 
133
	{
-
 
134
		$nb_ip = 0;
-
 
135
		//$nb_ip = $l_error_open_file." ".$wl_categorie_ip_file;
-
 
136
	}
-
 
137
 
-
 
138
	$nb_urls = 0; //no urls in WL
-
 
139
}
-
 
140
$global_usage = file($bl_dir."global_usage");
90
$global_usage = file($bl_dir."global_usage");
141
$langue = strtoupper($Language);
91
$langue = strtoupper($Language);
142
if(isset($categorie))
92
if(isset($categorie)){
143
{
-
 
144
	$fin1 = 0; $fin2 = 0;
93
	$fin1 = 0; $fin2 = 0;
145
	foreach ($global_usage as $line)
94
	foreach ($global_usage as $line){
146
	{
-
 
147
		if(preg_match("#^NAME:.$categorie$#", $line) == 1)
95
		if(preg_match("#^NAME:.$categorie$#", $line) == 1){
148
		{
-
 
149
			$fin1 = 1;
96
			$fin1 = 1;
150
		}
97
		}
151
		if($fin1 && preg_match("#^DESC.$langue:.#", $line) == 1)
98
		if($fin1 && preg_match("#^DESC.$langue:.#", $line) == 1){
152
		{
-
 
153
			$l_description_cat = preg_replace("#^DESC.$langue:.#", "", $line);
99
			$l_description_cat = preg_replace("#^DESC.$langue:.#", "", $line);
154
		}
100
		}
155
		if($fin1 && preg_match("#^NAME.$langue:.#", $line) == 1)
101
		if($fin1 && preg_match("#^NAME.$langue:.#", $line) == 1){
156
		{
-
 
157
			$l_name_cat = preg_replace("#^NAME.$langue:.#", "", $line);
102
			$l_name_cat = preg_replace("#^NAME.$langue:.#", "", $line);
158
			$fin2 = 1;
103
			$fin2 = 1;
159
		}
104
		}
160
		if($fin2) break;
105
		if($fin2) break;
161
	}
106
	}
Line 170... Line 115...
170
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
115
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
171
</TABLE>
116
</TABLE>
172
<TABLE width="100%" border=1 cellspacing=0 cellpadding=1>
117
<TABLE width="100%" border=1 cellspacing=0 cellpadding=1>
173
	<tr><td valign="middle" align="left">
118
	<tr><td valign="middle" align="left">
174
		<?php
119
		<?php
175
		if(isset($_GET["filtre"]))
-
 
176
		{
-
 
177
			$filtre = $_GET["filtre"];
-
 
178
		}
-
 
179
		else
-
 
180
		{
-
 
181
			$filtre = $liste == "bl" ? $bl_categorie_domain_file : $wl_categorie_domain_file;
-
 
182
		}
-
 
183
		$filtre_domain = $liste == "bl" ? $bl_categorie_domain_file : $wl_categorie_domain_file;
-
 
184
		$filtre_ip = $liste == "bl" ? $bl_categorie_ip_file : $wl_categorie_ip_file;
-
 
185
		$filtre_url = $liste == "bl" ? $bl_categorie_url_file : "";
-
 
186
		$compat_categorie=strtr($categorie,"-","_");
120
		$compat_categorie=strtr($categorie,"-","_");
187
		echo "<br><center><b>$l_name_cat</b></center>";
121
		echo "<br><center><b>$l_name_cat</b></center>";
188
		echo "<center><b>$l_description_cat</b></center><br>";
122
		echo "<center><b>$l_description_cat</b></center><br>";
189
		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>";
123
		echo "$l_nb_domains <b><a href='?cat=$categorie&filtre=$bl_categorie_domain_file&titre=domain&nb_domains=$nb_domains&nb_urls=$nb_urls&nb_ip=$nb_ip'>$nb_domains</a></b><br>";
190
		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>";
124
		echo "$l_nb_urls <b><a href='?cat=$categorie&filtre=$bl_categorie_url_file&titre=url&nb_domains=$nb_domains&nb_urls=$nb_urls&nb_ip=$nb_ip'>$nb_urls</a></b><br>";
191
		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>";
125
		echo "$l_nb_ip <b><a href='?cat=$categorie&filtre=$bl_categorie_ip_file&titre=ip&nb_domains=$nb_domains&nb_urls=$nb_urls&nb_ip=$nb_ip'>$nb_ip</a></b><br>";
192
		?>
126
		?>
193
	</td></tr>
127
	</td></tr>
194
</TABLE>
128
</TABLE>
195
<br>
129
<br>
196
<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
130
<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
197
	<tr><th>
131
	<tr><th>
198
		<?php
132
		<?php
199
		if(isset($_GET["titre"]))
133
		if(isset($_GET["titre"])){
200
		{
-
 
201
			$titre = $_GET["titre"];
134
			$titre = $_GET["titre"];
202
		}
135
		}
203
		else
136
		else {
204
		{
-
 
205
			$titre = "domain";
137
			$titre = "domain";
206
		}
138
		}
207
		echo $l_example.$titre;
139
		echo $l_example.$titre;
208
		?>
140
		?>
209
	</th></tr>
141
	</th></tr>
210
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
142
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
211
</TABLE>
143
</TABLE>
212
<TABLE width="100%" border=1 cellspacing=0 cellpadding=1>
144
<TABLE width="100%" border=1 cellspacing=0 cellpadding=1>
213
	<tr><td valign="middle" align="left">
145
	<tr><td valign="middle" align="left">
214
<?php
146
<?php
215
		if($titre == "domain")
147
		if($titre == "domain"){
216
		{
-
 
217
 
-
 
218
			$filtre = $liste == "bl" ? $bl_categorie_domain_file : $wl_categorie_domain_file;
-
 
219
			exec("head -n 15 ".escapeshellarg($filtre)." | grep 'transparent' | awk '{ print $2 }'", $resultat);
148
			exec("head -n 15 ".escapeshellarg($bl_categorie_domain_file)." | grep 'transparent' | awk '{ print $2 }'", $resultat);
220
		}
149
		}
221
		elseif($titre == "ip")
150
		elseif($titre == "ip"){
222
		{
-
 
223
			$filtre = $liste == "bl" ? $bl_categorie_ip_file : $wl_categorie_ip_file;
-
 
224
			exec("head -n 15 ".escapeshellarg($filtre)." | cut -d ' ' -f3", $resultat);
151
			exec("head -n 15 ".escapeshellarg($bl_categorie_ip_file)." | cut -d ' ' -f3", $resultat);
225
		}
152
		}
226
		else
153
		else {
227
		{
-
 
228
			exec("head -n 15 ".escapeshellarg($filtre), $resultat);
154
			exec("head -n 15 ".escapeshellarg($bl_categorie_ip_file), $resultat);
229
		}
155
		}
230
		for($i=0; $i<count($resultat); $i++)
156
		for($i=0; $i<count($resultat); $i++){
231
		{
-
 
232
			echo $resultat[$i]."<br/>";
157
			echo $resultat[$i]."<br/>";
233
		}
158
		}
234
		?>
159
		?>
235
	</td></tr>
160
	</td></tr>
236
</TABLE>
161
</TABLE>