setLanguageFile('frontend', 'language.home'); include_once $class_language->setLanguageFile('frontend', 'language.global'); include_once $class_language->setLanguageFile('frontend', 'language.files'); // Get user ID $usr_id = isset($_SESSION['USER_ID']) ? (int) $_SESSION['USER_ID'] : 0; $is_logged_in = $usr_id > 0; // Get configuration $cfg = $class_database->getConfigurations('video_module,short_module,live_module,image_module,audio_module,document_module,blog_module,user_subscriptions,file_history'); // Prepare content sections $sections = []; // 1. Continue Watching (only for logged-in users) if ($is_logged_in && $cfg['file_history'] == 1) { $continue_watching = VRecommendations::getContinueWatching($usr_id, 10); if (!empty($continue_watching)) { $sections['continue_watching'] = [ 'title' => 'Continue Watching', 'items' => $continue_watching, 'type' => 'mixed' ]; } } // 2. For You / Recommended Videos (personalized for logged-in users, trending for guests) if ($cfg['video_module'] == 1) { $for_you = VRecommendations::getForYouFeed(20, 'video'); $sections['for_you'] = [ 'title' => $is_logged_in ? 'Recommended for You' : 'Trending Videos', 'items' => $for_you, 'type' => 'video' ]; } // 3. Subscriptions Feed (only for logged-in users) if ($is_logged_in && $cfg['user_subscriptions'] == 1 && $cfg['video_module'] == 1) { $subscriptions = VRecommendations::getFromSubscriptions($usr_id, 15, 'video'); if (!empty($subscriptions)) { $sections['subscriptions'] = [ 'title' => 'Latest from Subscriptions', 'items' => $subscriptions, 'type' => 'video' ]; } } // 4. Trending Shorts if ($cfg['short_module'] == 1) { $trending_shorts = VRecommendations::getTrending(15, 'short'); $sections['trending_shorts'] = [ 'title' => 'Trending Shorts', 'items' => $trending_shorts, 'type' => 'short' ]; } // 5. Live Streams if ($cfg['live_module'] == 1) { $live_streams = VRecommendations::getTrending(10, 'live'); $sections['live'] = [ 'title' => 'Live Now', 'items' => $live_streams, 'type' => 'live' ]; } // 6. Popular This Week if ($cfg['video_module'] == 1) { $popular_week = VRecommendations::getTrending(20, 'video'); $sections['popular_week'] = [ 'title' => 'Popular This Week', 'items' => $popular_week, 'type' => 'video' ]; } // Assign sections to Smarty $smarty->assign('personalized_sections', $sections); $smarty->assign('is_logged_in', $is_logged_in); $smarty->assign('usr_id', $usr_id); // Display the enhanced homepage echo $class_smarty->displayPage('frontend', 'tpl_index_personalized', null, null); ?>