🤩 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:homepage.php
<?php /** * ARCHI-TECH Admin Homepage Customizer */ require_once __DIR__ . '/../includes/db.php'; require_once __DIR__ . '/../includes/functions.php'; check_admin_auth(); $success_msg = ''; $error_msg = ''; // Handle Settings Update if (isset($_POST['submit_homepage'])) { $hero_title = trim($_POST['hero_title']); $hero_subtitle = trim($_POST['hero_subtitle']); $slogan = trim($_POST['slogan']); $vision = trim($_POST['vision']); $mission = trim($_POST['mission']); try { // Prepare query $stmt = $pdo->prepare("INSERT INTO settings (setting_key, setting_value) VALUES (:key, :value) ON DUPLICATE KEY UPDATE setting_value = :value_update"); $stmt->execute(['key' => 'hero_title', 'value' => $hero_title, 'value_update' => $hero_title]); $stmt->execute(['key' => 'hero_subtitle', 'value' => $hero_subtitle, 'value_update' => $hero_subtitle]); $stmt->execute(['key' => 'slogan', 'value' => $slogan, 'value_update' => $slogan]); $stmt->execute(['key' => 'vision', 'value' => $vision, 'value_update' => $vision]); $stmt->execute(['key' => 'mission', 'value' => $mission, 'value_update' => $mission]); // Handle hero background image replacement if (isset($_FILES['hero_image']) && $_FILES['hero_image']['error'] === UPLOAD_ERR_OK) { $allowed = ['image/jpeg', 'image/png', 'image/webp', 'image/jpg']; if (in_array($_FILES['hero_image']['type'], $allowed)) { // Remove original first $orig_bg = get_setting('hero_image', 'assets/images/hero-bg.jpg'); if (file_exists(__DIR__ . '/../' . $orig_bg) && strpos($orig_bg, 'default') === false) { @unlink(__DIR__ . '/../' . $orig_bg); } $ext = pathinfo($_FILES['hero_image']['name'], PATHINFO_EXTENSION); $filename = 'hero_' . bin2hex(random_bytes(4)) . '.' . $ext; $destination = __DIR__ . '/../assets/images/' . $filename; if (move_uploaded_file($_FILES['hero_image']['tmp_name'], $destination)) { $db_path = 'assets/images/' . $filename; $stmt->execute(['key' => 'hero_image', 'value' => $db_path, 'value_update' => $db_path]); } } else { $error_msg = "Hero image file type invalid. Only JPG, PNG, and WebP are allowed."; } } if (empty($error_msg)) { $success_msg = "Homepage blocks updated successfully."; } } catch (PDOException $e) { $error_msg = "Database Error: " . $e->getMessage(); } } require_once __DIR__ . '/header.php'; require_once __DIR__ . '/navbar.php'; ?> <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-4 border-bottom border-secondary"> <h1 class="h2 text-white text-uppercase" style="letter-spacing: -0.01em; font-family: 'Syne', sans-serif;">Customize Homepage</h1> </div> <!-- Notice Alerts --> <?php if (!empty($success_msg)): ?> <div class="alert alert-success border-0 bg-success text-white mb-4"> <i class="bi bi-check-circle-fill me-2"></i><?= sanitize_input($success_msg) ?> </div> <?php endif; ?> <?php if (!empty($error_msg)): ?> <div class="alert alert-danger border-0 bg-danger text-white mb-4"> <i class="bi bi-exclamation-triangle-fill me-2"></i><?= sanitize_input($error_msg) ?> </div> <?php endif; ?> <div class="row justify-content-center"> <div class="col-lg-10"> <div class="glass-card"> <h3 class="h5 text-white text-uppercase mb-4" style="letter-spacing: 0.05em;"><i class="bi bi-palette text-accent-color me-2"></i>Homepage Blocks</h3> <form action="<?= BASE_URL ?>admin/homepage.php" method="POST" enctype="multipart/form-data"> <h5 class="text-accent-color text-uppercase small fw-bold border-bottom border-secondary pb-2 mb-3">1. Hero Showcase Block</h5> <div class="mb-3"> <label for="hero_title" class="form-label text-uppercase small text-muted fw-bold">Hero Title Tagline</label> <input type="text" class="form-control form-dark-control" id="hero_title" name="hero_title" required value="<?= sanitize_input(get_setting('hero_title', 'Shaping the Skylines of Tomorrow')) ?>"> </div> <div class="mb-3"> <label for="hero_subtitle" class="form-label text-uppercase small text-muted fw-bold">Hero Subtitle Description</label> <textarea class="form-control form-dark-control" id="hero_subtitle" name="hero_subtitle" rows="3" required><?= sanitize_input(get_setting('hero_subtitle', '')) ?></textarea> </div> <div class="mb-4"> <label for="hero_image" class="form-label text-uppercase small text-muted fw-bold">Hero Fullscreen Background Image</label> <input type="file" class="form-control form-dark-control" id="hero_image" name="hero_image"> <small class="text-muted">Currently active: <?= basename(get_setting('hero_image', 'hero-bg.jpg')) ?></small> </div> <h5 class="text-accent-color text-uppercase small fw-bold border-bottom border-secondary pb-2 mb-3 mt-5">2. Slogan, Vision & Mission Blocks</h5> <div class="mb-3"> <label for="slogan" class="form-label text-uppercase small text-muted fw-bold">Company Slogan</label> <input type="text" class="form-control form-dark-control" id="slogan" name="slogan" required value="<?= sanitize_input(get_setting('slogan', 'Innovative Designs. Lasting Impressions')) ?>"> </div> <div class="row"> <div class="col-md-6 mb-3"> <label for="vision" class="form-label text-uppercase small text-muted fw-bold">Our Vision Statement</label> <textarea class="form-control form-dark-control" id="vision" name="vision" rows="4" required><?= sanitize_input(get_setting('vision', '')) ?></textarea> </div> <div class="col-md-6 mb-3"> <label for="mission" class="form-label text-uppercase small text-muted fw-bold">Our Mission Statement</label> <textarea class="form-control form-dark-control" id="mission" name="mission" rows="4" required><?= sanitize_input(get_setting('mission', '')) ?></textarea> </div> </div> <div class="text-end pt-4 border-top border-secondary mt-4"> <a href="<?= BASE_URL ?>admin/index.php" class="btn btn-outline-light me-2">Cancel</a> <button type="submit" name="submit_homepage" class="btn-gold-filled px-4">Update Homepage Copy</button> </div> </form> </div> </div> </div> <?php require_once __DIR__ . '/footer.php'; ?>
Save Changes
Cancel
Create New File
Create New Folder