CoffreFortV1.1

This commit is contained in:
Flatlogic Bot 2025-10-07 17:07:28 +00:00
parent f29fa66d41
commit d63ebb2066
5 changed files with 224 additions and 88 deletions

View File

@ -0,0 +1,11 @@
CREATE TABLE IF NOT EXISTS `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(50) NOT NULL,
`password` varchar(255) NOT NULL,
`email` varchar(100) NOT NULL,
`role` enum('Admin','User/Member','Viewer','Auditor') NOT NULL DEFAULT 'User/Member',
`created_at` datetime DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `username` (`username`),
UNIQUE KEY `email` (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

View File

@ -1,4 +1,4 @@
<!DOCTYPE html>
<?php if (session_status() == PHP_SESSION_NONE) { session_start(); } ?><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
@ -42,9 +42,18 @@
<li class="nav-item">
<a class="nav-link" href="index.php#contact">Contact</a>
</li>
<li class="nav-item">
<a class="btn btn-outline-primary ms-lg-2" href="#">Login</a>
</li>
<?php if (isset($_SESSION['user_id'])): ?>
<li class="nav-item">
<a class="nav-link" href="#">Welcome, <?php echo htmlspecialchars($_SESSION['username']); ?></a>
</li>
<li class="nav-item">
<a class="btn btn-outline-primary ms-lg-2" href="logout.php">Logout</a>
</li>
<?php else: ?>
<li class="nav-item">
<a class="btn btn-outline-primary ms-lg-2" href="login.php">Login</a>
</li>
<?php endif; ?>
</ul>
</div>
</div>

213
index.php
View File

@ -1,106 +1,153 @@
<?php include 'includes/header.php'; ?>
<!-- Hero Section -->
<header class="hero text-center">
<div class="container">
<h1 class="display-3 fw-bold">Securely Share Your Documents</h1>
<p class="lead my-4">A professional, simple, and secure platform for sharing files with your team and clients.</p>
<a href="#contact" class="btn btn-primary btn-lg">Get Started</a>
<a href="#" class="btn btn-secondary btn-lg">Login</a>
</div>
</header>
<?php if (isset($_SESSION['user_id'])): ?>
<!-- About Section -->
<section id="about" class="section bg-white">
<div class="container">
<div class="row align-items-center">
<div class="col-lg-6">
<h2 class="fw-bold">Your Private Document Hub</h2>
<p class="lead text-muted">CoffreFort provides a secure environment where you can upload, manage, and share your important files. Say goodbye to insecure email attachments and consumer-grade file sharing services.</p>
<p>Built for businesses and professionals who need control and visibility over their shared data. Manage users, set permissions, and track activity with ease.</p>
</div>
<div class="col-lg-6 text-center">
<img src="https://picsum.photos/seed/about/800/600" class="img-fluid rounded shadow-lg" alt="A modern office environment with professionals collaborating.">
</div>
</div>
</div>
</section>
<div class="container mt-5 pt-5">
<h1 class="display-5">Welcome to your Dashboard, <?php echo htmlspecialchars($_SESSION['username']); ?>!</h1>
<p class="lead">This is your private area. More features will be added soon.</p>
<!-- Features Section -->
<section id="features" class="section">
<div class="container">
<div class="text-center mb-5">
<h2 class="fw-bold">Features Designed for Security and Ease of Use</h2>
<p class="lead text-muted">Everything you need to collaborate securely.</p>
</div>
<div class="row">
<div class="col-md-4 mb-4">
<div class="card h-100 text-center p-4">
<?php if ($_SESSION['role'] === 'Admin'): ?>
<div class="alert alert-info">
You are logged in as an <strong>Admin</strong>. You have full access to the system.
</div>
<?php endif; ?>
<div class="row mt-5">
<div class="col-md-4">
<div class="card">
<div class="card-body">
<i class="bi bi-shield-lock-fill fs-1 text-primary"></i>
<h3 class="card-title h4 mt-3">Admin User Creation</h3>
<p class="card-text">Admins have full control over user accounts, ensuring only authorized individuals can access the system. Self-registration is disabled to maintain a secure, private environment.</p>
<h5 class="card-title">Documents</h5>
<p class="card-text">Manage your documents here.</p>
<a href="#" class="btn btn-primary">Go to Documents</a>
</div>
</div>
</div>
<div class="col-md-4 mb-4">
<div class="card h-100 text-center p-4">
<div class="col-md-4">
<div class="card">
<div class="card-body">
<i class="bi bi-people-fill fs-1 text-primary"></i>
<h3 class="card-title h4 mt-3">Role-Based Access</h3>
<p class="card-text">Assign roles like Admin, User, Viewer, and Auditor to manage permissions effectively. Each role has specific capabilities, from full control to view-only access.</p>
<h5 class="card-title">Users</h5>
<p class="card-text">Manage users here.</p>
<a href="#" class="btn btn-primary">Go to Users</a>
</div>
</div>
</div>
<div class="col-md-4 mb-4">
<div class="card h-100 text-center p-4">
<div class="col-md-4">
<div class="card">
<div class="card-body">
<i class="bi bi-clock-history fs-1 text-primary"></i>
<h3 class="card-title h4 mt-3">Audit Logs & Alerts</h3>
<p class="card-text">Keep track of all activity with detailed audit logs. Receive automated alerts for important events like new user sign-ups and storage quotas nearing their limit.</p>
<h5 class="card-title">Settings</h5>
<p class="card-text">System settings.</p>
<a href="#" class="btn btn-primary">Go to Settings</a>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- Contact Section -->
<section id="contact" class="section bg-white">
<div class="container">
<div class="row">
<div class="col-lg-8 mx-auto text-center">
<h2 class="fw-bold">Get in Touch</h2>
<p class="lead text-muted mb-5">Have questions? We'd love to hear from you. Fill out the form below and we'll get back to you as soon as possible.</p>
<form id="contactForm" class="needs-validation" novalidate>
<div class="row g-3">
<div class="col-md-6">
<div class="form-floating">
<input type="text" class="form-control" id="name" placeholder="Your Name" required>
<label for="name">Your Name</label>
<div class="invalid-feedback">A name is required.</div>
</div>
</div>
<div class="col-md-6">
<div class="form-floating">
<input type="email" class="form-control" id="email" placeholder="Your Email" required>
<label for="email">Your Email</label>
<div class="invalid-feedback">A valid email is required.</div>
</div>
</div>
<div class="col-12">
<div class="form-floating">
<textarea class="form-control" id="message" placeholder="Your Message" style="height: 150px;" required></textarea>
<label for="message">Your Message</label>
<div class="invalid-feedback">A message is required.</div>
</div>
</div>
</div>
<button type="submit" class="btn btn-primary btn-lg mt-4">Send Message</button>
</form>
<?php else: ?>
<!-- Hero Section -->
<header class="hero text-center">
<div class="container">
<h1 class="display-3 fw-bold">Securely Share Your Documents</h1>
<p class="lead my-4">A professional, simple, and secure platform for sharing files with your team and clients.</p>
<a href="#contact" class="btn btn-primary btn-lg">Get Started</a>
<a href="login.php" class="btn btn-secondary btn-lg">Login</a>
</div>
</header>
<!-- About Section -->
<section id="about" class="section bg-white">
<div class="container">
<div class="row align-items-center">
<div class="col-lg-6">
<h2 class="fw-bold">Your Private Document Hub</h2>
<p class="lead text-muted">CoffreFort provides a secure environment where you can upload, manage, and share your important files. Say goodbye to insecure email attachments and consumer-grade file sharing services.</p>
<p>Built for businesses and professionals who need control and visibility over their shared data. Manage users, set permissions, and track activity with ease.</p>
</div>
<div class="col-lg-6 text-center">
<img src="https://picsum.photos/seed/about/800/600" class="img-fluid rounded shadow-lg" alt="A modern office environment with professionals collaborating.">
</div>
</div>
</div>
</div>
</section>
</section>
<!-- Features Section -->
<section id="features" class.section">
<div class="container">
<div class="text-center mb-5">
<h2 class="fw-bold">Features Designed for Security and Ease of Use</h2>
<p class="lead text-muted">Everything you need to collaborate securely.</p>
</div>
<div class="row">
<div class="col-md-4 mb-4">
<div class="card h-100 text-center p-4">
<div class="card-body">
<i class="bi bi-shield-lock-fill fs-1 text-primary"></i>
<h3 class="card-title h4 mt-3">Admin User Creation</h3>
<p class="card-text">Admins have full control over user accounts, ensuring only authorized individuals can access the system. Self-registration is disabled to maintain a secure, private environment.</p>
</div>
</div>
</div>
<div class="col-md-4 mb-4">
<div class="card h-100 text-center p-4">
<div class="card-body">
<i class="bi bi-people-fill fs-1 text-primary"></i>
<h3 class="card-title h4 mt-3">Role-Based Access</h3>
<p class="card-text">Assign roles like Admin, User, Viewer, and Auditor to manage permissions effectively. Each role has specific capabilities, from full control to view-only access.</p>
</div>
</div>
</div>
<div class="col-md-4 mb-4">
<div class="card h-100 text-center p-4">
<div class="card-body">
<i class="bi bi-clock-history fs-1 text-primary"></i>
<h3 class="card-title h4 mt-3">Audit Logs & Alerts</h3>
<p class="card-text">Keep track of all activity with detailed audit logs. Receive automated alerts for important events like new user sign-ups and storage quotas nearing their limit.</p>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- Contact Section -->
<section id="contact" class="section bg-white">
<div class="container">
<div class="row">
<div class="col-lg-8 mx-auto text-center">
<h2 class="fw-bold">Get in Touch</h2>
<p class="lead text-muted mb-5">Have questions? We'd love to hear from you. Fill out the form below and we'll get back to you as soon as possible.</p>
<form id="contactForm" class="needs-validation" novalidate>
<div class="row g-3">
<div class="col-md-6">
<div class="form-floating">
<input type="text" class="form-control" id="name" placeholder="Your Name" required>
<label for="name">Your Name</label>
<div class="invalid-feedback">A name is required.</div>
</div>
</div>
<div class="col-md-6">
<div class="form-floating">
<input type="email" class="form-control" id="email" placeholder="Your Email" required>
<label for="email">Your Email</label>
<div class="invalid-feedback">A valid email is required.</div>
</div>
</div>
<div class="col-12">
<div class="form-floating">
<textarea class="form-control" id="message" placeholder="Your Message" style="height: 150px;" required></textarea>
<label for="message">Your Message</label>
<div class="invalid-feedback">A message is required.</div>
</div>
</div>
</div>
<button type="submit" class="btn btn-primary btn-lg mt-4">Send Message</button>
</form>
</div>
</div>
</div>
</section>
<?php endif; ?>
<?php include 'includes/footer.php'; ?>

62
login.php Normal file
View File

@ -0,0 +1,62 @@
<?php
session_start();
require_once 'db/config.php';
$error = '';
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if (empty($_POST['username']) || empty($_POST['password'])) {
$error = 'Username and password are required.';
} else {
try {
$stmt = db()->prepare("SELECT * FROM users WHERE username = ?");
$stmt->execute([$_POST['username']]);
$user = $stmt->fetch();
if ($user && password_verify($_POST['password'], $user['password'])) {
$_SESSION['user_id'] = $user['id'];
$_SESSION['username'] = $user['username'];
$_SESSION['role'] = $user['role'];
header('Location: index.php');
exit;
} else {
$error = 'Invalid credentials.';
}
} catch (PDOException $e) {
$error = "Database error: " . $e->getMessage();
}
}
}
include 'includes/header.php';
?>
<div class="container mt-5">
<div class="row justify-content-center">
<div class="col-md-6">
<div class="card">
<div class="card-header">
<h4>Login</h4>
</div>
<div class="card-body">
<?php if ($error): ?>
<div class="alert alert-danger"><?php echo $error; ?></div>
<?php endif; ?>
<form action="login.php" method="post">
<div class="mb-3">
<label for="username" class="form-label">Username</label>
<input type="text" class="form-control" id="username" name="username" required>
</div>
<div class="mb-3">
<label for="password" class="form-label">Password</label>
<input type="password" class="form-control" id="password" name="password" required>
</div>
<button type="submit" class="btn btn-primary">Login</button>
</form>
</div>
</div>
</div>
</div>
</div>
<?php include 'includes/footer.php'; ?>

7
logout.php Normal file
View File

@ -0,0 +1,7 @@
<?php
session_start();
session_unset();
session_destroy();
header('Location: index.php');
exit;
?>