forked from tilderadio/site
move common schedule code to library
This commit is contained in:
parent
9a928f4a39
commit
c78aea671c
|
@ -1,35 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
include 'apikey.php';
|
include 'schedule.php';
|
||||||
|
|
||||||
if (empty($apikey)) {
|
|
||||||
die("missing api key");
|
|
||||||
}
|
|
||||||
$context = stream_context_create([
|
|
||||||
"http" => [
|
|
||||||
"method" => "GET",
|
|
||||||
"header" => "X-API-Key: $apikey\r\n"
|
|
||||||
]
|
|
||||||
]);
|
|
||||||
|
|
||||||
$from = gmdate("Y-m-d\TH:i:s\Z", strtotime("now + 1 day"));
|
|
||||||
$to = gmdate("Y-m-d\TH:i:s\Z", strtotime("now + 8 days"));
|
|
||||||
|
|
||||||
$schedule = json_decode(
|
|
||||||
file_get_contents(
|
|
||||||
"https://radio.tildeverse.org/api/station/1/streamers/schedule?start=$from&end=$to",
|
|
||||||
false,
|
|
||||||
$context
|
|
||||||
),
|
|
||||||
true
|
|
||||||
);
|
|
||||||
|
|
||||||
usort($schedule, function ($a, $b) {
|
|
||||||
return $a["start"] <=> $b["start"];
|
|
||||||
});
|
|
||||||
|
|
||||||
function formatdate($date) {
|
|
||||||
return gmdate("Ymd\THis\Z", strtotime($date));
|
|
||||||
}
|
|
||||||
|
|
||||||
header("Content-Type: text/calendar");
|
header("Content-Type: text/calendar");
|
||||||
|
|
||||||
|
|
|
@ -1,36 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
include '../header.php';
|
include '../header.php';
|
||||||
include 'apikey.php';
|
include 'schedule.php';
|
||||||
|
|
||||||
if (empty($apikey)) {
|
|
||||||
die("missing api key");
|
|
||||||
}
|
|
||||||
$context = stream_context_create([
|
|
||||||
"http" => [
|
|
||||||
"method" => "GET",
|
|
||||||
"header" => "X-API-Key: $apikey\r\n"
|
|
||||||
]
|
|
||||||
]);
|
|
||||||
|
|
||||||
$from = gmdate("Y-m-d\TH:i:s\Z", strtotime("now + 1 day"));
|
|
||||||
$to = gmdate("Y-m-d\TH:i:s\Z", strtotime("now + 8 days"));
|
|
||||||
|
|
||||||
$schedule = json_decode(
|
|
||||||
file_get_contents(
|
|
||||||
"https://radio.tildeverse.org/api/station/1/streamers/schedule?start=$from&end=$to",
|
|
||||||
false,
|
|
||||||
$context
|
|
||||||
),
|
|
||||||
true
|
|
||||||
);
|
|
||||||
|
|
||||||
usort($schedule, function ($a, $b) {
|
|
||||||
return $a["start"] <=> $b["start"];
|
|
||||||
});
|
|
||||||
|
|
||||||
function formatdate($date) {
|
|
||||||
return gmdate("D M d H:i", strtotime($date));
|
|
||||||
}
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<h1><a href="https://tilderadio.org"><img style="width:75px;" src="../logos/tilderadio-green.png">tilderadio.org</a></h1>
|
<h1><a href="https://tilderadio.org"><img style="width:75px;" src="../logos/tilderadio-green.png">tilderadio.org</a></h1>
|
||||||
|
|
34
schedule/schedule.php
Normal file
34
schedule/schedule.php
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
<?php
|
||||||
|
include 'apikey.php';
|
||||||
|
|
||||||
|
if (empty($apikey)) {
|
||||||
|
die("missing api key");
|
||||||
|
}
|
||||||
|
|
||||||
|
$context = stream_context_create([
|
||||||
|
"http" => [
|
||||||
|
"method" => "GET",
|
||||||
|
"header" => "X-API-Key: $apikey\r\n"
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
|
||||||
|
$from = gmdate("Y-m-d\TH:i:s\Z", strtotime("now + 1 day"));
|
||||||
|
$to = gmdate("Y-m-d\TH:i:s\Z", strtotime("now + 8 days"));
|
||||||
|
|
||||||
|
$schedule = json_decode(
|
||||||
|
file_get_contents(
|
||||||
|
"https://radio.tildeverse.org/api/station/1/streamers/schedule?start=$from&end=$to",
|
||||||
|
false,
|
||||||
|
$context
|
||||||
|
),
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
|
usort($schedule, function ($a, $b) {
|
||||||
|
return $a["start"] <=> $b["start"];
|
||||||
|
});
|
||||||
|
|
||||||
|
function formatdate($date) {
|
||||||
|
return gmdate("D M d H:i", strtotime($date));
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user