Linux websever 5.15.0-153-generic #163-Ubuntu SMP Thu Aug 7 16:37:18 UTC 2025 x86_64
Apache/2.4.52 (Ubuntu)
: 192.168.3.70 | : 192.168.1.99
Cant Read [ /etc/named.conf ]
8.1.2-1ubuntu2.23
urlab
www.github.com/MadExploits
Terminal
AUTO ROOT
Adminer
Backdoor Destroyer
Linux Exploit
Lock Shell
Lock File
Create User
CREATE RDP
PHP Mailer
BACKCONNECT
UNLOCK SHELL
HASH IDENTIFIER
CPANEL RESET
CREATE WP USER
README
+ Create Folder
+ Create File
/
var /
www /
html /
cqt /
server /
routes /
[ HOME SHELL ]
Name
Size
Permission
Action
auth.js
2.8
KB
-rw-r--r--
courses.js
5.97
KB
-rw-r--r--
labs.js
9.38
KB
-rw-r--r--
news.js
6.1
KB
-rw-r--r--
publications.js
8.21
KB
-rw-r--r--
rebuild.js
1.09
KB
-rw-r--r--
research.js
6.83
KB
-rw-r--r--
team.js
6.52
KB
-rw-r--r--
workshops.js
6.01
KB
-rw-r--r--
Delete
Unzip
Zip
${this.title}
Close
Code Editor : workshops.js
const express = require('express'); const router = express.Router(); const authMiddleware = require('../middleware/auth'); const { validateId, validateWorkshop } = require('../middleware/validation'); const { readJSON, writeJSON, createBackup } = require('../utils/fileOperations'); const multer = require('multer'); const path = require('path'); const fs = require('fs'); const fsp = require('fs').promises; const crypto = require('crypto'); // Helper function to check if two files are identical async function filesAreIdentical(path1, path2) { try { const [file1, file2] = await Promise.all([ fsp.readFile(path1), fsp.readFile(path2) ]); const hash1 = crypto.createHash('md5').update(file1).digest('hex'); const hash2 = crypto.createHash('md5').update(file2).digest('hex'); return hash1 === hash2; } catch (error) { return false; } } // Multer storage for workshops images const workshopsStorage = multer.diskStorage({ destination: (req, file, cb) => { const dest = path.join(__dirname, '../../public/images/workshops'); fs.mkdirSync(dest, { recursive: true }); cb(null, dest); }, filename: (req, file, cb) => { const ext = path.extname(file.originalname) || ''; const name = `${Date.now()}-${Math.random().toString(36).slice(2,8)}${ext}`; cb(null, name); } }); const imageFilter = (req, file, cb) => { const allowedMimes = ['image/jpeg', 'image/jpg', 'image/png', 'image/gif', 'image/webp']; if (allowedMimes.includes(file.mimetype)) { cb(null, true); } else { cb(new Error('Invalid file type. Only JPEG, PNG, GIF, and WebP images are allowed.'), false); } }; const upload = multer({ storage: workshopsStorage, fileFilter: imageFilter, limits: { fileSize: 5 * 1024 * 1024, files: 1 } }); const FILENAME = 'workshops.json'; router.get('/', async (req, res) => { try { const data = await readJSON(FILENAME); res.json(data); } catch (error) { res.status(500).json({ error: 'Error reading workshops data' }); } }); router.get('/:id', validateId(), async (req, res) => { try { const data = await readJSON(FILENAME); const item = data.find(w => w.id === req.params.id); if (!item) return res.status(404).json({ error: 'Workshop not found' }); res.json(item); } catch (error) { res.status(500).json({ error: 'Error reading workshops data' }); } }); router.post('/', authMiddleware, upload.single('image'), validateWorkshop(), async (req, res) => { try { await createBackup(FILENAME); const data = await readJSON(FILENAME); const newItem = { id: req.body.id || `workshop-${Date.now()}`, ...req.body, createdAt: new Date().toISOString() }; // If an image was uploaded, store its public path if (req.file) { newItem.image = `/images/workshops/${req.file.filename}`; } data.push(newItem); await writeJSON(FILENAME, data); res.status(201).json({ success: true, data: newItem }); } catch (error) { res.status(500).json({ error: 'Error creating workshop' }); } }); router.put('/:id', authMiddleware, validateId(), upload.single('image'), validateWorkshop(), async (req, res) => { try { await createBackup(FILENAME); const data = await readJSON(FILENAME); const index = data.findIndex(w => w.id === req.params.id); if (index === -1) return res.status(404).json({ error: 'Workshop not found' }); // Remove image from body to prevent overwriting uploaded file const { image: _, ...bodyWithoutImage } = req.body; // If a new image was uploaded, check if it's identical to existing one if (req.file) { const newFilePath = path.join(__dirname, '../../public/images/workshops', req.file.filename); const oldImage = data[index].image; let shouldUseNewFile = true; // Check if old image exists and compare with new upload if (oldImage && typeof oldImage === 'string' && oldImage.startsWith('/images/workshops/')) { const oldPath = path.join(__dirname, '../../public', oldImage.replace(/^\//, '')); const areIdentical = await filesAreIdentical(oldPath, newFilePath); if (areIdentical) { // Files are identical, remove the newly uploaded file and keep the old one await fsp.unlink(newFilePath).catch(() => {}); shouldUseNewFile = false; console.log('ℹ️ Identical file detected, keeping existing image'); } else { // Files are different, remove old file await fsp.unlink(oldPath).catch(() => {}); } } if (shouldUseNewFile) { data[index] = { ...data[index], ...bodyWithoutImage, image: `/images/workshops/${req.file.filename}`, id: req.params.id, updatedAt: new Date().toISOString() }; } else { data[index] = { ...data[index], ...bodyWithoutImage, id: req.params.id, updatedAt: new Date().toISOString() }; } } else { data[index] = { ...data[index], ...bodyWithoutImage, id: req.params.id, updatedAt: new Date().toISOString() }; } await writeJSON(FILENAME, data); res.json({ success: true, data: data[index] }); } catch (error) { res.status(500).json({ error: 'Error updating workshop' }); } }); router.delete('/:id', authMiddleware, validateId(), async (req, res) => { try { await createBackup(FILENAME); const data = await readJSON(FILENAME); const index = data.findIndex(w => w.id === req.params.id); if (index === -1) return res.status(404).json({ error: 'Workshop not found' }); const deleted = data.splice(index, 1); // Remove associated image file if exists const oldImage = deleted[0].image; if (oldImage && typeof oldImage === 'string' && oldImage.startsWith('/images/workshops/')) { const oldPath = path.join(__dirname, '../../public', oldImage.replace(/^\//, '')); await fsp.unlink(oldPath).catch(() => {}); } await writeJSON(FILENAME, data); res.json({ success: true, data: deleted[0] }); } catch (error) { res.status(500).json({ error: 'Error deleting workshop' }); } }); module.exports = router;
Close