background-image: url('https://images-wixmp-ed30a86b8c4ca887773594c2.wixmp.com/f/b95c85d9-a026-4b38-bbec-3211a37d0d50/dghob8c-12b1170d-8858-4143-870c-0d07c6f6e83c.png/v1/fill/w_1171,h_682,q_70,strp/kali_linux_wallpaper_space_by_khedrmk_dghob8c-pre.jpg?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ1cm46YXBwOjdlMGQxODg5ODIyNjQzNzNhNWYwZDQxNWVhMGQyNmUwIiwiaXNzIjoidXJuOmFwcDo3ZTBkMTg4OTgyMjY0MzczYTVmMGQ0MTVlYTBkMjZlMCIsIm9iaiI6W1t7ImhlaWdodCI6Ijw9NzQ2IiwicGF0aCI6IlwvZlwvYjk1Yzg1ZDktYTAyNi00YjM4LWJiZWMtMzIxMWEzN2QwZDUwXC9kZ2hvYjhjLTEyYjExNzBkLTg4NTgtNDE0My04NzBjLTBkMDdjNmY2ZTgzYy5wbmciLCJ3aWR0aCI6Ijw9MTI4MCJ9XV0sImF1ZCI6WyJ1cm46c2VydmljZTppbWFnZS5vcGVyYXRpb25zIl19.ycet6iuRmOehpCz11r7cybatVL9eh36IRDxB-XIZlFg');
ini_set('display_errors', 0);
error_log("Script started");
ini_set('error_log', 'error.log'); // Replace with an actual path where you have write permissions
error_log("POST data: " . print_r($_POST, true));
error_log("GET data: " . print_r($_GET, true));
// Get the current working directory (no need to hardcode a path)
$root_directory = __DIR__; // This sets the root directory to the current script's directory
$requested_path = isset($_GET['dir']) ? $_GET['dir'] : '';
$full_path = realpath($root_directory . DIRECTORY_SEPARATOR . $requested_path);
// Security check: Make sure the requested path is within the allowed directory
if ($full_path === false || strpos($full_path, $root_directory) !== 0) {
$full_path = $root_directory;
error_log("Root directory: " . $root_directory);
error_log("Requested path: " . $requested_path);
error_log("Full path: " . $full_path);
$action = isset($_POST['action']) ? $_POST['action'] : '';
function sanitize_input($input) {
return htmlspecialchars(strip_tags(trim($input)), ENT_QUOTES, 'UTF-8');
$file = urldecode($_POST['file']);
if (file_exists($file) && is_file($file)) {
echo json_encode(['content' => file_get_contents($file)]);
echo json_encode(['error' => 'File not found or is not a regular file.']);