index.php 1.1 KB

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