63 lines
1.5 KiB
PHP
Executable File
63 lines
1.5 KiB
PHP
Executable File
<?php
|
|
include_once ("../core/config.php");
|
|
$UTENTE = login();
|
|
$DIRITTI = diritti(1);
|
|
?>
|
|
<html>
|
|
<head>
|
|
<script type="text/javascript">
|
|
<!--
|
|
function confirmation(testo) {
|
|
alert(testo)
|
|
document.location.href='main.php'
|
|
}
|
|
//-->
|
|
</script>
|
|
|
|
<?php
|
|
if (isset($_GET['ip'])) {
|
|
$ip = $_GET['ip'];
|
|
if (isset($_GET['azione'])) {
|
|
$azione = $_GET['azione'];
|
|
switch ($azione) {
|
|
case "limita":
|
|
$query = "INSERT INTO proxy_pool (ip, pool, attivo, ins) VALUES ('$ip', 1, 1, NOW()) ON DUPLICATE KEY UPDATE attivo = 1";
|
|
mysql_query( $query, $DB_ID );
|
|
$testo = "Utente $ip inserito in pool di limitazione banda";
|
|
genera($DB_ID);
|
|
break;
|
|
case "libera":
|
|
$query = "INSERT INTO proxy_pool (ip, pool, attivo, ins) VALUES ('$ip', 1, 0, NOW()) ON DUPLICATE KEY UPDATE attivo = 0";
|
|
mysql_query( $query, $DB_ID );
|
|
$testo = "Utente $ip rimosso dal pool di limitazione banda";
|
|
genera($DB_ID);
|
|
break;
|
|
default:
|
|
$testo = "Regola non implementata";
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
?>
|
|
<script type="text/javascript">
|
|
// confirmation ('<?php print "$testo" ?>');
|
|
document.location.href='<?php print $_SERVER['HTTP_REFERER']?>'
|
|
</script>
|
|
|
|
<?php
|
|
function genera ($DB_ID) {
|
|
$file = 'squid_acl/listip';
|
|
$fp = fopen($file, 'w');
|
|
|
|
$query = "SELECT ip FROM proxy_pool WHERE attivo = 1 AND pool = 1";
|
|
$res = mysql_query( $query, $DB_ID );
|
|
while ($dato = mysql_fetch_array ( $res )) {
|
|
fwrite($fp, $dato['ip']."\n");
|
|
}
|
|
fclose($fp);
|
|
exec ("sudo /opt/squid/sbin/squid -k reconfigure");
|
|
// sudo /opt/squid/sbin/squid -k reconfigure
|
|
|
|
}
|
|
?>
|