Newer
Older
<?php
require 'functions.php';
// ---------------------------------------------------------
// Some global definitions that can be reused multiple times
// ---------------------------------------------------------
define('pagetitle', 'Librehosters');
define('debug', false); // Enable debug or not, will enable error reporting and disable caching
// Configuration
$directoryFile = [
'src' => '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);
}
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
$directory = getDirFile($directoryFile);
if (!is_array($directory)) {
http_response_code(500);
die();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>
<?php echo pagetitle; ?>
</title>
<link rel="stylesheet" href="bootstrap.min.css">
<link rel="stylesheet" href="custom.css">
</head>
<body>
<br>
<div class="container">
<h1 class="text-center">
<?php echo pagetitle; ?>
</h1>
<br>
<div class="row">
<?php
foreach ($directory as $librehostJsonUrl) {
$hostInformation = getHostInformation($librehostJsonUrl);
?>
<div class="col-sm-12 col-md-4 col-lg-3">
<div class="card">
<div class="card-header">
<h4> <?php echo $hostInformation['name'] ?> </h4>
<div class="text-muted"> <?php echo $hostInformation['organizationType'] ?> </div>
</div>
<div class="card-body">
<div class="card-text">
<h5><?php echo $hostInformation['tagLine'] ?></h5>
<?php echo $hostInformation['description'] ?>
<br>
<?php
foreach($hostInformation['communicationLanguages'] as $language) {
?>
<img src="img/flags/<?php echo $language ?>.svg" alt="<?php echo $language ?>" class="flag">
<?php
}
?>
</div>
</div>
<div class="card-footer">
<a href="<?php echo $hostInformation['homeUrl'] ?>" class="btn btn-primary" target="_blank" rel="noopener noreferrer">
Go to <?php echo $hostInformation['name'] ?> </a> <br>
<?php
if (filter_var($hostInformation['contactUrl'], FILTER_VALIDATE_URL)) {
echo '<a href="'.$hostInformation['contactUrl'].'" target="_blank" rel="noopener noreferrer" title="contact">contact</a>';
if (filter_var($hostInformation['privacyPolicyUrl'], FILTER_VALIDATE_URL) || filter_var($hostInformation['termsOfServiceUrl'], FILTER_VALIDATE_URL)) {
echo ' - ';
}
}
if (filter_var($hostInformation['privacyPolicyUrl'], FILTER_VALIDATE_URL)) {
echo '<a href="'.$hostInformation['privacyPolicyUrl'].'" target="_blank" rel="noopener noreferrer" title="privacy policy">privacy</a>';
if (filter_var($hostInformation['termsOfServiceUrl'], FILTER_VALIDATE_URL)) {
echo ' - ';
}
}
if (filter_var($hostInformation['termsOfServiceUrl'], FILTER_VALIDATE_URL)) {
echo '<a href="'.$hostInformation['termsOfServiceUrl'].'" target="_blank" rel="noopener noreferrer" title="terms of service" >tos</a>';
}
?>
</div>
</div>
<br>
</div>
<br>
<?php
}
?>
</div>
<footer class="bg-light text-center">
<br>
Created by <a href="mailto:klimplant@disroot.org">klimplant</a> | <a href="https://lab.libreho.st/klimplant/librelist" target="_blank" rel="noopener noreferrer">source code</a>
</footer>