pax_global_header 0000666 0000000 0000000 00000000064 13425267571 0014526 g ustar 00root root 0000000 0000000 52 comment=46d4ae54b89596b28d1c4c05b04e5dfc76d2e4b8
librelist-master/ 0000775 0000000 0000000 00000000000 13425267571 0014354 5 ustar 00root root 0000000 0000000 librelist-master/.gitignore 0000664 0000000 0000000 00000000220 13425267571 0016336 0 ustar 00root root 0000000 0000000 # ---> VisualStudioCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
config.json
.cache
librelist-master/LICENSE 0000664 0000000 0000000 00000002052 13425267571 0015360 0 ustar 00root root 0000000 0000000 MIT License
Copyright (c) 2018 klimplant
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
librelist-master/README.md 0000664 0000000 0000000 00000000105 13425267571 0015627 0 ustar 00root root 0000000 0000000 # libreList
Simple script to display the librehosters in a nice list librelist-master/cache.php 0000664 0000000 0000000 00000006206 13425267571 0016134 0 ustar 00root root 0000000 0000000 ";
}
return false;
}
$cache = file_get_contents(cacheFile);
$cache = unserialize($cache);
if (!is_array($cache)) {
if (debug) {
echo "cache is no array: " . __FILE__ . ":". __LINE__ . " \n
";
}
resetCache();
return false;
}
if (!validateCache($cache)) {
if (debug) {
echo "invalid cache: " . __FILE__ . ":". __LINE__ . " \n
";
}
resetCache();
return false;
}
$data = $cache['data'];
if (!array_key_exists($dataKey, $data)) {
if (debug) {
echo "array key not found: " . __FILE__ . ":". __LINE__ . " \n
";
}
return false;
}
if (!empty($dataKey)) {
return $data[$dataKey];
}
return $data;
}
function writeCache($data) {
$hash = serialize($data);
$hash = hash('sha512', $hash);
$meta = [
'timestamp' => time(),
'hash' => $hash,
];
$cache = [
'meta' => $meta,
'data' => $data
];
$cacheSerialized = serialize($cache);
file_put_contents(cacheFile, $cacheSerialized);
if (validateCache($cache, $data)) {
if (debug) {
echo "valid cache: " . __FILE__ . ":". __LINE__ . " \n
";
}
return true;
}
resetCache();
return false;
}
function resetCache() {
if (file_exists(cacheFile)) {
return unlink(cacheFile);
} else {
return true;
}
}
function validateCache($cache, $data = null) {
$meta = $cache['meta'];
$data = $cache['data'];
$hashMeta = $meta['hash'];
$dataHash = serialize($data);
$dataHash = hash(cacheHashAlgo, $dataHash);
if (debug) {
var_dump([$hashMeta, $dataHash, $hashMeta !== $dataHash]);
}
if ($hashMeta !== $dataHash) {
if (debug) {
echo "hashes don't match: " . __FILE__ . ":". __LINE__ . " \n
";
}
return false;
}
$timestamp = $meta['timestamp'];
if (debug) {
var_dump([$timestamp, time(), (time() - cacheMaxAge), (time() - cacheMaxAge) > $timestamp]);
}
if ((time() - cacheMaxAge) > $timestamp) {
if (debug) {
echo "cache expired: " . __FILE__ . ":". __LINE__ . " \n
";
}
return false;
}
if (!is_null($data) && $cache['data'] !== $data) {
if (debug) {
echo "data doesn't math: " . __FILE__ . ":". __LINE__ . " \n
";
}
return false;
}
return true;
}
librelist-master/custom.css 0000664 0000000 0000000 00000003777 13425267571 0016416 0 ustar 00root root 0000000 0000000 html, body {
margin: 0;
padding: 0;
background: #1f1f1f;
color: white;
}
body {
display: flex;
flex-direction: column;
align-items: center;
}
.header {
padding: 0 1rem;
text-align: center;
min-height: 5rem;
line-height: 5rem;
background: hsla(208, 56%, 46%, 1);
align-self: stretch;
}
.header h1 {
margin: 0;
}
.container {
max-width: 90%;
display: flex;
justify-content: space-between;
flex-wrap: wrap;
}
.container .card {
width: 100%;
margin: 1rem 0;
border: 1px solid hsla(208, 56%, 46%, 1);
border-radius: .25rem;
box-sizing: border-box;
display: flex;
flex-direction: column;
}
@media screen and (min-width: 700px) {
.container {
max-width: 80%;
}
.container .card {
width: 48%;
}
}
@media screen and (min-width: 1000px) {
.container .card {
width: 32%;
}
}
@media screen and (min-width: 1500px) {
.container {
max-width: 70%;
}
.container .card {
width: 23%;
}
}
.card-header, .card-body, .card-footer {
padding: 1rem;
border-radius: .25rem;
}
.container .card-header, .container .card-footer {
background: #292929;
}
.card-header h4 {
font-size: 1.5rem;
margin: 0;
word-wrap: break-word;
}
.card-header .text-muted {
color: #e6e6e6;
}
.card-body {
line-height: 1.5;
}
.card-body h5 {
margin: 0;
margin-bottom: 0.5rem;
font-size: 1.25rem;
line-height: 1.2;
}
.card-footer .btn {
background: hsla(208, 56%, 46%, 1);
padding: 0.5rem;
border-radius: 0.25rem;
color: white;
text-decoration: none;
display: inline-block;
margin-bottom: 0.5rem;
}
.card-footer .btn:hover {
background: hsla(208, 56%, 36%, 1);
}
.card-footer a {
color: hsla(208, 56%, 56%, 1);
}
.card-footer a:hover {
color: hsla(208, 56%, 46%, 1);
}
.container .card-body {
flex: 1 1 auto;
}
.flag {
margin-top: 0.5rem;
height: 1em;
width: 1.5em;
object-fit: cover;
border: 1px solid white;
}
.footer {
margin-top: 1rem;
text-align: center;
height: 3rem;
}
.footer a {
color: hsla(208, 56%, 56%, 1);
}
librelist-master/functions.php 0000664 0000000 0000000 00000002145 13425267571 0017077 0 ustar 00root root 0000000 0000000 'https://libreho.st/directory.json', // either url or path relative to script
'srcType' => 'url', // path or url
];
// ---------------------------------------------------------
if (debug) {
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
}
$hosts = getCache('hosts');
$recache = !is_array($hosts) || !useCache;
if ($recache) {
$directory = getDirFile($directoryFile);
if (!is_array($directory)) {
http_response_code(500);
# guess i'll
die();
# ¯\_(ツ)_/¯
}
if (debug) {
echo "recached: " . __FILE__ . ":". __LINE__ . " \n
";
}
resetCache();
$hosts = [];
$cacheData = [];
foreach ($directory as $librehostJsonUrl) {
$hostInformation = getHostInformation($librehostJsonUrl);
$hosts[] = $hostInformation;
}
$cacheData['hosts'] = $hosts;
writeCache($cacheData);
} elseif (debug) {
echo "Cache is valid";
}
?>