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.
118 righe
5.5 KiB
118 righe
5.5 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(); |
|
$sql = "SELECT b_log.codice, b_log.nometab, b_log.operazione, b_log.id_record, b_log.ip, b_log.dataop, b_utenti.cognome, b_utenti.nome "; |
|
if (empty($_SESSION["ente"])) { $sql .= ",b_enti.denominazione "; } |
|
$sql.= "FROM b_log LEFT JOIN b_utenti ON b_log.codoperatore = b_utenti.codice "; |
|
if (empty($_SESSION["ente"])) { |
|
$sql .= "LEFT JOIN b_enti ON b_log.codice_ente = b_enti.codice "; |
|
} |
|
$where = ""; |
|
if (!empty($_SESSION["log-filter"])) { |
|
if (isset($_SESSION["log-filter"]["nometab"]) && $_SESSION["log-filter"]["nometab"] !== "") { |
|
$bind[":nometab"] = $_SESSION["log-filter"]["nometab"]; |
|
$where .= (empty($where)) ? "WHERE " : "AND "; |
|
$where .= "b_log.nometab = :nometab "; |
|
} |
|
if (!empty($_SESSION["log-filter"]["operazione"])) { |
|
$bind[":operazione"] = $_SESSION["log-filter"]["operazione"]; |
|
$where .= (empty($where)) ? "WHERE " : "AND "; |
|
$where .= "b_log.operazione = :operazione "; |
|
} |
|
if (!empty($_SESSION["log-filter"]["id_record"])) { |
|
$bind[":id_record"] = $_SESSION["log-filter"]["id_record"]; |
|
$where .= (empty($where)) ? "WHERE " : "AND "; |
|
$where .= "b_log.id_record = :id_record "; |
|
} |
|
if (!empty($_SESSION["log-filter"]["ip"])) { |
|
$sud = suddivisione_pdo($_SESSION["log-filter"]["ip"],"ip"); |
|
$bind = array_merge($bind,$sud["bind"]); |
|
$where .= (empty($where)) ? "WHERE " : "AND "; |
|
$where .= $sud["sql"]; |
|
} |
|
if (!empty($_SESSION["log-filter"]["user"])) { |
|
$where .= (empty($where)) ? "WHERE (" : "AND ("; |
|
$sud = suddivisione_pdo($_SESSION["log-filter"]["user"],"b_utenti.cognome"); |
|
$bind = array_merge($bind,$sud["bind"]); |
|
$where .= $sud["sql"] . "OR "; |
|
$sud = suddivisione_pdo($_SESSION["log-filter"]["user"],"b_utenti.nome"); |
|
$bind = array_merge($bind,$sud["bind"]); |
|
$where .= $sud["sql"] . ")"; |
|
} |
|
if (isset($_SESSION["log-filter"]["codice_ente"]) && $_SESSION["log-filter"]["codice_ente"] !== "") { |
|
$bind[":codice_ente"] = $_SESSION["log-filter"]["codice_ente"]; |
|
$where .= (empty($where)) ? "WHERE " : "AND "; |
|
$where .= "b_log.codice_ente = :codice_ente "; |
|
} |
|
if (!empty($_SESSION["log-filter"]["from"])) { |
|
$bind[":dataop_from"] = datetime2mysql($_SESSION["log-filter"]["from"]); |
|
$where .= (empty($where)) ? "WHERE " : "AND "; |
|
$where .= "b_log.dataop >= :dataop_from "; |
|
} |
|
if (!empty($_SESSION["log-filter"]["to"])) { |
|
$bind[":dataop_to"] = datetime2mysql($_SESSION["log-filter"]["to"]); |
|
$where .= (empty($where)) ? "WHERE " : "AND "; |
|
$where .= "b_log.dataop <= :dataop_to "; |
|
} |
|
} |
|
$sql .= $where; |
|
if (!empty($_SESSION["ente"])) { |
|
$bind[":codice_ente"] = $_SESSION["ente"]->codice; |
|
$sql .= (empty($where)) ? "WHERE " : "AND "; |
|
$sql .= " b_log.codice_ente = :codice_ente "; |
|
} |
|
|
|
$ris = $pdo->go($sql,$bind); |
|
if ($ris->rowCount() > 0) { |
|
$return["recordsTotal"] = (int)$ris->rowCount(); |
|
$sql .= "ORDER BY b_log.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[] = $record["codice"]; |
|
$row[] = $record["nometab"]; |
|
$row[] = $record["operazione"]; |
|
$row[] = $record["id_record"]; |
|
$row[] = $record["ip"]; |
|
$row[] = $record["cognome"] . " " . $record["nome"]; |
|
$row[] = (empty($record["denominazione"])) ? "" : $record["denominazione"]; |
|
$row[] = mysql2datetime($record["dataop"]); |
|
$row[] = "<button class='btn btn-sm btn-info' onClick='showModalWithURL(\"show.php?codice=".$record["codice"]."\");'><span class='fa fa-search'></span></button>"; |
|
ob_start(); |
|
?> |
|
# <b><?= $record["codice"] ?></b><br> |
|
Tab: <b><?= $record["nometab"] ?></b><br> |
|
Ope: <b><?= $record["operazione"] ?></b><br> |
|
Row: <b><?= $record["id_record"] ?></b><br> |
|
IP: <b><?= $record["ip"] ?></b><br> |
|
User: <b><?= "{$record["cognome"]} {$record["nome"]}" ?></b><br> |
|
<? if(!empty($record["denominazione"])) { ?>IP: <b><?= "{$record["denominazione"]}" ?></b><br><? } ?> |
|
Time: <b><?= mysql2datetime($record["dataop"]) ?></b><br> |
|
<button class="btn btn-primary btn-block" onClick='showModalWithURL("show.php?codice=<?= $record["codice"] ?>");'> Visualizza</button> |
|
<? |
|
$row[] = ob_get_clean(); |
|
$return["data"][] = $row; |
|
} |
|
} else { |
|
$return["data"] = array(); |
|
} |
|
} else { |
|
$return["error"] = "No record"; |
|
} |
|
|
|
echo json_encode($return); |
|
} |
|
} |
|
?>
|
|
|