-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.php
140 lines (120 loc) · 6.29 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
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
<?php
if(isset($_GET["ready"])){
include_once("sql.php");
include_once("function.php");
$data = getMessage($connection,$_GET["id"],$_GET["password"]);
$data=htmlspecialchars($data);
$aaa= str_replace("\r\n","<br>",$data);
echo $aaa;
return ;
}
?>
<html>
<head>
<title>Bullet Secret Letter - NMQU.COM - Simple Encrypted Message Service</title>
<link rel="shortcut icon" href="https://blog.naixi.net/usr/nya/favicon.ico">
<link rel="stylesheet" href="./css/hack.css" />
<link rel="stylesheet" href="./css/dark-grey.css" />
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<meta itemprop="name" content="BSLHOME"/>
<meta itemprop="image" content="https://blog.naixi.net/usr/nya/logo_black.png" />
<meta name="description" itemprop="description" content="One-time encrypted message self-destruct after reading." />
<script src="js/clipboard.min.js"></script>
</head>
<body class="hack dark-grey">
<div class="main container">
<h1>Bullet Secret Letter</h1>
<h2>One-time encrypted message self-destruct after reading <a href="https://github.com/Nyarime/BulletSecretLetter">[Code]</a></h2>
<h2>how to use?</h2>
<ol>
<li>Click [Create Now!], Create a message and set a password</li>
<li>Copy the created link to whom you want to read the note</li>
<li>If the message is read, the message will self-destruct</li>
</ol>
<?php
include_once("sql.php");
include_once("function.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 = "https://".$_SERVER['HTTP_HOST']."/link.php?id=".$id_message."&password=".$password;
saveMessage($connection, $id_message, $_POST["message"],$password);
echo '<h2>Bullet Secret Letter link created:<button class="btn">Copy</button></h2><div class="alert alert-info">'.htmlspecialchars($message_link).'</div><h2>QRCode:Save the QR code to share with friends!</h2><div class="alert alert-info"><img src="https://api.naixi.net/qrcode/?m=3&e=H&p=3&text='.htmlspecialchars($message_link).'"></div><hr>The created link will be self-destructed after reading.<p>© 2024 <a href="https://naixi.net">Nyarime</a>. All Rights Reserved. <a href="https://nmqu.com/create.php">Create New Message</a> - <a href="https://github.com/Nyarime/BulletSecretLetter">GitHub</a></p>';
} else if (isset($_GET["id"])){
if (isset($_GET["password"])){
echo '<h2>Hey, you have a message:</h2><div id="warning" class="alert alert-info">****<br>*************<br>**********************</div>';
echo '<button type="submit" id="BSL" >Open it!</button>';
echo '<p> <p/>';
echo '<p>This message can only be read once after opening.</p>';
echo '<p>If you left after opening, this message will disappear forever!</p>';
echo '<p>© 2024 <a href="https://naixi.net">Nyarime</a>. All Rights Reserved. <a href="https://nmqu.com/create.php">Create New Message</a> - <a href="https://github.com/Nyarime/BulletSecretLetter">GitHub</a></p>';
} else {
$data = "Oops, this message password is missing!";
$data=htmlspecialchars($data);
echo '<h2>Hey, you have a message:</h2><div id="warning" class="alert alert-info">'.str_replace("\r\n","<br>",$data).'</div><hr>Warning! This message will be self-destructed after reading.<p>© 2024 <a href="https://naixi.net">Nyarime</a>. All Rights Reserved. <a href="https://nmqu.com/create.php">Create New Message</a> - <a href="https://github.com/Nyarime/BulletSecretLetter">GitHub</a></p>';
}
} else {
?>
<form method="get" action="/create.php">
<button type="submit" class="btn btn-primary btn-block">Create Now!</button>
</form>
<hr>
<h2>Tip: All messages are stored on NMQU.COM through AES256 algorithm, so you don't need to worry about information leakage.</h2>
<p>This project follows the MIT License, visit the <a href="https://github.com/Nyarime/BulletSecretLetter">GitHub</a> page.</p>
<p>© <?php echo date("Y");?> <a href="https://naixi.net">Nyarime</a>. All Rights Reserved. <a href="https://nmqu.com">NMQU.COM</a></p>
<?php
}
?>
</div>
</body>
<script>
var user = document.getElementById('BSL'); //获取用户控件
user.onclick = function () { //当用户离开当前文本框的时行验证
//1.创建Ajax对象
var xhr = new XMLHttpRequest();
//2.创建请求事件的监听
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == 200) {
var warning = document.getElementById('warning');
warning.innerHTML = xhr.responseText ;
document.getElementById('BSL').disabled = true;
//按钮 不可点
var change_cancel = document.getElementById("BSL");
change_cancel.style.display = "none";
//按钮 block可见 none 不可见
}
}
//3.初始化一个url请求
var user = document.getElementById('BSL').value;
//var password = document.getElementById('password').value;
// var data = 'icp='+user+'&password='+password; //生成post请求数据
var data = 'BSL='+user;
var url = window.location.href+"&ready=yes";
//var url = '/sms.php';
xhr.open('post',url,true); //请求类型为post,交互方式为异步
//4.设置请求头
xhr.setRequestHeader('content-type','application/x-www-form-urlencoded');
//5.发送url请求,需要传入参数
xhr.send(data);
}
</script>
<script>
var clipboard = new ClipboardJS('.btn', {
text: function() {
return "<?php echo($message_link) ?>";
}
});
clipboard.on('success', function(e) {
console.log(e);
alert("Copy messages link successfully!");
});
clipboard.on('error', function(e) {
console.log(e);
alert("The current browser does not support it, please copy the link manually.");
});
</script>
</html>