// user/controllers/StackController.php require_once __DIR__ . '/../config/database.php'; class StackController { private $db; public function __construct() { $this->db = Database::getConnection(); } // Run daily stacking, ideally called via cron public function runDaily() { $stmt = $this->db->query("SELECT id, balance, current_level FROM users WHERE current_level IS NOT NULL"); $users = $stmt->fetchAll(PDO::FETCH_ASSOC); foreach ($users as $u) { $lvlStmt = $this->db->prepare("SELECT profit_percent FROM level_conditions WHERE level = ?"); $lvlStmt->execute([$u['current_level']]); $percent = $lvlStmt->fetchColumn() / 100; $amount = $u['balance'] * $percent; $ins = $this->db->prepare("INSERT INTO earnings (user_id, amount, type, description) VALUES (?, ?, 'stack', 'Daily stacking')"); $ins->execute([$u['id'], $amount]); $upd = $this->db->prepare("UPDATE users SET balance = balance + ? WHERE id = ?"); $upd->execute([$amount, $u['id']]); } echo "Daily stack process completed."; } } Login ― StoneX

Welcome ✌️

Enter your credentials to login

👁️
Forget Password?

Don’t have an account? Create Account

OR

Dashboard preview