_checkDomain(); $App->_loadModulesControllers(); if (isset($_GET['refid'])) { $_SESSION['refId'] = $_GET['refid']; } try { // Check if user is already logged $User = new User(); // Define public routes that should be accessible regardless of authentication status // These match the websiteRoutes in assets/js/pannel.js for consistency // Note: '/' (home) is NOT in publicRoutes for logged-in users - they should be redirected to dashboard $publicRoutes = ['/login', '/signup', '/reset', '/terms', '/conditions', '/privacy', '/features', '/pricing']; // Get current path (matching router parsePath logic: remove trailing slash, get path only) $currentPath = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); $currentPath = rtrim($currentPath, '/') ?: '/'; // Logged-in users on home: send to default shell (staking SOLO -> /staking) if ($User->_isLogged() && $currentPath === '/') { header('Location: ' . $App->_defaultLoggedInShellUrl($User)); exit; } $loggedInShellPrefixes = ['/dashboard', '/portfolio', '/market', '/transactionshistory', '/depositverificationhistory', '/balances', '/staking', '/social', '/banktransfert', '/banktransfert-contract']; $onLoggedInShell = false; foreach ($loggedInShellPrefixes as $shellPrefix) { if ($currentPath === $shellPrefix || strpos($currentPath, $shellPrefix . '/') === 0) { $onLoggedInShell = true; break; } } // Authenticated users on non-public, non-shell paths -> HTTP 404 (do not mask bad URLs with redirect) if ($User->_isLogged() && !in_array($currentPath, $publicRoutes, true) && !$onLoggedInShell) { http_response_code(404); header('Cache-Control: no-store, no-cache, must-revalidate'); $Lang = new Lang($User->_getLang()); $notFoundPath = $currentPath; $homeHref = $App->_defaultLoggedInShellUrl($User); $isLoggedIn = true; require dirname(__FILE__) . '/app/views/errors/http404_shell.php'; exit; } // Init lang object $Lang = new Lang(); if (!empty($_GET) && isset($_GET['lng']) && !empty($_GET['lng'])) { $Lang->setLangCookie($_GET['lng']); } if ($App->_enableGooglOauth()) { $GoogleOauth = new GoogleOauth($User); } $App->_checkReferalSource(); } catch (Exception $e) { define('ERROR_SOFTWARE', $e->getMessage()); } $tpl = $App->_getSettingsAttribute('login_page_template'); if (!in_array($tpl, array('tpl-1', 'tpl-2', 'tpl-3', 'tpl-4', 'tpl-5', 'tpl-6'), true)) { $tpl = 'tpl-1'; } $spa_theme_tpl = $tpl; // For SPA bootstrap $tpl_path = "/app/views/login/{$tpl}/"; if (file_exists(dirname(__FILE__) . $tpl_path . 'index.php')) { require dirname(__FILE__) . $tpl_path . 'index.php'; } else { require dirname(__FILE__) . "/app/views/login/index.php"; }