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.
142 righe
5.1 KiB
142 righe
5.1 KiB
<? |
|
$configPath = substr(__DIR__,0,strpos(__DIR__,"/public_html"))."/config.php"; |
|
include_once($configPath); |
|
|
|
if (! empty($_SESSION["utente"]) && $_SESSION["utente"]->permission($radice)) { |
|
|
|
$return = []; |
|
$return["draw"] = (int) $_POST["draw"]; |
|
$return["recordsTotal"] = (int) 0; |
|
$return["recordsFiltered"] = (int) 0; |
|
|
|
if (isset($_POST["draw"])) { |
|
|
|
$select = "SELECT * "; |
|
$count = "SELECT COUNT(codice)"; |
|
$from = "FROM b_fileManager"; |
|
$where = ["soft_delete = :soft_delete"]; |
|
$bind[":soft_delete"] = "N"; |
|
|
|
$total = $pdo->go("{$count} {$from} WHERE {$where[0]}", $bind)->fetch(PDO::FETCH_COLUMN, 0); |
|
if($total > 0) { |
|
|
|
$moduli = array_filter($config["moduli"], function(&$settings) { return $settings["completed"] == "S" && ! $settings["nascosto"]; }); |
|
$moduli = array_column($config["moduli"], "titolo", 'id'); |
|
|
|
$return["recordsTotal"] = (int) $total; |
|
|
|
if(! empty($_POST["modulo"])) { |
|
$sources = []; |
|
$types = filesManager::availableTypes(); |
|
foreach ($types as $source => $type) { |
|
if(! empty($type["modulo"])) { |
|
$sources[$type["modulo"]][] = $source; |
|
} |
|
} |
|
if(! empty($sources[$_POST["modulo"]])) { |
|
$where[] = "sourceType IN ('" . implode("', '", $sources[$_POST["modulo"]]) . "')"; |
|
} |
|
} |
|
|
|
if(! empty($_POST["classificazione"])) { |
|
$where[] = "classificazione = :classificazione"; |
|
$bind[":classificazione"] = $_POST["classificazione"]; |
|
} |
|
|
|
if(! empty($_POST["titolo"])) { |
|
$where[] = "titolo LIKE :titolo"; |
|
$bind[":titolo"] = "%{$_POST["titolo"]}%"; |
|
} |
|
|
|
if(! empty($_POST["data_inizio"])) { |
|
$where[] = "timestamp >= :data_inizio"; |
|
$bind[":data_inizio"] = date2mysql($_POST["data_inizio"]) . " 00:00:00"; |
|
} |
|
|
|
if(! empty($_POST["data_fine"])) { |
|
$where[] = "timestamp <= :data_fine"; |
|
$bind[":data_fine"] = date2mysql($_POST["data_fine"]) . " 23:59:59"; |
|
} |
|
|
|
$types = filesManager::availableTypes(); |
|
|
|
$moduli = array_filter($config["moduli"], function(&$settings) { return $settings["completed"] == "S" && ! $settings["nascosto"]; }); |
|
$moduli = array_column($config["moduli"], "titolo", 'id'); |
|
|
|
$order = ["column" => "codice", "dir" => $_POST["order"][0]["dir"] ?? "DESC"]; |
|
switch($_POST["order"][0]["column"]) { |
|
case "0": $order["column"] = "codice"; break; |
|
case "2": $order["column"] = "modulo"; break; |
|
case "3": $order["column"] = "titolo"; break; |
|
} |
|
|
|
$where = "WHERE " . implode(" AND ", $where); |
|
|
|
$limit = ""; |
|
if(isset($_POST["start"]) && isset($_POST["length"]) && (int) $_POST["length"] > 0) { |
|
$start = (int) $_POST["start"]; |
|
$end = $start + (int) $_POST["length"]; |
|
$limit = "LIMIT {$start}, {$end}"; |
|
} |
|
|
|
$filtered = $pdo->go("{$count} {$from} {$where} ORDER BY {$order["column"]} {$order["dir"]}", $bind); |
|
$return["recordsFiltered"] = (int) $filtered->fetch(PDO::FETCH_COLUMN, 0); |
|
|
|
$result = $pdo->go("{$select} {$from} {$where} ORDER BY {$order["column"]} {$order["dir"]} {$limit}", $bind); |
|
if(! empty($_POST["token"])) { |
|
$_SESSION["ARCHIVIO-DOCUMENTALE"][$_POST["token"]]["sql"] = "{$select} {$from} {$where} ORDER BY {$order["column"]} {$order["dir"]} {$limit}"; |
|
$_SESSION["ARCHIVIO-DOCUMENTALE"][$_POST["token"]]["bind"] = $bind; |
|
$_SESSION["ARCHIVIO-DOCUMENTALE"][$_POST["token"]]["timestamp"] = date('Y-m-d H:i:s'); |
|
} |
|
|
|
$categoria = $pdo->prepare("SELECT titolo FROM b_categorie_documentali WHERE codice = :codice"); |
|
while ($record = $result->fetch(PDO::FETCH_ASSOC)) { |
|
|
|
$url = filesManager::getAttachURL($record, $record["sourceID"], $record["sourceType"], false); |
|
|
|
$row = []; |
|
$row[] = $record["codice"]; |
|
|
|
$modulo = $record["sourceType"]; |
|
if(! empty($types[$record["sourceType"]])) { |
|
$modulo = $types[$record["sourceType"]]["modulo"]; |
|
if(! empty($moduli[$modulo])) { |
|
$modulo = $moduli[$modulo]; |
|
} |
|
} |
|
$row[] = $modulo; |
|
|
|
$classificazione = "Nessuna"; |
|
if(! empty($record["classificazione"])) { |
|
$categoria->bindValue(":codice", $record["classificazione"]); |
|
$categoria->execute(); |
|
$classificazione = $categoria->fetch(PDO::FETCH_COLUMN, 0); |
|
} |
|
$row[] = $classificazione; |
|
|
|
ob_start(); |
|
?> |
|
<a target="_blank" href="<?= $url ?>"><?= $record["titolo"] ?></a> <span class="small">(<?= human_filesize($record["size"]) ?>)</span><br> |
|
<span class="small">SHA256: <?= $record["sha256"] ?> [<?= mysql2date($record["timestamp"]) ?>]</span> |
|
<? |
|
$row[] = ob_get_clean(); |
|
ob_start(); |
|
|
|
$row[] = ob_get_clean(); |
|
|
|
$return["data"][] = $row; |
|
|
|
} |
|
|
|
} |
|
|
|
echo json_encode($return, JSON_PRETTY_PRINT); |
|
exit(); |
|
|
|
} |
|
|
|
} |
|
|
|
header('HTTP/1.0 403 Forbidden'); |
|
die(); |
|
?>
|
|
|