Site Builder
Editing:
view.php
writable 0666
<?php /************************************************************************** * SOCIAL PROFILE – PUBLIC VIEW PAGE * ---------------------------------------------------------------------- * Looks inside /social/<slug>/ for: * • social.json (premium) OR * • new-social.json (free) * and renders a rich landing page for influencers to showcase * their best deals, sponsors and channels. * * ⚠ Requires PHP 8.1+ *************************************************************************/ declare(strict_types=1); /* ---------- bootstrap ------------------------------------------------- */ $slug = preg_replace('/[^a-z0-9_]/i', '', ($_GET['user'] ?? '')); if ($slug === '') { http_response_code(400); exit('Invalid user'); } $dir = $_SERVER['DOCUMENT_ROOT'] . "/social/$slug"; $filePremium = "$dir/social.json"; $fileFree = "$dir/new-social.json"; if (is_file($filePremium)) { $jsonFile = $filePremium; $isPremium = true; } elseif (is_file($fileFree )) { $jsonFile = $fileFree; $isPremium = false; } else { http_response_code(404); exit('Profile not found'); } $profile = json_decode(file_get_contents($jsonFile), true, 512, JSON_THROW_ON_ERROR); /* trust the "premium" flag if present – useful when you flip it in DB */ if (!$isPremium && !empty($profile['premium'])) $isPremium = true; /* convenience shortcuts ----------------------------------------------- */ $name = $profile['display_name'] ?: $profile['handle']; $handle = $profile['handle']; $slogan = $profile['slogan'] ?? ''; $descr = $profile['description'] ?? ''; $city = $profile['city'] ?? ''; $state = $profile['state'] ?? ''; $affiliate= $profile['affiliate_url'] ?? ''; $coupon = $profile['coupon_code'] ?? ''; $channels = $profile['channels'] ?? []; $website = $profile['website'] ?? ''; $email = $profile['email'] ?? ''; $phone = $profile['phone'] ?? ''; /* ---------- helper for channel badges -------------------------------- */ function channel_badge(string $label, ?string $url): string { if (!$url) return ''; $icon = match(strtolower($label)) { 'youtube' => 'fab fa-youtube', 'rumble' => 'fas fa-video', 'odysee' => 'fas fa-video', 'spotify' => 'fab fa-spotify', 'apple' => 'fab fa-apple', 'rss' => 'fas fa-rss', 'twitter' => 'fab fa-twitter', 'tiktok' => 'fab fa-tiktok', 'instagram' => 'fab fa-instagram', 'facebook' => 'fab fa-facebook', 'linkedin' => 'fab fa-linkedin', 'patreon' => 'fab fa-patreon', default => 'fas fa-link' }; $safe = htmlspecialchars($label); $url = htmlspecialchars($url); return "<a class=\"badge\" href=\"$url\" target=\"_blank\" rel=\"noopener\"> <i class=\"$icon\"></i> $safe </a>"; } /* ---------- split channels into HTML --------------------------------- */ $badges = []; foreach (['video','podcast','social'] as $grp) { foreach (($channels[$grp] ?? []) as $k => $u) { $b = channel_badge($k,$u); if ($b) $badges[] = $b; } } $badgesHTML = implode("\n", $badges); /* ---------- css + page render ---------------------------------------- */ ?> <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title><?= htmlspecialchars($name) ?> – Deals & Sponsors</title> <meta name="viewport" content="width=device-width,initial-scale=1"> <style> :root{ --fg:#222;--bg:#f9fbfe;--accent:#0b6bff;--lite:#ecf2ff; --premium:#ffe27d;--premium-dk:#d9b200; } body{margin:0;font-family:system-ui,Arial,sans-serif;background:var(--bg);color:var(--fg)} a{color:var(--accent);text-decoration:none} .hero{padding:2.6rem 1.2rem 2rem;text-align:center;color:#fff; background:linear-gradient(135deg,var(--accent),#0047d3);} .hero h1{font-size:2rem;margin:.1em 0} .hero p{margin:.6em 0 0;font-size:1.1rem;font-weight:500} .badge{display:inline-block;margin:.25em .33em;padding:.33em .65em .28em; background:var(--lite);border-radius:16px;font-size:.88rem;font-weight:600; color:#333;transition:.15s background} .badge:hover{background:#dbe6ff} .badge i{margin-right:.4em} .container{max-width:860px;margin:1.6rem auto;padding:0 1.2rem} .section{padding:1.4rem 0;border-bottom:1px solid #e4e9f3} .section h2{margin:.1em 0 .7em;font-size:1.3rem} .deal-card{display:flex;flex-wrap:wrap;gap:1.4rem;align-items:center;justify-content:center} .deal-card a.button{padding:.65em 1.4em;border-radius:4px;font-size:1.1rem; background:var(--accent);color:#fff;font-weight:600} .deal-card .coupon{font-size:1.35rem;font-weight:700;background:var(--lite); padding:.35em .7em;border-radius:6px;border:2px dashed var(--accent)} .contact-grid{display:flex;flex-wrap:wrap;gap:1.2rem;font-size:.95rem} .contact-grid > div{flex:1 1 260px} .contact-grid b{display:block;margin-bottom:.2em;color:#555} .premium-banner{background:var(--premium);padding:.5em .9em;text-align:center; font-weight:700;color:var(--premium-dk)} .free-banner{background:#ffe9e9;padding:.5em .9em;text-align:center; font-weight:600;color:#b30000} </style> </head> <body> <?php if ($isPremium): ?> <div class="premium-banner"><i class="fas fa-star"></i> Premium Influencer</div> <?php else: ?> <div class="free-banner">This is a free listing · <a href="/upgrade.php?user=<?= urlencode($slug) ?>">Upgrade to premium</a> to unlock full features!</div> <?php endif; ?> <header class="hero"> <h1><?= htmlspecialchars($name) ?></h1> <?php if ($slogan): ?><p><?= htmlspecialchars($slogan) ?></p><?php endif; ?> </header> <main class="container"> <?php if ($affiliate || $coupon): ?> <section class="section"> <h2>🔥 Featured Deal</h2> <div class="deal-card"> <?php if ($affiliate): ?> <a class="button" href="<?= htmlspecialchars($affiliate) ?>" target="_blank" rel="noopener"> Shop Now </a> <?php endif; ?> <?php if ($coupon): ?> <div class="coupon"><?= htmlspecialchars($coupon) ?></div> <?php endif; ?> </div> </section> <?php endif; ?> <?php if ($descr): ?> <section class="section"> <h2>About <?= htmlspecialchars($name) ?></h2> <p><?= nl2br(htmlspecialchars($descr)) ?></p> </section> <?php endif; ?> <?php if ($badgesHTML): ?> <section class="section"> <h2>Follow & Listen</h2> <?= $badgesHTML ?> </section> <?php endif; ?> <section class="section"> <h2>Contact</h2> <div class="contact-grid"> <?php if ($website): ?> <div><b>Website</b><a href="<?= htmlspecialchars($website) ?>" target="_blank" rel="noopener"><?= htmlspecialchars($website) ?></a></div> <?php endif; ?> <?php if ($email): ?> <div><b>Email</b><a href="mailto:<?= htmlspecialchars($email) ?>"><?= htmlspecialchars($email) ?></a></div> <?php endif; ?> <?php if ($phone): ?> <div><b>Text / Call</b><a href="tel:<?= htmlspecialchars($phone) ?>"><?= htmlspecialchars($phone) ?></a></div> <?php endif; ?> <?php if ($city || $state): ?> <div><b>Location</b><?= htmlspecialchars(trim("$city, $state", ", ")) ?></div> <?php endif; ?> </div> </section> <?php if (!empty($profile['tags'])): ?> <section class="section"> <h2>Tags</h2> <?php foreach ($profile['tags'] as $t): ?> <span class="badge"><i class="fas fa-tag"></i> <?= htmlspecialchars($t) ?></span> <?php endforeach; ?> </section> <?php endif; ?> <?php /* ================================================================ * COUPON CARDS – drop‑in for social/view.php * ============================================================== */ /* 1) pull coupons ------------------------------------------------ */ $coupons = []; $cpFile = "$dir/coupon.json"; if (is_file($cpFile)) { $raw = json_decode(file_get_contents($cpFile), true, 512, JSON_THROW_ON_ERROR); /* → normalise to numeric array */ if (array_is_list($raw)) { $coupons = $raw; } else { foreach ($raw as $k => $v) { if (is_numeric($k)) $coupons[(int)$k] = $v; // legacy “0”,”1” } if (!$coupons) $coupons[] = $raw; // single object ksort($coupons); $coupons = array_values($coupons); } } /* format phone once for reuse */ $phoneDigits = preg_replace('/\D/','',$phone ?? ''); $phoneFmt = ($phoneDigits && strlen($phoneDigits)===10) ? '('.substr($phoneDigits,0,3).') '.substr($phoneDigits,3,3).'-'.substr($phoneDigits,6) : ($phone ?? ''); ?> <?php if ($coupons): ?> <section class="section"> <h2>🔥 Best Deals</h2> <?php foreach ($coupons as $i => $cp): if (empty($cp['title'])) continue; // skip empties $descLimit = 160; $title = $cp['title'] ?? ''; $code = $cp['code'] ?? ''; $expiry = $cp['expiry'] ?? ''; $desc = trim($cp['desc'] ?? ''); $descFull = nl2br(htmlspecialchars($desc)); $descShort = nl2br(htmlspecialchars(mb_substr($desc,0,$descLimit,'UTF-8'))); $hasMore = mb_strlen($desc,'UTF-8') > $descLimit; /* unique IDs per card */ $cardID = "cpCard$i"; $descID="cpDesc$i"; $readID="read$i"; $lessID="less$i"; $printID="print$i"; $shareID="share$i"; ?> <style> @media print { #<?= $cardID ?> .coupon-toolbar, #<?= $cardID ?> .coupon-btn, #<?= $printID ?>, #<?= $shareID ?>, #<?= $readID ?>, #<?= $lessID ?> {display:none!important} #<?= $cardID ?> .desc-screen{display:none!important} #<?= $cardID ?> .desc-print{display:block!important} } #<?= $cardID ?> .desc-print{display:none} </style> <div style="max-width:470px;margin:2.2em auto"> <div id="<?= $cardID ?>" itemscope itemtype="https://schema.org/Offer" style="background:#fff;border:3.5px solid #ffb63b;border-radius:27px;max-width:500px;margin:auto;padding:2.2em 2em 1.5em;box-shadow:0 10px 38px #f5db9c3c;overflow:hidden"> <div style="text-align:center;font-weight:800;font-size:1.12em;color:#194285;border-bottom:1px solid #ef8f13;padding-bottom:.13em;margin-bottom:1em"> Recommended by <?= htmlspecialchars($handle) ?> </div> <div style="font-size:1.18em;font-weight:800;color:#df6200;margin-bottom:.12em" itemprop="name"> <?= htmlspecialchars($title) ?> </div> <!-- description --> <div class="desc desc-screen" id="<?= $descID ?>" itemprop="description" style="font-size:1.07em;color:#3a3232;margin-bottom:1.25em;line-height:1.5"> <?php if ($hasMore): ?> <?= $descShort ?> <button id="<?= $readID ?>" type="button" style="background:none;border:none;padding:0;margin-left:.27em;color:#2574bc;font-size:.98em;text-decoration:underline;cursor:pointer"> Read more </button> <?php else: ?><?= $descFull ?><?php endif; ?> </div> <div class="desc desc-print" style="font-size:1.07em;color:#3a3232;margin-bottom:1.25em;line-height:1.5"> <?= $descFull ?> </div> <div style="display:flex;gap:2.1em;align-items:center;margin-bottom:.4em"> <span style="font-weight:700;color:#ab2d00;font-size:1.05em">Coupon Code:</span> <span style="background:#ffefc1;border-radius:9px;display:inline-block;padding:.34em 1.8em;font-size:1.1em;color:#a95600;font-family:monospace;font-weight:700;letter-spacing:.09em;box-shadow:0 1px 8px #ffbe4e42"> <?= htmlspecialchars($code) ?> </span> </div> <div style="display:flex;gap:2.1em;align-items:center;margin-bottom:.4em"> <span style="font-weight:700;color:#ab2d00;font-size:1.05em">Expires:</span> <span style="font-size:1.08em;color:#a75608;font-weight:600"><?= htmlspecialchars($expiry ?: 'No Expiry') ?></span> </div> <!-- Get‑deal button (replaces phone) --> <?php if (!empty($cp['link'])): ?> <div style="text-align:center;margin:.8em 0 0"> <a href="<?= htmlspecialchars($cp['link']) ?>" target="_blank" rel="noopener" style="display:inline-block;background:#2357d7;color:#fff;padding:.55em 1.9em;border-radius:8px;font-weight:700;font-size:1.06rem;text-decoration:none"> Get Deal Now » </a> </div> <?php endif; ?> <div class="coupon-toolbar" style="display:flex;justify-content:center;gap:1.3em;margin:1.15em 0 0"> <button id="<?= $printID ?>" class="coupon-btn" style="padding:.67em 1.75em;border-radius:11px;font-size:1.09em;font-weight:700;border:none;cursor:pointer;box-shadow:0 1px 5px #ffeebb50;background:#ffeebb;color:#b25a00;display:flex;align-items:center;gap:.6em"> 🖨️ Print </button> <button id="<?= $shareID ?>" class="coupon-btn" style="padding:.67em 1.75em;border-radius:11px;font-size:1.09em;font-weight:700;border:none;cursor:pointer;box-shadow:0 1px 5px #ffeebb50;background:#ffeebb;color:#0e7f45;display:flex;align-items:center;gap:.6em"> 📤 Share </button> </div> </div> </div> <script> (() => { /* read‑more / show‑less */ const desc = document.getElementById('<?= $descID ?>'); const read = document.getElementById('<?= $readID ?>'); <?php if ($hasMore): ?> const full = <?= json_encode($descFull) ?>; const short= <?= json_encode($descShort) ?>; read.onclick = () => { desc.innerHTML = full + '<button id="<?= $lessID ?>" style="background:none;border:none;padding:0;margin-left:.4em;color:#2574bc;font-size:.98em;text-decoration:underline;cursor:pointer">Show less</button>'; document.getElementById('<?= $lessID ?>').onclick = () => { desc.innerHTML = short + read.outerHTML; document.getElementById('<?= $readID ?>').onclick = read.onclick; }; }; <?php endif; ?> /* print */ document.getElementById('<?= $printID ?>').onclick = () => { const html = document.getElementById('<?= $cardID ?>').outerHTML; const w = window.open('','w','width=600,height=800'); w.document.write('<html><head><title>Print Coupon</title><style>body{background:#f5f8fb;font-family:system-ui,Arial,sans-serif;margin:0}@media print{.coupon-toolbar{display:none}}</style></head><body>'+html+'</body></html>'); w.document.close(); setTimeout(()=>{w.print();w.close();},250); }; /* share */ document.getElementById('<?= $shareID ?>').onclick = async e => { /* strip any existing #fragment and append this card’s id */ const shareUrl = location.href.split('#')[0] + '#<?= $cardID ?>'; try { if (navigator.share) { await navigator.share({title: <?= json_encode($title) ?>, url: shareUrl}); } else { await navigator.clipboard.writeText(shareUrl); e.target.textContent = '✅ Copied!'; setTimeout(() => e.target.textContent = '📤 Share', 1500); } } catch {/* user cancelled, ignore */} }; })(); </script> <?php endforeach; ?> </section> <?php endif; ?> <?php /* ---------- “Book a Show / Ask a Question” contact form ---------- */ /* ─ renders only for premium profiles that have a valid e‑mail ─ */ $email = $profile['email'] ?? ''; if ($isPremium && filter_var($email, FILTER_VALIDATE_EMAIL)): ?> <!-- contact module --> <div style="max-width:470px;margin:2.4rem auto 0;font-family:system-ui,Arial,sans-serif"> <form id="scfForm" style="background:#fff;border:2px solid #ef8f13;border-radius:14px; box-shadow:0 2px 13px #ffcc7044;overflow:hidden" onsubmit="return scfSend(event);"> <!-- header ribbon --> <div style="background:#e62a19;color:#fff;padding:.75em 1em;text-align:center; font-weight:900;font-size:1.14em;line-height:1.25; border-bottom:2.5px solid #ffdd9c"> Book a Show / Ask a Question<br> <span style="font-size:.9em;font-weight:600;opacity:.9;">Contact <?= htmlspecialchars($handle) ?></span> </div> <div style="padding:1.1em .9em 1em"> <!-- name --> <div style="display:flex;flex-wrap:wrap;gap:.8em"> <div style="flex:1 1 145px"> <label for="scfFirst" style="font-weight:600;color:#de5200">First:</label> <input id="scfFirst" name="first" type="text" maxlength="32" required style="width:100%;padding:.4em .7em;border:1.2px solid #ffe4b2;border-radius:7px"> </div> <div style="flex:1 1 145px"> <label for="scfLast" style="font-weight:600;color:#de5200">Last:</label> <input id="scfLast" name="last" type="text" maxlength="32" required style="width:100%;padding:.4em .7em;border:1.2px solid #ffe4b2;border-radius:7px"> </div> </div> <!-- email / phone --> <div style="display:flex;flex-wrap:wrap;gap:.8em;margin-top:.75em"> <div style="flex:1 1 200px"> <label for="scfEmail" style="font-weight:600;color:#de5200">Your E‑mail:</label> <input id="scfEmail" name="email" type="email" maxlength="60" required style="width:100%;padding:.4em .7em;border:1.2px solid #ffe4b2;border-radius:7px"> </div> <div style="flex:1 1 170px"> <label for="scfPhone" style="font-weight:600;color:#de5200">Your Phone:</label> <input id="scfPhone" name="phone" type="text" maxlength="18" style="width:100%;padding:.4em .7em;border:1.2px solid #ffe4b2;border-radius:7px"> </div> </div> <!-- call‑time / zone --> <div style="display:flex;flex-wrap:wrap;gap:.8em;margin-top:.75em"> <div style="flex:1 1 150px"> <label for="scfWhen" style="font-weight:600;color:#de5200">Call When:</label> <select id="scfWhen" name="when" style="width:100%;padding:.4em .5em;border:1.2px solid #ffe4b2;border-radius:7px"> <option value="" selected>–</option><option>Anytime</option><option>Morning</option> <option>Afternoon</option><option>Evening</option> </select> </div> <div style="flex:1 1 110px"> <label for="scfZone" style="font-weight:600;color:#de5200">Zone:</label> <select id="scfZone" name="zone" style="width:100%;padding:.4em .5em;border:1.2px solid #ffe4b2;border-radius:7px"> <option value="" selected>–</option><option>ET</option><option>CT</option><option>MT</option><option>PT</option> </select> </div> </div> <!-- extra info toggle --> <div style="text-align:right;margin-top:1em"> <a id="scfToggle" href="#" style="font-size:.95em;color:#1567b2;font-weight:600;text-decoration:underline">+ Additional Information</a> </div> <div id="scfExtra" style="display:none;margin-top:.8em"> <label for="scfAddl" style="font-weight:600;color:#de5200">Details / Additional Info:</label> <textarea id="scfAddl" name="details" rows="3" style="width:100%;padding:.5em;border:1.2px solid #ffe4b2;border-radius:7px;resize:vertical"></textarea> </div> <!-- send --> <div style="text-align:right;margin-top:1.25em"> <button type="submit" style="background:#ef8f13;color:#fff;font-weight:800;padding:.63em 2.25em; font-size:1.05em;border:none;border-radius:9px;box-shadow:0 1px 7px #ffeebb7a;cursor:pointer"> SEND </button> </div> </div> </form> </div> <script> /* toggle extra textarea */ document.getElementById('scfToggle').onclick = e=>{ e.preventDefault(); const box=document.getElementById('scfExtra'); const open=box.style.display==='block'; box.style.display=open?'none':'block'; e.target.textContent=open?'+ Additional Information':'− Hide Additional Information'; }; /* mailto builder */ function scfSend(ev){ ev.preventDefault(); const v=id=>document.getElementById(id).value.trim(); const rows=[ `Name: ${v('scfFirst')} ${v('scfLast')}`, `E‑mail: ${v('scfEmail')||'—'}`, v('scfPhone') ? `Phone: ${v('scfPhone')}` : '', v('scfWhen') ? `Call When: ${v('scfWhen')}` : '', v('scfZone') ? `Zone: ${v('scfZone')}` : '' ].filter(Boolean); if(v('scfAddl')) rows.push('','Additional Information:',v('scfAddl')); const body = encodeURIComponent(rows.join('\n')); const subject = encodeURIComponent('Contact <?= addslashes($handle) ?>'); location.href = `mailto:<?= rawurlencode($email) ?>?subject=${subject}&body=${body}`; return false; } </script> <?php endif; ?> <!-- QR‑CODE “Save Contact” block for social profiles --> <?php /* pull basic fields that are already defined in view.php */ $qrName = htmlspecialchars($name, ENT_QUOTES, 'UTF-8'); // display name $qrHandle = ltrim($handle, '@'); // no leading @ $profileUrl= "https://bestdealon.com/social/$slug/"; /* core vCard */ $vcard = [ "BEGIN:VCARD", "VERSION:3.0", "FN:$qrName", "NICKNAME:$qrHandle", "URL;TYPE=profile:$profileUrl", ]; /* website */ if (!empty($website)) { $vcard[] = "URL;TYPE=website:$website"; } /* pick up to 3 social URLs in preferred order */ $socialPriority = ['twitter','instagram','facebook']; $added = 0; foreach ($socialPriority as $net) { if (!empty($channels['social'][$net])) { $url = $channels['social'][$net]; // make @username into a full URL when needed if ($net === 'twitter' && strpos($url,'http')!==0) $url = 'https://twitter.com/'.ltrim($url,'@'); if ($net === 'instagram'&& strpos($url,'http')!==0) $url = 'https://instagram.com/'.ltrim($url,'@'); if ($net === 'facebook' && strpos($url,'http')!==0) $url = 'https://facebook.com/'.ltrim($url,'@'); $vcard[] = "URL;TYPE=$net:$url"; if (++$added === 3) break; } } /* phone (optional) */ if (!empty($phone)) { $digits = preg_replace('/\D/','', $phone); $vcard[] = "TEL;TYPE=CELL:$digits"; } $vcard[] = "END:VCARD"; $qrVcard = implode("\n", $vcard); $qrImgUrl = "https://api.qrserver.com/v1/create-qr-code/?size=170x170&data=". urlencode($qrVcard); ?> <div style="text-align:center;margin:1.6em 0 0"> <img src="<?= $qrImgUrl ?>" alt="Scan to save contact for <?= $qrName ?>" style="width:170px;height:170px;border-radius:14px;box-shadow:0 1.5px 10px #e3eefd"> <div style="margin-top:.7em;font-size:1.09em;color:#2b4f8c;font-weight:700"> Scan to Save Contact </div> </div> </main> </body> </html>
Save changes
Create folder
writable 0777
Create
Cancel