diff --git a/content/legal/default.txt b/content/legal/default.txt index d4cb2ef..7b0bd9f 100644 --- a/content/legal/default.txt +++ b/content/legal/default.txt @@ -16,7 +16,7 @@ DE 300 983 590 ### Contact -(qdated: cddmail1) +(dated:) (link: pgp.asc text: PGP: D703 9FD2 4AAE 69E9 97A6 92FF 2E2A DD32 FE50 61C1 rel: pgpkey) This email address is valid for one week, after which it expires. Emails to this address are received by me personally and are responded to as fast as possible. Together with my reply, you will get my permanently valid email address. diff --git a/site/plugins/dated/index.php b/site/plugins/dated/index.php new file mode 100644 index 0000000..cdf0786 --- /dev/null +++ b/site/plugins/dated/index.php @@ -0,0 +1,46 @@ + [ + 'dated' => [ + 'html' => function($tag) { + $dated = dated(); + return '' . $dated . ''; + } + ] + ] +]); + +/** + * Returns the current dated address + * + * @return string + */ +function dated(): string { + // date in seven days + $date = modifiedJulianDate(time() + 7 * 24 * 60 * 60); + + return 'dated-' . $date . '@' . Url::host(); +} + +/** + * Returns the Modified Julian Date, + * which is the Julian Date with the first two digits stripped + * and with an offset of one day to compensate for the Julian Date + * starting at noon instead of at midnight + * + * @param int $timestamp Timestamp to calculate from, defaults to the current date + * @return int + */ +function modifiedJulianDate(?int $timestamp = null): int { + $timestamp = $timestamp ?? time(); + + return gregoriantojd( + date('m', $timestamp), + date('d', $timestamp), + date('Y', $timestamp) + ) - 2400001; +} diff --git a/site/plugins/qdated/index.php b/site/plugins/qdated/index.php deleted file mode 100644 index af75447..0000000 --- a/site/plugins/qdated/index.php +++ /dev/null @@ -1,29 +0,0 @@ - [ - 'qdated' => [ - 'html' => function($tag) { - $qdated = qdated($tag->qdated); - return '' . $qdated . ''; - } - ] - ] -]); - -/** - * Returns the current qdated address - * If qdated is not available, returns null - * - * @param string $destination - * @return string - */ -function qdated(string $destination) { - $path = $_SERVER['HOME'] . '/.config/qdated/' . $destination . '/current'; - if(!is_file($path)) return null; - - return 'dated-' . trim(F::read($path)) . '@' . Url::host(); -} diff --git a/site/snippets/header.php b/site/snippets/header.php index 0cc9d76..5c0c5b4 100644 --- a/site/snippets/header.php +++ b/site/snippets/header.php @@ -28,7 +28,7 @@ code designer