Sindbad~EG File Manager

Current Path : /home/u625735752/domains/floralwhite-woodpecker-723030.hostingersite.com/public_html/
Upload File :
Current File : /home/u625735752/domains/floralwhite-woodpecker-723030.hostingersite.com/public_html/programmes.php

<!DOCTYPE html>
<html lang="en">
<?php
// Include your database connection
include 'conn.php';

// --- 1. SETTINGS & DEFAULTS ---

// !! IMPORTANT: SET YOUR WEBSITE'S BASE URL HERE
$base_url = 'https://www.example.com'; // Change this to your live domain

// Set the unique key for this page (from the 'seo_meta' table)
$page_key = 'about'; // CHANGED FOR THIS PAGE

// Set default values for mandatory tags
$default_title = 'About Us | JAM ON'; // CHANGED FOR THIS PAGE
$default_description = 'Learn more about Jam-On FM, our team, and our mission to bring you the best in urban music.'; // CHANGED FOR THIS PAGE


// --- 2. FETCH SEO DATA ---

// Fetch Global Site-Wide Settings (from id=1)
$global_seo = [];
$global_res = $mysqli->query("SELECT * FROM seo_global WHERE id = 1");
if ($global_res && $global_res->num_rows > 0) {
    $global_seo = $global_res->fetch_assoc();
}

// Fetch Page-Specific Settings
$page_seo = [];
$stmt = $mysqli->prepare("SELECT * FROM seo_meta WHERE page_key = ?");
$stmt->bind_param("s", $page_key);
$stmt->execute();
$page_res = $stmt->get_result();
if ($page_res && $page_res->num_rows > 0) {
    $page_seo = $page_res->fetch_assoc();
}

// --- 3. HELPER FUNCTION ---

/**
 * Echoes a meta tag only if the content is not empty.
 * @param string $tag The full HTML tag (e.g., '<meta name="author" content="...">')
 * @param string $content The database value. If empty, nothing is echoed.
 */
function echo_tag($tag, $content) {
    if (!empty(trim($content ?? ''))) {
        echo $tag . "\n";
    }
}

/**
 * Creates an absolute URL.
 * @param string $base_url Your site's base URL
 * @param string $path The path from the database (e.g., 'uploads/seo/image.jpg')
 * @return string The full, absolute URL
 */
function absolute_url($base_url, $path) {
    if (empty($path)) return '';
    // Check if path is already a full URL
    if (strpos($path, 'http') === 0) {
        return $path;
    }
    // Create full URL
    return rtrim($base_url, '/') . '/' . ltrim($path, '/');
}

// --- 4. MERGE & PREPARE VALUES ---

// Page Title (Mandatory)
$title = !empty($page_seo['title']) ? $page_seo['title'] : $default_title;
// Meta Description (Mandatory)
$description = !empty($page_seo['meta_description']) ? $page_seo['meta_description'] : $default_description;

// Canonical (Page-specific, fallback to this page's URL)
$canonical = $page_seo['canonical'] ?? $base_url . '/about.php'; // CHANGED FOR THIS PAGE

// Open Graph
$og_title = $page_seo['og_title'] ?? $title;
$og_description = $page_seo['og_description'] ?? $description;
$og_url = $page_seo['og_url'] ?? $canonical;
$og_image_path = $page_seo['og_image'] ?? '';
$og_image_url = absolute_url($base_url, $og_image_path);

// Twitter
$tw_title = $page_seo['twitter_title'] ?? $og_title;
$tw_description = $page_seo['twitter_description'] ?? $og_description;
$tw_image_path = $page_seo['twitter_image'] ?? $og_image_path;
$tw_image_url = absolute_url($base_url, $tw_image_path);

?>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <html lang="en">
    <meta http-equiv="Content-Language" content="en">

    <title><?php echo htmlspecialchars($title); ?></title>
    <meta name="description" content="<?php echo htmlspecialchars($description); ?>">

    <?php
    // --- Optional Basic Tags ---
    echo_tag('<meta name="keywords" content="' . htmlspecialchars($page_seo['meta_keywords'] ?? '') . '">', $page_seo['meta_keywords'] ?? '');
    echo_tag('<meta name="author" content="' . htmlspecialchars($global_seo['author'] ?? '') . '">', $global_seo['author'] ?? '');
    echo_tag('<meta name="copyright" content="' . htmlspecialchars($global_seo['copyright'] ?? '') . '">', $global_seo['copyright'] ?? '');
    echo_tag('<link rel="canonical" href="' . htmlspecialchars($canonical) . '">', $canonical);
    
    // --- Robots / Indexing ---
    echo_tag('<meta name="robots" content="' . htmlspecialchars($page_seo['robots'] ?? 'index, follow') . '">', $page_seo['robots'] ?? '');
    echo_tag('<meta name="googlebot" content="' . htmlspecialchars($page_seo['robots'] ?? 'index, follow') . '">', $page_seo['robots'] ?? '');
    echo_tag('<meta name="bingbot" content="' . htmlspecialchars($page_seo['robots'] ?? 'index, follow') . '">', $page_seo['robots'] ?? '');
    echo '<meta name="referrer" content="no-referrer-when-downgrade">' . "\n";

    // --- Verification Codes (Global) ---
    echo_tag('<meta name="google-site-verification" content="' . htmlspecialchars($global_seo['google_verification'] ?? '') . '">', $global_seo['google_verification'] ?? '');
    echo_tag('<meta name="msvalidate.01" content="' . htmlspecialchars($global_seo['bing_verification'] ?? '') . '">', $global_seo['bing_verification'] ?? '');
    echo_tag('<meta name="yandex-verification" content="' . htmlspecialchars($global_seo['yandex_verification'] ?? '') . '">', $global_seo['yandex_verification'] ?? '');
    echo_tag('<meta name="facebook-domain-verification" content="' . htmlspecialchars($global_seo['facebook_verification'] ?? '') . '">', $global_seo['facebook_verification'] ?? '');

    // --- Open Graph (Facebook/LinkedIn) ---
    echo_tag('<meta property="og:title" content="' . htmlspecialchars($og_title) . '">', $og_title);
    echo_tag('<meta property="og:description" content="' . htmlspecialchars($og_description) . '">', $og_description);
    echo_tag('<meta property="og:type" content="' . htmlspecialchars($page_seo['og_type'] ?? 'website') . '">', $page_seo['og_type'] ?? 'website');
    echo_tag('<meta property="og:url" content="' . htmlspecialchars($og_url) . '">', $og_url);
    echo_tag('<meta property="og:image" content="' . htmlspecialchars($og_image_url) . '">', $og_image_url);
    echo_tag('<meta property="og:site_name" content="' . htmlspecialchars($global_seo['site_name'] ?? '') . '">', $global_seo['site_name'] ?? '');
    echo_tag('<meta property="fb:app_id" content="' . htmlspecialchars($global_seo['fb_app_id'] ?? '') . '">', $global_seo['fb_app_id'] ?? '');
    echo_tag('<meta property="article:published_time" content="' . (!empty($page_seo['article_published_time']) ? htmlspecialchars(date(DateTime::ISO8601, strtotime($page_seo['article_published_time']))) : '') . '">', $page_seo['article_published_time'] ?? '');
    echo_tag('<meta property="article:modified_time" content="' . (!empty($page_seo['article_modified_time']) ? htmlspecialchars(date(DateTime::ISO8601, strtotime($page_seo['article_modified_time']))) : '') . '">', $page_seo['article_modified_time'] ?? '');
    echo '<meta property="og:locale" content="en_US">' . "\n";

    // --- Twitter Card ---
    echo_tag('<meta name="twitter:card" content="' . htmlspecialchars($page_seo['twitter_card'] ?? 'summary_large_image') . '">', $page_seo['twitter_card'] ?? '');
    echo_tag('<meta name="twitter:title" content="' . htmlspecialchars($tw_title) . '">', $tw_title);
    echo_tag('<meta name="twitter:description" content="' . htmlspecialchars($tw_description) . '">', $tw_description);
    echo_tag('<meta name="twitter:image" content="' . htmlspecialchars($tw_image_url) . '">', $tw_image_url);
    echo_tag('<meta name="twitter:site" content="' . htmlspecialchars($global_seo['twitter_site'] ?? '') . '">', $global_seo['twitter_site'] ?? '');
    echo_tag('<meta name="twitter:creator" content="' . htmlspecialchars($page_seo['twitter_creator'] ?? '') . '">', $page_seo['twitter_creator'] ?? '');

    // --- Favicons & Manifest (Global) ---
    $favicon_url = absolute_url($base_url, $global_seo['favicon_ico'] ?? 'favicon.ico');
    echo '<link rel="icon" href="' . htmlspecialchars($favicon_url) . '" type="image/x-icon">' . "\n";
    echo_tag('<link rel="apple-touch-icon" sizes="180x180" href="' . absolute_url($base_url, $global_seo['apple_touch_icon'] ?? '') . '">', $global_seo['apple_touch_icon'] ?? '');
    echo_tag('<link rel="manifest" href="' . absolute_url($base_url, $global_seo['manifest_url'] ?? '') . '">', $global_seo['manifest_url'] ?? '');
    echo_tag('<meta name="theme-color" content="' . htmlspecialchars($global_seo['theme_color'] ?? '') . '">', $global_seo['theme_color'] ?? '');
    echo_tag('<meta name="application-name" content="' . htmlspecialchars($global_seo['site_name'] ?? '') . '">', $global_seo['site_name'] ?? '');

    // --- Geo & Local (Global) ---
    echo_tag('<meta name="geo.region" content="' . htmlspecialchars($global_seo['geo_region'] ?? '') . '">', $global_seo['geo_region'] ?? '');
    echo_tag('<meta name="geo.placename" content="' . htmlspecialchars($global_seo['geo_placename'] ?? '') . '">', $global_seo['geo_placename'] ?? '');
    echo_tag('<meta name="geo.position" content="' . htmlspecialchars($global_seo['geo_position'] ?? '') . '">', $global_seo['geo_position'] ?? '');
    
    // --- Sitemap (Global) ---
    echo_tag('<link rel="sitemap" type="application/xml" title="Sitemap" href="' . htmlspecialchars($global_seo['sitemap_url'] ?? '') . '">', $global_seo['sitemap_url'] ?? '');
    
    // --- Hreflang (Global) ---
    echo_tag('<link rel="alternate" href="' . htmlspecialchars($global_seo['hreflang_x_default'] ?? '') . '" hreflang="x-default">', $global_seo['hreflang_x_default'] ?? '');
    echo_tag('<link rel="alternate" href="' . htmlspecialchars($global_seo['hreflang_en'] ?? '') . '" hreflang="en">', $global_seo['hreflang_en'] ?? '');
    echo_tag('<link rel="alternate" href="' . htmlspecialchars($global_seo['hreflang_es'] ?? '') . '" hreflang="es">', $global_seo['hreflang_es'] ?? '');
    echo_tag('<link rel="alternate" href="' . htmlspecialchars($global_seo['hreflang_fr'] ?? '') . '" hreflang="fr">', $global_seo['hreflang_fr'] ?? '');

    // --- Schema.org JSON-LD (Page-specific) ---
    if (!empty($page_seo['schema_json'])) {
        echo "<script type=\"application/ld+json\">\n" . $page_seo['schema_json'] . "\n</script>\n";
    }

    // --- Your CSS/JS Include ---
    include 'head.php';
    ?>
</head>
<body>
<?php include 'header.php' ?>

<div class="container py-4">

  <!-- Programmes header with dropdown -->
  <div class="row align-items-center mb-4 motion-features">
    <div class="col-lg-8 col-6" data-aos="fade-right">
      <h2 class="display-5 fw-bold mb-4">Sendugan </h2>
    </div>
    <div class="col-lg-4 col-6 text-lg-end text-start" data-aos="fade-left">
      <select id="categorySelect" class="form-select w-auto mb-4 border-light ms-auto" aria-label="Select Category"> 
      </select>
    </div>
  </div>

  <!-- Tracks row -->
  <div class="row category-info" id="category-info" style="display: none;">
    <!-- Left: Category info (image only) -->
    <div class="col-lg-12 ">
        
      <!-- Category name moved here -->
      <h2 id="category-name" class="text-white mb-4"></h2> 
    </div>

    <div class="col-lg-6 ">
         
      <img id="category-image" src="" class="img-fluid mb-4 brr20" alt="Category Image" />
    </div>

    <!-- Right: Tracks -->
    <div class="col-lg-6">
 
      <div class="row gb-2" id="mixcloud-container"></div>

      <!-- Load More button -->
      <div class="text-center mt-4">
        <button id="loadMore" class="btn btn-outline-light btn-sm rounded-pill px-4 mt-3">Load More</button>
      </div>
    </div>
  
  
  </div>

</div>

  <!-- Mixcloud PlayerWidget API -->
  <script src="https://widget.mixcloud.com/media/js/widgetApi.js"></script>
  <script>
    const container = document.getElementById("mixcloud-container");
    const loadMoreBtn = document.getElementById("loadMore");
    const categoryInfo = document.getElementById("category-info");
    const categoryImage = document.getElementById("category-image");
    const categoryName = document.getElementById("category-name");
    const categorySelect = document.getElementById("categorySelect");

    let nextPage = "https://api.mixcloud.com/JamOnRadio/cloudcasts/";
    let categoryMap = new Map();
    let activeCategory = null;
    let activePlayer = null;
    const defaultCover = "https://via.placeholder.com/600x300?text=No+Image";

    // Loading spinner
    let loadingDiv = document.createElement("div");
    loadingDiv.innerHTML = `
      <div class="text‑center mt‑4" id="loading">
        <div class="spinner‑border text‑light" role="status">
          <span class="visually‑hidden">Loading...</span>
        </div>
      </div>
    `;
    container.parentElement.insertBefore(loadingDiv, container);
    const loadingIndicator = document.getElementById("loading");

    loadMoreBtn.style.display = "none";

    // Fetch Mixcloud data
    async function fetchMoreMixes() {
      if (!nextPage) return;

      loadingIndicator.style.display = "block";
      loadMoreBtn.style.display = "none";

      try {
        const response = await fetch(nextPage);
        const data = await response.json();

        data.data.forEach(item => {
          const category = item.tags && item.tags.length > 0 ? item.tags[0].name : "Uncategorized";
          if (!categoryMap.has(category)) {
            categoryMap.set(category, []);
          }
          categoryMap.get(category).push(item);
        });

        nextPage = data.paging.next || null;

        // Populate dropdown
        populateCategoryDropdown();

        // If no category selected yet, auto‑select first
        if (!activeCategory) {
          const firstCategory = categoryMap.keys().next().value;
          if (firstCategory) {
            categorySelect.value = firstCategory;
            activeCategory = firstCategory;
            showCategoryInfo(firstCategory);
            renderTracks(firstCategory);
          }
        }

      } catch (error) {
        console.error("Failed to fetch Mixcloud data:", error);
      }
    }

    function populateCategoryDropdown() { 
      categoryMap.forEach((_, category) => {
        const option = document.createElement("option");
        option.value = category;
        option.textContent = category;
        categorySelect.appendChild(option);
      });
    }

    // When a category is selected
    categorySelect.addEventListener("change", () => {
      const category = categorySelect.value;
      if (!category) return;

      activeCategory = category;
      container.innerHTML = "";
      container.style.opacity = "0";

      showCategoryInfo(category);
      renderTracks(category);
    });

    function showCategoryInfo(category) {
      const items = categoryMap.get(category);
      const cover = items && items[0] && items[0].pictures && items[0].pictures.extra_large
                    ? items[0].pictures.extra_large
                    : defaultCover;

      categoryImage.src = cover;
      categoryImage.alt = category;
      categoryName.textContent = category;

      categoryInfo.style.display = "flex";
    }

    function renderTracks(category, count = 6) {
      const items = categoryMap.get(category) || [];
      const toRender = items.splice(0, count);

      if (toRender.length === 0 && !nextPage) {
        loadMoreBtn.style.display = "none";
        return;
      }

      loadingIndicator.style.display = "block";
      container.style.opacity = "0";

      toRender.forEach(item => {
        const mixcloudPath = encodeURIComponent(item.url.replace("https://www.mixcloud.com", ""));
        const col = document.createElement("div");
        col.className = "col‑md‑12 mixcloud‑item mb‑4";
        const iframeId = `mixcloud‑${Date.now()}‑${Math.random().toString(36).substr(2,9)}`;

        col.innerHTML = `
          <iframe
            id="${iframeId}"
            width="100%" height="60"
            src="https://player-widget.mixcloud.com/widget/iframe/?hide_cover=1&mini=1&feed=${mixcloudPath}"
            frameborder="0"
            allow="autoplay; encrypted-media">
          </iframe>
        `;
        container.appendChild(col);

        const iframe = col.querySelector("iframe");
        iframe.addEventListener("load", () => {
          const widget = Mixcloud.PlayerWidget(iframe);
          widget.ready.then(() => {
            widget.events.play.on(() => {
              if (activePlayer && activePlayer !== widget) {
                activePlayer.pause();
              }
              activePlayer = widget;
            });
          });
        });
      });

      // Fade‑in after loading
      setTimeout(() => {
        container.style.transition = "opacity 1s";
        container.style.opacity = "1";
        loadingIndicator.style.display = "none";

        if ((categoryMap.get(category) || []).length > 0 || nextPage) {
          loadMoreBtn.style.display = "inline‑block";
        }
      }, 500);
    }

    // Load more button
    loadMoreBtn.addEventListener("click", async () => {
      loadMoreBtn.style.display = "none";
      container.style.opacity = "0";

      if ((categoryMap.get(activeCategory) || []).length < 6 && nextPage) {
        await fetchMoreMixes();
      }

      renderTracks(activeCategory);
    });

    // Initial fetch
    fetchMoreMixes();
  </script>

<?php include 'footer.php' ?>
</body>
</html>

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists