Old /splashpg.php?r= and /lcp.php?r= links keep the referral (301 to /?ref=<network username>), like ViralAdSource

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-11-17 08:17:12 -06:00
parent ae880afb75
commit f8e6a9d174
+4 -1
View File
@@ -332,7 +332,10 @@ const server = http.createServer(async (req, res) => {
// old site links (2026-11-13): referral links were /?<old username> (bare query) and pages were *.php. An old username maps to
// the same person's network username (oldrefs.json, matched by email); a page address goes home.
if (/\.php$/i.test(p) || (p === '/' && /^[A-Za-z0-9_.-]{2,40}$/.test(u.search.slice(1).split('&')[0]))) { // "&fbclid=..." may follow
const old = /\.php$/i.test(p) && p !== '/index.php' ? '' : u.search.slice(1).split('&')[0].toLowerCase();
// old splash/landing pages carried the referral as ?r=<old username> (2026-11-17: /splashpg.php?r= kept the ref like VAS)
const lp = p.toLowerCase(); const rq = String(u.searchParams.get('r') || '');
const old = (lp === '/splashpg.php' || lp === '/lcp.php') ? (/^[A-Za-z0-9_.-]{2,40}$/.test(rq) ? rq.toLowerCase() : '')
: /\.php$/i.test(p) && lp !== '/index.php' ? '' : u.search.slice(1).split('&')[0].toLowerCase();
let OR = {}; try { OR = JSON.parse(fs.readFileSync(path.join(C.dataDir, 'oldrefs.json'), 'utf8')); } catch (e) {}
const net = old && OR[old]; res.writeHead(301, { Location: net ? '/?ref=' + encodeURIComponent(net) : '/', 'Cache-Control': 'no-store' }); return res.end();
}