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