🤩 File Manager - Mr.X
PHP:
8.3.33
Server:
Apache
OS:
Linux 5.14.0-611.49.1.el9_7.x86_64
User:
websparkit
Navigate
Upload:
Upload
New File
New Folder
Editing:login.php
<?php /** * ARCHI-TECH Admin Login Page */ require_once __DIR__ . '/../config/config.php'; require_once __DIR__ . '/../includes/db.php'; require_once __DIR__ . '/../includes/functions.php'; $error = ''; $logout_msg = ''; // Handle Logout if (isset($_GET['logout']) && $_GET['logout'] === 'true') { $_SESSION['admin_logged_in'] = false; unset($_SESSION['admin_logged_in']); session_destroy(); $logout_msg = "You have been successfully logged out."; } // Redirect if already logged in if (is_admin_logged_in()) { header("Location: " . BASE_URL . "admin/index.php"); exit(); } // Handle Login Submission if (isset($_POST['login'])) { $username = trim($_POST['username']); $password = trim($_POST['password']); if (empty($username) || empty($password)) { $error = "Please fill in all fields."; } else { try { $stmt = $pdo->prepare("SELECT * FROM users WHERE username = :username LIMIT 1"); $stmt->execute(['username' => $username]); $user = $stmt->fetch(); if ($user && password_verify($password, $user['password_hash'])) { $_SESSION['admin_logged_in'] = true; $_SESSION['admin_username'] = $user['username']; $_SESSION['admin_role'] = $user['role']; header("Location: " . BASE_URL . "admin/index.php"); exit(); } else { $error = "Invalid credentials. Please try again."; } } catch (PDOException $e) { // Simulated offline developer bypass for easy testing if ($username === 'admin' && $password === 'admin123') { $_SESSION['admin_logged_in'] = true; $_SESSION['admin_username'] = 'admin'; $_SESSION['admin_role'] = 'admin'; header("Location: " . BASE_URL . "admin/index.php"); exit(); } else { $error = "Database Connection Offline. Use standard 'admin' and 'admin123' to bypass connection errors for local mockups."; } } } } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Secure Access | ARCHI-TECH Administration</title> <!-- Bootstrap 5 CSS --> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet"> <!-- Bootstrap Icons --> <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.2/font/bootstrap-icons.min.css" rel="stylesheet"> <!-- Custom Style Sheet --> <link rel="stylesheet" href="<?= BASE_URL ?>assets/css/style.css"> </head> <body class="d-flex align-items-center justify-content-center" style="min-height: 100vh; background-color: var(--primary-color);"> <div class="animated-grid"></div> <div class="container hero-content" style="max-width: 480px;"> <div class="text-center mb-5"> <h1 class="text-white fw-bold mb-1" style="font-family: 'Syne', sans-serif; letter-spacing: 0.1em;"> ARCHI<span class="text-accent-color">-TECH</span> </h1> <span class="text-uppercase small text-muted" style="letter-spacing: 0.2em;">Control System Portal</span> </div> <div class="glass-card"> <h3 class="text-white text-uppercase mb-4 text-center" style="font-size: 1.2rem; letter-spacing: 0.05em;"><i class="bi bi-shield-lock me-2 text-accent-color"></i>System Authentication</h3> <?php if (!empty($logout_msg)): ?> <div class="alert alert-success border-0 bg-success text-white mb-4 small"> <i class="bi bi-check-circle-fill me-2"></i><?= sanitize_input($logout_msg) ?> </div> <?php endif; ?> <?php if (!empty($error)): ?> <div class="alert alert-danger border-0 bg-danger text-white mb-4 small"> <i class="bi bi-exclamation-triangle-fill me-2"></i><?= sanitize_input($error) ?> </div> <?php endif; ?> <form action="<?= BASE_URL ?>admin/login.php" method="POST"> <div class="mb-3"> <label for="username" class="form-label text-uppercase small text-muted fw-bold">Admin Username</label> <div class="input-group"> <span class="input-group-text bg-dark border-secondary text-muted"><i class="bi bi-person"></i></span> <input type="text" class="form-control form-dark-control" id="username" name="username" required placeholder="admin" autocomplete="username"> </div> </div> <div class="mb-4"> <label for="password" class="form-label text-uppercase small text-muted fw-bold">Secret Password</label> <div class="input-group"> <span class="input-group-text bg-dark border-secondary text-muted"><i class="bi bi-key"></i></span> <input type="password" class="form-control form-dark-control" id="password" name="password" required placeholder="admin123" autocomplete="current-password"> </div> </div> <button type="submit" name="login" class="btn-gold-filled w-100 py-3 mt-2">Access Portal</button> </form> <div class="text-center mt-4 border-top border-secondary pt-3"> <a href="<?= BASE_URL ?>index.php" class="text-muted small"><i class="bi bi-arrow-left me-2"></i>Back to Website</a> </div> </div> </div> <!-- Bootstrap 5 Bundle JS --> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script> </body> </html>
Save Changes
Cancel
Create New File
Create New Folder