YGGwave~
the radio catalog
%s',
self::_getSignalPosition($hash),
self::_getSignalPosition($hash, true),
sprintf('%s', htmlspecialchars($data[2]),
htmlentities($data[1]),
sprintf('', urlencode($host),
htmlentities($data[1]),
sprintf('background:#%s', substr(dechex($hash), 0, 6)))));
}
}
}
}
}
return $result;
}
public static function getMetaKeywords() {
$keywords = [];
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])) {
// Link description tags
if (preg_match_all('/[A-z0-9]{3,}/ui', $data[1], $matches)) {
foreach ($matches[0] as $keyword) {
$keyword = trim($keyword);
$keyword = mb_strtolower($keyword);
$keyword = htmlentities($keyword);
if (isset($keywords[$keyword])) {
$keywords[$keyword]++;
} else {
$keywords[$keyword] = 1;
}
}
}
// URI-based tags
if ($query = parse_url($data[2], PHP_URL_PATH)) {
foreach (explode('/', $query) as $keyword) {
$keyword = trim($keyword);
if (!empty($keyword)) {
$keyword = mb_strtolower($keyword);
$keyword = htmlentities($keyword);
if (isset($keywords[$keyword])) {
$keywords[$keyword]++;
} else {
$keywords[$keyword] = 1;
}
}
}
}
}
}
}
}
// Display keyword has count > n
$result = [];
foreach ($keywords as $keyword => $quantity) {
// if ($quantity > 1) @TODO
$result[] = $keyword;
}
return implode(', ', $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];
$version++;
} while ($position < $padding || $position > 100 - $padding);
return $position;
}
}
?>
the radio catalog