You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.1 KiB

1 year ago
<?php
use function Hestiacp\quoteshellarg\quoteshellarg;
include $_SERVER["DOCUMENT_ROOT"] . "/inc/main.php";
// Check token
verify_csrf($_GET);
if ($_GET["type"] == "access") {
$type = "access";
}
if ($_GET["type"] == "error") {
$type = "error";
}
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Disposition: attachment; filename=" . $_GET["domain"] . "." . $type . "-log.txt");
header("Content-Type: application/octet-stream; ");
header("Content-Transfer-Encoding: binary");
$v_domain = $_GET["domain"];
if ($_GET["type"] == "access") {
$type = "access";
}
if ($_GET["type"] == "error") {
$type = "error";
}
$cmd = implode(" ", [
"/usr/bin/sudo " . quoteshellarg(HESTIA_DIR_BIN . "v-list-web-domain-" . $type . "log"),
// $user is already shell-escaped
$user,
quoteshellarg($v_domain),
"5000",
]);
passthru($cmd, $return_var);
if ($return_var != 0) {
$errstr = "Internal server error: command returned non-zero: {$return_var}: {$cmd}";
echo $errstr;
throw new Exception($errstr); // make sure it ends up in an errorlog somewhere
}