fix_course_index.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. /**
  3. * This script allows you to update all the paths in the
  4. * courses/[CODE]/index.php files when you change your Chamilo installation
  5. * or create a copy somewhere.
  6. * How to use:
  7. * - Copy into your courses directory
  8. * - Update paths
  9. * - Run from the command line (php5 fix_course_index.php)
  10. * - Check the results in one index.php file
  11. * - Delete this file
  12. */
  13. if (PHP_SAPI != 'cli') {
  14. die('This script can only be launched from the command line');
  15. }
  16. $dir = dirname(__FILE__);
  17. $list = scandir($dir);
  18. // Set the folders from/to (only the part that needs to be replaced)
  19. $originalPath = 'original.path.com';
  20. $destinationPath = 'destination.path.com';
  21. foreach ($list as $entry) {
  22. if (substr($entry, 0, 1) == '.') {
  23. continue;
  24. }
  25. if (!is_dir($dir . '/' . $entry)) {
  26. continue;
  27. }
  28. if (!is_file($dir . '/' . $entry . '/index.php')) {
  29. continue;
  30. }
  31. $file = file_get_contents($dir . '/' . $entry . '/index.php');
  32. $file = preg_replace('/' . $originalPath . '/', $destinationPath, $file);
  33. file_put_contents($dir . '/' . $entry . '/index.php', $file);
  34. //die($entry);
  35. }