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 /
.trash /
deployment_package /
Delete
Unzip
Name
Size
Permission
Date
Action
admin
[ DIR ]
drwxr-xr-x
2025-10-18 01:48
assets
[ DIR ]
drwxr-xr-x
2025-10-18 01:48
db
[ DIR ]
drwxr-xr-x
2025-10-18 01:48
includes
[ DIR ]
drwxr-xr-x
2025-10-18 01:48
uploads
[ DIR ]
drwxr-xr-x
2025-10-18 01:48
user
[ DIR ]
drwxr-xr-x
2025-10-18 01:48
DEPLOYMENT_INSTRUCTIONS.md
3.05
KB
-rw-r--r--
2025-10-18 01:48
FIX_DUPLICATE_COMMISSIONS.md
3.63
KB
-rw-r--r--
2025-10-18 00:32
FIX_USER_EDIT_ISSUE.md
6.15
KB
-rw-r--r--
2025-10-18 00:44
IMPROVEMENTS_SUMMARY.md
4.11
KB
-rw-r--r--
2025-10-18 00:40
README.txt
2.34
KB
-rw-r--r--
2025-10-17 23:08
README_DEPLOYMENT.txt
1.74
KB
-rw-r--r--
2025-10-18 01:49
README_REFERRAL_COMMISSIONS.md
4.02
KB
-rw-r--r--
2025-10-18 00:22
SQL_CHANGES_SUMMARY.md
2.02
KB
-rw-r--r--
2025-10-18 00:25
apply_database_fixes.php
5.17
KB
-rw-r--r--
2025-10-18 00:39
check_commission_levels.php
3.16
KB
-rw-r--r--
2025-10-18 00:53
check_database_structure.php
3.9
KB
-rw-r--r--
2025-10-18 00:55
check_duplicate_commissions.php
4.38
KB
-rw-r--r--
2025-10-18 00:32
check_referrals_table.php
2.28
KB
-rw-r--r--
2025-10-18 00:39
complete_setup.sql
5.34
KB
-rw-r--r--
2025-10-18 00:25
complete_setup_for_import.sql
5.36
KB
-rw-r--r--
2025-10-18 01:59
create_table_direct.php
3.44
KB
-rw-r--r--
2025-10-18 00:09
css_test.php
999
B
-rw-r--r--
2025-10-18 02:06
debug_referral_chain.php
6.88
KB
-rw-r--r--
2025-10-18 00:54
fix_duplicate_commissions.php
2.67
KB
-rw-r--r--
2025-10-18 00:31
fix_referral_commissions.sql
677
B
-rw-r--r--
2025-10-18 00:25
fix_referral_commissions_for_import.sql
705
B
-rw-r--r--
2025-10-18 01:59
index.php
25.74
KB
-rw-r--r--
2025-10-18 02:05
index_with_css_fix.php
25.82
KB
-rw-r--r--
2025-10-18 02:06
login.php
4.15
KB
-rw-r--r--
2025-10-18 02:05
logout.php
88
B
-rw-r--r--
2025-10-17 23:02
register.php
6.58
KB
-rw-r--r--
2025-10-18 02:05
run_setup.bat
714
B
-rw-r--r--
2025-10-18 00:23
setup_referral_commissions.php
2.73
KB
-rw-r--r--
2025-10-18 00:21
test.php
59
B
-rw-r--r--
2025-10-17 23:16
test_commission_application.php
6.93
KB
-rw-r--r--
2025-10-18 00:55
test_commission_display.php
3.26
KB
-rw-r--r--
2025-10-18 00:19
test_commission_fix.php
3.16
KB
-rw-r--r--
2025-10-18 00:39
test_mobile_menu.php
2.73
KB
-rw-r--r--
2025-10-18 01:24
test_referral.php
2.07
KB
-rw-r--r--
2025-10-17 23:55
update_referral_commissions.sql
682
B
-rw-r--r--
2025-10-18 00:25
update_referral_commissions_for_import.sql
710
B
-rw-r--r--
2025-10-18 01:59
update_referrals_table.sql
398
B
-rw-r--r--
2025-10-18 00:31
update_referrals_table_for_import.sql
426
B
-rw-r--r--
2025-10-18 01:59
verify_commissions.php
3.28
KB
-rw-r--r--
2025-10-18 00:20
verify_commissions_working.php
8.2
KB
-rw-r--r--
2025-10-18 00:56
Save
Rename
<?php require_once 'includes/db.php'; echo "<h2>Debug Referral Chain</h2>"; // Function to get referrer at a specific level function getReferrerAtLevel($pdo, $user_id, $level) { try { $current_user_id = $user_id; echo "<p>Starting with user ID: " . $current_user_id . "</p>"; // Traverse up the referral chain for ($i = 1; $i <= $level; $i++) { echo "<p>Checking level " . $i . "...</p>"; $stmt = $pdo->prepare("SELECT referred_by FROM users WHERE id = ?"); $stmt->execute([$current_user_id]); $user = $stmt->fetch(); echo "<p>Found user data: " . print_r($user, true) . "</p>"; if (!$user || !$user['referred_by']) { echo "<p>No referrer found at level " . $i . "</p>"; return null; // No referrer at this level } $current_user_id = $user['referred_by']; echo "<p>Moving to referrer ID: " . $current_user_id . "</p>"; } // Get the referrer details $stmt = $pdo->prepare("SELECT id FROM users WHERE id = ?"); $stmt->execute([$current_user_id]); $result = $stmt->fetch(); echo "<p>Final referrer result: " . print_r($result, true) . "</p>"; return $result; } catch (PDOException $e) { echo "<p style='color: red;'>Error: " . $e->getMessage() . "</p>"; return null; } } // Function to calculate and distribute referral commissions function calculateReferralCommissions($pdo, $user_id, $amount, $transaction_id = null) { try { echo "<h3>Calculating commissions for user ID: " . $user_id . ", amount: " . $amount . "</h3>"; // If transaction_id is provided, check if commissions have already been calculated for this transaction if ($transaction_id) { $stmt = $pdo->prepare("SELECT COUNT(*) as count FROM referrals WHERE source_transaction_id = ?"); $stmt->execute([$transaction_id]); if ($stmt->fetch()['count'] > 0) { // Commissions already calculated for this transaction echo "<p>Commissions already calculated for this transaction</p>"; return; } } // Get referral commission levels $stmt = $pdo->prepare("SELECT * FROM referral_commissions ORDER BY level ASC"); $stmt->execute(); $commission_levels = $stmt->fetchAll(); echo "<p>Found " . count($commission_levels) . " commission levels</p>"; // Get user's referrer $stmt = $pdo->prepare("SELECT referred_by FROM users WHERE id = ?"); $stmt->execute([$user_id]); $user = $stmt->fetch(); echo "<p>User data: " . print_r($user, true) . "</p>"; if (!$user || !$user['referred_by']) { echo "<p>No referrer for this user</p>"; return; // No referrer } // Calculate commissions for each level foreach ($commission_levels as $level_data) { $level = $level_data['level']; $percentage = $level_data['commission_percentage']; echo "<p>Processing level " . $level . " with " . $percentage . "% commission</p>"; // Get the referrer at this level $referrer = getReferrerAtLevel($pdo, $user_id, $level); if ($referrer) { $commission_amount = ($amount * $percentage) / 100; echo "<p>Commission amount: " . $commission_amount . " for referrer ID: " . $referrer['id'] . "</p>"; // Add commission to referrer's balance $stmt = $pdo->prepare("UPDATE users SET balance = balance + ? WHERE id = ?"); $stmt->execute([$commission_amount, $referrer['id']]); // Add transaction record $stmt = $pdo->prepare("INSERT INTO transactions (user_id, type, amount, note) VALUES (?, 'commission', ?, ?)"); $stmt->execute([$referrer['id'], $commission_amount, 'Referral commission (Level ' . $level . '): ' . $percentage . '% of ₨' . number_format($amount, 2)]); // Get the transaction ID of the newly inserted commission transaction $commission_transaction_id = $pdo->lastInsertId(); // Add referral record if ($transaction_id) { // If we have a transaction ID, include it in the referral record $stmt = $pdo->prepare("INSERT INTO referrals (user_id, referred_user_id, level, commission_amount, transaction_id, source_transaction_id) VALUES (?, ?, ?, ?, ?, ?)"); $stmt->execute([$referrer['id'], $user_id, $level, $commission_amount, $commission_transaction_id, $transaction_id]); } else { // If we don't have a transaction ID, insert without it $stmt = $pdo->prepare("INSERT INTO referrals (user_id, referred_user_id, level, commission_amount, transaction_id) VALUES (?, ?, ?, ?, ?)"); $stmt->execute([$referrer['id'], $user_id, $level, $commission_amount, $commission_transaction_id]); } echo "<p style='color: green;'>Commission awarded successfully!</p>"; } else { echo "<p>No referrer at level " . $level . "</p>"; } } } catch (PDOException $e) { // Log error but don't stop the process echo "<p style='color: red;'>Referral commission calculation failed: " . $e->getMessage() . "</p>"; error_log('Referral commission calculation failed: ' . $e->getMessage()); } } // Test with a specific user $test_user_id = 2; // Change this to a user ID that has a referrer $test_amount = 1000.00; echo "<p>Testing with user ID: " . $test_user_id . " and amount: " . $test_amount . "</p>"; // Get user details try { $stmt = $pdo->prepare("SELECT * FROM users WHERE id = ?"); $stmt->execute([$test_user_id]); $user = $stmt->fetch(); if ($user) { echo "<h3>User Details:</h3>"; echo "<pre>" . print_r($user, true) . "</pre>"; // Test the commission calculation calculateReferralCommissions($pdo, $test_user_id, $test_amount, 12345); } else { echo "<p>User not found</p>"; } } catch (PDOException $e) { echo "<p style='color: red;'>Error fetching user: " . $e->getMessage() . "</p>"; } echo "<hr>"; echo "<p><a href='admin/referral_commissions.php'>Go to Admin Referral Commissions</a> | "; echo "<a href='user/dashboard.php'>Go to User Dashboard</a></p>"; ?>