-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqr.php
More file actions
187 lines (160 loc) · 3.73 KB
/
Copy pathqr.php
File metadata and controls
187 lines (160 loc) · 3.73 KB
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
<?php
// Initialize DB if not exists
$dbFile = 'db.json';
if (!file_exists($dbFile)) file_put_contents($dbFile, json_encode([]));
$shortUrl = '';
$message = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$url = trim($_POST['url'] ?? '');
$name = trim($_POST['name'] ?? '');
if (filter_var($url, FILTER_VALIDATE_URL)) {
$data = json_decode(file_get_contents($dbFile), true);
$code = substr(str_shuffle(md5(uniqid())), 0, 6);
$data[$code] = [
'url' => $url,
'name' => $name,
'created' => gmdate('c'),
];
file_put_contents($dbFile, json_encode($data, JSON_PRETTY_PRINT));
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http';
$host = $_SERVER['HTTP_HOST'];
$path = rtrim(dirname($_SERVER['PHP_SELF']), '/');
$shortUrl = "$protocol://$host$path/u.php?c=$code"; // change if you want to use subfolder
} else {
$message = 'Invalid URL.';
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Dynamic QR Link Generator</title>
<style>
@keyframes animateBackground {
0% {
background-position: 0% 0%;
}
50% {
background-position: 100% 100%;
}
100% {
background-position: 0% 0%;
}
}
body {
font-family: sans-serif;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
align-items: center;
height: 100vh;
overflow: hidden;
background: radial-gradient(circle, #000000, #333333, #606060);
background-size: 300% 300%; /* Enlarging gradient for smoother shifts */
animation: animateBackground 60s infinite alternate ease-in-out;
}
a {
color: white;
}
a:hover{
color: black;
background: white;
}
form {
text-align: center;
font-size: 2em;
z-index: 2;
}
input[type="text"] {
width: 600px;
height: 2.5em;
margin: 0.5em 0;
z-index: 2;
}
label {
display: block;
margin-bottom: 1em;
color: #ffffff;
font-size: 1.2em;
text-align: left;
max-width: 600px;
margin-left: auto;
margin-right: auto;
}
button {
padding: 0.1em 0.5em;
z-index: 2;
// font-size: 2em;
}
button {
background-color: #333;
border: none;
color: white;
padding: 0.4em 1em; /* More touch-friendly */
font-size: 1.5em; /* Still large but more balanced */
margin: 1em 0;
border-radius: 6px; /* Optional: makes it look more modern */
cursor: pointer;
z-index: 2;
transition: background-color 0.3s ease, color 0.3s ease;
}
button:hover {
background-color: white;
color: #333;
}
h1 {
margin-bottom: 1em;
z-index: 2;
}
h2 {
font-size: 2.5em;
color: white;
margin-bottom: 0.5em;
z-index: 2;
}
.form-wrapper {
background: rgba(0, 0, 0, 0.5);
padding: 4em;
border-radius: 12px;
max-width: 700px;
width: 90%;
text-align: center;
position: relative;
z-index: 2;
margin-top: auto;
margin-bottom: auto;
}
body {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
</style>
</head>
<body>
<div class="form-wrapper">
<h2>Dynamic QR Link Generator</h2><br>
<br>
<br>
<form method="POST">
<label>
URL to shorten:<br>
<input type="text" name="url" placeholder="https://safienalbum.com" required>
</label>
<label>
Name or label (optional):<br>
<input type="text" name="name" placeholder="My special Link">
</label><br>
<button type="submit">Generate</button>
</form>
</div>
<?php if ($shortUrl): ?>
<p>✅ Short URL: <a href="<?= htmlspecialchars($shortUrl) ?>"><?= htmlspecialchars($shortUrl) ?></a></p>
<?php elseif ($message): ?>
<p style="color:red;">❌ <?= $message ?></p>
<?php endif; ?>
</body>
</html>