Aggiunto sistema partizionamento DB per ottimizzare l'accesso ai dati

This commit is contained in:
cmaffio
2016-04-18 17:08:22 +02:00
parent e6e4b5d15b
commit 2085e68354
18 changed files with 1122 additions and 52 deletions

62
proxy/pool_gest.php Executable file
View File

@@ -0,0 +1,62 @@
<?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) VALUES ('$ip', 1, 1) 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) VALUES ('$ip', 1, 0) 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
}
?>