forked from ArtezzaIT/Sharkphin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.html
More file actions
364 lines (352 loc) · 15.7 KB
/
Copy pathapp.html
File metadata and controls
364 lines (352 loc) · 15.7 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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
<html>
<head>
<title>Sharkphin</title>
<style>
body {
background-image: url("/background.jpg");
}
div {
display: table; /* Makes the div only as wide as its content */
background-color: rgba(249, 249, 249, 0.8); /* Slightly transparent background */
border: 1px solid #ccc;
padding: 10px;
border-radius: 5px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}
</style>
</head>
<body>
<div>
<h1>Connection Information</h1>
You are connected using ##UPN##
<a href="/logout">Logout</a>
<br>
<label><input type="checkbox" id="advanced" name="advanced"> Use Advanced Options</label>
<br>
</div>
<br>
<div>
<h1>Block Sender or Attachment</h1>
<form action="/block" method="get">
<table>
<tr>
<td>
<label for="blockitem">Email Address, Email Domain, or SHA256 File Hash:</label>
</td>
<td>
<input type="text" id="blockitem" name="blockitem" required>
</td>
</tr>
<tr>
<td colspan="2">
<button type="submit">Block Sender or File</button>
</td>
</tr>
</table>
</form>
</div>
<br>
<div>
<h1>Create New Search</h1>
<form action="/search" method="get">
<table>
<tr>
<td>
<label for="name">Search Name:</label>
</td>
<td>
<input type="text" id="name" name="name" required>
</td>
</tr>
<tr>
<td>
<label for="sender">Sender Address:</label>
</td>
<td>
<input type="text" id="sender" name="sender" required>
</td>
</tr>
<tr>
<td>
<label for="subject">Message Subject:</label>
</td>
<td>
<input type="text" id="subject" name="subject" required>
</td>
</tr>
<tr>
<td colspan="2">
<button type="submit">Create Search</button>
</td>
</tr>
</table>
</form>
<label style="display:none; color:white; background:red; font-weight:bold; border-radius:5px; padding:2px 6px;"><input type="checkbox" id="nosubjectsearch" name="nosubjectsearch"> Create search without a subject</label>
</div>
<br>
<div>
<h1>Existing Searches</h1>
<p>Search data is updated automatically. Thank you for your patience.</p>
<table id="AllSearches">
<tr>
<th>Name</th>
<th>Items</th>
<th>Status</th>
<th>Actions</th>
</tr>
</table>
</div>
<script>
async function updateSearchStatus() {
try {
const response = await fetch('/searchstatus');
console.log('Response:', response);
const data = await response.json();
console.log(data);
const table = document.getElementById('AllSearches');
// Clear existing rows except the header
table.innerHTML = `
<tr>
<th>Name</th>
<th>Items</th>
<th>Status</th>
<th>Actions</th>
</tr>
`;
if (Array.isArray(data)) {
data.forEach(search => {
const row = table.insertRow();
row.insertCell(0).textContent = search.Name;
row.insertCell(1).textContent = search.Items;
row.insertCell(2).textContent = search.Status;
const actionsCell = row.insertCell(3);
//Delete button
const deleteButton = document.createElement('button');
deleteButton.textContent = 'Remove Search';
deleteButton.onclick = () => deleteSearch(search.Name);
actionsCell.appendChild(deleteButton);
//Purge button
const purgeButton = document.createElement('button');
purgeButton.textContent = 'Purge';
purgeButton.onclick = () => purgeSearch(search.Name);
actionsCell.appendChild(purgeButton);
//Restart button
const restartButton = document.createElement('button');
restartButton.textContent = 'Restart';
restartButton.onclick = () => restartSearch(search.Name);
actionsCell.appendChild(restartButton);
//Hard Delete button
if (document.getElementById('advanced')?.checked) {
const hardDeleteButton = document.createElement('button');
hardDeleteButton.textContent = 'Hard Delete';
hardDeleteButton.style.backgroundColor = 'red';
hardDeleteButton.style.color = 'white';
hardDeleteButton.onclick = () => hardDelete(search.Name);
actionsCell.appendChild(hardDeleteButton);
}
});
} else if (typeof data === 'object' && data !== null) {
if (data.Message) {
const row = table.insertRow();
row.insertCell(0).textContent = data.Message;
} else {
const row = table.insertRow();
row.insertCell(0).textContent = data.Name;
row.insertCell(1).textContent = data.Items;
row.insertCell(2).textContent = data.Status;
const actionsCell = row.insertCell(3);
//Delete button
const deleteButton = document.createElement('button');
deleteButton.textContent = 'Remove Search';
deleteButton.onclick = () => deleteSearch(data.Name);
actionsCell.appendChild(deleteButton);
//Purge button
const purgeButton = document.createElement('button');
purgeButton.textContent = 'Purge Items';
purgeButton.onclick = () => purgeSearch(data.Name);
actionsCell.appendChild(purgeButton);
//Restart button
const restartButton = document.createElement('button');
restartButton.textContent = 'Refresh Search';
restartButton.onclick = () => restartSearch(data.Name);
actionsCell.appendChild(restartButton);
//Hard Delete button
if (document.getElementById('advanced')?.checked) {
const hardDeleteButton = document.createElement('button');
hardDeleteButton.textContent = 'Hard Delete';
hardDeleteButton.style.backgroundColor = 'red';
hardDeleteButton.style.color = 'white';
hardDeleteButton.onclick = () => hardDelete(search.Name);
actionsCell.appendChild(hardDeleteButton);
}
}
}
} catch (error) {
console.error('Error fetching search status:', error);
}
}
function deleteSearch(name) {
if (!confirm(`Are you sure you want to delete the search "${name}"?`)) {
return;
}
const loadingMessage = document.createElement('div');
loadingMessage.textContent = 'Deleting search, please wait...';
loadingMessage.style.position = 'fixed';
loadingMessage.style.top = '10px';
loadingMessage.style.left = '50%';
loadingMessage.style.transform = 'translateX(-50%)';
loadingMessage.style.backgroundColor = '#db31f5';
loadingMessage.style.border = '1px solid #ccc';
loadingMessage.style.padding = '10px';
loadingMessage.style.borderRadius = '5px';
loadingMessage.style.boxShadow = '0 2px 5px rgba(0, 0, 0, 0.2)';
document.body.appendChild(loadingMessage);
setTimeout(() => {
document.body.removeChild(loadingMessage);
}, 3000);
fetch(`/delete?name=${encodeURIComponent(name)}`)
.then(response => response.text())
.then(data => {
alert(data);
console.log(data);
})
.catch(error => {
alert('Error deleting search:', error);
console.log(data);
});
console.log('Delete search with id:', name);
updateSearchStatus();
}
function purgeSearch(name) {
if (!confirm(`Are you sure you want to purge the search "${name}"?`)) {
return;
}
const loadingMessage = document.createElement('div');
loadingMessage.textContent = 'Purging search, please wait...';
loadingMessage.style.position = 'fixed';
loadingMessage.style.top = '10px';
loadingMessage.style.left = '50%';
loadingMessage.style.transform = 'translateX(-50%)';
loadingMessage.style.backgroundColor = '#db31f5';
loadingMessage.style.border = '1px solid #ccc';
loadingMessage.style.padding = '10px';
loadingMessage.style.borderRadius = '5px';
loadingMessage.style.boxShadow = '0 2px 5px rgba(0, 0, 0, 0.2)';
document.body.appendChild(loadingMessage);
setTimeout(() => {
document.body.removeChild(loadingMessage);
}, 3000);
fetch(`/purge?name=${encodeURIComponent(name)}`)
.then(response => response.text())
.then(data => {
alert(data);
console.log(data);
})
.catch(error => {
alert('Error purging search:', error);
console.log(data);
});
console.log('Purge search with id:', name);
updateSearchStatus();
}
function restartSearch(name) {
const loadingMessage = document.createElement('div');
loadingMessage.textContent = 'Restarting search, please wait...';
loadingMessage.style.position = 'fixed';
loadingMessage.style.top = '10px';
loadingMessage.style.left = '50%';
loadingMessage.style.transform = 'translateX(-50%)';
loadingMessage.style.backgroundColor = '#db31f5';
loadingMessage.style.border = '1px solid #ccc';
loadingMessage.style.padding = '10px';
loadingMessage.style.borderRadius = '5px';
loadingMessage.style.boxShadow = '0 2px 5px rgba(0, 0, 0, 0.2)';
document.body.appendChild(loadingMessage);
setTimeout(() => {
document.body.removeChild(loadingMessage);
}, 3000);
fetch(`/restart?name=${encodeURIComponent(name)}`)
.then(response => response.text())
.then(data => {
alert(data);
console.log(data);
})
.catch(error => {
alert('Error restarting search:', error);
console.log(data);
});
console.log('Restarting search with id:', name);
updateSearchStatus();
}
function hardDelete(name) {
if (!confirm(`Are you sure you want to PERMANENTLY DELETE ALL ITEMS in the search "${name}"?`)) {
return;
}
const loadingMessage = document.createElement('div');
loadingMessage.textContent = 'Purging search (hard delete), please wait...';
loadingMessage.style.position = 'fixed';
loadingMessage.style.top = '10px';
loadingMessage.style.left = '50%';
loadingMessage.style.transform = 'translateX(-50%)';
loadingMessage.style.backgroundColor = '#db31f5';
loadingMessage.style.border = '1px solid #ccc';
loadingMessage.style.padding = '10px';
loadingMessage.style.borderRadius = '5px';
loadingMessage.style.boxShadow = '0 2px 5px rgba(0, 0, 0, 0.2)';
document.body.appendChild(loadingMessage);
setTimeout(() => {
document.body.removeChild(loadingMessage);
}, 3000);
fetch(`/harddelete?name=${encodeURIComponent(name)}`)
.then(response => response.text())
.then(data => {
alert(data);
console.log(data);
})
.catch(error => {
alert('Error purging search:', error);
console.log(data);
});
console.log('Purge search with id:', name);
updateSearchStatus();
}
setTimeout(() => {
updateSearchStatus();
setInterval(updateSearchStatus, 60000);
}, 5000);
document.getElementById('advanced').addEventListener('change', function() {
const subjectInput = document.getElementById('subject');
const noSubjectLabel = document.getElementById('nosubjectsearch').closest('label');
if (this.checked) {
//Open the wiki page in a new tab for Advanced Options use and warnings
window.open('https://github.com/ArtezzaIT/Sharkphin/wiki/Advanced-Options', '_blank');
// Show the no-subject checkbox when advanced options are enabled
if (noSubjectLabel) {
noSubjectLabel.style.display = 'block';
}
} else {
//Re-enable subject input when advanced options are unchecked
subjectInput.disabled = false;
subjectInput.setAttribute('required', '');
//Hide the nosubjectsearch checkbox when advanced options is unchecked
document.getElementById('nosubjectsearch').checked = false;
if (noSubjectLabel) {
noSubjectLabel.style.display = 'none';
}
}
});
document.getElementById('nosubjectsearch').addEventListener('change', function() {
const subjectInput = document.getElementById('subject');
if (this.checked) {
//Disable subject input in the GUI
subjectInput.value = '';
subjectInput.removeAttribute('required');
subjectInput.disabled = true;
}else {
//Re-enable subject input when advanced options are unchecked
subjectInput.disabled = false;
subjectInput.setAttribute('required', '');
}
});
</script>
</body>