initial commit
This commit is contained in:
commit
64ad93f61d
11 files changed
+412
No files matched your search
@@ -0,0 +1,64 @@
|
||||
---
|
||||
layout: default
|
||||
permalink: file_index.php
|
||||
---
|
||||
|
||||
<div class="publication">
|
||||
<div>
|
||||
<input type="text" id="searchBox" placeholder="Buscar arquivos..." onkeyup="filterList()">
|
||||
</div>
|
||||
<div class="pub-header">
|
||||
|
||||
<?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("assets/data/$filetype.txt", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
||||
|
||||
// Inicia a lista não ordenada
|
||||
|
||||
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>";
|
||||
?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<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>
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
---
|
||||
layout: default
|
||||
permalink: /
|
||||
---
|
||||
|
||||
<div class="publication">
|
||||
<div class="pub-header">
|
||||
|
||||
<?php
|
||||
// Pega todos os arquivos .txt no diretório atual
|
||||
$files = glob('assets/data/*.txt');
|
||||
|
||||
// Inicia a lista não ordenada
|
||||
echo "<ul>";
|
||||
|
||||
foreach ($files as $file) {
|
||||
// Remove a extensão .txt do nome do arquivo
|
||||
$filenameWithoutExtension = basename($file, '.txt');
|
||||
|
||||
// Cria o link com o nome do arquivo na query string
|
||||
$link = "/alice_index/file_index.php?filetype=" . urlencode($filenameWithoutExtension);
|
||||
|
||||
// Cria o item da lista com o link
|
||||
echo "<li><a href=\"$link\">$filenameWithoutExtension</a></li>";
|
||||
}
|
||||
|
||||
// Fecha a lista não ordenada
|
||||
echo "</ul>";
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
Reference in new issue
Block a user