🌙 File Manager - @r3dc0d3r1337-WORDPRESS
PHP:
8.1.34
Server:
LiteSpeed
OS:
Linux 5.14.0-611.34.1.el9_7.x86_64
User:
fastear1
Navigate
Upload:
Upload
New File
New Folder
Editing: update_db_v2.php
<?php /** * Database Update Script V2 * Adds Settings for D-Pin & Referrals, and creates tables for Commission Tracking */ require_once 'includes/config.php'; echo "<h2>⚙️ Applying Database V2 Updates...</h2>"; try { // 1. Add New Settings $newSettings = [ 'dpin_price' => '10.00', 'referral_level_1_percent' => '10', 'referral_level_2_percent' => '5', 'referral_level_3_percent' => '3', 'referral_level_4_percent' => '2', 'referral_level_5_percent' => '1' ]; foreach ($newSettings as $key => $val) { // Check if exists $stmt = $pdo->prepare("SELECT id FROM settings WHERE setting_key = ?"); $stmt->execute([$key]); if ($stmt->rowCount() == 0) { $stmt = $pdo->prepare("INSERT INTO settings (setting_key, setting_value) VALUES (?, ?)"); $stmt->execute([$key, $val]); echo "<p style='color:green'>✓ Added setting: $key</p>"; } else { echo "<p style='color:gray'>- Setting $key already exists</p>"; } } // 2. Create Referral Commissions Table $sql = "CREATE TABLE IF NOT EXISTS referral_commissions ( id INT AUTO_INCREMENT PRIMARY KEY, upline_id INT NOT NULL COMMENT 'Receiver of commission', downline_id INT NOT NULL COMMENT 'User who purchased plan', level INT NOT NULL COMMENT 'Referral Level (1-5)', amount DECIMAL(10, 6) NOT NULL, plan_amount DECIMAL(10, 2) NOT NULL, percentage DECIMAL(5, 2) NOT NULL, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY (upline_id) REFERENCES users(id) ON DELETE CASCADE, FOREIGN KEY (downline_id) REFERENCES users(id) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"; $pdo->exec($sql); echo "<p style='color:green'>✓ Checked/Created 'referral_commissions' table</p>"; echo "<h3>✅ Update V2 Complete!</h3>"; echo "<a href='admin/dashboard.php'>Go to Admin Dashboard</a>"; } catch (PDOException $e) { echo "<h3 style='color:red'>❌ Error: " . $e->getMessage() . "</h3>"; } ?>
Save Changes
Cancel
Create New File
Create New Folder