diff --git a/blog.js b/blog.js index 40ce3a1..0c2d8a3 100644 --- a/blog.js +++ b/blog.js @@ -110,7 +110,7 @@ function head(o) { + '
'; } function tail() { - return '
'; + return ''; } const authorBox = () => '
LinkSpin
' + AUTHOR + 'Founder of LinkSpin and the Crypto Team Build Network. Twenty-plus years of internet marketing, and a habit of writing down what actually worked.
'; const cardHtml = p => '' + (p.cover ? '' : '') + '

' + esc(p.title) + '

' + esc(p.excerpt) + '

' + fmtDate(p.publishedAt || p.created) + ' · ' + readMinutes(p.body) + ' min read' + (p.tags.length ? ' · ' + p.tags.map(esc).join(', ') : '') + '

'; diff --git a/catalog/traffic-sources.json b/catalog/traffic-sources.json index ea2b09a..13b26a7 100644 --- a/catalog/traffic-sources.json +++ b/catalog/traffic-sources.json @@ -59,6 +59,50 @@ "verified": true, "source": "network" }, + { + "key": "instantadpay", + "name": "InstantAdPay", + "site": "instantadpay.com", + "costModel": "", + "params": [], + "postbackUrl": "", + "notes": "Crypto Team Build Network site. Clicks that arrive from InstantAdPay (its footer, its Promo tools) carry ?src=iap and are counted under this source automatically.", + "verified": true, + "source": "network" + }, + { + "key": "linkspin", + "name": "LinkSpin", + "site": "linkspin.app", + "costModel": "", + "params": [], + "postbackUrl": "", + "notes": "Crypto Team Build Network site. Clicks that arrive from LinkSpin pages carry ?src=linkspin and are counted under this source automatically.", + "verified": true, + "source": "network" + }, + { + "key": "stackpol", + "name": "Stack POL", + "site": "stackpol.com", + "costModel": "", + "params": [], + "postbackUrl": "", + "notes": "Crypto Team Build Network site. Clicks that arrive from Stack POL carry ?src=stackpol and are counted under this source automatically.", + "verified": true, + "source": "network" + }, + { + "key": "earnerscorner", + "name": "Earners Corner", + "site": "earnerscorner.com", + "costModel": "", + "params": [], + "postbackUrl": "", + "notes": "Crypto Team Build Network forum. Clicks that arrive from Earners Corner carry ?src=earnerscorner and are counted under this source automatically.", + "verified": true, + "source": "network" + }, { "key": "7search-ppc", "name": "7Search PPC", diff --git a/health.js b/health.js index 336f1dd..f82cbac 100644 --- a/health.js +++ b/health.js @@ -60,6 +60,8 @@ const frameBlocked = h => { return false; }; // classify one URL -> { state, code, ms, note, frameBlocked, finalUrl } +// a spin-link destination as a click with no params reaches it: every {macro} empty (2026-11-14, the network links carry {s1}/{s2}) +const fillEmpty = u => String(u || '').replace(/\{[a-z0-9_]{1,24}\}/gi, ''); async function check(url) { const t0 = Date.now(); let out = { state: 'dead', code: 0, ms: 0, note: '', frameBlocked: false, finalUrl: url }; @@ -227,7 +229,7 @@ async function tick() { for (const d of r.destinations) { const due = d.active || (d.autoPaused && (!d.health || now - (d.health.checkedAt || 0) >= RECHECK_PAUSED)); if (!due) continue; - jobs.push(async () => { const c = await check(d.url); const ch = apply(r, d, c); changed = true; n++; if (ch) await tell(r, d, ch); }); + jobs.push(async () => { const c = await check(fillEmpty(d.url)); const ch = apply(r, d, c); changed = true; n++; if (ch) await tell(r, d, ch); }); } if (r.fallback) jobs.push(async () => { const c = await check(r.fallback); r.fallbackHealth = { state: c.state, code: c.code, ms: c.ms, checkedAt: Date.now(), note: c.note, frameBlocked: !!c.frameBlocked }; changed = true; }); } @@ -241,7 +243,7 @@ async function checkRotation(owner, id) { const r = rotator.findMine(owner, id); if (!r) return { error: 'No such rotation.' }; const last = lastManual.get(r.id) || 0; if (Date.now() - last < MANUAL_GAP) return { error: 'Checked less than a minute ago. Give it a moment.' }; lastManual.set(r.id, Date.now()); - const jobs = r.destinations.map(d => async () => { const c = await check(d.url); const ch = apply(r, d, c); if (ch) await tell(r, d, ch); }); + const jobs = r.destinations.map(d => async () => { const c = await check(fillEmpty(d.url)); const ch = apply(r, d, c); if (ch) await tell(r, d, ch); }); if (r.fallback) jobs.push(async () => { const c = await check(r.fallback); r.fallbackHealth = { state: c.state, code: c.code, ms: c.ms, checkedAt: Date.now(), note: c.note, frameBlocked: !!c.frameBlocked }; }); if (jobs.length > 50) { runAll(jobs).then(() => rotator.save()).catch(() => {}); return { ok: true, background: true, rotation: rotator.pub(r) }; } // a big link would outlive the request await runAll(jobs); rotator.save(); diff --git a/leaderboard.js b/leaderboard.js index 0ba05b7..7ba7fa9 100644 --- a/leaderboard.js +++ b/leaderboard.js @@ -146,7 +146,7 @@ async function renderPage() { const w = winners(); if (w.length) h += '

Past winners

' + w.slice(0, 12).map(x => '
' + (x.kind === 'week' ? 'Week of ' : 'Month of ') + fmtD(x.start) + ': ' + (x.top[0] ? esc(x.top[0].name) + ' (' + x.top[0].sales + ' sold, $' + x.top[0].usd + ')' : 'no sales') + (x.granted && x.granted.length ? ' · awarded: ' + x.granted.map(g => esc(g.name) + ' +' + g.credits.toLocaleString()).join(', ') : (x.prize ? ' · prize ' + esc(x.prize) : '')) + '
').join(''); h += '

Sales are $ of packages bought by members you directly sponsor. Weekly and monthly prizes are advertising credits or packages, never cash. No income is guaranteed.

'; - h += ''; + h += ''; return h; } function setLaunchPanel(fn) { if (R) R.launchPanel = fn; } diff --git a/netlinks.js b/netlinks.js new file mode 100644 index 0000000..89859fb --- /dev/null +++ b/netlinks.js @@ -0,0 +1,26 @@ +// Network links (Marty 2026-11-14: "Make sure each of these sites is its own traffic source and link spun so we can track it"). +// The admin account (NETWORK_LINKS_OWNER, else ADMIN_EMAIL) owns one spin link per network site, with a fixed short code, and one +// traffic source per network site (catalog templates marked "network"). Every site links to the others through these: +// https://linkspin.app/r/?src=&s1=&s2= +// src picks the traffic source (rotator.resolve + sources.networkSource), s1 fills ?ref= (the member keeps the sponsor credit), +// s2 is one path segment (how, join, ...; empty = the home page). Clicks show in that account's Reports by link and by source. +// Made once at boot when missing, never changed after: the owner may edit them like any link. +'use strict'; +const SITES = [ + { id: 'iap', code: 'nwiap', name: 'InstantAdPay', url: 'https://instantadpay.com/{s2}?ref={s1}' }, + { id: 'linkspin', code: 'nwls', name: 'LinkSpin', url: 'https://linkspin.app/{s2}?ref={s1}' }, + { id: 'dlb', code: 'nwdlb', name: 'Downline Banners', url: 'https://downlinebanners.com/{s2}?ref={s1}' }, + { id: 'vbb', code: 'nwvbb', name: 'Viral Banner Blitz', url: 'https://viralbannerblitz.com/{s2}?ref={s1}' }, + { id: 'stackpol', code: 'nwsp', name: 'Stack POL', url: 'https://stackpol.com/{s2}?ref={s1}' }, + { id: 'earnerscorner', code: 'nwec', name: 'Earners Corner', url: 'https://earnerscorner.com/{s2}' } +]; +function ensure(o) { // { owner, rotator, sources } + const owner = String(o.owner || '').trim().toLowerCase(); if (!owner) return { skipped: 'no owner' }; + const out = { owner: owner.replace(/^(.).*(@.*)$/, '$1***$2'), links: [], sources: [] }; + for (const s of SITES) { + const src = o.sources.networkSource(owner, s.id); out.sources.push(s.id + ':' + (src ? src.id : 'none')); + const r = o.rotator.ensureFixed(owner, s.code, 'Network: ' + s.name, s.url); out.links.push(s.code + ':' + (r.error || (r.created ? 'made' : 'ok'))); + } + return out; +} +module.exports = { SITES, ensure }; diff --git a/netsites.js b/netsites.js index 2536f92..e9288b4 100644 --- a/netsites.js +++ b/netsites.js @@ -32,9 +32,29 @@ function refresh() { return inflight; } function list() { if (Date.now() - cache.at > TTL) refresh(); return cache.list; } +// Tracked links (Marty 2026-11-14: "make sure each of these sites is its own traffic source and link spun so we can track it"): each +// entry also gets go = the LinkSpin network link for that site with ?src=, so a click shows in LinkSpin Reports under the +// site that sent it (LinkSpin netlinks.js: fixed codes on the admin account). This site = NETWORK_SITE_ID, else the request host. +// No go for this site itself, or when this site cannot be told (a test host): the page then uses the plain url. +const CODES = { iap: 'nwiap', linkspin: 'nwls', dlb: 'nwdlb', vbb: 'nwvbb', stackpol: 'nwsp', earnerscorner: 'nwec' }; +const linksBase = () => String(process.env.NETWORK_LINKS_BASE || 'https://linkspin.app').trim().replace(/\/+$/, ''); +const hostOf = u => { try { return new URL(u).hostname.toLowerCase().replace(/^www\./, ''); } catch (e) { return ''; } }; +function selfId(req, l) { + const env = String(process.env.NETWORK_SITE_ID || '').trim().toLowerCase(); if (env) return env; + const h = String((req && req.headers && (req.headers['x-forwarded-host'] || req.headers.host)) || '').split(',')[0].trim().toLowerCase().replace(/:\d+$/, '').replace(/^www\./, ''); + const m = h && (l || list()).find(s => hostOf(s.url) === h); return m ? m.id : ''; +} +// the LinkSpin-tracked link to site `id` sent from site `from` (from = id: the site's own promo kit); extra = { s1: member username, s2: one path segment } +function tracked(id, from, extra) { + const code = CODES[id]; if (!code || !from) return ''; + const q = new URLSearchParams({ src: from }); for (const [k, v] of Object.entries(extra || {})) if (v) q.set(k, String(v)); + return linksBase() + '/r/' + code + '?' + q.toString(); +} +function withGo(l, me) { return l.map(s => { const go = me && s.id !== me ? tracked(s.id, me) : ''; return go ? Object.assign({}, s, { go }) : s; }); } // GET /api/network-sites: public, cacheable, the same answer on every page function handle(req, res) { + const l = list(); res.writeHead(200, { 'Content-Type': 'application/json; charset=utf-8', 'Cache-Control': 'public, max-age=300', 'X-Content-Type-Options': 'nosniff' }); - res.end(JSON.stringify(list())); + res.end(JSON.stringify(withGo(l, selfId(req, l)))); } -module.exports = { list, handle, refresh, FALLBACK, _state: () => cache }; +module.exports = { list, handle, refresh, tracked, selfId, withGo, CODES, FALLBACK, _state: () => cache }; diff --git a/public/admin.html b/public/admin.html index 1919448..d7fe09b 100644 --- a/public/admin.html +++ b/public/admin.html @@ -548,7 +548,7 @@ - + diff --git a/public/assets/common.js b/public/assets/common.js index c7f9d1e..582e33c 100644 --- a/public/assets/common.js +++ b/public/assets/common.js @@ -79,7 +79,7 @@ window.IAP = (function () { const paint = list => { d.innerHTML = 'Part of the networkOne account across the network:' + list.map(s => (s.id === 'linkspin' || /linkspin\.app/.test(s.url)) ? '' + esc(s.name) + ' (you are here)' - : '' + esc(s.name) + '').join(''); + : '' + esc(s.name) + '').join(''); }; paint(NET_FALLBACK); networkSites().then(paint); diff --git a/public/assets/netline.js b/public/assets/netline.js index beb9cd7..c51afa5 100644 --- a/public/assets/netline.js +++ b/public/assets/netline.js @@ -13,7 +13,7 @@ host.appendChild(box); var paint = function (list) { box.innerHTML = 'TrustClickz · 615 Green Valley Drive, Moody, AL 35004Part of the networkOne account across the network:' + list.map(function (s) { - return s.id === me ? '' + esc(s.name) + ' (you are here)' : '' + esc(s.name) + ''; + return s.id === me ? '' + esc(s.name) + ' (you are here)' : '' + esc(s.name) + ''; }).join(''); }; paint(FALLBACK); diff --git a/public/contract.html b/public/contract.html index 7339ce7..5c453de 100644 --- a/public/contract.html +++ b/public/contract.html @@ -149,6 +149,6 @@ - + diff --git a/public/conversion-tracking.html b/public/conversion-tracking.html index 53de210..e1f932c 100644 --- a/public/conversion-tracking.html +++ b/public/conversion-tracking.html @@ -284,6 +284,6 @@ - + diff --git a/public/credits.html b/public/credits.html index 5b4a6be..7f4aa0c 100644 --- a/public/credits.html +++ b/public/credits.html @@ -81,7 +81,7 @@ - + diff --git a/public/disclaimer.html b/public/disclaimer.html index d217290..159ef0a 100644 --- a/public/disclaimer.html +++ b/public/disclaimer.html @@ -47,6 +47,6 @@ a Crypto Team Build Network property - + diff --git a/public/earning.html b/public/earning.html index a4ced3d..a9051d0 100644 --- a/public/earning.html +++ b/public/earning.html @@ -69,7 +69,7 @@
Advertising services with a performance referral program. Not an investment product; no income guarantees.
- - + + diff --git a/public/index.html b/public/index.html index f9e5455..0e887a3 100644 --- a/public/index.html +++ b/public/index.html @@ -225,6 +225,6 @@ - + diff --git a/public/join.html b/public/join.html index c1b9c5d..fcbe0c3 100644 --- a/public/join.html +++ b/public/join.html @@ -106,8 +106,8 @@ body.squeeze .card{position:sticky;top:16px} a Crypto Team Build Network property - + - + diff --git a/public/launch.html b/public/launch.html index b764218..10d00ee 100644 --- a/public/launch.html +++ b/public/launch.html @@ -102,7 +102,7 @@
Advertising services with a performance referral program. Not an investment product; no income guarantees.
- + diff --git a/public/ledger.html b/public/ledger.html index 28c1a18..11e42fb 100644 --- a/public/ledger.html +++ b/public/ledger.html @@ -65,8 +65,8 @@ a Crypto Team Build Network property - + - + diff --git a/public/my.html b/public/my.html index 4ac4dae..420b007 100644 --- a/public/my.html +++ b/public/my.html @@ -1015,7 +1015,7 @@ - + diff --git a/public/partners.html b/public/partners.html index 8ab9d5d..7cd9cea 100644 --- a/public/partners.html +++ b/public/partners.html @@ -131,8 +131,8 @@
Advertising services with a performance referral program. Not an investment product; no income guarantees. Crypto transactions are irreversible. Never spend what you cannot afford to lose.
- + - + diff --git a/public/plays.html b/public/plays.html index b95bbbc..d5b99a4 100644 --- a/public/plays.html +++ b/public/plays.html @@ -193,7 +193,7 @@
Advertising services with a performance referral program. Not an investment product; no income guarantees. Crypto transactions are irreversible. Never spend what you cannot afford.
- + diff --git a/public/privacy.html b/public/privacy.html index dc777ef..c3e8217 100644 --- a/public/privacy.html +++ b/public/privacy.html @@ -56,6 +56,6 @@ a Crypto Team Build Network property - + diff --git a/public/publishers.html b/public/publishers.html index 25e3453..50554eb 100644 --- a/public/publishers.html +++ b/public/publishers.html @@ -289,6 +289,6 @@ - + diff --git a/public/refuel.html b/public/refuel.html index dd08d06..6121dfa 100644 --- a/public/refuel.html +++ b/public/refuel.html @@ -281,6 +281,6 @@ - + diff --git a/public/support.html b/public/support.html index d3a8d4b..c88c28b 100644 --- a/public/support.html +++ b/public/support.html @@ -67,8 +67,8 @@ a Crypto Team Build Network property - + - + diff --git a/public/terms.html b/public/terms.html index d0df553..865b5fe 100644 --- a/public/terms.html +++ b/public/terms.html @@ -62,6 +62,6 @@ a Crypto Team Build Network property - + diff --git a/public/tx.html b/public/tx.html index 0af37dc..b31c99b 100644 --- a/public/tx.html +++ b/public/tx.html @@ -35,7 +35,7 @@

← Back to the live ledger · Read the contract review

- + diff --git a/public/wall.html b/public/wall.html index 1a882ab..7b81d89 100644 --- a/public/wall.html +++ b/public/wall.html @@ -49,7 +49,7 @@ - + diff --git a/public/wallets.html b/public/wallets.html index 3e20fec..ebf7ffb 100644 --- a/public/wallets.html +++ b/public/wallets.html @@ -120,7 +120,7 @@
Advertising services with a performance referral program. Not an investment product; no income guarantees. Crypto transactions are irreversible. Never share your recovery phrase.
- + diff --git a/qa/netsrc.test.mjs b/qa/netsrc.test.mjs new file mode 100644 index 0000000..b65a189 --- /dev/null +++ b/qa/netsrc.test.mjs @@ -0,0 +1,64 @@ +// Network sites as traffic sources (2026-11-14). Boots server.js on its own port with a throwaway seeded data dir (JSON store, no DB) +// and checks: the admin account gets one fixed network link per site (nwiap, nwls, nwdlb, nwvbb, nwsp, nwec) and one source per +// network site; /r/?src=&s1=&s2= lands on the right page with ?ref=; the click counts under the sending site's source; +// a member's own link with ?src= gets that site's source made on first use; an unknown src changes nothing; a reboot makes +// nothing twice. +// node qa/netsrc.test.mjs (from the site dir; PORT default 8973) +import fs from 'node:fs'; +import os from 'node:os'; +import path from 'node:path'; +import { spawn } from 'node:child_process'; + +const PORT = Number(process.env.PORT || 8973); const BASE = 'http://127.0.0.1:' + PORT; +let pass = 0, fail = 0; const ok = (c, what, x) => { if (c) { pass++; console.log(' ok ' + what); } else { fail++; console.log(' FAIL ' + what + (x !== undefined ? ' -> ' + JSON.stringify(x).slice(0, 400) : '')); } }; +const DATA = fs.mkdtempSync(path.join(os.tmpdir(), 'ns-qa-')); const now = Date.now(); const ADMIN = 'admin@ns.test', MEM = 'mem@ns.test'; +fs.writeFileSync(path.join(DATA, 'sources.json'), JSON.stringify({ v: 1, items: [{ id: 'aaaaaaaaaa', owner: MEM, name: 'My mailer', template: 'custom', site: 'mailer.example', params: [], postbackUrl: '', events: ['join'], enabled: true, created: now }] })); +fs.writeFileSync(path.join(DATA, 'rotator.json'), JSON.stringify({ v: 1, rotations: [ + { id: 1, owner: MEM, name: 'Mine', code: 'memlnk', fallback: '', destinations: [{ id: 1, url: 'https://offer.example.org/', weight: 1, active: true }], created: now, paused: false, nextDest: 2, sourceId: 'aaaaaaaaaa' }], hits: [], conv: [] })); +const env = Object.assign({}, process.env, { PORT: String(PORT), DATA_DIR: DATA, ADMIN_PASSWORD: 'x'.repeat(16), ADMIN_EMAIL: ADMIN }); +for (const k of ['NODE_ENV', 'DATABASE_URL', 'ENGINE_KEY', 'LS_SYNC_SECRET', 'OUTBOUND', 'LS_TESTERS', 'CURTAIN', 'HUB_ENABLED', 'HUB_URL', 'NETWORK_LINKS_OWNER', 'NETWORK_SSO_SECRET']) delete env[k]; +const site = path.resolve(path.dirname(new URL(import.meta.url).pathname.replace(/^\/([A-Za-z]:)/, '$1')), '..'); +const sleep = ms => new Promise(r => setTimeout(r, ms)); +let srv = null; +async function boot() { srv = spawn(process.execPath, ['server.js'], { cwd: site, env, stdio: ['ignore', 'ignore', 'ignore'] }); for (let i = 0; i < 60; i++) { try { if ((await fetch(BASE + '/api/config')).ok) break; } catch (e) {} await sleep(500); } await sleep(3800); } +async function stop() { if (srv) srv.kill(); srv = null; await sleep(600); } +const go = async (p, ref) => { const r = await fetch(BASE + p, { redirect: 'manual', headers: Object.assign({ 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0) Chrome/130 netsrc-qa' }, ref ? { Referer: ref } : {}) }); return { status: r.status, loc: r.headers.get('location') || '' }; }; +const read = f => JSON.parse(fs.readFileSync(path.join(DATA, f), 'utf8')); +const srcOf = (owner, tpl) => read('sources.json').items.find(x => x.owner === owner && x.template === tpl); +try { + await boot(); + const rots = read('rotator.json').rotations.filter(r => r.owner === ADMIN); + ok(['nwiap', 'nwls', 'nwdlb', 'nwvbb', 'nwsp', 'nwec'].every(c => rots.some(r => r.code === c)) && rots.length === 6, 'the admin account has the six network links', rots.map(r => r.code)); + const mineSrc = read('sources.json').items.filter(x => x.owner === ADMIN); + ok(['instantadpay', 'linkspin', 'downlinebanners', 'viralbannerblitz', 'stackpol', 'earnerscorner'].every(t => mineSrc.some(x => x.template === t)) && mineSrc.length === 6, 'and one source per network site', mineSrc.map(x => x.template)); + + let r = await go('/r/nwdlb?src=iap&s1=bob&s2=how'); + ok(r.status === 302 && /^https:\/\/downlinebanners\.com\/how\?ref=bob$/.test(r.loc), 'nwdlb: lands on /how with ?ref=bob', r); + r = await go('/r/nwiap?src=vbb&s1=amy'); + ok(r.status === 302 && /^https:\/\/instantadpay\.com\/\?ref=amy&lsclk=[a-f0-9]{10}$/.test(r.loc), 'nwiap: home page with ?ref=amy and the click id (InstantAdPay reports joins against it)', r); + r = await go('/r/nwec?src=dlb'); + ok(r.status === 302 && /^https:\/\/earnerscorner\.com\/(\?|$)/.test(r.loc), 'nwec: the forum home', r); + r = await go('/r/nwvbb?src=linkspin', 'https://linkspin.app/contract'); + ok(r.status === 302 && /^https:\/\/viralbannerblitz\.com\/\?ref=(&|$)/.test(r.loc), 'nwvbb with no member: an empty ref', r); + await sleep(300); + const hits = read('rotator.json').hits; const byCode = c => { const rr = read('rotator.json').rotations.find(x => x.code === c); return hits.filter(h => h.r === rr.id); }; + const h1 = byCode('nwdlb')[0], h2 = byCode('nwiap')[0], h3 = byCode('nwec')[0], h4 = byCode('nwvbb')[0]; + ok(h1 && h1.sr === srcOf(ADMIN, 'instantadpay').id && h1.s === 'instantadpay.com' && h1.q.s1 === 'bob', 'the DLB click counts under the InstantAdPay source (no referrer: the site name)', h1); + ok(h2 && h2.sr === srcOf(ADMIN, 'viralbannerblitz').id, 'the IAP click counts under the Viral Banner Blitz source', h2); + ok(h3 && h3.sr === srcOf(ADMIN, 'downlinebanners').id, 'the Earners Corner click counts under the Downline Banners source', h3); + ok(h4 && h4.sr === srcOf(ADMIN, 'linkspin').id && h4.s === 'linkspin.app', 'a real referrer is kept as the referrer', h4); + + ok(!srcOf(MEM, 'stackpol'), 'the member has no Stack POL source yet'); + r = await go('/r/memlnk?src=stackpol'); + ok(r.status === 302 && /^https:\/\/offer\.example\.org\//.test(r.loc), 'a member link with ?src=stackpol still redirects', r); + await go('/r/memlnk?src=nosuchsite'); await go('/r/memlnk'); await sleep(300); + const ms = srcOf(MEM, 'stackpol'); const mh = read('rotator.json').hits.filter(h => h.r === 1); + ok(ms && ms.name === 'Stack POL', 'the member got a Stack POL source on first use', ms); + ok(mh.length === 3 && mh[0].sr === ms.id && mh[1].sr === 'aaaaaaaaaa' && mh[2].sr === 'aaaaaaaaaa', 'that click counts under it; an unknown src or none keeps the attached source', mh.map(h => h.sr)); + ok(read('sources.json').items.filter(x => x.owner === MEM).length === 2, 'an unknown src makes no source'); + + await stop(); await boot(); + ok(read('rotator.json').rotations.filter(x => x.owner === ADMIN).length === 6 && read('sources.json').items.filter(x => x.owner === ADMIN).length === 6, 'a reboot makes nothing twice'); +} catch (e) { fail++; console.error(e); } +finally { await stop(); try { fs.rmSync(DATA, { recursive: true, force: true }); } catch (e) {} } +console.log('\n' + pass + ' passed, ' + fail + ' failed'); process.exit(fail ? 1 : 0); diff --git a/qa/run.sh b/qa/run.sh index 207b578..df392da 100644 --- a/qa/run.sh +++ b/qa/run.sh @@ -9,6 +9,7 @@ # bash qa/run.sh sponsorfollow # sponsor follow rule + network tank unit tests + carry hold guard + carry activation regression # bash qa/run.sh tankhold # holding tank: network alignment first, plain-activation hold (never a purchase), 24-hour rotation, payouts on at assignment (unit with a mocked clock + fake engine, then a local copy with a mock InstantAdPay) # bash qa/run.sh netconv # conversion linkage: InstantAdPay's joins, wallets, purchases counted once, own account left out, window, aged hits, two copies racing, one Reports list, the landing tag on network links +# bash qa/run.sh netsrc # network sites as traffic sources: the six fixed network links, ?src= picks the sending site's source, member links get it on first use # bash qa/run.sh lsid # page-builder lead -> rotator conversion + postback, audience pixel events and cookieless hits # bash qa/run.sh convpixel # conversion pixel: ad click ids, landing tag + goal pixel (url/stored/cookie/soft), dedupe, window, owner check, cost per goal, IAP partner calls, browser + framed # bash qa/run.sh nas # Network Ad Space billing: stop snapshot, active-only reconcile, restart without phantom delivery, the 1/N network + partner-zone rate (stubbed NAS, throwaway data) @@ -95,6 +96,8 @@ elif [ "$MODE" = "convpixel" ]; then node qa/convpixel.test.mjs || status=1 elif [ "$MODE" = "netconv" ]; then node qa/netconv.test.mjs || status=1 +elif [ "$MODE" = "netsrc" ]; then + node qa/netsrc.test.mjs || status=1 elif [ "$MODE" = "lsid" ]; then node qa/lsid-pixel.test.mjs || status=1 elif [ "$MODE" = "kb" ]; then diff --git a/releases.js b/releases.js index 52aba4d..2c21b7f 100644 --- a/releases.js +++ b/releases.js @@ -66,7 +66,7 @@ function renderPage() { h += '

Release notes

'; h += v.notes.length ? v.notes.map(n => '

' + esc(n.title) + n.tags.map(tagChip).join('') + '

' + fmt(n.date) + '

' + bodyHtml(n.body) + '
').join('') : '

No notes yet.

'; h += '

Suggestions and bug reports: the chat bubble on any page, or the LinkSpin Telegram group.

'; - h += ''; + h += ''; return h; } module.exports = { init, notes, roadmap, saveNote, saveRoadmap, remove, publicView, renderPage, bodyHtml, TAGS, STATUSES }; diff --git a/rotator.js b/rotator.js index 7defaf4..042d6ea 100644 --- a/rotator.js +++ b/rotator.js @@ -142,6 +142,16 @@ async function update(owner, id, body) { if (body.sourceId !== undefined) { const sid = String(body.sourceId || '').trim(); if (!sid) delete r.sourceId; else { if (!/^[a-f0-9]{10}$/.test(sid) || !SOURCES || !SOURCES.find(owner, sid)) return { error: 'No such source.' }; r.sourceId = sid; } } J.save(); return { ok: true, rotation: pub(r) }; } +// a link with a fixed code for an internal owner (netlinks.js, 2026-11-14): made once with one destination, never changed after +// (the owner may edit it like any link). Fixed codes are 4-5 characters, so a random 6-character code can never take one. +function ensureFixed(owner, code, name, url) { + const c = norm(code); if (!/^[a-z0-9]{4,5}$/.test(c)) return { error: 'code' }; + const have = J.db.rotations.find(r => r.code === c); + if (have) return have.owner === norm(owner) ? { ok: true, rotation: have, created: false } : { error: 'taken' }; + const u = cleanUrl(url); if (!u) return { error: 'url' }; + const r = { id: (J.db.rotations.reduce((m, x) => Math.max(m, x.id), 0) + 1), owner: norm(owner), name: String(name).slice(0, 80), code: c, fallback: '', destinations: [{ id: 1, url: u, label: '', weight: 1, active: true, added: Date.now() }], created: Date.now(), paused: false, nextDest: 2 }; + J.db.rotations.push(r); J.save(); return { ok: true, rotation: r, created: true }; +} async function remove(owner, id) { const n = J.db.rotations.length; J.db.rotations = J.db.rotations.filter(r => !(r.id === Number(id) && r.owner === norm(owner))); J.save(); return n !== J.db.rotations.length ? { ok: true } : { error: 'No such rotation.' }; } // opts.max: the admin import path only (BTC4Hits rotators, 2026-11-11) may go past the 25 a member can add, up to IMPORT_MAX const DEST_MAX = 25, IMPORT_MAX = 2000; @@ -196,9 +206,13 @@ async function resolve(code, req) { const device = /mobile|android|iphone|ipad/i.test(ua) ? 'mobile' : 'desktop'; // click ids and sub ids that rode in on the link (tracker / traffic-network params), kept per click const q = {}; try { const sp = new URL(req.url, 'http://x').searchParams; let n = 0; for (const [k, val] of sp) { const key = String(k).toLowerCase(); if (n >= 20) break; if (/^(clickid|click_id|cid|subid|sub_id|s[1-5]|sub[1-5]|t[1-5]|aff_sub[1-5]?|utm_(source|medium|campaign|term|content)|src|source|campaign|zone|placement|cost|creative|site|banner|keyword|geo|os|browser|device|carrier|format|external_id|visitor_id)$/.test(key)) { q[key] = String(val).slice(0, 200); n++; } } } catch (e) {} + // a network site sent this click (?src=dlb, 2026-11-14): it counts under the owner's source for that site, even on a link with + // another source attached (the network template has no postback, so no network is told about a click it did not send) + let sr = r.sourceId || undefined; + try { const ns = q.src && SOURCES && SOURCES.networkSource ? SOURCES.networkSource(r.owner, q.src) : null; if (ns) { sr = ns.id; if (src === 'direct' && ns.site) src = ns.site; } } catch (e) {} const id = crypto.randomBytes(6).toString('hex').slice(0, 10); // sr = the traffic source attached to the link at click time, so the network that sent this click is the one told about its conversion - J.db.hits.push({ id, r: r.id, d: d ? d.id : 0, ts: Date.now(), v, c: country, s: src, dv: device, bot: bot ? 1 : 0, oh: off ? 1 : undefined, q: Object.keys(q).length ? q : undefined, sr: r.sourceId || undefined, ac: ac || undefined }); + J.db.hits.push({ id, r: r.id, d: d ? d.id : 0, ts: Date.now(), v, c: country, s: src, dv: device, bot: bot ? 1 : 0, oh: off ? 1 : undefined, q: Object.keys(q).length ? q : undefined, sr, ac: ac || undefined }); if (HIT_IX) HIT_IX.set(id, J.db.hits.length - 1); if (docstore.isOn()) { const h = J.db.hits[J.db.hits.length - 1]; docstore.rowPut('rot_hits', h.id, h.ts, h); } // memory keeps the newest 200k, MySQL keeps every click if (J.db.hits.length > 200000) { J.db.hits = J.db.hits.slice(-150000); HIT_IX = null; } @@ -352,4 +366,4 @@ function adminAll() { hits: o.hits, hits7: o.hits7, bots: o.bots, conversions: cv[r.id] || 0 }; }); } module.exports = { init, convRows, adminAll, hitById, list, get, create, update, remove, addDest, updateDest, resolve, stats, totals, convert, summary, createDemo, claim, sweepDemos, servedToday, window24, - pub, rawRotations, save, findMine, setExternalConvert, PRESETS, cleanHours, cleanTz, cellAt, zoneFor, isOn, COUNTRY_TZ, sourceCounts, detachSource }; + pub, rawRotations, save, findMine, setExternalConvert, PRESETS, cleanHours, cleanTz, cellAt, zoneFor, isOn, COUNTRY_TZ, sourceCounts, detachSource, ensureFixed }; diff --git a/server.js b/server.js index d32d520..6990dcf 100644 --- a/server.js +++ b/server.js @@ -756,6 +756,8 @@ async function boot() { rotator.setExternalConvert((lsid, ev, facts) => /^[ai]/.test(String(lsid)) ? netconv.fromLinkSpin(lsid, ev, facts) : bannerspin.convert(lsid, ev, facts)); // Banner Spin click ids convert like spin-link clicks; ad clicks through the ledger netconv.init({ dataDir: DATA_DIR, convtrack, rotator, bannerspin, postbacks, marks }); sources.init({ dataDir: DATA_DIR, postbacks, rotator, catalogFile: path.join(ROOT, 'catalog', 'traffic-sources.json'), linkHost: () => { const hs = String(siteConfig().linkDomains || '').split(',').map(x => x.trim()).filter(Boolean); return hs[0] || SITE_HOST; } }); + // network links + one traffic source per network site on the admin account (netlinks.js, 2026-11-14), made once when missing + setTimeout(() => { try { console.log('network links', JSON.stringify(require('./netlinks').ensure({ owner: process.env.NETWORK_LINKS_OWNER || ADMIN_EMAIL, rotator, sources }))); } catch (e) { console.error('network links', e.message); } }, 3000); zones.init({ dataDir: DATA_DIR, ads, siteHost: SITE_HOST }); pages.init({ dataDir: DATA_DIR, ownHosts, imageBase: () => (IS_PROD ? 'https' : 'http') + '://' + SITE_HOST, openrouterKey: () => { if (process.env.OPENROUTER_API_KEY) return process.env.OPENROUTER_API_KEY.trim(); try { return fs.readFileSync(path.join(DATA_DIR, 'openrouter.key'), 'utf8').trim(); } catch (e) { return ''; } } }); audiences.init({ dataDir: DATA_DIR }); @@ -4437,7 +4439,7 @@ const server = http.createServer(async (req, res) => { + '' + '
' + esc(label) + ' badge for @' + esc(un) + '

@' + esc(un) + ' unlocked ' + label + '

' + esc(sub.charAt(0).toUpperCase() + sub.slice(1)) + '. On LinkSpin every ad package that sells pays the sponsor in the same transaction, straight to their wallet, on-chain.

' + 'Join @' + esc(un) + '\u2019s line free

Advertising with a performance referral program. Not an investment; no income is guaranteed.

' - + ''; + + ''; res.writeHead(200, baseHeaders({ 'Content-Type': 'text/html; charset=utf-8', 'Cache-Control': 'public, max-age=300' })); return res.end(html); } diff --git a/sources.js b/sources.js index 48bbbf3..e554da6 100644 --- a/sources.js +++ b/sources.js @@ -138,6 +138,18 @@ function forFire(owner, id) { const s = find(owner, id); return s && s.enabled & function save() { J.save(); } // name + placement key per source, for rotator.summary function meta(owner) { const m = {}; for (const s of mine(owner)) m[s.id] = { name: s.name, placementKey: placementKey(s), site: s.site || '' }; return m; } +// network sites as traffic sources (Marty 2026-11-14: "make sure each of these sites is its own traffic source"): a spin-link click +// carrying ?src= (iap, linkspin, dlb, vbb, stackpol, earnerscorner, or the catalog key) counts under the link owner's +// source for that site, made from the network catalog template the first time it is needed. Only network templates qualify. +const NET_SRC = { iap: 'instantadpay', instantadpay: 'instantadpay', linkspin: 'linkspin', dlb: 'downlinebanners', downlinebanners: 'downlinebanners', + vbb: 'viralbannerblitz', viralbannerblitz: 'viralbannerblitz', stackpol: 'stackpol', earnerscorner: 'earnerscorner' }; +function networkTemplate(src) { const k = NET_SRC[String(src || '').trim().toLowerCase()]; const t = k ? template(k) : null; return t && t.source === 'network' ? t : null; } +function networkSource(owner, src) { + const t = networkTemplate(src); if (!t || !owner) return null; + let s = J.db.items.find(x => x.owner === norm(owner) && x.template === t.key); + if (!s) { create(owner, { template: t.key, name: t.name, site: t.site }); s = J.db.items.find(x => x.owner === norm(owner) && x.template === t.key); } // create() runs to the end synchronously (no awaits) + return s ? { id: s.id, site: t.site } : null; +} // admin Member content (2026-10-18): every source of every owner function adminAll() { return J.db.items.map(s => Object.assign(pub(s), { owner: s.owner })); } -module.exports = { init, adminAll, catalog, list, create, update, get, urlFor, test, find, forFire, save, meta, KEYS, PLACEMENT_KEYS, LIMITS }; +module.exports = { init, adminAll, networkSource, networkTemplate, NET_SRC, catalog, list, create, update, get, urlFor, test, find, forFire, save, meta, KEYS, PLACEMENT_KEYS, LIMITS };