Primeiro commit
Signed-off-by: Rodrigo Martins <rodrigo.sousa.577@gmail.com>
This commit is contained in:
commit
a1beb6a2e0
425 files changed
+193665
No files matched your search
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
// status_check.php
|
||||
|
||||
// Conectar ao banco de dados
|
||||
$mysqli = new mysqli("10.15.0.42", "root", "34641747", "valida");
|
||||
|
||||
if ($mysqli->connect_error) {
|
||||
die("Connection failed: " . $mysqli->connect_error);
|
||||
}
|
||||
|
||||
// Paginação
|
||||
$files_per_page = 10;
|
||||
$page = isset($_GET['page_num']) ? (int)$_GET['page_num'] : 1;
|
||||
$page = max(1, $page);
|
||||
$offset = ($page - 1) * $files_per_page;
|
||||
|
||||
// Recuperar status dos arquivos
|
||||
$result = $mysqli->query("SELECT file_path, status FROM queue ORDER BY created_at DESC LIMIT $files_per_page OFFSET $offset");
|
||||
|
||||
$status = [];
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
$status[] = $row;
|
||||
}
|
||||
|
||||
// Contar o total de arquivos para a paginação
|
||||
$total_result = $mysqli->query("SELECT COUNT(*) AS total FROM queue");
|
||||
$total_files = $total_result->fetch_assoc()['total'];
|
||||
$total_pages = ceil($total_files / $files_per_page);
|
||||
|
||||
$mysqli->close();
|
||||
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode(['status' => $status, 'current_page' => $page, 'total_pages' => $total_pages]);
|
||||
?>
|
||||
Reference in new issue
Block a user