Site Builder
Editing:
tools1.php
writable 0666
<?php /************************************************************************** * AI TOOLBOX – front‑end launcher © BestDealOn 2025 * ------------------------------------------------------------------------ * • Reads tool metadata from business‑tools.json / profile‑tools.json * • Shows one grid per branch (Business / Profile) * • Button states: active • premium‑locked • disabled (admin) **************************************************************************/ require_once __DIR__.'/../members/lib/auth.php'; require_login(); // any logged‑in role may view toolbox /* ---------- config ---------- */ const ROOT_DIR = __DIR__; // /ai-tools const BRANCHES = [ 'Business Tools' => 'business-tools', 'Profile Tools' => 'profile-tools', ]; /* ---------- fetch & normalise ---------- */ function read_json(string $file): array { return (is_file($file) && ($j=json_decode(file_get_contents($file),true))) ? $j : []; } $all = []; // [branch => [toolRows…] ] foreach (BRANCHES as $title=>$dir){ $js = read_json("$dir/$dir.json"); // e.g. business-tools.json foreach ($js as $row){ $name = $row['name'] ?? ''; $slug = $row['file'] ?? ''; $tier = $row['tier'] ?? 'free'; // free|premium|admin $act = !empty($row['active']); $all[$title][] = [ 'name'=>$name, 'href'=>"/ai-tools/$dir/$slug", // e.g. /ai-tools/business-tools/keywords/index.php 'tier'=>$tier, 'active'=>$act, ]; } } /* ---------- helper ---------- */ function prettify(string $s): string{ $s=str_replace(['-','_'],' ',$s); return ucwords($s); } /* ---------- current user tier (premium?) ---------- */ $you = current_user(); $isPremium = ($you['tier'] ?? '')==='premium'; // adjust if you store differently ?> <!doctype html> <title>AI Toolbox – BestDealOn</title> <meta name=viewport content="width=device-width,initial-scale=1"> <style> :root{ --bg:#f4f7ff;--fg:#0f3760;--gold:#ffb63b;--blue:#0066ff; --card-bg:#fff;--line:#e1e7ff;--active:#0066ff;--prem:#f4ae1a;--dis:#c4c9d6} *{box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif;margin:0} body{background:var(--bg);color:var(--fg);padding:0 1rem 4rem} header{padding:1rem 0 .5rem;border-bottom:3px solid var(--gold);margin-bottom:1.5rem} .bread a{color:var(--blue);font-weight:700;text-decoration:none} .bread span{margin:0 .25rem} h1{text-align:center;font-size:1.9rem;margin-bottom:1.8rem} .grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(250px,1fr));gap:1.4rem} .tool{ display:flex;flex-direction:column;align-items:center;justify-content:center; min-height:120px;padding:1.2rem;border:3px solid var(--line);border-radius:18px; background:var(--card-bg);text-decoration:none;transition:.18s border-color} .tool h3{font-size:1.05rem;text-align:center;font-weight:700;margin-bottom:.9rem;color:var(--fg)} .badge{font-size:.75rem;font-weight:700;padding:.23rem .9rem;border-radius:999px;color:#fff} .active .badge{background:var(--active)} .premium .badge{background:var(--prem)} .disabled .badge{background:var(--dis)} .active {border-color:var(--active)} .premium {border-color:var(--prem);background:#fffbf3} .disabled {border-color:var(--dis);color:#8b8f9c;background:#fafbfe} .tool:hover:not(.disabled){box-shadow:0 4px 12px rgba(0,0,0,.07);transform:translateY(-2px)} @media (prefers-color-scheme:dark){ :root{--bg:#0d1117;--fg:#e6edf3;--card-bg:#161b22;--line:#30363d} .tool.disabled{background:#1b1f27;border-color:#323949;color:#8b97a9} } </style> <header> <nav class="bread" style="display:flex;justify-content:space-between;align-items:center"> <div> <a href="/">BestDealOn</a><span>»</span> <a href="/members/dashboard.php">Dashboard</a><span>»</span>AI Toolbox </div> <a href="/" style="font-weight:700;color:var(--blue);text-decoration:none">View Site</a> </nav> </header> <h1>AI Toolbox</h1> <?php foreach($all as $branch=>$tools): ?> <h2 style="margin:.4rem 0 1rem;font-size:1.3rem"><?= htmlspecialchars($branch) ?></h2> <div class="grid"> <?php foreach($tools as $t): $state = !$t['active'] ? 'disabled' : ($t['tier']==='premium' && !$isPremium ? 'premium':'active'); ?> <a class="tool <?= $state ?>" href="<?= $state==='disabled' ? '#' : htmlspecialchars($t['href']) ?>" <?= $state==='disabled' ? 'tabindex="-1"' : '' ?> aria-label="<?= prettify($t['name']) . ($state==='premium'?' (Premium Only)':($state==='disabled'?' (Disabled)':'')) ?>"> <h3><?= prettify($t['name']) ?></h3> <span class="badge"><?= strtoupper($state) ?></span> </a> <?php endforeach ?> </div> <br><br> <?php endforeach ?> </body> </html>
Save changes
Create folder
writable 0777
Create
Cancel