Publisher program (/publishers + zone tiers), chatbot rewritten for LinkSpin, $25 qualification copy fixes
Publisher program (Marty's zone-owner offer for outside site owners):
- /publishers public page: what a zone is, the nine sizes, the waterfall (member ads, network ads, house),
what pays (viewable only, bots never, warm-up 100 views at 40%, cap), what credits buy, install in four steps
with the origin lock explained, Standard/Verified tiers, FAQ, and a live "Network right now" strip
- GET /api/public/publishers: zones installed/live, viewable impressions and credits paid in the last 7 days,
live rates, sizes, warm-up; computed in zones.js and cached a minute
- zones.js: per-zone tier (default standard); verified zones earn network views at nasViewsPerCreditVerified
(default 8) instead of nasViewsPerCredit (10); member-campaign views stay at viewsPerCredit (5) on both tiers;
rateFor/tierOf exported; a pay log (zones.json "pay") so credits can be reported by day; publisherTotals(days)
returns {zones, live, views, viewable, credits, byDay, byZone} with Central day keys for the Reports screen
- admin: Tier select per zone in the Zones pane, saved via POST /api/admin/zones/:id (tier) or the alias
/api/admin/zones/:id/tier; the admin list carries the 7-day publisher totals
- Zones screen: first-run "Add your site" card (site, size, copy the tag, check it is live) for new accounts and
for /zones?start=1 from the publisher page; Verified tag on zone rows; rate note mentions the verified rate
- /partners (downline-builder kit) keeps its URL, gets the real LinkSpin ladder ($10 door to $500 Network, $25
qualifies), the 10% + 10% admin split, and a cross-link to the publisher program
Chatbot: every canned answer and the AI knowledge block now describe LinkSpin (spin links, pages, zones and the
publisher tiers, audiences, promo tools with the five hook angles, blog; the six packages, the 50/20/10/10+10 split,
$25 qualification, pass-ups, the contract; email codes, Control Room screens, sponsor carry-over from the network
registry, free activation). InstantAdPay-only mechanics removed (dormant-lead rescue, Five Dollar Friday, Wired
Wednesday, games, mint passes, surf earn tab); the holding tank stays because /tools > My line still runs it here.
Copy: "Level 2 opens after two of your people buy a $25 or larger package" on the home page, contract, launch,
earning, my, plays pages and promo.js (the $20 figures that remain are the $100 example split amounts).
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
@@ -17,12 +17,21 @@ const NAS_SIZES = new Set(['728x90', '468x60']); // the sizes Network Ad Space s
|
||||
const NAS_TAG = (w, h) => '<script src="https://www.networkadspace.com/showadss.php?w=' + w + '&h=' + h + '&n=1&bw=' + w + '&bh=' + h + '&c=999"></script>';
|
||||
const BOT = /bot|crawl|spider|slurp|facebookexternalhit|preview|telegrambot|whatsapp|curl|wget|python-requests|headless/i;
|
||||
const J = { db: null, FILE: () => path.join(DATA_DIR, 'zones.json'),
|
||||
load() { try { this.db = JSON.parse(fs.readFileSync(this.FILE(), 'utf8')); } catch (e) { this.db = { v: 1, zones: [], imps: [], acc: {} }; } for (const k of ['zones', 'imps']) if (!Array.isArray(this.db[k])) this.db[k] = []; if (!this.db.acc) this.db.acc = {}; },
|
||||
load() { try { this.db = JSON.parse(fs.readFileSync(this.FILE(), 'utf8')); } catch (e) { this.db = { v: 1, zones: [], imps: [], acc: {}, pay: [] }; } for (const k of ['zones', 'imps', 'pay']) if (!Array.isArray(this.db[k])) this.db[k] = []; if (!this.db.acc) this.db.acc = {}; },
|
||||
save() { try { fs.writeFileSync(this.FILE(), JSON.stringify(this.db)); } catch (e) {} } };
|
||||
function init(opts) { DATA_DIR = opts.dataDir; ads = opts.ads; siteHost = opts.siteHost || siteHost; J.load(); }
|
||||
const norm = e => String(e || '').trim().toLowerCase();
|
||||
const DAY = 86400000;
|
||||
function settings() { let s = {}; try { s = JSON.parse(fs.readFileSync(path.join(DATA_DIR, 'zone-rates.json'), 'utf8')); } catch (e) {} return Object.assign({ viewsPerCredit: 5, nasViewsPerCredit: 10, capPerVisitorDay: 50, houseOn: 1, nasOn: 0 }, s); } // nasOn default OFF: the network tier in zones is switched on with NAS at the end of testing (Marty 2026-10-09)
|
||||
// day keys in Central time (reports and the publisher strip count days the way Marty reads them)
|
||||
const dayFmt = new Intl.DateTimeFormat('en-CA', { timeZone: 'America/Chicago', year: 'numeric', month: '2-digit', day: '2-digit' });
|
||||
const dayKey = ts => dayFmt.format(new Date(ts));
|
||||
function settings() { let s = {}; try { s = JSON.parse(fs.readFileSync(path.join(DATA_DIR, 'zone-rates.json'), 'utf8')); } catch (e) {} return Object.assign({ viewsPerCredit: 5, nasViewsPerCredit: 10, nasViewsPerCreditVerified: 8, capPerVisitorDay: 50, houseOn: 1, nasOn: 0 }, s); } // nasOn default OFF: the network tier in zones is switched on with NAS at the end of testing (Marty 2026-10-09)
|
||||
// Publisher tiers (2026-10-10): every zone starts Standard; an admin marks a reviewed site Verified, and its network-ad
|
||||
// views pay at the better rate (1 credit per nasViewsPerCreditVerified views instead of nasViewsPerCredit). Member
|
||||
// campaign views pay the same on both tiers. The rate is applied when a view is credited (seen), not when it is served.
|
||||
const TIERS = ['standard', 'verified'];
|
||||
function tierOf(z) { return z && z.tier === 'verified' ? 'verified' : 'standard'; }
|
||||
function rateFor(z, nas, s) { s = s || settings(); if (!nas) return s.viewsPerCredit; return tierOf(z) === 'verified' ? s.nasViewsPerCreditVerified : s.nasViewsPerCredit; }
|
||||
// the document an NAS fallback renders in: our own frame, so the NAS tag's document.write lands in a page we control
|
||||
function nasFrame(size) { const wh = SIZES[size]; if (!wh || !NAS_SIZES.has(size)) return null; return '<!doctype html><html><head><meta charset="utf-8"><meta name="robots" content="noindex"><style>html,body{margin:0;padding:0;background:transparent;overflow:hidden}body{width:' + wh[0] + 'px;height:' + wh[1] + 'px}img{border:0;display:block}</style></head><body>' + NAS_TAG(wh[0], wh[1]) + '</body></html>'; }
|
||||
// Earning status (Marty, 2026-09-29): a zone earns only once its first WARMUP on-site views have landed with at least
|
||||
@@ -41,7 +50,7 @@ function pubZone(z) {
|
||||
const imps = impsOf(z);
|
||||
const seen = imps.filter(i => i.ok).length; const clicks = imps.filter(i => i.k).length; const last = J.db.imps.filter(i => i.z === z.id).slice(-1)[0];
|
||||
const ratio = imps.length ? seen / imps.length : 0; const st = statusOf(z, imps);
|
||||
return { id: z.id, name: z.name, site: z.site, size: z.size, active: !!z.active, created: z.created, views30: imps.length, viewable30: seen, viewablePct: imps.length ? Math.round(ratio * 100) : null, clicks30: clicks, credits: z.credits || 0, grade: !imps.length ? null : ratio >= 0.6 ? 'A' : ratio >= 0.4 ? 'B' : 'C', lastSeen: last ? last.ts : 0, house30: imps.filter(i => i.house).length, nas30: imps.filter(i => i.nas).length, campaign30: imps.filter(i => i.camp).length, offsite30: imps.filter(i => i.off).length, status: st.state, statusLabel: st.label, paused: !!z.adminPaused };
|
||||
return { id: z.id, name: z.name, site: z.site, size: z.size, tier: tierOf(z), active: !!z.active, created: z.created, views30: imps.length, viewable30: seen, viewablePct: imps.length ? Math.round(ratio * 100) : null, clicks30: clicks, credits: z.credits || 0, grade: !imps.length ? null : ratio >= 0.6 ? 'A' : ratio >= 0.4 ? 'B' : 'C', lastSeen: last ? last.ts : 0, house30: imps.filter(i => i.house).length, nas30: imps.filter(i => i.nas).length, campaign30: imps.filter(i => i.camp).length, offsite30: imps.filter(i => i.off).length, status: st.state, statusLabel: st.label, paused: !!z.adminPaused };
|
||||
}
|
||||
// the site the tag is running on, from the browser's referrer (cross-origin fetches still send the origin); matches the
|
||||
// declared site or any subdomain of it
|
||||
@@ -53,7 +62,7 @@ async function create(owner, body) {
|
||||
const size = SIZES[String(body.size || '')] ? String(body.size) : '728x90';
|
||||
const name = String(body.name || '').trim().slice(0, 60) || 'Zone'; const site = String(body.site || '').trim().toLowerCase().replace(/^https?:\/\//, '').replace(/^www\./, '').split('/')[0].split(':')[0].slice(0, 80);
|
||||
if (!/^[a-z0-9.-]+$/.test(site) || !site.includes('.')) return { error: 'Enter the site the tag will live on, like myblog.com. Paid ads only serve on that site.' };
|
||||
const z = { id: 'ls-' + crypto.randomBytes(3).toString('hex'), owner: norm(owner), name, site, size, active: true, created: Date.now(), credits: 0 };
|
||||
const z = { id: 'ls-' + crypto.randomBytes(3).toString('hex'), owner: norm(owner), name, site, size, tier: 'standard', active: true, created: Date.now(), credits: 0 };
|
||||
J.db.zones.push(z); J.save(); return { ok: true, zone: pubZone(z) };
|
||||
}
|
||||
async function update(owner, id, body) {
|
||||
@@ -95,10 +104,15 @@ async function seen(impId, req) {
|
||||
imp.ok = 1;
|
||||
const earning = statusOf(z, impsOf(z)).state === 'earning';
|
||||
if (earning && todayByVisitor < s.capPerVisitorDay && !imp.house && !imp.off) { // house and off-site views are not paid
|
||||
// LinkSpin campaign views and NAS views accrue on separate meters with their own rates; whole credits go to the owner
|
||||
const key = z.owner + (imp.nas ? '|nas' : ''); const per = imp.nas ? s.nasViewsPerCredit : s.viewsPerCredit;
|
||||
// LinkSpin campaign views and NAS views accrue on separate meters with their own rates (verified zones keep their own
|
||||
// network meter, since their rate differs); whole credits go to the owner and are logged for the publisher reports
|
||||
const key = z.owner + (imp.nas ? (tierOf(z) === 'verified' ? '|nasv' : '|nas') : ''); const per = rateFor(z, !!imp.nas, s);
|
||||
J.db.acc[key] = (J.db.acc[key] || 0) + 1;
|
||||
if (per > 0 && J.db.acc[key] >= per) { const cr = Math.floor(J.db.acc[key] / per); J.db.acc[key] -= cr * per; z.credits = (z.credits || 0) + cr; try { await ads.addEarned(z.owner, cr, { log: { kind: 'earn', note: 'Zone views: ' + z.name + (imp.nas ? ' (network)' : ''), ref: 'zone:' + z.id, rollup: true } }); } catch (e) {} }
|
||||
if (per > 0 && J.db.acc[key] >= per) {
|
||||
const cr = Math.floor(J.db.acc[key] / per); J.db.acc[key] -= cr * per; z.credits = (z.credits || 0) + cr;
|
||||
J.db.pay.push({ ts: Date.now(), z: z.id, n: cr, nas: imp.nas ? 1 : 0 }); if (J.db.pay.length > 100000) J.db.pay = J.db.pay.slice(-80000);
|
||||
try { await ads.addEarned(z.owner, cr, { log: { kind: 'earn', note: 'Zone views: ' + z.name + (imp.nas ? ' (network)' : ''), ref: 'zone:' + z.id, rollup: true } }); } catch (e) {}
|
||||
}
|
||||
}
|
||||
J.save(); return { ok: true };
|
||||
}
|
||||
@@ -114,7 +128,32 @@ async function adminSet(id, body) {
|
||||
const z = J.db.zones.find(z => z.id === String(id)); if (!z) return { error: 'No such zone.' };
|
||||
if (body.paused != null) z.adminPaused = !!body.paused;
|
||||
if (body.note != null) z.adminNote = String(body.note).slice(0, 200);
|
||||
if (body.tier != null) { const t = String(body.tier).toLowerCase(); if (!TIERS.includes(t)) return { error: 'Tier is standard or verified.' }; z.tier = t; }
|
||||
J.save(); return { ok: true, zone: Object.assign(pubZone(z), { owner: z.owner, note: z.adminNote || '' }) };
|
||||
}
|
||||
function totals() { const since = Date.now() - 30 * DAY; const imps = J.db.imps.filter(i => i.ts >= since && !i.bot); return { zones: J.db.zones.length, views30: imps.length, viewable30: imps.filter(i => i.ok).length, clicks30: imps.filter(i => i.k).length, nas30: imps.filter(i => i.nas).length, credits: J.db.zones.reduce((n, z) => n + (z.credits || 0), 0) }; }
|
||||
module.exports = { init, SIZES, NAS_SIZES, WARMUP, HOLD_RATIO, settings, nasFrame, list, create, update, tag, serve, seen, click, totals, adminList, adminSet };
|
||||
// -- publisher program totals (Reports screen + the public strip): the last N days, Central days, per day and per zone.
|
||||
// "live" = switched on, not admin-paused, and seen by a real visitor inside the window. Credits are read from the pay log
|
||||
// (kept since 2026-10-10; credits granted before that are in each zone's lifetime total only).
|
||||
function publisherTotals(days) {
|
||||
days = Math.max(1, Math.min(365, Number(days) || 7)); const since = Date.now() - days * DAY;
|
||||
const imps = J.db.imps.filter(i => i.ts >= since && !i.bot); const pays = J.db.pay.filter(p => p.ts >= since);
|
||||
const byDay = {}, byZone = {}, seenZ = new Set();
|
||||
const dayRec = ts => { const k = dayKey(ts); return byDay[k] = byDay[k] || { day: k, views: 0, viewable: 0, credits: 0 }; };
|
||||
const zoneRec = id => { if (byZone[id]) return byZone[id]; const z = J.db.zones.find(x => x.id === id) || {}; return byZone[id] = { id, name: z.name || id, site: z.site || '', size: z.size || '', tier: tierOf(z), owner: z.owner || '', views: 0, viewable: 0, credits: 0 }; };
|
||||
for (const i of imps) { const d = dayRec(i.ts), zr = zoneRec(i.z); d.views++; zr.views++; if (i.ok) { d.viewable++; zr.viewable++; } if (!i.off) seenZ.add(i.z); }
|
||||
for (const p of pays) { dayRec(p.ts).credits += p.n; zoneRec(p.z).credits += p.n; }
|
||||
const live = J.db.zones.filter(z => z.active && !z.adminPaused && seenZ.has(z.id)).length;
|
||||
return { days, zones: J.db.zones.length, live, views: imps.length, viewable: imps.filter(i => i.ok).length, credits: pays.reduce((n, p) => n + p.n, 0),
|
||||
byDay: Object.values(byDay).sort((a, b) => a.day < b.day ? -1 : 1), byZone: Object.values(byZone).sort((a, b) => b.views - a.views) };
|
||||
}
|
||||
// the public "Network right now" strip on /publishers: 7-day totals plus the rates, cached a minute
|
||||
let pubCache = null;
|
||||
function publisherPublic() {
|
||||
if (pubCache && Date.now() - pubCache.ts < 60000) return pubCache.data;
|
||||
const t = publisherTotals(7); const s = settings();
|
||||
const data = { zones: t.zones, live: t.live, views7: t.views, viewable7: t.viewable, credits7: t.credits, sizes: Object.keys(SIZES), networkSizes: Array.from(NAS_SIZES), tiers: TIERS,
|
||||
rates: { viewsPerCredit: s.viewsPerCredit, nasViewsPerCredit: s.nasViewsPerCredit, nasViewsPerCreditVerified: s.nasViewsPerCreditVerified, capPerVisitorDay: s.capPerVisitorDay }, warmup: WARMUP, holdRatio: HOLD_RATIO, updated: Date.now() };
|
||||
pubCache = { ts: Date.now(), data }; return data;
|
||||
}
|
||||
module.exports = { init, SIZES, NAS_SIZES, TIERS, WARMUP, HOLD_RATIO, settings, tierOf, rateFor, nasFrame, list, create, update, tag, serve, seen, click, totals, publisherTotals, publisherPublic, adminList, adminSet };
|
||||
|
||||
Reference in New Issue
Block a user