LinkSpin tracked links for text ads (Marty 2026-11-15): lstrack.js asks LinkSpin (POST LS_URL/api/partner/vab/links, net.v1 with NETWORK_SSO_SECRET, by network username) for a tracked link on the member's own LinkSpin account when they save their ad; /go/<ad> sends through it while it points at the ad's current link. "Track with LinkSpin" toggle on the ad form (default on), {clickid}/{placement} links not tracked, LinkSpin clicks on My page, counters in admin status. Fails soft (plain link) until LinkSpin ships the endpoint; a 2-minute sweep retries. Smoke 179/179 (17 new LinkSpin checks against a stand-in that starts down).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -13,6 +13,7 @@ Plain Node http server, no framework, the VBB / Downline Banners pattern. Contra
|
||||
- **Delivery** (wire.js + vabnas.js): every verified view of a Boosted ad counts toward its guarantee (oldest Boost first) and is kept as an audit row (`vab_bviews`, 120 days). Boosted ads are starred on the ticker and fill the member pages' Boosted places, furthest-behind first. A Boost not delivered on-site within 30 days is finished through **Network Ad Space as a text ad** (pid 1) for exactly the views still owed; NAS impressions count toward the same guarantee. NAS was chosen over LinkSpin zones because NAS serves text ads natively; LinkSpin zones are banner placements.
|
||||
- **Trust pack** (proof.js): `/ledger` (each Boost with every level paid, its place in the line, who was passed over, delivery), `/contract` (live facts), toasts of real events, one Telegram photo card per Boost (never twice: in-process guard + `docstore.claim`, nothing older than 2 hours), Terms / Earnings Disclaimer / Privacy (TrustClickz, 615 Green Valley Drive, Moody, AL 35004), the network footer from the hub (netsites.js, tracked LinkSpin links, code `nwvab`).
|
||||
- **Promo kit** (promokit.js): `GET /api/promo-kit?u=`, `/promote`, 21 creatives `public/art/kit/vab-{free,spread,boost}-{tile,strip,leader,box,tower,social,square}.png`.
|
||||
- **LinkSpin tracked links** (lstrack.js, 2026-11-15): when a member saves their text ad, LinkSpin makes or updates a tracked link for it on the member's own LinkSpin account (signed `POST LS_URL/api/partner/vab/links`, net.v1 HMAC with NETWORK_SSO_SECRET, by network username, source "ViralAdBlitz", ad id as s1/placement). `/go/<ad>` then sends through that link while it points at the ad's current link; otherwise straight to the member's link. "Track with LinkSpin" toggle on the ad form (default on); links with {clickid}/{placement} are not tracked. Fails soft: LinkSpin down or not shipped = plain link, a sweep retries every 2 minutes (failures back off 10 minutes, no account a day). My page shows the LinkSpin clicks; admin status has the counters. Env: `LS_TRACK=0` turns it off, `LS_TRACK_URL` overrides LS_URL (tests).
|
||||
- **Network ad zones**: 6 LinkSpin zones on Marty's account for viraladblitz.com (made 2026-11-15): `public/assets/common.js` ZONES (footer 728x90 ls-766b4a, phone 320x50 ls-66e157, ledger 468x60 ls-a5c68c, Boost 300x250 ls-754307, My page 468x60 ls-f880d2) and `ZONE_404` ls-c6c515 in server.js. They count as paid views only on viraladblitz.com (not on the staging host).
|
||||
- **Hub report** (hubreport.js): each Boost as contract-bind / contract-spend, contract `viraladblitz`, off unless `HUB_ENABLED=1`.
|
||||
- **Old links**: `/?<old>`, `/splashpg.php?pid=N&r=<old>`, `/lcp.php?pid=N&r=<old>` 301 to `/<network username>` from the oldrefs map (`POST /api/admin/oldrefs`), any other `*.php` to `/`.
|
||||
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
// LinkSpin tracking on member text ads (Marty 2026-11-15, the DownlineHydra module generalized: LinkSpin /api/partner/<site>/links).
|
||||
// When a member saves their text ad, LinkSpin makes (or updates) a tracked link for it on that member's own LinkSpin account (every
|
||||
// hub member has one through join-all), tagged with the account's "ViralAdBlitz" source and the ad id as a sub-id (?s1=<ad>&placement=<ad>),
|
||||
// so LinkSpin Reports show the ad's clicks. The ad's public link (/go/<ad>) then sends to the tracked link, which lands on the member's
|
||||
// own link. Per ad the member can switch tracking off ("Track with LinkSpin", default on): then /go/<ad> sends straight to their link.
|
||||
// Fail soft: if LinkSpin does not answer (or does not know the endpoint yet), the ad works exactly as before with its plain link,
|
||||
// and the sweep tries again later. A tracked link is used only while it points at the ad's current link (an edit never sends
|
||||
// traffic to an old destination). Links with {clickid} / {placement} macros are not tracked (they are filled here on every click).
|
||||
// Account: by network username (ViralAdBlitz never stores emails). The call: POST LS_URL/api/partner/vab/links, X-Net-Ts + X-Net-Sig =
|
||||
// hex HMAC-SHA256('net.v1.' + ts + newline + raw body) with NETWORK_SSO_SECRET (the Downline Banners Banner Spins pattern).
|
||||
// ensureAd(ad) -> updates ad.ls { code, link, url, at } or ad.lsErr / ad.lsTry; saves through the store
|
||||
// clicks(username) -> { <ad id>: { hits, hits30, unique30 } } | null (cached 5 minutes per member)
|
||||
// dest(ad) -> the tracked link when it is current, else null
|
||||
'use strict';
|
||||
const crypto = require('crypto');
|
||||
|
||||
let C = null, store = null; const st = { ensured: 0, failed: 0, noAccount: 0, lastError: null, lastOkAt: 0, sweeps: 0 };
|
||||
const cache = new Map();
|
||||
const MACRO = /\{(clickid|placement)\}|%7B(clickid|placement)%7D/i;
|
||||
const SITE = 'vab';
|
||||
function init(cfg, st0) { C = cfg; store = st0; }
|
||||
const base = () => String(process.env.LS_TRACK_URL || (C && C.lsBase) || '').replace(/\/+$/, '');
|
||||
const on = () => !!(C && process.env.LS_TRACK !== '0' && String(process.env.NETWORK_SSO_SECRET || '').trim().length >= 32 && base());
|
||||
|
||||
async function post(body, ms) {
|
||||
const sec = String(process.env.NETWORK_SSO_SECRET || '').trim();
|
||||
const raw = JSON.stringify(body); const ts = String(Date.now());
|
||||
const sig = crypto.createHmac('sha256', sec).update('net.v1.' + ts + '\n' + raw).digest('hex');
|
||||
const ac = new AbortController(); const t = setTimeout(() => ac.abort(), ms || 8000);
|
||||
try {
|
||||
const r = await fetch(base() + '/api/partner/' + SITE + '/links', { method: 'POST', body: raw, signal: ac.signal, headers: { 'Content-Type': 'application/json', 'X-Net-Ts': ts, 'X-Net-Sig': sig } });
|
||||
const j = await r.json().catch(() => ({})); return r.ok ? j : { error: j.error || 'LinkSpin answered ' + r.status };
|
||||
} catch (e) { return { error: 'LinkSpin did not answer.' }; } finally { clearTimeout(t); }
|
||||
}
|
||||
const ownerName = a => { const m = store.member(a.owner); return m && m.username ? String(m.username) : null; };
|
||||
// what the member sees about tracking for their ad
|
||||
function state(a) {
|
||||
if (!a) return null;
|
||||
if (a.track === false) return 'off';
|
||||
if (MACRO.test(String(a.link || ''))) return 'macros';
|
||||
if (a.ls && a.ls.url === a.link && a.ls.link) return 'tracked';
|
||||
if (!ownerName(a)) return 'no-username';
|
||||
if (a.lsNoAccount && a.lsTry && Date.now() - a.lsTry < 86400000) return 'no-account';
|
||||
return 'pending';
|
||||
}
|
||||
const wants = a => a && a.status !== 'removed' && a.track !== false && !MACRO.test(String(a.link || '')) && !(a.ls && a.ls.url === a.link && a.ls.link) && !!ownerName(a);
|
||||
function dest(a) { return a && a.track !== false && a.ls && a.ls.link && a.ls.url === a.link && !MACRO.test(String(a.link || '')) ? a.ls.link : null; }
|
||||
|
||||
async function ensureAd(a) {
|
||||
if (!on() || !wants(a)) return { skipped: true };
|
||||
const username = ownerName(a);
|
||||
const r = await post({ username, op: 'ensure', links: [{ id: String(a.id), name: a.headline, url: a.link }] });
|
||||
a.lsTry = Date.now();
|
||||
if (r.error) { st.failed++; st.lastError = String(r.error).slice(0, 160); a.lsErr = st.lastError; store.saveAd(a); return r; }
|
||||
if (r.account === false) { st.noAccount++; a.lsNoAccount = true; delete a.lsErr; store.saveAd(a); return r; }
|
||||
const l = r.links && r.links[String(a.id)];
|
||||
if (!l) { st.failed++; a.lsErr = String((r.errors && r.errors[String(a.id)]) || 'no link').slice(0, 160); store.saveAd(a); return r; }
|
||||
a.ls = { code: l.code, link: l.link, url: a.link, at: Date.now() }; delete a.lsErr; delete a.lsNoAccount;
|
||||
st.ensured++; st.lastOkAt = Date.now(); cache.delete(username.toLowerCase()); store.saveAd(a);
|
||||
return { ok: true, link: l.link };
|
||||
}
|
||||
// the retry sweep: ads that want a tracked link and have not been tried lately (failures back off 10 minutes, no account a day)
|
||||
async function sweep(max) {
|
||||
if (!on()) return 0; st.sweeps++; let n = 0;
|
||||
const backoff = Number(process.env.LS_RETRY_MS || 600000);
|
||||
for (const a of store.liveAds()) {
|
||||
if (n >= (max || 25)) break;
|
||||
if (!wants(a)) continue;
|
||||
if (a.lsTry && Date.now() - a.lsTry < (a.lsNoAccount ? 86400000 : backoff)) continue;
|
||||
n++; const r = await ensureAd(a).catch(() => ({ error: 'x' }));
|
||||
if (r && r.error === 'LinkSpin did not answer.') break; // LinkSpin is down: stop this round
|
||||
}
|
||||
return n;
|
||||
}
|
||||
async function clicks(username) {
|
||||
if (!on() || !username) return null;
|
||||
const k = String(username).toLowerCase();
|
||||
const hit = cache.get(k); if (hit && Date.now() - hit.at < Number(process.env.LS_CACHE_MS || 300000)) return hit.v;
|
||||
const r = await post({ username, op: 'stats' }, 3000);
|
||||
const v = r.error || r.account === false ? null : (r.stats || {});
|
||||
cache.set(k, { at: Date.now(), v }); if (cache.size > 20000) cache.clear();
|
||||
return v;
|
||||
}
|
||||
function view() { return Object.assign({ on: on(), base: base() }, st); }
|
||||
module.exports = { init, ensureAd, sweep, clicks, dest, state, view, on, _reset: () => cache.clear() };
|
||||
+2
-2
@@ -22,7 +22,7 @@
|
||||
<link rel="icon" type="image/svg+xml" href="/art/mark.svg"><link rel="icon" type="image/png" href="/art/icon-192.png"><link rel="apple-touch-icon" href="/art/icon-192.png">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Barlow+Condensed:ital,wght@1,700;1,800&family=Chakra+Petch:wght@500;600;700&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@500;700&display=swap">
|
||||
<link rel="stylesheet" href="/assets/vab.css?v=4">
|
||||
<link rel="stylesheet" href="/assets/vab.css?v=5">
|
||||
</head>
|
||||
<body>
|
||||
<main class="wrap">
|
||||
@@ -36,6 +36,6 @@
|
||||
<div id="status" class="note" hidden></div>
|
||||
</main>
|
||||
<script src="/assets/common.js?v=5"></script>
|
||||
<script src="/assets/admin.js?v=4"></script>
|
||||
<script src="/assets/admin.js?v=5"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+15
-2
@@ -24,6 +24,18 @@
|
||||
const vlink = tx => '<a href="' + esc(ex) + '/tx/' + esc(tx) + '" target="_blank" rel="noopener">verify</a>';
|
||||
const stat = (label, val, note, cls) => '<div class="stat' + (cls ? ' ' + cls : '') + '"><span>' + label + '</span><b>' + val + '</b>' + (note ? '<em>' + note + '</em>' : '') + '</div>';
|
||||
let counted = false;
|
||||
// LinkSpin tracking of the ad (server lstrack.js): the tracked link and its clicks as LinkSpin counts them, or why there is none
|
||||
const lsLine = ls => {
|
||||
if (!ls || !ls.on) return '';
|
||||
const why = { off: 'Tracking is off for this ad: visitors go straight to your link.', macros: 'Your link has {clickid} or {placement} codes, so it goes out as it is (not through LinkSpin).',
|
||||
pending: 'Your LinkSpin tracked link is being set up. Until then visitors go straight to your link.', 'no-username': 'Sign in through InstantAdPay or LinkSpin once to link your LinkSpin account.',
|
||||
'no-account': 'No LinkSpin account was found for your network username yet. Visitors go straight to your link.' }[ls.state];
|
||||
if (ls.state !== 'tracked') return '<p class="lsline small">' + esc(why || '') + '</p>';
|
||||
const c = ls.clicks;
|
||||
return '<p class="lsline small">Tracked with LinkSpin: <b>' + esc(ls.link.replace(/^https?:\/\//, '').replace(/\?.*$/, '')) + '</b>'
|
||||
+ (c ? ' · ' + VAB.n(c.hits) + ' clicks in all, ' + VAB.n(c.hits30) + ' in 30 days (' + VAB.n(c.unique30) + ' unique)' : ' · clicks show in your LinkSpin Reports')
|
||||
+ ' · <a href="https://linkspin.app/ads" target="_blank" rel="noopener">Open LinkSpin</a></p>';
|
||||
};
|
||||
async function load() {
|
||||
const d = await VAB.getJSON('/api/my'); if (d.error) { VAB.status(d.error, 'err'); return; }
|
||||
$('dash').hidden = false;
|
||||
@@ -52,6 +64,7 @@
|
||||
// my text ad: badges, preview, the form (folded behind "Edit ad" once the ad exists)
|
||||
$('adBadges').innerHTML = a ? (a.status === 'live' ? '<span class="chip live">LIVE</span>' : '<span class="chip idle">' + esc(a.status.toUpperCase()) + '</span>') + (active.length ? ' <span class="chip gold">★ BOOSTED</span>' : '') : '';
|
||||
$('adPrev').innerHTML = a ? '<div class="adprev' + (active.length ? ' star' : '') + '">' + (active.length ? '<span class="tag">★ BOOSTED</span>' : '') + '<b>' + esc(a.headline) + '</b><span>' + esc(a.line1) + '</span>' + (a.line2 ? '<span>' + esc(a.line2) + '</span>' : '') + '<a href="' + esc(a.link) + '" target="_blank" rel="noopener nofollow">' + esc(a.link.replace(/^https?:\/\//, '').slice(0, 60)) + '</a></div>'
|
||||
+ lsLine(d.linkspin)
|
||||
+ '<div class="row" style="margin-top:14px"><button type="button" class="btn-line" id="editAd">Edit ad</button>' + (d.page ? '<a class="btn-soft" href="' + esc(d.page) + '" target="_blank" rel="noopener">Preview my page</a>' : '') + '</div>' : '';
|
||||
if (!d.netVerified) {
|
||||
$('adNote').innerHTML = 'Text ads are free for network members. This wallet is not in the network yet: <a href="' + esc(d.joinUrl) + '" target="_blank" rel="noopener">join InstantAdPay free</a>, link this wallet there, then sign in here through InstantAdPay.';
|
||||
@@ -59,7 +72,7 @@
|
||||
} else {
|
||||
$('adForm').hidden = !!a; $('adNote').hidden = !!a;
|
||||
if ($('editAd')) $('editAd').onclick = () => { const h = !$('adForm').hidden; $('adForm').hidden = h; $('adNote').hidden = h; $('editAd').textContent = h ? 'Edit ad' : 'Close the editor'; if (!h) $('fHead').focus(); };
|
||||
if (a) { $('adHead').textContent = 'My text ad'; $('fHead').value = a.headline; $('fL1').value = a.line1; $('fL2').value = a.line2 || ''; $('fLink').value = a.link; $('adSave').textContent = 'Save changes'; }
|
||||
if (a) { $('adHead').textContent = 'My text ad'; $('fHead').value = a.headline; $('fL1').value = a.line1; $('fL2').value = a.line2 || ''; $('fLink').value = a.link; $('fTrack').checked = a.track !== false; $('adSave').textContent = 'Save changes'; }
|
||||
if (!counted) { counter($('fHead'), $('cHead'), lim.headline); counter($('fL1'), $('cL1'), lim.line); counter($('fL2'), $('cL2'), lim.line); counted = true; }
|
||||
else ['fHead', 'fL1', 'fL2'].forEach(id => $(id).dispatchEvent(new Event('input')));
|
||||
}
|
||||
@@ -92,7 +105,7 @@
|
||||
}
|
||||
$('adForm').addEventListener('submit', async e => {
|
||||
e.preventDefault(); $('adSave').disabled = true; VAB.status('Checking your link...');
|
||||
const r = await VAB.post('/api/my/ad', { headline: $('fHead').value, line1: $('fL1').value, line2: $('fL2').value, link: $('fLink').value });
|
||||
const r = await VAB.post('/api/my/ad', { headline: $('fHead').value, line1: $('fL1').value, line2: $('fL2').value, link: $('fLink').value, track: $('fTrack').checked });
|
||||
$('adSave').disabled = false;
|
||||
if (r.error) return VAB.status(r.error, 'err');
|
||||
VAB.status(r.created ? 'Posted. Your ad is live on your page and on your team\'s pages.' : 'Saved. Your ad shows the new text everywhere.', 'ok');
|
||||
|
||||
@@ -261,6 +261,8 @@ table.facts td{padding:12px 8px;border-bottom:1px solid var(--line2);overflow-wr
|
||||
label.f{display:flex;flex-direction:column;gap:6px;font:600 13px var(--body);color:var(--ink2)}
|
||||
.f input,.f textarea{background:#fff;border:2px solid var(--line);color:var(--ink);font:16px var(--body);padding:11px 12px;width:100%;border-radius:0}
|
||||
.f input:focus,.f textarea:focus{outline:none;border-color:var(--blue)}
|
||||
.chk{display:flex;gap:10px;align-items:flex-start;cursor:pointer}.chk input{width:20px;height:20px;margin:3px 0 0;flex:none;accent-color:var(--blue)}
|
||||
.lsline{margin:12px 0 0;padding:10px 12px;border:2px dashed var(--line);font-size:14px;overflow-wrap:anywhere}.lsline b{font-family:var(--mono,monospace)}
|
||||
.f .cnt{align-self:flex-end;font:12px var(--mono);color:var(--sub)}
|
||||
.form{display:flex;flex-direction:column;gap:14px;max-width:720px}
|
||||
.note{border-left:4px solid var(--blue);background:var(--card);padding:12px 16px;color:var(--ink2);overflow-wrap:anywhere}
|
||||
|
||||
+4
-4
@@ -22,7 +22,7 @@
|
||||
<link rel="icon" type="image/svg+xml" href="/art/mark.svg"><link rel="icon" type="image/png" href="/art/icon-192.png"><link rel="apple-touch-icon" href="/art/icon-192.png">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Barlow+Condensed:ital,wght@1,700;1,800&family=Chakra+Petch:wght@500;600;700&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@500;700&display=swap">
|
||||
<link rel="stylesheet" href="/assets/vab.css?v=4">
|
||||
<link rel="stylesheet" href="/assets/vab.css?v=5">
|
||||
</head>
|
||||
<body>
|
||||
<main class="wrap">
|
||||
@@ -68,8 +68,8 @@
|
||||
<div id="status" class="note" hidden></div>
|
||||
</main>
|
||||
<script src="/assets/common.js?v=5"></script>
|
||||
<script src="/assets/wallet.js?v=4"></script>
|
||||
<script src="/assets/buy.js?v=4"></script>
|
||||
<script src="/assets/boost.js?v=4"></script>
|
||||
<script src="/assets/wallet.js?v=5"></script>
|
||||
<script src="/assets/buy.js?v=5"></script>
|
||||
<script src="/assets/boost.js?v=5"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
<link rel="icon" type="image/svg+xml" href="/art/mark.svg"><link rel="icon" type="image/png" href="/art/icon-192.png"><link rel="apple-touch-icon" href="/art/icon-192.png">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Barlow+Condensed:ital,wght@1,700;1,800&family=Chakra+Petch:wght@500;600;700&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@500;700&display=swap">
|
||||
<link rel="stylesheet" href="/assets/vab.css?v=4">
|
||||
<link rel="stylesheet" href="/assets/vab.css?v=5">
|
||||
</head>
|
||||
<body>
|
||||
<main class="wrap">
|
||||
@@ -45,6 +45,6 @@
|
||||
<div id="status" class="note" hidden></div>
|
||||
</main>
|
||||
<script src="/assets/common.js?v=5"></script>
|
||||
<script src="/assets/contract.js?v=4"></script>
|
||||
<script src="/assets/contract.js?v=5"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
<link rel="icon" type="image/svg+xml" href="/art/mark.svg"><link rel="icon" type="image/png" href="/art/icon-192.png"><link rel="apple-touch-icon" href="/art/icon-192.png">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Barlow+Condensed:ital,wght@1,700;1,800&family=Chakra+Petch:wght@500;600;700&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@500;700&display=swap">
|
||||
<link rel="stylesheet" href="/assets/vab.css?v=4">
|
||||
<link rel="stylesheet" href="/assets/vab.css?v=5">
|
||||
</head>
|
||||
<body>
|
||||
<main class="wrap legal">
|
||||
@@ -34,6 +34,6 @@
|
||||
<div class="card"><h2>Who to ask</h2><p>TrustClickz, 615 Green Valley Drive, Moody, AL 35004. <a href="https://instantadpay.com/support" target="_blank" rel="noopener">Network support</a>.</p></div>
|
||||
</main>
|
||||
<script src="/assets/common.js?v=5"></script>
|
||||
<script src="/assets/static.js?v=4"></script>
|
||||
<script src="/assets/static.js?v=5"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+2
-2
@@ -23,7 +23,7 @@
|
||||
<link rel="icon" type="image/svg+xml" href="/art/mark.svg"><link rel="icon" type="image/png" href="/art/icon-192.png"><link rel="apple-touch-icon" href="/art/icon-192.png">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Barlow+Condensed:ital,wght@1,700;1,800&family=Chakra+Petch:wght@500;600;700&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@500;700&display=swap">
|
||||
<link rel="stylesheet" href="/assets/vab.css?v=4">
|
||||
<link rel="stylesheet" href="/assets/vab.css?v=5">
|
||||
</head>
|
||||
<body>
|
||||
<main class="wrap">
|
||||
@@ -95,6 +95,6 @@
|
||||
<div id="status" class="note" hidden></div>
|
||||
</main>
|
||||
<script src="/assets/common.js?v=5"></script>
|
||||
<script src="/assets/front.js?v=4"></script>
|
||||
<script src="/assets/front.js?v=5"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+2
-2
@@ -22,7 +22,7 @@
|
||||
<link rel="icon" type="image/svg+xml" href="/art/mark.svg"><link rel="icon" type="image/png" href="/art/icon-192.png"><link rel="apple-touch-icon" href="/art/icon-192.png">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Barlow+Condensed:ital,wght@1,700;1,800&family=Chakra+Petch:wght@500;600;700&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@500;700&display=swap">
|
||||
<link rel="stylesheet" href="/assets/vab.css?v=4">
|
||||
<link rel="stylesheet" href="/assets/vab.css?v=5">
|
||||
</head>
|
||||
<body>
|
||||
<main class="wrap">
|
||||
@@ -35,6 +35,6 @@
|
||||
<div id="status" class="note" hidden></div>
|
||||
</main>
|
||||
<script src="/assets/common.js?v=5"></script>
|
||||
<script src="/assets/ledger.js?v=4"></script>
|
||||
<script src="/assets/ledger.js?v=5"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+2
-2
@@ -22,7 +22,7 @@
|
||||
<link rel="icon" type="image/svg+xml" href="/art/mark.svg"><link rel="icon" type="image/png" href="/art/icon-192.png"><link rel="apple-touch-icon" href="/art/icon-192.png">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Barlow+Condensed:ital,wght@1,700;1,800&family=Chakra+Petch:wght@500;600;700&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@500;700&display=swap">
|
||||
<link rel="stylesheet" href="/assets/vab.css?v=4">
|
||||
<link rel="stylesheet" href="/assets/vab.css?v=5">
|
||||
</head>
|
||||
<body>
|
||||
<main class="wrap">
|
||||
@@ -43,6 +43,6 @@
|
||||
<div id="status" class="note" hidden></div>
|
||||
</main>
|
||||
<script src="/assets/common.js?v=5"></script>
|
||||
<script src="/assets/member.js?v=4"></script>
|
||||
<script src="/assets/member.js?v=5"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+4
-3
@@ -22,7 +22,7 @@
|
||||
<link rel="icon" type="image/svg+xml" href="/art/mark.svg"><link rel="icon" type="image/png" href="/art/icon-192.png"><link rel="apple-touch-icon" href="/art/icon-192.png">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Barlow+Condensed:ital,wght@1,700;1,800&family=Chakra+Petch:wght@500;600;700&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@500;700&display=swap">
|
||||
<link rel="stylesheet" href="/assets/vab.css?v=4">
|
||||
<link rel="stylesheet" href="/assets/vab.css?v=5">
|
||||
</head>
|
||||
<body>
|
||||
<main class="wrap">
|
||||
@@ -66,6 +66,7 @@
|
||||
<label class="f">First line <input id="fL1" maxlength="90" autocomplete="off" required><span class="cnt" id="cL1"></span></label>
|
||||
<label class="f">Second line (optional) <input id="fL2" maxlength="90" autocomplete="off"><span class="cnt" id="cL2"></span></label>
|
||||
<label class="f">Your link <input id="fLink" maxlength="600" autocomplete="off" inputmode="url" placeholder="https://" required></label>
|
||||
<label class="chk"><input type="checkbox" id="fTrack" checked> <span><b>Track with LinkSpin</b><br><span class="small muted">Your ad link goes out as a tracked link on your own LinkSpin account, so LinkSpin Reports show its clicks. Visitors still land on your link. Untick it for programs that refuse redirected traffic.</span></span></label>
|
||||
<div class="row" style="margin:0"><button class="btn-red" id="adSave" type="submit">Post my free text ad</button><span class="small muted">Tracking codes work: {clickid} and {placement} are filled on every click.</span></div>
|
||||
</form>
|
||||
</section>
|
||||
@@ -84,7 +85,7 @@
|
||||
<div id="status" class="note" hidden></div>
|
||||
</main>
|
||||
<script src="/assets/common.js?v=5"></script>
|
||||
<script src="/assets/wallet.js?v=4"></script>
|
||||
<script src="/assets/my.js?v=4"></script>
|
||||
<script src="/assets/wallet.js?v=5"></script>
|
||||
<script src="/assets/my.js?v=5"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+2
-2
@@ -22,7 +22,7 @@
|
||||
<link rel="icon" type="image/svg+xml" href="/art/mark.svg"><link rel="icon" type="image/png" href="/art/icon-192.png"><link rel="apple-touch-icon" href="/art/icon-192.png">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Barlow+Condensed:ital,wght@1,700;1,800&family=Chakra+Petch:wght@500;600;700&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@500;700&display=swap">
|
||||
<link rel="stylesheet" href="/assets/vab.css?v=4">
|
||||
<link rel="stylesheet" href="/assets/vab.css?v=5">
|
||||
</head>
|
||||
<body>
|
||||
<main class="wrap legal">
|
||||
@@ -35,6 +35,6 @@
|
||||
<div class="card"><h2>Contact</h2><p>Questions, problems or a request about your data: <a href="https://instantadpay.com/support" target="_blank" rel="noopener">network support</a>, or write to TrustClickz, 615 Green Valley Drive, Moody, AL 35004.</p></div>
|
||||
</main>
|
||||
<script src="/assets/common.js?v=5"></script>
|
||||
<script src="/assets/static.js?v=4"></script>
|
||||
<script src="/assets/static.js?v=5"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+3
-3
@@ -22,7 +22,7 @@
|
||||
<link rel="icon" type="image/svg+xml" href="/art/mark.svg"><link rel="icon" type="image/png" href="/art/icon-192.png"><link rel="apple-touch-icon" href="/art/icon-192.png">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Barlow+Condensed:ital,wght@1,700;1,800&family=Chakra+Petch:wght@500;600;700&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@500;700&display=swap">
|
||||
<link rel="stylesheet" href="/assets/vab.css?v=4">
|
||||
<link rel="stylesheet" href="/assets/vab.css?v=5">
|
||||
</head>
|
||||
<body>
|
||||
<main class="wrap">
|
||||
@@ -34,7 +34,7 @@
|
||||
<div id="kit" style="display:flex;flex-direction:column;gap:16px"><p class="muted">Loading the kit...</p></div>
|
||||
</main>
|
||||
<script src="/assets/common.js?v=5"></script>
|
||||
<script src="/assets/kitpage.js?v=4"></script>
|
||||
<script src="/assets/promote.js?v=4"></script>
|
||||
<script src="/assets/kitpage.js?v=5"></script>
|
||||
<script src="/assets/promote.js?v=5"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+2
-2
@@ -22,7 +22,7 @@
|
||||
<link rel="icon" type="image/svg+xml" href="/art/mark.svg"><link rel="icon" type="image/png" href="/art/icon-192.png"><link rel="apple-touch-icon" href="/art/icon-192.png">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Barlow+Condensed:ital,wght@1,700;1,800&family=Chakra+Petch:wght@500;600;700&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@500;700&display=swap">
|
||||
<link rel="stylesheet" href="/assets/vab.css?v=4">
|
||||
<link rel="stylesheet" href="/assets/vab.css?v=5">
|
||||
</head>
|
||||
<body>
|
||||
<main class="wrap legal">
|
||||
@@ -43,6 +43,6 @@
|
||||
<div class="card"><h2>Contact</h2><p>Questions, problems or a request about your data: <a href="https://instantadpay.com/support" target="_blank" rel="noopener">network support</a>, or write to TrustClickz, 615 Green Valley Drive, Moody, AL 35004.</p></div>
|
||||
</main>
|
||||
<script src="/assets/common.js?v=5"></script>
|
||||
<script src="/assets/static.js?v=4"></script>
|
||||
<script src="/assets/static.js?v=5"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -108,11 +108,27 @@ function chainBoost(o) {
|
||||
const TG = []; const TG_PORT = PORT + 4;
|
||||
listen(TG_PORT, async (q, r, b) => { TG.push({ method: q.url.split('/').pop(), token: q.url.split('/')[1], body: JSON.parse(b || '{}') }); r.setHeader('Content-Type', 'application/json'); r.end('{"ok":true,"result":{}}'); });
|
||||
|
||||
// ---- stand-in LinkSpin partner endpoint /api/partner/vab/links (net.v1 signature). Starts DOWN (404, as before LinkSpin ships it). ----
|
||||
const LS = { up: false, calls: [], badSig: 0, links: new Map(), known: new Set(['one', 'owner', 'four', 'five', 'six', 'seven', 'topdog', 'downline']), stats: {} }; const LS_PORT = PORT + 5;
|
||||
listen(LS_PORT, async (q, r, b) => {
|
||||
r.setHeader('Content-Type', 'application/json');
|
||||
if (!LS.up || q.url !== '/api/partner/vab/links') { r.statusCode = 404; return r.end('{"error":"Not found"}'); }
|
||||
const want = crypto.createHmac('sha256', SSO_SECRET).update('net.v1.' + q.headers['x-net-ts'] + '\n' + b).digest('hex');
|
||||
if (q.headers['x-net-sig'] !== want) { LS.badSig++; r.statusCode = 401; return r.end('{"error":"unauthorized"}'); }
|
||||
const j = JSON.parse(b || '{}'); LS.calls.push(j);
|
||||
if (!LS.known.has(String(j.username || '').toLowerCase())) return r.end('{"account":false}');
|
||||
if (j.op === 'stats') return r.end(JSON.stringify({ account: true, stats: LS.stats[j.username] || {} }));
|
||||
const links = {};
|
||||
for (const x of j.links || []) { const k = j.username + ':' + x.id; let l = LS.links.get(k); if (!l) { l = { code: crypto.randomBytes(3).toString('hex'), url: x.url }; LS.links.set(k, l); } l.url = x.url; links[x.id] = { code: l.code, link: 'https://spin.test/r/' + l.code + '?s1=' + x.id + '&placement=' + x.id, created: false }; }
|
||||
r.end(JSON.stringify({ account: true, username: j.username, host: 'spin.test', links, errors: {} }));
|
||||
});
|
||||
|
||||
const ENV = Object.assign({}, process.env, { PORT: String(PORT), DATA_DIR: DATA, ADMIN_TOKEN: ADMIN, NODE_ENV: 'development', DOCSTORE_URL: '',
|
||||
VISIT_SECONDS: '2', VISITS_PER_IP_DAY: '2', LINK_PROBE: '0', NETWORK_LOOKUP_URL: 'http://127.0.0.1:' + LOOKUP_PORT + '/api/network/member',
|
||||
NETWORK_SSO_SECRET: SSO_SECRET, IAP_URL: 'https://iap.invalid', LS_URL: 'https://ls.invalid', NETWORK_SITES_HUB: '0',
|
||||
CONTRACT_ADDRESS: SHOP, CHAIN_RPC: 'http://127.0.0.1:' + CHAIN_PORT, KEEPER_KEY: KEEPER_PK, SHOP_START_BLOCK: '1', SHOP_CONFIRMATIONS: '0', SHOP_POLL_MS: '200', EXPLORER: 'https://explorer.invalid',
|
||||
HUB_ENABLED: '1', HUB_URL: 'http://127.0.0.1:' + HUB_PORT, HUB_SECRET, HUB_SITE: 'viraladblitz', HUB_TICK_MS: '300', HUB_DOWN_MS: '300', HUB_CACHE_MS: '200',
|
||||
LS_TRACK_URL: 'http://127.0.0.1:' + LS_PORT, LS_SWEEP_FIRST_MS: '300', LS_SWEEP_MS: '300', LS_RETRY_MS: '300', LS_CACHE_MS: '100',
|
||||
TG_TOKEN: 'standin-token', TG_CHAT: '-100123', TG_PAY_TOPIC: '632242', TG_API: 'http://127.0.0.1:' + TG_PORT });
|
||||
process.on('exit', () => { try { srv && srv.kill(); } catch (e) {} });
|
||||
|
||||
@@ -385,9 +401,44 @@ const mtop = await anon.json('/api/wire?page=member&u=topdog');
|
||||
const rm = await anon.json('/api/admin/ad', { id: (await M[7].json('/api/my')).ad.id, status: 'removed', note: 'smoke' }, { 'x-admin-token': ADMIN }); ok(rm.ok, 'admin removes an ad');
|
||||
mp = await anon.json('/api/wire?page=member&u=owner'); ok(!mp.page.line.some(x => x.owner === '@seven') && mp.page.line.some(x => x.owner === '@topdog'), 'a removed ad leaves the member pages; the next one up (place 8) moves in', mp.page.line.map(x => [x.level, x.owner]));
|
||||
|
||||
console.log('14b. LinkSpin tracked links for text ads (lstrack.js)');
|
||||
my = await M1.json('/api/my'); ok(my.ad.status === 'live' && my.linkspin && my.linkspin.on && my.linkspin.state === 'pending' && my.linkspin.track === true, 'LinkSpin not answering the endpoint yet: the ad is live, tracking pending (fails soft)', my.linkspin);
|
||||
r = await anon.req('/go/' + ad1 + '?p=ticker'); ok(new URL(r.headers.get('location')).hostname === 'member-1.example-shop.com', 'while LinkSpin is down /go/<ad> sends to the member\'s own link', r.headers.get('location'));
|
||||
LS.up = true; await sleep(1500);
|
||||
my = await M1.json('/api/my'); const lsLink = my.linkspin && my.linkspin.link;
|
||||
ok(my.linkspin.state === 'tracked' && lsLink === 'https://spin.test/r/' + (LS.links.get('one:' + ad1) || {}).code + '?s1=' + ad1 + '&placement=' + ad1, 'LinkSpin up: the retry sweep makes the tracked link on the member\'s own account', my.linkspin);
|
||||
const ec = LS.calls.find(c => c.op === 'ensure' && c.username === 'one');
|
||||
ok(ec && ec.links.length === 1 && ec.links[0].id === String(ad1) && ec.links[0].url === my.ad.link && !ec.email && LS.badSig === 0, 'the call: signed net.v1, network username, ad id as the item id, the ad link as destination (no email sent)', ec);
|
||||
const clicksBefore = my.ad.clicks;
|
||||
r = await anon.req('/go/' + ad1 + '?p=ticker'); ok(r.status === 302 && r.headers.get('location') === lsLink, '/go/<ad> now sends through the LinkSpin tracked link', r.headers.get('location'));
|
||||
my = await M1.json('/api/my'); ok(my.ad.clicks === clicksBefore + 1, 'the click still counts here too');
|
||||
{ const a5 = (await M[5].json('/api/my')); ok(a5.linkspin.state === 'macros' && !LS.calls.some(c => c.username === 'five'), 'an ad link with {clickid}/{placement} is not sent to LinkSpin (macros are filled here)', a5.linkspin); }
|
||||
LS.stats.one = { [ad1]: { hits: 7, hits30: 3, unique30: 2 } }; await sleep(150);
|
||||
my = await M1.json('/api/my'); ok(my.linkspin.clicks && my.linkspin.clicks.hits === 7 && my.linkspin.clicks.hits30 === 3 && my.linkspin.clicks.unique30 === 2, 'My page shows the ad\'s clicks as LinkSpin counts them', my.linkspin);
|
||||
const code1 = (LS.links.get('one:' + ad1) || {}).code;
|
||||
pa = await M1.json('/api/my/ad', adBody(1, { link: 'https://member-1.example-shop.com/new-offer' }));
|
||||
ok(pa.ok && pa.linkspin === 'tracked' && LS.links.get('one:' + ad1).url === 'https://member-1.example-shop.com/new-offer' && LS.links.get('one:' + ad1).code === code1, 'editing the ad link updates the same LinkSpin link right away', pa);
|
||||
LS.up = false;
|
||||
pa = await M1.json('/api/my/ad', adBody(1, { link: 'https://member-1.example-shop.com/third' }));
|
||||
r = await anon.req('/go/' + ad1); ok(pa.ok && pa.linkspin === 'pending' && r.headers.get('location') === 'https://member-1.example-shop.com/third', 'edited while LinkSpin is down: saved, and /go/<ad> never sends to the old tracked destination', [pa, r.headers.get('location')]);
|
||||
LS.up = true; const n0 = LS.calls.length;
|
||||
pa = await M1.json('/api/my/ad', adBody(1, { link: 'https://member-1.example-shop.com/third', track: false }));
|
||||
r = await anon.req('/go/' + ad1); my = await M1.json('/api/my');
|
||||
ok(pa.ok && pa.linkspin === 'off' && my.ad.track === false && my.linkspin.state === 'off' && r.headers.get('location') === 'https://member-1.example-shop.com/third', '"Track with LinkSpin" off: /go/<ad> sends straight to the link', [pa, my.linkspin]);
|
||||
await sleep(900); ok(!LS.calls.slice(n0).some(c => c.op === 'ensure' && c.username === 'one'), 'tracking off: the sweep leaves that ad alone');
|
||||
pa = await M1.json('/api/my/ad', adBody(1, { link: 'https://member-1.example-shop.com/third' }));
|
||||
ok(pa.linkspin === 'off', 'an edit without the toggle keeps tracking off', pa);
|
||||
pa = await M1.json('/api/my/ad', adBody(1, { link: 'https://member-1.example-shop.com/third', track: true }));
|
||||
r = await anon.req('/go/' + ad1); ok(pa.linkspin === 'tracked' && r.headers.get('location').startsWith('https://spin.test/r/' + code1), 'switched back on: tracked again, same LinkSpin code', [pa, r.headers.get('location')]);
|
||||
{ const NL = await walletMember({ hub: { username: 'nolsacct', sponsorId: idOwner } }); const q2 = await NL.json('/api/my/ad', adBody('nl')); const m2 = await NL.json('/api/my');
|
||||
ok(q2.ok && q2.linkspin === 'no-account' && m2.linkspin.state === 'no-account', 'no LinkSpin account for the username: the ad works with its own link', m2.linkspin); }
|
||||
{ const s2 = await anon.json('/api/admin/status', undefined, { 'x-admin-token': ADMIN }); ok(s2.linkspin && s2.linkspin.on === true && s2.linkspin.ensured >= 3 && s2.linkspin.failed >= 1 && !JSON.stringify(s2.linkspin).includes(SSO_SECRET), 'admin status: LinkSpin tracking counters, no secret', s2.linkspin); }
|
||||
|
||||
await sleep(1000); // the store writes 800 ms after a change; a Windows kill has no SIGINT flush
|
||||
console.log('15. restart');
|
||||
await stop(); await boot(); await sleep(500);
|
||||
my = await OWN.json('/api/my'); ok(my.ad && my.ad.id === OWNAD && my.boosts[0].delivered === 6, 'after a restart: ads, Boosts and delivery are kept', my.boosts);
|
||||
r = await anon.req('/go/' + ad1); ok(r.headers.get('location').startsWith('https://spin.test/r/'), 'after a restart: the tracked link is kept', r.headers.get('location'));
|
||||
led = await anon.json('/api/ledger'); ok(led.items.length === 2 && TG.length === 1, 'after a restart: no re-record, no repost');
|
||||
const again = await view(client({ ip: shared, ua: 'Mozilla/5.0 SharedBrowser/9' }), 'front'); ok(!again.r.verified && again.r.why === 'ip', 'after a restart: the per-connection cap still holds (rebuilt from the visit rows)', again.r);
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ const hubline = require('./hubline');
|
||||
const proof = require('./proof');
|
||||
const netsites = require('./netsites');
|
||||
const vabnas = require('./vabnas');
|
||||
const lstrack = require('./lstrack');
|
||||
|
||||
const PUB = path.join(__dirname, 'public');
|
||||
const ADDR_RE = /^0x[0-9a-fA-F]{40}$/;
|
||||
@@ -241,7 +242,7 @@ const server = http.createServer(async (req, res) => {
|
||||
const a = store.ad(gm[1]); if (!a || a.status === 'removed') { res.writeHead(302, { Location: '/' }); return res.end(); }
|
||||
const pl = String(u.searchParams.get('p') || '').slice(0, 20);
|
||||
if (!isBot(req) && !limited(req, 'click', 600, 3600000)) { const vk = visitorKey(req); const s = session(req); wire.click(a, vk, wire.vtokenOk(vk, u.searchParams.get('v')), s ? s.address : null, pl); }
|
||||
res.writeHead(302, { Location: clickLink(a, pl), 'Cache-Control': 'no-store', 'Referrer-Policy': 'origin' }); return res.end();
|
||||
res.writeHead(302, { Location: lstrack.dest(a) || clickLink(a, pl), 'Cache-Control': 'no-store', 'Referrer-Policy': 'origin' }); return res.end(); // the member's LinkSpin tracked link when it is current (lstrack.js), else their own link
|
||||
}
|
||||
// a member page: viraladblitz.com/<network username>
|
||||
const pm = PAGE_RE.exec(p);
|
||||
@@ -350,7 +351,10 @@ const server = http.createServer(async (req, res) => {
|
||||
const a = store.adOf(me); const lo = netVerified(m) ? await hubline.lineOf({ wallet: me }, C.lineSearch) : { ok: true, line: [] };
|
||||
const line = []; for (const x of lo.line) { if (line.length >= C.levels) break; const la = x.wallet ? store.adOf(x.wallet) : null; line.push({ depth: x.depth, username: x.username, hasWallet: !!x.wallet, hasAd: !!(la && la.status === 'live') }); }
|
||||
const page = m.username ? 'https://' + C.site + '/' + encodeURIComponent(m.username) : null;
|
||||
return json(res, 200, { address: me, username: m.username, netVerified: netVerified(m), ad: a ? { id: a.id, headline: a.headline, line1: a.line1, line2: a.line2, link: a.link, status: a.status, views: a.views || 0, clicks: a.clicks || 0, vclicks: a.vclicks || 0, createdAt: a.createdAt } : null,
|
||||
let ls = null; // LinkSpin tracking of the ad (lstrack.js): state, the tracked link, its clicks as LinkSpin counts them
|
||||
if (a) { const stt = lstrack.state(a); ls = { on: lstrack.on(), track: a.track !== false, state: stt, link: stt === 'tracked' ? a.ls.link : null, clicks: null };
|
||||
if (stt === 'tracked' && m.username) { const cs = await lstrack.clicks(m.username).catch(() => null); if (cs && cs[String(a.id)]) { const c0 = cs[String(a.id)]; ls.clicks = { hits: c0.hits || 0, hits30: c0.hits30 || 0, unique30: c0.unique30 || 0 }; } } }
|
||||
return json(res, 200, { address: me, username: m.username, netVerified: netVerified(m), ad: a ? { id: a.id, headline: a.headline, line1: a.line1, line2: a.line2, link: a.link, status: a.status, views: a.views || 0, clicks: a.clicks || 0, vclicks: a.vclicks || 0, createdAt: a.createdAt, track: a.track !== false } : null, linkspin: ls,
|
||||
boosts: wire.purchases().filter(b => b.buyer === me).sort((x, y) => (y.at || 0) - (x.at || 0)).map(wire.boostView), earned: myEarned(me), line: line.slice(0, 8), lineOk: lo.ok,
|
||||
page, joinUrl: joinUrl(''), boost: C.boost });
|
||||
}
|
||||
@@ -367,10 +371,14 @@ const server = http.createServer(async (req, res) => {
|
||||
const lk = safety.checkLink(b.link, 'Your link'); if (lk.error) return json(res, 400, lk);
|
||||
const cur = store.adOf(me);
|
||||
if (C.linkProbe && (!cur || cur.link !== lk.url)) { const pr = await safety.probeLink(lk.url, { frames: false }); if (pr.error) return json(res, 400, pr); }
|
||||
if (cur) { Object.assign(cur, { headline, line1, line2, link: lk.url, status: cur.status === 'paused' ? 'paused' : 'live' }); store.saveAd(cur); return json(res, 200, { ok: true, ad: { id: cur.id }, created: false }); }
|
||||
const a = store.addAd({ owner: me, headline, line1, line2, link: lk.url, status: 'live', views: 0, clicks: 0, vclicks: 0 }); store.bump('adsPosted');
|
||||
// "Track with LinkSpin" (default on): the ad's public link goes through the member's own LinkSpin tracked link (lstrack.js).
|
||||
// LinkSpin is asked right away (at most 4 s); if it does not answer, the ad goes live with its own link and the sweep retries.
|
||||
const track = b.track === undefined ? (cur ? cur.track !== false : true) : b.track !== false && b.track !== 'off' && b.track !== 0;
|
||||
const lsNow = async x => { if (!lstrack.on() || x.track === false) return lstrack.state(x); await Promise.race([lstrack.ensureAd(x).catch(() => {}), new Promise(r => setTimeout(r, 4000).unref())]); return lstrack.state(x); };
|
||||
if (cur) { Object.assign(cur, { headline, line1, line2, link: lk.url, track, status: cur.status === 'paused' ? 'paused' : 'live' }); if (cur.link !== (cur.ls && cur.ls.url)) delete cur.lsTry; store.saveAd(cur); return json(res, 200, { ok: true, ad: { id: cur.id }, created: false, linkspin: await lsNow(cur) }); }
|
||||
const a = store.addAd({ owner: me, headline, line1, line2, link: lk.url, track, status: 'live', views: 0, clicks: 0, vclicks: 0 }); store.bump('adsPosted');
|
||||
wire.attachPending(me, a.id);
|
||||
return json(res, 200, { ok: true, ad: { id: a.id }, created: true });
|
||||
return json(res, 200, { ok: true, ad: { id: a.id }, created: true, linkspin: await lsNow(a) });
|
||||
}
|
||||
// a Boost: the buy() call for the member's own wallet, with a fresh line voucher when the line is not bound on chain yet
|
||||
if (p === '/api/my/order' && req.method === 'POST') {
|
||||
@@ -405,7 +413,7 @@ const server = http.createServer(async (req, res) => {
|
||||
today: store.today(), totals: S.totals, members: store.members().length, ads: { live: store.liveAds().length, all: store.ads().length },
|
||||
boosts: { orders: B.length, views: B.reduce((t, b) => t + b.views, 0), delivered: B.reduce((t, b) => t + b.delivered, 0), active: B.filter(b => b.remaining > 0).length, late: B.filter(b => b.status === 'finishing-in-network').length, waitingForAd: B.filter(b => b.status === 'waiting-for-ad').length },
|
||||
rows: { visits: store.visits().length, clicks: store.clicks().length, boostViews: store.bviews().length },
|
||||
shop: shop.view(), proof: proof.view(), hub: hubreport.view(), hubLookup: hubpeople.view(), nas: vabnas.view(), docstore: docstore.view(), oldrefs: Object.keys(oldRefMap()).length });
|
||||
shop: shop.view(), proof: proof.view(), hub: hubreport.view(), hubLookup: hubpeople.view(), nas: vabnas.view(), linkspin: lstrack.view(), docstore: docstore.view(), oldrefs: Object.keys(oldRefMap()).length });
|
||||
}
|
||||
if (p === '/api/admin/boosts' && req.method === 'GET') return json(res, 200, { boosts: wire.purchases().map(x => Object.assign(wire.boostView(x), { buyer: x.buyer, usdCents: x.usdCents, weiPaid: x.weiPaid, pays: x.pays || null, over: x.over || null })).sort((a, b) => (b.at || 0) - (a.at || 0)) });
|
||||
if (p === '/api/admin/oldrefs' && req.method === 'POST') {
|
||||
@@ -458,6 +466,9 @@ const server = http.createServer(async (req, res) => {
|
||||
shop.init(C);
|
||||
vabnas.init({ boosts: () => wire.purchases(), remaining: b => wire.remaining(b), ad: id => store.ad(id) });
|
||||
setInterval(() => { if (store.prune()) wire.rebuild(); }, 3600000).unref();
|
||||
lstrack.init(C, store); // LinkSpin tracked links for text ads: retry sweep (fails soft while LinkSpin is down or does not know the endpoint)
|
||||
{ let busy = false; const tick = () => { if (busy) return; busy = true; lstrack.sweep(25).catch(() => {}).finally(() => { busy = false; }); };
|
||||
setTimeout(tick, Number(process.env.LS_SWEEP_FIRST_MS || 20000)).unref(); setInterval(tick, Number(process.env.LS_SWEEP_MS || 120000)).unref(); }
|
||||
server.listen(C.port, () => console.log('ViralAdBlitz on :' + C.port + ', Boost $' + C.boost.usd + ' = ' + C.boost.views + ' views, store: ' + (docstore.isOn() ? 'MySQL documents' : 'files (prototype mode)')));
|
||||
})().catch(e => { console.error('start failed:', e.message); process.exit(1); });
|
||||
process.on('SIGINT', () => { store.flush(); process.exit(0); });
|
||||
|
||||
+2
-1
@@ -7,7 +7,7 @@ import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
const PUB = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', 'public');
|
||||
const SITE = 'https://viraladblitz.com';
|
||||
const V = { css: 4, common: 5, page: 4 };
|
||||
const V = { css: 5, common: 5, page: 5 };
|
||||
const F = { co: 'TrustClickz', addr: '615 Green Valley Drive, Moody, AL 35004', updated: 'November 14, 2026', boostUsd: 5, views: '500', days: 30 };
|
||||
const FONTS = 'https://fonts.googleapis.com/css2?family=Barlow+Condensed:ital,wght@1,700;1,800&family=Chakra+Petch:wght@500;600;700&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@500;700&display=swap';
|
||||
// the daylight look's shared SVG bits (same as common.js)
|
||||
@@ -190,6 +190,7 @@ ${PAGEHEAD('Your dashboard', 'My page', 'One free text ad for network members. S
|
||||
<label class="f">First line <input id="fL1" maxlength="90" autocomplete="off" required><span class="cnt" id="cL1"></span></label>
|
||||
<label class="f">Second line (optional) <input id="fL2" maxlength="90" autocomplete="off"><span class="cnt" id="cL2"></span></label>
|
||||
<label class="f">Your link <input id="fLink" maxlength="600" autocomplete="off" inputmode="url" placeholder="https://" required></label>
|
||||
<label class="chk"><input type="checkbox" id="fTrack" checked> <span><b>Track with LinkSpin</b><br><span class="small muted">Your ad link goes out as a tracked link on your own LinkSpin account, so LinkSpin Reports show its clicks. Visitors still land on your link. Untick it for programs that refuse redirected traffic.</span></span></label>
|
||||
<div class="row" style="margin:0"><button class="btn-red" id="adSave" type="submit">Post my free text ad</button><span class="small muted">Tracking codes work: {clickid} and {placement} are filled on every click.</span></div>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
Reference in New Issue
Block a user