gestione gare pubbliche
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 

91 righe
3.8 KiB

<?
$configPath = substr(__DIR__,0,strpos(__DIR__,"/public_html"))."/config.php";
include_once($configPath);
if (!empty($_SESSION["utente"]) && $_SESSION["utente"]->permission("controllo_accessi")) {
$table = "b_log_accessi";
if (!empty($_SESSION["access-filter"]["tipo"]) && $_SESSION["access-filter"]["tipo"] == "tentativi") { $table = "b_log_tentativi"; }
$sql = "SELECT $table.* ";
if ($table == "b_log_accessi") {
$sql .= ", b_utenti.cognome, b_utenti.nome ";
}
if (empty($_SESSION["ente"])) { $sql .= ",b_enti.denominazione "; }
$sql.= "FROM $table ";
if ($table == "b_log_accessi") {
$sql .= "JOIN b_utenti ON b_log_accessi.utente_modifica = b_utenti.codice ";
}
if (empty($_SESSION["ente"])) {
$sql .= "LEFT JOIN b_enti ON $table.codice_ente = b_enti.codice ";
}
$where = "";
$bind = array();
if (!empty($_SESSION["access-filter"])) {
if (!empty($_SESSION["access-filter"]["ip"])) {
$sud = suddivisione_pdo($_SESSION["access-filter"]["ip"],"ip");
$bind = array_merge($bind,$sud["bind"]);
$where .= (empty($where)) ? "WHERE " : "AND ";
$where .= $sud["sql"];
}
if (!empty($_SESSION["access-filter"]["user"])) {
$where .= (empty($where)) ? "WHERE (" : "AND (";
if ($table == "b_log_accessi") {
$sud = suddivisione_pdo($_SESSION["access-filter"]["user"],"b_utenti.cognome");
$bind = array_merge($bind,$sud["bind"]);
$where .= $sud["sql"] . "OR ";
$sud = suddivisione_pdo($_SESSION["access-filter"]["user"],"b_utenti.nome");
$bind = array_merge($bind,$sud["bind"]);
$where .= $sud["sql"] . ")";
} else {
$sud = suddivisione_pdo($_SESSION["access-filter"]["user"],"$table.username");
$bind = array_merge($bind,$sud["bind"]);
$where .= $sud["sql"] . ")";
}
}
if (isset($_SESSION["access-filter"]["codice_ente"]) && $_SESSION["access-filter"]["codice_ente"] !== "") {
$bind[":codice_ente"] = $_SESSION["access-filter"]["codice_ente"];
$where .= (empty($where)) ? "WHERE " : "AND ";
$where .= "$table.codice_ente = :codice_ente ";
}
if (!empty($_SESSION["access-filter"]["from"])) {
$bind[":dataop_from"] = datetime2mysql($_SESSION["access-filter"]["from"]);
$where .= (empty($where)) ? "WHERE " : "AND ";
$where .= "$table.timestamp >= :dataop_from ";
}
if (!empty($_SESSION["access-filter"]["to"])) {
$bind[":dataop_to"] = datetime2mysql($_SESSION["access-filter"]["to"]);
$where .= (empty($where)) ? "WHERE " : "AND ";
$where .= "$table.timestamp <= :dataop_to ";
}
}
$sql .= $where;
if (!empty($_SESSION["ente"])) {
$bind[":codice_ente"] = $_SESSION["ente"]->codice;
$sql .= (empty($where)) ? "WHERE " : "AND ";
$sql .= " $table.codice_ente = :codice_ente ";
}
$ris = $pdo->go($sql,$bind);
if ($ris->rowCount() > 0) {
$return = array();
$row = array();
$row[] = "USER";
if (empty($_SESSION["ente"])) { $row[] = strtoupper(__("ente")); }
$row[] = "IP";
$row[] = "TIMESTAMP";
$return[] = $row;
while($record = $ris->fetch(PDO::FETCH_ASSOC)) {
$row = array();
$row[] = (!empty($record["username"])) ? $record["username"] : $record["cognome"] . " " . $record["nome"];
$row[] = $record["ip"];
if (empty($_SESSION["ente"])) { $row[] = (empty($record["denominazione"])) ? "" : $record["denominazione"]; }
$row[] = mysql2datetime($record["timestamp"]);
$return[] = $row;
}
header("Content-Type:application/csv");
header("Content-Disposition:attachment;filename=access-log.csv");
foreach ($return as $row) {
echo arrayToCsv($row)."\n";
}
}
}
?>