PageRenderTime 53ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/Zend/replace_recursive.php

https://bitbucket.org/sunil_nextbits/magento2
PHP | 45 lines | 36 code | 9 blank | 0 comment | 7 complexity | e886103ea1f75208cc11780718aa3094 MD5 | raw file
  1. <?php
  2. replace_recursive('.');
  3. function replace_recursive($dir)
  4. {
  5. $files = glob($dir.'/*');
  6. foreach ($files as $file) {
  7. if ($file=='.' || $file=='..') {
  8. continue;
  9. }
  10. if (is_dir($file)) {
  11. replace_recursive($file);
  12. continue;
  13. }
  14. if (substr($file, -4)!=='.php') {
  15. continue;
  16. }
  17. if (false !== strpos($file, 'replace_recursive.php')) {
  18. continue;
  19. }
  20. $orig = file_get_contents($file);
  21. $replaced = preg_replace("/([^#])require_once/", "\$1#require_once", $orig);
  22. if (strpos($file, 'Locale/Math.php')!==false) {
  23. $replaced = str_replace(
  24. "#require_once 'Zend/Locale/Math/PhpMath.php';",
  25. "require_once 'Zend/Locale/Math/PhpMath.php';",
  26. $replaced);
  27. }
  28. if (strcmp($orig, $replaced)===0) {
  29. continue;
  30. }
  31. $fp = fopen($file, 'w');
  32. fwrite($fp, $replaced);
  33. fclose($fp);
  34. echo "Changed '$file'\n";
  35. }
  36. }