Network sites as LinkSpin traffic sources (Marty 2026-11-14: "Make sure each of these sites is its own traffic source and link spun so we can track it"). Catalog: InstantAdPay, LinkSpin, Stack POL, Earners Corner network templates (next to Downline Banners and Viral Banner Blitz). A spin-link click with ?src=<site id> (iap, linkspin, dlb, vbb, stackpol, earnerscorner) counts under the link owner's source for that site, made from the template on first use (network templates only, no postback, so no network hears of a click it did not send; no referrer = the site's name as referrer). netlinks.js: at boot the admin account gets one fixed network link per site, made once when missing: nwiap, nwls, nwdlb, nwvbb, nwsp, nwec -> https://<site>/{s2}?ref={s1} (Earners Corner without ref), so every site links to the others as linkspin.app/r/<code>?src=<sender>&s1=<member>&s2=<page>. Health checks probe a destination with its {macros} empty, as a click with no params lands. netsites.js: /api/network-sites adds go (the tracked link with ?src=linkspin); common.js + netline.js footers use it (rel nofollow). common.js?v=20261114ns, netline.js?v=20261114ns. qa: netsrc 16/16 (new, bash qa/run.sh netsrc), member 57 passed 0 failed, partner-spins 13/13, netconv 57/57, lsid 31/31

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-11-14 11:39:34 -06:00
parent 9025057128
commit a630979a3a
35 changed files with 226 additions and 39 deletions
+1 -1
View File
@@ -110,7 +110,7 @@ function head(o) {
+ '</head><body><div class="wrap bl">';
}
function tail() {
return '</div><script src="/assets/common.js?v=20261114nf"></script><script src="/assets/blog-page.js?v=20260914a"></script></body></html>';
return '</div><script src="/assets/common.js?v=20261114ns"></script><script src="/assets/blog-page.js?v=20260914a"></script></body></html>';
}
const authorBox = () => '<div class="author"><img src="/logo-icon.png" alt="LinkSpin"><div><b>' + AUTHOR + '</b><span>Founder of LinkSpin and the Crypto Team Build Network. Twenty-plus years of internet marketing, and a habit of writing down what actually worked.</span></div></div>';
const cardHtml = p => '<a class="post-card" href="/blog/' + esc(p.slug) + '">' + (p.cover ? '<img src="' + esc(p.cover) + '" alt="" loading="lazy" style="width:100%;border-radius:10px;margin:0 0 12px">' : '') + '<h2>' + esc(p.title) + '</h2><p>' + esc(p.excerpt) + '</p><p class="meta">' + fmtDate(p.publishedAt || p.created) + ' · ' + readMinutes(p.body) + ' min read' + (p.tags.length ? ' · ' + p.tags.map(esc).join(', ') : '') + '</p></a>';
+44
View File
@@ -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",
+4 -2
View File
@@ -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();
+1 -1
View File
@@ -146,7 +146,7 @@ async function renderPage() {
const w = winners();
if (w.length) h += '<h2 style="font-size:24px;margin:0 0 10px">Past winners</h2>' + w.slice(0, 12).map(x => '<div class="win"><b>' + (x.kind === 'week' ? 'Week of ' : 'Month of ') + fmtD(x.start) + '</b>: ' + (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) : '')) + '</div>').join('');
h += '<p class="muted small" style="margin-top:30px">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.</p>';
h += '</div><script src="/assets/common.js?v=20261114nf"></script><script src="/assets/blog-page.js?v=20260914a"></script></body></html>';
h += '</div><script src="/assets/common.js?v=20261114ns"></script><script src="/assets/blog-page.js?v=20260914a"></script></body></html>';
return h;
}
function setLaunchPanel(fn) { if (R) R.launchPanel = fn; }
+26
View File
@@ -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/<code>?src=<the site that sent the click>&s1=<member username>&s2=<page>
// 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 };
+22 -2
View File
@@ -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=<this site>, 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 };
+1 -1
View File
@@ -548,7 +548,7 @@
</div>
</div>
<script src="/assets/common.js?v=20261114nf"></script>
<script src="/assets/common.js?v=20261114ns"></script>
<script src="/assets/admin-kb.js?v=20261020kb"></script>
<script src="/assets/admin.js?v=20261112txt"></script><script src="/assets/admin-sponsorcheck.js?v=20261107tg"></script><script src="/assets/admin-refill.js?v=20261024rf"></script><script src="/assets/admin-kits.js?v=20261024kit"></script><script src="/assets/admin-launchweek.js?v=20261105lw"></script>
</body>
+1 -1
View File
@@ -79,7 +79,7 @@ window.IAP = (function () {
const paint = list => {
d.innerHTML = '<b>Part of the network</b><span>One account across the network:</span>' + list.map(s => (s.id === 'linkspin' || /linkspin\.app/.test(s.url))
? '<span aria-current="page" style="font-weight:700;color:var(--ink)">' + esc(s.name) + ' (you are here)</span>'
: '<a href="' + esc(s.url) + '" target="_blank" rel="noopener">' + esc(s.name) + '</a>').join('');
: '<a href="' + esc(s.go || s.url) + '" target="_blank" rel="noopener nofollow">' + esc(s.name) + '</a>').join('');
};
paint(NET_FALLBACK);
networkSites().then(paint);
+1 -1
View File
@@ -13,7 +13,7 @@
host.appendChild(box);
var paint = function (list) {
box.innerHTML = '<span style="flex-basis:100%">TrustClickz · 615 Green Valley Drive, Moody, AL 35004</span><b>Part of the network</b><span>One account across the network:</span>' + list.map(function (s) {
return s.id === me ? '<span aria-current="page" style="font-weight:700">' + esc(s.name) + ' (you are here)</span>' : '<a href="' + esc(s.url) + '" target="_blank" rel="noopener">' + esc(s.name) + '</a>';
return s.id === me ? '<span aria-current="page" style="font-weight:700">' + esc(s.name) + ' (you are here)</span>' : '<a href="' + esc(s.go || s.url) + '" target="_blank" rel="noopener nofollow">' + esc(s.name) + '</a>';
}).join('');
};
paint(FALLBACK);
+1 -1
View File
@@ -149,6 +149,6 @@
</div>
</footer>
<script src="/assets/contract.js?v=20261023ov"></script>
<script src="/assets/netline.js?v=20261114nf" data-site="linkspin"></script>
<script src="/assets/netline.js?v=20261114ns" data-site="linkspin"></script>
</body>
</html>
+1 -1
View File
@@ -284,6 +284,6 @@
</div>
</footer>
<script src="/assets/conversion-guide.js?v=20261024ct"></script>
<script src="/assets/netline.js?v=20261114nf" data-site="linkspin"></script>
<script src="/assets/netline.js?v=20261114ns" data-site="linkspin"></script>
</body>
</html>
+1 -1
View File
@@ -81,7 +81,7 @@
</div>
</div>
</div>
<script src="/assets/common.js?v=20261114nf"></script>
<script src="/assets/common.js?v=20261114ns"></script>
<script src="/assets/wallet.js?v=20261021a"></script>
<script src="/assets/cr-shell.js?v=20261113nl"></script>
<script src="/assets/credits-screen.js?v=20261107tg"></script>
+1 -1
View File
@@ -47,6 +47,6 @@
<span class="mono" style="font-size:11px">a Crypto Team Build Network property</span>
</div>
</footer>
<script src="/assets/netline.js?v=20261114nf" data-site="linkspin"></script>
<script src="/assets/netline.js?v=20261114ns" data-site="linkspin"></script>
</body>
</html>
+2 -2
View File
@@ -69,7 +69,7 @@
<div class="small">Advertising services with a performance referral program. Not an investment product; no income guarantees.</div>
</footer>
</div>
<script src="/assets/common.js?v=20261114nf"></script>
<script src="/assets/netline.js?v=20261114nf" data-site="linkspin"></script>
<script src="/assets/common.js?v=20261114ns"></script>
<script src="/assets/netline.js?v=20261114ns" data-site="linkspin"></script>
</body>
</html>
+1 -1
View File
@@ -225,6 +225,6 @@
</footer>
<script src="/assets/home.js?v=20261113me"></script>
<script src="/assets/netline.js?v=20261114nf" data-site="linkspin"></script>
<script src="/assets/netline.js?v=20261114ns" data-site="linkspin"></script>
</body>
</html>
+2 -2
View File
@@ -106,8 +106,8 @@ body.squeeze .card{position:sticky;top:16px}
<span class="mono" style="font-size:11px">a Crypto Team Build Network property</span>
</div>
</footer>
<script src="/assets/common.js?v=20261114nf"></script>
<script src="/assets/common.js?v=20261114ns"></script>
<script src="/assets/join.js?v=20261111b4h"></script>
<script src="/assets/netline.js?v=20261114nf" data-site="linkspin"></script>
<script src="/assets/netline.js?v=20261114ns" data-site="linkspin"></script>
</body>
</html>
+1 -1
View File
@@ -102,7 +102,7 @@
<div class="small">Advertising services with a performance referral program. Not an investment product; no income guarantees.</div>
</footer>
</div>
<script src="/assets/common.js?v=20261114nf"></script>
<script src="/assets/common.js?v=20261114ns"></script>
<script src="/assets/launch.js?v=20261105po"></script>
</body>
</html>
+2 -2
View File
@@ -65,8 +65,8 @@
<span class="mono" style="font-size:11px">a Crypto Team Build Network property</span>
</div>
</footer>
<script src="/assets/common.js?v=20261114nf"></script>
<script src="/assets/common.js?v=20261114ns"></script>
<script src="/assets/ledger.js?v=20261007a"></script>
<script src="/assets/netline.js?v=20261114nf" data-site="linkspin"></script>
<script src="/assets/netline.js?v=20261114ns" data-site="linkspin"></script>
</body>
</html>
+1 -1
View File
@@ -1015,7 +1015,7 @@
</div>
</div>
</div>
<script src="/assets/common.js?v=20261114nf"></script>
<script src="/assets/common.js?v=20261114ns"></script>
<script src="/assets/cr-shell.js?v=20261113nl"></script>
<script src="/assets/tools.js?v=20261011a"></script>
<script src="/assets/wallet.js?v=20261021a"></script>
+2 -2
View File
@@ -131,8 +131,8 @@
<div class="small">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.</div>
</footer>
</div>
<script src="/assets/common.js?v=20261114nf"></script>
<script src="/assets/common.js?v=20261114ns"></script>
<script src="/assets/partners.js?v=20261010a"></script>
<script src="/assets/netline.js?v=20261114nf" data-site="linkspin"></script>
<script src="/assets/netline.js?v=20261114ns" data-site="linkspin"></script>
</body>
</html>
+1 -1
View File
@@ -193,7 +193,7 @@
<div class="small">Advertising services with a performance referral program. Not an investment product; no income guarantees. Crypto transactions are irreversible. Never spend what you cannot afford.</div>
</footer>
</div>
<script src="/assets/common.js?v=20261114nf"></script>
<script src="/assets/common.js?v=20261114ns"></script>
<script src="/assets/plays.js?v=20260910b"></script>
</body>
</html>
+1 -1
View File
@@ -56,6 +56,6 @@
<span class="mono" style="font-size:11px">a Crypto Team Build Network property</span>
</div>
</footer>
<script src="/assets/netline.js?v=20261114nf" data-site="linkspin"></script>
<script src="/assets/netline.js?v=20261114ns" data-site="linkspin"></script>
</body>
</html>
+1 -1
View File
@@ -289,6 +289,6 @@
</footer>
<script src="/assets/publishers.js?v=20261010a"></script>
<script src="/assets/netline.js?v=20261114nf" data-site="linkspin"></script>
<script src="/assets/netline.js?v=20261114ns" data-site="linkspin"></script>
</body>
</html>
+1 -1
View File
@@ -281,6 +281,6 @@
</div>
</footer>
<script src="/assets/refuel-guide.js?v=20261024rg"></script>
<script src="/assets/netline.js?v=20261114nf" data-site="linkspin"></script>
<script src="/assets/netline.js?v=20261114ns" data-site="linkspin"></script>
</body>
</html>
+2 -2
View File
@@ -67,8 +67,8 @@
<span class="mono" style="font-size:11px">a Crypto Team Build Network property</span>
</div>
</footer>
<script src="/assets/common.js?v=20261114nf"></script>
<script src="/assets/common.js?v=20261114ns"></script>
<script src="/assets/support.js?v=20261016a"></script>
<script src="/assets/netline.js?v=20261114nf" data-site="linkspin"></script>
<script src="/assets/netline.js?v=20261114ns" data-site="linkspin"></script>
</body>
</html>
+1 -1
View File
@@ -62,6 +62,6 @@
<span class="mono" style="font-size:11px">a Crypto Team Build Network property</span>
</div>
</footer>
<script src="/assets/netline.js?v=20261114nf" data-site="linkspin"></script>
<script src="/assets/netline.js?v=20261114ns" data-site="linkspin"></script>
</body>
</html>
+1 -1
View File
@@ -35,7 +35,7 @@
<p><a href="/ledger">← Back to the live ledger</a> · <a href="/contract">Read the contract review</a></p>
</div>
</section>
<script src="/assets/common.js?v=20261114nf"></script>
<script src="/assets/common.js?v=20261114ns"></script>
<script src="/assets/tx.js?v=20260906m"></script>
</body>
</html>
+1 -1
View File
@@ -49,7 +49,7 @@
</div>
</div>
</section>
<script src="/assets/common.js?v=20261114nf"></script>
<script src="/assets/common.js?v=20261114ns"></script>
<script src="/assets/wall.js?v=20261030pp"></script>
<script src="/assets/wall-founder.js?v=20261105fd"></script>
</body>
+1 -1
View File
@@ -120,7 +120,7 @@
<div class="small">Advertising services with a performance referral program. Not an investment product; no income guarantees. Crypto transactions are irreversible. Never share your recovery phrase.</div>
</footer>
</div>
<script src="/assets/common.js?v=20261114nf"></script>
<script src="/assets/common.js?v=20261114ns"></script>
<script src="/assets/wallets.js?v=20261026a"></script>
</body>
</html>
+64
View File
@@ -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/<code>?src=&s1=&s2= lands on the right page with ?ref=<member>; the click counts under the sending site's source;
// a member's own link with ?src=<site> 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);
+3
View File
@@ -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
+1 -1
View File
@@ -66,7 +66,7 @@ function renderPage() {
h += '<h2 style="font-size:24px;margin:10px 0 16px">Release notes</h2>';
h += v.notes.length ? v.notes.map(n => '<article class="note" id="' + esc(n.id) + '"><h2>' + esc(n.title) + n.tags.map(tagChip).join('') + '</h2><p class="when">' + fmt(n.date) + '</p>' + bodyHtml(n.body) + '</article>').join('') : '<p class="muted">No notes yet.</p>';
h += '<p class="muted small" style="margin-top:30px">Suggestions and bug reports: the chat bubble on any page, or the LinkSpin Telegram group.</p>';
h += '</div><script src="/assets/common.js?v=20261114nf"></script><script src="/assets/blog-page.js?v=20260914a"></script></body></html>';
h += '</div><script src="/assets/common.js?v=20261114ns"></script><script src="/assets/blog-page.js?v=20260914a"></script></body></html>';
return h;
}
module.exports = { init, notes, roadmap, saveNote, saveRoadmap, remove, publicView, renderPage, bodyHtml, TAGS, STATUSES };
+16 -2
View File
@@ -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 };
+3 -1
View File
@@ -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) => {
+ '<style>.bp{max-width:560px;text-align:center;padding:40px 16px 60px}.bp img{width:100%;max-width:520px;border-radius:18px;border:1px solid var(--line);box-shadow:0 20px 60px rgba(0,0,0,.45)}.bp h1{font-size:clamp(24px,5vw,34px);margin:22px 0 8px}.bp p{color:var(--muted);max-width:44ch;margin:0 auto 20px}</style></head>'
+ '<body><div class="wrap bp"><img src="' + img + '" alt="' + esc(label) + ' badge for @' + esc(un) + '"><h1>@' + esc(un) + ' unlocked <em>' + label + '</em></h1><p>' + 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.</p>'
+ '<a class="btn" href="/join/' + esc(un) + '">Join @' + esc(un) + '\u2019s line free</a><p class="small" style="margin-top:26px">Advertising with a performance referral program. Not an investment; no income is guaranteed.</p></div>'
+ '<script src="/assets/common.js?v=20261114nf"></script><script src="/assets/blog-page.js?v=20260912a"></script></body></html>';
+ '<script src="/assets/common.js?v=20261114ns"></script><script src="/assets/blog-page.js?v=20260912a"></script></body></html>';
res.writeHead(200, baseHeaders({ 'Content-Type': 'text/html; charset=utf-8', 'Cache-Control': 'public, max-age=300' }));
return res.end(html);
}
+13 -1
View File
@@ -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=<site id> (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 };