🤩 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:functions.php
<?php /** * ARCHI-TECH Global Helper Functions */ require_once __DIR__ . '/db.php'; /** * Fetch a setting from the settings table with static caching */ function get_setting($key, $default = '') { global $pdo; static $settings_cache = null; if ($settings_cache === null) { $settings_cache = []; try { $stmt = $pdo->query("SELECT setting_key, setting_value FROM settings"); while ($row = $stmt->fetch()) { $settings_cache[$row['setting_key']] = $row['setting_value']; } } catch (Exception $e) { // Silent fallback in case DB schema is not loaded yet return $default; } } return isset($settings_cache[$key]) ? $settings_cache[$key] : $default; } /** * Sanitize user input to protect against XSS */ function sanitize_input($data) { if (is_array($data)) { return array_map('sanitize_input', $data); } return htmlspecialchars(trim($data), ENT_QUOTES, 'UTF-8'); } /** * Check if the active script matches the link to apply high-luxury navigation highlights */ function is_active_nav($page_name) { $current_script = basename($_SERVER['SCRIPT_NAME']); return ($current_script === $page_name) ? 'active' : ''; } /** * Format date for high-end portfolio grids */ function format_project_date($date_str) { if (empty($date_str)) return 'In Progress'; $date = date_create($date_str); return date_format($date, 'F Y'); } /** * Authenticate Admin Session */ function is_admin_logged_in() { return isset($_SESSION['admin_logged_in']) && $_SESSION['admin_logged_in'] === true; } /** * Restrict page access for logged-in administrators */ function check_admin_auth() { if (!is_admin_logged_in()) { header("Location: " . BASE_URL . "admin/login.php"); exit(); } } /** * Clean URL slug generation helper */ function slugify($text) { $text = preg_replace('~[^\pL\d]+~u', '-', $text); $text = iconv('utf-8', 'us-ascii//TRANSLIT', $text); $text = preg_replace('~[^-\w]+~', '', $text); $text = trim($text, '-'); $text = preg_replace('~-+~', '-', $text); $text = strtolower($text); if (empty($text)) { return 'n-a'; } return $text; }
Save Changes
Cancel
Create New File
Create New Folder