Site Builder
Editing:
tools.php
writable 0666
<?php /************************************************************************** * tools.php – AI Toolbox front‑end v1.1 * ---------------------------------------------------------------------- * • Expects ai‑tools/ (this file) * ├─ business‑tools/ * │ └─ business‑tools.json * └─ profile‑tools/ * └─ profile‑tools.json * • Each *‑tools.json has rows: { "name","http_path","active","tier" } * • Users must be logged in; premium test = profile['premium']==='on' **************************************************************************/ require_once $_SERVER['DOCUMENT_ROOT'].'/members/lib/auth.php'; require_login(); $me = current_user(); $isPrem = !empty($me['premium']) && strtolower($me['premium'])!=='off'; $baseDir = __DIR__; // /public_html/ai-tools /** helper: read & normalise one json file */ function load_list(string $json): array { if(!is_file($json)) return []; $raw = json_decode(file_get_contents($json),true); $out=[]; foreach($raw as $r){ $out[] = [ 'name' => $r['name'], 'href' => $r['http_path'], 'active'=>$r['active']??false, 'tier' => in_array($r['tier']??'free',['free','premium']) ? $r['tier'] : 'free' ]; } return $out; } /* ---------- get both branches ---------- */ $biz = load_list("$baseDir/business-tools/business-tools.json"); $pro = load_list("$baseDir/profile-tools/profile-tools.json"); /* ---------- helper: nicer label ---------- */ function pretty(string $slug): string { return ucwords(str_replace(['-', '_'], ' ', $slug)); } /* ---------- helper: public URL to profile ---------- */ function public_url(array $u): string { if ($u['acct_type']==='business') return "https://bestdealon.com/{$u['site_slug']}/"; return "https://bestdealon.com/social/{$u['site_slug']}/"; } ?> <!doctype html> <title>AI Toolbox • BestDealOn</title> <meta name=viewport content="width=device-width, initial-scale=1"> <style> :root{ --brand:#0066ff; /* active (free or premium) */ --warn:#ffb31c; /* premium – user lacks access */ --off:#d5dae4; /* disabled by admin */ --pill-bg:#f3f5ff; font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif; } body{margin:0;background:#f1f4fc;color:#0d1f3c} main{max-width:960px;margin:3rem auto;padding:0 1rem} header{background:#fff;border-bottom:3px solid var(--prem-gold);padding:.85rem 1rem; font-size:1rem;font-weight:700;display:flex;justify-content:space-between;align-items:center} .breadcrumb a{text-decoration:none;color:var(--blue)} .breadcrumb span{color:var(--txt)} #viewSite{font-weight:600;text-decoration:none;color:var(--blue)} h1{text-align:center;margin:0 0 2.2rem;font-size:2rem;font-weight:800;letter-spacing:.2px} h2{margin:2.4rem 0 1rem;font-size:1.3rem;font-weight:700;color:#0d2b4d} .grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(260px,1fr)); gap:1.1rem} /* ---------- card ---------- */ .tool{ display:flex;flex-direction:column;justify-content:center;align-items:center; aspect-ratio:3/1;min-height:96px;text-decoration:none;border:3px solid; border-radius:18px;font-weight:700;font-size:1.05rem;transition:.18s; } .tool:focus-visible{outline:4px solid #83a9ff;outline-offset:2px} /* states */ .active {border-color:var(--brand);background:#fff;color:#0d2b4d} .active:hover{box-shadow:0 4px 14px rgba(0,0,0,.07);transform:translateY(-2px)} .premium {border-color:var(--warn);background:#fff8ec;color:#925200} .disabled{border-color:var(--off);background:#fafbff;color:#7a808f;cursor:default} /* pill */ .pill{margin-top:.55rem;padding:.2rem .9rem;border-radius:999px;font-size:.78rem; font-weight:600;letter-spacing:.2px} .active .pill{background:var(--brand);color:#fff} .premium .pill{background:var(--warn);color:#fff} .disabled .pill{background:var(--off);color:#7a808f} </style> <!-- ======= Top breadcrumb ======= --> <header> <nav class="breadcrumb"> <a href="/">BestDealOn</a> » <a href="/members/dashboard.php">Dashboard</a> » <span>AI Toolbox</span> </nav> <a id="viewSite" href="<?=htmlspecialchars(public_url($me))?>" target=_blank>View Site</a> </header> <main> <h1>AI Toolbox</h1> <?php /* helper: render one block list */ function block(string $title, array $list, bool $isPrem) { echo "<h2><?= pretty($title) ?></h2><div class='grid'>"; foreach($list as $t){ $state = (!$t['active']? 'disabled' : ($t['tier']==='premium' && !$isPrem? 'premium' : 'active')); $href = $state==='active' ? $t['href'] : ($state==='premium'? '/members/subscriptions.php' : '#'); $lab = $state==='active' ? 'ACTIVE' : ($state==='premium'? 'PREMIUM' : 'DISABLED'); /* whole card becomes <a> unless disabled */ $tag = $state==='disabled' ? 'div' : 'a'; echo "<$tag class='tool $state' ".($tag==='a'?"href='$href'":'').">" . e(pretty($t['name'])) . "<span class='pill'>$lab</span></$tag>"; } echo "</div>"; } function e($s){return htmlspecialchars($s,ENT_QUOTES,'UTF-8');} block('Business Tools', $biz, $isPrem); block('Profile Tools', $pro, $isPrem); ?> </main> </html>
Save changes
Create folder
writable 0777
Create
Cancel