<?php
function path()
{
    echo "http://localhost/wdi_php/kirmson";
    
}

$slug = $_GET['slug'];

include_once 'include/connection.php';

$top = mysqli_query($conn, "SELECT * FROM blogs where slug='$slug'");
$num34=mysqli_num_rows($top);
while ($roh = mysqli_fetch_array($top)) {
    $tcat_id = $roh['id'];
}

if($num34 == 0)
{
    ?>
   <script>window.location.href = "http://localhost/wdi_php/kirmson/404.php";
</script>  
    
 <?php   
}

$actual_link = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
   // echo $actual_link;exit;
$host=$_SERVER['HTTP_HOST'];
$currentURL = $_SERVER['REQUEST_URI'];
if ($_SERVER['HTTPS'] != 'on') {
    ?>
    <script>window.location.href = "https://<?php echo $host.$currentURL ?>";
</script>
   
     <?php
}

$ser = mysqli_query($conn, "SELECT * FROM blogs where slug='$slug'");
while($row = mysqli_fetch_array($ser))
{
    $title = $row['name'];
    $banner = $row['banner'];
    $short_description = $row['short_description'];
    $description = $row['description'];
    $meta_title = $row['meta_title'];
    $meta_description = $row['meta_description'];
    $keywords = $row['keywords'];
}


?>

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    
   
<title><?php echo $meta_title; ?></title>
<meta name="description" content="<?php echo $meta_description; ?>" />
<meta name="keywords" content="<?php echo $keywords; ?>">


    <!-- ==== bootstarp link -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css">

    <link rel="stylesheet" href="<?php path(); ?>/css/style.css">
    
    <link rel="stylesheet" href="https://unpkg.com/aos@next/dist/aos.css" />
<link rel="canonical" href="<?php echo $actual_link ?>">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="icon" href="<?php path(); ?>/assets/logo.webp" sizes="32x32" />

<link href="https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap" rel="stylesheet">
</head>





<body>

<?php include('include/header.php');  ?>


     <!-- ===== blog detail section start ==== -->

     <section class="blog-detail" style="margin-top:150px;">
        <div class="container">

            <!-- <div class="text-center mt-3">
                <h5 class="section-title ff-secondary text-center text-primary fw-normal">Blog Details</h5>
                <h1 class="">Our Blog Details</h1>
            </div> -->

            <div class="row mt-5">

                <div class="col-md-9">

                    <div class="detail-text">

                        <h2><?php echo $title; ?></h2>
                        
                        <img src="<?php path(); ?>/admin/assets/images/blog-image/<?php echo $banner; ?>" alt="" width="100%">

                        <br> <br>

                        <p><?php echo $short_description; ?></p>

                        <p><?php echo $description; ?></p>

                    </div>

                </div>

                <div class="col-md-3">

                    <h3 class="section-title ff-secondary text-start">Latest Post</h5>
                    <!-- <h1 class="mb-4">Latest Post</h1> -->

                    <div class="row">
                        
                        <?php
                $blog = mysqli_query($conn, "SELECT * FROM `blogs` order by id DESC");
                while($rol = mysqli_fetch_array($blog))
                {
                    $title = $rol['name'];
                    $date = $rol['updated_at'];
                    $slug = $rol['slug'];
                ?>
                        <div class=" latestside-box  row mt-3 ">

                            <div class="col-md-12">

                                <a href="<?php path(); ?>/blogs/<?php echo $slug; ?>" style="text-decoration: none;">
                                    <h5 class="text-black"><?php echo $title; ?></h5>
                                </a>

                                <div class="row">
                                   
                                    <div class="col-md-12">
                                        <p><?php echo $date; ?> </p>
                                    </div>
                                </div>

                            </div>

                        </div>
                <?php
                }
                ?>
                    </div>
                </div>

            </div>
        </div>
    </section>

    <!-- ===== blog detail section end ==== -->



    <?php include('include/footer.php');  ?>

</body>

</html>