Updates!!
This commit is contained in:
parent
d170a95469
commit
302d41d09d
@ -1,5 +1,7 @@
|
|||||||
{
|
{
|
||||||
"require": {
|
"require": {
|
||||||
"johngrogg/ics-parser": "^2.1.17"
|
"johngrogg/ics-parser": "^3",
|
||||||
|
"symfony/http-client": "^6.2",
|
||||||
|
"symfony/http-kernel": "^6.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
1164
composer.lock
generated
1164
composer.lock
generated
File diff suppressed because it is too large
Load Diff
48
index.php
48
index.php
@ -1,9 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once 'vendor/autoload.php';
|
require_once 'vendor/autoload.php';
|
||||||
use ICal\ICal;
|
use ICal\ICal;
|
||||||
|
use Symfony\Component\HttpClient\CachingHttpClient;
|
||||||
|
use Symfony\Component\HttpClient\HttpClient;
|
||||||
|
use Symfony\Component\HttpKernel\HttpCache\Store;
|
||||||
|
|
||||||
|
$store = new Store('/tmp/dorf.jetzt/');
|
||||||
|
$client = HttpClient::create();
|
||||||
|
$client = new CachingHttpClient($client, $store, array('default_ttl' => 60, 'allow_revalidate' => true));
|
||||||
|
|
||||||
static $DATE_FORMAT = 'd.m.Y H:i';
|
static $DATE_FORMAT = 'd.m.Y H:i';
|
||||||
static $VISITORS_FILE = '/opt/dorf.jetzt_visitors';
|
static $VISITORS_FILE = '/opt/dorf.jetzt_visitors';
|
||||||
static $DORF_IN_LOCKDOWN = true;
|
static $DORF_IN_LOCKDOWN = false;
|
||||||
static $DORF_VIRTUAL_EVENTS = true;
|
static $DORF_VIRTUAL_EVENTS = true;
|
||||||
static $ICAL_URL = 'https://chaosdorf.de/~derf/cccd_all.ics';
|
static $ICAL_URL = 'https://chaosdorf.de/~derf/cccd_all.ics';
|
||||||
$state_map = array(
|
$state_map = array(
|
||||||
@ -50,23 +58,27 @@ $hash_to_state = array(
|
|||||||
'0' => 'error',
|
'0' => 'error',
|
||||||
);
|
);
|
||||||
if ($DORF_VIRTUAL_EVENTS || ! $DORF_IN_LOCKDOWN){
|
if ($DORF_VIRTUAL_EVENTS || ! $DORF_IN_LOCKDOWN){
|
||||||
$img = file_get_contents('https://chaosdorf.de/raumstatus/status.png');
|
try {
|
||||||
$hash = md5($img);
|
$response = $client->request('GET', 'https://chaosdorf.de/raumstatus/status.png');
|
||||||
$state = $hash_to_state[$hash];
|
$hash = md5($response->getContent());
|
||||||
$ical = new ICal(false, array(
|
} catch (\Exception $e){
|
||||||
'defaultSpan' => 2,
|
$hash = 0;
|
||||||
'defaultTimeZone' => 'Europe/Berlin',
|
}
|
||||||
'defaultWeekStart' => 'MO',
|
$state = $hash_to_state[$hash];
|
||||||
'filterDaysBefore' => '1',
|
$ical = new ICal(false, array(
|
||||||
));
|
'defaultSpan' => 2,
|
||||||
$ical->initUrl($ICAL_URL, $acceptLanguage = 'de');
|
'defaultTimeZone' => 'Europe/Berlin',
|
||||||
$events = $ical->eventsFromInterval('2 week');
|
'defaultWeekStart' => 'MO',
|
||||||
$first_event = $events[0];
|
'filterDaysBefore' => '1',
|
||||||
$events = array_slice($events, 1);
|
));
|
||||||
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
|
$ical->initUrl($ICAL_URL, $acceptLanguage = 'de');
|
||||||
$locale = locale_accept_from_http($_SERVER['HTTP_ACCEPT_LANGUAGE']);
|
$events = $ical->eventsFromInterval('2 week');
|
||||||
setlocale(LC_TIME, $locale);
|
$first_event = $events[0];
|
||||||
}
|
$events = array_slice($events, 1);
|
||||||
|
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
|
||||||
|
$locale = locale_accept_from_http($_SERVER['HTTP_ACCEPT_LANGUAGE']);
|
||||||
|
setlocale(LC_TIME, $locale);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
function format_event($event): string{
|
function format_event($event): string{
|
||||||
global $DATE_FORMAT, $ical;
|
global $DATE_FORMAT, $ical;
|
||||||
|
Loading…
Reference in New Issue
Block a user