$file) { $excludes[$key] = $src . '/' . $file; } $rec = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($src)); foreach ($rec as $file) { if ($file->isDir()) { $newDir = str_replace('src', 'encrypted', $file->getPath()); if (!is_dir($newDir)) { mkdir($newDir, 0777, true); } continue; } $filePath = $file->getPathname(); // Csak a PHP fájlokat titkosítjuk if (pathinfo($filePath, PATHINFO_EXTENSION) != 'php' || in_array($filePath, $excludes)) { $newFile = str_replace('src', 'encrypted', $filePath); copy($filePath, $newFile); continue; } $contents = file_get_contents($filePath); // 1. Namespace kinyerése $namespace = ''; if (preg_match('/namespace\s+([^;]+);/', $contents, $matches)) { $namespace = $matches[0]; // Kivesszük az eredeti szövegből a névteret $contents = str_replace($namespace, '', $contents); } // 2. PHP címkék eltávolítása a titkosítandó részből $pure_code = str_replace([''], '', $contents); // 3. Titkosítás (csak a tiszta kódot) $cipher = bolt_encrypt($pure_code, $php_blot_key); // 4. Új fájl összeállítása $header = "##!!!##"; $newFile = str_replace('src', 'encrypted', $filePath); $fp = fopen($newFile, 'w'); fwrite($fp, $header . $cipher); fclose($fp); unset($cipher); unset($contents); } echo "Sikeres titkosítás! A zárójelek a helyükön vannak, a névterek pedig kívül.\n";