-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathindex.php
More file actions
59 lines (56 loc) · 2.02 KB
/
index.php
File metadata and controls
59 lines (56 loc) · 2.02 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
<html>
<head>
<link rel="stylesheet" href="./css/hack.css" />
<link rel="stylesheet" href="./css/dark-grey.css" />
</head>
<body class="hack dark-grey">
<div class="main container">
<h1>private Note</h1>
<?php
include_once("sql.php");
include_once("func.php");
if (isset($_POST["message"],$_POST["password"])){
$id_message = rtrim(base64_encode(md5(microtime())),"=");
$password = $_POST["password"];
if ($password==""){
$password=rtrim(base64_encode(microtime()),"=");
}
$message_link = "http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."?id=".$id_message."&password=".$password;
saveMessage($connection, $id_message, $_POST["message"],$password);
echo '<h2>Note link ready</h2><div class="alert alert-info">'.htmlspecialchars($message_link).'</div><hr>The note will self-destruct after reading it.';
} else if (isset($_GET["id"])){
if (isset($_GET["password"])){
$data = getMessage($connection,$_GET["id"],$_GET["password"]);
} else {
$data = "parameter Password not set";
}
$data=htmlspecialchars($data);
echo '<div class="alert alert-info">'.str_replace("\r\n","<br>",$data).'</div>';
} else {
?>
<h2>New note</h2>
<form class="form" action="." method="post">
<fieldset class="form-group form-textarea">
<label for="message">MESSAGE:</label>
<textarea name="message" rows="10" placeholder="Write your note here..." class="form-control" required></textarea>
</fieldset>
<fieldset class="form-group">
<label for="password">PASSWORD:</label>
<input name="password" type="text" class="form-control">
</fieldset>
<div class="form-actions">
<button type="submit" class="btn btn-primary btn-block">Submit</button>
</div>
</form>
<hr>
<ol>
<li>Create a note and get a link</li>
<li>Copy the link and send it to whom you want to read the note</li>
<li>The note will self-destruct after being read</li>
</ol>
<?php
}
?>
</div>
</body>
</html>