forked from YGGverse/YGGwave
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
151 lines (119 loc) · 4.61 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<?php
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
error_reporting(E_ALL);
class YGGwave {
public static function getSignals() {
$result = [];
if ($signals = file_get_contents('SIGNALS/YGGDRASIL.md')) {
foreach (explode(PHP_EOL, $signals) as $signal) {
if (preg_match('/\[(.*?)\]\((.*?)\)/ui', $signal, $data)) {
if (!empty($data[1]) && !empty($data[2])) {
if ($host = parse_url($data[2], PHP_URL_HOST)) {
$hash = crc32($data[2]);
$result[] = sprintf('<div style="top:%s%%;left:%s%%">%s</div>',
self::_getSignalPosition($hash),
self::_getSignalPosition($hash, true),
sprintf('<a target="_blank"
href="%s"
title="%s">%s</a>', htmlspecialchars($data[2]),
htmlentities($data[1]),
sprintf('<img src="/yggo/file.php?type=identicon&query=%s"
alt="%s"
style="%s" />', urlencode($host),
htmlentities($data[1]),
sprintf('background:#%s', substr(dechex($hash), 0, 6)))));
}
}
}
}
}
return $result;
}
private static function _getSignalPosition(int $hash, bool $reverse = false, int $padding = 20) {
$variant = $reverse ? array_reverse(str_split($hash, 2)) : str_split($hash, 2);
$version = 0;
do {
if (!isset($variant[$version])) return rand($padding, 100 - $padding); // :)
$position = $variant[$version++];
} while ($position < $padding || $position > 100 - $padding);
return $position;
}
}
?>
<!DOCTYPE html>
<html lang="en-US">
<head>
<title>YGGwave ~ The Radio Catalog</title>
<meta name="description" content="Open Source, Javascript-less Radio Catalog" />
<meta name="keywords" content="web, radio, stream, catalog, yggdrasil, js-less, open source" />
<meta charset="utf-8" />
<style>
@font-face {
font-family: 'ThasadithRegular';
src: url('./fonts/Thasadith/Thasadith-Regular.eot');
src: url('./fonts/Thasadith/Thasadith-Regular.eot?#iefix') format('embedded-opentype'),
url('./fonts/Thasadith/Thasadith-Regular.woff2') format('woff2'),
url('./fonts/Thasadith/Thasadith-Regular.woff') format('woff'),
url('./fonts/Thasadith/Thasadith-Regular.ttf') format('truetype');
}
* {
border: 0;
margin: 0;
padding: 0;
color: #fff;
text-decoration: none;
font-family: ThasadithRegular, Sans-serif;
font-weight: lighter;
transition: all .5s ease-in;
-moz-transition: all .5s ease-in;
-o-transition: all .5s ease-in;
-webkit-transition: all .5s ease-in;
}
main {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
background-image: linear-gradient(to right top, #041b41, #003e68, #00658d, #008eac, #2ab8c6);
padding: 36px;
}
main > h1 > sup > a, main > h1 > sup > a:active, main > h1 > sup > a:visited {
opacity:0.8;
}
main p {
margin-left: 6px;
}
main > div > a, main > div > a:active, main > div > a:visited {
display: block;
padding: 4px;
width: 24px;
height: 24px;
border-radius: 50%;
border: 1px rgba(255, 255, 255, 0.36) solid;
}
main > div > a > img {
border-radius: 50%;
border: 2px rgba(255, 255, 255, 0.68) solid;
padding: 2px
}
main > div {
position: absolute;
opacity: 0.8;
}
main > div:hover {
opacity: 1;
}
</style>
</head>
<body>
<main>
<h1>YGGwave<sup><a href="https://github.com/YGGverse/YGGwave/tree/main/SIGNALS" style="color:#<?php echo substr(dechex(crc32(microtime())), 0, 6) ?>">~</a></sup></h1>
<p>the radio catalog</p>
<?php foreach (YGGwave::getSignals() as $signal) { ?>
<?php echo $signal ?>
<?php } ?>
</main>
</body>
</html>