Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $check_extensions = array('php', 'inc');
- $file = null;
- $directory = getcwd();
- $rit = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory), RecursiveIteratorIterator::CHILD_FIRST);
- try
- {
- foreach ($rit as $file)
- {
- if ($file->isFile())
- {
- $path_parts = pathinfo($file->getRealPath());
- if (isset($path_parts['extension']) && in_array($path_parts['extension'],$check_extensions))
- {
- $content = file_get_contents($file->getRealPath());
- if (preg_match("/\?>[\r\n?]{1,}/i", $content, $match)) {
- file_put_contents($file->getRealPath(), trim($content));
- }
- }
- }
- }
- }
- catch (Exception $e)
- {
- die ('Exception caught: '. $e->getMessage());
- }
- exit('done');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement