fix_course_index.php 1.1 KB

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