-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathindex.php
More file actions
43 lines (36 loc) · 1.19 KB
/
Copy pathindex.php
File metadata and controls
43 lines (36 loc) · 1.19 KB
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
<?php
header('Content-Type: text/html; charset=utf-8');
include_once 'src/RomanCalendar.php';
include_once 'src/RomanCalendarRenderHTML.php';
use RomanCalendar\RomanCalendar;
use RomanCalendar\RomanCalendarRenderHTML;
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/RomanCalendar.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
</head>
<body>
<?php
$debug = true; // Set to false in production
$year = filter_input(INPUT_GET, 'year', FILTER_VALIDATE_INT) ?? (int)date("Y");
$cacheFile = 'dat/' . $year . '/calendar.json';
if (file_exists($cacheFile) && !$debug) {
$fullYear = json_decode(file_get_contents($cacheFile), true);
} else {
$options = [
'epiphanyOnSunday' => true,
'ascensionOnSunday' => true,
'corpusChristiOnSunday' => true,
];
$fullYear = (new RomanCalendar($year, $options))->getFullYear();
if (!is_dir('dat/' . $year)) {
mkdir('dat/' . $year, 0744, true);
}
file_put_contents($cacheFile, json_encode($fullYear, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT | JSON_NUMERIC_CHECK));
}
$rHTML = new RomanCalendarRenderHTML();
$rHTML->printYearHTML($year, $fullYear);
?>
</body>
</html>