Loading meta.php +49 −24 Original line number Diff line number Diff line Loading @@ -7,8 +7,8 @@ ini_set('display_errors', 1); require 'vendor/autoload.php'; use Dotenv\Dotenv; use MongoDB\Client; use MongoDB\BSON\UTCDateTime; use MongoDB\Client; $dotenv = Dotenv::createImmutable(__DIR__); $dotenv->load(); Loading @@ -25,7 +25,8 @@ $mongo = new Client($dsn); $db = $mongo->secretdb; $collection = $db->secrets; function utcToIso(?UTCDateTime $dt): ?string { function utcToIso(?UTCDateTime $dt): ?string { if (!$dt) return null; // Mongo UTCDateTime -> DateTimeImmutable $d = $dt->toDateTime(); Loading @@ -33,7 +34,8 @@ function utcToIso(?UTCDateTime $dt): ?string { return $d->format('Y-m-d H:i:s') . ' UTC'; } function nowUtc(): DateTimeImmutable { function nowUtc(): DateTimeImmutable { return new DateTimeImmutable('now', new DateTimeZone('UTC')); } Loading @@ -55,8 +57,8 @@ if ($metaId !== '') { 'lastRetrievedAt' => 1, 'retrievedCount' => 1, // apzināti NEliekam: secret, displayToken, encrypted ] ] ], ], ); } Loading Loading @@ -97,7 +99,9 @@ $createdAtIso = $found ? utcToIso($doc['createdAt'] ?? null) : null; $displayedAtIso = $found ? utcToIso($doc['displayedAt'] ?? null) : null; $firstRetrievedAtIso = $found ? utcToIso($doc['firstRetrievedAt'] ?? null) : null; $lastRetrievedAtIso = $found ? utcToIso($doc['lastRetrievedAt'] ?? null) : null; $id = $found ? $doc['_id'] : null; $retrievedCount = $found ? (int)($doc['retrievedCount'] ?? 0) : 0; $encrypted = $found ? !empty($doc['encrypted']) : false; // (Optional) remaining time $remainingText = null; Loading @@ -122,10 +126,23 @@ if ($found && !$deleted && !$expired && isset($doc['expiresAt']) && $doc['expire <title>Noslēpuma statuss</title> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet"> <style> html { height: 100%; } body { min-height: 100%; display:flex; flex-direction:column; } .footer { margin-top:auto; } .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; } html { height: 100%; } body { min-height: 100%; display: flex; flex-direction: column; } .footer { margin-top: auto; } .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; } </style> </head> <body class="bg-light"> Loading Loading @@ -187,6 +204,14 @@ if ($found && !$deleted && !$expired && isset($doc['expiresAt']) && $doc['expire <div class="text-secondary small">Parādīts / izdzēsts</div> <div><?= htmlspecialchars($displayedAtIso ?? '-') ?></div> </div> <div class="col-12 col-md-6"> <div class="text-secondary small">Saite</div> <div><?= htmlspecialchars('https://' . $_SERVER['HTTP_HOST'] . '/' . $id) ?></div> </div> <div class="col-12 col-md-6"> <div class="text-secondary small">Kodēts</div> <div><?= htmlspecialchars($encrypted ? 'Jā' : 'Nē') ?></div> </div> </div> <div class="mt-4 alert alert-info mb-0"> Loading Loading
meta.php +49 −24 Original line number Diff line number Diff line Loading @@ -7,8 +7,8 @@ ini_set('display_errors', 1); require 'vendor/autoload.php'; use Dotenv\Dotenv; use MongoDB\Client; use MongoDB\BSON\UTCDateTime; use MongoDB\Client; $dotenv = Dotenv::createImmutable(__DIR__); $dotenv->load(); Loading @@ -25,7 +25,8 @@ $mongo = new Client($dsn); $db = $mongo->secretdb; $collection = $db->secrets; function utcToIso(?UTCDateTime $dt): ?string { function utcToIso(?UTCDateTime $dt): ?string { if (!$dt) return null; // Mongo UTCDateTime -> DateTimeImmutable $d = $dt->toDateTime(); Loading @@ -33,7 +34,8 @@ function utcToIso(?UTCDateTime $dt): ?string { return $d->format('Y-m-d H:i:s') . ' UTC'; } function nowUtc(): DateTimeImmutable { function nowUtc(): DateTimeImmutable { return new DateTimeImmutable('now', new DateTimeZone('UTC')); } Loading @@ -55,8 +57,8 @@ if ($metaId !== '') { 'lastRetrievedAt' => 1, 'retrievedCount' => 1, // apzināti NEliekam: secret, displayToken, encrypted ] ] ], ], ); } Loading Loading @@ -97,7 +99,9 @@ $createdAtIso = $found ? utcToIso($doc['createdAt'] ?? null) : null; $displayedAtIso = $found ? utcToIso($doc['displayedAt'] ?? null) : null; $firstRetrievedAtIso = $found ? utcToIso($doc['firstRetrievedAt'] ?? null) : null; $lastRetrievedAtIso = $found ? utcToIso($doc['lastRetrievedAt'] ?? null) : null; $id = $found ? $doc['_id'] : null; $retrievedCount = $found ? (int)($doc['retrievedCount'] ?? 0) : 0; $encrypted = $found ? !empty($doc['encrypted']) : false; // (Optional) remaining time $remainingText = null; Loading @@ -122,10 +126,23 @@ if ($found && !$deleted && !$expired && isset($doc['expiresAt']) && $doc['expire <title>Noslēpuma statuss</title> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet"> <style> html { height: 100%; } body { min-height: 100%; display:flex; flex-direction:column; } .footer { margin-top:auto; } .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; } html { height: 100%; } body { min-height: 100%; display: flex; flex-direction: column; } .footer { margin-top: auto; } .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; } </style> </head> <body class="bg-light"> Loading Loading @@ -187,6 +204,14 @@ if ($found && !$deleted && !$expired && isset($doc['expiresAt']) && $doc['expire <div class="text-secondary small">Parādīts / izdzēsts</div> <div><?= htmlspecialchars($displayedAtIso ?? '-') ?></div> </div> <div class="col-12 col-md-6"> <div class="text-secondary small">Saite</div> <div><?= htmlspecialchars('https://' . $_SERVER['HTTP_HOST'] . '/' . $id) ?></div> </div> <div class="col-12 col-md-6"> <div class="text-secondary small">Kodēts</div> <div><?= htmlspecialchars($encrypted ? 'Jā' : 'Nē') ?></div> </div> </div> <div class="mt-4 alert alert-info mb-0"> Loading