1 parent
bef34c6764
commit
4b0d1ee8a4
29 files changed
+4660
-3
No files matched your search
Executable
+76
@@ -0,0 +1,76 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="pt-br">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Lista de Arquivos</title>
|
||||
<style>
|
||||
#searchBox {
|
||||
margin-bottom: 20px;
|
||||
padding: 10px;
|
||||
width: 100%;
|
||||
max-width: 300px;
|
||||
font-size: 16px;
|
||||
}
|
||||
ul {
|
||||
list-style-type: none;
|
||||
padding: 0;
|
||||
}
|
||||
li {
|
||||
margin: 5px 0;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<?php
|
||||
// Pega o tipo de arquivo da query string
|
||||
$queries = array();
|
||||
parse_str($_SERVER['QUERY_STRING'], $queries);
|
||||
$filetype = isset($queries['filetype']) ? $queries['filetype'] : '';
|
||||
|
||||
// Lê o arquivo de texto em um array, cada linha como um elemento
|
||||
$lines = file("$filetype.txt", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
||||
|
||||
// Inicia a lista não ordenada
|
||||
echo '<input type="text" id="searchBox" placeholder="Buscar arquivos..." onkeyup="filterList()">';
|
||||
|
||||
echo "<ul id=\"fileList\">";
|
||||
|
||||
foreach ($lines as $line) {
|
||||
// Obtém o nome do arquivo e o caminho
|
||||
$filename = basename($line);
|
||||
$parts = explode('/', $line);
|
||||
$username = $parts[2];
|
||||
$path_after_public_html = implode('/', array_slice($parts, 4));
|
||||
$dir_after_public_html = dirname($path_after_public_html);
|
||||
|
||||
// Cria o item da lista com o link para o diretório
|
||||
echo "<li data-filename=\"$filename\" data-username=\"$username\" data-path=\"$dir_after_public_html\">($username) <a href=\"/~$username/$path_after_public_html\">$filename</a> ($dir_after_public_html)</li>";
|
||||
}
|
||||
|
||||
// Fecha a lista não ordenada
|
||||
echo "</ul>";
|
||||
?>
|
||||
|
||||
<script>
|
||||
function filterList() {
|
||||
// Pega o valor do campo de busca
|
||||
var filter = document.getElementById('searchBox').value.toLowerCase();
|
||||
var ul = document.getElementById('fileList');
|
||||
var li = ul.getElementsByTagName('li');
|
||||
|
||||
// Itera sobre os itens da lista e esconde os que não correspondem
|
||||
for (var i = 0; i < li.length; i++) {
|
||||
var filename = li[i].getAttribute('data-filename').toLowerCase();
|
||||
var username = li[i].getAttribute('data-username').toLowerCase();
|
||||
var path = li[i].getAttribute('data-path').toLowerCase();
|
||||
|
||||
if (filename.indexOf(filter) > -1 || username.indexOf(filter) > -1 || path.indexOf(filter) > -1) {
|
||||
li[i].style.display = "";
|
||||
} else {
|
||||
li[i].style.display = "none";
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in new issue
Block a user