-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SkyHighSundaeFileBin release day!!!!!!
- Loading branch information
0 parents
commit bf30a83
Showing
18 changed files
with
932 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"adminKey": "your-admin-key-here" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,192 @@ | ||
// app.js | ||
const express = require('express'); | ||
const multer = require('multer'); | ||
const uuid = require('uuid'); | ||
const fs = require('fs-extra'); | ||
const path = require('path'); | ||
|
||
const app = express(); | ||
const port = 3000; | ||
|
||
// Data files | ||
const adminDataPath = './admin.json'; | ||
const filesDataPath = './data/files.json'; | ||
const bannedIPsPath = './data/banned_ips.json'; | ||
|
||
// Load admin key | ||
const adminData = fs.readJsonSync(adminDataPath); | ||
const adminKey = adminData.adminKey; | ||
|
||
// Helper functions to load and save data | ||
const loadJSON = (path) => fs.readJsonSync(path, { throws: false }) || {}; | ||
const saveJSON = (path, data) => fs.writeJsonSync(path, data); | ||
|
||
// Localization Middleware | ||
const locales = { | ||
en: require('./locales/en.json'), | ||
de: require('./locales/de.json'), | ||
ru: require('./locales/ru.json'), | ||
uk: require('./locales/uk.json'), | ||
}; | ||
|
||
app.use((req, res, next) => { | ||
let lang = req.acceptsLanguages('en', 'de', 'ru', 'uk') || 'en'; | ||
req.locale = locales[lang] || locales['en']; | ||
next(); | ||
}); | ||
|
||
// Serve essential static files for banned.html before IP detection | ||
app.use('/css', express.static(path.join(__dirname, 'public', 'css'))); | ||
app.use('/js', express.static(path.join(__dirname, 'public', 'js'))); | ||
app.use('/locales', express.static(path.join(__dirname, 'locales'))); | ||
app.use('/images', express.static(path.join(__dirname, 'public', 'images'))); | ||
|
||
// IP Detection Middleware | ||
app.set('trust proxy', true); // If behind a proxy like Nginx or a load balancer | ||
app.use((req, res, next) => { | ||
let clientIP = req.ip.replace('::ffff:', ''); // Handle IPv4-mapped IPv6 addresses | ||
|
||
const bannedIPs = loadJSON(bannedIPsPath); | ||
|
||
if (bannedIPs[clientIP]) { | ||
// Allow access to banned.html and essential static assets | ||
if ( | ||
req.path === '/banned.html' || | ||
req.path.startsWith('/css/') || | ||
req.path.startsWith('/js/') || | ||
req.path.startsWith('/locales/') || | ||
req.path.startsWith('/images/') | ||
) { | ||
return next(); | ||
} else { | ||
return res.sendFile(path.join(__dirname, 'public', 'banned.html')); | ||
} | ||
} | ||
|
||
next(); | ||
}); | ||
|
||
// Middleware for parsing JSON and URL-encoded data | ||
app.use(express.json()); | ||
app.use(express.urlencoded({ extended: true })); | ||
|
||
// Serve other static files | ||
app.use(express.static('public')); | ||
|
||
// Storage configuration for Multer | ||
const storage = multer.diskStorage({ | ||
destination: (req, file, cb) => { | ||
cb(null, 'files/'); | ||
}, | ||
filename: (req, file, cb) => { | ||
const uniqueName = uuid.v4() + path.extname(file.originalname); | ||
cb(null, uniqueName); | ||
}, | ||
}); | ||
|
||
const upload = multer({ storage }); | ||
|
||
// Routes | ||
|
||
// Upload Route | ||
app.post('/upload', upload.single('file'), (req, res) => { | ||
const filesData = loadJSON(filesDataPath); | ||
const fileID = uuid.v4(); | ||
const fileData = { | ||
id: fileID, | ||
originalName: req.file.originalname, | ||
storedName: req.file.filename, | ||
size: req.file.size, | ||
uploadDate: new Date(), | ||
}; | ||
|
||
filesData[fileID] = fileData; | ||
saveJSON(filesDataPath, filesData); | ||
|
||
res.json({ link: `/file.html?id=${fileID}` }); | ||
}); | ||
|
||
// File Details API | ||
app.get('/file/:id/details', (req, res) => { | ||
const filesData = loadJSON(filesDataPath); | ||
const fileData = filesData[req.params.id]; | ||
|
||
if (!fileData) { | ||
return res.json({ error: req.locale.file_not_found }); | ||
} | ||
|
||
res.json(fileData); | ||
}); | ||
|
||
// File Download Action | ||
app.get('/download/:id', (req, res) => { | ||
const filesData = loadJSON(filesDataPath); | ||
const fileData = filesData[req.params.id]; | ||
|
||
if (!fileData) { | ||
return res.status(404).send(req.locale.file_not_found); | ||
} | ||
|
||
const filePath = path.join(__dirname, 'files', fileData.storedName); | ||
res.download(filePath, fileData.originalName); | ||
}); | ||
|
||
// Serve rules.html when accessing /rules | ||
app.get('/rules', (req, res) => { | ||
res.sendFile(path.join(__dirname, 'public', 'rules.html')); | ||
}); | ||
|
||
// Serve admin.html when accessing /admin | ||
app.get('/admin', (req, res) => { | ||
res.sendFile(path.join(__dirname, 'public', 'admin.html')); | ||
}); | ||
|
||
// Admin Authentication Middleware | ||
const authenticateAdmin = (req, res, next) => { | ||
const key = req.headers['x-admin-key'] || req.query.key; | ||
|
||
if (key === adminKey) { | ||
next(); | ||
} else { | ||
res.status(401).send('Unauthorized'); | ||
} | ||
}; | ||
|
||
// Admin Routes | ||
|
||
// Get All Files | ||
app.get('/admin/files', authenticateAdmin, (req, res) => { | ||
const filesData = loadJSON(filesDataPath); | ||
res.json(filesData); | ||
}); | ||
|
||
// Delete a File | ||
app.delete('/admin/files/:id', authenticateAdmin, (req, res) => { | ||
const filesData = loadJSON(filesDataPath); | ||
const fileData = filesData[req.params.id]; | ||
|
||
if (fileData) { | ||
fs.unlinkSync(`files/${fileData.storedName}`); | ||
delete filesData[req.params.id]; | ||
saveJSON(filesDataPath, filesData); | ||
res.json({ message: 'File deleted' }); | ||
} else { | ||
res.status(404).json({ message: 'File not found' }); | ||
} | ||
}); | ||
|
||
// Ban an IP | ||
app.post('/admin/ban', authenticateAdmin, (req, res) => { | ||
const bannedIPs = loadJSON(bannedIPsPath); | ||
const ipToBan = req.body.ip; | ||
|
||
bannedIPs[ipToBan] = true; | ||
saveJSON(bannedIPsPath, bannedIPs); | ||
|
||
res.json({ message: `IP ${ipToBan} has been banned` }); | ||
}); | ||
|
||
// Start the Server | ||
app.listen(port, () => { | ||
console.log(`Server running at http://localhost:${port}`); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{\rtf1\ansi\ansicpg1252\cocoartf2818 | ||
\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fswiss\fcharset0 Helvetica;} | ||
{\colortbl;\red255\green255\blue255;} | ||
{\*\expandedcolortbl;;} | ||
\paperw11900\paperh16840\margl1440\margr1440\vieww11520\viewh8400\viewkind0 | ||
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural\partightenfactor0 | ||
|
||
\f0\fs24 \cf0 Welcome to SkyHighSundaeFileBin!\ | ||
In this folder, the uploaded files are stored.\ | ||
Please delete this file.} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"title": "SkyHighSundaeFileBin", | ||
"description": "Gofile, aber einfacher.", | ||
"upload": "Hochladen", | ||
"rules": "Regeln", | ||
"admin_panel": "Admin-Bereich", | ||
"file_not_found": "Datei nicht gefunden", | ||
"banned_message": "Sie wurden von SkyHighSundaeFileBin wegen störendem Verhalten oder Spam-Dateien gesperrt.", | ||
"rule1": "Keine Spam-Dateien: Wenn Sie Pornos oder einen Computervirus hochladen, kann dies zur Löschung der Datei oder zu einer IP-Sperre führen.", | ||
"rule2": "Verwenden Sie SkyHighSundaeFileBin nicht, um Belästigungsdokumente und ähnliche Inhalte zu teilen.", | ||
"cancel_upload": "Upload abbrechen", | ||
"please_select_file": "Bitte wählen Sie eine Datei aus", | ||
"upload_failed": "Upload fehlgeschlagen", | ||
"upload_canceled": "Upload abgebrochen", | ||
"upload_progress": "Hochgeladen {mbUploaded} MB von {mbTotal} MB ({percent}%)", | ||
"upload_speed": "{mbPerSec} MB/s", | ||
"time_remaining": "Verbleibende Zeit: {timeRemaining} Sek.", | ||
"enter_admin_key": "Admin-Schlüssel eingeben", | ||
"login": "Anmelden", | ||
"uploaded_files": "Hochgeladene Dateien", | ||
"original_name": "Ursprünglicher Name", | ||
"size_mb": "Größe (MB)", | ||
"actions": "Aktionen", | ||
"delete": "Löschen", | ||
"ban_ip": "IP sperren", | ||
"enter_ip_to_ban": "IP zum Sperren eingeben", | ||
"ban_ip_btn": "IP sperren", | ||
"unauthorized": "Nicht autorisiert", | ||
"filename": "Dateiname", | ||
"size": "Größe", | ||
"upload_date": "Upload-Datum", | ||
"download": "Herunterladen" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"title": "SkyHighSundaeFileBin", | ||
"description": "Gofile but easier.", | ||
"upload": "Upload", | ||
"rules": "Rules", | ||
"admin_panel": "Admin Panel", | ||
"file_not_found": "File not found", | ||
"banned_message": "You have been banned from SkyHighSundaeFileBin due to disruptive behaviour or spam files.", | ||
"rule1": "No spam files: if you upload porn or a computer virus, it may result in file deletion or an IP ban.", | ||
"rule2": "Don't use SkyHighSundaeFileBin to share harassment documents and similar content.", | ||
"cancel_upload": "Cancel Upload", | ||
"please_select_file": "Please select a file", | ||
"upload_failed": "Upload failed", | ||
"upload_canceled": "Upload canceled", | ||
"upload_progress": "Uploaded {mbUploaded} MB of {mbTotal} MB ({percent}%)", | ||
"upload_speed": "{mbPerSec} MB/sec", | ||
"time_remaining": "Time remaining: {timeRemaining} sec", | ||
"enter_admin_key": "Enter Admin Key", | ||
"login": "Login", | ||
"uploaded_files": "Uploaded Files", | ||
"original_name": "Original Name", | ||
"size_mb": "Size (MB)", | ||
"actions": "Actions", | ||
"delete": "Delete", | ||
"ban_ip": "Ban IP", | ||
"enter_ip_to_ban": "Enter IP to ban", | ||
"ban_ip_btn": "Ban IP", | ||
"unauthorized": "Unauthorized", | ||
"filename": "Filename", | ||
"size": "Size", | ||
"upload_date": "Upload Date", | ||
"download": "Download" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"title": "SkyHighSundaeFileBin", | ||
"description": "Gofile, но проще.", | ||
"upload": "Загрузить", | ||
"rules": "Правила", | ||
"admin_panel": "Панель администратора", | ||
"file_not_found": "Файл не найден", | ||
"banned_message": "Вы были заблокированы на SkyHighSundaeFileBin за деструктивное поведение или спам-файлы.", | ||
"rule1": "Нет спам-файлов: если вы загрузите порно или компьютерный вирус, это может привести к удалению файла или блокировке IP.", | ||
"rule2": "Не используйте SkyHighSundaeFileBin для распространения документов с преследованием и подобного контента.", | ||
"cancel_upload": "Отменить загрузку", | ||
"please_select_file": "Пожалуйста, выберите файл", | ||
"upload_failed": "Ошибка загрузки", | ||
"upload_canceled": "Загрузка отменена", | ||
"upload_progress": "Загружено {mbUploaded} МБ из {mbTotal} МБ ({percent}%)", | ||
"upload_speed": "{mbPerSec} МБ/сек", | ||
"time_remaining": "Оставшееся время: {timeRemaining} сек", | ||
"enter_admin_key": "Введите ключ администратора", | ||
"login": "Войти", | ||
"uploaded_files": "Загруженные файлы", | ||
"original_name": "Оригинальное имя", | ||
"size_mb": "Размер (МБ)", | ||
"actions": "Действия", | ||
"delete": "Удалить", | ||
"ban_ip": "Заблокировать IP", | ||
"enter_ip_to_ban": "Введите IP для блокировки", | ||
"ban_ip_btn": "Заблокировать IP", | ||
"unauthorized": "Неавторизовано", | ||
"filename": "Имя файла", | ||
"size": "Размер", | ||
"upload_date": "Дата загрузки", | ||
"download": "Скачать" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"title": "SkyHighSundaeFileBin", | ||
"description": "Gofile, але простіше.", | ||
"upload": "Завантажити", | ||
"rules": "Правила", | ||
"admin_panel": "Панель адміністратора", | ||
"file_not_found": "Файл не знайдено", | ||
"banned_message": "Вас було заблоковано на SkyHighSundaeFileBin за деструктивну поведінку або спам-файли.", | ||
"rule1": "Немає спам-файлів: якщо ви завантажите порно або комп'ютерний вірус, це може призвести до видалення файлу або блокування IP.", | ||
"rule2": "Не використовуйте SkyHighSundaeFileBin для поширення документів з переслідуванням та подібним контентом.", | ||
"cancel_upload": "Скасувати завантаження", | ||
"please_select_file": "Будь ласка, виберіть файл", | ||
"upload_failed": "Не вдалося завантажити", | ||
"upload_canceled": "Завантаження скасовано", | ||
"upload_progress": "Завантажено {mbUploaded} МБ з {mbTotal} МБ ({percent}%)", | ||
"upload_speed": "{mbPerSec} МБ/сек", | ||
"time_remaining": "Залишилося часу: {timeRemaining} сек", | ||
"enter_admin_key": "Введіть ключ адміністратора", | ||
"login": "Увійти", | ||
"uploaded_files": "Завантажені файли", | ||
"original_name": "Оригінальна назва", | ||
"size_mb": "Розмір (МБ)", | ||
"actions": "Дії", | ||
"delete": "Видалити", | ||
"ban_ip": "Заблокувати IP", | ||
"enter_ip_to_ban": "Введіть IP для блокування", | ||
"ban_ip_btn": "Заблокувати IP", | ||
"unauthorized": "Неавторизовано", | ||
"filename": "Ім'я файлу", | ||
"size": "Розмір", | ||
"upload_date": "Дата завантаження", | ||
"download": "Завантажити" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "skyhighsundaefilebin", | ||
"version": "1.0.0", | ||
"description": "Gofile but easier.", | ||
"main": "app.js", | ||
"scripts": { | ||
"start": "node app.js" | ||
}, | ||
"dependencies": { | ||
"express": "^4.18.2", | ||
"fs-extra": "^10.0.0", | ||
"multer": "^1.4.4", | ||
"path": "^0.12.7", | ||
"uuid": "^8.3.2" | ||
} | ||
} |
Oops, something went wrong.