SiteโฏBuilder
Editing:
index1.php
writable 0666
<?php // --- CONFIG --- // $root = dirname(__DIR__); $ph = preg_replace('/\D/', '', $_GET['ph'] ?? ''); $bizdir = $root . '/ph/' . $ph; $bizjson = "$bizdir/business.json"; $couponjson = "$bizdir/coupon.json"; $isPaid = is_readable($bizjson); $coupon = []; if ($isPaid && is_readable($couponjson)) { $coupon = json_decode(file_get_contents($couponjson), true) ?: []; } function h($s){ return htmlspecialchars($s, ENT_QUOTES, 'UTF-8'); } // --- Handle AJAX save --- if ($_SERVER['REQUEST_METHOD']==='POST' && $isPaid) { $data = json_decode(file_get_contents("php://input"), true); $coupon = [ 'title' => trim($data['title'] ?? ''), 'desc' => trim($data['desc'] ?? ''), 'code' => trim($data['code'] ?? ''), 'expiry' => trim($data['expiry'] ?? ''), ]; file_put_contents($couponjson, json_encode($coupon, JSON_PRETTY_PRINT)); header('Content-Type: application/json'); echo json_encode(['success'=>true,'coupon'=>$coupon]); exit; } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Business Coupon Creator | 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:700px;margin:2.7em auto 0 auto;} h1{color:#2a3ca5;margin-bottom:.18em;} .coupon-form{background:#fffbe6;border:1.7px solid #f3e5b7;padding:1.9em 1.5em 1.5em 1.5em;border-radius:15px;box-shadow:0 3px 20px #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.2em;} .coupon-preview-title{font-size:1.15em;font-weight:700;color:#ab2d00;margin-bottom:.65em;} .coupon-preview { background: repeating-linear-gradient(135deg,#f7d89e,#f7d89e 10px,#fffbe6 10px,#fffbe6 20px); border:3.5px dashed #ffbe4e; border-radius:22px; max-width:420px; margin:auto; padding:2em 1.2em 1.5em 1.2em; box-shadow:0 4px 26px #ffbe4e25,0 1.5px 10px #fae1a1; position:relative; overflow:hidden; } .coupon-preview h2 {margin:0 0 .39em 0;color:#d64100;font-size:1.36em;} .coupon-preview .desc {font-size:1.12em;color:#824801;margin-bottom:1.11em;} .coupon-preview .row {display:flex;justify-content:space-between;align-items:center;} .coupon-preview .label {font-weight:700;color:#ab2d00;font-size:1em;} .coupon-preview .code { background:#ffefc1;border-radius:9px;display:inline-block;padding:.34em 1.9em;font-size:1.22em;color:#a95600;font-family:monospace;font-weight:700; letter-spacing:.06em;box-shadow:0 1px 5px #ffbe4e33; } .coupon-preview .expiry {font-size:1.01em;color:#ce5c00;} @media(max-width:600px){ .page-wrap,.coupon-preview{padding:.5em .3em;} .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 (!$ph || !is_dir($bizdir)): ?> <div class="upgrade-block"> <h2>Business Not Found</h2> Please use a valid business phone number. </div> <?php elseif (!$isPaid): ?> <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: ?> <h1>Coupon Creator for <?= h($ph) ?></h1> <form class="coupon-form" id="couponForm" autocomplete="off" onsubmit="return false;"> <label>Coupon Headline/Title<br> <input name="title" maxlength="70" value="<?= h($coupon['title'] ?? '') ?>" required> </label> <label>Details/Description<br> <textarea name="desc" rows="3" maxlength="300" required><?= h($coupon['desc'] ?? '') ?></textarea> </label> <label>Coupon Code<br> <input name="code" maxlength="30" value="<?= h($coupon['code'] ?? '') ?>" required> </label> <label>Expires (date)<br> <input name="expiry" type="date" value="<?= h($coupon['expiry'] ?? '') ?>" required> <span class="small">(Leave blank for 'No Expiry')</span> </label> <button style="background:#ef8f13;color:#fff;padding:.55em 2.1em;border-radius:8px;font-weight:700;letter-spacing:.05em; font-size:1.13em; border:none;cursor:pointer;">Save Coupon</button> <div id="saveMsg" style="margin-top:1em;font-size:1.06em;"></div> </form> <div class="coupon-preview-wrap"> <div class="coupon-preview-title">Live Coupon Preview</div> <div class="coupon-preview" id="couponPreview"> <h2 id="pvTitle"><?= h($coupon['title'] ?? 'Your Coupon Headline Here') ?></h2> <div class="desc" id="pvDesc"><?= h($coupon['desc'] ?? 'Your best deal description will appear here.') ?></div> <div class="row" style="margin-bottom:.65em;"> <span class="label">Coupon Code:</span> <span class="code" id="pvCode"><?= h($coupon['code'] ?? 'BESTDEAL') ?></span> </div> <div class="row"> <span class="label">Expires:</span> <span class="expiry" id="pvExpiry"><?= h($coupon['expiry'] ?? '') ?></span> </div> </div> </div> <script> function updatePreview() { document.getElementById('pvTitle').innerText = document.querySelector('[name=title]').value || 'Your Coupon Headline Here'; document.getElementById('pvDesc').innerText = document.querySelector('[name=desc]').value || 'Your best deal description will appear here.'; document.getElementById('pvCode').innerText = document.querySelector('[name=code]').value || 'BESTDEAL'; let exp = document.querySelector('[name=expiry]').value; document.getElementById('pvExpiry').innerText = exp ? exp : 'No Expiry'; } Array.from(document.querySelectorAll('.coupon-form input,.coupon-form textarea')).forEach(el=>{ el.addEventListener('input', updatePreview); }); document.getElementById('couponForm').onsubmit = async function() { const fd = new FormData(this); let payload = {}; fd.forEach((v,k)=>payload[k]=v); let r = await fetch(location.pathname+location.search, { method:'POST', headers: {'Content-Type':'application/json'}, body: JSON.stringify(payload) }); let json = await r.json(); document.getElementById('saveMsg').innerText = json.success ? 'Coupon saved!' : 'Error saving coupon.'; }; updatePreview(); </script> <?php endif; ?> </div> </body> </html>
Save changes
Create folder
writable 0777
Create
Cancel