📁 File Manager
🏠 /
/
home
/
u857492117
/
domains
/
mangaldaicollege.org
/
public_html
Dosya Düzenle: faq_report.php
<?php /** * faq_report.php — Private report of questions asked to the FAQ Assistant. * NOT linked from any menu, navbar, or page — access it directly by URL only. * Place this file in the same root folder as faq.php. * ⚠️ CHANGE THE PASSWORD BELOW BEFORE UPLOADING. */ session_start(); define('REPORT_PASSWORD', 'Admin@8421?'); // ⚠️ CHANGE THIS $logFile = __DIR__ . '/includes/data/faq_log.jsonl'; /* ---- Simple login ---- */ $loginError = ''; if (isset($_POST['password'])) { if (hash_equals(REPORT_PASSWORD, $_POST['password'])) { $_SESSION['faq_report_auth'] = true; } else { $loginError = 'Incorrect password.'; } } if (isset($_GET['logout'])) { unset($_SESSION['faq_report_auth']); } $isAuthed = !empty($_SESSION['faq_report_auth']); if (!$isAuthed) { ?> <!DOCTYPE html> <html><head><meta charset="UTF-8"><title>FAQ Report — Login</title> <style> body{font-family:sans-serif;background:#05060f;color:#fff;display:flex;align-items:center;justify-content:center;height:100vh;margin:0} form{background:#141414;padding:32px;border-radius:12px;border:1px solid #333;width:300px} input{width:100%;padding:10px;margin-top:8px;margin-bottom:16px;border-radius:6px;border:1px solid #444;background:#000;color:#fff;box-sizing:border-box} button{width:100%;padding:10px;background:#f4b400;border:none;border-radius:6px;font-weight:700;cursor:pointer} .err{color:#ff6b6b;font-size:0.85rem;margin-bottom:10px} h2{margin-top:0} label{font-size:0.8rem;color:#aaa} </style></head><body> <form method="POST"> <h2>🔒 FAQ Report Login</h2> <?php if ($loginError): ?><div class="err"><?= htmlspecialchars($loginError) ?></div><?php endif; ?> <label>Password</label> <input type="password" name="password" autofocus required> <button type="submit">Enter</button> </form> </body></html> <?php exit; } /* ---- Read log ---- */ $rows = []; if (file_exists($logFile)) { $lines = file($logFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); foreach ($lines as $line) { $d = json_decode($line, true); if ($d) $rows[] = $d; } } $rows = array_reverse($rows); // newest first /* ---- CSV export ---- */ if (isset($_GET['export']) && $_GET['export'] === 'csv') { header('Content-Type: text/csv'); header('Content-Disposition: attachment; filename="faq_questions.csv"'); $out = fopen('php://output', 'w'); fputcsv($out, ['Time', 'Question', 'Matched', 'Location', 'Latitude', 'Longitude', 'IP']); foreach ($rows as $r) { fputcsv($out, [ $r['time'] ?? '', $r['question'] ?? '', isset($r['matched']) ? ($r['matched'] ? 'Yes' : 'No') : '', $r['location'] ?? '', $r['lat'] ?? '', $r['lon'] ?? '', $r['ip'] ?? '', ]); } fclose($out); exit; } /* ---- Filter ---- */ $filter = $_GET['filter'] ?? 'all'; $search = trim($_GET['q'] ?? ''); $filtered = array_filter($rows, function($r) use ($filter, $search) { if ($filter === 'matched' && empty($r['matched'])) return false; if ($filter === 'unmatched' && !empty($r['matched'])) return false; if ($search !== '' && stripos($r['question'] ?? '', $search) === false) return false; return true; }); $total = count($rows); $matched = count(array_filter($rows, function($r){ return !empty($r['matched']); })); $unmatched = $total - $matched; ?> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>FAQ Assistant — Question Report</title> <style> body{font-family:'Segoe UI',sans-serif;background:#05060f;color:#eee;margin:0;padding:32px;} h1{color:#f4b400;font-size:1.4rem;margin-bottom:4px;} .sub{color:#888;font-size:0.85rem;margin-bottom:24px;} .stats{display:flex;gap:16px;margin-bottom:24px;flex-wrap:wrap;} .stat{background:#141414;border:1px solid #2a2a2a;border-radius:10px;padding:14px 20px;min-width:120px;} .stat .num{font-size:1.5rem;font-weight:700;color:#f4b400;} .stat .lbl{font-size:0.72rem;color:#999;text-transform:uppercase;letter-spacing:0.05em;} .toolbar{display:flex;gap:10px;flex-wrap:wrap;margin-bottom:16px;align-items:center;} .toolbar a, .toolbar button{ background:#141414;border:1px solid #333;color:#ddd;padding:7px 14px;border-radius:20px; font-size:0.78rem;text-decoration:none;cursor:pointer; } .toolbar a.active{background:#f4b400;color:#000;border-color:#f4b400;font-weight:700;} input[type=text]{background:#141414;border:1px solid #333;color:#fff;padding:8px 12px;border-radius:20px;font-size:0.8rem;min-width:220px;} table{width:100%;border-collapse:collapse;background:#0c0c14;border-radius:10px;overflow:hidden;} th,td{padding:10px 14px;text-align:left;font-size:0.82rem;border-bottom:1px solid #1e1e1e;} th{background:#161616;color:#f4b400;font-size:0.72rem;text-transform:uppercase;letter-spacing:0.05em;} tr:hover td{background:#111;} .badge{padding:2px 9px;border-radius:12px;font-size:0.68rem;font-weight:700;} .badge.yes{background:rgba(34,197,94,0.15);color:#4ade80;} .badge.no{background:rgba(239,68,68,0.15);color:#f87171;} .empty{padding:40px;text-align:center;color:#666;} .logout{margin-left:auto;color:#999 !important;} </style> </head> <body> <h1>📋 FAQ Assistant — Question Report</h1> <div class="sub">Private admin view · not linked from the site · use this to spot unanswered questions and improve the knowledge base.</div> <div class="stats"> <div class="stat"><div class="num"><?= $total ?></div><div class="lbl">Total Questions</div></div> <div class="stat"><div class="num"><?= $matched ?></div><div class="lbl">Answered</div></div> <div class="stat"><div class="num"><?= $unmatched ?></div><div class="lbl">Unanswered (fallback)</div></div> </div> <form class="toolbar" method="GET"> <a href="?filter=all<?= $search ? '&q='.urlencode($search) : '' ?>" class="<?= $filter==='all'?'active':'' ?>">All</a> <a href="?filter=matched<?= $search ? '&q='.urlencode($search) : '' ?>" class="<?= $filter==='matched'?'active':'' ?>">Answered</a> <a href="?filter=unmatched<?= $search ? '&q='.urlencode($search) : '' ?>" class="<?= $filter==='unmatched'?'active':'' ?>">Unanswered</a> <input type="hidden" name="filter" value="<?= htmlspecialchars($filter) ?>"> <input type="text" name="q" placeholder="Search questions…" value="<?= htmlspecialchars($search) ?>"> <button type="submit">Search</button> <a href="?export=csv&filter=<?= urlencode($filter) ?>&q=<?= urlencode($search) ?>">⬇ Export CSV</a> <a class="logout" href="?logout=1">Log out</a> </form> <?php if (empty($filtered)): ?> <div class="empty">No questions found.</div> <?php else: ?> <table> <thead><tr><th>Time</th><th>Question</th><th>Location</th><th>Lat / Lon</th><th>IP Address</th><th>Status</th></tr></thead> <tbody> <?php foreach ($filtered as $r): ?> <tr> <td style="white-space:nowrap;color:#888;"><?= htmlspecialchars($r['time'] ?? '') ?></td> <td><?= htmlspecialchars($r['question'] ?? '') ?></td> <td style="white-space:nowrap;color:#aaa;"><?= htmlspecialchars($r['location'] ?? 'Unknown') ?></td> <td style="white-space:nowrap;font-family:monospace;color:#aaa;"> <?php if (isset($r['lat']) && isset($r['lon']) && $r['lat'] !== null && $r['lon'] !== null): ?> <a href="https://www.google.com/maps?q=<?= urlencode($r['lat']) ?>,<?= urlencode($r['lon']) ?>" target="_blank" rel="noopener" style="color:#f4b400;text-decoration:none;"> <?= htmlspecialchars($r['lat']) ?>, <?= htmlspecialchars($r['lon']) ?> </a> <?php else: ?> — <?php endif; ?> </td> <td style="white-space:nowrap;color:#aaa;font-family:monospace;"><?= htmlspecialchars($r['ip'] ?? '') ?></td> <td> <?php if (!empty($r['matched'])): ?> <span class="badge yes">Answered</span> <?php else: ?> <span class="badge no">Unanswered</span> <?php endif; ?> </td> </tr> <?php endforeach; ?> </tbody> </table> <?php endif; ?> </body> </html>
💾 Kaydet
İptal