Site Builder
Editing:
modules-qrold.php
writable 0666
<?php /************************************************************************** * QR + vCard DOWNLOAD MODULE * ---------------------------------------------------------------------- * • Requires /qr-proxy.php which returns a png for ?data=<urlencoded vcard> * • Hides itself when profile lacks an email OR display_name **************************************************************************/ /* ---------- 1. Load profile ---------- */ /* 1) Load profile.json if $profile isn’t set */ if (function_exists('get_profile')) { $profile = get_profile(); } $name = $profile['display_name'] ?? $profile['handle'] ?? ''; $handle = ltrim($profile['handle'] ?? '', '@'); $phone = $profile['phone'] ?? ''; $site = $profile['website'] ?? ''; $email = $profile['email'] ?? ''; $slug = $profile['slug'] ?? ''; if (!$name || !$email) { return; } // nothing useful to encode /* ---------- 2. Build vCard 3.0 ---------- */ $lines = [ 'BEGIN:VCARD', 'VERSION:3.0', 'FN:' . $name, 'NICKNAME:' . $handle, 'EMAIL;TYPE=internet:' . $email, 'URL;TYPE=profile:https://bestdealon.com/social/' . $slug . '/', ]; if ($site) $lines[] = 'URL;TYPE=website:' . $site; if ($phone){ $digits = preg_replace('/\D/','',$phone); $lines[] = 'TEL;TYPE=CELL:' . $digits; } $lines[] = 'END:VCARD'; $vcard = implode("\n", $lines); /* proxy URL for QR image */ $qrURL = '/qr-proxy.php?data=' . rawurlencode($vcard); ?> <!-- ===== QR + DOWNLOAD SECTION (v2) ===== --> <section class="qr-shell"> <div class="qr-card"> <img id="qrImg" alt="Scan to save contact" width="170" height="170" src="<?= htmlspecialchars($qrURL) ?>" style="border-radius:14px;box-shadow:0 1.5px 10px #e3eefd"> <h3>Scan to Save Contact</h3> <button id="dlBtn" class="qr-btn" aria-label="Download contact as vCard"> 📱 Add to Phone (vCard) </button> <div class="qr-hint">Works on iOS & Android • 9 kB</div> <noscript style="margin-top:.7rem;font-size:.9rem"> <a href="<?= htmlspecialchars($qrURL) ?>" download="<?= $handle ?>.vcf"> Download contact card </a> </noscript> </div> </section> <style> .qr-shell{margin:2.6rem auto;max-width:clamp(480px,70vw,720px);width:100%; font-family:system-ui,Arial,sans-serif;text-align:center} .qr-card{ background:#fff;padding:1.7rem 1.5rem; border:3.5px solid #ffb63b; /* ← same as coupons */ border-radius:27px;box-shadow:0 8px 26px rgba(0,0,0,.06) } .qr-card h3{margin:1rem 0 .8rem;font-size:1.2rem;font-weight:700;color:#102a66} .qr-btn{ background:#ffb63b;color:#000;font-weight:700; padding:.65em 1.9em;border:none;border-radius:8px;cursor:pointer;font-size:1rem; box-shadow:0 2px 6px rgba(0,0,0,.08);transition:background .15s } .qr-btn:hover{background:#ffa726} .qr-hint{margin-top:.45rem;font-size:.85rem;color:#5d5d5d} </style> <script> /* JS unchanged – still streams the .vcf on the fly */ document.getElementById('dlBtn').addEventListener('click',()=>{ const blob = new Blob([`<?= addslashes($vcard) ?>`], {type:'text/vcard'}); const url = URL.createObjectURL(blob); const a = Object.assign(document.createElement('a'), {href:url,download:'<?= $handle ?: "contact" ?>.vcf'}); document.body.appendChild(a); a.click(); document.body.removeChild(a); URL.revokeObjectURL(url); }); </script>
Save changes
Create folder
writable 0777
Create
Cancel