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.
 
 
 
 
 

101 righe
4.3 KiB

<?
$configPath = substr(__DIR__,0,strpos(__DIR__,"/public_html"))."/config.php";
include_once($configPath);
if (!empty($_SESSION["utente"]) && $_SESSION["utente"]->permission($radice)) {
if (isset($_GET["draw"])) {
$return = array();
$return["draw"] = (int)$_GET["draw"];
$return["recordsTotal"] = (int)0;
$return["recordsFiltered"] = (int)0;
$bind = array();
$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 = "";
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["recordsTotal"] = (int)$ris->rowCount();
$sql .= "ORDER BY $table.codice DESC ";
if ($_GET["length"] !== "-1") { $sql.= "LIMIT ". (int)$_GET["start"] .", " . (int)$_GET["length"]; }
$ris = $pdo->go($sql,$bind);
if ($ris->rowCount() > 0) {
$return["recordsFiltered"] = $return["recordsTotal"];
$return["data"] = array();
while($record = $ris->fetch(PDO::FETCH_ASSOC)) {
$row = array();
$row[] = (!empty($record["username"])) ? $record["username"] : $record["cognome"] . " " . $record["nome"];
if (empty($_SESSION["ente"])) { $row[] = (empty($record["denominazione"])) ? "" : $record["denominazione"]; }
$row[] = $record["ip"];
$row[] = mysql2datetime($record["timestamp"]);
$return["data"][] = $row;
}
} else {
$return["data"] = array();
}
} else {
$return["data"] = array();
}
echo json_encode($return);
}
}
?>