function RecursiveFolder($sHOME) { global $BOMBED, $WIN; $win32 = $WIN == 1 ? "\\" : "/"; $folder = dir($sHOME); $foundfolders = array(); while ($file = $folder->read()) { if ($file != "." and $file != "..") { if (filetype($sHOME . $win32 . $file) == "dir") { $foundfolders[count($foundfolders)] = $sHOME . $win32 . $file; } else { $content = file_get_contents($sHOME . $win32 . $file); $BOM = SearchBOM($content); if ($BOM) { $BOMBED[count($BOMBED)] = $sHOME . $win32 . $file; // удаляем первые три символа $content = substr($content, 3); // сохраняем обратно в файл file_put_contents($sHOME . $win32 . $file, $content); } } } } $folder->close(); if (count($foundfolders) > 0) { foreach ($foundfolders as $folder) { RecursiveFolder($folder, $win32); } } }
function RecursiveFolder($sHOME) { global $BOMBED, $WIN; $win32 = $WIN == 1 ? "\\" : "/"; $folder = dir($sHOME); $foundfolders = array(); while ($file = $folder->read()) { if ($file != "." and $file != "..") { if (filetype($sHOME . $win32 . $file) == "dir") { $foundfolders[count($foundfolders)] = $sHOME . $win32 . $file; } else { $content = file_get_contents($sHOME . $win32 . $file); $BOM = SearchBOM($content); if ($BOM) { $BOMBED[count($BOMBED)] = $sHOME . $win32 . $file; // Remove first three chars from the file $content = substr($content, 3); // Write to file file_put_contents($sHOME . $win32 . $file, $content); } } } } $folder->close(); if (count($foundfolders) > 0) { foreach ($foundfolders as $folder) { RecursiveFolder($folder, $win32); } } }
function RecursiveFolder($sHOME) { global $BOMBED, $WIN; $win32 = $WIN == 1 ? "\\" : "/"; $folder = dir($sHOME); $foundfolders = array(); while ($file = $folder->read()) { if ($file != "." and $file != "..") { if (filetype($sHOME . $win32 . $file) == "dir") { $foundfolders[count($foundfolders)] = $sHOME . $win32 . $file; } else { $BOM = SearchBOM(file_get_contents($sHOME . $win32 . $file)); if ($BOM) { $BOMBED[count($BOMBED)] = $sHOME . $win32 . $file; } } } } $folder->close(); if (count($foundfolders) > 0) { foreach ($foundfolders as $folder) { RecursiveFolder($folder, $win32); } } }