Subversion Repositories ALCASAR

Rev

Rev 2099 | Rev 2400 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 2099 Rev 2299
Line 53... Line 53...
53
		echo "$filename doesn't exist";
53
		echo "$filename doesn't exist";
54
		}
54
		}
55
	}
55
	}
56
function echo_ip_file ($filename)
56
function echo_ip_file ($filename)
57
{
57
{
-
 
58
	$filename = escapeshellarg($filename);
58
	exec("cat $filename | cut -d ' ' -f3", $resultat);
59
	exec("cat $filename | cut -d ' ' -f3", $resultat);
59
	for($i=0; $i<exec("wc -l $filename"); $i++)
60
	for($i=0; $i<exec("wc -l $filename"); $i++)
60
	{
61
	{
61
		echo $resultat[$i]."\n";
62
		echo $resultat[$i]."\n";
62
	}
63
	}
Line 220... Line 221...
220
		if($fichier != "choix")
221
		if($fichier != "choix")
221
		{
222
		{
222
			$action=$_POST[$fichier];
223
			$action=$_POST[$fichier];
223
			if($action == $l_remove) //delete
224
			if($action == $l_remove) //delete
224
			{
225
			{
225
				exec("/bin/sed -i \"/^$fichier$/d\" $wl_categories_enabled"); 
226
				exec("/bin/sed -i ".escapeshellarg("/^$fichier$/d")." $wl_categories_enabled"); 
226
				exec("rm -rf $dir_blacklist$fichier");
227
				exec("rm -rf .".escapeshellarg("$dir_blacklist$fichier"));
227
				exec ("sudo /usr/local/bin/alcasar-bl.sh --reload");
228
				exec("sudo /usr/local/bin/alcasar-bl.sh --reload");
228
			}
229
			}
229
			if($action == $l_disable) //disable
230
			if($action == $l_disable) //disable
230
			{
231
			{
231
				exec("/bin/sed -i \"/^$fichier$/d\" $wl_categories_enabled"); 
232
				exec("/bin/sed -i ".escapeshellarg("/^$fichier$/d")." $wl_categories_enabled"); 
232
				exec("sudo /usr/local/bin/alcasar-bl.sh --reload");
233
				exec("sudo /usr/local/bin/alcasar-bl.sh --reload");
233
			}
234
			}
234
			if($action == $l_enable) //enable
235
			if($action == $l_enable) //enable
235
			{
236
			{
236
				file_put_contents ($wl_categories_enabled, $fichier."/n", FILE_APPEND);
237
				file_put_contents($wl_categories_enabled, $fichier."/n", FILE_APPEND);
237
				exec ("sudo /usr/local/bin/alcasar-bl.sh --reload");
238
				exec("sudo /usr/local/bin/alcasar-bl.sh --reload");
238
			}
239
			}
239
		}
240
		}
240
	}
241
	}
241
	break;
242
	break;
242
case 'MAJ_ossi_file_upload' :
243
case 'MAJ_ossi_file_upload' :
243
	$file_name = str_replace (".", "_",basename($_FILES['fichier_ip']['name']));
244
	$file_name = str_replace (".", "_",basename($_FILES['fichier_ip']['name']));
244
	if(!empty($file_name))
245
	if(!empty($file_name))
245
	{	
246
	{	
246
		$dest_dir = $dir_blacklist."ossi-wl-".$file_name;
247
		$dest_dir = $dir_blacklist."ossi-wl-".$file_name;
247
		exec ("mkdir $dest_dir");
248
		exec("mkdir ".escapeshellarg($dest_dir));
248
		$file=$_FILES['fichier_ip']['tmp_name'];
249
		$file=$_FILES['fichier_ip']['tmp_name'];
249
                exec("/usr/bin/dos2unix $file $file");
250
                exec("/usr/bin/dos2unix $file $file");
250
		if(move_uploaded_file($_FILES['fichier_ip']['tmp_name'], $dest_dir."/domains"))
251
		if(move_uploaded_file($_FILES['fichier_ip']['tmp_name'], $dest_dir."/domains"))
251
		{
252
		{
252
			touch ($dest_dir."/urls"); // create the URL file even if it isn't used
253
			touch ($dest_dir."/urls"); // create the URL file even if it isn't used
Line 254... Line 255...
254
			file_put_contents ($wl_categories_enabled, "ossi-wl-".$file_name."\n", FILE_APPEND); //Enabled by default
255
			file_put_contents ($wl_categories_enabled, "ossi-wl-".$file_name."\n", FILE_APPEND); //Enabled by default
255
			exec ("sudo /usr/local/bin/alcasar-bl.sh --reload");
256
			exec ("sudo /usr/local/bin/alcasar-bl.sh --reload");
256
		}
257
		}
257
		else
258
		else
258
		{
259
		{
259
			exec("rm -rf $dest_dir");
260
			exec("rm -rf ".escapeshellarg($dest_dir));
260
			echo $l_error_upload;
261
			echo $l_error_upload;
261
		}
262
		}
262
	}
263
	}
263
	break;
264
	break;
264
}
265
}
Line 272... Line 273...
272
<FORM action='wl_filter.php' method=POST>
273
<FORM action='wl_filter.php' method=POST>
273
<input type='hidden' name='choix' value='MAJ_cat_wl'>
274
<input type='hidden' name='choix' value='MAJ_cat_wl'>
274
<?php
275
<?php
275
echo "<center>";
276
echo "<center>";
276
// total number of IP, DNS & URLs
277
// total number of IP, DNS & URLs
277
$nbDomainNames = exec ("wc -l /usr/local/share/dnsmasq-wl/* | tail -n 1 | awk '{print $1}'");
278
$nbDomainNames = exec("wc -l /usr/local/share/dnsmasq-wl/* | tail -n 1 | awk '{print $1}'");
278
$nbUrl = "0";
279
$nbUrl = "0";
279
$nbIp = exec ("wc -l /usr/local/share/iptables-wl/* | tail -n 1 | awk '{print $1}'");
280
$nbIp = exec("wc -l /usr/local/share/iptables-wl/* | tail -n 1 | awk '{print $1}'");
280
echo "<b>$l_nbDomainNames</b> $nbDomainNames, <b>$l_nbUrl</b> $nbUrl, <b>$l_nbIp</b> $nbIp<br/>";
281
echo "<b>$l_nbDomainNames</b> $nbDomainNames, <b>$l_nbUrl</b> $nbUrl, <b>$l_nbIp</b> $nbIp<br/>";
281
echo "$l_wl_categories</center></td></tr>";	
282
echo "$l_wl_categories</center></td></tr>";	
282
//read & display all WL categories (checked or not)
283
//read & display all WL categories (checked or not)
283
$cols=1; 
284
$cols=1; 
284
if (file_exists($wl_categories))
285
if (file_exists($wl_categories))