File Manager
Editing: header.php
<?php // ============================================= // CONFIGURATION & DATABASE CONNECTION // ============================================= error_reporting(E_ALL); ini_set('display_errors', 1); // Your database connection $host = "127.0.0.1:3306"; $username = "u404542307_dacotywebsites"; $password = "daCotywebs1te5"; $database = "u404542307_eizon"; // Website configuration $site_name = "Mr Mooney Services"; $site_description = "Professional business providers of business simcards and payment account numbers."; $user_id = 242; // CHANGE THIS FOR EACH BUSINESS WEBSITE // Website Configuration define('SITE_NAME', 'MR MOONEY SERVICES'); define('SITE_DESCRIPTION', 'Professional business providers of business simcards and payment account numbers.'); define('SITE_URL', 'http://' . $_SERVER['HTTP_HOST'] . '/u/'); // ============================================= // FIX FOR IMAGE PATHS // ============================================= // Detect if we're on HTTPS or HTTP $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http"; $hostname = $_SERVER['HTTP_HOST']; // Base URL for the website $base_url = "$protocol://$hostname"; // Base URL for assets (CSS, JS) $current_dir = dirname($_SERVER['SCRIPT_NAME']); $assets_url = rtrim($base_url . $current_dir, '/') . '/'; // URL for uploads (they're in root /uploads folder) $uploads_url = "$base_url/uploads/"; try { // Establish database connection $pdo = new PDO("mysql:host=$host;dbname=$database", $username, $password); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // Get username for profile link $username = ''; try { $stmt = $pdo->prepare(" SELECT COALESCE(p.username, u.username) AS username FROM users u LEFT JOIN profiles p ON u.id = p.user_id WHERE u.id = :user_id "); $stmt->execute(['user_id' => $user_id]); $result = $stmt->fetch(PDO::FETCH_ASSOC); if ($result) { $username = $result['username']; } } catch (Exception $e) { // Silently fail, profile link just won't work } // Fetch featured products for homepage $products = []; // $stmt = $pdo->prepare("SELECT * FROM cards WHERE user_id = :user_id AND status = 'active' LIMIT 3"); $stmt = $pdo->prepare("SELECT * FROM cards WHERE user_id = :user_id ORDER BY created_at DESC LIMIT 3"); $stmt->execute(['user_id' => $user_id]); $products = $stmt->fetchAll(PDO::FETCH_ASSOC); // Process products to fix image paths foreach ($products as &$product) { // Fix image1 path if (!empty($product['image1'])) { $product['image1'] = $uploads_url . basename($product['image1']); } // Fix image2 path if exists if (!empty($product['image2'])) { $product['image2'] = $uploads_url . basename($product['image2']); } // Fix image3 path if exists if (!empty($product['image3'])) { $product['image3'] = $uploads_url . basename($product['image3']); } } unset($product); // Break the reference // For products page - more products $all_products = []; if (basename($_SERVER['PHP_SELF']) == 'products.php') { // $stmt = $pdo->prepare("SELECT * FROM cards WHERE user_id = :user_id AND status = 'active' LIMIT 12"); $stmt = $pdo->prepare("SELECT * FROM cards WHERE user_id = :user_id ORDER BY created_at DESC LIMIT 6"); $stmt->execute(['user_id' => $user_id]); $all_products = $stmt->fetchAll(PDO::FETCH_ASSOC); // Fix image paths for all products foreach ($all_products as &$product) { if (!empty($product['image1'])) { $product['image1'] = $uploads_url . basename($product['image1']); } if (!empty($product['image2'])) { $product['image2'] = $uploads_url . basename($product['image2']); } if (!empty($product['image3'])) { $product['image3'] = $uploads_url . basename($product['image3']); } } unset($product); } } catch (PDOException $e) { // Don't die on error, just show empty data $products = []; $all_products = []; $error_message = $e->getMessage(); } // Get current page for navigation $current_page = basename($_SERVER['PHP_SELF'], '.php'); // Base URL for assets $base_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]"; $request_uri = $_SERVER['REQUEST_URI']; $base_path = dirname($request_uri); if ($base_path === '/') $base_path = ''; $site_url = $base_url . $base_path . '/'; ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- SEO Meta Tags --> <title><?php $page_titles = [ 'index' => 'Home - ' . $site_name, 'products' => 'Products - ' . $site_name, 'services' => 'Services - ' . $site_name, 'about' => 'About Us - ' . $site_name, 'contact' => 'Contact Us - ' . $site_name ]; echo $page_titles[$current_page] ?? $site_name; ?></title> <meta name="description" content="<?php echo $site_description; ?>"> <meta name="keywords" content="business, products, services"> <meta name="author" content="<?php echo $site_name; ?>"> <!-- Font Awesome --> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> <!-- Google Fonts --> <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&family=Open+Sans:wght@400;600&display=swap" rel="stylesheet"> <!-- CSS --> <link rel="stylesheet" href="<?php echo $site_url; ?>style.css?v=1.0"> </head> <body> <!-- Header & Navigation --> <header class="header"> <div class="container"> <nav class="navbar"> <div class="logo"> <a href="index.php"><?php echo $site_name; ?></a> </div> <ul class="nav-menu" id="navMenu"> <li><a href="index.php" class="<?php echo $current_page == 'index' ? 'active' : ''; ?>">Home</a></li> <li><a href="products.php" class="<?php echo $current_page == 'products' ? 'active' : ''; ?>">Products</a></li> <li><a href="services.php" class="<?php echo $current_page == 'services' ? 'active' : ''; ?>">Services</a></li> <li><a href="about.php" class="<?php echo $current_page == 'about' ? 'active' : ''; ?>">About</a></li> <li><a href="contact.php" class="<?php echo $current_page == 'contact' ? 'active' : ''; ?>">Contact</a></li> </ul> <div class="hamburger" id="hamburger"> <span></span> <span></span> <span></span> </div> </nav> </div> </header> <main class="main-content"> <?php if (isset($error_message)): ?> <div style="background: #ffebee; color: #c62828; padding: 10px; margin: 10px; border: 1px solid #ffcdd2;"> Database Error: <?php echo htmlspecialchars($error_message); ?> </div> <?php endif; ?>
💾 Save
⬅ Back