old-remove-require-once.php 748 B

1234567891011121314151617181920212223242526272829303132
  1. #!/usr/bin/php
  2. <?php
  3. chdir(dirname(__FILE__));
  4. require_once 'common.php';
  5. assertCli();
  6. echo "Please do not run this script. It is here for historical purposes only.";
  7. exit;
  8. /**
  9. * @file
  10. * Removes leading includes from files.
  11. *
  12. * @note
  13. * This does not remove inline includes; those must be handled manually.
  14. */
  15. chdir(dirname(__FILE__) . '/../tests/HTMLPurifier');
  16. $FS = new FSTools();
  17. $files = $FS->globr('.', '*.php');
  18. foreach ($files as $file) {
  19. if (substr_count(basename($file), '.') > 1) continue;
  20. $old_code = file_get_contents($file);
  21. $new_code = preg_replace("#^require_once .+[\n\r]*#m", '', $old_code);
  22. if ($old_code !== $new_code) {
  23. file_put_contents($file, $new_code);
  24. }
  25. }
  26. // vim: et sw=4 sts=4