:: **Zploit** v1.0 | Current Path: **/home/kreativepixelz/www/kreativecrm/**
:: Editing File: portfolio_share_1.php
<?php ob_start(); include 'header.php'; // ✅ Page setup $page_parent = "Portfolio CRM"; $page_parent_link = "portfolio.php"; $page_title = "Share Portfolio"; include 'breadcrumb.php'; include 'menu.php'; // ✅ Get portfolio record if (!isset($_GET['id']) || empty($_GET['id'])) { header("Location: portfolio.php?msg=Invalid Request"); exit; } $id = intval($_GET['id']); $result = mysqli_query($conn, "SELECT * FROM portfolio_photos WHERE id='$id'"); $portfolio = mysqli_fetch_assoc($result); if (!$portfolio) { header("Location: portfolio.php?msg=Portfolio not found"); exit; } // ✅ Get section name $sectionQuery = mysqli_query($conn, "SELECT section_name FROM work_sections WHERE id='{$portfolio['work_section_id']}'"); $sectionRow = mysqli_fetch_assoc($sectionQuery); $section_name = strtolower(trim($sectionRow['section_name'])); $folder_name = preg_replace('/[^a-z0-9]+/', '_', $section_name); // ✅ Build paths $base_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://{$_SERVER['HTTP_HOST']}" . dirname($_SERVER['SCRIPT_NAME']) . "/"; $image_path = "uploads/portfolio/$folder_name/" . $portfolio['img_name']; ?> <div class="page-body"> <div class="container-fluid"> <div class="row"> <div class="col-sm-12"> <div class="card"> <div class="card-header"> <h2>Share Portfolio</h2> </div> <div class="card-body"> <form id="shareForm" method="POST"> <div class="row"> <!-- Mobile Number --> <div class="col-md-12"> <label class="form-label">Mobile Number</label> <input type="text" id="mobile" name="mobile" class="form-control" placeholder="Enter WhatsApp number" required> </div> <!-- Portfolio Media --> <div class="col-md-12 mt-3"> <label class="form-label">Portfolio Media</label> <?php if ($section_name === 'video production' && !empty($portfolio['video_link'])): ?> <?php // Extract YouTube link from iframe $iframe_html = $portfolio['video_link']; $video_link = ""; if (preg_match('/src="([^"]+)"/', $iframe_html, $matches)) { $video_url = $matches[1]; function convertToShortURL($video_url) { $parsed_url = parse_url($video_url); if (strpos($parsed_url['path'], '/embed/') !== false) { $video_id = str_replace('/embed/', '', $parsed_url['path']); return "https://youtu.be/" . $video_id; } return $video_url; } $video_link = convertToShortURL($video_url); } ?> <input type="text" id="media_link" class="form-control" value="<?= htmlspecialchars($video_link); ?>" readonly> <div class="mt-3"> <iframe src="<?= htmlspecialchars($video_url); ?>" title="YouTube video player" frameborder="0" width="560" height="315"> </iframe> </div> <?php elseif (!empty($portfolio['img_name']) && file_exists($image_path)): ?> <?php $full_image_url = $base_url . $image_path; ?> <input type="text" id="media_link" class="form-control" value="<?= htmlspecialchars($full_image_url); ?>" readonly> <?php $extension = strtolower(pathinfo($image_path, PATHINFO_EXTENSION)); ?> <?php if ($extension == 'pdf') { ?> <div class="mt-3"> <a href="<?= $image_path; ?>" target="_blank" class="btn btn-outline-primary"> <i class="fa fa-file-pdf-o"></i> View PDF </a> </div> <?php } else { ?> <div class="mt-3"> <img src="<?= $image_path; ?>" alt="Portfolio Image" width="250" class="border rounded"> </div> <?php } ?> <?php else: ?> <input type="text" id="media_link" class="form-control" value="No media available" readonly> <?php endif; ?> </div> <!-- Website Link --> <?php if (!empty($portfolio['website_link'])): ?> <div class="col-md-12 mt-4"> <label class="form-label">Website Link</label> <input type="text" id="website_link" class="form-control" value="<?= htmlspecialchars($portfolio['website_link']); ?>" readonly> <div class="mt-2"> <a href="<?= $portfolio['website_link']; ?>" target="_blank" class="btn btn-outline-info"> <i class="fa fa-globe"></i> View Website </a> </div> </div> <?php endif; ?> </div> <br><br> <div class="text-center"> <button type="button" id="whatsapp-send" class="btn btn-success" style="background:#00d757;border:none;"> <i class="fa fa-whatsapp"></i> Send on WhatsApp </button> <a href="portfolio.php" class="btn btn-secondary">Back</a> </div> </form> </div> </div> </div> </div> </div> </div> <!-- ✅ WhatsApp Send Script --> <script> document.getElementById('whatsapp-send').addEventListener('click', function () { const mobile = document.getElementById('mobile').value.trim(); const media_link = document.getElementById('media_link') ? document.getElementById('media_link').value.trim() : ''; const website_link = document.getElementById('website_link') ? document.getElementById('website_link').value.trim() : ''; if (!mobile) { alert('Please enter mobile number.'); return; } let message = "Hello,\n\nPlease check out our latest portfolio work:\n"; if (website_link) { message += "\nVisit our website: " + website_link + "\n"; } else if (media_link && media_link !== "No media available") { message += media_link + "\n"; } const encodedMessage = encodeURIComponent(message); const whatsappURL = `https://wa.me/${mobile}?text=${encodedMessage}`; window.open(whatsappURL, '_blank'); }); </script> <?php include 'footer.php'; ob_end_flush(); ?>