Siteβ―Builder
Editing:
portal.php
writable 0666
<?php /***************************************************************** * Affiliate selfβservice portal *****************************************************************/ require_once __DIR__.'/../lib/auth.php'; require_once __DIR__.'/../lib/db.php'; require_login(); $me = current_user(); if (!$me['is_affiliate']) { // not enrolled header('Location: enrol.php'); exit; } /* βββββββββββββββββββββ quick facts βββββββββββββββββββββββ */ $code = strtolower($me['username']); // referral slug $link = SITE_URL . '/members/?ref=' . urlencode($code); $bal = number_format($me['affiliate_balance'], 2); /* βββββββββββββββββββββ earning history βββββββββββββββββββ */ $rows = $db->prepare( 'SELECT occurred, event, amount, signup_id FROM affiliate_stats WHERE referral_user = ? ORDER BY occurred DESC' ); $rows->execute([$code]); $stats = $rows->fetchAll(PDO::FETCH_ASSOC); ?> <!doctype html> <title>AffiliateΒ Portal</title> <meta name=viewport content="width=device-width,initial-scale=1"> <style> *{box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif} body{margin:0;background:#fafafa;color:#111;line-height:1.45} article{max-width:820px;margin:3rem auto;padding:0 1rem} h2,h3{margin:1.5rem 0 .6rem} input[readonly]{width:100%;padding:.6rem;border:1px solid #ccc;border-radius:4px;font-size:.95rem} table{width:100%;border-collapse:collapse;margin-top:1rem;font-size:.9rem} th,td{padding:.55rem .6rem;border-bottom:1px solid #e2e2e2;text-align:left} th{background:#0073e6;color:#fff;font-weight:600} tr:nth-child(odd) td{background:#f5f5f5} .balance{font-size:2.1rem;font-weight:700;margin:.3rem 0 1.5rem} </style> <article> <h2>Your referral link</h2> <p><input value="<?= $link ?>" readonly onclick="this.select()"></p> <h3>Balance</h3> <p class=balance>$<?= $bal ?></p> <h3>Earnings</h3> <?php if (!$stats): ?> <p>No commissions yet β start sharing your link!</p> <?php else: ?> <table> <tr><th>Date</th><th>Event</th><th>Amount</th><th>SignupΒ ID</th></tr> <?php foreach ($stats as $r): ?> <tr> <td><?= htmlspecialchars($r['occurred']) ?></td> <td><?= htmlspecialchars(ucfirst($r['event'])) ?></td> <td>$<?= number_format($r['amount'],2) ?></td> <td><?= htmlspecialchars($r['signup_id']) ?></td> </tr> <?php endforeach ?> </table> <?php endif ?> </article>
Save changes
Create folder
writable 0777
Create
Cancel