:: **Zploit** v1.0 | Current Path: **/home/kreativepixelz/public_html/kreativecrm/**
:: Editing File: portfolio_share.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'; // -------------------------- // Helper: get YouTube ID // Accepts iframe HTML or watch URL or youtu.be // Returns video ID string or false function getYouTubeId($input) { if (empty($input)) return false; // If input contains iframe, extract src if (preg_match('/<iframe[^>]+src=["\']([^"\']+)["\']/', $input, $m)) { $input = $m[1]; } // parse URL $parts = parse_url(trim($input)); if (!$parts) return false; // youtu.be short link: path contains the id if (isset($parts['host']) && (strpos($parts['host'], 'youtu.be') !== false)) { $id = ltrim($parts['path'], '/'); return $id ?: false; } // youtube watch or embed if (isset($parts['host']) && (strpos($parts['host'], 'youtube.com') !== false)) { // watch?v=ID if (!empty($parts['query'])) { parse_str($parts['query'], $q); if (!empty($q['v'])) return $q['v']; } // embed/ID or /v/ID if (!empty($parts['path'])) { $segments = explode('/', trim($parts['path'], '/')); // find last non-empty segment $id = end($segments); return $id ?: false; } } // If input is just an ID (rare) if (preg_match('/^[A-Za-z0-9_-]{6,}$/', trim($input))) { return trim($input); } return false; } // -------------------------- // Get portfolio record if (!isset($_GET['id']) || empty($_GET['id'])) { header("Location: portfolio.php?msg=Invalid Request"); exit; } $id = intval($_GET['id']); // use prepared-ish query to be safe (mysqli real escape) $result = mysqli_query($conn, "SELECT * FROM portfolio_photos WHERE id='" . intval($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='" . intval($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) $scheme = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') ? 'https' : 'http'; $base_dir = rtrim(dirname($_SERVER['SCRIPT_NAME']), '/') . '/'; $base_url = $scheme . '://' . $_SERVER['HTTP_HOST'] . $base_dir; $image_path = "uploads/portfolio/$folder_name/" . ($portfolio['img_name'] ?? ''); $full_image_fs_path = __DIR__ . '/' . $image_path; // Prepare video info $video_link_raw = $portfolio['video_link'] ?? ''; $video_id = getYouTubeId(trim($video_link_raw)); $video_share_link = $video_id ? "https://youtu.be/" . $video_id : ''; $video_embed_link = $video_id ? "https://www.youtube.com/embed/" . $video_id : ''; ?> <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" onsubmit="return false;"> <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' && $video_id): ?> <!-- show short share link in the input, and embed preview --> <input type="text" id="media_link" class="form-control" value="<?= htmlspecialchars($video_share_link, ENT_QUOTES); ?>" readonly> <div class="mt-3"> <iframe src="<?= htmlspecialchars($video_embed_link, ENT_QUOTES); ?>" title="YouTube video player" frameborder="0" width="560" height="315" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen> </iframe> </div> <?php elseif (!empty($portfolio['img_name']) && file_exists($full_image_fs_path)): ?> <?php $full_image_url = $base_url . $image_path; ?> <input type="text" id="media_link" class="form-control" value="<?= htmlspecialchars($full_image_url, ENT_QUOTES); ?>" readonly> <?php $extension = strtolower(pathinfo($image_path, PATHINFO_EXTENSION)); ?> <?php if ($extension == 'pdf') { ?> <div class="mt-3"> <a href="<?= htmlspecialchars($full_image_url, ENT_QUOTES); ?>" 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="<?= htmlspecialchars($full_image_url, ENT_QUOTES); ?>" 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'], ENT_QUOTES); ?>" readonly> <div class="mt-2"> <a href="<?= htmlspecialchars($portfolio['website_link'], ENT_QUOTES); ?>" 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 mobileRaw = document.getElementById('mobile').value.trim(); const mediaLinkEl = document.getElementById('media_link'); const media_link = mediaLinkEl ? mediaLinkEl.value.trim() : ''; const websiteEl = document.getElementById('website_link'); const website_link = websiteEl ? websiteEl.value.trim() : ''; if (!mobileRaw) { alert('Please enter mobile number.'); return; } // sanitize mobile number (remove spaces, +, -) let mobile = mobileRaw.replace(/[\s+-]/g, ''); // If mobile starts with 0, remove it (wa.me expects country code) // NOTE: Ideally user should input with country code (e.g., 91XXXXXXXXXX) if (mobile.startsWith('0')) { mobile = mobile.replace(/^0+/, ''); } let message = "Hello,\n\nPlease check out our latest portfolio work:\n"; if (website_link && website_link !== "") { message += "\nVisit our website: " + website_link + "\n"; } // if both website and media exist, include both if (media_link && media_link !== "No media available") { message += "\nMedia: " + 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(); ?>