fill_all.php 1.6 KB

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