BootstrapController.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. class BootstrapController
  3. {
  4. private $path;
  5. private $path2;
  6. function __construct($path, $path2 = "")
  7. {
  8. $this->path = $path;
  9. $this->path2 = $path2;
  10. }
  11. function bootstrap ($get, $post = array())
  12. {
  13. if (!isset($get['valid']))
  14. {
  15. return "Funktioniert!";
  16. }
  17. if (isset($get['gchr']))
  18. {
  19. if (!isset($post['dsn']) || !isset($post['query']))
  20. {
  21. return "Fehler: fehlende Parameter";
  22. }
  23. require_once(dirname(__FILE__).'/RemoteQueryController.php');
  24. $rqController = new RemoteQueryController();
  25. return $rqController->connectFetchAndConvertToCsv($post['dsn'], $post['query']);
  26. }
  27. else if (isset($get['log']))
  28. {
  29. $logfile = "{$this->path}\\logs\\{$get['log']}";
  30. if (!file_exists($logfile)) return "Fehler: Datei '{$get['log']}' unbekannt";
  31. readfile($logfile);
  32. return "";
  33. }
  34. else if (!isset($get['batch']))
  35. {
  36. $cmd = "{$this->path}\\GCStarter.bat";
  37. }
  38. else
  39. {
  40. $cmd = "{$this->path}\\{$get['batch']}";
  41. if (!file_exists($cmd))
  42. {
  43. $cmd = "{$this->path2}\\{$get['batch']}";
  44. }
  45. if (!file_exists($cmd)) return "Fehler: Datei '{$get['batch']}' unbekannt";
  46. }
  47. $log = substr(sha1($cmd . strtotime("now")), 0, 10) . ".log";
  48. $logfile = "{$this->path}\\logs\\{$log}";
  49. `echo Starte Prozess... > {$logfile}`;
  50. $WshShell = new COM("WScript.Shell");
  51. $cmd = "cmd /C \" call {$cmd} 1> {$logfile} 2>&1 \" ";
  52. $WshShell = $WshShell->Run($cmd, 0, false);
  53. return $log;
  54. }
  55. }
  56. ?>