Siteβ―Builder
Editing:
ai-reviews.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 ------------------ $aiQuestions = [ "Give me a balanced review summary for this business, including both positive and negative feedback found online.", "Who owns or manages this business? Can you share details about the companyβs leadership or founder?", "What do real customers say about this business in their reviews?", "How active and responsive is this business on social media?", "Has this business been mentioned in news articles or received any awards?", "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?", "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']) : ''; } // Short prompt, no instructions $aiPrompt = "Business: $bizName\n" . ($bizCity && $bizState ? "Location: $bizCity, $bizState\n" : "") . ($bizSlogan ? "Slogan: $bizSlogan\n" : "") . "\nQuestion: $chosenQ\n"; $chatGPTurl = "https://chatgpt.com/?prompt=" . urlencode($aiPrompt); ?> <!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"> <style> body { background:#f7faff; font-family:system-ui,Arial,sans-serif; margin:0; color:#203855;} .top { background:#fff; box-shadow:0 2px 14px 0 rgba(40,80,130,.07); padding:1.3em 0 .9em; text-align:center; } .logo { font-weight:900; font-size:1.2em; letter-spacing:-.5px; color:#5016A8; } .wrap { background:#fff; max-width:450px; margin:2.1em auto 1.4em; border-radius:18px; box-shadow:0 2px 16px 0 rgba(60,100,180,.09); padding:1.5em 1.1em 1.4em 1.1em; position:relative;} h1 { font-size:1.45em; color:#176edc; margin-bottom:.25em; } .slogan { color:#5776c6; font-size:.97em; font-weight:600; margin-bottom:.2em; } .desc { color:#43596c; font-size:.97em; margin-bottom:.3em; } .bizinfo { color:#215b99; font-size:.97em; margin-bottom:.9em;} .bizinfo b { color:#294e8c; } .current-q { background:#eef2fb; color:#264989; border-radius:8px; padding:1em 1.1em; margin:1.15em 0 .2em 0; font-size:1.08em;} .changebtn {display:inline-block; margin:1.2em 0 0 .2em; background:#ededfb; color:#3250d0; font-weight:700; border:none; border-radius:7px; font-size:1.08em; padding:.45em 1.25em; cursor:pointer; transition:.13s;} .changebtn:hover { background:#5b36ff; color:#fff;} .qcount { font-size:.97em; color:#8d8dd7; font-weight:600; margin-left:.7em;} .showpromptbtn { background:none; border:none; color:#2464a8; font-weight:700; font-size:1.08em; margin:.85em 0 .4em 0; cursor:pointer;} .showpromptbtn:hover { color:#5b36ff; } .prompt-preview { display:none; background:#fff; border:1px dashed #b9d1fc; color:#244176; border-radius:7px; margin:.5em 0 1.05em 0; padding:.8em .5em; font-family:monospace; font-size:.98em; max-height:190px; overflow:auto;} .copybtn { float:right; background:#eceff9; color:#2457b5; font-weight:700; border:none; border-radius:7px; font-size:.92em; padding:.24em .9em; cursor:pointer; margin-top:-.3em;} .copybtn:hover { background:#dde3fa; } .gptbtn-sticky { position:sticky; bottom:0; left:0; right:0; display:flex; justify-content:center; background:transparent; padding:.9em 0 0 0; } .gptbtn { display:inline-block; padding:.72em 2em; font-size:1.14em; font-weight:700; color:#fff; background:#176edc; border-radius:8px; text-decoration:none;} .gptbtn:hover { background:#2457b5;} #modal-bg { display:none; position:fixed; z-index:1001; left:0; top:0; width:100vw; height:100vh; background:rgba(34,54,97,0.19);} #modal { display:none; position:fixed; left:50%; top:49%; transform:translate(-50%,-50%); z-index:1002; background:#fff; border-radius:17px; box-shadow:0 7px 44px 0 rgba(34,54,97,0.10); padding:1.4em 1em .6em 1em; max-width:96vw; width:370px; max-height:79vh; overflow-y:auto;} #modal h3 { margin:0 0 .8em 0; color:#2457b5; font-size:1.07em; text-align:center;} .qmodallist { margin:.5em 0 0 0; max-height:47vh; overflow-y:auto;} .qmodalitem { display:flex; align-items:center; gap:.85em; background:#f3f7ff; color:#234188; border-radius:8px; margin-bottom:.6em; font-size:1.04em; padding:.59em .7em; cursor:pointer; border:1.5px solid #d8e7ff;} .qmodalitem.selected,.qmodalitem:hover {background:#5b36ff; color:#fff; border-color:#5b36ff;} .qmodalitem .check {font-size:1.12em; margin-right:.29em;} .closebtn { display:block; margin:0 auto .2em auto; background:none; border:none; font-size:1.2em; color:#aaa; cursor:pointer;} @media (max-width:520px) { .wrap{padding:.67em .1em 1.5em .1em; max-width:99vw;} h1{font-size:1.07em;} .prompt-preview{font-size:.93em;} } </style> </head> <body> <div class="top"> <div class="logo">BEST <span style="color:#00c853">DEAL</span> <span style="color:#ff1744">ON</span> <span style="font-weight:400;color:#999">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"> <?= htmlspecialchars($chosenQ) ?> <button class="changebtn" onclick="showModal()" aria-label="Change Prompt">Change Prompt</button> <span class="qcount">(<?= $questionCount ?> available)</span> </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">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>Select a question (<?= $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> <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'});},180); } } 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'; </script> </body> </html>
Save changes
Create folder
writable 0777
Create
Cancel