File manager - Edit - /home/cuautla1/public_html/resultadobusqueda.php
Back
<?php $query = isset($_GET['q']) ? strtolower(trim($_GET['q'])) : ''; $rootFolder = __DIR__ . '/transparencia_files/'; $rootURL = '/transparencia_files/'; $results = []; function searchFiles($dir, $urlBase, $query, &$results) { $items = array_diff(scandir($dir), ['.', '..']); foreach ($items as $item) { $fullPath = $dir . '/' . $item; if (is_dir($fullPath)) { searchFiles($fullPath, $urlBase . rawurlencode($item) . '/', $query, $results); } else { if (str_contains(strtolower($item), $query)) { $results[] = [ 'name' => $item, 'url' => $urlBase . rawurlencode($item), 'fecha' => date('d/m/Y H:i', filemtime($fullPath)) ]; } } } } if ($query !== '' && is_dir($rootFolder)) { searchFiles($rootFolder, $rootURL, $query, $results); } ?> <!DOCTYPE html> <html lang="es"> <head> <meta charset="UTF-8" /> <title>Resultados de Busqueda</title> <link rel="stylesheet" href="menu.css"> <style> main { max-width: 1000px; margin: 40px auto; padding: 20px; font-family: Arial, sans-serif; } h1 { color: #006837; text-align: center; margin-bottom: 30px; } .table-container { overflow-x: auto; } table { width: 100%; border-collapse: collapse; } th, td { padding: 10px; border: 1px solid #ccc; } th { background-color: #78BE20; color: white; } a { color: #006837; text-decoration: none; } a:hover { text-decoration: underline; } </style> </head> <body> <?php include 'menu.php'; ?> <main> <h1>Resultados de Busqueda para: "<?= htmlspecialchars($query) ?>"</h1> <?php if (!empty($results)): ?> <div class="table-container"> <table> <thead> <tr><th>Documento</th><th>Fecha</th></tr> </thead> <tbody> <?php foreach ($results as $file): ?> <tr> <td><a href="<?= $file['url'] ?>" target="_blank"><?= htmlspecialchars($file['name']) ?></a></td> <td><?= $file['fecha'] ?></td> </tr> <?php endforeach; ?> </tbody> </table> </div> <?php else: ?> <p>No se encontraron resultados que coincidan.</p> <?php endif; ?> </main> <script src="menu.js"></script> </body> </html>
| ver. 1.4 |
Github
|
.
| PHP 8.3.28 | Generation time: 0 |
proxy
|
phpinfo
|
Settings