Site Builder
Editing:
indexgooood.php
writable 0666
<script src="/ai-business-research/admin-protect.js"></script><?php /* ============================================================ BestDealOn – Coupon Creator (safe lookup + paid check) ============================================================ */ function h($s){ return htmlspecialchars($s ?? '', ENT_QUOTES, 'UTF-8'); } /* ---------- phone & path ---------- */ $ph = preg_replace('/\D/','', $_GET['ph'] ?? ''); $root = dirname(__DIR__, 1); // adjust if folder structure differs $bizdir = $root . '/ph/' . $ph; $bizjson = "$bizdir/business.json"; $isPaid = is_readable($bizjson); /* ---------- lookup screen helper ---------- */ function show_lookup($ph='', $err=''){ ?><!DOCTYPE html><html lang="en"><head> <meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"> <title>Lookup Business | BestDealOn</title> <style> body{background:#f6f8fb;font-family:system-ui,Arial,sans-serif;margin:0;color:#234;} .wrap{max-width:500px;margin:3em auto;background:#fff;padding:2em;border-radius:17px;box-shadow:0 2px 18px #dde3fa33;text-align:center;} h1{font-size:1.4em;margin-bottom:.8em;} input{width:100%;padding:.7em;border-radius:7px;border:1.4px solid #b7c2df;font-size:1.08em;} button{margin-top:1em;padding:.7em 1.6em;font-size:1.08em;font-weight:700;background:#2357d7;color:#fff;border:none;border-radius:8px;cursor:pointer;} .err{color:#d7262d;margin-bottom:.9em;} </style></head><body> <div class="wrap"> <h1>Look up Your Business</h1> <?php if($err) echo "<div class='err'>".h($err)."</div>"; ?> <form method="get"> <input type="tel" name="ph" maxlength="10" pattern="\d{10}" placeholder="Enter 10‑digit phone" value="<?=h($ph)?>" required> <button type="submit">Load Profile</button> </form> </div></body></html><?php exit; } /* ---------- safe‑landing checks ---------- */ if (!$ph){ // no phone supplied show_lookup(); } if (!is_dir($bizdir)){ // phone folder missing show_lookup($ph, "No business found for phone $ph."); } ?> <script src="/ai-business-research/admin-protect.js"></script> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Coupon Creator for <?= h($ph) ?> | BestDealOn</title> <meta name="viewport" content="width=device-width,initial-scale=1"> <style> body {background:#f5f8fb;font-family:system-ui,Arial,sans-serif;margin:0;color:#263238;} .top-bar{background:#eee;padding:.8em 1.2em;font-weight:900;} .page-wrap{max-width:760px;margin:2.7em auto 0 auto;} h1{color:#2a3ca5;margin-bottom:.18em;} /* --- coupon form & preview (unchanged) --- */ .coupon-form{background:#fffbe6;border:2.5px solid #ffd973;padding:2.4em 2em 2em 2em;border-radius:18px;box-shadow:0 4px 30px #f5db9c3c;} .coupon-form label{font-weight:600;color:#704000;} .coupon-form input,.coupon-form textarea{font-size:1.1em;width:100%;padding:.4em;border-radius:7px;border:1.1px solid #ead27b;margin:.25em 0 1.05em 0;} .coupon-form input[type=date]{padding:.33em;} .coupon-form .small{font-size:.97em;color:#986;} .coupon-preview-wrap{margin-top:2.5em;} .coupon-preview-title{font-size:1.18em;font-weight:700;color:#b23c00;margin-bottom:.75em;} .coupon-toolbar{display:flex;justify-content:flex-end;gap:1.1em;margin-bottom:.6em;} .coupon-btn{padding:.5em 1.15em;border-radius:8px;font-size:1.07em;font-weight:700;border:none;cursor:pointer;box-shadow:0 1px 5px #ffeebb50;background:#ffeebb;transition:background .17s,color .17s;} .coupon-btn:hover{background:#ffd670;color:#fff;} .coupon-preview{background:#fff;border:3.5px solid #ffb63b;border-radius:27px;max-width:500px;margin:auto;padding:2.2em 2em 1.5em 2em;box-shadow:0 10px 38px #c59e6933,0 2.5px 17px #fae1a1;position:relative;overflow:hidden;} .coupon-preview h2{margin:0 0 .46em 0;color:#df6200;font-size:1.49em;} .coupon-preview .desc{font-size:1.15em;color:#56411e;margin-bottom:1.31em;line-height:1.5;} .coupon-preview .desc.collapsed{max-height:4.6em;overflow:hidden;position:relative;} .coupon-preview .read-more{color:#b0640d;font-weight:600;text-decoration:underline;cursor:pointer;margin-left:.36em;font-size:1.07em;} .coupon-preview .row{display:flex;justify-content:space-between;align-items:center;margin-bottom:.3em;} .coupon-preview .label{font-weight:700;color:#ab2d00;font-size:1.05em;} .coupon-preview .code{background:#ffefc1;border-radius:9px;display:inline-block;padding:.37em 2.1em;font-size:1.22em;color:#a95600;font-family:monospace;font-weight:700;letter-spacing:.08em;box-shadow:0 1px 8px #ffbe4e42;} .coupon-preview .expiry{font-size:1.09em;color:#a75608;font-weight:600;} .coupon-preview .desc.collapsed:after{content:"";display:block;position:absolute;right:0;bottom:0;width:90%;height:1.9em;background:linear-gradient(to top,#fff,0%,rgba(255,255,255,0) 100%);} @media(max-width:600px){.page-wrap,.coupon-preview{padding:.7em .14em;}.coupon-preview{max-width:98vw;}} .upgrade-block{margin-top:2.9em;text-align:center;background:#f7e6e6;padding:2.1em 1.3em;border-radius:13px;border:2px solid #f2cccc;box-shadow:0 1.5px 9px #f5bebe30;} .upgrade-block h2{color:#c00;} .upgrade-block a{display:inline-block;margin-top:1.1em;background:#ef8f13;color:#fff;padding:.65em 2.3em;border-radius:9px;font-weight:700;text-decoration:none;} </style> </head> <body> <div class="top-bar"><a href="/" style="text-decoration:none;color:#2a3ca5">BestDealOn</a> » Coupon Builder</div> <div class="page-wrap"> <?php if (!$isPaid): /* ---------- not premium ---------- */ ?> <div class="upgrade-block"> <h2>Coupons are a Premium Feature</h2> <div>Upgrade to a Premium Membership to create a business coupon and unlock AI marketing tools!</div> <a href="/advertise.php?geo=<?= h($ph) ?>">Become a Member</a> </div> <?php else: /* ---------- premium: show full builder ---------- */ ?> <h1>Coupon Creator for <?= h($ph) ?></h1> <!-- ===== Coupon form ===== --> <form class="coupon-form" id="couponForm" autocomplete="off" onsubmit="return false;"> <input type="hidden" name="ph" value="<?= h($ph) ?>"> <label>Coupon Headline/Title<br><input name="title" maxlength="100" required></label> <label>Details/Description<br><textarea name="desc" rows="4" required></textarea></label> <label>Coupon Code<br><input name="code" maxlength="40" required></label> <label>Expires (date)<br><input name="expiry" type="date" id="expiryField"> <span class="small">(Leave blank for 'No Expiry')</span></label> <button type="submit" style="background:#ef8f13;color:#fff;padding:.55em 2.1em;border-radius:8px;font-weight:700;font-size:1.13em;border:none;cursor:pointer;">Save Coupon</button> <div id="saveMsg" style="margin-top:1em;font-size:1.06em;"></div> </form> <!-- ===== Preview ===== --> <div class="coupon-preview-wrap"> <div class="coupon-preview-title">Live Coupon Preview</div> <div class="coupon-toolbar"> <button class="coupon-btn" id="printCouponBtn" title="Print only the coupon">🖨️ Print Coupon</button> <button class="coupon-btn" id="shareCouponBtn" title="Share this coupon">📤 Share Coupon</button> </div> <div class="coupon-preview" id="couponPreview" itemscope itemtype="https://schema.org/Offer"> <h2 id="pvTitle" itemprop="name">Your Coupon Headline Here</h2> <div class="desc collapsed" id="pvDesc" itemprop="description"></div> <span id="readMoreLink" class="read-more" style="display:none;">Read more</span> <div class="row"><span class="label">Coupon Code:</span><span class="code" id="pvCode" itemprop="identifier">BESTDEAL</span></div> <div class="row"><span class="label">Expires:</span><span class="expiry" id="pvExpiry" itemprop="validThrough"></span></div> </div> </div> <!-- ===== JS (unchanged) ===== --> <script> const ph = <?= json_encode($ph) ?>; window.addEventListener('DOMContentLoaded', async () => { try{ const r = await fetch('api.php?ph='+encodeURIComponent(ph)); const j = await r.json(); if(j.success && j.coupon){ ['title','desc','code','expiry'].forEach(k=>{ if(j.coupon[k]) document.querySelector('[name='+k+']').value=j.coupon[k]; }); } }catch(e){} // default expiry const ex=document.getElementById('expiryField'); if(ex&&!ex.value){ const d=new Date(); d.setFullYear(d.getFullYear()+1); ex.value=d.toISOString().slice(0,10); } updatePreview(); }); function updatePreview(){ const t=document.querySelector('[name=title]').value||'Your Coupon Headline Here'; const d=document.querySelector('[name=desc]').value||'Your best deal description will appear here.'; const c=document.querySelector('[name=code]').value||'BESTDEAL'; const e=document.querySelector('[name=expiry]').value; document.getElementById('pvTitle').innerText=t; document.getElementById('pvCode').innerText=c; document.getElementById('pvExpiry').innerText=e||'No Expiry'; const pv=document.getElementById('pvDesc'), rm=document.getElementById('readMoreLink'); const limit=170; if(d.length>limit){ pv.textContent=d.slice(0,limit)+'…'; pv.classList.add('collapsed'); rm.style.display=''; rm.onclick=()=>{pv.textContent=d; pv.classList.remove('collapsed'); rm.style.display='none';}; }else{pv.textContent=d; pv.classList.remove('collapsed'); rm.style.display='none';} } document.querySelector('[name=desc]').removeAttribute('maxlength'); document.querySelectorAll('.coupon-form input,.coupon-form textarea').forEach(el=>el.addEventListener('input',updatePreview)); document.getElementById('printCouponBtn').onclick=()=>{ const html=document.getElementById('couponPreview').outerHTML; const w=window.open('','','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;} ${document.querySelector('style').innerHTML}</style></head><body>${html}</body></html>`); w.document.close(); setTimeout(()=>{w.print();w.close();},200); }; document.getElementById('shareCouponBtn').onclick=function(){ const url=location.href, t=document.querySelector('[name=title]').value||'Coupon'; const d=document.querySelector('[name=desc]').value||''; if(navigator.share){navigator.share({title:t,text:d,url});} else{navigator.clipboard.writeText(url);this.textContent='✅ Link Copied!';setTimeout(()=>this.textContent='📤 Share Coupon',1700);} }; document.getElementById('couponForm').onsubmit=async function(e){ e.preventDefault(); const fd=new FormData(this), obj={}; fd.forEach((v,k)=>obj[k]=v); const r=await fetch('api.php?ph='+encodeURIComponent(ph),{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify(obj)}); const j=await r.json(); document.getElementById('saveMsg').innerText=j.success?'Coupon saved!':'Error saving coupon.'; }; </script> <?php endif; /* premium vs upgrade */ ?> </div></body></html>
Save changes
Create folder
writable 0777
Create
Cancel