Link-domain pool by channel + safety checks, hosted page images + provider allowlist, Reports pages and zones sections

Item 1 (domains.js): every short link domain in linkDomains gets a channel (email / messaging / social / reserve)
via the new linkDomainChannels site setting ("host:channel,..."; default order email, messaging, social, email,
reserve). Checks every 6 h + Admin > Link domains "Check now": Google Safe Browsing v4 when GSB_API_KEY is set
(unknown otherwise), URIBL + SURBL DNS lists (answer = listed, NXDOMAIN = clean, 127.0.0.1 or errors = unknown),
and a TelegramBot-UA reachability probe. Flagged or listed = BURNED: out of domains.live() (no new links or
pages on it, existing /r/ codes still resolve), admin told once via telegramAdminChatId or ADMIN_EMAIL.
State in DATA_DIR/domains.json. New: GET /api/my/link-hosts, GET+POST /api/admin/domains, admin pane.
/api/my/pages now hands out hosts from domains.live().

Item 2 (pages.js, formrestyle.js): POST /api/my/pages/upload (raw image body, multipart, or JSON base64) for
png/jpg/webp up to 2 MB, 50 per member, magic bytes checked, sharp re-encode when installed, stored under
DATA_DIR/uploads/pages/<owner-hash>/<id>.<ext>, served at /u/pages/... immutable for a year; delete via
POST /api/my/pages/images/<id> {remove}. Pages editor: Upload image button beside the image field + a strip of
the member's images. Provider allowlist (17 autoresponders, Sendy by /subscribe path) exposed as `providers`;
the editor says "Recognised: AWeber" or "Unknown provider: plain post to <host>" at paste time; pub() carries
formProvider. Unknown hosts still allowed when parse-or-refuse passes.

Item 3 (zonereport.js, pages.summary): /api/my/reports returns {spins, pages, zones} (spins still spread at the
top level) for the chosen days; Pages and Zones sections on /reports with 30-day bars, totals, per-item tables,
phone width checked. Zone numbers are a read-only view over zones.json (zones.js untouched).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-10-10 11:28:47 -05:00
parent 0938e89fbe
commit 0a30b1da60
11 changed files with 441 additions and 19 deletions
+24 -2
View File
@@ -44,8 +44,8 @@
});
// ── panes ──
const TITLES = { overview: 'Overview', house: 'House ads', campaigns: 'All campaigns', members: 'Members', reports: 'Reports', zones: 'Zones', traffic: 'Traffic', blog: 'Blog', releases: 'Releases and roadmap', pnl: 'Profit and loss', settings: 'Settings' };
const loaders = { overview: loadOverview, house: loadHouse, campaigns: loadCampaigns, members: loadMembers, reports: loadReports, zones: loadZones, traffic: loadTraffic, blog: loadBlog, releases: loadReleases, pnl: loadPnl, settings: loadSettings };
const TITLES = { overview: 'Overview', house: 'House ads', campaigns: 'All campaigns', members: 'Members', reports: 'Reports', zones: 'Zones', domains: 'Link domains', traffic: 'Traffic', blog: 'Blog', releases: 'Releases and roadmap', pnl: 'Profit and loss', settings: 'Settings' };
const loaders = { overview: loadOverview, house: loadHouse, campaigns: loadCampaigns, members: loadMembers, reports: loadReports, zones: loadZones, domains: loadDomains, traffic: loadTraffic, blog: loadBlog, releases: loadReleases, pnl: loadPnl, settings: loadSettings };
function setPane(name) {
if (!TITLES[name]) name = 'overview';
document.querySelectorAll('.pane').forEach(p => { p.hidden = p.id !== 'pane-' + name; });
@@ -488,6 +488,28 @@
try { await api('/api/admin/zones/' + b.dataset.znpause, pausing ? { paused: true, note: 'Paused ' + new Date().toLocaleDateString() } : { paused: false, note: '' }, 'POST'); loadZones(); } catch (e) { IAP.status(e.message, 'bad'); }
}));
}
// ── link domains: channel per domain, last safety check, burned flag; check now / clear / pull (2026-10-10) ──
async function loadDomains() {
const d = await api('/api/admin/domains');
const list = d.domains || []; const live = list.filter(x => !x.burned && x.channel !== 'reserve').length, burned = list.filter(x => x.burned).length;
$('dmSub').textContent = list.length + ' domain' + (list.length === 1 ? '' : 's') + ' · ' + live + ' live · ' + burned + ' burned';
$('dmGsb').textContent = d.gsb ? 'Google Safe Browsing: on' : 'Google Safe Browsing: off (set GSB_API_KEY on the server to turn it on)';
const ago = t => t ? new Date(t).toLocaleString() : 'never';
const mark = v => v === 'clean' ? '<span style="color:var(--ok,#2e9b5a)">clean</span>' : v === 'flagged' || v === 'listed' ? '<b style="color:var(--bad)">' + v + '</b>' : /^ok:/.test(v || '') ? '<span style="color:var(--ok,#2e9b5a)">answered ' + esc(v.slice(3)) + '</span>' : '<span class="muted">unknown</span>';
$('dmTable').innerHTML = '<tr><th>Domain</th><th>Channel</th><th>Safe Browsing</th><th>URIBL</th><th>SURBL</th><th>Reach</th><th>Status</th><th>Last check</th><th></th></tr>'
+ (list.length ? list.map(x => '<tr' + (x.burned ? ' style="background:rgba(192,57,43,.08)"' : '') + '><td><b>' + esc(x.host) + '</b></td>'
+ '<td><select data-dmch="' + esc(x.host) + '">' + (d.channels || []).map(c => '<option value="' + c + '"' + (c === x.channel ? ' selected' : '') + '>' + esc(d.labels[c] || c) + '</option>').join('') + '</select><br><span class="muted small">' + esc(d.notes[x.channel] || '') + '</span></td>'
+ '<td>' + mark(x.gsb) + '</td><td>' + mark(x.uribl) + '</td><td>' + mark(x.surbl) + '</td><td>' + mark(x.reach) + '</td>'
+ '<td>' + (x.burned ? '<b style="color:var(--bad)">BURNED</b><br><span class="muted small">' + esc(x.reason || '') + (x.burnedAt ? ' · ' + ago(x.burnedAt) : '') + '</span>' : x.channel === 'reserve' ? '<span class="muted">held in reserve</span>' : '<span style="color:var(--ok,#2e9b5a)">live</span>') + '</td>'
+ '<td>' + ago(x.checkedAt) + '</td>'
+ '<td class="act" style="white-space:nowrap"><button type="button" class="btn small ghost" data-dmcheck="' + esc(x.host) + '">Check now</button> ' + (x.burned ? '<button type="button" class="btn small sec" data-dmclear="' + esc(x.host) + '">Clear burn</button>' : '<button type="button" class="btn small sec" data-dmburn="' + esc(x.host) + '">Pull</button>') + '</td></tr>').join('')
: '<tr><td colspan="9" class="muted">No link domains yet. Add them to the linkDomains site setting (comma list) first.</td></tr>');
document.querySelectorAll('[data-dmch]').forEach(sel => sel.addEventListener('change', async () => { try { await api('/api/admin/domains', { action: 'channel', domain: sel.dataset.dmch, channel: sel.value }); IAP.status('Channel saved: ' + sel.dataset.dmch + ' is now ' + sel.value + '.', 'ok'); loadDomains(); } catch (e) { IAP.status(e.message, 'bad'); } }));
document.querySelectorAll('[data-dmcheck]').forEach(b => b.addEventListener('click', busy(b, async () => { const r = await api('/api/admin/domains', { action: 'check', domain: b.dataset.dmcheck }); const x = r.domain || {}; IAP.status(b.dataset.dmcheck + ': Safe Browsing ' + x.gsb + ', URIBL ' + x.uribl + ', SURBL ' + x.surbl + ', reach ' + x.reach + (x.burned ? ' · BURNED' : ''), x.burned ? 'bad' : 'ok'); loadDomains(); })));
document.querySelectorAll('[data-dmclear]').forEach(b => b.addEventListener('click', busy(b, async () => { await api('/api/admin/domains', { action: 'clear', domain: b.dataset.dmclear }); IAP.status(b.dataset.dmclear + ' is back in the pool.', 'ok'); loadDomains(); })));
document.querySelectorAll('[data-dmburn]').forEach(b => b.addEventListener('click', busy(b, async () => { await api('/api/admin/domains', { action: 'burn', domain: b.dataset.dmburn, reason: 'pulled by admin ' + new Date().toLocaleDateString() }); IAP.status(b.dataset.dmburn + ' pulled from the pool.', 'ok'); loadDomains(); })));
}
$('dmCheckAll').addEventListener('click', busy($('dmCheckAll'), async () => { IAP.status('Checking every domain…', 'ok'); const r = await api('/api/admin/domains', { action: 'check' }); const bad = (r.domains || []).filter(x => x.burned).length; IAP.status('Checked ' + (r.results || []).length + ' domains' + (bad ? ', ' + bad + ' burned' : ', none burned') + '.', bad ? 'bad' : 'ok'); loadDomains(); }));
// ── traffic: referring domains / sources, landing pages, angles, by day ──
let trfDays = 30;
document.querySelectorAll('#trfRange [data-days]').forEach(b => b.addEventListener('click', () => { trfDays = Number(b.dataset.days); document.querySelectorAll('#trfRange [data-days]').forEach(x => x.classList.toggle('on', x === b)); loadTraffic().catch(e => IAP.status(e.message, 'bad')); }));