Site Builder
Editing:
index.php
writable 0666
<?php /************************************************************************** * INFLUENCERS DIRECTORY – one‑file drop‑in * ---------------------------------------------------------------------- * • Place anywhere (e.g. /new‑influencers/influencers.php) * • Lists every folder in /social/ that contains profile.json * • Caches rendered HTML → _cache.html (refresh button invalidates it) * • Design matches the 2025 BestDealOn “gold‑card” look & feel **************************************************************************/ /* ---------------- Configuration -------------------------------------- */ $siteRoot = rtrim($_SERVER['DOCUMENT_ROOT'],'/'); $socialRoot = $siteRoot . '/social'; $cacheFile = __DIR__ . '/_cache.html'; $maxExcerpt = 90; // chars shown under each name /* -------------- cache‑bust request? ---------------------------------- */ $needRebuild = isset($_GET['rebuild']); if ($needRebuild && is_file($cacheFile)) unlink($cacheFile); /* -------------- serve cache if fresh -------------------------------- */ if (is_readable($cacheFile) && !$needRebuild) { echo file_get_contents($cacheFile); exit; } /* -------------- build fresh directory ------------------------------- */ $cards = []; foreach (glob($socialRoot.'/*', GLOB_ONLYDIR) as $dir) { $slug = basename($dir); $p = $dir.'/profile.json'; if (!is_readable($p)) continue; $json = json_decode(file_get_contents($p), true); if (!$json) continue; $handle = '@'.$slug; $slogan = trim($json['slogan'] ?? $json['description'] ?? ''); if (mb_strlen($slogan,'UTF-8') > $maxExcerpt) $slogan = mb_substr($slogan,0,$maxExcerpt,'UTF-8').'…'; /* coupon count */ $cp = $dir.'/coupon.json'; $couponN = 0; if (is_readable($cp)) { $arr = json_decode(file_get_contents($cp), true); if (is_array($arr)) $couponN = count($arr); } $cards[] = [ 'slug' => $slug, 'handle'=> $handle, 'slogan'=> $slogan, 'coups' => $couponN, 'url' => "/social/$slug/" ]; } /* alphabetical for consistency */ usort($cards, fn($a,$b)=>strcasecmp($a['slug'],$b['slug'])); /* ---------------- render HTML --------------------------------------- */ ob_start(); ?> <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>Discover Our Creators – BestDealOn</title> <meta name="viewport" content="width=device-width,initial-scale=1"> <style> :root{--gold:#ffb63b;--blue:#2357d7;--fg:#102a66;--text:#333;--bg:#f5f8fb} *{box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif} body{margin:0;background:var(--bg);color:var(--text)} .top{background:#eee;padding:1rem 1.4rem;font-weight:900} .top a{text-decoration:none;color:#2a3ca5} h1{margin:1.6rem 0;text-align:center;font-size:1.8rem;color:var(--fg)} .grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(260px,1fr));gap:1.6rem;max-width:1100px;margin:0 auto 2.4rem;padding:0 1rem} .card{background:#fff;border:3.5px solid var(--gold);border-radius:24px;box-shadow:0 8px 26px #f5db9c3c;padding:1.5rem 1.4rem;display:flex;flex-direction:column;min-height:220px} .card h2{margin:0 0 .6rem;font-size:1.25rem;font-weight:800;color:#df6200;word-break:break-all} .card p{margin:0 0 1.1rem;font-size:.95rem;line-height:1.46} .badge{display:inline-block;background:#ece7ff;color:#4d3ac9;font-weight:700;border-radius:12px;padding:.2rem .6rem;font-size:.78rem} .btn{display:block;margin-top:auto;text-align:center;background:var(--blue);color:#fff;padding:.55rem 0;border-radius:8px;font-weight:700;text-decoration:none} .btn:hover{background:#1e4dbf} .refresh{display:block;text-align:center;margin:0 0 2.6rem;font-size:.9rem} .refresh a{color:var(--blue);text-decoration:none;font-weight:700} @media(max-width:400px){h1{font-size:1.55rem}} </style> </head> <body> <div class="top"><a href="/">BestDealOn</a> » Influencers</div> <h1>Meet Our Verified Creators</h1> <?php if(!$cards): ?> <p style="text-align:center">No creator profiles found.</p> <?php else: ?> <div class="grid"> <?php foreach($cards as $c): ?> <article class="card" itemscope itemtype="https://schema.org/Person"> <h2 itemprop="name"><?= htmlspecialchars($c['handle']) ?></h2> <?php if($c['slogan']): ?><p itemprop="description"><?= htmlspecialchars($c['slogan']) ?></p><?php endif; ?> <span class="badge"><?= $c['coups'] ?> coupon<?= $c['coups']===1?'':'s' ?></span> <a class="btn" href="<?= htmlspecialchars($c['url']) ?>" itemprop="url">View profile »</a> </article> <?php endforeach ?> </div> <?php endif; ?> <p class="refresh"><a href="?rebuild=1">🔄 Refresh list</a></p> </body></html> <?php $html = ob_get_clean(); file_put_contents($cacheFile, $html, LOCK_EX); echo $html;
Save changes
Create folder
writable 0777
Create
Cancel