test.php 837 B

1234567891011121314151617181920212223
  1. <?php
  2. include_once("../../../auth.php");
  3. if (isset($_GET['testpara']) & isset($_GET['source'])){
  4. $testPara = json_decode($_GET['testpara'],true);
  5. $filepath = '../' . $_GET['source'];
  6. if (!file_exists($filepath)){
  7. die("ERROR. source file not found.");
  8. }
  9. $binaryPath = dirname($filepath) . "/" . basename($filepath,pathinfo($filepath, PATHINFO_EXTENSION)) . "out";
  10. if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
  11. $binaryPath = dirname($filepath) . "\\" . basename($filepath,pathinfo($filepath, PATHINFO_EXTENSION)) . "exe";
  12. }
  13. $results = [];
  14. foreach ($testPara as $para){
  15. array_push($results, nl2br(shell_exec($binaryPath . " " . $para)));
  16. }
  17. header('Content-Type: application/json');
  18. echo json_encode($results);
  19. }else{
  20. die("ERROR. Missing parameter.");
  21. }
  22. ?>