-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
90 lines (76 loc) · 2.98 KB
/
index.php
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
<?php
global $pdo;
require_once 'common.php';
if (isset($_GET['read'])) {
$uuid = $_GET['read'];
$secret = get_secret($uuid, false);
$secret_url = get_url("?uuid=$uuid");
$sharing_url = get_url("?read=$uuid");
if ($secret) { ?>
<div class="row">
<div class="col-md-8 offset-md-2 text-center">
<h1><?php echo $uuid; ?></h1>
<p>Click to see the secret: <a href="<?php echo $secret_url; ?>"><?php echo $secret_url; ?></a>.</p>
<button id="copy-button" class="btn btn-sm btn-success" onclick="copyUrl()">
<span id="copy-link"><i class="bi bi-copy me-2"></i>Copy Secret Link</span>
<span id="link-copied" class="d-none"><i class="bi bi-check me-2"></i>Secret Link Copied</span>
</button>
<script>
function copyUrl () {
navigator.clipboard.writeText(<?php echo json_encode($sharing_url); ?>)
.then(() => {
document.getElementById('copy-link').classList.add('d-none');
document.getElementById('link-copied').classList.remove('d-none');
document.getElementById('copy-button').disabled = true;
});
}
</script>
<hr>
<p class="small text-muted mb-1">(Remember: If you open the secret, it will instantly disappear)</p>
<p class="small text-muted">
Remaining time: <code><?php echo get_remaining_time($secret['createdAt'], $secret['expiry']); ?></code>
</p>
</div>
</div>
<?php
} else {
echo get_template('not-found');
}
echo get_template('footer');
exit;
}
if (isset($_GET['uuid'])) {
$uuid = $_GET['uuid'];
if (!is_valid_uuidv4($uuid)) {
echo get_template('not-found');
echo get_template('footer');
exit;
}
$secret = get_secret($uuid, true);
if ($secret) { ?>
<div class="row">
<div class="col-md-8 offset-md-2">
<h1 class="text-center"><?php echo $uuid; ?></h1>
<h2 class="h5 small text-muted text-center">(This will only be shown once)</h2>
<label style="display: none" for="theSecret">Secret Contents:</label>
<textarea id="theSecret" class="form-control mt-4" rows="3"><?php echo $secret['value']; ?></textarea>
</div>
</div>
<script type="application/javascript">
const jsConfetti = new JSConfetti();
jsConfetti.addConfetti({emojis: ['💥', '🦵', '💣', '🤯']});
</script>
<?php
} else {
echo get_template('not-found');
}
echo get_template('footer');
exit;
}
if (!is_allowed()) {
echo get_template('not-authorised');
echo get_template('footer');
exit;
}
echo get_template('new-secret');
echo get_template('footer');