Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3fc28af508 |
8
FTP-Server.code-workspace
Normal file
8
FTP-Server.code-workspace
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"folders": [
|
||||||
|
{
|
||||||
|
"path": "."
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"settings": {}
|
||||||
|
}
|
||||||
@@ -65,18 +65,7 @@ document.getElementById('logout-btn').addEventListener('click', async () => {
|
|||||||
window.location.reload();
|
window.location.reload();
|
||||||
});
|
});
|
||||||
|
|
||||||
function showLogin() {
|
|
||||||
loginScreen.classList.remove('hidden');
|
|
||||||
appScreen.classList.add('hidden');
|
|
||||||
}
|
|
||||||
|
|
||||||
function showApp() {
|
|
||||||
loginScreen.classList.add('hidden');
|
|
||||||
appScreen.classList.remove('hidden');
|
|
||||||
document.getElementById('user-display').textContent = currentUser.username;
|
|
||||||
loadFiles();
|
|
||||||
updateViewIcon();
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- View Mode ---
|
// --- View Mode ---
|
||||||
function toggleView() {
|
function toggleView() {
|
||||||
@@ -94,6 +83,27 @@ function updateViewIcon() {
|
|||||||
}
|
}
|
||||||
viewToggleBtn.addEventListener('click', toggleView);
|
viewToggleBtn.addEventListener('click', toggleView);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// --- Auth / UI State ---
|
||||||
|
|
||||||
|
function showLogin() {
|
||||||
|
// Force style to ensure hidden/visible
|
||||||
|
loginScreen.classList.remove('hidden');
|
||||||
|
loginScreen.style.display = 'flex';
|
||||||
|
appScreen.classList.add('hidden');
|
||||||
|
}
|
||||||
|
|
||||||
|
function showApp() {
|
||||||
|
loginScreen.classList.add('hidden');
|
||||||
|
loginScreen.style.display = 'none'; // Force hide
|
||||||
|
appScreen.classList.remove('hidden');
|
||||||
|
document.getElementById('user-display').textContent = currentUser.username;
|
||||||
|
loadFiles();
|
||||||
|
updateViewIcon();
|
||||||
|
}
|
||||||
|
|
||||||
// --- Files ---
|
// --- Files ---
|
||||||
async function loadFiles(path = currentPath) {
|
async function loadFiles(path = currentPath) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -40,9 +40,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<span id="user-display"></span>
|
<span id="user-display"></span>
|
||||||
<button id="theme-toggle" class="btn secondary" aria-label="Toggle Dark Mode">
|
|
||||||
<span class="icon">🌓</span>
|
|
||||||
</button>
|
|
||||||
<button id="logout-btn" class="btn secondary">Logout</button>
|
<button id="logout-btn" class="btn secondary">Logout</button>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|||||||
@@ -1,40 +1,15 @@
|
|||||||
:root {
|
:root {
|
||||||
--bg-color: #f8f9fa;
|
--bg-color: #111827;
|
||||||
--card-bg: #ffffff;
|
--card-bg: #1f2937;
|
||||||
--text-color: #1f2937;
|
--text-color: #f9fafb;
|
||||||
--text-secondary: #6b7280;
|
--text-secondary: #9ca3af;
|
||||||
--primary-color: #3b82f6;
|
--primary-color: #60a5fa;
|
||||||
--primary-hover: #2563eb;
|
--primary-hover: #3b82f6;
|
||||||
--border-color: #e5e7eb;
|
--border-color: #374151;
|
||||||
--danger-color: #ef4444;
|
--danger-color: #ef4444;
|
||||||
--modal-bg: rgba(0, 0, 0, 0.8);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Dark Mode Variables */
|
|
||||||
[data-theme="dark"] {
|
|
||||||
--bg-color: #111827;
|
|
||||||
--card-bg: #1f2937;
|
|
||||||
--text-color: #f9fafb;
|
|
||||||
--text-secondary: #9ca3af;
|
|
||||||
--primary-color: #60a5fa;
|
|
||||||
--primary-hover: #3b82f6;
|
|
||||||
--border-color: #374151;
|
|
||||||
--modal-bg: rgba(0, 0, 0, 0.9);
|
--modal-bg: rgba(0, 0, 0, 0.9);
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) {
|
|
||||||
:root:not([data-theme="light"]) {
|
|
||||||
--bg-color: #111827;
|
|
||||||
--card-bg: #1f2937;
|
|
||||||
--text-color: #f9fafb;
|
|
||||||
--text-secondary: #9ca3af;
|
|
||||||
--primary-color: #60a5fa;
|
|
||||||
--primary-hover: #3b82f6;
|
|
||||||
--border-color: #374151;
|
|
||||||
--modal-bg: rgba(0, 0, 0, 0.9);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
body {
|
body {
|
||||||
font-family: 'Inter', sans-serif;
|
font-family: 'Inter', sans-serif;
|
||||||
background-color: var(--bg-color);
|
background-color: var(--bg-color);
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
FROM node:18-alpine
|
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
COPY package*.json ./
|
|
||||||
RUN npm install
|
|
||||||
|
|
||||||
COPY . .
|
|
||||||
|
|
||||||
# Expose port 3000
|
|
||||||
EXPOSE 3000
|
|
||||||
|
|
||||||
# Create uploads directory
|
|
||||||
RUN mkdir -p uploads
|
|
||||||
|
|
||||||
CMD ["node", "server.js"]
|
|
||||||
2165
uploads/Think/all/package-lock.json
generated
2165
uploads/Think/all/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,24 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "simple-file-server",
|
|
||||||
"version": "1.0.0",
|
|
||||||
"main": "server.js",
|
|
||||||
"scripts": {
|
|
||||||
"test": "echo \"Error: no test specified\" && exit 1",
|
|
||||||
"start": "node server.js"
|
|
||||||
},
|
|
||||||
"keywords": [],
|
|
||||||
"author": "",
|
|
||||||
"license": "ISC",
|
|
||||||
"description": "",
|
|
||||||
"dependencies": {
|
|
||||||
"adm-zip": "^0.5.16",
|
|
||||||
"archiver": "^7.0.1",
|
|
||||||
"bcryptjs": "^3.0.3",
|
|
||||||
"cors": "^2.8.6",
|
|
||||||
"dotenv": "^17.2.4",
|
|
||||||
"express": "^5.2.1",
|
|
||||||
"express-session": "^1.19.0",
|
|
||||||
"mariadb": "^3.4.5",
|
|
||||||
"multer": "^2.0.2"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
const express = require('express');
|
|
||||||
const cors = require('cors');
|
|
||||||
const path = require('path');
|
|
||||||
const session = require('express-session');
|
|
||||||
require('dotenv').config();
|
|
||||||
|
|
||||||
const { initUserTable } = require('./db/connection');
|
|
||||||
const authRoutes = require('./routes/auth');
|
|
||||||
const fileRoutes = require('./routes/files');
|
|
||||||
|
|
||||||
const app = express();
|
|
||||||
const PORT = process.env.PORT || 3000;
|
|
||||||
|
|
||||||
// Initialize DB
|
|
||||||
initUserTable();
|
|
||||||
|
|
||||||
// Middleware
|
|
||||||
app.use(cors());
|
|
||||||
app.use(express.json());
|
|
||||||
app.use(express.urlencoded({ extended: true }));
|
|
||||||
|
|
||||||
// Session
|
|
||||||
app.use(session({
|
|
||||||
secret: process.env.SESSION_SECRET || 'supersecretkey',
|
|
||||||
resave: false,
|
|
||||||
saveUninitialized: false,
|
|
||||||
cookie: { secure: false } // Set to true if using HTTPS
|
|
||||||
}));
|
|
||||||
|
|
||||||
// Auth Middleware
|
|
||||||
const requireAuth = (req, res, next) => {
|
|
||||||
if (req.session.user) {
|
|
||||||
next();
|
|
||||||
} else {
|
|
||||||
res.status(401).json({ error: 'Unauthorized' });
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Routes
|
|
||||||
app.use('/api/auth', authRoutes);
|
|
||||||
app.use('/api', requireAuth, fileRoutes);
|
|
||||||
|
|
||||||
// Static files (public) - protect if needed, but for now let's allow loading the app
|
|
||||||
// We can protect specific assets if we want, but the API is protected.
|
|
||||||
// Actually, if we want to force login, we can serve a login page or handle it in specific separate file.
|
|
||||||
// The main `index.html` handles the login UI, so it should be public.
|
|
||||||
app.use(express.static('public'));
|
|
||||||
|
|
||||||
app.listen(PORT, () => {
|
|
||||||
console.log(`Server running on port ${PORT}`);
|
|
||||||
});
|
|
||||||
Reference in New Issue
Block a user