unificazione gestioni proxy

This commit is contained in:
cmaffio
2016-05-11 12:12:30 +02:00
parent 58ef34316d
commit 3f68b14259
10 changed files with 55 additions and 163 deletions

View File

@@ -54,6 +54,33 @@ if (isset($_GET['id'])) {
mysql_query( $query, $DB_ID );
break;
case "pool_ins":
$query = "INSERT INTO proxy_pool (ip, pool, attivo, ins) VALUES ('$id', 1, 1, NOW()) ON DUPLICATE KEY UPDATE attivo = 1";
mysql_query( $query, $DB_ID );
genera($DB_ID);
break;
case "pool_rem":
$query = "INSERT INTO proxy_pool (ip, pool, attivo, ins) VALUES ('$id', 1, 0, NOW()) ON DUPLICATE KEY UPDATE attivo = 0";
mysql_query( $query, $DB_ID );
genera($DB_ID);
break;
case "user_up":
$query = "UPDATE proxy_utenti SET attivo = 1 WHERE id = $id";
mysql_query( $query, $DB_ID );
$testo = "Utente Abilitato";
break;
case "user_down":
$query = "UPDATE proxy_utenti SET attivo = 0 WHERE id = $id";
mysql_query( $query, $DB_ID );
$testo = "Utente Disabilitato";
break;
case "user_rm":
$query = "DELETE FROM proxy_utenti WHERE id = $id";
mysql_query( $query, $DB_ID );
$testo = "Utente Eliminato";
break;
default:
$testo = "Regola non implementata";
break;
@@ -64,3 +91,19 @@ if (isset($_GET['id'])) {
<script type="text/javascript">
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");
}
?>