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 => { const url = location.href; try { if (navigator.share) await navigator.share({title:<?= json_encode($title) ?>,url}); else await navigator.clipboard.writeText(url); e.target.textContent='✅ Copied!'; setTimeout(()=>e.target.textContent='📤 Share',1500); } catch{} }; })(); </script> <?php endforeach; ?> </section> <?php endif; ?> <?php /* ---------- Social contact‑by‑email block --------------------------- */ $email = $profile['email'] ?? ''; if ($isPremium && filter_var($email, FILTER_VALIDATE_EMAIL)): ?> <div style="max-width:470px;margin:2.2rem 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);"> <!-- coloured ribbon --> <div style="background:#e62a19;color:#fff;font-weight:900;font-size:1.14em;line-height:1.25; padding:.7em 1em;text-align:center;letter-spacing:.01em;border-bottom:2.5px solid #ffdd9c;"> Book a Show / Ask a Question<br> <span style="font-size:.9em;font-weight:600;opacity:.9;">Contact <?= h($handle) ?></span> </div> <div style="padding:1.1em .9em .9em .9em"> <!-- Row 1 --> <div style="display:flex;flex-wrap:wrap;gap:.8em"> <div style="flex:1 1 145px;min-width:120px"> <label for="scfFirst" style="font-weight:600;color:#de5200">First:</label> <input id="scfFirst" type="text" maxlength="32" required style="width:100%;padding:.4em .7em;margin-top:.15em;border-radius:7px;border:1.2px solid #ffe4b2"> </div> <div style="flex:1 1 145px;min-width:120px"> <label for="scfLast" style="font-weight:600;color:#de5200">Last:</label> <input id="scfLast" type="text" maxlength="32" required style="width:100%;padding:.4em .7em;margin-top:.15em;border-radius:7px;border:1.2px solid #ffe4b2"> </div> </div> <!-- Row 2 --> <div style="display:flex;flex-wrap:wrap;gap:.8em;margin-top:.7em"> <div style="flex:1 1 200px;min-width:150px"> <label for="scfEmail" style="font-weight:600;color:#de5200">Your E‑mail:</label> <input id="scfEmail" type="email" maxlength="60" required style="width:100%;padding:.4em .7em;margin-top:.15em;border-radius:7px;border:1.2px solid #ffe4b2"> </div> <div style="flex:1 1 170px;min-width:130px"> <label for="scfPhone" style="font-weight:600;color:#de5200">Your Phone:</label> <input id="scfPhone" type="text" maxlength="18" style="width:100%;padding:.4em .7em;margin-top:.15em;border-radius:7px;border:1.2px solid #ffe4b2"> </div> </div> <!-- Row 3 --> <div style="display:flex;flex-wrap:wrap;gap:.8em;margin-top:.7em"> <div style="flex:1 1 150px;min-width:120px"> <label for="scfWhen" style="font-weight:600;color:#de5200">Call When:</label> <select id="scfWhen" style="width:100%;padding:.4em .5em;margin-top:.15em;border-radius:7px;border:1.2px solid #ffe4b2"> <option value="" selected>–</option> <option>Anytime</option><option>Morning</option><option>Afternoon</option><option>Evening</option> </select> </div> <div style="flex:1 1 110px;min-width:95px"> <label for="scfZone" style="font-weight:600;color:#de5200">Zone:</label> <select id="scfZone" style="width:100%;padding:.4em .5em;margin-top:.15em;border-radius:7px;border:1.2px solid #ffe4b2"> <option value="" selected>–</option><option>ET</option><option>CT</option><option>MT</option><option>PT</option> </select> </div> </div> <!-- extra info toggle --> <div style="margin-top:1.05em;text-align:right"> <a href="#" id="scfToggle" style="font-size:.95em;color:#1567b2;text-decoration:underline;cursor:pointer;font-weight:600">+ Additional Information</a> </div> <div id="scfExtra" style="display:none;margin-top:.9em"> <label for="scfAddl" style="font-weight:600;color:#de5200">Details / Additional Info:</label> <textarea id="scfAddl" rows="3" style="width:100%;padding:.5em;margin-top:.15em;border-radius:7px;border:1.2px solid #ffe4b2;resize:vertical"></textarea> </div> <!-- submit --> <div style="margin-top:1.3em;text-align:right"> <button type="submit" style="background:#ef8f13;color:#fff;font-weight:800;font-size:1.05em;padding:.63em 2.25em;border-radius:9px;border:none;box-shadow:0 1px 7px #ffeebb7a;cursor:pointer"> SEND </button> </div> </div> </form> </div> <script> /* toggle extra info */ 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'; }; /* build mailto */ 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 subj = encodeURIComponent('Contact '+<?= json_encode($handle) ?>); location.href=`mailto:<?= rawurlencode($email) ?>?subject=${subj}&body=${body}`; return false; } </script> <?php endif; ?> </main> </body> </html>
Save changes
Create folder
writable 0777
Create
Cancel