fill_all.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. $incdir = dirname(__FILE__).'/../../main/inc/';
  15. require $incdir.'global.inc.php';
  16. /**
  17. * Code logic
  18. */
  19. //Avoid execution if not from the command line
  20. 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.'); }
  21. $eol = PHP_EOL;
  22. $output = '';
  23. $files = scandir(dirname(__FILE__));
  24. foreach ($files as $file) {
  25. if (substr($file,0,1) == '.' or substr($file,0,5) != 'fill_') { ; } //skip
  26. else {
  27. if ($file == basename(__FILE__)) {
  28. //skip, this is the current file
  29. } else {
  30. $output .= $eol.'Reading file: '.$file.$eol;
  31. require_once $file;
  32. $function = basename($file,'.php');
  33. if (function_exists($function)) {
  34. $output .= $eol.'Executing function '.$function.$eol;
  35. $function();
  36. } else {
  37. //function not found
  38. }
  39. }
  40. }
  41. }
  42. /**
  43. * Display
  44. */
  45. echo $output.$eol;
  46. echo "Done all$eol";