Updates!!

This commit is contained in:
Christopher Teutsch 2022-12-17 00:10:35 +01:00
parent d170a95469
commit 302d41d09d
3 changed files with 1188 additions and 28 deletions

View File

@ -1,5 +1,7 @@
{
"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

File diff suppressed because it is too large Load Diff

View File

@ -1,9 +1,17 @@
<?php
require_once 'vendor/autoload.php';
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 $VISITORS_FILE = '/opt/dorf.jetzt_visitors';
static $DORF_IN_LOCKDOWN = true;
static $DORF_IN_LOCKDOWN = false;
static $DORF_VIRTUAL_EVENTS = true;
static $ICAL_URL = 'https://chaosdorf.de/~derf/cccd_all.ics';
$state_map = array(
@ -50,8 +58,12 @@ $hash_to_state = array(
'0' => 'error',
);
if ($DORF_VIRTUAL_EVENTS || ! $DORF_IN_LOCKDOWN){
$img = file_get_contents('https://chaosdorf.de/raumstatus/status.png');
$hash = md5($img);
try {
$response = $client->request('GET', 'https://chaosdorf.de/raumstatus/status.png');
$hash = md5($response->getContent());
} catch (\Exception $e){
$hash = 0;
}
$state = $hash_to_state[$hash];
$ical = new ICal(false, array(
'defaultSpan' => 2,