Loading index.php +14 −15 Original line number Diff line number Diff line Loading @@ -251,7 +251,7 @@ header('X-Robots-Tag: noindex, nofollow'); } const decryptBtn = document.getElementById('decryptBtn'); let secretResponse = null; let result = null; decryptBtn.addEventListener('click', async () => { const passphrase = document.getElementById('decryptPassphrase').value.trim(); Loading @@ -259,9 +259,7 @@ header('X-Robots-Tag: noindex, nofollow'); decryptBtn.disabled = true; try { // IMPORTANT: ideally this should be a POST that only "consumes" on purpose. let result; if (!secretResponse) { if (!result) { const response = await fetch(`/secret-api.php?id=${encodeURIComponent(id)}&retrieve`, { method: 'POST', headers: {'Content-Type': 'application/json'}, Loading @@ -269,9 +267,6 @@ header('X-Robots-Tag: noindex, nofollow'); }); result = await response.json().catch(() => ({})); } else { result = secretResponse; } // Generic failure (don’t reveal if id exists) if (!response.ok || !result || !result.secret) { Loading @@ -281,6 +276,7 @@ header('X-Robots-Tag: noindex, nofollow'); '<p class="mb-0">Neizdevās atvērt noslēpumu. Iespējams, tā termiņš ir beidzies vai saite nav pareiza.</p>'; return; } } // If secret is encrypted, require passphrase if (result.encrypted && !passphrase) { Loading @@ -293,6 +289,8 @@ header('X-Robots-Tag: noindex, nofollow'); ? await decryptMessage(result.secret, passphrase) : result.secret; document.getElementById('decryptedTextContainer').style.display = 'block'; document.getElementById('decryptBtn').style.display = 'none'; document.getElementById('passphrase-input-block').style.display = 'none'; } catch { alert('Nesanāca atkodēt 😬. Pārbaudi, vai burvju vārds ir pareizs 🔐🧙!'); } Loading @@ -306,7 +304,8 @@ header('X-Robots-Tag: noindex, nofollow'); decryptBtn.disabled = false; } }); }); }) ; </script> <div class="modal fade" id="infoModal" tabindex="-1" aria-labelledby="infoModalLabel" aria-hidden="true"> <div class="modal-dialog modal-lg modal-dialog-scrollable"> Loading Loading
index.php +14 −15 Original line number Diff line number Diff line Loading @@ -251,7 +251,7 @@ header('X-Robots-Tag: noindex, nofollow'); } const decryptBtn = document.getElementById('decryptBtn'); let secretResponse = null; let result = null; decryptBtn.addEventListener('click', async () => { const passphrase = document.getElementById('decryptPassphrase').value.trim(); Loading @@ -259,9 +259,7 @@ header('X-Robots-Tag: noindex, nofollow'); decryptBtn.disabled = true; try { // IMPORTANT: ideally this should be a POST that only "consumes" on purpose. let result; if (!secretResponse) { if (!result) { const response = await fetch(`/secret-api.php?id=${encodeURIComponent(id)}&retrieve`, { method: 'POST', headers: {'Content-Type': 'application/json'}, Loading @@ -269,9 +267,6 @@ header('X-Robots-Tag: noindex, nofollow'); }); result = await response.json().catch(() => ({})); } else { result = secretResponse; } // Generic failure (don’t reveal if id exists) if (!response.ok || !result || !result.secret) { Loading @@ -281,6 +276,7 @@ header('X-Robots-Tag: noindex, nofollow'); '<p class="mb-0">Neizdevās atvērt noslēpumu. Iespējams, tā termiņš ir beidzies vai saite nav pareiza.</p>'; return; } } // If secret is encrypted, require passphrase if (result.encrypted && !passphrase) { Loading @@ -293,6 +289,8 @@ header('X-Robots-Tag: noindex, nofollow'); ? await decryptMessage(result.secret, passphrase) : result.secret; document.getElementById('decryptedTextContainer').style.display = 'block'; document.getElementById('decryptBtn').style.display = 'none'; document.getElementById('passphrase-input-block').style.display = 'none'; } catch { alert('Nesanāca atkodēt 😬. Pārbaudi, vai burvju vārds ir pareizs 🔐🧙!'); } Loading @@ -306,7 +304,8 @@ header('X-Robots-Tag: noindex, nofollow'); decryptBtn.disabled = false; } }); }); }) ; </script> <div class="modal fade" id="infoModal" tabindex="-1" aria-labelledby="infoModalLabel" aria-hidden="true"> <div class="modal-dialog modal-lg modal-dialog-scrollable"> Loading