Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. <?php
  2.  
  3. $check_extensions = array('php', 'inc');
  4.  
  5. $file = null;
  6. $directory = getcwd();
  7. $rit = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory), RecursiveIteratorIterator::CHILD_FIRST);
  8. try
  9. {
  10. foreach ($rit as $file)
  11. {
  12. if ($file->isFile())
  13. {
  14. $path_parts = pathinfo($file->getRealPath());
  15. if (isset($path_parts['extension']) && in_array($path_parts['extension'],$check_extensions))
  16. {
  17.  
  18. $content = file_get_contents($file->getRealPath());
  19.  
  20. if (preg_match("/\?>[\r\n?]{1,}/i", $content, $match)) {
  21. file_put_contents($file->getRealPath(), trim($content));
  22. }
  23. }
  24. }
  25. }
  26. }
  27. catch (Exception $e)
  28. {
  29. die ('Exception caught: '. $e->getMessage());
  30. }
  31.  
  32. exit('done');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement