124 lines
5.0 KiB
PHP
124 lines
5.0 KiB
PHP
<?php include_once('header02.php');
|
|
|
|
checkUserSession();
|
|
|
|
$result = $conn->prepare("SELECT blog_id, title, description, status, date, image FROM blogs WHERE author = ? AND status != 'deleted' ORDER BY date DESC");
|
|
|
|
$result->bind_param("i", $user_id);
|
|
$result->execute();
|
|
$posts = $result->get_result();
|
|
?>
|
|
|
|
<style>
|
|
.image {
|
|
width: 400px;
|
|
/* Set your desired width */
|
|
height: 350px;
|
|
/* Set your desired height */
|
|
overflow: hidden;
|
|
/* Hide any overflow */
|
|
display: block;
|
|
/* Ensure proper block behavior */
|
|
}
|
|
|
|
.image img {
|
|
width: 100%;
|
|
/* Image scales to fill the container */
|
|
height: 100%;
|
|
/* Image scales to fill the container */
|
|
object-fit: cover;
|
|
/* Fills the container while maintaining aspect ratio */
|
|
object-position: top;
|
|
/* Aligns the top of the image with the top of the container */
|
|
display: block;
|
|
/* Prevents inline whitespace issues */
|
|
|
|
|
|
}
|
|
</style>
|
|
|
|
|
|
|
|
<?php
|
|
$bannerFolder = 'assets/images/banners/';
|
|
$bannerImages = glob($bannerFolder . '*.{jpg,jpeg,png,webp}', GLOB_BRACE);
|
|
|
|
$randomBanner = 'assets/images/base4/camping.jpg'; // default fallback
|
|
if (!empty($bannerImages)) {
|
|
$randomBanner = $bannerImages[array_rand($bannerImages)];
|
|
}
|
|
?>
|
|
<section class="page-banner-area pt-50 pb-35 rel z-1 bgs-cover" style="background-image: url('<?php echo $randomBanner; ?>');">
|
|
<!-- Overlay PNG -->
|
|
<div class="banner-overlay"></div>
|
|
<div class="container">
|
|
<div class="banner-inner text-white">
|
|
<h2 class="page-title mb-10" data-aos="fade-left" data-aos-duration="1500" data-aos-offset="50">My Blogs</h2>
|
|
<nav aria-label="breadcrumb">
|
|
<ol class="breadcrumb justify-content-center mb-20" data-aos="fade-right" data-aos-delay="200" data-aos-duration="1500" data-aos-offset="50">
|
|
<li class="breadcrumb-item"><a href="index.php">Home</a></li>
|
|
<li class="breadcrumb-item active">My Blogs</li>
|
|
</ol>
|
|
</nav>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
<!-- Page Banner End -->
|
|
|
|
|
|
|
|
<!-- Blog List Area start -->
|
|
<section class="blog-list-page py-100 rel z-1">
|
|
<div class="container">
|
|
<div class="row">
|
|
<div class="col-lg-12">
|
|
|
|
<h2>My Posts</h2>
|
|
<?php if (isset($_SESSION['message'])): ?>
|
|
<div class="alert alert-warning message-box">
|
|
<?php echo $_SESSION['message']; ?>
|
|
<span class="close-btn" onclick="this.parentElement.style.display='none'">×</span>
|
|
</div>
|
|
<?php unset($_SESSION['message']); ?>
|
|
<?php endif; ?>
|
|
<a href="blog_create.php">+ New Post</a>
|
|
|
|
<?php while ($post = $posts->fetch_assoc()):
|
|
// Output the HTML structure with dynamic data
|
|
echo '
|
|
<div class="destination-item style-three bgc-lighter booking" data-aos="fade-up" data-aos-duration="1500" data-aos-offset="50">
|
|
<div class="image" style="width:200px;height:200px;"><img src="' . $post["image"] . '" alt="' . $post["title"] . '"></div>
|
|
<div class="content" style="width:100%;">
|
|
|
|
<div class="destination-header">
|
|
<span class="badge bg-dark"> ' . strtoupper($post["status"]) . '</span>
|
|
</div>
|
|
|
|
<h5>' . $post["title"] . '</a></h5>
|
|
<p>' . $post["description"] . '</p>
|
|
<div class="destination-footer">
|
|
<div class="btn-group" style="display:flex; justify-content:flex-end; gap:10px; margin-top:10px;">
|
|
<a href="blog_edit.php?token='.encryptData($post["blog_id"], $salt).'" class="btn btn-sm" data-bs-toggle="tooltip" data-bs-placement="top" title="Edit"><i class="bi bi-pencil"></i></a>
|
|
<a href="blog_read.php?token='.encryptData($post["blog_id"], $salt).'" class="btn btn-sm" data-bs-toggle="tooltip" data-bs-placement="top" title="Preview"><i class="bi bi-eye"></i></a>
|
|
<a href="blog_delete.php?token='.encryptData($post["blog_id"], $salt).'" class="btn btn-sm" data-bs-toggle="tooltip" data-bs-placement="top" title="Delete"><i class="bi bi-trash"></i></a>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
</div>';
|
|
endwhile; ?>
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
</section>
|
|
<!-- Blog List Area end -->
|
|
<script>
|
|
const tooltipTriggerList = document.querySelectorAll('[data-bs-toggle="tooltip"]');
|
|
tooltipTriggerList.forEach(el => new bootstrap.Tooltip(el));
|
|
</script>
|
|
|
|
|
|
<?php include_once("insta_footer.php"); ?>
|