diff --git a/accounts.js b/accounts.js index 17aeb5b..633675e 100644 --- a/accounts.js +++ b/accounts.js @@ -36,6 +36,7 @@ const pub = a => a ? { email: a.email, sponsorRef: a.sponsorRef || '', code: a.c username: a.username || null, memberId: a.memberId || 0, joinedVia: a.joinedVia || null, joinedRef: a.joinedRef || null, lineBannerUrl: a.lineBannerUrl || null, lineTargetUrl: a.lineTargetUrl || null, wallOffers: a.wallOffers || null, avatarUrl: a.avatarUrl || null, bio: a.bio || null, socials: a.socials || null, + profileQuarantined: !!a.profileQuarantined, // 2026-10-30: first profile save of a brand-new free account planted a link; stored, never rendered publicly (spamscan.js) chatAvailable: a.chatAvailable === false ? false : true, lastSeen: a.lastSeen || 0, address: a.address || null, created: a.created } : null; const USER_RE = /^[a-zA-Z0-9_]{3,20}$/; @@ -116,12 +117,13 @@ const J = { acct.wallOffers = json || null; this.save(); return { ok: true, account: pub(acct) }; }, - async setProfile(e, avatarUrl, bio, socials) { + async setProfile(e, avatarUrl, bio, socials, quarantined) { const acct = this.db.byEmail[e]; if (!acct) return { error: 'No such account.' }; if (avatarUrl !== undefined) acct.avatarUrl = avatarUrl || null; if (bio !== undefined) acct.bio = bio || null; if (socials !== undefined) acct.socials = socials || null; + if (quarantined !== undefined) acct.profileQuarantined = !!quarantined; this.save(); return { ok: true, account: pub(acct) }; }, @@ -229,7 +231,7 @@ const J = { const rowPub = r => r ? pub({ email: r.email, sponsorRef: r.sponsor_ref, code: r.code, username: r.username, memberId: r.member_id || 0, joinedVia: r.joined_via || null, joinedRef: r.joined_ref || null, lineBannerUrl: r.line_banner_url, lineTargetUrl: r.line_target_url, wallOffers: r.wall_offers || null, - avatarUrl: r.avatar_url, bio: r.bio, socials: r.socials, + avatarUrl: r.avatar_url, bio: r.bio, socials: r.socials, profileQuarantined: !!r.profile_quarantined, chatAvailable: r.chat_available === 0 ? false : true, lastSeen: Number(r.last_seen || 0), address: r.address, created: Number(r.created) }) : null; const D = { @@ -284,10 +286,11 @@ const D = { await db.q('UPDATE accounts SET wall_offers=? WHERE email=?', [json || null, e]); return { ok: true, account: await this.byEmail(e) }; }, - async setProfile(e, avatarUrl, bio, socials) { + async setProfile(e, avatarUrl, bio, socials, quarantined) { if (avatarUrl !== undefined) await db.q('UPDATE accounts SET avatar_url=? WHERE email=?', [avatarUrl || null, e]); if (bio !== undefined) await db.q('UPDATE accounts SET bio=? WHERE email=?', [bio || null, e]); if (socials !== undefined) await db.q('UPDATE accounts SET socials=? WHERE email=?', [socials || null, e]); + if (quarantined !== undefined) await db.q('UPDATE accounts SET profile_quarantined=? WHERE email=?', [quarantined ? 1 : 0, e]); return { ok: true, account: await this.byEmail(e) }; }, async touchSeen(e) { await db.q('UPDATE accounts SET last_seen=? WHERE email=?', [Date.now(), e]); }, @@ -488,7 +491,7 @@ module.exports = { init, signup, login, ensure, onChange, byEmail, byAddress, by setUsername, setMemberId, namesForMembers, listByReferrer, downline, linkWallet, onWalletLinked, count, setLineBanner: (e, b, t) => impl().setLineBanner(String(e || '').toLowerCase(), b, t), setWallOffers: (e, j) => impl().setWallOffers(String(e || '').toLowerCase(), j), - setProfile: (e, a, bio, socials) => impl().setProfile(String(e || '').toLowerCase(), a, bio, socials).then(tap(String(e || '').toLowerCase())), + setProfile: (e, a, bio, socials, quarantined) => impl().setProfile(String(e || '').toLowerCase(), a, bio, socials, quarantined).then(tap(String(e || '').toLowerCase())), touchSeen: e => impl().touchSeen(String(e || '').toLowerCase()), adminSetAddress: (e, a) => impl().adminSetAddress(String(e || '').toLowerCase(), a ? normAddr(a) : null).then(tap(String(e || '').toLowerCase())), positionByAddress: a => impl().positionByAddress(normAddr(a)), diff --git a/ads.js b/ads.js index e2e5e10..5442d08 100644 Binary files a/ads.js and b/ads.js differ diff --git a/chatbot.js b/chatbot.js index 7fbb83b..35f4df7 100644 --- a/chatbot.js +++ b/chatbot.js @@ -25,7 +25,7 @@ let DATA_DIR = null; let chain = null; const MODEL = process.env.OPENROUTER_MODEL || 'deepseek/deepseek-v4-flash:nitro'; const CONTRACT = '0x26Bdc556b94399bEdd69ae3ACA5aA6c54D946e8b'; -const KNOWLEDGE_DATE = '2026-10-28'; // the day the CANNED answers and FACTS below were last checked against the site +const KNOWLEDGE_DATE = '2026-10-30'; // the day the CANNED answers and FACTS below were last checked against the site function init(opts) { if (opts && typeof opts.refuelOn === 'function') REFUEL_ON = opts.refuelOn; DATA_DIR = opts.dataDir; chain = opts.chain; return kb.init({ dataDir: DATA_DIR, seeds: seeds() }); } @@ -45,6 +45,9 @@ const CANNED = [ { id: 'support', title: 'Contact support or open a ticket', q: ['How do I contact support?', 'How do I talk to a real person?', 'How do I open a ticket?'], tags: ['support', 'help', 'ticket', 'contact'], re: SUPPORT_RE, handoff: true, a: 'Open Help in your Control Room (' + SITE_URL + '/help) to send Marty a ticket, and his replies land right there and in your email. Not signed in or locked out? Use ' + SITE_URL + '/support. You can also tap "Send this to support" below and I will pass this chat along.' }, + { id: 'prohibited-content', title: 'What content is not allowed?', q: ['What content is not allowed?', 'Can I put a link in my bio?', 'Can I advertise a casino or CBD?'], tags: ['prohibited content', 'rules', 'bio links', 'gambling', 'adult', 'link farm'], + re: /(not allowed|prohibited|forbidden|banned (content|words|niches?)|content (rules|policy)|what (content|ads|niches?) (is|are) (not )?(allowed|ok|accepted)|can i (post|promote|advertise|run) .*(casino|gambling|betting|adult|porn|cbd|weed|pharma|guns?)|link ?farm|backlinks?|links? in (the |my |your )?bio|bio (link|url)|why was my (bio|profile|link) (refused|rejected|blocked))/i, + a: 'Not allowed anywhere on LinkSpin (ads, campaigns, line banners, wall offers, bios and social links): gambling, casinos, betting, lotteries and sweepstakes; adult or sexual content; drugs and prescription pharmaceuticals; weapons; hate or harassment; malware, phishing and counterfeit goods; misleading financial promises. The bio is text only: no links and no domain names, links go in the social fields in your Control Room profile. Your bio, avatar and social links show on your public wall once you have bought a package; free accounts show only their name and the line\u2019s ads there. Accounts created just to place links in profile fields (link farming) are removed without notice, with their profile text. The full list is in the Terms, section 9: ' + SITE_URL + '/terms#prohibited' }, // Banner Spin (2026-10-20), ahead of the ad-editing and spin-link answers, which also match "banner" and "rotate" { id: 'level4-override', title: 'The Level 4 override (3%)', q: ['What is the Level 4 override?', 'Do I earn from my fourth level?', 'How does the 3% override work?'], tags: ['override', 'level 4', 'fourth level', 'commission', 'payouts'], re: /(level ?(4|four)|4th level|fourth level|override|3 ?%|three percent)/i, @@ -174,6 +177,7 @@ function systemPrompt(kbBlock) { return `You are the assistant on LinkSpin (${SITE_URL}), a link rotator, page builder and advertising network for marketers, a Crypto Team Build Network property. FACTS: +- PROHIBITED CONTENT (2026-10-30, Terms section 9, /terms#prohibited): gambling, casinos, betting, lotteries, sweepstakes; adult or sexual content; drugs and prescription pharmaceuticals; weapons; hate or harassment; malware, phishing, counterfeit goods; misleading financial promises. Refused at save time in bios, social links, line banners, wall offers and every campaign field. A bio may not contain a URL or a domain (links go in the social fields). Profile text, avatar and social links appear on the public wall ONLY for members who have bought a package; a free account's wall shows the name, the line's ads and the join button. Link-farm accounts (created to plant links in profile fields) are removed without notice with their profile text. - LEVEL 4 OVERRIDE (LIVE 2026-10-26, first payout Monday 2026-11-02): company paid, decided off chain, paid on chain. 3% of every LinkSpin package purchase (the POL actually paid) goes to the buyer's 4th upline on the LinkSpin contract sponsor chain if that member's contract buyerCount is 5 or more (qualifying buyer = referral whose first package was $25 or more; same bar as level 3); otherwise it hunts up to the next qualified upline, max 25 hops; company account #1 or nobody qualified = company keeps it; exactly one recipient per purchase. Paid weekly in POL every Monday after 9 AM Central for the previous Monday to Sunday Central week, from a company payer wallet via the contract's award(memberId); shown on the Wallet screen as 'Level 4 override' with a Polygon link. Under 0.01 POL carries to the next week. Purchases from the start date only, no back pay. Funded from the platform's 20%; the contract split is unchanged. Separate from InstantAdPay's override; qualification does not carry between sites. Never promise amounts. ${refuelFact()}${synFact()}- PRODUCT, all free with an email account: SPIN LINKS (the rotator: one short link, /r/, rotates between destinations by weight; pause any destination; a fallback for when all are off; one-hop redirect; every click recorded with day, country, source, device and a daily-salted visitor hash; bots filtered on the server; click ids and sub ids such as clickid, subid, s1 to s4 pass through to the destination; split tests by tagging the same link with different sub ids; a demo spin on the home page needs no account; DAYPARTING is live: a 7x24 hours grid per spin and per destination, time zone by name or the local time of the visitor, presets, and 'my best hours' from the clicks of the member after 200 clicks; automatic HEALTH CHECKS are live: every destination is checked every 30 minutes, a dead or parked one is paused after three failing checks and resumed when it passes twice, the owner is told once, and Check now runs it on demand). PAGES (page builder: scan any offer URL, get a bridge, review or squeeze page; designs, palettes, layouts and niche presets with hero images; leads to the member's own list, CSV or webhook; published on the pages domain lookfirst.page; sales, advertorial and press-release layouts are coming). ZONES (an ad slot on the member's own site: one async script tag, nine sizes 728x90, 468x60, 300x250, 336x280, 250x250, 125x125, 160x600, 120x600, 320x50; waterfall = LinkSpin member campaign, then a network ad for 728x90 and 468x60, then the LinkSpin house banner; pays ad credits per VIEWABLE impression, half the banner on screen for one second, bots never, 50 credited views per visitor per zone per day; rates 1 credit per 5 viewable member-ad views and 1 per 10 network-ad views, 1 per 8 on a Verified zone; warm-up: a zone earns after its first 100 on-site views with at least 40 percent viewable and goes on hold below that; origin lock: paid ads serve only on the declared site and its subdomains, elsewhere the house banner shows and nothing is earned; up to 50 zones per account; PUBLISHER PROGRAM at /publishers for site owners, tiers Standard (default) and Verified (admin-reviewed site, better network rate)). AUDIENCES (first-party retargeting: "My visitors" collects everyone who viewed the member's pages and zones for 30 days; a pixel tag /p.js for other sites; campaigns can "show only to" or "never show to" an audience; nothing personal stored). PROMO TOOLS at /tools#promo (social posts, text-a-friend, email swipes, banners, objection bank, hook videos; five hook angles with videos: links, pages, zones, audiences, stack; angle links are the invite link plus ?v=). REPORTS (every link in one view, plus Pages, Zones, and since 2026-10-12 Traffic sources and Placements). BLOG at /blog with RSS at /blog/feed.xml. TRAFFIC SOURCES at /sources (2026-10-12): a source is a record of a network the member buys traffic on, created from a catalog of networks (PropellerAds, Zeropark, Adsterra, ExoClick, HilltopAds, TrafficStars, PopAds and more, with each network's macro tokens and conversion postback URL; account-specific slots such as a goal id are filled in at creation) or defined by hand; a spin link is pointed at one source (Share kit on the Links screen, or the Sources screen), and then the Share kit's first row is the exact campaign URL for that network with its macros already in place; when a click that came through that source converts (join, lead, wallet, purchase, or a partner-reported conversion; the member picks which) LinkSpin fires that network's own postback with the network's click id and the payout, server to server, and only the network that sent the click is told; Reports show clicks, uniques and conversions by source and by placement (the value the network's zone, placement, site, campaign, creative, banner or keyword macro carried); up to 30 sources per account, 20 params each; a source with no postback still builds the campaign URL and shows in Reports; the account-level Postbacks list on the Links screen (for the member's own tracker) still works alongside. TRAFFIC GUIDE at /traffic-guide (2026-10-28, public, linked from the Sources screen header and each source's detail): pick an offer type (free sign-up or email capture; crypto or team-build opportunity; advertising tools and ad credits; games and play-to-earn; software, apps and AI tools; courses and info products; giveaways and freebies) to see each ad format rated best / good / weak / avoid with a reason, a tip, and the catalog networks that sell the good formats (strict-policy networks Google, Microsoft, Facebook, Taboola, Revcontent, MGID left out for the crypto offer; adult-only TrafficJunky only for games and giveaways); cards for the 8 formats (popunder, push, in-page push, native, search, social, banners, domain redirect: what it is, how you pay, what converts, what struggles, landing page); a table of all 30 catalog networks with the formats each sells, adult-heavy and strict-policy flags and best-for; ground rules (test small, track every click under Sources, one change at a time, block zones that waste money, no income promises, mainstream vs adult inventory). The New source picker shows the same format tags and can be searched by format (push, native...). Never promise results; the guide says Reports are the final word. Knowledge checked on ${KNOWLEDGE_DATE}. - CONVERSION PIXEL (LIVE 2026-10-23, Control Room > Conversions at ${SITE_URL}/conversions; InstantAdPay members see the same goals under Campaigns > Conversion tracking, held on their LinkSpin account): a member names GOALS (subscriber, sale, any word, optional default value, up to 20); each goal has a PUBLIC pixel id (px + 10 characters) that can only count clicks the member owns. EVERY CLICK GETS AN ID: LinkSpin ad clicks (banner, text, zones) and InstantAdPay ad clicks add lsclk= to the target address (other params kept); a spin link reached through an ad passes its own id on and inherits the ad as its source; spin links of a member with a goal add lsclk to the destination too, and so do Banner Spin clicks that go straight to a page (since 2026-10-26; a banner pointed at a spin link gets the spin link's id). SETUP, 3 steps: 1) the LANDING TAG on the landing page, one line , keeps the id on the member's own site 30 days (localStorage + a first-party cookie), fills hidden form fields named lsclk, lsid or clickid and adds the id to links that stay on the same site; 2) the GOAL PIXEL on the thank-you page, an image cv.gif?px=PIXEL_ID&goal=NAME (optional &value=19.95) or the script version cv.js that reads what the tag kept; 3) Send a test conversion (recorded apart, never counted). MATCHING ORDER: the click id in the address, then the id the tag kept, then LinkSpin's own cookie, then a 24-hour match on network + browser (a hash, no IP stored); the method is shown per goal so members see how solid each count is. RULES: each goal counts once per click (an ad click and the spin-link click it led to are one click), only within 30 days of a real click, only for the pixel owner's own clicks, rate limited per pixel and per visitor. OWN CLICKS (2026-10-26): the goal owner's own click on ANY click type (ads, spin links, Banner Spins) is kept as a test and never counted: a click made while signed in as the owner, or a click or conversion from a browser (network + browser soft key) the owner has signed in from on LinkSpin or InstantAdPay; the Conversions screen says 'N from your own clicks, kept as tests and left out'. To test, use Send a test conversion and the &test=1 page check, never a sign-up of your own. REPORTS per goal: conversions and cost per goal (the campaign's credits spent / its conversions, in that site's ad credits) by ad campaign (LinkSpin and InstantAdPay), spin link, Banner Spin (banners straight to a page), destination page and traffic source, plus CSV export. POSTBACKS: a postback or traffic source set to the event 'goal' fires for every goal with {event} = the goal name. AUTORESPONDERS: when Aweber, GetResponse or another provider hosts the thank-you page, set its thank-you (success) redirect to the member's own page that carries the pixel; otherwise the pixel still counts through the cookie or the 24-hour match, less surely. The tag and pixel never break the page if LinkSpin cannot be reached and work inside traffic-exchange frames. SETUP GUIDE (public, 2026-10-24): ${SITE_URL}/conversion-tracking (InstantAdPay's copy: https://instantadpay.com/conversion-tracking): why track, the flow, the 4 steps (goal, landing tag, goal pixel, test), copy-paste examples (plain HTML, WordPress footer plugin + Custom HTML block, page builders, Aweber/GetResponse custom thank-you page), the page check (add &test=1 to the pixel address, open the thank-you page, the last test time updates, then remove it), what to do without code on the thank-you page (image pixel = cookie or 24-hour match; LinkSpin.goal(pixelId, name) from the page's own code for a pop-up form; postbacks), how to read the report and a troubleshooting checklist (same domain for landing and thank-you page, goal pixel only on the thank-you page, the script version is surest, a Banner Spin banner pointed straight at a page now carries its own click id and counts under By Banner Spin; the member's own clicks on ads, spin links and Banner Spins are all kept as tests). Send members there for any setup question. diff --git a/db.js b/db.js index eb9bbe8..eef7355 100644 --- a/db.js +++ b/db.js @@ -90,6 +90,7 @@ async function bootstrap() { await alterSafe('ALTER TABLE accounts ADD COLUMN socials VARCHAR(1200) NULL'); // JSON {platform:url} await alterSafe('ALTER TABLE accounts ADD COLUMN line_banner_url VARCHAR(500) NULL'); await alterSafe('ALTER TABLE accounts ADD COLUMN line_target_url VARCHAR(500) NULL'); + await alterSafe('ALTER TABLE accounts ADD COLUMN profile_quarantined TINYINT NOT NULL DEFAULT 0'); // 2026-10-30 link-farm rule: first profile save of a new free account carried a link (spamscan.js) await q(`CREATE TABLE IF NOT EXISTS daily_views ( email VARCHAR(190) NOT NULL, day CHAR(10) NOT NULL, diff --git a/iapsync.js b/iapsync.js index c343f14..22b029d 100644 --- a/iapsync.js +++ b/iapsync.js @@ -30,6 +30,7 @@ // Until InstantAdPay answers proto 2, the hash of a row carrying the new facts is not recorded (sent again later). 'use strict'; const SF = require('./sponsorfollow'); +const prohibited = require('./prohibited'); // 2026-10-30: a profile that fails the policy never leaves this site const crypto = require('crypto'); const fs = require('fs'); const path = require('path'); @@ -52,10 +53,12 @@ function save() { try { fs.writeFileSync(FILE(), JSON.stringify(load())); } catc function init(deps) { R = deps; load(); } // { dataDir, accounts, registry, host, follow (sponsorfollow store), tank: () => tank } const PUBLIC = () => String(process.env.PUBLIC_URL || ('https://' + (R.host || 'linkspin.app'))).replace(/\/+$/, ''); function profileOf(a) { - let socials = null; try { socials = a.socials ? (typeof a.socials === 'string' ? JSON.parse(a.socials) : a.socials) : null; } catch (e) { socials = null; } + if (a.profileQuarantined) return null; // quarantined (link planted on a brand-new free account): stays here, unseen, until Marty decides + const cp = prohibited.cleanProfile({ avatarUrl: a.avatarUrl, bio: a.bio, socials: a.socials }, 'LinkSpin'); // policy applied on the way out too + const socials = cp.socials; const av = String(a.avatarUrl || '').trim(); const avatarUrl = !av ? null : /^https:\/\//i.test(av) ? av : av.startsWith('/') ? PUBLIC() + av : null; - const bio = String(a.bio || '').trim().slice(0, 600) || null; + const bio = cp.bio; if (!avatarUrl && !bio && !(socials && Object.keys(socials).length)) return null; return { avatarUrl, bio, socials: socials && Object.keys(socials).length ? socials : null }; } diff --git a/kb-seed.js b/kb-seed.js index d6d5418..ddb2169 100644 --- a/kb-seed.js +++ b/kb-seed.js @@ -56,6 +56,10 @@ const FAQ = [ { id: 'f-recovery-phrase', title: 'Recovery phrase and scam safety', source: 'faq', questions: ['Someone asked for my recovery phrase', 'Will support ever ask for my private key?', 'Someone messaged me asking for money'], tags: ['recovery phrase', 'private key', 'scam', 'security'], - answer: 'Never share your recovery phrase (the 12 or 24 words) or private key with anyone: whoever has them has your money. Nobody from LinkSpin will ever ask for them, and the site never sees them. If someone does ask, do not reply, and tell support through Help at ' + SITE_URL + '/help.' } + answer: 'Never share your recovery phrase (the 12 or 24 words) or private key with anyone: whoever has them has your money. Nobody from LinkSpin will ever ask for them, and the site never sees them. If someone does ask, do not reply, and tell support through Help at ' + SITE_URL + '/help.' }, + { id: 'f-prohibited-content', title: 'What content is not allowed?', source: 'faq', + questions: ['What content is not allowed?', 'Can I put a link in my bio?', 'Why was my bio refused?', 'Can I promote a casino or CBD offer?', 'What is link farming?'], + tags: ['prohibited content', 'rules', 'bio', 'links', 'gambling', 'adult', 'link farm', 'terms'], + answer: 'Not allowed anywhere on LinkSpin, in ads, campaigns, line banners, wall offers, bios and social links: gambling, casinos, betting, lotteries and sweepstakes; adult or sexual content; drugs and prescription pharmaceuticals; weapons; hate or harassment; malware, phishing and counterfeit goods; misleading financial promises. The bio is text only, no links and no domain names; links go in the social fields of your profile. Your bio, avatar and social links show on your public wall once you have bought a package; a free account\'s wall shows the name, the line\'s ads and the join button. Accounts created to place links in profile fields (link farming) are removed without notice, with their profile text. Full list: ' + SITE_URL + '/terms#prohibited' }, ]; module.exports = { FAQ }; diff --git a/prohibited.js b/prohibited.js new file mode 100644 index 0000000..804b365 --- /dev/null +++ b/prohibited.js @@ -0,0 +1,108 @@ +// Prohibited-content policy, one module shared by InstantAdPay and LinkSpin (keep the two copies identical). +// 2026-10-30: an SEO backlink farm opened 106 free accounts, each with a casino or local-business bio and a +// website link, and Google indexed that text under our domains through the public walls. Rules (Marty): +// - profile fields are not a free backlink: a bio may not carry a URL or a domain-looking token; +// - gambling, adult, pharma, weapons and link-selling terms are refused in every member-set text field +// (bio, social links, line banner, wall offers, campaign names, headlines, copy and target URLs); +// - case-insensitive and Unicode aware (NFC, lower-cased, letter/number boundaries, so "Essex" never hits "sex"). +// Pure functions, no state, no dependencies. +'use strict'; + +// One entry per term or phrase; spaces match any run of whitespace. Grouped for the Terms page and the admin. +const LIST = { + gambling: ['casino', 'casinos', 'cassino', 'cassinos', 'slots', 'slot gacor', 'betting', 'sportsbook', 'sportsbooks', 'bookmaker', 'bookmakers', 'bookie', + 'lottery', 'lotteries', 'lotto', 'poker', 'baccarat', 'roulette', 'blackjack', 'jackpot', 'togel', 'judi', 'judi online', 'apostas', 'apuestas', + 'nổ hũ', 'cá cược', 'đổi thưởng', 'xổ số', 'kèo', 'nhà cái', 'soi kèo', 'game bài', 'tài xỉu', 'bắn cá'], + adult: ['porn', 'porno', 'pornography', 'sex', 'sexy', 'escort', 'escorts', 'erotic', 'erotica', 'xxx', 'onlyfans', 'nude', 'nudes', 'hentai', 'cam girl', 'cam girls', 'sex cam', 'hookup', 'hookups'], + pharma: ['viagra', 'cialis', 'levitra', 'pharmacy', 'pharmacies', 'prescription', 'prescriptions', 'steroids', 'anabolic', 'cannabis', 'marijuana', 'weed', 'cbd', 'kratom', 'opioid', 'opioids', + 'xanax', 'adderall', 'tramadol', 'oxycodone', 'ketamine', 'cocaine', 'mdma', 'psilocybin', 'vape', 'vaping'], + weapons: ['firearm', 'firearms', 'guns', 'gun shop', 'gun store', 'ammunition', 'ammo', 'rifle', 'rifles', 'pistol', 'pistols', 'handgun', 'handguns', 'silencer', 'suppressor', 'explosives'], + linkfarm: ['backlink', 'backlinks', 'seo service', 'seo services', 'seo agency', 'link building', 'link-building', 'guest post', 'guest posts', 'guest posting', 'pbn', 'buy links', 'sell links', 'dofollow'] +}; +const ALL = Object.values(LIST).reduce((a, b) => a.concat(b), []); + +const esc = s => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); +const ZW = /[​-‏⁠]/g; // zero-width joiners hide nothing +const strip = s => String(s == null ? '' : s).normalize('NFC').replace(ZW, ''); +const norm = s => strip(s).toLowerCase(); +// Boundary = anything that is not a letter or a number (works for every script, unlike \b). +const TERM_RE = new RegExp('(? esc(norm(t)).replace(/\s+/g, '\\s+')).join('|') + ')(?![\\p{L}\\p{N}])', 'u'); + +// Common gTLDs plus the ccTLDs link farms actually use. A short two-letter list keeps "Mr.Li" style text out of it. +const TLDS = 'com|net|org|info|biz|io|co|app|xyz|me|tv|us|uk|vn|de|fr|ru|in|id|br|es|it|nl|ca|au|eu|ch|at|be|pt|pl|cz|se|no|fi|dk|ie|nz|za|ng|ke|eg|tr|ua|il|ae|sa|pk|bd|lk|np|kh|la|mm|my|sg|ph|th|jp|kr|cn|tw|hk|mx|ar|cl|pe|to|ly|cc|gg|ai|pw|ws|tk|ml|ga|cf|gq|su|' + + 'site|online|store|shop|club|top|pro|live|link|page|dev|fun|vip|one|tech|space|website|cloud|digital|agency|company|email|news|blog|life|world|today|zone|guru|ninja|game|games|team|network|money|cash|gold|bid|trade|win|bet|casino|poker|mobi|name|tel|travel|jobs|pics|photo|video|press|media|art|design|studio|capital|finance|exchange|solutions|services|systems|tools|works|center|group|global|international|institute|academy|school|education|university|church|community|social|chat|dating|love|wiki|review|reviews|directory|guide|help|support|rocks|ventures|holdings|partners|limited|ltd|llc|inc|asia|africa|london|nyc|tokyo|berlin|paris|best|buzz|click|host|hosting|lol|monster|wtf|ooo|icu|sbs|cfd|cyou|rest|bar|cam|surf|run|fit|health|care|dog|cat|pet|pets|wine|beer|vodka|bio|eco|green|energy|solar|car|cars|auto|bike|tires|taxi|limo|rent|rentals|house|homes|realty|estate|land|city|town|place|map|earth|fund|loans|credit|insure|legal|law|lawyer|attorney|tax|accountant|consulting|marketing|promo|sale|deals|discount|coupons|gift|gifts|toys|baby|kids|mom|family|wedding|party|events|tickets|show|theater|film|movie|music|band|dance|yoga|golf|football|soccer|hockey|tennis|racing'; +// Schemes and www. are matched in any case; a bare domain token (or an email address) only with its TLD in lower case, so a +// missed space after a period ("ads.One day") is not mistaken for a link while real spam domains (typed lower case) are caught. +const SCHEME_RE = /(?:https?:\/\/|ftp:\/\/|(? 'That content is not allowed on ' + (site || 'InstantAdPay/LinkSpin') + ' profiles (see Terms).'; +const blockedAdMsg = site => 'That content is not allowed on ' + (site || 'InstantAdPay/LinkSpin') + ' (see Terms, Prohibited content).'; + +// Bio rule: no links, no prohibited terms. Returns { ok: true } or { error, reason }. +function checkBio(bio, site) { + const t = String(bio || ''); + if (!t.trim()) return { ok: true }; + if (hasUrl(t)) return { error: BIO_LINK_MSG, reason: 'url' }; + const term = match(t); + if (term) return { error: blockedMsg(site), reason: 'term:' + term }; + return { ok: true }; +} +// Any other member-set text (social URL, banner target, campaign name, headline, copy): prohibited terms only. +// Pass profile: true for profile fields (the message names profiles), else the ad message is used. +function checkText(text, site, opts) { + const term = match(text); + if (!term) return { ok: true }; + return { error: (opts && opts.profile) ? blockedMsg(site) : blockedAdMsg(site), reason: 'term:' + term }; +} +// Several fields at once: { name: value, ... } -> first failure, with the field named in `field`. +function checkFields(fields, site, opts) { + for (const k of Object.keys(fields || {})) { + const v = fields[k]; if (v == null || v === '') continue; + const r = checkText(Array.isArray(v) ? v.join(' ') : String(v), site, opts); + if (r.error) return Object.assign({ field: k }, r); + } + return { ok: true }; +} +// Profile ingest (registry sync from the other property, or a saved profile replayed): the parts of a profile that may be +// stored. A bio with a link or a prohibited term is dropped (null); a social URL carrying a prohibited term is dropped. +function cleanProfile(pf, site) { + const out = { avatarUrl: null, bio: null, socials: null, dropped: [] }; + if (!pf || typeof pf !== 'object') return out; + const av = String(pf.avatarUrl || '').trim(); if (/^https:\/\/[^\s]+$/i.test(av) && av.length <= 300) out.avatarUrl = av; + const bio = String(pf.bio || '').trim().slice(0, 600); + if (bio) { const r = checkBio(bio, site); if (r.ok) out.bio = bio; else out.dropped.push('bio:' + r.reason); } + const src = pf.socials && typeof pf.socials === 'object' ? pf.socials : (typeof pf.socials === 'string' ? safeJson(pf.socials) : null); + if (src) { + const c = {}; + for (const k of Object.keys(src)) { + const v = String(src[k] || '').trim(); if (!v) continue; + const r = checkText(v, site, { profile: true }); if (r.ok) c[k] = v; else out.dropped.push('socials.' + k + ':' + r.reason); + } + if (Object.keys(c).length) out.socials = c; + } + return out; +} +function safeJson(s) { try { const o = JSON.parse(s); return o && typeof o === 'object' ? o : null; } catch (e) { return null; } } +// Terms-page wording, one line per group (kept here so both sites say the same thing). +const POLICY = [ + 'gambling, casinos, betting, lotteries and sweepstakes', + 'adult or sexual content', + 'drugs and prescription pharmaceuticals', + 'weapons', + 'hate or harassment', + 'malware, phishing and counterfeit goods', + 'misleading financial promises', + 'accounts created to place links in profile fields (link farming), which are removed without notice together with their profile text' +]; +// One log line per refusal, with the email masked (never the text itself at full length). +function logRefusal(where, email, r) { + try { console.log('prohibited-content refused', where, String(email || '-').replace(/^(.).*(@.*)$/, '$1***$2'), r && r.field ? 'field=' + r.field : '', r && r.reason ? r.reason : ''); } catch (e) {} +} +module.exports = { LIST, ALL, POLICY, match, hasUrl, checkBio, checkText, checkFields, cleanProfile, logRefusal, BIO_LINK_MSG, blockedMsg, blockedAdMsg }; diff --git a/public/admin.html b/public/admin.html index ca28407..00aeedc 100644 --- a/public/admin.html +++ b/public/admin.html @@ -233,6 +233,12 @@

Sponsor = the token the account joined under (username, share code, or member #). Editing it re-points free referrals and future purchases. On-chain sponsorship is permanent once activated.

+
+

Link-farm list

daily scan at 06:30 Central
+

Free accounts (no package, no wallet) that carry a link plus a farm signal: a prohibited term in the profile, a sign-in that ended within 15 minutes of the sign-up, or no sponsor. Nothing is deleted on its own. Delete uses the normal member delete (on-chain members are refused) and never touches InstantAdPay; the "also on InstantAdPay" column is there so you can decide. Allow keeps an email off this list for good.

+

+
+
- + diff --git a/qa/profile-policy.test.cjs b/qa/profile-policy.test.cjs new file mode 100644 index 0000000..7413361 --- /dev/null +++ b/qa/profile-policy.test.cjs @@ -0,0 +1,231 @@ +// Profile policy + link-farm scan (2026-10-30 incident: 106 free accounts used bios and socials as casino backlinks). +// Same file in both repos (InstantAdPay site/qa and LinkSpin site/qa); it works out which site it is in. +// node qa/profile-policy.test.cjs (also part of `bash qa/run.sh member`) +// Part A, no server: prohibited.js (URL bio refused, casino bio refused, clean bio accepted, Unicode terms, no false hit on +// "Essex"), spamscan.classify on a six-account fixture (3 farm patterns, a sponsored member with a link, a buyer with a +// link, an allowlisted farm), the quarantine rule, the 06:30 once-a-day claim, the Telegram text, and the byte-for-byte +// check of prohibited.js + spamscan.js against the sibling checkout when it is there. +// Part B, a LOCAL copy (throwaway DATA_DIR, JSON store, devCode sign-in, the other site pointed at a dead port): +// a fresh sponsorless account's first save with a link is quarantined (200 + notice) and never rendered; a clean bio saves; +// then a URL bio and a casino bio are refused; a free member's wall and JSON carry nothing from the profile and the fixed +// description; a buyer's JSON carries bio + socials and the wall still has the fixed description; a deleted or unknown name +// is a real 404 with X-Robots-Tag noindex; the line banner refuses a casino target; the admin scan lists the quarantined +// account, Allow removes it; the admin member card shows the flag. Exit code 1 on any failure. +'use strict'; +const fs = require('fs'); +const os = require('os'); +const path = require('path'); +const http = require('http'); +const crypto = require('crypto'); +const { spawn } = require('child_process'); + +const ROOT = path.join(__dirname, '..'); +const isLS = fs.existsSync(path.join(ROOT, 'iapsync.js')); +const SITE = isLS ? 'LinkSpin' : 'InstantAdPay'; +const SIBLING = isLS ? path.join(ROOT, '..', '..', 'onchain-ad-membership', 'site') : path.join(ROOT, '..', '..', 'linkspin', 'site'); +delete process.env.DATABASE_URL; +let fails = 0, n = 0; +async function t(name, fn) { n++; try { await fn(); console.log('ok', name); } catch (e) { fails++; console.log('FAIL', name, '::', e.message); } } +const eq = (a, b, m) => { if (a !== b) throw new Error((m || '') + ' expected ' + JSON.stringify(b) + ' got ' + JSON.stringify(a)); }; +const truthy = (v, m) => { if (!v) throw new Error(m || 'expected truthy'); }; + +const P = require(path.join(ROOT, 'prohibited.js')); +const spamscan = require(path.join(ROOT, 'spamscan.js')); + +(async () => { + // ---------------- Part A ---------------- + await t('bio with a URL is refused with the bio-link message', () => { + for (const b of ['Visit https://casino-vip.com now', 'see www.example.com', 'my site example.com/offers', 'best deals at nice-shop.xyz', 'mail bob@gmail.com']) { + const r = P.checkBio(b, SITE); eq(r.error, 'Links go in the social fields, not the bio.', b); + } + }); + await t('casino bio is refused with the Terms message', () => { + const r = P.checkBio('The best casino bonuses and slots in town', SITE); + eq(r.error, 'That content is not allowed on ' + SITE + ' profiles (see Terms).'); eq(r.reason, 'term:casino'); + eq(P.checkBio('NỔ HŨ ĐỔI THƯỞNG uy tín', SITE).reason, 'term:nổ hũ', 'Vietnamese, upper case'); + eq(P.checkBio('apostas online', SITE).reason, 'term:apostas'); + eq(P.checkBio('we sell backlinks', SITE).reason, 'term:backlinks'); + eq(P.checkBio('ca​sino', SITE).reason, 'term:casino', 'zero-width joiner stripped'); + }); + await t('clean bio is accepted; Essex, Sussex and sloppy punctuation are not links or terms', () => { + for (const b of ['Building a team on Polygon, paid the moment a package clears.', 'Essex marketer, Middlesex born, Sussex raised', 'I love ads.One day I will win', 'Price $9.99 v2.0 Oct.30 no.1', 'e.g. this, i.e. that', '']) + eq(P.checkBio(b, SITE).ok, true, b); + }); + await t('campaign fields and social URLs: prohibited terms only, with the field named', () => { + const r = P.checkFields({ name: 'Spring push', title: 'Free slots tonight', targetUrl: 'https://example.com' }, SITE); + eq(r.field, 'title'); eq(r.error, 'That content is not allowed on ' + SITE + ' (see Terms, Prohibited content).'); + eq(P.checkFields({ website: 'https://my-casino.bet/' }, SITE, { profile: true }).error, 'That content is not allowed on ' + SITE + ' profiles (see Terms).'); + eq(P.checkFields({ name: 'Spring push', targetUrl: 'https://example.com/landing' }, SITE).ok, true); + }); + await t('cleanProfile drops a linked or prohibited bio and a prohibited social, keeps the rest', () => { + const c = P.cleanProfile({ avatarUrl: 'https://img.example.com/a.png', bio: 'see casino.com', socials: { website: 'https://good.example.com/', twitter: 'https://x.com/slots_king' } }, SITE); + eq(c.bio, null); eq(c.avatarUrl, 'https://img.example.com/a.png'); eq(c.socials.website, 'https://good.example.com/'); eq(c.socials.twitter, undefined); + truthy(c.dropped.includes('bio:url') && c.dropped.some(d => d.startsWith('socials.twitter:term')), c.dropped.join(',')); + }); + + // the fixture: who the detector must and must not flag + const DAY = 86400000, now = Date.now(); + const F = [ + { email: 'farm1@x.test', username: 'farm1', memberId: 0, address: null, sponsorRef: 'someone', created: now - 3 * DAY, lastSeen: now - 3 * DAY + 60 * 60000, bio: 'Best casino bonuses', socials: JSON.stringify({ website: 'https://casino-x.com/' }) }, + { email: 'farm2@x.test', username: 'farm2', memberId: 0, address: null, sponsorRef: 'someone', created: now - 2 * DAY, lastSeen: now - 2 * DAY + 4 * 60000, bio: 'Local plumber in Austin', socials: JSON.stringify({ website: 'https://austin-plumber.example/' }) }, + { email: 'farm3@x.test', username: 'farm3', memberId: 0, address: null, sponsorRef: '', created: now - 1 * DAY, lastSeen: now - 1 * DAY + 3 * 60 * 60000, bio: 'Read my blog at huvip-blog.com', socials: null }, + { email: 'real@x.test', username: 'real', memberId: 0, address: null, sponsorRef: 'someone', created: now - 10 * DAY, lastSeen: now - 60000, bio: 'Team builder, here to learn', socials: JSON.stringify({ website: 'https://real-member.example/' }) }, + { email: 'buyer@x.test', username: 'buyer', memberId: 44, address: null, sponsorRef: '', created: now - 5 * DAY, lastSeen: now - 5 * DAY + 60000, bio: 'see my-site.com', socials: JSON.stringify({ website: 'https://my-site.com/' }) }, + { email: 'cryptogoat76@gmail.com', username: 'goat', memberId: 0, address: null, sponsorRef: '', created: now - 1 * DAY, lastSeen: now - 1 * DAY + 60000, bio: 'poker nights', socials: JSON.stringify({ website: 'https://poker.example/' }) }, + ]; + await t('classify: three farm patterns flagged, sponsored member and buyer not, allowlisted skipped', () => { + const allow = new Set(spamscan.DEFAULT_ALLOW); + const v = Object.fromEntries(F.map(a => [a.username, spamscan.classify(a, allow, now)])); + truthy(v.farm1.candidate && v.farm1.reasons[0] === 'prohibited:casino', 'farm1 ' + v.farm1.reasons); + truthy(v.farm2.candidate && v.farm2.reasons.includes('quick'), 'farm2 ' + v.farm2.reasons); + truthy(v.farm3.candidate && v.farm3.reasons.includes('no-sponsor') && v.farm3.links[0] === 'huvip-blog.com', 'farm3 ' + v.farm3.reasons + ' ' + v.farm3.links); + eq(v.real.candidate, false, 'real member with a link'); eq(v.real.reasons.length, 0); + eq(v.buyer.candidate, false, 'buyer with a link'); + eq(v.goat.candidate, false, 'allowlisted'); eq(v.goat.allowlisted, true); + eq(v.farm1.links[0], 'https://casino-x.com/'); + }); + await t('quarantine rule: brand-new, sponsorless, walletless, first save with a link', () => { + const fresh = { memberId: 0, address: null, sponsorRef: '', created: now - 3600000, bio: null, socials: null }; + eq(spamscan.shouldQuarantine(fresh, 'see my-blog.com', null, now), true, 'bio url'); + eq(spamscan.shouldQuarantine(fresh, 'hello', { website: 'https://my-blog.com/' }, now), true, 'website social'); + eq(spamscan.shouldQuarantine(fresh, 'hello', { twitter: 'https://x.com/me' }, now), true, 'X social'); + eq(spamscan.shouldQuarantine(fresh, 'hello', { telegram: 'https://t.me/me' }, now), false, 'telegram is not a farm field'); + eq(spamscan.shouldQuarantine(fresh, 'hello world', null, now), false, 'no link'); + eq(spamscan.shouldQuarantine(Object.assign({}, fresh, { sponsorRef: 'marty' }), 'see my-blog.com', null, now), false, 'has a sponsor'); + eq(spamscan.shouldQuarantine(Object.assign({}, fresh, { created: now - 25 * 3600000 }), 'see my-blog.com', null, now), false, 'older than 24 h'); + eq(spamscan.shouldQuarantine(Object.assign({}, fresh, { bio: 'old bio' }), 'see my-blog.com', null, now), false, 'not the first save'); + eq(spamscan.shouldQuarantine(Object.assign({}, fresh, { address: '0xabc' }), 'see my-blog.com', null, now), false, 'has a wallet'); + eq(spamscan.shouldQuarantine(Object.assign({}, fresh, { memberId: 3 }), 'see my-blog.com', null, now), false, 'bought'); + }); + function bench(o) { + o = o || {}; const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'spamscan-')); + const sent = []; const site = { spamScanAllow: spamscan.DEFAULT_ALLOW.join(', ') }; const claims = o.claims || new Set(); + spamscan.init({ dataDir: dir, site: SITE, siteUrl: 'https://' + SITE.toLowerCase() + '.test', otherSite: isLS ? 'InstantAdPay' : 'LinkSpin', + accounts: { listAll: async () => o.accounts || F }, siteConfig: () => site, saveSite: p => Object.assign(site, p), notify: async text => { sent.push(text); }, + marks: { claim: async k => { if (o.claimFalse) return false; if (claims.has(k)) return false; claims.add(k); return true; } }, alsoOn: async e => e === 'farm1@x.test' ? true : false }); + return { dir, sent, site, claims }; + } + const at = (h, m) => { // a timestamp on today's Central date at h:m Central + const d = new Date(); const ct = new Date(d.toLocaleString('en-US', { timeZone: 'America/Chicago' })); const diff = d.getTime() - ct.getTime(); + ct.setHours(h, m, 0, 0); return ct.getTime() + diff; + }; + await t('tick: nothing before 06:30, one run from 06:30 on, never twice in a day, result file written, one Telegram with the site name', async () => { + const b = bench(); + let r = await spamscan.tick(at(6, 0)); eq(r.skipped, true, 'before 06:30'); eq(b.sent.length, 0); + r = await spamscan.tick(at(6, 31)); truthy(r.candidates, 'ran'); eq(r.candidates.length, 3, 'three candidates'); eq(r.skipped, 1, 'one allowlisted'); + eq(b.sent.length, 1, 'one telegram'); truthy(b.sent[0].startsWith(SITE + ' link-farm scan: 3 candidate accounts ('), b.sent[0].split('\n')[0]); + truthy(b.sent[0].includes('Review in Admin > Members > Link-farm list'), 'review line'); truthy(b.sent[0].includes('@farm1 | joined ') && b.sent[0].includes('| https://casino-x.com/ | also on ' + (isLS ? 'InstantAdPay' : 'LinkSpin')), b.sent[0]); + r = await spamscan.tick(at(9, 0)); eq(r.skipped, true, 'second tick same day'); eq(b.sent.length, 1, 'still one telegram'); + const file = JSON.parse(fs.readFileSync(path.join(b.dir, 'wall-spam-scan.json'), 'utf8')); + eq(file.candidates.length, 3); eq(file.candidates.find(c => c.email === 'farm1@x.test').alsoOn, true); eq(file.scanned, 6); + truthy(b.claims.has('spamscan:' + spamscan.dayOf(at(6, 31))), 'claim key is the Central day'); + }); + await t('tick: a second app copy that loses the claim does not run or notify', async () => { + const b = bench({ claimFalse: true }); + const r = await spamscan.tick(at(7, 0)); eq(r.skipped, true); eq(r.claimedElsewhere, true); eq(b.sent.length, 0); + }); + await t('run: no candidates means no Telegram; Allow removes a candidate on the next run', async () => { + const b = bench({ accounts: F.filter(a => a.username === 'real' || a.username === 'buyer') }); + const r = await spamscan.run(); eq(r.candidates.length, 0); eq(b.sent.length, 0); + const b2 = bench(); await spamscan.run(); eq(spamscan.view().last.candidates.length, 3); + spamscan.setAllow('farm2@x.test', true); truthy(spamscan.allowlist().includes('farm2@x.test')); truthy(b2.site.spamScanAllow.includes('farm2@x.test'), 'saved to the site setting'); + await spamscan.run({ quiet: true }); eq(spamscan.view().last.candidates.length, 2); eq(spamscan.view().last.skipped, 2); + spamscan.setAllow('farm2@x.test', false); eq(spamscan.allowlist().includes('farm2@x.test'), false); + }); + await t('shared modules are byte-for-byte copies of the sibling checkout (prohibited.js, spamscan.js)', () => { + if (!fs.existsSync(SIBLING)) { console.log(' (sibling checkout not found at ' + SIBLING + ', skipped)'); return; } + for (const f of ['prohibited.js', 'spamscan.js', path.join('qa', 'profile-policy.test.cjs')]) { + const h = p => crypto.createHash('sha1').update(fs.readFileSync(p, 'utf8').replace(/\r\n/g, '\n')).digest('hex'); + const a = path.join(ROOT, f), b = path.join(SIBLING, f); + if (!fs.existsSync(b)) throw new Error(f + ' missing in sibling'); + eq(h(a), h(b), f + ' differs from the sibling copy'); + } + }); + + // ---------------- Part B ---------------- + const PORT = Number(process.env.PP_PORT || (isLS ? 8807 : 8806)); const ADMIN = 'localtest'; + const DATA = fs.mkdtempSync(path.join(os.tmpdir(), 'pp-' + SITE.toLowerCase() + '-')); fs.mkdirSync(path.join(DATA, 'uploads'), { recursive: true }); + // a paying member, seeded straight into the JSON store (memberId > 0): profile must render for them + const seed = { v: 2, byEmail: {}, byAddress: {}, byCode: {}, positions: {}, joins: 0 }; + seed.byEmail['buyer@example.com'] = { email: 'buyer@example.com', code: 'buyr01', username: 'buyerwall', memberId: 7, sponsorRef: '', created: now - 30 * DAY, lastSeen: now - DAY, + bio: 'Clean bio from a paying member', socials: JSON.stringify({ website: 'https://example.com/', twitter: 'https://x.com/buyer' }), avatarUrl: 'https://example.com/a.png' }; + seed.byCode.buyr01 = 'buyer@example.com'; + fs.writeFileSync(path.join(DATA, 'accounts.json'), JSON.stringify(seed)); + const env = Object.assign({}, process.env, { PORT: String(PORT), DATA_DIR: DATA, NODE_ENV: 'development', ADMIN_EMAIL: 'qa-admin@example.com', ADMIN_PASSWORD: ADMIN, + LS_URL: 'http://127.0.0.1:1', IAP_URL: 'http://127.0.0.1:1', LS_SYNC_SECRET: '' }); + delete env.DATABASE_URL; + const srv = spawn(process.execPath, ['server.js'], { cwd: ROOT, env, stdio: ['ignore', 'pipe', 'pipe'] }); + let log = ''; srv.stdout.on('data', d => { log += d; }); srv.stderr.on('data', d => { log += d; }); + const req = (method, p, o) => new Promise((resolve, reject) => { o = o || {}; + const headers = Object.assign({ 'User-Agent': 'Mozilla/5.0 QA', 'X-Forwarded-For': o.ip || '10.9.0.1' }, o.headers || {}); if (o.cookie) headers.Cookie = o.cookie; + let body = o.body; if (body) { body = Buffer.from(JSON.stringify(body)); headers['Content-Type'] = 'application/json'; headers['Content-Length'] = body.length; } + const r = http.request({ host: '127.0.0.1', port: PORT, path: p, method, headers }, res => { const ch = []; res.on('data', c => ch.push(c)); res.on('end', () => { const text = Buffer.concat(ch).toString(); let json = null; try { json = JSON.parse(text); } catch (e) {} resolve({ status: res.statusCode, headers: res.headers, text, json }); }); }); + r.on('error', reject); if (body) r.write(body); r.end(); }); + const adminH = { Authorization: 'Bearer ' + ADMIN }; + let ipn = 1; + async function signIn(email) { + const ip = '10.9.' + (ipn++) + '.7'; + const s = await req('POST', '/api/auth/email/start', { ip, body: { email, fts: Date.now() - 8000, fage: 8000, hp_field_x9: '' } }); + if (!s.json || !s.json.devCode) throw new Error('no devCode for ' + email + ': ' + s.text.slice(0, 200)); + const v = await req('POST', '/api/auth/email/verify', { ip, body: { email, code: s.json.devCode } }); + return [].concat(v.headers['set-cookie'] || []).map(x => x.split(';')[0]).join('; '); + } + const meta = (html, name) => { const m = new RegExp(' setTimeout(r, 500)); } } + if (!up) throw new Error('local server did not come up:\n' + log.slice(-1500)); + await req('PATCH', '/api/admin/site', { headers: adminH, body: { fraudMaxSignupsPerIpDay: 20 } }); + const fixed = nm => nm + '’s ad wall on ' + SITE + ': the network’s member ads, paid out on Polygon the moment a package clears.'; + + await t('local: unknown or deleted wall name is a real 404 with X-Robots-Tag noindex', async () => { + const r = await req('GET', '/wall/huvipblog'); eq(r.status, 404); truthy(/noindex/.test(String(r.headers['x-robots-tag'])), 'x-robots-tag ' + r.headers['x-robots-tag']); + truthy(r.text.includes('No wall under that name'), 'body'); eq((await req('GET', '/api/wall/huvipblog')).status, 404); + }); + await t('local: fresh sponsorless account, first save with a link: quarantined, saved, notice, nothing public', async () => { + const ck = await signIn('fresh@example.com'); + eq((await req('POST', '/api/my/profile', { cookie: ck, body: { username: 'freshlink' } })).status, 200); + const r = await req('POST', '/api/my/profile-details', { cookie: ck, body: { bio: 'Read my blog at huvip-blog.com', socials: { website: 'https://huvip-blog.com/' } } }); + eq(r.status, 200, r.text); eq(r.json.quarantined, true); eq(r.json.notice, 'Your profile links will appear after your first ad package.'); eq(r.json.account.profileQuarantined, true); + const w = await req('GET', '/api/wall/freshlink'); eq(w.status, 200); eq(w.json.bought, false); eq(w.json.bio, null); eq(w.json.socials, null); eq(w.json.avatarUrl, null); + const h = await req('GET', '/wall/freshlink'); eq(h.status, 200); eq(meta(h.text, 'description'), fixed('@freshlink')); eq(meta(h.text, 'og:description'), fixed('@freshlink')); + truthy(!h.text.includes('huvip-blog'), 'bio text must not be in the page'); truthy(!/noindex/i.test(h.text) && !r.headers['x-robots-tag'], 'wall stays indexable'); + const m = await req('GET', '/api/admin/member?email=fresh@example.com', { headers: adminH }); eq(m.json.account.profileQuarantined, true, 'admin card flag'); + }); + await t('local: clean bio saves; then a URL bio and a casino bio are refused; a casino social is refused', async () => { + const ck = await signIn('clean@example.com'); + await req('POST', '/api/my/profile', { cookie: ck, body: { username: 'cleanmember' } }); + let r = await req('POST', '/api/my/profile-details', { cookie: ck, body: { bio: 'Team builder on Polygon, paid when a package clears.' } }); eq(r.status, 200, r.text); eq(r.json.quarantined, undefined); + r = await req('POST', '/api/my/profile-details', { cookie: ck, body: { bio: 'Visit https://my-shop.example.com for deals' } }); eq(r.status, 400); eq(r.json.error, 'Links go in the social fields, not the bio.'); + r = await req('POST', '/api/my/profile-details', { cookie: ck, body: { bio: 'Best casino bonuses and slots' } }); eq(r.status, 400); eq(r.json.error, 'That content is not allowed on ' + SITE + ' profiles (see Terms).'); + r = await req('POST', '/api/my/profile-details', { cookie: ck, body: { socials: { website: 'https://top-casino.bet/' } } }); eq(r.status, 400); eq(r.json.error, 'That content is not allowed on ' + SITE + ' profiles (see Terms).'); + const w = await req('GET', '/api/wall/cleanmember'); eq(w.json.bought, false); eq(w.json.bio, null, 'free member: no bio on the public JSON'); + const h = await req('GET', '/wall/cleanmember'); eq(h.status, 200); eq(meta(h.text, 'description'), fixed('@cleanmember')); truthy(!h.text.includes('Team builder on Polygon'), 'free member: no bio in the page'); + r = await req('POST', '/api/my/linebanner', { cookie: ck, body: { targetUrl: 'https://casino-royale.example/' } }); eq(r.status, 400); truthy(/not allowed/.test(r.json.error), r.json.error); + }); + await t('local: a paying member gets bio, socials and avatar in the JSON; the wall keeps the fixed description and title carries the handle', async () => { + const w = await req('GET', '/api/wall/buyerwall'); eq(w.status, 200, w.text); eq(w.json.bought, true); eq(w.json.bio, 'Clean bio from a paying member'); eq(w.json.socials.website, 'https://example.com/'); eq(w.json.avatarUrl, 'https://example.com/a.png'); + const h = await req('GET', '/wall/buyerwall'); eq(h.status, 200); eq(meta(h.text, 'description'), fixed('@buyerwall')); eq(meta(h.text, 'og:image'), 'https://example.com/a.png'); + truthy(/@buyerwall’s ad wall \| /.test(h.text), 'title'); truthy(!h.text.includes('Clean bio from a paying member'), 'bio never in the meta'); + const js = fs.readFileSync(path.join(ROOT, 'public', 'assets', 'wall.js'), 'utf8'); + truthy(js.includes('rel="sponsored ugc noopener"') && !js.includes('rel="noopener nofollow me"'), 'outbound profile links are sponsored ugc'); + truthy(/w\.bought && w\.socials/.test(js) && /\(w\.bought && w\.bio\)/.test(js), 'wall.js renders profile only when bought'); + truthy(fs.readFileSync(path.join(ROOT, 'public', 'wall.html'), 'utf8').includes('wall.js?v=20261030pp'), 'wall.js version bumped'); + }); + await t('local: admin scan lists the quarantined account, not the buyer or the clean member; Allow removes it', async () => { + let r = await req('POST', '/api/admin/spamscan/run', { headers: adminH, body: {} }); eq(r.status, 200, r.text); + const emails = r.json.last.candidates.map(c => c.email); truthy(emails.includes('fresh@example.com'), emails.join(',')); truthy(!emails.includes('buyer@example.com') && !emails.includes('clean@example.com'), emails.join(',')); + const c = r.json.last.candidates.find(x => x.email === 'fresh@example.com'); truthy(c.reasons.includes('quarantined') && c.reasons.includes('no-sponsor'), c.reasons.join(',')); eq(c.firstLink, 'https://huvip-blog.com/'); truthy('alsoOn' in c, 'also-on column present'); + truthy(fs.existsSync(path.join(DATA, 'wall-spam-scan.json')), 'result file'); + r = await req('POST', '/api/admin/spamscan/allow', { headers: adminH, body: { email: 'fresh@example.com' } }); truthy(r.json.allow.includes('fresh@example.com')); + r = await req('POST', '/api/admin/spamscan/run', { headers: adminH, body: {} }); truthy(!r.json.last.candidates.some(x => x.email === 'fresh@example.com'), 'allowed account gone'); + r = await req('POST', '/api/admin/spamscan/allow', { headers: adminH, body: { email: 'fresh@example.com', remove: true } }); truthy(!r.json.allow.includes('fresh@example.com')); + r = await req('DELETE', '/api/admin/member?email=fresh@example.com', { headers: adminH }); eq(r.status, 200, r.text); + eq((await req('GET', '/wall/freshlink')).status, 404, 'deleted wall is a 404'); + eq((await req('DELETE', '/api/admin/member?email=buyer@example.com', { headers: adminH })).status, 400, 'on-chain member refused'); + }); + } catch (e) { fails++; console.log('FAIL local copy ::', e.message); } + finally { try { srv.kill(); } catch (e) {} await new Promise(r => setTimeout(r, 300)); try { fs.rmSync(DATA, { recursive: true, force: true }); } catch (e) {} } + if (fails && /error|Error/.test(log)) console.log('--- server log tail ---\n' + log.slice(-2500)); + console.log(fails ? fails + ' of ' + n + ' checks FAILED' : 'profile policy + link-farm scan: all ' + n + ' checks passed'); + process.exit(fails ? 1 : 0); +})(); diff --git a/qa/run.sh b/qa/run.sh index 62e94f6..830e057 100644 --- a/qa/run.sh +++ b/qa/run.sh @@ -12,6 +12,7 @@ # 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) # bash qa/run.sh loginqueue # prepaid login-slot queue: ads.js unit test (two app copies promoting at once) + HTTP/Ads-screen e2e on a local copy # bash qa/run.sh override # level-4 override: week math, hunt, house, dust carry, cap, balance, two concurrent payers (fake chain + signer, throwaway data) +# bash qa/run.sh policy # profile policy + link-farm scan: prohibited list, bio links, quarantine, 06:30 claim, walls of free/paying members, 404 walls (unit + local copy; also runs in member) # bash qa/run.sh fuel # Fuel Your Offers: refill notices, refuel streak, Refuel Kit, Engine Room (unit + two-copy tests, throwaway data) # Each local run boots server.js on its own port with a throwaway data dir (JSON store, no DB, no # mail key, devCode sign-in), so nothing touches production data. Reports land in qa/out/. @@ -57,6 +58,9 @@ elif [ "$MODE" = "override" ]; then node qa/override.test.cjs || status=1 elif [ "$MODE" = "member" ]; then start_local 8796 && { LOCAL=http://127.0.0.1:8796 node qa/walk.mjs member || status=1; }; stop_local 8796 + node qa/profile-policy.test.cjs || status=1 +elif [ "$MODE" = "policy" ]; then + node qa/profile-policy.test.cjs || status=1 elif [ "$MODE" = "sponsorfollow" ]; then node qa/sponsorfollow.test.cjs || status=1 node qa/carry-hold.test.cjs || status=1 diff --git a/server.js b/server.js index 44d6b2d..7a082de 100644 --- a/server.js +++ b/server.js @@ -67,6 +67,8 @@ const convtrack = require('./convtrack'); // conversion pixel: goals, ad click i const marks = require('./marks'); // one-time claims shared by both app copies during a deploy (event_marks or exclusive files), 2026-10-24 const refill = require('./refill'); const refuel = require('./refuel'); +const prohibited = require('./prohibited'); // prohibited-content policy shared with InstantAdPay (2026-10-30 link-farm incident) +const spamscan = require('./spamscan'); // daily link-farm scan + quarantine rule, byte-for-byte copy of InstantAdPay's const kit = require('./kit'); const engine = require('./engine'); // the Engine Room (same file as InstantAdPay), 2026-10-24 const kitspin = require('./kitspin'); // Refuel Kit -> Banner Spin loader // the Refuel Kit: monthly members-only LinkSpin banner sets, personalized per member (2026-10-24) // Monthly Refuel streak, LinkSpin side: reports $25+ packages to InstantAdPay (the source of truth), applies its grants (2026-10-24) // refill notices: low / out / idle, one message per owner, conversions tracked (2026-10-24) @@ -174,6 +176,14 @@ const faucetHits = new Map(); // address -> last faucet ts (rehearsal test-POL f const visitTokens = persistedMap('visit'); // email -> verified-visit token (dwell + captcha floor) // walk the referral chain upward via sponsorRef (code/username/member id) const polUsdC = { at: 0, v: 0 }; // /api/public/polusd cache (2026-10-22) +// A PAYING member (memberId > 0, or a registered linked position) gets their profile on public pages; a free account gets +// nothing from the profile there (2026-10-30 link-farm incident: 106 free accounts used bios and socials as backlinks). +async function hasBought(a) { + if (!a) return false; if (Number(a.memberId) > 0) return true; + try { return (await accounts.positions(a.email)).some(p => Number(p.memberId) > 0); } catch (e) { return false; } +} +// the wall's meta description is always this sentence, never profile text, so the indexed snippet is ours +const wallDescription = nm => nm + '\u2019s ad wall on LinkSpin: the network\u2019s member ads, paid out on Polygon the moment a package clears.'; async function uplineSlides(email, depth = 3) { const out = []; let cur = await accounts.byEmail(email); @@ -647,6 +657,13 @@ async function boot() { linkFor: async email => { const a = await accounts.byEmail(email); if (!a) return null; const tok = a.username || a.code; return tok ? { username: a.username || null, link: SITE_URL + '/join/' + tok } : null; } }); setTimeout(() => refuel.tick().catch(e => console.error('refuel', e.message)), 75000); setInterval(() => refuel.tick().catch(e => console.error('refuel', e.message)), 60 * 1000); + // link-farm scan (2026-10-30): 06:30 Central, once a day across app copies (marks), Telegram to the private admin chat only when there is something to review + spamscan.init({ dataDir: DATA_DIR, site: 'LinkSpin', siteUrl: SITE_URL, otherSite: 'InstantAdPay', accounts, siteConfig, marks, + saveSite: patch => { const cur = siteConfig(); fs.writeFileSync(SITE_FILE, JSON.stringify(Object.assign(cur, patch), null, 2)); }, + notify: async text => { const sc = siteConfig(); const chat = String(sc.telegramAdminChatId || '1289244227').trim(); if (sc.telegramBotToken) return telegramSend(chat, text); if (ADMIN_EMAIL && mailer.hasKey()) return mailer.send(ADMIN_EMAIL, 'LinkSpin link-farm scan', text); }, + alsoOn: async (email, a) => (a && a.joinedVia === 'instantadpay') ? true : !!(await registry.get(email)) }); // the local registry mirror of InstantAdPay's rows, never a cascade + setTimeout(() => spamscan.tick().catch(e => console.error('spamscan', e.message)), 150000); + setInterval(() => spamscan.tick().catch(e => console.error('spamscan', e.message)), 5 * 60 * 1000); refill.init({ dataDir: DATA_DIR, siteConfig, ads, accounts, chain, mailer, drip, marks, siteUrl: SITE_URL, houseOwner: ads.HOUSE_OWNER, streakLine: email => refuel.streakLine(email), creditsFor: async email => { const v = await adminMember.view(email); return (v && v.credits && v.credits.available) || 0; }, message: async (to, subject, html) => { await messages.deliver(1, ADMIN_EMAIL || 'house@' + SITE_HOST, [to], subject, html, 'notice'); } }); @@ -783,6 +800,7 @@ function siteConfig() { telegramBotToken: '', telegramChatId: '', telegramTopicId: '', telegramEvents: 'payouts', telegramCtaUrl: SITE_URL + '/', telegramEchoChatId: '', telegramEchoTopicId: '', telegramEchoEvents: 'payouts', // shared cross-program payments topic telegramAdminChatId: '', // private chat for admin alerts (sign-up guard bursts); falls back to ADMIN_EMAIL + spamScanAllow: spamscan.DEFAULT_ALLOW.join(', '), // link-farm scan (2026-10-30): emails never listed as candidates; Admin > Members > Link-farm list > Allow adds here launchAt: '', // public launch moment, ISO 8601 with offset (e.g. 2026-09-18T19:00:00-05:00): countdown on /launch + dashboard mark aiCreditsPerGen: 10, aiFreeSurge: 20, aiFreeCircuit: 60, aiFreeNexus: 150, // AI Copy Engine: free generations per month by badge, then credits per generation carryClaimDays: '3', @@ -1644,7 +1662,7 @@ const server = http.createServer(async (req, res) => { const t = nameTok.toLowerCase(); let a = await accounts.byCode(t); if (!a) a = await accounts.byUsername(t); if (!a && /^\d+$/.test(nameTok)) a = await accounts.byMemberId(Number(nameTok)); - if (a) { name = a.username ? '@' + a.username : (a.memberId ? 'member #' + a.memberId : null); avatarUrl = a.avatarUrl || null; own = !!(acct && a.email === acct.email); var bio = null, cobrand = false; try { cobrand = (await ads.milestonesOf(a.email)).includes('level3'); if (cobrand) bio = a.bio ? String(a.bio).slice(0, 220) : null; } catch (e) {} } + if (a) { name = a.username ? '@' + a.username : (a.memberId ? 'member #' + a.memberId : null); avatarUrl = a.avatarUrl || null; own = !!(acct && a.email === acct.email); var bio = null, cobrand = false; try { cobrand = (await ads.milestonesOf(a.email)).includes('level3'); if (cobrand && !a.profileQuarantined && await hasBought(a)) bio = a.bio ? String(a.bio).slice(0, 220) : null; } catch (e) {} } } return json(res, 200, { ref: tok, sponsorId, sponsorBlocked, sponsorRouted, tankHold: intentBuy ? null : tankHold, sponsorName: spd.name || null, invited: !!(tok || showTok), name, avatarUrl, own, bio: typeof bio === 'undefined' ? null : bio, cobrand: typeof cobrand === 'undefined' ? false : cobrand }); } @@ -2193,6 +2211,15 @@ const server = http.createServer(async (req, res) => { } return json(res, 200, await adminMember.view(e)); } + // -- link-farm scan (2026-10-30): last result + allowlist, run now (no Telegram), allow / unallow an email + if (p === '/api/admin/spamscan' && req.method === 'GET') { if (!isAdmin(req)) return json(res, 401, { error: 'auth' }); return json(res, 200, spamscan.view()); } + if (p === '/api/admin/spamscan/run' && req.method === 'POST') { if (!isAdmin(req)) return json(res, 401, { error: 'auth' }); await spamscan.run({ manual: true, quiet: true }); return json(res, 200, spamscan.view()); } + if (p === '/api/admin/spamscan/allow' && req.method === 'POST') { + if (!isAdmin(req)) return json(res, 401, { error: 'auth' }); + const b = await readBody(req); const e = String(b.email || '').trim().toLowerCase(); if (!e) return json(res, 400, { error: 'Which email?' }); + spamscan.setAllow(e, !b.remove); console.log('spamscan allowlist', b.remove ? 'removed' : 'added', e); + return json(res, 200, spamscan.view()); + } if (p === '/api/admin/member' && req.method === 'DELETE') { if (!isAdmin(req)) return json(res, 401, { error: 'auth' }); const e = String(u.searchParams.get('email') || '').trim().toLowerCase(); const acct = e && await accounts.byEmail(e); @@ -2841,8 +2868,10 @@ const server = http.createServer(async (req, res) => { if (r.wallet && !a.address) wallets.push([e, r.wallet]); if (r.profile && typeof r.profile === 'object') { // the InstantAdPay profile fills only what is still empty here; the member can change it on this side any time (Marty 2026-10-11) const pf = r.profile, ok = v => /^https:[/][/][^ ]+$/i.test(v) && v.length <= 300; - const av = String(pf.avatarUrl || '').trim(); const bio = String(pf.bio || '').trim().slice(0, 600); let soc = null; - if (pf.socials && typeof pf.socials === 'object') { const c = {}; for (const k of ['facebook', 'twitter', 'youtube', 'instagram', 'tiktok', 'telegram', 'linkedin', 'website', 'video']) { const v = String(pf.socials[k] || '').trim(); if (ok(v)) c[k] = v; } if (Object.keys(c).length) soc = JSON.stringify(c); } + // prohibited-content policy on ingest (2026-10-30): a bio with a link or a prohibited term, or a social carrying one, is dropped, not stored + const cp = prohibited.cleanProfile(pf, 'LinkSpin'); if (cp.dropped.length) console.log('registry profile dropped', String(e).replace(/^(.).*(@.*)$/, '$1***$2'), cp.dropped.join(',')); + const av = String(pf.avatarUrl || '').trim(); const bio = cp.bio || ''; let soc = null; + if (cp.socials) { const c = {}; for (const k of ['facebook', 'twitter', 'youtube', 'instagram', 'tiktok', 'telegram', 'linkedin', 'website', 'video']) { const v = String(cp.socials[k] || '').trim(); if (ok(v)) c[k] = v; } if (Object.keys(c).length) soc = JSON.stringify(c); } const upd = [!a.avatarUrl && ok(av) ? av : undefined, !a.bio && bio ? bio : undefined, !a.socials && soc ? soc : undefined]; if (upd.some(x => x !== undefined)) { try { await accounts.setProfile(e, upd[0], upd[1], upd[2]); updated++; } catch (err) {} } } @@ -3358,7 +3387,7 @@ const server = http.createServer(async (req, res) => { return json(res, 400, { error: 'Avatar must be an uploaded image or an https image URL.' }); const bio = b.bio === undefined ? undefined : String(b.bio || '').trim().slice(0, 600); // socials: {platform: url}; keep only known platforms with valid https urls - let socials; + let socials, cleanSoc = null; if (b.socials !== undefined) { const PLAT = ['facebook', 'twitter', 'youtube', 'instagram', 'tiktok', 'telegram', 'linkedin', 'website', 'video']; const clean = {}; @@ -3370,8 +3399,17 @@ const server = http.createServer(async (req, res) => { if (clean.video && !/^https:\/\/((www\.|m\.)?youtube\.com\/(watch\?|shorts\/|embed\/)|youtu\.be\/|(www\.)?vimeo\.com\/\d+|player\.vimeo\.com\/video\/\d+|[^\s]+\.(mp4|webm)(\?|$))/i.test(clean.video)) return json(res, 400, { error: 'The intro video needs to be a YouTube link, a Vimeo link, or a direct .mp4 link.' }); socials = Object.keys(clean).length ? JSON.stringify(clean) : null; + cleanSoc = clean; } - const r = await accounts.setProfile(s.email, avatar, bio, socials); + // prohibited-content policy (2026-10-30): gambling, adult, pharma, weapons and link-selling terms are refused in the bio and the social URLs + { const pr = prohibited.checkFields(Object.assign({ bio }, cleanSoc || {}), 'LinkSpin', { profile: true }); if (pr.error) { prohibited.logRefusal('profile-details', s.email, pr); return json(res, 400, { error: pr.error }); } } + // a bio is not a backlink: links go in the social fields. Exception, the quarantine rule: a brand-new free account (no wallet, + // no sponsor, under 24 h) whose first save plants a link is saved with profileQuarantined and never rendered publicly + const acct = await accounts.byEmail(s.email); + const quarantine = spamscan.shouldQuarantine(acct, bio, cleanSoc) ? true : undefined; + if (bio && prohibited.hasUrl(bio) && !quarantine) { prohibited.logRefusal('profile-details', s.email, { field: 'bio', reason: 'url' }); return json(res, 400, { error: prohibited.BIO_LINK_MSG }); } + const r = await accounts.setProfile(s.email, avatar, bio, socials, quarantine); + if (quarantine && !r.error) { console.log('profile quarantined', String(s.email).replace(/^(.).*(@.*)$/, '$1***$2'), prohibited.hasUrl(bio) ? 'bio-url' : 'social-link'); r.quarantined = true; r.notice = spamscan.QUARANTINE_NOTICE; } return json(res, r.error ? 400 : 200, r); } // -- wall positions 2 & 3: the member's own offers, unlocked at 2 / 5 qualifying buyers @@ -3388,6 +3426,7 @@ const server = http.createServer(async (req, res) => { const title = String(o.title || '').trim().slice(0, 60); if (targetUrl && !/^https:\/\/[^\s]+$/i.test(targetUrl)) return json(res, 400, { error: 'Position ' + (i + 2) + ': the link must start with https://' }); if (bannerUrl && !/^(\/uploads\/[a-z0-9]{24}\.(png|jpg|webp|gif)|https:\/\/[^\s]+)$/i.test(bannerUrl)) return json(res, 400, { error: 'Position ' + (i + 2) + ': banner must be an uploaded image or an https image URL.' }); + { const pr = prohibited.checkFields({ title, targetUrl }, 'LinkSpin'); if (pr.error) { prohibited.logRefusal('wall-offers', s.email, pr); return json(res, 400, { error: pr.error }); } } out.push(targetUrl ? { title: title || null, bannerUrl: bannerUrl || null, targetUrl } : null); } const r = await accounts.setWallOffers(s.email, out.some(Boolean) ? JSON.stringify(out) : null); @@ -3400,6 +3439,7 @@ const server = http.createServer(async (req, res) => { const b = await readBody(req); const target = String(b.targetUrl || '').trim(); if (!/^https?:\/\/[^\s]+$/i.test(target)) return json(res, 400, { error: 'Destination URL must start with http(s)://' }); + { const pr = prohibited.checkFields({ targetUrl: target }, 'LinkSpin'); if (pr.error) { prohibited.logRefusal('linebanner', s.email, pr); return json(res, 400, { error: pr.error }); } } const fc = await frameCheck(target); // welcome tours frame it full screen if (!fc.ok) return json(res, 400, { error: fc.reason }); const banner = String(b.bannerUrl || '').trim(); @@ -3465,9 +3505,11 @@ const server = http.createServer(async (req, res) => { badge = { img: '/badges/badge-' + t[0] + '.jpg?v=3', label: t[1] }; } const joinPath = '/join/' + (a.username || a.code); - let socials = null; try { socials = a.socials ? JSON.parse(a.socials) : null; } catch (e) {} - return json(res, 200, { name: a.username ? '@' + a.username : 'member #' + (a.memberId || 0), - avatarUrl: a.avatarUrl || null, bio: a.bio || null, socials, badge, + // profile fields (bio, avatar, socials, intro video) only for a paying member; a free account's wall carries the name, the line's ads and the join call (2026-10-30) + const bought = (await hasBought(a)) && !a.profileQuarantined; + let socials = null; if (bought) { try { socials = a.socials ? JSON.parse(a.socials) : null; } catch (e) {} } + return json(res, 200, { name: a.username ? '@' + a.username : 'member #' + (a.memberId || 0), bought, + avatarUrl: bought ? (a.avatarUrl || null) : null, bio: bought ? (a.bio || null) : null, socials, badge, joinUrl: joinPath, qrUrl: '/api/qr?d=' + encodeURIComponent(SITE_URL + joinPath), ladder: finalLadder, unlocked, buyerCount: bc }); } // -- watch-to-earn video ads: serve one, then reward a server-clock-verified watch @@ -4178,13 +4220,20 @@ const server = http.createServer(async (req, res) => { try { const tok = m[1].toLowerCase(); let a = await accounts.byUsername(tok); if (!a) a = await accounts.byCode(tok); + // a deleted or never-seen name is a real 404, never a bare "Banner wall" page at 200 (a soft 404 Google kept indexed, 2026-10-30) + if (!a) { + const nf = '<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>No wall under that name | LinkSpin

No wall under that name

This member page does not exist or was removed.

Go to LinkSpin

'; + res.writeHead(404, baseHeaders({ 'Content-Type': 'text/html; charset=utf-8', 'Cache-Control': 'no-cache', 'X-Robots-Tag': 'noindex' })); + return res.end(nf); + } let html = fs.readFileSync(path.join(PUBLIC_DIR, 'wall.html'), 'utf8'); if (a) { const nm = a.username ? '@' + a.username : 'member #' + (a.memberId || 0); const esc = t => String(t || '').replace(/[&<>"]/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"' }[c])); - const title = nm + ' on LinkSpin'; - const desc = a.bio ? esc(a.bio).slice(0, 200) : 'Join ' + nm + '’s line on LinkSpin — instant on-chain ad payouts, free to join.'; - const img = a.avatarUrl && /^https:/.test(a.avatarUrl) ? a.avatarUrl : SITE_URL + '/banners/linkspin-og-1200x630.png'; + const bought = (await hasBought(a)) && !a.profileQuarantined; // only a paying member's avatar becomes the share image + const title = nm + '\u2019s ad wall | LinkSpin'; + const desc = esc(wallDescription(nm)); // fixed site sentence, never the bio (indexed snippet stays ours) + const img = bought && a.avatarUrl && /^https:/.test(a.avatarUrl) ? a.avatarUrl : SITE_URL + '/banners/linkspin-og-1200x630.png'; const url = SITE_URL + '/wall/' + (a.username || a.code); const og = [ '', diff --git a/spamscan.js b/spamscan.js new file mode 100644 index 0000000..fe1ce95 --- /dev/null +++ b/spamscan.js @@ -0,0 +1,133 @@ +// Link-farm scan (Marty, 2026-10-30). BYTE-FOR-BYTE COPY in both repos (InstantAdPay site/ and LinkSpin site/): the two +// sites must flag the same accounts by the same rule; qa/profile-policy.test.cjs on each side hashes this file and +// prohibited.js against the sibling checkout when it is present. Edit one, copy to the other, never fork. +// +// Why: an SEO backlink farm opened 106 free accounts with casino and local-business bios plus a website link, and the public +// walls put that text in front of Google. The accounts are gone; this job finds the next batch before the crawler does. +// What: an in-app daily job (checked every few minutes, claimOnce per Central day, runs at 06:30 Central; replaces a server +// cron) lists accounts with memberId 0 and no wallet that carry a link (URL in the bio, or any social set) AND at least +// one farm signal: a prohibited term in the bio or socials, a sign-in that stopped within 15 minutes of the sign-up, or +// no sponsor at all. Emails on the site's spamScanAllow setting are skipped. The result lands in DATA_DIR/wall-spam-scan.json +// and, only when there are candidates, ONE Telegram goes to the private admin chat. The admin pane "Link-farm list" +// (Admin > Members) shows the rows with delete (the existing DELETE /api/admin/member, which refuses on-chain members) and +// allow (adds the email to spamScanAllow). Nothing is deleted automatically, and nothing cascades to the other site. +'use strict'; +const fs = require('fs'); +const path = require('path'); +const P = require('./prohibited'); + +const TZ = 'America/Chicago'; +const dayOf = ts => new Date(ts).toLocaleDateString('en-CA', { timeZone: TZ }); +const minuteOf = ts => { const [h, m] = new Date(ts).toLocaleTimeString('en-GB', { timeZone: TZ, hour: '2-digit', minute: '2-digit', hour12: false }).split(':').map(Number); return h * 60 + m; }; +const RUN_AT = 6 * 60 + 30; // 06:30 Central +const QUICK_MS = 15 * 60 * 1000; +const DEFAULT_ALLOW = ['cryptogoat76@gmail.com', 'csicsokaren@gmail.com', 'osamedefe2026@gmail.com']; +const SOCIAL_KEYS = ['facebook', 'twitter', 'youtube', 'instagram', 'tiktok', 'telegram', 'linkedin', 'website', 'video']; +const LINK_KEYS = ['website', 'twitter', 'youtube']; // the fields a farm comes for (quarantine rule at profile save) + +let X = null, FILE = null, S = null, running = false; +// opts: { dataDir, site, siteUrl, accounts, siteConfig(), saveSite(patch), notify(text) async, marks?, alsoOn?(email) async -> true|false|null, otherSite } +function init(opts) { X = opts; FILE = path.join(opts.dataDir, 'wall-spam-scan.json'); S = load(); } +function load() { try { return JSON.parse(fs.readFileSync(FILE, 'utf8')); } catch (e) { return { day: null, at: 0, candidates: [], scanned: 0, skipped: 0 }; } } +function save() { try { fs.writeFileSync(FILE, JSON.stringify(S, null, 2)); } catch (e) {} } +async function claimOnce(key) { try { return X.marks ? await X.marks.claim(key) : true; } catch (e) { return true; } } +const norm = e => String(e || '').trim().toLowerCase(); + +function parseSocials(v) { if (!v) return null; if (typeof v === 'object') return v; try { const o = JSON.parse(v); return o && typeof o === 'object' ? o : null; } catch (e) { return null; } } +// every link a profile carries, socials first, then URLs picked out of the bio +function linksOf(a) { + const out = []; const soc = parseSocials(a.socials) || {}; + for (const k of SOCIAL_KEYS) { const v = String(soc[k] || '').trim(); if (v) out.push(v); } + const m = String(a.bio || '').match(/https?:\/\/[^\s<>"']+|(?:www\.)?[a-z0-9-]+(?:\.[a-z0-9-]+)*\.[a-z]{2,24}(?:\/[^\s<>"']*)?/gi); + if (m) for (const u of m) if (!out.includes(u)) out.push(u); + return out; +} +// Allowlist: the site setting (array or comma/space separated string) plus the seeded three. +function allowlist() { + const c = (X && X.siteConfig && X.siteConfig()) || {}; + const raw = c.spamScanAllow == null ? DEFAULT_ALLOW : c.spamScanAllow; + const arr = Array.isArray(raw) ? raw : String(raw).split(/[\s,;]+/); + return [...new Set(arr.map(norm).filter(Boolean))]; +} +function setAllow(email, on) { + const list = allowlist(); const e = norm(email); if (!e) return list; + const next = on ? [...new Set(list.concat(e))] : list.filter(x => x !== e); + if (X.saveSite) X.saveSite({ spamScanAllow: next.join(', ') }); + return next; +} + +// The detector. Pure: account in, verdict out. `allow` is a Set of lower-cased emails (defaults to the site allowlist). +function classify(a, allow, now) { + now = now || Date.now(); + const r = { email: a.email, candidate: false, reasons: [], links: [] }; + if (!a || !a.email) return r; + if (Number(a.memberId) > 0) return r; // a buyer is a member, never a candidate + if (a.address) return r; // a wallet means they came to earn, not to plant a link + const bioUrl = P.hasUrl(a.bio); + const soc = parseSocials(a.socials); const socialsPresent = !!(soc && SOCIAL_KEYS.some(k => String(soc[k] || '').trim())); + if (!bioUrl && !socialsPresent && !a.profileQuarantined) return r; + r.links = linksOf(a); + const term = P.match(a.bio) || (soc ? SOCIAL_KEYS.map(k => P.match(soc[k])).find(Boolean) : null); + if (term) r.reasons.push('prohibited:' + term); + const seen = Number(a.lastSeen) || Number(a.created) || now; + if (Number(a.created) && seen - Number(a.created) < QUICK_MS) r.reasons.push('quick'); + if (!a.sponsorRef) r.reasons.push('no-sponsor'); + if (a.profileQuarantined) r.reasons.push('quarantined'); + if (!r.reasons.length) return r; + if ((allow || new Set(allowlist())).has(norm(a.email))) { r.allowlisted = true; return r; } + r.candidate = true; + return r; +} +// Quarantine rule at profile save (Marty): a brand-new account (memberId 0, no wallet, no sponsor, younger than 24 h) +// whose FIRST profile save carries a URL in the bio or a website / X / YouTube social is saved with profileQuarantined. +function shouldQuarantine(acct, bio, socials, now) { + now = now || Date.now(); + if (!acct || Number(acct.memberId) > 0 || acct.address || acct.sponsorRef) return false; + if (!(Number(acct.created) > 0) || now - Number(acct.created) >= 24 * 3600 * 1000) return false; + if (acct.bio || parseSocials(acct.socials)) return false; // not the first save + const soc = parseSocials(socials) || {}; + return P.hasUrl(bio) || LINK_KEYS.some(k => String(soc[k] || '').trim()); +} +const QUARANTINE_NOTICE = 'Your profile links will appear after your first ad package.'; + +// One pass over every account. Writes the result file; sends the Telegram when there is anything to review. +async function run(opts) { + if (running) return S; running = true; + try { + const now = Date.now(); const allow = new Set(allowlist()); + const all = await X.accounts.listAll(50000, { shells: true }); + const names = new Map(); for (const a of all) { if (a.username) names.set(norm(a.username), a); if (a.code) names.set(norm(a.code), a); } + const out = []; let skipped = 0; + for (const a of all) { + const c = classify(a, allow, now); + if (c.allowlisted) { skipped++; continue; } + if (!c.candidate) continue; + const sp = a.sponsorRef ? names.get(norm(a.sponsorRef)) : null; + let alsoOn = null; try { alsoOn = X.alsoOn ? await X.alsoOn(a.email, a) : null; } catch (e) { alsoOn = null; } + out.push({ email: a.email, username: a.username || null, created: Number(a.created) || 0, lastSeen: Number(a.lastSeen) || 0, sponsorRef: a.sponsorRef || '', + sponsorName: sp ? (sp.username ? '@' + sp.username : sp.email) : (a.sponsorRef || null), firstLink: c.links[0] || null, links: c.links.slice(0, 6), reasons: c.reasons, + bio: String(a.bio || '').slice(0, 160), quarantined: !!a.profileQuarantined, alsoOn }); + } + out.sort((x, y) => y.created - x.created); + S = { day: dayOf(now), at: now, candidates: out, scanned: all.length, skipped, manual: !!(opts && opts.manual) }; save(); + if (out.length && !(opts && opts.quiet)) { try { await X.notify(telegramText(out, now)); S.notified = now; save(); } catch (e) { console.error('spamscan notify', e.message); } } + console.log('spamscan', X.site, 'scanned', all.length, 'candidates', out.length, 'allowlisted', skipped); + return S; + } finally { running = false; } +} +function telegramText(out, now) { + const lines = [X.site + ' link-farm scan: ' + out.length + ' candidate account' + (out.length === 1 ? '' : 's') + ' (' + dayOf(now) + ', ' + X.siteUrl.replace(/^https?:\/\//, '') + ')']; + for (const c of out.slice(0, 15)) lines.push((c.username ? '@' + c.username : c.email) + ' | joined ' + dayOf(c.created || now) + ' | sponsor ' + (c.sponsorName || 'none') + ' | ' + (c.firstLink || 'no link') + (c.alsoOn === true ? ' | also on ' + X.otherSite : '')); + if (out.length > 15) lines.push('... and ' + (out.length - 15) + ' more'); + lines.push('Review in Admin > Members > Link-farm list'); + return lines.join('\n'); +} +// checked every few minutes from server.js: once per Central day, from 06:30 on +async function tick(now) { + now = now || Date.now(); const day = dayOf(now); + if (minuteOf(now) < RUN_AT || S.day === day) return { skipped: true }; + if (!await claimOnce('spamscan:' + day)) { S.day = day; save(); return { skipped: true, claimedElsewhere: true }; } + return run(); +} +function view() { return { site: X ? X.site : null, otherSite: X ? X.otherSite : null, last: S, allow: allowlist(), running }; } +module.exports = { init, classify, shouldQuarantine, linksOf, allowlist, setAllow, run, tick, view, telegramText, QUARANTINE_NOTICE, DEFAULT_ALLOW, RUN_AT, QUICK_MS, dayOf, minuteOf };