mirror of
https://github.com/whoswhip/Sharpbin.git
synced 2026-12-06 02:48:43 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ae3b96d7e0 | ||
|
|
6e95ae595a | ||
|
|
517a82d058 | ||
|
|
46615aba5b | ||
|
|
59c609e7c1 | ||
|
|
ada51d5c56 | ||
|
|
c158cde86d | ||
|
|
38d25d785e | ||
|
|
410172f922 | ||
|
|
b872de29d2 | ||
|
|
c90bd84ad7 | ||
|
|
eb542342c9 | ||
|
|
92f1ef1dbf | ||
|
|
553b1a12db | ||
|
|
bdcc3a1dc6 | ||
|
|
c28b9b92b1 | ||
|
|
0d5fd3bc5d | ||
|
|
ab04010c30 | ||
|
|
49f8911be2 | ||
|
|
eb21e6d662 | ||
|
|
233b338f9b |
@@ -0,0 +1,62 @@
|
||||
using System.IO.Compression;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Sharpbin
|
||||
{
|
||||
public class Compression
|
||||
{
|
||||
public static async Task<byte[]> CompressString(string text)
|
||||
{
|
||||
byte[] compressedBytes;
|
||||
using (var ms = new MemoryStream())
|
||||
{
|
||||
using (var cs = new GZipStream(ms, CompressionMode.Compress))
|
||||
{
|
||||
byte[] inputBytes = Encoding.UTF8.GetBytes(text);
|
||||
await cs.WriteAsync(inputBytes, 0, inputBytes.Length);
|
||||
}
|
||||
compressedBytes = ms.ToArray();
|
||||
}
|
||||
return compressedBytes;
|
||||
}
|
||||
|
||||
public static async Task<string> DecompressByteArrayToString(byte[] compressedBytes)
|
||||
{
|
||||
string decompressedText;
|
||||
using (var ms = new MemoryStream(compressedBytes))
|
||||
{
|
||||
using (var cs = new GZipStream(ms, CompressionMode.Decompress))
|
||||
{
|
||||
using (var sr = new StreamReader(cs))
|
||||
{
|
||||
decompressedText = await sr.ReadToEndAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
return decompressedText;
|
||||
}
|
||||
|
||||
public static async Task<byte[]> DecompressByteArray(byte[] compressedBytes)
|
||||
{
|
||||
byte[] decompressedBytes;
|
||||
using (var ms = new MemoryStream(compressedBytes))
|
||||
{
|
||||
using (var cs = new GZipStream(ms, CompressionMode.Decompress))
|
||||
{
|
||||
using (var msDecompressed = new MemoryStream())
|
||||
{
|
||||
await cs.CopyToAsync(msDecompressed);
|
||||
decompressedBytes = msDecompressed.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
return decompressedBytes;
|
||||
}
|
||||
|
||||
public static bool IsCompressed(byte[] data)
|
||||
{
|
||||
return data.Length >= 2 && data[0] == 0x1F && data[1] == 0x8B;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,31 @@ namespace Sharpbin
|
||||
|
||||
return Convert.ToBase64String(encryptedBytes);
|
||||
}
|
||||
public static string EncryptByteArray(byte[] bytes, string password)
|
||||
{
|
||||
byte[] encryptedBytes;
|
||||
|
||||
using (Aes aes = Aes.Create())
|
||||
{
|
||||
aes.KeySize = 256;
|
||||
aes.Key = Encoding.UTF8.GetBytes(password.PadRight(32, ' '));
|
||||
aes.IV = new byte[16];
|
||||
|
||||
ICryptoTransform encryptor = aes.CreateEncryptor(aes.Key, aes.IV);
|
||||
|
||||
using (var ms = new MemoryStream())
|
||||
{
|
||||
using (var cs = new CryptoStream(ms, encryptor, CryptoStreamMode.Write))
|
||||
{
|
||||
cs.Write(bytes, 0, bytes.Length);
|
||||
}
|
||||
|
||||
encryptedBytes = ms.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
return Convert.ToBase64String(encryptedBytes);
|
||||
}
|
||||
|
||||
public static string DecryptString(string input, string password)
|
||||
{
|
||||
@@ -59,5 +84,29 @@ namespace Sharpbin
|
||||
|
||||
return decryptedText;
|
||||
}
|
||||
public static byte[] DecryptByteArray(byte[] input, string password)
|
||||
{
|
||||
byte[] decryptedBytes;
|
||||
|
||||
using (Aes aes = Aes.Create())
|
||||
{
|
||||
aes.KeySize = 256;
|
||||
aes.Key = Encoding.UTF8.GetBytes(password.PadRight(32, ' '));
|
||||
aes.IV = new byte[16];
|
||||
|
||||
ICryptoTransform decryptor = aes.CreateDecryptor(aes.Key, aes.IV);
|
||||
|
||||
using (var ms = new MemoryStream(input))
|
||||
{
|
||||
using (var cs = new CryptoStream(ms, decryptor, CryptoStreamMode.Read))
|
||||
{
|
||||
decryptedBytes = new byte[ms.Length];
|
||||
cs.Read(decryptedBytes, 0, decryptedBytes.Length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return decryptedBytes;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+26
-2
@@ -1,8 +1,9 @@
|
||||
namespace Sharpbin
|
||||
using Org.BouncyCastle.Asn1.Cms;
|
||||
|
||||
namespace Sharpbin
|
||||
{
|
||||
public class Logging
|
||||
{
|
||||
public static string Api_CreateMessage = "";
|
||||
public static async Task<Log> LogRequestAsync(HttpContext context)
|
||||
{
|
||||
Log log = new Log();
|
||||
@@ -14,6 +15,29 @@
|
||||
log.IP = context.Request.Headers["X-Forwarded-For"].ToString() ?? context.Connection.RemoteIpAddress.ToString();
|
||||
return log;
|
||||
}
|
||||
public static async Task LogError(string message)
|
||||
{
|
||||
Console.BackgroundColor = ConsoleColor.Red;
|
||||
Console.ForegroundColor = ConsoleColor.White;
|
||||
Console.WriteLine($"[ERROR - {DateTime.Now}] {message}");
|
||||
await File.AppendAllTextAsync("logs.log", $"[ERROR - {DateTime.Now}] {message}\n");
|
||||
Console.ResetColor();
|
||||
}
|
||||
public static async Task LogInfo(string message)
|
||||
{
|
||||
Console.WriteLine($"[INFO - {DateTime.Now}] {message}");
|
||||
await File.AppendAllTextAsync("logs.log", $"[INFO - {DateTime.Now}] {message}\n");
|
||||
Console.ResetColor();
|
||||
}
|
||||
public static async Task LogWarning(string message)
|
||||
{
|
||||
Console.BackgroundColor = ConsoleColor.Yellow;
|
||||
Console.ForegroundColor = ConsoleColor.Black;
|
||||
Console.WriteLine($"[WARNING - {DateTime.Now}] {message}");
|
||||
await File.AppendAllTextAsync("logs.log", $"[WARNING - {DateTime.Now}] {message}\n");
|
||||
Console.ResetColor();
|
||||
}
|
||||
|
||||
}
|
||||
public class Log
|
||||
{
|
||||
|
||||
+596
-289
File diff suppressed because it is too large
Load Diff
@@ -49,7 +49,7 @@
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="pastes.sqlite">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
@@ -90,7 +90,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<Content Update="config.json">
|
||||
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
|
||||
namespace Sharpbin
|
||||
|
||||
@@ -153,7 +153,7 @@
|
||||
|
||||
}).then(response => response.json())
|
||||
.then(obj => {
|
||||
const result = JSON.parse(obj);
|
||||
const result = obj;
|
||||
if (result.message != null) {
|
||||
createNotification(`${result.message} for ${reason}`);
|
||||
} else {
|
||||
@@ -174,7 +174,7 @@
|
||||
|
||||
}).then(response => response.json())
|
||||
.then(obj => {
|
||||
const result = JSON.parse(obj);
|
||||
const result = obj;
|
||||
if (result.message != null) {
|
||||
createNotification(`${result.message} for ${reason}`);
|
||||
} else {
|
||||
@@ -199,7 +199,7 @@
|
||||
|
||||
}).then(response => response.json())
|
||||
.then(obj => {
|
||||
const result = JSON.parse(obj);
|
||||
const result = obj;
|
||||
if (result.message != null) {
|
||||
createNotification(`${result.message} to ${result.password}`);
|
||||
navigator.clipboard.writeText(result.password);
|
||||
|
||||
@@ -13,10 +13,13 @@
|
||||
<a href="/">home</a>
|
||||
<a href="/pastes">recent pastes</a>
|
||||
<a href="/archive">archive</a>
|
||||
{html}
|
||||
<a href="login" id="login-signup-btn" style="display: none;" >login</a>
|
||||
<a href="sign-up" id="login-signup-btn" style="display: none;">sign up</a>
|
||||
<a href="dash" id="dash-btn" style="display: none;">dashboard</a>
|
||||
</div>
|
||||
<div class="nav-hamburger-menu">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="56" height="56" fill="currentColor" class="bi bi-list" viewBox="0 0 16 16" id="hamburger-button" style="cursor: pointer;">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="56" height="56" fill="currentColor" class="bi bi-list"
|
||||
viewBox="0 0 16 16" id="hamburger-button" style="cursor: pointer;">
|
||||
<path fill-rule="evenodd"
|
||||
d="M2.5 12a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5m0-4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5m0-4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5" />
|
||||
</svg>
|
||||
@@ -24,7 +27,9 @@
|
||||
<a href="/">home</a>
|
||||
<a href="/pastes">recent pastes</a>
|
||||
<a href="/archive">archive</a>
|
||||
{html}
|
||||
<a href="login" id="login-signup-btn" style="display: none;" >login</a>
|
||||
<a href="sign-up" id="login-signup-btn" style="display: none;">sign up</a>
|
||||
<a href="dash" id="dash-btn" style="display: none;">dashboard</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container-wrapper">
|
||||
@@ -32,18 +37,73 @@
|
||||
<h1>paste archive</h1>
|
||||
<input type="text" placeholder="search" class="text-input" oninput="search()">
|
||||
<div class="pastes-wrapper">
|
||||
{pastes}
|
||||
Loading...
|
||||
</div>
|
||||
<div class="buttons-wrapper">
|
||||
<a class="arrow-button" href="/archive?page={backpagenum}"><</a>
|
||||
<p>{currentpagenum}/{totalpages}</p>
|
||||
<a class="arrow-button" href="/archive?page={pagenum}">></a>
|
||||
<a class="arrow-button" id="back-page"><</a>
|
||||
<p id="page-count"></p>
|
||||
<a class="arrow-button" id="next-page">></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<script>
|
||||
let searchTimeout;
|
||||
let pagenum = 1;
|
||||
|
||||
function authenticate() {
|
||||
fetch('/api/accounts/authenticate')
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.message == "Authenticated") {
|
||||
document.querySelectorAll("#login-signup-btn").forEach(element => {
|
||||
element.style.display = 'none';
|
||||
});
|
||||
document.getElementById('dash-btn').style.display = 'block';
|
||||
}else{
|
||||
document.querySelectorAll("#login-signup-btn").forEach(element => {
|
||||
element.style.display = 'block';
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function getPastes() {
|
||||
fetch(`/api/pastes/get`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
page: pagenum
|
||||
})
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
const pastesWrapper = document.querySelector('.pastes-wrapper');
|
||||
const pageCount = document.getElementById('page-count');
|
||||
pastesWrapper.innerHTML = '';
|
||||
pageCount.innerHTML = `${pagenum}/${data.pages}`;
|
||||
if (data.pastes.length === 0) {
|
||||
pastesWrapper.innerHTML = '<h1>no pastes found</h1>';
|
||||
return;
|
||||
}
|
||||
data.pastes.forEach(paste => {
|
||||
title = paste.title.length > 30 ? paste.title.substring(0, 30) + '...' : paste.title;
|
||||
pastesWrapper.innerHTML += `<a href="/${paste.id}" title="${paste.title}"><li>${title} ${paste.date} ${paste.size}</li></a>`;
|
||||
});
|
||||
});
|
||||
}
|
||||
document.getElementById('back-page').addEventListener('click', function () {
|
||||
if (pagenum > 1) {
|
||||
pagenum--;
|
||||
getPastes();
|
||||
}
|
||||
});
|
||||
document.getElementById('next-page').addEventListener('click', function () {
|
||||
pagenum++;
|
||||
getPastes();
|
||||
});
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
var mobile = window.mobileCheck();
|
||||
@@ -51,6 +111,8 @@
|
||||
document.querySelector('.nav-div').style.display = 'none';
|
||||
document.querySelector('.nav-hamburger-menu').style.display = 'flex';
|
||||
}
|
||||
authenticate();
|
||||
getPastes();
|
||||
});
|
||||
|
||||
document.getElementById("hamburger-button").addEventListener("click", function () {
|
||||
|
||||
@@ -84,11 +84,10 @@
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(obj => {
|
||||
const result = JSON.parse(obj);
|
||||
if (result.pasteId != null) {
|
||||
window.location.href = `/${result.pasteId}`;
|
||||
} else if (result.error != null) {
|
||||
notification(result.error);
|
||||
if (obj.pasteId != null) {
|
||||
window.location.href = `/${obj.pasteId}`;
|
||||
} else if (obj.error != null) {
|
||||
notification(obj.error);
|
||||
}
|
||||
})
|
||||
});
|
||||
@@ -309,6 +308,8 @@
|
||||
border: #2a2a2a00 2px solid;
|
||||
cursor: pointer;
|
||||
font-size: 1.2em;
|
||||
font-family: "Noto Sans Mono", "Consolas", "SF Mono", monospace;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.button:hover {
|
||||
@@ -319,7 +320,7 @@
|
||||
|
||||
.nav-div {
|
||||
top: 0;
|
||||
margin-top: 10px;
|
||||
margin-top: 1.5px;
|
||||
position: absolute;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
|
||||
.then(response => response.json())
|
||||
.then(obj => {
|
||||
const result = JSON.parse(obj);
|
||||
const result = obj;
|
||||
isLoggingIn = true;
|
||||
if (result.message != null) {
|
||||
window.location.href = "/";
|
||||
|
||||
+281
-9
@@ -4,7 +4,6 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>{pastetitle}</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
@@ -12,7 +11,9 @@
|
||||
<a href="/">home</a>
|
||||
<a href="/pastes">recent pastes</a>
|
||||
<a href="/archive">archive</a>
|
||||
{html}
|
||||
<a href="login" id="login-signup-btn" style="display: none;" >login</a>
|
||||
<a href="sign-up" id="login-signup-btn" style="display: none;">sign up</a>
|
||||
<a href="dash" id="dash-btn" style="display: none;">dashboard</a>
|
||||
</div>
|
||||
<div class="nav-hamburger-menu">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="56" height="56" fill="currentColor" class="bi bi-list"
|
||||
@@ -24,13 +25,16 @@
|
||||
<a href="/">home</a>
|
||||
<a href="/pastes">recent pastes</a>
|
||||
<a href="/archive">archive</a>
|
||||
{html}
|
||||
<a href="login" id="login-signup-btn" style="display: none;" >login</a>
|
||||
<a href="sign-up" id="login-signup-btn" style="display: none;">sign up</a>
|
||||
<a href="dash" id="dash-btn" style="display: none;">dashboard</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container-wrapper">
|
||||
<div class="paste-container">
|
||||
<h1 id="paste-title" title="{pastetitleattribute}">{pastetitle}</h1>
|
||||
<h3 class="uploader-text">{username} <a id="creationdate">{creationdate}</a> {pastesize}</h3>
|
||||
<h1 id="paste-title"></h1>
|
||||
<h3 class="uploader-text"><a id="uploader-username" class="user-a"></a> <a id="creationdate"></a> <a id="paste-size"></a>
|
||||
</h3>
|
||||
<div class="paste-wrapper">
|
||||
<p id="text"></p>
|
||||
</div>
|
||||
@@ -40,22 +44,93 @@
|
||||
</a>
|
||||
<button id="copy-button" class="button">copy</button>
|
||||
<button id="download-button" class="button">download</button>
|
||||
{deletebutton}
|
||||
<button id="delete-button" class="button" style="display: none;">delete</button>
|
||||
<button id="edit-button" class="button" style="display: none;">edit</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="notifcations-wrapper" id="notifications"></div>
|
||||
<div class="input-wrapper" id="input-wrapper">
|
||||
<div class="input-wrapper-container">
|
||||
<h2 id="input-message"></h2>
|
||||
<div>
|
||||
<button id="yes-button" class="button">Yes</button>
|
||||
<button id="no-button" class="button">No</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<script>
|
||||
info = "";
|
||||
editing = false;
|
||||
function localizeDateTime(unixTimestamp) {
|
||||
const date = new Date(unixTimestamp * 1000);
|
||||
return date.toLocaleString();
|
||||
}
|
||||
function authenticate() {
|
||||
fetch('/api/accounts/authenticate')
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.message == "Authenticated") {
|
||||
if (info.uploader == data.username || data.type == "Admin") {
|
||||
document.getElementById('delete-button').style.display = 'block';
|
||||
document.getElementById('edit-button').style.display = 'block';
|
||||
}
|
||||
document.querySelectorAll("#login-signup-btn").forEach(element => {
|
||||
element.style.display = 'none';
|
||||
});
|
||||
document.getElementById('dash-btn').style.display = 'block';
|
||||
}else{
|
||||
document.querySelectorAll("#login-signup-btn").forEach(element => {
|
||||
element.style.display = 'block';
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
function fetchInfo() {
|
||||
fetch('/api/pastes/info?id={pasteid}')
|
||||
.then(response => response.json())
|
||||
.then(json => {
|
||||
info = json;
|
||||
title = json.title.length > 40 ? json.title.substring(0, 40) + '...' : json.title;
|
||||
document.getElementById('uploader-username').innerText = json.uploader || 'Anonymous';
|
||||
document.getElementById('creationdate').innerText = localizeDateTime(json.date);
|
||||
document.getElementById('paste-size').innerText = json.size;
|
||||
document.getElementById('paste-size').title = `Compressed Size: ${json.compressedSize}`;
|
||||
document.getElementById('paste-title').innerText = title;
|
||||
document.getElementById('paste-title').title = json.title;
|
||||
if (json.title == "") {
|
||||
document.getElementById('paste-title').innerText = `Untitled ${json.uid}`;
|
||||
document.title = `Untitled ${json.uid}`;
|
||||
}
|
||||
if (json.uploader && json.uploader.startsWith("Anonymous") && json.uploader.length == 46) {
|
||||
document.getElementById('uploader-username').innerText = 'Anonymous';
|
||||
} else if (json.uploader) {
|
||||
document.getElementById('uploader-username').href = `/u/${json.uploader}`;
|
||||
}
|
||||
})
|
||||
.catch(error => console.error('Error fetching paste info:', error));
|
||||
}
|
||||
document.getElementById("edit-button").addEventListener("click", function () {
|
||||
if (editing) {
|
||||
createInput('Are you sure you want to save this edit?');
|
||||
document.getElementById('yes-button').addEventListener("click", finalizeEdit);
|
||||
} else {
|
||||
editing = true;
|
||||
var editButton = document.getElementById('edit-button');
|
||||
editButton.innerText = 'save';
|
||||
var text = document.getElementById('text');
|
||||
var innertext = text.innerText;
|
||||
text.innerHTML = `<textarea class="textarea" id="edit-textarea" style="width: 100%; height: ${text.clientHeight}px;">${innertext}</textarea>`;
|
||||
}
|
||||
});
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
fetchInfo();
|
||||
authenticate();
|
||||
const creationdateElement = document.getElementById('creationdate');
|
||||
const creationdateText = creationdateElement.innerText.trim();
|
||||
const textElement = document.getElementById('text');
|
||||
|
||||
creationdateElement.innerText = localizeDateTime(parseInt(creationdateText));
|
||||
textElement.innerText = "Loading...";
|
||||
fetch(`/raw/{pasteid}`)
|
||||
@@ -109,8 +184,106 @@
|
||||
element.click();
|
||||
document.body.removeChild(element);
|
||||
});
|
||||
{ deletescript }
|
||||
document.getElementById("delete-button").addEventListener("click", function () {
|
||||
createInput('Are you sure you want to delete this paste?');
|
||||
document.getElementById("yes-button").addEventListener("click", function () {
|
||||
fetch(`/api/pastes/delete?id={pasteid}`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
id: '{pasteid}'
|
||||
})
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(obj => {
|
||||
const result = obj;
|
||||
if (result.message != null) {
|
||||
createNotification(`Success: ${result.message}`);
|
||||
setTimeout(() => {
|
||||
const inputWrapper = document.getElementById('input-wrapper');
|
||||
inputWrapper.style.display = 'none';
|
||||
window.location.href = '/';
|
||||
}, 2000);
|
||||
} else {
|
||||
const inputWrapper = document.getElementById('input-wrapper');
|
||||
inputWrapper.style.display = 'none';
|
||||
createNotification(`Error: ${result.error}`);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
document.getElementById("no-button").addEventListener("click", function () {
|
||||
const inputWrapper = document.getElementById('input-wrapper');
|
||||
inputWrapper.style.display = 'none';
|
||||
});
|
||||
function createNotification(message) {
|
||||
const notificationWrapper = document.getElementById('notifications');
|
||||
const notificationDiv = document.createElement('div');
|
||||
notificationDiv.classList.add('notification-div');
|
||||
notificationDiv.id = 'notification';
|
||||
|
||||
const notificationText = document.createElement('h2');
|
||||
notificationText.id = 'notification-text';
|
||||
notificationText.innerText = message;
|
||||
|
||||
notificationDiv.appendChild(notificationText);
|
||||
notificationWrapper.appendChild(notificationDiv);
|
||||
|
||||
notificationDiv.style.animation = 'none';
|
||||
notificationDiv.style.display = 'none';
|
||||
notificationDiv.style.display = 'flex';
|
||||
notificationDiv.style.animation = 'hoverup 1s';
|
||||
|
||||
setTimeout(() => {
|
||||
notificationDiv.style.animation = 'hoverdown 1s';
|
||||
}, 4000);
|
||||
|
||||
setTimeout(() => {
|
||||
notificationDiv.remove();
|
||||
}, 4900);
|
||||
}
|
||||
function createInput(message) {
|
||||
const inputWrapper = document.getElementById('input-wrapper');
|
||||
const inputMessage = document.getElementById('input-message');
|
||||
inputMessage.innerText = message;
|
||||
inputWrapper.style.display = 'flex';
|
||||
}
|
||||
function finalizeEdit() {
|
||||
var textarea = document.getElementById('edit-textarea');
|
||||
var text = textarea.value;
|
||||
fetch(`/api/pastes/edit`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
id: '{pasteid}',
|
||||
text: text
|
||||
})
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(obj => {
|
||||
const result = obj;
|
||||
if (result.message != null) {
|
||||
const inputWrapper = document.getElementById('input-wrapper');
|
||||
inputWrapper.style.display = 'none';
|
||||
document.getElementById('edit-button').innerText = "edit";
|
||||
createNotification(`Success: ${result.message}`);
|
||||
document.getElementById('text').innerText = text;
|
||||
document.getElementById('edit-textarea').remove();
|
||||
editing = false;
|
||||
} else {
|
||||
const inputWrapper = document.getElementById('input-wrapper');
|
||||
inputWrapper.style.display = 'none';
|
||||
document.getElementById('edit-button').innerText = "edit";
|
||||
createNotification(`Error: ${result.error}`);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -118,6 +291,44 @@
|
||||
<style>
|
||||
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Mono:wght@100..900&display=swap');
|
||||
|
||||
.textarea{
|
||||
font-family: "Noto Sans Mono", "Consolas", "SF Mono", monospace;
|
||||
font-weight: 500;
|
||||
max-width: 100%;
|
||||
min-width: 100%;
|
||||
background-color: #1d1d1d;
|
||||
color: white;
|
||||
border: none;
|
||||
}
|
||||
.textarea:focus{
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.input-wrapper{
|
||||
z-index: 100;
|
||||
display: none;
|
||||
position: absolute;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
color: white;
|
||||
backdrop-filter: blur(5px);
|
||||
}
|
||||
.input-wrapper-container{
|
||||
z-index: 101;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 50%;
|
||||
border-radius: 5px;
|
||||
padding: 20px;
|
||||
background-color: #181818;
|
||||
border: #222222 2px solid;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: "Noto Sans Mono", "Consolas", "SF Mono", monospace;
|
||||
font-weight: bold;
|
||||
@@ -210,11 +421,12 @@
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.user-a {
|
||||
.user-a:any-link {
|
||||
color: rgb(190, 190, 190);
|
||||
text-decoration: none;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
|
||||
.nav-div {
|
||||
top: 0;
|
||||
@@ -233,6 +445,7 @@
|
||||
height: fit-content;
|
||||
overflow-y: auto;
|
||||
border: #222222 2px solid;
|
||||
z-index: 999999;
|
||||
}
|
||||
|
||||
.nav-hamburger-menu {
|
||||
@@ -314,4 +527,63 @@
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@keyframes hoverup {
|
||||
0% {
|
||||
opacity: 0;
|
||||
transform: translateY(100%);
|
||||
}
|
||||
|
||||
25% {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
50% {
|
||||
|
||||
transform: translateY(-10px);
|
||||
}
|
||||
|
||||
100% {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes hoverdown {
|
||||
0% {
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
50% {
|
||||
transform: translateY(-10px);
|
||||
}
|
||||
|
||||
100% {
|
||||
transform: translateY(200%);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.notification-div {
|
||||
display: flex;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
width: fit-content;
|
||||
height: fit-content;
|
||||
color: white;
|
||||
background-color: #181818;
|
||||
border-radius: 5px;
|
||||
border: #222222 2px solid;
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
margin-right: 10px;
|
||||
margin-bottom: 10px;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
z-index: 102;
|
||||
position: absolute;
|
||||
}
|
||||
.notifcations-wrapper{
|
||||
z-index: 101;
|
||||
}
|
||||
</style>
|
||||
@@ -12,10 +12,13 @@
|
||||
<a href="/">home</a>
|
||||
<a href="/pastes">recent pastes</a>
|
||||
<a href="/archive">archive</a>
|
||||
{html}
|
||||
<a href="login" id="login-signup-btn" style="display: none;" >login</a>
|
||||
<a href="sign-up" id="login-signup-btn" style="display: none;">sign up</a>
|
||||
<a href="dash" id="dash-btn" style="display: none;">dashboard</a>
|
||||
</div>
|
||||
<div class="nav-hamburger-menu">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="56" height="56" fill="currentColor" class="bi bi-list" viewBox="0 0 16 16" id="hamburger-button" style="cursor: pointer;">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="56" height="56" fill="currentColor" class="bi bi-list"
|
||||
viewBox="0 0 16 16" id="hamburger-button" style="cursor: pointer;">
|
||||
<path fill-rule="evenodd"
|
||||
d="M2.5 12a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5m0-4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5m0-4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5" />
|
||||
</svg>
|
||||
@@ -23,13 +26,16 @@
|
||||
<a href="/">home</a>
|
||||
<a href="/pastes">recent pastes</a>
|
||||
<a href="/archive">archive</a>
|
||||
{html}
|
||||
<a href="login" id="login-signup-btn" style="display: none;" >login</a>
|
||||
<a href="sign-up" id="login-signup-btn" style="display: none;">sign up</a>
|
||||
<a href="dash" id="dash-btn" style="display: none;">dashboard</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container-wrapper">
|
||||
<div class="paste-container">
|
||||
<h1 id="paste-title" title="{pastetitleattribute}">{pastetitle}</h1>
|
||||
<h3 class="uploader-text">{username} <a id="creationdate">{creationdate}</a> {pastesize}</h3>
|
||||
<h1 id="paste-title"></h1>
|
||||
<h3 class="uploader-text"><a id="uploader-username" class="user-a"></a> <a id="creationdate"></a> <a id="paste-size"></a>
|
||||
</h3>
|
||||
<div class="paste-wrapper">
|
||||
<p id="text"></p>
|
||||
</div>
|
||||
@@ -39,13 +45,15 @@
|
||||
</a>
|
||||
<button id="copy-button" class="button">copy</button>
|
||||
<button id="download-button" class="button">download</button>
|
||||
{deletebutton}
|
||||
<button id="delete-button" class="button" style="display: none;">delete</button>
|
||||
<button id="edit-button" class="button" style="display: none;">edit</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="passwordDiv">
|
||||
<div class="inputDiv">
|
||||
<h1>This paste is password protected</h1>
|
||||
<input type="password" id="password" class="textinput" name="password" maxlength="500" placeholder="password">
|
||||
<input type="password" id="password" class="textinput" name="password" maxlength="500"
|
||||
placeholder="password">
|
||||
<button id="submitPassword" class="button-input">Submit</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -53,8 +61,76 @@
|
||||
<div class="notification-div" id="notification">
|
||||
<h2 id="notification-text"></h2>
|
||||
</div>
|
||||
<div class="input-wrapper" id="input-wrapper">
|
||||
<div class="input-wrapper-container">
|
||||
<h2 id="input-message"></h2>
|
||||
<div>
|
||||
<button id="yes-button" class="button">Yes</button>
|
||||
<button id="no-button" class="button">No</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<script>
|
||||
info = "";
|
||||
editing = false;
|
||||
function authenticate() {
|
||||
fetch('/api/accounts/authenticate')
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.message == "Authenticated") {
|
||||
if (info.uploader == data.username || data.type == "Admin") {
|
||||
document.getElementById('delete-button').style.display = 'block';
|
||||
//document.getElementById('edit-button').style.display = 'block';
|
||||
}
|
||||
document.querySelectorAll("#login-signup-btn").forEach(element => {
|
||||
element.style.display = 'none';
|
||||
});
|
||||
document.getElementById('dash-btn').style.display = 'block';
|
||||
}else{
|
||||
document.querySelectorAll("#login-signup-btn").forEach(element => {
|
||||
element.style.display = 'block';
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
function fetchInfo() {
|
||||
fetch('/api/pastes/info?id={pasteid}')
|
||||
.then(response => response.json())
|
||||
.then(json => {
|
||||
info = json;
|
||||
document.getElementById('uploader-username').innerText = json.uploader;
|
||||
document.getElementById('creationdate').innerText = localizeDateTime(json.date);
|
||||
document.getElementById('paste-size').innerText = json.size;
|
||||
document.getElementById('paste-size').title = `Compressed Size: ${json.compressedSize}`;
|
||||
document.getElementById('paste-title').innerText = json.title;
|
||||
document.getElementById('paste-title').title = json.title;
|
||||
if (json.title == "") {
|
||||
document.getElementById('paste-title').innerText = `Untitled ${json.uid}`;
|
||||
document.title = `Untitled ${json.uid}`;
|
||||
}
|
||||
if (json.uploader.startsWith("Anonymous") && json.uploader.length == 46) {
|
||||
document.getElementById('uploader-username').innerText = 'Anonymous';
|
||||
} else {
|
||||
document.getElementById('uploader-username').href = `/u/${json.uploader}`;
|
||||
}
|
||||
});
|
||||
}
|
||||
document.getElementById("edit-button").addEventListener("click", function () {
|
||||
if (editing) {
|
||||
createInput('Are you sure you want to save this edit?');
|
||||
document.getElementById('yes-button').removeEventListener("click", deletePaste);
|
||||
document.getElementById('yes-button').addEventListener("click", finalizeEdit);
|
||||
document.getElementById('yes-button').removeEventListener("click", finalizeEdit);
|
||||
} else {
|
||||
editing = true;
|
||||
var editButton = document.getElementById('edit-button');
|
||||
editButton.innerText = 'save';
|
||||
var text = document.getElementById('text');
|
||||
var innertext = text.innerText;
|
||||
text.innerHTML = `<textarea class="textarea" id="edit-textarea" style="width: 100%; height: ${text.clientHeight}px;">${innertext}</textarea>`;
|
||||
}
|
||||
});
|
||||
document.getElementById("submitPassword").addEventListener("click", function () {
|
||||
var password = document.getElementById("password").value;
|
||||
fetch(`/api/pastes/password/{pasteid}`, {
|
||||
@@ -66,31 +142,28 @@
|
||||
password: password
|
||||
})
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(obj => {
|
||||
const result = JSON.parse(obj);
|
||||
if (result.content != null){
|
||||
const textElement = document.getElementById('text');
|
||||
textElement.innerText = result.content;
|
||||
document.querySelector(".passwordDiv").style.display = "none";
|
||||
const viewRawButton = document.getElementById('view-raw-a');
|
||||
viewRawButton.href = `/raw/{pasteid}?password=${password}`;
|
||||
}
|
||||
else {
|
||||
notification(`Error: ${result.error}`);
|
||||
}
|
||||
});
|
||||
.then(response => response.json())
|
||||
.then(result => {
|
||||
if (result.content != null) {
|
||||
const textElement = document.getElementById('text');
|
||||
textElement.innerText = result.content;
|
||||
document.querySelector(".passwordDiv").style.display = "none";
|
||||
const viewRawButton = document.getElementById('view-raw-a');
|
||||
viewRawButton.href = `/raw/{pasteid}?password=` + password;
|
||||
}
|
||||
else {
|
||||
notification(`Error: ${result.error}`);
|
||||
}
|
||||
});
|
||||
});
|
||||
function localizeDateTime(unixTimestamp) {
|
||||
const date = new Date(unixTimestamp * 1000);
|
||||
return date.toLocaleString();
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
const creationdateElement = document.getElementById('creationdate');
|
||||
const creationdateText = creationdateElement.innerText.trim();
|
||||
|
||||
creationdateElement.innerText = localizeDateTime(parseInt(creationdateText));
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
fetchInfo();
|
||||
authenticated();
|
||||
var mobile = window.mobileCheck();
|
||||
if (mobile) {
|
||||
document.querySelector('.nav-div').style.display = 'none';
|
||||
@@ -122,7 +195,66 @@
|
||||
element.click();
|
||||
document.body.removeChild(element);
|
||||
});
|
||||
{deletescript}
|
||||
document.getElementById("delete-button").addEventListener("click", function () {
|
||||
createInput('Are you sure you want to delete this paste?');
|
||||
document.getElementById('yes-button').removeEventListener("click", finalizeEdit);
|
||||
document.getElementById('yes-button').addEventListener("click", deletePaste);
|
||||
document.getElementById('yes-button').removeEventListener("click", deletePaste);
|
||||
});
|
||||
function deletePaste() {
|
||||
fetch(`/api/pastes/delete?id={pasteid}`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
id: '{pasteid}'
|
||||
})
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(result => {
|
||||
if (result.message != null) {
|
||||
createNotification(`Success: ${result.message}`);
|
||||
setTimeout(() => {
|
||||
window.location.href = '/';
|
||||
}, 2000);
|
||||
} else {
|
||||
createNotification(`Error: ${result.error}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
function finalizeEdit() {
|
||||
var textarea = document.getElementById('edit-textarea');
|
||||
var text = textarea.value;
|
||||
fetch(`/api/pastes/edit`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
id: '{pasteid}',
|
||||
text: text
|
||||
})
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(result => {
|
||||
if (result.message != null) {
|
||||
createNotification(`Success: ${result.message}`);
|
||||
document.getElementById('text').innerText = text;
|
||||
document.getElementById('edit-textarea').remove();
|
||||
editing = false;
|
||||
} else {
|
||||
createNotification(`Error: ${result.error}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
document.getElementById("no-button").addEventListener("click", function () {
|
||||
const inputWrapper = document.getElementById('input-wrapper');
|
||||
inputWrapper.style.display = 'none';
|
||||
document.getElementById('yes-button').removeEventListener("click", finalizeEdit);
|
||||
document.getElementById('yes-button').removeEventListener("click", deletePaste);
|
||||
|
||||
});
|
||||
function notification(message) {
|
||||
const notification = document.getElementById('notification');
|
||||
const notificationText = document.getElementById('notification-text');
|
||||
@@ -140,13 +272,19 @@
|
||||
}, 4900);
|
||||
|
||||
}
|
||||
|
||||
function createInput(message) {
|
||||
const inputWrapper = document.getElementById('input-wrapper');
|
||||
const inputMessage = document.getElementById('input-message');
|
||||
inputMessage.innerText = message;
|
||||
inputWrapper.style.display = 'flex';
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
</html>
|
||||
<style>
|
||||
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Mono:wght@100..900&display=swap');
|
||||
|
||||
body {
|
||||
font-family: "Noto Sans Mono", "Consolas", "SF Mono", monospace;
|
||||
font-weight: bold;
|
||||
@@ -157,6 +295,32 @@
|
||||
background-color: #0d0d0d;
|
||||
}
|
||||
|
||||
.input-wrapper {
|
||||
z-index: 100;
|
||||
display: none;
|
||||
position: absolute;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
color: white;
|
||||
backdrop-filter: blur(5px);
|
||||
}
|
||||
|
||||
.input-wrapper-container {
|
||||
z-index: 101;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 50%;
|
||||
border-radius: 5px;
|
||||
padding: 20px;
|
||||
background-color: #181818;
|
||||
border: #222222 2px solid;
|
||||
}
|
||||
|
||||
.container-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -165,6 +329,7 @@
|
||||
width: 100%;
|
||||
height: 98.7vh;
|
||||
}
|
||||
|
||||
.button-input {
|
||||
transition: 300ms;
|
||||
background-color: #222222;
|
||||
@@ -182,11 +347,13 @@
|
||||
font-weight: 625;
|
||||
box-sizing: content-box;
|
||||
}
|
||||
|
||||
.button-input:hover {
|
||||
transition: 300ms;
|
||||
background-color: #333333;
|
||||
border: 2px solid #3a3a3a;
|
||||
}
|
||||
|
||||
.passwordDiv {
|
||||
z-index: 100;
|
||||
position: absolute;
|
||||
@@ -199,6 +366,7 @@
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.inputDiv {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -207,6 +375,7 @@
|
||||
width: fit-content;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.textinput {
|
||||
width: 100%;
|
||||
height: 50px;
|
||||
@@ -219,6 +388,7 @@
|
||||
font-weight: 625;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.textinput:focus {
|
||||
outline: none;
|
||||
border: 2px solid #333333;
|
||||
@@ -297,7 +467,7 @@
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.user-a {
|
||||
.user-a:any-link {
|
||||
color: rgb(190, 190, 190);
|
||||
text-decoration: none;
|
||||
text-decoration: underline;
|
||||
@@ -321,6 +491,7 @@
|
||||
height: fit-content;
|
||||
overflow-y: auto;
|
||||
border: #222222 2px solid;
|
||||
z-index: 999999;
|
||||
}
|
||||
|
||||
.nav-hamburger-menu {
|
||||
@@ -383,6 +554,7 @@
|
||||
background-color: #333333;
|
||||
border: #3a3a3a 2px solid;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 800px) {
|
||||
.nav-div {
|
||||
display: none;
|
||||
@@ -399,8 +571,9 @@
|
||||
.nav-buttons a {
|
||||
display: block;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@keyframes hoverup {
|
||||
0% {
|
||||
opacity: 0;
|
||||
@@ -436,6 +609,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.notification-div {
|
||||
position: fixed;
|
||||
display: none;
|
||||
@@ -453,6 +627,10 @@
|
||||
margin-bottom: 10px;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
z-index: 102;
|
||||
position: absolute;
|
||||
}
|
||||
.notifcations-wrapper{
|
||||
z-index: 101;
|
||||
}
|
||||
</style>
|
||||
@@ -65,7 +65,7 @@
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(obj => {
|
||||
const result = JSON.parse(obj);
|
||||
const result = obj;
|
||||
if (result.message != null) {
|
||||
window.location.href = "/";
|
||||
isLoggingIn = false;
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# Sharpbin is currently being re-written.
|
||||
Quite frankly the current code base is quite messy, I also am just bored and would like to improve this since it's a pretty fun thing to make.
|
||||
# Sharpbin
|
||||
Sharpbin is a Pastebin type website completely in C#, except for the frontend, being pure HTML & CSS.
|
||||
Sharpbin can be used for sharing large amounts of text.
|
||||
@@ -13,8 +15,13 @@ Sharpbin can be used for sharing large amounts of text.
|
||||
- Private encrypted pastes, sadly the encryption is server side, although client side may be soon!
|
||||
- Mobile Support
|
||||
- Captchas for logins and sign ups
|
||||
- Editable pastes
|
||||
... And more to come!
|
||||
|
||||
# TODO
|
||||
- ~~Fix css on the confirmations~~
|
||||
- ~~Update file size when an edit is made in the database~~
|
||||
|
||||
# Demo Website & Screenshots
|
||||
You can find the test website at https://bin.whoswhip.top , there is no removed functionality and is the exact same code in this repo.
|
||||
<div>
|
||||
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
############################################
|
||||
#### Sharpbin Linux installer ####
|
||||
############################################
|
||||
##
|
||||
## This is a semi completed script to install Sharpbin on Linux, however it does not set it as a system daemon/service, cause idk how to do that lol
|
||||
##
|
||||
|
||||
mkdir sharpbin
|
||||
cd sharpbin
|
||||
|
||||
curl -s "https://api.github.com/repos/whoswhip/Sharpbin/releases/latest" | jq -r '.assets[] | select(.name | test("sharpbin-linux-.*\\.tar$")) | .browser_download_url' | xargs -I {} curl -L -o sharpbin-linux.tar {}
|
||||
|
||||
tar -xvf sharpbin-linux.tar
|
||||
chmod +x Sharpbin
|
||||
|
||||
echo "Enter your cloudflare sitekey: "
|
||||
read sitekey
|
||||
echo "Enter your cloudflare secretkey: "
|
||||
read secretkey
|
||||
|
||||
|
||||
echo "{ \"CF_TurnstileSiteKey\": \"$sitekey\", \"CF_TurnstileSecret\": \"$secretkey\" }" > config.json
|
||||
Reference in New Issue
Block a user