Siteβ―Builder
Editing:
ai-review.php
writable 0666
<?php // Get business info using phone number in URL (?ph=) $ph = isset($_GET['ph']) ? preg_replace('/[^\d]/','',$_GET['ph']) : ''; $city = isset($_GET['city']) ? preg_replace('/[^A-Za-z0-9\- ]/', '', $_GET['city']) : ''; $state = isset($_GET['state']) ? preg_replace('/[^A-Za-z]/','',$_GET['state']) : ''; $bizname = isset($_GET['bizname']) ? trim($_GET['bizname']) : ''; $bizData = []; if ($ph) { $bizPath = $_SERVER['DOCUMENT_ROOT'] . '/ph/' . $ph . '/business.json'; if (file_exists($bizPath)) { $bizData = json_decode(file_get_contents($bizPath), true) ?: []; } } if (!$bizData && $bizname) { $bizData = [ "name" => $bizname, "city" => $city, "state" => $state, "phone" => $ph ]; } $bizName = $bizData['name'] ?? $bizname; $bizCity = $bizData['city'] ?? $city; $bizState = $bizData['state'] ?? $state; $bizPhone = $bizData['phone'] ?? $ph; $bizDesc = $bizData['description'] ?? ''; $bizSlogan = $bizData['slogan'] ?? ''; $bizAddr = $bizData['address'] ?? ''; $bizZip = $bizData['zip'] ?? ''; $bizTags = isset($bizData['tags']) && is_array($bizData['tags']) ? implode(', ', $bizData['tags']) : ''; $bizType = $bizTags ? explode(',', $bizTags)[0] : $bizName; // You may want to refine this for best results // ------------------ PHP: Load Business & Question ------------------ // ---------- Data setup (as before) ---------- $aiQuestions = [ "π What do real customers say about this business in their reviews?", "π§βπΌ Who owns or manages this business? Can you share details about the companyβs leadership or founder?", "π Has this business been mentioned in news articles or received any awards?", "π¬ How active and responsive is this business on social media?", "βοΈ Are there any recent complaints or legal actions involving this business?", "π How does this business compare to its top local competitors?", "π What are the businessβs strongest and weakest points according to reviews?", "π© Can you find any red flags or warning signs about this business?", "π Give me a balanced review summary for this business, including both positive and negative feedback found online.", "β What questions should I ask this business before buying or hiring them?" ]; $questionCount = count($aiQuestions); $ph = isset($_GET['ph']) ? preg_replace('/[^\d]/', '', $_GET['ph']) : ''; $bizCity = isset($_GET['city']) ? trim($_GET['city']) : ''; $bizState = isset($_GET['state']) ? trim($_GET['state']) : ''; $bizName = isset($_GET['bizname']) ? trim($_GET['bizname']) : ''; $qidx = isset($_GET['qidx']) && isset($aiQuestions[$_GET['qidx']]) ? (int)$_GET['qidx'] : 0; $chosenQ = $aiQuestions[$qidx]; // Load business.json if phone number provided $bizSlogan = $bizDesc = $bizAddr = $bizZip = $bizTags = ''; if ($ph && is_readable($_SERVER['DOCUMENT_ROOT'] . "/ph/$ph/business.json")) { $bfile = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/ph/$ph/business.json"), true); $bizName = $bfile['name'] ?? $bizName; $bizSlogan = $bfile['slogan'] ?? ''; $bizAddr = $bfile['address'] ?? ''; $bizCity = $bfile['city'] ?? $bizCity; $bizState = $bfile['state'] ?? $bizState; $bizZip = $bfile['zip'] ?? ''; $bizDesc = $bfile['description'] ?? ''; $bizTags = isset($bfile['tags']) ? implode(', ', $bfile['tags']) : ''; } $aiPrompt = "Business: $bizName\n" . ($bizCity && $bizState ? "Location: $bizCity, $bizState\n" : "") . ($bizSlogan ? "Slogan: $bizSlogan\n" : "") . "\nQuestion: " . preg_replace('/^[^a-zA-Z0-9]+/','',$chosenQ) . "\n"; $chatGPTurl = "https://chatgpt.com/?prompt=" . urlencode($aiPrompt); $shareUrl = "https://" . $_SERVER['HTTP_HOST'] . strtok($_SERVER['REQUEST_URI'],'?') . "?ph=$ph&city=" . urlencode($bizCity) . "&state=" . urlencode($bizState) . "&bizname=" . urlencode($bizName) . "&qidx=$qidx"; ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>AI Review for <?= htmlspecialchars($bizName) ?> | BestDealOn</title> <meta name="viewport" content="width=device-width,initial-scale=1"> <meta name="robots" content="noindex,follow"> <style> body { background:#f6f9fd; font-family:system-ui,Arial,sans-serif; margin:0; color:#22334e;} .top { background:#fff; box-shadow:0 1px 7px 0 rgba(60,80,130,.08); padding:1.1em 0 .8em; text-align:center; } .logo { font-weight:900; font-size:1.24em; letter-spacing:-.5px; color:#5016A8; } .logo .d { color:#00c853; } .logo .o{ color:#ff1744; } .wrap { background:#fff; max-width:480px; margin:2em auto 2em; border-radius:17px; box-shadow:0 2px 18px 0 rgba(60,100,180,.08); padding:1.5em 1.35em 1.3em 1.35em; position:relative;} h1 { font-size:1.36em; color:#176edc; margin-bottom:.14em; letter-spacing:-.01em;} .slogan { color:#4c65b7; font-size:1.04em; font-weight:600; margin-bottom:.22em; } .desc { color:#405769; font-size:.97em; margin-bottom:.4em; } .bizinfo { color:#195799; font-size:1.01em; margin-bottom:.6em;} .bizinfo b { color:#2c4e8d; } .current-q { background:#f2f5fe; color:#27334b; border-radius:10px; padding:1.1em 1.1em .2em 1.1em; margin:.7em 0 .7em 0; font-size:1.09em; position:relative; box-shadow:0 1px 8px #dde3fd33; display:flex; flex-direction:column; gap:.52em; } .current-q .qicon { font-size:1.22em; margin-right:.26em; vertical-align:-3px;} .btn-row { display:flex; align-items:center; flex-wrap:wrap; gap:.7em; margin-top:.65em;} .quick-btn { background:linear-gradient(95deg,#94f9a7 0%,#c1efb6 100%); color:#218e24; font-weight:700; border:none; border-radius:8px; font-size:1em; padding:.4em 1.2em; cursor:pointer; transition:.13s; margin-right:.1em; box-shadow:0 1.5px 7px #c1efb655; animation: shimmer 2.3s infinite linear; } @keyframes shimmer {0%{filter:brightness(1.11);} 8%{filter:brightness(1.26);} 12%{filter:brightness(1.06);} 100%{filter:brightness(1.11);}} .quick-btn:active { background:#00c853; color:#fff;} .changebtn { background:#ededfb; color:#3753d0; font-weight:700; border:none; border-radius:8px; font-size:1em; padding:.4em 1.2em; cursor:pointer; transition:.13s; } .changebtn:hover { background:#5b36ff; color:#fff;} .qcount { font-size:.97em; color:#8d8dd7; font-weight:600; margin-left:.4em;} .share-btn { font-size:.98em; color:#3970f8; text-decoration:underline; border:none; background:none; cursor:pointer; margin-left:.5em; transition:.15s; display:inline-flex; align-items:center; gap:.18em; } .share-btn .share-ico { font-size:1.18em; } .share-btn.copied { color:#00802b; font-weight:700; } .showpromptbtn { background:none; border:none; color:#2354a8; font-weight:700; font-size:1.09em; margin:1.15em 0 .6em 0; cursor:pointer;} .showpromptbtn:hover { color:#5b36ff; } .prompt-preview { display:none; background:#fff; border:1px dashed #b9d1fc; color:#244176; border-radius:7px; margin:.18em 0 1.12em 0; padding:1.09em 1.07em .45em 1.07em; font-family:monospace; font-size:.97em; max-height:190px; overflow:auto; position:relative; } .copybtn { float:right; background:#eceff9; color:#2457b5; font-weight:700; border:none; border-radius:7px; font-size:.97em; padding:.25em .94em; cursor:pointer; margin-top:-.22em;} .copybtn:hover { background:#dde3fa; } .gptbtn-sticky { position:sticky; bottom:0; left:0; right:0; display:flex; justify-content:center; background:transparent; padding:1.2em 0 0 0; z-index:11;} .gptbtn { display:inline-block; padding:.77em 2.35em; font-size:1.18em; font-weight:700; color:#fff; background:#176edc; border-radius:10px; text-decoration:none; box-shadow:0 3px 20px #5b36ff13; transition:.16s; } .gptbtn.pulse { animation:pulse .7s; } @keyframes pulse {0%{box-shadow:0 0 0 0 #00c85355;} 100%{box-shadow:0 0 0 13px #00c85300;}} #modal-bg { display:none; position:fixed; z-index:1001; left:0; top:0; width:100vw; height:100vh; background:rgba(34,54,97,0.13);} #modal { display:none; position:fixed; left:50%; top:57%; transform:translate(-50%,-50%); z-index:1002; background:#fff; border-radius:17px; box-shadow:0 7px 44px 0 rgba(34,54,97,0.12); padding:1.25em 1.13em .65em 1.13em; max-width:95vw; width:345px; max-height:73vh; overflow-y:auto; } #modal h3 { margin:0 0 .7em 0; color:#2457b5; font-size:1.07em; text-align:center;} .qmodallist { margin:.28em 0 0 0; max-height:47vh; overflow-y:auto;} .qmodalitem { display:flex; align-items:center; gap:.77em; background:#f3f7ff; color:#233178; border-radius:8px; margin-bottom:.57em; font-size:1.03em; padding:.52em .67em; cursor:pointer; border:1.5px solid #d8e7ff; transition:.13s; } .qmodalitem.selected,.qmodalitem:hover {background:#5b36ff; color:#fff; border-color:#5b36ff;} .qmodalitem .check {font-size:1.09em; margin-right:.14em;} .closebtn { display:block; margin:0 auto .15em auto; background:none; border:none; font-size:1.21em; color:#aaa; cursor:pointer;} .footer-note { font-size:.93em; color:#8f9ebc; text-align:center; margin:2.1em 0 .4em 0; letter-spacing:.02em; } @media (max-width:530px) { .wrap{padding:.64em .05em 1.1em .05em; max-width:99vw;} h1{font-size:1.11em;} .prompt-preview{font-size:.93em;} .gptbtn {font-size:1em; padding:.64em 1em;} } </style> </head> <body> <div class="top"> <div class="logo">BEST <span class="d">DEAL</span> <span class="o">ON</span> <span style="font-weight:400;color:#888;font-size:.93em">AI Review</span></div> </div> <div class="wrap"> <h1>AI Review for <?= htmlspecialchars($bizName) ?></h1> <?php if($bizSlogan): ?><div class="slogan"><?= htmlspecialchars($bizSlogan) ?></div><?php endif; ?> <?php if($bizDesc): ?><div class="desc"><?= htmlspecialchars($bizDesc) ?></div><?php endif; ?> <div class="bizinfo"> <?php if($bizAddr): ?><b>Address:</b> <?= htmlspecialchars($bizAddr) ?><?php endif; ?> <?php if($bizCity && $bizState): ?> <b>City/State:</b> <?= htmlspecialchars($bizCity) ?>, <?= htmlspecialchars($bizState) ?><?php endif; ?> <?php if($bizZip): ?> <b>ZIP:</b> <?= htmlspecialchars($bizZip) ?><?php endif; ?> <?php if($ph): ?> <b>Phone:</b> <?= htmlspecialchars($ph) ?><?php endif; ?> <?php if($bizTags): ?> <b>Tags:</b> <?= htmlspecialchars($bizTags) ?><?php endif; ?> </div> <div class="current-q" id="quickreview"> <span class="qicon"><?= htmlspecialchars(mb_substr($chosenQ,0,2)) ?></span> <?= htmlspecialchars(preg_replace('/^[^a-zA-Z0-9]+/','',$chosenQ)) ?> <div class="btn-row"> <button class="quick-btn" onclick="quickReview()" aria-label="Quick Review" title="Tap for instant review summary">Quick Review</button> <button class="changebtn" onclick="showModal()" aria-label="Change Prompt">Change Prompt</button> <span class="qcount">(<?= $questionCount ?> available)</span> <button class="share-btn" id="shareBtn" onclick="shareLink()" type="button" aria-label="Share This Review"><span class="share-ico">π</span> Share This Review</button> </div> </div> <button class="showpromptbtn" id="togglePrompt" onclick="togglePrompt()">Show Full Prompt</button> <div class="prompt-preview" id="promptBox"> <button class="copybtn" onclick="copyPrompt()" type="button" aria-label="Copy Prompt">Copy</button> <?= nl2br(htmlspecialchars($aiPrompt)) ?> </div> <!-- Hidden form for modal question selection --> <form id="qform" method="get" action="" style="display:none"> <input type="hidden" name="ph" value="<?= htmlspecialchars($ph) ?>"> <input type="hidden" name="city" value="<?= htmlspecialchars($bizCity) ?>"> <input type="hidden" name="state" value="<?= htmlspecialchars($bizState) ?>"> <input type="hidden" name="bizname" value="<?= htmlspecialchars($bizName) ?>"> <input type="hidden" name="qidx" id="qidx" value="<?= $qidx ?>"> </form> </div> <div class="gptbtn-sticky"> <a class="gptbtn" href="<?= htmlspecialchars($chatGPTurl) ?>" target="_blank" rel="noopener" id="gptbtn">π§ Ask ChatGPT About This Business</a> </div> <!-- Modal window for question selection --> <div id="modal-bg"></div> <div id="modal"> <button class="closebtn" onclick="closeModal()" aria-label="Close">×</button> <h3>Pick a question for AI (<?= $questionCount ?>):</h3> <div class="qmodallist"> <?php foreach($aiQuestions as $i => $q): ?> <div class="qmodalitem<?= ($qidx==$i?' selected':'') ?>" data-idx="<?= $i ?>"> <span class="check"><?= ($qidx==$i ? 'β' : 'β') ?></span> <?= htmlspecialchars($q) ?> </div> <?php endforeach; ?> </div> </div> <div class="footer-note"> <span>π No data is sent to us. You use ChatGPT direct. AI answers may not be 100% accurateβalways double-check.</span> </div> <script> function showModal() { document.getElementById('modal-bg').style.display = 'block'; document.getElementById('modal').style.display = 'block'; document.body.style.overflow = 'hidden'; } function closeModal() { document.getElementById('modal-bg').style.display = 'none'; document.getElementById('modal').style.display = 'none'; document.body.style.overflow = ''; } document.getElementById('modal-bg').onclick = closeModal; document.querySelectorAll('.qmodalitem').forEach(function(item){ item.onclick = function() { document.getElementById('qidx').value = item.getAttribute('data-idx'); document.getElementById('qform').submit(); }; }); function togglePrompt() { var p = document.getElementById('promptBox'); var b = document.getElementById('togglePrompt'); if (p.style.display === 'block') { p.style.display = 'none'; b.textContent = "Show Full Prompt"; } else { p.style.display = 'block'; b.textContent = "Hide Full Prompt"; setTimeout(function(){p.scrollIntoView({behavior:'smooth',block:'center'});},160); } } function copyPrompt() { var el = document.createElement('textarea'); el.value = document.getElementById('promptBox').textContent.replace(/Copy$/,''); document.body.appendChild(el); el.select(); document.execCommand('copy'); document.body.removeChild(el); alert('Prompt copied!'); } document.getElementById('promptBox').style.display = 'none'; function quickReview() { // Animate review card var quick = document.getElementById('quickreview'); quick.style.background="#e9ffe9"; setTimeout(function(){quick.style.background="#f2f5fe";}, 650); var btn = document.getElementById('gptbtn'); btn.classList.add('pulse'); setTimeout(function(){btn.classList.remove('pulse');}, 800); } function shareLink() { var btn = document.getElementById('shareBtn'); var url = "<?= htmlspecialchars($shareUrl) ?>"; navigator.clipboard.writeText(url).then(function() { btn.textContent = "β Copied!"; btn.classList.add('copied'); setTimeout(function(){ btn.innerHTML = '<span class="share-ico">π</span> Share This Review'; btn.classList.remove('copied'); }, 1400); }, function() { prompt('Copy this review link:', url); }); } </script> </body> </html>
Save changes
Create folder
writable 0777
Create
Cancel