fill_all.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php //$id$
  2. /**
  3. * This script contains calls to the various filling scripts that allow a
  4. * demo presenter to fill his Dokeos with demo data.
  5. * This script is locked against execution from the browser, to avoid malicious
  6. * insertion on production portals.
  7. * To execute, you need the PHP5 Command Line Interface (CLI) to be installed
  8. * on your system and t launch this script manually using: php5 fill_all.php
  9. * @author Yannick Warnier <yannick.warnier@dokeos.com>
  10. */
  11. /**
  12. * Initialisation section
  13. */
  14. require_once '../../main/inc/global.inc.php';
  15. /**
  16. * Code logic
  17. */
  18. //Avoid execution if not from the command line
  19. if (PHP_SAPI != 'cli') { die('This demo-data filling script can only be run from the command line. Please launch it from the command line using: php5 fill_all.php. To enable it from your browser (very highly dangerous), remove the first line of code from the "logic" section of this file.'); }
  20. $eol = PHP_EOL;
  21. $output = '';
  22. $files = scandir('.');
  23. foreach ($files as $file) {
  24. if (substr($file,0,1) == '.' or substr($file,0,5) != 'fill_') { ; } //skip
  25. else {
  26. if ($file == basename(__FILE__)) {
  27. ; //skip, this is the current file
  28. } else {
  29. $output .= $file.$eol;
  30. require_once $file;
  31. $function = basename($file,'.php');
  32. if (function_exists($function)) {
  33. $output .= 'Executing function '.$function.$eol;
  34. $function();
  35. } else {
  36. //function not found
  37. }
  38. }
  39. }
  40. }
  41. /**
  42. * Display
  43. */
  44. echo $output.$eol;
  45. echo "Done all$eol";