Site Builder
Editing:
dashboardok.php
writable 0666
<?php /***************************************************************** * Member Dashboard – modern skin, zero external dependencies *****************************************************************/ require_once __DIR__.'/lib/auth.php'; require_once __DIR__.'/lib/paths.php'; require_once __DIR__.'/lib/db.php'; session_start(); require_login(); /* ---------------------------------------------------------------- 0. Convenience variables ----------------------------------------------------------------- */ $u = current_user(); $slug = $u['site_slug'] ?? ''; // 7276101188 or rfsafe $isBusiness = preg_match('/^\d{10}$/', $slug); $kindWord = $isBusiness ? 'business' : 'influencer'; $profileDir = $isBusiness ? business_path($slug) : social_path($slug); if ($isBusiness && !empty($u['google_name'])) { $welcomeName = $u['google_name']; } else { $welcomeName = $u['username']; } $profileExists = is_file($profileDir.'profile.json'); $linkUrl = null; $code = strtolower($u['username']); if ($u['acct_type'] === 'social') { // social‑profile lives at /social/{user}/profile.json $profileFile = $_SERVER['DOCUMENT_ROOT'] . "/social/{$code}/profile.json"; $minisiteurl = "/social/{$code}/"; $createProfileUrl = "/members/create/add-social.php?user=" . urlencode($code); $boundaryFile = $_SERVER['DOCUMENT_ROOT'] . "/social/{$code}/boundary.json"; } else { // business‑profile lives at /ph/{user}/profile.json $profileFile = $_SERVER['DOCUMENT_ROOT'] . "/ph/{$code}/profile.json"; $minisiteurl = "/ph/{$code}/"; $createProfileUrl = "/members/create/add-business.php?ph=" . urlencode($code); $boundaryFile = $_SERVER['DOCUMENT_ROOT'] . "/ph/{$code}/boundary.json"; } // check existence/readability $boundaryExists = is_readable($boundaryFile); // check existence/readability $profileExists = is_readable($profileFile); /* editable pages */ $stmt = $db->prepare( 'SELECT p.slug, p.file FROM pages p JOIN user_pages up ON up.page_id = p.id WHERE up.user_id = ?' ); $stmt->execute([$u['id']]); $pages = $stmt->fetchAll(PDO::FETCH_ASSOC); /* premium status */ $paidUntil = $u['premium_until'] ?? null; $paid = $paidUntil && strtotime($paidUntil) > time(); /* ---------------------------------------------------------------- 1. Basic guards ----------------------------------------------------------------- */ if ($u['status'] === 'suspended') { exit('Account suspended – contact support.'); } /* ---------------------------------------------------------------- 2. HTML ----------------------------------------------------------------- */ ?><!doctype html> <title>Dashboard – BestDealOn</title> <meta name=viewport content="width=device-width,initial-scale=1"> <head> <style> /* ───── minimalist design language (no CDN) ───── */ *{box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif} body{margin:0;background:#f2f4f7;color:#111;line-height:1.45} a{color:#0066d6;text-decoration:none} a:hover{text-decoration:underline} h1,h2,h3{margin:.4em 0 .3em} .wrapper{max-width:880px;margin:2.4rem auto;padding:0 1.2rem} .card{background:#fff;border-radius:8px;border:1px solid #d8dee7;padding:1.6rem;margin-bottom:1.6rem} .btn{ display:inline-block;border:0;border-radius:4px;padding:.6rem 1rem;font-weight:600; color:#fff;background:#0073e6;font-size:.94rem;cursor:pointer;text-decoration:none } .btn:hover{background:#005fc2} .badge{display:inline-block;padding:.25em .6em;border-radius:4px;font-size:.8rem;color:#fff} .badge-premium{background:#009688} .notice{background:#fffbe6;border:1px solid #fff0c2;border-radius:6px;padding:1rem;margin:1rem 0} ul.page-list{list-style:none;margin:.6rem 0 0;padding:0} ul.page-list li{margin:.25rem 0} @media (min-width:680px){ .grid{display:grid;grid-template-columns:1fr 1fr;gap:1.4rem} } .top{background:#eee;padding:.8em 1.2em;font-weight:900} </style> </head> <body> <div class="top"><a href="/" style="text-decoration:none;color:#2a3ca5">BestDealOn</a> » Dashboard</div> <div class=wrapper> <h1>Welcome, <?=$welcomeName?>!</h1> <!-- ADMIN SHORTCUT --> <?php if ($u['role'] === 'admin'): ?> <p class=notice style="border-left:5px solid #d33"> <strong>Administrator:</strong><br> <a href="/members/admin/users.php">Open user manager →</a><br> <br><a href="/members/admin/subscriptions.php">Open subscriptions manager →</a><br><br> <a href="/pages/modules/modules-admin.php">Modules Admin →</a><br> <a href="/ai-tools/tools-admin.php">AI Tools Admin →</a><br> </p> <?php endif; ?> <!-- PREMIUM BANNER / CTA --> <div class=card> <?php if ($paid): ?> <span class="badge badge-premium">Premium</span> <p style="margin:.8rem 0 0"> Valid until <strong><?= date('M j, Y', strtotime($paidUntil)) ?></strong> (<?= floor((strtotime($paidUntil) - time())/86400) ?> days left) </p> <p><a href="/ai-tools/tools.php">AI Tools →</a></p> <p><a href="/members/subscriptions.php">Manage subscription →</a></p> <p><a href="/members/modules.php">Manage modules →</a></p> <p><a href="/members/backup.php">Backup modules →</a></p> <?php else: ?> <p><strong>You’re on the free plan.</strong></p> <p style="margin-top:.6rem"> <a class=btn style="background:#28a745" href="/members/stripe/checkout.php"> Upgrade to Premium — $100 / year </a> </p> <?php endif; ?> </div> <!-- AFFILIATE SECTION FOR SOCIAL ACCOUNTS --> <?php if ($u['acct_type']==='social'): ?> <div class=card> <!-- New attention‑grabber for free users --> <?php if (empty($paid)): /* only show to free members */ ?> <p style="margin:.8rem 0; font-size:1.05em; font-weight:700; color:#d33;"> 🎉 Refer 1 Premium sign‑up and get your own Premium upgrade free! </p> <?php endif; ?> <h3>Advertising Affiliate</h3> <?php if (!$u['is_affiliate']): ?> <p>You can earn $20 for every Premium sign‑up you refer.</p> <a class=btn href="/members/affiliate/enrol.php"> Become an Advertising Agent </a> <?php else: $code = strtolower($u['username']); $link = SITE_URL.'/members/?ref='.urlencode($code); ?> <p class=notice>Your code: <strong><?= $code ?></strong></p> <p><small>Referral link:</small><br> <input value="<?= $link ?>" readonly style="width:100%;padding:.4rem;border:1px solid #ccc;border-radius:4px" onclick="this.select()"></p> <p><a href="/members/affiliate/portal.php">Affiliate tools →</a></p> <?php endif; ?> </div> <?php endif; ?> <!-- PROFILE STATUS & EDIT LINKS --> <div class="grid"> <div class=card> <h3>Your public site</h3> <p>You are logged in as a <strong><?= $kindWord ?></strong>.<br> Public URL: <code>/<?= htmlspecialchars($slug) ?>/</code></p> <?php if (!$profileExists): ?> <p style="margin-top:1.2rem"> <a class=btn href="/members/create/build-profile.php?kind=<?= $isBusiness?'business':'social' ?>&step=1"> ➕ Add your <?= $kindWord ?> profile </a> </p> <?php else: ?> <p>Your profile is live.</p> <a class=btn href="<?= $minisiteurl ?>"> View Your Full Page Ad </a> <?php endif; ?> </div> <?php // normalize username & decide paths/URLs $code = strtolower($u['username']); if ($u['acct_type'] === 'social') { // social‑profile lives at /social/{user}/profile.json $profileFile = $_SERVER['DOCUMENT_ROOT'] . "/social/{$code}/profile.json"; $createProfileUrl = "/members/create/add-social.php?user=" . urlencode($code); } else { // business‑profile lives at /ph/{user}/profile.json $profileFile = $_SERVER['DOCUMENT_ROOT'] . "/ph/{$code}/profile.json"; $createProfileUrl = "/members/create/add-business.php?ph=" . urlencode($code); } // check existence/readability $profileExists = is_readable($profileFile); ?> <div class="card"> <?php if (!$profileExists): ?> <h3>Let’s get your profile set up</h3> <p>You’ll need to create your main profile page before adding any ad‑related pages.</p> <a href="<?= htmlspecialchars($createProfileUrl, ENT_QUOTES, 'UTF-8') ?>" class="btn"> ➕ Add your <?= $kindWord ?> profile </a> <?php elseif (!$boundaryExists): ?> <h3>Step 2 – Define your boundary</h3> <p>You must set your geofence before you can edit any pages.</p> <a href="/members/create/boundary.php?<?= $u['acct_type']==='social' ? 'user='.urlencode($code) : 'ph='.urlencode($code) ?>" class="btn"> 🗺️ Set Your Boundary </a> <?php else: ?> <h3>Pages you can edit</h3> <?php if ($pages): ?> <ul class="page-list"> <?php foreach ($pages as $p): $href = '/members/' . htmlspecialchars($p['file'], ENT_QUOTES, 'UTF-8') . ($u['acct_type']==='social' ? '?user=' . urlencode($code) : '?ph=' . urlencode($code)); ?> <li>• <a href="<?= $href ?>"> <?= htmlspecialchars($p['slug'], ENT_QUOTES, 'UTF-8') ?> </a></li> <?php endforeach; ?> </ul> <?php else: ?> <p>No editable pages assigned.</p> <?php endif; ?> <?php endif; ?> </div> </div><!-- /.grid --> <p style="margin:2.4rem 0 .6rem"> <a href="/members/logout.php">Log out</a> </p> </div></body><!-- /.wrapper -->
Save changes
Create folder
writable 0777
Create
Cancel