/
home
/
shalala
/
winterhits.com
/
Upload File
HOME
<?php $skip = ['.', '..', 'cgi-bin', 'wp-admin', 'wp-includes', 'wp-content']; $root = __DIR__; $tracks = []; $errors = []; $found = []; // ── scan all subdirectories ─────────────────────────────────────────────────── $dirs = scandir($root); foreach ($dirs as $dir) { if (in_array($dir, $skip)) continue; if (!is_dir($root . '/' . $dir)) continue; if (str_starts_with($dir, '.')) continue; $indexFile = $root . '/' . $dir . '/index.html'; if (!file_exists($indexFile)) continue; $html = file_get_contents($indexFile); // extract the contents of <script id="track-config" type="application/json"> $pattern = '/<script[^>]+id=["\']track-config["\'][^>]*>(.*?)<\/script>/s'; if (!preg_match($pattern, $html, $matches)) { $errors[] = "/$dir/ — no track-config block found, skipping."; continue; } $json = trim($matches[1]); $cfg = json_decode($json, true); if (json_last_error() !== JSON_ERROR_NONE) { $errors[] = "/$dir/ — invalid JSON in track-config: " . json_last_error_msg(); continue; } $entry = [ 'title' => $cfg['title'] ?? 'Untitled', 'artist' => $cfg['artist'] ?? '', 'url' => '/' . $dir . '/', ]; // optional extras carried into tracks.json (useful for richer UI later) if (!empty($cfg['subtitle'])) $entry['subtitle'] = $cfg['subtitle']; if (!empty($cfg['artwork'])) $entry['artwork'] = '/' . $dir . '/artwork/' . $cfg['artwork']; if (!empty($cfg['label'])) $entry['label'] = $cfg['label']; $tracks[] = $entry; $found[] = $dir; } // ── sort alphabetically by title ───────────────────────────────────────────── usort($tracks, fn($a, $b) => strcasecmp($a['title'], $b['title'])); // ── write tracks.json ───────────────────────────────────────────────────────── $outputFile = $root . '/tracks.json'; $json = json_encode($tracks, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); $written = file_put_contents($outputFile, $json); ?><!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"/> <meta name="viewport" content="width=device-width, initial-scale=1.0"/> <title>Track Scanner</title> <style> body { font-family: monospace; background: #0d0d0d; color: #f0ece4; padding: 2rem; max-width: 640px; margin: 0 auto; } h1 { font-size: 1rem; letter-spacing: 0.2em; text-transform: uppercase; color: #e8d5a3; margin-bottom: 1.5rem; } .ok { color: #7ecb8a; } .err { color: #e07c7c; } .dim { color: #7a7570; } ul { list-style: none; padding: 0; margin: 0 0 1.5rem; } li { padding: 0.3rem 0; border-bottom: 1px solid #2a2a2a; font-size: 0.85rem; } pre { background: #161616; border: 1px solid #2a2a2a; padding: 1rem; font-size: 0.75rem; overflow-x: auto; color: #a89060; line-height: 1.6; } </style> </head> <body> <h1>Marshall Records — Track Scanner</h1> <?php if ($written === false): ?> <p class="err">✗ Could not write tracks.json — check file permissions.</p> <?php else: ?> <p class="ok">✓ tracks.json written successfully (<?= count($tracks) ?> track<?= count($tracks) !== 1 ? 's' : '' ?>)</p> <?php endif; ?> <?php if (!empty($found)): ?> <br> <p class="dim">Tracks found:</p> <ul> <?php foreach ($found as $dir): ?> <li class="ok">✓ /<?= htmlspecialchars($dir) ?>/</li> <?php endforeach; ?> </ul> <?php endif; ?> <?php if (!empty($errors)): ?> <p class="dim">Warnings:</p> <ul> <?php foreach ($errors as $e): ?> <li class="err">⚠ <?= htmlspecialchars($e) ?></li> <?php endforeach; ?> </ul> <?php endif; ?> <?php if ($written !== false): ?> <p class="dim">Generated tracks.json:</p> <pre><?= htmlspecialchars($json) ?></pre> <?php endif; ?> </body> </html>