forked from AndrewPaglusch/FlashPaper
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
76 lines (62 loc) · 1.95 KB
/
index.php
File metadata and controls
76 lines (62 loc) · 1.95 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
<?php
#Settings
define('RETURN_FULL_URL', true);
define('MAX_INPUT_LENGTH', 3000);
define('_DIRECT_ACCESS_CHECK', 1);
require_once "includes/functions.php";
include('html/header.php');
if (isset($_GET['k'])) {
#**User is trying to view a secret**
if (isset($_GET['accept']) && $_GET['accept'] == "true") {
try {
$secret = retrieve_secret($_GET['k']);
$message = htmlentities($secret);
$message_title = "Self-Destructing Message";
$message_subtitle = "This message has been destroyed";
include('html/message.php');
} catch (Exception $e) {
$error_message = $e->getMessage();
include('html/error.php');
}
} else {
#This is to prevent 'preview bots' from automatically viewing the secret and thus destroying it
include('html/confirm.php');
}
} elseif (isset($_POST['submit'])) {
#**User just submitted a secret. Show them the generated URL**
try {
$incoming_text = $_POST['secret'];
if ( strlen($incoming_text) > constant('MAX_INPUT_LENGTH') ) {
throw new exception("Input length too long");
}
$k = store_secret($incoming_text);
if (constant('RETURN_FULL_URL') == true) {
$message = $_SERVER['REQUEST_SCHEME'] . "://" . $_SERVER['HTTP_HOST'] . "/?k=" . $k;
} else {
$message = $k;
}
$message_title = "Self-Destructing URL";
$message_subtitle = "";
include('html/message.php');
} catch (Exception $e) {
$error_message = $e->getMessage();
include('html/error.php');
}
} else {
#**User is loading the main page**
#Get template from URL (if any)
$template_text = "";
try {
if (isset($_GET['t']) && $_GET['t'] != "") {
$template_text = file_get_contents('templates/' . basename($_GET['t'] . '.txt'));
}
$message_title = "Self-Destructing Message";
$message_subtitle = "";
include('html/form.php');
} catch (Exception $e) {
$error_message = "Template can not be found!";
include('html/error.php');
}
}
include('html/footer.php');
?>