|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en"> |
| 3 | +<head> |
| 4 | + <meta charset="UTF-8"> |
| 5 | + <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 6 | + <title>PHP deserializer</title> |
| 7 | + <style> |
| 8 | + * { |
| 9 | + box-sizing: border-box; |
| 10 | + } |
| 11 | + |
| 12 | + body { |
| 13 | + font-family: Helvetica, Arial, sans-serif; |
| 14 | + line-height: 1.5; |
| 15 | + max-width: 800px; |
| 16 | + margin: 0 auto; |
| 17 | + padding: 1rem; |
| 18 | + } |
| 19 | + |
| 20 | + h1 { |
| 21 | + margin-top: 0; |
| 22 | + } |
| 23 | + |
| 24 | + textarea { |
| 25 | + width: 100%; |
| 26 | + min-height: 200px; |
| 27 | + margin-bottom: 1rem; |
| 28 | + padding: 0.5rem; |
| 29 | + border: 1px solid #ccc; |
| 30 | + border-radius: 4px; |
| 31 | + font-size: 16px; |
| 32 | + font-family: monospace; |
| 33 | + } |
| 34 | + |
| 35 | + button { |
| 36 | + background: #0066cc; |
| 37 | + color: white; |
| 38 | + border: none; |
| 39 | + padding: 0.5rem 1rem; |
| 40 | + border-radius: 4px; |
| 41 | + font-size: 16px; |
| 42 | + cursor: pointer; |
| 43 | + } |
| 44 | + |
| 45 | + button:disabled { |
| 46 | + background: #ccc; |
| 47 | + cursor: not-allowed; |
| 48 | + } |
| 49 | + |
| 50 | + .error { |
| 51 | + color: #cc0000; |
| 52 | + background: #ffebeb; |
| 53 | + padding: 1rem; |
| 54 | + border-radius: 4px; |
| 55 | + margin-bottom: 1rem; |
| 56 | + display: none; |
| 57 | + } |
| 58 | + |
| 59 | + .output-container { |
| 60 | + display: none; |
| 61 | + margin-bottom: 1rem; |
| 62 | + } |
| 63 | + |
| 64 | + .copy-button { |
| 65 | + margin-bottom: 1rem; |
| 66 | + } |
| 67 | + </style> |
| 68 | +</head> |
| 69 | +<body> |
| 70 | + <h1>PHP deserializer</h1> |
| 71 | + <p>Paste serialized PHP data below to convert it to JSON</p> |
| 72 | + |
| 73 | + <textarea id="input" placeholder="Paste serialized PHP data here"></textarea> |
| 74 | + |
| 75 | + <div id="error" class="error"></div> |
| 76 | + |
| 77 | + <div id="output-container" class="output-container"> |
| 78 | + <button id="copy" class="copy-button">Copy JSON to clipboard</button> |
| 79 | + <textarea id="output" readonly></textarea> |
| 80 | + </div> |
| 81 | + |
| 82 | +<script type="module"> |
| 83 | +import * as phpSerialize from 'https://cdn.jsdelivr.net/npm/php-serialize@5.0.1/+esm' |
| 84 | + |
| 85 | +const input = document.getElementById('input') |
| 86 | +const output = document.getElementById('output') |
| 87 | +const error = document.getElementById('error') |
| 88 | +const copyButton = document.getElementById('copy') |
| 89 | +const outputContainer = document.getElementById('output-container') |
| 90 | + |
| 91 | +function updateOutput() { |
| 92 | + const serialized = input.value.trim() |
| 93 | + error.style.display = 'none' |
| 94 | + outputContainer.style.display = 'none' |
| 95 | + |
| 96 | + if (!serialized) { |
| 97 | + return |
| 98 | + } |
| 99 | + |
| 100 | + try { |
| 101 | + const parsed = phpSerialize.unserialize(serialized) |
| 102 | + const json = JSON.stringify(parsed, null, 2) |
| 103 | + output.value = json |
| 104 | + outputContainer.style.display = 'block' |
| 105 | + } catch (err) { |
| 106 | + error.textContent = `Error: ${err.message}` |
| 107 | + error.style.display = 'block' |
| 108 | + } |
| 109 | +} |
| 110 | + |
| 111 | +input.addEventListener('input', updateOutput) |
| 112 | + |
| 113 | +copyButton.addEventListener('click', async () => { |
| 114 | + try { |
| 115 | + await navigator.clipboard.writeText(output.value) |
| 116 | + const originalText = copyButton.textContent |
| 117 | + copyButton.textContent = 'Copied!' |
| 118 | + copyButton.disabled = true |
| 119 | + setTimeout(() => { |
| 120 | + copyButton.textContent = originalText |
| 121 | + copyButton.disabled = false |
| 122 | + }, 2000) |
| 123 | + } catch (err) { |
| 124 | + error.textContent = `Error copying to clipboard: ${err.message}` |
| 125 | + error.style.display = 'block' |
| 126 | + } |
| 127 | +}) |
| 128 | +</script> |
| 129 | +</body> |
| 130 | +</html> |
0 commit comments