📁 Folder Navigator
Position:
Root
/
apphome
/
affiliates
Create
Folders
No folders here.
Files
📄 affiliates.xml
📄 index.php
📄 sidebyside.html
📝 File Editor
Editing:
index.php
<?php session_start(); $affFile = 'affiliates.xml'; $apptFile = '../store/appointments.xml'; // --- HANDLE LOGOUT --- if(isset($_GET['logout'])){ session_destroy(); header("Location: " . $_SERVER['PHP_SELF']); exit(); } $msg = ""; $error = ""; // --- HANDLE REGISTRATION OR LOGIN --- if ($_SERVER['REQUEST_METHOD'] === 'POST' && (isset($_POST['register']) || isset($_POST['login']))) { $name_input = htmlspecialchars($_POST['aff_name']); $id = strtolower(preg_replace('/[^a-zA-Z0-9]/', '', $name_input)); $xml = file_exists($affFile) ? simplexml_load_file($affFile) : new SimpleXMLElement('<affiliates></affiliates>'); $exists = false; foreach($xml->partner as $p) { if((string)$p->id == $id) { $exists = true; break; } } if (isset($_POST['register'])) { if(!$exists) { $new = $xml->addChild('partner'); $new->addChild('id', $id); $new->addChild('name', $name_input); $new->addChild('email', htmlspecialchars($_POST['aff_email'])); $new->addChild('address', htmlspecialchars($_POST['aff_address'])); $new->addChild('pay_method', htmlspecialchars($_POST['pay_method'])); $new->addChild('pay_handle', htmlspecialchars($_POST['pay_handle'])); $new->addChild('joined', date('Y-m-d')); $xml->asXML($affFile); $msg = "Account created! Welcome, <strong>$name_input</strong>."; } else { $msg = "Welcome back!"; } $_SESSION['my_aff_id'] = $id; } else { if($exists) { $_SESSION['my_aff_id'] = $id; $msg = "Welcome back!"; } else { $error = "Affiliate ID not found. Please register."; } } } // --- HANDLE WITHDRAW REQUEST --- if (isset($_POST['request_withdraw']) && isset($_SESSION['my_aff_id'])) { $amount = (float)$_POST['amount']; $method = htmlspecialchars($_POST['withdraw_method']); $handle = htmlspecialchars($_POST['withdraw_handle']); if (file_exists($apptFile)) { $apptXml = simplexml_load_file($apptFile); $new = $apptXml->addChild('appointment'); $new->addChild('name', "WITHDRAW REQUEST"); $new->addChild('email', $_SESSION['my_aff_id']); $new->addChild('services', "Affiliate Payout Requested"); $new->addChild('price', number_format($amount, 2, '.', '')); $new->addChild('method', $method); $new->addChild('customer_payment_info', $handle); $new->addChild('date', date('Y-m-d')); $new->addChild('timestamp', date('Y-m-d H:i:s')); $apptXml->asXML($apptFile); $withdraw_success = "Request for $" . number_format($amount, 2) . " sent!"; } } // --- STATS CALCULATION --- $stats = ['sales' => 0, 'earned' => 0]; if (isset($_SESSION['my_aff_id'])) { if (file_exists($apptFile)) { $apptXml = simplexml_load_file($apptFile); foreach ($apptXml->appointment as $appt) { if ((string)$appt->affiliate_id == $_SESSION['my_aff_id']) { $stats['sales']++; $stats['earned'] += (float)$appt->commission; } } } } ?> <!DOCTYPE html> <html> <head> <title>APP HOST REGISTRATION Affiliate Partner Program</title> <style> body { font-family: 'Segoe UI', sans-serif; background: #f1f5f9; padding: 20px; text-align: center; color: #1e293b; } .box { max-width: 550px; margin: auto; background: white; padding: 10px; border-radius: 12px; box-shadow: 0 4px 10px rgba(0,0,0,0.1); text-align: left; } .input { width: 100%; padding: 12px; margin: 8px 0; border: 1px solid #cbd5e1; border-radius: 8px; box-sizing: border-box; } .btn { width: 100%; color: white; border: none; padding: 12px; border-radius: 8px; cursor: pointer; font-weight: bold; margin-top:10px; } .btn-blue { background: #2563eb; } .btn-green { background: #059669; } .stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 20px 0; } .stat { background: #f0fdf4; padding: 15px; border-radius: 8px; border: 1px solid #bbf7d0; text-align: center; } .error { color: #dc2626; background: #fef2f2; padding: 10px; border-radius: 6px; margin-bottom: 15px; text-align: center; } .back-link { display: block; text-align: center; margin-bottom: 20px; color: #64748b; text-decoration: none; font-weight: 600; font-size: 14px; } .back-link:hover { color: #2563eb; } </style> </head> <body> <div class="box"> <!-- Back to Catalog Link --> <h5 style="text-align:center;">🤝 App Host Affiliate Partner Program Registration</h5> <?php if (!isset($_SESSION['my_aff_id'])): ?> <?php if ($error) echo "<div class='error'>$error</div>"; ?> <form method="POST"> <label>Full Name</label><input type="text" name="aff_name" required class="input"> <label>Email</label><input type="email" name="aff_email" class="input"> <label>Mailing Address</label><input type="text" name="aff_address" class="input"> <label>Preferred Payment Method</label> <select name="pay_method" class="input"> <option value="Cash App">Cash App</option> <option value="Venmo">Venmo</option> <option value="PayPal">PayPal</option> <option value="Chime">Chime</option> </select> <label>Payment Handle ($Cashtag / Email)</label><input type="text" name="pay_handle" class="input"> <button type="submit" name="register" class="btn btn-blue">Register New Partner</button> <button type="submit" name="login" class="btn btn-green">Check My Commission</button> </form> <?php else: ?> <p>Hello, <strong><?php echo $_SESSION['my_aff_id']; ?></strong>! <?php echo $msg; ?></p> <div style="background: #f8fafc; padding: 15px; border: 1px dashed #2563eb; margin-top: 10px;"> <strong>Referral Link:</strong><br> <code style="word-break:break-all;">n4sappme.com/apphome/store/catalog.php?ref=<?php echo $_SESSION['my_aff_id']; ?></code> </div> <div class="stat-grid"> <div class="stat"><small>Sales</small><br><strong style="font-size:1.5rem;"><?php echo $stats['sales']; ?></strong></div> <div class="stat"><small>Earned</small><br><strong style="color: #15803d; font-size:1.5rem;">$<?php echo number_format($stats['earned'], 2); ?></strong></div> </div> <form method="POST" style="background:#f1f5f9; padding:20px; border-radius:10px;"> <h3 style="margin-top:0;">Request Payout</h3> <?php if(isset($withdraw_success)) echo "<p style='color:green;'>$withdraw_success</p>"; ?> <label>Amount ($)</label> <input type="number" name="amount" step="0.01" max="<?php echo $stats['earned']; ?>" class="input" placeholder="0.00" required> <label>Send To:</label> <select name="withdraw_method" class="input"> <option value="Cash App">Cash App</option> <option value="Venmo">Venmo</option> <option value="PayPal">PayPal</option> <option value="Chime">Chime</option> <option value="Bank Transfer">Bank Transfer</option> </select> <input type="text" name="withdraw_handle" placeholder="Payment Handle / Account" required class="input"> <button type="submit" name="request_withdraw" class="btn btn-green">Submit Request</button> </form> <div style="text-align:center; margin-top:20px; display: flex; justify-content: space-between;"> <a href="?logout=1" style="color:#ef4444; font-weight:bold; text-decoration:none; font-size:13px;">Logout / Exit</a> </div> <?php endif; ?> </div> </body> </html>
💾 Save Changes