index.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. use function Hestiacp\quoteshellarg\quoteshellarg;
  3. include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
  4. // Check token
  5. verify_csrf($_GET);
  6. if ($_GET['type'] == 'access') {
  7. $type = 'access';
  8. }
  9. if ($_GET['type'] == 'error') {
  10. $type = 'error';
  11. }
  12. header("Cache-Control: public");
  13. header("Content-Description: File Transfer");
  14. header("Content-Disposition: attachment; filename=".$_GET['domain'].".".$type."-log.txt");
  15. header("Content-Type: application/octet-stream; ");
  16. header("Content-Transfer-Encoding: binary");
  17. $v_domain = $_GET['domain'];
  18. if ($_GET['type'] == 'access') {
  19. $type = 'access';
  20. }
  21. if ($_GET['type'] == 'error') {
  22. $type = 'error';
  23. }
  24. $cmd = implode(" ", array(
  25. '/usr/bin/sudo ' . quoteshellarg(HESTIA_DIR_BIN . "v-list-web-domain-" . $type . "log"),
  26. // $user is already shell-escaped
  27. $user,
  28. quoteshellarg($v_domain),
  29. "5000",
  30. ));
  31. passthru($cmd, $return_var);
  32. if ($return_var != 0) {
  33. $errstr = "Internal server error: command returned non-zero: {$return_var}: {$cmd}";
  34. echo $errstr;
  35. throw new Exception($errstr); // make sure it ends up in an errorlog somewhere
  36. }