summaryrefslogtreecommitdiff
path: root/index.php
diff options
context:
space:
mode:
authorMinteck <nekostarfan@gmail.com>2021-08-24 15:35:35 +0200
committerMinteck <nekostarfan@gmail.com>2021-08-24 15:35:35 +0200
commitdf8d64debc84de2c89e6700f1f2b05b224fff900 (patch)
treeaf2a816c23be7b743b2d92c799ecd858faebb235 /index.php
downloadtimetracker-df8d64debc84de2c89e6700f1f2b05b224fff900.tar.gz
timetracker-df8d64debc84de2c89e6700f1f2b05b224fff900.tar.bz2
timetracker-df8d64debc84de2c89e6700f1f2b05b224fff900.zip
Initial commit
Diffstat (limited to 'index.php')
-rw-r--r--index.php188
1 files changed, 188 insertions, 0 deletions
diff --git a/index.php b/index.php
new file mode 100644
index 0000000..c60b386
--- /dev/null
+++ b/index.php
@@ -0,0 +1,188 @@
+<?php
+
+setlocale(LC_TIME, array('fr_FR.UTF-8','fr_FR@euro','fr_FR','french'));
+
+if (isset($_GET['next']) && is_integer((int)$_GET['next']) && $_GET['next'] > 0) {
+ $file = date("Y-m-d", strtotime("+" . $_GET['next'] . " day"));
+ $number = (int)date("Ymd", strtotime("+" . $_GET['next'] . " day"));
+ $today = (int)date("Ymd");
+} else if (isset($_GET['back']) && is_integer((int)$_GET['back']) && $_GET['back'] > 0) {
+ $file = date("Y-m-d", strtotime("-" . $_GET['back'] . " day"));
+ $number = (int)date("Ymd", strtotime("-" . $_GET['back'] . " day"));
+ $today = (int)date("Ymd");
+} else {
+ $file = date("Y-m-d");
+ $number = (int)date("Ymd");
+ $today = (int)date("Ymd");
+}
+
+if ((int)substr($number, 4) >= 320 && (int)substr($number, 4) < 621) $image = "/seasons/spring.webp";
+if ((int)substr($number, 4) >= 621 && (int)substr($number, 4) < 921) $image = "/seasons/summer.webp";
+if ((int)substr($number, 4) >= 922 && (int)substr($number, 4) < 1221) $image = "/seasons/fall.webp";
+if ((int)substr($number, 4) >= 1221) $image = "/seasons/winter.webp";
+if ((int)substr($number, 4) < 320) $image = "/seasons/winter.webp";
+
+if (isset($_GET['next']) && is_integer((int)$_GET['next']) && $_GET['next'] > 0) {
+ if (strftime("%Y", strtotime("+" . $_GET['next'] . " day")) !== strftime("%Y")) {
+ $_TITLE = strftime("%a %e %b %Y", strtotime("+" . $_GET['next'] . " day"));
+ } else {
+ $_TITLE = strftime("%a %e %b", strtotime("+" . $_GET['next'] . " day"));
+ }
+} else if (isset($_GET['back']) && is_integer((int)$_GET['back']) && $_GET['back'] > 0) {
+ if (strftime("%Y", strtotime("-" . $_GET['back'] . " day")) !== strftime("%Y")) {
+ $_TITLE = strftime("%a %e %b %Y", strtotime("-" . $_GET['back'] . " day"));
+ } else {
+ $_TITLE = strftime("%a %e %b", strtotime("-" . $_GET['back'] . " day"));
+ }
+} else {
+ $_TITLE = strftime("%a %e %b");
+}
+
+require_once $_SERVER['DOCUMENT_ROOT'] . "/private/header.php";
+$config = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/private/config.json"), true) ?>
+
+<h1 style="text-align:center;margin-top:50px;">TimeTracker <small><small><small><small><a href="/glossary" title="Consulter le glossaire contenant de l'aide sur les termes techniques">[Glossaire]</a></small></small></small></small></h1>
+<h2 style="text-align:center;"><?php
+
+ if (isset($_GET['next']) && is_integer((int)$_GET['next']) && $_GET['next'] > 0) {
+ if (strftime("%Y", strtotime("+" . $_GET['next'] . " day")) !== strftime("%Y")) {
+ echo(strftime("%a %e %b %Y", strtotime("+" . $_GET['next'] . " day")));
+ } else {
+ echo(strftime("%a %e %b", strtotime("+" . $_GET['next'] . " day")));
+ }
+ } else if (isset($_GET['back']) && is_integer((int)$_GET['back']) && $_GET['back'] > 0) {
+ if (strftime("%Y", strtotime("-" . $_GET['back'] . " day")) !== strftime("%Y")) {
+ echo(strftime("%a %e %b %Y", strtotime("-" . $_GET['back'] . " day")));
+ } else {
+ echo(strftime("%a %e %b", strtotime("-" . $_GET['back'] . " day")));
+ }
+ } else {
+ echo(strftime("%a %e %b"));
+ }
+
+ ?><br><small><small><small><a title="Mois précédent" href="/<?php
+
+ if (isset($_GET['next']) && is_integer((int)$_GET['next']) && $_GET['next'] > 29) {
+ if ($_GET['next'] - 30 === 0) {
+ echo("");
+ } else {
+ echo("?next=" . ($_GET['next'] - 30));
+ }
+ } else if (isset($_GET['back']) && is_integer((int)$_GET['back']) && $_GET['back'] > 0) {
+ echo("?back=" . ($_GET['back'] + 30));
+ } else {
+ echo("?back=30");
+ }
+
+ ?>">[<<<]</a> &nbsp; <a title="Semaine suivante" href="/<?php
+
+ if (isset($_GET['next']) && is_integer((int)$_GET['next']) && $_GET['next'] > 6) {
+ if ($_GET['next'] - 7 === 0) {
+ echo("");
+ } else {
+ echo("?next=" . ($_GET['next'] - 7));
+ }
+ } else if (isset($_GET['back']) && is_integer((int)$_GET['back']) && $_GET['back'] > 0) {
+ echo("?back=" . ($_GET['back'] + 7));
+ } else {
+ echo("?back=7");
+ }
+
+ ?>">[<<]</a> &nbsp; <a title="Jour précédent" href="/<?php
+
+ if (isset($_GET['next']) && is_integer((int)$_GET['next']) && $_GET['next'] > 0 && $_GET['next'] < 738389) {
+ if ($_GET['next'] - 1 === 0) {
+ echo("");
+ } else {
+ echo("?next=" . ($_GET['next'] - 1));
+ }
+ } else if (isset($_GET['back']) && is_integer((int)$_GET['back']) && $_GET['back'] > 0 && $_GET['back'] < 738389) {
+ echo("?back=" . ($_GET['back'] + 1));
+ } else {
+ echo("?back=1");
+ }
+
+ ?>">[<]</a> &nbsp; <a href="/" title="Retourner à la page d'aujourd'hui">[Aujourd'hui]</a> &nbsp; <a title="Jour suivant" href="/<?php
+
+ if (isset($_GET['back']) && is_integer((int)$_GET['back']) && $_GET['back'] > 0) {
+ if ($_GET['back'] - 1 === 0) {
+ echo("");
+ } else {
+ echo("?back=" . ($_GET['back'] - 1));
+ }
+ } else if (isset($_GET['next']) && is_integer((int)$_GET['next']) && $_GET['next'] > 0) {
+ echo("?next=" . ($_GET['next'] + 1));
+ } else {
+ echo("?next=1");
+ }
+
+ ?>">[>]</a> &nbsp; <a title="Semaine suivante" href="/<?php
+
+ if (isset($_GET['back']) && is_integer((int)$_GET['back']) && $_GET['back'] > 6) {
+ if ($_GET['back'] - 7 === 0) {
+ echo("");
+ } else {
+ echo("?back=" . ($_GET['back'] - 7));
+ }
+ } else if (isset($_GET['next']) && is_integer((int)$_GET['next']) && $_GET['next'] > 0) {
+ echo("?next=" . ($_GET['next'] + 7));
+ } else {
+ echo("?next=7");
+ }
+
+ ?>">[>>]</a> &nbsp; <a title="Mois suivant" href="/<?php
+
+ if (isset($_GET['back']) && is_integer((int)$_GET['back']) && $_GET['back'] > 29) {
+ if ($_GET['back'] - 30 === 0) {
+ echo("");
+ } else {
+ echo("?back=" . ($_GET['back'] - 30));
+ }
+ } else if (isset($_GET['next']) && is_integer((int)$_GET['next']) && $_GET['next'] > 0) {
+ echo("?next=" . ($_GET['next'] + 30));
+ } else {
+ echo("?next=30");
+ }
+
+ ?>">[>>>]</a></small></small></small></h2>
+<br>
+<hr>
+
+<div class="container">
+ <?php foreach ($config["birthdays"] as $birthday): if (substr($number, 4) === $birthday["date"]): ?>
+ <div class="alert alert-info">
+ <strong>🎂 Anniversaire</strong> de <?= $birthday["name"] ?> (<?= explode("-", $file)[0] - $birthday["year"] ?> an<?= explode("-", $file)[0] - $birthday["year"] > 1 ? "s" : "" ?><?= explode("-", $file)[0] - $birthday["year"] === 18 ? ", majorité" : "" ?>)
+ </div>
+ <?php endif; endforeach; ?>
+ <?php foreach ($config["events"] as $event): if (substr($number, 4) === $event["date"]): ?>
+ <div class="alert alert-info">
+ <strong><?= $event["name"] ?></strong>
+ </div>
+ <?php endif; endforeach; ?>
+ <?php if ($number === $today): ?>
+ <div class="alert alert-success">
+ <strong>Vous consultez les informations d'aujourd'hui,</strong> les données peuvent ne pas être complètes.
+ </div>
+ <?php endif; ?>
+ <?php if ($number > $today): ?>
+ <div class="alert alert-danger">
+ <strong>Erreur :</strong> Vous ne pouvez pas consulter les données d'un jour qui se situe dans le futur.
+ </div>
+ <?php else: if ($config["born"] > $number): ?>
+ <div class="alert alert-danger">
+ <strong>Erreur :</strong> Le gestionnaire de cette instance de TimeTracker n'été pas né à ce jour.
+ </div>
+ <?php else: if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/private/db/" . $file . ".json")): ?>
+ <div class="alert alert-warning">
+ <strong>Avertissement :</strong> Aucune donnée n'est disponible pour le jour sélectionné.
+ </div>
+ <?php else: ?>
+ <ul class="list-group">
+ <?php $day = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/private/db/" . $file . ".json"), true); foreach ($day as $item): ?>
+ <li class="list-group-item"><?= preg_replace("@\[([a-zA-Z0-9 ,.;:|!?*\$€<>(){}'\"~éèàêâùô¡¿§µ%£#_`\@=+-/]*)\]@", "<a href=\"/glossary/#$1\">$1</a>", $item) ?></li>
+ <?php endforeach; ?>
+ </ul>
+ <?php endif; endif; endif; ?>
+</div>
+
+<?php require_once $_SERVER['DOCUMENT_ROOT'] . "/private/footer.php"; ?> \ No newline at end of file