🤩 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:settings.php
<?php /** * ARCHI-TECH Admin Global Settings Options */ require_once __DIR__ . '/../includes/db.php'; require_once __DIR__ . '/../includes/functions.php'; check_admin_auth(); $success_msg = ''; $error_msg = ''; // Handle Global Options Submit if (isset($_POST['submit_settings'])) { $company_name = trim($_POST['company_name']); $address = trim($_POST['address']); $phone = trim($_POST['phone']); $email = trim($_POST['email']); $maps_embed = trim($_POST['maps_embed']); $facebook = trim($_POST['facebook']); $instagram = trim($_POST['instagram']); $linkedin = trim($_POST['linkedin']); try { $stmt = $pdo->prepare("INSERT INTO settings (setting_key, setting_value) VALUES (:key, :value) ON DUPLICATE KEY UPDATE setting_value = :value_update"); $stmt->execute(['key' => 'company_name', 'value' => $company_name, 'value_update' => $company_name]); $stmt->execute(['key' => 'address', 'value' => $address, 'value_update' => $address]); $stmt->execute(['key' => 'phone', 'value' => $phone, 'value_update' => $phone]); $stmt->execute(['key' => 'email', 'value' => $email, 'value_update' => $email]); $stmt->execute(['key' => 'maps_embed', 'value' => $maps_embed, 'value_update' => $maps_embed]); $stmt->execute(['key' => 'facebook', 'value' => $facebook, 'value_update' => $facebook]); $stmt->execute(['key' => 'instagram', 'value' => $instagram, 'value_update' => $instagram]); $stmt->execute(['key' => 'linkedin', 'value' => $linkedin, 'value_update' => $linkedin]); $success_msg = "Global settings configurations updated successfully."; } catch (PDOException $e) { $error_msg = "Database Error: " . $e->getMessage(); } } // Handle Admin Password Reset Submit if (isset($_POST['submit_password'])) { $new_pass = trim($_POST['new_password']); $confirm_pass = trim($_POST['confirm_password']); if (empty($new_pass) || empty($confirm_pass)) { $error_msg = "Password inputs cannot be empty."; } elseif ($new_pass !== $confirm_pass) { $error_msg = "Passwords do not match."; } elseif (strlen($new_pass) < 6) { $error_msg = "Password must be at least 6 characters long."; } else { try { $hashed = password_hash($new_pass, PASSWORD_DEFAULT); $stmt = $pdo->prepare("UPDATE users SET password_hash = :hash WHERE username = :user"); $stmt->execute([ 'hash' => $hashed, 'user' => $_SESSION['admin_username'] ]); $success_msg = "Administrator password successfully updated."; } 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;">Site Settings</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 g-4"> <!-- Left Column: Site Info Settings --> <div class="col-lg-7"> <div class="glass-card"> <h3 class="h5 text-white text-uppercase mb-4" style="letter-spacing: 0.05em;"><i class="bi bi-sliders text-accent-color me-2"></i>Global Properties</h3> <form action="<?= BASE_URL ?>admin/settings.php" method="POST"> <div class="mb-3"> <label for="company_name" class="form-label text-uppercase small text-muted fw-bold">Company Name</label> <input type="text" class="form-control form-dark-control" id="company_name" name="company_name" required value="<?= sanitize_input(get_setting('company_name', 'ARCHI-TECH')) ?>"> </div> <div class="row"> <div class="col-md-6 mb-3"> <label for="phone" class="form-label text-uppercase small text-muted fw-bold">Contact Phone Number</label> <input type="text" class="form-control form-dark-control" id="phone" name="phone" required value="<?= sanitize_input(get_setting('phone', '')) ?>"> </div> <div class="col-md-6 mb-3"> <label for="email" class="form-label text-uppercase small text-muted fw-bold">Contact Email Address</label> <input type="email" class="form-control form-dark-control" id="email" name="email" required value="<?= sanitize_input(get_setting('email', '')) ?>"> </div> </div> <div class="mb-3"> <label for="address" class="form-label text-uppercase small text-muted fw-bold">Studio Physical Address</label> <input type="text" class="form-control form-dark-control" id="address" name="address" required value="<?= sanitize_input(get_setting('address', '')) ?>"> </div> <div class="mb-3"> <label for="maps_embed" class="form-label text-uppercase small text-muted fw-bold">Google Maps Embed URL (src parameter only)</label> <textarea class="form-control form-dark-control" id="maps_embed" name="maps_embed" rows="3"><?= sanitize_input(get_setting('maps_embed', '')) ?></textarea> </div> <h5 class="text-accent-color text-uppercase small fw-bold border-bottom border-secondary pb-2 mb-3 mt-4">Social Media Handles</h5> <div class="row"> <div class="col-md-4 mb-3"> <label for="facebook" class="form-label text-uppercase small text-muted fw-bold">Facebook URL</label> <input type="url" class="form-control form-dark-control" id="facebook" name="facebook" value="<?= sanitize_input(get_setting('facebook', '#')) ?>"> </div> <div class="col-md-4 mb-3"> <label for="instagram" class="form-label text-uppercase small text-muted fw-bold">Instagram URL</label> <input type="url" class="form-control form-dark-control" id="instagram" name="instagram" value="<?= sanitize_input(get_setting('instagram', '#')) ?>"> </div> <div class="col-md-4 mb-3"> <label for="linkedin" class="form-label text-uppercase small text-muted fw-bold">LinkedIn URL</label> <input type="url" class="form-control form-dark-control" id="linkedin" name="linkedin" value="<?= sanitize_input(get_setting('linkedin', '#')) ?>"> </div> </div> <div class="text-end pt-3 mt-4 border-top border-secondary"> <button type="submit" name="submit_settings" class="btn-gold-filled px-4">Update Configuration Settings</button> </div> </form> </div> </div> <!-- Right Column: Reset password --> <div class="col-lg-5"> <div class="glass-card"> <h3 class="h5 text-white text-uppercase mb-4" style="letter-spacing: 0.05em;"><i class="bi bi-shield-lock text-accent-color me-2"></i>Change password</h3> <form action="<?= BASE_URL ?>admin/settings.php" method="POST"> <div class="mb-3"> <label for="new_password" class="form-label text-uppercase small text-muted fw-bold">New Secret Password</label> <input type="password" class="form-control form-dark-control" id="new_password" name="new_password" required minlength="6" placeholder="Enter new password"> </div> <div class="mb-4"> <label for="confirm_password" class="form-label text-uppercase small text-muted fw-bold">Confirm Secret Password</label> <input type="password" class="form-control form-dark-control" id="confirm_password" name="confirm_password" required minlength="6" placeholder="Confirm new password"> </div> <button type="submit" name="submit_password" class="btn btn-gold w-100 py-3 mt-2 text-uppercase fw-bold" style="font-size: 0.85rem; letter-spacing: 0.05em;">Reset Security Credentials</button> </form> </div> <div class="glass-card mt-4"> <h5 class="text-accent-color text-uppercase mb-3"><i class="bi bi-info-circle me-2"></i>Site Info</h5> <p class="small text-white-50 mb-0">Changes saved here are cached dynamically inside static memory buffers in the backend helper functions, reducing SQL database load times significantly.</p> </div> </div> </div> <?php require_once __DIR__ . '/footer.php'; ?>
Save Changes
Cancel
Create New File
Create New Folder