first commit
Some checks failed
Vulhub Format Check and Lint / format-check (push) Has been cancelled
Vulhub Format Check and Lint / markdown-check (push) Has been cancelled
Vulhub Docker Image CI / longtime-images-test (push) Has been cancelled
Vulhub Docker Image CI / images-test (push) Has been cancelled

This commit is contained in:
2025-09-06 16:08:15 +08:00
commit 63285f61aa
2624 changed files with 88491 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
import "bootstrap/dist/css/bootstrap.min.css";
export const metadata = {
title: "Admin Dashboard",
description: "Admin Dashboard for Next.js",
};
export default function RootLayout({ children }) {
return (
<html lang="en" suppressHydrationWarning>
<body>{children}</body>
</html>
);
}

View File

@@ -0,0 +1,83 @@
"use client";
import { useState } from "react";
import { useRouter } from "next/navigation";
export default function Login() {
const [username, setUsername] = useState("");
const [password, setPassword] = useState("");
const [error, setError] = useState("");
const router = useRouter();
const handleSubmit = async (e) => {
e.preventDefault();
// Simple validation
if (!username || !password) {
setError("Username and password are required");
return;
}
// Set login cookie (expires in 24 hours)
document.cookie = `next_username=${username}; path=/; max-age=${
60 * 60
}; SameSite=Strict`;
document.cookie = `next_password=${password}; path=/; max-age=${
60 * 60
}; SameSite=Strict`;
console.log("Cookie set", username, password);
router.push("/"); // Redirect to dashboard
};
return (
<div className="container-fluid bg-light min-vh-100 d-flex align-items-center justify-content-center">
<div className="card shadow p-4" style={{ maxWidth: "400px" }}>
<div className="card-body">
<h1 className="card-title text-center mb-4 fw-bold">Admin Login</h1>
{error && (
<div className="alert alert-danger" role="alert">
{error}
</div>
)}
<form onSubmit={handleSubmit}>
<div className="mb-3">
<label htmlFor="username" className="form-label">
Username
</label>
<input
id="username"
type="text"
className="form-control"
value={username}
onChange={(e) => setUsername(e.target.value)}
/>
</div>
<div className="mb-4">
<label htmlFor="password" className="form-label">
Password
</label>
<input
id="password"
type="password"
className="form-control"
value={password}
onChange={(e) => setPassword(e.target.value)}
/>
</div>
<button type="submit" className="btn btn-primary w-100">
Login
</button>
</form>
<div className="mt-3 text-center text-muted small">
<p>Demo credentials: admin / password</p>
</div>
</div>
</div>
</div>
);
}

View File

@@ -0,0 +1,86 @@
import { cookies } from "next/headers";
import Topbar from "../components/topbar";
export default async function Home() {
const cookieStore = await cookies();
const username = cookieStore.get("next_username")?.value;
return (
<div className="min-vh-100 bg-light">
<nav className="navbar navbar-expand-lg navbar-light bg-white shadow-sm">
<div className="container">
<a className="navbar-brand fw-semibold" href="#">
Admin Dashboard
</a>
<div className="ms-auto">{username && <Topbar />}</div>
</div>
</nav>
<div className="container py-4">
<div className="row">
<div className="col-md-12">
<div className="card border-4 border-light border-opacity-50 bg-white p-4">
<div className="card-body">
<h2 className="card-title fs-4 fw-semibold mb-3">
Dashboard Content
</h2>
<p className="card-text">
This is a protected page that only authenticated users can
access.
</p>
<p className="card-text text-muted mt-2">
In a real application, you would display important data and
admin controls here.
</p>
</div>
</div>
</div>
</div>
<div className="row mt-4">
<div className="col-md-4 mb-4">
<div className="card h-100">
<div className="card-body">
<h5 className="card-title">Users</h5>
<p className="card-text">
Manage user accounts and permissions.
</p>
<button className="btn btn-outline-primary">
Manage Users
</button>
</div>
</div>
</div>
<div className="col-md-4 mb-4">
<div className="card h-100">
<div className="card-body">
<h5 className="card-title">Content</h5>
<p className="card-text">
Edit website content and media files.
</p>
<button className="btn btn-outline-primary">
Edit Content
</button>
</div>
</div>
</div>
<div className="col-md-4 mb-4">
<div className="card h-100">
<div className="card-body">
<h5 className="card-title">Settings</h5>
<p className="card-text">
Configure system settings and preferences.
</p>
<button className="btn btn-outline-primary">
System Settings
</button>
</div>
</div>
</div>
</div>
</div>
</div>
);
}