New public page /who-gets-paid: live upgrade payment path for any position

Marty: let anyone enter a position and watch who the contract pays when it
upgrades, so members can simulate helping someone. chain.paymentPath reads the
buyer and up to 16 matrix uplines live from the contract (not the snapshot) and
stops where _payUpline stops (root #1, empty, 16). GET /api/public/payment-path
is rate-limited like the member lookup, cached 60 s. The page walks the rule
from the buyer upward, one generation per step; the real next upgrade is
labelled, higher levels are what-ifs, and any passed-over upline gets a "what
if they did?" to give them the missing level or direct and re-run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-09-26 09:08:50 -05:00
parent 687ecb7eb6
commit f27f2894d0
4 changed files with 282 additions and 2 deletions
+26 -1
View File
@@ -859,4 +859,29 @@ async function getIncome(id) {
};
}
module.exports = { startIndexer, getPayoutsPublic, verifyMember, memberLookup, memberPublic, getIncome, getOwnerUpgradeNeeds, getOrgRouting, getOrgShare, getCoachingScan, getMatrixTree, isInTeam, nextOpenPosition, depthFrom, memberIdByAccount, liveDirects, balanceOf, CONTRACT };
// Live upgrade payment path for /who-gets-paid (Marty, 2026-09-26): the buyer plus up to 16
// matrix uplines, read straight from the contract (not the snapshot, so a level or direct that
// changed a minute ago is already reflected). Mirrors _payUpline's walk: it starts at the
// buyer's matrix parent and stops at the root (#1), an empty upline, or 16 steps.
const ROOT_ID = 1;
async function paymentPath(id) {
const pick = m => ({ id: m.id, level: m.level, tier: m.tier, directCount: m.directCount, uplineId: m.uplineId, referrerId: m.referrerId });
const b = await fetchMember(id);
if (!b) return { found: false };
const buyer = pick(Object.assign({ id }, b));
const uplines = [];
let cur = b.uplineId, stopped = null;
for (let i = 0; i < 16; i++) {
if (!cur) { stopped = 'empty'; break; }
if (cur === ROOT_ID) { stopped = 'root'; break; }
const m = await fetchMember(cur);
if (!m) { stopped = 'empty'; break; }
uplines.push(pick(Object.assign({ id: cur }, m)));
cur = m.uplineId;
}
if (!stopped) stopped = 'max';
await fetchCosts().catch(() => {});
return { found: true, buyer, uplines, stopped, costs: costs ? { up: costs.up } : null, at: Date.now() };
}
module.exports = { paymentPath, startIndexer, getPayoutsPublic, verifyMember, memberLookup, memberPublic, getIncome, getOwnerUpgradeNeeds, getOrgRouting, getOrgShare, getCoachingScan, getMatrixTree, isInTeam, nextOpenPosition, depthFrom, memberIdByAccount, liveDirects, balanceOf, CONTRACT };
+111
View File
@@ -0,0 +1,111 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="description" content="Enter any RM Circle position and watch, step by step, who the contract pays when that position upgrades. Live from the blockchain."><title>Who Gets Paid | RM Circle Team Build</title>
<link rel="canonical" href="https://rmcircle.team/who-gets-paid">
<meta property="og:type" content="website"><meta property="og:site_name" content="RM Circle Team Build"><meta property="og:title" content="Who gets paid when a position upgrades"><meta property="og:description" content="Enter any position number and watch the contract search up the matrix, live from the blockchain."><meta property="og:url" content="https://rmcircle.team/who-gets-paid"><meta property="og:image" content="https://rmcircle.team/og-card.jpg">
<meta name="twitter:card" content="summary_large_image"><meta name="twitter:title" content="Who gets paid when a position upgrades"><meta name="twitter:image" content="https://rmcircle.team/og-card.jpg">
<link rel="icon" type="image/png" href="/favicon.png"><link rel="stylesheet" href="/styles.css">
<style>
.wgp{--fee:#b8a2f5;--fee-soft:rgba(184,162,245,.13);--skip-soft:rgba(174,189,202,.10);--pass-soft:rgba(255,126,107,.12);--paid-soft:rgba(123,224,161,.13)}
.wgp .tool{background:var(--panel);border:1px solid var(--line);border-radius:18px;padding:20px}
.wgp .row{display:flex;flex-wrap:wrap;gap:12px 16px;align-items:end}
.wgp label.k{display:block;font-size:11px;letter-spacing:.12em;text-transform:uppercase;color:var(--muted);margin-bottom:6px;font-weight:700}
.wgp input,.wgp select{font:inherit;font-size:16px;color:var(--text);background:var(--bg);border:1px solid var(--line);border-radius:10px;padding:10px 12px}
.wgp input{width:140px}
.wgp input:focus-visible,.wgp select:focus-visible,.wgp button:focus-visible{outline:2px solid var(--gold);outline-offset:2px}
.wgp .buyer{margin-top:16px;display:grid;grid-template-columns:repeat(auto-fit,minmax(140px,1fr));gap:10px}
.wgp .fact{background:var(--bg);border:1px solid var(--line);border-radius:12px;padding:10px 14px}
.wgp .fact small{display:block;font-size:11px;letter-spacing:.1em;text-transform:uppercase;color:var(--muted)}
.wgp .fact strong{font-size:18px}
.wgp .sum{margin-top:14px;padding:12px 14px;border-radius:12px;background:var(--bg);border:1px solid var(--line);line-height:1.55}
.wgp .chain{list-style:none;padding:0;margin:14px 0 0;display:flex;flex-direction:column-reverse;gap:6px}
.wgp .hop{display:grid;grid-template-columns:54px 84px 1fr auto;gap:10px;align-items:center;padding:9px 12px;border-radius:10px;border:1px solid var(--line);background:var(--bg);font-size:14.5px;transition:background .25s,border-color .25s}
.wgp .hop .n{font-size:12px;color:var(--muted);font-variant-numeric:tabular-nums}
.wgp .hop .id{font-weight:800;font-variant-numeric:tabular-nums}
.wgp .hop .meta{color:var(--muted);font-size:13.5px}
.wgp .hop .tag{font-size:11px;font-weight:800;letter-spacing:.06em;text-transform:uppercase;padding:3px 9px;border-radius:999px;white-space:nowrap}
.wgp .hop.idle .tag{display:none}
.wgp .hop.buyer{border-style:dashed}
.wgp .hop.skip{background:var(--skip-soft)} .wgp .hop.skip .tag{background:var(--muted);color:var(--bg)}
.wgp .hop.fail{background:var(--pass-soft);border-color:var(--danger)} .wgp .hop.fail .tag{background:var(--danger);color:var(--bg)}
.wgp .hop.paid{background:var(--paid-soft);border-color:var(--ok);box-shadow:0 0 0 1px var(--ok)} .wgp .hop.paid .tag{background:var(--ok);color:var(--bg)}
.wgp .hop.fee{background:var(--fee-soft);border-color:var(--fee)} .wgp .hop.fee .tag{background:var(--fee);color:var(--bg)}
.wgp .hop.whatif .id::after{content:" (what if)";font-weight:600;font-size:12px;color:var(--gold)}
.wgp .why{grid-column:3 / -1;font-size:13.5px;line-height:1.45;color:var(--text)}
.wgp .why button{margin-left:6px;font:inherit;font-size:12.5px;font-weight:700;color:var(--gold);background:transparent;border:1px solid var(--gold);border-radius:999px;padding:2px 10px;cursor:pointer}
.wgp .legend{display:flex;flex-wrap:wrap;gap:8px 16px;margin-top:12px;font-size:13px;color:var(--muted)}
.wgp .legend span::before{content:"";display:inline-block;width:10px;height:10px;border-radius:3px;margin-right:6px;vertical-align:-1px}
.wgp .lg-skip::before{background:var(--muted)} .wgp .lg-fail::before{background:var(--danger)} .wgp .lg-paid::before{background:var(--ok)} .wgp .lg-fee::before{background:var(--fee)}
.wgp .steps{list-style:none;counter-reset:s;padding:0;margin:12px 0 0;display:grid;gap:10px}
.wgp .steps li{counter-increment:s;display:grid;grid-template-columns:32px 1fr;gap:12px;align-items:start;color:var(--muted);line-height:1.6}
.wgp .steps li::before{content:counter(s);width:32px;height:32px;border-radius:50%;display:grid;place-items:center;font-weight:800;color:var(--gold);border:1px solid var(--gold)}
.wgp .steps li.stop::before{content:"■";color:var(--fee);border-color:var(--fee)}
.wgp .steps b{color:var(--text)}
.wgp pre{margin:14px 0 0;background:var(--bg);border:1px solid var(--line);border-radius:12px;padding:14px 16px;overflow-x:auto;font:13px/1.55 ui-monospace,SFMono-Regular,Consolas,Menlo,monospace;color:var(--text)}
.wgp pre .c{color:var(--muted)}
.wgp .tbl{overflow-x:auto;border:1px solid var(--line);border-radius:12px;margin-top:14px}
.wgp table{border-collapse:collapse;width:100%;font-size:14.5px;font-variant-numeric:tabular-nums}
.wgp th,.wgp td{text-align:left;padding:9px 12px;border-bottom:1px solid var(--line)}
.wgp th{font-size:11px;letter-spacing:.1em;text-transform:uppercase;color:var(--muted)}
.wgp tr:last-child td{border-bottom:0}
@media (max-width:560px){.wgp .hop{grid-template-columns:44px 1fr auto}.wgp .hop .meta{grid-column:2 / -1;grid-row:2}.wgp .why{grid-column:1 / -1}}
@media (prefers-reduced-motion: reduce){.wgp .hop{transition:none}}
</style>
</head>
<body>
<header class="wrap nav"><a class="brand" href="/"><img class="brand-mark" src="/logo.jpg" alt="The RM Circle" width="42" height="42"><span><span id="brandName">RM Circle</span><small>Who gets paid</small></span></a><div class="nav-actions"><a class="btn btn-secondary hide-mobile" href="/training">Training</a><a class="btn btn-secondary" href="/how-pay-works">How pay works</a><a class="btn btn-primary" href="/start">Get Started</a></div></header>
<main class="wgp">
<section class="section"><div class="wrap" style="max-width:920px">
<div class="section-head" style="max-width:780px"><div class="eyebrow">Live from the contract</div>
<h1 style="font-size:clamp(30px,5vw,46px);margin:8px 0 10px">Who gets paid when a position <span class="gold">upgrades?</span></h1>
<p>Enter any position number. The page reads that position and everyone above it straight from the blockchain, then walks the contract's rule one generation at a time, from the buyer upward, until it finds who gets paid. Use "what if" on anyone who is passed over to see what it would take for them to catch it.</p></div>
<div class="tool">
<form class="row" id="wgpForm">
<div><label class="k" for="wgpId">Position #</label><input id="wgpId" inputmode="numeric" pattern="[0-9]*" autocomplete="off" placeholder="e.g. 1191"></div>
<button class="btn btn-primary" type="submit" id="wgpLoad">Load position</button>
<div id="wgpBuyWrap" hidden><label class="k" for="wgpLvl">If it buys</label><select id="wgpLvl"></select></div>
<button class="btn btn-secondary" type="button" id="wgpRun" hidden>Run the search</button>
<button class="btn btn-secondary" type="button" id="wgpReset" hidden>Clear what-ifs</button>
</form>
<div class="buyer" id="wgpBuyer" hidden></div>
<div class="sum" id="wgpSum">Enter a position number to start.</div>
<ol class="chain" id="wgpChain"></ol>
<div class="legend" id="wgpLegend" hidden><span class="lg-skip">skipped, not checked</span><span class="lg-fail">checked, passed over</span><span class="lg-paid">paid 100%</span><span class="lg-fee">fee wallet</span></div>
</div>
<p class="micro" style="margin-top:12px">Read live from the contract at <a href="https://polygonscan.com/address/0x33BdAEEfd6d17d80aE53816c916dFb26c4fB2DAF#code" target="_blank" rel="noopener" style="color:var(--teal)">0x33Bd…4fB2DAF</a>. The next level shown is the position's real next purchase; higher levels and "what if" changes are simulations of the same rule. This shows mechanics only, not a promise of income.</p>
</div></section>
<section class="section"><div class="wrap" style="max-width:920px">
<div class="eyebrow">The rule</div>
<h2 style="margin:6px 0 8px">How the contract picks who gets paid</h2>
<p style="color:var(--muted);max-width:720px">An upgrade is never split. 100% of it goes to one upline in the matrix, or to the fee wallet if nobody qualifies.</p>
<ol class="steps">
<li><span><b>Skip.</b> Skip a number of uplines equal to the buyer's current level minus one, without checking them. Buying Ascensus from Scintilla skips none.</span></li>
<li><span><b>Check.</b> From there, look at each upline in turn: do they hold at least the level the buyer is leaving, and do they have 2 directs?</span></li>
<li><span><b>Pay or pass.</b> The first upline that passes both checks is paid the full amount and the search ends. Anyone who fails is passed over.</span></li>
<li class="stop"><span><b>Stop.</b> If the search reaches position #1 (the root) or has taken 16 steps, the whole payment goes to the fee wallet.</span></li>
</ol>
<pre><span class="c">// upgrade() · the number that drives everything</span>
_payUpline(id, currentLevel - 1, cost); <span class="c">// levelIndex = the buyer's level - 1</span>
<span class="c">// _payUpline() · skip, then check</span>
if (i &lt; levelIndex) { upline = u.uplineId; continue; } <span class="c">// skip this many</span>
if (u.level &gt; levelIndex &amp;&amp; u.directCount &gt;= 2) { <span class="c">// the first to pass gets 100%</span></pre>
<div class="tbl"><table>
<thead><tr><th>Buying</th><th>levelIndex</th><th>Uplines skipped</th><th>Catcher must hold</th></tr></thead>
<tbody>
<tr><td>Ascensus</td><td>0</td><td>0</td><td>Scintilla or higher</td></tr>
<tr><td>Fabrica</td><td>1</td><td>1</td><td>Ascensus or higher</td></tr>
<tr><td>Culmen</td><td>2</td><td>2</td><td>Fabrica or higher</td></tr>
<tr><td>Apex</td><td>3</td><td>3</td><td>Culmen or higher</td></tr>
<tr><td>Fastigium</td><td>4</td><td>4</td><td>Apex or higher</td></tr>
<tr><td>Vertex</td><td>5</td><td>5</td><td>Fastigium or higher</td></tr>
<tr><td>Corona</td><td>6</td><td>6</td><td>Vertex or higher</td></tr>
</tbody>
</table></div>
<p class="micro" style="margin-top:12px">Every row also needs 2 directs. The amount is set by the buyer's tier; Standard is exactly half of Premium. The search follows the <b>matrix</b> (where each member was placed), not the sponsor line. <a href="/contract" style="color:var(--teal)">Can the contract change? See the security review →</a></p>
</div></section>
</main>
<footer class="wrap disclaimer">Independent, unaffiliated team resource. Informational and educational only. No income is guaranteed. Cryptocurrency participation carries risk of total loss.<div class="footer-links"><a href="/">Home</a><a href="/training">Training</a><a href="/contract">Contract Security</a><a href="/disclaimer">Disclaimers</a><a href="/how-pay-works">How You Get Paid</a><a href="/tools">Promo Tools</a><a href="/privacy">Privacy</a><a href="/refunds">Refunds</a></div></footer>
<script src="/who-gets-paid.js?v=20260926a"></script>
<script src="/track.js"></script><script src="/chat.js?v=20260920" defer></script><script src="/translate.js" defer></script><script src="/tg-app.js" defer></script><script src="/nav-dash.js" defer></script>
</body></html>
+128
View File
@@ -0,0 +1,128 @@
/* /who-gets-paid (Marty, 2026-09-26): enter any position, read it and its matrix uplines live
from /api/public/payment-path, and walk the contract's _payUpline rule one step at a time from
the buyer upward. "What if" lets a viewer give a passed-over upline the level or direct they
are missing and see where the payment would land instead. The rule here is the contract's:
skip levelIndex uplines; pay the first with level > levelIndex and directCount >= 2;
stop at the root (#1) or after 16 steps and send it to the fee wallet. */
(function () {
var NAMES = ['Scintilla', 'Ascensus', 'Fabrica', 'Culmen', 'Apex', 'Fastigium', 'Vertex', 'Corona'];
var $ = function (id) { return document.getElementById(id); };
var form = $('wgpForm'), idIn = $('wgpId'), sel = $('wgpLvl'), buyWrap = $('wgpBuyWrap');
var runBtn = $('wgpRun'), resetBtn = $('wgpReset'), buyerEl = $('wgpBuyer'), sumEl = $('wgpSum');
var chainEl = $('wgpChain'), legend = $('wgpLegend');
var data = null, overrides = {}, timer = null;
function esc(s) { return String(s).replace(/[&<>"]/g, function (c) { return { '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' }[c]; }); }
function fmt(n) { return Number(n || 0).toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 }); }
function lvName(l) { return NAMES[l - 1] || ('level ' + l); }
function eff(u) { var o = overrides[u.id] || {}; return { level: o.level || u.level, directCount: o.directCount != null ? o.directCount : u.directCount, what: !!(o.level || o.directCount != null) }; }
function price(li) {
var t = data.buyer.tier === 2 ? 2 : 1;
return data.costs && data.costs.up && data.costs.up[t] ? data.costs.up[t][li] : null;
}
function evaluate(li) {
var steps = [], paid = null, U = data.uplines;
for (var i = 0; i < U.length; i++) {
var e = eff(U[i]);
if (i < li) { steps.push({ s: 'skip', why: 'Skipped: ' + (i + 1) + ' of ' + li + ' skipped without checking.' }); continue; }
var lvOk = e.level > li, dOk = e.directCount >= 2;
if (lvOk && dOk) { steps.push({ s: 'paid', why: 'Holds ' + lvName(e.level) + ', needs ' + lvName(li + 1) + ' or higher, and has ' + e.directCount + ' directs. Paid in full; the search ends.' }); paid = i; break; }
var need = [];
if (!lvOk) need.push('needs ' + lvName(li + 1) + ' or higher (holds ' + lvName(e.level) + ')');
if (!dOk) need.push('needs 2 directs (has ' + e.directCount + ')');
steps.push({ s: 'fail', why: 'Passed over: ' + need.join(' and ') + '.', fix: { id: U[i].id, level: lvOk ? null : li + 1, directs: dOk ? null : 2 } });
}
return { steps: steps, paid: paid };
}
function draw(li, upto) {
var r = evaluate(li), U = data.uplines, b = data.buyer;
var html = '<li class="hop buyer idle"><span class="n">buyer</span><span class="id">#' + b.id + '</span><span class="meta">' + lvName(b.level) + ' · ' + b.directCount + ' direct' + (b.directCount === 1 ? '' : 's') + ' · buying ' + lvName(li + 1) + '</span><span class="tag"></span></li>';
for (var i = 0; i < U.length; i++) {
var u = U[i], e = eff(u), st = (i < r.steps.length && i < upto) ? r.steps[i] : null;
var cls = st ? st.s : 'idle', tag = st ? (st.s === 'skip' ? 'skipped' : st.s === 'fail' ? 'passed over' : 'paid') : '';
var why = '';
if (st) {
why = '<span class="why">' + esc(st.why);
if (st.fix && upto >= r.steps.length) why += '<button type="button" data-fix="' + st.fix.id + '" data-level="' + (st.fix.level || '') + '" data-directs="' + (st.fix.directs || '') + '">What if they did?</button>';
why += '</span>';
}
html += '<li class="hop ' + cls + (e.what ? ' whatif' : '') + '"><span class="n">up ' + (i + 1) + '</span><span class="id">#' + u.id + '</span><span class="meta">' + lvName(e.level) + ' · ' + e.directCount + ' direct' + (e.directCount === 1 ? '' : 's') + '</span><span class="tag">' + tag + '</span>' + why + '</li>';
}
var done = upto >= r.steps.length, amt = price(li);
var amtTxt = amt != null ? fmt(amt) + ' POL' : 'the upgrade';
if (done && r.paid === null) {
var reason = data.stopped === 'root' && U.length < 16 ? 'The next upline is #1, the root. The search stops there.' : 'The search used all 16 steps.';
html += '<li class="hop fee"><span class="n">stop</span><span class="id">fee</span><span class="meta">' + (data.stopped === 'root' && U.length < 16 ? '#1 root reached' : '16 steps used') + '</span><span class="tag">fee wallet</span><span class="why">' + reason + ' Nobody qualified, so the full ' + amtTxt + ' goes to the fee wallet.</span></li>';
}
chainEl.innerHTML = html;
if (done) {
var wi = Object.keys(overrides).length ? ' <span style="color:var(--gold)">(with your what-if changes)</span>' : '';
sumEl.innerHTML = r.paid !== null
? '<b>#' + U[r.paid].id + ' would be paid ' + amtTxt + '</b>' + wi + '. ' + li + ' upline' + (li === 1 ? '' : 's') + ' skipped, ' + (r.paid - li) + ' passed over.'
: '<b>Nobody in reach qualifies, so the full ' + amtTxt + ' would go to the fee wallet</b>' + wi + '. Skipped ' + Math.min(li, U.length) + ', checked ' + Math.max(0, U.length - li) + '.';
} else sumEl.textContent = 'Checking ' + (upto + 1) + ' up…';
}
function run(animate) {
if (!data) return;
if (timer) { clearInterval(timer); timer = null; }
var li = Number(sel.value), total = evaluate(li).steps.length;
var reduce = window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches;
if (!animate || reduce) { draw(li, total); return; }
var k = 0; draw(li, 0);
timer = setInterval(function () { k++; draw(li, k); if (k >= total) { clearInterval(timer); timer = null; } }, 380);
}
function showBuyer() {
var b = data.buyer, t = b.tier === 2 ? 'Premium' : 'Standard';
buyerEl.innerHTML =
'<div class="fact"><small>Position</small><strong>#' + b.id + '</strong></div>' +
'<div class="fact"><small>Level</small><strong>' + lvName(b.level) + '</strong></div>' +
'<div class="fact"><small>Tier</small><strong>' + t + '</strong></div>' +
'<div class="fact"><small>Directs</small><strong>' + b.directCount + '</strong></div>' +
'<div class="fact"><small>Matrix parent</small><strong>' + (b.uplineId ? '#' + b.uplineId : '—') + '</strong></div>';
buyerEl.hidden = false;
sel.innerHTML = '';
for (var L = b.level + 1; L <= 8; L++) {
var li = L - 2, o = document.createElement('option'), p = price(li);
o.value = li;
o.textContent = NAMES[L - 1] + (p != null ? ' · ' + fmt(p) + ' POL' : '') + (L === b.level + 1 ? ' (its real next upgrade)' : ' (what if)');
sel.appendChild(o);
}
var canBuy = b.level < 8;
buyWrap.hidden = !canBuy; runBtn.hidden = !canBuy; legend.hidden = !canBuy;
if (!canBuy) { chainEl.innerHTML = ''; sumEl.innerHTML = '<b>#' + b.id + ' already holds Corona</b>, the top level, so it has no upgrade left to buy.'; }
}
function load(id) {
if (!id) return;
if (timer) { clearInterval(timer); timer = null; }
overrides = {}; resetBtn.hidden = true;
sumEl.textContent = 'Reading #' + id + ' and its uplines from the blockchain…';
chainEl.innerHTML = ''; buyerEl.hidden = true;
try { history.replaceState(null, '', '/who-gets-paid?id=' + id); } catch (e) {}
fetch('/api/public/payment-path?id=' + encodeURIComponent(id)).then(function (r) {
return r.json().then(function (j) { if (!r.ok) throw new Error(j.error || 'Lookup failed.'); return j; });
}).then(function (j) {
data = j; showBuyer();
if (data.buyer.level < 8) run(false);
}).catch(function (e) { data = null; sumEl.textContent = e.message || 'Lookup failed. Try again.'; });
}
form.addEventListener('submit', function (e) { e.preventDefault(); var id = parseInt(idIn.value, 10); if (id > 0) load(id); else sumEl.textContent = 'Enter a position number, like 1191.'; });
runBtn.addEventListener('click', function () { run(true); });
sel.addEventListener('change', function () { run(false); });
resetBtn.addEventListener('click', function () { overrides = {}; resetBtn.hidden = true; run(false); });
chainEl.addEventListener('click', function (e) {
var bt = e.target.closest('button[data-fix]'); if (!bt) return;
var id = Number(bt.dataset.fix), o = overrides[id] || {};
if (bt.dataset.level) o.level = Number(bt.dataset.level);
if (bt.dataset.directs) o.directCount = Number(bt.dataset.directs);
overrides[id] = o; resetBtn.hidden = false; run(false);
});
var q = new URLSearchParams(location.search).get('id');
if (q && /^\d+$/.test(q)) { idIn.value = q; load(Number(q)); }
})();
+17 -1
View File
@@ -625,6 +625,7 @@ async function handleTranslate(req,res){
// frame-src includes 'self' so our own pages (the Page Builder preview framing
// a member's /p/<id> page) are not blocked by our own policy.
const pathCache=new Map(); // /api/public/payment-path results, 60 s
const CSP_BASE="default-src 'self'; script-src 'self' https://polhunter.com https://www.networkadspace.com https://networkadspace.com; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; media-src 'self' https://coolify-saasytop.nyc3.digitaloceanspaces.com; connect-src 'self' https://polhunter.com; font-src 'self' data:; form-action 'self'; frame-src 'self' https://www.youtube-nocookie.com"; // polhunter.com: the PolHunter embed on /training (2026-09-19)
function securityHeaders(extra={}) {
// Public pages must render inside safelist / traffic-exchange iframes, so framing stays open here; admin.html re-locks it via ADMIN_FRAME_HEADERS.
@@ -709,6 +710,21 @@ async function handleApi(req,res,pathname){
if(owner||!data||!data.nextStep||data.nextStep.funded==null)return {data,owner};
return {data:Object.assign({},data,{nextStep:Object.assign({},data.nextStep,{funded:null})}),owner};
}
// /who-gets-paid: live upgrade payment path for any position (public, rate-limited, 60 s cache)
if(req.method==='GET'&&pathname==='/api/public/payment-path'){
const ip=String(req.headers['x-forwarded-for']||req.socket.remoteAddress||'').split(',')[0].trim();
if(memberLookupLimited(ip))return json(res,429,{error:'Too many lookups. Give it a minute.'});
const id=Number(new URL(req.url,'http://x').searchParams.get('id')||0);
if(!Number.isInteger(id)||id<1||id>281474976710655)return json(res,400,{error:'Enter a position number.'});
const hit=pathCache.get(id);
if(hit&&Date.now()-hit.ts<60000)return json(res,200,hit.data,{'Cache-Control':'public, max-age=30'});
try{
const r=await Promise.race([chain.paymentPath(id),new Promise((_,rej)=>setTimeout(()=>rej(new Error('Blockchain lookup timed out. Try again.')),25000))]);
if(!r.found)return json(res,404,{error:'Position #'+id+' does not exist.'});
pathCache.set(id,{ts:Date.now(),data:r});
return json(res,200,r,{'Cache-Control':'public, max-age=30'});
}catch(e){return json(res,502,{error:e.message||'Lookup failed.'});}
}
if(req.method==='GET'&&pathname==='/api/public/member'){
const ip=String(req.headers['x-forwarded-for']||req.socket.remoteAddress||'').split(',')[0].trim();
if(memberLookupLimited(ip))return json(res,429,{error:'Too many lookups — give it a minute.'});
@@ -1888,7 +1904,7 @@ const server=http.createServer(async(req,res)=>{
if((mj=pathname.match(/^\/join\/(\d{1,15})$/)))return serveMemberPage(req,res,path.join(PUBLIC_DIR,'join.html'),'join',mj[1]);
}
let file;
if(pathname==='/')file=path.join(PUBLIC_DIR,'index.html');else if(pathname==='/app'||pathname==='/app/')file=path.join(PUBLIC_DIR,'app.html');else if(pathname==='/start'||pathname==='/start/')file=path.join(PUBLIC_DIR,'start.html');else if(pathname==='/training'||pathname==='/training/')file=path.join(PUBLIC_DIR,'training.html');else if(pathname==='/presentation'||pathname==='/presentation/'||pathname==='/webinar'||pathname==='/webinar/')file=path.join(PUBLIC_DIR,'presentation.html');else if(pathname==='/admin'||pathname==='/admin/')file=path.join(PUBLIC_DIR,'admin.html');else if(pathname==='/my'||pathname==='/my/'||/^\/my\/\d{1,15}$/.test(pathname))file=path.join(PUBLIC_DIR,'my.html');else if(pathname==='/contract'||pathname==='/contract/')file=path.join(PUBLIC_DIR,'contract.html');else if(pathname==='/disclaimer'||pathname==='/disclaimer/')file=path.join(PUBLIC_DIR,'disclaimer.html');else if(pathname==='/privacy'||pathname==='/privacy/')file=path.join(PUBLIC_DIR,'privacy.html');else if(pathname==='/refunds'||pathname==='/refunds/')file=path.join(PUBLIC_DIR,'refunds.html');else if(pathname==='/how-pay-works'||pathname==='/how-pay-works/')file=path.join(PUBLIC_DIR,'how-pay-works.html');else if(pathname==='/tools'||pathname==='/tools/')file=path.join(PUBLIC_DIR,'tools.html');else if(pathname==='/fast-start'||pathname==='/fast-start/')file=path.join(PUBLIC_DIR,'fast-start.html');else if(pathname==='/flyers'||pathname==='/flyers/')file=path.join(PUBLIC_DIR,'flyers.html');else if(pathname==='/weekly-rhythm'||pathname==='/weekly-rhythm/')file=path.join(PUBLIC_DIR,'weekly-rhythm.html');else if(pathname==='/generation-pay'||pathname==='/generation-pay/')file=path.join(PUBLIC_DIR,'generation-pay.html');else if(pathname==='/replays'||pathname==='/replays/')file=path.join(PUBLIC_DIR,'replays.html');else if(pathname==='/suite'||pathname==='/suite/')file=path.join(PUBLIC_DIR,'suite.html');else if(pathname==='/suite/copy'||pathname==='/suite/copy/')file=path.join(PUBLIC_DIR,'suite-copy.html');else if(pathname==='/suite/page'||pathname==='/suite/page/')file=path.join(PUBLIC_DIR,'suite-page.html');else if(pathname==='/suite/email'||pathname==='/suite/email/')file=path.join(PUBLIC_DIR,'suite-email.html');else if(pathname==='/suite/video'||pathname==='/suite/video/')file=path.join(PUBLIC_DIR,'suite-video.html');else if(pathname==='/suite/traffic'||pathname==='/suite/traffic/')file=path.join(PUBLIC_DIR,'suite-traffic.html');else if(pathname==='/suite/voice'||pathname==='/suite/voice/')file=path.join(PUBLIC_DIR,'suite-voice.html');else if(pathname==='/suite/split'||pathname==='/suite/split/')file=path.join(PUBLIC_DIR,'suite-split.html');else if(pathname==='/suite/funnel'||pathname==='/suite/funnel/')file=path.join(PUBLIC_DIR,'suite-funnel.html');else if(pathname==='/suite/leader'||pathname==='/suite/leader/')file=path.join(PUBLIC_DIR,'suite-leader.html');else if(pathname==='/suite/founder'||pathname==='/suite/founder/')file=path.join(PUBLIC_DIR,'suite-founder.html');else if(pathname==='/wallet-check'||pathname==='/wallet-check/')file=path.join(PUBLIC_DIR,'wallet-check.html');else if(pathname==='/suite/brand'||pathname==='/suite/brand/')file=path.join(PUBLIC_DIR,'suite-brand.html');else if(pathname==='/suite/grants'||pathname==='/suite/grants/')file=path.join(PUBLIC_DIR,'suite-grants.html');else if(pathname==='/suite/intel'||pathname==='/suite/intel/')file=path.join(PUBLIC_DIR,'suite-intel.html');else if(pathname==='/direct-join'||pathname==='/direct-join/'){if(!getSession(req)){res.writeHead(302,{Location:'/admin'});return res.end();}file=path.join(ROOT,'private','direct-join.html');}else if(pathname==='/join-now'||pathname==='/join-now/'){if(!getConfig().dappFallbackPublic){res.writeHead(302,{Location:'/start'});return res.end();}file=path.join(ROOT,'private','join-now.html');}else if(/^\/join\/\d{1,15}$/.test(pathname))file=path.join(PUBLIC_DIR,'join.html');else if(pathname==='/join'||pathname==='/join/'){res.writeHead(302,{Location:'/join-now'});return res.end();}else{
if(pathname==='/')file=path.join(PUBLIC_DIR,'index.html');else if(pathname==='/app'||pathname==='/app/')file=path.join(PUBLIC_DIR,'app.html');else if(pathname==='/start'||pathname==='/start/')file=path.join(PUBLIC_DIR,'start.html');else if(pathname==='/training'||pathname==='/training/')file=path.join(PUBLIC_DIR,'training.html');else if(pathname==='/presentation'||pathname==='/presentation/'||pathname==='/webinar'||pathname==='/webinar/')file=path.join(PUBLIC_DIR,'presentation.html');else if(pathname==='/admin'||pathname==='/admin/')file=path.join(PUBLIC_DIR,'admin.html');else if(pathname==='/my'||pathname==='/my/'||/^\/my\/\d{1,15}$/.test(pathname))file=path.join(PUBLIC_DIR,'my.html');else if(pathname==='/contract'||pathname==='/contract/')file=path.join(PUBLIC_DIR,'contract.html');else if(pathname==='/disclaimer'||pathname==='/disclaimer/')file=path.join(PUBLIC_DIR,'disclaimer.html');else if(pathname==='/privacy'||pathname==='/privacy/')file=path.join(PUBLIC_DIR,'privacy.html');else if(pathname==='/refunds'||pathname==='/refunds/')file=path.join(PUBLIC_DIR,'refunds.html');else if(pathname==='/how-pay-works'||pathname==='/how-pay-works/')file=path.join(PUBLIC_DIR,'how-pay-works.html');else if(pathname==='/who-gets-paid'||pathname==='/who-gets-paid/')file=path.join(PUBLIC_DIR,'who-gets-paid.html');else if(pathname==='/tools'||pathname==='/tools/')file=path.join(PUBLIC_DIR,'tools.html');else if(pathname==='/fast-start'||pathname==='/fast-start/')file=path.join(PUBLIC_DIR,'fast-start.html');else if(pathname==='/flyers'||pathname==='/flyers/')file=path.join(PUBLIC_DIR,'flyers.html');else if(pathname==='/weekly-rhythm'||pathname==='/weekly-rhythm/')file=path.join(PUBLIC_DIR,'weekly-rhythm.html');else if(pathname==='/generation-pay'||pathname==='/generation-pay/')file=path.join(PUBLIC_DIR,'generation-pay.html');else if(pathname==='/replays'||pathname==='/replays/')file=path.join(PUBLIC_DIR,'replays.html');else if(pathname==='/suite'||pathname==='/suite/')file=path.join(PUBLIC_DIR,'suite.html');else if(pathname==='/suite/copy'||pathname==='/suite/copy/')file=path.join(PUBLIC_DIR,'suite-copy.html');else if(pathname==='/suite/page'||pathname==='/suite/page/')file=path.join(PUBLIC_DIR,'suite-page.html');else if(pathname==='/suite/email'||pathname==='/suite/email/')file=path.join(PUBLIC_DIR,'suite-email.html');else if(pathname==='/suite/video'||pathname==='/suite/video/')file=path.join(PUBLIC_DIR,'suite-video.html');else if(pathname==='/suite/traffic'||pathname==='/suite/traffic/')file=path.join(PUBLIC_DIR,'suite-traffic.html');else if(pathname==='/suite/voice'||pathname==='/suite/voice/')file=path.join(PUBLIC_DIR,'suite-voice.html');else if(pathname==='/suite/split'||pathname==='/suite/split/')file=path.join(PUBLIC_DIR,'suite-split.html');else if(pathname==='/suite/funnel'||pathname==='/suite/funnel/')file=path.join(PUBLIC_DIR,'suite-funnel.html');else if(pathname==='/suite/leader'||pathname==='/suite/leader/')file=path.join(PUBLIC_DIR,'suite-leader.html');else if(pathname==='/suite/founder'||pathname==='/suite/founder/')file=path.join(PUBLIC_DIR,'suite-founder.html');else if(pathname==='/wallet-check'||pathname==='/wallet-check/')file=path.join(PUBLIC_DIR,'wallet-check.html');else if(pathname==='/suite/brand'||pathname==='/suite/brand/')file=path.join(PUBLIC_DIR,'suite-brand.html');else if(pathname==='/suite/grants'||pathname==='/suite/grants/')file=path.join(PUBLIC_DIR,'suite-grants.html');else if(pathname==='/suite/intel'||pathname==='/suite/intel/')file=path.join(PUBLIC_DIR,'suite-intel.html');else if(pathname==='/direct-join'||pathname==='/direct-join/'){if(!getSession(req)){res.writeHead(302,{Location:'/admin'});return res.end();}file=path.join(ROOT,'private','direct-join.html');}else if(pathname==='/join-now'||pathname==='/join-now/'){if(!getConfig().dappFallbackPublic){res.writeHead(302,{Location:'/start'});return res.end();}file=path.join(ROOT,'private','join-now.html');}else if(/^\/join\/\d{1,15}$/.test(pathname))file=path.join(PUBLIC_DIR,'join.html');else if(pathname==='/join'||pathname==='/join/'){res.writeHead(302,{Location:'/join-now'});return res.end();}else{
const safe=path.normalize(pathname).replace(/^([.][.][/\\])+/, '').replace(/^[/\\]+/,'');file=path.join(PUBLIC_DIR,safe);if(!file.startsWith(PUBLIC_DIR))file='';
}
if(file&&staticFile(req,res,file))return;return staticFile(req,res,path.join(PUBLIC_DIR,'404.html'),404);